@google/gemini-cli-a2a-server 0.21.0-nightly.20251210.d90356e8a → 0.21.0-nightly.20251211.8c83e1ea9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a2a-server.mjs +559 -422
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/a2a-server.mjs
CHANGED
|
@@ -8766,15 +8766,15 @@ var require_file = __commonJS({
|
|
|
8766
8766
|
_incFile(callback) {
|
|
8767
8767
|
debug2("_incFile", this.filename);
|
|
8768
8768
|
const ext2 = path72.extname(this._basename);
|
|
8769
|
-
const
|
|
8769
|
+
const basename15 = path72.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
|
-
path72.join(this.dirname, `${
|
|
8777
|
-
path72.join(this.dirname, `${
|
|
8776
|
+
path72.join(this.dirname, `${basename15}${num}${ext2}`),
|
|
8777
|
+
path72.join(this.dirname, `${basename15}${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,
|
|
8787
|
+
this._checkMaxFilesIncrementing(ext2, basename15, cb);
|
|
8788
8788
|
} else {
|
|
8789
|
-
this._checkMaxFilesTailable(ext2,
|
|
8789
|
+
this._checkMaxFilesTailable(ext2, basename15, 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 = path72.extname(this._basename);
|
|
8803
|
-
const
|
|
8803
|
+
const basename15 = path72.basename(this._basename, ext2);
|
|
8804
8804
|
const isRotation = this.rotationFormat ? this.rotationFormat() : this._created;
|
|
8805
|
-
return !this.tailable && this._created ? `${
|
|
8805
|
+
return !this.tailable && this._created ? `${basename15}${isRotation}${ext2}` : `${basename15}${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,
|
|
8815
|
+
_checkMaxFilesIncrementing(ext2, basename15, 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 = `${
|
|
8822
|
+
const filePath = `${basename15}${isOldest}${ext2}${isZipped}`;
|
|
8823
8823
|
const target = path72.join(this.dirname, filePath);
|
|
8824
8824
|
fs63.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,
|
|
8837
|
+
_checkMaxFilesTailable(ext2, basename15, 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 = `${
|
|
8845
|
+
let fileName = `${basename15}${i4 - 1}${ext2}${isZipped}`;
|
|
8846
8846
|
const tmppath = path72.join(this.dirname, fileName);
|
|
8847
8847
|
fs63.exists(tmppath, (exists2) => {
|
|
8848
8848
|
if (!exists2) {
|
|
8849
8849
|
return cb(null);
|
|
8850
8850
|
}
|
|
8851
|
-
fileName = `${
|
|
8851
|
+
fileName = `${basename15}${i4}${ext2}${isZipped}`;
|
|
8852
8852
|
fs63.rename(tmppath, path72.join(this.dirname, fileName), cb);
|
|
8853
8853
|
});
|
|
8854
8854
|
}.bind(this, x2));
|
|
8855
8855
|
}
|
|
8856
8856
|
asyncSeries(tasks, () => {
|
|
8857
8857
|
fs63.rename(
|
|
8858
|
-
path72.join(this.dirname, `${
|
|
8859
|
-
path72.join(this.dirname, `${
|
|
8858
|
+
path72.join(this.dirname, `${basename15}${ext2}${isZipped}`),
|
|
8859
|
+
path72.join(this.dirname, `${basename15}1${ext2}${isZipped}`),
|
|
8860
8860
|
callback
|
|
8861
8861
|
);
|
|
8862
8862
|
});
|
|
@@ -33264,7 +33264,7 @@ var require_view = __commonJS({
|
|
|
33264
33264
|
var path72 = __require("node:path");
|
|
33265
33265
|
var fs63 = __require("node:fs");
|
|
33266
33266
|
var dirname17 = path72.dirname;
|
|
33267
|
-
var
|
|
33267
|
+
var basename15 = path72.basename;
|
|
33268
33268
|
var extname3 = path72.extname;
|
|
33269
33269
|
var join27 = path72.join;
|
|
33270
33270
|
var resolve14 = path72.resolve;
|
|
@@ -33303,7 +33303,7 @@ var require_view = __commonJS({
|
|
|
33303
33303
|
var root = roots[i4];
|
|
33304
33304
|
var loc = resolve14(root, name4);
|
|
33305
33305
|
var dir = dirname17(loc);
|
|
33306
|
-
var file =
|
|
33306
|
+
var file = basename15(loc);
|
|
33307
33307
|
path73 = this.resolve(dir, file);
|
|
33308
33308
|
}
|
|
33309
33309
|
return path73;
|
|
@@ -33333,7 +33333,7 @@ var require_view = __commonJS({
|
|
|
33333
33333
|
if (stat3 && stat3.isFile()) {
|
|
33334
33334
|
return path73;
|
|
33335
33335
|
}
|
|
33336
|
-
path73 = join27(dir,
|
|
33336
|
+
path73 = join27(dir, basename15(file, ext2), "index" + ext2);
|
|
33337
33337
|
stat3 = tryStat(path73);
|
|
33338
33338
|
if (stat3 && stat3.isFile()) {
|
|
33339
33339
|
return path73;
|
|
@@ -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
|
|
36628
|
+
var basename15 = __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 =
|
|
36664
|
+
var name4 = basename15(filename);
|
|
36665
36665
|
var isQuotedString = TEXT_REGEXP.test(name4);
|
|
36666
|
-
var fallbackName = typeof fallback !== "string" ? fallback && getlatin1(name4) :
|
|
36666
|
+
var fallbackName = typeof fallback !== "string" ? fallback && getlatin1(name4) : basename15(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;
|
|
@@ -45825,7 +45825,7 @@ var require_view2 = __commonJS({
|
|
|
45825
45825
|
var path72 = __require("path");
|
|
45826
45826
|
var fs63 = __require("fs");
|
|
45827
45827
|
var dirname17 = path72.dirname;
|
|
45828
|
-
var
|
|
45828
|
+
var basename15 = path72.basename;
|
|
45829
45829
|
var extname3 = path72.extname;
|
|
45830
45830
|
var join27 = path72.join;
|
|
45831
45831
|
var resolve14 = path72.resolve;
|
|
@@ -45864,7 +45864,7 @@ var require_view2 = __commonJS({
|
|
|
45864
45864
|
var root = roots[i4];
|
|
45865
45865
|
var loc = resolve14(root, name4);
|
|
45866
45866
|
var dir = dirname17(loc);
|
|
45867
|
-
var file =
|
|
45867
|
+
var file = basename15(loc);
|
|
45868
45868
|
path73 = this.resolve(dir, file);
|
|
45869
45869
|
}
|
|
45870
45870
|
return path73;
|
|
@@ -45880,7 +45880,7 @@ var require_view2 = __commonJS({
|
|
|
45880
45880
|
if (stat3 && stat3.isFile()) {
|
|
45881
45881
|
return path73;
|
|
45882
45882
|
}
|
|
45883
|
-
path73 = join27(dir,
|
|
45883
|
+
path73 = join27(dir, basename15(file, ext2), "index" + ext2);
|
|
45884
45884
|
stat3 = tryStat(path73);
|
|
45885
45885
|
if (stat3 && stat3.isFile()) {
|
|
45886
45886
|
return path73;
|
|
@@ -45903,7 +45903,7 @@ var require_content_disposition2 = __commonJS({
|
|
|
45903
45903
|
"use strict";
|
|
45904
45904
|
module2.exports = contentDisposition;
|
|
45905
45905
|
module2.exports.parse = parse10;
|
|
45906
|
-
var
|
|
45906
|
+
var basename15 = __require("path").basename;
|
|
45907
45907
|
var Buffer11 = require_safe_buffer().Buffer;
|
|
45908
45908
|
var ENCODE_URL_ATTR_CHAR_REGEXP = /[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g;
|
|
45909
45909
|
var HEX_ESCAPE_REGEXP = /%[0-9A-Fa-f]{2}/;
|
|
@@ -45939,9 +45939,9 @@ var require_content_disposition2 = __commonJS({
|
|
|
45939
45939
|
if (typeof fallback === "string" && NON_LATIN1_REGEXP.test(fallback)) {
|
|
45940
45940
|
throw new TypeError("fallback must be ISO-8859-1 string");
|
|
45941
45941
|
}
|
|
45942
|
-
var name4 =
|
|
45942
|
+
var name4 = basename15(filename);
|
|
45943
45943
|
var isQuotedString = TEXT_REGEXP.test(name4);
|
|
45944
|
-
var fallbackName = typeof fallback !== "string" ? fallback && getlatin1(name4) :
|
|
45944
|
+
var fallbackName = typeof fallback !== "string" ? fallback && getlatin1(name4) : basename15(fallback);
|
|
45945
45945
|
var hasFallback = typeof fallbackName === "string" && fallbackName !== name4;
|
|
45946
45946
|
if (hasFallback || !isQuotedString || HEX_ESCAPE_REGEXP.test(name4)) {
|
|
45947
45947
|
params["filename*"] = name4;
|
|
@@ -147379,11 +147379,11 @@ var require_path_parse = __commonJS({
|
|
|
147379
147379
|
};
|
|
147380
147380
|
};
|
|
147381
147381
|
var splitPathRe = /^((\/?)(?:[^\/]*\/)*)((\.{1,2}|[^\/]+?|)(\.[^.\/]*|))[\/]*$/;
|
|
147382
|
-
var
|
|
147382
|
+
var posix3 = {};
|
|
147383
147383
|
function posixSplitPath(filename) {
|
|
147384
147384
|
return splitPathRe.exec(filename).slice(1);
|
|
147385
147385
|
}
|
|
147386
|
-
|
|
147386
|
+
posix3.parse = function(pathString) {
|
|
147387
147387
|
if (typeof pathString !== "string") {
|
|
147388
147388
|
throw new TypeError(
|
|
147389
147389
|
"Parameter 'pathString' must be a string, not " + typeof pathString
|
|
@@ -147404,8 +147404,8 @@ var require_path_parse = __commonJS({
|
|
|
147404
147404
|
if (isWindows5)
|
|
147405
147405
|
module2.exports = win323.parse;
|
|
147406
147406
|
else
|
|
147407
|
-
module2.exports =
|
|
147408
|
-
module2.exports.posix =
|
|
147407
|
+
module2.exports = posix3.parse;
|
|
147408
|
+
module2.exports.posix = posix3.parse;
|
|
147409
147409
|
module2.exports.win32 = win323.parse;
|
|
147410
147410
|
}
|
|
147411
147411
|
});
|
|
@@ -148914,7 +148914,7 @@ var require_import_in_the_middle = __commonJS({
|
|
|
148914
148914
|
"node_modules/import-in-the-middle/index.js"(exports2, module2) {
|
|
148915
148915
|
var path72 = __require("path");
|
|
148916
148916
|
var parse10 = require_module_details_from_path();
|
|
148917
|
-
var { fileURLToPath:
|
|
148917
|
+
var { fileURLToPath: fileURLToPath14 } = __require("url");
|
|
148918
148918
|
var { MessageChannel } = __require("worker_threads");
|
|
148919
148919
|
var {
|
|
148920
148920
|
importHooks,
|
|
@@ -148993,7 +148993,7 @@ var require_import_in_the_middle = __commonJS({
|
|
|
148993
148993
|
} else {
|
|
148994
148994
|
if (name4.startsWith("file://")) {
|
|
148995
148995
|
try {
|
|
148996
|
-
name4 =
|
|
148996
|
+
name4 = fileURLToPath14(name4);
|
|
148997
148997
|
} catch (e3) {
|
|
148998
148998
|
}
|
|
148999
148999
|
}
|
|
@@ -149008,7 +149008,7 @@ var require_import_in_the_middle = __commonJS({
|
|
|
149008
149008
|
if (moduleName2 === name4) {
|
|
149009
149009
|
if (baseDir) {
|
|
149010
149010
|
if (internals) {
|
|
149011
|
-
name4 = name4 + path72.sep + path72.relative(baseDir,
|
|
149011
|
+
name4 = name4 + path72.sep + path72.relative(baseDir, fileURLToPath14(filename));
|
|
149012
149012
|
} else {
|
|
149013
149013
|
if (!getExperimentalPatchInternals() && !baseDir.endsWith(specifiers.get(filename))) continue;
|
|
149014
149014
|
}
|
|
@@ -272176,9 +272176,9 @@ var require_parse11 = __commonJS({
|
|
|
272176
272176
|
const idx = prev.value.lastIndexOf("[");
|
|
272177
272177
|
const pre = prev.value.slice(0, idx);
|
|
272178
272178
|
const rest2 = prev.value.slice(idx + 2);
|
|
272179
|
-
const
|
|
272180
|
-
if (
|
|
272181
|
-
prev.value = pre +
|
|
272179
|
+
const posix3 = POSIX_REGEX_SOURCE[rest2];
|
|
272180
|
+
if (posix3) {
|
|
272181
|
+
prev.value = pre + posix3;
|
|
272182
272182
|
state.backtrack = true;
|
|
272183
272183
|
advance();
|
|
272184
272184
|
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
@@ -272694,7 +272694,7 @@ var require_picomatch = __commonJS({
|
|
|
272694
272694
|
throw new TypeError("Expected pattern to be a non-empty string");
|
|
272695
272695
|
}
|
|
272696
272696
|
const opts = options2 || {};
|
|
272697
|
-
const
|
|
272697
|
+
const posix3 = opts.windows;
|
|
272698
272698
|
const regex2 = isState ? picomatch2.compileRe(glob2, options2) : picomatch2.makeRe(glob2, options2, false, true);
|
|
272699
272699
|
const state = regex2.state;
|
|
272700
272700
|
delete regex2.state;
|
|
@@ -272704,8 +272704,8 @@ var require_picomatch = __commonJS({
|
|
|
272704
272704
|
isIgnored = picomatch2(opts.ignore, ignoreOpts, returnState);
|
|
272705
272705
|
}
|
|
272706
272706
|
const matcher = (input, returnObject = false) => {
|
|
272707
|
-
const { isMatch, match: match2, output } = picomatch2.test(input, regex2, options2, { glob: glob2, posix:
|
|
272708
|
-
const result = { glob: glob2, state, regex: regex2, posix:
|
|
272707
|
+
const { isMatch, match: match2, output } = picomatch2.test(input, regex2, options2, { glob: glob2, posix: posix3 });
|
|
272708
|
+
const result = { glob: glob2, state, regex: regex2, posix: posix3, input, output, match: match2, isMatch };
|
|
272709
272709
|
if (typeof opts.onResult === "function") {
|
|
272710
272710
|
opts.onResult(result);
|
|
272711
272711
|
}
|
|
@@ -272730,7 +272730,7 @@ var require_picomatch = __commonJS({
|
|
|
272730
272730
|
}
|
|
272731
272731
|
return matcher;
|
|
272732
272732
|
};
|
|
272733
|
-
picomatch2.test = (input, regex2, options2, { glob: glob2, posix:
|
|
272733
|
+
picomatch2.test = (input, regex2, options2, { glob: glob2, posix: posix3 } = {}) => {
|
|
272734
272734
|
if (typeof input !== "string") {
|
|
272735
272735
|
throw new TypeError("Expected input to be a string");
|
|
272736
272736
|
}
|
|
@@ -272738,7 +272738,7 @@ var require_picomatch = __commonJS({
|
|
|
272738
272738
|
return { isMatch: false, output: "" };
|
|
272739
272739
|
}
|
|
272740
272740
|
const opts = options2 || {};
|
|
272741
|
-
const format3 = opts.format || (
|
|
272741
|
+
const format3 = opts.format || (posix3 ? utils.toPosixSlashes : null);
|
|
272742
272742
|
let match2 = input === glob2;
|
|
272743
272743
|
let output = match2 && format3 ? format3(input) : input;
|
|
272744
272744
|
if (match2 === false) {
|
|
@@ -272747,7 +272747,7 @@ var require_picomatch = __commonJS({
|
|
|
272747
272747
|
}
|
|
272748
272748
|
if (match2 === false || opts.capture === true) {
|
|
272749
272749
|
if (opts.matchBase === true || opts.basename === true) {
|
|
272750
|
-
match2 = picomatch2.matchBase(input, regex2, options2,
|
|
272750
|
+
match2 = picomatch2.matchBase(input, regex2, options2, posix3);
|
|
272751
272751
|
} else {
|
|
272752
272752
|
match2 = regex2.exec(output);
|
|
272753
272753
|
}
|
|
@@ -309839,8 +309839,8 @@ function sanitizeHookName(hookName) {
|
|
|
309839
309839
|
}
|
|
309840
309840
|
if (command.includes("/") || command.includes("\\")) {
|
|
309841
309841
|
const pathParts = command.split(/[/\\]/);
|
|
309842
|
-
const
|
|
309843
|
-
return
|
|
309842
|
+
const basename15 = pathParts[pathParts.length - 1];
|
|
309843
|
+
return basename15 || "unknown-command";
|
|
309844
309844
|
}
|
|
309845
309845
|
return command;
|
|
309846
309846
|
}
|
|
@@ -311908,8 +311908,8 @@ var Float64Vector = import_vector.default.Float64Vector;
|
|
|
311908
311908
|
var PointerVector = import_vector.default.PointerVector;
|
|
311909
311909
|
|
|
311910
311910
|
// packages/core/dist/src/generated/git-commit.js
|
|
311911
|
-
var GIT_COMMIT_INFO = "
|
|
311912
|
-
var CLI_VERSION = "0.21.0-nightly.
|
|
311911
|
+
var GIT_COMMIT_INFO = "8c83e1ea9";
|
|
311912
|
+
var CLI_VERSION = "0.21.0-nightly.20251211.8c83e1ea9";
|
|
311913
311913
|
|
|
311914
311914
|
// packages/core/dist/src/ide/detect-ide.js
|
|
311915
311915
|
var IDE_DEFINITIONS = {
|
|
@@ -315094,9 +315094,10 @@ async function createContentGenerator(config3, gcConfig, sessionId2) {
|
|
|
315094
315094
|
if (gcConfig.fakeResponses) {
|
|
315095
315095
|
return FakeContentGenerator.fromFile(gcConfig.fakeResponses);
|
|
315096
315096
|
}
|
|
315097
|
-
const version4 =
|
|
315097
|
+
const version4 = await getVersion();
|
|
315098
|
+
const model = getEffectiveModel(gcConfig.isInFallbackMode(), gcConfig.getModel(), gcConfig.getPreviewFeatures());
|
|
315098
315099
|
const customHeadersEnv = process.env["GEMINI_CLI_CUSTOM_HEADERS"] || void 0;
|
|
315099
|
-
const userAgent = `GeminiCLI/${version4} (${process.platform}; ${process.arch})`;
|
|
315100
|
+
const userAgent = `GeminiCLI/${version4}/${model} (${process.platform}; ${process.arch})`;
|
|
315100
315101
|
const customHeadersMap = parseCustomHeaders(customHeadersEnv);
|
|
315101
315102
|
const apiKeyAuthMechanism = process.env["GEMINI_API_KEY_AUTH_MECHANISM"] || "x-goog-api-key";
|
|
315102
315103
|
const baseHeaders = {
|
|
@@ -315669,6 +315670,7 @@ var READ_FILE_TOOL_NAME = "read_file";
|
|
|
315669
315670
|
var LS_TOOL_NAME = "list_directory";
|
|
315670
315671
|
var MEMORY_TOOL_NAME = "save_memory";
|
|
315671
315672
|
var EDIT_TOOL_NAMES = /* @__PURE__ */ new Set([EDIT_TOOL_NAME, WRITE_FILE_TOOL_NAME]);
|
|
315673
|
+
var DELEGATE_TO_AGENT_TOOL_NAME = "delegate_to_agent";
|
|
315672
315674
|
|
|
315673
315675
|
// packages/core/dist/src/tools/ls.js
|
|
315674
315676
|
var LSToolInvocation = class extends BaseToolInvocation {
|
|
@@ -352380,8 +352382,8 @@ Expectation for required parameters:
|
|
|
352380
352382
|
};
|
|
352381
352383
|
|
|
352382
352384
|
// packages/core/dist/src/tools/smart-edit.js
|
|
352383
|
-
import * as
|
|
352384
|
-
import * as
|
|
352385
|
+
import * as fs43 from "node:fs";
|
|
352386
|
+
import * as path43 from "node:path";
|
|
352385
352387
|
import * as crypto19 from "node:crypto";
|
|
352386
352388
|
|
|
352387
352389
|
// packages/core/dist/src/utils/editor.js
|
|
@@ -352757,28 +352759,28 @@ function parseGoogleApiError(error2) {
|
|
|
352757
352759
|
const code2 = currentError.code;
|
|
352758
352760
|
const message = currentError.message;
|
|
352759
352761
|
const errorDetails = currentError.details;
|
|
352760
|
-
if (
|
|
352762
|
+
if (code2 && message) {
|
|
352761
352763
|
const details = [];
|
|
352762
|
-
|
|
352763
|
-
|
|
352764
|
-
|
|
352765
|
-
|
|
352766
|
-
|
|
352767
|
-
if (typeKey
|
|
352768
|
-
|
|
352769
|
-
|
|
352764
|
+
if (Array.isArray(errorDetails)) {
|
|
352765
|
+
for (const detail of errorDetails) {
|
|
352766
|
+
if (detail && typeof detail === "object") {
|
|
352767
|
+
const detailObj = detail;
|
|
352768
|
+
const typeKey = Object.keys(detailObj).find((key) => key.trim() === "@type");
|
|
352769
|
+
if (typeKey) {
|
|
352770
|
+
if (typeKey !== "@type") {
|
|
352771
|
+
detailObj["@type"] = detailObj[typeKey];
|
|
352772
|
+
delete detailObj[typeKey];
|
|
352773
|
+
}
|
|
352774
|
+
details.push(detailObj);
|
|
352770
352775
|
}
|
|
352771
|
-
details.push(detailObj);
|
|
352772
352776
|
}
|
|
352773
352777
|
}
|
|
352774
352778
|
}
|
|
352775
|
-
|
|
352776
|
-
|
|
352777
|
-
|
|
352778
|
-
|
|
352779
|
-
|
|
352780
|
-
};
|
|
352781
|
-
}
|
|
352779
|
+
return {
|
|
352780
|
+
code: code2,
|
|
352781
|
+
message,
|
|
352782
|
+
details
|
|
352783
|
+
};
|
|
352782
352784
|
}
|
|
352783
352785
|
return null;
|
|
352784
352786
|
}
|
|
@@ -352820,6 +352822,16 @@ function fromApiError(errorObj) {
|
|
|
352820
352822
|
try {
|
|
352821
352823
|
data = JSON.parse(data);
|
|
352822
352824
|
} catch (_) {
|
|
352825
|
+
if (typeof data === "string") {
|
|
352826
|
+
const firstBrace = data.indexOf("{");
|
|
352827
|
+
const lastBrace = data.lastIndexOf("}");
|
|
352828
|
+
if (firstBrace !== -1 && lastBrace !== -1 && lastBrace > firstBrace) {
|
|
352829
|
+
try {
|
|
352830
|
+
data = JSON.parse(data.substring(firstBrace, lastBrace + 1));
|
|
352831
|
+
} catch (__) {
|
|
352832
|
+
}
|
|
352833
|
+
}
|
|
352834
|
+
}
|
|
352823
352835
|
}
|
|
352824
352836
|
}
|
|
352825
352837
|
if (Array.isArray(data) && data.length > 0) {
|
|
@@ -352897,8 +352909,8 @@ function classifyGoogleError(error2) {
|
|
|
352897
352909
|
const message = googleApiError?.message || (error2 instanceof Error ? error2.message : "Model not found");
|
|
352898
352910
|
return new ModelNotFoundError(message, status);
|
|
352899
352911
|
}
|
|
352900
|
-
if (!googleApiError || googleApiError.code !== 429) {
|
|
352901
|
-
const errorMessage = error2 instanceof Error ? error2.message : String(error2);
|
|
352912
|
+
if (!googleApiError || googleApiError.code !== 429 || googleApiError.details.length === 0) {
|
|
352913
|
+
const errorMessage = googleApiError?.message || (error2 instanceof Error ? error2.message : String(error2));
|
|
352902
352914
|
const match2 = errorMessage.match(/Please retry in ([0-9.]+(?:ms|s))/);
|
|
352903
352915
|
if (match2?.[1]) {
|
|
352904
352916
|
const retryDelaySeconds = parseDurationInSeconds(match2[1]);
|
|
@@ -353652,17 +353664,133 @@ async function FixLLMEditWithInstruction(instruction, old_string, new_string, er
|
|
|
353652
353664
|
}
|
|
353653
353665
|
|
|
353654
353666
|
// packages/core/dist/src/utils/pathCorrector.js
|
|
353655
|
-
import * as
|
|
353667
|
+
import * as fs42 from "node:fs";
|
|
353668
|
+
import * as path42 from "node:path";
|
|
353669
|
+
|
|
353670
|
+
// packages/core/dist/src/utils/bfsFileSearch.js
|
|
353671
|
+
import * as fs41 from "node:fs/promises";
|
|
353672
|
+
import * as fsSync from "node:fs";
|
|
353656
353673
|
import * as path41 from "node:path";
|
|
353674
|
+
var logger3 = {
|
|
353675
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
353676
|
+
debug: (...args2) => debugLogger.debug("[DEBUG] [BfsFileSearch]", ...args2)
|
|
353677
|
+
};
|
|
353678
|
+
async function bfsFileSearch(rootDir, options2) {
|
|
353679
|
+
const { ignoreDirs = [], maxDirs = Infinity, debug: debug2 = false } = options2;
|
|
353680
|
+
const foundFiles = [];
|
|
353681
|
+
const queue = [rootDir];
|
|
353682
|
+
const visited = /* @__PURE__ */ new Set();
|
|
353683
|
+
let scannedDirCount = 0;
|
|
353684
|
+
let queueHead = 0;
|
|
353685
|
+
const ignoreDirsSet = new Set(ignoreDirs);
|
|
353686
|
+
const PARALLEL_BATCH_SIZE = 15;
|
|
353687
|
+
while (queueHead < queue.length && scannedDirCount < maxDirs) {
|
|
353688
|
+
const batchSize = Math.min(PARALLEL_BATCH_SIZE, maxDirs - scannedDirCount);
|
|
353689
|
+
const currentBatch = [];
|
|
353690
|
+
while (currentBatch.length < batchSize && queueHead < queue.length) {
|
|
353691
|
+
const currentDir = queue[queueHead];
|
|
353692
|
+
queueHead++;
|
|
353693
|
+
if (!visited.has(currentDir)) {
|
|
353694
|
+
visited.add(currentDir);
|
|
353695
|
+
currentBatch.push(currentDir);
|
|
353696
|
+
}
|
|
353697
|
+
}
|
|
353698
|
+
scannedDirCount += currentBatch.length;
|
|
353699
|
+
if (currentBatch.length === 0)
|
|
353700
|
+
continue;
|
|
353701
|
+
if (debug2) {
|
|
353702
|
+
logger3.debug(`Scanning [${scannedDirCount}/${maxDirs}]: batch of ${currentBatch.length}`);
|
|
353703
|
+
}
|
|
353704
|
+
const readPromises = currentBatch.map(async (currentDir) => {
|
|
353705
|
+
try {
|
|
353706
|
+
const entries2 = await fs41.readdir(currentDir, { withFileTypes: true });
|
|
353707
|
+
return { currentDir, entries: entries2 };
|
|
353708
|
+
} catch (error2) {
|
|
353709
|
+
const message = error2?.message ?? "Unknown error";
|
|
353710
|
+
debugLogger.warn(`[WARN] Skipping unreadable directory: ${currentDir} (${message})`);
|
|
353711
|
+
if (debug2) {
|
|
353712
|
+
logger3.debug(`Full error for ${currentDir}:`, error2);
|
|
353713
|
+
}
|
|
353714
|
+
return { currentDir, entries: [] };
|
|
353715
|
+
}
|
|
353716
|
+
});
|
|
353717
|
+
const results = await Promise.all(readPromises);
|
|
353718
|
+
for (const { currentDir, entries: entries2 } of results) {
|
|
353719
|
+
processDirEntries(currentDir, entries2, options2, ignoreDirsSet, queue, foundFiles);
|
|
353720
|
+
}
|
|
353721
|
+
}
|
|
353722
|
+
return foundFiles;
|
|
353723
|
+
}
|
|
353724
|
+
function bfsFileSearchSync(rootDir, options2) {
|
|
353725
|
+
const { ignoreDirs = [], maxDirs = Infinity, debug: debug2 = false } = options2;
|
|
353726
|
+
const foundFiles = [];
|
|
353727
|
+
const queue = [rootDir];
|
|
353728
|
+
const visited = /* @__PURE__ */ new Set();
|
|
353729
|
+
let scannedDirCount = 0;
|
|
353730
|
+
let queueHead = 0;
|
|
353731
|
+
const ignoreDirsSet = new Set(ignoreDirs);
|
|
353732
|
+
while (queueHead < queue.length && scannedDirCount < maxDirs) {
|
|
353733
|
+
const currentDir = queue[queueHead];
|
|
353734
|
+
queueHead++;
|
|
353735
|
+
if (!visited.has(currentDir)) {
|
|
353736
|
+
visited.add(currentDir);
|
|
353737
|
+
scannedDirCount++;
|
|
353738
|
+
if (debug2) {
|
|
353739
|
+
logger3.debug(`Scanning Sync [${scannedDirCount}/${maxDirs}]: ${currentDir}`);
|
|
353740
|
+
}
|
|
353741
|
+
try {
|
|
353742
|
+
const entries2 = fsSync.readdirSync(currentDir, { withFileTypes: true });
|
|
353743
|
+
processDirEntries(currentDir, entries2, options2, ignoreDirsSet, queue, foundFiles);
|
|
353744
|
+
} catch (error2) {
|
|
353745
|
+
const message = error2?.message ?? "Unknown error";
|
|
353746
|
+
debugLogger.warn(`[WARN] Skipping unreadable directory: ${currentDir} (${message})`);
|
|
353747
|
+
}
|
|
353748
|
+
}
|
|
353749
|
+
}
|
|
353750
|
+
return foundFiles;
|
|
353751
|
+
}
|
|
353752
|
+
function processDirEntries(currentDir, entries2, options2, ignoreDirsSet, queue, foundFiles) {
|
|
353753
|
+
for (const entry of entries2) {
|
|
353754
|
+
const fullPath = path41.join(currentDir, entry.name);
|
|
353755
|
+
const isDirectory = entry.isDirectory();
|
|
353756
|
+
const isMatchingFile = entry.isFile() && entry.name === options2.fileName;
|
|
353757
|
+
if (!isDirectory && !isMatchingFile) {
|
|
353758
|
+
continue;
|
|
353759
|
+
}
|
|
353760
|
+
if (isDirectory && ignoreDirsSet.has(entry.name)) {
|
|
353761
|
+
continue;
|
|
353762
|
+
}
|
|
353763
|
+
if (options2.fileService?.shouldIgnoreFile(fullPath, {
|
|
353764
|
+
respectGitIgnore: options2.fileFilteringOptions?.respectGitIgnore,
|
|
353765
|
+
respectGeminiIgnore: options2.fileFilteringOptions?.respectGeminiIgnore
|
|
353766
|
+
})) {
|
|
353767
|
+
continue;
|
|
353768
|
+
}
|
|
353769
|
+
if (isDirectory) {
|
|
353770
|
+
queue.push(fullPath);
|
|
353771
|
+
} else {
|
|
353772
|
+
foundFiles.push(fullPath);
|
|
353773
|
+
}
|
|
353774
|
+
}
|
|
353775
|
+
}
|
|
353776
|
+
|
|
353777
|
+
// packages/core/dist/src/utils/pathCorrector.js
|
|
353657
353778
|
function correctPath(filePath, config3) {
|
|
353658
|
-
const directPath =
|
|
353659
|
-
if (
|
|
353779
|
+
const directPath = path42.join(config3.getTargetDir(), filePath);
|
|
353780
|
+
if (fs42.existsSync(directPath)) {
|
|
353660
353781
|
return { success: true, correctedPath: directPath };
|
|
353661
353782
|
}
|
|
353662
353783
|
const workspaceContext = config3.getWorkspaceContext();
|
|
353663
|
-
const fileSystem = config3.getFileSystemService();
|
|
353664
353784
|
const searchPaths = workspaceContext.getDirectories();
|
|
353665
|
-
const
|
|
353785
|
+
const basename15 = path42.basename(filePath);
|
|
353786
|
+
const normalizedTarget = filePath.replace(/\\/g, "/");
|
|
353787
|
+
const foundFiles = searchPaths.flatMap((searchPath) => bfsFileSearchSync(searchPath, {
|
|
353788
|
+
fileName: basename15,
|
|
353789
|
+
maxDirs: 50,
|
|
353790
|
+
// Capped to avoid deep hangs
|
|
353791
|
+
fileService: config3.getFileService(),
|
|
353792
|
+
fileFilteringOptions: config3.getFileFilteringOptions()
|
|
353793
|
+
})).filter((f3) => f3.replace(/\\/g, "/").endsWith(normalizedTarget));
|
|
353666
353794
|
if (foundFiles.length === 0) {
|
|
353667
353795
|
return {
|
|
353668
353796
|
success: false,
|
|
@@ -354044,7 +354172,7 @@ var EditToolInvocation2 = class extends BaseToolInvocation {
|
|
|
354044
354172
|
debugLogger.log(`Error: ${editData.error.display}`);
|
|
354045
354173
|
return false;
|
|
354046
354174
|
}
|
|
354047
|
-
const fileName =
|
|
354175
|
+
const fileName = path43.basename(this.params.file_path);
|
|
354048
354176
|
const fileDiff = createPatch(fileName, editData.currentContent ?? "", editData.newContent, "Current", "Proposed", DEFAULT_DIFF_OPTIONS);
|
|
354049
354177
|
const ideClient = await IdeClient.getInstance();
|
|
354050
354178
|
const ideConfirmation = this.config.getIdeMode() && ideClient.isDiffingEnabled() ? ideClient.openDiff(this.params.file_path, editData.newContent) : void 0;
|
|
@@ -354128,7 +354256,7 @@ var EditToolInvocation2 = class extends BaseToolInvocation {
|
|
|
354128
354256
|
if (editData.isNewFile) {
|
|
354129
354257
|
displayResult = `Created ${shortenPath(makeRelative(this.params.file_path, this.config.getTargetDir()))}`;
|
|
354130
354258
|
} else {
|
|
354131
|
-
const fileName =
|
|
354259
|
+
const fileName = path43.basename(this.params.file_path);
|
|
354132
354260
|
const fileDiff = createPatch(
|
|
354133
354261
|
fileName,
|
|
354134
354262
|
editData.currentContent ?? "",
|
|
@@ -354173,9 +354301,9 @@ var EditToolInvocation2 = class extends BaseToolInvocation {
|
|
|
354173
354301
|
* Creates parent directories if they don't exist
|
|
354174
354302
|
*/
|
|
354175
354303
|
ensureParentDirectoriesExist(filePath) {
|
|
354176
|
-
const dirName =
|
|
354177
|
-
if (!
|
|
354178
|
-
|
|
354304
|
+
const dirName = path43.dirname(filePath);
|
|
354305
|
+
if (!fs43.existsSync(dirName)) {
|
|
354306
|
+
fs43.mkdirSync(dirName, { recursive: true });
|
|
354179
354307
|
}
|
|
354180
354308
|
}
|
|
354181
354309
|
};
|
|
@@ -354258,7 +354386,7 @@ A good instruction should concisely answer:
|
|
|
354258
354386
|
return "The 'file_path' parameter must be non-empty.";
|
|
354259
354387
|
}
|
|
354260
354388
|
let filePath = params.file_path;
|
|
354261
|
-
if (!
|
|
354389
|
+
if (!path43.isAbsolute(filePath)) {
|
|
354262
354390
|
const result = correctPath(filePath, this.config);
|
|
354263
354391
|
if (!result.success) {
|
|
354264
354392
|
return result.error;
|
|
@@ -354313,8 +354441,8 @@ A good instruction should concisely answer:
|
|
|
354313
354441
|
};
|
|
354314
354442
|
|
|
354315
354443
|
// packages/core/dist/src/tools/shell.js
|
|
354316
|
-
import
|
|
354317
|
-
import
|
|
354444
|
+
import fs44 from "node:fs";
|
|
354445
|
+
import path44 from "node:path";
|
|
354318
354446
|
import os17, { EOL as EOL2 } from "node:os";
|
|
354319
354447
|
import crypto20 from "node:crypto";
|
|
354320
354448
|
|
|
@@ -360043,7 +360171,7 @@ var ShellToolInvocation = class extends BaseToolInvocation {
|
|
|
360043
360171
|
}
|
|
360044
360172
|
const isWindows5 = os17.platform() === "win32";
|
|
360045
360173
|
const tempFileName = `shell_pgrep_${crypto20.randomBytes(6).toString("hex")}.tmp`;
|
|
360046
|
-
const tempFilePath =
|
|
360174
|
+
const tempFilePath = path44.join(os17.tmpdir(), tempFileName);
|
|
360047
360175
|
const timeoutMs = this.config.getShellToolInactivityTimeout();
|
|
360048
360176
|
const timeoutController = new AbortController();
|
|
360049
360177
|
let timeoutTimer;
|
|
@@ -360056,7 +360184,7 @@ var ShellToolInvocation = class extends BaseToolInvocation {
|
|
|
360056
360184
|
command += ";";
|
|
360057
360185
|
return `{ ${command} }; __code=$?; pgrep -g 0 >${tempFilePath} 2>&1; exit $__code;`;
|
|
360058
360186
|
})();
|
|
360059
|
-
const cwd = this.params.dir_path ?
|
|
360187
|
+
const cwd = this.params.dir_path ? path44.resolve(this.config.getTargetDir(), this.params.dir_path) : this.config.getTargetDir();
|
|
360060
360188
|
let cumulativeOutput = "";
|
|
360061
360189
|
let lastUpdateTime = Date.now();
|
|
360062
360190
|
let isBinaryStream = false;
|
|
@@ -360115,8 +360243,8 @@ var ShellToolInvocation = class extends BaseToolInvocation {
|
|
|
360115
360243
|
const result = await resultPromise;
|
|
360116
360244
|
const backgroundPIDs = [];
|
|
360117
360245
|
if (os17.platform() !== "win32") {
|
|
360118
|
-
if (
|
|
360119
|
-
const pgrepLines =
|
|
360246
|
+
if (fs44.existsSync(tempFilePath)) {
|
|
360247
|
+
const pgrepLines = fs44.readFileSync(tempFilePath, "utf8").split(EOL2).filter(Boolean);
|
|
360120
360248
|
for (const line of pgrepLines) {
|
|
360121
360249
|
if (!/^\d+$/.test(line)) {
|
|
360122
360250
|
debugLogger.error(`pgrep: ${line}`);
|
|
@@ -360208,8 +360336,8 @@ ${result.output}`;
|
|
|
360208
360336
|
clearTimeout(timeoutTimer);
|
|
360209
360337
|
signal.removeEventListener("abort", onAbort);
|
|
360210
360338
|
timeoutController.signal.removeEventListener("abort", onAbort);
|
|
360211
|
-
if (
|
|
360212
|
-
|
|
360339
|
+
if (fs44.existsSync(tempFilePath)) {
|
|
360340
|
+
fs44.unlinkSync(tempFilePath);
|
|
360213
360341
|
}
|
|
360214
360342
|
}
|
|
360215
360343
|
}
|
|
@@ -360303,7 +360431,7 @@ var ShellTool = class _ShellTool extends BaseDeclarativeTool {
|
|
|
360303
360431
|
return "Could not identify command root to obtain permission from user.";
|
|
360304
360432
|
}
|
|
360305
360433
|
if (params.dir_path) {
|
|
360306
|
-
const resolvedPath =
|
|
360434
|
+
const resolvedPath = path44.resolve(this.config.getTargetDir(), params.dir_path);
|
|
360307
360435
|
const workspaceContext = this.config.getWorkspaceContext();
|
|
360308
360436
|
if (!workspaceContext.isPathWithinWorkspace(resolvedPath)) {
|
|
360309
360437
|
return `Directory '${resolvedPath}' is not within any of the registered workspace directories.`;
|
|
@@ -360317,8 +360445,8 @@ var ShellTool = class _ShellTool extends BaseDeclarativeTool {
|
|
|
360317
360445
|
};
|
|
360318
360446
|
|
|
360319
360447
|
// packages/core/dist/src/tools/write-file.js
|
|
360320
|
-
import
|
|
360321
|
-
import
|
|
360448
|
+
import fs45 from "node:fs";
|
|
360449
|
+
import path45 from "node:path";
|
|
360322
360450
|
async function getCorrectedFileContent(config3, filePath, proposedContent, abortSignal) {
|
|
360323
360451
|
let originalContent = "";
|
|
360324
360452
|
let fileExists2 = false;
|
|
@@ -360359,7 +360487,7 @@ var WriteFileToolInvocation = class extends BaseToolInvocation {
|
|
|
360359
360487
|
constructor(config3, params, messageBus, toolName, displayName) {
|
|
360360
360488
|
super(params, messageBus, toolName, displayName);
|
|
360361
360489
|
this.config = config3;
|
|
360362
|
-
this.resolvedPath =
|
|
360490
|
+
this.resolvedPath = path45.resolve(this.config.getTargetDir(), this.params.file_path);
|
|
360363
360491
|
}
|
|
360364
360492
|
toolLocations() {
|
|
360365
360493
|
return [{ path: this.resolvedPath }];
|
|
@@ -360378,7 +360506,7 @@ var WriteFileToolInvocation = class extends BaseToolInvocation {
|
|
|
360378
360506
|
}
|
|
360379
360507
|
const { originalContent, correctedContent } = correctedContentResult;
|
|
360380
360508
|
const relativePath = makeRelative(this.resolvedPath, this.config.getTargetDir());
|
|
360381
|
-
const fileName =
|
|
360509
|
+
const fileName = path45.basename(this.resolvedPath);
|
|
360382
360510
|
const fileDiff = createPatch(
|
|
360383
360511
|
fileName,
|
|
360384
360512
|
originalContent,
|
|
@@ -360432,12 +360560,12 @@ var WriteFileToolInvocation = class extends BaseToolInvocation {
|
|
|
360432
360560
|
const { originalContent, correctedContent: fileContent, fileExists: fileExists2 } = correctedContentResult;
|
|
360433
360561
|
const isNewFile = !fileExists2 || correctedContentResult.error !== void 0 && !correctedContentResult.fileExists;
|
|
360434
360562
|
try {
|
|
360435
|
-
const dirName =
|
|
360436
|
-
if (!
|
|
360437
|
-
|
|
360563
|
+
const dirName = path45.dirname(this.resolvedPath);
|
|
360564
|
+
if (!fs45.existsSync(dirName)) {
|
|
360565
|
+
fs45.mkdirSync(dirName, { recursive: true });
|
|
360438
360566
|
}
|
|
360439
360567
|
await this.config.getFileSystemService().writeTextFile(this.resolvedPath, fileContent);
|
|
360440
|
-
const fileName =
|
|
360568
|
+
const fileName = path45.basename(this.resolvedPath);
|
|
360441
360569
|
const currentContentForDiff = correctedContentResult.error ? "" : originalContent;
|
|
360442
360570
|
const fileDiff = createPatch(fileName, currentContentForDiff, fileContent, "Original", "Written", DEFAULT_DIFF_OPTIONS);
|
|
360443
360571
|
const originallyProposedContent = ai_proposed_content || content;
|
|
@@ -360450,7 +360578,7 @@ var WriteFileToolInvocation = class extends BaseToolInvocation {
|
|
|
360450
360578
|
}
|
|
360451
360579
|
const mimetype = getSpecificMimeType(this.resolvedPath);
|
|
360452
360580
|
const programmingLanguage = getLanguageFromFilePath(this.resolvedPath);
|
|
360453
|
-
const extension =
|
|
360581
|
+
const extension = path45.extname(this.resolvedPath);
|
|
360454
360582
|
const operation = isNewFile ? FileOperation.CREATE : FileOperation.UPDATE;
|
|
360455
360583
|
logFileOperation(this.config, new FileOperationEvent(WRITE_FILE_TOOL_NAME, operation, fileContent.split("\n").length, mimetype, extension, programmingLanguage));
|
|
360456
360584
|
const displayResult = {
|
|
@@ -360525,15 +360653,15 @@ var WriteFileTool = class _WriteFileTool extends BaseDeclarativeTool {
|
|
|
360525
360653
|
if (!filePath) {
|
|
360526
360654
|
return `Missing or empty "file_path"`;
|
|
360527
360655
|
}
|
|
360528
|
-
const resolvedPath =
|
|
360656
|
+
const resolvedPath = path45.resolve(this.config.getTargetDir(), filePath);
|
|
360529
360657
|
const workspaceContext = this.config.getWorkspaceContext();
|
|
360530
360658
|
if (!workspaceContext.isPathWithinWorkspace(resolvedPath)) {
|
|
360531
360659
|
const directories = workspaceContext.getDirectories();
|
|
360532
360660
|
return `File path must be within one of the workspace directories: ${directories.join(", ")}`;
|
|
360533
360661
|
}
|
|
360534
360662
|
try {
|
|
360535
|
-
if (
|
|
360536
|
-
const stats =
|
|
360663
|
+
if (fs45.existsSync(resolvedPath)) {
|
|
360664
|
+
const stats = fs45.lstatSync(resolvedPath);
|
|
360537
360665
|
if (stats.isDirectory()) {
|
|
360538
360666
|
return `Path is a directory, not a file: ${resolvedPath}`;
|
|
360539
360667
|
}
|
|
@@ -365941,13 +366069,13 @@ var WebSearchTool = class _WebSearchTool extends BaseDeclarativeTool {
|
|
|
365941
366069
|
};
|
|
365942
366070
|
|
|
365943
366071
|
// packages/core/dist/src/utils/getFolderStructure.js
|
|
365944
|
-
import * as
|
|
365945
|
-
import * as
|
|
366072
|
+
import * as fs46 from "node:fs/promises";
|
|
366073
|
+
import * as path46 from "node:path";
|
|
365946
366074
|
var MAX_ITEMS = 200;
|
|
365947
366075
|
var TRUNCATION_INDICATOR = "...";
|
|
365948
366076
|
var DEFAULT_IGNORED_FOLDERS = /* @__PURE__ */ new Set(["node_modules", ".git", "dist"]);
|
|
365949
366077
|
async function readFullStructure(rootPath, options2) {
|
|
365950
|
-
const rootName =
|
|
366078
|
+
const rootName = path46.basename(rootPath);
|
|
365951
366079
|
const rootNode = {
|
|
365952
366080
|
name: rootName,
|
|
365953
366081
|
path: rootPath,
|
|
@@ -365972,7 +366100,7 @@ async function readFullStructure(rootPath, options2) {
|
|
|
365972
366100
|
}
|
|
365973
366101
|
let entries2;
|
|
365974
366102
|
try {
|
|
365975
|
-
const rawEntries = await
|
|
366103
|
+
const rawEntries = await fs46.readdir(currentPath, { withFileTypes: true });
|
|
365976
366104
|
entries2 = rawEntries.sort((a2, b) => a2.name.localeCompare(b.name));
|
|
365977
366105
|
} catch (error2) {
|
|
365978
366106
|
if (isNodeError(error2) && (error2.code === "EACCES" || error2.code === "ENOENT")) {
|
|
@@ -365997,7 +366125,7 @@ async function readFullStructure(rootPath, options2) {
|
|
|
365997
366125
|
break;
|
|
365998
366126
|
}
|
|
365999
366127
|
const fileName = entry.name;
|
|
366000
|
-
const filePath =
|
|
366128
|
+
const filePath = path46.join(currentPath, fileName);
|
|
366001
366129
|
if (options2.fileService?.shouldIgnoreFile(filePath, filterFileOptions)) {
|
|
366002
366130
|
continue;
|
|
366003
366131
|
}
|
|
@@ -366017,7 +366145,7 @@ async function readFullStructure(rootPath, options2) {
|
|
|
366017
366145
|
break;
|
|
366018
366146
|
}
|
|
366019
366147
|
const subFolderName = entry.name;
|
|
366020
|
-
const subFolderPath =
|
|
366148
|
+
const subFolderPath = path46.join(currentPath, subFolderName);
|
|
366021
366149
|
const isIgnored = options2.fileService?.shouldIgnoreFile(subFolderPath, filterFileOptions) ?? false;
|
|
366022
366150
|
if (options2.ignoredFolders.has(subFolderName) || isIgnored) {
|
|
366023
366151
|
const ignoredSubFolder = {
|
|
@@ -366055,7 +366183,7 @@ async function readFullStructure(rootPath, options2) {
|
|
|
366055
366183
|
function formatStructure(node, currentIndent, isLastChildOfParent, isProcessingRootNode, builder) {
|
|
366056
366184
|
const connector = isLastChildOfParent ? "\u2514\u2500\u2500\u2500" : "\u251C\u2500\u2500\u2500";
|
|
366057
366185
|
if (!isProcessingRootNode || node.isIgnored) {
|
|
366058
|
-
builder.push(`${currentIndent}${connector}${node.name}${
|
|
366186
|
+
builder.push(`${currentIndent}${connector}${node.name}${path46.sep}${node.isIgnored ? TRUNCATION_INDICATOR : ""}`);
|
|
366059
366187
|
}
|
|
366060
366188
|
const indentForChildren = isProcessingRootNode ? "" : currentIndent + (isLastChildOfParent ? " " : "\u2502 ");
|
|
366061
366189
|
const fileCount = node.files.length;
|
|
@@ -366079,7 +366207,7 @@ function formatStructure(node, currentIndent, isLastChildOfParent, isProcessingR
|
|
|
366079
366207
|
}
|
|
366080
366208
|
}
|
|
366081
366209
|
async function getFolderStructure(directory, options2) {
|
|
366082
|
-
const resolvedPath =
|
|
366210
|
+
const resolvedPath = path46.resolve(directory);
|
|
366083
366211
|
const mergedOptions = {
|
|
366084
366212
|
maxItems: options2?.maxItems ?? MAX_ITEMS,
|
|
366085
366213
|
ignoredFolders: options2?.ignoredFolders ?? DEFAULT_IGNORED_FOLDERS,
|
|
@@ -366112,7 +366240,7 @@ async function getFolderStructure(directory, options2) {
|
|
|
366112
366240
|
}
|
|
366113
366241
|
return `${summary}
|
|
366114
366242
|
|
|
366115
|
-
${resolvedPath}${
|
|
366243
|
+
${resolvedPath}${path46.sep}
|
|
366116
366244
|
${structureLines.join("\n")}`;
|
|
366117
366245
|
} catch (error2) {
|
|
366118
366246
|
console.error(`Error getting folder structure for ${resolvedPath}:`, error2);
|
|
@@ -366193,8 +366321,8 @@ function getResponseTextFromParts(parts2) {
|
|
|
366193
366321
|
}
|
|
366194
366322
|
|
|
366195
366323
|
// packages/core/dist/src/core/coreToolScheduler.js
|
|
366196
|
-
import * as
|
|
366197
|
-
import * as
|
|
366324
|
+
import * as fs47 from "node:fs/promises";
|
|
366325
|
+
import * as path47 from "node:path";
|
|
366198
366326
|
var import_fast_levenshtein = __toESM(require_levenshtein(), 1);
|
|
366199
366327
|
|
|
366200
366328
|
// packages/core/dist/src/hooks/hookTranslator.js
|
|
@@ -366860,10 +366988,10 @@ async function truncateAndSaveToFile(content, callId, projectTempDir, threshold,
|
|
|
366860
366988
|
const beginning = lines.slice(0, head);
|
|
366861
366989
|
const end = lines.slice(-(truncateLines - head));
|
|
366862
366990
|
const truncatedContent = beginning.join("\n") + "\n... [CONTENT TRUNCATED] ...\n" + end.join("\n");
|
|
366863
|
-
const safeFileName = `${
|
|
366864
|
-
const outputFile =
|
|
366991
|
+
const safeFileName = `${path47.basename(callId)}.output`;
|
|
366992
|
+
const outputFile = path47.join(projectTempDir, safeFileName);
|
|
366865
366993
|
try {
|
|
366866
|
-
await
|
|
366994
|
+
await fs47.writeFile(outputFile, fileContent);
|
|
366867
366995
|
return {
|
|
366868
366996
|
content: `Tool output was too large and has been truncated.
|
|
366869
366997
|
The full output has been saved to: ${outputFile}
|
|
@@ -367539,8 +367667,8 @@ function parseThought(rawText) {
|
|
|
367539
367667
|
}
|
|
367540
367668
|
|
|
367541
367669
|
// packages/core/dist/src/services/chatRecordingService.js
|
|
367542
|
-
import
|
|
367543
|
-
import
|
|
367670
|
+
import path48 from "node:path";
|
|
367671
|
+
import fs48 from "node:fs";
|
|
367544
367672
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
367545
367673
|
var SESSION_FILE_PREFIX = "session-";
|
|
367546
367674
|
var ChatRecordingService = class {
|
|
@@ -367570,11 +367698,11 @@ var ChatRecordingService = class {
|
|
|
367570
367698
|
});
|
|
367571
367699
|
this.cachedLastConvData = null;
|
|
367572
367700
|
} else {
|
|
367573
|
-
const chatsDir =
|
|
367574
|
-
|
|
367701
|
+
const chatsDir = path48.join(this.config.storage.getProjectTempDir(), "chats");
|
|
367702
|
+
fs48.mkdirSync(chatsDir, { recursive: true });
|
|
367575
367703
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 16).replace(/:/g, "-");
|
|
367576
367704
|
const filename = `${SESSION_FILE_PREFIX}${timestamp}-${this.sessionId.slice(0, 8)}.json`;
|
|
367577
|
-
this.conversationFile =
|
|
367705
|
+
this.conversationFile = path48.join(chatsDir, filename);
|
|
367578
367706
|
this.writeConversation({
|
|
367579
367707
|
sessionId: this.sessionId,
|
|
367580
367708
|
projectHash: this.projectHash,
|
|
@@ -367744,7 +367872,7 @@ var ChatRecordingService = class {
|
|
|
367744
367872
|
*/
|
|
367745
367873
|
readConversation() {
|
|
367746
367874
|
try {
|
|
367747
|
-
this.cachedLastConvData =
|
|
367875
|
+
this.cachedLastConvData = fs48.readFileSync(this.conversationFile, "utf8");
|
|
367748
367876
|
return JSON.parse(this.cachedLastConvData);
|
|
367749
367877
|
} catch (error2) {
|
|
367750
367878
|
if (error2.code !== "ENOENT") {
|
|
@@ -367773,7 +367901,7 @@ var ChatRecordingService = class {
|
|
|
367773
367901
|
conversation.lastUpdated = (/* @__PURE__ */ new Date()).toISOString();
|
|
367774
367902
|
const newContent = JSON.stringify(conversation, null, 2);
|
|
367775
367903
|
this.cachedLastConvData = newContent;
|
|
367776
|
-
|
|
367904
|
+
fs48.writeFileSync(this.conversationFile, newContent);
|
|
367777
367905
|
}
|
|
367778
367906
|
} catch (error2) {
|
|
367779
367907
|
debugLogger.error("Error writing conversation file.", error2);
|
|
@@ -367816,14 +367944,21 @@ var ChatRecordingService = class {
|
|
|
367816
367944
|
return null;
|
|
367817
367945
|
}
|
|
367818
367946
|
}
|
|
367947
|
+
/**
|
|
367948
|
+
* Gets the path to the current conversation file.
|
|
367949
|
+
* Returns null if the service hasn't been initialized yet.
|
|
367950
|
+
*/
|
|
367951
|
+
getConversationFilePath() {
|
|
367952
|
+
return this.conversationFile;
|
|
367953
|
+
}
|
|
367819
367954
|
/**
|
|
367820
367955
|
* Deletes a session file by session ID.
|
|
367821
367956
|
*/
|
|
367822
367957
|
deleteSession(sessionId2) {
|
|
367823
367958
|
try {
|
|
367824
|
-
const chatsDir =
|
|
367825
|
-
const sessionPath =
|
|
367826
|
-
|
|
367959
|
+
const chatsDir = path48.join(this.config.storage.getProjectTempDir(), "chats");
|
|
367960
|
+
const sessionPath = path48.join(chatsDir, `${sessionId2}.json`);
|
|
367961
|
+
fs48.unlinkSync(sessionPath);
|
|
367827
367962
|
} catch (error2) {
|
|
367828
367963
|
debugLogger.error("Error deleting session file.", error2);
|
|
367829
367964
|
throw error2;
|
|
@@ -368928,8 +369063,8 @@ function getCitations(resp) {
|
|
|
368928
369063
|
}
|
|
368929
369064
|
|
|
368930
369065
|
// packages/core/dist/src/core/prompts.js
|
|
368931
|
-
import
|
|
368932
|
-
import
|
|
369066
|
+
import path49 from "node:path";
|
|
369067
|
+
import fs49 from "node:fs";
|
|
368933
369068
|
import os18 from "node:os";
|
|
368934
369069
|
import process20 from "node:process";
|
|
368935
369070
|
|
|
@@ -369248,7 +369383,7 @@ function resolvePathFromEnv(envVar) {
|
|
|
369248
369383
|
if (customPath === "~") {
|
|
369249
369384
|
customPath = home;
|
|
369250
369385
|
} else {
|
|
369251
|
-
customPath =
|
|
369386
|
+
customPath = path49.join(home, customPath.slice(2));
|
|
369252
369387
|
}
|
|
369253
369388
|
} catch (error2) {
|
|
369254
369389
|
debugLogger.warn(`Could not resolve home directory for path: ${trimmedEnvVar}`, error2);
|
|
@@ -369257,20 +369392,20 @@ function resolvePathFromEnv(envVar) {
|
|
|
369257
369392
|
}
|
|
369258
369393
|
return {
|
|
369259
369394
|
isSwitch: false,
|
|
369260
|
-
value:
|
|
369395
|
+
value: path49.resolve(customPath),
|
|
369261
369396
|
isDisabled: false
|
|
369262
369397
|
};
|
|
369263
369398
|
}
|
|
369264
369399
|
function getCoreSystemPrompt(config3, userMemory) {
|
|
369265
369400
|
let systemMdEnabled = false;
|
|
369266
|
-
let systemMdPath =
|
|
369401
|
+
let systemMdPath = path49.resolve(path49.join(GEMINI_DIR, "system.md"));
|
|
369267
369402
|
const systemMdResolution = resolvePathFromEnv(process20.env["GEMINI_SYSTEM_MD"]);
|
|
369268
369403
|
if (systemMdResolution.value && !systemMdResolution.isDisabled) {
|
|
369269
369404
|
systemMdEnabled = true;
|
|
369270
369405
|
if (!systemMdResolution.isSwitch) {
|
|
369271
369406
|
systemMdPath = systemMdResolution.value;
|
|
369272
369407
|
}
|
|
369273
|
-
if (!
|
|
369408
|
+
if (!fs49.existsSync(systemMdPath)) {
|
|
369274
369409
|
throw new Error(`missing system prompt file '${systemMdPath}'`);
|
|
369275
369410
|
}
|
|
369276
369411
|
}
|
|
@@ -369283,7 +369418,7 @@ function getCoreSystemPrompt(config3, userMemory) {
|
|
|
369283
369418
|
const interactiveMode = config3.isInteractiveShellEnabled();
|
|
369284
369419
|
let basePrompt;
|
|
369285
369420
|
if (systemMdEnabled) {
|
|
369286
|
-
basePrompt =
|
|
369421
|
+
basePrompt = fs49.readFileSync(systemMdPath, "utf8");
|
|
369287
369422
|
} else {
|
|
369288
369423
|
const promptConfig = {
|
|
369289
369424
|
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.`,
|
|
@@ -369299,7 +369434,9 @@ function getCoreSystemPrompt(config3, userMemory) {
|
|
|
369299
369434
|
- ${interactiveMode ? `**Confirm Ambiguity/Expansion:** Do not take significant actions beyond the clear scope of the request without confirming with the user. If asked *how* to do something, explain first, don't just do it.` : `**Handle Ambiguity/Expansion:** Do not take significant actions beyond the clear scope of the request.`}
|
|
369300
369435
|
- **Explaining Changes:** After completing a code modification or file operation *do not* provide summaries unless asked.
|
|
369301
369436
|
- **Do Not revert changes:** Do not revert changes to the codebase unless asked to do so by the user. Only revert changes made by you if they have resulted in an error or if the user has explicitly asked you to revert the changes.${mandatesVariant}${!interactiveMode ? `
|
|
369302
|
-
- **Continue the work** You are not to interact with the user. Do your best to complete the task at hand, using your best judgement and avoid asking user for any additional information.` : ""}
|
|
369437
|
+
- **Continue the work** You are not to interact with the user. Do your best to complete the task at hand, using your best judgement and avoid asking user for any additional information.` : ""}
|
|
369438
|
+
|
|
369439
|
+
${config3.getAgentRegistry().getDirectoryContext()}`,
|
|
369303
369440
|
primaryWorkflows_prefix: `
|
|
369304
369441
|
# Primary Workflows
|
|
369305
369442
|
|
|
@@ -369313,15 +369450,15 @@ Use '${READ_FILE_TOOL_NAME}' to understand context and validate any assumptions
|
|
|
369313
369450
|
|
|
369314
369451
|
## Software Engineering Tasks
|
|
369315
369452
|
When requested to perform tasks like fixing bugs, adding features, refactoring, or explaining code, follow this sequence:
|
|
369316
|
-
1. **Understand & Strategize:** Think about the user's request and the relevant codebase context. When the task involves **complex refactoring, codebase exploration or system-wide analysis**, your **first and primary
|
|
369317
|
-
2. **Plan:** Build a coherent and grounded (based on the understanding in step 1) plan for how you intend to resolve the user's task. If '${CodebaseInvestigatorAgent.name}' was used, do not ignore the output of
|
|
369453
|
+
1. **Understand & Strategize:** Think about the user's request and the relevant codebase context. When the task involves **complex refactoring, codebase exploration or system-wide analysis**, your **first and primary action** must be to delegate to the '${CodebaseInvestigatorAgent.name}' agent using the '${DELEGATE_TO_AGENT_TOOL_NAME}' tool. Use it to build a comprehensive understanding of the code, its structure, and dependencies. For **simple, targeted searches** (like finding a specific function name, file path, or variable declaration), you should use '${GREP_TOOL_NAME}' or '${GLOB_TOOL_NAME}' directly.
|
|
369454
|
+
2. **Plan:** Build a coherent and grounded (based on the understanding in step 1) plan for how you intend to resolve the user's task. If '${CodebaseInvestigatorAgent.name}' was used, do not ignore the output of the agent, you must use it as the foundation of your plan. Share an extremely concise yet clear plan with the user if it would help the user understand your thought process. As part of the plan, you should use an iterative development process that includes writing unit tests to verify your changes. Use output logs or debug statements as part of this process to arrive at a solution.`,
|
|
369318
369455
|
primaryWorkflows_prefix_ci_todo: `
|
|
369319
369456
|
# Primary Workflows
|
|
369320
369457
|
|
|
369321
369458
|
## Software Engineering Tasks
|
|
369322
369459
|
When requested to perform tasks like fixing bugs, adding features, refactoring, or explaining code, follow this sequence:
|
|
369323
|
-
1. **Understand & Strategize:** Think about the user's request and the relevant codebase context. When the task involves **complex refactoring, codebase exploration or system-wide analysis**, your **first and primary
|
|
369324
|
-
2. **Plan:** Build a coherent and grounded (based on the understanding in step 1) plan for how you intend to resolve the user's task. If '${CodebaseInvestigatorAgent.name}' was used, do not ignore the output of
|
|
369460
|
+
1. **Understand & Strategize:** Think about the user's request and the relevant codebase context. When the task involves **complex refactoring, codebase exploration or system-wide analysis**, your **first and primary action** must be to delegate to the '${CodebaseInvestigatorAgent.name}' agent using the '${DELEGATE_TO_AGENT_TOOL_NAME}' tool. Use it to build a comprehensive understanding of the code, its structure, and dependencies. For **simple, targeted searches** (like finding a specific function name, file path, or variable declaration), you should use '${GREP_TOOL_NAME}' or '${GLOB_TOOL_NAME}' directly.
|
|
369461
|
+
2. **Plan:** Build a coherent and grounded (based on the understanding in step 1) plan for how you intend to resolve the user's task. If '${CodebaseInvestigatorAgent.name}' was used, do not ignore the output of the agent, you must use it as the foundation of your plan. For complex tasks, break them down into smaller, manageable subtasks and use the \`${WRITE_TODOS_TOOL_NAME}\` tool to track your progress. Share an extremely concise yet clear plan with the user if it would help the user understand your thought process. As part of the plan, you should use an iterative development process that includes writing unit tests to verify your changes. Use output logs or debug statements as part of this process to arrive at a solution.`,
|
|
369325
369462
|
primaryWorkflows_todo: `
|
|
369326
369463
|
# Primary Workflows
|
|
369327
369464
|
|
|
@@ -369488,8 +369625,8 @@ Your core function is efficient and safe assistance. Balance extreme conciseness
|
|
|
369488
369625
|
const writeSystemMdResolution = resolvePathFromEnv(process20.env["GEMINI_WRITE_SYSTEM_MD"]);
|
|
369489
369626
|
if (writeSystemMdResolution.value && !writeSystemMdResolution.isDisabled) {
|
|
369490
369627
|
const writePath = writeSystemMdResolution.isSwitch ? systemMdPath : writeSystemMdResolution.value;
|
|
369491
|
-
|
|
369492
|
-
|
|
369628
|
+
fs49.mkdirSync(path49.dirname(writePath), { recursive: true });
|
|
369629
|
+
fs49.writeFileSync(writePath, basePrompt);
|
|
369493
369630
|
}
|
|
369494
369631
|
const memorySuffix = userMemory && userMemory.trim().length > 0 ? `
|
|
369495
369632
|
|
|
@@ -370682,8 +370819,8 @@ var GeminiClient = class {
|
|
|
370682
370819
|
|
|
370683
370820
|
// packages/core/dist/src/utils/gitIgnoreParser.js
|
|
370684
370821
|
var import_ignore3 = __toESM(require_ignore(), 1);
|
|
370685
|
-
import * as
|
|
370686
|
-
import * as
|
|
370822
|
+
import * as fs50 from "node:fs";
|
|
370823
|
+
import * as path50 from "node:path";
|
|
370687
370824
|
var GitIgnoreParser = class {
|
|
370688
370825
|
extraPatterns;
|
|
370689
370826
|
projectRoot;
|
|
@@ -370692,7 +370829,7 @@ var GitIgnoreParser = class {
|
|
|
370692
370829
|
processedExtraPatterns = [];
|
|
370693
370830
|
constructor(projectRoot, extraPatterns) {
|
|
370694
370831
|
this.extraPatterns = extraPatterns;
|
|
370695
|
-
this.projectRoot =
|
|
370832
|
+
this.projectRoot = path50.resolve(projectRoot);
|
|
370696
370833
|
if (this.extraPatterns) {
|
|
370697
370834
|
this.processedExtraPatterns = this.processPatterns(this.extraPatterns, ".");
|
|
370698
370835
|
}
|
|
@@ -370700,12 +370837,12 @@ var GitIgnoreParser = class {
|
|
|
370700
370837
|
loadPatternsForFile(patternsFilePath) {
|
|
370701
370838
|
let content;
|
|
370702
370839
|
try {
|
|
370703
|
-
content =
|
|
370840
|
+
content = fs50.readFileSync(patternsFilePath, "utf-8");
|
|
370704
370841
|
} catch (_error) {
|
|
370705
370842
|
return [];
|
|
370706
370843
|
}
|
|
370707
|
-
const isExcludeFile = patternsFilePath.endsWith(
|
|
370708
|
-
const relativeBaseDir = isExcludeFile ? "." :
|
|
370844
|
+
const isExcludeFile = patternsFilePath.endsWith(path50.join(".git", "info", "exclude"));
|
|
370845
|
+
const relativeBaseDir = isExcludeFile ? "." : path50.dirname(path50.relative(this.projectRoot, patternsFilePath)).split(path50.sep).join(path50.posix.sep);
|
|
370709
370846
|
const rawPatterns = content.split("\n");
|
|
370710
370847
|
return this.processPatterns(rawPatterns, relativeBaseDir);
|
|
370711
370848
|
}
|
|
@@ -370725,9 +370862,9 @@ var GitIgnoreParser = class {
|
|
|
370725
370862
|
let newPattern = p;
|
|
370726
370863
|
if (relativeBaseDir && relativeBaseDir !== ".") {
|
|
370727
370864
|
if (!isAnchoredInFile && !p.includes("/")) {
|
|
370728
|
-
newPattern =
|
|
370865
|
+
newPattern = path50.posix.join("**", p);
|
|
370729
370866
|
}
|
|
370730
|
-
newPattern =
|
|
370867
|
+
newPattern = path50.posix.join(relativeBaseDir, newPattern);
|
|
370731
370868
|
if (!newPattern.startsWith("/")) {
|
|
370732
370869
|
newPattern = "/" + newPattern;
|
|
370733
370870
|
}
|
|
@@ -370745,13 +370882,13 @@ var GitIgnoreParser = class {
|
|
|
370745
370882
|
if (!filePath || typeof filePath !== "string") {
|
|
370746
370883
|
return false;
|
|
370747
370884
|
}
|
|
370748
|
-
const absoluteFilePath =
|
|
370885
|
+
const absoluteFilePath = path50.resolve(this.projectRoot, filePath);
|
|
370749
370886
|
if (!absoluteFilePath.startsWith(this.projectRoot)) {
|
|
370750
370887
|
return false;
|
|
370751
370888
|
}
|
|
370752
370889
|
try {
|
|
370753
|
-
const resolved =
|
|
370754
|
-
const relativePath =
|
|
370890
|
+
const resolved = path50.resolve(this.projectRoot, filePath);
|
|
370891
|
+
const relativePath = path50.relative(this.projectRoot, resolved);
|
|
370755
370892
|
if (relativePath === "" || relativePath.startsWith("..")) {
|
|
370756
370893
|
return false;
|
|
370757
370894
|
}
|
|
@@ -370762,19 +370899,19 @@ var GitIgnoreParser = class {
|
|
|
370762
370899
|
const ig = (0, import_ignore3.default)();
|
|
370763
370900
|
ig.add(".git");
|
|
370764
370901
|
if (this.globalPatterns === void 0) {
|
|
370765
|
-
const excludeFile =
|
|
370766
|
-
this.globalPatterns =
|
|
370902
|
+
const excludeFile = path50.join(this.projectRoot, ".git", "info", "exclude");
|
|
370903
|
+
this.globalPatterns = fs50.existsSync(excludeFile) ? this.loadPatternsForFile(excludeFile) : [];
|
|
370767
370904
|
}
|
|
370768
370905
|
ig.add(this.globalPatterns);
|
|
370769
|
-
const pathParts = relativePath.split(
|
|
370906
|
+
const pathParts = relativePath.split(path50.sep);
|
|
370770
370907
|
const dirsToVisit = [this.projectRoot];
|
|
370771
370908
|
let currentAbsDir = this.projectRoot;
|
|
370772
370909
|
for (let i4 = 0; i4 < pathParts.length - 1; i4++) {
|
|
370773
|
-
currentAbsDir =
|
|
370910
|
+
currentAbsDir = path50.join(currentAbsDir, pathParts[i4]);
|
|
370774
370911
|
dirsToVisit.push(currentAbsDir);
|
|
370775
370912
|
}
|
|
370776
370913
|
for (const dir of dirsToVisit) {
|
|
370777
|
-
const relativeDir =
|
|
370914
|
+
const relativeDir = path50.relative(this.projectRoot, dir);
|
|
370778
370915
|
if (relativeDir) {
|
|
370779
370916
|
const normalizedRelativeDir = relativeDir.replace(/\\/g, "/");
|
|
370780
370917
|
const igPlusExtras = (0, import_ignore3.default)().add(ig).add(this.processedExtraPatterns);
|
|
@@ -370788,8 +370925,8 @@ var GitIgnoreParser = class {
|
|
|
370788
370925
|
ig.add(patterns);
|
|
370789
370926
|
}
|
|
370790
370927
|
} else {
|
|
370791
|
-
const gitignorePath =
|
|
370792
|
-
if (
|
|
370928
|
+
const gitignorePath = path50.join(dir, ".gitignore");
|
|
370929
|
+
if (fs50.existsSync(gitignorePath)) {
|
|
370793
370930
|
const patterns = this.loadPatternsForFile(gitignorePath);
|
|
370794
370931
|
this.cache.set(dir, patterns);
|
|
370795
370932
|
ig.add(patterns);
|
|
@@ -370810,21 +370947,21 @@ var GitIgnoreParser = class {
|
|
|
370810
370947
|
|
|
370811
370948
|
// packages/core/dist/src/utils/geminiIgnoreParser.js
|
|
370812
370949
|
var import_ignore4 = __toESM(require_ignore(), 1);
|
|
370813
|
-
import * as
|
|
370814
|
-
import * as
|
|
370950
|
+
import * as fs51 from "node:fs";
|
|
370951
|
+
import * as path51 from "node:path";
|
|
370815
370952
|
var GeminiIgnoreParser = class {
|
|
370816
370953
|
projectRoot;
|
|
370817
370954
|
patterns = [];
|
|
370818
370955
|
ig = (0, import_ignore4.default)();
|
|
370819
370956
|
constructor(projectRoot) {
|
|
370820
|
-
this.projectRoot =
|
|
370957
|
+
this.projectRoot = path51.resolve(projectRoot);
|
|
370821
370958
|
this.loadPatterns();
|
|
370822
370959
|
}
|
|
370823
370960
|
loadPatterns() {
|
|
370824
|
-
const patternsFilePath =
|
|
370961
|
+
const patternsFilePath = path51.join(this.projectRoot, ".geminiignore");
|
|
370825
370962
|
let content;
|
|
370826
370963
|
try {
|
|
370827
|
-
content =
|
|
370964
|
+
content = fs51.readFileSync(patternsFilePath, "utf-8");
|
|
370828
370965
|
} catch (_error) {
|
|
370829
370966
|
return;
|
|
370830
370967
|
}
|
|
@@ -370841,8 +370978,8 @@ var GeminiIgnoreParser = class {
|
|
|
370841
370978
|
if (filePath.startsWith("\\") || filePath === "/" || filePath.includes("\0")) {
|
|
370842
370979
|
return false;
|
|
370843
370980
|
}
|
|
370844
|
-
const resolved =
|
|
370845
|
-
const relativePath =
|
|
370981
|
+
const resolved = path51.resolve(this.projectRoot, filePath);
|
|
370982
|
+
const relativePath = path51.relative(this.projectRoot, resolved);
|
|
370846
370983
|
if (relativePath === "" || relativePath.startsWith("..")) {
|
|
370847
370984
|
return false;
|
|
370848
370985
|
}
|
|
@@ -370858,14 +370995,14 @@ var GeminiIgnoreParser = class {
|
|
|
370858
370995
|
};
|
|
370859
370996
|
|
|
370860
370997
|
// packages/core/dist/src/services/fileDiscoveryService.js
|
|
370861
|
-
import * as
|
|
370998
|
+
import * as path52 from "node:path";
|
|
370862
370999
|
var FileDiscoveryService = class {
|
|
370863
371000
|
gitIgnoreFilter = null;
|
|
370864
371001
|
geminiIgnoreFilter = null;
|
|
370865
371002
|
combinedIgnoreFilter = null;
|
|
370866
371003
|
projectRoot;
|
|
370867
371004
|
constructor(projectRoot) {
|
|
370868
|
-
this.projectRoot =
|
|
371005
|
+
this.projectRoot = path52.resolve(projectRoot);
|
|
370869
371006
|
if (isGitRepository(this.projectRoot)) {
|
|
370870
371007
|
this.gitIgnoreFilter = new GitIgnoreParser(this.projectRoot);
|
|
370871
371008
|
}
|
|
@@ -370917,8 +371054,8 @@ var FileDiscoveryService = class {
|
|
|
370917
371054
|
};
|
|
370918
371055
|
|
|
370919
371056
|
// packages/core/dist/src/services/gitService.js
|
|
370920
|
-
import * as
|
|
370921
|
-
import * as
|
|
371057
|
+
import * as fs52 from "node:fs/promises";
|
|
371058
|
+
import * as path53 from "node:path";
|
|
370922
371059
|
|
|
370923
371060
|
// node_modules/simple-git/dist/esm/index.js
|
|
370924
371061
|
var import_file_exists = __toESM(require_dist8(), 1);
|
|
@@ -375446,7 +375583,7 @@ var GitService = class {
|
|
|
375446
375583
|
projectRoot;
|
|
375447
375584
|
storage;
|
|
375448
375585
|
constructor(projectRoot, storage2) {
|
|
375449
|
-
this.projectRoot =
|
|
375586
|
+
this.projectRoot = path53.resolve(projectRoot);
|
|
375450
375587
|
this.storage = storage2;
|
|
375451
375588
|
}
|
|
375452
375589
|
getHistoryDir() {
|
|
@@ -375477,10 +375614,10 @@ var GitService = class {
|
|
|
375477
375614
|
*/
|
|
375478
375615
|
async setupShadowGitRepository() {
|
|
375479
375616
|
const repoDir = this.getHistoryDir();
|
|
375480
|
-
const gitConfigPath =
|
|
375481
|
-
await
|
|
375617
|
+
const gitConfigPath = path53.join(repoDir, ".gitconfig");
|
|
375618
|
+
await fs52.mkdir(repoDir, { recursive: true });
|
|
375482
375619
|
const gitConfigContent = "[user]\n name = Gemini CLI\n email = gemini-cli@google.com\n[commit]\n gpgsign = false\n";
|
|
375483
|
-
await
|
|
375620
|
+
await fs52.writeFile(gitConfigPath, gitConfigContent);
|
|
375484
375621
|
const repo = simpleGit(repoDir);
|
|
375485
375622
|
const isRepoDefined = await repo.checkIsRepo(CheckRepoActions.IS_REPO_ROOT);
|
|
375486
375623
|
if (!isRepoDefined) {
|
|
@@ -375489,22 +375626,22 @@ var GitService = class {
|
|
|
375489
375626
|
});
|
|
375490
375627
|
await repo.commit("Initial commit", { "--allow-empty": null });
|
|
375491
375628
|
}
|
|
375492
|
-
const userGitIgnorePath =
|
|
375493
|
-
const shadowGitIgnorePath =
|
|
375629
|
+
const userGitIgnorePath = path53.join(this.projectRoot, ".gitignore");
|
|
375630
|
+
const shadowGitIgnorePath = path53.join(repoDir, ".gitignore");
|
|
375494
375631
|
let userGitIgnoreContent = "";
|
|
375495
375632
|
try {
|
|
375496
|
-
userGitIgnoreContent = await
|
|
375633
|
+
userGitIgnoreContent = await fs52.readFile(userGitIgnorePath, "utf-8");
|
|
375497
375634
|
} catch (error2) {
|
|
375498
375635
|
if (isNodeError(error2) && error2.code !== "ENOENT") {
|
|
375499
375636
|
throw error2;
|
|
375500
375637
|
}
|
|
375501
375638
|
}
|
|
375502
|
-
await
|
|
375639
|
+
await fs52.writeFile(shadowGitIgnorePath, userGitIgnoreContent);
|
|
375503
375640
|
}
|
|
375504
375641
|
get shadowGitRepository() {
|
|
375505
375642
|
const repoDir = this.getHistoryDir();
|
|
375506
375643
|
return simpleGit(this.projectRoot).env({
|
|
375507
|
-
GIT_DIR:
|
|
375644
|
+
GIT_DIR: path53.join(repoDir, ".git"),
|
|
375508
375645
|
GIT_WORK_TREE: this.projectRoot,
|
|
375509
375646
|
// Prevent git from using the user's global git config.
|
|
375510
375647
|
HOME: repoDir,
|
|
@@ -375566,23 +375703,13 @@ function shouldAttemptBrowserLaunch() {
|
|
|
375566
375703
|
}
|
|
375567
375704
|
|
|
375568
375705
|
// packages/core/dist/src/services/fileSystemService.js
|
|
375569
|
-
import
|
|
375570
|
-
import * as path53 from "node:path";
|
|
375706
|
+
import fs53 from "node:fs/promises";
|
|
375571
375707
|
var StandardFileSystemService = class {
|
|
375572
375708
|
async readTextFile(filePath) {
|
|
375573
|
-
return
|
|
375709
|
+
return fs53.readFile(filePath, "utf-8");
|
|
375574
375710
|
}
|
|
375575
375711
|
async writeTextFile(filePath, content) {
|
|
375576
|
-
await
|
|
375577
|
-
}
|
|
375578
|
-
findFiles(fileName, searchPaths) {
|
|
375579
|
-
return searchPaths.flatMap((searchPath) => {
|
|
375580
|
-
const pattern = path53.posix.join(searchPath, "**", fileName);
|
|
375581
|
-
return globSync(pattern, {
|
|
375582
|
-
nodir: true,
|
|
375583
|
-
absolute: true
|
|
375584
|
-
});
|
|
375585
|
-
});
|
|
375712
|
+
await fs53.writeFile(filePath, content, "utf-8");
|
|
375586
375713
|
}
|
|
375587
375714
|
};
|
|
375588
375715
|
|
|
@@ -375653,6 +375780,9 @@ var ModelAvailabilityService = class {
|
|
|
375653
375780
|
}
|
|
375654
375781
|
}
|
|
375655
375782
|
}
|
|
375783
|
+
reset() {
|
|
375784
|
+
this.health.clear();
|
|
375785
|
+
}
|
|
375656
375786
|
setState(model, nextState) {
|
|
375657
375787
|
this.health.set(model, nextState);
|
|
375658
375788
|
}
|
|
@@ -376026,12 +376156,13 @@ var ModelConfigService = class {
|
|
|
376026
376156
|
}
|
|
376027
376157
|
internalGetResolvedConfig(context2) {
|
|
376028
376158
|
const config3 = this.config || {};
|
|
376029
|
-
const { aliases: aliases2 = {}, customAliases = {}, overrides = [] } = config3;
|
|
376159
|
+
const { aliases: aliases2 = {}, customAliases = {}, overrides = [], customOverrides = [] } = config3;
|
|
376030
376160
|
const allAliases = {
|
|
376031
376161
|
...aliases2,
|
|
376032
376162
|
...customAliases,
|
|
376033
376163
|
...this.runtimeAliases
|
|
376034
376164
|
};
|
|
376165
|
+
const allOverrides = [...overrides, ...customOverrides];
|
|
376035
376166
|
let baseModel = context2.model;
|
|
376036
376167
|
let resolvedConfig = {};
|
|
376037
376168
|
if (allAliases[context2.model]) {
|
|
@@ -376044,7 +376175,7 @@ var ModelConfigService = class {
|
|
|
376044
376175
|
...context2,
|
|
376045
376176
|
model: modelForMatching
|
|
376046
376177
|
};
|
|
376047
|
-
const matches =
|
|
376178
|
+
const matches = allOverrides.map((override, index) => {
|
|
376048
376179
|
const matchEntries = Object.entries(override.match);
|
|
376049
376180
|
if (matchEntries.length === 0) {
|
|
376050
376181
|
return null;
|
|
@@ -376319,93 +376450,28 @@ var DEFAULT_MODEL_CONFIGS = {
|
|
|
376319
376450
|
model: "gemini-2.5-pro"
|
|
376320
376451
|
}
|
|
376321
376452
|
}
|
|
376322
|
-
}
|
|
376453
|
+
},
|
|
376454
|
+
overrides: [
|
|
376455
|
+
{
|
|
376456
|
+
match: { model: "chat-base", isRetry: true },
|
|
376457
|
+
modelConfig: {
|
|
376458
|
+
generateContentConfig: {
|
|
376459
|
+
temperature: 1
|
|
376460
|
+
}
|
|
376461
|
+
}
|
|
376462
|
+
}
|
|
376463
|
+
]
|
|
376323
376464
|
};
|
|
376324
376465
|
|
|
376325
376466
|
// packages/core/dist/src/utils/memoryDiscovery.js
|
|
376326
376467
|
import * as fs55 from "node:fs/promises";
|
|
376327
|
-
import * as
|
|
376328
|
-
import * as
|
|
376468
|
+
import * as fsSync2 from "node:fs";
|
|
376469
|
+
import * as path55 from "node:path";
|
|
376329
376470
|
import { homedir as homedir4 } from "node:os";
|
|
376330
376471
|
|
|
376331
|
-
// packages/core/dist/src/utils/bfsFileSearch.js
|
|
376332
|
-
import * as fs53 from "node:fs/promises";
|
|
376333
|
-
import * as path54 from "node:path";
|
|
376334
|
-
var logger3 = {
|
|
376335
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
376336
|
-
debug: (...args2) => debugLogger.debug("[DEBUG] [BfsFileSearch]", ...args2)
|
|
376337
|
-
};
|
|
376338
|
-
async function bfsFileSearch(rootDir, options2) {
|
|
376339
|
-
const { fileName, ignoreDirs = [], maxDirs = Infinity, debug: debug2 = false, fileService } = options2;
|
|
376340
|
-
const foundFiles = [];
|
|
376341
|
-
const queue = [rootDir];
|
|
376342
|
-
const visited = /* @__PURE__ */ new Set();
|
|
376343
|
-
let scannedDirCount = 0;
|
|
376344
|
-
let queueHead = 0;
|
|
376345
|
-
const ignoreDirsSet = new Set(ignoreDirs);
|
|
376346
|
-
const PARALLEL_BATCH_SIZE = 15;
|
|
376347
|
-
while (queueHead < queue.length && scannedDirCount < maxDirs) {
|
|
376348
|
-
const batchSize = Math.min(PARALLEL_BATCH_SIZE, maxDirs - scannedDirCount);
|
|
376349
|
-
const currentBatch = [];
|
|
376350
|
-
while (currentBatch.length < batchSize && queueHead < queue.length) {
|
|
376351
|
-
const currentDir = queue[queueHead];
|
|
376352
|
-
queueHead++;
|
|
376353
|
-
if (!visited.has(currentDir)) {
|
|
376354
|
-
visited.add(currentDir);
|
|
376355
|
-
currentBatch.push(currentDir);
|
|
376356
|
-
}
|
|
376357
|
-
}
|
|
376358
|
-
scannedDirCount += currentBatch.length;
|
|
376359
|
-
if (currentBatch.length === 0)
|
|
376360
|
-
continue;
|
|
376361
|
-
if (debug2) {
|
|
376362
|
-
logger3.debug(`Scanning [${scannedDirCount}/${maxDirs}]: batch of ${currentBatch.length}`);
|
|
376363
|
-
}
|
|
376364
|
-
const readPromises = currentBatch.map(async (currentDir) => {
|
|
376365
|
-
try {
|
|
376366
|
-
const entries2 = await fs53.readdir(currentDir, { withFileTypes: true });
|
|
376367
|
-
return { currentDir, entries: entries2 };
|
|
376368
|
-
} catch (error2) {
|
|
376369
|
-
const message = error2?.message ?? "Unknown error";
|
|
376370
|
-
debugLogger.warn(`[WARN] Skipping unreadable directory: ${currentDir} (${message})`);
|
|
376371
|
-
if (debug2) {
|
|
376372
|
-
logger3.debug(`Full error for ${currentDir}:`, error2);
|
|
376373
|
-
}
|
|
376374
|
-
return { currentDir, entries: [] };
|
|
376375
|
-
}
|
|
376376
|
-
});
|
|
376377
|
-
const results = await Promise.all(readPromises);
|
|
376378
|
-
for (const { currentDir, entries: entries2 } of results) {
|
|
376379
|
-
for (const entry of entries2) {
|
|
376380
|
-
const fullPath = path54.join(currentDir, entry.name);
|
|
376381
|
-
const isDirectory = entry.isDirectory();
|
|
376382
|
-
const isMatchingFile = entry.isFile() && entry.name === fileName;
|
|
376383
|
-
if (!isDirectory && !isMatchingFile) {
|
|
376384
|
-
continue;
|
|
376385
|
-
}
|
|
376386
|
-
if (isDirectory && ignoreDirsSet.has(entry.name)) {
|
|
376387
|
-
continue;
|
|
376388
|
-
}
|
|
376389
|
-
if (fileService?.shouldIgnoreFile(fullPath, {
|
|
376390
|
-
respectGitIgnore: options2.fileFilteringOptions?.respectGitIgnore,
|
|
376391
|
-
respectGeminiIgnore: options2.fileFilteringOptions?.respectGeminiIgnore
|
|
376392
|
-
})) {
|
|
376393
|
-
continue;
|
|
376394
|
-
}
|
|
376395
|
-
if (isDirectory) {
|
|
376396
|
-
queue.push(fullPath);
|
|
376397
|
-
} else {
|
|
376398
|
-
foundFiles.push(fullPath);
|
|
376399
|
-
}
|
|
376400
|
-
}
|
|
376401
|
-
}
|
|
376402
|
-
}
|
|
376403
|
-
return foundFiles;
|
|
376404
|
-
}
|
|
376405
|
-
|
|
376406
376472
|
// packages/core/dist/src/utils/memoryImportProcessor.js
|
|
376407
376473
|
import * as fs54 from "node:fs/promises";
|
|
376408
|
-
import * as
|
|
376474
|
+
import * as path54 from "node:path";
|
|
376409
376475
|
|
|
376410
376476
|
// node_modules/marked/lib/marked.esm.js
|
|
376411
376477
|
function _getDefaults() {
|
|
@@ -378553,9 +378619,9 @@ var logger4 = {
|
|
|
378553
378619
|
error: (...args2) => debugLogger.error("[ERROR] [ImportProcessor]", ...args2)
|
|
378554
378620
|
};
|
|
378555
378621
|
async function findProjectRoot(startDir) {
|
|
378556
|
-
let currentDir =
|
|
378622
|
+
let currentDir = path54.resolve(startDir);
|
|
378557
378623
|
while (true) {
|
|
378558
|
-
const gitPath =
|
|
378624
|
+
const gitPath = path54.join(currentDir, ".git");
|
|
378559
378625
|
try {
|
|
378560
378626
|
const stats = await fs54.lstat(gitPath);
|
|
378561
378627
|
if (stats.isDirectory()) {
|
|
@@ -378563,13 +378629,13 @@ async function findProjectRoot(startDir) {
|
|
|
378563
378629
|
}
|
|
378564
378630
|
} catch {
|
|
378565
378631
|
}
|
|
378566
|
-
const parentDir =
|
|
378632
|
+
const parentDir = path54.dirname(currentDir);
|
|
378567
378633
|
if (parentDir === currentDir) {
|
|
378568
378634
|
break;
|
|
378569
378635
|
}
|
|
378570
378636
|
currentDir = parentDir;
|
|
378571
378637
|
}
|
|
378572
|
-
return
|
|
378638
|
+
return path54.resolve(startDir);
|
|
378573
378639
|
}
|
|
378574
378640
|
function hasMessage(err2) {
|
|
378575
378641
|
return typeof err2 === "object" && err2 !== null && "message" in err2 && typeof err2.message === "string";
|
|
@@ -378658,7 +378724,7 @@ async function processImports(content, basePath, debugMode = false, importState
|
|
|
378658
378724
|
const flatFiles = [];
|
|
378659
378725
|
const processedFiles = /* @__PURE__ */ new Set();
|
|
378660
378726
|
async function processFlat(fileContent, fileBasePath, filePath, depth) {
|
|
378661
|
-
const normalizedPath =
|
|
378727
|
+
const normalizedPath = path54.normalize(filePath);
|
|
378662
378728
|
if (processedFiles.has(normalizedPath))
|
|
378663
378729
|
return;
|
|
378664
378730
|
processedFiles.add(normalizedPath);
|
|
@@ -378673,14 +378739,14 @@ async function processImports(content, basePath, debugMode = false, importState
|
|
|
378673
378739
|
if (!validateImportPath(importPath, fileBasePath, [projectRoot || ""])) {
|
|
378674
378740
|
continue;
|
|
378675
378741
|
}
|
|
378676
|
-
const fullPath =
|
|
378677
|
-
const normalizedFullPath =
|
|
378742
|
+
const fullPath = path54.resolve(fileBasePath, importPath);
|
|
378743
|
+
const normalizedFullPath = path54.normalize(fullPath);
|
|
378678
378744
|
if (processedFiles.has(normalizedFullPath))
|
|
378679
378745
|
continue;
|
|
378680
378746
|
try {
|
|
378681
378747
|
await fs54.access(fullPath);
|
|
378682
378748
|
const importedContent = await fs54.readFile(fullPath, "utf-8");
|
|
378683
|
-
await processFlat(importedContent,
|
|
378749
|
+
await processFlat(importedContent, path54.dirname(fullPath), normalizedFullPath, depth + 1);
|
|
378684
378750
|
} catch (error2) {
|
|
378685
378751
|
if (debugMode) {
|
|
378686
378752
|
logger4.warn(`Failed to import ${fullPath}: ${hasMessage(error2) ? error2.message : "Unknown error"}`);
|
|
@@ -378688,7 +378754,7 @@ async function processImports(content, basePath, debugMode = false, importState
|
|
|
378688
378754
|
}
|
|
378689
378755
|
}
|
|
378690
378756
|
}
|
|
378691
|
-
const rootPath =
|
|
378757
|
+
const rootPath = path54.normalize(importState.currentFile || path54.resolve(basePath));
|
|
378692
378758
|
await processFlat(content, basePath, rootPath, 0);
|
|
378693
378759
|
const flatContent = flatFiles.map((f3) => `--- File: ${f3.path} ---
|
|
378694
378760
|
${f3.content.trim()}
|
|
@@ -378715,7 +378781,7 @@ ${f3.content.trim()}
|
|
|
378715
378781
|
result += `<!-- Import failed: ${importPath} - Path traversal attempt -->`;
|
|
378716
378782
|
continue;
|
|
378717
378783
|
}
|
|
378718
|
-
const fullPath =
|
|
378784
|
+
const fullPath = path54.resolve(basePath, importPath);
|
|
378719
378785
|
if (importState.processedFiles.has(fullPath)) {
|
|
378720
378786
|
result += `<!-- File already processed: ${importPath} -->`;
|
|
378721
378787
|
continue;
|
|
@@ -378730,7 +378796,7 @@ ${f3.content.trim()}
|
|
|
378730
378796
|
currentFile: fullPath
|
|
378731
378797
|
};
|
|
378732
378798
|
newImportState.processedFiles.add(fullPath);
|
|
378733
|
-
const imported = await processImports(fileContent,
|
|
378799
|
+
const imported = await processImports(fileContent, path54.dirname(fullPath), debugMode, newImportState, projectRoot, importFormat);
|
|
378734
378800
|
result += `<!-- Imported from: ${importPath} -->
|
|
378735
378801
|
${imported.content}
|
|
378736
378802
|
<!-- End of import from: ${importPath} -->`;
|
|
@@ -378759,7 +378825,7 @@ function validateImportPath(importPath, basePath, allowedDirectories) {
|
|
|
378759
378825
|
if (/^(file|https?):\/\//.test(importPath)) {
|
|
378760
378826
|
return false;
|
|
378761
378827
|
}
|
|
378762
|
-
const resolvedPath =
|
|
378828
|
+
const resolvedPath = path54.resolve(basePath, importPath);
|
|
378763
378829
|
return allowedDirectories.some((allowedDir) => isSubpath(allowedDir, resolvedPath));
|
|
378764
378830
|
}
|
|
378765
378831
|
|
|
@@ -378774,9 +378840,9 @@ var logger5 = {
|
|
|
378774
378840
|
error: (...args2) => console.error("[ERROR] [MemoryDiscovery]", ...args2)
|
|
378775
378841
|
};
|
|
378776
378842
|
async function findProjectRoot2(startDir) {
|
|
378777
|
-
let currentDir =
|
|
378843
|
+
let currentDir = path55.resolve(startDir);
|
|
378778
378844
|
while (true) {
|
|
378779
|
-
const gitPath =
|
|
378845
|
+
const gitPath = path55.join(currentDir, ".git");
|
|
378780
378846
|
try {
|
|
378781
378847
|
const stats = await fs55.lstat(gitPath);
|
|
378782
378848
|
if (stats.isDirectory()) {
|
|
@@ -378794,7 +378860,7 @@ async function findProjectRoot2(startDir) {
|
|
|
378794
378860
|
}
|
|
378795
378861
|
}
|
|
378796
378862
|
}
|
|
378797
|
-
const parentDir =
|
|
378863
|
+
const parentDir = path55.dirname(currentDir);
|
|
378798
378864
|
if (parentDir === currentDir) {
|
|
378799
378865
|
return null;
|
|
378800
378866
|
}
|
|
@@ -378830,17 +378896,17 @@ async function getGeminiMdFilePathsInternalForEachDir(dir, userHomePath, debugMo
|
|
|
378830
378896
|
const allPaths = /* @__PURE__ */ new Set();
|
|
378831
378897
|
const geminiMdFilenames = getAllGeminiMdFilenames();
|
|
378832
378898
|
for (const geminiMdFilename of geminiMdFilenames) {
|
|
378833
|
-
const resolvedHome =
|
|
378834
|
-
const globalMemoryPath =
|
|
378899
|
+
const resolvedHome = path55.resolve(userHomePath);
|
|
378900
|
+
const globalMemoryPath = path55.join(resolvedHome, GEMINI_DIR, geminiMdFilename);
|
|
378835
378901
|
try {
|
|
378836
|
-
await fs55.access(globalMemoryPath,
|
|
378902
|
+
await fs55.access(globalMemoryPath, fsSync2.constants.R_OK);
|
|
378837
378903
|
allPaths.add(globalMemoryPath);
|
|
378838
378904
|
if (debugMode)
|
|
378839
378905
|
logger5.debug(`Found readable global ${geminiMdFilename}: ${globalMemoryPath}`);
|
|
378840
378906
|
} catch {
|
|
378841
378907
|
}
|
|
378842
378908
|
if (dir && folderTrust) {
|
|
378843
|
-
const resolvedCwd =
|
|
378909
|
+
const resolvedCwd = path55.resolve(dir);
|
|
378844
378910
|
if (debugMode)
|
|
378845
378911
|
logger5.debug(`Searching for ${geminiMdFilename} starting from CWD: ${resolvedCwd}`);
|
|
378846
378912
|
const projectRoot = await findProjectRoot2(resolvedCwd);
|
|
@@ -378848,14 +378914,14 @@ async function getGeminiMdFilePathsInternalForEachDir(dir, userHomePath, debugMo
|
|
|
378848
378914
|
logger5.debug(`Determined project root: ${projectRoot ?? "None"}`);
|
|
378849
378915
|
const upwardPaths = [];
|
|
378850
378916
|
let currentDir = resolvedCwd;
|
|
378851
|
-
const ultimateStopDir = projectRoot ?
|
|
378852
|
-
while (currentDir && currentDir !==
|
|
378853
|
-
if (currentDir ===
|
|
378917
|
+
const ultimateStopDir = projectRoot ? path55.dirname(projectRoot) : path55.dirname(resolvedHome);
|
|
378918
|
+
while (currentDir && currentDir !== path55.dirname(currentDir)) {
|
|
378919
|
+
if (currentDir === path55.join(resolvedHome, GEMINI_DIR)) {
|
|
378854
378920
|
break;
|
|
378855
378921
|
}
|
|
378856
|
-
const potentialPath =
|
|
378922
|
+
const potentialPath = path55.join(currentDir, geminiMdFilename);
|
|
378857
378923
|
try {
|
|
378858
|
-
await fs55.access(potentialPath,
|
|
378924
|
+
await fs55.access(potentialPath, fsSync2.constants.R_OK);
|
|
378859
378925
|
if (potentialPath !== globalMemoryPath) {
|
|
378860
378926
|
upwardPaths.unshift(potentialPath);
|
|
378861
378927
|
}
|
|
@@ -378864,7 +378930,7 @@ async function getGeminiMdFilePathsInternalForEachDir(dir, userHomePath, debugMo
|
|
|
378864
378930
|
if (currentDir === ultimateStopDir) {
|
|
378865
378931
|
break;
|
|
378866
378932
|
}
|
|
378867
|
-
currentDir =
|
|
378933
|
+
currentDir = path55.dirname(currentDir);
|
|
378868
378934
|
}
|
|
378869
378935
|
upwardPaths.forEach((p) => allPaths.add(p));
|
|
378870
378936
|
const mergedOptions = {
|
|
@@ -378897,7 +378963,7 @@ async function readGeminiMdFiles(filePaths, debugMode, importFormat = "tree") {
|
|
|
378897
378963
|
const batchPromises = batch.map(async (filePath) => {
|
|
378898
378964
|
try {
|
|
378899
378965
|
const content = await fs55.readFile(filePath, "utf-8");
|
|
378900
|
-
const processedResult = await processImports(content,
|
|
378966
|
+
const processedResult = await processImports(content, path55.dirname(filePath), debugMode, void 0, void 0, importFormat);
|
|
378901
378967
|
if (debugMode)
|
|
378902
378968
|
logger5.debug(`Successfully read and processed imports: ${filePath} (Length: ${processedResult.content.length})`);
|
|
378903
378969
|
return { filePath, content: processedResult.content };
|
|
@@ -378931,7 +378997,7 @@ function concatenateInstructions(instructionContents, currentWorkingDirectoryFor
|
|
|
378931
378997
|
if (trimmedContent.length === 0) {
|
|
378932
378998
|
return null;
|
|
378933
378999
|
}
|
|
378934
|
-
const displayPath =
|
|
379000
|
+
const displayPath = path55.isAbsolute(item.filePath) ? path55.relative(currentWorkingDirectoryForDisplay, item.filePath) : item.filePath;
|
|
378935
379001
|
return `--- Context from: ${displayPath} ---
|
|
378936
379002
|
${trimmedContent}
|
|
378937
379003
|
--- End of Context from: ${displayPath} ---`;
|
|
@@ -378941,9 +379007,9 @@ async function loadGlobalMemory(debugMode = false) {
|
|
|
378941
379007
|
const userHome = homedir4();
|
|
378942
379008
|
const geminiMdFilenames = getAllGeminiMdFilenames();
|
|
378943
379009
|
const accessChecks = geminiMdFilenames.map(async (filename) => {
|
|
378944
|
-
const globalPath =
|
|
379010
|
+
const globalPath = path55.join(userHome, GEMINI_DIR, filename);
|
|
378945
379011
|
try {
|
|
378946
|
-
await fs55.access(globalPath,
|
|
379012
|
+
await fs55.access(globalPath, fsSync2.constants.R_OK);
|
|
378947
379013
|
if (debugMode) {
|
|
378948
379014
|
logger5.debug(`Found global memory file: ${globalPath}`);
|
|
378949
379015
|
}
|
|
@@ -378964,10 +379030,10 @@ async function loadGlobalMemory(debugMode = false) {
|
|
|
378964
379030
|
}
|
|
378965
379031
|
async function findUpwardGeminiFiles(startDir, stopDir, debugMode) {
|
|
378966
379032
|
const upwardPaths = [];
|
|
378967
|
-
let currentDir =
|
|
378968
|
-
const resolvedStopDir =
|
|
379033
|
+
let currentDir = path55.resolve(startDir);
|
|
379034
|
+
const resolvedStopDir = path55.resolve(stopDir);
|
|
378969
379035
|
const geminiMdFilenames = getAllGeminiMdFilenames();
|
|
378970
|
-
const globalGeminiDir =
|
|
379036
|
+
const globalGeminiDir = path55.join(homedir4(), GEMINI_DIR);
|
|
378971
379037
|
if (debugMode) {
|
|
378972
379038
|
logger5.debug(`Starting upward search from ${currentDir} stopping at ${resolvedStopDir}`);
|
|
378973
379039
|
}
|
|
@@ -378976,9 +379042,9 @@ async function findUpwardGeminiFiles(startDir, stopDir, debugMode) {
|
|
|
378976
379042
|
break;
|
|
378977
379043
|
}
|
|
378978
379044
|
const accessChecks = geminiMdFilenames.map(async (filename) => {
|
|
378979
|
-
const potentialPath =
|
|
379045
|
+
const potentialPath = path55.join(currentDir, filename);
|
|
378980
379046
|
try {
|
|
378981
|
-
await fs55.access(potentialPath,
|
|
379047
|
+
await fs55.access(potentialPath, fsSync2.constants.R_OK);
|
|
378982
379048
|
return potentialPath;
|
|
378983
379049
|
} catch {
|
|
378984
379050
|
return null;
|
|
@@ -378986,17 +379052,17 @@ async function findUpwardGeminiFiles(startDir, stopDir, debugMode) {
|
|
|
378986
379052
|
});
|
|
378987
379053
|
const foundPathsInDir = (await Promise.all(accessChecks)).filter((p) => p !== null);
|
|
378988
379054
|
upwardPaths.unshift(...foundPathsInDir);
|
|
378989
|
-
if (currentDir === resolvedStopDir || currentDir ===
|
|
379055
|
+
if (currentDir === resolvedStopDir || currentDir === path55.dirname(currentDir)) {
|
|
378990
379056
|
break;
|
|
378991
379057
|
}
|
|
378992
|
-
currentDir =
|
|
379058
|
+
currentDir = path55.dirname(currentDir);
|
|
378993
379059
|
}
|
|
378994
379060
|
return upwardPaths;
|
|
378995
379061
|
}
|
|
378996
379062
|
async function loadEnvironmentMemory(trustedRoots, extensionLoader, debugMode = false) {
|
|
378997
379063
|
const allPaths = /* @__PURE__ */ new Set();
|
|
378998
379064
|
const traversalPromises = trustedRoots.map(async (root) => {
|
|
378999
|
-
const resolvedRoot =
|
|
379065
|
+
const resolvedRoot = path55.resolve(root);
|
|
379000
379066
|
if (debugMode) {
|
|
379001
379067
|
logger5.debug(`Loading environment memory for trusted root: ${resolvedRoot} (Stopping exactly here)`);
|
|
379002
379068
|
}
|
|
@@ -379016,8 +379082,8 @@ async function loadEnvironmentMemory(trustedRoots, extensionLoader, debugMode =
|
|
|
379016
379082
|
};
|
|
379017
379083
|
}
|
|
379018
379084
|
async function loadServerHierarchicalMemory(currentWorkingDirectory, includeDirectoriesToReadGemini, debugMode, fileService, extensionLoader, folderTrust, importFormat = "tree", fileFilteringOptions, maxDirs = 200) {
|
|
379019
|
-
const realCwd = await fs55.realpath(
|
|
379020
|
-
const realHome = await fs55.realpath(
|
|
379085
|
+
const realCwd = await fs55.realpath(path55.resolve(currentWorkingDirectory));
|
|
379086
|
+
const realHome = await fs55.realpath(path55.resolve(homedir4()));
|
|
379021
379087
|
const isHomeDirectory = realCwd === realHome;
|
|
379022
379088
|
currentWorkingDirectory = isHomeDirectory ? "" : currentWorkingDirectory;
|
|
379023
379089
|
if (debugMode)
|
|
@@ -379053,10 +379119,10 @@ async function refreshServerHierarchicalMemory(config3) {
|
|
|
379053
379119
|
return result;
|
|
379054
379120
|
}
|
|
379055
379121
|
async function loadJitSubdirectoryMemory(targetPath, trustedRoots, alreadyLoadedPaths, debugMode = false) {
|
|
379056
|
-
const resolvedTarget =
|
|
379122
|
+
const resolvedTarget = path55.resolve(targetPath);
|
|
379057
379123
|
let bestRoot = null;
|
|
379058
379124
|
for (const root of trustedRoots) {
|
|
379059
|
-
const resolvedRoot =
|
|
379125
|
+
const resolvedRoot = path55.resolve(root);
|
|
379060
379126
|
if (resolvedTarget.startsWith(resolvedRoot) && (!bestRoot || resolvedRoot.length > bestRoot.length)) {
|
|
379061
379127
|
bestRoot = resolvedRoot;
|
|
379062
379128
|
}
|
|
@@ -379152,7 +379218,7 @@ var ContextManager = class {
|
|
|
379152
379218
|
|
|
379153
379219
|
// packages/core/dist/src/utils/workspaceContext.js
|
|
379154
379220
|
import * as fs56 from "node:fs";
|
|
379155
|
-
import * as
|
|
379221
|
+
import * as path56 from "node:path";
|
|
379156
379222
|
var WorkspaceContext = class {
|
|
379157
379223
|
targetDir;
|
|
379158
379224
|
directories = /* @__PURE__ */ new Set();
|
|
@@ -379209,7 +379275,7 @@ var WorkspaceContext = class {
|
|
|
379209
379275
|
}
|
|
379210
379276
|
}
|
|
379211
379277
|
resolveAndValidateDir(directory) {
|
|
379212
|
-
const absolutePath =
|
|
379278
|
+
const absolutePath = path56.resolve(this.targetDir, directory);
|
|
379213
379279
|
if (!fs56.existsSync(absolutePath)) {
|
|
379214
379280
|
throw new Error(`Directory does not exist: ${absolutePath}`);
|
|
379215
379281
|
}
|
|
@@ -379264,7 +379330,7 @@ var WorkspaceContext = class {
|
|
|
379264
379330
|
*/
|
|
379265
379331
|
fullyResolvedPath(pathToCheck) {
|
|
379266
379332
|
try {
|
|
379267
|
-
return fs56.realpathSync(
|
|
379333
|
+
return fs56.realpathSync(path56.resolve(this.targetDir, pathToCheck));
|
|
379268
379334
|
} catch (e3) {
|
|
379269
379335
|
if (isNodeError(e3) && e3.code === "ENOENT" && e3.path && // realpathSync does not set e.path correctly for symlinks to
|
|
379270
379336
|
// non-existent files.
|
|
@@ -379281,8 +379347,8 @@ var WorkspaceContext = class {
|
|
|
379281
379347
|
* @returns True if the path is within the root directory, false otherwise
|
|
379282
379348
|
*/
|
|
379283
379349
|
isPathWithinRoot(pathToCheck, rootDirectory) {
|
|
379284
|
-
const relative5 =
|
|
379285
|
-
return !relative5.startsWith(`..${
|
|
379350
|
+
const relative5 = path56.relative(rootDirectory, pathToCheck);
|
|
379351
|
+
return !relative5.startsWith(`..${path56.sep}`) && relative5 !== ".." && !path56.isAbsolute(relative5);
|
|
379286
379352
|
}
|
|
379287
379353
|
/**
|
|
379288
379354
|
* Checks if a file path is a symbolic link that points to a file.
|
|
@@ -380709,10 +380775,10 @@ var HookEventHandler = class {
|
|
|
380709
380775
|
* Create base hook input with common fields
|
|
380710
380776
|
*/
|
|
380711
380777
|
createBaseInput(eventName) {
|
|
380778
|
+
const transcriptPath = this.config.getGeminiClient()?.getChatRecordingService()?.getConversationFilePath() ?? "";
|
|
380712
380779
|
return {
|
|
380713
380780
|
session_id: this.config.getSessionId(),
|
|
380714
|
-
transcript_path:
|
|
380715
|
-
// TODO: Implement transcript path when supported
|
|
380781
|
+
transcript_path: transcriptPath,
|
|
380716
380782
|
cwd: this.config.getWorkingDir(),
|
|
380717
380783
|
hook_event_name: eventName,
|
|
380718
380784
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -381025,47 +381091,44 @@ var AgentRegistry = class {
|
|
|
381025
381091
|
getAllDefinitions() {
|
|
381026
381092
|
return Array.from(this.agents.values());
|
|
381027
381093
|
}
|
|
381028
|
-
|
|
381094
|
+
/**
|
|
381095
|
+
* Returns a list of all registered agent names.
|
|
381096
|
+
*/
|
|
381097
|
+
getAllAgentNames() {
|
|
381098
|
+
return Array.from(this.agents.keys());
|
|
381099
|
+
}
|
|
381100
|
+
/**
|
|
381101
|
+
* Generates a description for the delegate_to_agent tool.
|
|
381102
|
+
* Unlike getDirectoryContext() which is for system prompts,
|
|
381103
|
+
* this is formatted for tool descriptions.
|
|
381104
|
+
*/
|
|
381105
|
+
getToolDescription() {
|
|
381106
|
+
if (this.agents.size === 0) {
|
|
381107
|
+
return "Delegates a task to a specialized sub-agent. No agents are currently available.";
|
|
381108
|
+
}
|
|
381109
|
+
const agentDescriptions = Array.from(this.agents.entries()).map(([name4, def2]) => `- **${name4}**: ${def2.description}`).join("\n");
|
|
381110
|
+
return `Delegates a task to a specialized sub-agent.
|
|
381029
381111
|
|
|
381030
|
-
|
|
381031
|
-
|
|
381032
|
-
|
|
381033
|
-
|
|
381034
|
-
|
|
381035
|
-
|
|
381036
|
-
|
|
381037
|
-
|
|
381038
|
-
|
|
381039
|
-
|
|
381040
|
-
case "number":
|
|
381041
|
-
case "integer":
|
|
381042
|
-
case "boolean":
|
|
381043
|
-
schemaProperty.type = definition.type;
|
|
381044
|
-
break;
|
|
381045
|
-
case "string[]":
|
|
381046
|
-
schemaProperty.type = "array";
|
|
381047
|
-
schemaProperty.items = { type: "string" };
|
|
381048
|
-
break;
|
|
381049
|
-
case "number[]":
|
|
381050
|
-
schemaProperty.type = "array";
|
|
381051
|
-
schemaProperty.items = { type: "number" };
|
|
381052
|
-
break;
|
|
381053
|
-
default: {
|
|
381054
|
-
const exhaustiveCheck = definition.type;
|
|
381055
|
-
throw new Error(`Unsupported input type '${exhaustiveCheck}' for parameter '${name4}'. Supported types: string, number, integer, boolean, string[], number[]`);
|
|
381056
|
-
}
|
|
381112
|
+
Available agents:
|
|
381113
|
+
${agentDescriptions}`;
|
|
381114
|
+
}
|
|
381115
|
+
/**
|
|
381116
|
+
* Generates a markdown "Phone Book" of available agents and their schemas.
|
|
381117
|
+
* This MUST be injected into the System Prompt of the parent agent.
|
|
381118
|
+
*/
|
|
381119
|
+
getDirectoryContext() {
|
|
381120
|
+
if (this.agents.size === 0) {
|
|
381121
|
+
return "No sub-agents are currently available.";
|
|
381057
381122
|
}
|
|
381058
|
-
|
|
381059
|
-
|
|
381060
|
-
|
|
381123
|
+
let context2 = "## Available Sub-Agents\n";
|
|
381124
|
+
context2 += "Use `delegate_to_agent` for complex tasks requiring specialized analysis.\n\n";
|
|
381125
|
+
for (const [name4, def2] of this.agents.entries()) {
|
|
381126
|
+
context2 += `- **${name4}**: ${def2.description}
|
|
381127
|
+
`;
|
|
381061
381128
|
}
|
|
381129
|
+
return context2;
|
|
381062
381130
|
}
|
|
381063
|
-
|
|
381064
|
-
type: "object",
|
|
381065
|
-
properties,
|
|
381066
|
-
required: required2.length > 0 ? required2 : void 0
|
|
381067
|
-
};
|
|
381068
|
-
}
|
|
381131
|
+
};
|
|
381069
381132
|
|
|
381070
381133
|
// packages/core/dist/src/core/nonInteractiveToolExecutor.js
|
|
381071
381134
|
async function executeToolCall(config3, toolCallRequest, abortSignal) {
|
|
@@ -381847,71 +381910,126 @@ Error: ${errorMessage}`,
|
|
|
381847
381910
|
}
|
|
381848
381911
|
};
|
|
381849
381912
|
|
|
381850
|
-
// packages/core/dist/src/agents/
|
|
381851
|
-
var
|
|
381852
|
-
|
|
381913
|
+
// packages/core/dist/src/agents/delegate-to-agent-tool.js
|
|
381914
|
+
var DelegateToAgentTool = class extends BaseDeclarativeTool {
|
|
381915
|
+
registry;
|
|
381853
381916
|
config;
|
|
381854
|
-
|
|
381855
|
-
|
|
381856
|
-
|
|
381857
|
-
|
|
381858
|
-
|
|
381859
|
-
|
|
381860
|
-
|
|
381861
|
-
|
|
381862
|
-
|
|
381863
|
-
|
|
381864
|
-
|
|
381865
|
-
|
|
381917
|
+
constructor(registry2, config3, messageBus) {
|
|
381918
|
+
const definitions = registry2.getAllDefinitions();
|
|
381919
|
+
let schema;
|
|
381920
|
+
if (definitions.length === 0) {
|
|
381921
|
+
schema = external_exports.object({
|
|
381922
|
+
agent_name: external_exports.string().describe("No agents are currently available.")
|
|
381923
|
+
});
|
|
381924
|
+
} else {
|
|
381925
|
+
const agentSchemas = definitions.map((def2) => {
|
|
381926
|
+
const inputShape = {
|
|
381927
|
+
agent_name: external_exports.literal(def2.name).describe(def2.description)
|
|
381928
|
+
};
|
|
381929
|
+
for (const [key, inputDef] of Object.entries(def2.inputConfig.inputs)) {
|
|
381930
|
+
if (key === "agent_name") {
|
|
381931
|
+
throw new Error(`Agent '${def2.name}' cannot have an input parameter named 'agent_name' as it is a reserved parameter for delegation.`);
|
|
381932
|
+
}
|
|
381933
|
+
let validator;
|
|
381934
|
+
switch (inputDef.type) {
|
|
381935
|
+
case "string":
|
|
381936
|
+
validator = external_exports.string();
|
|
381937
|
+
break;
|
|
381938
|
+
case "number":
|
|
381939
|
+
validator = external_exports.number();
|
|
381940
|
+
break;
|
|
381941
|
+
case "boolean":
|
|
381942
|
+
validator = external_exports.boolean();
|
|
381943
|
+
break;
|
|
381944
|
+
case "integer":
|
|
381945
|
+
validator = external_exports.number().int();
|
|
381946
|
+
break;
|
|
381947
|
+
case "string[]":
|
|
381948
|
+
validator = external_exports.array(external_exports.string());
|
|
381949
|
+
break;
|
|
381950
|
+
case "number[]":
|
|
381951
|
+
validator = external_exports.array(external_exports.number());
|
|
381952
|
+
break;
|
|
381953
|
+
default: {
|
|
381954
|
+
const _exhaustiveCheck = inputDef.type;
|
|
381955
|
+
void _exhaustiveCheck;
|
|
381956
|
+
throw new Error(`Unhandled agent input type: '${inputDef.type}'`);
|
|
381957
|
+
}
|
|
381958
|
+
}
|
|
381959
|
+
if (!inputDef.required) {
|
|
381960
|
+
validator = validator.optional();
|
|
381961
|
+
}
|
|
381962
|
+
inputShape[key] = validator.describe(inputDef.description);
|
|
381963
|
+
}
|
|
381964
|
+
return external_exports.object(inputShape);
|
|
381965
|
+
});
|
|
381966
|
+
if (agentSchemas.length === 1) {
|
|
381967
|
+
schema = agentSchemas[0];
|
|
381968
|
+
} else {
|
|
381969
|
+
schema = external_exports.discriminatedUnion("agent_name", agentSchemas);
|
|
381970
|
+
}
|
|
381971
|
+
}
|
|
381866
381972
|
super(
|
|
381867
|
-
|
|
381868
|
-
|
|
381869
|
-
|
|
381973
|
+
DELEGATE_TO_AGENT_TOOL_NAME,
|
|
381974
|
+
"Delegate to Agent",
|
|
381975
|
+
registry2.getToolDescription(),
|
|
381870
381976
|
Kind.Think,
|
|
381871
|
-
|
|
381977
|
+
zodToJsonSchema(schema),
|
|
381872
381978
|
/* isOutputMarkdown */
|
|
381873
381979
|
true,
|
|
381874
381980
|
/* canUpdateOutput */
|
|
381875
381981
|
true,
|
|
381876
381982
|
messageBus
|
|
381877
381983
|
);
|
|
381878
|
-
this.
|
|
381984
|
+
this.registry = registry2;
|
|
381879
381985
|
this.config = config3;
|
|
381880
381986
|
}
|
|
381881
|
-
/**
|
|
381882
|
-
* Creates an invocation instance for executing the subagent.
|
|
381883
|
-
*
|
|
381884
|
-
* This method is called by the tool framework when the parent agent decides
|
|
381885
|
-
* to use this tool.
|
|
381886
|
-
*
|
|
381887
|
-
* @param params The validated input parameters from the parent agent's call.
|
|
381888
|
-
* @returns A `ToolInvocation` instance ready for execution.
|
|
381889
|
-
*/
|
|
381890
381987
|
createInvocation(params) {
|
|
381891
|
-
return new
|
|
381988
|
+
return new DelegateInvocation(params, this.registry, this.config, this.messageBus);
|
|
381989
|
+
}
|
|
381990
|
+
};
|
|
381991
|
+
var DelegateInvocation = class extends BaseToolInvocation {
|
|
381992
|
+
registry;
|
|
381993
|
+
config;
|
|
381994
|
+
constructor(params, registry2, config3, messageBus) {
|
|
381995
|
+
super(params, messageBus, DELEGATE_TO_AGENT_TOOL_NAME);
|
|
381996
|
+
this.registry = registry2;
|
|
381997
|
+
this.config = config3;
|
|
381998
|
+
}
|
|
381999
|
+
getDescription() {
|
|
382000
|
+
return `Delegating to agent '${this.params.agent_name}'`;
|
|
382001
|
+
}
|
|
382002
|
+
async execute(signal, updateOutput) {
|
|
382003
|
+
const definition = this.registry.getDefinition(this.params.agent_name);
|
|
382004
|
+
if (!definition) {
|
|
382005
|
+
throw new Error(`Agent '${this.params.agent_name}' exists in the tool definition but could not be found in the registry.`);
|
|
382006
|
+
}
|
|
382007
|
+
const { agent_name, ...agentArgs } = this.params;
|
|
382008
|
+
const subagentInvocation = new SubagentInvocation(agentArgs, definition, this.config, this.messageBus);
|
|
382009
|
+
return subagentInvocation.execute(signal, updateOutput);
|
|
381892
382010
|
}
|
|
381893
382011
|
};
|
|
381894
382012
|
|
|
381895
382013
|
// node_modules/read-package-up/index.js
|
|
381896
|
-
import
|
|
382014
|
+
import path59 from "node:path";
|
|
381897
382015
|
|
|
381898
382016
|
// node_modules/find-up-simple/index.js
|
|
381899
382017
|
import process21 from "node:process";
|
|
381900
382018
|
import fsPromises4 from "node:fs/promises";
|
|
381901
382019
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
381902
|
-
import
|
|
382020
|
+
import path57 from "node:path";
|
|
381903
382021
|
var toPath2 = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath8(urlOrPath) : urlOrPath;
|
|
381904
382022
|
async function findUp(name4, {
|
|
381905
382023
|
cwd = process21.cwd(),
|
|
381906
382024
|
type = "file",
|
|
381907
382025
|
stopAt
|
|
381908
382026
|
} = {}) {
|
|
381909
|
-
let directory =
|
|
381910
|
-
const { root } =
|
|
381911
|
-
stopAt =
|
|
381912
|
-
const isAbsoluteName =
|
|
382027
|
+
let directory = path57.resolve(toPath2(cwd) ?? "");
|
|
382028
|
+
const { root } = path57.parse(directory);
|
|
382029
|
+
stopAt = path57.resolve(directory, toPath2(stopAt ?? root));
|
|
382030
|
+
const isAbsoluteName = path57.isAbsolute(name4);
|
|
381913
382031
|
while (directory) {
|
|
381914
|
-
const filePath = isAbsoluteName ? name4 :
|
|
382032
|
+
const filePath = isAbsoluteName ? name4 : path57.join(directory, name4);
|
|
381915
382033
|
try {
|
|
381916
382034
|
const stats = await fsPromises4.stat(filePath);
|
|
381917
382035
|
if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) {
|
|
@@ -381922,13 +382040,13 @@ async function findUp(name4, {
|
|
|
381922
382040
|
if (directory === stopAt || directory === root) {
|
|
381923
382041
|
break;
|
|
381924
382042
|
}
|
|
381925
|
-
directory =
|
|
382043
|
+
directory = path57.dirname(directory);
|
|
381926
382044
|
}
|
|
381927
382045
|
}
|
|
381928
382046
|
|
|
381929
382047
|
// node_modules/read-pkg/index.js
|
|
381930
382048
|
import fsPromises5 from "node:fs/promises";
|
|
381931
|
-
import
|
|
382049
|
+
import path58 from "node:path";
|
|
381932
382050
|
|
|
381933
382051
|
// node_modules/parse-json/index.js
|
|
381934
382052
|
var import_code_frame = __toESM(require_lib12(), 1);
|
|
@@ -382057,7 +382175,7 @@ function toPath3(urlOrPath) {
|
|
|
382057
382175
|
}
|
|
382058
382176
|
|
|
382059
382177
|
// node_modules/read-pkg/index.js
|
|
382060
|
-
var getPackagePath = (cwd) =>
|
|
382178
|
+
var getPackagePath = (cwd) => path58.resolve(toPath3(cwd) ?? ".", "package.json");
|
|
382061
382179
|
var _readPackage = (file, normalize5) => {
|
|
382062
382180
|
const json = typeof file === "string" ? parseJson(file) : file;
|
|
382063
382181
|
if (normalize5) {
|
|
@@ -382077,7 +382195,7 @@ async function readPackageUp(options2) {
|
|
|
382077
382195
|
return;
|
|
382078
382196
|
}
|
|
382079
382197
|
return {
|
|
382080
|
-
packageJson: await readPackage({ ...options2, cwd:
|
|
382198
|
+
packageJson: await readPackage({ ...options2, cwd: path59.dirname(filePath) }),
|
|
382081
382199
|
path: filePath
|
|
382082
382200
|
};
|
|
382083
382201
|
}
|
|
@@ -382118,10 +382236,22 @@ async function getReleaseChannel(cwd) {
|
|
|
382118
382236
|
}
|
|
382119
382237
|
|
|
382120
382238
|
// packages/core/dist/src/code_assist/experiments/client_metadata.js
|
|
382121
|
-
import { fileURLToPath as
|
|
382239
|
+
import { fileURLToPath as fileURLToPath11 } from "node:url";
|
|
382122
382240
|
import path61 from "node:path";
|
|
382241
|
+
|
|
382242
|
+
// packages/core/dist/src/utils/version.js
|
|
382243
|
+
import { fileURLToPath as fileURLToPath10 } from "node:url";
|
|
382244
|
+
import path60 from "node:path";
|
|
382123
382245
|
var __filename = fileURLToPath10(import.meta.url);
|
|
382124
|
-
var __dirname5 =
|
|
382246
|
+
var __dirname5 = path60.dirname(__filename);
|
|
382247
|
+
async function getVersion() {
|
|
382248
|
+
const pkgJson = await getPackageJson(__dirname5);
|
|
382249
|
+
return "0.21.0-nightly.20251211.8c83e1ea9";
|
|
382250
|
+
}
|
|
382251
|
+
|
|
382252
|
+
// packages/core/dist/src/code_assist/experiments/client_metadata.js
|
|
382253
|
+
var __filename2 = fileURLToPath11(import.meta.url);
|
|
382254
|
+
var __dirname6 = path61.dirname(__filename2);
|
|
382125
382255
|
var clientMetadataPromise;
|
|
382126
382256
|
function getPlatform() {
|
|
382127
382257
|
const platform11 = process.platform;
|
|
@@ -382148,9 +382278,9 @@ async function getClientMetadata() {
|
|
|
382148
382278
|
clientMetadataPromise = (async () => ({
|
|
382149
382279
|
ideName: "IDE_UNSPECIFIED",
|
|
382150
382280
|
pluginType: "GEMINI",
|
|
382151
|
-
ideVersion:
|
|
382281
|
+
ideVersion: await getVersion(),
|
|
382152
382282
|
platform: getPlatform(),
|
|
382153
|
-
updateChannel: await getReleaseChannel(
|
|
382283
|
+
updateChannel: await getReleaseChannel(__dirname6)
|
|
382154
382284
|
}))();
|
|
382155
382285
|
}
|
|
382156
382286
|
return clientMetadataPromise;
|
|
@@ -383289,7 +383419,7 @@ var ServiceAccountImpersonationProvider = class {
|
|
|
383289
383419
|
};
|
|
383290
383420
|
|
|
383291
383421
|
// packages/core/dist/src/tools/mcp-client.js
|
|
383292
|
-
import { basename as
|
|
383422
|
+
import { basename as basename12 } from "node:path";
|
|
383293
383423
|
import { pathToFileURL } from "node:url";
|
|
383294
383424
|
|
|
383295
383425
|
// packages/core/dist/src/mcp/oauth-provider.js
|
|
@@ -384676,7 +384806,7 @@ async function connectToMcpServer(mcpServerName, mcpServerConfig, debugMode, wor
|
|
|
384676
384806
|
for (const dir of workspaceContext.getDirectories()) {
|
|
384677
384807
|
roots.push({
|
|
384678
384808
|
uri: pathToFileURL(dir).toString(),
|
|
384679
|
-
name:
|
|
384809
|
+
name: basename12(dir)
|
|
384680
384810
|
});
|
|
384681
384811
|
}
|
|
384682
384812
|
return {
|
|
@@ -385417,11 +385547,19 @@ var Config = class {
|
|
|
385417
385547
|
this.geminiClient = new GeminiClient(this);
|
|
385418
385548
|
this.modelRouterService = new ModelRouterService(this);
|
|
385419
385549
|
let modelConfigServiceConfig = params.modelConfigServiceConfig;
|
|
385420
|
-
if (modelConfigServiceConfig
|
|
385421
|
-
modelConfigServiceConfig
|
|
385422
|
-
|
|
385423
|
-
|
|
385424
|
-
|
|
385550
|
+
if (modelConfigServiceConfig) {
|
|
385551
|
+
if (!modelConfigServiceConfig.aliases) {
|
|
385552
|
+
modelConfigServiceConfig = {
|
|
385553
|
+
...modelConfigServiceConfig,
|
|
385554
|
+
aliases: DEFAULT_MODEL_CONFIGS.aliases
|
|
385555
|
+
};
|
|
385556
|
+
}
|
|
385557
|
+
if (!modelConfigServiceConfig.overrides) {
|
|
385558
|
+
modelConfigServiceConfig = {
|
|
385559
|
+
...modelConfigServiceConfig,
|
|
385560
|
+
overrides: DEFAULT_MODEL_CONFIGS.overrides
|
|
385561
|
+
};
|
|
385562
|
+
}
|
|
385425
385563
|
}
|
|
385426
385564
|
this.modelConfigService = new ModelConfigService(modelConfigServiceConfig ?? DEFAULT_MODEL_CONFIGS);
|
|
385427
385565
|
}
|
|
@@ -385464,6 +385602,7 @@ var Config = class {
|
|
|
385464
385602
|
return this.contentGenerator;
|
|
385465
385603
|
}
|
|
385466
385604
|
async refreshAuth(authMethod) {
|
|
385605
|
+
this.modelAvailabilityService.reset();
|
|
385467
385606
|
if (this.contentGeneratorConfig?.authType === AuthType2.USE_GEMINI && authMethod !== AuthType2.USE_GEMINI) {
|
|
385468
385607
|
this.geminiClient.stripThoughtsFromHistory();
|
|
385469
385608
|
}
|
|
@@ -385545,6 +385684,7 @@ var Config = class {
|
|
|
385545
385684
|
coreEvents.emitModelChanged(newModel);
|
|
385546
385685
|
}
|
|
385547
385686
|
this.setFallbackMode(false);
|
|
385687
|
+
this.modelAvailabilityService.reset();
|
|
385548
385688
|
}
|
|
385549
385689
|
getActiveModel() {
|
|
385550
385690
|
return this._activeModel ?? this.model;
|
|
@@ -386088,16 +386228,13 @@ var Config = class {
|
|
|
386088
386228
|
if (this.getUseWriteTodos()) {
|
|
386089
386229
|
registerCoreTool(WriteTodosTool, this);
|
|
386090
386230
|
}
|
|
386091
|
-
if (this.getCodebaseInvestigatorSettings().enabled) {
|
|
386092
|
-
const
|
|
386093
|
-
|
|
386094
|
-
|
|
386095
|
-
const
|
|
386096
|
-
|
|
386097
|
-
|
|
386098
|
-
const wrapper = new SubagentToolWrapper(definition, this, messageBusEnabled ? this.getMessageBus() : void 0);
|
|
386099
|
-
registry2.registerTool(wrapper);
|
|
386100
|
-
}
|
|
386231
|
+
if (this.isAgentsEnabled() || this.getCodebaseInvestigatorSettings().enabled) {
|
|
386232
|
+
const allowedTools = this.getAllowedTools();
|
|
386233
|
+
const isAllowed = !allowedTools || allowedTools.includes(DELEGATE_TO_AGENT_TOOL_NAME);
|
|
386234
|
+
if (isAllowed) {
|
|
386235
|
+
const messageBusEnabled = this.getEnableMessageBusIntegration();
|
|
386236
|
+
const delegateTool = new DelegateToAgentTool(this.agentRegistry, this, messageBusEnabled ? this.getMessageBus() : void 0);
|
|
386237
|
+
registry2.registerTool(delegateTool);
|
|
386101
386238
|
}
|
|
386102
386239
|
}
|
|
386103
386240
|
await registry2.discoverAllTools();
|
|
@@ -386224,11 +386361,11 @@ var PolicyFileSchema = external_exports.object({
|
|
|
386224
386361
|
|
|
386225
386362
|
// packages/core/dist/src/policy/config.js
|
|
386226
386363
|
import * as path64 from "node:path";
|
|
386227
|
-
import { fileURLToPath as
|
|
386364
|
+
import { fileURLToPath as fileURLToPath12 } from "node:url";
|
|
386228
386365
|
init_events();
|
|
386229
|
-
var
|
|
386230
|
-
var
|
|
386231
|
-
var DEFAULT_CORE_POLICIES_DIR = path64.join(
|
|
386366
|
+
var __filename3 = fileURLToPath12(import.meta.url);
|
|
386367
|
+
var __dirname7 = path64.dirname(__filename3);
|
|
386368
|
+
var DEFAULT_CORE_POLICIES_DIR = path64.join(__dirname7, "policies");
|
|
386232
386369
|
|
|
386233
386370
|
// packages/core/dist/src/commands/extensions.js
|
|
386234
386371
|
function listExtensions(config3) {
|