@google/gemini-cli 0.52.0-preview.0 → 0.53.0-preview.0

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.
Files changed (55) hide show
  1. package/bundle/{chunk-H4QBAJVE.js → chunk-27C6XFMY.js} +182 -85
  2. package/bundle/{chunk-2JOVER4Y.js → chunk-4OVORMGE.js} +1 -1
  3. package/bundle/{chunk-NA3AQERF.js → chunk-5RDOS7UZ.js} +168 -81
  4. package/bundle/{chunk-JIZMX5VA.js → chunk-6AD4A2WF.js} +1 -1
  5. package/bundle/{chunk-URY5Z7OD.js → chunk-7VUO7T2C.js} +3 -3
  6. package/bundle/{chunk-QPWNOZZA.js → chunk-BDSSP5BZ.js} +1 -1
  7. package/bundle/{chunk-RBAJ4USN.js → chunk-BRZT2CQU.js} +1 -1
  8. package/bundle/{chunk-G5GKJ24J.js → chunk-BX6DTJOD.js} +1 -1
  9. package/bundle/{chunk-7DP44OLX.js → chunk-CTNBR234.js} +2 -2
  10. package/bundle/{chunk-4POBROII.js → chunk-GHVD6PXK.js} +1 -1
  11. package/bundle/{chunk-PVW3N4AH.js → chunk-HF533LET.js} +184 -87
  12. package/bundle/{chunk-QWB2NQDU.js → chunk-HVYOZEAP.js} +3 -3
  13. package/bundle/{chunk-NX6KSZP7.js → chunk-IODN6H35.js} +1 -1
  14. package/bundle/{chunk-G4YQC4AV.js → chunk-LUM47MYE.js} +1 -1
  15. package/bundle/{chunk-GT4ZUA5O.js → chunk-PKFZO3SN.js} +1 -1
  16. package/bundle/{chunk-4PY4INPX.js → chunk-PLMRBJEA.js} +2 -2
  17. package/bundle/{chunk-TKB33QSB.js → chunk-PVCJCQWY.js} +1 -1
  18. package/bundle/{chunk-73WMB3MX.js → chunk-QSTUV3QH.js} +7 -7
  19. package/bundle/{chunk-A2UAPUDF.js → chunk-SLQKIE73.js} +1 -1
  20. package/bundle/{chunk-6QIR5QWV.js → chunk-SXKIOLLX.js} +7 -7
  21. package/bundle/{chunk-SO3OO5YC.js → chunk-UEI42N7R.js} +3 -3
  22. package/bundle/{chunk-PK356GGP.js → chunk-UJVAPQ7V.js} +1 -1
  23. package/bundle/{chunk-BTPQ2MQ6.js → chunk-WVDR5L2V.js} +7 -7
  24. package/bundle/{chunk-LXIJXSLZ.js → chunk-XH7QC2TB.js} +2 -2
  25. package/bundle/{cleanup-CNR4RPBP.js → cleanup-4FVUYQ7H.js} +2 -2
  26. package/bundle/{cleanup-UVL5TK4S.js → cleanup-XETKRH7X.js} +2 -2
  27. package/bundle/{cleanup-YMN2TL6U.js → cleanup-ZR34H2GU.js} +2 -2
  28. package/bundle/{core-KZ4XRQQ6.js → core-I73XKBPY.js} +3 -1
  29. package/bundle/{dist-SEFVUQID.js → core-PVG4D2MR.js} +3 -1
  30. package/bundle/{devtoolsService-7TGRNOVV.js → devtoolsService-IVPTF5ZJ.js} +2 -2
  31. package/bundle/{devtoolsService-PFO3BZC7.js → devtoolsService-OUX7PWP3.js} +2 -2
  32. package/bundle/{devtoolsService-SDOVVX7E.js → devtoolsService-QYDPHHFN.js} +2 -2
  33. package/bundle/{core-3UX5OSS4.js → dist-PRJQFPSQ.js} +3 -1
  34. package/bundle/docs/CONTRIBUTING.md +3 -3
  35. package/bundle/docs/cli/sandbox.md +3 -2
  36. package/bundle/docs/reference/configuration.md +4 -4
  37. package/bundle/{gemini-IR6EZI53.js → gemini-E2E3U6PR.js} +13 -13
  38. package/bundle/{gemini-PV3DL2IX.js → gemini-LA6TNI44.js} +14 -14
  39. package/bundle/{gemini-BPKBGO4O.js → gemini-QKB55UV6.js} +14 -14
  40. package/bundle/gemini.js +7 -7
  41. package/bundle/{interactiveCli-QLXRE74K.js → interactiveCli-ADLAWPXN.js} +8 -8
  42. package/bundle/{interactiveCli-A6PVVEMY.js → interactiveCli-FS3OVPXQ.js} +8 -8
  43. package/bundle/{interactiveCli-JYC6ZXT3.js → interactiveCli-OD2LO24X.js} +8 -8
  44. package/bundle/{liteRtServerManager-GH4QSUW6.js → liteRtServerManager-3SKK7MNE.js} +4 -4
  45. package/bundle/{liteRtServerManager-EMYCURQC.js → liteRtServerManager-O7PFOUFD.js} +4 -4
  46. package/bundle/{liteRtServerManager-UZTNT425.js → liteRtServerManager-T2Z3RLS3.js} +4 -4
  47. package/bundle/{oauth2-provider-NHVNIDFT.js → oauth2-provider-DFVE3NYF.js} +1 -1
  48. package/bundle/{oauth2-provider-NZYJE7VU.js → oauth2-provider-E3S5DGLL.js} +1 -1
  49. package/bundle/{oauth2-provider-2U3SDH5S.js → oauth2-provider-Q433RA6I.js} +1 -1
  50. package/bundle/sandbox-macos-permissive-open.sb +113 -4
  51. package/bundle/sandbox-macos-permissive-proxied.sb +111 -9
  52. package/bundle/{start-GDRL6IAP.js → start-3FPYJBRX.js} +6 -6
  53. package/bundle/{start-YXVG22DK.js → start-5G2UDZZ6.js} +6 -6
  54. package/bundle/{start-52AYSDXT.js → start-XMJ23QZN.js} +6 -6
  55. package/package.json +1 -1
@@ -278401,66 +278401,85 @@ var oauthClientPromises = /* @__PURE__ */ new Map();
278401
278401
  function getUseEncryptedStorageFlag() {
278402
278402
  return process.env[FORCE_ENCRYPTED_FILE_ENV_VAR] === "true";
278403
278403
  }
278404
+ function isAdcCredentials(credentials3) {
278405
+ if (credentials3 && typeof credentials3 === "object" && "type" in credentials3) {
278406
+ const type2 = credentials3.type;
278407
+ return typeof type2 === "string" && type2 !== "authorized_user";
278408
+ }
278409
+ return false;
278410
+ }
278404
278411
  async function initOauthClient(authType, config2) {
278405
- const credentials3 = await fetchCachedCredentials();
278406
- if (credentials3 && typeof credentials3 === "object" && "type" in credentials3 && (credentials3.type === "external_account_authorized_user" || credentials3.type === "service_account")) {
278407
- const auth2 = new import_google_auth_library3.GoogleAuth({
278408
- scopes: OAUTH_SCOPE
278412
+ function createBaseOAuth2Client() {
278413
+ const client2 = new import_google_auth_library3.OAuth2Client({
278414
+ clientId: OAUTH_CLIENT_ID,
278415
+ clientSecret: OAUTH_CLIENT_SECRET,
278416
+ transporterOptions: {
278417
+ proxy: config2.getProxy()
278418
+ }
278409
278419
  });
278410
- const byoidClient = auth2.fromJSON({
278411
- ...credentials3,
278412
- refresh_token: credentials3.refresh_token ?? void 0
278420
+ const useEncryptedStorage = getUseEncryptedStorageFlag();
278421
+ client2.on("tokens", async (tokens) => {
278422
+ if (useEncryptedStorage) {
278423
+ await OAuthCredentialStorage.saveCredentials(tokens);
278424
+ } else {
278425
+ await cacheCredentials(tokens);
278426
+ }
278427
+ await triggerPostAuthCallbacks(tokens);
278413
278428
  });
278414
- const token2 = await byoidClient.getAccessToken();
278415
- if (token2) {
278416
- debugLogger.debug(`Created ${credentials3.type} auth client.`);
278417
- return byoidClient;
278418
- }
278429
+ return client2;
278419
278430
  }
278420
- const client = new import_google_auth_library3.OAuth2Client({
278421
- clientId: OAUTH_CLIENT_ID,
278422
- clientSecret: OAUTH_CLIENT_SECRET,
278423
- transporterOptions: {
278424
- proxy: config2.getProxy()
278425
- }
278426
- });
278427
- const useEncryptedStorage = getUseEncryptedStorageFlag();
278428
278431
  if (process.env["GOOGLE_GENAI_USE_GCA"] && process.env["GOOGLE_CLOUD_ACCESS_TOKEN"]) {
278429
- client.setCredentials({
278432
+ const client2 = createBaseOAuth2Client();
278433
+ client2.setCredentials({
278430
278434
  access_token: process.env["GOOGLE_CLOUD_ACCESS_TOKEN"]
278431
278435
  });
278432
- await fetchAndCacheUserInfo(client);
278433
- return client;
278436
+ await fetchAndCacheUserInfo(client2);
278437
+ return client2;
278434
278438
  }
278435
- client.on("tokens", async (tokens) => {
278436
- if (useEncryptedStorage) {
278437
- await OAuthCredentialStorage.saveCredentials(tokens);
278438
- } else {
278439
- await cacheCredentials(tokens);
278440
- }
278441
- await triggerPostAuthCallbacks(tokens);
278442
- });
278443
- if (credentials3) {
278444
- client.setCredentials(credentials3);
278445
- try {
278446
- const { token: token2 } = await client.getAccessToken();
278447
- if (token2) {
278448
- await client.getTokenInfo(token2);
278449
- if (!userAccountManager2.getCachedGoogleAccount()) {
278450
- try {
278451
- await fetchAndCacheUserInfo(client);
278452
- } catch (error40) {
278453
- debugLogger.warn("Failed to fetch user info:", getErrorMessage(error40));
278439
+ const credentialsList = await fetchCachedCredentialsList();
278440
+ for (const credentials3 of credentialsList) {
278441
+ if (isAdcCredentials(credentials3)) {
278442
+ try {
278443
+ const auth2 = new import_google_auth_library3.GoogleAuth({
278444
+ scopes: OAUTH_SCOPE
278445
+ });
278446
+ const adcClient = auth2.fromJSON({
278447
+ ...credentials3,
278448
+ refresh_token: credentials3.refresh_token ?? void 0
278449
+ });
278450
+ const response = await adcClient.getAccessToken();
278451
+ const token2 = response.token ?? null;
278452
+ if (token2) {
278453
+ debugLogger.debug("Created " + credentials3.type + " auth client.");
278454
+ return adcClient;
278455
+ }
278456
+ } catch (error40) {
278457
+ debugLogger.debug("ADC credentials verification failed:", getErrorMessage(error40));
278458
+ }
278459
+ } else if (credentials3) {
278460
+ const client2 = createBaseOAuth2Client();
278461
+ client2.setCredentials(credentials3);
278462
+ try {
278463
+ const { token: token2 } = await client2.getAccessToken();
278464
+ if (token2) {
278465
+ await client2.getTokenInfo(token2);
278466
+ if (!userAccountManager2.getCachedGoogleAccount()) {
278467
+ try {
278468
+ await fetchAndCacheUserInfo(client2);
278469
+ } catch (error40) {
278470
+ debugLogger.warn("Failed to fetch user info:", getErrorMessage(error40));
278471
+ }
278454
278472
  }
278473
+ debugLogger.log("Loaded cached credentials.");
278474
+ await triggerPostAuthCallbacks(client2.credentials || credentials3);
278475
+ return client2;
278455
278476
  }
278456
- debugLogger.log("Loaded cached credentials.");
278457
- await triggerPostAuthCallbacks(credentials3);
278458
- return client;
278477
+ } catch (error40) {
278478
+ debugLogger.debug("Cached credentials are not valid:", getErrorMessage(error40));
278459
278479
  }
278460
- } catch (error40) {
278461
- debugLogger.debug(`Cached credentials are not valid:`, getErrorMessage(error40));
278462
278480
  }
278463
278481
  }
278482
+ const client = createBaseOAuth2Client();
278464
278483
  if (authType === AuthType2.COMPUTE_ADC) {
278465
278484
  try {
278466
278485
  debugLogger.log("Attempting to authenticate via metadata server application default credentials.");
@@ -278769,13 +278788,21 @@ function getAvailablePort() {
278769
278788
  }
278770
278789
  });
278771
278790
  }
278772
- async function fetchCachedCredentials() {
278791
+ async function fetchCachedCredentialsList() {
278792
+ const credentialsList = [];
278773
278793
  const useEncryptedStorage = getUseEncryptedStorageFlag();
278774
278794
  if (useEncryptedStorage) {
278775
- return OAuthCredentialStorage.loadCredentials();
278795
+ try {
278796
+ const creds = await OAuthCredentialStorage.loadCredentials();
278797
+ if (creds) {
278798
+ credentialsList.push(creds);
278799
+ }
278800
+ } catch (error40) {
278801
+ debugLogger.debug("Failed to load credentials from encrypted storage:", error40);
278802
+ }
278776
278803
  }
278777
278804
  const pathsToTry = [
278778
- Storage.getOAuthCredsPath(),
278805
+ ...!useEncryptedStorage ? [Storage.getOAuthCredsPath()] : [],
278779
278806
  process.env["GOOGLE_APPLICATION_CREDENTIALS"]
278780
278807
  ].filter((p) => !!p);
278781
278808
  for (const keyFile of pathsToTry) {
@@ -278784,14 +278811,15 @@ async function fetchCachedCredentials() {
278784
278811
  const parsed = JSON.parse(keyFileString);
278785
278812
  const isOAuthCreds = (val) => typeof val === "object" && val !== null;
278786
278813
  if (isOAuthCreds(parsed)) {
278787
- return parsed;
278814
+ credentialsList.push(parsed);
278815
+ } else {
278816
+ throw new Error("Invalid credentials format");
278788
278817
  }
278789
- throw new Error("Invalid credentials format");
278790
278818
  } catch (error40) {
278791
278819
  debugLogger.debug(`Failed to load credentials from ${keyFile}:`, getErrorMessage(error40));
278792
278820
  }
278793
278821
  }
278794
- return null;
278822
+ return credentialsList;
278795
278823
  }
278796
278824
  function clearOauthClientCache() {
278797
278825
  oauthClientPromises.clear();
@@ -282465,8 +282493,8 @@ function isValidToolName(name3, options = {}) {
282465
282493
  }
282466
282494
 
282467
282495
  // packages/core/dist/src/generated/git-commit.js
282468
- var GIT_COMMIT_INFO = "1ae8ba649";
282469
- var CLI_VERSION = "0.52.0-preview.0";
282496
+ var GIT_COMMIT_INFO = "9681621c6";
282497
+ var CLI_VERSION = "0.53.0-preview.0";
282470
282498
 
282471
282499
  // packages/core/dist/src/ide/detect-ide.js
282472
282500
  var IDE_DEFINITIONS = {
@@ -289959,6 +289987,10 @@ function getDiffCommand(oldPath, newPath, editor) {
289959
289987
  }
289960
289988
  }
289961
289989
  async function openDiff(oldPath, newPath, editor) {
289990
+ if (isHeadlessMode()) {
289991
+ debugLogger.warn("External editor spawning is disabled in headless/server mode.");
289992
+ return;
289993
+ }
289962
289994
  const diffCommand = getDiffCommand(oldPath, newPath, editor);
289963
289995
  if (!diffCommand) {
289964
289996
  debugLogger.error("No diff tool available. Install a supported editor.");
@@ -305643,7 +305675,7 @@ function getVersion() {
305643
305675
  }
305644
305676
  versionPromise = (async () => {
305645
305677
  const pkgJson = await getPackageJson(__dirname4);
305646
- return "0.52.0-preview.0";
305678
+ return "0.53.0-preview.0";
305647
305679
  })();
305648
305680
  return versionPromise;
305649
305681
  }
@@ -310612,13 +310644,19 @@ async function createContentGeneratorConfig(config2, authType, apiKey, baseUrl,
310612
310644
  customHeaders,
310613
310645
  vertexAiRouting
310614
310646
  };
310647
+ const getEnv3 = (key) => {
310648
+ if (config2?.env && config2.env[key] !== void 0) {
310649
+ return config2.env[key];
310650
+ }
310651
+ return process.env[key];
310652
+ };
310615
310653
  if (authType === AuthType2.LOGIN_WITH_GOOGLE || authType === AuthType2.COMPUTE_ADC) {
310616
310654
  return contentGeneratorConfig;
310617
310655
  }
310618
- const geminiApiKey = apiKey || process.env["GEMINI_API_KEY"] || await loadApiKey() || void 0;
310619
- const googleApiKey = process.env["GOOGLE_API_KEY"] || void 0;
310620
- const googleCloudProject = process.env["GOOGLE_CLOUD_PROJECT"] || process.env["GOOGLE_CLOUD_PROJECT_ID"] || void 0;
310621
- const googleCloudLocation = process.env["GOOGLE_CLOUD_LOCATION"] || void 0;
310656
+ const geminiApiKey = apiKey || getEnv3("GEMINI_API_KEY") || await loadApiKey() || void 0;
310657
+ const googleApiKey = getEnv3("GOOGLE_API_KEY") || void 0;
310658
+ const googleCloudProject = getEnv3("GOOGLE_CLOUD_PROJECT") || getEnv3("GOOGLE_CLOUD_PROJECT_ID") || void 0;
310659
+ const googleCloudLocation = getEnv3("GOOGLE_CLOUD_LOCATION") || void 0;
310622
310660
  if (authType === AuthType2.USE_GEMINI && geminiApiKey) {
310623
310661
  contentGeneratorConfig.apiKey = geminiApiKey;
310624
310662
  contentGeneratorConfig.vertexai = false;
@@ -310630,7 +310668,7 @@ async function createContentGeneratorConfig(config2, authType, apiKey, baseUrl,
310630
310668
  return contentGeneratorConfig;
310631
310669
  }
310632
310670
  if (authType === AuthType2.GATEWAY) {
310633
- contentGeneratorConfig.apiKey = apiKey || process.env["GEMINI_API_KEY"] || "";
310671
+ contentGeneratorConfig.apiKey = apiKey || getEnv3("GEMINI_API_KEY") || "";
310634
310672
  contentGeneratorConfig.vertexai = false;
310635
310673
  return contentGeneratorConfig;
310636
310674
  }
@@ -320914,7 +320952,7 @@ import { TextDecoder as TextDecoder2 } from "node:util";
320914
320952
  import os28 from "node:os";
320915
320953
  import fs47, { mkdirSync as mkdirSync4 } from "node:fs";
320916
320954
  import path57 from "node:path";
320917
- var import_headless2 = __toESM(require_xterm_headless(), 1);
320955
+ var import_headless3 = __toESM(require_xterm_headless(), 1);
320918
320956
 
320919
320957
  // packages/core/dist/src/utils/terminalSerializer.js
320920
320958
  var Attribute;
@@ -321789,7 +321827,7 @@ var ExecutionLifecycleService = class {
321789
321827
  };
321790
321828
 
321791
321829
  // packages/core/dist/src/services/shellExecutionService.js
321792
- var { Terminal } = import_headless2.default;
321830
+ var { Terminal } = import_headless3.default;
321793
321831
  var MAX_CHILD_PROCESS_BUFFER_SIZE = 16 * 1024 * 1024;
321794
321832
  var GEMINI_CLI_IDENTIFICATION_ENV_VAR = "GEMINI_CLI";
321795
321833
  var GEMINI_CLI_IDENTIFICATION_ENV_VAR_VALUE = "1";
@@ -321987,9 +322025,10 @@ ${truncated}`;
321987
322025
  const guardedCommand = ensurePromptvarsDisabled(commandToExecute, shell);
321988
322026
  const finalCommand = injectUtf8CodepageForPty(guardedCommand, shell, isWindows3, usingPty);
321989
322027
  const spawnArgs = [...argsPrefix, finalCommand];
322028
+ const sourceEnv = shellExecutionConfig.env ?? process.env;
321990
322029
  const gitConfigKeys = [];
321991
322030
  if (!isInteractive) {
321992
- for (const key in process.env) {
322031
+ for (const key in sourceEnv) {
321993
322032
  if (key.startsWith("GIT_CONFIG_")) {
321994
322033
  gitConfigKeys.push(key);
321995
322034
  }
@@ -322002,7 +322041,7 @@ ${truncated}`;
322002
322041
  ...gitConfigKeys
322003
322042
  ]
322004
322043
  };
322005
- const sanitizedEnv = sanitizeEnvironment(process.env, sanitizationConfig);
322044
+ const sanitizedEnv = sanitizeEnvironment(sourceEnv, sanitizationConfig);
322006
322045
  const baseEnv = {
322007
322046
  ...sanitizedEnv,
322008
322047
  [GEMINI_CLI_IDENTIFICATION_ENV_VAR]: GEMINI_CLI_IDENTIFICATION_ENV_VAR_VALUE,
@@ -322012,7 +322051,7 @@ ${truncated}`;
322012
322051
  };
322013
322052
  if (!isInteractive) {
322014
322053
  for (const key of gitConfigKeys) {
322015
- baseEnv[key] = process.env[key];
322054
+ baseEnv[key] = sourceEnv[key];
322016
322055
  }
322017
322056
  const gitConfigCount = parseInt(baseEnv["GIT_CONFIG_COUNT"] || "0", 10);
322018
322057
  const newKey = `GIT_CONFIG_KEY_${gitConfigCount}`;
@@ -323385,6 +323424,7 @@ exit $__code`;
323385
323424
  }
323386
323425
  }, combinedController.signal, this.context.config.isInteractiveShellEnabled(), {
323387
323426
  ...shellExecutionConfig,
323427
+ env: this.context.config.env,
323388
323428
  sessionId: this.context.config?.getSessionId?.() ?? "default",
323389
323429
  pager: "cat",
323390
323430
  sanitizationConfig: shellExecutionConfig?.sanitizationConfig ?? this.context.config.sanitizationConfig,
@@ -330526,7 +330566,8 @@ var GeminiChat = class {
330526
330566
  return binaryParts.length > 0 ? binaryParts : void 0;
330527
330567
  }
330528
330568
  async makeApiCallAndProcessStream(modelConfigKey, requestHistory, prompt_id, abortSignal, role, apiHistoryOverride) {
330529
- const scrubbedHistory = this.context.config.isContextManagementEnabled() ? scrubHistory([...requestHistory]) : [...requestHistory];
330569
+ let scrubbedHistory = this.context.config.isContextManagementEnabled() ? scrubHistory([...requestHistory]) : [...requestHistory];
330570
+ scrubbedHistory = coalesceConsecutiveRoles(scrubbedHistory);
330530
330571
  const scrubbedContents = scrubbedHistory.map((h2) => h2.content);
330531
330572
  const requestContents = apiHistoryOverride ? scrubContents(apiHistoryOverride) : scrubbedContents;
330532
330573
  const contentsForPreviewModel = this.ensureActiveLoopHasThoughtSignatures(requestContents);
@@ -331046,6 +331087,29 @@ function stripToolCallIdPrefixes(contents) {
331046
331087
  })
331047
331088
  }));
331048
331089
  }
331090
+ function coalesceConsecutiveRoles(history) {
331091
+ const result2 = [];
331092
+ for (const turn of history) {
331093
+ const lastIdx = result2.length - 1;
331094
+ const last2 = result2[lastIdx];
331095
+ if (last2 && last2.content.role && last2.content.role === turn.content.role) {
331096
+ const hasParts = last2.content.parts || turn.content.parts;
331097
+ result2[lastIdx] = {
331098
+ id: last2.id,
331099
+ content: {
331100
+ ...last2.content,
331101
+ parts: hasParts ? [...last2.content.parts || [], ...turn.content.parts || []] : void 0
331102
+ }
331103
+ };
331104
+ } else {
331105
+ result2.push({
331106
+ id: turn.id,
331107
+ content: { ...turn.content }
331108
+ });
331109
+ }
331110
+ }
331111
+ return result2;
331112
+ }
331049
331113
 
331050
331114
  // packages/core/dist/src/utils/ragLogger.js
331051
331115
  import * as fs50 from "node:fs";
@@ -338173,7 +338237,7 @@ var A2AAuthProviderFactory = class _A2AAuthProviderFactory {
338173
338237
  return provider;
338174
338238
  }
338175
338239
  case "oauth2": {
338176
- const { OAuth2AuthProvider } = await import("./oauth2-provider-NZYJE7VU.js");
338240
+ const { OAuth2AuthProvider } = await import("./oauth2-provider-E3S5DGLL.js");
338177
338241
  const provider = new OAuth2AuthProvider(authConfig, options.agentName ?? "unknown", agentCard, options.agentCardUrl);
338178
338242
  await provider.initialize();
338179
338243
  return provider;
@@ -340320,8 +340384,7 @@ var LoopDetectionService = class {
340320
340384
  promptId = "";
340321
340385
  userPrompt = "";
340322
340386
  // Tool call tracking
340323
- lastToolCallKey = null;
340324
- toolCallRepetitionCount = 0;
340387
+ toolCallHistory = [];
340325
340388
  // Content streaming tracking
340326
340389
  streamContentHistory = "";
340327
340390
  contentStats = /* @__PURE__ */ new Map();
@@ -340443,14 +340506,31 @@ var LoopDetectionService = class {
340443
340506
  }
340444
340507
  checkToolCallLoop(toolCall) {
340445
340508
  const key = this.getToolCallKey(toolCall);
340446
- if (this.lastToolCallKey === key) {
340447
- this.toolCallRepetitionCount++;
340448
- } else {
340449
- this.lastToolCallKey = key;
340450
- this.toolCallRepetitionCount = 1;
340451
- }
340452
- if (this.toolCallRepetitionCount >= TOOL_CALL_LOOP_THRESHOLD) {
340453
- return true;
340509
+ this.toolCallHistory.push(key);
340510
+ const maxRequiredLength = 5 * TOOL_CALL_LOOP_THRESHOLD;
340511
+ if (this.toolCallHistory.length > maxRequiredLength) {
340512
+ this.toolCallHistory = this.toolCallHistory.slice(-maxRequiredLength);
340513
+ }
340514
+ const n3 = this.toolCallHistory.length;
340515
+ const R = TOOL_CALL_LOOP_THRESHOLD;
340516
+ for (let k = 1; k <= 5; k++) {
340517
+ const requiredLength = k * R;
340518
+ if (n3 >= requiredLength) {
340519
+ const cycle = this.toolCallHistory.slice(-k);
340520
+ let isPatternMatch = true;
340521
+ for (let i3 = 0; i3 < requiredLength; i3++) {
340522
+ const indexFromEnd = requiredLength - i3;
340523
+ const actualKey = this.toolCallHistory[n3 - indexFromEnd];
340524
+ const expectedKey = cycle[i3 % k];
340525
+ if (actualKey !== expectedKey) {
340526
+ isPatternMatch = false;
340527
+ break;
340528
+ }
340529
+ }
340530
+ if (isPatternMatch) {
340531
+ return true;
340532
+ }
340533
+ }
340454
340534
  }
340455
340535
  return false;
340456
340536
  }
@@ -340708,8 +340788,7 @@ ${this.userPrompt}
340708
340788
  this.loopDetected = false;
340709
340789
  }
340710
340790
  resetToolCallCount() {
340711
- this.lastToolCallKey = null;
340712
- this.toolCallRepetitionCount = 0;
340791
+ this.toolCallHistory = [];
340713
340792
  }
340714
340793
  resetContentTracking(resetHistory = true) {
340715
340794
  if (resetHistory) {
@@ -363616,7 +363695,9 @@ var CheckerRunner = class _CheckerRunner {
363616
363695
  executeCheckerProcess(checkerPath, input, checkerName) {
363617
363696
  return new Promise((resolve29) => {
363618
363697
  const child = spawn9(checkerPath, [], {
363619
- stdio: ["pipe", "pipe", "pipe"]
363698
+ stdio: ["pipe", "pipe", "pipe"],
363699
+ cwd: this.contextBuilder.config.getWorkingDir(),
363700
+ env: { ...process.env, ...this.contextBuilder.config.env }
363620
363701
  });
363621
363702
  let stdout = "";
363622
363703
  let stderr = "";
@@ -363723,6 +363804,9 @@ var ContextBuilder = class {
363723
363804
  constructor(context2) {
363724
363805
  this.context = context2;
363725
363806
  }
363807
+ get config() {
363808
+ return this.context.config;
363809
+ }
363726
363810
  /**
363727
363811
  * Builds the full context object with all available data.
363728
363812
  */
@@ -375825,6 +375909,7 @@ var Config = class {
375825
375909
  useTerminalBuffer;
375826
375910
  useRenderProcess;
375827
375911
  shellExecutionConfig;
375912
+ env;
375828
375913
  extensionManagement = true;
375829
375914
  extensionRegistryURI;
375830
375915
  truncateToolOutputThreshold;
@@ -375991,6 +376076,7 @@ var Config = class {
375991
376076
  this.checkpointing = params.checkpointing ?? false;
375992
376077
  this.proxy = params.proxy;
375993
376078
  this.cwd = params.cwd ?? process15.cwd();
376079
+ this.env = params.env;
375994
376080
  this.fileDiscoveryService = params.fileDiscoveryService ?? null;
375995
376081
  this.bugCommand = params.bugCommand;
375996
376082
  this.model = params.model;
@@ -395851,6 +395937,7 @@ export {
395851
395937
  isSchemaDepthError,
395852
395938
  isInvalidArgumentError,
395853
395939
  stripToolCallIdPrefixes,
395940
+ coalesceConsecutiveRoles,
395854
395941
  populateToolDisplay,
395855
395942
  toolResultDisplayToDisplayContent,
395856
395943
  renderDisplayDiff,
@@ -28,7 +28,7 @@ import {
28
28
  partListUnionToString,
29
29
  require_strip_json_comments,
30
30
  sanitizeFilenamePart
31
- } from "./chunk-H4QBAJVE.js";
31
+ } from "./chunk-HF533LET.js";
32
32
  import {
33
33
  __commonJS,
34
34
  __require,
@@ -2,7 +2,7 @@ const require = (await import('node:module')).createRequire(import.meta.url); co
2
2
  import {
3
3
  exitCli,
4
4
  require_source
5
- } from "./chunk-PK356GGP.js";
5
+ } from "./chunk-UJVAPQ7V.js";
6
6
  import {
7
7
  DEFAULT_PORT,
8
8
  SERVER_START_WAIT_MS,
@@ -14,10 +14,10 @@ import {
14
14
  isServerRunning,
15
15
  resolveGemmaConfig,
16
16
  writeServerProcessInfo
17
- } from "./chunk-JIZMX5VA.js";
17
+ } from "./chunk-LUM47MYE.js";
18
18
  import {
19
19
  debugLogger
20
- } from "./chunk-H4QBAJVE.js";
20
+ } from "./chunk-5RDOS7UZ.js";
21
21
  import {
22
22
  __toESM
23
23
  } from "./chunk-34MYV7JD.js";
@@ -1,7 +1,7 @@
1
1
  const require = (await import('node:module')).createRequire(import.meta.url); const __chunk_filename = (await import('node:url')).fileURLToPath(import.meta.url); const __chunk_dirname = (await import('node:path')).dirname(__chunk_filename);
2
2
  import {
3
3
  checkExhaustive
4
- } from "./chunk-PVW3N4AH.js";
4
+ } from "./chunk-27C6XFMY.js";
5
5
  import {
6
6
  __commonJS,
7
7
  __toESM
@@ -2,7 +2,7 @@ const require = (await import('node:module')).createRequire(import.meta.url); co
2
2
  import {
3
3
  CoreToolCallStatus,
4
4
  checkExhaustive
5
- } from "./chunk-NA3AQERF.js";
5
+ } from "./chunk-5RDOS7UZ.js";
6
6
  import {
7
7
  __commonJS,
8
8
  __toESM
@@ -5,7 +5,7 @@ import {
5
5
  isTelemetrySdkInitialized,
6
6
  resetBrowserSession,
7
7
  shutdownTelemetry
8
- } from "./chunk-H4QBAJVE.js";
8
+ } from "./chunk-5RDOS7UZ.js";
9
9
 
10
10
  // packages/cli/src/utils/cleanup.ts
11
11
  import { promises as fs } from "node:fs";
@@ -1,13 +1,13 @@
1
1
  const require = (await import('node:module')).createRequire(import.meta.url); const __chunk_filename = (await import('node:url')).fileURLToPath(import.meta.url); const __chunk_dirname = (await import('node:path')).dirname(__chunk_filename);
2
2
  import {
3
3
  runExitCleanup
4
- } from "./chunk-GT4ZUA5O.js";
4
+ } from "./chunk-PVCJCQWY.js";
5
5
  import {
6
6
  RELEASE_CHANNEL_STABILITY,
7
7
  debugLogger,
8
8
  getChannelFromVersion,
9
9
  isGitRepository
10
- } from "./chunk-PVW3N4AH.js";
10
+ } from "./chunk-HF533LET.js";
11
11
 
12
12
  // packages/cli/src/utils/installationInfo.ts
13
13
  import * as fs from "node:fs";
@@ -1,7 +1,7 @@
1
1
  const require = (await import('node:module')).createRequire(import.meta.url); const __chunk_filename = (await import('node:url')).fileURLToPath(import.meta.url); const __chunk_dirname = (await import('node:path')).dirname(__chunk_filename);
2
2
  import {
3
3
  checkExhaustive
4
- } from "./chunk-H4QBAJVE.js";
4
+ } from "./chunk-HF533LET.js";
5
5
  import {
6
6
  __commonJS,
7
7
  __toESM