@google/gemini-cli-a2a-server 0.21.0-nightly.20251208.7a7203757 → 0.21.0-nightly.20251209.ec9a8c7a7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a2a-server.mjs +441 -177
- package/dist/src/agent/task.d.ts +2 -0
- package/dist/src/agent/task.js +6 -6
- package/dist/src/agent/task.js.map +1 -1
- package/dist/src/agent/task.test.js +59 -0
- package/dist/src/agent/task.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/a2a-server.mjs
CHANGED
|
@@ -308225,7 +308225,8 @@ async function triggerPostAuthCallbacks(tokens) {
|
|
|
308225
308225
|
client_secret: OAUTH_CLIENT_SECRET,
|
|
308226
308226
|
refresh_token: tokens.refresh_token ?? void 0,
|
|
308227
308227
|
// Ensure null is not passed
|
|
308228
|
-
type: "authorized_user"
|
|
308228
|
+
type: "authorized_user",
|
|
308229
|
+
client_email: userAccountManager.getCachedGoogleAccount() ?? void 0
|
|
308229
308230
|
};
|
|
308230
308231
|
authEvents.emit("post_auth", jwtInput);
|
|
308231
308232
|
}
|
|
@@ -308341,6 +308342,12 @@ async function initOauthClient(authType, config3) {
|
|
|
308341
308342
|
writeToStderr("Failed to authenticate with user code.\n");
|
|
308342
308343
|
throw new FatalAuthenticationError("Failed to authenticate with user code.");
|
|
308343
308344
|
}
|
|
308345
|
+
try {
|
|
308346
|
+
await fetchAndCacheUserInfo(client);
|
|
308347
|
+
} catch (error2) {
|
|
308348
|
+
debugLogger.warn("Failed to retrieve Google Account ID during authentication:", getErrorMessage(error2));
|
|
308349
|
+
}
|
|
308350
|
+
await triggerPostAuthCallbacks(client.credentials);
|
|
308344
308351
|
} else {
|
|
308345
308352
|
const webLogin = await authWithWeb(client);
|
|
308346
308353
|
coreEvents.emit(CoreEvent.UserFeedback, {
|
|
@@ -308388,6 +308395,7 @@ Please try running again with NO_BROWSER=true set.`
|
|
|
308388
308395
|
severity: "info",
|
|
308389
308396
|
message: "Authentication succeeded\n"
|
|
308390
308397
|
});
|
|
308398
|
+
await triggerPostAuthCallbacks(client.credentials);
|
|
308391
308399
|
}
|
|
308392
308400
|
return client;
|
|
308393
308401
|
}
|
|
@@ -311504,6 +311512,37 @@ var SmartEditCorrectionEvent = class {
|
|
|
311504
311512
|
return `Smart Edit Tool Correction: ${this.correction}`;
|
|
311505
311513
|
}
|
|
311506
311514
|
};
|
|
311515
|
+
var EVENT_STARTUP_STATS = "gemini_cli.startup_stats";
|
|
311516
|
+
var StartupStatsEvent = class {
|
|
311517
|
+
"event.name";
|
|
311518
|
+
"event.timestamp";
|
|
311519
|
+
phases;
|
|
311520
|
+
os_platform;
|
|
311521
|
+
os_release;
|
|
311522
|
+
is_docker;
|
|
311523
|
+
constructor(phases, os_platform, os_release, is_docker) {
|
|
311524
|
+
this["event.name"] = "startup_stats";
|
|
311525
|
+
this["event.timestamp"] = (/* @__PURE__ */ new Date()).toISOString();
|
|
311526
|
+
this.phases = phases;
|
|
311527
|
+
this.os_platform = os_platform;
|
|
311528
|
+
this.os_release = os_release;
|
|
311529
|
+
this.is_docker = is_docker;
|
|
311530
|
+
}
|
|
311531
|
+
toOpenTelemetryAttributes(config3) {
|
|
311532
|
+
return {
|
|
311533
|
+
...getCommonAttributes(config3),
|
|
311534
|
+
"event.name": EVENT_STARTUP_STATS,
|
|
311535
|
+
"event.timestamp": this["event.timestamp"],
|
|
311536
|
+
phases: JSON.stringify(this.phases),
|
|
311537
|
+
os_platform: this.os_platform,
|
|
311538
|
+
os_release: this.os_release,
|
|
311539
|
+
is_docker: this.is_docker
|
|
311540
|
+
};
|
|
311541
|
+
}
|
|
311542
|
+
toLogBody() {
|
|
311543
|
+
return `Startup stats: ${this.phases.length} phases recorded.`;
|
|
311544
|
+
}
|
|
311545
|
+
};
|
|
311507
311546
|
var BaseAgentEvent = class {
|
|
311508
311547
|
"event.timestamp";
|
|
311509
311548
|
agent_id;
|
|
@@ -311858,8 +311897,8 @@ var Float64Vector = import_vector.default.Float64Vector;
|
|
|
311858
311897
|
var PointerVector = import_vector.default.PointerVector;
|
|
311859
311898
|
|
|
311860
311899
|
// packages/core/dist/src/generated/git-commit.js
|
|
311861
|
-
var GIT_COMMIT_INFO = "
|
|
311862
|
-
var CLI_VERSION = "0.21.0-nightly.
|
|
311900
|
+
var GIT_COMMIT_INFO = "ec9a8c7a7";
|
|
311901
|
+
var CLI_VERSION = "0.21.0-nightly.20251209.ec9a8c7a7";
|
|
311863
311902
|
|
|
311864
311903
|
// packages/core/dist/src/ide/detect-ide.js
|
|
311865
311904
|
var IDE_DEFINITIONS = {
|
|
@@ -314058,6 +314097,25 @@ var StartupProfiler = class _StartupProfiler {
|
|
|
314058
314097
|
debugLogger.log("[STARTUP] Skipping phase without measure:", phase.name);
|
|
314059
314098
|
}
|
|
314060
314099
|
}
|
|
314100
|
+
const startupPhases = [];
|
|
314101
|
+
for (const phase of this.phases.values()) {
|
|
314102
|
+
if (!phase.ended)
|
|
314103
|
+
continue;
|
|
314104
|
+
const measure = measures.find((m2) => m2.name === phase.name);
|
|
314105
|
+
if (measure && phase.cpuUsage) {
|
|
314106
|
+
startupPhases.push({
|
|
314107
|
+
name: phase.name,
|
|
314108
|
+
duration_ms: measure.duration,
|
|
314109
|
+
cpu_usage_user_usec: phase.cpuUsage.user,
|
|
314110
|
+
cpu_usage_system_usec: phase.cpuUsage.system,
|
|
314111
|
+
start_time_usec: (performance2.timeOrigin + measure.startTime) * 1e3,
|
|
314112
|
+
end_time_usec: (performance2.timeOrigin + measure.startTime + measure.duration) * 1e3
|
|
314113
|
+
});
|
|
314114
|
+
}
|
|
314115
|
+
}
|
|
314116
|
+
if (startupPhases.length > 0) {
|
|
314117
|
+
logStartupStats(config3, new StartupStatsEvent(startupPhases, os6.platform(), os6.release(), fs27.existsSync("/.dockerenv")));
|
|
314118
|
+
}
|
|
314061
314119
|
for (const phaseName of this.phases.keys()) {
|
|
314062
314120
|
const startMarkName = this.getStartMarkName(phaseName);
|
|
314063
314121
|
const endMarkName = this.getEndMarkName(phaseName);
|
|
@@ -314105,6 +314163,7 @@ var telemetryInitialized = false;
|
|
|
314105
314163
|
var callbackRegistered = false;
|
|
314106
314164
|
var authListener = void 0;
|
|
314107
314165
|
var telemetryBuffer = [];
|
|
314166
|
+
var activeTelemetryEmail;
|
|
314108
314167
|
function bufferTelemetryEvent(fn) {
|
|
314109
314168
|
if (telemetryInitialized) {
|
|
314110
314169
|
fn();
|
|
@@ -314143,7 +314202,15 @@ function parseOtlpEndpoint(otlpEndpointSetting, protocol) {
|
|
|
314143
314202
|
}
|
|
314144
314203
|
}
|
|
314145
314204
|
async function initializeTelemetry(config3, credentials) {
|
|
314146
|
-
if (
|
|
314205
|
+
if (!config3.getTelemetryEnabled()) {
|
|
314206
|
+
return;
|
|
314207
|
+
}
|
|
314208
|
+
if (telemetryInitialized) {
|
|
314209
|
+
if (credentials?.client_email && activeTelemetryEmail && credentials.client_email !== activeTelemetryEmail) {
|
|
314210
|
+
const message = `Telemetry credentials have changed (from ${activeTelemetryEmail} to ${credentials.client_email}), but telemetry cannot be re-initialized in this process. Please restart the CLI to use the new account for telemetry.`;
|
|
314211
|
+
debugLogger.error(message);
|
|
314212
|
+
console.error(message);
|
|
314213
|
+
}
|
|
314147
314214
|
return;
|
|
314148
314215
|
}
|
|
314149
314216
|
if (config3.getTelemetryUseCollector() && config3.getTelemetryUseCliAuth()) {
|
|
@@ -314155,7 +314222,7 @@ async function initializeTelemetry(config3, credentials) {
|
|
|
314155
314222
|
callbackRegistered = true;
|
|
314156
314223
|
authListener = async (newCredentials) => {
|
|
314157
314224
|
if (config3.getTelemetryEnabled() && config3.getTelemetryUseCliAuth()) {
|
|
314158
|
-
debugLogger.log("Telemetry reinit with credentials
|
|
314225
|
+
debugLogger.log("Telemetry reinit with credentials.");
|
|
314159
314226
|
await initializeTelemetry(config3, newCredentials);
|
|
314160
314227
|
}
|
|
314161
314228
|
};
|
|
@@ -314250,6 +314317,7 @@ async function initializeTelemetry(config3, credentials) {
|
|
|
314250
314317
|
debugLogger.log("OpenTelemetry SDK started successfully.");
|
|
314251
314318
|
}
|
|
314252
314319
|
telemetryInitialized = true;
|
|
314320
|
+
activeTelemetryEmail = credentials?.client_email;
|
|
314253
314321
|
initializeMetrics(config3);
|
|
314254
314322
|
void flushTelemetryBuffer();
|
|
314255
314323
|
} catch (error2) {
|
|
@@ -314287,6 +314355,7 @@ async function shutdownTelemetry(config3, fromProcessExit = true) {
|
|
|
314287
314355
|
authListener = void 0;
|
|
314288
314356
|
}
|
|
314289
314357
|
callbackRegistered = false;
|
|
314358
|
+
activeTelemetryEmail = void 0;
|
|
314290
314359
|
}
|
|
314291
314360
|
}
|
|
314292
314361
|
|
|
@@ -314631,6 +314700,16 @@ function logHookCall(config3, event) {
|
|
|
314631
314700
|
recordHookCallMetrics(config3, event.hook_event_name, event.hook_name, event.duration_ms, event.success);
|
|
314632
314701
|
});
|
|
314633
314702
|
}
|
|
314703
|
+
function logStartupStats(config3, event) {
|
|
314704
|
+
bufferTelemetryEvent(() => {
|
|
314705
|
+
const logger6 = import_api_logs.logs.getLogger(SERVICE_NAME);
|
|
314706
|
+
const logRecord = {
|
|
314707
|
+
body: event.toLogBody(),
|
|
314708
|
+
attributes: event.toOpenTelemetryAttributes(config3)
|
|
314709
|
+
};
|
|
314710
|
+
logger6.emit(logRecord);
|
|
314711
|
+
});
|
|
314712
|
+
}
|
|
314634
314713
|
|
|
314635
314714
|
// packages/core/dist/src/utils/quotaErrorDetection.js
|
|
314636
314715
|
function isApiError(error2) {
|
|
@@ -315004,7 +315083,7 @@ async function createContentGenerator(config3, gcConfig, sessionId2) {
|
|
|
315004
315083
|
if (gcConfig.fakeResponses) {
|
|
315005
315084
|
return FakeContentGenerator.fromFile(gcConfig.fakeResponses);
|
|
315006
315085
|
}
|
|
315007
|
-
const version4 = "0.21.0-nightly.
|
|
315086
|
+
const version4 = "0.21.0-nightly.20251209.ec9a8c7a7";
|
|
315008
315087
|
const customHeadersEnv = process.env["GEMINI_CLI_CUSTOM_HEADERS"] || void 0;
|
|
315009
315088
|
const userAgent = `GeminiCLI/${version4} (${process.platform}; ${process.arch})`;
|
|
315010
315089
|
const customHeadersMap = parseCustomHeaders(customHeadersEnv);
|
|
@@ -317884,7 +317963,7 @@ var ReadFileTool = class _ReadFileTool extends BaseDeclarativeTool {
|
|
|
317884
317963
|
config;
|
|
317885
317964
|
static Name = READ_FILE_TOOL_NAME;
|
|
317886
317965
|
constructor(config3, messageBus) {
|
|
317887
|
-
super(_ReadFileTool.Name, "ReadFile", `Reads and returns the content of a specified file. If the file is large, the content will be truncated. The tool's response will clearly indicate if truncation has occurred and will provide details on how to read more of the file using the 'offset' and 'limit' parameters. Handles text, images (PNG, JPG, GIF, WEBP, SVG, BMP), and PDF files. For text files, it can read specific line ranges.`, Kind.Read, {
|
|
317966
|
+
super(_ReadFileTool.Name, "ReadFile", `Reads and returns the content of a specified file. If the file is large, the content will be truncated. The tool's response will clearly indicate if truncation has occurred and will provide details on how to read more of the file using the 'offset' and 'limit' parameters. Handles text, images (PNG, JPG, GIF, WEBP, SVG, BMP), audio files (MP3, WAV, AIFF, AAC, OGG, FLAC), and PDF files. For text files, it can read specific line ranges.`, Kind.Read, {
|
|
317888
317967
|
properties: {
|
|
317889
317968
|
file_path: {
|
|
317890
317969
|
description: "The path to the file to read.",
|
|
@@ -352869,6 +352948,208 @@ function delay2(ms, signal) {
|
|
|
352869
352948
|
});
|
|
352870
352949
|
}
|
|
352871
352950
|
|
|
352951
|
+
// packages/core/dist/src/availability/errorClassification.js
|
|
352952
|
+
function classifyFailureKind(error2) {
|
|
352953
|
+
if (error2 instanceof TerminalQuotaError) {
|
|
352954
|
+
return "terminal";
|
|
352955
|
+
}
|
|
352956
|
+
if (error2 instanceof RetryableQuotaError) {
|
|
352957
|
+
return "transient";
|
|
352958
|
+
}
|
|
352959
|
+
if (error2 instanceof ModelNotFoundError) {
|
|
352960
|
+
return "not_found";
|
|
352961
|
+
}
|
|
352962
|
+
return "unknown";
|
|
352963
|
+
}
|
|
352964
|
+
|
|
352965
|
+
// packages/core/dist/src/config/models.js
|
|
352966
|
+
var PREVIEW_GEMINI_MODEL = "gemini-3-pro-preview";
|
|
352967
|
+
var DEFAULT_GEMINI_MODEL = "gemini-2.5-pro";
|
|
352968
|
+
var DEFAULT_GEMINI_FLASH_MODEL = "gemini-2.5-flash";
|
|
352969
|
+
var DEFAULT_GEMINI_FLASH_LITE_MODEL = "gemini-2.5-flash-lite";
|
|
352970
|
+
var DEFAULT_GEMINI_MODEL_AUTO = "auto";
|
|
352971
|
+
var GEMINI_MODEL_ALIAS_PRO = "pro";
|
|
352972
|
+
var GEMINI_MODEL_ALIAS_FLASH = "flash";
|
|
352973
|
+
var GEMINI_MODEL_ALIAS_FLASH_LITE = "flash-lite";
|
|
352974
|
+
var DEFAULT_GEMINI_EMBEDDING_MODEL = "gemini-embedding-001";
|
|
352975
|
+
var DEFAULT_THINKING_MODE = 8192;
|
|
352976
|
+
function resolveModel(requestedModel, previewFeaturesEnabled) {
|
|
352977
|
+
switch (requestedModel) {
|
|
352978
|
+
case DEFAULT_GEMINI_MODEL_AUTO:
|
|
352979
|
+
case GEMINI_MODEL_ALIAS_PRO: {
|
|
352980
|
+
return previewFeaturesEnabled ? PREVIEW_GEMINI_MODEL : DEFAULT_GEMINI_MODEL;
|
|
352981
|
+
}
|
|
352982
|
+
case GEMINI_MODEL_ALIAS_FLASH: {
|
|
352983
|
+
return DEFAULT_GEMINI_FLASH_MODEL;
|
|
352984
|
+
}
|
|
352985
|
+
case GEMINI_MODEL_ALIAS_FLASH_LITE: {
|
|
352986
|
+
return DEFAULT_GEMINI_FLASH_LITE_MODEL;
|
|
352987
|
+
}
|
|
352988
|
+
default: {
|
|
352989
|
+
return requestedModel;
|
|
352990
|
+
}
|
|
352991
|
+
}
|
|
352992
|
+
}
|
|
352993
|
+
function getEffectiveModel(isInFallbackMode, requestedModel, previewFeaturesEnabled) {
|
|
352994
|
+
const resolvedModel = resolveModel(requestedModel, previewFeaturesEnabled);
|
|
352995
|
+
if (!isInFallbackMode) {
|
|
352996
|
+
return resolvedModel;
|
|
352997
|
+
}
|
|
352998
|
+
if (resolvedModel.includes("lite")) {
|
|
352999
|
+
return resolvedModel;
|
|
353000
|
+
}
|
|
353001
|
+
return DEFAULT_GEMINI_FLASH_MODEL;
|
|
353002
|
+
}
|
|
353003
|
+
function isGemini2Model(model) {
|
|
353004
|
+
return /^gemini-2(\.|$)/.test(model);
|
|
353005
|
+
}
|
|
353006
|
+
|
|
353007
|
+
// packages/core/dist/src/availability/policyCatalog.js
|
|
353008
|
+
var DEFAULT_ACTIONS = {
|
|
353009
|
+
terminal: "prompt",
|
|
353010
|
+
transient: "prompt",
|
|
353011
|
+
not_found: "prompt",
|
|
353012
|
+
unknown: "prompt"
|
|
353013
|
+
};
|
|
353014
|
+
var DEFAULT_STATE = {
|
|
353015
|
+
terminal: "terminal",
|
|
353016
|
+
transient: "terminal",
|
|
353017
|
+
not_found: "terminal",
|
|
353018
|
+
unknown: "terminal"
|
|
353019
|
+
};
|
|
353020
|
+
var DEFAULT_CHAIN = [
|
|
353021
|
+
definePolicy({ model: DEFAULT_GEMINI_MODEL }),
|
|
353022
|
+
definePolicy({ model: DEFAULT_GEMINI_FLASH_MODEL, isLastResort: true })
|
|
353023
|
+
];
|
|
353024
|
+
var PREVIEW_CHAIN = [
|
|
353025
|
+
definePolicy({
|
|
353026
|
+
model: PREVIEW_GEMINI_MODEL,
|
|
353027
|
+
stateTransitions: { transient: "sticky_retry" },
|
|
353028
|
+
actions: { transient: "silent" }
|
|
353029
|
+
}),
|
|
353030
|
+
definePolicy({ model: DEFAULT_GEMINI_MODEL }),
|
|
353031
|
+
definePolicy({ model: DEFAULT_GEMINI_FLASH_MODEL, isLastResort: true })
|
|
353032
|
+
];
|
|
353033
|
+
function getModelPolicyChain(options2) {
|
|
353034
|
+
if (options2.previewEnabled) {
|
|
353035
|
+
return cloneChain(PREVIEW_CHAIN);
|
|
353036
|
+
}
|
|
353037
|
+
return cloneChain(DEFAULT_CHAIN);
|
|
353038
|
+
}
|
|
353039
|
+
function createDefaultPolicy(model, options2) {
|
|
353040
|
+
return definePolicy({ model, isLastResort: options2?.isLastResort });
|
|
353041
|
+
}
|
|
353042
|
+
function definePolicy(config3) {
|
|
353043
|
+
return {
|
|
353044
|
+
model: config3.model,
|
|
353045
|
+
isLastResort: config3.isLastResort,
|
|
353046
|
+
actions: { ...DEFAULT_ACTIONS, ...config3.actions ?? {} },
|
|
353047
|
+
stateTransitions: {
|
|
353048
|
+
...DEFAULT_STATE,
|
|
353049
|
+
...config3.stateTransitions ?? {}
|
|
353050
|
+
}
|
|
353051
|
+
};
|
|
353052
|
+
}
|
|
353053
|
+
function clonePolicy(policy) {
|
|
353054
|
+
return {
|
|
353055
|
+
...policy,
|
|
353056
|
+
actions: { ...policy.actions },
|
|
353057
|
+
stateTransitions: { ...policy.stateTransitions }
|
|
353058
|
+
};
|
|
353059
|
+
}
|
|
353060
|
+
function cloneChain(chain2) {
|
|
353061
|
+
return chain2.map(clonePolicy);
|
|
353062
|
+
}
|
|
353063
|
+
|
|
353064
|
+
// packages/core/dist/src/availability/policyHelpers.js
|
|
353065
|
+
function resolvePolicyChain(config3, preferredModel) {
|
|
353066
|
+
const chain2 = getModelPolicyChain({
|
|
353067
|
+
previewEnabled: !!config3.getPreviewFeatures(),
|
|
353068
|
+
userTier: config3.getUserTier()
|
|
353069
|
+
});
|
|
353070
|
+
const activeModel = preferredModel ?? getEffectiveModel(config3.isInFallbackMode(), config3.getModel(), config3.getPreviewFeatures());
|
|
353071
|
+
if (activeModel === "auto") {
|
|
353072
|
+
return [...chain2];
|
|
353073
|
+
}
|
|
353074
|
+
if (chain2.some((policy) => policy.model === activeModel)) {
|
|
353075
|
+
return [...chain2];
|
|
353076
|
+
}
|
|
353077
|
+
return [createDefaultPolicy(activeModel, { isLastResort: true })];
|
|
353078
|
+
}
|
|
353079
|
+
function buildFallbackPolicyContext(chain2, failedModel) {
|
|
353080
|
+
const index = chain2.findIndex((policy) => policy.model === failedModel);
|
|
353081
|
+
if (index === -1) {
|
|
353082
|
+
return { failedPolicy: void 0, candidates: chain2 };
|
|
353083
|
+
}
|
|
353084
|
+
return {
|
|
353085
|
+
failedPolicy: chain2[index],
|
|
353086
|
+
candidates: [...chain2.slice(index + 1), ...chain2.slice(0, index)]
|
|
353087
|
+
};
|
|
353088
|
+
}
|
|
353089
|
+
function resolvePolicyAction(failureKind, policy) {
|
|
353090
|
+
return policy.actions?.[failureKind] ?? "prompt";
|
|
353091
|
+
}
|
|
353092
|
+
function createAvailabilityContextProvider(config3, modelGetter) {
|
|
353093
|
+
return () => {
|
|
353094
|
+
if (!config3.isModelAvailabilityServiceEnabled()) {
|
|
353095
|
+
return void 0;
|
|
353096
|
+
}
|
|
353097
|
+
const service = config3.getModelAvailabilityService();
|
|
353098
|
+
const currentModel = modelGetter();
|
|
353099
|
+
const chain2 = resolvePolicyChain(config3, currentModel);
|
|
353100
|
+
const policy = chain2.find((p) => p.model === currentModel);
|
|
353101
|
+
return policy ? { service, policy } : void 0;
|
|
353102
|
+
};
|
|
353103
|
+
}
|
|
353104
|
+
function selectModelForAvailability(config3, requestedModel) {
|
|
353105
|
+
if (!config3.isModelAvailabilityServiceEnabled()) {
|
|
353106
|
+
return void 0;
|
|
353107
|
+
}
|
|
353108
|
+
const chain2 = resolvePolicyChain(config3, requestedModel);
|
|
353109
|
+
const selection = config3.getModelAvailabilityService().selectFirstAvailable(chain2.map((p) => p.model));
|
|
353110
|
+
if (selection.selectedModel)
|
|
353111
|
+
return selection;
|
|
353112
|
+
const backupModel = chain2.find((p) => p.isLastResort)?.model ?? DEFAULT_GEMINI_MODEL;
|
|
353113
|
+
return { selectedModel: backupModel, skipped: [] };
|
|
353114
|
+
}
|
|
353115
|
+
function applyModelSelection(config3, requestedModel, currentConfig, overrideScope, options2 = {}) {
|
|
353116
|
+
const selection = selectModelForAvailability(config3, requestedModel);
|
|
353117
|
+
if (!selection?.selectedModel) {
|
|
353118
|
+
return { model: requestedModel, config: currentConfig };
|
|
353119
|
+
}
|
|
353120
|
+
const finalModel = selection.selectedModel;
|
|
353121
|
+
let finalConfig = currentConfig;
|
|
353122
|
+
if (finalModel !== requestedModel) {
|
|
353123
|
+
const { generateContentConfig } = config3.modelConfigService.getResolvedConfig({
|
|
353124
|
+
overrideScope,
|
|
353125
|
+
model: finalModel
|
|
353126
|
+
});
|
|
353127
|
+
finalConfig = currentConfig ? { ...currentConfig, ...generateContentConfig } : generateContentConfig;
|
|
353128
|
+
}
|
|
353129
|
+
config3.setActiveModel(finalModel);
|
|
353130
|
+
if (selection.attempts && options2.consumeAttempt !== false) {
|
|
353131
|
+
config3.getModelAvailabilityService().consumeStickyAttempt(finalModel);
|
|
353132
|
+
}
|
|
353133
|
+
return {
|
|
353134
|
+
model: finalModel,
|
|
353135
|
+
config: finalConfig,
|
|
353136
|
+
maxAttempts: selection.attempts
|
|
353137
|
+
};
|
|
353138
|
+
}
|
|
353139
|
+
function applyAvailabilityTransition(getContext, failureKind) {
|
|
353140
|
+
const context2 = getContext?.();
|
|
353141
|
+
if (!context2)
|
|
353142
|
+
return;
|
|
353143
|
+
const transition = context2.policy.stateTransitions?.[failureKind];
|
|
353144
|
+
if (!transition)
|
|
353145
|
+
return;
|
|
353146
|
+
if (transition === "terminal") {
|
|
353147
|
+
context2.service.markTerminal(context2.policy.model, failureKind === "terminal" ? "quota" : "capacity");
|
|
353148
|
+
} else if (transition === "sticky_retry") {
|
|
353149
|
+
context2.service.markRetryOncePerTurn(context2.policy.model);
|
|
353150
|
+
}
|
|
353151
|
+
}
|
|
353152
|
+
|
|
352872
353153
|
// packages/core/dist/src/utils/retry.js
|
|
352873
353154
|
var DEFAULT_RETRY_OPTIONS = {
|
|
352874
353155
|
maxAttempts: 3,
|
|
@@ -352934,7 +353215,7 @@ async function retryWithBackoff(fn, options2) {
|
|
|
352934
353215
|
throw new Error("maxAttempts must be a positive number.");
|
|
352935
353216
|
}
|
|
352936
353217
|
const cleanOptions = options2 ? Object.fromEntries(Object.entries(options2).filter(([_, v]) => v != null)) : {};
|
|
352937
|
-
const { maxAttempts, initialDelayMs, maxDelayMs, onPersistent429, authType, shouldRetryOnError, shouldRetryOnContent, retryFetchErrors, signal } = {
|
|
353218
|
+
const { maxAttempts, initialDelayMs, maxDelayMs, onPersistent429, authType, shouldRetryOnError, shouldRetryOnContent, retryFetchErrors, signal, getAvailabilityContext } = {
|
|
352938
353219
|
...DEFAULT_RETRY_OPTIONS,
|
|
352939
353220
|
shouldRetryOnError: isRetryableError,
|
|
352940
353221
|
...cleanOptions
|
|
@@ -352955,12 +353236,21 @@ async function retryWithBackoff(fn, options2) {
|
|
|
352955
353236
|
currentDelay = Math.min(maxDelayMs, currentDelay * 2);
|
|
352956
353237
|
continue;
|
|
352957
353238
|
}
|
|
353239
|
+
const successContext = getAvailabilityContext?.();
|
|
353240
|
+
if (successContext) {
|
|
353241
|
+
successContext.service.markHealthy(successContext.policy.model);
|
|
353242
|
+
}
|
|
352958
353243
|
return result;
|
|
352959
353244
|
} catch (error2) {
|
|
352960
353245
|
if (error2 instanceof Error && error2.name === "AbortError") {
|
|
352961
353246
|
throw error2;
|
|
352962
353247
|
}
|
|
352963
353248
|
const classifiedError = classifyGoogleError(error2);
|
|
353249
|
+
const failureKind = classifyFailureKind(classifiedError);
|
|
353250
|
+
const appliedImmediate = failureKind === "terminal" || failureKind === "not_found";
|
|
353251
|
+
if (appliedImmediate) {
|
|
353252
|
+
applyAvailabilityTransition(getAvailabilityContext, failureKind);
|
|
353253
|
+
}
|
|
352964
353254
|
const errorCode = getErrorStatus(error2);
|
|
352965
353255
|
if (classifiedError instanceof TerminalQuotaError || classifiedError instanceof ModelNotFoundError) {
|
|
352966
353256
|
if (onPersistent429 && authType === AuthType2.LOGIN_WITH_GOOGLE) {
|
|
@@ -352992,6 +353282,9 @@ async function retryWithBackoff(fn, options2) {
|
|
|
352992
353282
|
console.warn("Model fallback failed:", fallbackError);
|
|
352993
353283
|
}
|
|
352994
353284
|
}
|
|
353285
|
+
if (!appliedImmediate) {
|
|
353286
|
+
applyAvailabilityTransition(getAvailabilityContext, failureKind);
|
|
353287
|
+
}
|
|
352995
353288
|
throw classifiedError instanceof RetryableQuotaError ? classifiedError : error2;
|
|
352996
353289
|
}
|
|
352997
353290
|
if (classifiedError instanceof RetryableQuotaError) {
|
|
@@ -353009,6 +353302,9 @@ async function retryWithBackoff(fn, options2) {
|
|
|
353009
353302
|
}
|
|
353010
353303
|
}
|
|
353011
353304
|
if (attempt >= maxAttempts || !shouldRetryOnError(error2, retryFetchErrors)) {
|
|
353305
|
+
if (!appliedImmediate) {
|
|
353306
|
+
applyAvailabilityTransition(getAvailabilityContext, failureKind);
|
|
353307
|
+
}
|
|
353012
353308
|
throw error2;
|
|
353013
353309
|
}
|
|
353014
353310
|
const errorStatus = getErrorStatus(error2);
|
|
@@ -353131,11 +353427,36 @@ var BaseLlmClient = class {
|
|
|
353131
353427
|
}
|
|
353132
353428
|
async _generateWithRetry(requestParams, promptId, maxAttempts, shouldRetryOnContent, errorContext) {
|
|
353133
353429
|
const abortSignal = requestParams.config?.abortSignal;
|
|
353430
|
+
const getAvailabilityContext = createAvailabilityContextProvider(this.config, () => requestParams.model);
|
|
353431
|
+
const { model, config: newConfig, maxAttempts: availabilityMaxAttempts } = applyModelSelection(this.config, requestParams.model, requestParams.config);
|
|
353432
|
+
requestParams.model = model;
|
|
353433
|
+
if (newConfig) {
|
|
353434
|
+
requestParams.config = newConfig;
|
|
353435
|
+
}
|
|
353436
|
+
if (abortSignal) {
|
|
353437
|
+
requestParams.config = { ...requestParams.config, abortSignal };
|
|
353438
|
+
}
|
|
353134
353439
|
try {
|
|
353135
|
-
const apiCall = () =>
|
|
353440
|
+
const apiCall = () => {
|
|
353441
|
+
if (this.config.isModelAvailabilityServiceEnabled()) {
|
|
353442
|
+
const activeModel = this.config.getActiveModel();
|
|
353443
|
+
if (activeModel !== requestParams.model) {
|
|
353444
|
+
requestParams.model = activeModel;
|
|
353445
|
+
const { generateContentConfig } = this.config.modelConfigService.getResolvedConfig({
|
|
353446
|
+
model: activeModel
|
|
353447
|
+
});
|
|
353448
|
+
requestParams.config = {
|
|
353449
|
+
...requestParams.config,
|
|
353450
|
+
...generateContentConfig
|
|
353451
|
+
};
|
|
353452
|
+
}
|
|
353453
|
+
}
|
|
353454
|
+
return this.contentGenerator.generateContent(requestParams, promptId);
|
|
353455
|
+
};
|
|
353136
353456
|
return await retryWithBackoff(apiCall, {
|
|
353137
353457
|
shouldRetryOnContent,
|
|
353138
|
-
maxAttempts: maxAttempts ?? DEFAULT_MAX_ATTEMPTS
|
|
353458
|
+
maxAttempts: availabilityMaxAttempts ?? maxAttempts ?? DEFAULT_MAX_ATTEMPTS,
|
|
353459
|
+
getAvailabilityContext
|
|
353139
353460
|
});
|
|
353140
353461
|
} catch (error2) {
|
|
353141
353462
|
if (abortSignal?.aborted) {
|
|
@@ -365758,48 +366079,6 @@ My setup is complete. I will provide my first command in the next turn.
|
|
|
365758
366079
|
];
|
|
365759
366080
|
}
|
|
365760
366081
|
|
|
365761
|
-
// packages/core/dist/src/config/models.js
|
|
365762
|
-
var PREVIEW_GEMINI_MODEL = "gemini-3-pro-preview";
|
|
365763
|
-
var DEFAULT_GEMINI_MODEL = "gemini-2.5-pro";
|
|
365764
|
-
var DEFAULT_GEMINI_FLASH_MODEL = "gemini-2.5-flash";
|
|
365765
|
-
var DEFAULT_GEMINI_FLASH_LITE_MODEL = "gemini-2.5-flash-lite";
|
|
365766
|
-
var DEFAULT_GEMINI_MODEL_AUTO = "auto";
|
|
365767
|
-
var GEMINI_MODEL_ALIAS_PRO = "pro";
|
|
365768
|
-
var GEMINI_MODEL_ALIAS_FLASH = "flash";
|
|
365769
|
-
var GEMINI_MODEL_ALIAS_FLASH_LITE = "flash-lite";
|
|
365770
|
-
var DEFAULT_GEMINI_EMBEDDING_MODEL = "gemini-embedding-001";
|
|
365771
|
-
var DEFAULT_THINKING_MODE = 8192;
|
|
365772
|
-
function resolveModel(requestedModel, previewFeaturesEnabled) {
|
|
365773
|
-
switch (requestedModel) {
|
|
365774
|
-
case DEFAULT_GEMINI_MODEL_AUTO:
|
|
365775
|
-
case GEMINI_MODEL_ALIAS_PRO: {
|
|
365776
|
-
return previewFeaturesEnabled ? PREVIEW_GEMINI_MODEL : DEFAULT_GEMINI_MODEL;
|
|
365777
|
-
}
|
|
365778
|
-
case GEMINI_MODEL_ALIAS_FLASH: {
|
|
365779
|
-
return DEFAULT_GEMINI_FLASH_MODEL;
|
|
365780
|
-
}
|
|
365781
|
-
case GEMINI_MODEL_ALIAS_FLASH_LITE: {
|
|
365782
|
-
return DEFAULT_GEMINI_FLASH_LITE_MODEL;
|
|
365783
|
-
}
|
|
365784
|
-
default: {
|
|
365785
|
-
return requestedModel;
|
|
365786
|
-
}
|
|
365787
|
-
}
|
|
365788
|
-
}
|
|
365789
|
-
function getEffectiveModel(isInFallbackMode, requestedModel, previewFeaturesEnabled) {
|
|
365790
|
-
const resolvedModel = resolveModel(requestedModel, previewFeaturesEnabled);
|
|
365791
|
-
if (!isInFallbackMode) {
|
|
365792
|
-
return resolvedModel;
|
|
365793
|
-
}
|
|
365794
|
-
if (resolvedModel.includes("lite")) {
|
|
365795
|
-
return resolvedModel;
|
|
365796
|
-
}
|
|
365797
|
-
return DEFAULT_GEMINI_FLASH_MODEL;
|
|
365798
|
-
}
|
|
365799
|
-
function isGemini2Model(model) {
|
|
365800
|
-
return /^gemini-2(\.|$)/.test(model);
|
|
365801
|
-
}
|
|
365802
|
-
|
|
365803
366082
|
// packages/core/dist/src/utils/generateContentResponseUtilities.js
|
|
365804
366083
|
function getResponseTextFromParts(parts2) {
|
|
365805
366084
|
if (!parts2) {
|
|
@@ -367451,9 +367730,6 @@ var ChatRecordingService = class {
|
|
|
367451
367730
|
}
|
|
367452
367731
|
};
|
|
367453
367732
|
|
|
367454
|
-
// packages/core/dist/src/fallback/handler.js
|
|
367455
|
-
init_events();
|
|
367456
|
-
|
|
367457
367733
|
// packages/core/dist/src/utils/secure-browser-launcher.js
|
|
367458
367734
|
import { execFile as execFile6 } from "node:child_process";
|
|
367459
367735
|
import { promisify as promisify13 } from "node:util";
|
|
@@ -367539,89 +367815,8 @@ async function openBrowserSecurely(url5) {
|
|
|
367539
367815
|
}
|
|
367540
367816
|
}
|
|
367541
367817
|
|
|
367542
|
-
// packages/core/dist/src/availability/policyCatalog.js
|
|
367543
|
-
var DEFAULT_ACTIONS = {
|
|
367544
|
-
terminal: "prompt",
|
|
367545
|
-
transient: "prompt",
|
|
367546
|
-
not_found: "prompt",
|
|
367547
|
-
unknown: "prompt"
|
|
367548
|
-
};
|
|
367549
|
-
var DEFAULT_STATE = {
|
|
367550
|
-
terminal: "terminal",
|
|
367551
|
-
transient: "terminal",
|
|
367552
|
-
not_found: "terminal",
|
|
367553
|
-
unknown: "terminal"
|
|
367554
|
-
};
|
|
367555
|
-
var DEFAULT_CHAIN = [
|
|
367556
|
-
definePolicy({ model: DEFAULT_GEMINI_MODEL }),
|
|
367557
|
-
definePolicy({ model: DEFAULT_GEMINI_FLASH_MODEL, isLastResort: true })
|
|
367558
|
-
];
|
|
367559
|
-
var PREVIEW_CHAIN = [
|
|
367560
|
-
definePolicy({
|
|
367561
|
-
model: PREVIEW_GEMINI_MODEL,
|
|
367562
|
-
stateTransitions: { transient: "sticky_retry" }
|
|
367563
|
-
}),
|
|
367564
|
-
definePolicy({ model: DEFAULT_GEMINI_MODEL }),
|
|
367565
|
-
definePolicy({ model: DEFAULT_GEMINI_FLASH_MODEL, isLastResort: true })
|
|
367566
|
-
];
|
|
367567
|
-
function getModelPolicyChain(options2) {
|
|
367568
|
-
if (options2.previewEnabled) {
|
|
367569
|
-
return cloneChain(PREVIEW_CHAIN);
|
|
367570
|
-
}
|
|
367571
|
-
return cloneChain(DEFAULT_CHAIN);
|
|
367572
|
-
}
|
|
367573
|
-
function createDefaultPolicy(model, options2) {
|
|
367574
|
-
return definePolicy({ model, isLastResort: options2?.isLastResort });
|
|
367575
|
-
}
|
|
367576
|
-
function definePolicy(config3) {
|
|
367577
|
-
return {
|
|
367578
|
-
model: config3.model,
|
|
367579
|
-
isLastResort: config3.isLastResort,
|
|
367580
|
-
actions: { ...DEFAULT_ACTIONS, ...config3.actions ?? {} },
|
|
367581
|
-
stateTransitions: {
|
|
367582
|
-
...DEFAULT_STATE,
|
|
367583
|
-
...config3.stateTransitions ?? {}
|
|
367584
|
-
}
|
|
367585
|
-
};
|
|
367586
|
-
}
|
|
367587
|
-
function clonePolicy(policy) {
|
|
367588
|
-
return {
|
|
367589
|
-
...policy,
|
|
367590
|
-
actions: { ...policy.actions },
|
|
367591
|
-
stateTransitions: { ...policy.stateTransitions }
|
|
367592
|
-
};
|
|
367593
|
-
}
|
|
367594
|
-
function cloneChain(chain2) {
|
|
367595
|
-
return chain2.map(clonePolicy);
|
|
367596
|
-
}
|
|
367597
|
-
|
|
367598
|
-
// packages/core/dist/src/availability/policyHelpers.js
|
|
367599
|
-
function resolvePolicyChain(config3) {
|
|
367600
|
-
const chain2 = getModelPolicyChain({
|
|
367601
|
-
previewEnabled: !!config3.getPreviewFeatures(),
|
|
367602
|
-
userTier: config3.getUserTier()
|
|
367603
|
-
});
|
|
367604
|
-
const activeModel = getEffectiveModel(config3.isInFallbackMode(), config3.getModel(), config3.getPreviewFeatures());
|
|
367605
|
-
if (chain2.some((policy) => policy.model === activeModel)) {
|
|
367606
|
-
return chain2;
|
|
367607
|
-
}
|
|
367608
|
-
return [createDefaultPolicy(activeModel, { isLastResort: true })];
|
|
367609
|
-
}
|
|
367610
|
-
function buildFallbackPolicyContext(chain2, failedModel) {
|
|
367611
|
-
const index = chain2.findIndex((policy) => policy.model === failedModel);
|
|
367612
|
-
if (index === -1) {
|
|
367613
|
-
return { failedPolicy: void 0, candidates: chain2 };
|
|
367614
|
-
}
|
|
367615
|
-
return {
|
|
367616
|
-
failedPolicy: chain2[index],
|
|
367617
|
-
candidates: [...chain2.slice(index + 1), ...chain2.slice(0, index)]
|
|
367618
|
-
};
|
|
367619
|
-
}
|
|
367620
|
-
function resolvePolicyAction(failureKind, policy) {
|
|
367621
|
-
return policy.actions?.[failureKind] ?? "prompt";
|
|
367622
|
-
}
|
|
367623
|
-
|
|
367624
367818
|
// packages/core/dist/src/fallback/handler.js
|
|
367819
|
+
init_events();
|
|
367625
367820
|
var UPGRADE_URL_PAGE = "https://goo.gle/set-up-gemini-code-assist";
|
|
367626
367821
|
async function handleFallback(config3, failedModel, authType, error2) {
|
|
367627
367822
|
if (config3.isModelAvailabilityServiceEnabled()) {
|
|
@@ -367660,6 +367855,7 @@ async function handlePolicyDrivenFallback(config3, failedModel, authType, error2
|
|
|
367660
367855
|
}
|
|
367661
367856
|
const chain2 = resolvePolicyChain(config3);
|
|
367662
367857
|
const { failedPolicy, candidates } = buildFallbackPolicyContext(chain2, failedModel);
|
|
367858
|
+
const failureKind = classifyFailureKind(error2);
|
|
367663
367859
|
if (!candidates.length) {
|
|
367664
367860
|
return null;
|
|
367665
367861
|
}
|
|
@@ -367671,7 +367867,6 @@ async function handlePolicyDrivenFallback(config3, failedModel, authType, error2
|
|
|
367671
367867
|
if (!fallbackModel || fallbackModel === failedModel || !selectedPolicy) {
|
|
367672
367868
|
return null;
|
|
367673
367869
|
}
|
|
367674
|
-
const failureKind = classifyFailureKind(error2);
|
|
367675
367870
|
const action = resolvePolicyAction(failureKind, selectedPolicy);
|
|
367676
367871
|
if (action === "silent") {
|
|
367677
367872
|
return processIntent(config3, "retry_always", failedModel, fallbackModel, authType, error2);
|
|
@@ -367691,7 +367886,7 @@ async function handlePolicyDrivenFallback(config3, failedModel, authType, error2
|
|
|
367691
367886
|
}
|
|
367692
367887
|
try {
|
|
367693
367888
|
const intent = await handler(failedModel, fallbackModel, error2);
|
|
367694
|
-
return await processIntent(config3, intent, failedModel, fallbackModel, authType);
|
|
367889
|
+
return await processIntent(config3, intent, failedModel, fallbackModel, authType, error2);
|
|
367695
367890
|
} catch (handlerError) {
|
|
367696
367891
|
debugLogger.error("Fallback handler failed:", handlerError);
|
|
367697
367892
|
return null;
|
|
@@ -367705,18 +367900,30 @@ async function handleUpgrade() {
|
|
|
367705
367900
|
}
|
|
367706
367901
|
}
|
|
367707
367902
|
async function processIntent(config3, intent, failedModel, fallbackModel, authType, error2) {
|
|
367903
|
+
const isAvailabilityEnabled = config3.isModelAvailabilityServiceEnabled();
|
|
367708
367904
|
switch (intent) {
|
|
367709
367905
|
case "retry_always":
|
|
367710
|
-
if (
|
|
367711
|
-
|
|
367906
|
+
if (isAvailabilityEnabled) {
|
|
367907
|
+
config3.setActiveModel(fallbackModel);
|
|
367712
367908
|
} else {
|
|
367713
|
-
|
|
367909
|
+
if (failedModel === PREVIEW_GEMINI_MODEL && !(error2 instanceof TerminalQuotaError)) {
|
|
367910
|
+
activatePreviewModelFallbackMode(config3);
|
|
367911
|
+
} else {
|
|
367912
|
+
activateFallbackMode(config3, authType);
|
|
367913
|
+
}
|
|
367714
367914
|
}
|
|
367715
367915
|
return true;
|
|
367716
367916
|
case "retry_once":
|
|
367917
|
+
if (isAvailabilityEnabled) {
|
|
367918
|
+
config3.setActiveModel(fallbackModel);
|
|
367919
|
+
}
|
|
367717
367920
|
return true;
|
|
367718
367921
|
case "stop":
|
|
367719
|
-
|
|
367922
|
+
if (isAvailabilityEnabled) {
|
|
367923
|
+
config3.setActiveModel(fallbackModel);
|
|
367924
|
+
} else {
|
|
367925
|
+
activateFallbackMode(config3, authType);
|
|
367926
|
+
}
|
|
367720
367927
|
return false;
|
|
367721
367928
|
case "retry_later":
|
|
367722
367929
|
return false;
|
|
@@ -367741,18 +367948,6 @@ function activatePreviewModelFallbackMode(config3) {
|
|
|
367741
367948
|
config3.setPreviewModelFallbackMode(true);
|
|
367742
367949
|
}
|
|
367743
367950
|
}
|
|
367744
|
-
function classifyFailureKind(error2) {
|
|
367745
|
-
if (error2 instanceof TerminalQuotaError) {
|
|
367746
|
-
return "terminal";
|
|
367747
|
-
}
|
|
367748
|
-
if (error2 instanceof RetryableQuotaError) {
|
|
367749
|
-
return "transient";
|
|
367750
|
-
}
|
|
367751
|
-
if (error2 instanceof ModelNotFoundError) {
|
|
367752
|
-
return "not_found";
|
|
367753
|
-
}
|
|
367754
|
-
return "unknown";
|
|
367755
|
-
}
|
|
367756
367951
|
|
|
367757
367952
|
// packages/core/dist/src/core/geminiRequest.js
|
|
367758
367953
|
function partListUnionToString(value) {
|
|
@@ -368103,19 +368298,45 @@ var GeminiChat = class {
|
|
|
368103
368298
|
return streamWithRetries.call(this);
|
|
368104
368299
|
}
|
|
368105
368300
|
async makeApiCallAndProcessStream(model, generateContentConfig, requestContents, prompt_id) {
|
|
368106
|
-
let effectiveModel = model;
|
|
368107
368301
|
const contentsForPreviewModel = this.ensureActiveLoopHasThoughtSignatures(requestContents);
|
|
368108
|
-
|
|
368109
|
-
|
|
368302
|
+
const { model: availabilityFinalModel, config: newAvailabilityConfig, maxAttempts: availabilityMaxAttempts } = applyModelSelection(this.config, model, generateContentConfig);
|
|
368303
|
+
const abortSignal = generateContentConfig.abortSignal;
|
|
368304
|
+
let lastModelToUse = availabilityFinalModel;
|
|
368305
|
+
let currentGenerateContentConfig = newAvailabilityConfig ?? generateContentConfig;
|
|
368306
|
+
if (abortSignal) {
|
|
368307
|
+
currentGenerateContentConfig = {
|
|
368308
|
+
...currentGenerateContentConfig,
|
|
368309
|
+
abortSignal
|
|
368310
|
+
};
|
|
368311
|
+
}
|
|
368312
|
+
let lastConfig = currentGenerateContentConfig;
|
|
368110
368313
|
let lastContentsToUse = requestContents;
|
|
368314
|
+
const getAvailabilityContext = createAvailabilityContextProvider(this.config, () => lastModelToUse);
|
|
368111
368315
|
const apiCall = async () => {
|
|
368112
|
-
let modelToUse
|
|
368113
|
-
if (this.config.
|
|
368114
|
-
modelToUse =
|
|
368316
|
+
let modelToUse;
|
|
368317
|
+
if (this.config.isModelAvailabilityServiceEnabled()) {
|
|
368318
|
+
modelToUse = this.config.getActiveModel();
|
|
368319
|
+
if (modelToUse !== lastModelToUse) {
|
|
368320
|
+
const { generateContentConfig: newConfig } = this.config.modelConfigService.getResolvedConfig({
|
|
368321
|
+
model: modelToUse
|
|
368322
|
+
});
|
|
368323
|
+
currentGenerateContentConfig = {
|
|
368324
|
+
...currentGenerateContentConfig,
|
|
368325
|
+
...newConfig
|
|
368326
|
+
};
|
|
368327
|
+
if (abortSignal) {
|
|
368328
|
+
currentGenerateContentConfig.abortSignal = abortSignal;
|
|
368329
|
+
}
|
|
368330
|
+
}
|
|
368331
|
+
} else {
|
|
368332
|
+
modelToUse = getEffectiveModel(this.config.isInFallbackMode(), model, this.config.getPreviewFeatures());
|
|
368333
|
+
if (this.config.isPreviewModelBypassMode() && modelToUse === PREVIEW_GEMINI_MODEL) {
|
|
368334
|
+
modelToUse = DEFAULT_GEMINI_MODEL;
|
|
368335
|
+
}
|
|
368115
368336
|
}
|
|
368116
|
-
|
|
368337
|
+
lastModelToUse = modelToUse;
|
|
368117
368338
|
const config3 = {
|
|
368118
|
-
...
|
|
368339
|
+
...currentGenerateContentConfig,
|
|
368119
368340
|
// TODO(12622): Ensure we don't overrwrite these when they are
|
|
368120
368341
|
// passed via config.
|
|
368121
368342
|
systemInstruction: this.systemInstruction,
|
|
@@ -368180,20 +368401,21 @@ var GeminiChat = class {
|
|
|
368180
368401
|
config: config3
|
|
368181
368402
|
}, prompt_id);
|
|
368182
368403
|
};
|
|
368183
|
-
const onPersistent429Callback = async (authType, error2) => handleFallback(this.config,
|
|
368404
|
+
const onPersistent429Callback = async (authType, error2) => handleFallback(this.config, lastModelToUse, authType, error2);
|
|
368184
368405
|
const streamResponse = await retryWithBackoff(apiCall, {
|
|
368185
368406
|
onPersistent429: onPersistent429Callback,
|
|
368186
368407
|
authType: this.config.getContentGeneratorConfig()?.authType,
|
|
368187
368408
|
retryFetchErrors: this.config.getRetryFetchErrors(),
|
|
368188
368409
|
signal: generateContentConfig.abortSignal,
|
|
368189
|
-
maxAttempts: this.config.isPreviewModelFallbackMode() && model === PREVIEW_GEMINI_MODEL ? 1 : void 0
|
|
368410
|
+
maxAttempts: availabilityMaxAttempts ?? (this.config.isPreviewModelFallbackMode() && model === PREVIEW_GEMINI_MODEL ? 1 : void 0),
|
|
368411
|
+
getAvailabilityContext
|
|
368190
368412
|
});
|
|
368191
368413
|
const originalRequest = {
|
|
368192
368414
|
model: lastModelToUse,
|
|
368193
368415
|
config: lastConfig,
|
|
368194
368416
|
contents: lastContentsToUse
|
|
368195
368417
|
};
|
|
368196
|
-
return this.processStreamResponse(
|
|
368418
|
+
return this.processStreamResponse(lastModelToUse, streamResponse, originalRequest);
|
|
368197
368419
|
}
|
|
368198
368420
|
/**
|
|
368199
368421
|
* Returns the chat history.
|
|
@@ -370129,6 +370351,9 @@ var GeminiClient = class {
|
|
|
370129
370351
|
return getEffectiveModel(this.config.isInFallbackMode(), configModel, this.config.getPreviewFeatures());
|
|
370130
370352
|
}
|
|
370131
370353
|
async *sendMessageStream(request3, signal, prompt_id, turns = MAX_TURNS, isInvalidStreamRetry = false) {
|
|
370354
|
+
if (!isInvalidStreamRetry) {
|
|
370355
|
+
this.config.resetTurn();
|
|
370356
|
+
}
|
|
370132
370357
|
const hooksEnabled = this.config.getEnableHooks();
|
|
370133
370358
|
const messageBus = this.config.getMessageBus();
|
|
370134
370359
|
if (hooksEnabled && messageBus) {
|
|
@@ -370213,9 +370438,11 @@ var GeminiClient = class {
|
|
|
370213
370438
|
const router = await this.config.getModelRouterService();
|
|
370214
370439
|
const decision = await router.route(routingContext);
|
|
370215
370440
|
modelToUse = decision.model;
|
|
370216
|
-
this.currentSequenceModel = modelToUse;
|
|
370217
|
-
yield { type: GeminiEventType.ModelInfo, value: modelToUse };
|
|
370218
370441
|
}
|
|
370442
|
+
const { model: finalModel } = applyModelSelection(this.config, modelToUse, void 0, void 0, { consumeAttempt: false });
|
|
370443
|
+
modelToUse = finalModel;
|
|
370444
|
+
this.currentSequenceModel = modelToUse;
|
|
370445
|
+
yield { type: GeminiEventType.ModelInfo, value: modelToUse };
|
|
370219
370446
|
const resultStream = turn.run({ model: modelToUse }, request3, linkedSignal);
|
|
370220
370447
|
for await (const event of resultStream) {
|
|
370221
370448
|
if (this.loopDetector.addAndCheck(event)) {
|
|
@@ -370280,10 +370507,29 @@ var GeminiClient = class {
|
|
|
370280
370507
|
try {
|
|
370281
370508
|
const userMemory = this.config.getUserMemory();
|
|
370282
370509
|
const systemInstruction = getCoreSystemPrompt(this.config, userMemory);
|
|
370510
|
+
const { model, config: newConfig, maxAttempts: availabilityMaxAttempts } = applyModelSelection(this.config, currentAttemptModel, currentAttemptGenerateContentConfig, modelConfigKey.overrideScope);
|
|
370511
|
+
currentAttemptModel = model;
|
|
370512
|
+
if (newConfig) {
|
|
370513
|
+
currentAttemptGenerateContentConfig = newConfig;
|
|
370514
|
+
}
|
|
370515
|
+
const getAvailabilityContext = createAvailabilityContextProvider(this.config, () => currentAttemptModel);
|
|
370283
370516
|
const apiCall = () => {
|
|
370284
|
-
|
|
370285
|
-
|
|
370286
|
-
|
|
370517
|
+
let modelConfigToUse = desiredModelConfig;
|
|
370518
|
+
if (!this.config.isModelAvailabilityServiceEnabled()) {
|
|
370519
|
+
modelConfigToUse = this.config.isInFallbackMode() ? fallbackModelConfig : desiredModelConfig;
|
|
370520
|
+
currentAttemptModel = modelConfigToUse.model;
|
|
370521
|
+
currentAttemptGenerateContentConfig = modelConfigToUse.generateContentConfig;
|
|
370522
|
+
} else {
|
|
370523
|
+
const active = this.config.getActiveModel();
|
|
370524
|
+
if (active !== currentAttemptModel) {
|
|
370525
|
+
currentAttemptModel = active;
|
|
370526
|
+
const newConfig2 = this.config.modelConfigService.getResolvedConfig({
|
|
370527
|
+
...modelConfigKey,
|
|
370528
|
+
model: currentAttemptModel
|
|
370529
|
+
});
|
|
370530
|
+
currentAttemptGenerateContentConfig = newConfig2.generateContentConfig;
|
|
370531
|
+
}
|
|
370532
|
+
}
|
|
370287
370533
|
const requestConfig = {
|
|
370288
370534
|
...currentAttemptGenerateContentConfig,
|
|
370289
370535
|
abortSignal,
|
|
@@ -370301,7 +370547,9 @@ var GeminiClient = class {
|
|
|
370301
370547
|
);
|
|
370302
370548
|
const result = await retryWithBackoff(apiCall, {
|
|
370303
370549
|
onPersistent429: onPersistent429Callback,
|
|
370304
|
-
authType: this.config.getContentGeneratorConfig()?.authType
|
|
370550
|
+
authType: this.config.getContentGeneratorConfig()?.authType,
|
|
370551
|
+
maxAttempts: availabilityMaxAttempts,
|
|
370552
|
+
getAvailabilityContext
|
|
370305
370553
|
});
|
|
370306
370554
|
return result;
|
|
370307
370555
|
} catch (error2) {
|
|
@@ -381789,7 +382037,7 @@ async function getClientMetadata() {
|
|
|
381789
382037
|
clientMetadataPromise = (async () => ({
|
|
381790
382038
|
ideName: "IDE_UNSPECIFIED",
|
|
381791
382039
|
pluginType: "GEMINI",
|
|
381792
|
-
ideVersion: "0.21.0-nightly.
|
|
382040
|
+
ideVersion: "0.21.0-nightly.20251209.ec9a8c7a7",
|
|
381793
382041
|
platform: getPlatform(),
|
|
381794
382042
|
updateChannel: await getReleaseChannel(__dirname5)
|
|
381795
382043
|
}))();
|
|
@@ -384752,6 +385000,7 @@ var Config = class {
|
|
|
384752
385000
|
folderTrust;
|
|
384753
385001
|
ideMode;
|
|
384754
385002
|
inFallbackMode = false;
|
|
385003
|
+
_activeModel;
|
|
384755
385004
|
maxSessionTurns;
|
|
384756
385005
|
listSessions;
|
|
384757
385006
|
deleteSession;
|
|
@@ -384859,6 +385108,7 @@ var Config = class {
|
|
|
384859
385108
|
this.fileDiscoveryService = params.fileDiscoveryService ?? null;
|
|
384860
385109
|
this.bugCommand = params.bugCommand;
|
|
384861
385110
|
this.model = params.model;
|
|
385111
|
+
this._activeModel = params.model;
|
|
384862
385112
|
this.enableModelAvailabilityService = params.enableModelAvailabilityService ?? false;
|
|
384863
385113
|
this.enableAgents = params.enableAgents ?? false;
|
|
384864
385114
|
this.experimentalJitContext = params.experimentalJitContext ?? false;
|
|
@@ -385068,10 +385318,23 @@ var Config = class {
|
|
|
385068
385318
|
setModel(newModel) {
|
|
385069
385319
|
if (this.model !== newModel || this.inFallbackMode) {
|
|
385070
385320
|
this.model = newModel;
|
|
385321
|
+
this._activeModel = newModel;
|
|
385071
385322
|
coreEvents.emitModelChanged(newModel);
|
|
385072
385323
|
}
|
|
385073
385324
|
this.setFallbackMode(false);
|
|
385074
385325
|
}
|
|
385326
|
+
getActiveModel() {
|
|
385327
|
+
return this._activeModel ?? this.model;
|
|
385328
|
+
}
|
|
385329
|
+
setActiveModel(model) {
|
|
385330
|
+
if (this._activeModel !== model) {
|
|
385331
|
+
this._activeModel = model;
|
|
385332
|
+
coreEvents.emitModelChanged(model);
|
|
385333
|
+
}
|
|
385334
|
+
}
|
|
385335
|
+
resetTurn() {
|
|
385336
|
+
this.modelAvailabilityService.resetTurn();
|
|
385337
|
+
}
|
|
385075
385338
|
isInFallbackMode() {
|
|
385076
385339
|
return this.inFallbackMode;
|
|
385077
385340
|
}
|
|
@@ -386430,6 +386693,8 @@ var Task = class _Task {
|
|
|
386430
386693
|
completedToolCalls;
|
|
386431
386694
|
skipFinalTrueAfterInlineEdit = false;
|
|
386432
386695
|
modelInfo;
|
|
386696
|
+
currentPromptId;
|
|
386697
|
+
promptCount = 0;
|
|
386433
386698
|
// For tool waiting logic
|
|
386434
386699
|
pendingToolCalls = /* @__PURE__ */ new Map();
|
|
386435
386700
|
//toolCallId --> status
|
|
@@ -387031,8 +387296,7 @@ var Task = class _Task {
|
|
|
387031
387296
|
yield* this.geminiClient.sendMessageStream(
|
|
387032
387297
|
llmParts,
|
|
387033
387298
|
aborted3,
|
|
387034
|
-
|
|
387035
|
-
""
|
|
387299
|
+
completedToolCalls[0]?.request.prompt_id ?? ""
|
|
387036
387300
|
);
|
|
387037
387301
|
}
|
|
387038
387302
|
async *acceptUserMessage(requestContext, aborted3) {
|
|
@@ -387052,6 +387316,7 @@ var Task = class _Task {
|
|
|
387052
387316
|
}
|
|
387053
387317
|
}
|
|
387054
387318
|
if (hasContentForLlm) {
|
|
387319
|
+
this.currentPromptId = this.config.getSessionId() + "########" + this.promptCount++;
|
|
387055
387320
|
logger.info("[Task] Sending new parts to LLM.");
|
|
387056
387321
|
const stateChange = {
|
|
387057
387322
|
kind: "state-change" /* StateChangeEvent */
|
|
@@ -387060,8 +387325,7 @@ var Task = class _Task {
|
|
|
387060
387325
|
yield* this.geminiClient.sendMessageStream(
|
|
387061
387326
|
llmParts,
|
|
387062
387327
|
aborted3,
|
|
387063
|
-
|
|
387064
|
-
""
|
|
387328
|
+
this.currentPromptId
|
|
387065
387329
|
);
|
|
387066
387330
|
} else if (anyConfirmationHandled) {
|
|
387067
387331
|
logger.info(
|