@google/gemini-cli-a2a-server 0.21.0-nightly.20251210.d90356e8a → 0.21.0-nightly.20251212.54de67536
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 +563 -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
|
}
|
|
@@ -309535,6 +309535,10 @@ var DiscoveredMCPToolInvocation = class _DiscoveredMCPToolInvocation extends Bas
|
|
|
309535
309535
|
const functionResponse = rawResponseParts?.[0]?.functionResponse;
|
|
309536
309536
|
const response = functionResponse?.response;
|
|
309537
309537
|
if (response) {
|
|
309538
|
+
const isErrorTop = response.isError;
|
|
309539
|
+
if (isErrorTop === true || isErrorTop === "true") {
|
|
309540
|
+
return true;
|
|
309541
|
+
}
|
|
309538
309542
|
const error2 = response?.error;
|
|
309539
309543
|
const isError2 = error2?.isError;
|
|
309540
309544
|
if (error2 && (isError2 === true || isError2 === "true")) {
|
|
@@ -309839,8 +309843,8 @@ function sanitizeHookName(hookName) {
|
|
|
309839
309843
|
}
|
|
309840
309844
|
if (command.includes("/") || command.includes("\\")) {
|
|
309841
309845
|
const pathParts = command.split(/[/\\]/);
|
|
309842
|
-
const
|
|
309843
|
-
return
|
|
309846
|
+
const basename15 = pathParts[pathParts.length - 1];
|
|
309847
|
+
return basename15 || "unknown-command";
|
|
309844
309848
|
}
|
|
309845
309849
|
return command;
|
|
309846
309850
|
}
|
|
@@ -311908,8 +311912,8 @@ var Float64Vector = import_vector.default.Float64Vector;
|
|
|
311908
311912
|
var PointerVector = import_vector.default.PointerVector;
|
|
311909
311913
|
|
|
311910
311914
|
// packages/core/dist/src/generated/git-commit.js
|
|
311911
|
-
var GIT_COMMIT_INFO = "
|
|
311912
|
-
var CLI_VERSION = "0.21.0-nightly.
|
|
311915
|
+
var GIT_COMMIT_INFO = "54de67536";
|
|
311916
|
+
var CLI_VERSION = "0.21.0-nightly.20251212.54de67536";
|
|
311913
311917
|
|
|
311914
311918
|
// packages/core/dist/src/ide/detect-ide.js
|
|
311915
311919
|
var IDE_DEFINITIONS = {
|
|
@@ -315094,9 +315098,10 @@ async function createContentGenerator(config3, gcConfig, sessionId2) {
|
|
|
315094
315098
|
if (gcConfig.fakeResponses) {
|
|
315095
315099
|
return FakeContentGenerator.fromFile(gcConfig.fakeResponses);
|
|
315096
315100
|
}
|
|
315097
|
-
const version4 =
|
|
315101
|
+
const version4 = await getVersion();
|
|
315102
|
+
const model = getEffectiveModel(gcConfig.isInFallbackMode(), gcConfig.getModel(), gcConfig.getPreviewFeatures());
|
|
315098
315103
|
const customHeadersEnv = process.env["GEMINI_CLI_CUSTOM_HEADERS"] || void 0;
|
|
315099
|
-
const userAgent = `GeminiCLI/${version4} (${process.platform}; ${process.arch})`;
|
|
315104
|
+
const userAgent = `GeminiCLI/${version4}/${model} (${process.platform}; ${process.arch})`;
|
|
315100
315105
|
const customHeadersMap = parseCustomHeaders(customHeadersEnv);
|
|
315101
315106
|
const apiKeyAuthMechanism = process.env["GEMINI_API_KEY_AUTH_MECHANISM"] || "x-goog-api-key";
|
|
315102
315107
|
const baseHeaders = {
|
|
@@ -315669,6 +315674,7 @@ var READ_FILE_TOOL_NAME = "read_file";
|
|
|
315669
315674
|
var LS_TOOL_NAME = "list_directory";
|
|
315670
315675
|
var MEMORY_TOOL_NAME = "save_memory";
|
|
315671
315676
|
var EDIT_TOOL_NAMES = /* @__PURE__ */ new Set([EDIT_TOOL_NAME, WRITE_FILE_TOOL_NAME]);
|
|
315677
|
+
var DELEGATE_TO_AGENT_TOOL_NAME = "delegate_to_agent";
|
|
315672
315678
|
|
|
315673
315679
|
// packages/core/dist/src/tools/ls.js
|
|
315674
315680
|
var LSToolInvocation = class extends BaseToolInvocation {
|
|
@@ -352380,8 +352386,8 @@ Expectation for required parameters:
|
|
|
352380
352386
|
};
|
|
352381
352387
|
|
|
352382
352388
|
// packages/core/dist/src/tools/smart-edit.js
|
|
352383
|
-
import * as
|
|
352384
|
-
import * as
|
|
352389
|
+
import * as fs43 from "node:fs";
|
|
352390
|
+
import * as path43 from "node:path";
|
|
352385
352391
|
import * as crypto19 from "node:crypto";
|
|
352386
352392
|
|
|
352387
352393
|
// packages/core/dist/src/utils/editor.js
|
|
@@ -352757,28 +352763,28 @@ function parseGoogleApiError(error2) {
|
|
|
352757
352763
|
const code2 = currentError.code;
|
|
352758
352764
|
const message = currentError.message;
|
|
352759
352765
|
const errorDetails = currentError.details;
|
|
352760
|
-
if (
|
|
352766
|
+
if (code2 && message) {
|
|
352761
352767
|
const details = [];
|
|
352762
|
-
|
|
352763
|
-
|
|
352764
|
-
|
|
352765
|
-
|
|
352766
|
-
|
|
352767
|
-
if (typeKey
|
|
352768
|
-
|
|
352769
|
-
|
|
352768
|
+
if (Array.isArray(errorDetails)) {
|
|
352769
|
+
for (const detail of errorDetails) {
|
|
352770
|
+
if (detail && typeof detail === "object") {
|
|
352771
|
+
const detailObj = detail;
|
|
352772
|
+
const typeKey = Object.keys(detailObj).find((key) => key.trim() === "@type");
|
|
352773
|
+
if (typeKey) {
|
|
352774
|
+
if (typeKey !== "@type") {
|
|
352775
|
+
detailObj["@type"] = detailObj[typeKey];
|
|
352776
|
+
delete detailObj[typeKey];
|
|
352777
|
+
}
|
|
352778
|
+
details.push(detailObj);
|
|
352770
352779
|
}
|
|
352771
|
-
details.push(detailObj);
|
|
352772
352780
|
}
|
|
352773
352781
|
}
|
|
352774
352782
|
}
|
|
352775
|
-
|
|
352776
|
-
|
|
352777
|
-
|
|
352778
|
-
|
|
352779
|
-
|
|
352780
|
-
};
|
|
352781
|
-
}
|
|
352783
|
+
return {
|
|
352784
|
+
code: code2,
|
|
352785
|
+
message,
|
|
352786
|
+
details
|
|
352787
|
+
};
|
|
352782
352788
|
}
|
|
352783
352789
|
return null;
|
|
352784
352790
|
}
|
|
@@ -352820,6 +352826,16 @@ function fromApiError(errorObj) {
|
|
|
352820
352826
|
try {
|
|
352821
352827
|
data = JSON.parse(data);
|
|
352822
352828
|
} catch (_) {
|
|
352829
|
+
if (typeof data === "string") {
|
|
352830
|
+
const firstBrace = data.indexOf("{");
|
|
352831
|
+
const lastBrace = data.lastIndexOf("}");
|
|
352832
|
+
if (firstBrace !== -1 && lastBrace !== -1 && lastBrace > firstBrace) {
|
|
352833
|
+
try {
|
|
352834
|
+
data = JSON.parse(data.substring(firstBrace, lastBrace + 1));
|
|
352835
|
+
} catch (__) {
|
|
352836
|
+
}
|
|
352837
|
+
}
|
|
352838
|
+
}
|
|
352823
352839
|
}
|
|
352824
352840
|
}
|
|
352825
352841
|
if (Array.isArray(data) && data.length > 0) {
|
|
@@ -352897,8 +352913,8 @@ function classifyGoogleError(error2) {
|
|
|
352897
352913
|
const message = googleApiError?.message || (error2 instanceof Error ? error2.message : "Model not found");
|
|
352898
352914
|
return new ModelNotFoundError(message, status);
|
|
352899
352915
|
}
|
|
352900
|
-
if (!googleApiError || googleApiError.code !== 429) {
|
|
352901
|
-
const errorMessage = error2 instanceof Error ? error2.message : String(error2);
|
|
352916
|
+
if (!googleApiError || googleApiError.code !== 429 || googleApiError.details.length === 0) {
|
|
352917
|
+
const errorMessage = googleApiError?.message || (error2 instanceof Error ? error2.message : String(error2));
|
|
352902
352918
|
const match2 = errorMessage.match(/Please retry in ([0-9.]+(?:ms|s))/);
|
|
352903
352919
|
if (match2?.[1]) {
|
|
352904
352920
|
const retryDelaySeconds = parseDurationInSeconds(match2[1]);
|
|
@@ -353652,17 +353668,133 @@ async function FixLLMEditWithInstruction(instruction, old_string, new_string, er
|
|
|
353652
353668
|
}
|
|
353653
353669
|
|
|
353654
353670
|
// packages/core/dist/src/utils/pathCorrector.js
|
|
353655
|
-
import * as
|
|
353671
|
+
import * as fs42 from "node:fs";
|
|
353672
|
+
import * as path42 from "node:path";
|
|
353673
|
+
|
|
353674
|
+
// packages/core/dist/src/utils/bfsFileSearch.js
|
|
353675
|
+
import * as fs41 from "node:fs/promises";
|
|
353676
|
+
import * as fsSync from "node:fs";
|
|
353656
353677
|
import * as path41 from "node:path";
|
|
353678
|
+
var logger3 = {
|
|
353679
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
353680
|
+
debug: (...args2) => debugLogger.debug("[DEBUG] [BfsFileSearch]", ...args2)
|
|
353681
|
+
};
|
|
353682
|
+
async function bfsFileSearch(rootDir, options2) {
|
|
353683
|
+
const { ignoreDirs = [], maxDirs = Infinity, debug: debug2 = false } = options2;
|
|
353684
|
+
const foundFiles = [];
|
|
353685
|
+
const queue = [rootDir];
|
|
353686
|
+
const visited = /* @__PURE__ */ new Set();
|
|
353687
|
+
let scannedDirCount = 0;
|
|
353688
|
+
let queueHead = 0;
|
|
353689
|
+
const ignoreDirsSet = new Set(ignoreDirs);
|
|
353690
|
+
const PARALLEL_BATCH_SIZE = 15;
|
|
353691
|
+
while (queueHead < queue.length && scannedDirCount < maxDirs) {
|
|
353692
|
+
const batchSize = Math.min(PARALLEL_BATCH_SIZE, maxDirs - scannedDirCount);
|
|
353693
|
+
const currentBatch = [];
|
|
353694
|
+
while (currentBatch.length < batchSize && queueHead < queue.length) {
|
|
353695
|
+
const currentDir = queue[queueHead];
|
|
353696
|
+
queueHead++;
|
|
353697
|
+
if (!visited.has(currentDir)) {
|
|
353698
|
+
visited.add(currentDir);
|
|
353699
|
+
currentBatch.push(currentDir);
|
|
353700
|
+
}
|
|
353701
|
+
}
|
|
353702
|
+
scannedDirCount += currentBatch.length;
|
|
353703
|
+
if (currentBatch.length === 0)
|
|
353704
|
+
continue;
|
|
353705
|
+
if (debug2) {
|
|
353706
|
+
logger3.debug(`Scanning [${scannedDirCount}/${maxDirs}]: batch of ${currentBatch.length}`);
|
|
353707
|
+
}
|
|
353708
|
+
const readPromises = currentBatch.map(async (currentDir) => {
|
|
353709
|
+
try {
|
|
353710
|
+
const entries2 = await fs41.readdir(currentDir, { withFileTypes: true });
|
|
353711
|
+
return { currentDir, entries: entries2 };
|
|
353712
|
+
} catch (error2) {
|
|
353713
|
+
const message = error2?.message ?? "Unknown error";
|
|
353714
|
+
debugLogger.warn(`[WARN] Skipping unreadable directory: ${currentDir} (${message})`);
|
|
353715
|
+
if (debug2) {
|
|
353716
|
+
logger3.debug(`Full error for ${currentDir}:`, error2);
|
|
353717
|
+
}
|
|
353718
|
+
return { currentDir, entries: [] };
|
|
353719
|
+
}
|
|
353720
|
+
});
|
|
353721
|
+
const results = await Promise.all(readPromises);
|
|
353722
|
+
for (const { currentDir, entries: entries2 } of results) {
|
|
353723
|
+
processDirEntries(currentDir, entries2, options2, ignoreDirsSet, queue, foundFiles);
|
|
353724
|
+
}
|
|
353725
|
+
}
|
|
353726
|
+
return foundFiles;
|
|
353727
|
+
}
|
|
353728
|
+
function bfsFileSearchSync(rootDir, options2) {
|
|
353729
|
+
const { ignoreDirs = [], maxDirs = Infinity, debug: debug2 = false } = options2;
|
|
353730
|
+
const foundFiles = [];
|
|
353731
|
+
const queue = [rootDir];
|
|
353732
|
+
const visited = /* @__PURE__ */ new Set();
|
|
353733
|
+
let scannedDirCount = 0;
|
|
353734
|
+
let queueHead = 0;
|
|
353735
|
+
const ignoreDirsSet = new Set(ignoreDirs);
|
|
353736
|
+
while (queueHead < queue.length && scannedDirCount < maxDirs) {
|
|
353737
|
+
const currentDir = queue[queueHead];
|
|
353738
|
+
queueHead++;
|
|
353739
|
+
if (!visited.has(currentDir)) {
|
|
353740
|
+
visited.add(currentDir);
|
|
353741
|
+
scannedDirCount++;
|
|
353742
|
+
if (debug2) {
|
|
353743
|
+
logger3.debug(`Scanning Sync [${scannedDirCount}/${maxDirs}]: ${currentDir}`);
|
|
353744
|
+
}
|
|
353745
|
+
try {
|
|
353746
|
+
const entries2 = fsSync.readdirSync(currentDir, { withFileTypes: true });
|
|
353747
|
+
processDirEntries(currentDir, entries2, options2, ignoreDirsSet, queue, foundFiles);
|
|
353748
|
+
} catch (error2) {
|
|
353749
|
+
const message = error2?.message ?? "Unknown error";
|
|
353750
|
+
debugLogger.warn(`[WARN] Skipping unreadable directory: ${currentDir} (${message})`);
|
|
353751
|
+
}
|
|
353752
|
+
}
|
|
353753
|
+
}
|
|
353754
|
+
return foundFiles;
|
|
353755
|
+
}
|
|
353756
|
+
function processDirEntries(currentDir, entries2, options2, ignoreDirsSet, queue, foundFiles) {
|
|
353757
|
+
for (const entry of entries2) {
|
|
353758
|
+
const fullPath = path41.join(currentDir, entry.name);
|
|
353759
|
+
const isDirectory = entry.isDirectory();
|
|
353760
|
+
const isMatchingFile = entry.isFile() && entry.name === options2.fileName;
|
|
353761
|
+
if (!isDirectory && !isMatchingFile) {
|
|
353762
|
+
continue;
|
|
353763
|
+
}
|
|
353764
|
+
if (isDirectory && ignoreDirsSet.has(entry.name)) {
|
|
353765
|
+
continue;
|
|
353766
|
+
}
|
|
353767
|
+
if (options2.fileService?.shouldIgnoreFile(fullPath, {
|
|
353768
|
+
respectGitIgnore: options2.fileFilteringOptions?.respectGitIgnore,
|
|
353769
|
+
respectGeminiIgnore: options2.fileFilteringOptions?.respectGeminiIgnore
|
|
353770
|
+
})) {
|
|
353771
|
+
continue;
|
|
353772
|
+
}
|
|
353773
|
+
if (isDirectory) {
|
|
353774
|
+
queue.push(fullPath);
|
|
353775
|
+
} else {
|
|
353776
|
+
foundFiles.push(fullPath);
|
|
353777
|
+
}
|
|
353778
|
+
}
|
|
353779
|
+
}
|
|
353780
|
+
|
|
353781
|
+
// packages/core/dist/src/utils/pathCorrector.js
|
|
353657
353782
|
function correctPath(filePath, config3) {
|
|
353658
|
-
const directPath =
|
|
353659
|
-
if (
|
|
353783
|
+
const directPath = path42.join(config3.getTargetDir(), filePath);
|
|
353784
|
+
if (fs42.existsSync(directPath)) {
|
|
353660
353785
|
return { success: true, correctedPath: directPath };
|
|
353661
353786
|
}
|
|
353662
353787
|
const workspaceContext = config3.getWorkspaceContext();
|
|
353663
|
-
const fileSystem = config3.getFileSystemService();
|
|
353664
353788
|
const searchPaths = workspaceContext.getDirectories();
|
|
353665
|
-
const
|
|
353789
|
+
const basename15 = path42.basename(filePath);
|
|
353790
|
+
const normalizedTarget = filePath.replace(/\\/g, "/");
|
|
353791
|
+
const foundFiles = searchPaths.flatMap((searchPath) => bfsFileSearchSync(searchPath, {
|
|
353792
|
+
fileName: basename15,
|
|
353793
|
+
maxDirs: 50,
|
|
353794
|
+
// Capped to avoid deep hangs
|
|
353795
|
+
fileService: config3.getFileService(),
|
|
353796
|
+
fileFilteringOptions: config3.getFileFilteringOptions()
|
|
353797
|
+
})).filter((f3) => f3.replace(/\\/g, "/").endsWith(normalizedTarget));
|
|
353666
353798
|
if (foundFiles.length === 0) {
|
|
353667
353799
|
return {
|
|
353668
353800
|
success: false,
|
|
@@ -354044,7 +354176,7 @@ var EditToolInvocation2 = class extends BaseToolInvocation {
|
|
|
354044
354176
|
debugLogger.log(`Error: ${editData.error.display}`);
|
|
354045
354177
|
return false;
|
|
354046
354178
|
}
|
|
354047
|
-
const fileName =
|
|
354179
|
+
const fileName = path43.basename(this.params.file_path);
|
|
354048
354180
|
const fileDiff = createPatch(fileName, editData.currentContent ?? "", editData.newContent, "Current", "Proposed", DEFAULT_DIFF_OPTIONS);
|
|
354049
354181
|
const ideClient = await IdeClient.getInstance();
|
|
354050
354182
|
const ideConfirmation = this.config.getIdeMode() && ideClient.isDiffingEnabled() ? ideClient.openDiff(this.params.file_path, editData.newContent) : void 0;
|
|
@@ -354128,7 +354260,7 @@ var EditToolInvocation2 = class extends BaseToolInvocation {
|
|
|
354128
354260
|
if (editData.isNewFile) {
|
|
354129
354261
|
displayResult = `Created ${shortenPath(makeRelative(this.params.file_path, this.config.getTargetDir()))}`;
|
|
354130
354262
|
} else {
|
|
354131
|
-
const fileName =
|
|
354263
|
+
const fileName = path43.basename(this.params.file_path);
|
|
354132
354264
|
const fileDiff = createPatch(
|
|
354133
354265
|
fileName,
|
|
354134
354266
|
editData.currentContent ?? "",
|
|
@@ -354173,9 +354305,9 @@ var EditToolInvocation2 = class extends BaseToolInvocation {
|
|
|
354173
354305
|
* Creates parent directories if they don't exist
|
|
354174
354306
|
*/
|
|
354175
354307
|
ensureParentDirectoriesExist(filePath) {
|
|
354176
|
-
const dirName =
|
|
354177
|
-
if (!
|
|
354178
|
-
|
|
354308
|
+
const dirName = path43.dirname(filePath);
|
|
354309
|
+
if (!fs43.existsSync(dirName)) {
|
|
354310
|
+
fs43.mkdirSync(dirName, { recursive: true });
|
|
354179
354311
|
}
|
|
354180
354312
|
}
|
|
354181
354313
|
};
|
|
@@ -354258,7 +354390,7 @@ A good instruction should concisely answer:
|
|
|
354258
354390
|
return "The 'file_path' parameter must be non-empty.";
|
|
354259
354391
|
}
|
|
354260
354392
|
let filePath = params.file_path;
|
|
354261
|
-
if (!
|
|
354393
|
+
if (!path43.isAbsolute(filePath)) {
|
|
354262
354394
|
const result = correctPath(filePath, this.config);
|
|
354263
354395
|
if (!result.success) {
|
|
354264
354396
|
return result.error;
|
|
@@ -354313,8 +354445,8 @@ A good instruction should concisely answer:
|
|
|
354313
354445
|
};
|
|
354314
354446
|
|
|
354315
354447
|
// packages/core/dist/src/tools/shell.js
|
|
354316
|
-
import
|
|
354317
|
-
import
|
|
354448
|
+
import fs44 from "node:fs";
|
|
354449
|
+
import path44 from "node:path";
|
|
354318
354450
|
import os17, { EOL as EOL2 } from "node:os";
|
|
354319
354451
|
import crypto20 from "node:crypto";
|
|
354320
354452
|
|
|
@@ -360043,7 +360175,7 @@ var ShellToolInvocation = class extends BaseToolInvocation {
|
|
|
360043
360175
|
}
|
|
360044
360176
|
const isWindows5 = os17.platform() === "win32";
|
|
360045
360177
|
const tempFileName = `shell_pgrep_${crypto20.randomBytes(6).toString("hex")}.tmp`;
|
|
360046
|
-
const tempFilePath =
|
|
360178
|
+
const tempFilePath = path44.join(os17.tmpdir(), tempFileName);
|
|
360047
360179
|
const timeoutMs = this.config.getShellToolInactivityTimeout();
|
|
360048
360180
|
const timeoutController = new AbortController();
|
|
360049
360181
|
let timeoutTimer;
|
|
@@ -360056,7 +360188,7 @@ var ShellToolInvocation = class extends BaseToolInvocation {
|
|
|
360056
360188
|
command += ";";
|
|
360057
360189
|
return `{ ${command} }; __code=$?; pgrep -g 0 >${tempFilePath} 2>&1; exit $__code;`;
|
|
360058
360190
|
})();
|
|
360059
|
-
const cwd = this.params.dir_path ?
|
|
360191
|
+
const cwd = this.params.dir_path ? path44.resolve(this.config.getTargetDir(), this.params.dir_path) : this.config.getTargetDir();
|
|
360060
360192
|
let cumulativeOutput = "";
|
|
360061
360193
|
let lastUpdateTime = Date.now();
|
|
360062
360194
|
let isBinaryStream = false;
|
|
@@ -360115,8 +360247,8 @@ var ShellToolInvocation = class extends BaseToolInvocation {
|
|
|
360115
360247
|
const result = await resultPromise;
|
|
360116
360248
|
const backgroundPIDs = [];
|
|
360117
360249
|
if (os17.platform() !== "win32") {
|
|
360118
|
-
if (
|
|
360119
|
-
const pgrepLines =
|
|
360250
|
+
if (fs44.existsSync(tempFilePath)) {
|
|
360251
|
+
const pgrepLines = fs44.readFileSync(tempFilePath, "utf8").split(EOL2).filter(Boolean);
|
|
360120
360252
|
for (const line of pgrepLines) {
|
|
360121
360253
|
if (!/^\d+$/.test(line)) {
|
|
360122
360254
|
debugLogger.error(`pgrep: ${line}`);
|
|
@@ -360208,8 +360340,8 @@ ${result.output}`;
|
|
|
360208
360340
|
clearTimeout(timeoutTimer);
|
|
360209
360341
|
signal.removeEventListener("abort", onAbort);
|
|
360210
360342
|
timeoutController.signal.removeEventListener("abort", onAbort);
|
|
360211
|
-
if (
|
|
360212
|
-
|
|
360343
|
+
if (fs44.existsSync(tempFilePath)) {
|
|
360344
|
+
fs44.unlinkSync(tempFilePath);
|
|
360213
360345
|
}
|
|
360214
360346
|
}
|
|
360215
360347
|
}
|
|
@@ -360303,7 +360435,7 @@ var ShellTool = class _ShellTool extends BaseDeclarativeTool {
|
|
|
360303
360435
|
return "Could not identify command root to obtain permission from user.";
|
|
360304
360436
|
}
|
|
360305
360437
|
if (params.dir_path) {
|
|
360306
|
-
const resolvedPath =
|
|
360438
|
+
const resolvedPath = path44.resolve(this.config.getTargetDir(), params.dir_path);
|
|
360307
360439
|
const workspaceContext = this.config.getWorkspaceContext();
|
|
360308
360440
|
if (!workspaceContext.isPathWithinWorkspace(resolvedPath)) {
|
|
360309
360441
|
return `Directory '${resolvedPath}' is not within any of the registered workspace directories.`;
|
|
@@ -360317,8 +360449,8 @@ var ShellTool = class _ShellTool extends BaseDeclarativeTool {
|
|
|
360317
360449
|
};
|
|
360318
360450
|
|
|
360319
360451
|
// packages/core/dist/src/tools/write-file.js
|
|
360320
|
-
import
|
|
360321
|
-
import
|
|
360452
|
+
import fs45 from "node:fs";
|
|
360453
|
+
import path45 from "node:path";
|
|
360322
360454
|
async function getCorrectedFileContent(config3, filePath, proposedContent, abortSignal) {
|
|
360323
360455
|
let originalContent = "";
|
|
360324
360456
|
let fileExists2 = false;
|
|
@@ -360359,7 +360491,7 @@ var WriteFileToolInvocation = class extends BaseToolInvocation {
|
|
|
360359
360491
|
constructor(config3, params, messageBus, toolName, displayName) {
|
|
360360
360492
|
super(params, messageBus, toolName, displayName);
|
|
360361
360493
|
this.config = config3;
|
|
360362
|
-
this.resolvedPath =
|
|
360494
|
+
this.resolvedPath = path45.resolve(this.config.getTargetDir(), this.params.file_path);
|
|
360363
360495
|
}
|
|
360364
360496
|
toolLocations() {
|
|
360365
360497
|
return [{ path: this.resolvedPath }];
|
|
@@ -360378,7 +360510,7 @@ var WriteFileToolInvocation = class extends BaseToolInvocation {
|
|
|
360378
360510
|
}
|
|
360379
360511
|
const { originalContent, correctedContent } = correctedContentResult;
|
|
360380
360512
|
const relativePath = makeRelative(this.resolvedPath, this.config.getTargetDir());
|
|
360381
|
-
const fileName =
|
|
360513
|
+
const fileName = path45.basename(this.resolvedPath);
|
|
360382
360514
|
const fileDiff = createPatch(
|
|
360383
360515
|
fileName,
|
|
360384
360516
|
originalContent,
|
|
@@ -360432,12 +360564,12 @@ var WriteFileToolInvocation = class extends BaseToolInvocation {
|
|
|
360432
360564
|
const { originalContent, correctedContent: fileContent, fileExists: fileExists2 } = correctedContentResult;
|
|
360433
360565
|
const isNewFile = !fileExists2 || correctedContentResult.error !== void 0 && !correctedContentResult.fileExists;
|
|
360434
360566
|
try {
|
|
360435
|
-
const dirName =
|
|
360436
|
-
if (!
|
|
360437
|
-
|
|
360567
|
+
const dirName = path45.dirname(this.resolvedPath);
|
|
360568
|
+
if (!fs45.existsSync(dirName)) {
|
|
360569
|
+
fs45.mkdirSync(dirName, { recursive: true });
|
|
360438
360570
|
}
|
|
360439
360571
|
await this.config.getFileSystemService().writeTextFile(this.resolvedPath, fileContent);
|
|
360440
|
-
const fileName =
|
|
360572
|
+
const fileName = path45.basename(this.resolvedPath);
|
|
360441
360573
|
const currentContentForDiff = correctedContentResult.error ? "" : originalContent;
|
|
360442
360574
|
const fileDiff = createPatch(fileName, currentContentForDiff, fileContent, "Original", "Written", DEFAULT_DIFF_OPTIONS);
|
|
360443
360575
|
const originallyProposedContent = ai_proposed_content || content;
|
|
@@ -360450,7 +360582,7 @@ var WriteFileToolInvocation = class extends BaseToolInvocation {
|
|
|
360450
360582
|
}
|
|
360451
360583
|
const mimetype = getSpecificMimeType(this.resolvedPath);
|
|
360452
360584
|
const programmingLanguage = getLanguageFromFilePath(this.resolvedPath);
|
|
360453
|
-
const extension =
|
|
360585
|
+
const extension = path45.extname(this.resolvedPath);
|
|
360454
360586
|
const operation = isNewFile ? FileOperation.CREATE : FileOperation.UPDATE;
|
|
360455
360587
|
logFileOperation(this.config, new FileOperationEvent(WRITE_FILE_TOOL_NAME, operation, fileContent.split("\n").length, mimetype, extension, programmingLanguage));
|
|
360456
360588
|
const displayResult = {
|
|
@@ -360525,15 +360657,15 @@ var WriteFileTool = class _WriteFileTool extends BaseDeclarativeTool {
|
|
|
360525
360657
|
if (!filePath) {
|
|
360526
360658
|
return `Missing or empty "file_path"`;
|
|
360527
360659
|
}
|
|
360528
|
-
const resolvedPath =
|
|
360660
|
+
const resolvedPath = path45.resolve(this.config.getTargetDir(), filePath);
|
|
360529
360661
|
const workspaceContext = this.config.getWorkspaceContext();
|
|
360530
360662
|
if (!workspaceContext.isPathWithinWorkspace(resolvedPath)) {
|
|
360531
360663
|
const directories = workspaceContext.getDirectories();
|
|
360532
360664
|
return `File path must be within one of the workspace directories: ${directories.join(", ")}`;
|
|
360533
360665
|
}
|
|
360534
360666
|
try {
|
|
360535
|
-
if (
|
|
360536
|
-
const stats =
|
|
360667
|
+
if (fs45.existsSync(resolvedPath)) {
|
|
360668
|
+
const stats = fs45.lstatSync(resolvedPath);
|
|
360537
360669
|
if (stats.isDirectory()) {
|
|
360538
360670
|
return `Path is a directory, not a file: ${resolvedPath}`;
|
|
360539
360671
|
}
|
|
@@ -365941,13 +366073,13 @@ var WebSearchTool = class _WebSearchTool extends BaseDeclarativeTool {
|
|
|
365941
366073
|
};
|
|
365942
366074
|
|
|
365943
366075
|
// packages/core/dist/src/utils/getFolderStructure.js
|
|
365944
|
-
import * as
|
|
365945
|
-
import * as
|
|
366076
|
+
import * as fs46 from "node:fs/promises";
|
|
366077
|
+
import * as path46 from "node:path";
|
|
365946
366078
|
var MAX_ITEMS = 200;
|
|
365947
366079
|
var TRUNCATION_INDICATOR = "...";
|
|
365948
366080
|
var DEFAULT_IGNORED_FOLDERS = /* @__PURE__ */ new Set(["node_modules", ".git", "dist"]);
|
|
365949
366081
|
async function readFullStructure(rootPath, options2) {
|
|
365950
|
-
const rootName =
|
|
366082
|
+
const rootName = path46.basename(rootPath);
|
|
365951
366083
|
const rootNode = {
|
|
365952
366084
|
name: rootName,
|
|
365953
366085
|
path: rootPath,
|
|
@@ -365972,7 +366104,7 @@ async function readFullStructure(rootPath, options2) {
|
|
|
365972
366104
|
}
|
|
365973
366105
|
let entries2;
|
|
365974
366106
|
try {
|
|
365975
|
-
const rawEntries = await
|
|
366107
|
+
const rawEntries = await fs46.readdir(currentPath, { withFileTypes: true });
|
|
365976
366108
|
entries2 = rawEntries.sort((a2, b) => a2.name.localeCompare(b.name));
|
|
365977
366109
|
} catch (error2) {
|
|
365978
366110
|
if (isNodeError(error2) && (error2.code === "EACCES" || error2.code === "ENOENT")) {
|
|
@@ -365997,7 +366129,7 @@ async function readFullStructure(rootPath, options2) {
|
|
|
365997
366129
|
break;
|
|
365998
366130
|
}
|
|
365999
366131
|
const fileName = entry.name;
|
|
366000
|
-
const filePath =
|
|
366132
|
+
const filePath = path46.join(currentPath, fileName);
|
|
366001
366133
|
if (options2.fileService?.shouldIgnoreFile(filePath, filterFileOptions)) {
|
|
366002
366134
|
continue;
|
|
366003
366135
|
}
|
|
@@ -366017,7 +366149,7 @@ async function readFullStructure(rootPath, options2) {
|
|
|
366017
366149
|
break;
|
|
366018
366150
|
}
|
|
366019
366151
|
const subFolderName = entry.name;
|
|
366020
|
-
const subFolderPath =
|
|
366152
|
+
const subFolderPath = path46.join(currentPath, subFolderName);
|
|
366021
366153
|
const isIgnored = options2.fileService?.shouldIgnoreFile(subFolderPath, filterFileOptions) ?? false;
|
|
366022
366154
|
if (options2.ignoredFolders.has(subFolderName) || isIgnored) {
|
|
366023
366155
|
const ignoredSubFolder = {
|
|
@@ -366055,7 +366187,7 @@ async function readFullStructure(rootPath, options2) {
|
|
|
366055
366187
|
function formatStructure(node, currentIndent, isLastChildOfParent, isProcessingRootNode, builder) {
|
|
366056
366188
|
const connector = isLastChildOfParent ? "\u2514\u2500\u2500\u2500" : "\u251C\u2500\u2500\u2500";
|
|
366057
366189
|
if (!isProcessingRootNode || node.isIgnored) {
|
|
366058
|
-
builder.push(`${currentIndent}${connector}${node.name}${
|
|
366190
|
+
builder.push(`${currentIndent}${connector}${node.name}${path46.sep}${node.isIgnored ? TRUNCATION_INDICATOR : ""}`);
|
|
366059
366191
|
}
|
|
366060
366192
|
const indentForChildren = isProcessingRootNode ? "" : currentIndent + (isLastChildOfParent ? " " : "\u2502 ");
|
|
366061
366193
|
const fileCount = node.files.length;
|
|
@@ -366079,7 +366211,7 @@ function formatStructure(node, currentIndent, isLastChildOfParent, isProcessingR
|
|
|
366079
366211
|
}
|
|
366080
366212
|
}
|
|
366081
366213
|
async function getFolderStructure(directory, options2) {
|
|
366082
|
-
const resolvedPath =
|
|
366214
|
+
const resolvedPath = path46.resolve(directory);
|
|
366083
366215
|
const mergedOptions = {
|
|
366084
366216
|
maxItems: options2?.maxItems ?? MAX_ITEMS,
|
|
366085
366217
|
ignoredFolders: options2?.ignoredFolders ?? DEFAULT_IGNORED_FOLDERS,
|
|
@@ -366112,7 +366244,7 @@ async function getFolderStructure(directory, options2) {
|
|
|
366112
366244
|
}
|
|
366113
366245
|
return `${summary}
|
|
366114
366246
|
|
|
366115
|
-
${resolvedPath}${
|
|
366247
|
+
${resolvedPath}${path46.sep}
|
|
366116
366248
|
${structureLines.join("\n")}`;
|
|
366117
366249
|
} catch (error2) {
|
|
366118
366250
|
console.error(`Error getting folder structure for ${resolvedPath}:`, error2);
|
|
@@ -366193,8 +366325,8 @@ function getResponseTextFromParts(parts2) {
|
|
|
366193
366325
|
}
|
|
366194
366326
|
|
|
366195
366327
|
// packages/core/dist/src/core/coreToolScheduler.js
|
|
366196
|
-
import * as
|
|
366197
|
-
import * as
|
|
366328
|
+
import * as fs47 from "node:fs/promises";
|
|
366329
|
+
import * as path47 from "node:path";
|
|
366198
366330
|
var import_fast_levenshtein = __toESM(require_levenshtein(), 1);
|
|
366199
366331
|
|
|
366200
366332
|
// packages/core/dist/src/hooks/hookTranslator.js
|
|
@@ -366860,10 +366992,10 @@ async function truncateAndSaveToFile(content, callId, projectTempDir, threshold,
|
|
|
366860
366992
|
const beginning = lines.slice(0, head);
|
|
366861
366993
|
const end = lines.slice(-(truncateLines - head));
|
|
366862
366994
|
const truncatedContent = beginning.join("\n") + "\n... [CONTENT TRUNCATED] ...\n" + end.join("\n");
|
|
366863
|
-
const safeFileName = `${
|
|
366864
|
-
const outputFile =
|
|
366995
|
+
const safeFileName = `${path47.basename(callId)}.output`;
|
|
366996
|
+
const outputFile = path47.join(projectTempDir, safeFileName);
|
|
366865
366997
|
try {
|
|
366866
|
-
await
|
|
366998
|
+
await fs47.writeFile(outputFile, fileContent);
|
|
366867
366999
|
return {
|
|
366868
367000
|
content: `Tool output was too large and has been truncated.
|
|
366869
367001
|
The full output has been saved to: ${outputFile}
|
|
@@ -367539,8 +367671,8 @@ function parseThought(rawText) {
|
|
|
367539
367671
|
}
|
|
367540
367672
|
|
|
367541
367673
|
// packages/core/dist/src/services/chatRecordingService.js
|
|
367542
|
-
import
|
|
367543
|
-
import
|
|
367674
|
+
import path48 from "node:path";
|
|
367675
|
+
import fs48 from "node:fs";
|
|
367544
367676
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
367545
367677
|
var SESSION_FILE_PREFIX = "session-";
|
|
367546
367678
|
var ChatRecordingService = class {
|
|
@@ -367570,11 +367702,11 @@ var ChatRecordingService = class {
|
|
|
367570
367702
|
});
|
|
367571
367703
|
this.cachedLastConvData = null;
|
|
367572
367704
|
} else {
|
|
367573
|
-
const chatsDir =
|
|
367574
|
-
|
|
367705
|
+
const chatsDir = path48.join(this.config.storage.getProjectTempDir(), "chats");
|
|
367706
|
+
fs48.mkdirSync(chatsDir, { recursive: true });
|
|
367575
367707
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 16).replace(/:/g, "-");
|
|
367576
367708
|
const filename = `${SESSION_FILE_PREFIX}${timestamp}-${this.sessionId.slice(0, 8)}.json`;
|
|
367577
|
-
this.conversationFile =
|
|
367709
|
+
this.conversationFile = path48.join(chatsDir, filename);
|
|
367578
367710
|
this.writeConversation({
|
|
367579
367711
|
sessionId: this.sessionId,
|
|
367580
367712
|
projectHash: this.projectHash,
|
|
@@ -367744,7 +367876,7 @@ var ChatRecordingService = class {
|
|
|
367744
367876
|
*/
|
|
367745
367877
|
readConversation() {
|
|
367746
367878
|
try {
|
|
367747
|
-
this.cachedLastConvData =
|
|
367879
|
+
this.cachedLastConvData = fs48.readFileSync(this.conversationFile, "utf8");
|
|
367748
367880
|
return JSON.parse(this.cachedLastConvData);
|
|
367749
367881
|
} catch (error2) {
|
|
367750
367882
|
if (error2.code !== "ENOENT") {
|
|
@@ -367773,7 +367905,7 @@ var ChatRecordingService = class {
|
|
|
367773
367905
|
conversation.lastUpdated = (/* @__PURE__ */ new Date()).toISOString();
|
|
367774
367906
|
const newContent = JSON.stringify(conversation, null, 2);
|
|
367775
367907
|
this.cachedLastConvData = newContent;
|
|
367776
|
-
|
|
367908
|
+
fs48.writeFileSync(this.conversationFile, newContent);
|
|
367777
367909
|
}
|
|
367778
367910
|
} catch (error2) {
|
|
367779
367911
|
debugLogger.error("Error writing conversation file.", error2);
|
|
@@ -367816,14 +367948,21 @@ var ChatRecordingService = class {
|
|
|
367816
367948
|
return null;
|
|
367817
367949
|
}
|
|
367818
367950
|
}
|
|
367951
|
+
/**
|
|
367952
|
+
* Gets the path to the current conversation file.
|
|
367953
|
+
* Returns null if the service hasn't been initialized yet.
|
|
367954
|
+
*/
|
|
367955
|
+
getConversationFilePath() {
|
|
367956
|
+
return this.conversationFile;
|
|
367957
|
+
}
|
|
367819
367958
|
/**
|
|
367820
367959
|
* Deletes a session file by session ID.
|
|
367821
367960
|
*/
|
|
367822
367961
|
deleteSession(sessionId2) {
|
|
367823
367962
|
try {
|
|
367824
|
-
const chatsDir =
|
|
367825
|
-
const sessionPath =
|
|
367826
|
-
|
|
367963
|
+
const chatsDir = path48.join(this.config.storage.getProjectTempDir(), "chats");
|
|
367964
|
+
const sessionPath = path48.join(chatsDir, `${sessionId2}.json`);
|
|
367965
|
+
fs48.unlinkSync(sessionPath);
|
|
367827
367966
|
} catch (error2) {
|
|
367828
367967
|
debugLogger.error("Error deleting session file.", error2);
|
|
367829
367968
|
throw error2;
|
|
@@ -368928,8 +369067,8 @@ function getCitations(resp) {
|
|
|
368928
369067
|
}
|
|
368929
369068
|
|
|
368930
369069
|
// packages/core/dist/src/core/prompts.js
|
|
368931
|
-
import
|
|
368932
|
-
import
|
|
369070
|
+
import path49 from "node:path";
|
|
369071
|
+
import fs49 from "node:fs";
|
|
368933
369072
|
import os18 from "node:os";
|
|
368934
369073
|
import process20 from "node:process";
|
|
368935
369074
|
|
|
@@ -369248,7 +369387,7 @@ function resolvePathFromEnv(envVar) {
|
|
|
369248
369387
|
if (customPath === "~") {
|
|
369249
369388
|
customPath = home;
|
|
369250
369389
|
} else {
|
|
369251
|
-
customPath =
|
|
369390
|
+
customPath = path49.join(home, customPath.slice(2));
|
|
369252
369391
|
}
|
|
369253
369392
|
} catch (error2) {
|
|
369254
369393
|
debugLogger.warn(`Could not resolve home directory for path: ${trimmedEnvVar}`, error2);
|
|
@@ -369257,20 +369396,20 @@ function resolvePathFromEnv(envVar) {
|
|
|
369257
369396
|
}
|
|
369258
369397
|
return {
|
|
369259
369398
|
isSwitch: false,
|
|
369260
|
-
value:
|
|
369399
|
+
value: path49.resolve(customPath),
|
|
369261
369400
|
isDisabled: false
|
|
369262
369401
|
};
|
|
369263
369402
|
}
|
|
369264
369403
|
function getCoreSystemPrompt(config3, userMemory) {
|
|
369265
369404
|
let systemMdEnabled = false;
|
|
369266
|
-
let systemMdPath =
|
|
369405
|
+
let systemMdPath = path49.resolve(path49.join(GEMINI_DIR, "system.md"));
|
|
369267
369406
|
const systemMdResolution = resolvePathFromEnv(process20.env["GEMINI_SYSTEM_MD"]);
|
|
369268
369407
|
if (systemMdResolution.value && !systemMdResolution.isDisabled) {
|
|
369269
369408
|
systemMdEnabled = true;
|
|
369270
369409
|
if (!systemMdResolution.isSwitch) {
|
|
369271
369410
|
systemMdPath = systemMdResolution.value;
|
|
369272
369411
|
}
|
|
369273
|
-
if (!
|
|
369412
|
+
if (!fs49.existsSync(systemMdPath)) {
|
|
369274
369413
|
throw new Error(`missing system prompt file '${systemMdPath}'`);
|
|
369275
369414
|
}
|
|
369276
369415
|
}
|
|
@@ -369283,7 +369422,7 @@ function getCoreSystemPrompt(config3, userMemory) {
|
|
|
369283
369422
|
const interactiveMode = config3.isInteractiveShellEnabled();
|
|
369284
369423
|
let basePrompt;
|
|
369285
369424
|
if (systemMdEnabled) {
|
|
369286
|
-
basePrompt =
|
|
369425
|
+
basePrompt = fs49.readFileSync(systemMdPath, "utf8");
|
|
369287
369426
|
} else {
|
|
369288
369427
|
const promptConfig = {
|
|
369289
369428
|
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 +369438,9 @@ function getCoreSystemPrompt(config3, userMemory) {
|
|
|
369299
369438
|
- ${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
369439
|
- **Explaining Changes:** After completing a code modification or file operation *do not* provide summaries unless asked.
|
|
369301
369440
|
- **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.` : ""}
|
|
369441
|
+
- **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.` : ""}
|
|
369442
|
+
|
|
369443
|
+
${config3.getAgentRegistry().getDirectoryContext()}`,
|
|
369303
369444
|
primaryWorkflows_prefix: `
|
|
369304
369445
|
# Primary Workflows
|
|
369305
369446
|
|
|
@@ -369313,15 +369454,15 @@ Use '${READ_FILE_TOOL_NAME}' to understand context and validate any assumptions
|
|
|
369313
369454
|
|
|
369314
369455
|
## Software Engineering Tasks
|
|
369315
369456
|
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
|
|
369457
|
+
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.
|
|
369458
|
+
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
369459
|
primaryWorkflows_prefix_ci_todo: `
|
|
369319
369460
|
# Primary Workflows
|
|
369320
369461
|
|
|
369321
369462
|
## Software Engineering Tasks
|
|
369322
369463
|
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
|
|
369464
|
+
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.
|
|
369465
|
+
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
369466
|
primaryWorkflows_todo: `
|
|
369326
369467
|
# Primary Workflows
|
|
369327
369468
|
|
|
@@ -369488,8 +369629,8 @@ Your core function is efficient and safe assistance. Balance extreme conciseness
|
|
|
369488
369629
|
const writeSystemMdResolution = resolvePathFromEnv(process20.env["GEMINI_WRITE_SYSTEM_MD"]);
|
|
369489
369630
|
if (writeSystemMdResolution.value && !writeSystemMdResolution.isDisabled) {
|
|
369490
369631
|
const writePath = writeSystemMdResolution.isSwitch ? systemMdPath : writeSystemMdResolution.value;
|
|
369491
|
-
|
|
369492
|
-
|
|
369632
|
+
fs49.mkdirSync(path49.dirname(writePath), { recursive: true });
|
|
369633
|
+
fs49.writeFileSync(writePath, basePrompt);
|
|
369493
369634
|
}
|
|
369494
369635
|
const memorySuffix = userMemory && userMemory.trim().length > 0 ? `
|
|
369495
369636
|
|
|
@@ -370682,8 +370823,8 @@ var GeminiClient = class {
|
|
|
370682
370823
|
|
|
370683
370824
|
// packages/core/dist/src/utils/gitIgnoreParser.js
|
|
370684
370825
|
var import_ignore3 = __toESM(require_ignore(), 1);
|
|
370685
|
-
import * as
|
|
370686
|
-
import * as
|
|
370826
|
+
import * as fs50 from "node:fs";
|
|
370827
|
+
import * as path50 from "node:path";
|
|
370687
370828
|
var GitIgnoreParser = class {
|
|
370688
370829
|
extraPatterns;
|
|
370689
370830
|
projectRoot;
|
|
@@ -370692,7 +370833,7 @@ var GitIgnoreParser = class {
|
|
|
370692
370833
|
processedExtraPatterns = [];
|
|
370693
370834
|
constructor(projectRoot, extraPatterns) {
|
|
370694
370835
|
this.extraPatterns = extraPatterns;
|
|
370695
|
-
this.projectRoot =
|
|
370836
|
+
this.projectRoot = path50.resolve(projectRoot);
|
|
370696
370837
|
if (this.extraPatterns) {
|
|
370697
370838
|
this.processedExtraPatterns = this.processPatterns(this.extraPatterns, ".");
|
|
370698
370839
|
}
|
|
@@ -370700,12 +370841,12 @@ var GitIgnoreParser = class {
|
|
|
370700
370841
|
loadPatternsForFile(patternsFilePath) {
|
|
370701
370842
|
let content;
|
|
370702
370843
|
try {
|
|
370703
|
-
content =
|
|
370844
|
+
content = fs50.readFileSync(patternsFilePath, "utf-8");
|
|
370704
370845
|
} catch (_error) {
|
|
370705
370846
|
return [];
|
|
370706
370847
|
}
|
|
370707
|
-
const isExcludeFile = patternsFilePath.endsWith(
|
|
370708
|
-
const relativeBaseDir = isExcludeFile ? "." :
|
|
370848
|
+
const isExcludeFile = patternsFilePath.endsWith(path50.join(".git", "info", "exclude"));
|
|
370849
|
+
const relativeBaseDir = isExcludeFile ? "." : path50.dirname(path50.relative(this.projectRoot, patternsFilePath)).split(path50.sep).join(path50.posix.sep);
|
|
370709
370850
|
const rawPatterns = content.split("\n");
|
|
370710
370851
|
return this.processPatterns(rawPatterns, relativeBaseDir);
|
|
370711
370852
|
}
|
|
@@ -370725,9 +370866,9 @@ var GitIgnoreParser = class {
|
|
|
370725
370866
|
let newPattern = p;
|
|
370726
370867
|
if (relativeBaseDir && relativeBaseDir !== ".") {
|
|
370727
370868
|
if (!isAnchoredInFile && !p.includes("/")) {
|
|
370728
|
-
newPattern =
|
|
370869
|
+
newPattern = path50.posix.join("**", p);
|
|
370729
370870
|
}
|
|
370730
|
-
newPattern =
|
|
370871
|
+
newPattern = path50.posix.join(relativeBaseDir, newPattern);
|
|
370731
370872
|
if (!newPattern.startsWith("/")) {
|
|
370732
370873
|
newPattern = "/" + newPattern;
|
|
370733
370874
|
}
|
|
@@ -370745,13 +370886,13 @@ var GitIgnoreParser = class {
|
|
|
370745
370886
|
if (!filePath || typeof filePath !== "string") {
|
|
370746
370887
|
return false;
|
|
370747
370888
|
}
|
|
370748
|
-
const absoluteFilePath =
|
|
370889
|
+
const absoluteFilePath = path50.resolve(this.projectRoot, filePath);
|
|
370749
370890
|
if (!absoluteFilePath.startsWith(this.projectRoot)) {
|
|
370750
370891
|
return false;
|
|
370751
370892
|
}
|
|
370752
370893
|
try {
|
|
370753
|
-
const resolved =
|
|
370754
|
-
const relativePath =
|
|
370894
|
+
const resolved = path50.resolve(this.projectRoot, filePath);
|
|
370895
|
+
const relativePath = path50.relative(this.projectRoot, resolved);
|
|
370755
370896
|
if (relativePath === "" || relativePath.startsWith("..")) {
|
|
370756
370897
|
return false;
|
|
370757
370898
|
}
|
|
@@ -370762,19 +370903,19 @@ var GitIgnoreParser = class {
|
|
|
370762
370903
|
const ig = (0, import_ignore3.default)();
|
|
370763
370904
|
ig.add(".git");
|
|
370764
370905
|
if (this.globalPatterns === void 0) {
|
|
370765
|
-
const excludeFile =
|
|
370766
|
-
this.globalPatterns =
|
|
370906
|
+
const excludeFile = path50.join(this.projectRoot, ".git", "info", "exclude");
|
|
370907
|
+
this.globalPatterns = fs50.existsSync(excludeFile) ? this.loadPatternsForFile(excludeFile) : [];
|
|
370767
370908
|
}
|
|
370768
370909
|
ig.add(this.globalPatterns);
|
|
370769
|
-
const pathParts = relativePath.split(
|
|
370910
|
+
const pathParts = relativePath.split(path50.sep);
|
|
370770
370911
|
const dirsToVisit = [this.projectRoot];
|
|
370771
370912
|
let currentAbsDir = this.projectRoot;
|
|
370772
370913
|
for (let i4 = 0; i4 < pathParts.length - 1; i4++) {
|
|
370773
|
-
currentAbsDir =
|
|
370914
|
+
currentAbsDir = path50.join(currentAbsDir, pathParts[i4]);
|
|
370774
370915
|
dirsToVisit.push(currentAbsDir);
|
|
370775
370916
|
}
|
|
370776
370917
|
for (const dir of dirsToVisit) {
|
|
370777
|
-
const relativeDir =
|
|
370918
|
+
const relativeDir = path50.relative(this.projectRoot, dir);
|
|
370778
370919
|
if (relativeDir) {
|
|
370779
370920
|
const normalizedRelativeDir = relativeDir.replace(/\\/g, "/");
|
|
370780
370921
|
const igPlusExtras = (0, import_ignore3.default)().add(ig).add(this.processedExtraPatterns);
|
|
@@ -370788,8 +370929,8 @@ var GitIgnoreParser = class {
|
|
|
370788
370929
|
ig.add(patterns);
|
|
370789
370930
|
}
|
|
370790
370931
|
} else {
|
|
370791
|
-
const gitignorePath =
|
|
370792
|
-
if (
|
|
370932
|
+
const gitignorePath = path50.join(dir, ".gitignore");
|
|
370933
|
+
if (fs50.existsSync(gitignorePath)) {
|
|
370793
370934
|
const patterns = this.loadPatternsForFile(gitignorePath);
|
|
370794
370935
|
this.cache.set(dir, patterns);
|
|
370795
370936
|
ig.add(patterns);
|
|
@@ -370810,21 +370951,21 @@ var GitIgnoreParser = class {
|
|
|
370810
370951
|
|
|
370811
370952
|
// packages/core/dist/src/utils/geminiIgnoreParser.js
|
|
370812
370953
|
var import_ignore4 = __toESM(require_ignore(), 1);
|
|
370813
|
-
import * as
|
|
370814
|
-
import * as
|
|
370954
|
+
import * as fs51 from "node:fs";
|
|
370955
|
+
import * as path51 from "node:path";
|
|
370815
370956
|
var GeminiIgnoreParser = class {
|
|
370816
370957
|
projectRoot;
|
|
370817
370958
|
patterns = [];
|
|
370818
370959
|
ig = (0, import_ignore4.default)();
|
|
370819
370960
|
constructor(projectRoot) {
|
|
370820
|
-
this.projectRoot =
|
|
370961
|
+
this.projectRoot = path51.resolve(projectRoot);
|
|
370821
370962
|
this.loadPatterns();
|
|
370822
370963
|
}
|
|
370823
370964
|
loadPatterns() {
|
|
370824
|
-
const patternsFilePath =
|
|
370965
|
+
const patternsFilePath = path51.join(this.projectRoot, ".geminiignore");
|
|
370825
370966
|
let content;
|
|
370826
370967
|
try {
|
|
370827
|
-
content =
|
|
370968
|
+
content = fs51.readFileSync(patternsFilePath, "utf-8");
|
|
370828
370969
|
} catch (_error) {
|
|
370829
370970
|
return;
|
|
370830
370971
|
}
|
|
@@ -370841,8 +370982,8 @@ var GeminiIgnoreParser = class {
|
|
|
370841
370982
|
if (filePath.startsWith("\\") || filePath === "/" || filePath.includes("\0")) {
|
|
370842
370983
|
return false;
|
|
370843
370984
|
}
|
|
370844
|
-
const resolved =
|
|
370845
|
-
const relativePath =
|
|
370985
|
+
const resolved = path51.resolve(this.projectRoot, filePath);
|
|
370986
|
+
const relativePath = path51.relative(this.projectRoot, resolved);
|
|
370846
370987
|
if (relativePath === "" || relativePath.startsWith("..")) {
|
|
370847
370988
|
return false;
|
|
370848
370989
|
}
|
|
@@ -370858,14 +370999,14 @@ var GeminiIgnoreParser = class {
|
|
|
370858
370999
|
};
|
|
370859
371000
|
|
|
370860
371001
|
// packages/core/dist/src/services/fileDiscoveryService.js
|
|
370861
|
-
import * as
|
|
371002
|
+
import * as path52 from "node:path";
|
|
370862
371003
|
var FileDiscoveryService = class {
|
|
370863
371004
|
gitIgnoreFilter = null;
|
|
370864
371005
|
geminiIgnoreFilter = null;
|
|
370865
371006
|
combinedIgnoreFilter = null;
|
|
370866
371007
|
projectRoot;
|
|
370867
371008
|
constructor(projectRoot) {
|
|
370868
|
-
this.projectRoot =
|
|
371009
|
+
this.projectRoot = path52.resolve(projectRoot);
|
|
370869
371010
|
if (isGitRepository(this.projectRoot)) {
|
|
370870
371011
|
this.gitIgnoreFilter = new GitIgnoreParser(this.projectRoot);
|
|
370871
371012
|
}
|
|
@@ -370917,8 +371058,8 @@ var FileDiscoveryService = class {
|
|
|
370917
371058
|
};
|
|
370918
371059
|
|
|
370919
371060
|
// packages/core/dist/src/services/gitService.js
|
|
370920
|
-
import * as
|
|
370921
|
-
import * as
|
|
371061
|
+
import * as fs52 from "node:fs/promises";
|
|
371062
|
+
import * as path53 from "node:path";
|
|
370922
371063
|
|
|
370923
371064
|
// node_modules/simple-git/dist/esm/index.js
|
|
370924
371065
|
var import_file_exists = __toESM(require_dist8(), 1);
|
|
@@ -375446,7 +375587,7 @@ var GitService = class {
|
|
|
375446
375587
|
projectRoot;
|
|
375447
375588
|
storage;
|
|
375448
375589
|
constructor(projectRoot, storage2) {
|
|
375449
|
-
this.projectRoot =
|
|
375590
|
+
this.projectRoot = path53.resolve(projectRoot);
|
|
375450
375591
|
this.storage = storage2;
|
|
375451
375592
|
}
|
|
375452
375593
|
getHistoryDir() {
|
|
@@ -375477,10 +375618,10 @@ var GitService = class {
|
|
|
375477
375618
|
*/
|
|
375478
375619
|
async setupShadowGitRepository() {
|
|
375479
375620
|
const repoDir = this.getHistoryDir();
|
|
375480
|
-
const gitConfigPath =
|
|
375481
|
-
await
|
|
375621
|
+
const gitConfigPath = path53.join(repoDir, ".gitconfig");
|
|
375622
|
+
await fs52.mkdir(repoDir, { recursive: true });
|
|
375482
375623
|
const gitConfigContent = "[user]\n name = Gemini CLI\n email = gemini-cli@google.com\n[commit]\n gpgsign = false\n";
|
|
375483
|
-
await
|
|
375624
|
+
await fs52.writeFile(gitConfigPath, gitConfigContent);
|
|
375484
375625
|
const repo = simpleGit(repoDir);
|
|
375485
375626
|
const isRepoDefined = await repo.checkIsRepo(CheckRepoActions.IS_REPO_ROOT);
|
|
375486
375627
|
if (!isRepoDefined) {
|
|
@@ -375489,22 +375630,22 @@ var GitService = class {
|
|
|
375489
375630
|
});
|
|
375490
375631
|
await repo.commit("Initial commit", { "--allow-empty": null });
|
|
375491
375632
|
}
|
|
375492
|
-
const userGitIgnorePath =
|
|
375493
|
-
const shadowGitIgnorePath =
|
|
375633
|
+
const userGitIgnorePath = path53.join(this.projectRoot, ".gitignore");
|
|
375634
|
+
const shadowGitIgnorePath = path53.join(repoDir, ".gitignore");
|
|
375494
375635
|
let userGitIgnoreContent = "";
|
|
375495
375636
|
try {
|
|
375496
|
-
userGitIgnoreContent = await
|
|
375637
|
+
userGitIgnoreContent = await fs52.readFile(userGitIgnorePath, "utf-8");
|
|
375497
375638
|
} catch (error2) {
|
|
375498
375639
|
if (isNodeError(error2) && error2.code !== "ENOENT") {
|
|
375499
375640
|
throw error2;
|
|
375500
375641
|
}
|
|
375501
375642
|
}
|
|
375502
|
-
await
|
|
375643
|
+
await fs52.writeFile(shadowGitIgnorePath, userGitIgnoreContent);
|
|
375503
375644
|
}
|
|
375504
375645
|
get shadowGitRepository() {
|
|
375505
375646
|
const repoDir = this.getHistoryDir();
|
|
375506
375647
|
return simpleGit(this.projectRoot).env({
|
|
375507
|
-
GIT_DIR:
|
|
375648
|
+
GIT_DIR: path53.join(repoDir, ".git"),
|
|
375508
375649
|
GIT_WORK_TREE: this.projectRoot,
|
|
375509
375650
|
// Prevent git from using the user's global git config.
|
|
375510
375651
|
HOME: repoDir,
|
|
@@ -375566,23 +375707,13 @@ function shouldAttemptBrowserLaunch() {
|
|
|
375566
375707
|
}
|
|
375567
375708
|
|
|
375568
375709
|
// packages/core/dist/src/services/fileSystemService.js
|
|
375569
|
-
import
|
|
375570
|
-
import * as path53 from "node:path";
|
|
375710
|
+
import fs53 from "node:fs/promises";
|
|
375571
375711
|
var StandardFileSystemService = class {
|
|
375572
375712
|
async readTextFile(filePath) {
|
|
375573
|
-
return
|
|
375713
|
+
return fs53.readFile(filePath, "utf-8");
|
|
375574
375714
|
}
|
|
375575
375715
|
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
|
-
});
|
|
375716
|
+
await fs53.writeFile(filePath, content, "utf-8");
|
|
375586
375717
|
}
|
|
375587
375718
|
};
|
|
375588
375719
|
|
|
@@ -375653,6 +375784,9 @@ var ModelAvailabilityService = class {
|
|
|
375653
375784
|
}
|
|
375654
375785
|
}
|
|
375655
375786
|
}
|
|
375787
|
+
reset() {
|
|
375788
|
+
this.health.clear();
|
|
375789
|
+
}
|
|
375656
375790
|
setState(model, nextState) {
|
|
375657
375791
|
this.health.set(model, nextState);
|
|
375658
375792
|
}
|
|
@@ -376026,12 +376160,13 @@ var ModelConfigService = class {
|
|
|
376026
376160
|
}
|
|
376027
376161
|
internalGetResolvedConfig(context2) {
|
|
376028
376162
|
const config3 = this.config || {};
|
|
376029
|
-
const { aliases: aliases2 = {}, customAliases = {}, overrides = [] } = config3;
|
|
376163
|
+
const { aliases: aliases2 = {}, customAliases = {}, overrides = [], customOverrides = [] } = config3;
|
|
376030
376164
|
const allAliases = {
|
|
376031
376165
|
...aliases2,
|
|
376032
376166
|
...customAliases,
|
|
376033
376167
|
...this.runtimeAliases
|
|
376034
376168
|
};
|
|
376169
|
+
const allOverrides = [...overrides, ...customOverrides];
|
|
376035
376170
|
let baseModel = context2.model;
|
|
376036
376171
|
let resolvedConfig = {};
|
|
376037
376172
|
if (allAliases[context2.model]) {
|
|
@@ -376044,7 +376179,7 @@ var ModelConfigService = class {
|
|
|
376044
376179
|
...context2,
|
|
376045
376180
|
model: modelForMatching
|
|
376046
376181
|
};
|
|
376047
|
-
const matches =
|
|
376182
|
+
const matches = allOverrides.map((override, index) => {
|
|
376048
376183
|
const matchEntries = Object.entries(override.match);
|
|
376049
376184
|
if (matchEntries.length === 0) {
|
|
376050
376185
|
return null;
|
|
@@ -376319,93 +376454,28 @@ var DEFAULT_MODEL_CONFIGS = {
|
|
|
376319
376454
|
model: "gemini-2.5-pro"
|
|
376320
376455
|
}
|
|
376321
376456
|
}
|
|
376322
|
-
}
|
|
376457
|
+
},
|
|
376458
|
+
overrides: [
|
|
376459
|
+
{
|
|
376460
|
+
match: { model: "chat-base", isRetry: true },
|
|
376461
|
+
modelConfig: {
|
|
376462
|
+
generateContentConfig: {
|
|
376463
|
+
temperature: 1
|
|
376464
|
+
}
|
|
376465
|
+
}
|
|
376466
|
+
}
|
|
376467
|
+
]
|
|
376323
376468
|
};
|
|
376324
376469
|
|
|
376325
376470
|
// packages/core/dist/src/utils/memoryDiscovery.js
|
|
376326
376471
|
import * as fs55 from "node:fs/promises";
|
|
376327
|
-
import * as
|
|
376328
|
-
import * as
|
|
376472
|
+
import * as fsSync2 from "node:fs";
|
|
376473
|
+
import * as path55 from "node:path";
|
|
376329
376474
|
import { homedir as homedir4 } from "node:os";
|
|
376330
376475
|
|
|
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
376476
|
// packages/core/dist/src/utils/memoryImportProcessor.js
|
|
376407
376477
|
import * as fs54 from "node:fs/promises";
|
|
376408
|
-
import * as
|
|
376478
|
+
import * as path54 from "node:path";
|
|
376409
376479
|
|
|
376410
376480
|
// node_modules/marked/lib/marked.esm.js
|
|
376411
376481
|
function _getDefaults() {
|
|
@@ -378553,9 +378623,9 @@ var logger4 = {
|
|
|
378553
378623
|
error: (...args2) => debugLogger.error("[ERROR] [ImportProcessor]", ...args2)
|
|
378554
378624
|
};
|
|
378555
378625
|
async function findProjectRoot(startDir) {
|
|
378556
|
-
let currentDir =
|
|
378626
|
+
let currentDir = path54.resolve(startDir);
|
|
378557
378627
|
while (true) {
|
|
378558
|
-
const gitPath =
|
|
378628
|
+
const gitPath = path54.join(currentDir, ".git");
|
|
378559
378629
|
try {
|
|
378560
378630
|
const stats = await fs54.lstat(gitPath);
|
|
378561
378631
|
if (stats.isDirectory()) {
|
|
@@ -378563,13 +378633,13 @@ async function findProjectRoot(startDir) {
|
|
|
378563
378633
|
}
|
|
378564
378634
|
} catch {
|
|
378565
378635
|
}
|
|
378566
|
-
const parentDir =
|
|
378636
|
+
const parentDir = path54.dirname(currentDir);
|
|
378567
378637
|
if (parentDir === currentDir) {
|
|
378568
378638
|
break;
|
|
378569
378639
|
}
|
|
378570
378640
|
currentDir = parentDir;
|
|
378571
378641
|
}
|
|
378572
|
-
return
|
|
378642
|
+
return path54.resolve(startDir);
|
|
378573
378643
|
}
|
|
378574
378644
|
function hasMessage(err2) {
|
|
378575
378645
|
return typeof err2 === "object" && err2 !== null && "message" in err2 && typeof err2.message === "string";
|
|
@@ -378658,7 +378728,7 @@ async function processImports(content, basePath, debugMode = false, importState
|
|
|
378658
378728
|
const flatFiles = [];
|
|
378659
378729
|
const processedFiles = /* @__PURE__ */ new Set();
|
|
378660
378730
|
async function processFlat(fileContent, fileBasePath, filePath, depth) {
|
|
378661
|
-
const normalizedPath =
|
|
378731
|
+
const normalizedPath = path54.normalize(filePath);
|
|
378662
378732
|
if (processedFiles.has(normalizedPath))
|
|
378663
378733
|
return;
|
|
378664
378734
|
processedFiles.add(normalizedPath);
|
|
@@ -378673,14 +378743,14 @@ async function processImports(content, basePath, debugMode = false, importState
|
|
|
378673
378743
|
if (!validateImportPath(importPath, fileBasePath, [projectRoot || ""])) {
|
|
378674
378744
|
continue;
|
|
378675
378745
|
}
|
|
378676
|
-
const fullPath =
|
|
378677
|
-
const normalizedFullPath =
|
|
378746
|
+
const fullPath = path54.resolve(fileBasePath, importPath);
|
|
378747
|
+
const normalizedFullPath = path54.normalize(fullPath);
|
|
378678
378748
|
if (processedFiles.has(normalizedFullPath))
|
|
378679
378749
|
continue;
|
|
378680
378750
|
try {
|
|
378681
378751
|
await fs54.access(fullPath);
|
|
378682
378752
|
const importedContent = await fs54.readFile(fullPath, "utf-8");
|
|
378683
|
-
await processFlat(importedContent,
|
|
378753
|
+
await processFlat(importedContent, path54.dirname(fullPath), normalizedFullPath, depth + 1);
|
|
378684
378754
|
} catch (error2) {
|
|
378685
378755
|
if (debugMode) {
|
|
378686
378756
|
logger4.warn(`Failed to import ${fullPath}: ${hasMessage(error2) ? error2.message : "Unknown error"}`);
|
|
@@ -378688,7 +378758,7 @@ async function processImports(content, basePath, debugMode = false, importState
|
|
|
378688
378758
|
}
|
|
378689
378759
|
}
|
|
378690
378760
|
}
|
|
378691
|
-
const rootPath =
|
|
378761
|
+
const rootPath = path54.normalize(importState.currentFile || path54.resolve(basePath));
|
|
378692
378762
|
await processFlat(content, basePath, rootPath, 0);
|
|
378693
378763
|
const flatContent = flatFiles.map((f3) => `--- File: ${f3.path} ---
|
|
378694
378764
|
${f3.content.trim()}
|
|
@@ -378715,7 +378785,7 @@ ${f3.content.trim()}
|
|
|
378715
378785
|
result += `<!-- Import failed: ${importPath} - Path traversal attempt -->`;
|
|
378716
378786
|
continue;
|
|
378717
378787
|
}
|
|
378718
|
-
const fullPath =
|
|
378788
|
+
const fullPath = path54.resolve(basePath, importPath);
|
|
378719
378789
|
if (importState.processedFiles.has(fullPath)) {
|
|
378720
378790
|
result += `<!-- File already processed: ${importPath} -->`;
|
|
378721
378791
|
continue;
|
|
@@ -378730,7 +378800,7 @@ ${f3.content.trim()}
|
|
|
378730
378800
|
currentFile: fullPath
|
|
378731
378801
|
};
|
|
378732
378802
|
newImportState.processedFiles.add(fullPath);
|
|
378733
|
-
const imported = await processImports(fileContent,
|
|
378803
|
+
const imported = await processImports(fileContent, path54.dirname(fullPath), debugMode, newImportState, projectRoot, importFormat);
|
|
378734
378804
|
result += `<!-- Imported from: ${importPath} -->
|
|
378735
378805
|
${imported.content}
|
|
378736
378806
|
<!-- End of import from: ${importPath} -->`;
|
|
@@ -378759,7 +378829,7 @@ function validateImportPath(importPath, basePath, allowedDirectories) {
|
|
|
378759
378829
|
if (/^(file|https?):\/\//.test(importPath)) {
|
|
378760
378830
|
return false;
|
|
378761
378831
|
}
|
|
378762
|
-
const resolvedPath =
|
|
378832
|
+
const resolvedPath = path54.resolve(basePath, importPath);
|
|
378763
378833
|
return allowedDirectories.some((allowedDir) => isSubpath(allowedDir, resolvedPath));
|
|
378764
378834
|
}
|
|
378765
378835
|
|
|
@@ -378774,9 +378844,9 @@ var logger5 = {
|
|
|
378774
378844
|
error: (...args2) => console.error("[ERROR] [MemoryDiscovery]", ...args2)
|
|
378775
378845
|
};
|
|
378776
378846
|
async function findProjectRoot2(startDir) {
|
|
378777
|
-
let currentDir =
|
|
378847
|
+
let currentDir = path55.resolve(startDir);
|
|
378778
378848
|
while (true) {
|
|
378779
|
-
const gitPath =
|
|
378849
|
+
const gitPath = path55.join(currentDir, ".git");
|
|
378780
378850
|
try {
|
|
378781
378851
|
const stats = await fs55.lstat(gitPath);
|
|
378782
378852
|
if (stats.isDirectory()) {
|
|
@@ -378794,7 +378864,7 @@ async function findProjectRoot2(startDir) {
|
|
|
378794
378864
|
}
|
|
378795
378865
|
}
|
|
378796
378866
|
}
|
|
378797
|
-
const parentDir =
|
|
378867
|
+
const parentDir = path55.dirname(currentDir);
|
|
378798
378868
|
if (parentDir === currentDir) {
|
|
378799
378869
|
return null;
|
|
378800
378870
|
}
|
|
@@ -378830,17 +378900,17 @@ async function getGeminiMdFilePathsInternalForEachDir(dir, userHomePath, debugMo
|
|
|
378830
378900
|
const allPaths = /* @__PURE__ */ new Set();
|
|
378831
378901
|
const geminiMdFilenames = getAllGeminiMdFilenames();
|
|
378832
378902
|
for (const geminiMdFilename of geminiMdFilenames) {
|
|
378833
|
-
const resolvedHome =
|
|
378834
|
-
const globalMemoryPath =
|
|
378903
|
+
const resolvedHome = path55.resolve(userHomePath);
|
|
378904
|
+
const globalMemoryPath = path55.join(resolvedHome, GEMINI_DIR, geminiMdFilename);
|
|
378835
378905
|
try {
|
|
378836
|
-
await fs55.access(globalMemoryPath,
|
|
378906
|
+
await fs55.access(globalMemoryPath, fsSync2.constants.R_OK);
|
|
378837
378907
|
allPaths.add(globalMemoryPath);
|
|
378838
378908
|
if (debugMode)
|
|
378839
378909
|
logger5.debug(`Found readable global ${geminiMdFilename}: ${globalMemoryPath}`);
|
|
378840
378910
|
} catch {
|
|
378841
378911
|
}
|
|
378842
378912
|
if (dir && folderTrust) {
|
|
378843
|
-
const resolvedCwd =
|
|
378913
|
+
const resolvedCwd = path55.resolve(dir);
|
|
378844
378914
|
if (debugMode)
|
|
378845
378915
|
logger5.debug(`Searching for ${geminiMdFilename} starting from CWD: ${resolvedCwd}`);
|
|
378846
378916
|
const projectRoot = await findProjectRoot2(resolvedCwd);
|
|
@@ -378848,14 +378918,14 @@ async function getGeminiMdFilePathsInternalForEachDir(dir, userHomePath, debugMo
|
|
|
378848
378918
|
logger5.debug(`Determined project root: ${projectRoot ?? "None"}`);
|
|
378849
378919
|
const upwardPaths = [];
|
|
378850
378920
|
let currentDir = resolvedCwd;
|
|
378851
|
-
const ultimateStopDir = projectRoot ?
|
|
378852
|
-
while (currentDir && currentDir !==
|
|
378853
|
-
if (currentDir ===
|
|
378921
|
+
const ultimateStopDir = projectRoot ? path55.dirname(projectRoot) : path55.dirname(resolvedHome);
|
|
378922
|
+
while (currentDir && currentDir !== path55.dirname(currentDir)) {
|
|
378923
|
+
if (currentDir === path55.join(resolvedHome, GEMINI_DIR)) {
|
|
378854
378924
|
break;
|
|
378855
378925
|
}
|
|
378856
|
-
const potentialPath =
|
|
378926
|
+
const potentialPath = path55.join(currentDir, geminiMdFilename);
|
|
378857
378927
|
try {
|
|
378858
|
-
await fs55.access(potentialPath,
|
|
378928
|
+
await fs55.access(potentialPath, fsSync2.constants.R_OK);
|
|
378859
378929
|
if (potentialPath !== globalMemoryPath) {
|
|
378860
378930
|
upwardPaths.unshift(potentialPath);
|
|
378861
378931
|
}
|
|
@@ -378864,7 +378934,7 @@ async function getGeminiMdFilePathsInternalForEachDir(dir, userHomePath, debugMo
|
|
|
378864
378934
|
if (currentDir === ultimateStopDir) {
|
|
378865
378935
|
break;
|
|
378866
378936
|
}
|
|
378867
|
-
currentDir =
|
|
378937
|
+
currentDir = path55.dirname(currentDir);
|
|
378868
378938
|
}
|
|
378869
378939
|
upwardPaths.forEach((p) => allPaths.add(p));
|
|
378870
378940
|
const mergedOptions = {
|
|
@@ -378897,7 +378967,7 @@ async function readGeminiMdFiles(filePaths, debugMode, importFormat = "tree") {
|
|
|
378897
378967
|
const batchPromises = batch.map(async (filePath) => {
|
|
378898
378968
|
try {
|
|
378899
378969
|
const content = await fs55.readFile(filePath, "utf-8");
|
|
378900
|
-
const processedResult = await processImports(content,
|
|
378970
|
+
const processedResult = await processImports(content, path55.dirname(filePath), debugMode, void 0, void 0, importFormat);
|
|
378901
378971
|
if (debugMode)
|
|
378902
378972
|
logger5.debug(`Successfully read and processed imports: ${filePath} (Length: ${processedResult.content.length})`);
|
|
378903
378973
|
return { filePath, content: processedResult.content };
|
|
@@ -378931,7 +379001,7 @@ function concatenateInstructions(instructionContents, currentWorkingDirectoryFor
|
|
|
378931
379001
|
if (trimmedContent.length === 0) {
|
|
378932
379002
|
return null;
|
|
378933
379003
|
}
|
|
378934
|
-
const displayPath =
|
|
379004
|
+
const displayPath = path55.isAbsolute(item.filePath) ? path55.relative(currentWorkingDirectoryForDisplay, item.filePath) : item.filePath;
|
|
378935
379005
|
return `--- Context from: ${displayPath} ---
|
|
378936
379006
|
${trimmedContent}
|
|
378937
379007
|
--- End of Context from: ${displayPath} ---`;
|
|
@@ -378941,9 +379011,9 @@ async function loadGlobalMemory(debugMode = false) {
|
|
|
378941
379011
|
const userHome = homedir4();
|
|
378942
379012
|
const geminiMdFilenames = getAllGeminiMdFilenames();
|
|
378943
379013
|
const accessChecks = geminiMdFilenames.map(async (filename) => {
|
|
378944
|
-
const globalPath =
|
|
379014
|
+
const globalPath = path55.join(userHome, GEMINI_DIR, filename);
|
|
378945
379015
|
try {
|
|
378946
|
-
await fs55.access(globalPath,
|
|
379016
|
+
await fs55.access(globalPath, fsSync2.constants.R_OK);
|
|
378947
379017
|
if (debugMode) {
|
|
378948
379018
|
logger5.debug(`Found global memory file: ${globalPath}`);
|
|
378949
379019
|
}
|
|
@@ -378964,10 +379034,10 @@ async function loadGlobalMemory(debugMode = false) {
|
|
|
378964
379034
|
}
|
|
378965
379035
|
async function findUpwardGeminiFiles(startDir, stopDir, debugMode) {
|
|
378966
379036
|
const upwardPaths = [];
|
|
378967
|
-
let currentDir =
|
|
378968
|
-
const resolvedStopDir =
|
|
379037
|
+
let currentDir = path55.resolve(startDir);
|
|
379038
|
+
const resolvedStopDir = path55.resolve(stopDir);
|
|
378969
379039
|
const geminiMdFilenames = getAllGeminiMdFilenames();
|
|
378970
|
-
const globalGeminiDir =
|
|
379040
|
+
const globalGeminiDir = path55.join(homedir4(), GEMINI_DIR);
|
|
378971
379041
|
if (debugMode) {
|
|
378972
379042
|
logger5.debug(`Starting upward search from ${currentDir} stopping at ${resolvedStopDir}`);
|
|
378973
379043
|
}
|
|
@@ -378976,9 +379046,9 @@ async function findUpwardGeminiFiles(startDir, stopDir, debugMode) {
|
|
|
378976
379046
|
break;
|
|
378977
379047
|
}
|
|
378978
379048
|
const accessChecks = geminiMdFilenames.map(async (filename) => {
|
|
378979
|
-
const potentialPath =
|
|
379049
|
+
const potentialPath = path55.join(currentDir, filename);
|
|
378980
379050
|
try {
|
|
378981
|
-
await fs55.access(potentialPath,
|
|
379051
|
+
await fs55.access(potentialPath, fsSync2.constants.R_OK);
|
|
378982
379052
|
return potentialPath;
|
|
378983
379053
|
} catch {
|
|
378984
379054
|
return null;
|
|
@@ -378986,17 +379056,17 @@ async function findUpwardGeminiFiles(startDir, stopDir, debugMode) {
|
|
|
378986
379056
|
});
|
|
378987
379057
|
const foundPathsInDir = (await Promise.all(accessChecks)).filter((p) => p !== null);
|
|
378988
379058
|
upwardPaths.unshift(...foundPathsInDir);
|
|
378989
|
-
if (currentDir === resolvedStopDir || currentDir ===
|
|
379059
|
+
if (currentDir === resolvedStopDir || currentDir === path55.dirname(currentDir)) {
|
|
378990
379060
|
break;
|
|
378991
379061
|
}
|
|
378992
|
-
currentDir =
|
|
379062
|
+
currentDir = path55.dirname(currentDir);
|
|
378993
379063
|
}
|
|
378994
379064
|
return upwardPaths;
|
|
378995
379065
|
}
|
|
378996
379066
|
async function loadEnvironmentMemory(trustedRoots, extensionLoader, debugMode = false) {
|
|
378997
379067
|
const allPaths = /* @__PURE__ */ new Set();
|
|
378998
379068
|
const traversalPromises = trustedRoots.map(async (root) => {
|
|
378999
|
-
const resolvedRoot =
|
|
379069
|
+
const resolvedRoot = path55.resolve(root);
|
|
379000
379070
|
if (debugMode) {
|
|
379001
379071
|
logger5.debug(`Loading environment memory for trusted root: ${resolvedRoot} (Stopping exactly here)`);
|
|
379002
379072
|
}
|
|
@@ -379016,8 +379086,8 @@ async function loadEnvironmentMemory(trustedRoots, extensionLoader, debugMode =
|
|
|
379016
379086
|
};
|
|
379017
379087
|
}
|
|
379018
379088
|
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(
|
|
379089
|
+
const realCwd = await fs55.realpath(path55.resolve(currentWorkingDirectory));
|
|
379090
|
+
const realHome = await fs55.realpath(path55.resolve(homedir4()));
|
|
379021
379091
|
const isHomeDirectory = realCwd === realHome;
|
|
379022
379092
|
currentWorkingDirectory = isHomeDirectory ? "" : currentWorkingDirectory;
|
|
379023
379093
|
if (debugMode)
|
|
@@ -379053,10 +379123,10 @@ async function refreshServerHierarchicalMemory(config3) {
|
|
|
379053
379123
|
return result;
|
|
379054
379124
|
}
|
|
379055
379125
|
async function loadJitSubdirectoryMemory(targetPath, trustedRoots, alreadyLoadedPaths, debugMode = false) {
|
|
379056
|
-
const resolvedTarget =
|
|
379126
|
+
const resolvedTarget = path55.resolve(targetPath);
|
|
379057
379127
|
let bestRoot = null;
|
|
379058
379128
|
for (const root of trustedRoots) {
|
|
379059
|
-
const resolvedRoot =
|
|
379129
|
+
const resolvedRoot = path55.resolve(root);
|
|
379060
379130
|
if (resolvedTarget.startsWith(resolvedRoot) && (!bestRoot || resolvedRoot.length > bestRoot.length)) {
|
|
379061
379131
|
bestRoot = resolvedRoot;
|
|
379062
379132
|
}
|
|
@@ -379152,7 +379222,7 @@ var ContextManager = class {
|
|
|
379152
379222
|
|
|
379153
379223
|
// packages/core/dist/src/utils/workspaceContext.js
|
|
379154
379224
|
import * as fs56 from "node:fs";
|
|
379155
|
-
import * as
|
|
379225
|
+
import * as path56 from "node:path";
|
|
379156
379226
|
var WorkspaceContext = class {
|
|
379157
379227
|
targetDir;
|
|
379158
379228
|
directories = /* @__PURE__ */ new Set();
|
|
@@ -379209,7 +379279,7 @@ var WorkspaceContext = class {
|
|
|
379209
379279
|
}
|
|
379210
379280
|
}
|
|
379211
379281
|
resolveAndValidateDir(directory) {
|
|
379212
|
-
const absolutePath =
|
|
379282
|
+
const absolutePath = path56.resolve(this.targetDir, directory);
|
|
379213
379283
|
if (!fs56.existsSync(absolutePath)) {
|
|
379214
379284
|
throw new Error(`Directory does not exist: ${absolutePath}`);
|
|
379215
379285
|
}
|
|
@@ -379264,7 +379334,7 @@ var WorkspaceContext = class {
|
|
|
379264
379334
|
*/
|
|
379265
379335
|
fullyResolvedPath(pathToCheck) {
|
|
379266
379336
|
try {
|
|
379267
|
-
return fs56.realpathSync(
|
|
379337
|
+
return fs56.realpathSync(path56.resolve(this.targetDir, pathToCheck));
|
|
379268
379338
|
} catch (e3) {
|
|
379269
379339
|
if (isNodeError(e3) && e3.code === "ENOENT" && e3.path && // realpathSync does not set e.path correctly for symlinks to
|
|
379270
379340
|
// non-existent files.
|
|
@@ -379281,8 +379351,8 @@ var WorkspaceContext = class {
|
|
|
379281
379351
|
* @returns True if the path is within the root directory, false otherwise
|
|
379282
379352
|
*/
|
|
379283
379353
|
isPathWithinRoot(pathToCheck, rootDirectory) {
|
|
379284
|
-
const relative5 =
|
|
379285
|
-
return !relative5.startsWith(`..${
|
|
379354
|
+
const relative5 = path56.relative(rootDirectory, pathToCheck);
|
|
379355
|
+
return !relative5.startsWith(`..${path56.sep}`) && relative5 !== ".." && !path56.isAbsolute(relative5);
|
|
379286
379356
|
}
|
|
379287
379357
|
/**
|
|
379288
379358
|
* Checks if a file path is a symbolic link that points to a file.
|
|
@@ -380709,10 +380779,10 @@ var HookEventHandler = class {
|
|
|
380709
380779
|
* Create base hook input with common fields
|
|
380710
380780
|
*/
|
|
380711
380781
|
createBaseInput(eventName) {
|
|
380782
|
+
const transcriptPath = this.config.getGeminiClient()?.getChatRecordingService()?.getConversationFilePath() ?? "";
|
|
380712
380783
|
return {
|
|
380713
380784
|
session_id: this.config.getSessionId(),
|
|
380714
|
-
transcript_path:
|
|
380715
|
-
// TODO: Implement transcript path when supported
|
|
380785
|
+
transcript_path: transcriptPath,
|
|
380716
380786
|
cwd: this.config.getWorkingDir(),
|
|
380717
380787
|
hook_event_name: eventName,
|
|
380718
380788
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -381025,47 +381095,44 @@ var AgentRegistry = class {
|
|
|
381025
381095
|
getAllDefinitions() {
|
|
381026
381096
|
return Array.from(this.agents.values());
|
|
381027
381097
|
}
|
|
381028
|
-
|
|
381098
|
+
/**
|
|
381099
|
+
* Returns a list of all registered agent names.
|
|
381100
|
+
*/
|
|
381101
|
+
getAllAgentNames() {
|
|
381102
|
+
return Array.from(this.agents.keys());
|
|
381103
|
+
}
|
|
381104
|
+
/**
|
|
381105
|
+
* Generates a description for the delegate_to_agent tool.
|
|
381106
|
+
* Unlike getDirectoryContext() which is for system prompts,
|
|
381107
|
+
* this is formatted for tool descriptions.
|
|
381108
|
+
*/
|
|
381109
|
+
getToolDescription() {
|
|
381110
|
+
if (this.agents.size === 0) {
|
|
381111
|
+
return "Delegates a task to a specialized sub-agent. No agents are currently available.";
|
|
381112
|
+
}
|
|
381113
|
+
const agentDescriptions = Array.from(this.agents.entries()).map(([name4, def2]) => `- **${name4}**: ${def2.description}`).join("\n");
|
|
381114
|
+
return `Delegates a task to a specialized sub-agent.
|
|
381029
381115
|
|
|
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
|
-
}
|
|
381116
|
+
Available agents:
|
|
381117
|
+
${agentDescriptions}`;
|
|
381118
|
+
}
|
|
381119
|
+
/**
|
|
381120
|
+
* Generates a markdown "Phone Book" of available agents and their schemas.
|
|
381121
|
+
* This MUST be injected into the System Prompt of the parent agent.
|
|
381122
|
+
*/
|
|
381123
|
+
getDirectoryContext() {
|
|
381124
|
+
if (this.agents.size === 0) {
|
|
381125
|
+
return "No sub-agents are currently available.";
|
|
381057
381126
|
}
|
|
381058
|
-
|
|
381059
|
-
|
|
381060
|
-
|
|
381127
|
+
let context2 = "## Available Sub-Agents\n";
|
|
381128
|
+
context2 += "Use `delegate_to_agent` for complex tasks requiring specialized analysis.\n\n";
|
|
381129
|
+
for (const [name4, def2] of this.agents.entries()) {
|
|
381130
|
+
context2 += `- **${name4}**: ${def2.description}
|
|
381131
|
+
`;
|
|
381061
381132
|
}
|
|
381133
|
+
return context2;
|
|
381062
381134
|
}
|
|
381063
|
-
|
|
381064
|
-
type: "object",
|
|
381065
|
-
properties,
|
|
381066
|
-
required: required2.length > 0 ? required2 : void 0
|
|
381067
|
-
};
|
|
381068
|
-
}
|
|
381135
|
+
};
|
|
381069
381136
|
|
|
381070
381137
|
// packages/core/dist/src/core/nonInteractiveToolExecutor.js
|
|
381071
381138
|
async function executeToolCall(config3, toolCallRequest, abortSignal) {
|
|
@@ -381847,71 +381914,126 @@ Error: ${errorMessage}`,
|
|
|
381847
381914
|
}
|
|
381848
381915
|
};
|
|
381849
381916
|
|
|
381850
|
-
// packages/core/dist/src/agents/
|
|
381851
|
-
var
|
|
381852
|
-
|
|
381917
|
+
// packages/core/dist/src/agents/delegate-to-agent-tool.js
|
|
381918
|
+
var DelegateToAgentTool = class extends BaseDeclarativeTool {
|
|
381919
|
+
registry;
|
|
381853
381920
|
config;
|
|
381854
|
-
|
|
381855
|
-
|
|
381856
|
-
|
|
381857
|
-
|
|
381858
|
-
|
|
381859
|
-
|
|
381860
|
-
|
|
381861
|
-
|
|
381862
|
-
|
|
381863
|
-
|
|
381864
|
-
|
|
381865
|
-
|
|
381921
|
+
constructor(registry2, config3, messageBus) {
|
|
381922
|
+
const definitions = registry2.getAllDefinitions();
|
|
381923
|
+
let schema;
|
|
381924
|
+
if (definitions.length === 0) {
|
|
381925
|
+
schema = external_exports.object({
|
|
381926
|
+
agent_name: external_exports.string().describe("No agents are currently available.")
|
|
381927
|
+
});
|
|
381928
|
+
} else {
|
|
381929
|
+
const agentSchemas = definitions.map((def2) => {
|
|
381930
|
+
const inputShape = {
|
|
381931
|
+
agent_name: external_exports.literal(def2.name).describe(def2.description)
|
|
381932
|
+
};
|
|
381933
|
+
for (const [key, inputDef] of Object.entries(def2.inputConfig.inputs)) {
|
|
381934
|
+
if (key === "agent_name") {
|
|
381935
|
+
throw new Error(`Agent '${def2.name}' cannot have an input parameter named 'agent_name' as it is a reserved parameter for delegation.`);
|
|
381936
|
+
}
|
|
381937
|
+
let validator;
|
|
381938
|
+
switch (inputDef.type) {
|
|
381939
|
+
case "string":
|
|
381940
|
+
validator = external_exports.string();
|
|
381941
|
+
break;
|
|
381942
|
+
case "number":
|
|
381943
|
+
validator = external_exports.number();
|
|
381944
|
+
break;
|
|
381945
|
+
case "boolean":
|
|
381946
|
+
validator = external_exports.boolean();
|
|
381947
|
+
break;
|
|
381948
|
+
case "integer":
|
|
381949
|
+
validator = external_exports.number().int();
|
|
381950
|
+
break;
|
|
381951
|
+
case "string[]":
|
|
381952
|
+
validator = external_exports.array(external_exports.string());
|
|
381953
|
+
break;
|
|
381954
|
+
case "number[]":
|
|
381955
|
+
validator = external_exports.array(external_exports.number());
|
|
381956
|
+
break;
|
|
381957
|
+
default: {
|
|
381958
|
+
const _exhaustiveCheck = inputDef.type;
|
|
381959
|
+
void _exhaustiveCheck;
|
|
381960
|
+
throw new Error(`Unhandled agent input type: '${inputDef.type}'`);
|
|
381961
|
+
}
|
|
381962
|
+
}
|
|
381963
|
+
if (!inputDef.required) {
|
|
381964
|
+
validator = validator.optional();
|
|
381965
|
+
}
|
|
381966
|
+
inputShape[key] = validator.describe(inputDef.description);
|
|
381967
|
+
}
|
|
381968
|
+
return external_exports.object(inputShape);
|
|
381969
|
+
});
|
|
381970
|
+
if (agentSchemas.length === 1) {
|
|
381971
|
+
schema = agentSchemas[0];
|
|
381972
|
+
} else {
|
|
381973
|
+
schema = external_exports.discriminatedUnion("agent_name", agentSchemas);
|
|
381974
|
+
}
|
|
381975
|
+
}
|
|
381866
381976
|
super(
|
|
381867
|
-
|
|
381868
|
-
|
|
381869
|
-
|
|
381977
|
+
DELEGATE_TO_AGENT_TOOL_NAME,
|
|
381978
|
+
"Delegate to Agent",
|
|
381979
|
+
registry2.getToolDescription(),
|
|
381870
381980
|
Kind.Think,
|
|
381871
|
-
|
|
381981
|
+
zodToJsonSchema(schema),
|
|
381872
381982
|
/* isOutputMarkdown */
|
|
381873
381983
|
true,
|
|
381874
381984
|
/* canUpdateOutput */
|
|
381875
381985
|
true,
|
|
381876
381986
|
messageBus
|
|
381877
381987
|
);
|
|
381878
|
-
this.
|
|
381988
|
+
this.registry = registry2;
|
|
381879
381989
|
this.config = config3;
|
|
381880
381990
|
}
|
|
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
381991
|
createInvocation(params) {
|
|
381891
|
-
return new
|
|
381992
|
+
return new DelegateInvocation(params, this.registry, this.config, this.messageBus);
|
|
381993
|
+
}
|
|
381994
|
+
};
|
|
381995
|
+
var DelegateInvocation = class extends BaseToolInvocation {
|
|
381996
|
+
registry;
|
|
381997
|
+
config;
|
|
381998
|
+
constructor(params, registry2, config3, messageBus) {
|
|
381999
|
+
super(params, messageBus, DELEGATE_TO_AGENT_TOOL_NAME);
|
|
382000
|
+
this.registry = registry2;
|
|
382001
|
+
this.config = config3;
|
|
382002
|
+
}
|
|
382003
|
+
getDescription() {
|
|
382004
|
+
return `Delegating to agent '${this.params.agent_name}'`;
|
|
382005
|
+
}
|
|
382006
|
+
async execute(signal, updateOutput) {
|
|
382007
|
+
const definition = this.registry.getDefinition(this.params.agent_name);
|
|
382008
|
+
if (!definition) {
|
|
382009
|
+
throw new Error(`Agent '${this.params.agent_name}' exists in the tool definition but could not be found in the registry.`);
|
|
382010
|
+
}
|
|
382011
|
+
const { agent_name, ...agentArgs } = this.params;
|
|
382012
|
+
const subagentInvocation = new SubagentInvocation(agentArgs, definition, this.config, this.messageBus);
|
|
382013
|
+
return subagentInvocation.execute(signal, updateOutput);
|
|
381892
382014
|
}
|
|
381893
382015
|
};
|
|
381894
382016
|
|
|
381895
382017
|
// node_modules/read-package-up/index.js
|
|
381896
|
-
import
|
|
382018
|
+
import path59 from "node:path";
|
|
381897
382019
|
|
|
381898
382020
|
// node_modules/find-up-simple/index.js
|
|
381899
382021
|
import process21 from "node:process";
|
|
381900
382022
|
import fsPromises4 from "node:fs/promises";
|
|
381901
382023
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
381902
|
-
import
|
|
382024
|
+
import path57 from "node:path";
|
|
381903
382025
|
var toPath2 = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath8(urlOrPath) : urlOrPath;
|
|
381904
382026
|
async function findUp(name4, {
|
|
381905
382027
|
cwd = process21.cwd(),
|
|
381906
382028
|
type = "file",
|
|
381907
382029
|
stopAt
|
|
381908
382030
|
} = {}) {
|
|
381909
|
-
let directory =
|
|
381910
|
-
const { root } =
|
|
381911
|
-
stopAt =
|
|
381912
|
-
const isAbsoluteName =
|
|
382031
|
+
let directory = path57.resolve(toPath2(cwd) ?? "");
|
|
382032
|
+
const { root } = path57.parse(directory);
|
|
382033
|
+
stopAt = path57.resolve(directory, toPath2(stopAt ?? root));
|
|
382034
|
+
const isAbsoluteName = path57.isAbsolute(name4);
|
|
381913
382035
|
while (directory) {
|
|
381914
|
-
const filePath = isAbsoluteName ? name4 :
|
|
382036
|
+
const filePath = isAbsoluteName ? name4 : path57.join(directory, name4);
|
|
381915
382037
|
try {
|
|
381916
382038
|
const stats = await fsPromises4.stat(filePath);
|
|
381917
382039
|
if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) {
|
|
@@ -381922,13 +382044,13 @@ async function findUp(name4, {
|
|
|
381922
382044
|
if (directory === stopAt || directory === root) {
|
|
381923
382045
|
break;
|
|
381924
382046
|
}
|
|
381925
|
-
directory =
|
|
382047
|
+
directory = path57.dirname(directory);
|
|
381926
382048
|
}
|
|
381927
382049
|
}
|
|
381928
382050
|
|
|
381929
382051
|
// node_modules/read-pkg/index.js
|
|
381930
382052
|
import fsPromises5 from "node:fs/promises";
|
|
381931
|
-
import
|
|
382053
|
+
import path58 from "node:path";
|
|
381932
382054
|
|
|
381933
382055
|
// node_modules/parse-json/index.js
|
|
381934
382056
|
var import_code_frame = __toESM(require_lib12(), 1);
|
|
@@ -382057,7 +382179,7 @@ function toPath3(urlOrPath) {
|
|
|
382057
382179
|
}
|
|
382058
382180
|
|
|
382059
382181
|
// node_modules/read-pkg/index.js
|
|
382060
|
-
var getPackagePath = (cwd) =>
|
|
382182
|
+
var getPackagePath = (cwd) => path58.resolve(toPath3(cwd) ?? ".", "package.json");
|
|
382061
382183
|
var _readPackage = (file, normalize5) => {
|
|
382062
382184
|
const json = typeof file === "string" ? parseJson(file) : file;
|
|
382063
382185
|
if (normalize5) {
|
|
@@ -382077,7 +382199,7 @@ async function readPackageUp(options2) {
|
|
|
382077
382199
|
return;
|
|
382078
382200
|
}
|
|
382079
382201
|
return {
|
|
382080
|
-
packageJson: await readPackage({ ...options2, cwd:
|
|
382202
|
+
packageJson: await readPackage({ ...options2, cwd: path59.dirname(filePath) }),
|
|
382081
382203
|
path: filePath
|
|
382082
382204
|
};
|
|
382083
382205
|
}
|
|
@@ -382118,10 +382240,22 @@ async function getReleaseChannel(cwd) {
|
|
|
382118
382240
|
}
|
|
382119
382241
|
|
|
382120
382242
|
// packages/core/dist/src/code_assist/experiments/client_metadata.js
|
|
382121
|
-
import { fileURLToPath as
|
|
382243
|
+
import { fileURLToPath as fileURLToPath11 } from "node:url";
|
|
382122
382244
|
import path61 from "node:path";
|
|
382245
|
+
|
|
382246
|
+
// packages/core/dist/src/utils/version.js
|
|
382247
|
+
import { fileURLToPath as fileURLToPath10 } from "node:url";
|
|
382248
|
+
import path60 from "node:path";
|
|
382123
382249
|
var __filename = fileURLToPath10(import.meta.url);
|
|
382124
|
-
var __dirname5 =
|
|
382250
|
+
var __dirname5 = path60.dirname(__filename);
|
|
382251
|
+
async function getVersion() {
|
|
382252
|
+
const pkgJson = await getPackageJson(__dirname5);
|
|
382253
|
+
return "0.21.0-nightly.20251212.54de67536";
|
|
382254
|
+
}
|
|
382255
|
+
|
|
382256
|
+
// packages/core/dist/src/code_assist/experiments/client_metadata.js
|
|
382257
|
+
var __filename2 = fileURLToPath11(import.meta.url);
|
|
382258
|
+
var __dirname6 = path61.dirname(__filename2);
|
|
382125
382259
|
var clientMetadataPromise;
|
|
382126
382260
|
function getPlatform() {
|
|
382127
382261
|
const platform11 = process.platform;
|
|
@@ -382148,9 +382282,9 @@ async function getClientMetadata() {
|
|
|
382148
382282
|
clientMetadataPromise = (async () => ({
|
|
382149
382283
|
ideName: "IDE_UNSPECIFIED",
|
|
382150
382284
|
pluginType: "GEMINI",
|
|
382151
|
-
ideVersion:
|
|
382285
|
+
ideVersion: await getVersion(),
|
|
382152
382286
|
platform: getPlatform(),
|
|
382153
|
-
updateChannel: await getReleaseChannel(
|
|
382287
|
+
updateChannel: await getReleaseChannel(__dirname6)
|
|
382154
382288
|
}))();
|
|
382155
382289
|
}
|
|
382156
382290
|
return clientMetadataPromise;
|
|
@@ -383289,7 +383423,7 @@ var ServiceAccountImpersonationProvider = class {
|
|
|
383289
383423
|
};
|
|
383290
383424
|
|
|
383291
383425
|
// packages/core/dist/src/tools/mcp-client.js
|
|
383292
|
-
import { basename as
|
|
383426
|
+
import { basename as basename12 } from "node:path";
|
|
383293
383427
|
import { pathToFileURL } from "node:url";
|
|
383294
383428
|
|
|
383295
383429
|
// packages/core/dist/src/mcp/oauth-provider.js
|
|
@@ -384676,7 +384810,7 @@ async function connectToMcpServer(mcpServerName, mcpServerConfig, debugMode, wor
|
|
|
384676
384810
|
for (const dir of workspaceContext.getDirectories()) {
|
|
384677
384811
|
roots.push({
|
|
384678
384812
|
uri: pathToFileURL(dir).toString(),
|
|
384679
|
-
name:
|
|
384813
|
+
name: basename12(dir)
|
|
384680
384814
|
});
|
|
384681
384815
|
}
|
|
384682
384816
|
return {
|
|
@@ -385417,11 +385551,19 @@ var Config = class {
|
|
|
385417
385551
|
this.geminiClient = new GeminiClient(this);
|
|
385418
385552
|
this.modelRouterService = new ModelRouterService(this);
|
|
385419
385553
|
let modelConfigServiceConfig = params.modelConfigServiceConfig;
|
|
385420
|
-
if (modelConfigServiceConfig
|
|
385421
|
-
modelConfigServiceConfig
|
|
385422
|
-
|
|
385423
|
-
|
|
385424
|
-
|
|
385554
|
+
if (modelConfigServiceConfig) {
|
|
385555
|
+
if (!modelConfigServiceConfig.aliases) {
|
|
385556
|
+
modelConfigServiceConfig = {
|
|
385557
|
+
...modelConfigServiceConfig,
|
|
385558
|
+
aliases: DEFAULT_MODEL_CONFIGS.aliases
|
|
385559
|
+
};
|
|
385560
|
+
}
|
|
385561
|
+
if (!modelConfigServiceConfig.overrides) {
|
|
385562
|
+
modelConfigServiceConfig = {
|
|
385563
|
+
...modelConfigServiceConfig,
|
|
385564
|
+
overrides: DEFAULT_MODEL_CONFIGS.overrides
|
|
385565
|
+
};
|
|
385566
|
+
}
|
|
385425
385567
|
}
|
|
385426
385568
|
this.modelConfigService = new ModelConfigService(modelConfigServiceConfig ?? DEFAULT_MODEL_CONFIGS);
|
|
385427
385569
|
}
|
|
@@ -385464,6 +385606,7 @@ var Config = class {
|
|
|
385464
385606
|
return this.contentGenerator;
|
|
385465
385607
|
}
|
|
385466
385608
|
async refreshAuth(authMethod) {
|
|
385609
|
+
this.modelAvailabilityService.reset();
|
|
385467
385610
|
if (this.contentGeneratorConfig?.authType === AuthType2.USE_GEMINI && authMethod !== AuthType2.USE_GEMINI) {
|
|
385468
385611
|
this.geminiClient.stripThoughtsFromHistory();
|
|
385469
385612
|
}
|
|
@@ -385545,6 +385688,7 @@ var Config = class {
|
|
|
385545
385688
|
coreEvents.emitModelChanged(newModel);
|
|
385546
385689
|
}
|
|
385547
385690
|
this.setFallbackMode(false);
|
|
385691
|
+
this.modelAvailabilityService.reset();
|
|
385548
385692
|
}
|
|
385549
385693
|
getActiveModel() {
|
|
385550
385694
|
return this._activeModel ?? this.model;
|
|
@@ -386088,16 +386232,13 @@ var Config = class {
|
|
|
386088
386232
|
if (this.getUseWriteTodos()) {
|
|
386089
386233
|
registerCoreTool(WriteTodosTool, this);
|
|
386090
386234
|
}
|
|
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
|
-
}
|
|
386235
|
+
if (this.isAgentsEnabled() || this.getCodebaseInvestigatorSettings().enabled) {
|
|
386236
|
+
const allowedTools = this.getAllowedTools();
|
|
386237
|
+
const isAllowed = !allowedTools || allowedTools.includes(DELEGATE_TO_AGENT_TOOL_NAME);
|
|
386238
|
+
if (isAllowed) {
|
|
386239
|
+
const messageBusEnabled = this.getEnableMessageBusIntegration();
|
|
386240
|
+
const delegateTool = new DelegateToAgentTool(this.agentRegistry, this, messageBusEnabled ? this.getMessageBus() : void 0);
|
|
386241
|
+
registry2.registerTool(delegateTool);
|
|
386101
386242
|
}
|
|
386102
386243
|
}
|
|
386103
386244
|
await registry2.discoverAllTools();
|
|
@@ -386224,11 +386365,11 @@ var PolicyFileSchema = external_exports.object({
|
|
|
386224
386365
|
|
|
386225
386366
|
// packages/core/dist/src/policy/config.js
|
|
386226
386367
|
import * as path64 from "node:path";
|
|
386227
|
-
import { fileURLToPath as
|
|
386368
|
+
import { fileURLToPath as fileURLToPath12 } from "node:url";
|
|
386228
386369
|
init_events();
|
|
386229
|
-
var
|
|
386230
|
-
var
|
|
386231
|
-
var DEFAULT_CORE_POLICIES_DIR = path64.join(
|
|
386370
|
+
var __filename3 = fileURLToPath12(import.meta.url);
|
|
386371
|
+
var __dirname7 = path64.dirname(__filename3);
|
|
386372
|
+
var DEFAULT_CORE_POLICIES_DIR = path64.join(__dirname7, "policies");
|
|
386232
386373
|
|
|
386233
386374
|
// packages/core/dist/src/commands/extensions.js
|
|
386234
386375
|
function listExtensions(config3) {
|