gemini-cli-leo 0.1.30-pre.3 → 0.1.30
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/docs/openai-provider-env-shadowing.md +502 -0
- package/docs/sidebar.json +4 -0
- package/gemini.mjs +423 -203
- package/package.json +1 -1
package/gemini.mjs
CHANGED
|
@@ -174783,8 +174783,8 @@ var GIT_COMMIT_INFO, CLI_VERSION;
|
|
|
174783
174783
|
var init_git_commit = __esm({
|
|
174784
174784
|
"packages/core/dist/src/generated/git-commit.js"() {
|
|
174785
174785
|
"use strict";
|
|
174786
|
-
GIT_COMMIT_INFO = "
|
|
174787
|
-
CLI_VERSION = "0.1.30
|
|
174786
|
+
GIT_COMMIT_INFO = "8f1203e";
|
|
174787
|
+
CLI_VERSION = "0.1.30";
|
|
174788
174788
|
}
|
|
174789
174789
|
});
|
|
174790
174790
|
|
|
@@ -318256,7 +318256,7 @@ function getVersion() {
|
|
|
318256
318256
|
}
|
|
318257
318257
|
versionPromise = (async () => {
|
|
318258
318258
|
const pkgJson = await getPackageJson(__dirname4);
|
|
318259
|
-
return "0.1.30
|
|
318259
|
+
return "0.1.30";
|
|
318260
318260
|
})();
|
|
318261
318261
|
return versionPromise;
|
|
318262
318262
|
}
|
|
@@ -320154,9 +320154,12 @@ var init_baseLlmClient = __esm({
|
|
|
320154
320154
|
}
|
|
320155
320155
|
async _generateWithRetry(options, shouldRetryOnContent, errorContext, role = LlmRole.UTILITY_TOOL) {
|
|
320156
320156
|
const { modelConfigKey, contents, systemInstruction, abortSignal, promptId, maxAttempts, additionalProperties } = options;
|
|
320157
|
+
const requestRole = role;
|
|
320158
|
+
const requestPromptId = promptId;
|
|
320157
320159
|
const { model, config: generateContentConfig, maxAttempts: availabilityMaxAttempts } = applyModelSelection(this.config, modelConfigKey);
|
|
320158
320160
|
let currentModel = model;
|
|
320159
320161
|
let currentGenerateContentConfig = generateContentConfig;
|
|
320162
|
+
let currentAvailabilityMaxAttempts = availabilityMaxAttempts;
|
|
320160
320163
|
const getAvailabilityContext = createAvailabilityContextProvider(this.config, () => currentModel);
|
|
320161
320164
|
let initialActiveModel = this.config.getActiveModel();
|
|
320162
320165
|
let isFirstAttempt = true;
|
|
@@ -320173,12 +320176,14 @@ var init_baseLlmClient = __esm({
|
|
|
320173
320176
|
});
|
|
320174
320177
|
currentModel = resolvedModel;
|
|
320175
320178
|
currentGenerateContentConfig = generateContentConfig2;
|
|
320179
|
+
currentAvailabilityMaxAttempts = void 0;
|
|
320176
320180
|
} else if (!firstAttempt && (this.config.getModelAvailabilityService?.()?.snapshot(currentModel)?.available ?? true) === false) {
|
|
320177
|
-
const { model: reselectedModel, config: reselectedConfig } = applyModelSelection(this.config, modelConfigKey);
|
|
320181
|
+
const { model: reselectedModel, config: reselectedConfig, maxAttempts: reselectedMaxAttempts } = applyModelSelection(this.config, modelConfigKey);
|
|
320178
320182
|
currentModel = reselectedModel;
|
|
320179
320183
|
if (reselectedConfig) {
|
|
320180
320184
|
currentGenerateContentConfig = reselectedConfig;
|
|
320181
320185
|
}
|
|
320186
|
+
currentAvailabilityMaxAttempts = reselectedMaxAttempts;
|
|
320182
320187
|
initialActiveModel = this.config.getActiveModel();
|
|
320183
320188
|
}
|
|
320184
320189
|
const finalConfig = {
|
|
@@ -320192,7 +320197,7 @@ var init_baseLlmClient = __esm({
|
|
|
320192
320197
|
config: finalConfig,
|
|
320193
320198
|
contents
|
|
320194
320199
|
};
|
|
320195
|
-
return this.contentGenerator.generateContent(requestParams,
|
|
320200
|
+
return this.contentGenerator.generateContent(requestParams, requestPromptId, requestRole);
|
|
320196
320201
|
};
|
|
320197
320202
|
return await retryWithBackoff(apiCall, {
|
|
320198
320203
|
shouldRetryOnContent,
|
|
@@ -320203,7 +320208,7 @@ var init_baseLlmClient = __esm({
|
|
|
320203
320208
|
retryFetchErrors: this.config.getRetryFetchErrors(),
|
|
320204
320209
|
signal: abortSignal,
|
|
320205
320210
|
onRetry: (attempt, error40, delayMs) => {
|
|
320206
|
-
const actualMaxAttempts = getAvailabilityContext()?.policy.maxAttempts ?? maxAttempts ?? DEFAULT_MAX_ATTEMPTS2;
|
|
320211
|
+
const actualMaxAttempts = getAvailabilityContext()?.policy.maxAttempts ?? currentAvailabilityMaxAttempts ?? maxAttempts ?? DEFAULT_MAX_ATTEMPTS2;
|
|
320207
320212
|
const modelName = getDisplayString(currentModel);
|
|
320208
320213
|
const errorType = getRetryErrorType(error40);
|
|
320209
320214
|
coreEvents.emitRetryAttempt({
|
|
@@ -320213,7 +320218,9 @@ var init_baseLlmClient = __esm({
|
|
|
320213
320218
|
error: errorType,
|
|
320214
320219
|
model: modelName,
|
|
320215
320220
|
status: getErrorStatus(error40),
|
|
320216
|
-
sessionId: this.config.getSessionId?.()
|
|
320221
|
+
sessionId: this.config.getSessionId?.(),
|
|
320222
|
+
role: requestRole,
|
|
320223
|
+
promptId: requestPromptId
|
|
320217
320224
|
});
|
|
320218
320225
|
logNetworkRetryAttempt(this.config, new NetworkRetryAttemptEvent(attempt, actualMaxAttempts, errorType, delayMs, modelName));
|
|
320219
320226
|
}
|
|
@@ -325135,11 +325142,15 @@ function createSafeAgent(options) {
|
|
|
325135
325142
|
connect
|
|
325136
325143
|
});
|
|
325137
325144
|
}
|
|
325138
|
-
function updateGlobalFetchTimeouts(timeoutMs) {
|
|
325145
|
+
function updateGlobalFetchTimeouts(timeoutMs, bodyTimeoutMs) {
|
|
325139
325146
|
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
325140
325147
|
throw new RangeError(`Invalid timeout value: ${timeoutMs}. Must be a positive finite number.`);
|
|
325141
325148
|
}
|
|
325149
|
+
if (bodyTimeoutMs !== void 0 && (!Number.isFinite(bodyTimeoutMs) || bodyTimeoutMs <= 0)) {
|
|
325150
|
+
throw new RangeError(`Invalid body timeout value: ${bodyTimeoutMs}. Must be a positive finite number.`);
|
|
325151
|
+
}
|
|
325142
325152
|
defaultHeadersTimeout = timeoutMs;
|
|
325153
|
+
defaultBodyTimeout = bodyTimeoutMs ?? Math.max(DEFAULT_BODY_TIMEOUT, timeoutMs);
|
|
325143
325154
|
defaultSafeAgent = createSafeAgent({
|
|
325144
325155
|
headersTimeout: defaultHeadersTimeout,
|
|
325145
325156
|
bodyTimeout: defaultBodyTimeout
|
|
@@ -325312,7 +325323,14 @@ async function fetchWithTimeout(url4, timeout2, options) {
|
|
|
325312
325323
|
}
|
|
325313
325324
|
function setGlobalProxy(proxy2) {
|
|
325314
325325
|
const trimmedProxy = proxy2.trim();
|
|
325315
|
-
currentProxy = trimmedProxy;
|
|
325326
|
+
currentProxy = trimmedProxy || void 0;
|
|
325327
|
+
if (!currentProxy) {
|
|
325328
|
+
undici.setGlobalDispatcher(new undici.Agent({
|
|
325329
|
+
headersTimeout: defaultHeadersTimeout,
|
|
325330
|
+
bodyTimeout: defaultBodyTimeout
|
|
325331
|
+
}));
|
|
325332
|
+
return;
|
|
325333
|
+
}
|
|
325316
325334
|
const noProxy = (process.env["NO_PROXY"] ?? process.env["no_proxy"] ?? "")?.trim();
|
|
325317
325335
|
undici.setGlobalDispatcher(new undici.EnvHttpProxyAgent({
|
|
325318
325336
|
httpProxy: trimmedProxy,
|
|
@@ -325322,7 +325340,7 @@ function setGlobalProxy(proxy2) {
|
|
|
325322
325340
|
bodyTimeout: defaultBodyTimeout
|
|
325323
325341
|
}));
|
|
325324
325342
|
}
|
|
325325
|
-
var undici, import_ipaddr, FetchError3, PrivateIpError, defaultHeadersTimeout, defaultBodyTimeout, currentProxy, defaultSafeAgent, IANA_BENCHMARK_RANGE;
|
|
325343
|
+
var undici, import_ipaddr, FetchError3, PrivateIpError, DEFAULT_HEADERS_TIMEOUT, DEFAULT_BODY_TIMEOUT, defaultHeadersTimeout, defaultBodyTimeout, currentProxy, defaultSafeAgent, IANA_BENCHMARK_RANGE;
|
|
325326
325344
|
var init_fetch = __esm({
|
|
325327
325345
|
"packages/core/dist/src/utils/fetch.js"() {
|
|
325328
325346
|
"use strict";
|
|
@@ -325343,8 +325361,10 @@ var init_fetch = __esm({
|
|
|
325343
325361
|
this.name = "PrivateIpError";
|
|
325344
325362
|
}
|
|
325345
325363
|
};
|
|
325346
|
-
|
|
325347
|
-
|
|
325364
|
+
DEFAULT_HEADERS_TIMEOUT = 6e4;
|
|
325365
|
+
DEFAULT_BODY_TIMEOUT = 3e5;
|
|
325366
|
+
defaultHeadersTimeout = DEFAULT_HEADERS_TIMEOUT;
|
|
325367
|
+
defaultBodyTimeout = DEFAULT_BODY_TIMEOUT;
|
|
325348
325368
|
currentProxy = void 0;
|
|
325349
325369
|
defaultSafeAgent = createSafeAgent();
|
|
325350
325370
|
undici.setGlobalDispatcher(new undici.Agent({
|
|
@@ -325578,7 +325598,7 @@ function resolveProvider(requestedId, filePath = getOpenAiProvidersPath(), confi
|
|
|
325578
325598
|
const entries = loadProviderEntries(filePath);
|
|
325579
325599
|
if (entries.length === 0) {
|
|
325580
325600
|
if (requestedId) {
|
|
325581
|
-
throw new
|
|
325601
|
+
throw new UnknownProviderError(requestedId, [], `No providers are configured in ${filePath}, so "${requestedId}" cannot be resolved. Run /provider add to create one.`);
|
|
325582
325602
|
}
|
|
325583
325603
|
return void 0;
|
|
325584
325604
|
}
|
|
@@ -325587,8 +325607,8 @@ function resolveProvider(requestedId, filePath = getOpenAiProvidersPath(), confi
|
|
|
325587
325607
|
}
|
|
325588
325608
|
const entry = entries.find((candidate) => candidate.id === requestedId);
|
|
325589
325609
|
if (!entry) {
|
|
325590
|
-
const
|
|
325591
|
-
throw new
|
|
325610
|
+
const knownIds = entries.map((candidate) => candidate.id);
|
|
325611
|
+
throw new UnknownProviderError(requestedId, knownIds, `Unknown provider "${requestedId}". Configured providers: ${knownIds.join(", ")}.`);
|
|
325592
325612
|
}
|
|
325593
325613
|
return toProfile(entry, configEnv, filePath);
|
|
325594
325614
|
}
|
|
@@ -325754,7 +325774,7 @@ function removeProvider(providerId, filePath = getOpenAiProvidersPath()) {
|
|
|
325754
325774
|
document2["providers"] = remaining;
|
|
325755
325775
|
writeProviderDocument(filePath, document2);
|
|
325756
325776
|
}
|
|
325757
|
-
var PROVIDER_ID_PATTERN, ENV_VAR_NAME_PATTERN, TOKEN_COUNT_UNITS, TOKEN_COUNT_HINT, tokenCountSchema, providerModelSchema, providerSchema, providersFileSchema, OPENAI_PROVIDER_ENV, providerUpdateSchema;
|
|
325777
|
+
var PROVIDER_ID_PATTERN, ENV_VAR_NAME_PATTERN, TOKEN_COUNT_UNITS, TOKEN_COUNT_HINT, tokenCountSchema, providerModelSchema, providerSchema, providersFileSchema, UnknownProviderError, OPENAI_PROVIDER_ENV, providerUpdateSchema;
|
|
325758
325778
|
var init_providers = __esm({
|
|
325759
325779
|
"packages/core/dist/src/core/openai/providers.js"() {
|
|
325760
325780
|
"use strict";
|
|
@@ -325800,6 +325820,16 @@ var init_providers = __esm({
|
|
|
325800
325820
|
providersFileSchema = external_exports.object({
|
|
325801
325821
|
providers: external_exports.array(providerSchema)
|
|
325802
325822
|
}).strict();
|
|
325823
|
+
UnknownProviderError = class extends Error {
|
|
325824
|
+
requestedId;
|
|
325825
|
+
knownIds;
|
|
325826
|
+
constructor(requestedId, knownIds, message) {
|
|
325827
|
+
super(message);
|
|
325828
|
+
this.requestedId = requestedId;
|
|
325829
|
+
this.knownIds = knownIds;
|
|
325830
|
+
this.name = "UnknownProviderError";
|
|
325831
|
+
}
|
|
325832
|
+
};
|
|
325803
325833
|
OPENAI_PROVIDER_ENV = "GEMINI_OPENAI_PROVIDER";
|
|
325804
325834
|
providerUpdateSchema = providerSchema.pick({
|
|
325805
325835
|
label: true,
|
|
@@ -327352,7 +327382,7 @@ function resolveActiveProvider(options) {
|
|
|
327352
327382
|
try {
|
|
327353
327383
|
return resolveProvider(choice2, void 0, env5);
|
|
327354
327384
|
} catch (error40) {
|
|
327355
|
-
if (requestedId !== void 0) {
|
|
327385
|
+
if (requestedId !== void 0 || !(error40 instanceof UnknownProviderError)) {
|
|
327356
327386
|
throw error40;
|
|
327357
327387
|
}
|
|
327358
327388
|
return resolveImplicitProvider(sessionProviderId, env5);
|
|
@@ -327366,14 +327396,14 @@ function resolveActiveProvider(options) {
|
|
|
327366
327396
|
function resolveImplicitProvider(staleId, env5) {
|
|
327367
327397
|
const fallback = resolveProvider(void 0, void 0, env5);
|
|
327368
327398
|
if (staleId && fallback) {
|
|
327369
|
-
coreEvents.emitFeedback("warning", `The selected OpenAI provider "${staleId}" is
|
|
327399
|
+
coreEvents.emitFeedback("warning", `The selected OpenAI provider "${staleId}" is not configured in the provider file, so this session is using "${fallback.id}" instead. Run /provider to choose another.`);
|
|
327370
327400
|
}
|
|
327371
327401
|
return fallback;
|
|
327372
327402
|
}
|
|
327373
|
-
function hasResolvableOpenAiProvider(env5, filePath) {
|
|
327403
|
+
function hasResolvableOpenAiProvider(env5, filePath, selectedProviderId2) {
|
|
327404
|
+
const cleanEnv = toCleanEnv(env5);
|
|
327374
327405
|
try {
|
|
327375
|
-
const
|
|
327376
|
-
const requestedId = cleanEnv?.[OPENAI_PROVIDER_ENV];
|
|
327406
|
+
const requestedId = pickRequestedId(cleanEnv, selectedProviderId2);
|
|
327377
327407
|
const profile = resolveProvider(requestedId, filePath, cleanEnv);
|
|
327378
327408
|
return Boolean(profile?.baseUrl && profile?.modelId);
|
|
327379
327409
|
} catch (error40) {
|
|
@@ -327381,6 +327411,32 @@ function hasResolvableOpenAiProvider(env5, filePath) {
|
|
|
327381
327411
|
return false;
|
|
327382
327412
|
}
|
|
327383
327413
|
}
|
|
327414
|
+
function describeUnusableOpenAiProvider(env5, filePath, selectedProviderId2) {
|
|
327415
|
+
const cleanEnv = toCleanEnv(env5);
|
|
327416
|
+
const requestedId = pickRequestedId(cleanEnv, selectedProviderId2);
|
|
327417
|
+
if (!requestedId) {
|
|
327418
|
+
return null;
|
|
327419
|
+
}
|
|
327420
|
+
try {
|
|
327421
|
+
resolveProvider(requestedId, filePath, cleanEnv);
|
|
327422
|
+
return null;
|
|
327423
|
+
} catch (error40) {
|
|
327424
|
+
if (error40 instanceof UnknownProviderError) {
|
|
327425
|
+
return null;
|
|
327426
|
+
}
|
|
327427
|
+
return getErrorMessage(error40);
|
|
327428
|
+
}
|
|
327429
|
+
}
|
|
327430
|
+
function pickRequestedId(cleanEnv, selectedProviderId2) {
|
|
327431
|
+
const persisted = selectedProviderId2?.trim();
|
|
327432
|
+
return persisted ? persisted : cleanEnv?.[OPENAI_PROVIDER_ENV];
|
|
327433
|
+
}
|
|
327434
|
+
function toCleanEnv(env5) {
|
|
327435
|
+
if (!env5) {
|
|
327436
|
+
return void 0;
|
|
327437
|
+
}
|
|
327438
|
+
return Object.fromEntries(Object.entries(env5).filter((entry) => entry[1] !== void 0));
|
|
327439
|
+
}
|
|
327384
327440
|
function reportUnreadableProviderFile(error40, filePath) {
|
|
327385
327441
|
const path204 = filePath ?? getOpenAiProvidersPath();
|
|
327386
327442
|
try {
|
|
@@ -351216,6 +351272,7 @@ var init_web_fetch = __esm({
|
|
|
351216
351272
|
init_tool_names();
|
|
351217
351273
|
init_debugLogger();
|
|
351218
351274
|
init_events();
|
|
351275
|
+
init_promptIdContext();
|
|
351219
351276
|
init_retry();
|
|
351220
351277
|
init_coreTools();
|
|
351221
351278
|
init_resolver();
|
|
@@ -351244,7 +351301,9 @@ var init_web_fetch = __esm({
|
|
|
351244
351301
|
delayMs,
|
|
351245
351302
|
error: errorType,
|
|
351246
351303
|
model: modelName,
|
|
351247
|
-
sessionId: this.context.config.getSessionId?.()
|
|
351304
|
+
sessionId: this.context.config.getSessionId?.(),
|
|
351305
|
+
role: LlmRole.UTILITY_TOOL,
|
|
351306
|
+
promptId: promptIdContext.getStore()
|
|
351248
351307
|
});
|
|
351249
351308
|
logNetworkRetryAttempt(this.context.config, new NetworkRetryAttemptEvent(attempt, maxAttempts, errorType, delayMs, modelName));
|
|
351250
351309
|
}
|
|
@@ -353267,7 +353326,9 @@ var init_geminiChat = __esm({
|
|
|
353267
353326
|
error: errorType,
|
|
353268
353327
|
model,
|
|
353269
353328
|
status: getErrorStatus(error40),
|
|
353270
|
-
sessionId: this.context.config.getSessionId?.()
|
|
353329
|
+
sessionId: this.context.config.getSessionId?.(),
|
|
353330
|
+
role,
|
|
353331
|
+
promptId: prompt_id
|
|
353271
353332
|
});
|
|
353272
353333
|
await new Promise((res) => setTimeout(res, delayMs));
|
|
353273
353334
|
continue;
|
|
@@ -353418,6 +353479,7 @@ var init_geminiChat = __esm({
|
|
|
353418
353479
|
const contentsForPreviewModel = this.ensureActiveLoopHasThoughtSignatures(requestContents);
|
|
353419
353480
|
const { model: availabilityFinalModel, config: newAvailabilityConfig, maxAttempts: availabilityMaxAttempts } = applyModelSelection(this.context.config, modelConfigKey);
|
|
353420
353481
|
let lastModelToUse = availabilityFinalModel;
|
|
353482
|
+
let currentAvailabilityMaxAttempts = availabilityMaxAttempts;
|
|
353421
353483
|
let currentGenerateContentConfig = newAvailabilityConfig;
|
|
353422
353484
|
let lastConfig = currentGenerateContentConfig;
|
|
353423
353485
|
let lastContentsToUse = [...requestContents];
|
|
@@ -353436,12 +353498,14 @@ var init_geminiChat = __esm({
|
|
|
353436
353498
|
if (this.context.config.getActiveModel() !== initialActiveModel) {
|
|
353437
353499
|
initialActiveModel = this.context.config.getActiveModel();
|
|
353438
353500
|
modelToUse = resolveModel(initialActiveModel, useGemini3_1, useCustomToolModel, hasAccessToPreview, this.context.config, useLatestFlash, useLatestFlashLite);
|
|
353501
|
+
currentAvailabilityMaxAttempts = void 0;
|
|
353439
353502
|
} else if (!firstAttempt && (this.context.config.getModelAvailabilityService?.()?.snapshot(modelToUse)?.available ?? true) === false) {
|
|
353440
|
-
const { model: reselectedModel, config: reselectedConfig } = applyModelSelection(this.context.config, modelConfigKey);
|
|
353503
|
+
const { model: reselectedModel, config: reselectedConfig, maxAttempts: reselectedMaxAttempts } = applyModelSelection(this.context.config, modelConfigKey);
|
|
353441
353504
|
modelToUse = resolveModel(reselectedModel, useGemini3_1, useCustomToolModel, hasAccessToPreview, this.context.config, useLatestFlash, useLatestFlashLite);
|
|
353442
353505
|
if (reselectedConfig) {
|
|
353443
353506
|
currentGenerateContentConfig = reselectedConfig;
|
|
353444
353507
|
}
|
|
353508
|
+
currentAvailabilityMaxAttempts = reselectedMaxAttempts;
|
|
353445
353509
|
initialActiveModel = this.context.config.getActiveModel();
|
|
353446
353510
|
}
|
|
353447
353511
|
if (modelToUse !== lastModelToUse) {
|
|
@@ -353555,14 +353619,17 @@ var init_geminiChat = __esm({
|
|
|
353555
353619
|
maxAttempts: availabilityMaxAttempts ?? this.context.config.getMaxAttempts(),
|
|
353556
353620
|
getAvailabilityContext,
|
|
353557
353621
|
onRetry: (attempt, error40, delayMs) => {
|
|
353622
|
+
const actualMaxAttempts = getAvailabilityContext()?.policy.maxAttempts ?? currentAvailabilityMaxAttempts ?? this.context.config.getMaxAttempts();
|
|
353558
353623
|
coreEvents.emitRetryAttempt({
|
|
353559
353624
|
attempt,
|
|
353560
|
-
maxAttempts:
|
|
353625
|
+
maxAttempts: actualMaxAttempts,
|
|
353561
353626
|
delayMs,
|
|
353562
353627
|
error: error40 instanceof Error ? error40.message : String(error40),
|
|
353563
353628
|
model: lastModelToUse,
|
|
353564
353629
|
status: getErrorStatus(error40),
|
|
353565
|
-
sessionId: this.context.config.getSessionId?.()
|
|
353630
|
+
sessionId: this.context.config.getSessionId?.(),
|
|
353631
|
+
role,
|
|
353632
|
+
promptId: prompt_id
|
|
353566
353633
|
});
|
|
353567
353634
|
}
|
|
353568
353635
|
});
|
|
@@ -354423,13 +354490,42 @@ function tokenLimit(model) {
|
|
|
354423
354490
|
return DEFAULT_TOKEN_LIMIT;
|
|
354424
354491
|
}
|
|
354425
354492
|
}
|
|
354426
|
-
|
|
354493
|
+
function outputTokenLimit(model) {
|
|
354494
|
+
switch (model) {
|
|
354495
|
+
case PREVIEW_GEMINI_MODEL:
|
|
354496
|
+
case PREVIEW_GEMINI_3_1_MODEL:
|
|
354497
|
+
case PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL:
|
|
354498
|
+
case PREVIEW_GEMINI_FLASH_MODEL:
|
|
354499
|
+
case DEFAULT_GEMINI_MODEL:
|
|
354500
|
+
case DEFAULT_GEMINI_FLASH_MODEL:
|
|
354501
|
+
case DEFAULT_GEMINI_FLASH_LITE_MODEL:
|
|
354502
|
+
case BASE_GEMINI_FLASH_MODEL:
|
|
354503
|
+
case LATEST_GEMINI_FLASH_MODEL:
|
|
354504
|
+
case LEGACY_CCPA_FLASH_MODEL:
|
|
354505
|
+
case BASE_GEMINI_FLASH_LITE_MODEL:
|
|
354506
|
+
case LATEST_GEMINI_FLASH_LITE_MODEL:
|
|
354507
|
+
case "gemini-2.5-flash":
|
|
354508
|
+
case "gemini-2.5-flash-lite":
|
|
354509
|
+
case "gemini-3.1-flash-lite-preview":
|
|
354510
|
+
case GEMINI_MODEL_ALIAS_AUTO:
|
|
354511
|
+
case PREVIEW_GEMINI_MODEL_AUTO:
|
|
354512
|
+
case DEFAULT_GEMINI_MODEL_AUTO:
|
|
354513
|
+
case GEMINI_MODEL_ALIAS_PRO:
|
|
354514
|
+
case GEMINI_MODEL_ALIAS_FLASH:
|
|
354515
|
+
case GEMINI_MODEL_ALIAS_FLASH_LITE:
|
|
354516
|
+
return DEFAULT_OUTPUT_TOKEN_LIMIT;
|
|
354517
|
+
default:
|
|
354518
|
+
return void 0;
|
|
354519
|
+
}
|
|
354520
|
+
}
|
|
354521
|
+
var DEFAULT_TOKEN_LIMIT, DEFAULT_OUTPUT_TOKEN_LIMIT, GEMMA_4_TOKEN_LIMIT;
|
|
354427
354522
|
var init_tokenLimits = __esm({
|
|
354428
354523
|
"packages/core/dist/src/core/tokenLimits.js"() {
|
|
354429
354524
|
"use strict";
|
|
354430
354525
|
init_models();
|
|
354431
354526
|
init_contextWindow();
|
|
354432
354527
|
DEFAULT_TOKEN_LIMIT = 1048576;
|
|
354528
|
+
DEFAULT_OUTPUT_TOKEN_LIMIT = 65536;
|
|
354433
354529
|
GEMMA_4_TOKEN_LIMIT = 256e3;
|
|
354434
354530
|
}
|
|
354435
354531
|
});
|
|
@@ -372687,6 +372783,7 @@ var init_client3 = __esm({
|
|
|
372687
372783
|
init_models();
|
|
372688
372784
|
init_partUtils();
|
|
372689
372785
|
init_events();
|
|
372786
|
+
init_promptIdContext();
|
|
372690
372787
|
init_initializer();
|
|
372691
372788
|
MAX_TURNS = 100;
|
|
372692
372789
|
GeminiClient = class {
|
|
@@ -373346,6 +373443,8 @@ ${responseText}` : responseText;
|
|
|
373346
373443
|
return turn;
|
|
373347
373444
|
}
|
|
373348
373445
|
async generateContent(modelConfigKey, contents, abortSignal, role) {
|
|
373446
|
+
const requestPromptId = promptIdContext.getStore() ?? this.lastPromptId;
|
|
373447
|
+
const requestRole = role;
|
|
373349
373448
|
const desiredModelConfig = this.config.modelConfigService.getResolvedConfig(modelConfigKey);
|
|
373350
373449
|
let { model: currentAttemptModel, generateContentConfig: currentAttemptGenerateContentConfig } = desiredModelConfig;
|
|
373351
373450
|
try {
|
|
@@ -373356,6 +373455,7 @@ ${responseText}` : responseText;
|
|
|
373356
373455
|
if (newConfig) {
|
|
373357
373456
|
currentAttemptGenerateContentConfig = newConfig;
|
|
373358
373457
|
}
|
|
373458
|
+
let currentAvailabilityMaxAttempts = availabilityMaxAttempts;
|
|
373359
373459
|
const getAvailabilityContext = createAvailabilityContextProvider(this.config, () => currentAttemptModel);
|
|
373360
373460
|
let initialActiveModel = this.config.getActiveModel();
|
|
373361
373461
|
let isFirstAttempt = true;
|
|
@@ -373371,12 +373471,14 @@ ${responseText}` : responseText;
|
|
|
373371
373471
|
});
|
|
373372
373472
|
currentAttemptModel = resolvedModel;
|
|
373373
373473
|
currentAttemptGenerateContentConfig = generateContentConfig;
|
|
373474
|
+
currentAvailabilityMaxAttempts = void 0;
|
|
373374
373475
|
} else if (!firstAttempt && (this.config.getModelAvailabilityService?.()?.snapshot(currentAttemptModel)?.available ?? true) === false) {
|
|
373375
|
-
const { model: reselectedModel, config: reselectedConfig } = applyModelSelection(this.config, modelConfigKey);
|
|
373476
|
+
const { model: reselectedModel, config: reselectedConfig, maxAttempts: reselectedMaxAttempts } = applyModelSelection(this.config, modelConfigKey);
|
|
373376
373477
|
currentAttemptModel = reselectedModel;
|
|
373377
373478
|
if (reselectedConfig) {
|
|
373378
373479
|
currentAttemptGenerateContentConfig = reselectedConfig;
|
|
373379
373480
|
}
|
|
373481
|
+
currentAvailabilityMaxAttempts = reselectedMaxAttempts;
|
|
373380
373482
|
initialActiveModel = this.config.getActiveModel();
|
|
373381
373483
|
}
|
|
373382
373484
|
const requestConfig = {
|
|
@@ -373388,7 +373490,7 @@ ${responseText}` : responseText;
|
|
|
373388
373490
|
model: currentAttemptModel,
|
|
373389
373491
|
config: requestConfig,
|
|
373390
373492
|
contents
|
|
373391
|
-
},
|
|
373493
|
+
}, requestPromptId, requestRole);
|
|
373392
373494
|
};
|
|
373393
373495
|
const onPersistent429Callback = async (authType, error40) => (
|
|
373394
373496
|
// Pass the captured model to the centralized handler.
|
|
@@ -373412,14 +373514,17 @@ ${responseText}` : responseText;
|
|
|
373412
373514
|
retryFetchErrors: this.config.getRetryFetchErrors(),
|
|
373413
373515
|
getAvailabilityContext,
|
|
373414
373516
|
onRetry: (attempt, error40, delayMs) => {
|
|
373517
|
+
const actualMaxAttempts = getAvailabilityContext()?.policy.maxAttempts ?? currentAvailabilityMaxAttempts ?? this.config.getMaxAttempts();
|
|
373415
373518
|
coreEvents.emitRetryAttempt({
|
|
373416
373519
|
attempt,
|
|
373417
|
-
maxAttempts:
|
|
373520
|
+
maxAttempts: actualMaxAttempts,
|
|
373418
373521
|
delayMs,
|
|
373419
373522
|
error: error40 instanceof Error ? error40.message : String(error40),
|
|
373420
373523
|
model: getDisplayString(currentAttemptModel),
|
|
373421
373524
|
status: getErrorStatus(error40),
|
|
373422
|
-
sessionId: this.config.getSessionId?.()
|
|
373525
|
+
sessionId: this.config.getSessionId?.(),
|
|
373526
|
+
role: requestRole,
|
|
373527
|
+
promptId: requestPromptId
|
|
373423
373528
|
});
|
|
373424
373529
|
}
|
|
373425
373530
|
});
|
|
@@ -428185,6 +428290,7 @@ __export(dist_exports, {
|
|
|
428185
428290
|
DEFAULT_MEMORY_FILE_FILTERING_OPTIONS: () => DEFAULT_MEMORY_FILE_FILTERING_OPTIONS,
|
|
428186
428291
|
DEFAULT_MODEL_CONFIGS: () => DEFAULT_MODEL_CONFIGS,
|
|
428187
428292
|
DEFAULT_OTLP_ENDPOINT: () => DEFAULT_OTLP_ENDPOINT,
|
|
428293
|
+
DEFAULT_OUTPUT_TOKEN_LIMIT: () => DEFAULT_OUTPUT_TOKEN_LIMIT,
|
|
428188
428294
|
DEFAULT_POLICY_TIER: () => DEFAULT_POLICY_TIER,
|
|
428189
428295
|
DEFAULT_QUERY_STRING: () => DEFAULT_QUERY_STRING,
|
|
428190
428296
|
DEFAULT_TELEMETRY_TARGET: () => DEFAULT_TELEMETRY_TARGET,
|
|
@@ -428612,6 +428718,7 @@ __export(dist_exports, {
|
|
|
428612
428718
|
USER_STEERING_INSTRUCTION: () => USER_STEERING_INSTRUCTION,
|
|
428613
428719
|
UiTelemetryService: () => UiTelemetryService,
|
|
428614
428720
|
UnauthorizedError: () => UnauthorizedError,
|
|
428721
|
+
UnknownProviderError: () => UnknownProviderError,
|
|
428615
428722
|
UserAccountManager: () => UserAccountManager,
|
|
428616
428723
|
UserPromptEvent: () => UserPromptEvent,
|
|
428617
428724
|
UserTierId: () => UserTierId,
|
|
@@ -428731,6 +428838,7 @@ __export(dist_exports, {
|
|
|
428731
428838
|
deleteStoredSession: () => deleteStoredSession,
|
|
428732
428839
|
deleteSubagentSessionDirAndArtifactsAsync: () => deleteSubagentSessionDirAndArtifactsAsync,
|
|
428733
428840
|
deriveSessionShortId: () => deriveSessionShortId,
|
|
428841
|
+
describeUnusableOpenAiProvider: () => describeUnusableOpenAiProvider,
|
|
428734
428842
|
detectBOM: () => detectBOM,
|
|
428735
428843
|
detectCommandSubstitution: () => detectCommandSubstitution,
|
|
428736
428844
|
detectFileType: () => detectFileType,
|
|
@@ -429090,6 +429198,7 @@ __export(dist_exports, {
|
|
|
429090
429198
|
normalizeUrl: () => normalizeUrl,
|
|
429091
429199
|
openBrowserSecurely: () => openBrowserSecurely,
|
|
429092
429200
|
openDiff: () => openDiff,
|
|
429201
|
+
outputTokenLimit: () => outputTokenLimit,
|
|
429093
429202
|
parseAgentMarkdown: () => parseAgentMarkdown,
|
|
429094
429203
|
parseAndFormatApiError: () => parseAndFormatApiError,
|
|
429095
429204
|
parseBashCommandDetails: () => parseBashCommandDetails,
|
|
@@ -488213,6 +488322,28 @@ function findEnvFile(startDir, isTrusted, ignoreLocalEnv) {
|
|
|
488213
488322
|
currentDir = parentDir;
|
|
488214
488323
|
}
|
|
488215
488324
|
}
|
|
488325
|
+
function findUserLevelEnvFiles(primaryPath) {
|
|
488326
|
+
const candidates = [
|
|
488327
|
+
path128.join(homedir(), GEMINI_DIR, ".env"),
|
|
488328
|
+
path128.join(homedir(), ".env")
|
|
488329
|
+
];
|
|
488330
|
+
const seen = /* @__PURE__ */ new Set();
|
|
488331
|
+
const files = [];
|
|
488332
|
+
for (const candidate of candidates) {
|
|
488333
|
+
const resolved = path128.resolve(candidate);
|
|
488334
|
+
if (resolved === (primaryPath && path128.resolve(primaryPath))) {
|
|
488335
|
+
continue;
|
|
488336
|
+
}
|
|
488337
|
+
if (seen.has(resolved)) {
|
|
488338
|
+
continue;
|
|
488339
|
+
}
|
|
488340
|
+
seen.add(resolved);
|
|
488341
|
+
if (fs111.existsSync(resolved)) {
|
|
488342
|
+
files.push(resolved);
|
|
488343
|
+
}
|
|
488344
|
+
}
|
|
488345
|
+
return files;
|
|
488346
|
+
}
|
|
488216
488347
|
function setUpCloudShellEnvironment(envFilePath, isTrusted, isSandboxed, selectedAuthType) {
|
|
488217
488348
|
if (!process43.env[USER_GCP_PROJECT]) {
|
|
488218
488349
|
const current = process43.env["GOOGLE_CLOUD_PROJECT"];
|
|
@@ -488259,30 +488390,36 @@ function loadEnvironment(settings, workspaceDir, isWorkspaceTrustedFn = isWorksp
|
|
|
488259
488390
|
);
|
|
488260
488391
|
}
|
|
488261
488392
|
if (envFilePath) {
|
|
488262
|
-
|
|
488263
|
-
|
|
488264
|
-
|
|
488265
|
-
|
|
488266
|
-
|
|
488267
|
-
|
|
488268
|
-
|
|
488269
|
-
|
|
488270
|
-
|
|
488271
|
-
|
|
488272
|
-
|
|
488273
|
-
|
|
488274
|
-
|
|
488275
|
-
|
|
488276
|
-
|
|
488393
|
+
loadEnvFileIntoProcess(envFilePath, settings, isTrusted);
|
|
488394
|
+
}
|
|
488395
|
+
for (const fallbackPath of findUserLevelEnvFiles(envFilePath)) {
|
|
488396
|
+
loadEnvFileIntoProcess(fallbackPath, settings, isTrusted);
|
|
488397
|
+
}
|
|
488398
|
+
}
|
|
488399
|
+
function loadEnvFileIntoProcess(envFilePath, settings, isTrusted) {
|
|
488400
|
+
try {
|
|
488401
|
+
const envFileContent = fs111.readFileSync(envFilePath, "utf-8");
|
|
488402
|
+
const parsedEnv = dotenv.parse(envFileContent);
|
|
488403
|
+
const excludedVars = settings?.advanced?.excludedEnvVars || DEFAULT_EXCLUDED_ENV_VARS;
|
|
488404
|
+
const isProjectEnvFile = !envFilePath.includes(GEMINI_DIR);
|
|
488405
|
+
for (const key in parsedEnv) {
|
|
488406
|
+
if (Object.hasOwn(parsedEnv, key)) {
|
|
488407
|
+
let value = parsedEnv[key];
|
|
488408
|
+
if (!isTrusted) {
|
|
488409
|
+
if (!AUTH_ENV_VAR_WHITELIST.includes(key)) {
|
|
488277
488410
|
continue;
|
|
488278
488411
|
}
|
|
488279
|
-
|
|
488280
|
-
|
|
488281
|
-
|
|
488412
|
+
value = sanitizeEnvVar(value);
|
|
488413
|
+
}
|
|
488414
|
+
if (isProjectEnvFile && excludedVars.includes(key)) {
|
|
488415
|
+
continue;
|
|
488416
|
+
}
|
|
488417
|
+
if (!Object.hasOwn(process43.env, key)) {
|
|
488418
|
+
process43.env[key] = value;
|
|
488282
488419
|
}
|
|
488283
488420
|
}
|
|
488284
|
-
} catch {
|
|
488285
488421
|
}
|
|
488422
|
+
} catch {
|
|
488286
488423
|
}
|
|
488287
488424
|
}
|
|
488288
488425
|
function isWorktreeEnabled(settings) {
|
|
@@ -511263,6 +511400,155 @@ var init_gemma = __esm({
|
|
|
511263
511400
|
}
|
|
511264
511401
|
});
|
|
511265
511402
|
|
|
511403
|
+
// packages/cli/src/ui/openai/openAiProviderPreference.ts
|
|
511404
|
+
function readPersistedProviderId(settings) {
|
|
511405
|
+
const id = settings?.security?.auth?.openAiProviderId;
|
|
511406
|
+
return typeof id === "string" && id.trim().length > 0 ? id : void 0;
|
|
511407
|
+
}
|
|
511408
|
+
function persistProviderId(settings, providerId) {
|
|
511409
|
+
try {
|
|
511410
|
+
settings.setValue(
|
|
511411
|
+
"User" /* User */,
|
|
511412
|
+
OPENAI_PROVIDER_SETTING_KEY,
|
|
511413
|
+
providerId
|
|
511414
|
+
);
|
|
511415
|
+
} catch {
|
|
511416
|
+
}
|
|
511417
|
+
}
|
|
511418
|
+
function persistOpenAiMode(settings) {
|
|
511419
|
+
try {
|
|
511420
|
+
settings.setValue(
|
|
511421
|
+
"User" /* User */,
|
|
511422
|
+
AUTH_MODE_SETTING_KEY,
|
|
511423
|
+
AuthType2.USE_OPENAI
|
|
511424
|
+
);
|
|
511425
|
+
} catch {
|
|
511426
|
+
}
|
|
511427
|
+
}
|
|
511428
|
+
function hasConfiguredProviders() {
|
|
511429
|
+
try {
|
|
511430
|
+
return loadProviderEntries().length > 0;
|
|
511431
|
+
} catch {
|
|
511432
|
+
return false;
|
|
511433
|
+
}
|
|
511434
|
+
}
|
|
511435
|
+
function providerHasDefaultModel(providerId) {
|
|
511436
|
+
try {
|
|
511437
|
+
const entry = loadProviderEntries().find(
|
|
511438
|
+
(candidate) => candidate.id === providerId
|
|
511439
|
+
);
|
|
511440
|
+
if (!entry) {
|
|
511441
|
+
return true;
|
|
511442
|
+
}
|
|
511443
|
+
return Boolean(entry.modelId);
|
|
511444
|
+
} catch {
|
|
511445
|
+
return true;
|
|
511446
|
+
}
|
|
511447
|
+
}
|
|
511448
|
+
function rememberModelForProvider(providerId, modelId) {
|
|
511449
|
+
if (!providerId || modelId.trim().length === 0) {
|
|
511450
|
+
return;
|
|
511451
|
+
}
|
|
511452
|
+
persistProviderModelId(providerId, modelId);
|
|
511453
|
+
}
|
|
511454
|
+
var OPENAI_PROVIDER_SETTING_KEY, AUTH_MODE_SETTING_KEY;
|
|
511455
|
+
var init_openAiProviderPreference = __esm({
|
|
511456
|
+
"packages/cli/src/ui/openai/openAiProviderPreference.ts"() {
|
|
511457
|
+
"use strict";
|
|
511458
|
+
init_settings();
|
|
511459
|
+
init_dist4();
|
|
511460
|
+
OPENAI_PROVIDER_SETTING_KEY = "security.auth.openAiProviderId";
|
|
511461
|
+
AUTH_MODE_SETTING_KEY = "security.auth.selectedType";
|
|
511462
|
+
}
|
|
511463
|
+
});
|
|
511464
|
+
|
|
511465
|
+
// packages/cli/src/config/auth.ts
|
|
511466
|
+
function selectedProviderId() {
|
|
511467
|
+
return readPersistedProviderId(loadSettings().merged);
|
|
511468
|
+
}
|
|
511469
|
+
function isOpenAiEndpointConfigured() {
|
|
511470
|
+
loadEnvironment(loadSettings().merged, process.cwd());
|
|
511471
|
+
const hasBaseUrl = hasOpenAiBaseUrl();
|
|
511472
|
+
const hasModelId = Boolean(
|
|
511473
|
+
process.env[OPENAI_MODEL_ID_ENV] || process.env[OPENAI_MODEL_ID_FALLBACK_ENV]
|
|
511474
|
+
);
|
|
511475
|
+
if (hasBaseUrl && hasModelId) {
|
|
511476
|
+
return true;
|
|
511477
|
+
}
|
|
511478
|
+
return hasResolvableOpenAiProvider(
|
|
511479
|
+
{ ...process.env },
|
|
511480
|
+
void 0,
|
|
511481
|
+
selectedProviderId()
|
|
511482
|
+
);
|
|
511483
|
+
}
|
|
511484
|
+
function hasOpenAiBaseUrl() {
|
|
511485
|
+
loadEnvironment(loadSettings().merged, process.cwd());
|
|
511486
|
+
return Boolean(
|
|
511487
|
+
process.env[OPENAI_BASE_URL_ENV] || process.env[OPENAI_BASE_URL_FALLBACK_ENV]
|
|
511488
|
+
);
|
|
511489
|
+
}
|
|
511490
|
+
async function validateAuthMethod(authMethod) {
|
|
511491
|
+
loadEnvironment(loadSettings().merged, process.cwd());
|
|
511492
|
+
if (authMethod === AuthType2.LOGIN_WITH_GOOGLE || authMethod === AuthType2.COMPUTE_ADC) {
|
|
511493
|
+
return null;
|
|
511494
|
+
}
|
|
511495
|
+
if (authMethod === AuthType2.USE_GEMINI) {
|
|
511496
|
+
const key = process.env["GEMINI_API_KEY"] || await loadApiKey();
|
|
511497
|
+
if (!key) {
|
|
511498
|
+
return "When using Gemini API, you must specify the GEMINI_API_KEY environment variable.\nUpdate your environment and try again (no reload needed if using .env)!";
|
|
511499
|
+
}
|
|
511500
|
+
return null;
|
|
511501
|
+
}
|
|
511502
|
+
if (authMethod === AuthType2.USE_VERTEX_AI) {
|
|
511503
|
+
const hasVertexProjectLocationConfig = !!process.env["GOOGLE_CLOUD_PROJECT"] && !!process.env["GOOGLE_CLOUD_LOCATION"];
|
|
511504
|
+
const hasGoogleApiKey = !!process.env["GOOGLE_API_KEY"];
|
|
511505
|
+
if (!hasVertexProjectLocationConfig && !hasGoogleApiKey) {
|
|
511506
|
+
return "When using Vertex AI, you must specify either:\n\u2022 GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION environment variables.\n\u2022 GOOGLE_API_KEY environment variable (if using express mode).\nUpdate your environment and try again (no reload needed if using .env)!";
|
|
511507
|
+
}
|
|
511508
|
+
return null;
|
|
511509
|
+
}
|
|
511510
|
+
if (authMethod === AuthType2.USE_OPENAI) {
|
|
511511
|
+
const selected = selectedProviderId();
|
|
511512
|
+
if (hasResolvableOpenAiProvider({ ...process.env }, void 0, selected)) {
|
|
511513
|
+
try {
|
|
511514
|
+
parseHeaderJson(process.env["GEMINI_OPENAI_HEADERS"]);
|
|
511515
|
+
} catch (error40) {
|
|
511516
|
+
return error40 instanceof Error ? error40.message : String(error40);
|
|
511517
|
+
}
|
|
511518
|
+
return null;
|
|
511519
|
+
}
|
|
511520
|
+
const providerFailure = describeUnusableOpenAiProvider(
|
|
511521
|
+
{ ...process.env },
|
|
511522
|
+
void 0,
|
|
511523
|
+
selected
|
|
511524
|
+
);
|
|
511525
|
+
if (providerFailure) {
|
|
511526
|
+
return providerFailure;
|
|
511527
|
+
}
|
|
511528
|
+
if (!process.env["GEMINI_OPENAI_BASE_URL"] && !process.env["GOOGLE_GEMINI_BASE_URL"]) {
|
|
511529
|
+
return "When using an OpenAI-compatible API, you must specify the GEMINI_OPENAI_BASE_URL environment variable.\nUpdate your environment and try again (no reload needed if using .env)!";
|
|
511530
|
+
}
|
|
511531
|
+
if (!process.env["GEMINI_OPENAI_MODELID"] && !process.env["GEMINI_MODEL"]) {
|
|
511532
|
+
return "When using an OpenAI-compatible API, you must specify the GEMINI_OPENAI_MODELID environment variable.\nUpdate your environment and try again (no reload needed if using .env)!";
|
|
511533
|
+
}
|
|
511534
|
+
try {
|
|
511535
|
+
parseHeaderJson(process.env["GEMINI_OPENAI_HEADERS"]);
|
|
511536
|
+
} catch (error40) {
|
|
511537
|
+
return error40 instanceof Error ? error40.message : String(error40);
|
|
511538
|
+
}
|
|
511539
|
+
return null;
|
|
511540
|
+
}
|
|
511541
|
+
return "Invalid auth method selected.";
|
|
511542
|
+
}
|
|
511543
|
+
var init_auth3 = __esm({
|
|
511544
|
+
"packages/cli/src/config/auth.ts"() {
|
|
511545
|
+
"use strict";
|
|
511546
|
+
init_dist4();
|
|
511547
|
+
init_settings();
|
|
511548
|
+
init_openAiProviderPreference();
|
|
511549
|
+
}
|
|
511550
|
+
});
|
|
511551
|
+
|
|
511266
511552
|
// packages/cli/src/acp/acpUtils.ts
|
|
511267
511553
|
function hasMeta(obj) {
|
|
511268
511554
|
return typeof obj === "object" && obj !== null && "_meta" in obj;
|
|
@@ -511465,7 +511751,7 @@ function buildAvailableModels(config2, settings) {
|
|
|
511465
511751
|
const useGemini31 = config2.getGemini31LaunchedSync?.() ?? false;
|
|
511466
511752
|
const useLatestFlash = config2.hasLatestFlashGAAccess?.() ?? false;
|
|
511467
511753
|
const useLatestFlashLite = config2.hasLatestFlashLiteGAAccess?.() ?? false;
|
|
511468
|
-
const selectedAuthType = settings.merged.security
|
|
511754
|
+
const selectedAuthType = settings.merged.security?.auth?.selectedType ?? config2.getContentGeneratorConfig?.()?.authType;
|
|
511469
511755
|
const useCustomToolModel = useGemini31 && selectedAuthType === AuthType2.USE_GEMINI;
|
|
511470
511756
|
if (config2.getExperimentalDynamicModelConfiguration?.() === true && config2.getModelConfigService) {
|
|
511471
511757
|
const options = config2.getModelConfigService().getAvailableModelOptions({
|
|
@@ -511526,6 +511812,14 @@ function buildAvailableModels(config2, settings) {
|
|
|
511526
511812
|
}
|
|
511527
511813
|
manualOptions.unshift(...previewOptions);
|
|
511528
511814
|
}
|
|
511815
|
+
const seen = /* @__PURE__ */ new Set();
|
|
511816
|
+
const uniqueManualOptions = manualOptions.filter((option2) => {
|
|
511817
|
+
if (seen.has(option2.value)) {
|
|
511818
|
+
return false;
|
|
511819
|
+
}
|
|
511820
|
+
seen.add(option2.value);
|
|
511821
|
+
return true;
|
|
511822
|
+
});
|
|
511529
511823
|
const scaleOptions = (options) => options.map((o3) => ({
|
|
511530
511824
|
modelId: o3.value,
|
|
511531
511825
|
name: o3.title,
|
|
@@ -511534,7 +511828,7 @@ function buildAvailableModels(config2, settings) {
|
|
|
511534
511828
|
return {
|
|
511535
511829
|
availableModels: [
|
|
511536
511830
|
...scaleOptions(mainOptions),
|
|
511537
|
-
...scaleOptions(
|
|
511831
|
+
...scaleOptions(uniqueManualOptions)
|
|
511538
511832
|
],
|
|
511539
511833
|
currentModelId: preferredModel
|
|
511540
511834
|
};
|
|
@@ -511574,7 +511868,7 @@ function getModelListings(config2, settings) {
|
|
|
511574
511868
|
const { availableModels } = buildAvailableModels(config2, settings);
|
|
511575
511869
|
return (availableModels ?? []).map((m3) => {
|
|
511576
511870
|
const inputTokens = tokenLimit(m3.modelId) ?? DEFAULT_TOKEN_LIMIT;
|
|
511577
|
-
const outputTokens =
|
|
511871
|
+
const outputTokens = outputTokenLimit(m3.modelId);
|
|
511578
511872
|
return {
|
|
511579
511873
|
modelId: m3.modelId,
|
|
511580
511874
|
id: m3.modelId,
|
|
@@ -511583,7 +511877,7 @@ function getModelListings(config2, settings) {
|
|
|
511583
511877
|
description: m3.description ?? "",
|
|
511584
511878
|
contextLimits: {
|
|
511585
511879
|
inputTokens,
|
|
511586
|
-
outputTokens
|
|
511880
|
+
...outputTokens !== void 0 ? { outputTokens } : {}
|
|
511587
511881
|
}
|
|
511588
511882
|
};
|
|
511589
511883
|
});
|
|
@@ -511593,7 +511887,8 @@ async function handleList3(options) {
|
|
|
511593
511887
|
const settings = options?.loadedSettings ?? loadSettings(workspaceDir);
|
|
511594
511888
|
const argv = {
|
|
511595
511889
|
...DEFAULT_CLI_ARGS,
|
|
511596
|
-
...options?.argv
|
|
511890
|
+
...options?.argv,
|
|
511891
|
+
isCommand: true
|
|
511597
511892
|
};
|
|
511598
511893
|
const config2 = await loadCliConfig(
|
|
511599
511894
|
settings.merged,
|
|
@@ -511607,6 +511902,33 @@ async function handleList3(options) {
|
|
|
511607
511902
|
);
|
|
511608
511903
|
initializeOutputListenersAndFlush(config2);
|
|
511609
511904
|
await config2.storage.initialize();
|
|
511905
|
+
const authConfig = settings.merged.security?.auth;
|
|
511906
|
+
const authType = authConfig?.selectedType || getAuthTypeFromEnv();
|
|
511907
|
+
const enforcedType = authConfig?.enforcedType;
|
|
511908
|
+
if (enforcedType && authType !== enforcedType) {
|
|
511909
|
+
const message = authType ? `The enforced authentication type is '${enforcedType}', but the current type is '${authType}'. Please re-authenticate with the correct type.` : `The auth type '${enforcedType}' is enforced, but no authentication is configured.`;
|
|
511910
|
+
throw new Error(message);
|
|
511911
|
+
}
|
|
511912
|
+
if (authType && !authConfig?.useExternal) {
|
|
511913
|
+
try {
|
|
511914
|
+
if (authType !== AuthType2.GATEWAY) {
|
|
511915
|
+
const authError = await validateAuthMethod(authType);
|
|
511916
|
+
if (authError) {
|
|
511917
|
+
throw new Error(authError);
|
|
511918
|
+
}
|
|
511919
|
+
}
|
|
511920
|
+
config2.isBrowserLaunchSuppressed = () => true;
|
|
511921
|
+
await config2.refreshAuth(authType);
|
|
511922
|
+
} catch (e3) {
|
|
511923
|
+
if (enforcedType) {
|
|
511924
|
+
throw e3;
|
|
511925
|
+
}
|
|
511926
|
+
debugLogger.debug(
|
|
511927
|
+
"Failed to refresh auth for models list, falling back to default catalog:",
|
|
511928
|
+
e3
|
|
511929
|
+
);
|
|
511930
|
+
}
|
|
511931
|
+
}
|
|
511610
511932
|
const models = getModelListings(config2, settings);
|
|
511611
511933
|
if (options?.outputFormat === "json") {
|
|
511612
511934
|
process.stdout.write(JSON.stringify(models, null, 2) + "\n");
|
|
@@ -511620,8 +511942,9 @@ async function handleList3(options) {
|
|
|
511620
511942
|
process.stdout.write(` Description: ${model.description}
|
|
511621
511943
|
`);
|
|
511622
511944
|
}
|
|
511945
|
+
const outputLimitText = model.contextLimits.outputTokens !== void 0 ? ` / ${model.contextLimits.outputTokens.toLocaleString()} output tokens` : "";
|
|
511623
511946
|
process.stdout.write(
|
|
511624
|
-
` Context limit: ${model.contextLimits.inputTokens.toLocaleString()} input tokens
|
|
511947
|
+
` Context limit: ${model.contextLimits.inputTokens.toLocaleString()} input tokens${outputLimitText}
|
|
511625
511948
|
|
|
511626
511949
|
`
|
|
511627
511950
|
);
|
|
@@ -511634,6 +511957,7 @@ var init_list4 = __esm({
|
|
|
511634
511957
|
init_dist4();
|
|
511635
511958
|
import_chalk19 = __toESM(require_source(), 1);
|
|
511636
511959
|
init_settings();
|
|
511960
|
+
init_auth3();
|
|
511637
511961
|
init_config6();
|
|
511638
511962
|
init_acpUtils();
|
|
511639
511963
|
init_utils9();
|
|
@@ -511681,6 +512005,7 @@ var init_list4 = __esm({
|
|
|
511681
512005
|
}),
|
|
511682
512006
|
handler: async (argv) => {
|
|
511683
512007
|
const outputFormat = argv["output-format"] === "json" ? "json" : "text";
|
|
512008
|
+
let exitCode;
|
|
511684
512009
|
try {
|
|
511685
512010
|
await handleList3({
|
|
511686
512011
|
outputFormat,
|
|
@@ -511692,8 +512017,13 @@ var init_list4 = __esm({
|
|
|
511692
512017
|
"Error: " + (error40 instanceof Error ? error40.stack || error40.message : String(error40)) + "\n"
|
|
511693
512018
|
);
|
|
511694
512019
|
process.exitCode = 1;
|
|
512020
|
+
exitCode = 1;
|
|
511695
512021
|
} finally {
|
|
511696
|
-
|
|
512022
|
+
if (exitCode !== void 0) {
|
|
512023
|
+
await exitCli(exitCode);
|
|
512024
|
+
} else {
|
|
512025
|
+
await exitCli();
|
|
512026
|
+
}
|
|
511697
512027
|
}
|
|
511698
512028
|
}
|
|
511699
512029
|
};
|
|
@@ -511802,7 +512132,7 @@ async function loadSandboxConfig(settings, argv) {
|
|
|
511802
512132
|
}
|
|
511803
512133
|
const command2 = getSandboxCommand(sandboxValue);
|
|
511804
512134
|
const packageJson2 = await getPackageJson(__dirname11);
|
|
511805
|
-
const image3 = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.
|
|
512135
|
+
const image3 = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.1.30" ?? customImage ?? packageJson2?.config?.sandboxImageUri;
|
|
511806
512136
|
const isNative = command2 === "windows-native" || command2 === "sandbox-exec" || command2 === "lxc";
|
|
511807
512137
|
return command2 && (image3 || isNative) ? { enabled: true, allowedPaths, networkAccess, command: command2, image: image3 } : void 0;
|
|
511808
512138
|
}
|
|
@@ -520727,7 +521057,7 @@ var GIT_COMMIT_INFO2;
|
|
|
520727
521057
|
var init_git_commit2 = __esm({
|
|
520728
521058
|
"packages/cli/src/generated/git-commit.ts"() {
|
|
520729
521059
|
"use strict";
|
|
520730
|
-
GIT_COMMIT_INFO2 = "
|
|
521060
|
+
GIT_COMMIT_INFO2 = "8f1203e";
|
|
520731
521061
|
}
|
|
520732
521062
|
});
|
|
520733
521063
|
|
|
@@ -557991,64 +558321,6 @@ var init_OpenAiModelDialog = __esm({
|
|
|
557991
558321
|
}
|
|
557992
558322
|
});
|
|
557993
558323
|
|
|
557994
|
-
// packages/cli/src/ui/openai/openAiProviderPreference.ts
|
|
557995
|
-
function persistProviderId(settings, providerId) {
|
|
557996
|
-
try {
|
|
557997
|
-
settings.setValue(
|
|
557998
|
-
"User" /* User */,
|
|
557999
|
-
OPENAI_PROVIDER_SETTING_KEY,
|
|
558000
|
-
providerId
|
|
558001
|
-
);
|
|
558002
|
-
} catch {
|
|
558003
|
-
}
|
|
558004
|
-
}
|
|
558005
|
-
function persistOpenAiMode(settings) {
|
|
558006
|
-
try {
|
|
558007
|
-
settings.setValue(
|
|
558008
|
-
"User" /* User */,
|
|
558009
|
-
AUTH_MODE_SETTING_KEY,
|
|
558010
|
-
AuthType2.USE_OPENAI
|
|
558011
|
-
);
|
|
558012
|
-
} catch {
|
|
558013
|
-
}
|
|
558014
|
-
}
|
|
558015
|
-
function hasConfiguredProviders() {
|
|
558016
|
-
try {
|
|
558017
|
-
return loadProviderEntries().length > 0;
|
|
558018
|
-
} catch {
|
|
558019
|
-
return false;
|
|
558020
|
-
}
|
|
558021
|
-
}
|
|
558022
|
-
function providerHasDefaultModel(providerId) {
|
|
558023
|
-
try {
|
|
558024
|
-
const entry = loadProviderEntries().find(
|
|
558025
|
-
(candidate) => candidate.id === providerId
|
|
558026
|
-
);
|
|
558027
|
-
if (!entry) {
|
|
558028
|
-
return true;
|
|
558029
|
-
}
|
|
558030
|
-
return Boolean(entry.modelId);
|
|
558031
|
-
} catch {
|
|
558032
|
-
return true;
|
|
558033
|
-
}
|
|
558034
|
-
}
|
|
558035
|
-
function rememberModelForProvider(providerId, modelId) {
|
|
558036
|
-
if (!providerId || modelId.trim().length === 0) {
|
|
558037
|
-
return;
|
|
558038
|
-
}
|
|
558039
|
-
persistProviderModelId(providerId, modelId);
|
|
558040
|
-
}
|
|
558041
|
-
var OPENAI_PROVIDER_SETTING_KEY, AUTH_MODE_SETTING_KEY;
|
|
558042
|
-
var init_openAiProviderPreference = __esm({
|
|
558043
|
-
"packages/cli/src/ui/openai/openAiProviderPreference.ts"() {
|
|
558044
|
-
"use strict";
|
|
558045
|
-
init_settings();
|
|
558046
|
-
init_dist4();
|
|
558047
|
-
OPENAI_PROVIDER_SETTING_KEY = "security.auth.openAiProviderId";
|
|
558048
|
-
AUTH_MODE_SETTING_KEY = "security.auth.selectedType";
|
|
558049
|
-
}
|
|
558050
|
-
});
|
|
558051
|
-
|
|
558052
558324
|
// packages/cli/src/ui/openai/ProviderModelDialog.tsx
|
|
558053
558325
|
function parseTokenField(raw) {
|
|
558054
558326
|
const trimmed2 = raw.trim();
|
|
@@ -593918,7 +594190,7 @@ async function performInitialAuth(config2, authType) {
|
|
|
593918
594190
|
}
|
|
593919
594191
|
return { authError: null, accountSuspensionInfo: null };
|
|
593920
594192
|
}
|
|
593921
|
-
var
|
|
594193
|
+
var init_auth4 = __esm({
|
|
593922
594194
|
"packages/cli/src/core/auth.ts"() {
|
|
593923
594195
|
"use strict";
|
|
593924
594196
|
init_dist4();
|
|
@@ -593981,81 +594253,11 @@ var init_initializer2 = __esm({
|
|
|
593981
594253
|
"use strict";
|
|
593982
594254
|
init_dist4();
|
|
593983
594255
|
init_settings();
|
|
593984
|
-
|
|
594256
|
+
init_auth4();
|
|
593985
594257
|
init_theme2();
|
|
593986
594258
|
}
|
|
593987
594259
|
});
|
|
593988
594260
|
|
|
593989
|
-
// packages/cli/src/config/auth.ts
|
|
593990
|
-
function isOpenAiEndpointConfigured() {
|
|
593991
|
-
loadEnvironment(loadSettings().merged, process.cwd());
|
|
593992
|
-
const hasBaseUrl = hasOpenAiBaseUrl();
|
|
593993
|
-
const hasModelId = Boolean(
|
|
593994
|
-
process.env[OPENAI_MODEL_ID_ENV] || process.env[OPENAI_MODEL_ID_FALLBACK_ENV]
|
|
593995
|
-
);
|
|
593996
|
-
if (hasBaseUrl && hasModelId) {
|
|
593997
|
-
return true;
|
|
593998
|
-
}
|
|
593999
|
-
return hasResolvableOpenAiProvider({ ...process.env });
|
|
594000
|
-
}
|
|
594001
|
-
function hasOpenAiBaseUrl() {
|
|
594002
|
-
loadEnvironment(loadSettings().merged, process.cwd());
|
|
594003
|
-
return Boolean(
|
|
594004
|
-
process.env[OPENAI_BASE_URL_ENV] || process.env[OPENAI_BASE_URL_FALLBACK_ENV]
|
|
594005
|
-
);
|
|
594006
|
-
}
|
|
594007
|
-
async function validateAuthMethod(authMethod) {
|
|
594008
|
-
loadEnvironment(loadSettings().merged, process.cwd());
|
|
594009
|
-
if (authMethod === AuthType2.LOGIN_WITH_GOOGLE || authMethod === AuthType2.COMPUTE_ADC) {
|
|
594010
|
-
return null;
|
|
594011
|
-
}
|
|
594012
|
-
if (authMethod === AuthType2.USE_GEMINI) {
|
|
594013
|
-
const key = process.env["GEMINI_API_KEY"] || await loadApiKey();
|
|
594014
|
-
if (!key) {
|
|
594015
|
-
return "When using Gemini API, you must specify the GEMINI_API_KEY environment variable.\nUpdate your environment and try again (no reload needed if using .env)!";
|
|
594016
|
-
}
|
|
594017
|
-
return null;
|
|
594018
|
-
}
|
|
594019
|
-
if (authMethod === AuthType2.USE_VERTEX_AI) {
|
|
594020
|
-
const hasVertexProjectLocationConfig = !!process.env["GOOGLE_CLOUD_PROJECT"] && !!process.env["GOOGLE_CLOUD_LOCATION"];
|
|
594021
|
-
const hasGoogleApiKey = !!process.env["GOOGLE_API_KEY"];
|
|
594022
|
-
if (!hasVertexProjectLocationConfig && !hasGoogleApiKey) {
|
|
594023
|
-
return "When using Vertex AI, you must specify either:\n\u2022 GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION environment variables.\n\u2022 GOOGLE_API_KEY environment variable (if using express mode).\nUpdate your environment and try again (no reload needed if using .env)!";
|
|
594024
|
-
}
|
|
594025
|
-
return null;
|
|
594026
|
-
}
|
|
594027
|
-
if (authMethod === AuthType2.USE_OPENAI) {
|
|
594028
|
-
if (hasResolvableOpenAiProvider({ ...process.env })) {
|
|
594029
|
-
try {
|
|
594030
|
-
parseHeaderJson(process.env["GEMINI_OPENAI_HEADERS"]);
|
|
594031
|
-
} catch (error40) {
|
|
594032
|
-
return error40 instanceof Error ? error40.message : String(error40);
|
|
594033
|
-
}
|
|
594034
|
-
return null;
|
|
594035
|
-
}
|
|
594036
|
-
if (!process.env["GEMINI_OPENAI_BASE_URL"] && !process.env["GOOGLE_GEMINI_BASE_URL"]) {
|
|
594037
|
-
return "When using an OpenAI-compatible API, you must specify the GEMINI_OPENAI_BASE_URL environment variable.\nUpdate your environment and try again (no reload needed if using .env)!";
|
|
594038
|
-
}
|
|
594039
|
-
if (!process.env["GEMINI_OPENAI_MODELID"] && !process.env["GEMINI_MODEL"]) {
|
|
594040
|
-
return "When using an OpenAI-compatible API, you must specify the GEMINI_OPENAI_MODELID environment variable.\nUpdate your environment and try again (no reload needed if using .env)!";
|
|
594041
|
-
}
|
|
594042
|
-
try {
|
|
594043
|
-
parseHeaderJson(process.env["GEMINI_OPENAI_HEADERS"]);
|
|
594044
|
-
} catch (error40) {
|
|
594045
|
-
return error40 instanceof Error ? error40.message : String(error40);
|
|
594046
|
-
}
|
|
594047
|
-
return null;
|
|
594048
|
-
}
|
|
594049
|
-
return "Invalid auth method selected.";
|
|
594050
|
-
}
|
|
594051
|
-
var init_auth4 = __esm({
|
|
594052
|
-
"packages/cli/src/config/auth.ts"() {
|
|
594053
|
-
"use strict";
|
|
594054
|
-
init_dist4();
|
|
594055
|
-
init_settings();
|
|
594056
|
-
}
|
|
594057
|
-
});
|
|
594058
|
-
|
|
594059
594261
|
// node_modules/@agentclientprotocol/sdk/dist/schema/index.js
|
|
594060
594262
|
var AGENT_METHODS, CLIENT_METHODS, PROTOCOL_VERSION;
|
|
594061
594263
|
var init_schema2 = __esm({
|
|
@@ -598391,7 +598593,7 @@ var init_validateNonInterActiveAuth = __esm({
|
|
|
598391
598593
|
"use strict";
|
|
598392
598594
|
init_dist4();
|
|
598393
598595
|
init_settings();
|
|
598394
|
-
|
|
598596
|
+
init_auth3();
|
|
598395
598597
|
init_errors6();
|
|
598396
598598
|
init_cleanup2();
|
|
598397
598599
|
}
|
|
@@ -612002,7 +612204,7 @@ var init_useAuth = __esm({
|
|
|
612002
612204
|
init_dist4();
|
|
612003
612205
|
init_dist4();
|
|
612004
612206
|
init_types21();
|
|
612005
|
-
|
|
612207
|
+
init_auth3();
|
|
612006
612208
|
useAuthCommand = (settings, config2, initialAuthError = null, initialAccountSuspensionInfo = null) => {
|
|
612007
612209
|
const [authState, setAuthState] = (0, import_react138.useState)(
|
|
612008
612210
|
initialAuthError ? "updating" /* Updating */ : "unauthenticated" /* Unauthenticated */
|
|
@@ -612352,7 +612554,7 @@ var init_AuthDialog = __esm({
|
|
|
612352
612554
|
init_useKeypress();
|
|
612353
612555
|
init_types21();
|
|
612354
612556
|
init_useAuth();
|
|
612355
|
-
|
|
612557
|
+
init_auth3();
|
|
612356
612558
|
init_processUtils();
|
|
612357
612559
|
import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1);
|
|
612358
612560
|
}
|
|
@@ -615614,7 +615816,7 @@ var init_DialogManager = __esm({
|
|
|
615614
615816
|
init_BannedAccountDialog();
|
|
615615
615817
|
init_ApiAuthDialog();
|
|
615616
615818
|
init_openai2();
|
|
615617
|
-
|
|
615819
|
+
init_auth3();
|
|
615618
615820
|
init_ProviderDialogs();
|
|
615619
615821
|
init_EditorSettingsDialog();
|
|
615620
615822
|
init_PrivacyNotice();
|
|
@@ -626645,6 +626847,8 @@ var init_useGeminiStream = __esm({
|
|
|
626645
626847
|
);
|
|
626646
626848
|
const cancelPromiseRef = (0, import_react197.useRef)(Promise.resolve());
|
|
626647
626849
|
const activeQueryIdRef = (0, import_react197.useRef)(null);
|
|
626850
|
+
const lastQueryRef = (0, import_react197.useRef)(null);
|
|
626851
|
+
const lastPromptIdRef = (0, import_react197.useRef)(null);
|
|
626648
626852
|
const previousApprovalModeRef = (0, import_react197.useRef)(
|
|
626649
626853
|
config2.getApprovalMode()
|
|
626650
626854
|
);
|
|
@@ -626664,7 +626868,7 @@ var init_useGeminiStream = __esm({
|
|
|
626664
626868
|
}, [config2]);
|
|
626665
626869
|
(0, import_react197.useEffect)(() => {
|
|
626666
626870
|
const handleRetryAttempt = (payload) => {
|
|
626667
|
-
if (turnCancelledRef.current || !isRespondingRef.current) {
|
|
626871
|
+
if (turnCancelledRef.current || !isRespondingRef.current || payload.role !== LlmRole.MAIN || !lastPromptIdRef.current || payload.promptId !== lastPromptIdRef.current) {
|
|
626668
626872
|
return;
|
|
626669
626873
|
}
|
|
626670
626874
|
setRetryStatus(payload);
|
|
@@ -626962,8 +627166,6 @@ var init_useGeminiStream = __esm({
|
|
|
626962
627166
|
backgroundTasks,
|
|
626963
627167
|
settings.merged.ui?.compactToolOutput
|
|
626964
627168
|
]);
|
|
626965
|
-
const lastQueryRef = (0, import_react197.useRef)(null);
|
|
626966
|
-
const lastPromptIdRef = (0, import_react197.useRef)(null);
|
|
626967
627169
|
const loopDetectedRef = (0, import_react197.useRef)(false);
|
|
626968
627170
|
const autoNudgeAttemptCountRef = (0, import_react197.useRef)(0);
|
|
626969
627171
|
const MAX_AUTO_NUDGE_ATTEMPTS = 2;
|
|
@@ -627390,6 +627592,7 @@ var init_useGeminiStream = __esm({
|
|
|
627390
627592
|
);
|
|
627391
627593
|
const handleThoughtEvent = (0, import_react197.useCallback)(
|
|
627392
627594
|
(eventValue, _userMessageTimestamp) => {
|
|
627595
|
+
setRetryStatus(null);
|
|
627393
627596
|
setThought(eventValue);
|
|
627394
627597
|
if (getInlineThinkingMode(settings) === "full") {
|
|
627395
627598
|
addItem({
|
|
@@ -627718,6 +627921,7 @@ var init_useGeminiStream = __esm({
|
|
|
627718
627921
|
);
|
|
627719
627922
|
break;
|
|
627720
627923
|
case GeminiEventType.ToolCallRequest:
|
|
627924
|
+
setRetryStatus(null);
|
|
627721
627925
|
toolCallRequests.push(event.value);
|
|
627722
627926
|
pendingToolCallRequestsRef.current.push(event.value);
|
|
627723
627927
|
break;
|
|
@@ -627905,10 +628109,11 @@ var init_useGeminiStream = __esm({
|
|
|
627905
628109
|
startNewPrompt();
|
|
627906
628110
|
setThought(null);
|
|
627907
628111
|
}
|
|
627908
|
-
setIsResponding(true);
|
|
627909
|
-
setInitError(null);
|
|
627910
628112
|
lastQueryRef.current = queryToSend;
|
|
627911
628113
|
lastPromptIdRef.current = prompt_id;
|
|
628114
|
+
setRetryStatus(null);
|
|
628115
|
+
setIsResponding(true);
|
|
628116
|
+
setInitError(null);
|
|
627912
628117
|
try {
|
|
627913
628118
|
const stream2 = geminiClient.sendMessageStream(
|
|
627914
628119
|
queryToSend,
|
|
@@ -629610,7 +629815,7 @@ var init_useLoadingIndicator = __esm({
|
|
|
629610
629815
|
const prevStreamingStateRef = (0, import_react200.useRef)(null);
|
|
629611
629816
|
const [prevRetryStatus, setPrevRetryStatus] = (0, import_react200.useState)(null);
|
|
629612
629817
|
const [countdownSeconds, setCountdownSeconds] = (0, import_react200.useState)(null);
|
|
629613
|
-
const isSameRetry = retryStatus === prevRetryStatus || retryStatus !== null && prevRetryStatus !== null && retryStatus.attempt === prevRetryStatus.attempt && retryStatus.delayMs === prevRetryStatus.delayMs && retryStatus.model === prevRetryStatus.model && retryStatus.status === prevRetryStatus.status && retryStatus.error === prevRetryStatus.error;
|
|
629818
|
+
const isSameRetry = retryStatus === prevRetryStatus || retryStatus !== null && prevRetryStatus !== null && retryStatus.attempt === prevRetryStatus.attempt && retryStatus.maxAttempts === prevRetryStatus.maxAttempts && retryStatus.delayMs === prevRetryStatus.delayMs && retryStatus.model === prevRetryStatus.model && retryStatus.status === prevRetryStatus.status && retryStatus.error === prevRetryStatus.error && retryStatus.role === prevRetryStatus.role && retryStatus.promptId === prevRetryStatus.promptId;
|
|
629614
629819
|
if (!isSameRetry) {
|
|
629615
629820
|
setPrevRetryStatus(retryStatus);
|
|
629616
629821
|
setCountdownSeconds(
|
|
@@ -629622,6 +629827,8 @@ var init_useLoadingIndicator = __esm({
|
|
|
629622
629827
|
const attempt = retryStatus?.attempt ?? 0;
|
|
629623
629828
|
const delayMs = retryStatus?.delayMs ?? 0;
|
|
629624
629829
|
const model = retryStatus?.model ?? "";
|
|
629830
|
+
const role = retryStatus?.role;
|
|
629831
|
+
const promptId = retryStatus?.promptId;
|
|
629625
629832
|
(0, import_react200.useEffect)(() => {
|
|
629626
629833
|
if (!isTimerActive || !isRateLimit || countdownSeconds === null || countdownSeconds <= 1) {
|
|
629627
629834
|
return;
|
|
@@ -629637,7 +629844,16 @@ var init_useLoadingIndicator = __esm({
|
|
|
629637
629844
|
return () => {
|
|
629638
629845
|
clearInterval(intervalId);
|
|
629639
629846
|
};
|
|
629640
|
-
}, [
|
|
629847
|
+
}, [
|
|
629848
|
+
attempt,
|
|
629849
|
+
delayMs,
|
|
629850
|
+
model,
|
|
629851
|
+
role,
|
|
629852
|
+
promptId,
|
|
629853
|
+
isTimerActive,
|
|
629854
|
+
isRateLimit,
|
|
629855
|
+
countdownSeconds
|
|
629856
|
+
]);
|
|
629641
629857
|
(0, import_react200.useEffect)(() => {
|
|
629642
629858
|
if (prevStreamingStateRef.current === "waiting_for_confirmation" /* WaitingForConfirmation */ && streamingState === "responding" /* Responding */) {
|
|
629643
629859
|
setTimerResetKey((prevKey) => prevKey + 1);
|
|
@@ -633831,6 +634047,11 @@ function useSessionResume({
|
|
|
633831
634047
|
}
|
|
633832
634048
|
setIsResuming(true);
|
|
633833
634049
|
try {
|
|
634050
|
+
const client = config2.getGeminiClient();
|
|
634051
|
+
if (!client) {
|
|
634052
|
+
throw new Error("Gemini client is not initialized");
|
|
634053
|
+
}
|
|
634054
|
+
await client.resumeChat(clientHistory, resumedData);
|
|
633834
634055
|
setQuittingMessages(null);
|
|
633835
634056
|
historyManagerRef.current.loadHistory(toHistoryItemsWithIds(uiHistory));
|
|
633836
634057
|
refreshStaticRef.current();
|
|
@@ -633838,7 +634059,6 @@ function useSessionResume({
|
|
|
633838
634059
|
const workspaceContext = config2.getWorkspaceContext();
|
|
633839
634060
|
workspaceContext.addDirectories(resumedData.conversation.directories);
|
|
633840
634061
|
}
|
|
633841
|
-
await config2.getGeminiClient()?.resumeChat(clientHistory, resumedData);
|
|
633842
634062
|
} catch (error40) {
|
|
633843
634063
|
coreEvents.emitFeedback(
|
|
633844
634064
|
"error",
|
|
@@ -634926,7 +635146,7 @@ var init_AppContainer = __esm({
|
|
|
634926
635146
|
init_MouseContext();
|
|
634927
635147
|
init_ScrollProvider();
|
|
634928
635148
|
init_dist4();
|
|
634929
|
-
|
|
635149
|
+
init_auth3();
|
|
634930
635150
|
init_useHistoryManager();
|
|
634931
635151
|
init_useMemoryMonitor();
|
|
634932
635152
|
init_useThemeCommand();
|
|
@@ -638475,7 +638695,7 @@ var init_gemini = __esm({
|
|
|
638475
638695
|
init_worktreeSetup();
|
|
638476
638696
|
init_sessionCleanup();
|
|
638477
638697
|
init_initializer2();
|
|
638478
|
-
|
|
638698
|
+
init_auth3();
|
|
638479
638699
|
init_acpStdioTransport();
|
|
638480
638700
|
init_validateNonInterActiveAuth();
|
|
638481
638701
|
init_events2();
|