@google/gemini-cli-a2a-server 0.19.0-nightly.20251121.5982abeff → 0.19.0-nightly.20251123.dadd606c0

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.
@@ -303410,6 +303410,11 @@ var FatalAuthenticationError = class extends FatalError {
303410
303410
  super(message, 41);
303411
303411
  }
303412
303412
  };
303413
+ var FatalCancellationError = class extends FatalError {
303414
+ constructor(message) {
303415
+ super(message, 130);
303416
+ }
303417
+ };
303413
303418
  var ForbiddenError = class extends Error {
303414
303419
  };
303415
303420
  var UnauthorizedError = class extends Error {
@@ -304155,7 +304160,63 @@ init_base_token_storage();
304155
304160
  var DEFAULT_SERVICE_NAME = "gemini-cli-oauth";
304156
304161
  var FORCE_ENCRYPTED_FILE_ENV_VAR = "GEMINI_FORCE_ENCRYPTED_FILE_STORAGE";
304157
304162
 
304163
+ // packages/core/dist/src/utils/stdio.js
304164
+ init_events();
304165
+ var originalStdoutWrite = process.stdout.write.bind(process.stdout);
304166
+ var originalStderrWrite = process.stderr.write.bind(process.stderr);
304167
+ function writeToStdout(...args2) {
304168
+ return originalStdoutWrite(...args2);
304169
+ }
304170
+ function writeToStderr(...args2) {
304171
+ return originalStderrWrite(...args2);
304172
+ }
304173
+ function createInkStdio() {
304174
+ const inkStdout = new Proxy(process.stdout, {
304175
+ get(target, prop, receiver) {
304176
+ if (prop === "write") {
304177
+ return writeToStdout;
304178
+ }
304179
+ const value = Reflect.get(target, prop, receiver);
304180
+ if (typeof value === "function") {
304181
+ return value.bind(target);
304182
+ }
304183
+ return value;
304184
+ }
304185
+ });
304186
+ const inkStderr = new Proxy(process.stderr, {
304187
+ get(target, prop, receiver) {
304188
+ if (prop === "write") {
304189
+ return writeToStderr;
304190
+ }
304191
+ const value = Reflect.get(target, prop, receiver);
304192
+ if (typeof value === "function") {
304193
+ return value.bind(target);
304194
+ }
304195
+ return value;
304196
+ }
304197
+ });
304198
+ return { stdout: inkStdout, stderr: inkStderr };
304199
+ }
304200
+
304201
+ // packages/core/dist/src/utils/terminal.js
304202
+ function disableMouseEvents() {
304203
+ writeToStdout("\x1B[?1006l\x1B[?1002l");
304204
+ }
304205
+ function disableKittyKeyboardProtocol() {
304206
+ writeToStdout("\x1B[<u");
304207
+ }
304208
+ function enableLineWrapping() {
304209
+ writeToStdout("\x1B[?7h");
304210
+ }
304211
+ function enterAlternateScreen() {
304212
+ writeToStdout("\x1B[?1049h");
304213
+ }
304214
+ function exitAlternateScreen() {
304215
+ writeToStdout("\x1B[?1049l");
304216
+ }
304217
+
304158
304218
  // packages/core/dist/src/code_assist/oauth2.js
304219
+ init_events();
304159
304220
  var userAccountManager = new UserAccountManager();
304160
304221
  var OAUTH_CLIENT_ID = "681255809395-oo8ft2oprdrnp9e3aqf6av3hmdib135j.apps.googleusercontent.com";
304161
304222
  var OAUTH_CLIENT_SECRET = "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";
@@ -304246,18 +304307,31 @@ async function initOauthClient(authType, config2) {
304246
304307
  if (config2.isBrowserLaunchSuppressed()) {
304247
304308
  let success = false;
304248
304309
  const maxRetries = 2;
304249
- for (let i4 = 0; !success && i4 < maxRetries; i4++) {
304250
- success = await authWithUserCode(client);
304251
- if (!success) {
304252
- debugLogger.error("\nFailed to authenticate with user code.", i4 === maxRetries - 1 ? "" : "Retrying...\n");
304310
+ enterAlternateScreen();
304311
+ writeToStdout("\x1B[2J\x1B[H");
304312
+ disableMouseEvents();
304313
+ disableKittyKeyboardProtocol();
304314
+ enableLineWrapping();
304315
+ try {
304316
+ for (let i4 = 0; !success && i4 < maxRetries; i4++) {
304317
+ success = await authWithUserCode(client);
304318
+ if (!success) {
304319
+ writeToStderr("\nFailed to authenticate with user code." + (i4 === maxRetries - 1 ? "" : " Retrying...\n"));
304320
+ }
304253
304321
  }
304322
+ } finally {
304323
+ exitAlternateScreen();
304324
+ coreEvents.emit(CoreEvent.ExternalEditorClosed);
304254
304325
  }
304255
304326
  if (!success) {
304327
+ writeToStderr("Failed to authenticate with user code.\n");
304256
304328
  throw new FatalAuthenticationError("Failed to authenticate with user code.");
304257
304329
  }
304258
304330
  } else {
304259
304331
  const webLogin = await authWithWeb(client);
304260
- debugLogger.log(`
304332
+ coreEvents.emit(CoreEvent.UserFeedback, {
304333
+ severity: "info",
304334
+ message: `
304261
304335
 
304262
304336
  Code Assist login required.
304263
304337
  Attempting to open authentication page in your browser.
@@ -304265,19 +304339,30 @@ Otherwise navigate to:
304265
304339
 
304266
304340
  ${webLogin.authUrl}
304267
304341
 
304268
- `);
304342
+
304343
+ `
304344
+ });
304269
304345
  try {
304270
304346
  const childProcess2 = await open_default(webLogin.authUrl);
304271
304347
  childProcess2.on("error", (error) => {
304272
- debugLogger.error(`Failed to open browser with error:`, getErrorMessage(error), `
304273
- Please try running again with NO_BROWSER=true set.`);
304348
+ coreEvents.emit(CoreEvent.UserFeedback, {
304349
+ severity: "error",
304350
+ message: `Failed to open browser with error: ${getErrorMessage(error)}
304351
+ Please try running again with NO_BROWSER=true set.`
304352
+ });
304274
304353
  });
304275
304354
  } catch (err2) {
304276
- debugLogger.error(`Failed to open browser with error:`, getErrorMessage(err2), `
304277
- Please try running again with NO_BROWSER=true set.`);
304355
+ coreEvents.emit(CoreEvent.UserFeedback, {
304356
+ severity: "error",
304357
+ message: `Failed to open browser with error: ${getErrorMessage(err2)}
304358
+ Please try running again with NO_BROWSER=true set.`
304359
+ });
304278
304360
  throw new FatalAuthenticationError(`Failed to open browser: ${getErrorMessage(err2)}`);
304279
304361
  }
304280
- debugLogger.log("Waiting for authentication...");
304362
+ coreEvents.emit(CoreEvent.UserFeedback, {
304363
+ severity: "info",
304364
+ message: "Waiting for authentication...\n"
304365
+ });
304281
304366
  const authTimeout = 5 * 60 * 1e3;
304282
304367
  const timeoutPromise = new Promise((_, reject) => {
304283
304368
  setTimeout(() => {
@@ -304285,6 +304370,10 @@ Please try running again with NO_BROWSER=true set.`);
304285
304370
  }, authTimeout);
304286
304371
  });
304287
304372
  await Promise.race([webLogin.loginCompletePromise, timeoutPromise]);
304373
+ coreEvents.emit(CoreEvent.UserFeedback, {
304374
+ severity: "info",
304375
+ message: "Authentication succeeded\n"
304376
+ });
304288
304377
  }
304289
304378
  return client;
304290
304379
  }
@@ -304295,47 +304384,56 @@ async function getOauthClient(authType, config2) {
304295
304384
  return oauthClientPromises.get(authType);
304296
304385
  }
304297
304386
  async function authWithUserCode(client) {
304298
- const redirectUri = "https://codeassist.google.com/authcode";
304299
- const codeVerifier = await client.generateCodeVerifierAsync();
304300
- const state = crypto13.randomBytes(32).toString("hex");
304301
- const authUrl = client.generateAuthUrl({
304302
- redirect_uri: redirectUri,
304303
- access_type: "offline",
304304
- scope: OAUTH_SCOPE,
304305
- code_challenge_method: import_google_auth_library8.CodeChallengeMethod.S256,
304306
- code_challenge: codeVerifier.codeChallenge,
304307
- state
304308
- });
304309
- debugLogger.log("Please visit the following URL to authorize the application:");
304310
- debugLogger.log("");
304311
- debugLogger.log(authUrl);
304312
- debugLogger.log("");
304313
- const code2 = await new Promise((resolve14) => {
304314
- const rl = readline.createInterface({
304315
- input: process.stdin,
304316
- output: process.stdout
304317
- });
304318
- rl.question("Enter the authorization code: ", (code3) => {
304319
- rl.close();
304320
- resolve14(code3.trim());
304321
- });
304322
- });
304323
- if (!code2) {
304324
- debugLogger.error("Authorization code is required.");
304325
- return false;
304326
- }
304327
304387
  try {
304328
- const { tokens } = await client.getToken({
304329
- code: code2,
304330
- codeVerifier: codeVerifier.codeVerifier,
304331
- redirect_uri: redirectUri
304388
+ const redirectUri = "https://codeassist.google.com/authcode";
304389
+ const codeVerifier = await client.generateCodeVerifierAsync();
304390
+ const state = crypto13.randomBytes(32).toString("hex");
304391
+ const authUrl = client.generateAuthUrl({
304392
+ redirect_uri: redirectUri,
304393
+ access_type: "offline",
304394
+ scope: OAUTH_SCOPE,
304395
+ code_challenge_method: import_google_auth_library8.CodeChallengeMethod.S256,
304396
+ code_challenge: codeVerifier.codeChallenge,
304397
+ state
304332
304398
  });
304333
- client.setCredentials(tokens);
304334
- } catch (error) {
304335
- debugLogger.error("Failed to authenticate with authorization code:", getErrorMessage(error));
304399
+ writeToStdout("Please visit the following URL to authorize the application:\n\n" + authUrl + "\n\n");
304400
+ const code2 = await new Promise((resolve14, _) => {
304401
+ const rl = readline.createInterface({
304402
+ input: process.stdin,
304403
+ output: createInkStdio().stdout,
304404
+ terminal: true
304405
+ });
304406
+ rl.question("Enter the authorization code: ", (code3) => {
304407
+ rl.close();
304408
+ resolve14(code3.trim());
304409
+ });
304410
+ });
304411
+ if (!code2) {
304412
+ writeToStderr("Authorization code is required.\n");
304413
+ debugLogger.error("Authorization code is required.");
304414
+ return false;
304415
+ }
304416
+ try {
304417
+ const { tokens } = await client.getToken({
304418
+ code: code2,
304419
+ codeVerifier: codeVerifier.codeVerifier,
304420
+ redirect_uri: redirectUri
304421
+ });
304422
+ client.setCredentials(tokens);
304423
+ } catch (error) {
304424
+ writeToStderr("Failed to authenticate with authorization code:" + getErrorMessage(error) + "\n");
304425
+ debugLogger.error("Failed to authenticate with authorization code:", getErrorMessage(error));
304426
+ return false;
304427
+ }
304428
+ return true;
304429
+ } catch (err2) {
304430
+ if (err2 instanceof FatalCancellationError) {
304431
+ throw err2;
304432
+ }
304433
+ writeToStderr("Failed to authenticate with user code:" + getErrorMessage(err2) + "\n");
304434
+ debugLogger.error("Failed to authenticate with user code:", getErrorMessage(err2));
304336
304435
  return false;
304337
304436
  }
304338
- return true;
304339
304437
  }
304340
304438
  async function authWithWeb(client) {
304341
304439
  const port = await getAvailablePort();
@@ -304984,7 +305082,7 @@ var addFormatsFunc = addFormats.default || addFormats;
304984
305082
  addFormatsFunc(ajValidator);
304985
305083
  var SchemaValidator = class {
304986
305084
  /**
304987
- * Returns null if the data confroms to the schema described by schema (or if schema
305085
+ * Returns null if the data conforms to the schema described by schema (or if schema
304988
305086
  * is null). Otherwise, returns a string describing the error.
304989
305087
  */
304990
305088
  static validate(schema, data) {
@@ -306384,7 +306482,7 @@ function toFinishReasons(candidates) {
306384
306482
  }
306385
306483
  function toOutputType(requested_mime) {
306386
306484
  switch (requested_mime) {
306387
- // explictly support the known good values of responseMimeType
306485
+ // explicitly support the known good values of responseMimeType
306388
306486
  case "text/plain":
306389
306487
  return OTelOutputType.TEXT;
306390
306488
  case "application/json":
@@ -307485,6 +307583,7 @@ var EventMetadataKey;
307485
307583
  EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_OS"] = 82] = "GEMINI_CLI_OS";
307486
307584
  EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_USER_SETTINGS"] = 84] = "GEMINI_CLI_USER_SETTINGS";
307487
307585
  EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_GH_WORKFLOW_NAME"] = 130] = "GEMINI_CLI_GH_WORKFLOW_NAME";
307586
+ EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_EXPERIMENT_IDS"] = 131] = "GEMINI_CLI_EXPERIMENT_IDS";
307488
307587
  EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_LOOP_DETECTED_TYPE"] = 38] = "GEMINI_CLI_LOOP_DETECTED_TYPE";
307489
307588
  EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_SLASH_COMMAND_NAME"] = 41] = "GEMINI_CLI_SLASH_COMMAND_NAME";
307490
307589
  EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_SLASH_COMMAND_SUBCOMMAND"] = 42] = "GEMINI_CLI_SLASH_COMMAND_SUBCOMMAND";
@@ -307590,8 +307689,8 @@ var Float64Vector = import_vector.default.Float64Vector;
307590
307689
  var PointerVector = import_vector.default.PointerVector;
307591
307690
 
307592
307691
  // packages/core/dist/src/generated/git-commit.js
307593
- var GIT_COMMIT_INFO = "5982abeff";
307594
- var CLI_VERSION = "0.19.0-nightly.20251121.5982abeff";
307692
+ var GIT_COMMIT_INFO = "dadd606c0";
307693
+ var CLI_VERSION = "0.19.0-nightly.20251123.dadd606c0";
307595
307694
 
307596
307695
  // packages/core/dist/src/ide/detect-ide.js
307597
307696
  var IDE_DEFINITIONS = {
@@ -307764,22 +307863,44 @@ var ClearcutLogger = class _ClearcutLogger {
307764
307863
  static clearInstance() {
307765
307864
  _ClearcutLogger.instance = void 0;
307766
307865
  }
307866
+ enqueueHelper(event) {
307867
+ const wasAtCapacity = this.events.size >= MAX_EVENTS;
307868
+ if (wasAtCapacity) {
307869
+ this.events.shift();
307870
+ }
307871
+ this.events.push([
307872
+ {
307873
+ event_time_ms: Date.now(),
307874
+ source_extension_json: safeJsonStringify(event)
307875
+ }
307876
+ ]);
307877
+ if (wasAtCapacity && this.config?.getDebugMode()) {
307878
+ debugLogger.debug(`ClearcutLogger: Dropped old event to prevent memory leak (queue size: ${this.events.size})`);
307879
+ }
307880
+ }
307767
307881
  enqueueLogEvent(event) {
307768
307882
  try {
307769
- const wasAtCapacity = this.events.size >= MAX_EVENTS;
307770
- if (wasAtCapacity) {
307771
- this.events.shift();
307883
+ this.enqueueHelper(event);
307884
+ } catch (error) {
307885
+ if (this.config?.getDebugMode()) {
307886
+ console.error("ClearcutLogger: Failed to enqueue log event.", error);
307772
307887
  }
307773
- this.events.push([
307774
- {
307775
- event_time_ms: Date.now(),
307776
- source_extension_json: safeJsonStringify(event),
307777
- gws_experiment: this.config?.getExperiments()?.experimentIds ?? []
307888
+ }
307889
+ }
307890
+ async enqueueLogEventAfterExperimentsLoadAsync(event) {
307891
+ try {
307892
+ this.config?.getExperimentsAsync().then((experiments) => {
307893
+ if (experiments) {
307894
+ const exp_id_data = [
307895
+ {
307896
+ gemini_cli_key: EventMetadataKey.GEMINI_CLI_EXPERIMENT_IDS,
307897
+ value: experiments.experimentIds.toString() ?? "NA"
307898
+ }
307899
+ ];
307900
+ event.event_metadata = [[...event.event_metadata[0], ...exp_id_data]];
307778
307901
  }
307779
- ]);
307780
- if (wasAtCapacity && this.config?.getDebugMode()) {
307781
- debugLogger.debug(`ClearcutLogger: Dropped old event to prevent memory leak (queue size: ${this.events.size})`);
307782
- }
307902
+ this.enqueueHelper(event);
307903
+ });
307783
307904
  } catch (error) {
307784
307905
  if (this.config?.getDebugMode()) {
307785
307906
  console.error("ClearcutLogger: Failed to enqueue log event.", error);
@@ -307787,6 +307908,7 @@ var ClearcutLogger = class _ClearcutLogger {
307787
307908
  }
307788
307909
  }
307789
307910
  createBasicLogEvent(eventName, data = []) {
307911
+ const email = this.userAccountManager.getCachedGoogleAccount();
307790
307912
  const surface = determineSurface();
307791
307913
  const ghWorkflowName = determineGHWorkflowName();
307792
307914
  const baseMetadata = [
@@ -307814,28 +307936,27 @@ var ClearcutLogger = class _ClearcutLogger {
307814
307936
  value: ghWorkflowName
307815
307937
  });
307816
307938
  }
307817
- return {
307939
+ const logEvent = {
307818
307940
  console_type: "GEMINI_CLI",
307819
307941
  application: 102,
307820
307942
  // GEMINI_CLI
307821
307943
  event_name: eventName,
307822
307944
  event_metadata: [baseMetadata]
307823
307945
  };
307946
+ if (email) {
307947
+ logEvent.client_email = email;
307948
+ } else {
307949
+ logEvent.client_install_id = this.installationManager.getInstallationId();
307950
+ }
307951
+ return logEvent;
307824
307952
  }
307825
307953
  createLogEvent(eventName, data = []) {
307826
- const email = this.userAccountManager.getCachedGoogleAccount();
307827
307954
  if (eventName !== EventNames.START_SESSION) {
307828
307955
  data.push(...this.sessionData);
307829
307956
  }
307830
307957
  const totalAccounts = this.userAccountManager.getLifetimeGoogleAccounts();
307831
307958
  data = this.addDefaultFields(data, totalAccounts);
307832
- const logEvent = this.createBasicLogEvent(eventName, data);
307833
- if (email) {
307834
- logEvent.client_email = email;
307835
- } else {
307836
- logEvent.client_install_id = this.installationManager.getInstallationId();
307837
- }
307838
- return logEvent;
307959
+ return this.createBasicLogEvent(eventName, data);
307839
307960
  }
307840
307961
  flushIfNeeded() {
307841
307962
  if (Date.now() - this.lastFlushTime < FLUSH_INTERVAL_MS) {
@@ -307983,9 +308104,10 @@ var ClearcutLogger = class _ClearcutLogger {
307983
308104
  }
307984
308105
  ];
307985
308106
  this.sessionData = data;
307986
- this.enqueueLogEvent(this.createLogEvent(EventNames.START_SESSION, data));
307987
- this.flushToClearcut().catch((error) => {
307988
- debugLogger.debug("Error flushing to Clearcut:", error);
308107
+ this.enqueueLogEventAfterExperimentsLoadAsync(this.createLogEvent(EventNames.START_SESSION, data)).then(() => {
308108
+ this.flushToClearcut().catch((error) => {
308109
+ debugLogger.debug("Error flushing to Clearcut:", error);
308110
+ });
307989
308111
  });
307990
308112
  }
307991
308113
  logNewPromptEvent(event) {
@@ -308272,8 +308394,11 @@ var ClearcutLogger = class _ClearcutLogger {
308272
308394
  value: JSON.stringify(event.connection_type)
308273
308395
  }
308274
308396
  ];
308275
- this.enqueueLogEvent(this.createLogEvent(EventNames.IDE_CONNECTION, data));
308276
- this.flushIfNeeded();
308397
+ this.enqueueLogEventAfterExperimentsLoadAsync(this.createLogEvent(EventNames.START_SESSION, data)).then(() => {
308398
+ this.flushToClearcut().catch((error) => {
308399
+ debugLogger.debug("Error flushing to Clearcut:", error);
308400
+ });
308401
+ });
308277
308402
  }
308278
308403
  logConversationFinishedEvent(event) {
308279
308404
  const data = [
@@ -308697,6 +308822,12 @@ var ClearcutLogger = class _ClearcutLogger {
308697
308822
  value: this.config?.isInteractive().toString() ?? "false"
308698
308823
  }
308699
308824
  ];
308825
+ if (this.config?.getExperiments()) {
308826
+ defaultLogMetadata.push({
308827
+ gemini_cli_key: EventMetadataKey.GEMINI_CLI_EXPERIMENT_IDS,
308828
+ value: this.config?.getExperiments()?.experimentIds.toString() ?? "NA"
308829
+ });
308830
+ }
308700
308831
  return [...data, ...defaultLogMetadata];
308701
308832
  }
308702
308833
  getProxyAgent() {
@@ -310450,7 +310581,7 @@ async function createContentGenerator(config2, gcConfig, sessionId2) {
310450
310581
  if (gcConfig.fakeResponses) {
310451
310582
  return FakeContentGenerator.fromFile(gcConfig.fakeResponses);
310452
310583
  }
310453
- const version3 = "0.19.0-nightly.20251121.5982abeff";
310584
+ const version3 = "0.19.0-nightly.20251123.dadd606c0";
310454
310585
  const userAgent = `GeminiCLI/${version3} (${process.platform}; ${process.arch})`;
310455
310586
  const baseHeaders = {
310456
310587
  "User-Agent": userAgent
@@ -343003,49 +343134,32 @@ var BaseLlmClient = class {
343003
343134
  this.config = config2;
343004
343135
  }
343005
343136
  async generateJson(options2) {
343006
- const { modelConfigKey, contents, schema, abortSignal, systemInstruction, promptId, maxAttempts } = options2;
343137
+ const { schema, modelConfigKey, contents, systemInstruction, abortSignal, promptId, maxAttempts } = options2;
343007
343138
  const { model, generateContentConfig } = this.config.modelConfigService.getResolvedConfig(modelConfigKey);
343008
- const requestConfig = {
343009
- abortSignal,
343010
- ...generateContentConfig,
343011
- ...systemInstruction && { systemInstruction },
343012
- responseJsonSchema: schema,
343013
- responseMimeType: "application/json"
343014
- };
343015
- try {
343016
- const apiCall = () => this.contentGenerator.generateContent({
343017
- model,
343018
- config: requestConfig,
343019
- contents
343020
- }, promptId);
343021
- const shouldRetryOnContent = (response) => {
343022
- const text = getResponseText(response)?.trim();
343023
- if (!text) {
343024
- return true;
343025
- }
343026
- try {
343027
- JSON.parse(this.cleanJsonResponse(text, model));
343028
- return false;
343029
- } catch (_e) {
343030
- return true;
343031
- }
343032
- };
343033
- const result = await retryWithBackoff(apiCall, {
343034
- shouldRetryOnContent,
343035
- maxAttempts: maxAttempts ?? DEFAULT_MAX_ATTEMPTS
343036
- });
343037
- return JSON.parse(this.cleanJsonResponse(getResponseText(result).trim(), model));
343038
- } catch (error) {
343039
- if (abortSignal.aborted) {
343040
- throw error;
343139
+ const shouldRetryOnContent = (response) => {
343140
+ const text = getResponseText(response)?.trim();
343141
+ if (!text) {
343142
+ return true;
343041
343143
  }
343042
- if (error instanceof Error && error.message.includes("Retry attempts exhausted")) {
343043
- await reportError(error, "API returned invalid content (empty or unparsable JSON) after all retries.", contents, "generateJson-invalid-content");
343044
- } else {
343045
- await reportError(error, "Error generating JSON content via API.", contents, "generateJson-api");
343144
+ try {
343145
+ JSON.parse(this.cleanJsonResponse(text, model));
343146
+ return false;
343147
+ } catch (_e) {
343148
+ return true;
343046
343149
  }
343047
- throw new Error(`Failed to generate JSON content: ${getErrorMessage(error)}`);
343048
- }
343150
+ };
343151
+ const result = await this._generateWithRetry({
343152
+ model,
343153
+ contents,
343154
+ config: {
343155
+ ...generateContentConfig,
343156
+ ...systemInstruction && { systemInstruction },
343157
+ responseJsonSchema: schema,
343158
+ responseMimeType: "application/json",
343159
+ abortSignal
343160
+ }
343161
+ }, promptId, maxAttempts, shouldRetryOnContent, "generateJson");
343162
+ return JSON.parse(this.cleanJsonResponse(getResponseText(result).trim(), model));
343049
343163
  }
343050
343164
  async generateEmbedding(texts) {
343051
343165
  if (!texts || texts.length === 0) {
@@ -343079,6 +343193,43 @@ var BaseLlmClient = class {
343079
343193
  }
343080
343194
  return text;
343081
343195
  }
343196
+ async generateContent(options2) {
343197
+ const { modelConfigKey, contents, systemInstruction, abortSignal, promptId, maxAttempts } = options2;
343198
+ const { model, generateContentConfig } = this.config.modelConfigService.getResolvedConfig(modelConfigKey);
343199
+ const shouldRetryOnContent = (response) => {
343200
+ const text = getResponseText(response)?.trim();
343201
+ return !text;
343202
+ };
343203
+ return this._generateWithRetry({
343204
+ model,
343205
+ contents,
343206
+ config: {
343207
+ ...generateContentConfig,
343208
+ ...systemInstruction && { systemInstruction },
343209
+ abortSignal
343210
+ }
343211
+ }, promptId, maxAttempts, shouldRetryOnContent, "generateContent");
343212
+ }
343213
+ async _generateWithRetry(requestParams, promptId, maxAttempts, shouldRetryOnContent, errorContext) {
343214
+ const abortSignal = requestParams.config?.abortSignal;
343215
+ try {
343216
+ const apiCall = () => this.contentGenerator.generateContent(requestParams, promptId);
343217
+ return await retryWithBackoff(apiCall, {
343218
+ shouldRetryOnContent,
343219
+ maxAttempts: maxAttempts ?? DEFAULT_MAX_ATTEMPTS
343220
+ });
343221
+ } catch (error) {
343222
+ if (abortSignal?.aborted) {
343223
+ throw error;
343224
+ }
343225
+ if (error instanceof Error && error.message.includes("Retry attempts exhausted")) {
343226
+ await reportError(error, `API returned invalid content after all retries.`, requestParams.contents, `${errorContext}-invalid-content`);
343227
+ } else {
343228
+ await reportError(error, `Error generating content via API.`, requestParams.contents, `${errorContext}-api`);
343229
+ }
343230
+ throw new Error(`Failed to generate content: ${getErrorMessage(error)}`);
343231
+ }
343232
+ }
343082
343233
  };
343083
343234
 
343084
343235
  // packages/core/dist/src/utils/llm-edit-fixer.js
@@ -348214,7 +348365,7 @@ function hasPromptCommandTransform(root) {
348214
348365
  for (let i4 = 0; i4 < current.childCount - 1; i4 += 1) {
348215
348366
  const operatorNode = current.child(i4);
348216
348367
  const transformNode = current.child(i4 + 1);
348217
- if (operatorNode?.type === "@" && transformNode?.text?.toLowerCase() === "p") {
348368
+ if (operatorNode?.text === "@" && transformNode?.text?.toLowerCase() === "p") {
348218
348369
  return true;
348219
348370
  }
348220
348371
  }
@@ -357112,6 +357263,12 @@ var GeminiChat = class {
357112
357263
  thinkingLevel: ThinkingLevel.HIGH
357113
357264
  };
357114
357265
  delete config2.thinkingConfig?.thinkingBudget;
357266
+ } else {
357267
+ config2.thinkingConfig = {
357268
+ ...config2.thinkingConfig,
357269
+ thinkingBudget: DEFAULT_THINKING_MODE
357270
+ };
357271
+ delete config2.thinkingConfig?.thinkingLevel;
357115
357272
  }
357116
357273
  return this.config.getContentGenerator().generateContentStream({
357117
357274
  model: modelToUse,
@@ -357588,7 +357745,7 @@ You are a sub-agent in a larger system. Your only responsibility is to provide d
357588
357745
  - **DO:** Find the key modules, classes, and functions that are part of the problem and its solution.
357589
357746
  - **DO:** Understand *why* the code is written the way it is. Question everything.
357590
357747
  - **DO:** Foresee the ripple effects of a change. If \`function A\` is modified, you must check its callers. If a data structure is altered, you must identify where its type definitions need to be updated.
357591
- - **DO:** provide a conclusion and insights to the main agent that invoked you. If the agent is trying to solve a bug, you should provide the root cause of the bug, its impacts, how to fix it etc. If it's a new feature, you should provide insights on where to implement it, what chagnes are necessary etc.
357748
+ - **DO:** provide a conclusion and insights to the main agent that invoked you. If the agent is trying to solve a bug, you should provide the root cause of the bug, its impacts, how to fix it etc. If it's a new feature, you should provide insights on where to implement it, what changes are necessary etc.
357592
357749
  - **DO NOT:** Write the final implementation code yourself.
357593
357750
  - **DO NOT:** Stop at the first relevant file. Your goal is a comprehensive understanding of the entire relevant subsystem.
357594
357751
  You operate in a non-interactive loop and must reason based on the information provided and the output of your tools.
@@ -364398,8 +364555,12 @@ var ModelConfigService = class {
364398
364555
  }
364399
364556
  internalGetResolvedConfig(context2) {
364400
364557
  const config2 = this.config || {};
364401
- const { aliases: aliases2 = {}, overrides = [] } = config2;
364402
- const allAliases = { ...aliases2, ...this.runtimeAliases };
364558
+ const { aliases: aliases2 = {}, customAliases = {}, overrides = [] } = config2;
364559
+ const allAliases = {
364560
+ ...aliases2,
364561
+ ...customAliases,
364562
+ ...this.runtimeAliases
364563
+ };
364403
364564
  let baseModel = context2.model;
364404
364565
  let resolvedConfig = {};
364405
364566
  if (allAliases[context2.model]) {
@@ -367577,7 +367738,7 @@ async function getClientMetadata() {
367577
367738
  clientMetadataPromise = (async () => ({
367578
367739
  ideName: "IDE_UNSPECIFIED",
367579
367740
  pluginType: "GEMINI",
367580
- ideVersion: "0.19.0-nightly.20251121.5982abeff",
367741
+ ideVersion: "0.19.0-nightly.20251123.dadd606c0",
367581
367742
  platform: getPlatform(),
367582
367743
  updateChannel: await getReleaseChannel(__dirname5)
367583
367744
  }))();
@@ -373080,9 +373241,6 @@ var Config = class {
373080
373241
  messageBus;
373081
373242
  policyEngine;
373082
373243
  outputSettings;
373083
- useModelRouter;
373084
- initialUseModelRouter;
373085
- disableModelRouterForAuth;
373086
373244
  enableMessageBusIntegration;
373087
373245
  codebaseInvestigatorSettings;
373088
373246
  continueOnFailedApiCall;
@@ -373179,9 +373337,6 @@ var Config = class {
373179
373337
  this.enableToolOutputTruncation = params.enableToolOutputTruncation ?? true;
373180
373338
  this.useSmartEdit = params.useSmartEdit ?? true;
373181
373339
  this.useWriteTodos = params.useWriteTodos ?? true;
373182
- this.initialUseModelRouter = params.useModelRouter ?? false;
373183
- this.useModelRouter = this.initialUseModelRouter;
373184
- this.disableModelRouterForAuth = params.disableModelRouterForAuth ?? [];
373185
373340
  this.enableHooks = params.enableHooks ?? false;
373186
373341
  const hasHooks = params.hooks && Object.keys(params.hooks).length > 0;
373187
373342
  const hooksNeedMessageBus = this.enableHooks && hasHooks;
@@ -373264,13 +373419,6 @@ var Config = class {
373264
373419
  return this.contentGenerator;
373265
373420
  }
373266
373421
  async refreshAuth(authMethod) {
373267
- this.useModelRouter = this.initialUseModelRouter;
373268
- if (this.disableModelRouterForAuth?.includes(authMethod)) {
373269
- this.useModelRouter = false;
373270
- if (this.model === DEFAULT_GEMINI_MODEL_AUTO) {
373271
- this.model = DEFAULT_GEMINI_MODEL;
373272
- }
373273
- }
373274
373422
  if (this.contentGeneratorConfig?.authType === AuthType2.USE_GEMINI && authMethod !== AuthType2.USE_GEMINI) {
373275
373423
  this.geminiClient.stripThoughtsFromHistory();
373276
373424
  }
@@ -373298,6 +373446,16 @@ var Config = class {
373298
373446
  }
373299
373447
  this.inFallbackMode = false;
373300
373448
  }
373449
+ async getExperimentsAsync() {
373450
+ if (this.experiments) {
373451
+ return this.experiments;
373452
+ }
373453
+ const codeAssistServer = getCodeAssistServer(this);
373454
+ if (codeAssistServer) {
373455
+ return getExperiments(codeAssistServer);
373456
+ }
373457
+ return void 0;
373458
+ }
373301
373459
  getUserTier() {
373302
373460
  return this.contentGenerator?.userTier;
373303
373461
  }
@@ -373764,9 +373922,6 @@ var Config = class {
373764
373922
  getOutputFormat() {
373765
373923
  return this.outputSettings?.format ? this.outputSettings.format : OutputFormat.TEXT;
373766
373924
  }
373767
- getUseModelRouter() {
373768
- return this.useModelRouter;
373769
- }
373770
373925
  async getGitService() {
373771
373926
  if (!this.gitService) {
373772
373927
  this.gitService = new GitService(this.targetDir, this.storage);
@@ -374267,11 +374422,6 @@ var PreCompressTrigger;
374267
374422
  PreCompressTrigger2["Auto"] = "auto";
374268
374423
  })(PreCompressTrigger || (PreCompressTrigger = {}));
374269
374424
 
374270
- // packages/core/dist/src/utils/stdio.js
374271
- init_events();
374272
- var originalStdoutWrite = process.stdout.write.bind(process.stdout);
374273
- var originalStderrWrite = process.stderr.write.bind(process.stderr);
374274
-
374275
374425
  // packages/core/dist/index.js
374276
374426
  init_keychain_token_storage();
374277
374427