@polka-codes/cli-shared 0.9.1 → 0.9.3
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/index.js +1291 -1014
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -13741,333 +13741,6 @@ var require_public_api = __commonJS((exports) => {
|
|
|
13741
13741
|
exports.stringify = stringify;
|
|
13742
13742
|
});
|
|
13743
13743
|
|
|
13744
|
-
// ../../node_modules/ignore/index.js
|
|
13745
|
-
var require_ignore = __commonJS((exports, module) => {
|
|
13746
|
-
function makeArray(subject) {
|
|
13747
|
-
return Array.isArray(subject) ? subject : [subject];
|
|
13748
|
-
}
|
|
13749
|
-
var UNDEFINED = undefined;
|
|
13750
|
-
var EMPTY = "";
|
|
13751
|
-
var SPACE = " ";
|
|
13752
|
-
var ESCAPE = "\\";
|
|
13753
|
-
var REGEX_TEST_BLANK_LINE = /^\s+$/;
|
|
13754
|
-
var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
|
|
13755
|
-
var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
13756
|
-
var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
|
13757
|
-
var REGEX_SPLITALL_CRLF = /\r?\n/g;
|
|
13758
|
-
var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
|
|
13759
|
-
var REGEX_TEST_TRAILING_SLASH = /\/$/;
|
|
13760
|
-
var SLASH = "/";
|
|
13761
|
-
var TMP_KEY_IGNORE = "node-ignore";
|
|
13762
|
-
if (typeof Symbol !== "undefined") {
|
|
13763
|
-
TMP_KEY_IGNORE = Symbol.for("node-ignore");
|
|
13764
|
-
}
|
|
13765
|
-
var KEY_IGNORE = TMP_KEY_IGNORE;
|
|
13766
|
-
var define2 = (object5, key, value) => {
|
|
13767
|
-
Object.defineProperty(object5, key, { value });
|
|
13768
|
-
return value;
|
|
13769
|
-
};
|
|
13770
|
-
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
|
|
13771
|
-
var RETURN_FALSE = () => false;
|
|
13772
|
-
var sanitizeRange = (range) => range.replace(REGEX_REGEXP_RANGE, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY);
|
|
13773
|
-
var cleanRangeBackSlash = (slashes) => {
|
|
13774
|
-
const { length } = slashes;
|
|
13775
|
-
return slashes.slice(0, length - length % 2);
|
|
13776
|
-
};
|
|
13777
|
-
var REPLACERS = [
|
|
13778
|
-
[
|
|
13779
|
-
/^\uFEFF/,
|
|
13780
|
-
() => EMPTY
|
|
13781
|
-
],
|
|
13782
|
-
[
|
|
13783
|
-
/((?:\\\\)*?)(\\?\s+)$/,
|
|
13784
|
-
(_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)
|
|
13785
|
-
],
|
|
13786
|
-
[
|
|
13787
|
-
/(\\+?)\s/g,
|
|
13788
|
-
(_, m1) => {
|
|
13789
|
-
const { length } = m1;
|
|
13790
|
-
return m1.slice(0, length - length % 2) + SPACE;
|
|
13791
|
-
}
|
|
13792
|
-
],
|
|
13793
|
-
[
|
|
13794
|
-
/[\\$.|*+(){^]/g,
|
|
13795
|
-
(match) => `\\${match}`
|
|
13796
|
-
],
|
|
13797
|
-
[
|
|
13798
|
-
/(?!\\)\?/g,
|
|
13799
|
-
() => "[^/]"
|
|
13800
|
-
],
|
|
13801
|
-
[
|
|
13802
|
-
/^\//,
|
|
13803
|
-
() => "^"
|
|
13804
|
-
],
|
|
13805
|
-
[
|
|
13806
|
-
/\//g,
|
|
13807
|
-
() => "\\/"
|
|
13808
|
-
],
|
|
13809
|
-
[
|
|
13810
|
-
/^\^*\\\*\\\*\\\//,
|
|
13811
|
-
() => "^(?:.*\\/)?"
|
|
13812
|
-
],
|
|
13813
|
-
[
|
|
13814
|
-
/^(?=[^^])/,
|
|
13815
|
-
function startingReplacer() {
|
|
13816
|
-
return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^";
|
|
13817
|
-
}
|
|
13818
|
-
],
|
|
13819
|
-
[
|
|
13820
|
-
/\\\/\\\*\\\*(?=\\\/|$)/g,
|
|
13821
|
-
(_, index, str) => index + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+"
|
|
13822
|
-
],
|
|
13823
|
-
[
|
|
13824
|
-
/(^|[^\\]+)(\\\*)+(?=.+)/g,
|
|
13825
|
-
(_, p1, p2) => {
|
|
13826
|
-
const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
|
|
13827
|
-
return p1 + unescaped;
|
|
13828
|
-
}
|
|
13829
|
-
],
|
|
13830
|
-
[
|
|
13831
|
-
/\\\\\\(?=[$.|*+(){^])/g,
|
|
13832
|
-
() => ESCAPE
|
|
13833
|
-
],
|
|
13834
|
-
[
|
|
13835
|
-
/\\\\/g,
|
|
13836
|
-
() => ESCAPE
|
|
13837
|
-
],
|
|
13838
|
-
[
|
|
13839
|
-
/(\\)?\[([^\]/]*?)(\\*)($|\])/g,
|
|
13840
|
-
(match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range)}${endEscape}]` : "[]" : "[]"
|
|
13841
|
-
],
|
|
13842
|
-
[
|
|
13843
|
-
/(?:[^*])$/,
|
|
13844
|
-
(match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)`
|
|
13845
|
-
]
|
|
13846
|
-
];
|
|
13847
|
-
var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\\\*$/;
|
|
13848
|
-
var MODE_IGNORE = "regex";
|
|
13849
|
-
var MODE_CHECK_IGNORE = "checkRegex";
|
|
13850
|
-
var UNDERSCORE = "_";
|
|
13851
|
-
var TRAILING_WILD_CARD_REPLACERS = {
|
|
13852
|
-
[MODE_IGNORE](_, p1) {
|
|
13853
|
-
const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
|
|
13854
|
-
return `${prefix}(?=$|\\/$)`;
|
|
13855
|
-
},
|
|
13856
|
-
[MODE_CHECK_IGNORE](_, p1) {
|
|
13857
|
-
const prefix = p1 ? `${p1}[^/]*` : "[^/]*";
|
|
13858
|
-
return `${prefix}(?=$|\\/$)`;
|
|
13859
|
-
}
|
|
13860
|
-
};
|
|
13861
|
-
var makeRegexPrefix = (pattern) => REPLACERS.reduce((prev, [matcher, replacer]) => prev.replace(matcher, replacer.bind(pattern)), pattern);
|
|
13862
|
-
var isString = (subject) => typeof subject === "string";
|
|
13863
|
-
var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
|
|
13864
|
-
var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
|
|
13865
|
-
|
|
13866
|
-
class IgnoreRule {
|
|
13867
|
-
constructor(pattern, mark, body, ignoreCase, negative, prefix) {
|
|
13868
|
-
this.pattern = pattern;
|
|
13869
|
-
this.mark = mark;
|
|
13870
|
-
this.negative = negative;
|
|
13871
|
-
define2(this, "body", body);
|
|
13872
|
-
define2(this, "ignoreCase", ignoreCase);
|
|
13873
|
-
define2(this, "regexPrefix", prefix);
|
|
13874
|
-
}
|
|
13875
|
-
get regex() {
|
|
13876
|
-
const key = UNDERSCORE + MODE_IGNORE;
|
|
13877
|
-
if (this[key]) {
|
|
13878
|
-
return this[key];
|
|
13879
|
-
}
|
|
13880
|
-
return this._make(MODE_IGNORE, key);
|
|
13881
|
-
}
|
|
13882
|
-
get checkRegex() {
|
|
13883
|
-
const key = UNDERSCORE + MODE_CHECK_IGNORE;
|
|
13884
|
-
if (this[key]) {
|
|
13885
|
-
return this[key];
|
|
13886
|
-
}
|
|
13887
|
-
return this._make(MODE_CHECK_IGNORE, key);
|
|
13888
|
-
}
|
|
13889
|
-
_make(mode, key) {
|
|
13890
|
-
const str = this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD, TRAILING_WILD_CARD_REPLACERS[mode]);
|
|
13891
|
-
const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
|
|
13892
|
-
return define2(this, key, regex);
|
|
13893
|
-
}
|
|
13894
|
-
}
|
|
13895
|
-
var createRule = ({
|
|
13896
|
-
pattern,
|
|
13897
|
-
mark
|
|
13898
|
-
}, ignoreCase) => {
|
|
13899
|
-
let negative = false;
|
|
13900
|
-
let body = pattern;
|
|
13901
|
-
if (body.indexOf("!") === 0) {
|
|
13902
|
-
negative = true;
|
|
13903
|
-
body = body.substr(1);
|
|
13904
|
-
}
|
|
13905
|
-
body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
|
|
13906
|
-
const regexPrefix = makeRegexPrefix(body);
|
|
13907
|
-
return new IgnoreRule(pattern, mark, body, ignoreCase, negative, regexPrefix);
|
|
13908
|
-
};
|
|
13909
|
-
|
|
13910
|
-
class RuleManager {
|
|
13911
|
-
constructor(ignoreCase) {
|
|
13912
|
-
this._ignoreCase = ignoreCase;
|
|
13913
|
-
this._rules = [];
|
|
13914
|
-
}
|
|
13915
|
-
_add(pattern) {
|
|
13916
|
-
if (pattern && pattern[KEY_IGNORE]) {
|
|
13917
|
-
this._rules = this._rules.concat(pattern._rules._rules);
|
|
13918
|
-
this._added = true;
|
|
13919
|
-
return;
|
|
13920
|
-
}
|
|
13921
|
-
if (isString(pattern)) {
|
|
13922
|
-
pattern = {
|
|
13923
|
-
pattern
|
|
13924
|
-
};
|
|
13925
|
-
}
|
|
13926
|
-
if (checkPattern(pattern.pattern)) {
|
|
13927
|
-
const rule = createRule(pattern, this._ignoreCase);
|
|
13928
|
-
this._added = true;
|
|
13929
|
-
this._rules.push(rule);
|
|
13930
|
-
}
|
|
13931
|
-
}
|
|
13932
|
-
add(pattern) {
|
|
13933
|
-
this._added = false;
|
|
13934
|
-
makeArray(isString(pattern) ? splitPattern(pattern) : pattern).forEach(this._add, this);
|
|
13935
|
-
return this._added;
|
|
13936
|
-
}
|
|
13937
|
-
test(path, checkUnignored, mode) {
|
|
13938
|
-
let ignored = false;
|
|
13939
|
-
let unignored = false;
|
|
13940
|
-
let matchedRule;
|
|
13941
|
-
this._rules.forEach((rule) => {
|
|
13942
|
-
const { negative } = rule;
|
|
13943
|
-
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
13944
|
-
return;
|
|
13945
|
-
}
|
|
13946
|
-
const matched = rule[mode].test(path);
|
|
13947
|
-
if (!matched) {
|
|
13948
|
-
return;
|
|
13949
|
-
}
|
|
13950
|
-
ignored = !negative;
|
|
13951
|
-
unignored = negative;
|
|
13952
|
-
matchedRule = negative ? UNDEFINED : rule;
|
|
13953
|
-
});
|
|
13954
|
-
const ret = {
|
|
13955
|
-
ignored,
|
|
13956
|
-
unignored
|
|
13957
|
-
};
|
|
13958
|
-
if (matchedRule) {
|
|
13959
|
-
ret.rule = matchedRule;
|
|
13960
|
-
}
|
|
13961
|
-
return ret;
|
|
13962
|
-
}
|
|
13963
|
-
}
|
|
13964
|
-
var throwError = (message, Ctor) => {
|
|
13965
|
-
throw new Ctor(message);
|
|
13966
|
-
};
|
|
13967
|
-
var checkPath = (path, originalPath, doThrow) => {
|
|
13968
|
-
if (!isString(path)) {
|
|
13969
|
-
return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
13970
|
-
}
|
|
13971
|
-
if (!path) {
|
|
13972
|
-
return doThrow(`path must not be empty`, TypeError);
|
|
13973
|
-
}
|
|
13974
|
-
if (checkPath.isNotRelative(path)) {
|
|
13975
|
-
const r = "`path.relative()`d";
|
|
13976
|
-
return doThrow(`path should be a ${r} string, but got "${originalPath}"`, RangeError);
|
|
13977
|
-
}
|
|
13978
|
-
return true;
|
|
13979
|
-
};
|
|
13980
|
-
var isNotRelative = (path) => REGEX_TEST_INVALID_PATH.test(path);
|
|
13981
|
-
checkPath.isNotRelative = isNotRelative;
|
|
13982
|
-
checkPath.convert = (p) => p;
|
|
13983
|
-
|
|
13984
|
-
class Ignore {
|
|
13985
|
-
constructor({
|
|
13986
|
-
ignorecase = true,
|
|
13987
|
-
ignoreCase = ignorecase,
|
|
13988
|
-
allowRelativePaths = false
|
|
13989
|
-
} = {}) {
|
|
13990
|
-
define2(this, KEY_IGNORE, true);
|
|
13991
|
-
this._rules = new RuleManager(ignoreCase);
|
|
13992
|
-
this._strictPathCheck = !allowRelativePaths;
|
|
13993
|
-
this._initCache();
|
|
13994
|
-
}
|
|
13995
|
-
_initCache() {
|
|
13996
|
-
this._ignoreCache = Object.create(null);
|
|
13997
|
-
this._testCache = Object.create(null);
|
|
13998
|
-
}
|
|
13999
|
-
add(pattern) {
|
|
14000
|
-
if (this._rules.add(pattern)) {
|
|
14001
|
-
this._initCache();
|
|
14002
|
-
}
|
|
14003
|
-
return this;
|
|
14004
|
-
}
|
|
14005
|
-
addPattern(pattern) {
|
|
14006
|
-
return this.add(pattern);
|
|
14007
|
-
}
|
|
14008
|
-
_test(originalPath, cache, checkUnignored, slices) {
|
|
14009
|
-
const path = originalPath && checkPath.convert(originalPath);
|
|
14010
|
-
checkPath(path, originalPath, this._strictPathCheck ? throwError : RETURN_FALSE);
|
|
14011
|
-
return this._t(path, cache, checkUnignored, slices);
|
|
14012
|
-
}
|
|
14013
|
-
checkIgnore(path) {
|
|
14014
|
-
if (!REGEX_TEST_TRAILING_SLASH.test(path)) {
|
|
14015
|
-
return this.test(path);
|
|
14016
|
-
}
|
|
14017
|
-
const slices = path.split(SLASH).filter(Boolean);
|
|
14018
|
-
slices.pop();
|
|
14019
|
-
if (slices.length) {
|
|
14020
|
-
const parent = this._t(slices.join(SLASH) + SLASH, this._testCache, true, slices);
|
|
14021
|
-
if (parent.ignored) {
|
|
14022
|
-
return parent;
|
|
14023
|
-
}
|
|
14024
|
-
}
|
|
14025
|
-
return this._rules.test(path, false, MODE_CHECK_IGNORE);
|
|
14026
|
-
}
|
|
14027
|
-
_t(path, cache, checkUnignored, slices) {
|
|
14028
|
-
if (path in cache) {
|
|
14029
|
-
return cache[path];
|
|
14030
|
-
}
|
|
14031
|
-
if (!slices) {
|
|
14032
|
-
slices = path.split(SLASH).filter(Boolean);
|
|
14033
|
-
}
|
|
14034
|
-
slices.pop();
|
|
14035
|
-
if (!slices.length) {
|
|
14036
|
-
return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE);
|
|
14037
|
-
}
|
|
14038
|
-
const parent = this._t(slices.join(SLASH) + SLASH, cache, checkUnignored, slices);
|
|
14039
|
-
return cache[path] = parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
|
|
14040
|
-
}
|
|
14041
|
-
ignores(path) {
|
|
14042
|
-
return this._test(path, this._ignoreCache, false).ignored;
|
|
14043
|
-
}
|
|
14044
|
-
createFilter() {
|
|
14045
|
-
return (path) => !this.ignores(path);
|
|
14046
|
-
}
|
|
14047
|
-
filter(paths) {
|
|
14048
|
-
return makeArray(paths).filter(this.createFilter());
|
|
14049
|
-
}
|
|
14050
|
-
test(path) {
|
|
14051
|
-
return this._test(path, this._testCache, true);
|
|
14052
|
-
}
|
|
14053
|
-
}
|
|
14054
|
-
var factory = (options) => new Ignore(options);
|
|
14055
|
-
var isPathValid = (path) => checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
|
|
14056
|
-
var setupWindows = () => {
|
|
14057
|
-
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
14058
|
-
checkPath.convert = makePosix;
|
|
14059
|
-
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
14060
|
-
checkPath.isNotRelative = (path) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
|
|
14061
|
-
};
|
|
14062
|
-
if (typeof process !== "undefined" && process.platform === "win32") {
|
|
14063
|
-
setupWindows();
|
|
14064
|
-
}
|
|
14065
|
-
module.exports = factory;
|
|
14066
|
-
factory.default = factory;
|
|
14067
|
-
module.exports.isPathValid = isPathValid;
|
|
14068
|
-
define2(module.exports, Symbol.for("setupWindows"), setupWindows);
|
|
14069
|
-
});
|
|
14070
|
-
|
|
14071
13744
|
// ../../node_modules/yoctocolors-cjs/index.js
|
|
14072
13745
|
var require_yoctocolors_cjs = __commonJS((exports, module) => {
|
|
14073
13746
|
var tty = __require("node:tty");
|
|
@@ -15711,142 +15384,338 @@ var require_ansi_escapes = __commonJS((exports, module) => {
|
|
|
15711
15384
|
};
|
|
15712
15385
|
});
|
|
15713
15386
|
|
|
15714
|
-
//
|
|
15715
|
-
|
|
15716
|
-
|
|
15717
|
-
|
|
15387
|
+
// ../../node_modules/ignore/index.js
|
|
15388
|
+
var require_ignore = __commonJS((exports, module) => {
|
|
15389
|
+
function makeArray(subject) {
|
|
15390
|
+
return Array.isArray(subject) ? subject : [subject];
|
|
15391
|
+
}
|
|
15392
|
+
var UNDEFINED = undefined;
|
|
15393
|
+
var EMPTY = "";
|
|
15394
|
+
var SPACE = " ";
|
|
15395
|
+
var ESCAPE = "\\";
|
|
15396
|
+
var REGEX_TEST_BLANK_LINE = /^\s+$/;
|
|
15397
|
+
var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
|
|
15398
|
+
var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
15399
|
+
var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
|
15400
|
+
var REGEX_SPLITALL_CRLF = /\r?\n/g;
|
|
15401
|
+
var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
|
|
15402
|
+
var REGEX_TEST_TRAILING_SLASH = /\/$/;
|
|
15403
|
+
var SLASH = "/";
|
|
15404
|
+
var TMP_KEY_IGNORE = "node-ignore";
|
|
15405
|
+
if (typeof Symbol !== "undefined") {
|
|
15406
|
+
TMP_KEY_IGNORE = Symbol.for("node-ignore");
|
|
15407
|
+
}
|
|
15408
|
+
var KEY_IGNORE = TMP_KEY_IGNORE;
|
|
15409
|
+
var define2 = (object5, key2, value) => {
|
|
15410
|
+
Object.defineProperty(object5, key2, { value });
|
|
15411
|
+
return value;
|
|
15412
|
+
};
|
|
15413
|
+
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
|
|
15414
|
+
var RETURN_FALSE = () => false;
|
|
15415
|
+
var sanitizeRange = (range) => range.replace(REGEX_REGEXP_RANGE, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY);
|
|
15416
|
+
var cleanRangeBackSlash = (slashes) => {
|
|
15417
|
+
const { length } = slashes;
|
|
15418
|
+
return slashes.slice(0, length - length % 2);
|
|
15419
|
+
};
|
|
15420
|
+
var REPLACERS = [
|
|
15421
|
+
[
|
|
15422
|
+
/^\uFEFF/,
|
|
15423
|
+
() => EMPTY
|
|
15424
|
+
],
|
|
15425
|
+
[
|
|
15426
|
+
/((?:\\\\)*?)(\\?\s+)$/,
|
|
15427
|
+
(_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)
|
|
15428
|
+
],
|
|
15429
|
+
[
|
|
15430
|
+
/(\\+?)\s/g,
|
|
15431
|
+
(_, m1) => {
|
|
15432
|
+
const { length } = m1;
|
|
15433
|
+
return m1.slice(0, length - length % 2) + SPACE;
|
|
15434
|
+
}
|
|
15435
|
+
],
|
|
15436
|
+
[
|
|
15437
|
+
/[\\$.|*+(){^]/g,
|
|
15438
|
+
(match) => `\\${match}`
|
|
15439
|
+
],
|
|
15440
|
+
[
|
|
15441
|
+
/(?!\\)\?/g,
|
|
15442
|
+
() => "[^/]"
|
|
15443
|
+
],
|
|
15444
|
+
[
|
|
15445
|
+
/^\//,
|
|
15446
|
+
() => "^"
|
|
15447
|
+
],
|
|
15448
|
+
[
|
|
15449
|
+
/\//g,
|
|
15450
|
+
() => "\\/"
|
|
15451
|
+
],
|
|
15452
|
+
[
|
|
15453
|
+
/^\^*\\\*\\\*\\\//,
|
|
15454
|
+
() => "^(?:.*\\/)?"
|
|
15455
|
+
],
|
|
15456
|
+
[
|
|
15457
|
+
/^(?=[^^])/,
|
|
15458
|
+
function startingReplacer() {
|
|
15459
|
+
return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^";
|
|
15460
|
+
}
|
|
15461
|
+
],
|
|
15462
|
+
[
|
|
15463
|
+
/\\\/\\\*\\\*(?=\\\/|$)/g,
|
|
15464
|
+
(_, index, str) => index + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+"
|
|
15465
|
+
],
|
|
15466
|
+
[
|
|
15467
|
+
/(^|[^\\]+)(\\\*)+(?=.+)/g,
|
|
15468
|
+
(_, p1, p2) => {
|
|
15469
|
+
const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
|
|
15470
|
+
return p1 + unescaped;
|
|
15471
|
+
}
|
|
15472
|
+
],
|
|
15473
|
+
[
|
|
15474
|
+
/\\\\\\(?=[$.|*+(){^])/g,
|
|
15475
|
+
() => ESCAPE
|
|
15476
|
+
],
|
|
15477
|
+
[
|
|
15478
|
+
/\\\\/g,
|
|
15479
|
+
() => ESCAPE
|
|
15480
|
+
],
|
|
15481
|
+
[
|
|
15482
|
+
/(\\)?\[([^\]/]*?)(\\*)($|\])/g,
|
|
15483
|
+
(match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range)}${endEscape}]` : "[]" : "[]"
|
|
15484
|
+
],
|
|
15485
|
+
[
|
|
15486
|
+
/(?:[^*])$/,
|
|
15487
|
+
(match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)`
|
|
15488
|
+
]
|
|
15489
|
+
];
|
|
15490
|
+
var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\\\*$/;
|
|
15491
|
+
var MODE_IGNORE = "regex";
|
|
15492
|
+
var MODE_CHECK_IGNORE = "checkRegex";
|
|
15493
|
+
var UNDERSCORE = "_";
|
|
15494
|
+
var TRAILING_WILD_CARD_REPLACERS = {
|
|
15495
|
+
[MODE_IGNORE](_, p1) {
|
|
15496
|
+
const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
|
|
15497
|
+
return `${prefix}(?=$|\\/$)`;
|
|
15498
|
+
},
|
|
15499
|
+
[MODE_CHECK_IGNORE](_, p1) {
|
|
15500
|
+
const prefix = p1 ? `${p1}[^/]*` : "[^/]*";
|
|
15501
|
+
return `${prefix}(?=$|\\/$)`;
|
|
15502
|
+
}
|
|
15503
|
+
};
|
|
15504
|
+
var makeRegexPrefix = (pattern) => REPLACERS.reduce((prev, [matcher, replacer]) => prev.replace(matcher, replacer.bind(pattern)), pattern);
|
|
15505
|
+
var isString = (subject) => typeof subject === "string";
|
|
15506
|
+
var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
|
|
15507
|
+
var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
|
|
15718
15508
|
|
|
15719
|
-
|
|
15720
|
-
|
|
15721
|
-
|
|
15722
|
-
|
|
15723
|
-
|
|
15724
|
-
|
|
15725
|
-
|
|
15726
|
-
|
|
15727
|
-
|
|
15728
|
-
|
|
15729
|
-
|
|
15730
|
-
|
|
15731
|
-
|
|
15732
|
-
outputPrice: modelInfo.outputPrice ?? 0,
|
|
15733
|
-
cacheWritesPrice: modelInfo.cacheWritesPrice ?? 0,
|
|
15734
|
-
cacheReadsPrice: modelInfo.cacheReadsPrice ?? 0
|
|
15735
|
-
};
|
|
15509
|
+
class IgnoreRule {
|
|
15510
|
+
constructor(pattern, mark, body, ignoreCase, negative, prefix) {
|
|
15511
|
+
this.pattern = pattern;
|
|
15512
|
+
this.mark = mark;
|
|
15513
|
+
this.negative = negative;
|
|
15514
|
+
define2(this, "body", body);
|
|
15515
|
+
define2(this, "ignoreCase", ignoreCase);
|
|
15516
|
+
define2(this, "regexPrefix", prefix);
|
|
15517
|
+
}
|
|
15518
|
+
get regex() {
|
|
15519
|
+
const key2 = UNDERSCORE + MODE_IGNORE;
|
|
15520
|
+
if (this[key2]) {
|
|
15521
|
+
return this[key2];
|
|
15736
15522
|
}
|
|
15523
|
+
return this._make(MODE_IGNORE, key2);
|
|
15524
|
+
}
|
|
15525
|
+
get checkRegex() {
|
|
15526
|
+
const key2 = UNDERSCORE + MODE_CHECK_IGNORE;
|
|
15527
|
+
if (this[key2]) {
|
|
15528
|
+
return this[key2];
|
|
15529
|
+
}
|
|
15530
|
+
return this._make(MODE_CHECK_IGNORE, key2);
|
|
15531
|
+
}
|
|
15532
|
+
_make(mode, key2) {
|
|
15533
|
+
const str = this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD, TRAILING_WILD_CARD_REPLACERS[mode]);
|
|
15534
|
+
const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
|
|
15535
|
+
return define2(this, key2, regex);
|
|
15737
15536
|
}
|
|
15738
|
-
this.#modelInfos = infos;
|
|
15739
|
-
this.#maxMessages = opts.maxMessages ?? 1000;
|
|
15740
|
-
this.#maxCost = opts.maxCost ?? 100;
|
|
15741
15537
|
}
|
|
15742
|
-
|
|
15743
|
-
|
|
15744
|
-
|
|
15745
|
-
|
|
15746
|
-
|
|
15747
|
-
|
|
15748
|
-
|
|
15749
|
-
|
|
15750
|
-
|
|
15751
|
-
|
|
15752
|
-
|
|
15753
|
-
|
|
15754
|
-
|
|
15755
|
-
|
|
15756
|
-
|
|
15757
|
-
|
|
15758
|
-
|
|
15759
|
-
|
|
15760
|
-
|
|
15761
|
-
|
|
15762
|
-
|
|
15763
|
-
|
|
15538
|
+
var createRule = ({
|
|
15539
|
+
pattern,
|
|
15540
|
+
mark
|
|
15541
|
+
}, ignoreCase) => {
|
|
15542
|
+
let negative = false;
|
|
15543
|
+
let body = pattern;
|
|
15544
|
+
if (body.indexOf("!") === 0) {
|
|
15545
|
+
negative = true;
|
|
15546
|
+
body = body.substr(1);
|
|
15547
|
+
}
|
|
15548
|
+
body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
|
|
15549
|
+
const regexPrefix = makeRegexPrefix(body);
|
|
15550
|
+
return new IgnoreRule(pattern, mark, body, ignoreCase, negative, regexPrefix);
|
|
15551
|
+
};
|
|
15552
|
+
|
|
15553
|
+
class RuleManager {
|
|
15554
|
+
constructor(ignoreCase) {
|
|
15555
|
+
this._ignoreCase = ignoreCase;
|
|
15556
|
+
this._rules = [];
|
|
15557
|
+
}
|
|
15558
|
+
_add(pattern) {
|
|
15559
|
+
if (pattern && pattern[KEY_IGNORE]) {
|
|
15560
|
+
this._rules = this._rules.concat(pattern._rules._rules);
|
|
15561
|
+
this._added = true;
|
|
15562
|
+
return;
|
|
15764
15563
|
}
|
|
15765
|
-
|
|
15766
|
-
|
|
15767
|
-
|
|
15768
|
-
const input = usage.inputTokens ?? 0;
|
|
15769
|
-
const output = usage.outputTokens ?? 0;
|
|
15770
|
-
return {
|
|
15771
|
-
input,
|
|
15772
|
-
output,
|
|
15773
|
-
cachedRead,
|
|
15774
|
-
cost: (output * modelInfo.outputPrice + cacheWrite * modelInfo.inputPrice + cachedRead * modelInfo.cacheReadsPrice) / 1e6
|
|
15564
|
+
if (isString(pattern)) {
|
|
15565
|
+
pattern = {
|
|
15566
|
+
pattern
|
|
15775
15567
|
};
|
|
15776
15568
|
}
|
|
15777
|
-
|
|
15778
|
-
const
|
|
15779
|
-
|
|
15780
|
-
|
|
15781
|
-
return {
|
|
15782
|
-
input,
|
|
15783
|
-
output,
|
|
15784
|
-
cachedRead,
|
|
15785
|
-
cost: (input * modelInfo.inputPrice + output * modelInfo.outputPrice) / 1e6
|
|
15786
|
-
};
|
|
15569
|
+
if (checkPattern(pattern.pattern)) {
|
|
15570
|
+
const rule = createRule(pattern, this._ignoreCase);
|
|
15571
|
+
this._added = true;
|
|
15572
|
+
this._rules.push(rule);
|
|
15787
15573
|
}
|
|
15788
15574
|
}
|
|
15789
|
-
|
|
15790
|
-
|
|
15791
|
-
|
|
15792
|
-
|
|
15793
|
-
|
|
15794
|
-
|
|
15795
|
-
|
|
15796
|
-
|
|
15797
|
-
|
|
15798
|
-
|
|
15799
|
-
|
|
15800
|
-
|
|
15801
|
-
|
|
15802
|
-
|
|
15803
|
-
|
|
15804
|
-
|
|
15805
|
-
|
|
15806
|
-
|
|
15807
|
-
|
|
15808
|
-
|
|
15809
|
-
|
|
15810
|
-
|
|
15811
|
-
|
|
15812
|
-
|
|
15813
|
-
|
|
15814
|
-
|
|
15815
|
-
|
|
15816
|
-
|
|
15817
|
-
|
|
15818
|
-
|
|
15819
|
-
}
|
|
15820
|
-
isLimitExceeded() {
|
|
15821
|
-
const messageCount = this.#maxMessages !== undefined && this.#calls >= this.#maxMessages;
|
|
15822
|
-
const cost = this.#maxCost !== undefined && this.#totals.cost >= this.#maxCost;
|
|
15823
|
-
return {
|
|
15824
|
-
messageCount,
|
|
15825
|
-
maxMessages: this.#maxMessages,
|
|
15826
|
-
cost,
|
|
15827
|
-
maxCost: this.#maxCost,
|
|
15828
|
-
result: messageCount || cost
|
|
15829
|
-
};
|
|
15830
|
-
}
|
|
15831
|
-
checkLimit() {
|
|
15832
|
-
const result = this.isLimitExceeded();
|
|
15833
|
-
if (result.result) {
|
|
15834
|
-
throw new Error(`Usage limit exceeded. Message count: ${result.messageCount}/${result.maxMessages}, cost: ${result.cost}/${result.maxCost}`);
|
|
15575
|
+
add(pattern) {
|
|
15576
|
+
this._added = false;
|
|
15577
|
+
makeArray(isString(pattern) ? splitPattern(pattern) : pattern).forEach(this._add, this);
|
|
15578
|
+
return this._added;
|
|
15579
|
+
}
|
|
15580
|
+
test(path, checkUnignored, mode) {
|
|
15581
|
+
let ignored = false;
|
|
15582
|
+
let unignored = false;
|
|
15583
|
+
let matchedRule;
|
|
15584
|
+
this._rules.forEach((rule) => {
|
|
15585
|
+
const { negative } = rule;
|
|
15586
|
+
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
15587
|
+
return;
|
|
15588
|
+
}
|
|
15589
|
+
const matched = rule[mode].test(path);
|
|
15590
|
+
if (!matched) {
|
|
15591
|
+
return;
|
|
15592
|
+
}
|
|
15593
|
+
ignored = !negative;
|
|
15594
|
+
unignored = negative;
|
|
15595
|
+
matchedRule = negative ? UNDEFINED : rule;
|
|
15596
|
+
});
|
|
15597
|
+
const ret = {
|
|
15598
|
+
ignored,
|
|
15599
|
+
unignored
|
|
15600
|
+
};
|
|
15601
|
+
if (matchedRule) {
|
|
15602
|
+
ret.rule = matchedRule;
|
|
15603
|
+
}
|
|
15604
|
+
return ret;
|
|
15835
15605
|
}
|
|
15836
15606
|
}
|
|
15837
|
-
|
|
15838
|
-
|
|
15839
|
-
}
|
|
15840
|
-
|
|
15841
|
-
|
|
15842
|
-
|
|
15607
|
+
var throwError = (message, Ctor) => {
|
|
15608
|
+
throw new Ctor(message);
|
|
15609
|
+
};
|
|
15610
|
+
var checkPath = (path, originalPath, doThrow) => {
|
|
15611
|
+
if (!isString(path)) {
|
|
15612
|
+
return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
15613
|
+
}
|
|
15614
|
+
if (!path) {
|
|
15615
|
+
return doThrow(`path must not be empty`, TypeError);
|
|
15616
|
+
}
|
|
15617
|
+
if (checkPath.isNotRelative(path)) {
|
|
15618
|
+
const r = "`path.relative()`d";
|
|
15619
|
+
return doThrow(`path should be a ${r} string, but got "${originalPath}"`, RangeError);
|
|
15620
|
+
}
|
|
15621
|
+
return true;
|
|
15622
|
+
};
|
|
15623
|
+
var isNotRelative = (path) => REGEX_TEST_INVALID_PATH.test(path);
|
|
15624
|
+
checkPath.isNotRelative = isNotRelative;
|
|
15625
|
+
checkPath.convert = (p) => p;
|
|
15626
|
+
|
|
15627
|
+
class Ignore {
|
|
15628
|
+
constructor({
|
|
15629
|
+
ignorecase = true,
|
|
15630
|
+
ignoreCase = ignorecase,
|
|
15631
|
+
allowRelativePaths = false
|
|
15632
|
+
} = {}) {
|
|
15633
|
+
define2(this, KEY_IGNORE, true);
|
|
15634
|
+
this._rules = new RuleManager(ignoreCase);
|
|
15635
|
+
this._strictPathCheck = !allowRelativePaths;
|
|
15636
|
+
this._initCache();
|
|
15637
|
+
}
|
|
15638
|
+
_initCache() {
|
|
15639
|
+
this._ignoreCache = Object.create(null);
|
|
15640
|
+
this._testCache = Object.create(null);
|
|
15641
|
+
}
|
|
15642
|
+
add(pattern) {
|
|
15643
|
+
if (this._rules.add(pattern)) {
|
|
15644
|
+
this._initCache();
|
|
15645
|
+
}
|
|
15646
|
+
return this;
|
|
15647
|
+
}
|
|
15648
|
+
addPattern(pattern) {
|
|
15649
|
+
return this.add(pattern);
|
|
15650
|
+
}
|
|
15651
|
+
_test(originalPath, cache, checkUnignored, slices) {
|
|
15652
|
+
const path = originalPath && checkPath.convert(originalPath);
|
|
15653
|
+
checkPath(path, originalPath, this._strictPathCheck ? throwError : RETURN_FALSE);
|
|
15654
|
+
return this._t(path, cache, checkUnignored, slices);
|
|
15655
|
+
}
|
|
15656
|
+
checkIgnore(path) {
|
|
15657
|
+
if (!REGEX_TEST_TRAILING_SLASH.test(path)) {
|
|
15658
|
+
return this.test(path);
|
|
15659
|
+
}
|
|
15660
|
+
const slices = path.split(SLASH).filter(Boolean);
|
|
15661
|
+
slices.pop();
|
|
15662
|
+
if (slices.length) {
|
|
15663
|
+
const parent = this._t(slices.join(SLASH) + SLASH, this._testCache, true, slices);
|
|
15664
|
+
if (parent.ignored) {
|
|
15665
|
+
return parent;
|
|
15666
|
+
}
|
|
15667
|
+
}
|
|
15668
|
+
return this._rules.test(path, false, MODE_CHECK_IGNORE);
|
|
15669
|
+
}
|
|
15670
|
+
_t(path, cache, checkUnignored, slices) {
|
|
15671
|
+
if (path in cache) {
|
|
15672
|
+
return cache[path];
|
|
15673
|
+
}
|
|
15674
|
+
if (!slices) {
|
|
15675
|
+
slices = path.split(SLASH).filter(Boolean);
|
|
15676
|
+
}
|
|
15677
|
+
slices.pop();
|
|
15678
|
+
if (!slices.length) {
|
|
15679
|
+
return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE);
|
|
15680
|
+
}
|
|
15681
|
+
const parent = this._t(slices.join(SLASH) + SLASH, cache, checkUnignored, slices);
|
|
15682
|
+
return cache[path] = parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
|
|
15683
|
+
}
|
|
15684
|
+
ignores(path) {
|
|
15685
|
+
return this._test(path, this._ignoreCache, false).ignored;
|
|
15686
|
+
}
|
|
15687
|
+
createFilter() {
|
|
15688
|
+
return (path) => !this.ignores(path);
|
|
15689
|
+
}
|
|
15690
|
+
filter(paths) {
|
|
15691
|
+
return makeArray(paths).filter(this.createFilter());
|
|
15692
|
+
}
|
|
15693
|
+
test(path) {
|
|
15694
|
+
return this._test(path, this._testCache, true);
|
|
15695
|
+
}
|
|
15843
15696
|
}
|
|
15844
|
-
|
|
15845
|
-
|
|
15846
|
-
|
|
15847
|
-
|
|
15697
|
+
var factory = (options) => new Ignore(options);
|
|
15698
|
+
var isPathValid = (path) => checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
|
|
15699
|
+
var setupWindows = () => {
|
|
15700
|
+
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
15701
|
+
checkPath.convert = makePosix;
|
|
15702
|
+
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
15703
|
+
checkPath.isNotRelative = (path) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
|
|
15704
|
+
};
|
|
15705
|
+
if (typeof process !== "undefined" && process.platform === "win32") {
|
|
15706
|
+
setupWindows();
|
|
15848
15707
|
}
|
|
15849
|
-
|
|
15708
|
+
module.exports = factory;
|
|
15709
|
+
factory.default = factory;
|
|
15710
|
+
module.exports.isPathValid = isPathValid;
|
|
15711
|
+
define2(module.exports, Symbol.for("setupWindows"), setupWindows);
|
|
15712
|
+
});
|
|
15713
|
+
|
|
15714
|
+
// src/config.ts
|
|
15715
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
15716
|
+
import { homedir } from "node:os";
|
|
15717
|
+
import { join } from "node:path";
|
|
15718
|
+
|
|
15850
15719
|
// ../core/src/tools/allTools.ts
|
|
15851
15720
|
var exports_allTools = {};
|
|
15852
15721
|
__export(exports_allTools, {
|
|
@@ -26920,35 +26789,27 @@ var toolInfo = {
|
|
|
26920
26789
|
description: "Call this when vital details are missing. Pose each follow-up as one direct, unambiguous question. If it speeds the reply, add up to five short, mutually-exclusive answer options. Group any related questions in the same call to avoid a back-and-forth chain.",
|
|
26921
26790
|
parameters: exports_external.object({
|
|
26922
26791
|
questions: exports_external.array(questionObject).describe("One or more follow-up questions you need answered before you can continue.").meta({ usageValue: "questions here" })
|
|
26923
|
-
})
|
|
26924
|
-
|
|
26925
|
-
|
|
26926
|
-
|
|
26927
|
-
|
|
26928
|
-
|
|
26929
|
-
name: "questions",
|
|
26930
|
-
value: { prompt: "What is the target deployment environment?" }
|
|
26792
|
+
}).meta({
|
|
26793
|
+
examples: [
|
|
26794
|
+
{
|
|
26795
|
+
description: "Single clarifying question (no options)",
|
|
26796
|
+
input: {
|
|
26797
|
+
questions: { prompt: "What is the target deployment environment?" }
|
|
26931
26798
|
}
|
|
26932
|
-
|
|
26933
|
-
|
|
26934
|
-
|
|
26935
|
-
|
|
26936
|
-
|
|
26937
|
-
{
|
|
26938
|
-
name: "questions",
|
|
26939
|
-
value: {
|
|
26799
|
+
},
|
|
26800
|
+
{
|
|
26801
|
+
description: "Single question with multiple-choice options",
|
|
26802
|
+
input: {
|
|
26803
|
+
questions: {
|
|
26940
26804
|
prompt: "Which frontend framework are you using?",
|
|
26941
26805
|
options: ["React", "Angular", "Vue", "Svelte"]
|
|
26942
26806
|
}
|
|
26943
26807
|
}
|
|
26944
|
-
|
|
26945
|
-
|
|
26946
|
-
|
|
26947
|
-
|
|
26948
|
-
|
|
26949
|
-
{
|
|
26950
|
-
name: "questions",
|
|
26951
|
-
value: [
|
|
26808
|
+
},
|
|
26809
|
+
{
|
|
26810
|
+
description: "Two related questions in one call",
|
|
26811
|
+
input: {
|
|
26812
|
+
questions: [
|
|
26952
26813
|
{ prompt: "What type of application are you building?" },
|
|
26953
26814
|
{
|
|
26954
26815
|
prompt: "Preferred programming language?",
|
|
@@ -26956,21 +26817,18 @@ var toolInfo = {
|
|
|
26956
26817
|
}
|
|
26957
26818
|
]
|
|
26958
26819
|
}
|
|
26959
|
-
|
|
26960
|
-
|
|
26961
|
-
|
|
26962
|
-
|
|
26963
|
-
|
|
26964
|
-
{
|
|
26965
|
-
name: "questions",
|
|
26966
|
-
value: {
|
|
26820
|
+
},
|
|
26821
|
+
{
|
|
26822
|
+
description: "Binary (yes/no) confirmation",
|
|
26823
|
+
input: {
|
|
26824
|
+
questions: {
|
|
26967
26825
|
prompt: "Is it acceptable to refactor existing tests to improve performance?",
|
|
26968
26826
|
options: ["Yes", "No"]
|
|
26969
26827
|
}
|
|
26970
26828
|
}
|
|
26971
|
-
|
|
26972
|
-
|
|
26973
|
-
|
|
26829
|
+
}
|
|
26830
|
+
]
|
|
26831
|
+
}),
|
|
26974
26832
|
permissionLevel: 0 /* None */
|
|
26975
26833
|
};
|
|
26976
26834
|
var handler = async (provider, args) => {
|
|
@@ -27015,18 +26873,16 @@ var toolInfo2 = {
|
|
|
27015
26873
|
description: "Use this tool when you believe the user’s requested task is complete. Indicate that your work is finished, but acknowledge the user may still provide additional instructions or questions if they want to continue. This tool MUST NOT to be used with any other tool.",
|
|
27016
26874
|
parameters: exports_external.object({
|
|
27017
26875
|
result: exports_external.string().describe("The result of the task. Formulate this result in a way that is final and does not require further input from the user. Don't end your result with questions or offers for further assistance.").meta({ usageValue: "Your final result description here" })
|
|
27018
|
-
})
|
|
27019
|
-
|
|
27020
|
-
|
|
27021
|
-
|
|
27022
|
-
|
|
27023
|
-
|
|
27024
|
-
name: "result",
|
|
27025
|
-
value: "Your final result description here"
|
|
26876
|
+
}).meta({
|
|
26877
|
+
examples: [
|
|
26878
|
+
{
|
|
26879
|
+
description: "Request to present the result of the task",
|
|
26880
|
+
input: {
|
|
26881
|
+
result: "Your final result description here"
|
|
27026
26882
|
}
|
|
27027
|
-
|
|
27028
|
-
|
|
27029
|
-
|
|
26883
|
+
}
|
|
26884
|
+
]
|
|
26885
|
+
}),
|
|
27030
26886
|
permissionLevel: 0 /* None */
|
|
27031
26887
|
};
|
|
27032
26888
|
var handler2 = async (provider, args) => {
|
|
@@ -27050,7 +26906,7 @@ var handler2 = async (provider, args) => {
|
|
|
27050
26906
|
message: `<user_message>${moreMessage}</user_message>`
|
|
27051
26907
|
};
|
|
27052
26908
|
};
|
|
27053
|
-
var isAvailable2 = (
|
|
26909
|
+
var isAvailable2 = (_provider) => {
|
|
27054
26910
|
return true;
|
|
27055
26911
|
};
|
|
27056
26912
|
var attemptCompletion_default = {
|
|
@@ -27072,30 +26928,19 @@ var toolInfo3 = {
|
|
|
27072
26928
|
const values = Array.isArray(val) ? val : [val];
|
|
27073
26929
|
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
27074
26930
|
}, exports_external.array(exports_external.string())).optional().describe("The files relevant to the task. Comma separated paths").meta({ usageValue: "Relevant files" })
|
|
27075
|
-
})
|
|
27076
|
-
|
|
27077
|
-
|
|
27078
|
-
|
|
27079
|
-
|
|
27080
|
-
|
|
27081
|
-
|
|
27082
|
-
|
|
27083
|
-
|
|
27084
|
-
{
|
|
27085
|
-
name: "task",
|
|
27086
|
-
value: "Analyze the authentication implementation"
|
|
27087
|
-
},
|
|
27088
|
-
{
|
|
27089
|
-
name: "context",
|
|
27090
|
-
value: "Need to understand the security implications of the current auth system"
|
|
27091
|
-
},
|
|
27092
|
-
{
|
|
27093
|
-
name: "files",
|
|
27094
|
-
value: "src/auth/login.ts,src/auth/types.ts"
|
|
26931
|
+
}).meta({
|
|
26932
|
+
examples: [
|
|
26933
|
+
{
|
|
26934
|
+
description: "Delegate a code analysis task to the analyzer agent",
|
|
26935
|
+
input: {
|
|
26936
|
+
agentName: "analyzer",
|
|
26937
|
+
task: "Analyze the authentication implementation",
|
|
26938
|
+
context: "Need to understand the security implications of the current auth system",
|
|
26939
|
+
files: "src/auth/login.ts,src/auth/types.ts"
|
|
27095
26940
|
}
|
|
27096
|
-
|
|
27097
|
-
|
|
27098
|
-
|
|
26941
|
+
}
|
|
26942
|
+
]
|
|
26943
|
+
}),
|
|
27099
26944
|
permissionLevel: 0 /* None */
|
|
27100
26945
|
};
|
|
27101
26946
|
var handler3 = async (_provider, args) => {
|
|
@@ -27139,16 +26984,17 @@ var toolInfo4 = {
|
|
|
27139
26984
|
}
|
|
27140
26985
|
return val;
|
|
27141
26986
|
}, exports_external.boolean().optional().default(false)).describe("Set to `true` for commands that install/uninstall software, modify or delete files, change system settings, perform network operations, or have other side effects. Use `false` for safe, read-only, or purely local development actions (e.g., listing files, make a build, running tests).").meta({ usageValue: "true | false" })
|
|
26987
|
+
}).meta({
|
|
26988
|
+
examples: [
|
|
26989
|
+
{
|
|
26990
|
+
description: "Make a build",
|
|
26991
|
+
input: {
|
|
26992
|
+
command: "npm run build",
|
|
26993
|
+
requiresApproval: "false"
|
|
26994
|
+
}
|
|
26995
|
+
}
|
|
26996
|
+
]
|
|
27142
26997
|
}),
|
|
27143
|
-
examples: [
|
|
27144
|
-
{
|
|
27145
|
-
description: "Make a build",
|
|
27146
|
-
parameters: [
|
|
27147
|
-
{ name: "command", value: "npm run build" },
|
|
27148
|
-
{ name: "requiresApproval", value: "false" }
|
|
27149
|
-
]
|
|
27150
|
-
}
|
|
27151
|
-
],
|
|
27152
26998
|
permissionLevel: 3 /* Arbitrary */
|
|
27153
26999
|
};
|
|
27154
27000
|
var handler4 = async (provider, args) => {
|
|
@@ -27206,36 +27052,28 @@ var toolInfo5 = {
|
|
|
27206
27052
|
const values = Array.isArray(val) ? val : [val];
|
|
27207
27053
|
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
27208
27054
|
}, exports_external.array(exports_external.string())).describe("One or more URLs to fetch, separated by commas if multiple.").meta({ usageValue: "url" })
|
|
27209
|
-
})
|
|
27210
|
-
|
|
27211
|
-
|
|
27212
|
-
|
|
27213
|
-
|
|
27214
|
-
|
|
27215
|
-
name: "url",
|
|
27216
|
-
value: "https://example.com"
|
|
27055
|
+
}).meta({
|
|
27056
|
+
examples: [
|
|
27057
|
+
{
|
|
27058
|
+
description: "Fetch a single webpage",
|
|
27059
|
+
input: {
|
|
27060
|
+
url: "https://example.com"
|
|
27217
27061
|
}
|
|
27218
|
-
|
|
27219
|
-
|
|
27220
|
-
|
|
27221
|
-
|
|
27222
|
-
|
|
27223
|
-
{
|
|
27224
|
-
name: "url",
|
|
27225
|
-
value: "https://example.com,https://developer.mozilla.org/en-US/docs/Web/HTTP"
|
|
27062
|
+
},
|
|
27063
|
+
{
|
|
27064
|
+
description: "Fetch multiple webpages",
|
|
27065
|
+
input: {
|
|
27066
|
+
url: "https://example.com,https://developer.mozilla.org/en-US/docs/Web/HTTP"
|
|
27226
27067
|
}
|
|
27227
|
-
|
|
27228
|
-
|
|
27229
|
-
|
|
27230
|
-
|
|
27231
|
-
|
|
27232
|
-
{
|
|
27233
|
-
name: "url",
|
|
27234
|
-
value: "https://raw.githubusercontent.com/user/repo/main/README.md"
|
|
27068
|
+
},
|
|
27069
|
+
{
|
|
27070
|
+
description: "Fetch a raw file from GitHub",
|
|
27071
|
+
input: {
|
|
27072
|
+
url: "https://raw.githubusercontent.com/user/repo/main/README.md"
|
|
27235
27073
|
}
|
|
27236
|
-
|
|
27237
|
-
|
|
27238
|
-
|
|
27074
|
+
}
|
|
27075
|
+
]
|
|
27076
|
+
}),
|
|
27239
27077
|
permissionLevel: 1 /* Read */
|
|
27240
27078
|
};
|
|
27241
27079
|
var handler5 = async (provider, args) => {
|
|
@@ -27277,8 +27115,62 @@ var fetchUrl_default = {
|
|
|
27277
27115
|
handler: handler5,
|
|
27278
27116
|
isAvailable: isAvailable5
|
|
27279
27117
|
};
|
|
27280
|
-
// ../core/src/tools/
|
|
27118
|
+
// ../core/src/tools/handOver.ts
|
|
27281
27119
|
var toolInfo6 = {
|
|
27120
|
+
name: "hand_over",
|
|
27121
|
+
description: "Hand over the current task to another agent to complete. This tool MUST NOT to be used with any other tool.",
|
|
27122
|
+
parameters: exports_external.object({
|
|
27123
|
+
agentName: exports_external.string().describe("The name of the agent to hand over the task to").meta({ usageValue: "Name of the target agent" }),
|
|
27124
|
+
task: exports_external.string().describe("The task to be completed by the target agent").meta({ usageValue: "Task description" }),
|
|
27125
|
+
context: exports_external.string().describe("The context information for the task").meta({ usageValue: "Context information" }),
|
|
27126
|
+
files: exports_external.preprocess((val) => {
|
|
27127
|
+
if (!val)
|
|
27128
|
+
return [];
|
|
27129
|
+
const values = Array.isArray(val) ? val : [val];
|
|
27130
|
+
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
27131
|
+
}, exports_external.array(exports_external.string())).optional().describe("The files relevant to the task. Comma separated paths").meta({ usageValue: "Relevant files" })
|
|
27132
|
+
}).meta({
|
|
27133
|
+
examples: [
|
|
27134
|
+
{
|
|
27135
|
+
description: "Hand over a coding task to the coder agent",
|
|
27136
|
+
input: {
|
|
27137
|
+
agentName: "coder",
|
|
27138
|
+
task: "Implement the login feature",
|
|
27139
|
+
context: "We need a secure login system with email and password",
|
|
27140
|
+
files: "src/auth/login.ts,src/auth/types.ts"
|
|
27141
|
+
}
|
|
27142
|
+
}
|
|
27143
|
+
]
|
|
27144
|
+
}),
|
|
27145
|
+
permissionLevel: 0 /* None */
|
|
27146
|
+
};
|
|
27147
|
+
var handler6 = async (_provider, args) => {
|
|
27148
|
+
const parsed = toolInfo6.parameters.safeParse(args);
|
|
27149
|
+
if (!parsed.success) {
|
|
27150
|
+
return {
|
|
27151
|
+
type: "Invalid" /* Invalid */,
|
|
27152
|
+
message: `Invalid arguments for hand_over: ${parsed.error.message}`
|
|
27153
|
+
};
|
|
27154
|
+
}
|
|
27155
|
+
const { agentName, task, context, files } = parsed.data;
|
|
27156
|
+
return {
|
|
27157
|
+
type: "HandOver" /* HandOver */,
|
|
27158
|
+
agentName,
|
|
27159
|
+
task,
|
|
27160
|
+
context,
|
|
27161
|
+
files: files ?? []
|
|
27162
|
+
};
|
|
27163
|
+
};
|
|
27164
|
+
var isAvailable6 = (_provider) => {
|
|
27165
|
+
return true;
|
|
27166
|
+
};
|
|
27167
|
+
var handOver_default = {
|
|
27168
|
+
...toolInfo6,
|
|
27169
|
+
handler: handler6,
|
|
27170
|
+
isAvailable: isAvailable6
|
|
27171
|
+
};
|
|
27172
|
+
// ../core/src/tools/listFiles.ts
|
|
27173
|
+
var toolInfo7 = {
|
|
27282
27174
|
name: "list_files",
|
|
27283
27175
|
description: "Request to list files and directories within the specified directory. If recursive is true, it will list all files and directories recursively. If recursive is false or not provided, it will only list the top-level contents. Do not use this tool to confirm the existence of files you may have created, as the user will let you know if the files were created successfully or not.",
|
|
27284
27176
|
parameters: exports_external.object({
|
|
@@ -27294,32 +27186,27 @@ var toolInfo6 = {
|
|
|
27294
27186
|
}
|
|
27295
27187
|
return val;
|
|
27296
27188
|
}, exports_external.boolean().optional().default(true)).describe("Whether to list files recursively. Use true for recursive listing, false or omit for top-level only.").meta({ usageValue: "true or false (optional)" })
|
|
27297
|
-
})
|
|
27298
|
-
|
|
27299
|
-
|
|
27300
|
-
|
|
27301
|
-
|
|
27302
|
-
|
|
27303
|
-
|
|
27304
|
-
value: "src"
|
|
27305
|
-
},
|
|
27306
|
-
{
|
|
27307
|
-
name: "maxCount",
|
|
27308
|
-
value: "100"
|
|
27189
|
+
}).meta({
|
|
27190
|
+
examples: [
|
|
27191
|
+
{
|
|
27192
|
+
description: "Request to list files",
|
|
27193
|
+
input: {
|
|
27194
|
+
path: "src",
|
|
27195
|
+
maxCount: "100"
|
|
27309
27196
|
}
|
|
27310
|
-
|
|
27311
|
-
|
|
27312
|
-
|
|
27197
|
+
}
|
|
27198
|
+
]
|
|
27199
|
+
}),
|
|
27313
27200
|
permissionLevel: 1 /* Read */
|
|
27314
27201
|
};
|
|
27315
|
-
var
|
|
27202
|
+
var handler7 = async (provider, args) => {
|
|
27316
27203
|
if (!provider.listFiles) {
|
|
27317
27204
|
return {
|
|
27318
27205
|
type: "Error" /* Error */,
|
|
27319
27206
|
message: "Not possible to list files. Abort."
|
|
27320
27207
|
};
|
|
27321
27208
|
}
|
|
27322
|
-
const { path, maxCount, recursive } =
|
|
27209
|
+
const { path, maxCount, recursive } = toolInfo7.parameters.parse(args);
|
|
27323
27210
|
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount);
|
|
27324
27211
|
return {
|
|
27325
27212
|
type: "Reply" /* Reply */,
|
|
@@ -27331,16 +27218,16 @@ ${files.join(`
|
|
|
27331
27218
|
<list_files_truncated>${limitReached}</list_files_truncated>`
|
|
27332
27219
|
};
|
|
27333
27220
|
};
|
|
27334
|
-
var
|
|
27221
|
+
var isAvailable7 = (provider) => {
|
|
27335
27222
|
return !!provider.listFiles;
|
|
27336
27223
|
};
|
|
27337
27224
|
var listFiles_default = {
|
|
27338
|
-
...
|
|
27339
|
-
handler:
|
|
27340
|
-
isAvailable:
|
|
27225
|
+
...toolInfo7,
|
|
27226
|
+
handler: handler7,
|
|
27227
|
+
isAvailable: isAvailable7
|
|
27341
27228
|
};
|
|
27342
27229
|
// ../core/src/tools/readFile.ts
|
|
27343
|
-
var
|
|
27230
|
+
var toolInfo8 = {
|
|
27344
27231
|
name: "read_file",
|
|
27345
27232
|
description: "Request to read the contents of one or multiple files at the specified paths. Use comma separated paths to read multiple files. Use this when you need to examine the contents of an existing file you do not know the contents of, for example to analyze code, review text files, or extract information from configuration files. May not be suitable for other types of binary files, as it returns the raw content as a string. Try to list all the potential files are relevent to the task, and then use this tool to read all the relevant files.",
|
|
27346
27233
|
parameters: exports_external.object({
|
|
@@ -27350,37 +27237,32 @@ var toolInfo7 = {
|
|
|
27350
27237
|
const values = Array.isArray(val) ? val : [val];
|
|
27351
27238
|
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
27352
27239
|
}, exports_external.array(exports_external.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" })
|
|
27353
|
-
})
|
|
27354
|
-
|
|
27355
|
-
|
|
27356
|
-
|
|
27357
|
-
|
|
27358
|
-
|
|
27359
|
-
name: "path",
|
|
27360
|
-
value: "src/main.js"
|
|
27240
|
+
}).meta({
|
|
27241
|
+
examples: [
|
|
27242
|
+
{
|
|
27243
|
+
description: "Request to read the contents of a file",
|
|
27244
|
+
input: {
|
|
27245
|
+
path: "src/main.js"
|
|
27361
27246
|
}
|
|
27362
|
-
|
|
27363
|
-
|
|
27364
|
-
|
|
27365
|
-
|
|
27366
|
-
|
|
27367
|
-
{
|
|
27368
|
-
name: "path",
|
|
27369
|
-
value: "src/main.js,src/index.js"
|
|
27247
|
+
},
|
|
27248
|
+
{
|
|
27249
|
+
description: "Request to read multiple files",
|
|
27250
|
+
input: {
|
|
27251
|
+
path: "src/main.js,src/index.js"
|
|
27370
27252
|
}
|
|
27371
|
-
|
|
27372
|
-
|
|
27373
|
-
|
|
27253
|
+
}
|
|
27254
|
+
]
|
|
27255
|
+
}),
|
|
27374
27256
|
permissionLevel: 1 /* Read */
|
|
27375
27257
|
};
|
|
27376
|
-
var
|
|
27258
|
+
var handler8 = async (provider, args) => {
|
|
27377
27259
|
if (!provider.readFile) {
|
|
27378
27260
|
return {
|
|
27379
27261
|
type: "Error" /* Error */,
|
|
27380
27262
|
message: "Not possible to read file. Abort."
|
|
27381
27263
|
};
|
|
27382
27264
|
}
|
|
27383
|
-
const { path: paths } =
|
|
27265
|
+
const { path: paths } = toolInfo8.parameters.parse(args);
|
|
27384
27266
|
const resp = [];
|
|
27385
27267
|
for (const path of paths) {
|
|
27386
27268
|
const fileContent = await provider.readFile(path);
|
|
@@ -27401,13 +27283,102 @@ var handler7 = async (provider, args) => {
|
|
|
27401
27283
|
`)
|
|
27402
27284
|
};
|
|
27403
27285
|
};
|
|
27404
|
-
var
|
|
27286
|
+
var isAvailable8 = (provider) => {
|
|
27405
27287
|
return !!provider.readFile;
|
|
27406
27288
|
};
|
|
27407
27289
|
var readFile_default = {
|
|
27408
|
-
...
|
|
27409
|
-
handler:
|
|
27410
|
-
isAvailable:
|
|
27290
|
+
...toolInfo8,
|
|
27291
|
+
handler: handler8,
|
|
27292
|
+
isAvailable: isAvailable8
|
|
27293
|
+
};
|
|
27294
|
+
// ../core/src/tools/removeFile.ts
|
|
27295
|
+
var toolInfo9 = {
|
|
27296
|
+
name: "remove_file",
|
|
27297
|
+
description: "Request to remove a file at the specified path.",
|
|
27298
|
+
parameters: exports_external.object({
|
|
27299
|
+
path: exports_external.string().describe("The path of the file to remove").meta({ usageValue: "File path here" })
|
|
27300
|
+
}).meta({
|
|
27301
|
+
examples: [
|
|
27302
|
+
{
|
|
27303
|
+
description: "Request to remove a file",
|
|
27304
|
+
input: {
|
|
27305
|
+
path: "src/main.js"
|
|
27306
|
+
}
|
|
27307
|
+
}
|
|
27308
|
+
]
|
|
27309
|
+
}),
|
|
27310
|
+
permissionLevel: 2 /* Write */
|
|
27311
|
+
};
|
|
27312
|
+
var handler9 = async (provider, args) => {
|
|
27313
|
+
if (!provider.removeFile) {
|
|
27314
|
+
return {
|
|
27315
|
+
type: "Error" /* Error */,
|
|
27316
|
+
message: "Not possible to remove file. Abort."
|
|
27317
|
+
};
|
|
27318
|
+
}
|
|
27319
|
+
const parsed = toolInfo9.parameters.safeParse(args);
|
|
27320
|
+
if (!parsed.success) {
|
|
27321
|
+
return {
|
|
27322
|
+
type: "Invalid" /* Invalid */,
|
|
27323
|
+
message: `Invalid arguments for remove_file: ${parsed.error.message}`
|
|
27324
|
+
};
|
|
27325
|
+
}
|
|
27326
|
+
const { path } = parsed.data;
|
|
27327
|
+
await provider.removeFile(path);
|
|
27328
|
+
return {
|
|
27329
|
+
type: "Reply" /* Reply */,
|
|
27330
|
+
message: `<remove_file_path>${path}</remove_file_path><status>Success</status>`
|
|
27331
|
+
};
|
|
27332
|
+
};
|
|
27333
|
+
var isAvailable9 = (provider) => {
|
|
27334
|
+
return !!provider.removeFile;
|
|
27335
|
+
};
|
|
27336
|
+
var removeFile_default = {
|
|
27337
|
+
...toolInfo9,
|
|
27338
|
+
handler: handler9,
|
|
27339
|
+
isAvailable: isAvailable9
|
|
27340
|
+
};
|
|
27341
|
+
// ../core/src/tools/renameFile.ts
|
|
27342
|
+
var toolInfo10 = {
|
|
27343
|
+
name: "rename_file",
|
|
27344
|
+
description: "Request to rename a file from source path to target path.",
|
|
27345
|
+
parameters: exports_external.object({
|
|
27346
|
+
source_path: exports_external.string().describe("The current path of the file").meta({ usageValue: "Source file path here" }),
|
|
27347
|
+
target_path: exports_external.string().describe("The new path for the file").meta({ usageValue: "Target file path here" })
|
|
27348
|
+
}).meta({
|
|
27349
|
+
examples: [
|
|
27350
|
+
{
|
|
27351
|
+
description: "Request to rename a file",
|
|
27352
|
+
input: {
|
|
27353
|
+
source_path: "src/old-name.js",
|
|
27354
|
+
target_path: "src/new-name.js"
|
|
27355
|
+
}
|
|
27356
|
+
}
|
|
27357
|
+
]
|
|
27358
|
+
}),
|
|
27359
|
+
permissionLevel: 2 /* Write */
|
|
27360
|
+
};
|
|
27361
|
+
var handler10 = async (provider, args) => {
|
|
27362
|
+
if (!provider.renameFile) {
|
|
27363
|
+
return {
|
|
27364
|
+
type: "Error" /* Error */,
|
|
27365
|
+
message: "Not possible to rename file. Abort."
|
|
27366
|
+
};
|
|
27367
|
+
}
|
|
27368
|
+
const { source_path, target_path } = toolInfo10.parameters.parse(args);
|
|
27369
|
+
await provider.renameFile(source_path, target_path);
|
|
27370
|
+
return {
|
|
27371
|
+
type: "Reply" /* Reply */,
|
|
27372
|
+
message: `<rename_file_path>${target_path}</rename_file_path><status>Success</status>`
|
|
27373
|
+
};
|
|
27374
|
+
};
|
|
27375
|
+
var isAvailable10 = (provider) => {
|
|
27376
|
+
return !!provider.renameFile;
|
|
27377
|
+
};
|
|
27378
|
+
var renameFile_default = {
|
|
27379
|
+
...toolInfo10,
|
|
27380
|
+
handler: handler10,
|
|
27381
|
+
isAvailable: isAvailable10
|
|
27411
27382
|
};
|
|
27412
27383
|
// ../core/src/tools/utils/replaceInFile.ts
|
|
27413
27384
|
var replaceInFile = (fileContent, diff) => {
|
|
@@ -27484,7 +27455,7 @@ var replaceInFile = (fileContent, diff) => {
|
|
|
27484
27455
|
};
|
|
27485
27456
|
|
|
27486
27457
|
// ../core/src/tools/replaceInFile.ts
|
|
27487
|
-
var
|
|
27458
|
+
var toolInfo11 = {
|
|
27488
27459
|
name: "replace_in_file",
|
|
27489
27460
|
description: "Request to replace sections of content in an existing file using SEARCH/REPLACE blocks that define exact changes to specific parts of the file. This tool should be used when you need to make targeted changes to specific parts of a file.",
|
|
27490
27461
|
parameters: exports_external.object({
|
|
@@ -27513,18 +27484,13 @@ Critical rules:
|
|
|
27513
27484
|
4. Special operations:
|
|
27514
27485
|
* To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
|
|
27515
27486
|
* To delete code: Use empty REPLACE section`).meta({ usageValue: "Search and replace blocks here" })
|
|
27516
|
-
})
|
|
27517
|
-
|
|
27518
|
-
|
|
27519
|
-
|
|
27520
|
-
|
|
27521
|
-
|
|
27522
|
-
|
|
27523
|
-
value: "src/main.js"
|
|
27524
|
-
},
|
|
27525
|
-
{
|
|
27526
|
-
name: "diff",
|
|
27527
|
-
value: `<<<<<<< SEARCH
|
|
27487
|
+
}).meta({
|
|
27488
|
+
examples: [
|
|
27489
|
+
{
|
|
27490
|
+
description: "Request to replace sections of content in a file",
|
|
27491
|
+
input: {
|
|
27492
|
+
path: "src/main.js",
|
|
27493
|
+
diff: `<<<<<<< SEARCH
|
|
27528
27494
|
import React from 'react';
|
|
27529
27495
|
=======
|
|
27530
27496
|
import React, { useState } from 'react';
|
|
@@ -27552,35 +27518,23 @@ return (
|
|
|
27552
27518
|
<div>
|
|
27553
27519
|
>>>>>>> REPLACE`
|
|
27554
27520
|
}
|
|
27555
|
-
|
|
27556
|
-
|
|
27557
|
-
|
|
27558
|
-
|
|
27559
|
-
|
|
27560
|
-
|
|
27561
|
-
name: "path",
|
|
27562
|
-
value: "src/config.js"
|
|
27563
|
-
},
|
|
27564
|
-
{
|
|
27565
|
-
name: "diff",
|
|
27566
|
-
value: `<<<<<<< SEARCH
|
|
27521
|
+
},
|
|
27522
|
+
{
|
|
27523
|
+
description: "Request to perform a simple, single-line replacement",
|
|
27524
|
+
input: {
|
|
27525
|
+
path: "src/config.js",
|
|
27526
|
+
diff: `<<<<<<< SEARCH
|
|
27567
27527
|
const API_URL = 'https://api.example.com';
|
|
27568
27528
|
=======
|
|
27569
27529
|
const API_URL = 'https://api.staging.example.com';
|
|
27570
27530
|
>>>>>>> REPLACE`
|
|
27571
27531
|
}
|
|
27572
|
-
|
|
27573
|
-
|
|
27574
|
-
|
|
27575
|
-
|
|
27576
|
-
|
|
27577
|
-
|
|
27578
|
-
name: "path",
|
|
27579
|
-
value: "src/utils.js"
|
|
27580
|
-
},
|
|
27581
|
-
{
|
|
27582
|
-
name: "diff",
|
|
27583
|
-
value: `<<<<<<< SEARCH
|
|
27532
|
+
},
|
|
27533
|
+
{
|
|
27534
|
+
description: "Request to add a new function to a file",
|
|
27535
|
+
input: {
|
|
27536
|
+
path: "src/utils.js",
|
|
27537
|
+
diff: `<<<<<<< SEARCH
|
|
27584
27538
|
function helperA() {
|
|
27585
27539
|
// ...
|
|
27586
27540
|
}
|
|
@@ -27594,18 +27548,12 @@ function newHelper() {
|
|
|
27594
27548
|
}
|
|
27595
27549
|
>>>>>>> REPLACE`
|
|
27596
27550
|
}
|
|
27597
|
-
|
|
27598
|
-
|
|
27599
|
-
|
|
27600
|
-
|
|
27601
|
-
|
|
27602
|
-
|
|
27603
|
-
name: "path",
|
|
27604
|
-
value: "src/app.js"
|
|
27605
|
-
},
|
|
27606
|
-
{
|
|
27607
|
-
name: "diff",
|
|
27608
|
-
value: `<<<<<<< SEARCH
|
|
27551
|
+
},
|
|
27552
|
+
{
|
|
27553
|
+
description: "Request to delete a block of code from a file",
|
|
27554
|
+
input: {
|
|
27555
|
+
path: "src/app.js",
|
|
27556
|
+
diff: `<<<<<<< SEARCH
|
|
27609
27557
|
function oldFeature() {
|
|
27610
27558
|
// This is no longer needed
|
|
27611
27559
|
}
|
|
@@ -27613,12 +27561,12 @@ function oldFeature() {
|
|
|
27613
27561
|
=======
|
|
27614
27562
|
>>>>>>> REPLACE`
|
|
27615
27563
|
}
|
|
27616
|
-
|
|
27617
|
-
|
|
27618
|
-
|
|
27564
|
+
}
|
|
27565
|
+
]
|
|
27566
|
+
}),
|
|
27619
27567
|
permissionLevel: 2 /* Write */
|
|
27620
27568
|
};
|
|
27621
|
-
var
|
|
27569
|
+
var handler11 = async (provider, args) => {
|
|
27622
27570
|
if (!provider.readFile || !provider.writeFile) {
|
|
27623
27571
|
return {
|
|
27624
27572
|
type: "Error" /* Error */,
|
|
@@ -27626,7 +27574,7 @@ var handler8 = async (provider, args) => {
|
|
|
27626
27574
|
};
|
|
27627
27575
|
}
|
|
27628
27576
|
try {
|
|
27629
|
-
const { path, diff } =
|
|
27577
|
+
const { path, diff } = toolInfo11.parameters.parse(args);
|
|
27630
27578
|
const fileContent = await provider.readFile(path);
|
|
27631
27579
|
if (fileContent == null) {
|
|
27632
27580
|
return {
|
|
@@ -27663,16 +27611,16 @@ var handler8 = async (provider, args) => {
|
|
|
27663
27611
|
};
|
|
27664
27612
|
}
|
|
27665
27613
|
};
|
|
27666
|
-
var
|
|
27614
|
+
var isAvailable11 = (provider) => {
|
|
27667
27615
|
return !!provider.readFile && !!provider.writeFile;
|
|
27668
27616
|
};
|
|
27669
27617
|
var replaceInFile_default = {
|
|
27670
|
-
...
|
|
27671
|
-
handler:
|
|
27672
|
-
isAvailable:
|
|
27618
|
+
...toolInfo11,
|
|
27619
|
+
handler: handler11,
|
|
27620
|
+
isAvailable: isAvailable11
|
|
27673
27621
|
};
|
|
27674
27622
|
// ../core/src/tools/searchFiles.ts
|
|
27675
|
-
var
|
|
27623
|
+
var toolInfo12 = {
|
|
27676
27624
|
name: "search_files",
|
|
27677
27625
|
description: "Request to perform a regex search across files in a specified directory, outputting context-rich results that include surrounding lines. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.",
|
|
27678
27626
|
parameters: exports_external.object({
|
|
@@ -27683,29 +27631,21 @@ var toolInfo9 = {
|
|
|
27683
27631
|
filePattern: exports_external.string().optional().describe('Comma-separated glob pattern to filter files (e.g., "*.ts" for TypeScript files or "*.ts,*.js" for both TypeScript and JavaScript files). If not provided, it will search all files (*).').meta({
|
|
27684
27632
|
usageValue: "file pattern here (optional)"
|
|
27685
27633
|
})
|
|
27686
|
-
})
|
|
27687
|
-
|
|
27688
|
-
|
|
27689
|
-
|
|
27690
|
-
|
|
27691
|
-
|
|
27692
|
-
|
|
27693
|
-
|
|
27694
|
-
},
|
|
27695
|
-
{
|
|
27696
|
-
name: "regex",
|
|
27697
|
-
value: "^components/"
|
|
27698
|
-
},
|
|
27699
|
-
{
|
|
27700
|
-
name: "filePattern",
|
|
27701
|
-
value: "*.ts,*.tsx"
|
|
27634
|
+
}).meta({
|
|
27635
|
+
examples: [
|
|
27636
|
+
{
|
|
27637
|
+
description: "Request to perform a regex search across files",
|
|
27638
|
+
input: {
|
|
27639
|
+
path: "src",
|
|
27640
|
+
regex: "^components/",
|
|
27641
|
+
filePattern: "*.ts,*.tsx"
|
|
27702
27642
|
}
|
|
27703
|
-
|
|
27704
|
-
|
|
27705
|
-
|
|
27643
|
+
}
|
|
27644
|
+
]
|
|
27645
|
+
}),
|
|
27706
27646
|
permissionLevel: 1 /* Read */
|
|
27707
27647
|
};
|
|
27708
|
-
var
|
|
27648
|
+
var handler12 = async (provider, args) => {
|
|
27709
27649
|
if (!provider.searchFiles) {
|
|
27710
27650
|
return {
|
|
27711
27651
|
type: "Error" /* Error */,
|
|
@@ -27713,7 +27653,7 @@ var handler9 = async (provider, args) => {
|
|
|
27713
27653
|
};
|
|
27714
27654
|
}
|
|
27715
27655
|
try {
|
|
27716
|
-
const { path, regex, filePattern } =
|
|
27656
|
+
const { path, regex, filePattern } = toolInfo12.parameters.parse(args);
|
|
27717
27657
|
const files = await provider.searchFiles(path, regex, filePattern ?? "*");
|
|
27718
27658
|
return {
|
|
27719
27659
|
type: "Reply" /* Reply */,
|
|
@@ -27733,33 +27673,28 @@ ${files.join(`
|
|
|
27733
27673
|
};
|
|
27734
27674
|
}
|
|
27735
27675
|
};
|
|
27736
|
-
var
|
|
27676
|
+
var isAvailable12 = (provider) => {
|
|
27737
27677
|
return !!provider.searchFiles;
|
|
27738
27678
|
};
|
|
27739
27679
|
var searchFiles_default = {
|
|
27740
|
-
...
|
|
27741
|
-
handler:
|
|
27742
|
-
isAvailable:
|
|
27680
|
+
...toolInfo12,
|
|
27681
|
+
handler: handler12,
|
|
27682
|
+
isAvailable: isAvailable12
|
|
27743
27683
|
};
|
|
27744
27684
|
// ../core/src/tools/writeToFile.ts
|
|
27745
|
-
var
|
|
27685
|
+
var toolInfo13 = {
|
|
27746
27686
|
name: "write_to_file",
|
|
27747
27687
|
description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file. Ensure that the output content does not include incorrect escaped character patterns such as `<`, `>`, or `&`. Also ensure there is no unwanted CDATA tags in the content.",
|
|
27748
27688
|
parameters: exports_external.object({
|
|
27749
27689
|
path: exports_external.string().describe("The path of the file to write to").meta({ usageValue: "File path here" }),
|
|
27750
27690
|
content: exports_external.string().describe("The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified.").meta({ usageValue: "Your file content here" })
|
|
27751
|
-
})
|
|
27752
|
-
|
|
27753
|
-
|
|
27754
|
-
|
|
27755
|
-
|
|
27756
|
-
|
|
27757
|
-
|
|
27758
|
-
value: "src/main.js"
|
|
27759
|
-
},
|
|
27760
|
-
{
|
|
27761
|
-
name: "content",
|
|
27762
|
-
value: `import React from 'react';
|
|
27691
|
+
}).meta({
|
|
27692
|
+
examples: [
|
|
27693
|
+
{
|
|
27694
|
+
description: "Request to write content to a file",
|
|
27695
|
+
input: {
|
|
27696
|
+
path: "src/main.js",
|
|
27697
|
+
content: `import React from 'react';
|
|
27763
27698
|
|
|
27764
27699
|
function App() {
|
|
27765
27700
|
return (
|
|
@@ -27772,19 +27707,19 @@ function App() {
|
|
|
27772
27707
|
export default App;
|
|
27773
27708
|
`
|
|
27774
27709
|
}
|
|
27775
|
-
|
|
27776
|
-
|
|
27777
|
-
|
|
27710
|
+
}
|
|
27711
|
+
]
|
|
27712
|
+
}),
|
|
27778
27713
|
permissionLevel: 2 /* Write */
|
|
27779
27714
|
};
|
|
27780
|
-
var
|
|
27715
|
+
var handler13 = async (provider, args) => {
|
|
27781
27716
|
if (!provider.writeFile) {
|
|
27782
27717
|
return {
|
|
27783
27718
|
type: "Error" /* Error */,
|
|
27784
27719
|
message: "Not possible to write file. Abort."
|
|
27785
27720
|
};
|
|
27786
27721
|
}
|
|
27787
|
-
const parsed =
|
|
27722
|
+
const parsed = toolInfo13.parameters.safeParse(args);
|
|
27788
27723
|
if (!parsed.success) {
|
|
27789
27724
|
return {
|
|
27790
27725
|
type: "Invalid" /* Invalid */,
|
|
@@ -27801,171 +27736,10 @@ var handler10 = async (provider, args) => {
|
|
|
27801
27736
|
message: `<write_to_file_path>${path}</write_to_file_path><status>Success</status>`
|
|
27802
27737
|
};
|
|
27803
27738
|
};
|
|
27804
|
-
var
|
|
27739
|
+
var isAvailable13 = (provider) => {
|
|
27805
27740
|
return !!provider.writeFile;
|
|
27806
27741
|
};
|
|
27807
27742
|
var writeToFile_default = {
|
|
27808
|
-
...toolInfo10,
|
|
27809
|
-
handler: handler10,
|
|
27810
|
-
isAvailable: isAvailable10
|
|
27811
|
-
};
|
|
27812
|
-
// ../core/src/tools/handOver.ts
|
|
27813
|
-
var toolInfo11 = {
|
|
27814
|
-
name: "hand_over",
|
|
27815
|
-
description: "Hand over the current task to another agent to complete. This tool MUST NOT to be used with any other tool.",
|
|
27816
|
-
parameters: exports_external.object({
|
|
27817
|
-
agentName: exports_external.string().describe("The name of the agent to hand over the task to").meta({ usageValue: "Name of the target agent" }),
|
|
27818
|
-
task: exports_external.string().describe("The task to be completed by the target agent").meta({ usageValue: "Task description" }),
|
|
27819
|
-
context: exports_external.string().describe("The context information for the task").meta({ usageValue: "Context information" }),
|
|
27820
|
-
files: exports_external.preprocess((val) => {
|
|
27821
|
-
if (!val)
|
|
27822
|
-
return [];
|
|
27823
|
-
const values = Array.isArray(val) ? val : [val];
|
|
27824
|
-
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
27825
|
-
}, exports_external.array(exports_external.string())).optional().describe("The files relevant to the task. Comma separated paths").meta({ usageValue: "Relevant files" })
|
|
27826
|
-
}),
|
|
27827
|
-
examples: [
|
|
27828
|
-
{
|
|
27829
|
-
description: "Hand over a coding task to the coder agent",
|
|
27830
|
-
parameters: [
|
|
27831
|
-
{
|
|
27832
|
-
name: "agentName",
|
|
27833
|
-
value: "coder"
|
|
27834
|
-
},
|
|
27835
|
-
{
|
|
27836
|
-
name: "task",
|
|
27837
|
-
value: "Implement the login feature"
|
|
27838
|
-
},
|
|
27839
|
-
{
|
|
27840
|
-
name: "context",
|
|
27841
|
-
value: "We need a secure login system with email and password"
|
|
27842
|
-
},
|
|
27843
|
-
{
|
|
27844
|
-
name: "files",
|
|
27845
|
-
value: "src/auth/login.ts,src/auth/types.ts"
|
|
27846
|
-
}
|
|
27847
|
-
]
|
|
27848
|
-
}
|
|
27849
|
-
],
|
|
27850
|
-
permissionLevel: 0 /* None */
|
|
27851
|
-
};
|
|
27852
|
-
var handler11 = async (_provider, args) => {
|
|
27853
|
-
const parsed = toolInfo11.parameters.safeParse(args);
|
|
27854
|
-
if (!parsed.success) {
|
|
27855
|
-
return {
|
|
27856
|
-
type: "Invalid" /* Invalid */,
|
|
27857
|
-
message: `Invalid arguments for hand_over: ${parsed.error.message}`
|
|
27858
|
-
};
|
|
27859
|
-
}
|
|
27860
|
-
const { agentName, task, context, files } = parsed.data;
|
|
27861
|
-
return {
|
|
27862
|
-
type: "HandOver" /* HandOver */,
|
|
27863
|
-
agentName,
|
|
27864
|
-
task,
|
|
27865
|
-
context,
|
|
27866
|
-
files: files ?? []
|
|
27867
|
-
};
|
|
27868
|
-
};
|
|
27869
|
-
var isAvailable11 = (_provider) => {
|
|
27870
|
-
return true;
|
|
27871
|
-
};
|
|
27872
|
-
var handOver_default = {
|
|
27873
|
-
...toolInfo11,
|
|
27874
|
-
handler: handler11,
|
|
27875
|
-
isAvailable: isAvailable11
|
|
27876
|
-
};
|
|
27877
|
-
// ../core/src/tools/removeFile.ts
|
|
27878
|
-
var toolInfo12 = {
|
|
27879
|
-
name: "remove_file",
|
|
27880
|
-
description: "Request to remove a file at the specified path.",
|
|
27881
|
-
parameters: exports_external.object({
|
|
27882
|
-
path: exports_external.string().describe("The path of the file to remove").meta({ usageValue: "File path here" })
|
|
27883
|
-
}),
|
|
27884
|
-
examples: [
|
|
27885
|
-
{
|
|
27886
|
-
description: "Request to remove a file",
|
|
27887
|
-
parameters: [
|
|
27888
|
-
{
|
|
27889
|
-
name: "path",
|
|
27890
|
-
value: "src/main.js"
|
|
27891
|
-
}
|
|
27892
|
-
]
|
|
27893
|
-
}
|
|
27894
|
-
],
|
|
27895
|
-
permissionLevel: 2 /* Write */
|
|
27896
|
-
};
|
|
27897
|
-
var handler12 = async (provider, args) => {
|
|
27898
|
-
if (!provider.removeFile) {
|
|
27899
|
-
return {
|
|
27900
|
-
type: "Error" /* Error */,
|
|
27901
|
-
message: "Not possible to remove file. Abort."
|
|
27902
|
-
};
|
|
27903
|
-
}
|
|
27904
|
-
const parsed = toolInfo12.parameters.safeParse(args);
|
|
27905
|
-
if (!parsed.success) {
|
|
27906
|
-
return {
|
|
27907
|
-
type: "Invalid" /* Invalid */,
|
|
27908
|
-
message: `Invalid arguments for remove_file: ${parsed.error.message}`
|
|
27909
|
-
};
|
|
27910
|
-
}
|
|
27911
|
-
const { path } = parsed.data;
|
|
27912
|
-
await provider.removeFile(path);
|
|
27913
|
-
return {
|
|
27914
|
-
type: "Reply" /* Reply */,
|
|
27915
|
-
message: `<remove_file_path>${path}</remove_file_path><status>Success</status>`
|
|
27916
|
-
};
|
|
27917
|
-
};
|
|
27918
|
-
var isAvailable12 = (provider) => {
|
|
27919
|
-
return !!provider.removeFile;
|
|
27920
|
-
};
|
|
27921
|
-
var removeFile_default = {
|
|
27922
|
-
...toolInfo12,
|
|
27923
|
-
handler: handler12,
|
|
27924
|
-
isAvailable: isAvailable12
|
|
27925
|
-
};
|
|
27926
|
-
// ../core/src/tools/renameFile.ts
|
|
27927
|
-
var toolInfo13 = {
|
|
27928
|
-
name: "rename_file",
|
|
27929
|
-
description: "Request to rename a file from source path to target path.",
|
|
27930
|
-
parameters: exports_external.object({
|
|
27931
|
-
source_path: exports_external.string().describe("The current path of the file").meta({ usageValue: "Source file path here" }),
|
|
27932
|
-
target_path: exports_external.string().describe("The new path for the file").meta({ usageValue: "Target file path here" })
|
|
27933
|
-
}),
|
|
27934
|
-
examples: [
|
|
27935
|
-
{
|
|
27936
|
-
description: "Request to rename a file",
|
|
27937
|
-
parameters: [
|
|
27938
|
-
{
|
|
27939
|
-
name: "source_path",
|
|
27940
|
-
value: "src/old-name.js"
|
|
27941
|
-
},
|
|
27942
|
-
{
|
|
27943
|
-
name: "target_path",
|
|
27944
|
-
value: "src/new-name.js"
|
|
27945
|
-
}
|
|
27946
|
-
]
|
|
27947
|
-
}
|
|
27948
|
-
],
|
|
27949
|
-
permissionLevel: 2 /* Write */
|
|
27950
|
-
};
|
|
27951
|
-
var handler13 = async (provider, args) => {
|
|
27952
|
-
if (!provider.renameFile) {
|
|
27953
|
-
return {
|
|
27954
|
-
type: "Error" /* Error */,
|
|
27955
|
-
message: "Not possible to rename file. Abort."
|
|
27956
|
-
};
|
|
27957
|
-
}
|
|
27958
|
-
const { source_path, target_path } = toolInfo13.parameters.parse(args);
|
|
27959
|
-
await provider.renameFile(source_path, target_path);
|
|
27960
|
-
return {
|
|
27961
|
-
type: "Reply" /* Reply */,
|
|
27962
|
-
message: `<rename_file_path>${target_path}</rename_file_path><status>Success</status>`
|
|
27963
|
-
};
|
|
27964
|
-
};
|
|
27965
|
-
var isAvailable13 = (provider) => {
|
|
27966
|
-
return !!provider.renameFile;
|
|
27967
|
-
};
|
|
27968
|
-
var renameFile_default = {
|
|
27969
27743
|
...toolInfo13,
|
|
27970
27744
|
handler: handler13,
|
|
27971
27745
|
isAvailable: isAvailable13
|
|
@@ -27995,43 +27769,140 @@ var getAvailableTools = ({
|
|
|
27995
27769
|
return tools;
|
|
27996
27770
|
};
|
|
27997
27771
|
|
|
27998
|
-
// ../core/src/
|
|
27999
|
-
|
|
28000
|
-
|
|
28001
|
-
|
|
28002
|
-
|
|
28003
|
-
|
|
28004
|
-
|
|
28005
|
-
|
|
28006
|
-
const
|
|
28007
|
-
|
|
28008
|
-
|
|
28009
|
-
|
|
28010
|
-
|
|
28011
|
-
|
|
28012
|
-
|
|
28013
|
-
|
|
27772
|
+
// ../core/src/UsageMeter.ts
|
|
27773
|
+
class UsageMeter {
|
|
27774
|
+
#totals = { input: 0, output: 0, cachedRead: 0, cost: 0 };
|
|
27775
|
+
#calls = 0;
|
|
27776
|
+
#modelInfos;
|
|
27777
|
+
#maxMessages;
|
|
27778
|
+
#maxCost;
|
|
27779
|
+
constructor(modelInfos = {}, opts = {}) {
|
|
27780
|
+
const infos = {};
|
|
27781
|
+
for (const [provider2, providerInfo] of Object.entries(modelInfos)) {
|
|
27782
|
+
for (const [model, modelInfo] of Object.entries(providerInfo)) {
|
|
27783
|
+
infos[`${provider2.split("-")[0]}:${model.replace(/[.-]/g, "")}`] = {
|
|
27784
|
+
inputPrice: modelInfo.inputPrice ?? 0,
|
|
27785
|
+
outputPrice: modelInfo.outputPrice ?? 0,
|
|
27786
|
+
cacheWritesPrice: modelInfo.cacheWritesPrice ?? 0,
|
|
27787
|
+
cacheReadsPrice: modelInfo.cacheReadsPrice ?? 0
|
|
27788
|
+
};
|
|
27789
|
+
}
|
|
28014
27790
|
}
|
|
28015
|
-
|
|
28016
|
-
|
|
28017
|
-
|
|
28018
|
-
|
|
28019
|
-
|
|
28020
|
-
|
|
28021
|
-
|
|
27791
|
+
this.#modelInfos = infos;
|
|
27792
|
+
this.#maxMessages = opts.maxMessages ?? 1000;
|
|
27793
|
+
this.#maxCost = opts.maxCost ?? 100;
|
|
27794
|
+
}
|
|
27795
|
+
#calculageUsage(usage, providerMetadata, modelInfo) {
|
|
27796
|
+
const providerMetadataKey = Object.keys(providerMetadata ?? {})[0];
|
|
27797
|
+
const metadata = providerMetadata?.[providerMetadataKey] ?? {};
|
|
27798
|
+
switch (providerMetadataKey) {
|
|
27799
|
+
case "openrouter":
|
|
27800
|
+
return {
|
|
27801
|
+
input: usage.inputTokens ?? 0,
|
|
27802
|
+
output: usage.outputTokens ?? 0,
|
|
27803
|
+
cachedRead: usage.cachedInputTokens ?? 0,
|
|
27804
|
+
cost: metadata.usage?.cost ?? 0
|
|
27805
|
+
};
|
|
27806
|
+
case "anthropic": {
|
|
27807
|
+
const cachedRead = usage.cachedInputTokens ?? 0;
|
|
27808
|
+
const cacheWrite = metadata?.promptCacheMissTokens ?? 0;
|
|
27809
|
+
const input = usage.inputTokens ?? 0;
|
|
27810
|
+
const output = usage.outputTokens ?? 0;
|
|
27811
|
+
return {
|
|
27812
|
+
input: input + cacheWrite + cachedRead,
|
|
27813
|
+
output,
|
|
27814
|
+
cachedRead,
|
|
27815
|
+
cost: (input * modelInfo.inputPrice + output * modelInfo.outputPrice + cacheWrite * modelInfo.cacheWritesPrice + cachedRead * modelInfo.cacheReadsPrice) / 1e6
|
|
27816
|
+
};
|
|
27817
|
+
}
|
|
27818
|
+
case "deepseek": {
|
|
27819
|
+
const cachedRead = usage.cachedInputTokens ?? 0;
|
|
27820
|
+
const cacheWrite = metadata.promptCacheMissTokens ?? 0;
|
|
27821
|
+
const input = usage.inputTokens ?? 0;
|
|
27822
|
+
const output = usage.outputTokens ?? 0;
|
|
27823
|
+
return {
|
|
27824
|
+
input,
|
|
27825
|
+
output,
|
|
27826
|
+
cachedRead,
|
|
27827
|
+
cost: (output * modelInfo.outputPrice + cacheWrite * modelInfo.inputPrice + cachedRead * modelInfo.cacheReadsPrice) / 1e6
|
|
27828
|
+
};
|
|
27829
|
+
}
|
|
27830
|
+
default: {
|
|
27831
|
+
const cachedRead = usage.cachedInputTokens ?? 0;
|
|
27832
|
+
const input = usage.inputTokens ?? 0;
|
|
27833
|
+
const output = usage.outputTokens ?? 0;
|
|
27834
|
+
return {
|
|
27835
|
+
input,
|
|
27836
|
+
output,
|
|
27837
|
+
cachedRead,
|
|
27838
|
+
cost: (input * modelInfo.inputPrice + output * modelInfo.outputPrice) / 1e6
|
|
27839
|
+
};
|
|
28022
27840
|
}
|
|
28023
27841
|
}
|
|
28024
|
-
parameters.push(param);
|
|
28025
27842
|
}
|
|
28026
|
-
|
|
28027
|
-
}
|
|
28028
|
-
|
|
28029
|
-
|
|
28030
|
-
|
|
28031
|
-
|
|
28032
|
-
|
|
28033
|
-
|
|
28034
|
-
|
|
27843
|
+
addUsage(llm, resp, options = {}) {
|
|
27844
|
+
const modelInfo = options.modelInfo ?? this.#modelInfos[`${llm.provider.split(".")[0]}:${llm.modelId.replace(/[.-]/g, "")}`] ?? {
|
|
27845
|
+
inputPrice: 0,
|
|
27846
|
+
outputPrice: 0,
|
|
27847
|
+
cacheWritesPrice: 0,
|
|
27848
|
+
cacheReadsPrice: 0
|
|
27849
|
+
};
|
|
27850
|
+
const usage = "totalUsage" in resp ? resp.totalUsage : resp.usage;
|
|
27851
|
+
const result = this.#calculageUsage(usage, resp.providerMetadata, modelInfo);
|
|
27852
|
+
this.#totals.input += result.input;
|
|
27853
|
+
this.#totals.output += result.output;
|
|
27854
|
+
this.#totals.cachedRead += result.cachedRead;
|
|
27855
|
+
this.#totals.cost += result.cost;
|
|
27856
|
+
this.#calls++;
|
|
27857
|
+
}
|
|
27858
|
+
setUsage(newUsage) {
|
|
27859
|
+
if (newUsage.input != null)
|
|
27860
|
+
this.#totals.input = newUsage.input;
|
|
27861
|
+
if (newUsage.output != null)
|
|
27862
|
+
this.#totals.output = newUsage.output;
|
|
27863
|
+
if (newUsage.cachedRead != null)
|
|
27864
|
+
this.#totals.cachedRead = newUsage.cachedRead;
|
|
27865
|
+
if (newUsage.cost != null)
|
|
27866
|
+
this.#totals.cost = newUsage.cost;
|
|
27867
|
+
if (newUsage.calls != null)
|
|
27868
|
+
this.#calls = newUsage.calls;
|
|
27869
|
+
}
|
|
27870
|
+
incrementMessageCount(n = 1) {
|
|
27871
|
+
this.#calls += n;
|
|
27872
|
+
}
|
|
27873
|
+
resetUsage() {
|
|
27874
|
+
this.#totals = { input: 0, output: 0, cachedRead: 0, cost: 0 };
|
|
27875
|
+
this.#calls = 0;
|
|
27876
|
+
}
|
|
27877
|
+
isLimitExceeded() {
|
|
27878
|
+
const messageCount = this.#maxMessages !== undefined && this.#calls >= this.#maxMessages;
|
|
27879
|
+
const cost = this.#maxCost !== undefined && this.#totals.cost >= this.#maxCost;
|
|
27880
|
+
return {
|
|
27881
|
+
messageCount,
|
|
27882
|
+
maxMessages: this.#maxMessages,
|
|
27883
|
+
cost,
|
|
27884
|
+
maxCost: this.#maxCost,
|
|
27885
|
+
result: messageCount || cost
|
|
27886
|
+
};
|
|
27887
|
+
}
|
|
27888
|
+
checkLimit() {
|
|
27889
|
+
const result = this.isLimitExceeded();
|
|
27890
|
+
if (result.result) {
|
|
27891
|
+
throw new Error(`Usage limit exceeded. Message count: ${result.messageCount}/${result.maxMessages}, cost: ${result.cost}/${result.maxCost}`);
|
|
27892
|
+
}
|
|
27893
|
+
}
|
|
27894
|
+
get usage() {
|
|
27895
|
+
return { ...this.#totals, messageCount: this.#calls };
|
|
27896
|
+
}
|
|
27897
|
+
printUsage() {
|
|
27898
|
+
const u = this.usage;
|
|
27899
|
+
console.log(`Usage - messages: ${u.messageCount}, input: ${u.input}, cached: ${u.cachedRead}, ` + `output: ${u.output}, cost: $${u.cost.toFixed(4)}`);
|
|
27900
|
+
}
|
|
27901
|
+
onFinishHandler(llm) {
|
|
27902
|
+
return (evt) => {
|
|
27903
|
+
this.addUsage(llm, evt);
|
|
27904
|
+
};
|
|
27905
|
+
}
|
|
28035
27906
|
}
|
|
28036
27907
|
|
|
28037
27908
|
// ../../node_modules/@ai-sdk/provider/dist/index.mjs
|
|
@@ -50565,6 +50436,53 @@ var JSONRPCMessageSchema = exports_external2.union([
|
|
|
50565
50436
|
JSONRPCErrorSchema
|
|
50566
50437
|
]);
|
|
50567
50438
|
|
|
50439
|
+
// ../core/src/Agent/AgentBase.ts
|
|
50440
|
+
var import_lodash = __toESM(require_lodash(), 1);
|
|
50441
|
+
|
|
50442
|
+
// ../core/src/tool-v1-compat.ts
|
|
50443
|
+
function zodSchemaToParameters(schema) {
|
|
50444
|
+
const parameters = [];
|
|
50445
|
+
const { shape } = schema;
|
|
50446
|
+
for (const name17 in shape) {
|
|
50447
|
+
const def = shape[name17];
|
|
50448
|
+
const isOptional = def.safeParse(undefined).success;
|
|
50449
|
+
const description = def.description || "";
|
|
50450
|
+
const param = {
|
|
50451
|
+
name: name17,
|
|
50452
|
+
description,
|
|
50453
|
+
required: !isOptional
|
|
50454
|
+
};
|
|
50455
|
+
const usageValue = def.meta()?.usageValue;
|
|
50456
|
+
if (usageValue) {
|
|
50457
|
+
param.usageValue = usageValue;
|
|
50458
|
+
}
|
|
50459
|
+
if (def instanceof exports_external.ZodObject) {
|
|
50460
|
+
param.children = zodSchemaToParameters(def);
|
|
50461
|
+
} else if (def instanceof exports_external.ZodArray) {
|
|
50462
|
+
param.allowMultiple = true;
|
|
50463
|
+
const element = def.element;
|
|
50464
|
+
if (element instanceof exports_external.ZodObject) {
|
|
50465
|
+
param.children = zodSchemaToParameters(element);
|
|
50466
|
+
}
|
|
50467
|
+
}
|
|
50468
|
+
parameters.push(param);
|
|
50469
|
+
}
|
|
50470
|
+
return parameters;
|
|
50471
|
+
}
|
|
50472
|
+
function toToolInfoV1(tool) {
|
|
50473
|
+
const { parameters: zodSchema2, ...rest } = tool;
|
|
50474
|
+
const v1Parameters = zodSchemaToParameters(zodSchema2);
|
|
50475
|
+
const examples = zodSchema2.meta()?.examples;
|
|
50476
|
+
const v1Tool = {
|
|
50477
|
+
...rest,
|
|
50478
|
+
parameters: v1Parameters
|
|
50479
|
+
};
|
|
50480
|
+
if (examples) {
|
|
50481
|
+
v1Tool.examples = examples;
|
|
50482
|
+
}
|
|
50483
|
+
return v1Tool;
|
|
50484
|
+
}
|
|
50485
|
+
|
|
50568
50486
|
// ../core/src/Agent/parseAssistantMessage.ts
|
|
50569
50487
|
function parseNestedParameters(content, parameterPrefix, childrenParams) {
|
|
50570
50488
|
const result = {};
|
|
@@ -50738,7 +50656,7 @@ var toolInfoExamplesPrompt = (tool, example, toolNamePrefix, parameterPrefix) =>
|
|
|
50738
50656
|
## Example: ${example.description}
|
|
50739
50657
|
|
|
50740
50658
|
<${toolNamePrefix}${tool.name}>
|
|
50741
|
-
${example.
|
|
50659
|
+
${Object.entries(example.input).map(([name17, value]) => renderParameterValue(name17, value, parameterPrefix)).join(`
|
|
50742
50660
|
`)}
|
|
50743
50661
|
</${toolNamePrefix}${tool.name}>
|
|
50744
50662
|
`;
|
|
@@ -50747,6 +50665,7 @@ var toolUsePrompt = (tools, toolNamePrefix) => {
|
|
|
50747
50665
|
return "";
|
|
50748
50666
|
}
|
|
50749
50667
|
const parameterPrefix = `${toolNamePrefix}parameter_`;
|
|
50668
|
+
const v1Tools = tools.map(toToolInfoV1);
|
|
50750
50669
|
return `
|
|
50751
50670
|
====
|
|
50752
50671
|
|
|
@@ -50805,11 +50724,11 @@ Always adhere to this format, ensuring every opening tag has a matching closing
|
|
|
50805
50724
|
NEVER surround tool use with triple backticks (\`\`\`).
|
|
50806
50725
|
|
|
50807
50726
|
# Tools
|
|
50808
|
-
${
|
|
50727
|
+
${v1Tools.map((tool) => toolInfoPrompt(tool, toolNamePrefix, parameterPrefix)).join(`
|
|
50809
50728
|
`)}
|
|
50810
50729
|
|
|
50811
50730
|
# Tool Use Examples
|
|
50812
|
-
${
|
|
50731
|
+
${v1Tools.map((tool) => {
|
|
50813
50732
|
let promp = "";
|
|
50814
50733
|
for (const example of tool.examples ?? []) {
|
|
50815
50734
|
promp += toolInfoExamplesPrompt(tool, example, toolNamePrefix, parameterPrefix);
|
|
@@ -50843,7 +50762,7 @@ ${agent.responsibilities.map((resp) => ` - ${resp}`).join(`
|
|
|
50843
50762
|
- **Current Agent Role**
|
|
50844
50763
|
You are currently acting as **${name17}**. If you identify the task is beyond your current scope, use the handover or delegate tool to transition to the other agent. Include sufficient context so the new agent can seamlessly continue the work.
|
|
50845
50764
|
`;
|
|
50846
|
-
var capabilities = (
|
|
50765
|
+
var capabilities = (_toolNamePrefix) => `
|
|
50847
50766
|
====
|
|
50848
50767
|
|
|
50849
50768
|
CAPABILITIES
|
|
@@ -50902,6 +50821,8 @@ e.g. <tool_tool_name>tool_name</tool_tool_name>
|
|
|
50902
50821
|
Ensure the opening and closing tags are correctly nested and closed, and that you are using the correct tool name.
|
|
50903
50822
|
Avoid unnecessary text or symbols before or after the tool use.
|
|
50904
50823
|
Avoid unnecessary escape characters or special characters.
|
|
50824
|
+
`,
|
|
50825
|
+
requireUseToolNative: `Error: No tool use detected. You MUST use a tool before proceeding.
|
|
50905
50826
|
`,
|
|
50906
50827
|
toolResults: (tool, result) => {
|
|
50907
50828
|
if (typeof result === "string") {
|
|
@@ -50940,6 +50861,7 @@ class AgentBase {
|
|
|
50940
50861
|
config;
|
|
50941
50862
|
handlers;
|
|
50942
50863
|
#policies;
|
|
50864
|
+
#toolSet;
|
|
50943
50865
|
#messages = [];
|
|
50944
50866
|
#aborted = false;
|
|
50945
50867
|
#abortController;
|
|
@@ -50977,6 +50899,20 @@ ${instance.prompt}`;
|
|
|
50977
50899
|
role: "system",
|
|
50978
50900
|
content: this.config.systemPrompt
|
|
50979
50901
|
});
|
|
50902
|
+
if (this.config.toolFormat === "native") {
|
|
50903
|
+
const tools = {};
|
|
50904
|
+
for (const tool of Object.values(this.handlers)) {
|
|
50905
|
+
const toolName = import_lodash.camelCase(tool.name);
|
|
50906
|
+
tools[toolName] = {
|
|
50907
|
+
description: tool.description,
|
|
50908
|
+
inputSchema: jsonSchema(toJSONSchema(tool.parameters))
|
|
50909
|
+
};
|
|
50910
|
+
this.handlers[toolName] = tool;
|
|
50911
|
+
}
|
|
50912
|
+
this.#toolSet = tools;
|
|
50913
|
+
} else {
|
|
50914
|
+
this.#toolSet = {};
|
|
50915
|
+
}
|
|
50980
50916
|
}
|
|
50981
50917
|
abort() {
|
|
50982
50918
|
this.#aborted = true;
|
|
@@ -51004,13 +50940,19 @@ ${instance.prompt}`;
|
|
|
51004
50940
|
if (this.#messages.length === 0) {
|
|
51005
50941
|
this.#callback({ kind: "StartTask" /* StartTask */, agent: this, systemPrompt: this.config.systemPrompt });
|
|
51006
50942
|
}
|
|
51007
|
-
return await this.#request(
|
|
50943
|
+
return await this.#request({
|
|
50944
|
+
role: "user",
|
|
50945
|
+
content: prompt
|
|
50946
|
+
});
|
|
51008
50947
|
}
|
|
51009
50948
|
async handleStepResponse(response) {
|
|
51010
50949
|
return this.#handleResponse(response);
|
|
51011
50950
|
}
|
|
51012
50951
|
async#processLoop(userMessage) {
|
|
51013
|
-
let nextRequest =
|
|
50952
|
+
let nextRequest = {
|
|
50953
|
+
role: "user",
|
|
50954
|
+
content: userMessage
|
|
50955
|
+
};
|
|
51014
50956
|
while (true) {
|
|
51015
50957
|
if (this.#aborted) {
|
|
51016
50958
|
return { type: "Aborted" };
|
|
@@ -51039,10 +50981,7 @@ ${instance.prompt}`;
|
|
|
51039
50981
|
throw new Error("userMessage is missing");
|
|
51040
50982
|
}
|
|
51041
50983
|
await this.#callback({ kind: "StartRequest" /* StartRequest */, agent: this, userMessage });
|
|
51042
|
-
this.#messages.push(
|
|
51043
|
-
role: "user",
|
|
51044
|
-
content: userMessage
|
|
51045
|
-
});
|
|
50984
|
+
this.#messages.push(userMessage);
|
|
51046
50985
|
for (const instance of this.#policies) {
|
|
51047
50986
|
if (instance.onBeforeRequest) {
|
|
51048
50987
|
await instance.onBeforeRequest(this);
|
|
@@ -51054,11 +50993,11 @@ ${instance.prompt}`;
|
|
|
51054
50993
|
messages = await instance.prepareMessages(this, messages);
|
|
51055
50994
|
}
|
|
51056
50995
|
}
|
|
51057
|
-
let currentAssistantMessage = "";
|
|
51058
50996
|
const retryCount = this.config.retryCount ?? 5;
|
|
51059
|
-
const requestTimeoutSeconds = this.config.requestTimeoutSeconds ??
|
|
50997
|
+
const requestTimeoutSeconds = this.config.requestTimeoutSeconds ?? 90;
|
|
50998
|
+
let respMessages = [];
|
|
51060
50999
|
for (let i = 0;i < retryCount; i++) {
|
|
51061
|
-
|
|
51000
|
+
respMessages = [];
|
|
51062
51001
|
let timeout;
|
|
51063
51002
|
const resetTimeout = () => {
|
|
51064
51003
|
if (timeout) {
|
|
@@ -51072,40 +51011,22 @@ ${instance.prompt}`;
|
|
|
51072
51011
|
}
|
|
51073
51012
|
};
|
|
51074
51013
|
this.#abortController = new AbortController;
|
|
51075
|
-
const providerOptions = {};
|
|
51076
|
-
const thinkingBudgetTokens = this.config.parameters?.thinkingBudgetTokens;
|
|
51077
|
-
const enableThinking = thinkingBudgetTokens > 0;
|
|
51078
|
-
if (enableThinking) {
|
|
51079
|
-
providerOptions.anthropic = {
|
|
51080
|
-
thinking: { type: "enabled", budgetTokens: thinkingBudgetTokens }
|
|
51081
|
-
};
|
|
51082
|
-
providerOptions.openrouter = {
|
|
51083
|
-
reasoning: {
|
|
51084
|
-
max_tokens: thinkingBudgetTokens
|
|
51085
|
-
}
|
|
51086
|
-
};
|
|
51087
|
-
providerOptions.google = {
|
|
51088
|
-
thinkingConfig: {
|
|
51089
|
-
includeThoughts: true,
|
|
51090
|
-
thinkingBudget: thinkingBudgetTokens
|
|
51091
|
-
}
|
|
51092
|
-
};
|
|
51093
|
-
}
|
|
51094
51014
|
try {
|
|
51095
|
-
const
|
|
51015
|
+
const streamTextOptions = {
|
|
51096
51016
|
model: this.ai,
|
|
51097
51017
|
messages,
|
|
51098
|
-
providerOptions,
|
|
51018
|
+
providerOptions: this.config.parameters?.providerOptions,
|
|
51099
51019
|
onChunk: async ({ chunk }) => {
|
|
51100
51020
|
resetTimeout();
|
|
51101
51021
|
switch (chunk.type) {
|
|
51102
51022
|
case "text":
|
|
51103
|
-
currentAssistantMessage += chunk.text;
|
|
51104
51023
|
await this.#callback({ kind: "Text" /* Text */, agent: this, newText: chunk.text });
|
|
51105
51024
|
break;
|
|
51106
51025
|
case "reasoning":
|
|
51107
51026
|
await this.#callback({ kind: "Reasoning" /* Reasoning */, agent: this, newText: chunk.text });
|
|
51108
51027
|
break;
|
|
51028
|
+
case "tool-call":
|
|
51029
|
+
break;
|
|
51109
51030
|
}
|
|
51110
51031
|
},
|
|
51111
51032
|
onFinish: this.config.usageMeter.onFinishHandler(this.ai),
|
|
@@ -51113,8 +51034,18 @@ ${instance.prompt}`;
|
|
|
51113
51034
|
console.error("Error in stream:", error81);
|
|
51114
51035
|
},
|
|
51115
51036
|
abortSignal: this.#abortController.signal
|
|
51037
|
+
};
|
|
51038
|
+
if (this.config.toolFormat === "native") {
|
|
51039
|
+
streamTextOptions.tools = this.#toolSet;
|
|
51040
|
+
}
|
|
51041
|
+
const stream = streamText(streamTextOptions);
|
|
51042
|
+
await stream.consumeStream({
|
|
51043
|
+
onError: (error81) => {
|
|
51044
|
+
console.error("Error in stream:", error81);
|
|
51045
|
+
}
|
|
51116
51046
|
});
|
|
51117
|
-
await stream.
|
|
51047
|
+
const resp = await stream.response;
|
|
51048
|
+
respMessages = resp.messages;
|
|
51118
51049
|
} catch (error81) {
|
|
51119
51050
|
if (error81 instanceof Error && error81.name === "AbortError") {
|
|
51120
51051
|
break;
|
|
@@ -51125,7 +51056,7 @@ ${instance.prompt}`;
|
|
|
51125
51056
|
clearTimeout(timeout);
|
|
51126
51057
|
}
|
|
51127
51058
|
}
|
|
51128
|
-
if (
|
|
51059
|
+
if (respMessages.length > 0) {
|
|
51129
51060
|
break;
|
|
51130
51061
|
}
|
|
51131
51062
|
if (this.#aborted) {
|
|
@@ -51133,17 +51064,45 @@ ${instance.prompt}`;
|
|
|
51133
51064
|
}
|
|
51134
51065
|
console.debug(`Retrying request ${i + 1} of ${retryCount}`);
|
|
51135
51066
|
}
|
|
51136
|
-
if (
|
|
51067
|
+
if (respMessages.length === 0) {
|
|
51137
51068
|
if (this.#aborted) {
|
|
51138
51069
|
return [];
|
|
51139
51070
|
}
|
|
51140
51071
|
throw new Error("No assistant message received");
|
|
51141
51072
|
}
|
|
51142
|
-
|
|
51143
|
-
this
|
|
51144
|
-
|
|
51145
|
-
|
|
51146
|
-
|
|
51073
|
+
this.#messages.push(...respMessages);
|
|
51074
|
+
if (this.config.toolFormat === "native") {
|
|
51075
|
+
return respMessages.flatMap((msg) => {
|
|
51076
|
+
if (msg.role === "assistant") {
|
|
51077
|
+
const content = msg.content;
|
|
51078
|
+
if (typeof content === "string") {
|
|
51079
|
+
return [{ type: "text", content }];
|
|
51080
|
+
}
|
|
51081
|
+
return content.flatMap((part) => {
|
|
51082
|
+
if (part.type === "text") {
|
|
51083
|
+
return [{ type: "text", content: part.text }];
|
|
51084
|
+
}
|
|
51085
|
+
if (part.type === "tool-call") {
|
|
51086
|
+
return [{ type: "tool_use", id: part.toolCallId, name: part.toolName, params: part.input }];
|
|
51087
|
+
}
|
|
51088
|
+
return [];
|
|
51089
|
+
});
|
|
51090
|
+
}
|
|
51091
|
+
return [];
|
|
51092
|
+
});
|
|
51093
|
+
}
|
|
51094
|
+
const currentAssistantMessage = respMessages.map((msg) => {
|
|
51095
|
+
if (typeof msg.content === "string") {
|
|
51096
|
+
return msg.content;
|
|
51097
|
+
}
|
|
51098
|
+
return msg.content.map((part) => {
|
|
51099
|
+
if (part.type === "text") {
|
|
51100
|
+
return part.text;
|
|
51101
|
+
}
|
|
51102
|
+
return "";
|
|
51103
|
+
});
|
|
51104
|
+
}).join(`
|
|
51105
|
+
`);
|
|
51147
51106
|
const ret = parseAssistantMessage(currentAssistantMessage, this.config.tools.map(toToolInfoV1), this.config.toolNamePrefix);
|
|
51148
51107
|
await this.#callback({ kind: "EndRequest" /* EndRequest */, agent: this, message: currentAssistantMessage });
|
|
51149
51108
|
return ret;
|
|
@@ -51157,12 +51116,12 @@ ${instance.prompt}`;
|
|
|
51157
51116
|
case "text":
|
|
51158
51117
|
break;
|
|
51159
51118
|
case "tool_use": {
|
|
51160
|
-
await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name });
|
|
51119
|
+
await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name, content: content.params });
|
|
51161
51120
|
const toolResp = await this.#invokeTool(content.name, content.params);
|
|
51162
51121
|
switch (toolResp.type) {
|
|
51163
51122
|
case "Reply" /* Reply */: {
|
|
51164
|
-
await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name });
|
|
51165
|
-
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
51123
|
+
await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name, content: toolResp.message });
|
|
51124
|
+
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message, id: content.id });
|
|
51166
51125
|
break;
|
|
51167
51126
|
}
|
|
51168
51127
|
case "Exit" /* Exit */:
|
|
@@ -51171,17 +51130,17 @@ ${instance.prompt}`;
|
|
|
51171
51130
|
}
|
|
51172
51131
|
return { type: "exit", reason: toolResp };
|
|
51173
51132
|
case "Invalid" /* Invalid */: {
|
|
51174
|
-
await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name });
|
|
51175
|
-
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
51133
|
+
await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name, content: toolResp.message });
|
|
51134
|
+
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message, id: content.id });
|
|
51176
51135
|
break outer;
|
|
51177
51136
|
}
|
|
51178
51137
|
case "Error" /* Error */: {
|
|
51179
|
-
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name });
|
|
51180
|
-
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
51138
|
+
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, content: toolResp.message });
|
|
51139
|
+
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message, id: content.id });
|
|
51181
51140
|
break outer;
|
|
51182
51141
|
}
|
|
51183
51142
|
case "Interrupted" /* Interrupted */:
|
|
51184
|
-
await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name });
|
|
51143
|
+
await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name, content: toolResp.message });
|
|
51185
51144
|
return { type: "exit", reason: toolResp };
|
|
51186
51145
|
case "HandOver" /* HandOver */: {
|
|
51187
51146
|
if (toolResponses.length > 0) {
|
|
@@ -51215,7 +51174,7 @@ ${instance.prompt}`;
|
|
|
51215
51174
|
}
|
|
51216
51175
|
case "Pause" /* Pause */: {
|
|
51217
51176
|
await this.#callback({ kind: "ToolPause" /* ToolPause */, agent: this, tool: content.name, object: toolResp.object });
|
|
51218
|
-
toolResponses.push({ type: "pause", tool: content.name, object: toolResp.object });
|
|
51177
|
+
toolResponses.push({ type: "pause", tool: content.name, object: toolResp.object, id: content.id });
|
|
51219
51178
|
hasPause = true;
|
|
51220
51179
|
}
|
|
51221
51180
|
}
|
|
@@ -51227,10 +51186,49 @@ ${instance.prompt}`;
|
|
|
51227
51186
|
return { type: "exit", reason: { type: "Pause", responses: toolResponses } };
|
|
51228
51187
|
}
|
|
51229
51188
|
if (toolResponses.length === 0) {
|
|
51230
|
-
return {
|
|
51189
|
+
return {
|
|
51190
|
+
type: "reply",
|
|
51191
|
+
message: {
|
|
51192
|
+
role: "user",
|
|
51193
|
+
content: responsePrompts.requireUseToolNative
|
|
51194
|
+
}
|
|
51195
|
+
};
|
|
51196
|
+
}
|
|
51197
|
+
if (this.config.toolFormat === "native") {
|
|
51198
|
+
const toolResults = toolResponses.filter((resp) => resp.type === "response").map((resp) => ({
|
|
51199
|
+
type: "tool-result",
|
|
51200
|
+
toolCallId: resp.id,
|
|
51201
|
+
toolName: resp.tool,
|
|
51202
|
+
output: {
|
|
51203
|
+
type: "text",
|
|
51204
|
+
value: resp.response
|
|
51205
|
+
}
|
|
51206
|
+
}));
|
|
51207
|
+
return {
|
|
51208
|
+
type: "reply",
|
|
51209
|
+
message: {
|
|
51210
|
+
role: "tool",
|
|
51211
|
+
content: toolResults
|
|
51212
|
+
}
|
|
51213
|
+
};
|
|
51214
|
+
}
|
|
51215
|
+
if (toolResponses.length === 0) {
|
|
51216
|
+
return {
|
|
51217
|
+
type: "reply",
|
|
51218
|
+
message: {
|
|
51219
|
+
role: "user",
|
|
51220
|
+
content: responsePrompts.requireUseTool
|
|
51221
|
+
}
|
|
51222
|
+
};
|
|
51231
51223
|
}
|
|
51232
51224
|
const finalResp = toolResponses.filter((resp) => resp.type === "response").flatMap(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2));
|
|
51233
|
-
return {
|
|
51225
|
+
return {
|
|
51226
|
+
type: "reply",
|
|
51227
|
+
message: {
|
|
51228
|
+
role: "user",
|
|
51229
|
+
content: finalResp
|
|
51230
|
+
}
|
|
51231
|
+
};
|
|
51234
51232
|
}
|
|
51235
51233
|
async#invokeTool(name17, args) {
|
|
51236
51234
|
try {
|
|
@@ -51271,6 +51269,80 @@ ${instance.prompt}`;
|
|
|
51271
51269
|
}
|
|
51272
51270
|
}
|
|
51273
51271
|
|
|
51272
|
+
// ../core/src/Agent/AnalyzerAgent/prompts.ts
|
|
51273
|
+
var fullSystemPrompt = (info, tools, toolNamePrefix, instructions, scripts, useNativeTool) => `
|
|
51274
|
+
# Analyzer Agent
|
|
51275
|
+
|
|
51276
|
+
## Role
|
|
51277
|
+
You are the **Analyzer** agent, responsible for:
|
|
51278
|
+
1. **Project Structure Analysis** – Understand codebase organization and architecture.
|
|
51279
|
+
2. **Code Pattern Analysis** – Identify common patterns, conventions, and best practices.
|
|
51280
|
+
3. **Dependency Analysis** – Examine project dependencies and their usage.
|
|
51281
|
+
4. **Workflow Analysis** – Understand development tools, scripts, and processes.
|
|
51282
|
+
5. **Documentation Review** – Analyze documentation and code comments.
|
|
51283
|
+
|
|
51284
|
+
> **Note**: The **Analyzer** agent focuses on understanding and analyzing the codebase without making modifications. Your role is to provide insights and understanding that can inform development decisions.
|
|
51285
|
+
|
|
51286
|
+
## Rules
|
|
51287
|
+
1. **Thoroughness**: Conduct comprehensive analysis of relevant project aspects.
|
|
51288
|
+
2. **Pattern Recognition**: Identify recurring patterns, conventions, and architectural decisions.
|
|
51289
|
+
3. **Dependency Mapping**: Track and understand relationships between components.
|
|
51290
|
+
4. **Workflow Understanding**: Analyze build processes, testing approaches, and development tools.
|
|
51291
|
+
5. **Documentation Assessment**: Review documentation quality and completeness.
|
|
51292
|
+
6. **Non-Modification**: Never modify code or files - focus solely on analysis.
|
|
51293
|
+
|
|
51294
|
+
${useNativeTool ? "" : toolUsePrompt(tools, toolNamePrefix)}
|
|
51295
|
+
${capabilities(toolNamePrefix)}
|
|
51296
|
+
${systemInformation(info)}
|
|
51297
|
+
${customInstructions(instructions)}
|
|
51298
|
+
${customScripts(scripts)}
|
|
51299
|
+
`;
|
|
51300
|
+
|
|
51301
|
+
// ../core/src/Agent/AnalyzerAgent/index.ts
|
|
51302
|
+
class AnalyzerAgent extends AgentBase {
|
|
51303
|
+
constructor(options) {
|
|
51304
|
+
const combinedTools = [...options.additionalTools ?? [], ...Object.values(exports_allTools)];
|
|
51305
|
+
const tools = getAvailableTools({
|
|
51306
|
+
provider: options.provider,
|
|
51307
|
+
allTools: combinedTools,
|
|
51308
|
+
hasAgent: (options.agents?.length ?? 0) > 0,
|
|
51309
|
+
permissionLevel: 1 /* Read */,
|
|
51310
|
+
interactive: true
|
|
51311
|
+
});
|
|
51312
|
+
const toolNamePrefix = options.toolFormat === "native" ? "" : "tool_";
|
|
51313
|
+
const systemPrompt = fullSystemPrompt({
|
|
51314
|
+
os: options.os
|
|
51315
|
+
}, tools, toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {}, options.toolFormat === "native");
|
|
51316
|
+
super(analyzerAgentInfo.name, options.ai, {
|
|
51317
|
+
systemPrompt,
|
|
51318
|
+
tools,
|
|
51319
|
+
toolNamePrefix,
|
|
51320
|
+
provider: options.provider,
|
|
51321
|
+
interactive: options.interactive,
|
|
51322
|
+
agents: options.agents,
|
|
51323
|
+
scripts: options.scripts,
|
|
51324
|
+
callback: options.callback,
|
|
51325
|
+
policies: options.policies,
|
|
51326
|
+
toolFormat: options.toolFormat,
|
|
51327
|
+
parameters: options.parameters ?? {},
|
|
51328
|
+
usageMeter: options.usageMeter ?? new UsageMeter
|
|
51329
|
+
});
|
|
51330
|
+
}
|
|
51331
|
+
onBeforeInvokeTool() {
|
|
51332
|
+
return Promise.resolve(undefined);
|
|
51333
|
+
}
|
|
51334
|
+
}
|
|
51335
|
+
var analyzerAgentInfo = {
|
|
51336
|
+
name: "analyzer",
|
|
51337
|
+
responsibilities: [
|
|
51338
|
+
"Analyzing project structure and organization",
|
|
51339
|
+
"Identifying key source code files and their relationships",
|
|
51340
|
+
"Understanding common coding patterns and conventions",
|
|
51341
|
+
"Examining development workflow and tooling",
|
|
51342
|
+
"Analyzing dependencies and their usage patterns"
|
|
51343
|
+
]
|
|
51344
|
+
};
|
|
51345
|
+
|
|
51274
51346
|
// ../core/src/Agent/CodeFixerAgent/prompts.ts
|
|
51275
51347
|
var basePrompt = `You are a highly skilled software engineer specializing in debugging and fixing code issues. You have extensive experience with:
|
|
51276
51348
|
- Type systems and type checking
|
|
@@ -51337,7 +51409,7 @@ RETRY GUIDELINES
|
|
|
51337
51409
|
- Explain why the issue remains
|
|
51338
51410
|
- Suggest manual intervention steps
|
|
51339
51411
|
- Report any partial improvements`;
|
|
51340
|
-
var fullSystemPrompt3 = (info, tools, toolNamePrefix, instructions, scripts,
|
|
51412
|
+
var fullSystemPrompt3 = (info, tools, toolNamePrefix, instructions, scripts, _interactive, useNativeTool) => `
|
|
51341
51413
|
${basePrompt}
|
|
51342
51414
|
${useNativeTool ? "" : toolUsePrompt(tools, toolNamePrefix)}
|
|
51343
51415
|
${codeFixingStrategies}
|
|
@@ -51360,10 +51432,10 @@ class CodeFixerAgent extends AgentBase {
|
|
|
51360
51432
|
permissionLevel: 3 /* Arbitrary */,
|
|
51361
51433
|
interactive: true
|
|
51362
51434
|
});
|
|
51363
|
-
const toolNamePrefix = "tool_";
|
|
51435
|
+
const toolNamePrefix = options.toolFormat === "native" ? "" : "tool_";
|
|
51364
51436
|
const systemPrompt = fullSystemPrompt3({
|
|
51365
51437
|
os: options.os
|
|
51366
|
-
}, tools
|
|
51438
|
+
}, tools, toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {}, options.interactive, options.toolFormat === "native");
|
|
51367
51439
|
super(codeFixerAgentInfo.name, options.ai, {
|
|
51368
51440
|
systemPrompt,
|
|
51369
51441
|
tools,
|
|
@@ -51380,7 +51452,7 @@ class CodeFixerAgent extends AgentBase {
|
|
|
51380
51452
|
});
|
|
51381
51453
|
this.#maxRetries = options.maxRetries ?? 5;
|
|
51382
51454
|
}
|
|
51383
|
-
async onBeforeInvokeTool(name17,
|
|
51455
|
+
async onBeforeInvokeTool(name17, _args) {
|
|
51384
51456
|
if (name17 === attemptCompletion_default.name) {
|
|
51385
51457
|
if (this.#retryCount > this.#maxRetries) {
|
|
51386
51458
|
return;
|
|
@@ -51609,23 +51681,23 @@ var prompt = `You are an AiTool designed to assist users in creating new project
|
|
|
51609
51681
|
- Create a .gitattributes file with appropriate configurations:
|
|
51610
51682
|
- Mark lock files as generated and exclude them from diffs
|
|
51611
51683
|
- Example for different package managers:
|
|
51612
|
-
|
|
51684
|
+
|
|
51613
51685
|
# For Bun
|
|
51614
51686
|
bun.lock linguist-generated=true
|
|
51615
51687
|
bun.lock -diff
|
|
51616
|
-
|
|
51688
|
+
|
|
51617
51689
|
# For npm
|
|
51618
51690
|
package-lock.json linguist-generated=true
|
|
51619
51691
|
package-lock.json -diff
|
|
51620
|
-
|
|
51692
|
+
|
|
51621
51693
|
# For Yarn
|
|
51622
51694
|
yarn.lock linguist-generated=true
|
|
51623
51695
|
yarn.lock -diff
|
|
51624
|
-
|
|
51696
|
+
|
|
51625
51697
|
# For pnpm
|
|
51626
51698
|
pnpm-lock.yaml linguist-generated=true
|
|
51627
51699
|
pnpm-lock.yaml -diff
|
|
51628
|
-
|
|
51700
|
+
|
|
51629
51701
|
- Include other common configurations as needed based on project type
|
|
51630
51702
|
|
|
51631
51703
|
6. **Handover to Coder Agent:**
|
|
@@ -51881,6 +51953,184 @@ var generateProjectConfig_default = {
|
|
|
51881
51953
|
agent: "analyzer"
|
|
51882
51954
|
};
|
|
51883
51955
|
|
|
51956
|
+
// ../core/src/AiTool/tools/gitDiff.ts
|
|
51957
|
+
var toolInfo14 = {
|
|
51958
|
+
name: "git_diff",
|
|
51959
|
+
description: "Get the git diff for the current repository. Can be used to get staged changes, unstaged changes, or changes between commits. By default, it returns unstaged changes.",
|
|
51960
|
+
parameters: exports_external.object({
|
|
51961
|
+
staged: exports_external.preprocess((val) => {
|
|
51962
|
+
if (typeof val === "string") {
|
|
51963
|
+
const lower = val.toLowerCase();
|
|
51964
|
+
if (lower === "false")
|
|
51965
|
+
return false;
|
|
51966
|
+
if (lower === "true")
|
|
51967
|
+
return true;
|
|
51968
|
+
}
|
|
51969
|
+
return val;
|
|
51970
|
+
}, exports_external.boolean().optional().default(false)).describe("Get staged changes instead of unstaged changes."),
|
|
51971
|
+
commitRange: exports_external.string().optional().describe('The commit range to get the diff for (e.g., "main...HEAD").'),
|
|
51972
|
+
file: exports_external.string().optional().describe("Get the diff for a specific file.")
|
|
51973
|
+
}),
|
|
51974
|
+
permissionLevel: 1 /* Read */
|
|
51975
|
+
};
|
|
51976
|
+
var handler14 = async (provider2, args) => {
|
|
51977
|
+
if (!provider2.executeCommand) {
|
|
51978
|
+
return {
|
|
51979
|
+
type: "Error" /* Error */,
|
|
51980
|
+
message: "Not possible to execute command. Abort."
|
|
51981
|
+
};
|
|
51982
|
+
}
|
|
51983
|
+
const { staged, file: file3, commitRange } = toolInfo14.parameters.parse(args);
|
|
51984
|
+
const commandParts = ["git", "diff", "--no-color"];
|
|
51985
|
+
if (staged) {
|
|
51986
|
+
commandParts.push("--staged");
|
|
51987
|
+
}
|
|
51988
|
+
if (commitRange) {
|
|
51989
|
+
commandParts.push(commitRange);
|
|
51990
|
+
}
|
|
51991
|
+
if (file3) {
|
|
51992
|
+
commandParts.push("--", file3);
|
|
51993
|
+
}
|
|
51994
|
+
const command = commandParts.join(" ");
|
|
51995
|
+
try {
|
|
51996
|
+
const result = await provider2.executeCommand(command, false);
|
|
51997
|
+
if (result.exitCode === 0) {
|
|
51998
|
+
if (!result.stdout.trim()) {
|
|
51999
|
+
return {
|
|
52000
|
+
type: "Reply" /* Reply */,
|
|
52001
|
+
message: "No diff found."
|
|
52002
|
+
};
|
|
52003
|
+
}
|
|
52004
|
+
return {
|
|
52005
|
+
type: "Reply" /* Reply */,
|
|
52006
|
+
message: `<diff file="${file3 ?? "all"}">
|
|
52007
|
+
${result.stdout}
|
|
52008
|
+
</diff>`
|
|
52009
|
+
};
|
|
52010
|
+
}
|
|
52011
|
+
return {
|
|
52012
|
+
type: "Error" /* Error */,
|
|
52013
|
+
message: `\`${command}\` exited with code ${result.exitCode}:
|
|
52014
|
+
${result.stderr}`
|
|
52015
|
+
};
|
|
52016
|
+
} catch (error81) {
|
|
52017
|
+
return {
|
|
52018
|
+
type: "Error" /* Error */,
|
|
52019
|
+
message: error81 instanceof Error ? error81.message : String(error81)
|
|
52020
|
+
};
|
|
52021
|
+
}
|
|
52022
|
+
};
|
|
52023
|
+
var isAvailable14 = (provider2) => {
|
|
52024
|
+
return !!provider2.executeCommand;
|
|
52025
|
+
};
|
|
52026
|
+
var gitDiff_default = {
|
|
52027
|
+
...toolInfo14,
|
|
52028
|
+
handler: handler14,
|
|
52029
|
+
isAvailable: isAvailable14
|
|
52030
|
+
};
|
|
52031
|
+
|
|
52032
|
+
// ../core/src/AiTool/reviewDiff.ts
|
|
52033
|
+
var prompt5 = `
|
|
52034
|
+
# Code Review Prompt
|
|
52035
|
+
|
|
52036
|
+
You are a senior software engineer reviewing code changes.
|
|
52037
|
+
|
|
52038
|
+
## Viewing Changes
|
|
52039
|
+
- Use **git_diff** to inspect code.
|
|
52040
|
+
- **Pull request**: use the provided commit range.
|
|
52041
|
+
- **Local changes**: diff staged or unstaged files.
|
|
52042
|
+
- If a pull request is present you may receive:
|
|
52043
|
+
- <pr_title>
|
|
52044
|
+
- <pr_description>
|
|
52045
|
+
- <commit_messages>
|
|
52046
|
+
- A <review_instructions> tag tells you the focus of the review.
|
|
52047
|
+
|
|
52048
|
+
## Focus Areas
|
|
52049
|
+
- Readability and maintainability
|
|
52050
|
+
- Correctness, edge cases, potential bugs
|
|
52051
|
+
- Performance implications
|
|
52052
|
+
- Clarity of intent
|
|
52053
|
+
- Best-practice adherence
|
|
52054
|
+
|
|
52055
|
+
## Output Format
|
|
52056
|
+
Do **not** include praise or positive feedback. Ignore generated files such as lock files.
|
|
52057
|
+
|
|
52058
|
+
Return your review as a JSON object inside a \`\`\`json block, wrapped like:
|
|
52059
|
+
<tool_attempt_completion>
|
|
52060
|
+
<tool_parameter_result>
|
|
52061
|
+
\`\`\`json
|
|
52062
|
+
{
|
|
52063
|
+
"overview": "Summary of overall concerns.",
|
|
52064
|
+
"specificReviews": [
|
|
52065
|
+
{
|
|
52066
|
+
"file": "path/filename.ext",
|
|
52067
|
+
"lines": "N or N-M",
|
|
52068
|
+
"review": "Describe the issue and actionable fix or improvement."
|
|
52069
|
+
}
|
|
52070
|
+
]
|
|
52071
|
+
}
|
|
52072
|
+
\`\`\`
|
|
52073
|
+
</tool_parameter_result>
|
|
52074
|
+
</tool_attempt_completion>
|
|
52075
|
+
`;
|
|
52076
|
+
var reviewDiff_default = {
|
|
52077
|
+
name: "reviewDiff",
|
|
52078
|
+
description: "Reviews a git diff",
|
|
52079
|
+
prompt: prompt5,
|
|
52080
|
+
formatInput: (params) => {
|
|
52081
|
+
const parts = [];
|
|
52082
|
+
if (params.pullRequestTitle) {
|
|
52083
|
+
parts.push(`<pr_title>
|
|
52084
|
+
${params.pullRequestTitle}
|
|
52085
|
+
</pr_title>`);
|
|
52086
|
+
}
|
|
52087
|
+
if (params.pullRequestDescription) {
|
|
52088
|
+
parts.push(`<pr_description>
|
|
52089
|
+
${params.pullRequestDescription}
|
|
52090
|
+
</pr_description>`);
|
|
52091
|
+
}
|
|
52092
|
+
if (params.commitMessages) {
|
|
52093
|
+
parts.push(`<commit_messages>
|
|
52094
|
+
${params.commitMessages}
|
|
52095
|
+
</commit_messages>`);
|
|
52096
|
+
}
|
|
52097
|
+
let instructions = "";
|
|
52098
|
+
if (params.commitRange) {
|
|
52099
|
+
instructions = `Review the pull request. Get the diff using the git_diff tool with the commit range '${params.commitRange}'.`;
|
|
52100
|
+
} else if (params.staged) {
|
|
52101
|
+
instructions = "Review the staged changes. Get the diff using the git_diff tool with staged: true.";
|
|
52102
|
+
} else {
|
|
52103
|
+
instructions = "Review the unstaged changes. Get the diff using the git_diff tool.";
|
|
52104
|
+
}
|
|
52105
|
+
parts.push(`<review_instructions>
|
|
52106
|
+
${instructions}
|
|
52107
|
+
</review_instructions>`);
|
|
52108
|
+
return parts.join(`
|
|
52109
|
+
`);
|
|
52110
|
+
},
|
|
52111
|
+
parseOutput: (output) => {
|
|
52112
|
+
const jsonBlockRegex = /```json\n([\s\S]*?)\n```/;
|
|
52113
|
+
const match = output.match(jsonBlockRegex);
|
|
52114
|
+
const content = match ? match[1] : output;
|
|
52115
|
+
try {
|
|
52116
|
+
return JSON.parse(content);
|
|
52117
|
+
} catch (error81) {
|
|
52118
|
+
console.error("Error parsing JSON output:", error81);
|
|
52119
|
+
return {
|
|
52120
|
+
overview: `Could not parse review output. Raw output:
|
|
52121
|
+
${output}`,
|
|
52122
|
+
specificReviews: []
|
|
52123
|
+
};
|
|
52124
|
+
}
|
|
52125
|
+
},
|
|
52126
|
+
agent: (options) => {
|
|
52127
|
+
return new AnalyzerAgent({
|
|
52128
|
+
...options,
|
|
52129
|
+
additionalTools: [gitDiff_default]
|
|
52130
|
+
});
|
|
52131
|
+
}
|
|
52132
|
+
};
|
|
52133
|
+
|
|
51884
52134
|
// ../core/src/AiTool/index.ts
|
|
51885
52135
|
var executeTool = async (definition, ai, params, usageMeter) => {
|
|
51886
52136
|
const resp = await generateText({
|
|
@@ -51896,10 +52146,7 @@ var executeTool = async (definition, ai, params, usageMeter) => {
|
|
|
51896
52146
|
usageMeter.addUsage(ai, resp);
|
|
51897
52147
|
return definition.parseOutput(resp.text);
|
|
51898
52148
|
};
|
|
51899
|
-
var
|
|
51900
|
-
if (!definition.agent) {
|
|
51901
|
-
throw new Error("Agent not specified");
|
|
51902
|
-
}
|
|
52149
|
+
var executeMultiAgentTool = async (definition, agent, params) => {
|
|
51903
52150
|
const exitReason = await agent.startTask({
|
|
51904
52151
|
agentName: definition.agent,
|
|
51905
52152
|
task: definition.prompt,
|
|
@@ -51910,22 +52157,38 @@ var executeAgentTool = async (definition, agent, params) => {
|
|
|
51910
52157
|
}
|
|
51911
52158
|
throw new Error(`Tool execution failed: ${exitReason.type}`);
|
|
51912
52159
|
};
|
|
52160
|
+
var executeAgentTool = async (definition, options, params) => {
|
|
52161
|
+
const agent = definition.agent(options);
|
|
52162
|
+
const exitReason = await agent.start(`${definition.prompt}
|
|
52163
|
+
|
|
52164
|
+
${definition.formatInput(params)}`);
|
|
52165
|
+
if (exitReason.type === "Exit" /* Exit */) {
|
|
52166
|
+
return definition.parseOutput(exitReason.message);
|
|
52167
|
+
}
|
|
52168
|
+
throw new Error(`Tool execution failed: ${exitReason.type}`);
|
|
52169
|
+
};
|
|
51913
52170
|
var makeTool = (definition) => {
|
|
51914
52171
|
return async (ai, params, usageMeter) => {
|
|
51915
52172
|
return executeTool(definition, ai, params, usageMeter);
|
|
51916
52173
|
};
|
|
51917
52174
|
};
|
|
51918
|
-
var
|
|
52175
|
+
var makeMultiAgentTool = (definition) => {
|
|
51919
52176
|
return async (agent, params) => {
|
|
51920
|
-
return
|
|
52177
|
+
return executeMultiAgentTool(definition, agent, params);
|
|
52178
|
+
};
|
|
52179
|
+
};
|
|
52180
|
+
var makeAgentTool = (definition) => {
|
|
52181
|
+
return async (options, params) => {
|
|
52182
|
+
return executeAgentTool(definition, options, params);
|
|
51921
52183
|
};
|
|
51922
52184
|
};
|
|
51923
52185
|
var generateGitCommitMessage = makeTool(generateGitCommitMessage_default);
|
|
51924
52186
|
var generateGithubPullRequestDetails = makeTool(generateGithubPullRequestDetails_default);
|
|
51925
|
-
var
|
|
51926
|
-
var
|
|
52187
|
+
var reviewDiff = makeAgentTool(reviewDiff_default);
|
|
52188
|
+
var generateProjectConfig = makeMultiAgentTool(generateProjectConfig_default);
|
|
52189
|
+
var createNewProject = makeMultiAgentTool(createNewProject_default);
|
|
51927
52190
|
// src/config.ts
|
|
51928
|
-
var
|
|
52191
|
+
var import_lodash2 = __toESM(require_lodash(), 1);
|
|
51929
52192
|
|
|
51930
52193
|
// node_modules/yaml/dist/index.js
|
|
51931
52194
|
var composer = require_composer();
|
|
@@ -55814,7 +56077,7 @@ function getGlobalConfigPath(home = homedir()) {
|
|
|
55814
56077
|
function loadConfigAtPath(path) {
|
|
55815
56078
|
try {
|
|
55816
56079
|
return readConfig(path);
|
|
55817
|
-
} catch (
|
|
56080
|
+
} catch (_error) {
|
|
55818
56081
|
return;
|
|
55819
56082
|
}
|
|
55820
56083
|
}
|
|
@@ -55836,7 +56099,7 @@ function mergeConfigs(configs) {
|
|
|
55836
56099
|
return {};
|
|
55837
56100
|
}
|
|
55838
56101
|
const mergedConfig = configs.reduce((acc, config4) => {
|
|
55839
|
-
const merged =
|
|
56102
|
+
const merged = import_lodash2.merge({}, acc, config4);
|
|
55840
56103
|
let accRules = acc.rules ?? [];
|
|
55841
56104
|
if (typeof accRules === "string") {
|
|
55842
56105
|
accRules = [accRules];
|
|
@@ -55898,12 +56161,11 @@ var readConfig = (path) => {
|
|
|
55898
56161
|
var readLocalConfig = (path) => {
|
|
55899
56162
|
try {
|
|
55900
56163
|
return readConfig(path ?? localConfigFileName);
|
|
55901
|
-
} catch (
|
|
56164
|
+
} catch (_error) {
|
|
55902
56165
|
return;
|
|
55903
56166
|
}
|
|
55904
56167
|
};
|
|
55905
56168
|
// src/provider.ts
|
|
55906
|
-
var import_ignore2 = __toESM(require_ignore(), 1);
|
|
55907
56169
|
import { spawn as spawn2 } from "node:child_process";
|
|
55908
56170
|
import { mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
55909
56171
|
import { dirname } from "node:path";
|
|
@@ -56468,15 +56730,15 @@ function useKeypress(userHandler) {
|
|
|
56468
56730
|
signal.current = userHandler;
|
|
56469
56731
|
useEffect((rl) => {
|
|
56470
56732
|
let ignore = false;
|
|
56471
|
-
const
|
|
56733
|
+
const handler15 = withUpdates((_input, event) => {
|
|
56472
56734
|
if (ignore)
|
|
56473
56735
|
return;
|
|
56474
56736
|
signal.current(event, rl);
|
|
56475
56737
|
});
|
|
56476
|
-
rl.input.on("keypress",
|
|
56738
|
+
rl.input.on("keypress", handler15);
|
|
56477
56739
|
return () => {
|
|
56478
56740
|
ignore = true;
|
|
56479
|
-
rl.input.removeListener("keypress",
|
|
56741
|
+
rl.input.removeListener("keypress", handler15);
|
|
56480
56742
|
};
|
|
56481
56743
|
}, []);
|
|
56482
56744
|
}
|
|
@@ -56635,16 +56897,16 @@ class Emitter {
|
|
|
56635
56897
|
|
|
56636
56898
|
class SignalExitBase {
|
|
56637
56899
|
}
|
|
56638
|
-
var signalExitWrap = (
|
|
56900
|
+
var signalExitWrap = (handler15) => {
|
|
56639
56901
|
return {
|
|
56640
56902
|
onExit(cb, opts) {
|
|
56641
|
-
return
|
|
56903
|
+
return handler15.onExit(cb, opts);
|
|
56642
56904
|
},
|
|
56643
56905
|
load() {
|
|
56644
|
-
return
|
|
56906
|
+
return handler15.load();
|
|
56645
56907
|
},
|
|
56646
56908
|
unload() {
|
|
56647
|
-
return
|
|
56909
|
+
return handler15.unload();
|
|
56648
56910
|
}
|
|
56649
56911
|
};
|
|
56650
56912
|
};
|
|
@@ -56800,11 +57062,11 @@ class ScreenManager {
|
|
|
56800
57062
|
render(content, bottomContent = "") {
|
|
56801
57063
|
const promptLine = lastLine(content);
|
|
56802
57064
|
const rawPromptLine = stripVTControlCharacters(promptLine);
|
|
56803
|
-
let
|
|
57065
|
+
let prompt6 = rawPromptLine;
|
|
56804
57066
|
if (this.rl.line.length > 0) {
|
|
56805
|
-
|
|
57067
|
+
prompt6 = prompt6.slice(0, -this.rl.line.length);
|
|
56806
57068
|
}
|
|
56807
|
-
this.rl.setPrompt(
|
|
57069
|
+
this.rl.setPrompt(prompt6);
|
|
56808
57070
|
this.cursorPos = this.rl.getCursorPos();
|
|
56809
57071
|
const width = readlineWidth();
|
|
56810
57072
|
content = breakLines(content, width);
|
|
@@ -56874,7 +57136,7 @@ function getCallSites() {
|
|
|
56874
57136
|
}
|
|
56875
57137
|
function createPrompt(view) {
|
|
56876
57138
|
const callSites = getCallSites();
|
|
56877
|
-
const
|
|
57139
|
+
const prompt6 = (config4, context = {}) => {
|
|
56878
57140
|
const { input = process.stdin, signal } = context;
|
|
56879
57141
|
const cleanups = new Set;
|
|
56880
57142
|
const output = new import_mute_stream.default;
|
|
@@ -56939,7 +57201,7 @@ function createPrompt(view) {
|
|
|
56939
57201
|
}).then(() => promise4), { cancel });
|
|
56940
57202
|
});
|
|
56941
57203
|
};
|
|
56942
|
-
return
|
|
57204
|
+
return prompt6;
|
|
56943
57205
|
}
|
|
56944
57206
|
// ../../node_modules/@inquirer/core/dist/esm/lib/Separator.js
|
|
56945
57207
|
var import_yoctocolors_cjs2 = __toESM(require_yoctocolors_cjs(), 1);
|
|
@@ -57181,6 +57443,9 @@ ${theme.style.description(selectedChoice.description)}` : ``;
|
|
|
57181
57443
|
return `${[prefix, message, helpTipTop].filter(Boolean).join(" ")}
|
|
57182
57444
|
${page}${helpTipBottom}${choiceDescription}${import_ansi_escapes2.default.cursorHide}`;
|
|
57183
57445
|
});
|
|
57446
|
+
// src/provider.ts
|
|
57447
|
+
var import_ignore2 = __toESM(require_ignore(), 1);
|
|
57448
|
+
|
|
57184
57449
|
// src/utils/checkRipgrep.ts
|
|
57185
57450
|
import { spawnSync } from "node:child_process";
|
|
57186
57451
|
var rgAvailability = {
|
|
@@ -57343,7 +57608,7 @@ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
|
|
|
57343
57608
|
}
|
|
57344
57609
|
|
|
57345
57610
|
// src/provider.ts
|
|
57346
|
-
var getProvider = (
|
|
57611
|
+
var getProvider = (_agentName, _config, options = {}) => {
|
|
57347
57612
|
const ig = import_ignore2.default().add(options.excludeFiles ?? []);
|
|
57348
57613
|
const provider2 = {
|
|
57349
57614
|
readFile: async (path) => {
|
|
@@ -57378,7 +57643,7 @@ var getProvider = (agentName, config4, options = {}) => {
|
|
|
57378
57643
|
listFiles: async (path, recursive, maxCount) => {
|
|
57379
57644
|
return await listFiles(path, recursive, maxCount, process.cwd(), options.excludeFiles);
|
|
57380
57645
|
},
|
|
57381
|
-
executeCommand: (command,
|
|
57646
|
+
executeCommand: (command, _needApprove) => {
|
|
57382
57647
|
return new Promise((resolve3, reject) => {
|
|
57383
57648
|
options.command?.onStarted(command);
|
|
57384
57649
|
const child = spawn2(command, [], {
|
|
@@ -57429,7 +57694,7 @@ var getProvider = (agentName, config4, options = {}) => {
|
|
|
57429
57694
|
}
|
|
57430
57695
|
return answerOptions[0] ?? "<warning>This is non-interactive mode, no answer can be provided.</warning>";
|
|
57431
57696
|
},
|
|
57432
|
-
attemptCompletion: async (
|
|
57697
|
+
attemptCompletion: async (_result) => {
|
|
57433
57698
|
return;
|
|
57434
57699
|
},
|
|
57435
57700
|
fetchUrl: async (url3) => {
|
|
@@ -57963,7 +58228,7 @@ ${event.systemPrompt}`);
|
|
|
57963
58228
|
======== New Request ========
|
|
57964
58229
|
`);
|
|
57965
58230
|
if (verbose) {
|
|
57966
|
-
const
|
|
58231
|
+
const userMessage = event.userMessage.content;
|
|
57967
58232
|
if (typeof userMessage === "string") {
|
|
57968
58233
|
console.log(userMessage);
|
|
57969
58234
|
} else {
|
|
@@ -57982,9 +58247,17 @@ ${event.systemPrompt}`);
|
|
|
57982
58247
|
case "file":
|
|
57983
58248
|
console.log(source_default.yellow(`[File name: ${content.filename}, type: ${content.mediaType}]`));
|
|
57984
58249
|
break;
|
|
57985
|
-
|
|
57986
|
-
console.log(source_default.
|
|
57987
|
-
|
|
58250
|
+
case "tool-call":
|
|
58251
|
+
console.log(source_default.yellow(`[Tool call: ${content.toolName}]`));
|
|
58252
|
+
break;
|
|
58253
|
+
case "tool-result":
|
|
58254
|
+
console.log(source_default.yellow(`[Tool result: ${content.toolName}]`));
|
|
58255
|
+
if (verbose > 0) {
|
|
58256
|
+
console.log(content.output);
|
|
58257
|
+
}
|
|
58258
|
+
break;
|
|
58259
|
+
case "reasoning":
|
|
58260
|
+
break;
|
|
57988
58261
|
}
|
|
57989
58262
|
}
|
|
57990
58263
|
}
|
|
@@ -58018,29 +58291,33 @@ ${event.systemPrompt}`);
|
|
|
58018
58291
|
process.stdout.write(source_default.dim(event.newText));
|
|
58019
58292
|
hadReasoning = true;
|
|
58020
58293
|
break;
|
|
58021
|
-
case "ToolUse" /* ToolUse */:
|
|
58022
|
-
|
|
58023
|
-
|
|
58024
|
-
|
|
58025
|
-
|
|
58026
|
-
|
|
58294
|
+
case "ToolUse" /* ToolUse */: {
|
|
58295
|
+
console.log(source_default.yellow(`
|
|
58296
|
+
|
|
58297
|
+
Tool use:`, event.tool), event.content);
|
|
58298
|
+
const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
|
|
58299
|
+
stats.calls++;
|
|
58300
|
+
toolCallStats.set(event.tool, stats);
|
|
58027
58301
|
break;
|
|
58028
|
-
|
|
58029
|
-
|
|
58030
|
-
|
|
58031
|
-
|
|
58032
|
-
|
|
58033
|
-
}
|
|
58302
|
+
}
|
|
58303
|
+
case "ToolReply" /* ToolReply */: {
|
|
58304
|
+
const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
|
|
58305
|
+
stats.success++;
|
|
58306
|
+
toolCallStats.set(event.tool, stats);
|
|
58034
58307
|
break;
|
|
58308
|
+
}
|
|
58035
58309
|
case "ToolInvalid" /* ToolInvalid */:
|
|
58036
58310
|
break;
|
|
58037
|
-
case "ToolError" /* ToolError */:
|
|
58038
|
-
|
|
58039
|
-
|
|
58040
|
-
|
|
58041
|
-
|
|
58042
|
-
}
|
|
58311
|
+
case "ToolError" /* ToolError */: {
|
|
58312
|
+
console.error(source_default.red(`
|
|
58313
|
+
|
|
58314
|
+
Tool error:`, event.tool));
|
|
58315
|
+
console.error(source_default.red(event.content));
|
|
58316
|
+
const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
|
|
58317
|
+
stats.errors++;
|
|
58318
|
+
toolCallStats.set(event.tool, stats);
|
|
58043
58319
|
break;
|
|
58320
|
+
}
|
|
58044
58321
|
case "ToolInterrupted" /* ToolInterrupted */:
|
|
58045
58322
|
break;
|
|
58046
58323
|
case "ToolHandOver" /* ToolHandOver */:
|