@google/gemini-cli-a2a-server 0.23.0-preview.2 → 0.24.0-nightly.20251227.37be16243

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.
@@ -8766,15 +8766,15 @@ var require_file = __commonJS({
8766
8766
  _incFile(callback) {
8767
8767
  debug2("_incFile", this.filename);
8768
8768
  const ext2 = path75.extname(this._basename);
8769
- const basename15 = path75.basename(this._basename, ext2);
8769
+ const basename14 = path75.basename(this._basename, ext2);
8770
8770
  const tasks = [];
8771
8771
  if (this.zippedArchive) {
8772
8772
  tasks.push(
8773
8773
  function(cb) {
8774
8774
  const num = this._created > 0 && !this.tailable ? this._created : "";
8775
8775
  this._compressFile(
8776
- path75.join(this.dirname, `${basename15}${num}${ext2}`),
8777
- path75.join(this.dirname, `${basename15}${num}${ext2}.gz`),
8776
+ path75.join(this.dirname, `${basename14}${num}${ext2}`),
8777
+ path75.join(this.dirname, `${basename14}${num}${ext2}.gz`),
8778
8778
  cb
8779
8779
  );
8780
8780
  }.bind(this)
@@ -8784,9 +8784,9 @@ var require_file = __commonJS({
8784
8784
  function(cb) {
8785
8785
  if (!this.tailable) {
8786
8786
  this._created += 1;
8787
- this._checkMaxFilesIncrementing(ext2, basename15, cb);
8787
+ this._checkMaxFilesIncrementing(ext2, basename14, cb);
8788
8788
  } else {
8789
- this._checkMaxFilesTailable(ext2, basename15, cb);
8789
+ this._checkMaxFilesTailable(ext2, basename14, cb);
8790
8790
  }
8791
8791
  }.bind(this)
8792
8792
  );
@@ -8800,9 +8800,9 @@ var require_file = __commonJS({
8800
8800
  */
8801
8801
  _getFile() {
8802
8802
  const ext2 = path75.extname(this._basename);
8803
- const basename15 = path75.basename(this._basename, ext2);
8803
+ const basename14 = path75.basename(this._basename, ext2);
8804
8804
  const isRotation = this.rotationFormat ? this.rotationFormat() : this._created;
8805
- return !this.tailable && this._created ? `${basename15}${isRotation}${ext2}` : `${basename15}${ext2}`;
8805
+ return !this.tailable && this._created ? `${basename14}${isRotation}${ext2}` : `${basename14}${ext2}`;
8806
8806
  }
8807
8807
  /**
8808
8808
  * Increment the number of files created or checked by this instance.
@@ -8812,14 +8812,14 @@ var require_file = __commonJS({
8812
8812
  * @returns {undefined}
8813
8813
  * @private
8814
8814
  */
8815
- _checkMaxFilesIncrementing(ext2, basename15, callback) {
8815
+ _checkMaxFilesIncrementing(ext2, basename14, callback) {
8816
8816
  if (!this.maxFiles || this._created < this.maxFiles) {
8817
8817
  return setImmediate(callback);
8818
8818
  }
8819
8819
  const oldest = this._created - this.maxFiles;
8820
8820
  const isOldest = oldest !== 0 ? oldest : "";
8821
8821
  const isZipped = this.zippedArchive ? ".gz" : "";
8822
- const filePath = `${basename15}${isOldest}${ext2}${isZipped}`;
8822
+ const filePath = `${basename14}${isOldest}${ext2}${isZipped}`;
8823
8823
  const target = path75.join(this.dirname, filePath);
8824
8824
  fs66.unlink(target, callback);
8825
8825
  }
@@ -8834,7 +8834,7 @@ var require_file = __commonJS({
8834
8834
  * @returns {undefined}
8835
8835
  * @private
8836
8836
  */
8837
- _checkMaxFilesTailable(ext2, basename15, callback) {
8837
+ _checkMaxFilesTailable(ext2, basename14, callback) {
8838
8838
  const tasks = [];
8839
8839
  if (!this.maxFiles) {
8840
8840
  return;
@@ -8842,21 +8842,21 @@ var require_file = __commonJS({
8842
8842
  const isZipped = this.zippedArchive ? ".gz" : "";
8843
8843
  for (let x2 = this.maxFiles - 1; x2 > 1; x2--) {
8844
8844
  tasks.push(function(i4, cb) {
8845
- let fileName = `${basename15}${i4 - 1}${ext2}${isZipped}`;
8845
+ let fileName = `${basename14}${i4 - 1}${ext2}${isZipped}`;
8846
8846
  const tmppath = path75.join(this.dirname, fileName);
8847
8847
  fs66.exists(tmppath, (exists2) => {
8848
8848
  if (!exists2) {
8849
8849
  return cb(null);
8850
8850
  }
8851
- fileName = `${basename15}${i4}${ext2}${isZipped}`;
8851
+ fileName = `${basename14}${i4}${ext2}${isZipped}`;
8852
8852
  fs66.rename(tmppath, path75.join(this.dirname, fileName), cb);
8853
8853
  });
8854
8854
  }.bind(this, x2));
8855
8855
  }
8856
8856
  asyncSeries(tasks, () => {
8857
8857
  fs66.rename(
8858
- path75.join(this.dirname, `${basename15}${ext2}${isZipped}`),
8859
- path75.join(this.dirname, `${basename15}1${ext2}${isZipped}`),
8858
+ path75.join(this.dirname, `${basename14}${ext2}${isZipped}`),
8859
+ path75.join(this.dirname, `${basename14}1${ext2}${isZipped}`),
8860
8860
  callback
8861
8861
  );
8862
8862
  });
@@ -33263,8 +33263,8 @@ var require_view = __commonJS({
33263
33263
  var debug2 = require_src()("express:view");
33264
33264
  var path75 = __require("node:path");
33265
33265
  var fs66 = __require("node:fs");
33266
- var dirname17 = path75.dirname;
33267
- var basename15 = path75.basename;
33266
+ var dirname18 = path75.dirname;
33267
+ var basename14 = path75.basename;
33268
33268
  var extname3 = path75.extname;
33269
33269
  var join29 = path75.join;
33270
33270
  var resolve14 = path75.resolve;
@@ -33302,8 +33302,8 @@ var require_view = __commonJS({
33302
33302
  for (var i4 = 0; i4 < roots.length && !path76; i4++) {
33303
33303
  var root = roots[i4];
33304
33304
  var loc = resolve14(root, name4);
33305
- var dir = dirname17(loc);
33306
- var file = basename15(loc);
33305
+ var dir = dirname18(loc);
33306
+ var file = basename14(loc);
33307
33307
  path76 = this.resolve(dir, file);
33308
33308
  }
33309
33309
  return path76;
@@ -33333,7 +33333,7 @@ var require_view = __commonJS({
33333
33333
  if (stat3 && stat3.isFile()) {
33334
33334
  return path76;
33335
33335
  }
33336
- path76 = join29(dir, basename15(file, ext2), "index" + ext2);
33336
+ path76 = join29(dir, basename14(file, ext2), "index" + ext2);
33337
33337
  stat3 = tryStat(path76);
33338
33338
  if (stat3 && stat3.isFile()) {
33339
33339
  return path76;
@@ -36625,7 +36625,7 @@ var require_content_disposition = __commonJS({
36625
36625
  "use strict";
36626
36626
  module2.exports = contentDisposition;
36627
36627
  module2.exports.parse = parse10;
36628
- var basename15 = __require("path").basename;
36628
+ var basename14 = __require("path").basename;
36629
36629
  var Buffer11 = require_safe_buffer().Buffer;
36630
36630
  var ENCODE_URL_ATTR_CHAR_REGEXP = /[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g;
36631
36631
  var HEX_ESCAPE_REGEXP = /%[0-9A-Fa-f]{2}/;
@@ -36661,9 +36661,9 @@ var require_content_disposition = __commonJS({
36661
36661
  if (typeof fallback === "string" && NON_LATIN1_REGEXP.test(fallback)) {
36662
36662
  throw new TypeError("fallback must be ISO-8859-1 string");
36663
36663
  }
36664
- var name4 = basename15(filename);
36664
+ var name4 = basename14(filename);
36665
36665
  var isQuotedString = TEXT_REGEXP.test(name4);
36666
- var fallbackName = typeof fallback !== "string" ? fallback && getlatin1(name4) : basename15(fallback);
36666
+ var fallbackName = typeof fallback !== "string" ? fallback && getlatin1(name4) : basename14(fallback);
36667
36667
  var hasFallback = typeof fallbackName === "string" && fallbackName !== name4;
36668
36668
  if (hasFallback || !isQuotedString || HEX_ESCAPE_REGEXP.test(name4)) {
36669
36669
  params["filename*"] = name4;
@@ -45813,8 +45813,8 @@ var require_view2 = __commonJS({
45813
45813
  var debug2 = require_src4()("express:view");
45814
45814
  var path75 = __require("path");
45815
45815
  var fs66 = __require("fs");
45816
- var dirname17 = path75.dirname;
45817
- var basename15 = path75.basename;
45816
+ var dirname18 = path75.dirname;
45817
+ var basename14 = path75.basename;
45818
45818
  var extname3 = path75.extname;
45819
45819
  var join29 = path75.join;
45820
45820
  var resolve14 = path75.resolve;
@@ -45852,8 +45852,8 @@ var require_view2 = __commonJS({
45852
45852
  for (var i4 = 0; i4 < roots.length && !path76; i4++) {
45853
45853
  var root = roots[i4];
45854
45854
  var loc = resolve14(root, name4);
45855
- var dir = dirname17(loc);
45856
- var file = basename15(loc);
45855
+ var dir = dirname18(loc);
45856
+ var file = basename14(loc);
45857
45857
  path76 = this.resolve(dir, file);
45858
45858
  }
45859
45859
  return path76;
@@ -45869,7 +45869,7 @@ var require_view2 = __commonJS({
45869
45869
  if (stat3 && stat3.isFile()) {
45870
45870
  return path76;
45871
45871
  }
45872
- path76 = join29(dir, basename15(file, ext2), "index" + ext2);
45872
+ path76 = join29(dir, basename14(file, ext2), "index" + ext2);
45873
45873
  stat3 = tryStat(path76);
45874
45874
  if (stat3 && stat3.isFile()) {
45875
45875
  return path76;
@@ -45892,7 +45892,7 @@ var require_content_disposition2 = __commonJS({
45892
45892
  "use strict";
45893
45893
  module2.exports = contentDisposition;
45894
45894
  module2.exports.parse = parse10;
45895
- var basename15 = __require("path").basename;
45895
+ var basename14 = __require("path").basename;
45896
45896
  var Buffer11 = require_safe_buffer().Buffer;
45897
45897
  var ENCODE_URL_ATTR_CHAR_REGEXP = /[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g;
45898
45898
  var HEX_ESCAPE_REGEXP = /%[0-9A-Fa-f]{2}/;
@@ -45928,9 +45928,9 @@ var require_content_disposition2 = __commonJS({
45928
45928
  if (typeof fallback === "string" && NON_LATIN1_REGEXP.test(fallback)) {
45929
45929
  throw new TypeError("fallback must be ISO-8859-1 string");
45930
45930
  }
45931
- var name4 = basename15(filename);
45931
+ var name4 = basename14(filename);
45932
45932
  var isQuotedString = TEXT_REGEXP.test(name4);
45933
- var fallbackName = typeof fallback !== "string" ? fallback && getlatin1(name4) : basename15(fallback);
45933
+ var fallbackName = typeof fallback !== "string" ? fallback && getlatin1(name4) : basename14(fallback);
45934
45934
  var hasFallback = typeof fallbackName === "string" && fallbackName !== name4;
45935
45935
  if (hasFallback || !isQuotedString || HEX_ESCAPE_REGEXP.test(name4)) {
45936
45936
  params["filename*"] = name4;
@@ -68416,8 +68416,8 @@ var require_graceful_fs = __commonJS({
68416
68416
  }
68417
68417
  }
68418
68418
  var fs$writeFile = fs67.writeFile;
68419
- fs67.writeFile = writeFile6;
68420
- function writeFile6(path75, data, options2, cb) {
68419
+ fs67.writeFile = writeFile5;
68420
+ function writeFile5(path75, data, options2, cb) {
68421
68421
  if (typeof options2 === "function")
68422
68422
  cb = options2, options2 = null;
68423
68423
  return go$writeFile(path75, data, options2, cb);
@@ -69769,7 +69769,7 @@ var require_jsonfile = __commonJS({
69769
69769
  return obj;
69770
69770
  }
69771
69771
  var readFile8 = universalify.fromPromise(_readFile);
69772
- function readFileSync9(file, options2 = {}) {
69772
+ function readFileSync10(file, options2 = {}) {
69773
69773
  if (typeof options2 === "string") {
69774
69774
  options2 = { encoding: options2 };
69775
69775
  }
@@ -69793,17 +69793,17 @@ var require_jsonfile = __commonJS({
69793
69793
  const str = stringify5(obj, options2);
69794
69794
  await universalify.fromCallback(fs66.writeFile)(file, str, options2);
69795
69795
  }
69796
- var writeFile6 = universalify.fromPromise(_writeFile);
69797
- function writeFileSync5(file, obj, options2 = {}) {
69796
+ var writeFile5 = universalify.fromPromise(_writeFile);
69797
+ function writeFileSync6(file, obj, options2 = {}) {
69798
69798
  const fs66 = options2.fs || _fs;
69799
69799
  const str = stringify5(obj, options2);
69800
69800
  return fs66.writeFileSync(file, str, options2);
69801
69801
  }
69802
69802
  module2.exports = {
69803
69803
  readFile: readFile8,
69804
- readFileSync: readFileSync9,
69805
- writeFile: writeFile6,
69806
- writeFileSync: writeFileSync5
69804
+ readFileSync: readFileSync10,
69805
+ writeFile: writeFile5,
69806
+ writeFileSync: writeFileSync6
69807
69807
  };
69808
69808
  }
69809
69809
  });
@@ -153014,8 +153014,8 @@ var require_sync = __commonJS({
153014
153014
  }
153015
153015
  return x2;
153016
153016
  };
153017
- var defaultReadPackageSync = function defaultReadPackageSync2(readFileSync9, pkgfile) {
153018
- var body2 = readFileSync9(pkgfile);
153017
+ var defaultReadPackageSync = function defaultReadPackageSync2(readFileSync10, pkgfile) {
153018
+ var body2 = readFileSync10(pkgfile);
153019
153019
  try {
153020
153020
  var pkg2 = JSON.parse(body2);
153021
153021
  return pkg2;
@@ -153035,7 +153035,7 @@ var require_sync = __commonJS({
153035
153035
  }
153036
153036
  var opts = normalizeOptions2(x2, options2);
153037
153037
  var isFile3 = opts.isFile || defaultIsFile;
153038
- var readFileSync9 = opts.readFileSync || fs66.readFileSync;
153038
+ var readFileSync10 = opts.readFileSync || fs66.readFileSync;
153039
153039
  var isDirectory = opts.isDirectory || defaultIsDir;
153040
153040
  var realpathSync4 = opts.realpathSync || defaultRealpathSync;
153041
153041
  var readPackageSync2 = opts.readPackageSync || defaultReadPackageSync;
@@ -153092,7 +153092,7 @@ var require_sync = __commonJS({
153092
153092
  if (!isFile3(pkgfile)) {
153093
153093
  return loadpkg(path75.dirname(dir));
153094
153094
  }
153095
- var pkg2 = readPackageSync2(readFileSync9, pkgfile);
153095
+ var pkg2 = readPackageSync2(readFileSync10, pkgfile);
153096
153096
  if (pkg2 && opts.packageFilter) {
153097
153097
  pkg2 = opts.packageFilter(
153098
153098
  pkg2,
@@ -153106,7 +153106,7 @@ var require_sync = __commonJS({
153106
153106
  var pkgfile = path75.join(maybeRealpathSync(realpathSync4, x3, opts), "/package.json");
153107
153107
  if (isFile3(pkgfile)) {
153108
153108
  try {
153109
- var pkg2 = readPackageSync2(readFileSync9, pkgfile);
153109
+ var pkg2 = readPackageSync2(readFileSync10, pkgfile);
153110
153110
  } catch (e3) {
153111
153111
  }
153112
153112
  if (pkg2 && opts.packageFilter) {
@@ -249909,8 +249909,8 @@ var require_snapshot_utils = __commonJS({
249909
249909
  var require_snapshot_recorder = __commonJS({
249910
249910
  "node_modules/undici/lib/mock/snapshot-recorder.js"(exports2, module2) {
249911
249911
  "use strict";
249912
- var { writeFile: writeFile6, readFile: readFile8, mkdir: mkdir7 } = __require("node:fs/promises");
249913
- var { dirname: dirname17, resolve: resolve14 } = __require("node:path");
249912
+ var { writeFile: writeFile5, readFile: readFile8, mkdir: mkdir7 } = __require("node:fs/promises");
249913
+ var { dirname: dirname18, resolve: resolve14 } = __require("node:path");
249914
249914
  var { setTimeout: setTimeout4, clearTimeout: clearTimeout2 } = __require("node:timers");
249915
249915
  var { InvalidArgumentError, UndiciError } = require_errors7();
249916
249916
  var { hashId, isUrlExcludedFactory, normalizeHeaders: normalizeHeaders2, createHeaderFilters } = require_snapshot_utils();
@@ -250134,12 +250134,12 @@ var require_snapshot_recorder = __commonJS({
250134
250134
  throw new InvalidArgumentError("Snapshot path is required");
250135
250135
  }
250136
250136
  const resolvedPath = resolve14(path75);
250137
- await mkdir7(dirname17(resolvedPath), { recursive: true });
250137
+ await mkdir7(dirname18(resolvedPath), { recursive: true });
250138
250138
  const data = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
250139
250139
  hash,
250140
250140
  snapshot
250141
250141
  }));
250142
- await writeFile6(resolvedPath, JSON.stringify(data, null, 2), { flush: true });
250142
+ await writeFile5(resolvedPath, JSON.stringify(data, null, 2), { flush: true });
250143
250143
  }
250144
250144
  /**
250145
250145
  * Clears all recorded snapshots
@@ -269000,6 +269000,97 @@ var require_xterm_headless = __commonJS({
269000
269000
  }
269001
269001
  });
269002
269002
 
269003
+ // node_modules/fast-levenshtein/levenshtein.js
269004
+ var require_levenshtein = __commonJS({
269005
+ "node_modules/fast-levenshtein/levenshtein.js"(exports2, module2) {
269006
+ (function() {
269007
+ "use strict";
269008
+ var collator;
269009
+ try {
269010
+ collator = typeof Intl !== "undefined" && typeof Intl.Collator !== "undefined" ? Intl.Collator("generic", { sensitivity: "base" }) : null;
269011
+ } catch (err2) {
269012
+ console.log("Collator could not be initialized and wouldn't be used");
269013
+ }
269014
+ var prevRow = [], str2Char = [];
269015
+ var Levenshtein = {
269016
+ /**
269017
+ * Calculate levenshtein distance of the two strings.
269018
+ *
269019
+ * @param str1 String the first string.
269020
+ * @param str2 String the second string.
269021
+ * @param [options] Additional options.
269022
+ * @param [options.useCollator] Use `Intl.Collator` for locale-sensitive string comparison.
269023
+ * @return Integer the levenshtein distance (0 and above).
269024
+ */
269025
+ get: function(str1, str2, options2) {
269026
+ var useCollator = options2 && collator && options2.useCollator;
269027
+ var str1Len = str1.length, str2Len = str2.length;
269028
+ if (str1Len === 0) return str2Len;
269029
+ if (str2Len === 0) return str1Len;
269030
+ var curCol, nextCol, i4, j, tmp;
269031
+ for (i4 = 0; i4 < str2Len; ++i4) {
269032
+ prevRow[i4] = i4;
269033
+ str2Char[i4] = str2.charCodeAt(i4);
269034
+ }
269035
+ prevRow[str2Len] = str2Len;
269036
+ var strCmp;
269037
+ if (useCollator) {
269038
+ for (i4 = 0; i4 < str1Len; ++i4) {
269039
+ nextCol = i4 + 1;
269040
+ for (j = 0; j < str2Len; ++j) {
269041
+ curCol = nextCol;
269042
+ strCmp = 0 === collator.compare(str1.charAt(i4), String.fromCharCode(str2Char[j]));
269043
+ nextCol = prevRow[j] + (strCmp ? 0 : 1);
269044
+ tmp = curCol + 1;
269045
+ if (nextCol > tmp) {
269046
+ nextCol = tmp;
269047
+ }
269048
+ tmp = prevRow[j + 1] + 1;
269049
+ if (nextCol > tmp) {
269050
+ nextCol = tmp;
269051
+ }
269052
+ prevRow[j] = curCol;
269053
+ }
269054
+ prevRow[j] = nextCol;
269055
+ }
269056
+ } else {
269057
+ for (i4 = 0; i4 < str1Len; ++i4) {
269058
+ nextCol = i4 + 1;
269059
+ for (j = 0; j < str2Len; ++j) {
269060
+ curCol = nextCol;
269061
+ strCmp = str1.charCodeAt(i4) === str2Char[j];
269062
+ nextCol = prevRow[j] + (strCmp ? 0 : 1);
269063
+ tmp = curCol + 1;
269064
+ if (nextCol > tmp) {
269065
+ nextCol = tmp;
269066
+ }
269067
+ tmp = prevRow[j + 1] + 1;
269068
+ if (nextCol > tmp) {
269069
+ nextCol = tmp;
269070
+ }
269071
+ prevRow[j] = curCol;
269072
+ }
269073
+ prevRow[j] = nextCol;
269074
+ }
269075
+ }
269076
+ return nextCol;
269077
+ }
269078
+ };
269079
+ if (typeof define !== "undefined" && define !== null && define.amd) {
269080
+ define(function() {
269081
+ return Levenshtein;
269082
+ });
269083
+ } else if (typeof module2 !== "undefined" && module2 !== null && typeof exports2 !== "undefined" && module2.exports === exports2) {
269084
+ module2.exports = Levenshtein;
269085
+ } else if (typeof self !== "undefined" && typeof self.postMessage === "function" && typeof self.importScripts === "function") {
269086
+ self.Levenshtein = Levenshtein;
269087
+ } else if (typeof window !== "undefined" && window !== null) {
269088
+ window.Levenshtein = Levenshtein;
269089
+ }
269090
+ })();
269091
+ }
269092
+ });
269093
+
269003
269094
  // node_modules/deepmerge/dist/cjs.js
269004
269095
  var require_cjs2 = __commonJS({
269005
269096
  "node_modules/deepmerge/dist/cjs.js"(exports2, module2) {
@@ -269103,97 +269194,6 @@ var require_cjs2 = __commonJS({
269103
269194
  }
269104
269195
  });
269105
269196
 
269106
- // node_modules/fast-levenshtein/levenshtein.js
269107
- var require_levenshtein = __commonJS({
269108
- "node_modules/fast-levenshtein/levenshtein.js"(exports2, module2) {
269109
- (function() {
269110
- "use strict";
269111
- var collator;
269112
- try {
269113
- collator = typeof Intl !== "undefined" && typeof Intl.Collator !== "undefined" ? Intl.Collator("generic", { sensitivity: "base" }) : null;
269114
- } catch (err2) {
269115
- console.log("Collator could not be initialized and wouldn't be used");
269116
- }
269117
- var prevRow = [], str2Char = [];
269118
- var Levenshtein = {
269119
- /**
269120
- * Calculate levenshtein distance of the two strings.
269121
- *
269122
- * @param str1 String the first string.
269123
- * @param str2 String the second string.
269124
- * @param [options] Additional options.
269125
- * @param [options.useCollator] Use `Intl.Collator` for locale-sensitive string comparison.
269126
- * @return Integer the levenshtein distance (0 and above).
269127
- */
269128
- get: function(str1, str2, options2) {
269129
- var useCollator = options2 && collator && options2.useCollator;
269130
- var str1Len = str1.length, str2Len = str2.length;
269131
- if (str1Len === 0) return str2Len;
269132
- if (str2Len === 0) return str1Len;
269133
- var curCol, nextCol, i4, j, tmp;
269134
- for (i4 = 0; i4 < str2Len; ++i4) {
269135
- prevRow[i4] = i4;
269136
- str2Char[i4] = str2.charCodeAt(i4);
269137
- }
269138
- prevRow[str2Len] = str2Len;
269139
- var strCmp;
269140
- if (useCollator) {
269141
- for (i4 = 0; i4 < str1Len; ++i4) {
269142
- nextCol = i4 + 1;
269143
- for (j = 0; j < str2Len; ++j) {
269144
- curCol = nextCol;
269145
- strCmp = 0 === collator.compare(str1.charAt(i4), String.fromCharCode(str2Char[j]));
269146
- nextCol = prevRow[j] + (strCmp ? 0 : 1);
269147
- tmp = curCol + 1;
269148
- if (nextCol > tmp) {
269149
- nextCol = tmp;
269150
- }
269151
- tmp = prevRow[j + 1] + 1;
269152
- if (nextCol > tmp) {
269153
- nextCol = tmp;
269154
- }
269155
- prevRow[j] = curCol;
269156
- }
269157
- prevRow[j] = nextCol;
269158
- }
269159
- } else {
269160
- for (i4 = 0; i4 < str1Len; ++i4) {
269161
- nextCol = i4 + 1;
269162
- for (j = 0; j < str2Len; ++j) {
269163
- curCol = nextCol;
269164
- strCmp = str1.charCodeAt(i4) === str2Char[j];
269165
- nextCol = prevRow[j] + (strCmp ? 0 : 1);
269166
- tmp = curCol + 1;
269167
- if (nextCol > tmp) {
269168
- nextCol = tmp;
269169
- }
269170
- tmp = prevRow[j + 1] + 1;
269171
- if (nextCol > tmp) {
269172
- nextCol = tmp;
269173
- }
269174
- prevRow[j] = curCol;
269175
- }
269176
- prevRow[j] = nextCol;
269177
- }
269178
- }
269179
- return nextCol;
269180
- }
269181
- };
269182
- if (typeof define !== "undefined" && define !== null && define.amd) {
269183
- define(function() {
269184
- return Levenshtein;
269185
- });
269186
- } else if (typeof module2 !== "undefined" && module2 !== null && typeof exports2 !== "undefined" && module2.exports === exports2) {
269187
- module2.exports = Levenshtein;
269188
- } else if (typeof self !== "undefined" && typeof self.postMessage === "function" && typeof self.importScripts === "function") {
269189
- self.Levenshtein = Levenshtein;
269190
- } else if (typeof window !== "undefined" && window !== null) {
269191
- window.Levenshtein = Levenshtein;
269192
- }
269193
- })();
269194
- }
269195
- });
269196
-
269197
269197
  // node_modules/@kwsites/file-exists/dist/src/index.js
269198
269198
  var require_src62 = __commonJS({
269199
269199
  "node_modules/@kwsites/file-exists/dist/src/index.js"(exports2) {
@@ -275221,7 +275221,7 @@ var A2AExpressApp = class {
275221
275221
  }
275222
275222
  };
275223
275223
 
275224
- // packages/a2a-server/node_modules/uuid/dist/esm/stringify.js
275224
+ // packages/a2a-server/node_modules/uuid/dist-node/stringify.js
275225
275225
  var byteToHex2 = [];
275226
275226
  for (let i4 = 0; i4 < 256; ++i4) {
275227
275227
  byteToHex2.push((i4 + 256).toString(16).slice(1));
@@ -275230,8 +275230,8 @@ function unsafeStringify2(arr, offset = 0) {
275230
275230
  return (byteToHex2[arr[offset + 0]] + byteToHex2[arr[offset + 1]] + byteToHex2[arr[offset + 2]] + byteToHex2[arr[offset + 3]] + "-" + byteToHex2[arr[offset + 4]] + byteToHex2[arr[offset + 5]] + "-" + byteToHex2[arr[offset + 6]] + byteToHex2[arr[offset + 7]] + "-" + byteToHex2[arr[offset + 8]] + byteToHex2[arr[offset + 9]] + "-" + byteToHex2[arr[offset + 10]] + byteToHex2[arr[offset + 11]] + byteToHex2[arr[offset + 12]] + byteToHex2[arr[offset + 13]] + byteToHex2[arr[offset + 14]] + byteToHex2[arr[offset + 15]]).toLowerCase();
275231
275231
  }
275232
275232
 
275233
- // packages/a2a-server/node_modules/uuid/dist/esm/rng.js
275234
- import { randomFillSync as randomFillSync2 } from "crypto";
275233
+ // packages/a2a-server/node_modules/uuid/dist-node/rng.js
275234
+ import { randomFillSync as randomFillSync2 } from "node:crypto";
275235
275235
  var rnds8Pool2 = new Uint8Array(256);
275236
275236
  var poolPtr2 = rnds8Pool2.length;
275237
275237
  function rng2() {
@@ -275242,15 +275242,12 @@ function rng2() {
275242
275242
  return rnds8Pool2.slice(poolPtr2, poolPtr2 += 16);
275243
275243
  }
275244
275244
 
275245
- // packages/a2a-server/node_modules/uuid/dist/esm/native.js
275246
- import { randomUUID as randomUUID2 } from "crypto";
275245
+ // packages/a2a-server/node_modules/uuid/dist-node/native.js
275246
+ import { randomUUID as randomUUID2 } from "node:crypto";
275247
275247
  var native_default2 = { randomUUID: randomUUID2 };
275248
275248
 
275249
- // packages/a2a-server/node_modules/uuid/dist/esm/v4.js
275250
- function v42(options2, buf, offset) {
275251
- if (native_default2.randomUUID && !buf && !options2) {
275252
- return native_default2.randomUUID();
275253
- }
275249
+ // packages/a2a-server/node_modules/uuid/dist-node/v4.js
275250
+ function _v4(options2, buf, offset) {
275254
275251
  options2 = options2 || {};
275255
275252
  const rnds = options2.random ?? options2.rng?.() ?? rng2();
275256
275253
  if (rnds.length < 16) {
@@ -275270,6 +275267,12 @@ function v42(options2, buf, offset) {
275270
275267
  }
275271
275268
  return unsafeStringify2(rnds);
275272
275269
  }
275270
+ function v42(options2, buf, offset) {
275271
+ if (native_default2.randomUUID && !buf && !options2) {
275272
+ return native_default2.randomUUID();
275273
+ }
275274
+ return _v4(options2, buf, offset);
275275
+ }
275273
275276
  var v4_default2 = v42;
275274
275277
 
275275
275278
  // node_modules/@google-cloud/storage/build/esm/src/nodejs-common/service.js
@@ -309407,7 +309410,142 @@ function getResponseText(response) {
309407
309410
  return null;
309408
309411
  }
309409
309412
 
309413
+ // packages/core/dist/src/config/models.js
309414
+ var PREVIEW_GEMINI_MODEL = "gemini-3-pro-preview";
309415
+ var PREVIEW_GEMINI_FLASH_MODEL = "gemini-3-flash-preview";
309416
+ var DEFAULT_GEMINI_MODEL = "gemini-2.5-pro";
309417
+ var DEFAULT_GEMINI_FLASH_MODEL = "gemini-2.5-flash";
309418
+ var DEFAULT_GEMINI_FLASH_LITE_MODEL = "gemini-2.5-flash-lite";
309419
+ var PREVIEW_GEMINI_MODEL_AUTO = "auto-gemini-3";
309420
+ var DEFAULT_GEMINI_MODEL_AUTO = "auto-gemini-2.5";
309421
+ var GEMINI_MODEL_ALIAS_AUTO = "auto";
309422
+ var GEMINI_MODEL_ALIAS_PRO = "pro";
309423
+ var GEMINI_MODEL_ALIAS_FLASH = "flash";
309424
+ var GEMINI_MODEL_ALIAS_FLASH_LITE = "flash-lite";
309425
+ var DEFAULT_GEMINI_EMBEDDING_MODEL = "gemini-embedding-001";
309426
+ var DEFAULT_THINKING_MODE = 8192;
309427
+ function resolveModel(requestedModel, previewFeaturesEnabled = false) {
309428
+ switch (requestedModel) {
309429
+ case PREVIEW_GEMINI_MODEL_AUTO: {
309430
+ return PREVIEW_GEMINI_MODEL;
309431
+ }
309432
+ case DEFAULT_GEMINI_MODEL_AUTO: {
309433
+ return DEFAULT_GEMINI_MODEL;
309434
+ }
309435
+ case GEMINI_MODEL_ALIAS_PRO: {
309436
+ return previewFeaturesEnabled ? PREVIEW_GEMINI_MODEL : DEFAULT_GEMINI_MODEL;
309437
+ }
309438
+ case GEMINI_MODEL_ALIAS_FLASH: {
309439
+ return previewFeaturesEnabled ? PREVIEW_GEMINI_FLASH_MODEL : DEFAULT_GEMINI_FLASH_MODEL;
309440
+ }
309441
+ case GEMINI_MODEL_ALIAS_FLASH_LITE: {
309442
+ return DEFAULT_GEMINI_FLASH_LITE_MODEL;
309443
+ }
309444
+ default: {
309445
+ return requestedModel;
309446
+ }
309447
+ }
309448
+ }
309449
+ function resolveClassifierModel(requestedModel, modelAlias, previewFeaturesEnabled = false) {
309450
+ if (modelAlias === GEMINI_MODEL_ALIAS_FLASH) {
309451
+ if (requestedModel === DEFAULT_GEMINI_MODEL_AUTO || requestedModel === DEFAULT_GEMINI_MODEL) {
309452
+ return DEFAULT_GEMINI_FLASH_MODEL;
309453
+ }
309454
+ if (requestedModel === PREVIEW_GEMINI_MODEL_AUTO || requestedModel === PREVIEW_GEMINI_MODEL) {
309455
+ return PREVIEW_GEMINI_FLASH_MODEL;
309456
+ }
309457
+ return resolveModel(GEMINI_MODEL_ALIAS_FLASH, previewFeaturesEnabled);
309458
+ }
309459
+ return resolveModel(requestedModel, previewFeaturesEnabled);
309460
+ }
309461
+ function isPreviewModel(model) {
309462
+ return model === PREVIEW_GEMINI_MODEL || model === PREVIEW_GEMINI_FLASH_MODEL || model === PREVIEW_GEMINI_MODEL_AUTO;
309463
+ }
309464
+ function isGemini2Model(model) {
309465
+ return /^gemini-2(\.|$)/.test(model);
309466
+ }
309467
+ function supportsMultimodalFunctionResponse(model) {
309468
+ return model.startsWith("gemini-3-");
309469
+ }
309470
+
309410
309471
  // packages/core/dist/src/utils/generateContentResponseUtilities.js
309472
+ function createFunctionResponsePart(callId, toolName, output) {
309473
+ return {
309474
+ functionResponse: {
309475
+ id: callId,
309476
+ name: toolName,
309477
+ response: { output }
309478
+ }
309479
+ };
309480
+ }
309481
+ function toParts2(input) {
309482
+ const parts2 = [];
309483
+ for (const part of Array.isArray(input) ? input : [input]) {
309484
+ if (typeof part === "string") {
309485
+ parts2.push({ text: part });
309486
+ } else if (part) {
309487
+ parts2.push(part);
309488
+ }
309489
+ }
309490
+ return parts2;
309491
+ }
309492
+ function convertToFunctionResponse(toolName, callId, llmContent, model) {
309493
+ if (typeof llmContent === "string") {
309494
+ return [createFunctionResponsePart(callId, toolName, llmContent)];
309495
+ }
309496
+ const parts2 = toParts2(llmContent);
309497
+ const textParts = [];
309498
+ const inlineDataParts = [];
309499
+ const fileDataParts = [];
309500
+ for (const part2 of parts2) {
309501
+ if (part2.text !== void 0) {
309502
+ textParts.push(part2.text);
309503
+ } else if (part2.inlineData) {
309504
+ inlineDataParts.push(part2);
309505
+ } else if (part2.fileData) {
309506
+ fileDataParts.push(part2);
309507
+ } else if (part2.functionResponse) {
309508
+ if (parts2.length > 1) {
309509
+ debugLogger.warn("convertToFunctionResponse received multiple parts with a functionResponse. Only the functionResponse will be used, other parts will be ignored");
309510
+ }
309511
+ return [
309512
+ {
309513
+ functionResponse: {
309514
+ id: callId,
309515
+ name: toolName,
309516
+ response: part2.functionResponse.response
309517
+ }
309518
+ }
309519
+ ];
309520
+ }
309521
+ }
309522
+ const part = {
309523
+ functionResponse: {
309524
+ id: callId,
309525
+ name: toolName,
309526
+ response: textParts.length > 0 ? { output: textParts.join("\n") } : {}
309527
+ }
309528
+ };
309529
+ const isMultimodalFRSupported = supportsMultimodalFunctionResponse(model);
309530
+ const siblingParts = [...fileDataParts];
309531
+ if (inlineDataParts.length > 0) {
309532
+ if (isMultimodalFRSupported) {
309533
+ part.functionResponse.parts = inlineDataParts;
309534
+ } else {
309535
+ siblingParts.push(...inlineDataParts);
309536
+ }
309537
+ }
309538
+ if (textParts.length === 0 && (inlineDataParts.length > 0 || fileDataParts.length > 0)) {
309539
+ const totalBinaryItems = inlineDataParts.length + fileDataParts.length;
309540
+ part.functionResponse.response = {
309541
+ output: `Binary content provided (${totalBinaryItems} item(s)).`
309542
+ };
309543
+ }
309544
+ if (siblingParts.length > 0) {
309545
+ return [part, ...siblingParts];
309546
+ }
309547
+ return [part];
309548
+ }
309411
309549
  function getCitations(resp) {
309412
309550
  return (resp.candidates?.[0]?.citationMetadata?.citations ?? []).filter((citation) => citation.uri !== void 0).map((citation) => {
309413
309551
  if (citation.title) {
@@ -309781,7 +309919,7 @@ var DeclarativeTool = class {
309781
309919
  * A convenience method that builds and executes the tool in one step.
309782
309920
  * Never throws.
309783
309921
  * @param params The raw, untrusted parameters from the model.
309784
- * @params abortSignal a signal to abort.
309922
+ * @param abortSignal a signal to abort.
309785
309923
  * @returns The result of the tool execution.
309786
309924
  */
309787
309925
  async validateBuildAndExecute(params, abortSignal) {
@@ -310224,7 +310362,7 @@ var __filename = fileURLToPath4(import.meta.url);
310224
310362
  var __dirname3 = path20.dirname(__filename);
310225
310363
  async function getVersion() {
310226
310364
  const pkgJson = await getPackageJson(__dirname3);
310227
- return "0.23.0-preview.2";
310365
+ return "0.24.0-nightly.20251227.37be16243";
310228
310366
  }
310229
310367
 
310230
310368
  // packages/core/dist/src/code_assist/experiments/client_metadata.js
@@ -310360,7 +310498,7 @@ var CodeAssistServer = class {
310360
310498
  await this.recordCodeAssistMetrics({
310361
310499
  project: this.projectId,
310362
310500
  metadata: await getClientMetadata(),
310363
- metrics: [{ conversationOffered }]
310501
+ metrics: [{ conversationOffered, timestamp: (/* @__PURE__ */ new Date()).toISOString() }]
310364
310502
  });
310365
310503
  }
310366
310504
  async recordConversationInteraction(interaction) {
@@ -310370,7 +310508,12 @@ var CodeAssistServer = class {
310370
310508
  await this.recordCodeAssistMetrics({
310371
310509
  project: this.projectId,
310372
310510
  metadata: await getClientMetadata(),
310373
- metrics: [{ conversationInteraction: interaction }]
310511
+ metrics: [
310512
+ {
310513
+ conversationInteraction: interaction,
310514
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
310515
+ }
310516
+ ]
310374
310517
  });
310375
310518
  }
310376
310519
  async recordCodeAssistMetrics(request3) {
@@ -310944,8 +311087,8 @@ function sanitizeHookName(hookName) {
310944
311087
  }
310945
311088
  if (command.includes("/") || command.includes("\\")) {
310946
311089
  const pathParts = command.split(/[/\\]/);
310947
- const basename15 = pathParts[pathParts.length - 1];
310948
- return basename15 || "unknown-command";
311090
+ const basename14 = pathParts[pathParts.length - 1];
311091
+ return basename14 || "unknown-command";
310949
311092
  }
310950
311093
  return command;
310951
311094
  }
@@ -312995,8 +313138,8 @@ var Float64Vector = import_vector.default.Float64Vector;
312995
313138
  var PointerVector = import_vector.default.PointerVector;
312996
313139
 
312997
313140
  // packages/core/dist/src/generated/git-commit.js
312998
- var GIT_COMMIT_INFO = "bc40695ce";
312999
- var CLI_VERSION = "0.23.0-preview.2";
313141
+ var GIT_COMMIT_INFO = "37be16243";
313142
+ var CLI_VERSION = "0.24.0-nightly.20251227.37be16243";
313000
313143
 
313001
313144
  // packages/core/dist/src/ide/detect-ide.js
313002
313145
  var IDE_DEFINITIONS = {
@@ -316199,7 +316342,7 @@ async function createContentGenerator(config3, gcConfig, sessionId2) {
316199
316342
  return FakeContentGenerator.fromFile(gcConfig.fakeResponses);
316200
316343
  }
316201
316344
  const version4 = await getVersion();
316202
- const model = getEffectiveModel(gcConfig.getModel(), gcConfig.getPreviewFeatures());
316345
+ const model = resolveModel(gcConfig.getModel(), gcConfig.getPreviewFeatures());
316203
316346
  const customHeadersEnv = process.env["GEMINI_CLI_CUSTOM_HEADERS"] || void 0;
316204
316347
  const userAgent = `GeminiCLI/${version4}/${model} (${process.platform}; ${process.arch})`;
316205
316348
  const customHeadersMap = parseCustomHeaders(customHeadersEnv);
@@ -318948,6 +319091,55 @@ async function fileExists(filePath) {
318948
319091
  return false;
318949
319092
  }
318950
319093
  }
319094
+ async function saveTruncatedContent(content, callId, projectTempDir, threshold, truncateLines) {
319095
+ if (content.length <= threshold) {
319096
+ return { content };
319097
+ }
319098
+ let lines = content.split("\n");
319099
+ let fileContent = content;
319100
+ if (lines.length <= truncateLines) {
319101
+ const wrapWidth = 120;
319102
+ const wrappedLines = [];
319103
+ for (const line of lines) {
319104
+ if (line.length > wrapWidth) {
319105
+ for (let i4 = 0; i4 < line.length; i4 += wrapWidth) {
319106
+ wrappedLines.push(line.substring(i4, i4 + wrapWidth));
319107
+ }
319108
+ } else {
319109
+ wrappedLines.push(line);
319110
+ }
319111
+ }
319112
+ lines = wrappedLines;
319113
+ fileContent = lines.join("\n");
319114
+ }
319115
+ const head = Math.floor(truncateLines / 5);
319116
+ const beginning = lines.slice(0, head);
319117
+ const end = lines.slice(-(truncateLines - head));
319118
+ const truncatedContent = beginning.join("\n") + "\n... [CONTENT TRUNCATED] ...\n" + end.join("\n");
319119
+ const safeFileName = `${path26.basename(callId)}.output`;
319120
+ const outputFile = path26.join(projectTempDir, safeFileName);
319121
+ try {
319122
+ await fsPromises3.writeFile(outputFile, fileContent);
319123
+ return {
319124
+ content: `Tool output was too large and has been truncated.
319125
+ The full output has been saved to: ${outputFile}
319126
+ To read the complete output, use the ${READ_FILE_TOOL_NAME} tool with the absolute file path above. For large files, you can use the offset and limit parameters to read specific sections:
319127
+ - ${READ_FILE_TOOL_NAME} tool with offset=0, limit=100 to see the first 100 lines
319128
+ - ${READ_FILE_TOOL_NAME} tool with offset=N to skip N lines from the beginning
319129
+ - ${READ_FILE_TOOL_NAME} tool with limit=M to read only M lines at a time
319130
+ The truncated output below shows the beginning and end of the content. The marker '... [CONTENT TRUNCATED] ...' indicates where content was removed.
319131
+ This allows you to efficiently examine different parts of the output without loading the entire file.
319132
+ Truncated part of the output:
319133
+ ${truncatedContent}`,
319134
+ outputFile
319135
+ };
319136
+ } catch (_error) {
319137
+ return {
319138
+ content: truncatedContent + `
319139
+ [Note: Could not save full output to file]`
319140
+ };
319141
+ }
319142
+ }
318951
319143
 
318952
319144
  // packages/core/dist/src/utils/language-detection.js
318953
319145
  import * as path27 from "node:path";
@@ -353021,6 +353213,8 @@ var IdeClient = class _IdeClient {
353021
353213
  noProxy: [existingNoProxy, "127.0.0.1"].filter(Boolean).join(",")
353022
353214
  });
353023
353215
  const undiciPromise = Promise.resolve().then(() => __toESM(require_undici(), 1));
353216
+ undiciPromise.catch(() => {
353217
+ });
353024
353218
  return async (url5, init3) => {
353025
353219
  const { fetch: fetchFn } = await undiciPromise;
353026
353220
  const fetchOptions = {
@@ -354164,67 +354358,6 @@ function classifyFailureKind(error2) {
354164
354358
  return "unknown";
354165
354359
  }
354166
354360
 
354167
- // packages/core/dist/src/config/models.js
354168
- var PREVIEW_GEMINI_MODEL = "gemini-3-pro-preview";
354169
- var PREVIEW_GEMINI_FLASH_MODEL = "gemini-3-flash-preview";
354170
- var DEFAULT_GEMINI_MODEL = "gemini-2.5-pro";
354171
- var DEFAULT_GEMINI_FLASH_MODEL = "gemini-2.5-flash";
354172
- var DEFAULT_GEMINI_FLASH_LITE_MODEL = "gemini-2.5-flash-lite";
354173
- var PREVIEW_GEMINI_MODEL_AUTO = "auto-gemini-3";
354174
- var DEFAULT_GEMINI_MODEL_AUTO = "auto-gemini-2.5";
354175
- var GEMINI_MODEL_ALIAS_AUTO = "auto";
354176
- var GEMINI_MODEL_ALIAS_PRO = "pro";
354177
- var GEMINI_MODEL_ALIAS_FLASH = "flash";
354178
- var GEMINI_MODEL_ALIAS_FLASH_LITE = "flash-lite";
354179
- var DEFAULT_GEMINI_EMBEDDING_MODEL = "gemini-embedding-001";
354180
- var DEFAULT_THINKING_MODE = 8192;
354181
- function resolveModel(requestedModel, previewFeaturesEnabled = false) {
354182
- switch (requestedModel) {
354183
- case PREVIEW_GEMINI_MODEL_AUTO: {
354184
- return PREVIEW_GEMINI_MODEL;
354185
- }
354186
- case DEFAULT_GEMINI_MODEL_AUTO: {
354187
- return DEFAULT_GEMINI_MODEL;
354188
- }
354189
- case GEMINI_MODEL_ALIAS_PRO: {
354190
- return previewFeaturesEnabled ? PREVIEW_GEMINI_MODEL : DEFAULT_GEMINI_MODEL;
354191
- }
354192
- case GEMINI_MODEL_ALIAS_FLASH: {
354193
- return previewFeaturesEnabled ? PREVIEW_GEMINI_FLASH_MODEL : DEFAULT_GEMINI_FLASH_MODEL;
354194
- }
354195
- case GEMINI_MODEL_ALIAS_FLASH_LITE: {
354196
- return DEFAULT_GEMINI_FLASH_LITE_MODEL;
354197
- }
354198
- default: {
354199
- return requestedModel;
354200
- }
354201
- }
354202
- }
354203
- function resolveClassifierModel(requestedModel, modelAlias, previewFeaturesEnabled = false) {
354204
- if (modelAlias === GEMINI_MODEL_ALIAS_FLASH) {
354205
- if (requestedModel === DEFAULT_GEMINI_MODEL_AUTO || requestedModel === DEFAULT_GEMINI_MODEL) {
354206
- return DEFAULT_GEMINI_FLASH_MODEL;
354207
- }
354208
- if (requestedModel === PREVIEW_GEMINI_MODEL_AUTO || requestedModel === PREVIEW_GEMINI_MODEL) {
354209
- return PREVIEW_GEMINI_FLASH_MODEL;
354210
- }
354211
- return resolveModel(GEMINI_MODEL_ALIAS_FLASH, previewFeaturesEnabled);
354212
- }
354213
- return resolveModel(requestedModel, previewFeaturesEnabled);
354214
- }
354215
- function getEffectiveModel(requestedModel, previewFeaturesEnabled) {
354216
- return resolveModel(requestedModel, previewFeaturesEnabled);
354217
- }
354218
- function isPreviewModel(model) {
354219
- return model === PREVIEW_GEMINI_MODEL || model === PREVIEW_GEMINI_FLASH_MODEL || model === PREVIEW_GEMINI_MODEL_AUTO;
354220
- }
354221
- function isGemini2Model(model) {
354222
- return /^gemini-2(\.|$)/.test(model);
354223
- }
354224
- function supportsMultimodalFunctionResponse(model) {
354225
- return model.startsWith("gemini-3-");
354226
- }
354227
-
354228
354361
  // packages/core/dist/src/availability/policyCatalog.js
354229
354362
  var DEFAULT_ACTIONS = {
354230
354363
  terminal: "prompt",
@@ -354373,9 +354506,6 @@ function applyAvailabilityTransition(getContext, failureKind) {
354373
354506
  // packages/core/dist/src/fallback/handler.js
354374
354507
  var UPGRADE_URL_PAGE = "https://goo.gle/set-up-gemini-code-assist";
354375
354508
  async function handleFallback(config3, failedModel, authType, error2) {
354376
- return handlePolicyDrivenFallback(config3, failedModel, authType, error2);
354377
- }
354378
- async function handlePolicyDrivenFallback(config3, failedModel, authType, error2) {
354379
354509
  if (authType !== AuthType2.LOGIN_WITH_GOOGLE) {
354380
354510
  return null;
354381
354511
  }
@@ -355099,10 +355229,10 @@ function correctPath(filePath, config3) {
355099
355229
  }
355100
355230
  const workspaceContext = config3.getWorkspaceContext();
355101
355231
  const searchPaths = workspaceContext.getDirectories();
355102
- const basename15 = path48.basename(filePath);
355232
+ const basename14 = path48.basename(filePath);
355103
355233
  const normalizedTarget = filePath.replace(/\\/g, "/");
355104
355234
  const foundFiles = searchPaths.flatMap((searchPath) => bfsFileSearchSync(searchPath, {
355105
- fileName: basename15,
355235
+ fileName: basename14,
355106
355236
  maxDirs: 50,
355107
355237
  // Capped to avoid deep hangs
355108
355238
  fileService: config3.getFileService(),
@@ -360686,6 +360816,136 @@ function convertColorToHex(color, colorMode, defaultColor) {
360686
360816
  return defaultColor;
360687
360817
  }
360688
360818
 
360819
+ // packages/core/dist/src/services/environmentSanitization.js
360820
+ function sanitizeEnvironment(processEnv, config3) {
360821
+ if (!config3.enableEnvironmentVariableRedaction) {
360822
+ return { ...processEnv };
360823
+ }
360824
+ const results = {};
360825
+ const allowedSet = new Set((config3.allowedEnvironmentVariables || []).map((k) => k.toUpperCase()));
360826
+ const blockedSet = new Set((config3.blockedEnvironmentVariables || []).map((k) => k.toUpperCase()));
360827
+ const isStrictSanitization = !!processEnv["GITHUB_SHA"];
360828
+ for (const key in processEnv) {
360829
+ const value = processEnv[key];
360830
+ if (!shouldRedactEnvironmentVariable(key, value, allowedSet, blockedSet, isStrictSanitization)) {
360831
+ results[key] = value;
360832
+ }
360833
+ }
360834
+ return results;
360835
+ }
360836
+ var ALWAYS_ALLOWED_ENVIRONMENT_VARIABLES = /* @__PURE__ */ new Set([
360837
+ // Cross-platform
360838
+ "PATH",
360839
+ // Windows specific
360840
+ "SYSTEMROOT",
360841
+ "COMSPEC",
360842
+ "PATHEXT",
360843
+ "WINDIR",
360844
+ "TEMP",
360845
+ "TMP",
360846
+ "USERPROFILE",
360847
+ "SYSTEMDRIVE",
360848
+ // Unix/Linux/macOS specific
360849
+ "HOME",
360850
+ "LANG",
360851
+ "SHELL",
360852
+ "TMPDIR",
360853
+ "USER",
360854
+ "LOGNAME",
360855
+ // GitHub Action-related variables
360856
+ "ADDITIONAL_CONTEXT",
360857
+ "AVAILABLE_LABELS",
360858
+ "BRANCH_NAME",
360859
+ "DESCRIPTION",
360860
+ "EVENT_NAME",
360861
+ "GITHUB_ENV",
360862
+ "IS_PULL_REQUEST",
360863
+ "ISSUES_TO_TRIAGE",
360864
+ "ISSUE_BODY",
360865
+ "ISSUE_NUMBER",
360866
+ "ISSUE_TITLE",
360867
+ "PULL_REQUEST_NUMBER",
360868
+ "REPOSITORY",
360869
+ "TITLE",
360870
+ "TRIGGERING_ACTOR"
360871
+ ]);
360872
+ var NEVER_ALLOWED_ENVIRONMENT_VARIABLES = /* @__PURE__ */ new Set([
360873
+ "CLIENT_ID",
360874
+ "DB_URI",
360875
+ "CONNECTION_STRING",
360876
+ "AWS_DEFAULT_REGION",
360877
+ "AZURE_CLIENT_ID",
360878
+ "AZURE_TENANT_ID",
360879
+ "SLACK_WEBHOOK_URL",
360880
+ "TWILIO_ACCOUNT_SID",
360881
+ "DATABASE_URL",
360882
+ "GOOGLE_CLOUD_PROJECT",
360883
+ "GOOGLE_CLOUD_ACCOUNT",
360884
+ "FIREBASE_PROJECT_ID"
360885
+ ]);
360886
+ var NEVER_ALLOWED_NAME_PATTERNS = [
360887
+ /TOKEN/i,
360888
+ /SECRET/i,
360889
+ /PASSWORD/i,
360890
+ /PASSWD/i,
360891
+ /KEY/i,
360892
+ /AUTH/i,
360893
+ /CREDENTIAL/i,
360894
+ /CREDS/i,
360895
+ /PRIVATE/i,
360896
+ /CERT/i
360897
+ ];
360898
+ var NEVER_ALLOWED_VALUE_PATTERNS = [
360899
+ /-----BEGIN (RSA|OPENSSH|EC|PGP) PRIVATE KEY-----/i,
360900
+ /-----BEGIN CERTIFICATE-----/i,
360901
+ // Credentials in URL
360902
+ /(https?|ftp|smtp):\/\/[^:]+:[^@]+@/i,
360903
+ // GitHub tokens (classic, fine-grained, OAuth, etc.)
360904
+ /(ghp|gho|ghu|ghs|ghr|github_pat)_[a-zA-Z0-9_]{36,}/i,
360905
+ // Google API keys
360906
+ /AIzaSy[a-zA-Z0-9_\\-]{33}/i,
360907
+ // Amazon AWS Access Key ID
360908
+ /AKIA[A-Z0-9]{16}/i,
360909
+ // Generic OAuth/JWT tokens
360910
+ /eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]*/i,
360911
+ // Stripe API keys
360912
+ /(s|r)k_(live|test)_[0-9a-zA-Z]{24}/i,
360913
+ // Slack tokens (bot, user, etc.)
360914
+ /xox[abpr]-[a-zA-Z0-9-]+/i
360915
+ ];
360916
+ function shouldRedactEnvironmentVariable(key, value, allowedSet, blockedSet, isStrictSanitization = false) {
360917
+ key = key.toUpperCase();
360918
+ value = value?.toUpperCase();
360919
+ if (allowedSet?.has(key)) {
360920
+ return false;
360921
+ }
360922
+ if (blockedSet?.has(key)) {
360923
+ return true;
360924
+ }
360925
+ if (ALWAYS_ALLOWED_ENVIRONMENT_VARIABLES.has(key) || key.startsWith("GEMINI_CLI_")) {
360926
+ return false;
360927
+ }
360928
+ if (NEVER_ALLOWED_ENVIRONMENT_VARIABLES.has(key)) {
360929
+ return true;
360930
+ }
360931
+ if (isStrictSanitization) {
360932
+ return true;
360933
+ }
360934
+ for (const pattern of NEVER_ALLOWED_NAME_PATTERNS) {
360935
+ if (pattern.test(key)) {
360936
+ return true;
360937
+ }
360938
+ }
360939
+ if (value) {
360940
+ for (const pattern of NEVER_ALLOWED_VALUE_PATTERNS) {
360941
+ if (pattern.test(value)) {
360942
+ return true;
360943
+ }
360944
+ }
360945
+ }
360946
+ return false;
360947
+ }
360948
+
360689
360949
  // packages/core/dist/src/services/shellExecutionService.js
360690
360950
  var { Terminal } = import_headless.default;
360691
360951
  var SIGKILL_TIMEOUT_MS = 200;
@@ -360730,64 +360990,6 @@ var getFullBufferText = (terminal) => {
360730
360990
  }
360731
360991
  return lines.join("\n");
360732
360992
  };
360733
- function getSanitizedEnv() {
360734
- const isRunningInGithub = process.env["GITHUB_SHA"] || process.env["SURFACE"] === "Github";
360735
- if (!isRunningInGithub) {
360736
- return { ...process.env };
360737
- }
360738
- const env2 = {};
360739
- const essentialVars = [
360740
- // Cross-platform
360741
- "PATH",
360742
- // Windows specific
360743
- "Path",
360744
- "SYSTEMROOT",
360745
- "SystemRoot",
360746
- "COMSPEC",
360747
- "ComSpec",
360748
- "PATHEXT",
360749
- "WINDIR",
360750
- "TEMP",
360751
- "TMP",
360752
- "USERPROFILE",
360753
- "SYSTEMDRIVE",
360754
- "SystemDrive",
360755
- // Unix/Linux/macOS specific
360756
- "HOME",
360757
- "LANG",
360758
- "SHELL",
360759
- "TMPDIR",
360760
- "USER",
360761
- "LOGNAME",
360762
- // GitHub Action-related variables
360763
- "ADDITIONAL_CONTEXT",
360764
- "AVAILABLE_LABELS",
360765
- "BRANCH_NAME",
360766
- "DESCRIPTION",
360767
- "EVENT_NAME",
360768
- "GITHUB_ENV",
360769
- "IS_PULL_REQUEST",
360770
- "ISSUES_TO_TRIAGE",
360771
- "ISSUE_BODY",
360772
- "ISSUE_NUMBER",
360773
- "ISSUE_TITLE",
360774
- "PULL_REQUEST_NUMBER",
360775
- "REPOSITORY",
360776
- "TITLE",
360777
- "TRIGGERING_ACTOR"
360778
- ];
360779
- for (const key of essentialVars) {
360780
- if (process.env[key] !== void 0) {
360781
- env2[key] = process.env[key];
360782
- }
360783
- }
360784
- for (const key in process.env) {
360785
- if (key.startsWith("GEMINI_CLI_")) {
360786
- env2[key] = process.env[key];
360787
- }
360788
- }
360789
- return env2;
360790
- }
360791
360993
  var ShellExecutionService = class {
360792
360994
  static activePtys = /* @__PURE__ */ new Map();
360793
360995
  /**
@@ -360810,7 +361012,7 @@ var ShellExecutionService = class {
360810
361012
  }
360811
361013
  }
360812
361014
  }
360813
- return this.childProcessFallback(commandToExecute, cwd, onOutputEvent, abortSignal);
361015
+ return this.childProcessFallback(commandToExecute, cwd, onOutputEvent, abortSignal, shellExecutionConfig.sanitizationConfig);
360814
361016
  }
360815
361017
  static appendAndTruncate(currentBuffer, chunk2, maxSize) {
360816
361018
  const chunkLength = chunk2.length;
@@ -360829,7 +361031,7 @@ var ShellExecutionService = class {
360829
361031
  const truncatedBuffer = currentBuffer.substring(charsToTrim);
360830
361032
  return { newBuffer: truncatedBuffer + chunk2, truncated: true };
360831
361033
  }
360832
- static childProcessFallback(commandToExecute, cwd, onOutputEvent, abortSignal) {
361034
+ static childProcessFallback(commandToExecute, cwd, onOutputEvent, abortSignal, sanitizationConfig) {
360833
361035
  try {
360834
361036
  const isWindows5 = os16.platform() === "win32";
360835
361037
  const { executable, argsPrefix, shell } = getShellConfiguration();
@@ -360842,7 +361044,7 @@ var ShellExecutionService = class {
360842
361044
  shell: false,
360843
361045
  detached: !isWindows5,
360844
361046
  env: {
360845
- ...getSanitizedEnv(),
361047
+ ...sanitizeEnvironment(process.env, sanitizationConfig),
360846
361048
  GEMINI_CLI: "1",
360847
361049
  TERM: "xterm-256color",
360848
361050
  PAGER: "cat",
@@ -361011,7 +361213,7 @@ var ShellExecutionService = class {
361011
361213
  cols,
361012
361214
  rows,
361013
361215
  env: {
361014
- ...getSanitizedEnv(),
361216
+ ...sanitizeEnvironment(process.env, shellExecutionConfig.sanitizationConfig),
361015
361217
  GEMINI_CLI: "1",
361016
361218
  TERM: "xterm-256color",
361017
361219
  PAGER: shellExecutionConfig.pager ?? "cat",
@@ -361314,6 +361516,24 @@ var ShellExecutionService = class {
361314
361516
  };
361315
361517
 
361316
361518
  // packages/core/dist/src/utils/tool-utils.js
361519
+ var import_fast_levenshtein = __toESM(require_levenshtein(), 1);
361520
+ function getToolSuggestion(unknownToolName, allToolNames, topN = 3) {
361521
+ const matches = allToolNames.map((toolName) => ({
361522
+ name: toolName,
361523
+ distance: import_fast_levenshtein.default.get(unknownToolName, toolName)
361524
+ }));
361525
+ matches.sort((a2, b) => a2.distance - b.distance);
361526
+ const topNResults = matches.slice(0, topN);
361527
+ if (topNResults.length === 0) {
361528
+ return "";
361529
+ }
361530
+ const suggestedNames = topNResults.map((match2) => `"${match2.name}"`).join(", ");
361531
+ if (topNResults.length > 1) {
361532
+ return ` Did you mean one of: ${suggestedNames}?`;
361533
+ } else {
361534
+ return ` Did you mean ${suggestedNames}?`;
361535
+ }
361536
+ }
361317
361537
  function doesToolInvocationMatch(toolOrToolName, invocation, patterns) {
361318
361538
  let toolNames;
361319
361539
  if (isTool(toolOrToolName)) {
@@ -361508,7 +361728,12 @@ var ShellToolInvocation = class extends BaseToolInvocation {
361508
361728
  return description;
361509
361729
  }
361510
361730
  getPolicyUpdateOptions(outcome) {
361511
- if (outcome === ToolConfirmationOutcome.ProceedAlwaysAndSave) {
361731
+ if (outcome === ToolConfirmationOutcome.ProceedAlwaysAndSave || outcome === ToolConfirmationOutcome.ProceedAlways) {
361732
+ const command = stripShellWrapper(this.params.command);
361733
+ const rootCommands = [...new Set(getCommandRoots(command))];
361734
+ if (rootCommands.length > 0) {
361735
+ return { commandPrefix: rootCommands };
361736
+ }
361512
361737
  return { commandPrefix: this.params.command };
361513
361738
  }
361514
361739
  return void 0;
@@ -361615,7 +361840,11 @@ var ShellToolInvocation = class extends BaseToolInvocation {
361615
361840
  updateOutput(cumulativeOutput);
361616
361841
  lastUpdateTime = Date.now();
361617
361842
  }
361618
- }, combinedController.signal, this.config.getEnableInteractiveShell(), { ...shellExecutionConfig, pager: "cat" });
361843
+ }, combinedController.signal, this.config.getEnableInteractiveShell(), {
361844
+ ...shellExecutionConfig,
361845
+ pager: "cat",
361846
+ sanitizationConfig: shellExecutionConfig?.sanitizationConfig ?? this.config.sanitizationConfig
361847
+ });
361619
361848
  if (pid && setPidCallback) {
361620
361849
  setPidCallback(pid);
361621
361850
  }
@@ -367694,11 +367923,6 @@ My setup is complete. I will provide my first command in the next turn.
367694
367923
  ];
367695
367924
  }
367696
367925
 
367697
- // packages/core/dist/src/core/coreToolScheduler.js
367698
- import * as fs48 from "node:fs/promises";
367699
- import * as path53 from "node:path";
367700
- var import_fast_levenshtein = __toESM(require_levenshtein(), 1);
367701
-
367702
367926
  // packages/core/dist/src/hooks/hookTranslator.js
367703
367927
  var HookTranslator = class {
367704
367928
  };
@@ -367868,6 +368092,13 @@ var HookTranslatorGenAIv1 = class extends HookTranslator {
367868
368092
  var defaultHookTranslator = new HookTranslatorGenAIv1();
367869
368093
 
367870
368094
  // packages/core/dist/src/hooks/types.js
368095
+ var ConfigSource;
368096
+ (function(ConfigSource2) {
368097
+ ConfigSource2["Project"] = "project";
368098
+ ConfigSource2["User"] = "user";
368099
+ ConfigSource2["System"] = "system";
368100
+ ConfigSource2["Extensions"] = "extensions";
368101
+ })(ConfigSource || (ConfigSource = {}));
367871
368102
  var HookEventName;
367872
368103
  (function(HookEventName2) {
367873
368104
  HookEventName2["BeforeTool"] = "BeforeTool";
@@ -367886,6 +368117,11 @@ var HookType;
367886
368117
  (function(HookType2) {
367887
368118
  HookType2["Command"] = "command";
367888
368119
  })(HookType || (HookType = {}));
368120
+ function getHookKey(hook) {
368121
+ const name4 = hook.name || "";
368122
+ const command = hook.command || "";
368123
+ return `${name4}:${command}`;
368124
+ }
367889
368125
  function createHookOutput(eventName, data) {
367890
368126
  switch (eventName) {
367891
368127
  case "BeforeModel":
@@ -367969,32 +368205,6 @@ var DefaultHookOutput = class {
367969
368205
  }
367970
368206
  };
367971
368207
  var BeforeToolHookOutput = class extends DefaultHookOutput {
367972
- /**
367973
- * Get the effective blocking reason, considering compatibility fields
367974
- */
367975
- getEffectiveReason() {
367976
- if (this.hookSpecificOutput) {
367977
- if ("permissionDecisionReason" in this.hookSpecificOutput) {
367978
- const compatReason = this.hookSpecificOutput["permissionDecisionReason"];
367979
- if (typeof compatReason === "string") {
367980
- return compatReason;
367981
- }
367982
- }
367983
- }
367984
- return super.getEffectiveReason();
367985
- }
367986
- /**
367987
- * Check if this output represents a blocking decision, considering compatibility fields
367988
- */
367989
- isBlockingDecision() {
367990
- if (this.hookSpecificOutput && "permissionDecision" in this.hookSpecificOutput) {
367991
- const compatDecision = this.hookSpecificOutput["permissionDecision"];
367992
- if (compatDecision === "block" || compatDecision === "deny") {
367993
- return true;
367994
- }
367995
- }
367996
- return super.isBlockingDecision();
367997
- }
367998
368208
  };
367999
368209
  var BeforeModelHookOutput = class extends DefaultHookOutput {
368000
368210
  /**
@@ -368271,83 +368481,6 @@ async function executeToolWithHooks(invocation, toolName, signal, messageBus, ho
368271
368481
  }
368272
368482
 
368273
368483
  // packages/core/dist/src/core/coreToolScheduler.js
368274
- function createFunctionResponsePart(callId, toolName, output) {
368275
- return {
368276
- functionResponse: {
368277
- id: callId,
368278
- name: toolName,
368279
- response: { output }
368280
- }
368281
- };
368282
- }
368283
- function convertToFunctionResponse(toolName, callId, llmContent, model) {
368284
- if (typeof llmContent === "string") {
368285
- return [createFunctionResponsePart(callId, toolName, llmContent)];
368286
- }
368287
- const parts2 = toParts2(llmContent);
368288
- const textParts = [];
368289
- const inlineDataParts = [];
368290
- const fileDataParts = [];
368291
- for (const part2 of parts2) {
368292
- if (part2.text !== void 0) {
368293
- textParts.push(part2.text);
368294
- } else if (part2.inlineData) {
368295
- inlineDataParts.push(part2);
368296
- } else if (part2.fileData) {
368297
- fileDataParts.push(part2);
368298
- } else if (part2.functionResponse) {
368299
- if (parts2.length > 1) {
368300
- debugLogger.warn("convertToFunctionResponse received multiple parts with a functionResponse. Only the functionResponse will be used, other parts will be ignored");
368301
- }
368302
- return [
368303
- {
368304
- functionResponse: {
368305
- id: callId,
368306
- name: toolName,
368307
- response: part2.functionResponse.response
368308
- }
368309
- }
368310
- ];
368311
- }
368312
- }
368313
- const part = {
368314
- functionResponse: {
368315
- id: callId,
368316
- name: toolName,
368317
- response: textParts.length > 0 ? { output: textParts.join("\n") } : {}
368318
- }
368319
- };
368320
- const isMultimodalFRSupported = supportsMultimodalFunctionResponse(model);
368321
- const siblingParts = [...fileDataParts];
368322
- if (inlineDataParts.length > 0) {
368323
- if (isMultimodalFRSupported) {
368324
- part.functionResponse.parts = inlineDataParts;
368325
- } else {
368326
- siblingParts.push(...inlineDataParts);
368327
- }
368328
- }
368329
- if (textParts.length === 0 && (inlineDataParts.length > 0 || fileDataParts.length > 0)) {
368330
- const totalBinaryItems = inlineDataParts.length + fileDataParts.length;
368331
- part.functionResponse.response = {
368332
- output: `Binary content provided (${totalBinaryItems} item(s)).`
368333
- };
368334
- }
368335
- if (siblingParts.length > 0) {
368336
- return [part, ...siblingParts];
368337
- }
368338
- return [part];
368339
- }
368340
- function toParts2(input) {
368341
- const parts2 = [];
368342
- for (const part of Array.isArray(input) ? input : [input]) {
368343
- if (typeof part === "string") {
368344
- parts2.push({ text: part });
368345
- } else if (part) {
368346
- parts2.push(part);
368347
- }
368348
- }
368349
- return parts2;
368350
- }
368351
368484
  var createErrorResponse = (request3, error2, errorType) => ({
368352
368485
  callId: request3.callId,
368353
368486
  error: error2,
@@ -368364,55 +368497,6 @@ var createErrorResponse = (request3, error2, errorType) => ({
368364
368497
  errorType,
368365
368498
  contentLength: error2.message.length
368366
368499
  });
368367
- async function truncateAndSaveToFile(content, callId, projectTempDir, threshold, truncateLines) {
368368
- if (content.length <= threshold) {
368369
- return { content };
368370
- }
368371
- let lines = content.split("\n");
368372
- let fileContent = content;
368373
- if (lines.length <= truncateLines) {
368374
- const wrapWidth = 120;
368375
- const wrappedLines = [];
368376
- for (const line of lines) {
368377
- if (line.length > wrapWidth) {
368378
- for (let i4 = 0; i4 < line.length; i4 += wrapWidth) {
368379
- wrappedLines.push(line.substring(i4, i4 + wrapWidth));
368380
- }
368381
- } else {
368382
- wrappedLines.push(line);
368383
- }
368384
- }
368385
- lines = wrappedLines;
368386
- fileContent = lines.join("\n");
368387
- }
368388
- const head = Math.floor(truncateLines / 5);
368389
- const beginning = lines.slice(0, head);
368390
- const end = lines.slice(-(truncateLines - head));
368391
- const truncatedContent = beginning.join("\n") + "\n... [CONTENT TRUNCATED] ...\n" + end.join("\n");
368392
- const safeFileName = `${path53.basename(callId)}.output`;
368393
- const outputFile = path53.join(projectTempDir, safeFileName);
368394
- try {
368395
- await fs48.writeFile(outputFile, fileContent);
368396
- return {
368397
- content: `Tool output was too large and has been truncated.
368398
- The full output has been saved to: ${outputFile}
368399
- To read the complete output, use the ${READ_FILE_TOOL_NAME} tool with the absolute file path above. For large files, you can use the offset and limit parameters to read specific sections:
368400
- - ${READ_FILE_TOOL_NAME} tool with offset=0, limit=100 to see the first 100 lines
368401
- - ${READ_FILE_TOOL_NAME} tool with offset=N to skip N lines from the beginning
368402
- - ${READ_FILE_TOOL_NAME} tool with limit=M to read only M lines at a time
368403
- The truncated output below shows the beginning and end of the content. The marker '... [CONTENT TRUNCATED] ...' indicates where content was removed.
368404
- This allows you to efficiently examine different parts of the output without loading the entire file.
368405
- Truncated part of the output:
368406
- ${truncatedContent}`,
368407
- outputFile
368408
- };
368409
- } catch (_error) {
368410
- return {
368411
- content: truncatedContent + `
368412
- [Note: Could not save full output to file]`
368413
- };
368414
- }
368415
- }
368416
368500
  var CoreToolScheduler = class _CoreToolScheduler {
368417
368501
  // Static WeakMap to track which MessageBus instances already have a handler subscribed
368418
368502
  // This prevents duplicate subscriptions when multiple CoreToolScheduler instances are created
@@ -368606,31 +368690,6 @@ var CoreToolScheduler = class _CoreToolScheduler {
368606
368690
  return new Error(String(e3));
368607
368691
  }
368608
368692
  }
368609
- /**
368610
- * Generates a suggestion string for a tool name that was not found in the registry.
368611
- * It finds the closest matches based on Levenshtein distance.
368612
- * @param unknownToolName The tool name that was not found.
368613
- * @param topN The number of suggestions to return. Defaults to 3.
368614
- * @returns A suggestion string like " Did you mean 'tool'?" or " Did you mean one of: 'tool1', 'tool2'?", or an empty string if no suggestions are found.
368615
- */
368616
- getToolSuggestion(unknownToolName, topN = 3) {
368617
- const allToolNames = this.config.getToolRegistry().getAllToolNames();
368618
- const matches = allToolNames.map((toolName) => ({
368619
- name: toolName,
368620
- distance: import_fast_levenshtein.default.get(unknownToolName, toolName)
368621
- }));
368622
- matches.sort((a2, b) => a2.distance - b.distance);
368623
- const topNResults = matches.slice(0, topN);
368624
- if (topNResults.length === 0) {
368625
- return "";
368626
- }
368627
- const suggestedNames = topNResults.map((match2) => `"${match2.name}"`).join(", ");
368628
- if (topNResults.length > 1) {
368629
- return ` Did you mean one of: ${suggestedNames}?`;
368630
- } else {
368631
- return ` Did you mean ${suggestedNames}?`;
368632
- }
368633
- }
368634
368693
  schedule(request3, signal) {
368635
368694
  return runInDevTraceSpan({ name: "schedule" }, async ({ metadata: spanMetadata }) => {
368636
368695
  spanMetadata.input = request3;
@@ -368687,7 +368746,7 @@ var CoreToolScheduler = class _CoreToolScheduler {
368687
368746
  const newToolCalls = requestsToProcess.map((reqInfo) => {
368688
368747
  const toolInstance = this.config.getToolRegistry().getTool(reqInfo.name);
368689
368748
  if (!toolInstance) {
368690
- const suggestion = this.getToolSuggestion(reqInfo.name);
368749
+ const suggestion = getToolSuggestion(reqInfo.name, this.config.getToolRegistry().getAllToolNames());
368691
368750
  const errorMessage = `Tool "${reqInfo.name}" not found in registry. Tools must use the exact names that are registered.${suggestion}`;
368692
368751
  return {
368693
368752
  status: "error",
@@ -368902,7 +368961,7 @@ var CoreToolScheduler = class _CoreToolScheduler {
368902
368961
  const originalContentLength = content.length;
368903
368962
  const threshold = this.config.getTruncateToolOutputThreshold();
368904
368963
  const lines = this.config.getTruncateToolOutputLines();
368905
- const truncatedResult = await truncateAndSaveToFile(content, callId, this.config.storage.getProjectTempDir(), threshold, lines);
368964
+ const truncatedResult = await saveTruncatedContent(content, callId, this.config.storage.getProjectTempDir(), threshold, lines);
368906
368965
  content = truncatedResult.content;
368907
368966
  outputFile = truncatedResult.outputFile;
368908
368967
  if (outputFile) {
@@ -369071,8 +369130,8 @@ function parseThought(rawText) {
369071
369130
  }
369072
369131
 
369073
369132
  // packages/core/dist/src/services/chatRecordingService.js
369074
- import path54 from "node:path";
369075
- import fs49 from "node:fs";
369133
+ import path53 from "node:path";
369134
+ import fs48 from "node:fs";
369076
369135
  import { randomUUID as randomUUID5 } from "node:crypto";
369077
369136
  var SESSION_FILE_PREFIX = "session-";
369078
369137
  var ChatRecordingService = class {
@@ -369102,11 +369161,11 @@ var ChatRecordingService = class {
369102
369161
  });
369103
369162
  this.cachedLastConvData = null;
369104
369163
  } else {
369105
- const chatsDir = path54.join(this.config.storage.getProjectTempDir(), "chats");
369106
- fs49.mkdirSync(chatsDir, { recursive: true });
369164
+ const chatsDir = path53.join(this.config.storage.getProjectTempDir(), "chats");
369165
+ fs48.mkdirSync(chatsDir, { recursive: true });
369107
369166
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 16).replace(/:/g, "-");
369108
369167
  const filename = `${SESSION_FILE_PREFIX}${timestamp}-${this.sessionId.slice(0, 8)}.json`;
369109
- this.conversationFile = path54.join(chatsDir, filename);
369168
+ this.conversationFile = path53.join(chatsDir, filename);
369110
369169
  this.writeConversation({
369111
369170
  sessionId: this.sessionId,
369112
369171
  projectHash: this.projectHash,
@@ -369276,7 +369335,7 @@ var ChatRecordingService = class {
369276
369335
  */
369277
369336
  readConversation() {
369278
369337
  try {
369279
- this.cachedLastConvData = fs49.readFileSync(this.conversationFile, "utf8");
369338
+ this.cachedLastConvData = fs48.readFileSync(this.conversationFile, "utf8");
369280
369339
  return JSON.parse(this.cachedLastConvData);
369281
369340
  } catch (error2) {
369282
369341
  if (error2.code !== "ENOENT") {
@@ -369305,7 +369364,7 @@ var ChatRecordingService = class {
369305
369364
  conversation.lastUpdated = (/* @__PURE__ */ new Date()).toISOString();
369306
369365
  const newContent = JSON.stringify(conversation, null, 2);
369307
369366
  this.cachedLastConvData = newContent;
369308
- fs49.writeFileSync(this.conversationFile, newContent);
369367
+ fs48.writeFileSync(this.conversationFile, newContent);
369309
369368
  }
369310
369369
  } catch (error2) {
369311
369370
  debugLogger.error("Error writing conversation file.", error2);
@@ -369360,9 +369419,9 @@ var ChatRecordingService = class {
369360
369419
  */
369361
369420
  deleteSession(sessionId2) {
369362
369421
  try {
369363
- const chatsDir = path54.join(this.config.storage.getProjectTempDir(), "chats");
369364
- const sessionPath = path54.join(chatsDir, `${sessionId2}.json`);
369365
- fs49.unlinkSync(sessionPath);
369422
+ const chatsDir = path53.join(this.config.storage.getProjectTempDir(), "chats");
369423
+ const sessionPath = path53.join(chatsDir, `${sessionId2}.json`);
369424
+ fs48.unlinkSync(sessionPath);
369366
369425
  } catch (error2) {
369367
369426
  debugLogger.error("Error deleting session file.", error2);
369368
369427
  throw error2;
@@ -370202,8 +370261,8 @@ ${[...this.pendingCitations].sort().join("\n")}`
370202
370261
  };
370203
370262
 
370204
370263
  // packages/core/dist/src/core/prompts.js
370205
- import path55 from "node:path";
370206
- import fs50 from "node:fs";
370264
+ import path54 from "node:path";
370265
+ import fs49 from "node:fs";
370207
370266
  import os18 from "node:os";
370208
370267
  import process21 from "node:process";
370209
370268
 
@@ -370523,7 +370582,7 @@ function resolvePathFromEnv(envVar) {
370523
370582
  if (customPath === "~") {
370524
370583
  customPath = home;
370525
370584
  } else {
370526
- customPath = path55.join(home, customPath.slice(2));
370585
+ customPath = path54.join(home, customPath.slice(2));
370527
370586
  }
370528
370587
  } catch (error2) {
370529
370588
  debugLogger.warn(`Could not resolve home directory for path: ${trimmedEnvVar}`, error2);
@@ -370532,20 +370591,20 @@ function resolvePathFromEnv(envVar) {
370532
370591
  }
370533
370592
  return {
370534
370593
  isSwitch: false,
370535
- value: path55.resolve(customPath),
370594
+ value: path54.resolve(customPath),
370536
370595
  isDisabled: false
370537
370596
  };
370538
370597
  }
370539
370598
  function getCoreSystemPrompt(config3, userMemory) {
370540
370599
  let systemMdEnabled = false;
370541
- let systemMdPath = path55.resolve(path55.join(GEMINI_DIR, "system.md"));
370600
+ let systemMdPath = path54.resolve(path54.join(GEMINI_DIR, "system.md"));
370542
370601
  const systemMdResolution = resolvePathFromEnv(process21.env["GEMINI_SYSTEM_MD"]);
370543
370602
  if (systemMdResolution.value && !systemMdResolution.isDisabled) {
370544
370603
  systemMdEnabled = true;
370545
370604
  if (!systemMdResolution.isSwitch) {
370546
370605
  systemMdPath = systemMdResolution.value;
370547
370606
  }
370548
- if (!fs50.existsSync(systemMdPath)) {
370607
+ if (!fs49.existsSync(systemMdPath)) {
370549
370608
  throw new Error(`missing system prompt file '${systemMdPath}'`);
370550
370609
  }
370551
370610
  }
@@ -370558,7 +370617,7 @@ function getCoreSystemPrompt(config3, userMemory) {
370558
370617
  const interactiveMode = config3.isInteractiveShellEnabled();
370559
370618
  let basePrompt;
370560
370619
  if (systemMdEnabled) {
370561
- basePrompt = fs50.readFileSync(systemMdPath, "utf8");
370620
+ basePrompt = fs49.readFileSync(systemMdPath, "utf8");
370562
370621
  } else {
370563
370622
  const promptConfig = {
370564
370623
  preamble: `You are ${interactiveMode ? "an interactive " : "a non-interactive "}CLI agent specializing in software engineering tasks. Your primary goal is to help users safely and efficiently, adhering strictly to the following instructions and utilizing your available tools.`,
@@ -370764,8 +370823,8 @@ Your core function is efficient and safe assistance. Balance extreme conciseness
370764
370823
  const writeSystemMdResolution = resolvePathFromEnv(process21.env["GEMINI_WRITE_SYSTEM_MD"]);
370765
370824
  if (writeSystemMdResolution.value && !writeSystemMdResolution.isDisabled) {
370766
370825
  const writePath = writeSystemMdResolution.isSwitch ? systemMdPath : writeSystemMdResolution.value;
370767
- fs50.mkdirSync(path55.dirname(writePath), { recursive: true });
370768
- fs50.writeFileSync(writePath, basePrompt);
370826
+ fs49.mkdirSync(path54.dirname(writePath), { recursive: true });
370827
+ fs49.writeFileSync(writePath, basePrompt);
370769
370828
  }
370770
370829
  const memorySuffix = userMemory && userMemory.trim().length > 0 ? `
370771
370830
 
@@ -371723,7 +371782,7 @@ var GeminiClient = class {
371723
371782
  };
371724
371783
  }
371725
371784
  }
371726
- _getEffectiveModelForCurrentTurn() {
371785
+ _getActiveModelForCurrentTurn() {
371727
371786
  if (this.currentSequenceModel) {
371728
371787
  return this.currentSequenceModel;
371729
371788
  }
@@ -371766,7 +371825,7 @@ var GeminiClient = class {
371766
371825
  if (!boundedTurns) {
371767
371826
  return new Turn(this.getChat(), prompt_id);
371768
371827
  }
371769
- const modelForLimitCheck = this._getEffectiveModelForCurrentTurn();
371828
+ const modelForLimitCheck = this._getActiveModelForCurrentTurn();
371770
371829
  const estimatedRequestTokenCount = await calculateRequestTokenCount(request3, this.getContentGeneratorOrFail(), modelForLimitCheck);
371771
371830
  const remainingTokenCount = tokenLimit(modelForLimitCheck) - this.getChat().getLastPromptTokenCount();
371772
371831
  if (estimatedRequestTokenCount > remainingTokenCount * 0.95) {
@@ -371933,7 +371992,7 @@ var GeminiClient = class {
371933
371992
  }
371934
371993
  }
371935
371994
  async tryCompressChat(prompt_id, force = false) {
371936
- const model = this._getEffectiveModelForCurrentTurn();
371995
+ const model = this._getActiveModelForCurrentTurn();
371937
371996
  const { newHistory, info: info2 } = await this.compressionService.compress(this.getChat(), prompt_id, force, model, this.config, this.hasFailedCompressionAttempt);
371938
371997
  if (info2.compressionStatus === CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT) {
371939
371998
  this.hasFailedCompressionAttempt = this.hasFailedCompressionAttempt || !force;
@@ -371950,8 +372009,8 @@ var GeminiClient = class {
371950
372009
 
371951
372010
  // packages/core/dist/src/utils/gitIgnoreParser.js
371952
372011
  var import_ignore4 = __toESM(require_ignore(), 1);
371953
- import * as fs51 from "node:fs";
371954
- import * as path56 from "node:path";
372012
+ import * as fs50 from "node:fs";
372013
+ import * as path55 from "node:path";
371955
372014
  var GitIgnoreParser = class {
371956
372015
  extraPatterns;
371957
372016
  projectRoot;
@@ -371960,7 +372019,7 @@ var GitIgnoreParser = class {
371960
372019
  processedExtraPatterns = [];
371961
372020
  constructor(projectRoot, extraPatterns) {
371962
372021
  this.extraPatterns = extraPatterns;
371963
- this.projectRoot = path56.resolve(projectRoot);
372022
+ this.projectRoot = path55.resolve(projectRoot);
371964
372023
  if (this.extraPatterns) {
371965
372024
  this.processedExtraPatterns = this.processPatterns(this.extraPatterns, ".");
371966
372025
  }
@@ -371968,12 +372027,12 @@ var GitIgnoreParser = class {
371968
372027
  loadPatternsForFile(patternsFilePath) {
371969
372028
  let content;
371970
372029
  try {
371971
- content = fs51.readFileSync(patternsFilePath, "utf-8");
372030
+ content = fs50.readFileSync(patternsFilePath, "utf-8");
371972
372031
  } catch (_error) {
371973
372032
  return [];
371974
372033
  }
371975
- const isExcludeFile = patternsFilePath.endsWith(path56.join(".git", "info", "exclude"));
371976
- const relativeBaseDir = isExcludeFile ? "." : path56.dirname(path56.relative(this.projectRoot, patternsFilePath)).split(path56.sep).join(path56.posix.sep);
372034
+ const isExcludeFile = patternsFilePath.endsWith(path55.join(".git", "info", "exclude"));
372035
+ const relativeBaseDir = isExcludeFile ? "." : path55.dirname(path55.relative(this.projectRoot, patternsFilePath)).split(path55.sep).join(path55.posix.sep);
371977
372036
  const rawPatterns = content.split("\n");
371978
372037
  return this.processPatterns(rawPatterns, relativeBaseDir);
371979
372038
  }
@@ -371993,9 +372052,9 @@ var GitIgnoreParser = class {
371993
372052
  let newPattern = p;
371994
372053
  if (relativeBaseDir && relativeBaseDir !== ".") {
371995
372054
  if (!isAnchoredInFile && !p.includes("/")) {
371996
- newPattern = path56.posix.join("**", p);
372055
+ newPattern = path55.posix.join("**", p);
371997
372056
  }
371998
- newPattern = path56.posix.join(relativeBaseDir, newPattern);
372057
+ newPattern = path55.posix.join(relativeBaseDir, newPattern);
371999
372058
  if (!newPattern.startsWith("/")) {
372000
372059
  newPattern = "/" + newPattern;
372001
372060
  }
@@ -372013,13 +372072,13 @@ var GitIgnoreParser = class {
372013
372072
  if (!filePath || typeof filePath !== "string") {
372014
372073
  return false;
372015
372074
  }
372016
- const absoluteFilePath = path56.resolve(this.projectRoot, filePath);
372075
+ const absoluteFilePath = path55.resolve(this.projectRoot, filePath);
372017
372076
  if (!absoluteFilePath.startsWith(this.projectRoot)) {
372018
372077
  return false;
372019
372078
  }
372020
372079
  try {
372021
- const resolved = path56.resolve(this.projectRoot, filePath);
372022
- const relativePath = path56.relative(this.projectRoot, resolved);
372080
+ const resolved = path55.resolve(this.projectRoot, filePath);
372081
+ const relativePath = path55.relative(this.projectRoot, resolved);
372023
372082
  if (relativePath === "" || relativePath.startsWith("..")) {
372024
372083
  return false;
372025
372084
  }
@@ -372030,19 +372089,19 @@ var GitIgnoreParser = class {
372030
372089
  const ig = (0, import_ignore4.default)();
372031
372090
  ig.add(".git");
372032
372091
  if (this.globalPatterns === void 0) {
372033
- const excludeFile = path56.join(this.projectRoot, ".git", "info", "exclude");
372034
- this.globalPatterns = fs51.existsSync(excludeFile) ? this.loadPatternsForFile(excludeFile) : [];
372092
+ const excludeFile = path55.join(this.projectRoot, ".git", "info", "exclude");
372093
+ this.globalPatterns = fs50.existsSync(excludeFile) ? this.loadPatternsForFile(excludeFile) : [];
372035
372094
  }
372036
372095
  ig.add(this.globalPatterns);
372037
- const pathParts = relativePath.split(path56.sep);
372096
+ const pathParts = relativePath.split(path55.sep);
372038
372097
  const dirsToVisit = [this.projectRoot];
372039
372098
  let currentAbsDir = this.projectRoot;
372040
372099
  for (let i4 = 0; i4 < pathParts.length - 1; i4++) {
372041
- currentAbsDir = path56.join(currentAbsDir, pathParts[i4]);
372100
+ currentAbsDir = path55.join(currentAbsDir, pathParts[i4]);
372042
372101
  dirsToVisit.push(currentAbsDir);
372043
372102
  }
372044
372103
  for (const dir of dirsToVisit) {
372045
- const relativeDir = path56.relative(this.projectRoot, dir);
372104
+ const relativeDir = path55.relative(this.projectRoot, dir);
372046
372105
  if (relativeDir) {
372047
372106
  const normalizedRelativeDir = relativeDir.replace(/\\/g, "/");
372048
372107
  const igPlusExtras = (0, import_ignore4.default)().add(ig).add(this.processedExtraPatterns);
@@ -372056,8 +372115,8 @@ var GitIgnoreParser = class {
372056
372115
  ig.add(patterns);
372057
372116
  }
372058
372117
  } else {
372059
- const gitignorePath = path56.join(dir, ".gitignore");
372060
- if (fs51.existsSync(gitignorePath)) {
372118
+ const gitignorePath = path55.join(dir, ".gitignore");
372119
+ if (fs50.existsSync(gitignorePath)) {
372061
372120
  const patterns = this.loadPatternsForFile(gitignorePath);
372062
372121
  this.cache.set(dir, patterns);
372063
372122
  ig.add(patterns);
@@ -372077,14 +372136,14 @@ var GitIgnoreParser = class {
372077
372136
  };
372078
372137
 
372079
372138
  // packages/core/dist/src/services/fileDiscoveryService.js
372080
- import * as path57 from "node:path";
372139
+ import * as path56 from "node:path";
372081
372140
  var FileDiscoveryService = class {
372082
372141
  gitIgnoreFilter = null;
372083
372142
  geminiIgnoreFilter = null;
372084
372143
  combinedIgnoreFilter = null;
372085
372144
  projectRoot;
372086
372145
  constructor(projectRoot) {
372087
- this.projectRoot = path57.resolve(projectRoot);
372146
+ this.projectRoot = path56.resolve(projectRoot);
372088
372147
  if (isGitRepository(this.projectRoot)) {
372089
372148
  this.gitIgnoreFilter = new GitIgnoreParser(this.projectRoot);
372090
372149
  }
@@ -372136,8 +372195,8 @@ var FileDiscoveryService = class {
372136
372195
  };
372137
372196
 
372138
372197
  // packages/core/dist/src/services/gitService.js
372139
- import * as fs52 from "node:fs/promises";
372140
- import * as path58 from "node:path";
372198
+ import * as fs51 from "node:fs/promises";
372199
+ import * as path57 from "node:path";
372141
372200
 
372142
372201
  // node_modules/simple-git/dist/esm/index.js
372143
372202
  var import_file_exists = __toESM(require_dist8(), 1);
@@ -376665,7 +376724,7 @@ var GitService = class {
376665
376724
  projectRoot;
376666
376725
  storage;
376667
376726
  constructor(projectRoot, storage2) {
376668
- this.projectRoot = path58.resolve(projectRoot);
376727
+ this.projectRoot = path57.resolve(projectRoot);
376669
376728
  this.storage = storage2;
376670
376729
  }
376671
376730
  getHistoryDir() {
@@ -376696,34 +376755,39 @@ var GitService = class {
376696
376755
  */
376697
376756
  async setupShadowGitRepository() {
376698
376757
  const repoDir = this.getHistoryDir();
376699
- const gitConfigPath = path58.join(repoDir, ".gitconfig");
376700
- await fs52.mkdir(repoDir, { recursive: true });
376758
+ const gitConfigPath = path57.join(repoDir, ".gitconfig");
376759
+ await fs51.mkdir(repoDir, { recursive: true });
376701
376760
  const gitConfigContent = "[user]\n name = Gemini CLI\n email = gemini-cli@google.com\n[commit]\n gpgsign = false\n";
376702
- await fs52.writeFile(gitConfigPath, gitConfigContent);
376761
+ await fs51.writeFile(gitConfigPath, gitConfigContent);
376703
376762
  const repo = simpleGit(repoDir);
376704
- const isRepoDefined = await repo.checkIsRepo(CheckRepoActions.IS_REPO_ROOT);
376763
+ let isRepoDefined = false;
376764
+ try {
376765
+ isRepoDefined = await repo.checkIsRepo(CheckRepoActions.IS_REPO_ROOT);
376766
+ } catch (error2) {
376767
+ debugLogger.debug(`checkIsRepo failed, will initialize repository: ${error2 instanceof Error ? error2.message : String(error2)}`);
376768
+ }
376705
376769
  if (!isRepoDefined) {
376706
376770
  await repo.init(false, {
376707
376771
  "--initial-branch": "main"
376708
376772
  });
376709
376773
  await repo.commit("Initial commit", { "--allow-empty": null });
376710
376774
  }
376711
- const userGitIgnorePath = path58.join(this.projectRoot, ".gitignore");
376712
- const shadowGitIgnorePath = path58.join(repoDir, ".gitignore");
376775
+ const userGitIgnorePath = path57.join(this.projectRoot, ".gitignore");
376776
+ const shadowGitIgnorePath = path57.join(repoDir, ".gitignore");
376713
376777
  let userGitIgnoreContent = "";
376714
376778
  try {
376715
- userGitIgnoreContent = await fs52.readFile(userGitIgnorePath, "utf-8");
376779
+ userGitIgnoreContent = await fs51.readFile(userGitIgnorePath, "utf-8");
376716
376780
  } catch (error2) {
376717
376781
  if (isNodeError(error2) && error2.code !== "ENOENT") {
376718
376782
  throw error2;
376719
376783
  }
376720
376784
  }
376721
- await fs52.writeFile(shadowGitIgnorePath, userGitIgnoreContent);
376785
+ await fs51.writeFile(shadowGitIgnorePath, userGitIgnoreContent);
376722
376786
  }
376723
376787
  get shadowGitRepository() {
376724
376788
  const repoDir = this.getHistoryDir();
376725
376789
  return simpleGit(this.projectRoot).env({
376726
- GIT_DIR: path58.join(repoDir, ".git"),
376790
+ GIT_DIR: path57.join(repoDir, ".git"),
376727
376791
  GIT_WORK_TREE: this.projectRoot,
376728
376792
  // Prevent git from using the user's global git config.
376729
376793
  HOME: repoDir,
@@ -376785,13 +376849,13 @@ function shouldAttemptBrowserLaunch() {
376785
376849
  }
376786
376850
 
376787
376851
  // packages/core/dist/src/services/fileSystemService.js
376788
- import fs53 from "node:fs/promises";
376852
+ import fs52 from "node:fs/promises";
376789
376853
  var StandardFileSystemService = class {
376790
376854
  async readTextFile(filePath) {
376791
- return fs53.readFile(filePath, "utf-8");
376855
+ return fs52.readFile(filePath, "utf-8");
376792
376856
  }
376793
376857
  async writeTextFile(filePath, content) {
376794
- await fs53.writeFile(filePath, content, "utf-8");
376858
+ await fs52.writeFile(filePath, content, "utf-8");
376795
376859
  }
376796
376860
  };
376797
376861
 
@@ -377112,7 +377176,7 @@ var OverrideStrategy = class {
377112
377176
  if (overrideModel === DEFAULT_GEMINI_MODEL_AUTO || overrideModel === PREVIEW_GEMINI_MODEL_AUTO)
377113
377177
  return null;
377114
377178
  return {
377115
- model: getEffectiveModel(overrideModel, config3.getPreviewFeatures()),
377179
+ model: resolveModel(overrideModel, config3.getPreviewFeatures()),
377116
377180
  metadata: {
377117
377181
  source: this.name,
377118
377182
  latencyMs: 0,
@@ -377548,14 +377612,14 @@ var DEFAULT_MODEL_CONFIGS = {
377548
377612
  };
377549
377613
 
377550
377614
  // packages/core/dist/src/utils/memoryDiscovery.js
377551
- import * as fs55 from "node:fs/promises";
377615
+ import * as fs54 from "node:fs/promises";
377552
377616
  import * as fsSync2 from "node:fs";
377553
- import * as path60 from "node:path";
377617
+ import * as path59 from "node:path";
377554
377618
  import { homedir as homedir4 } from "node:os";
377555
377619
 
377556
377620
  // packages/core/dist/src/utils/memoryImportProcessor.js
377557
- import * as fs54 from "node:fs/promises";
377558
- import * as path59 from "node:path";
377621
+ import * as fs53 from "node:fs/promises";
377622
+ import * as path58 from "node:path";
377559
377623
 
377560
377624
  // node_modules/marked/lib/marked.esm.js
377561
377625
  function _getDefaults() {
@@ -379703,23 +379767,23 @@ var logger4 = {
379703
379767
  error: (...args2) => debugLogger.error("[ERROR] [ImportProcessor]", ...args2)
379704
379768
  };
379705
379769
  async function findProjectRoot(startDir) {
379706
- let currentDir = path59.resolve(startDir);
379770
+ let currentDir = path58.resolve(startDir);
379707
379771
  while (true) {
379708
- const gitPath = path59.join(currentDir, ".git");
379772
+ const gitPath = path58.join(currentDir, ".git");
379709
379773
  try {
379710
- const stats = await fs54.lstat(gitPath);
379774
+ const stats = await fs53.lstat(gitPath);
379711
379775
  if (stats.isDirectory()) {
379712
379776
  return currentDir;
379713
379777
  }
379714
379778
  } catch {
379715
379779
  }
379716
- const parentDir = path59.dirname(currentDir);
379780
+ const parentDir = path58.dirname(currentDir);
379717
379781
  if (parentDir === currentDir) {
379718
379782
  break;
379719
379783
  }
379720
379784
  currentDir = parentDir;
379721
379785
  }
379722
- return path59.resolve(startDir);
379786
+ return path58.resolve(startDir);
379723
379787
  }
379724
379788
  function hasMessage(err2) {
379725
379789
  return typeof err2 === "object" && err2 !== null && "message" in err2 && typeof err2.message === "string";
@@ -379808,7 +379872,7 @@ async function processImports(content, basePath, debugMode = false, importState
379808
379872
  const flatFiles = [];
379809
379873
  const processedFiles = /* @__PURE__ */ new Set();
379810
379874
  async function processFlat(fileContent, fileBasePath, filePath, depth) {
379811
- const normalizedPath = path59.normalize(filePath);
379875
+ const normalizedPath = path58.normalize(filePath);
379812
379876
  if (processedFiles.has(normalizedPath))
379813
379877
  return;
379814
379878
  processedFiles.add(normalizedPath);
@@ -379823,14 +379887,14 @@ async function processImports(content, basePath, debugMode = false, importState
379823
379887
  if (!validateImportPath(importPath, fileBasePath, [projectRoot || ""])) {
379824
379888
  continue;
379825
379889
  }
379826
- const fullPath = path59.resolve(fileBasePath, importPath);
379827
- const normalizedFullPath = path59.normalize(fullPath);
379890
+ const fullPath = path58.resolve(fileBasePath, importPath);
379891
+ const normalizedFullPath = path58.normalize(fullPath);
379828
379892
  if (processedFiles.has(normalizedFullPath))
379829
379893
  continue;
379830
379894
  try {
379831
- await fs54.access(fullPath);
379832
- const importedContent = await fs54.readFile(fullPath, "utf-8");
379833
- await processFlat(importedContent, path59.dirname(fullPath), normalizedFullPath, depth + 1);
379895
+ await fs53.access(fullPath);
379896
+ const importedContent = await fs53.readFile(fullPath, "utf-8");
379897
+ await processFlat(importedContent, path58.dirname(fullPath), normalizedFullPath, depth + 1);
379834
379898
  } catch (error2) {
379835
379899
  if (debugMode) {
379836
379900
  logger4.warn(`Failed to import ${fullPath}: ${hasMessage(error2) ? error2.message : "Unknown error"}`);
@@ -379838,7 +379902,7 @@ async function processImports(content, basePath, debugMode = false, importState
379838
379902
  }
379839
379903
  }
379840
379904
  }
379841
- const rootPath = path59.normalize(importState.currentFile || path59.resolve(basePath));
379905
+ const rootPath = path58.normalize(importState.currentFile || path58.resolve(basePath));
379842
379906
  await processFlat(content, basePath, rootPath, 0);
379843
379907
  const flatContent = flatFiles.map((f3) => `--- File: ${f3.path} ---
379844
379908
  ${f3.content.trim()}
@@ -379865,14 +379929,14 @@ ${f3.content.trim()}
379865
379929
  result += `<!-- Import failed: ${importPath} - Path traversal attempt -->`;
379866
379930
  continue;
379867
379931
  }
379868
- const fullPath = path59.resolve(basePath, importPath);
379932
+ const fullPath = path58.resolve(basePath, importPath);
379869
379933
  if (importState.processedFiles.has(fullPath)) {
379870
379934
  result += `<!-- File already processed: ${importPath} -->`;
379871
379935
  continue;
379872
379936
  }
379873
379937
  try {
379874
- await fs54.access(fullPath);
379875
- const fileContent = await fs54.readFile(fullPath, "utf-8");
379938
+ await fs53.access(fullPath);
379939
+ const fileContent = await fs53.readFile(fullPath, "utf-8");
379876
379940
  const newImportState = {
379877
379941
  ...importState,
379878
379942
  processedFiles: new Set(importState.processedFiles),
@@ -379880,7 +379944,7 @@ ${f3.content.trim()}
379880
379944
  currentFile: fullPath
379881
379945
  };
379882
379946
  newImportState.processedFiles.add(fullPath);
379883
- const imported = await processImports(fileContent, path59.dirname(fullPath), debugMode, newImportState, projectRoot, importFormat);
379947
+ const imported = await processImports(fileContent, path58.dirname(fullPath), debugMode, newImportState, projectRoot, importFormat);
379884
379948
  result += `<!-- Imported from: ${importPath} -->
379885
379949
  ${imported.content}
379886
379950
  <!-- End of import from: ${importPath} -->`;
@@ -379909,7 +379973,7 @@ function validateImportPath(importPath, basePath, allowedDirectories) {
379909
379973
  if (/^(file|https?):\/\//.test(importPath)) {
379910
379974
  return false;
379911
379975
  }
379912
- const resolvedPath = path59.resolve(basePath, importPath);
379976
+ const resolvedPath = path58.resolve(basePath, importPath);
379913
379977
  return allowedDirectories.some((allowedDir) => isSubpath(allowedDir, resolvedPath));
379914
379978
  }
379915
379979
 
@@ -379924,11 +379988,11 @@ var logger5 = {
379924
379988
  error: (...args2) => console.error("[ERROR] [MemoryDiscovery]", ...args2)
379925
379989
  };
379926
379990
  async function findProjectRoot2(startDir) {
379927
- let currentDir = path60.resolve(startDir);
379991
+ let currentDir = path59.resolve(startDir);
379928
379992
  while (true) {
379929
- const gitPath = path60.join(currentDir, ".git");
379993
+ const gitPath = path59.join(currentDir, ".git");
379930
379994
  try {
379931
- const stats = await fs55.lstat(gitPath);
379995
+ const stats = await fs54.lstat(gitPath);
379932
379996
  if (stats.isDirectory()) {
379933
379997
  return currentDir;
379934
379998
  }
@@ -379944,7 +380008,7 @@ async function findProjectRoot2(startDir) {
379944
380008
  }
379945
380009
  }
379946
380010
  }
379947
- const parentDir = path60.dirname(currentDir);
380011
+ const parentDir = path59.dirname(currentDir);
379948
380012
  if (parentDir === currentDir) {
379949
380013
  return null;
379950
380014
  }
@@ -379980,17 +380044,17 @@ async function getGeminiMdFilePathsInternalForEachDir(dir, userHomePath, debugMo
379980
380044
  const allPaths = /* @__PURE__ */ new Set();
379981
380045
  const geminiMdFilenames = getAllGeminiMdFilenames();
379982
380046
  for (const geminiMdFilename of geminiMdFilenames) {
379983
- const resolvedHome = path60.resolve(userHomePath);
379984
- const globalMemoryPath = path60.join(resolvedHome, GEMINI_DIR, geminiMdFilename);
380047
+ const resolvedHome = path59.resolve(userHomePath);
380048
+ const globalMemoryPath = path59.join(resolvedHome, GEMINI_DIR, geminiMdFilename);
379985
380049
  try {
379986
- await fs55.access(globalMemoryPath, fsSync2.constants.R_OK);
380050
+ await fs54.access(globalMemoryPath, fsSync2.constants.R_OK);
379987
380051
  allPaths.add(globalMemoryPath);
379988
380052
  if (debugMode)
379989
380053
  logger5.debug(`Found readable global ${geminiMdFilename}: ${globalMemoryPath}`);
379990
380054
  } catch {
379991
380055
  }
379992
380056
  if (dir && folderTrust) {
379993
- const resolvedCwd = path60.resolve(dir);
380057
+ const resolvedCwd = path59.resolve(dir);
379994
380058
  if (debugMode)
379995
380059
  logger5.debug(`Searching for ${geminiMdFilename} starting from CWD: ${resolvedCwd}`);
379996
380060
  const projectRoot = await findProjectRoot2(resolvedCwd);
@@ -379998,14 +380062,14 @@ async function getGeminiMdFilePathsInternalForEachDir(dir, userHomePath, debugMo
379998
380062
  logger5.debug(`Determined project root: ${projectRoot ?? "None"}`);
379999
380063
  const upwardPaths = [];
380000
380064
  let currentDir = resolvedCwd;
380001
- const ultimateStopDir = projectRoot ? path60.dirname(projectRoot) : path60.dirname(resolvedHome);
380002
- while (currentDir && currentDir !== path60.dirname(currentDir)) {
380003
- if (currentDir === path60.join(resolvedHome, GEMINI_DIR)) {
380065
+ const ultimateStopDir = projectRoot ? path59.dirname(projectRoot) : path59.dirname(resolvedHome);
380066
+ while (currentDir && currentDir !== path59.dirname(currentDir)) {
380067
+ if (currentDir === path59.join(resolvedHome, GEMINI_DIR)) {
380004
380068
  break;
380005
380069
  }
380006
- const potentialPath = path60.join(currentDir, geminiMdFilename);
380070
+ const potentialPath = path59.join(currentDir, geminiMdFilename);
380007
380071
  try {
380008
- await fs55.access(potentialPath, fsSync2.constants.R_OK);
380072
+ await fs54.access(potentialPath, fsSync2.constants.R_OK);
380009
380073
  if (potentialPath !== globalMemoryPath) {
380010
380074
  upwardPaths.unshift(potentialPath);
380011
380075
  }
@@ -380014,7 +380078,7 @@ async function getGeminiMdFilePathsInternalForEachDir(dir, userHomePath, debugMo
380014
380078
  if (currentDir === ultimateStopDir) {
380015
380079
  break;
380016
380080
  }
380017
- currentDir = path60.dirname(currentDir);
380081
+ currentDir = path59.dirname(currentDir);
380018
380082
  }
380019
380083
  upwardPaths.forEach((p) => allPaths.add(p));
380020
380084
  const mergedOptions = {
@@ -380046,8 +380110,8 @@ async function readGeminiMdFiles(filePaths, debugMode, importFormat = "tree") {
380046
380110
  const batch = filePaths.slice(i4, i4 + CONCURRENT_LIMIT);
380047
380111
  const batchPromises = batch.map(async (filePath) => {
380048
380112
  try {
380049
- const content = await fs55.readFile(filePath, "utf-8");
380050
- const processedResult = await processImports(content, path60.dirname(filePath), debugMode, void 0, void 0, importFormat);
380113
+ const content = await fs54.readFile(filePath, "utf-8");
380114
+ const processedResult = await processImports(content, path59.dirname(filePath), debugMode, void 0, void 0, importFormat);
380051
380115
  if (debugMode)
380052
380116
  logger5.debug(`Successfully read and processed imports: ${filePath} (Length: ${processedResult.content.length})`);
380053
380117
  return { filePath, content: processedResult.content };
@@ -380081,7 +380145,7 @@ function concatenateInstructions(instructionContents, currentWorkingDirectoryFor
380081
380145
  if (trimmedContent.length === 0) {
380082
380146
  return null;
380083
380147
  }
380084
- const displayPath = path60.isAbsolute(item.filePath) ? path60.relative(currentWorkingDirectoryForDisplay, item.filePath) : item.filePath;
380148
+ const displayPath = path59.isAbsolute(item.filePath) ? path59.relative(currentWorkingDirectoryForDisplay, item.filePath) : item.filePath;
380085
380149
  return `--- Context from: ${displayPath} ---
380086
380150
  ${trimmedContent}
380087
380151
  --- End of Context from: ${displayPath} ---`;
@@ -380091,9 +380155,9 @@ async function loadGlobalMemory(debugMode = false) {
380091
380155
  const userHome = homedir4();
380092
380156
  const geminiMdFilenames = getAllGeminiMdFilenames();
380093
380157
  const accessChecks = geminiMdFilenames.map(async (filename) => {
380094
- const globalPath = path60.join(userHome, GEMINI_DIR, filename);
380158
+ const globalPath = path59.join(userHome, GEMINI_DIR, filename);
380095
380159
  try {
380096
- await fs55.access(globalPath, fsSync2.constants.R_OK);
380160
+ await fs54.access(globalPath, fsSync2.constants.R_OK);
380097
380161
  if (debugMode) {
380098
380162
  logger5.debug(`Found global memory file: ${globalPath}`);
380099
380163
  }
@@ -380114,10 +380178,10 @@ async function loadGlobalMemory(debugMode = false) {
380114
380178
  }
380115
380179
  async function findUpwardGeminiFiles(startDir, stopDir, debugMode) {
380116
380180
  const upwardPaths = [];
380117
- let currentDir = path60.resolve(startDir);
380118
- const resolvedStopDir = path60.resolve(stopDir);
380181
+ let currentDir = path59.resolve(startDir);
380182
+ const resolvedStopDir = path59.resolve(stopDir);
380119
380183
  const geminiMdFilenames = getAllGeminiMdFilenames();
380120
- const globalGeminiDir = path60.join(homedir4(), GEMINI_DIR);
380184
+ const globalGeminiDir = path59.join(homedir4(), GEMINI_DIR);
380121
380185
  if (debugMode) {
380122
380186
  logger5.debug(`Starting upward search from ${currentDir} stopping at ${resolvedStopDir}`);
380123
380187
  }
@@ -380126,9 +380190,9 @@ async function findUpwardGeminiFiles(startDir, stopDir, debugMode) {
380126
380190
  break;
380127
380191
  }
380128
380192
  const accessChecks = geminiMdFilenames.map(async (filename) => {
380129
- const potentialPath = path60.join(currentDir, filename);
380193
+ const potentialPath = path59.join(currentDir, filename);
380130
380194
  try {
380131
- await fs55.access(potentialPath, fsSync2.constants.R_OK);
380195
+ await fs54.access(potentialPath, fsSync2.constants.R_OK);
380132
380196
  return potentialPath;
380133
380197
  } catch {
380134
380198
  return null;
@@ -380136,17 +380200,17 @@ async function findUpwardGeminiFiles(startDir, stopDir, debugMode) {
380136
380200
  });
380137
380201
  const foundPathsInDir = (await Promise.all(accessChecks)).filter((p) => p !== null);
380138
380202
  upwardPaths.unshift(...foundPathsInDir);
380139
- if (currentDir === resolvedStopDir || currentDir === path60.dirname(currentDir)) {
380203
+ if (currentDir === resolvedStopDir || currentDir === path59.dirname(currentDir)) {
380140
380204
  break;
380141
380205
  }
380142
- currentDir = path60.dirname(currentDir);
380206
+ currentDir = path59.dirname(currentDir);
380143
380207
  }
380144
380208
  return upwardPaths;
380145
380209
  }
380146
380210
  async function loadEnvironmentMemory(trustedRoots, extensionLoader, debugMode = false) {
380147
380211
  const allPaths = /* @__PURE__ */ new Set();
380148
380212
  const traversalPromises = trustedRoots.map(async (root) => {
380149
- const resolvedRoot = path60.resolve(root);
380213
+ const resolvedRoot = path59.resolve(root);
380150
380214
  if (debugMode) {
380151
380215
  logger5.debug(`Loading environment memory for trusted root: ${resolvedRoot} (Stopping exactly here)`);
380152
380216
  }
@@ -380166,8 +380230,8 @@ async function loadEnvironmentMemory(trustedRoots, extensionLoader, debugMode =
380166
380230
  };
380167
380231
  }
380168
380232
  async function loadServerHierarchicalMemory(currentWorkingDirectory, includeDirectoriesToReadGemini, debugMode, fileService, extensionLoader, folderTrust, importFormat = "tree", fileFilteringOptions, maxDirs = 200) {
380169
- const realCwd = await fs55.realpath(path60.resolve(currentWorkingDirectory));
380170
- const realHome = await fs55.realpath(path60.resolve(homedir4()));
380233
+ const realCwd = await fs54.realpath(path59.resolve(currentWorkingDirectory));
380234
+ const realHome = await fs54.realpath(path59.resolve(homedir4()));
380171
380235
  const isHomeDirectory = realCwd === realHome;
380172
380236
  currentWorkingDirectory = isHomeDirectory ? "" : currentWorkingDirectory;
380173
380237
  if (debugMode)
@@ -380203,10 +380267,10 @@ async function refreshServerHierarchicalMemory(config3) {
380203
380267
  return result;
380204
380268
  }
380205
380269
  async function loadJitSubdirectoryMemory(targetPath, trustedRoots, alreadyLoadedPaths, debugMode = false) {
380206
- const resolvedTarget = path60.resolve(targetPath);
380270
+ const resolvedTarget = path59.resolve(targetPath);
380207
380271
  let bestRoot = null;
380208
380272
  for (const root of trustedRoots) {
380209
- const resolvedRoot = path60.resolve(root);
380273
+ const resolvedRoot = path59.resolve(root);
380210
380274
  if (resolvedTarget.startsWith(resolvedRoot) && (!bestRoot || resolvedRoot.length > bestRoot.length)) {
380211
380275
  bestRoot = resolvedRoot;
380212
380276
  }
@@ -380302,8 +380366,8 @@ var ContextManager = class {
380302
380366
  };
380303
380367
 
380304
380368
  // packages/core/dist/src/utils/workspaceContext.js
380305
- import * as fs56 from "node:fs";
380306
- import * as path61 from "node:path";
380369
+ import * as fs55 from "node:fs";
380370
+ import * as path60 from "node:path";
380307
380371
  var WorkspaceContext = class {
380308
380372
  targetDir;
380309
380373
  directories = /* @__PURE__ */ new Set();
@@ -380360,15 +380424,15 @@ var WorkspaceContext = class {
380360
380424
  }
380361
380425
  }
380362
380426
  resolveAndValidateDir(directory) {
380363
- const absolutePath = path61.resolve(this.targetDir, directory);
380364
- if (!fs56.existsSync(absolutePath)) {
380427
+ const absolutePath = path60.resolve(this.targetDir, directory);
380428
+ if (!fs55.existsSync(absolutePath)) {
380365
380429
  throw new Error(`Directory does not exist: ${absolutePath}`);
380366
380430
  }
380367
- const stats = fs56.statSync(absolutePath);
380431
+ const stats = fs55.statSync(absolutePath);
380368
380432
  if (!stats.isDirectory()) {
380369
380433
  throw new Error(`Path is not a directory: ${absolutePath}`);
380370
380434
  }
380371
- return fs56.realpathSync(absolutePath);
380435
+ return fs55.realpathSync(absolutePath);
380372
380436
  }
380373
380437
  /**
380374
380438
  * Gets a copy of all workspace directories.
@@ -380415,7 +380479,7 @@ var WorkspaceContext = class {
380415
380479
  */
380416
380480
  fullyResolvedPath(pathToCheck) {
380417
380481
  try {
380418
- return fs56.realpathSync(path61.resolve(this.targetDir, pathToCheck));
380482
+ return fs55.realpathSync(path60.resolve(this.targetDir, pathToCheck));
380419
380483
  } catch (e3) {
380420
380484
  if (isNodeError(e3) && e3.code === "ENOENT" && e3.path && // realpathSync does not set e.path correctly for symlinks to
380421
380485
  // non-existent files.
@@ -380432,15 +380496,15 @@ var WorkspaceContext = class {
380432
380496
  * @returns True if the path is within the root directory, false otherwise
380433
380497
  */
380434
380498
  isPathWithinRoot(pathToCheck, rootDirectory) {
380435
- const relative5 = path61.relative(rootDirectory, pathToCheck);
380436
- return !relative5.startsWith(`..${path61.sep}`) && relative5 !== ".." && !path61.isAbsolute(relative5);
380499
+ const relative5 = path60.relative(rootDirectory, pathToCheck);
380500
+ return !relative5.startsWith(`..${path60.sep}`) && relative5 !== ".." && !path60.isAbsolute(relative5);
380437
380501
  }
380438
380502
  /**
380439
380503
  * Checks if a file path is a symbolic link that points to a file.
380440
380504
  */
380441
380505
  isFileSymlink(filePath) {
380442
380506
  try {
380443
- return !fs56.readlinkSync(filePath).endsWith("/");
380507
+ return !fs55.readlinkSync(filePath).endsWith("/");
380444
380508
  } catch (_error) {
380445
380509
  return false;
380446
380510
  }
@@ -380633,7 +380697,12 @@ var SafetyCheckDecision;
380633
380697
  })(SafetyCheckDecision || (SafetyCheckDecision = {}));
380634
380698
 
380635
380699
  // packages/core/dist/src/policy/policy-engine.js
380636
- function ruleMatches(rule, toolCall, stringifiedArgs, serverName) {
380700
+ function ruleMatches(rule, toolCall, stringifiedArgs, serverName, currentApprovalMode) {
380701
+ if (rule.modes && rule.modes.length > 0) {
380702
+ if (!rule.modes.includes(currentApprovalMode)) {
380703
+ return false;
380704
+ }
380705
+ }
380637
380706
  if (rule.toolName) {
380638
380707
  if (rule.toolName.endsWith("__*")) {
380639
380708
  const prefix = rule.toolName.slice(0, -3);
@@ -380676,6 +380745,7 @@ var PolicyEngine = class {
380676
380745
  nonInteractive;
380677
380746
  checkerRunner;
380678
380747
  allowHooks;
380748
+ approvalMode;
380679
380749
  constructor(config3 = {}, checkerRunner) {
380680
380750
  this.rules = (config3.rules ?? []).sort((a2, b) => (b.priority ?? 0) - (a2.priority ?? 0));
380681
380751
  this.checkers = (config3.checkers ?? []).sort((a2, b) => (b.priority ?? 0) - (a2.priority ?? 0));
@@ -380684,6 +380754,19 @@ var PolicyEngine = class {
380684
380754
  this.nonInteractive = config3.nonInteractive ?? false;
380685
380755
  this.checkerRunner = checkerRunner;
380686
380756
  this.allowHooks = config3.allowHooks ?? true;
380757
+ this.approvalMode = config3.approvalMode ?? ApprovalMode.DEFAULT;
380758
+ }
380759
+ /**
380760
+ * Update the current approval mode.
380761
+ */
380762
+ setApprovalMode(mode) {
380763
+ this.approvalMode = mode;
380764
+ }
380765
+ /**
380766
+ * Get the current approval mode.
380767
+ */
380768
+ getApprovalMode() {
380769
+ return this.approvalMode;
380687
380770
  }
380688
380771
  /**
380689
380772
  * Check if a tool call is allowed based on the configured policies.
@@ -380698,7 +380781,7 @@ var PolicyEngine = class {
380698
380781
  let matchedRule;
380699
380782
  let decision;
380700
380783
  for (const rule of this.rules) {
380701
- if (ruleMatches(rule, toolCall, stringifiedArgs, serverName)) {
380784
+ if (ruleMatches(rule, toolCall, stringifiedArgs, serverName, this.approvalMode)) {
380702
380785
  debugLogger.debug(`[PolicyEngine.check] MATCHED rule: toolName=${rule.toolName}, decision=${rule.decision}, priority=${rule.priority}, argsPattern=${rule.argsPattern?.source || "none"}`);
380703
380786
  if (toolCall.name && SHELL_TOOL_NAMES.includes(toolCall.name) && rule.decision === PolicyDecision.ALLOW) {
380704
380787
  const command = toolCall.args?.command;
@@ -380744,7 +380827,7 @@ var PolicyEngine = class {
380744
380827
  }
380745
380828
  if (decision !== PolicyDecision.DENY && this.checkerRunner) {
380746
380829
  for (const checkerRule of this.checkers) {
380747
- if (ruleMatches(checkerRule, toolCall, stringifiedArgs, serverName)) {
380830
+ if (ruleMatches(checkerRule, toolCall, stringifiedArgs, serverName, this.approvalMode)) {
380748
380831
  debugLogger.debug(`[PolicyEngine.check] Running safety checker: ${checkerRule.checker.name}`);
380749
380832
  try {
380750
380833
  const result = await this.checkerRunner.runChecker(toolCall, checkerRule.checker);
@@ -380865,14 +380948,88 @@ var PolicyEngine = class {
380865
380948
  }
380866
380949
  };
380867
380950
 
380951
+ // packages/core/dist/src/hooks/trustedHooks.js
380952
+ import * as fs56 from "node:fs";
380953
+ import * as path61 from "node:path";
380954
+ var TrustedHooksManager = class {
380955
+ configPath;
380956
+ trustedHooks = {};
380957
+ constructor() {
380958
+ this.configPath = path61.join(Storage2.getGlobalGeminiDir(), "trusted_hooks.json");
380959
+ this.load();
380960
+ }
380961
+ load() {
380962
+ try {
380963
+ if (fs56.existsSync(this.configPath)) {
380964
+ const content = fs56.readFileSync(this.configPath, "utf-8");
380965
+ this.trustedHooks = JSON.parse(content);
380966
+ }
380967
+ } catch (error2) {
380968
+ debugLogger.warn("Failed to load trusted hooks config", error2);
380969
+ this.trustedHooks = {};
380970
+ }
380971
+ }
380972
+ save() {
380973
+ try {
380974
+ const dir = path61.dirname(this.configPath);
380975
+ if (!fs56.existsSync(dir)) {
380976
+ fs56.mkdirSync(dir, { recursive: true });
380977
+ }
380978
+ fs56.writeFileSync(this.configPath, JSON.stringify(this.trustedHooks, null, 2));
380979
+ } catch (error2) {
380980
+ debugLogger.warn("Failed to save trusted hooks config", error2);
380981
+ }
380982
+ }
380983
+ /**
380984
+ * Get untrusted hooks for a project
380985
+ * @param projectPath Absolute path to the project root
380986
+ * @param hooks The hooks configuration to check
380987
+ * @returns List of untrusted hook commands/names
380988
+ */
380989
+ getUntrustedHooks(projectPath, hooks) {
380990
+ const trustedKeys = new Set(this.trustedHooks[projectPath] || []);
380991
+ const untrusted = [];
380992
+ for (const eventName of Object.keys(hooks)) {
380993
+ const definitions = hooks[eventName];
380994
+ if (!Array.isArray(definitions))
380995
+ continue;
380996
+ for (const def2 of definitions) {
380997
+ if (!def2 || !Array.isArray(def2.hooks))
380998
+ continue;
380999
+ for (const hook of def2.hooks) {
381000
+ const key = getHookKey(hook);
381001
+ if (!trustedKeys.has(key)) {
381002
+ untrusted.push(hook.name || hook.command || "unknown-hook");
381003
+ }
381004
+ }
381005
+ }
381006
+ }
381007
+ return Array.from(new Set(untrusted));
381008
+ }
381009
+ /**
381010
+ * Trust all provided hooks for a project
381011
+ */
381012
+ trustHooks(projectPath, hooks) {
381013
+ const currentTrusted = new Set(this.trustedHooks[projectPath] || []);
381014
+ for (const eventName of Object.keys(hooks)) {
381015
+ const definitions = hooks[eventName];
381016
+ if (!Array.isArray(definitions))
381017
+ continue;
381018
+ for (const def2 of definitions) {
381019
+ if (!def2 || !Array.isArray(def2.hooks))
381020
+ continue;
381021
+ for (const hook of def2.hooks) {
381022
+ currentTrusted.add(getHookKey(hook));
381023
+ }
381024
+ }
381025
+ }
381026
+ this.trustedHooks[projectPath] = Array.from(currentTrusted);
381027
+ this.save();
381028
+ }
381029
+ };
381030
+
380868
381031
  // packages/core/dist/src/hooks/hookRegistry.js
380869
- var ConfigSource;
380870
- (function(ConfigSource2) {
380871
- ConfigSource2["Project"] = "project";
380872
- ConfigSource2["User"] = "user";
380873
- ConfigSource2["System"] = "system";
380874
- ConfigSource2["Extensions"] = "extensions";
380875
- })(ConfigSource || (ConfigSource = {}));
381032
+ init_events();
380876
381033
  var HookRegistry = class {
380877
381034
  config;
380878
381035
  entries = [];
@@ -380923,13 +381080,43 @@ var HookRegistry = class {
380923
381080
  getHookName(entry) {
380924
381081
  return entry.config.name || entry.config.command || "unknown-command";
380925
381082
  }
381083
+ /**
381084
+ * Check for untrusted project hooks and warn the user
381085
+ */
381086
+ checkProjectHooksTrust() {
381087
+ const projectHooks = this.config.getProjectHooks();
381088
+ if (!projectHooks)
381089
+ return;
381090
+ try {
381091
+ const trustedHooksManager = new TrustedHooksManager();
381092
+ const untrusted = trustedHooksManager.getUntrustedHooks(this.config.getProjectRoot(), projectHooks);
381093
+ if (untrusted.length > 0) {
381094
+ const message = `WARNING: The following project-level hooks have been detected in this workspace:
381095
+ ${untrusted.map((h3) => ` - ${h3}`).join("\n")}
381096
+
381097
+ These hooks will be executed. If you did not configure these hooks or do not trust this project,
381098
+ please review the project settings (.gemini/settings.json) and remove them.`;
381099
+ coreEvents.emitFeedback("warning", message);
381100
+ trustedHooksManager.trustHooks(this.config.getProjectRoot(), projectHooks);
381101
+ }
381102
+ } catch (error2) {
381103
+ debugLogger.warn("Failed to check project hooks trust", error2);
381104
+ }
381105
+ }
380926
381106
  /**
380927
381107
  * Process hooks from the config that was already loaded by the CLI
380928
381108
  */
380929
381109
  processHooksFromConfig() {
381110
+ if (this.config.isTrustedFolder()) {
381111
+ this.checkProjectHooksTrust();
381112
+ }
380930
381113
  const configHooks = this.config.getHooks();
380931
381114
  if (configHooks) {
380932
- this.processHooksConfiguration(configHooks, ConfigSource.Project);
381115
+ if (this.config.isTrustedFolder()) {
381116
+ this.processHooksConfiguration(configHooks, ConfigSource.Project);
381117
+ } else {
381118
+ debugLogger.warn("Project hooks disabled because the folder is not trusted.");
381119
+ }
380933
381120
  }
380934
381121
  const extensions = this.config.getExtensions() || [];
380935
381122
  for (const extension of extensions) {
@@ -380972,6 +381159,7 @@ var HookRegistry = class {
380972
381159
  config: hookConfig
380973
381160
  });
380974
381161
  const isDisabled = disabledHooks.includes(hookName);
381162
+ hookConfig.source = source;
380975
381163
  this.entries.push({
380976
381164
  config: hookConfig,
380977
381165
  source,
@@ -381032,13 +381220,26 @@ var EXIT_CODE_SUCCESS = 0;
381032
381220
  var EXIT_CODE_BLOCKING_ERROR = 2;
381033
381221
  var EXIT_CODE_NON_BLOCKING_ERROR = 1;
381034
381222
  var HookRunner = class {
381035
- constructor() {
381223
+ config;
381224
+ constructor(config3) {
381225
+ this.config = config3;
381036
381226
  }
381037
381227
  /**
381038
381228
  * Execute a single hook
381039
381229
  */
381040
381230
  async executeHook(hookConfig, eventName, input) {
381041
381231
  const startTime = Date.now();
381232
+ if (hookConfig.source === ConfigSource.Project && !this.config.isTrustedFolder()) {
381233
+ const errorMessage = "Security: Blocked execution of project hook in untrusted folder";
381234
+ debugLogger.warn(errorMessage);
381235
+ return {
381236
+ hookConfig,
381237
+ eventName,
381238
+ success: false,
381239
+ error: new Error(errorMessage),
381240
+ duration: 0
381241
+ };
381242
+ }
381042
381243
  try {
381043
381244
  return await this.executeCommandHook(hookConfig, eventName, input, startTime);
381044
381245
  } catch (error2) {
@@ -381135,7 +381336,7 @@ var HookRunner = class {
381135
381336
  const shellConfig = getShellConfiguration();
381136
381337
  const command = this.expandCommand(hookConfig.command, input, shellConfig.shell);
381137
381338
  const env2 = {
381138
- ...process.env,
381339
+ ...sanitizeEnvironment(process.env, this.config.sanitizationConfig),
381139
381340
  GEMINI_PROJECT_DIR: input.cwd,
381140
381341
  CLAUDE_PROJECT_DIR: input.cwd
381141
381342
  // For compatibility
@@ -381561,7 +381762,7 @@ var HookPlanner = class {
381561
381762
  const seen = /* @__PURE__ */ new Set();
381562
381763
  const deduplicated = [];
381563
381764
  for (const entry of entries2) {
381564
- const key = this.getHookKey(entry);
381765
+ const key = getHookKey(entry.config);
381565
381766
  if (!seen.has(key)) {
381566
381767
  seen.add(key);
381567
381768
  deduplicated.push(entry);
@@ -381571,14 +381772,6 @@ var HookPlanner = class {
381571
381772
  }
381572
381773
  return deduplicated;
381573
381774
  }
381574
- /**
381575
- * Generate a unique key for a hook entry
381576
- */
381577
- getHookKey(entry) {
381578
- const name4 = entry.config.name || "";
381579
- const command = entry.config.command || "";
381580
- return `${name4}:${command}`;
381581
- }
381582
381775
  };
381583
381776
 
381584
381777
  // packages/core/dist/src/hooks/hookEventHandler.js
@@ -382059,7 +382252,7 @@ var HookSystem = class {
382059
382252
  const logger6 = import_api_logs2.logs.getLogger(SERVICE_NAME);
382060
382253
  const messageBus = config3.getMessageBus();
382061
382254
  this.hookRegistry = new HookRegistry(config3);
382062
- this.hookRunner = new HookRunner();
382255
+ this.hookRunner = new HookRunner(config3);
382063
382256
  this.hookAggregator = new HookAggregator();
382064
382257
  this.hookPlanner = new HookPlanner(this.hookRegistry);
382065
382258
  this.hookEventHandler = new HookEventHandler(config3, logger6, this.hookPlanner, this.hookRunner, this.hookAggregator, messageBus);
@@ -384714,7 +384907,7 @@ var ServiceAccountImpersonationProvider = class {
384714
384907
  };
384715
384908
 
384716
384909
  // packages/core/dist/src/tools/mcp-client.js
384717
- import { basename as basename12 } from "node:path";
384910
+ import { basename as basename11 } from "node:path";
384718
384911
  import { pathToFileURL } from "node:url";
384719
384912
 
384720
384913
  // packages/core/dist/src/mcp/oauth-provider.js
@@ -385534,7 +385727,7 @@ var McpClient = class {
385534
385727
  }
385535
385728
  this.updateStatus(MCPServerStatus.CONNECTING);
385536
385729
  try {
385537
- this.client = await connectToMcpServer(this.serverName, this.serverConfig, this.debugMode, this.workspaceContext);
385730
+ this.client = await connectToMcpServer(this.serverName, this.serverConfig, this.debugMode, this.workspaceContext, this.cliConfig.sanitizationConfig);
385538
385731
  this.registerNotificationHandlers();
385539
385732
  const originalOnError = this.client.onerror;
385540
385733
  this.client.onerror = (error2) => {
@@ -386086,7 +386279,7 @@ async function retryWithOAuth(client, serverName, config3, accessToken, httpRetu
386086
386279
  }
386087
386280
  }
386088
386281
  }
386089
- async function connectToMcpServer(mcpServerName, mcpServerConfig, debugMode, workspaceContext) {
386282
+ async function connectToMcpServer(mcpServerName, mcpServerConfig, debugMode, workspaceContext, sanitizationConfig) {
386090
386283
  const mcpClient = new Client({
386091
386284
  name: "gemini-cli-mcp-client",
386092
386285
  version: "0.0.1"
@@ -386104,7 +386297,7 @@ async function connectToMcpServer(mcpServerName, mcpServerConfig, debugMode, wor
386104
386297
  for (const dir of workspaceContext.getDirectories()) {
386105
386298
  roots.push({
386106
386299
  uri: pathToFileURL(dir).toString(),
386107
- name: basename12(dir)
386300
+ name: basename11(dir)
386108
386301
  });
386109
386302
  }
386110
386303
  return {
@@ -386131,7 +386324,7 @@ async function connectToMcpServer(mcpServerName, mcpServerConfig, debugMode, wor
386131
386324
  let httpReturned404 = false;
386132
386325
  let sseError = null;
386133
386326
  try {
386134
- const transport = await createTransport(mcpServerName, mcpServerConfig, debugMode);
386327
+ const transport = await createTransport(mcpServerName, mcpServerConfig, debugMode, sanitizationConfig);
386135
386328
  try {
386136
386329
  await mcpClient.connect(transport, {
386137
386330
  timeout: mcpServerConfig.timeout ?? MCP_DEFAULT_TIMEOUT_MSEC
@@ -386286,7 +386479,7 @@ function createUrlTransport(mcpServerName, mcpServerConfig, transportOptions) {
386286
386479
  }
386287
386480
  throw new Error(`No URL configured for MCP server '${mcpServerName}'`);
386288
386481
  }
386289
- async function createTransport(mcpServerName, mcpServerConfig, debugMode) {
386482
+ async function createTransport(mcpServerName, mcpServerConfig, debugMode, sanitizationConfig) {
386290
386483
  const noUrl = !mcpServerConfig.url && !mcpServerConfig.httpUrl;
386291
386484
  if (noUrl) {
386292
386485
  if (mcpServerConfig.authProviderType === AuthProviderType.GOOGLE_CREDENTIALS) {
@@ -386329,7 +386522,7 @@ async function createTransport(mcpServerName, mcpServerConfig, debugMode) {
386329
386522
  command: mcpServerConfig.command,
386330
386523
  args: mcpServerConfig.args || [],
386331
386524
  env: {
386332
- ...process.env,
386525
+ ...sanitizeEnvironment(process.env, sanitizationConfig),
386333
386526
  ...mcpServerConfig.env || {}
386334
386527
  },
386335
386528
  cwd: mcpServerConfig.cwd,
@@ -386604,6 +386797,9 @@ var Config = class {
386604
386797
  mcpClientManager;
386605
386798
  allowedMcpServers;
386606
386799
  blockedMcpServers;
386800
+ allowedEnvironmentVariables;
386801
+ blockedEnvironmentVariables;
386802
+ enableEnvironmentVariableRedaction;
386607
386803
  promptRegistry;
386608
386804
  resourceRegistry;
386609
386805
  agentRegistry;
@@ -386628,7 +386824,6 @@ var Config = class {
386628
386824
  userMemory;
386629
386825
  geminiMdFileCount;
386630
386826
  geminiMdFilePaths;
386631
- approvalMode;
386632
386827
  showMemoryUsage;
386633
386828
  accessibility;
386634
386829
  telemetrySettings;
@@ -386700,10 +386895,12 @@ var Config = class {
386700
386895
  pendingIncludeDirectories;
386701
386896
  enableHooks;
386702
386897
  hooks;
386898
+ projectHooks;
386703
386899
  disabledHooks;
386704
386900
  experiments;
386705
386901
  experimentsPromise;
386706
386902
  hookSystem;
386903
+ onModelChange;
386707
386904
  enableAgents;
386708
386905
  experimentalJitContext;
386709
386906
  contextManager;
@@ -386728,10 +386925,12 @@ var Config = class {
386728
386925
  this.mcpServers = params.mcpServers;
386729
386926
  this.allowedMcpServers = params.allowedMcpServers ?? [];
386730
386927
  this.blockedMcpServers = params.blockedMcpServers ?? [];
386928
+ this.allowedEnvironmentVariables = params.allowedEnvironmentVariables ?? [];
386929
+ this.blockedEnvironmentVariables = params.blockedEnvironmentVariables ?? [];
386930
+ this.enableEnvironmentVariableRedaction = params.enableEnvironmentVariableRedaction ?? false;
386731
386931
  this.userMemory = params.userMemory ?? "";
386732
386932
  this.geminiMdFileCount = params.geminiMdFileCount ?? 0;
386733
386933
  this.geminiMdFilePaths = params.geminiMdFilePaths ?? [];
386734
- this.approvalMode = params.approvalMode ?? ApprovalMode.DEFAULT;
386735
386934
  this.showMemoryUsage = params.showMemoryUsage ?? false;
386736
386935
  this.accessibility = params.accessibility ?? {};
386737
386936
  this.telemetrySettings = {
@@ -386787,7 +386986,8 @@ var Config = class {
386787
386986
  terminalWidth: params.shellExecutionConfig?.terminalWidth ?? 80,
386788
386987
  terminalHeight: params.shellExecutionConfig?.terminalHeight ?? 24,
386789
386988
  showColor: params.shellExecutionConfig?.showColor ?? false,
386790
- pager: params.shellExecutionConfig?.pager ?? "cat"
386989
+ pager: params.shellExecutionConfig?.pager ?? "cat",
386990
+ sanitizationConfig: this.sanitizationConfig
386791
386991
  };
386792
386992
  this.truncateToolOutputThreshold = params.truncateToolOutputThreshold ?? DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD;
386793
386993
  this.truncateToolOutputLines = params.truncateToolOutputLines ?? DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES;
@@ -386820,7 +387020,10 @@ var Config = class {
386820
387020
  this.enablePromptCompletion = params.enablePromptCompletion ?? false;
386821
387021
  this.fileExclusions = new FileExclusions(this);
386822
387022
  this.eventEmitter = params.eventEmitter;
386823
- this.policyEngine = new PolicyEngine(params.policyEngineConfig);
387023
+ this.policyEngine = new PolicyEngine({
387024
+ ...params.policyEngineConfig,
387025
+ approvalMode: params.approvalMode ?? params.policyEngineConfig?.approvalMode
387026
+ });
386824
387027
  this.messageBus = new MessageBus(this.policyEngine, this.debugMode);
386825
387028
  this.outputSettings = {
386826
387029
  format: params.output?.format ?? OutputFormat.TEXT
@@ -386828,7 +387031,9 @@ var Config = class {
386828
387031
  this.retryFetchErrors = params.retryFetchErrors ?? false;
386829
387032
  this.disableYoloMode = params.disableYoloMode ?? false;
386830
387033
  this.hooks = params.hooks;
387034
+ this.projectHooks = params.projectHooks;
386831
387035
  this.experiments = params.experiments;
387036
+ this.onModelChange = params.onModelChange;
386832
387037
  if (params.contextFileName) {
386833
387038
  setGeminiMdFilename(params.contextFileName);
386834
387039
  }
@@ -386992,11 +387197,14 @@ var Config = class {
386992
387197
  getModel() {
386993
387198
  return this.model;
386994
387199
  }
386995
- setModel(newModel) {
387200
+ setModel(newModel, isFallbackModel = false) {
386996
387201
  if (this.model !== newModel || this._activeModel !== newModel) {
386997
387202
  this.model = newModel;
386998
387203
  this._activeModel = newModel;
386999
387204
  coreEvents.emitModelChanged(newModel);
387205
+ if (this.onModelChange && !isFallbackModel) {
387206
+ this.onModelChange(newModel);
387207
+ }
387000
387208
  }
387001
387209
  this.modelAvailabilityService.reset();
387002
387210
  }
@@ -387152,6 +387360,13 @@ var Config = class {
387152
387360
  getBlockedMcpServers() {
387153
387361
  return this.blockedMcpServers;
387154
387362
  }
387363
+ get sanitizationConfig() {
387364
+ return {
387365
+ allowedEnvironmentVariables: this.allowedEnvironmentVariables,
387366
+ blockedEnvironmentVariables: this.blockedEnvironmentVariables,
387367
+ enableEnvironmentVariableRedaction: this.enableEnvironmentVariableRedaction
387368
+ };
387369
+ }
387155
387370
  setMcpServers(mcpServers) {
387156
387371
  this.mcpServers = mcpServers;
387157
387372
  }
@@ -387198,13 +387413,13 @@ var Config = class {
387198
387413
  this.geminiMdFilePaths = paths;
387199
387414
  }
387200
387415
  getApprovalMode() {
387201
- return this.approvalMode;
387416
+ return this.policyEngine.getApprovalMode();
387202
387417
  }
387203
387418
  setApprovalMode(mode) {
387204
387419
  if (!this.isTrustedFolder() && mode !== ApprovalMode.DEFAULT) {
387205
387420
  throw new Error("Cannot enable privileged approval modes in an untrusted folder.");
387206
387421
  }
387207
- this.approvalMode = mode;
387422
+ this.policyEngine.setApprovalMode(mode);
387208
387423
  }
387209
387424
  isYoloModeDisabled() {
387210
387425
  return this.disableYoloMode || !this.isTrustedFolder();
@@ -387455,7 +387670,8 @@ var Config = class {
387455
387670
  terminalWidth: config3.terminalWidth ?? this.shellExecutionConfig.terminalWidth,
387456
387671
  terminalHeight: config3.terminalHeight ?? this.shellExecutionConfig.terminalHeight,
387457
387672
  showColor: config3.showColor ?? this.shellExecutionConfig.showColor,
387458
- pager: config3.pager ?? this.shellExecutionConfig.pager
387673
+ pager: config3.pager ?? this.shellExecutionConfig.pager,
387674
+ sanitizationConfig: config3.sanitizationConfig ?? this.shellExecutionConfig.sanitizationConfig
387459
387675
  };
387460
387676
  }
387461
387677
  getScreenReader() {
@@ -387592,6 +387808,12 @@ var Config = class {
387592
387808
  getHooks() {
387593
387809
  return this.hooks;
387594
387810
  }
387811
+ /**
387812
+ * Get project-specific hooks configuration
387813
+ */
387814
+ getProjectHooks() {
387815
+ return this.projectHooks;
387816
+ }
387595
387817
  /**
387596
387818
  * Get disabled hooks list
387597
387819
  */
@@ -387668,7 +387890,7 @@ var PolicyRuleSchema = external_exports.object({
387668
387890
  }).int({ message: "priority must be an integer" }).min(0, { message: "priority must be >= 0" }).max(999, {
387669
387891
  message: "priority must be <= 999 to prevent tier overflow. Priorities >= 1000 would jump to the next tier."
387670
387892
  }),
387671
- modes: external_exports.array(external_exports.string()).optional()
387893
+ modes: external_exports.array(external_exports.nativeEnum(ApprovalMode)).optional()
387672
387894
  });
387673
387895
  var SafetyCheckerRuleSchema = external_exports.object({
387674
387896
  toolName: external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]).optional(),
@@ -387677,7 +387899,7 @@ var SafetyCheckerRuleSchema = external_exports.object({
387677
387899
  commandPrefix: external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]).optional(),
387678
387900
  commandRegex: external_exports.string().optional(),
387679
387901
  priority: external_exports.number().int().default(0),
387680
- modes: external_exports.array(external_exports.string()).optional(),
387902
+ modes: external_exports.array(external_exports.nativeEnum(ApprovalMode)).optional(),
387681
387903
  checker: external_exports.discriminatedUnion("type", [
387682
387904
  external_exports.object({
387683
387905
  type: external_exports.literal("in-process"),