@polka-codes/runner 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 +1276 -1011
- package/package.json +7 -4
package/dist/index.js
CHANGED
|
@@ -16180,333 +16180,6 @@ var require_public_api = __commonJS((exports) => {
|
|
|
16180
16180
|
exports.stringify = stringify;
|
|
16181
16181
|
});
|
|
16182
16182
|
|
|
16183
|
-
// ../../node_modules/ignore/index.js
|
|
16184
|
-
var require_ignore = __commonJS((exports, module) => {
|
|
16185
|
-
function makeArray(subject) {
|
|
16186
|
-
return Array.isArray(subject) ? subject : [subject];
|
|
16187
|
-
}
|
|
16188
|
-
var UNDEFINED = undefined;
|
|
16189
|
-
var EMPTY = "";
|
|
16190
|
-
var SPACE = " ";
|
|
16191
|
-
var ESCAPE = "\\";
|
|
16192
|
-
var REGEX_TEST_BLANK_LINE = /^\s+$/;
|
|
16193
|
-
var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
|
|
16194
|
-
var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
16195
|
-
var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
|
16196
|
-
var REGEX_SPLITALL_CRLF = /\r?\n/g;
|
|
16197
|
-
var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
|
|
16198
|
-
var REGEX_TEST_TRAILING_SLASH = /\/$/;
|
|
16199
|
-
var SLASH = "/";
|
|
16200
|
-
var TMP_KEY_IGNORE = "node-ignore";
|
|
16201
|
-
if (typeof Symbol !== "undefined") {
|
|
16202
|
-
TMP_KEY_IGNORE = Symbol.for("node-ignore");
|
|
16203
|
-
}
|
|
16204
|
-
var KEY_IGNORE = TMP_KEY_IGNORE;
|
|
16205
|
-
var define2 = (object5, key, value) => {
|
|
16206
|
-
Object.defineProperty(object5, key, { value });
|
|
16207
|
-
return value;
|
|
16208
|
-
};
|
|
16209
|
-
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
|
|
16210
|
-
var RETURN_FALSE = () => false;
|
|
16211
|
-
var sanitizeRange = (range) => range.replace(REGEX_REGEXP_RANGE, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY);
|
|
16212
|
-
var cleanRangeBackSlash = (slashes) => {
|
|
16213
|
-
const { length } = slashes;
|
|
16214
|
-
return slashes.slice(0, length - length % 2);
|
|
16215
|
-
};
|
|
16216
|
-
var REPLACERS = [
|
|
16217
|
-
[
|
|
16218
|
-
/^\uFEFF/,
|
|
16219
|
-
() => EMPTY
|
|
16220
|
-
],
|
|
16221
|
-
[
|
|
16222
|
-
/((?:\\\\)*?)(\\?\s+)$/,
|
|
16223
|
-
(_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)
|
|
16224
|
-
],
|
|
16225
|
-
[
|
|
16226
|
-
/(\\+?)\s/g,
|
|
16227
|
-
(_, m1) => {
|
|
16228
|
-
const { length } = m1;
|
|
16229
|
-
return m1.slice(0, length - length % 2) + SPACE;
|
|
16230
|
-
}
|
|
16231
|
-
],
|
|
16232
|
-
[
|
|
16233
|
-
/[\\$.|*+(){^]/g,
|
|
16234
|
-
(match) => `\\${match}`
|
|
16235
|
-
],
|
|
16236
|
-
[
|
|
16237
|
-
/(?!\\)\?/g,
|
|
16238
|
-
() => "[^/]"
|
|
16239
|
-
],
|
|
16240
|
-
[
|
|
16241
|
-
/^\//,
|
|
16242
|
-
() => "^"
|
|
16243
|
-
],
|
|
16244
|
-
[
|
|
16245
|
-
/\//g,
|
|
16246
|
-
() => "\\/"
|
|
16247
|
-
],
|
|
16248
|
-
[
|
|
16249
|
-
/^\^*\\\*\\\*\\\//,
|
|
16250
|
-
() => "^(?:.*\\/)?"
|
|
16251
|
-
],
|
|
16252
|
-
[
|
|
16253
|
-
/^(?=[^^])/,
|
|
16254
|
-
function startingReplacer() {
|
|
16255
|
-
return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^";
|
|
16256
|
-
}
|
|
16257
|
-
],
|
|
16258
|
-
[
|
|
16259
|
-
/\\\/\\\*\\\*(?=\\\/|$)/g,
|
|
16260
|
-
(_, index, str) => index + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+"
|
|
16261
|
-
],
|
|
16262
|
-
[
|
|
16263
|
-
/(^|[^\\]+)(\\\*)+(?=.+)/g,
|
|
16264
|
-
(_, p1, p2) => {
|
|
16265
|
-
const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
|
|
16266
|
-
return p1 + unescaped;
|
|
16267
|
-
}
|
|
16268
|
-
],
|
|
16269
|
-
[
|
|
16270
|
-
/\\\\\\(?=[$.|*+(){^])/g,
|
|
16271
|
-
() => ESCAPE
|
|
16272
|
-
],
|
|
16273
|
-
[
|
|
16274
|
-
/\\\\/g,
|
|
16275
|
-
() => ESCAPE
|
|
16276
|
-
],
|
|
16277
|
-
[
|
|
16278
|
-
/(\\)?\[([^\]/]*?)(\\*)($|\])/g,
|
|
16279
|
-
(match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range)}${endEscape}]` : "[]" : "[]"
|
|
16280
|
-
],
|
|
16281
|
-
[
|
|
16282
|
-
/(?:[^*])$/,
|
|
16283
|
-
(match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)`
|
|
16284
|
-
]
|
|
16285
|
-
];
|
|
16286
|
-
var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\\\*$/;
|
|
16287
|
-
var MODE_IGNORE = "regex";
|
|
16288
|
-
var MODE_CHECK_IGNORE = "checkRegex";
|
|
16289
|
-
var UNDERSCORE = "_";
|
|
16290
|
-
var TRAILING_WILD_CARD_REPLACERS = {
|
|
16291
|
-
[MODE_IGNORE](_, p1) {
|
|
16292
|
-
const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
|
|
16293
|
-
return `${prefix}(?=$|\\/$)`;
|
|
16294
|
-
},
|
|
16295
|
-
[MODE_CHECK_IGNORE](_, p1) {
|
|
16296
|
-
const prefix = p1 ? `${p1}[^/]*` : "[^/]*";
|
|
16297
|
-
return `${prefix}(?=$|\\/$)`;
|
|
16298
|
-
}
|
|
16299
|
-
};
|
|
16300
|
-
var makeRegexPrefix = (pattern) => REPLACERS.reduce((prev, [matcher, replacer]) => prev.replace(matcher, replacer.bind(pattern)), pattern);
|
|
16301
|
-
var isString = (subject) => typeof subject === "string";
|
|
16302
|
-
var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
|
|
16303
|
-
var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
|
|
16304
|
-
|
|
16305
|
-
class IgnoreRule {
|
|
16306
|
-
constructor(pattern, mark, body, ignoreCase, negative, prefix) {
|
|
16307
|
-
this.pattern = pattern;
|
|
16308
|
-
this.mark = mark;
|
|
16309
|
-
this.negative = negative;
|
|
16310
|
-
define2(this, "body", body);
|
|
16311
|
-
define2(this, "ignoreCase", ignoreCase);
|
|
16312
|
-
define2(this, "regexPrefix", prefix);
|
|
16313
|
-
}
|
|
16314
|
-
get regex() {
|
|
16315
|
-
const key = UNDERSCORE + MODE_IGNORE;
|
|
16316
|
-
if (this[key]) {
|
|
16317
|
-
return this[key];
|
|
16318
|
-
}
|
|
16319
|
-
return this._make(MODE_IGNORE, key);
|
|
16320
|
-
}
|
|
16321
|
-
get checkRegex() {
|
|
16322
|
-
const key = UNDERSCORE + MODE_CHECK_IGNORE;
|
|
16323
|
-
if (this[key]) {
|
|
16324
|
-
return this[key];
|
|
16325
|
-
}
|
|
16326
|
-
return this._make(MODE_CHECK_IGNORE, key);
|
|
16327
|
-
}
|
|
16328
|
-
_make(mode, key) {
|
|
16329
|
-
const str = this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD, TRAILING_WILD_CARD_REPLACERS[mode]);
|
|
16330
|
-
const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
|
|
16331
|
-
return define2(this, key, regex);
|
|
16332
|
-
}
|
|
16333
|
-
}
|
|
16334
|
-
var createRule = ({
|
|
16335
|
-
pattern,
|
|
16336
|
-
mark
|
|
16337
|
-
}, ignoreCase) => {
|
|
16338
|
-
let negative = false;
|
|
16339
|
-
let body = pattern;
|
|
16340
|
-
if (body.indexOf("!") === 0) {
|
|
16341
|
-
negative = true;
|
|
16342
|
-
body = body.substr(1);
|
|
16343
|
-
}
|
|
16344
|
-
body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
|
|
16345
|
-
const regexPrefix = makeRegexPrefix(body);
|
|
16346
|
-
return new IgnoreRule(pattern, mark, body, ignoreCase, negative, regexPrefix);
|
|
16347
|
-
};
|
|
16348
|
-
|
|
16349
|
-
class RuleManager {
|
|
16350
|
-
constructor(ignoreCase) {
|
|
16351
|
-
this._ignoreCase = ignoreCase;
|
|
16352
|
-
this._rules = [];
|
|
16353
|
-
}
|
|
16354
|
-
_add(pattern) {
|
|
16355
|
-
if (pattern && pattern[KEY_IGNORE]) {
|
|
16356
|
-
this._rules = this._rules.concat(pattern._rules._rules);
|
|
16357
|
-
this._added = true;
|
|
16358
|
-
return;
|
|
16359
|
-
}
|
|
16360
|
-
if (isString(pattern)) {
|
|
16361
|
-
pattern = {
|
|
16362
|
-
pattern
|
|
16363
|
-
};
|
|
16364
|
-
}
|
|
16365
|
-
if (checkPattern(pattern.pattern)) {
|
|
16366
|
-
const rule = createRule(pattern, this._ignoreCase);
|
|
16367
|
-
this._added = true;
|
|
16368
|
-
this._rules.push(rule);
|
|
16369
|
-
}
|
|
16370
|
-
}
|
|
16371
|
-
add(pattern) {
|
|
16372
|
-
this._added = false;
|
|
16373
|
-
makeArray(isString(pattern) ? splitPattern(pattern) : pattern).forEach(this._add, this);
|
|
16374
|
-
return this._added;
|
|
16375
|
-
}
|
|
16376
|
-
test(path, checkUnignored, mode) {
|
|
16377
|
-
let ignored = false;
|
|
16378
|
-
let unignored = false;
|
|
16379
|
-
let matchedRule;
|
|
16380
|
-
this._rules.forEach((rule) => {
|
|
16381
|
-
const { negative } = rule;
|
|
16382
|
-
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
16383
|
-
return;
|
|
16384
|
-
}
|
|
16385
|
-
const matched = rule[mode].test(path);
|
|
16386
|
-
if (!matched) {
|
|
16387
|
-
return;
|
|
16388
|
-
}
|
|
16389
|
-
ignored = !negative;
|
|
16390
|
-
unignored = negative;
|
|
16391
|
-
matchedRule = negative ? UNDEFINED : rule;
|
|
16392
|
-
});
|
|
16393
|
-
const ret = {
|
|
16394
|
-
ignored,
|
|
16395
|
-
unignored
|
|
16396
|
-
};
|
|
16397
|
-
if (matchedRule) {
|
|
16398
|
-
ret.rule = matchedRule;
|
|
16399
|
-
}
|
|
16400
|
-
return ret;
|
|
16401
|
-
}
|
|
16402
|
-
}
|
|
16403
|
-
var throwError = (message, Ctor) => {
|
|
16404
|
-
throw new Ctor(message);
|
|
16405
|
-
};
|
|
16406
|
-
var checkPath = (path, originalPath, doThrow) => {
|
|
16407
|
-
if (!isString(path)) {
|
|
16408
|
-
return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
16409
|
-
}
|
|
16410
|
-
if (!path) {
|
|
16411
|
-
return doThrow(`path must not be empty`, TypeError);
|
|
16412
|
-
}
|
|
16413
|
-
if (checkPath.isNotRelative(path)) {
|
|
16414
|
-
const r = "`path.relative()`d";
|
|
16415
|
-
return doThrow(`path should be a ${r} string, but got "${originalPath}"`, RangeError);
|
|
16416
|
-
}
|
|
16417
|
-
return true;
|
|
16418
|
-
};
|
|
16419
|
-
var isNotRelative = (path) => REGEX_TEST_INVALID_PATH.test(path);
|
|
16420
|
-
checkPath.isNotRelative = isNotRelative;
|
|
16421
|
-
checkPath.convert = (p) => p;
|
|
16422
|
-
|
|
16423
|
-
class Ignore {
|
|
16424
|
-
constructor({
|
|
16425
|
-
ignorecase = true,
|
|
16426
|
-
ignoreCase = ignorecase,
|
|
16427
|
-
allowRelativePaths = false
|
|
16428
|
-
} = {}) {
|
|
16429
|
-
define2(this, KEY_IGNORE, true);
|
|
16430
|
-
this._rules = new RuleManager(ignoreCase);
|
|
16431
|
-
this._strictPathCheck = !allowRelativePaths;
|
|
16432
|
-
this._initCache();
|
|
16433
|
-
}
|
|
16434
|
-
_initCache() {
|
|
16435
|
-
this._ignoreCache = Object.create(null);
|
|
16436
|
-
this._testCache = Object.create(null);
|
|
16437
|
-
}
|
|
16438
|
-
add(pattern) {
|
|
16439
|
-
if (this._rules.add(pattern)) {
|
|
16440
|
-
this._initCache();
|
|
16441
|
-
}
|
|
16442
|
-
return this;
|
|
16443
|
-
}
|
|
16444
|
-
addPattern(pattern) {
|
|
16445
|
-
return this.add(pattern);
|
|
16446
|
-
}
|
|
16447
|
-
_test(originalPath, cache, checkUnignored, slices) {
|
|
16448
|
-
const path = originalPath && checkPath.convert(originalPath);
|
|
16449
|
-
checkPath(path, originalPath, this._strictPathCheck ? throwError : RETURN_FALSE);
|
|
16450
|
-
return this._t(path, cache, checkUnignored, slices);
|
|
16451
|
-
}
|
|
16452
|
-
checkIgnore(path) {
|
|
16453
|
-
if (!REGEX_TEST_TRAILING_SLASH.test(path)) {
|
|
16454
|
-
return this.test(path);
|
|
16455
|
-
}
|
|
16456
|
-
const slices = path.split(SLASH).filter(Boolean);
|
|
16457
|
-
slices.pop();
|
|
16458
|
-
if (slices.length) {
|
|
16459
|
-
const parent = this._t(slices.join(SLASH) + SLASH, this._testCache, true, slices);
|
|
16460
|
-
if (parent.ignored) {
|
|
16461
|
-
return parent;
|
|
16462
|
-
}
|
|
16463
|
-
}
|
|
16464
|
-
return this._rules.test(path, false, MODE_CHECK_IGNORE);
|
|
16465
|
-
}
|
|
16466
|
-
_t(path, cache, checkUnignored, slices) {
|
|
16467
|
-
if (path in cache) {
|
|
16468
|
-
return cache[path];
|
|
16469
|
-
}
|
|
16470
|
-
if (!slices) {
|
|
16471
|
-
slices = path.split(SLASH).filter(Boolean);
|
|
16472
|
-
}
|
|
16473
|
-
slices.pop();
|
|
16474
|
-
if (!slices.length) {
|
|
16475
|
-
return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE);
|
|
16476
|
-
}
|
|
16477
|
-
const parent = this._t(slices.join(SLASH) + SLASH, cache, checkUnignored, slices);
|
|
16478
|
-
return cache[path] = parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
|
|
16479
|
-
}
|
|
16480
|
-
ignores(path) {
|
|
16481
|
-
return this._test(path, this._ignoreCache, false).ignored;
|
|
16482
|
-
}
|
|
16483
|
-
createFilter() {
|
|
16484
|
-
return (path) => !this.ignores(path);
|
|
16485
|
-
}
|
|
16486
|
-
filter(paths) {
|
|
16487
|
-
return makeArray(paths).filter(this.createFilter());
|
|
16488
|
-
}
|
|
16489
|
-
test(path) {
|
|
16490
|
-
return this._test(path, this._testCache, true);
|
|
16491
|
-
}
|
|
16492
|
-
}
|
|
16493
|
-
var factory = (options) => new Ignore(options);
|
|
16494
|
-
var isPathValid = (path) => checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
|
|
16495
|
-
var setupWindows = () => {
|
|
16496
|
-
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
16497
|
-
checkPath.convert = makePosix;
|
|
16498
|
-
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
16499
|
-
checkPath.isNotRelative = (path) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
|
|
16500
|
-
};
|
|
16501
|
-
if (typeof process !== "undefined" && process.platform === "win32") {
|
|
16502
|
-
setupWindows();
|
|
16503
|
-
}
|
|
16504
|
-
module.exports = factory;
|
|
16505
|
-
factory.default = factory;
|
|
16506
|
-
module.exports.isPathValid = isPathValid;
|
|
16507
|
-
define2(module.exports, Symbol.for("setupWindows"), setupWindows);
|
|
16508
|
-
});
|
|
16509
|
-
|
|
16510
16183
|
// ../../node_modules/yoctocolors-cjs/index.js
|
|
16511
16184
|
var require_yoctocolors_cjs = __commonJS((exports, module) => {
|
|
16512
16185
|
var tty = __require("node:tty");
|
|
@@ -18150,6 +17823,333 @@ var require_ansi_escapes = __commonJS((exports, module) => {
|
|
|
18150
17823
|
};
|
|
18151
17824
|
});
|
|
18152
17825
|
|
|
17826
|
+
// ../../node_modules/ignore/index.js
|
|
17827
|
+
var require_ignore = __commonJS((exports, module) => {
|
|
17828
|
+
function makeArray(subject) {
|
|
17829
|
+
return Array.isArray(subject) ? subject : [subject];
|
|
17830
|
+
}
|
|
17831
|
+
var UNDEFINED = undefined;
|
|
17832
|
+
var EMPTY = "";
|
|
17833
|
+
var SPACE = " ";
|
|
17834
|
+
var ESCAPE = "\\";
|
|
17835
|
+
var REGEX_TEST_BLANK_LINE = /^\s+$/;
|
|
17836
|
+
var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
|
|
17837
|
+
var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
17838
|
+
var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
|
17839
|
+
var REGEX_SPLITALL_CRLF = /\r?\n/g;
|
|
17840
|
+
var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
|
|
17841
|
+
var REGEX_TEST_TRAILING_SLASH = /\/$/;
|
|
17842
|
+
var SLASH = "/";
|
|
17843
|
+
var TMP_KEY_IGNORE = "node-ignore";
|
|
17844
|
+
if (typeof Symbol !== "undefined") {
|
|
17845
|
+
TMP_KEY_IGNORE = Symbol.for("node-ignore");
|
|
17846
|
+
}
|
|
17847
|
+
var KEY_IGNORE = TMP_KEY_IGNORE;
|
|
17848
|
+
var define2 = (object5, key2, value) => {
|
|
17849
|
+
Object.defineProperty(object5, key2, { value });
|
|
17850
|
+
return value;
|
|
17851
|
+
};
|
|
17852
|
+
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
|
|
17853
|
+
var RETURN_FALSE = () => false;
|
|
17854
|
+
var sanitizeRange = (range) => range.replace(REGEX_REGEXP_RANGE, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY);
|
|
17855
|
+
var cleanRangeBackSlash = (slashes) => {
|
|
17856
|
+
const { length } = slashes;
|
|
17857
|
+
return slashes.slice(0, length - length % 2);
|
|
17858
|
+
};
|
|
17859
|
+
var REPLACERS = [
|
|
17860
|
+
[
|
|
17861
|
+
/^\uFEFF/,
|
|
17862
|
+
() => EMPTY
|
|
17863
|
+
],
|
|
17864
|
+
[
|
|
17865
|
+
/((?:\\\\)*?)(\\?\s+)$/,
|
|
17866
|
+
(_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)
|
|
17867
|
+
],
|
|
17868
|
+
[
|
|
17869
|
+
/(\\+?)\s/g,
|
|
17870
|
+
(_, m1) => {
|
|
17871
|
+
const { length } = m1;
|
|
17872
|
+
return m1.slice(0, length - length % 2) + SPACE;
|
|
17873
|
+
}
|
|
17874
|
+
],
|
|
17875
|
+
[
|
|
17876
|
+
/[\\$.|*+(){^]/g,
|
|
17877
|
+
(match) => `\\${match}`
|
|
17878
|
+
],
|
|
17879
|
+
[
|
|
17880
|
+
/(?!\\)\?/g,
|
|
17881
|
+
() => "[^/]"
|
|
17882
|
+
],
|
|
17883
|
+
[
|
|
17884
|
+
/^\//,
|
|
17885
|
+
() => "^"
|
|
17886
|
+
],
|
|
17887
|
+
[
|
|
17888
|
+
/\//g,
|
|
17889
|
+
() => "\\/"
|
|
17890
|
+
],
|
|
17891
|
+
[
|
|
17892
|
+
/^\^*\\\*\\\*\\\//,
|
|
17893
|
+
() => "^(?:.*\\/)?"
|
|
17894
|
+
],
|
|
17895
|
+
[
|
|
17896
|
+
/^(?=[^^])/,
|
|
17897
|
+
function startingReplacer() {
|
|
17898
|
+
return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^";
|
|
17899
|
+
}
|
|
17900
|
+
],
|
|
17901
|
+
[
|
|
17902
|
+
/\\\/\\\*\\\*(?=\\\/|$)/g,
|
|
17903
|
+
(_, index, str) => index + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+"
|
|
17904
|
+
],
|
|
17905
|
+
[
|
|
17906
|
+
/(^|[^\\]+)(\\\*)+(?=.+)/g,
|
|
17907
|
+
(_, p1, p2) => {
|
|
17908
|
+
const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
|
|
17909
|
+
return p1 + unescaped;
|
|
17910
|
+
}
|
|
17911
|
+
],
|
|
17912
|
+
[
|
|
17913
|
+
/\\\\\\(?=[$.|*+(){^])/g,
|
|
17914
|
+
() => ESCAPE
|
|
17915
|
+
],
|
|
17916
|
+
[
|
|
17917
|
+
/\\\\/g,
|
|
17918
|
+
() => ESCAPE
|
|
17919
|
+
],
|
|
17920
|
+
[
|
|
17921
|
+
/(\\)?\[([^\]/]*?)(\\*)($|\])/g,
|
|
17922
|
+
(match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range)}${endEscape}]` : "[]" : "[]"
|
|
17923
|
+
],
|
|
17924
|
+
[
|
|
17925
|
+
/(?:[^*])$/,
|
|
17926
|
+
(match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)`
|
|
17927
|
+
]
|
|
17928
|
+
];
|
|
17929
|
+
var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\\\*$/;
|
|
17930
|
+
var MODE_IGNORE = "regex";
|
|
17931
|
+
var MODE_CHECK_IGNORE = "checkRegex";
|
|
17932
|
+
var UNDERSCORE = "_";
|
|
17933
|
+
var TRAILING_WILD_CARD_REPLACERS = {
|
|
17934
|
+
[MODE_IGNORE](_, p1) {
|
|
17935
|
+
const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
|
|
17936
|
+
return `${prefix}(?=$|\\/$)`;
|
|
17937
|
+
},
|
|
17938
|
+
[MODE_CHECK_IGNORE](_, p1) {
|
|
17939
|
+
const prefix = p1 ? `${p1}[^/]*` : "[^/]*";
|
|
17940
|
+
return `${prefix}(?=$|\\/$)`;
|
|
17941
|
+
}
|
|
17942
|
+
};
|
|
17943
|
+
var makeRegexPrefix = (pattern) => REPLACERS.reduce((prev, [matcher, replacer]) => prev.replace(matcher, replacer.bind(pattern)), pattern);
|
|
17944
|
+
var isString = (subject) => typeof subject === "string";
|
|
17945
|
+
var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
|
|
17946
|
+
var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
|
|
17947
|
+
|
|
17948
|
+
class IgnoreRule {
|
|
17949
|
+
constructor(pattern, mark, body, ignoreCase, negative, prefix) {
|
|
17950
|
+
this.pattern = pattern;
|
|
17951
|
+
this.mark = mark;
|
|
17952
|
+
this.negative = negative;
|
|
17953
|
+
define2(this, "body", body);
|
|
17954
|
+
define2(this, "ignoreCase", ignoreCase);
|
|
17955
|
+
define2(this, "regexPrefix", prefix);
|
|
17956
|
+
}
|
|
17957
|
+
get regex() {
|
|
17958
|
+
const key2 = UNDERSCORE + MODE_IGNORE;
|
|
17959
|
+
if (this[key2]) {
|
|
17960
|
+
return this[key2];
|
|
17961
|
+
}
|
|
17962
|
+
return this._make(MODE_IGNORE, key2);
|
|
17963
|
+
}
|
|
17964
|
+
get checkRegex() {
|
|
17965
|
+
const key2 = UNDERSCORE + MODE_CHECK_IGNORE;
|
|
17966
|
+
if (this[key2]) {
|
|
17967
|
+
return this[key2];
|
|
17968
|
+
}
|
|
17969
|
+
return this._make(MODE_CHECK_IGNORE, key2);
|
|
17970
|
+
}
|
|
17971
|
+
_make(mode, key2) {
|
|
17972
|
+
const str = this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD, TRAILING_WILD_CARD_REPLACERS[mode]);
|
|
17973
|
+
const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
|
|
17974
|
+
return define2(this, key2, regex);
|
|
17975
|
+
}
|
|
17976
|
+
}
|
|
17977
|
+
var createRule = ({
|
|
17978
|
+
pattern,
|
|
17979
|
+
mark
|
|
17980
|
+
}, ignoreCase) => {
|
|
17981
|
+
let negative = false;
|
|
17982
|
+
let body = pattern;
|
|
17983
|
+
if (body.indexOf("!") === 0) {
|
|
17984
|
+
negative = true;
|
|
17985
|
+
body = body.substr(1);
|
|
17986
|
+
}
|
|
17987
|
+
body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
|
|
17988
|
+
const regexPrefix = makeRegexPrefix(body);
|
|
17989
|
+
return new IgnoreRule(pattern, mark, body, ignoreCase, negative, regexPrefix);
|
|
17990
|
+
};
|
|
17991
|
+
|
|
17992
|
+
class RuleManager {
|
|
17993
|
+
constructor(ignoreCase) {
|
|
17994
|
+
this._ignoreCase = ignoreCase;
|
|
17995
|
+
this._rules = [];
|
|
17996
|
+
}
|
|
17997
|
+
_add(pattern) {
|
|
17998
|
+
if (pattern && pattern[KEY_IGNORE]) {
|
|
17999
|
+
this._rules = this._rules.concat(pattern._rules._rules);
|
|
18000
|
+
this._added = true;
|
|
18001
|
+
return;
|
|
18002
|
+
}
|
|
18003
|
+
if (isString(pattern)) {
|
|
18004
|
+
pattern = {
|
|
18005
|
+
pattern
|
|
18006
|
+
};
|
|
18007
|
+
}
|
|
18008
|
+
if (checkPattern(pattern.pattern)) {
|
|
18009
|
+
const rule = createRule(pattern, this._ignoreCase);
|
|
18010
|
+
this._added = true;
|
|
18011
|
+
this._rules.push(rule);
|
|
18012
|
+
}
|
|
18013
|
+
}
|
|
18014
|
+
add(pattern) {
|
|
18015
|
+
this._added = false;
|
|
18016
|
+
makeArray(isString(pattern) ? splitPattern(pattern) : pattern).forEach(this._add, this);
|
|
18017
|
+
return this._added;
|
|
18018
|
+
}
|
|
18019
|
+
test(path, checkUnignored, mode) {
|
|
18020
|
+
let ignored = false;
|
|
18021
|
+
let unignored = false;
|
|
18022
|
+
let matchedRule;
|
|
18023
|
+
this._rules.forEach((rule) => {
|
|
18024
|
+
const { negative } = rule;
|
|
18025
|
+
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
18026
|
+
return;
|
|
18027
|
+
}
|
|
18028
|
+
const matched = rule[mode].test(path);
|
|
18029
|
+
if (!matched) {
|
|
18030
|
+
return;
|
|
18031
|
+
}
|
|
18032
|
+
ignored = !negative;
|
|
18033
|
+
unignored = negative;
|
|
18034
|
+
matchedRule = negative ? UNDEFINED : rule;
|
|
18035
|
+
});
|
|
18036
|
+
const ret = {
|
|
18037
|
+
ignored,
|
|
18038
|
+
unignored
|
|
18039
|
+
};
|
|
18040
|
+
if (matchedRule) {
|
|
18041
|
+
ret.rule = matchedRule;
|
|
18042
|
+
}
|
|
18043
|
+
return ret;
|
|
18044
|
+
}
|
|
18045
|
+
}
|
|
18046
|
+
var throwError = (message, Ctor) => {
|
|
18047
|
+
throw new Ctor(message);
|
|
18048
|
+
};
|
|
18049
|
+
var checkPath = (path, originalPath, doThrow) => {
|
|
18050
|
+
if (!isString(path)) {
|
|
18051
|
+
return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
18052
|
+
}
|
|
18053
|
+
if (!path) {
|
|
18054
|
+
return doThrow(`path must not be empty`, TypeError);
|
|
18055
|
+
}
|
|
18056
|
+
if (checkPath.isNotRelative(path)) {
|
|
18057
|
+
const r = "`path.relative()`d";
|
|
18058
|
+
return doThrow(`path should be a ${r} string, but got "${originalPath}"`, RangeError);
|
|
18059
|
+
}
|
|
18060
|
+
return true;
|
|
18061
|
+
};
|
|
18062
|
+
var isNotRelative = (path) => REGEX_TEST_INVALID_PATH.test(path);
|
|
18063
|
+
checkPath.isNotRelative = isNotRelative;
|
|
18064
|
+
checkPath.convert = (p) => p;
|
|
18065
|
+
|
|
18066
|
+
class Ignore {
|
|
18067
|
+
constructor({
|
|
18068
|
+
ignorecase = true,
|
|
18069
|
+
ignoreCase = ignorecase,
|
|
18070
|
+
allowRelativePaths = false
|
|
18071
|
+
} = {}) {
|
|
18072
|
+
define2(this, KEY_IGNORE, true);
|
|
18073
|
+
this._rules = new RuleManager(ignoreCase);
|
|
18074
|
+
this._strictPathCheck = !allowRelativePaths;
|
|
18075
|
+
this._initCache();
|
|
18076
|
+
}
|
|
18077
|
+
_initCache() {
|
|
18078
|
+
this._ignoreCache = Object.create(null);
|
|
18079
|
+
this._testCache = Object.create(null);
|
|
18080
|
+
}
|
|
18081
|
+
add(pattern) {
|
|
18082
|
+
if (this._rules.add(pattern)) {
|
|
18083
|
+
this._initCache();
|
|
18084
|
+
}
|
|
18085
|
+
return this;
|
|
18086
|
+
}
|
|
18087
|
+
addPattern(pattern) {
|
|
18088
|
+
return this.add(pattern);
|
|
18089
|
+
}
|
|
18090
|
+
_test(originalPath, cache, checkUnignored, slices) {
|
|
18091
|
+
const path = originalPath && checkPath.convert(originalPath);
|
|
18092
|
+
checkPath(path, originalPath, this._strictPathCheck ? throwError : RETURN_FALSE);
|
|
18093
|
+
return this._t(path, cache, checkUnignored, slices);
|
|
18094
|
+
}
|
|
18095
|
+
checkIgnore(path) {
|
|
18096
|
+
if (!REGEX_TEST_TRAILING_SLASH.test(path)) {
|
|
18097
|
+
return this.test(path);
|
|
18098
|
+
}
|
|
18099
|
+
const slices = path.split(SLASH).filter(Boolean);
|
|
18100
|
+
slices.pop();
|
|
18101
|
+
if (slices.length) {
|
|
18102
|
+
const parent = this._t(slices.join(SLASH) + SLASH, this._testCache, true, slices);
|
|
18103
|
+
if (parent.ignored) {
|
|
18104
|
+
return parent;
|
|
18105
|
+
}
|
|
18106
|
+
}
|
|
18107
|
+
return this._rules.test(path, false, MODE_CHECK_IGNORE);
|
|
18108
|
+
}
|
|
18109
|
+
_t(path, cache, checkUnignored, slices) {
|
|
18110
|
+
if (path in cache) {
|
|
18111
|
+
return cache[path];
|
|
18112
|
+
}
|
|
18113
|
+
if (!slices) {
|
|
18114
|
+
slices = path.split(SLASH).filter(Boolean);
|
|
18115
|
+
}
|
|
18116
|
+
slices.pop();
|
|
18117
|
+
if (!slices.length) {
|
|
18118
|
+
return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE);
|
|
18119
|
+
}
|
|
18120
|
+
const parent = this._t(slices.join(SLASH) + SLASH, cache, checkUnignored, slices);
|
|
18121
|
+
return cache[path] = parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
|
|
18122
|
+
}
|
|
18123
|
+
ignores(path) {
|
|
18124
|
+
return this._test(path, this._ignoreCache, false).ignored;
|
|
18125
|
+
}
|
|
18126
|
+
createFilter() {
|
|
18127
|
+
return (path) => !this.ignores(path);
|
|
18128
|
+
}
|
|
18129
|
+
filter(paths) {
|
|
18130
|
+
return makeArray(paths).filter(this.createFilter());
|
|
18131
|
+
}
|
|
18132
|
+
test(path) {
|
|
18133
|
+
return this._test(path, this._testCache, true);
|
|
18134
|
+
}
|
|
18135
|
+
}
|
|
18136
|
+
var factory = (options) => new Ignore(options);
|
|
18137
|
+
var isPathValid = (path) => checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
|
|
18138
|
+
var setupWindows = () => {
|
|
18139
|
+
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
18140
|
+
checkPath.convert = makePosix;
|
|
18141
|
+
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
18142
|
+
checkPath.isNotRelative = (path) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
|
|
18143
|
+
};
|
|
18144
|
+
if (typeof process !== "undefined" && process.platform === "win32") {
|
|
18145
|
+
setupWindows();
|
|
18146
|
+
}
|
|
18147
|
+
module.exports = factory;
|
|
18148
|
+
factory.default = factory;
|
|
18149
|
+
module.exports.isPathValid = isPathValid;
|
|
18150
|
+
define2(module.exports, Symbol.for("setupWindows"), setupWindows);
|
|
18151
|
+
});
|
|
18152
|
+
|
|
18153
18153
|
// ../../node_modules/ws/lib/constants.js
|
|
18154
18154
|
var require_constants = __commonJS((exports, module) => {
|
|
18155
18155
|
var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
|
|
@@ -19540,9 +19540,9 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
19540
19540
|
}
|
|
19541
19541
|
Object.defineProperty(MessageEvent.prototype, "data", { enumerable: true });
|
|
19542
19542
|
var EventTarget = {
|
|
19543
|
-
addEventListener(type,
|
|
19543
|
+
addEventListener(type, handler15, options = {}) {
|
|
19544
19544
|
for (const listener of this.listeners(type)) {
|
|
19545
|
-
if (!options[kForOnEventAttribute] && listener[kListener] ===
|
|
19545
|
+
if (!options[kForOnEventAttribute] && listener[kListener] === handler15 && !listener[kForOnEventAttribute]) {
|
|
19546
19546
|
return;
|
|
19547
19547
|
}
|
|
19548
19548
|
}
|
|
@@ -19553,7 +19553,7 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
19553
19553
|
data: isBinary ? data : data.toString()
|
|
19554
19554
|
});
|
|
19555
19555
|
event[kTarget] = this;
|
|
19556
|
-
callListener(
|
|
19556
|
+
callListener(handler15, this, event);
|
|
19557
19557
|
};
|
|
19558
19558
|
} else if (type === "close") {
|
|
19559
19559
|
wrapper = function onClose(code, message) {
|
|
@@ -19563,7 +19563,7 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
19563
19563
|
wasClean: this._closeFrameReceived && this._closeFrameSent
|
|
19564
19564
|
});
|
|
19565
19565
|
event[kTarget] = this;
|
|
19566
|
-
callListener(
|
|
19566
|
+
callListener(handler15, this, event);
|
|
19567
19567
|
};
|
|
19568
19568
|
} else if (type === "error") {
|
|
19569
19569
|
wrapper = function onError(error81) {
|
|
@@ -19572,28 +19572,28 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
19572
19572
|
message: error81.message
|
|
19573
19573
|
});
|
|
19574
19574
|
event[kTarget] = this;
|
|
19575
|
-
callListener(
|
|
19575
|
+
callListener(handler15, this, event);
|
|
19576
19576
|
};
|
|
19577
19577
|
} else if (type === "open") {
|
|
19578
19578
|
wrapper = function onOpen() {
|
|
19579
19579
|
const event = new Event("open");
|
|
19580
19580
|
event[kTarget] = this;
|
|
19581
|
-
callListener(
|
|
19581
|
+
callListener(handler15, this, event);
|
|
19582
19582
|
};
|
|
19583
19583
|
} else {
|
|
19584
19584
|
return;
|
|
19585
19585
|
}
|
|
19586
19586
|
wrapper[kForOnEventAttribute] = !!options[kForOnEventAttribute];
|
|
19587
|
-
wrapper[kListener] =
|
|
19587
|
+
wrapper[kListener] = handler15;
|
|
19588
19588
|
if (options.once) {
|
|
19589
19589
|
this.once(type, wrapper);
|
|
19590
19590
|
} else {
|
|
19591
19591
|
this.on(type, wrapper);
|
|
19592
19592
|
}
|
|
19593
19593
|
},
|
|
19594
|
-
removeEventListener(type,
|
|
19594
|
+
removeEventListener(type, handler15) {
|
|
19595
19595
|
for (const listener of this.listeners(type)) {
|
|
19596
|
-
if (listener[kListener] ===
|
|
19596
|
+
if (listener[kListener] === handler15 && !listener[kForOnEventAttribute]) {
|
|
19597
19597
|
this.removeListener(type, listener);
|
|
19598
19598
|
break;
|
|
19599
19599
|
}
|
|
@@ -20119,16 +20119,16 @@ var require_websocket = __commonJS((exports, module) => {
|
|
|
20119
20119
|
}
|
|
20120
20120
|
return null;
|
|
20121
20121
|
},
|
|
20122
|
-
set(
|
|
20122
|
+
set(handler15) {
|
|
20123
20123
|
for (const listener of this.listeners(method)) {
|
|
20124
20124
|
if (listener[kForOnEventAttribute]) {
|
|
20125
20125
|
this.removeListener(method, listener);
|
|
20126
20126
|
break;
|
|
20127
20127
|
}
|
|
20128
20128
|
}
|
|
20129
|
-
if (typeof
|
|
20129
|
+
if (typeof handler15 !== "function")
|
|
20130
20130
|
return;
|
|
20131
|
-
this.addEventListener(method,
|
|
20131
|
+
this.addEventListener(method, handler15, {
|
|
20132
20132
|
[kForOnEventAttribute]: true
|
|
20133
20133
|
});
|
|
20134
20134
|
}
|
|
@@ -21008,7 +21008,7 @@ var {
|
|
|
21008
21008
|
Help
|
|
21009
21009
|
} = import__.default;
|
|
21010
21010
|
// package.json
|
|
21011
|
-
var version = "0.9.
|
|
21011
|
+
var version = "0.9.3";
|
|
21012
21012
|
|
|
21013
21013
|
// src/runner.ts
|
|
21014
21014
|
import { execSync } from "node:child_process";
|
|
@@ -21019,137 +21019,6 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
21019
21019
|
import { homedir } from "node:os";
|
|
21020
21020
|
import { join } from "node:path";
|
|
21021
21021
|
|
|
21022
|
-
// ../core/src/UsageMeter.ts
|
|
21023
|
-
class UsageMeter {
|
|
21024
|
-
#totals = { input: 0, output: 0, cachedRead: 0, cost: 0 };
|
|
21025
|
-
#calls = 0;
|
|
21026
|
-
#modelInfos;
|
|
21027
|
-
#maxMessages;
|
|
21028
|
-
#maxCost;
|
|
21029
|
-
constructor(modelInfos = {}, opts = {}) {
|
|
21030
|
-
const infos = {};
|
|
21031
|
-
for (const [provider, providerInfo] of Object.entries(modelInfos)) {
|
|
21032
|
-
for (const [model, modelInfo] of Object.entries(providerInfo)) {
|
|
21033
|
-
infos[`${provider.split("-")[0]}:${model.replace(/[\.-]/g, "")}`] = {
|
|
21034
|
-
inputPrice: modelInfo.inputPrice ?? 0,
|
|
21035
|
-
outputPrice: modelInfo.outputPrice ?? 0,
|
|
21036
|
-
cacheWritesPrice: modelInfo.cacheWritesPrice ?? 0,
|
|
21037
|
-
cacheReadsPrice: modelInfo.cacheReadsPrice ?? 0
|
|
21038
|
-
};
|
|
21039
|
-
}
|
|
21040
|
-
}
|
|
21041
|
-
this.#modelInfos = infos;
|
|
21042
|
-
this.#maxMessages = opts.maxMessages ?? 1000;
|
|
21043
|
-
this.#maxCost = opts.maxCost ?? 100;
|
|
21044
|
-
}
|
|
21045
|
-
#calculageUsage(usage, providerMetadata, modelInfo) {
|
|
21046
|
-
const providerMetadataKey = Object.keys(providerMetadata ?? {})[0];
|
|
21047
|
-
const metadata = providerMetadata?.[providerMetadataKey] ?? {};
|
|
21048
|
-
switch (providerMetadataKey) {
|
|
21049
|
-
case "openrouter":
|
|
21050
|
-
return {
|
|
21051
|
-
input: usage.inputTokens ?? 0,
|
|
21052
|
-
output: usage.outputTokens ?? 0,
|
|
21053
|
-
cachedRead: usage.cachedInputTokens ?? 0,
|
|
21054
|
-
cost: metadata.usage?.cost ?? 0
|
|
21055
|
-
};
|
|
21056
|
-
case "anthropic": {
|
|
21057
|
-
const cachedRead = usage.cachedInputTokens ?? 0;
|
|
21058
|
-
const cacheWrite = metadata?.promptCacheMissTokens ?? 0;
|
|
21059
|
-
const input = usage.inputTokens ?? 0;
|
|
21060
|
-
const output = usage.outputTokens ?? 0;
|
|
21061
|
-
return {
|
|
21062
|
-
input: input + cacheWrite + cachedRead,
|
|
21063
|
-
output,
|
|
21064
|
-
cachedRead,
|
|
21065
|
-
cost: (input * modelInfo.inputPrice + output * modelInfo.outputPrice + cacheWrite * modelInfo.cacheWritesPrice + cachedRead * modelInfo.cacheReadsPrice) / 1e6
|
|
21066
|
-
};
|
|
21067
|
-
}
|
|
21068
|
-
case "deepseek": {
|
|
21069
|
-
const cachedRead = usage.cachedInputTokens ?? 0;
|
|
21070
|
-
const cacheWrite = metadata.promptCacheMissTokens ?? 0;
|
|
21071
|
-
const input = usage.inputTokens ?? 0;
|
|
21072
|
-
const output = usage.outputTokens ?? 0;
|
|
21073
|
-
return {
|
|
21074
|
-
input,
|
|
21075
|
-
output,
|
|
21076
|
-
cachedRead,
|
|
21077
|
-
cost: (output * modelInfo.outputPrice + cacheWrite * modelInfo.inputPrice + cachedRead * modelInfo.cacheReadsPrice) / 1e6
|
|
21078
|
-
};
|
|
21079
|
-
}
|
|
21080
|
-
default: {
|
|
21081
|
-
const cachedRead = usage.cachedInputTokens ?? 0;
|
|
21082
|
-
const input = usage.inputTokens ?? 0;
|
|
21083
|
-
const output = usage.outputTokens ?? 0;
|
|
21084
|
-
return {
|
|
21085
|
-
input,
|
|
21086
|
-
output,
|
|
21087
|
-
cachedRead,
|
|
21088
|
-
cost: (input * modelInfo.inputPrice + output * modelInfo.outputPrice) / 1e6
|
|
21089
|
-
};
|
|
21090
|
-
}
|
|
21091
|
-
}
|
|
21092
|
-
}
|
|
21093
|
-
addUsage(llm, resp, options = {}) {
|
|
21094
|
-
const modelInfo = options.modelInfo ?? this.#modelInfos[`${llm.provider.split(".")[0]}:${llm.modelId.replace(/[\.-]/g, "")}`] ?? {
|
|
21095
|
-
inputPrice: 0,
|
|
21096
|
-
outputPrice: 0,
|
|
21097
|
-
cacheWritesPrice: 0,
|
|
21098
|
-
cacheReadsPrice: 0
|
|
21099
|
-
};
|
|
21100
|
-
const usage = "totalUsage" in resp ? resp.totalUsage : resp.usage;
|
|
21101
|
-
const result = this.#calculageUsage(usage, resp.providerMetadata, modelInfo);
|
|
21102
|
-
this.#totals.input += result.input;
|
|
21103
|
-
this.#totals.output += result.output;
|
|
21104
|
-
this.#totals.cachedRead += result.cachedRead;
|
|
21105
|
-
this.#totals.cost += result.cost;
|
|
21106
|
-
this.#calls++;
|
|
21107
|
-
}
|
|
21108
|
-
setUsage(newUsage) {
|
|
21109
|
-
if (newUsage.input != null)
|
|
21110
|
-
this.#totals.input = newUsage.input;
|
|
21111
|
-
if (newUsage.output != null)
|
|
21112
|
-
this.#totals.output = newUsage.output;
|
|
21113
|
-
if (newUsage.cachedRead != null)
|
|
21114
|
-
this.#totals.cachedRead = newUsage.cachedRead;
|
|
21115
|
-
if (newUsage.cost != null)
|
|
21116
|
-
this.#totals.cost = newUsage.cost;
|
|
21117
|
-
if (newUsage.calls != null)
|
|
21118
|
-
this.#calls = newUsage.calls;
|
|
21119
|
-
}
|
|
21120
|
-
incrementMessageCount(n = 1) {
|
|
21121
|
-
this.#calls += n;
|
|
21122
|
-
}
|
|
21123
|
-
isLimitExceeded() {
|
|
21124
|
-
const messageCount = this.#maxMessages !== undefined && this.#calls >= this.#maxMessages;
|
|
21125
|
-
const cost = this.#maxCost !== undefined && this.#totals.cost >= this.#maxCost;
|
|
21126
|
-
return {
|
|
21127
|
-
messageCount,
|
|
21128
|
-
maxMessages: this.#maxMessages,
|
|
21129
|
-
cost,
|
|
21130
|
-
maxCost: this.#maxCost,
|
|
21131
|
-
result: messageCount || cost
|
|
21132
|
-
};
|
|
21133
|
-
}
|
|
21134
|
-
checkLimit() {
|
|
21135
|
-
const result = this.isLimitExceeded();
|
|
21136
|
-
if (result.result) {
|
|
21137
|
-
throw new Error(`Usage limit exceeded. Message count: ${result.messageCount}/${result.maxMessages}, cost: ${result.cost}/${result.maxCost}`);
|
|
21138
|
-
}
|
|
21139
|
-
}
|
|
21140
|
-
get usage() {
|
|
21141
|
-
return { ...this.#totals, messageCount: this.#calls };
|
|
21142
|
-
}
|
|
21143
|
-
printUsage() {
|
|
21144
|
-
const u = this.usage;
|
|
21145
|
-
console.log(`Usage - messages: ${u.messageCount}, input: ${u.input}, cached: ${u.cachedRead}, ` + `output: ${u.output}, cost: $${u.cost.toFixed(4)}`);
|
|
21146
|
-
}
|
|
21147
|
-
onFinishHandler(llm) {
|
|
21148
|
-
return (evt) => {
|
|
21149
|
-
this.addUsage(llm, evt);
|
|
21150
|
-
};
|
|
21151
|
-
}
|
|
21152
|
-
}
|
|
21153
21022
|
// ../core/src/tools/allTools.ts
|
|
21154
21023
|
var exports_allTools = {};
|
|
21155
21024
|
__export(exports_allTools, {
|
|
@@ -32223,35 +32092,27 @@ var toolInfo = {
|
|
|
32223
32092
|
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.",
|
|
32224
32093
|
parameters: exports_external.object({
|
|
32225
32094
|
questions: exports_external.array(questionObject).describe("One or more follow-up questions you need answered before you can continue.").meta({ usageValue: "questions here" })
|
|
32226
|
-
})
|
|
32227
|
-
|
|
32228
|
-
|
|
32229
|
-
|
|
32230
|
-
|
|
32231
|
-
|
|
32232
|
-
name: "questions",
|
|
32233
|
-
value: { prompt: "What is the target deployment environment?" }
|
|
32095
|
+
}).meta({
|
|
32096
|
+
examples: [
|
|
32097
|
+
{
|
|
32098
|
+
description: "Single clarifying question (no options)",
|
|
32099
|
+
input: {
|
|
32100
|
+
questions: { prompt: "What is the target deployment environment?" }
|
|
32234
32101
|
}
|
|
32235
|
-
|
|
32236
|
-
|
|
32237
|
-
|
|
32238
|
-
|
|
32239
|
-
|
|
32240
|
-
{
|
|
32241
|
-
name: "questions",
|
|
32242
|
-
value: {
|
|
32102
|
+
},
|
|
32103
|
+
{
|
|
32104
|
+
description: "Single question with multiple-choice options",
|
|
32105
|
+
input: {
|
|
32106
|
+
questions: {
|
|
32243
32107
|
prompt: "Which frontend framework are you using?",
|
|
32244
32108
|
options: ["React", "Angular", "Vue", "Svelte"]
|
|
32245
32109
|
}
|
|
32246
32110
|
}
|
|
32247
|
-
|
|
32248
|
-
|
|
32249
|
-
|
|
32250
|
-
|
|
32251
|
-
|
|
32252
|
-
{
|
|
32253
|
-
name: "questions",
|
|
32254
|
-
value: [
|
|
32111
|
+
},
|
|
32112
|
+
{
|
|
32113
|
+
description: "Two related questions in one call",
|
|
32114
|
+
input: {
|
|
32115
|
+
questions: [
|
|
32255
32116
|
{ prompt: "What type of application are you building?" },
|
|
32256
32117
|
{
|
|
32257
32118
|
prompt: "Preferred programming language?",
|
|
@@ -32259,21 +32120,18 @@ var toolInfo = {
|
|
|
32259
32120
|
}
|
|
32260
32121
|
]
|
|
32261
32122
|
}
|
|
32262
|
-
|
|
32263
|
-
|
|
32264
|
-
|
|
32265
|
-
|
|
32266
|
-
|
|
32267
|
-
{
|
|
32268
|
-
name: "questions",
|
|
32269
|
-
value: {
|
|
32123
|
+
},
|
|
32124
|
+
{
|
|
32125
|
+
description: "Binary (yes/no) confirmation",
|
|
32126
|
+
input: {
|
|
32127
|
+
questions: {
|
|
32270
32128
|
prompt: "Is it acceptable to refactor existing tests to improve performance?",
|
|
32271
32129
|
options: ["Yes", "No"]
|
|
32272
32130
|
}
|
|
32273
32131
|
}
|
|
32274
|
-
|
|
32275
|
-
|
|
32276
|
-
|
|
32132
|
+
}
|
|
32133
|
+
]
|
|
32134
|
+
}),
|
|
32277
32135
|
permissionLevel: 0 /* None */
|
|
32278
32136
|
};
|
|
32279
32137
|
var handler = async (provider, args) => {
|
|
@@ -32318,18 +32176,16 @@ var toolInfo2 = {
|
|
|
32318
32176
|
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.",
|
|
32319
32177
|
parameters: exports_external.object({
|
|
32320
32178
|
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" })
|
|
32321
|
-
})
|
|
32322
|
-
|
|
32323
|
-
|
|
32324
|
-
|
|
32325
|
-
|
|
32326
|
-
|
|
32327
|
-
name: "result",
|
|
32328
|
-
value: "Your final result description here"
|
|
32179
|
+
}).meta({
|
|
32180
|
+
examples: [
|
|
32181
|
+
{
|
|
32182
|
+
description: "Request to present the result of the task",
|
|
32183
|
+
input: {
|
|
32184
|
+
result: "Your final result description here"
|
|
32329
32185
|
}
|
|
32330
|
-
|
|
32331
|
-
|
|
32332
|
-
|
|
32186
|
+
}
|
|
32187
|
+
]
|
|
32188
|
+
}),
|
|
32333
32189
|
permissionLevel: 0 /* None */
|
|
32334
32190
|
};
|
|
32335
32191
|
var handler2 = async (provider, args) => {
|
|
@@ -32353,7 +32209,7 @@ var handler2 = async (provider, args) => {
|
|
|
32353
32209
|
message: `<user_message>${moreMessage}</user_message>`
|
|
32354
32210
|
};
|
|
32355
32211
|
};
|
|
32356
|
-
var isAvailable2 = (
|
|
32212
|
+
var isAvailable2 = (_provider) => {
|
|
32357
32213
|
return true;
|
|
32358
32214
|
};
|
|
32359
32215
|
var attemptCompletion_default = {
|
|
@@ -32375,30 +32231,19 @@ var toolInfo3 = {
|
|
|
32375
32231
|
const values = Array.isArray(val) ? val : [val];
|
|
32376
32232
|
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
32377
32233
|
}, exports_external.array(exports_external.string())).optional().describe("The files relevant to the task. Comma separated paths").meta({ usageValue: "Relevant files" })
|
|
32378
|
-
})
|
|
32379
|
-
|
|
32380
|
-
|
|
32381
|
-
|
|
32382
|
-
|
|
32383
|
-
|
|
32384
|
-
|
|
32385
|
-
|
|
32386
|
-
|
|
32387
|
-
{
|
|
32388
|
-
name: "task",
|
|
32389
|
-
value: "Analyze the authentication implementation"
|
|
32390
|
-
},
|
|
32391
|
-
{
|
|
32392
|
-
name: "context",
|
|
32393
|
-
value: "Need to understand the security implications of the current auth system"
|
|
32394
|
-
},
|
|
32395
|
-
{
|
|
32396
|
-
name: "files",
|
|
32397
|
-
value: "src/auth/login.ts,src/auth/types.ts"
|
|
32234
|
+
}).meta({
|
|
32235
|
+
examples: [
|
|
32236
|
+
{
|
|
32237
|
+
description: "Delegate a code analysis task to the analyzer agent",
|
|
32238
|
+
input: {
|
|
32239
|
+
agentName: "analyzer",
|
|
32240
|
+
task: "Analyze the authentication implementation",
|
|
32241
|
+
context: "Need to understand the security implications of the current auth system",
|
|
32242
|
+
files: "src/auth/login.ts,src/auth/types.ts"
|
|
32398
32243
|
}
|
|
32399
|
-
|
|
32400
|
-
|
|
32401
|
-
|
|
32244
|
+
}
|
|
32245
|
+
]
|
|
32246
|
+
}),
|
|
32402
32247
|
permissionLevel: 0 /* None */
|
|
32403
32248
|
};
|
|
32404
32249
|
var handler3 = async (_provider, args) => {
|
|
@@ -32442,16 +32287,17 @@ var toolInfo4 = {
|
|
|
32442
32287
|
}
|
|
32443
32288
|
return val;
|
|
32444
32289
|
}, 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" })
|
|
32290
|
+
}).meta({
|
|
32291
|
+
examples: [
|
|
32292
|
+
{
|
|
32293
|
+
description: "Make a build",
|
|
32294
|
+
input: {
|
|
32295
|
+
command: "npm run build",
|
|
32296
|
+
requiresApproval: "false"
|
|
32297
|
+
}
|
|
32298
|
+
}
|
|
32299
|
+
]
|
|
32445
32300
|
}),
|
|
32446
|
-
examples: [
|
|
32447
|
-
{
|
|
32448
|
-
description: "Make a build",
|
|
32449
|
-
parameters: [
|
|
32450
|
-
{ name: "command", value: "npm run build" },
|
|
32451
|
-
{ name: "requiresApproval", value: "false" }
|
|
32452
|
-
]
|
|
32453
|
-
}
|
|
32454
|
-
],
|
|
32455
32301
|
permissionLevel: 3 /* Arbitrary */
|
|
32456
32302
|
};
|
|
32457
32303
|
var handler4 = async (provider, args) => {
|
|
@@ -32509,36 +32355,28 @@ var toolInfo5 = {
|
|
|
32509
32355
|
const values = Array.isArray(val) ? val : [val];
|
|
32510
32356
|
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
32511
32357
|
}, exports_external.array(exports_external.string())).describe("One or more URLs to fetch, separated by commas if multiple.").meta({ usageValue: "url" })
|
|
32512
|
-
})
|
|
32513
|
-
|
|
32514
|
-
|
|
32515
|
-
|
|
32516
|
-
|
|
32517
|
-
|
|
32518
|
-
name: "url",
|
|
32519
|
-
value: "https://example.com"
|
|
32358
|
+
}).meta({
|
|
32359
|
+
examples: [
|
|
32360
|
+
{
|
|
32361
|
+
description: "Fetch a single webpage",
|
|
32362
|
+
input: {
|
|
32363
|
+
url: "https://example.com"
|
|
32520
32364
|
}
|
|
32521
|
-
|
|
32522
|
-
|
|
32523
|
-
|
|
32524
|
-
|
|
32525
|
-
|
|
32526
|
-
{
|
|
32527
|
-
name: "url",
|
|
32528
|
-
value: "https://example.com,https://developer.mozilla.org/en-US/docs/Web/HTTP"
|
|
32365
|
+
},
|
|
32366
|
+
{
|
|
32367
|
+
description: "Fetch multiple webpages",
|
|
32368
|
+
input: {
|
|
32369
|
+
url: "https://example.com,https://developer.mozilla.org/en-US/docs/Web/HTTP"
|
|
32529
32370
|
}
|
|
32530
|
-
|
|
32531
|
-
|
|
32532
|
-
|
|
32533
|
-
|
|
32534
|
-
|
|
32535
|
-
{
|
|
32536
|
-
name: "url",
|
|
32537
|
-
value: "https://raw.githubusercontent.com/user/repo/main/README.md"
|
|
32371
|
+
},
|
|
32372
|
+
{
|
|
32373
|
+
description: "Fetch a raw file from GitHub",
|
|
32374
|
+
input: {
|
|
32375
|
+
url: "https://raw.githubusercontent.com/user/repo/main/README.md"
|
|
32538
32376
|
}
|
|
32539
|
-
|
|
32540
|
-
|
|
32541
|
-
|
|
32377
|
+
}
|
|
32378
|
+
]
|
|
32379
|
+
}),
|
|
32542
32380
|
permissionLevel: 1 /* Read */
|
|
32543
32381
|
};
|
|
32544
32382
|
var handler5 = async (provider, args) => {
|
|
@@ -32580,8 +32418,62 @@ var fetchUrl_default = {
|
|
|
32580
32418
|
handler: handler5,
|
|
32581
32419
|
isAvailable: isAvailable5
|
|
32582
32420
|
};
|
|
32583
|
-
// ../core/src/tools/
|
|
32421
|
+
// ../core/src/tools/handOver.ts
|
|
32584
32422
|
var toolInfo6 = {
|
|
32423
|
+
name: "hand_over",
|
|
32424
|
+
description: "Hand over the current task to another agent to complete. This tool MUST NOT to be used with any other tool.",
|
|
32425
|
+
parameters: exports_external.object({
|
|
32426
|
+
agentName: exports_external.string().describe("The name of the agent to hand over the task to").meta({ usageValue: "Name of the target agent" }),
|
|
32427
|
+
task: exports_external.string().describe("The task to be completed by the target agent").meta({ usageValue: "Task description" }),
|
|
32428
|
+
context: exports_external.string().describe("The context information for the task").meta({ usageValue: "Context information" }),
|
|
32429
|
+
files: exports_external.preprocess((val) => {
|
|
32430
|
+
if (!val)
|
|
32431
|
+
return [];
|
|
32432
|
+
const values = Array.isArray(val) ? val : [val];
|
|
32433
|
+
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
32434
|
+
}, exports_external.array(exports_external.string())).optional().describe("The files relevant to the task. Comma separated paths").meta({ usageValue: "Relevant files" })
|
|
32435
|
+
}).meta({
|
|
32436
|
+
examples: [
|
|
32437
|
+
{
|
|
32438
|
+
description: "Hand over a coding task to the coder agent",
|
|
32439
|
+
input: {
|
|
32440
|
+
agentName: "coder",
|
|
32441
|
+
task: "Implement the login feature",
|
|
32442
|
+
context: "We need a secure login system with email and password",
|
|
32443
|
+
files: "src/auth/login.ts,src/auth/types.ts"
|
|
32444
|
+
}
|
|
32445
|
+
}
|
|
32446
|
+
]
|
|
32447
|
+
}),
|
|
32448
|
+
permissionLevel: 0 /* None */
|
|
32449
|
+
};
|
|
32450
|
+
var handler6 = async (_provider, args) => {
|
|
32451
|
+
const parsed = toolInfo6.parameters.safeParse(args);
|
|
32452
|
+
if (!parsed.success) {
|
|
32453
|
+
return {
|
|
32454
|
+
type: "Invalid" /* Invalid */,
|
|
32455
|
+
message: `Invalid arguments for hand_over: ${parsed.error.message}`
|
|
32456
|
+
};
|
|
32457
|
+
}
|
|
32458
|
+
const { agentName, task, context, files } = parsed.data;
|
|
32459
|
+
return {
|
|
32460
|
+
type: "HandOver" /* HandOver */,
|
|
32461
|
+
agentName,
|
|
32462
|
+
task,
|
|
32463
|
+
context,
|
|
32464
|
+
files: files ?? []
|
|
32465
|
+
};
|
|
32466
|
+
};
|
|
32467
|
+
var isAvailable6 = (_provider) => {
|
|
32468
|
+
return true;
|
|
32469
|
+
};
|
|
32470
|
+
var handOver_default = {
|
|
32471
|
+
...toolInfo6,
|
|
32472
|
+
handler: handler6,
|
|
32473
|
+
isAvailable: isAvailable6
|
|
32474
|
+
};
|
|
32475
|
+
// ../core/src/tools/listFiles.ts
|
|
32476
|
+
var toolInfo7 = {
|
|
32585
32477
|
name: "list_files",
|
|
32586
32478
|
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.",
|
|
32587
32479
|
parameters: exports_external.object({
|
|
@@ -32597,32 +32489,27 @@ var toolInfo6 = {
|
|
|
32597
32489
|
}
|
|
32598
32490
|
return val;
|
|
32599
32491
|
}, 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)" })
|
|
32600
|
-
})
|
|
32601
|
-
|
|
32602
|
-
|
|
32603
|
-
|
|
32604
|
-
|
|
32605
|
-
|
|
32606
|
-
|
|
32607
|
-
value: "src"
|
|
32608
|
-
},
|
|
32609
|
-
{
|
|
32610
|
-
name: "maxCount",
|
|
32611
|
-
value: "100"
|
|
32492
|
+
}).meta({
|
|
32493
|
+
examples: [
|
|
32494
|
+
{
|
|
32495
|
+
description: "Request to list files",
|
|
32496
|
+
input: {
|
|
32497
|
+
path: "src",
|
|
32498
|
+
maxCount: "100"
|
|
32612
32499
|
}
|
|
32613
|
-
|
|
32614
|
-
|
|
32615
|
-
|
|
32500
|
+
}
|
|
32501
|
+
]
|
|
32502
|
+
}),
|
|
32616
32503
|
permissionLevel: 1 /* Read */
|
|
32617
32504
|
};
|
|
32618
|
-
var
|
|
32505
|
+
var handler7 = async (provider, args) => {
|
|
32619
32506
|
if (!provider.listFiles) {
|
|
32620
32507
|
return {
|
|
32621
32508
|
type: "Error" /* Error */,
|
|
32622
32509
|
message: "Not possible to list files. Abort."
|
|
32623
32510
|
};
|
|
32624
32511
|
}
|
|
32625
|
-
const { path, maxCount, recursive } =
|
|
32512
|
+
const { path, maxCount, recursive } = toolInfo7.parameters.parse(args);
|
|
32626
32513
|
const [files, limitReached] = await provider.listFiles(path, recursive, maxCount);
|
|
32627
32514
|
return {
|
|
32628
32515
|
type: "Reply" /* Reply */,
|
|
@@ -32634,16 +32521,16 @@ ${files.join(`
|
|
|
32634
32521
|
<list_files_truncated>${limitReached}</list_files_truncated>`
|
|
32635
32522
|
};
|
|
32636
32523
|
};
|
|
32637
|
-
var
|
|
32524
|
+
var isAvailable7 = (provider) => {
|
|
32638
32525
|
return !!provider.listFiles;
|
|
32639
32526
|
};
|
|
32640
32527
|
var listFiles_default = {
|
|
32641
|
-
...
|
|
32642
|
-
handler:
|
|
32643
|
-
isAvailable:
|
|
32528
|
+
...toolInfo7,
|
|
32529
|
+
handler: handler7,
|
|
32530
|
+
isAvailable: isAvailable7
|
|
32644
32531
|
};
|
|
32645
32532
|
// ../core/src/tools/readFile.ts
|
|
32646
|
-
var
|
|
32533
|
+
var toolInfo8 = {
|
|
32647
32534
|
name: "read_file",
|
|
32648
32535
|
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.",
|
|
32649
32536
|
parameters: exports_external.object({
|
|
@@ -32653,37 +32540,32 @@ var toolInfo7 = {
|
|
|
32653
32540
|
const values = Array.isArray(val) ? val : [val];
|
|
32654
32541
|
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
32655
32542
|
}, exports_external.array(exports_external.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" })
|
|
32656
|
-
})
|
|
32657
|
-
|
|
32658
|
-
|
|
32659
|
-
|
|
32660
|
-
|
|
32661
|
-
|
|
32662
|
-
name: "path",
|
|
32663
|
-
value: "src/main.js"
|
|
32543
|
+
}).meta({
|
|
32544
|
+
examples: [
|
|
32545
|
+
{
|
|
32546
|
+
description: "Request to read the contents of a file",
|
|
32547
|
+
input: {
|
|
32548
|
+
path: "src/main.js"
|
|
32664
32549
|
}
|
|
32665
|
-
|
|
32666
|
-
|
|
32667
|
-
|
|
32668
|
-
|
|
32669
|
-
|
|
32670
|
-
{
|
|
32671
|
-
name: "path",
|
|
32672
|
-
value: "src/main.js,src/index.js"
|
|
32550
|
+
},
|
|
32551
|
+
{
|
|
32552
|
+
description: "Request to read multiple files",
|
|
32553
|
+
input: {
|
|
32554
|
+
path: "src/main.js,src/index.js"
|
|
32673
32555
|
}
|
|
32674
|
-
|
|
32675
|
-
|
|
32676
|
-
|
|
32556
|
+
}
|
|
32557
|
+
]
|
|
32558
|
+
}),
|
|
32677
32559
|
permissionLevel: 1 /* Read */
|
|
32678
32560
|
};
|
|
32679
|
-
var
|
|
32561
|
+
var handler8 = async (provider, args) => {
|
|
32680
32562
|
if (!provider.readFile) {
|
|
32681
32563
|
return {
|
|
32682
32564
|
type: "Error" /* Error */,
|
|
32683
32565
|
message: "Not possible to read file. Abort."
|
|
32684
32566
|
};
|
|
32685
32567
|
}
|
|
32686
|
-
const { path: paths } =
|
|
32568
|
+
const { path: paths } = toolInfo8.parameters.parse(args);
|
|
32687
32569
|
const resp = [];
|
|
32688
32570
|
for (const path of paths) {
|
|
32689
32571
|
const fileContent = await provider.readFile(path);
|
|
@@ -32704,13 +32586,102 @@ var handler7 = async (provider, args) => {
|
|
|
32704
32586
|
`)
|
|
32705
32587
|
};
|
|
32706
32588
|
};
|
|
32707
|
-
var
|
|
32589
|
+
var isAvailable8 = (provider) => {
|
|
32708
32590
|
return !!provider.readFile;
|
|
32709
32591
|
};
|
|
32710
32592
|
var readFile_default = {
|
|
32711
|
-
...
|
|
32712
|
-
handler:
|
|
32713
|
-
isAvailable:
|
|
32593
|
+
...toolInfo8,
|
|
32594
|
+
handler: handler8,
|
|
32595
|
+
isAvailable: isAvailable8
|
|
32596
|
+
};
|
|
32597
|
+
// ../core/src/tools/removeFile.ts
|
|
32598
|
+
var toolInfo9 = {
|
|
32599
|
+
name: "remove_file",
|
|
32600
|
+
description: "Request to remove a file at the specified path.",
|
|
32601
|
+
parameters: exports_external.object({
|
|
32602
|
+
path: exports_external.string().describe("The path of the file to remove").meta({ usageValue: "File path here" })
|
|
32603
|
+
}).meta({
|
|
32604
|
+
examples: [
|
|
32605
|
+
{
|
|
32606
|
+
description: "Request to remove a file",
|
|
32607
|
+
input: {
|
|
32608
|
+
path: "src/main.js"
|
|
32609
|
+
}
|
|
32610
|
+
}
|
|
32611
|
+
]
|
|
32612
|
+
}),
|
|
32613
|
+
permissionLevel: 2 /* Write */
|
|
32614
|
+
};
|
|
32615
|
+
var handler9 = async (provider, args) => {
|
|
32616
|
+
if (!provider.removeFile) {
|
|
32617
|
+
return {
|
|
32618
|
+
type: "Error" /* Error */,
|
|
32619
|
+
message: "Not possible to remove file. Abort."
|
|
32620
|
+
};
|
|
32621
|
+
}
|
|
32622
|
+
const parsed = toolInfo9.parameters.safeParse(args);
|
|
32623
|
+
if (!parsed.success) {
|
|
32624
|
+
return {
|
|
32625
|
+
type: "Invalid" /* Invalid */,
|
|
32626
|
+
message: `Invalid arguments for remove_file: ${parsed.error.message}`
|
|
32627
|
+
};
|
|
32628
|
+
}
|
|
32629
|
+
const { path } = parsed.data;
|
|
32630
|
+
await provider.removeFile(path);
|
|
32631
|
+
return {
|
|
32632
|
+
type: "Reply" /* Reply */,
|
|
32633
|
+
message: `<remove_file_path>${path}</remove_file_path><status>Success</status>`
|
|
32634
|
+
};
|
|
32635
|
+
};
|
|
32636
|
+
var isAvailable9 = (provider) => {
|
|
32637
|
+
return !!provider.removeFile;
|
|
32638
|
+
};
|
|
32639
|
+
var removeFile_default = {
|
|
32640
|
+
...toolInfo9,
|
|
32641
|
+
handler: handler9,
|
|
32642
|
+
isAvailable: isAvailable9
|
|
32643
|
+
};
|
|
32644
|
+
// ../core/src/tools/renameFile.ts
|
|
32645
|
+
var toolInfo10 = {
|
|
32646
|
+
name: "rename_file",
|
|
32647
|
+
description: "Request to rename a file from source path to target path.",
|
|
32648
|
+
parameters: exports_external.object({
|
|
32649
|
+
source_path: exports_external.string().describe("The current path of the file").meta({ usageValue: "Source file path here" }),
|
|
32650
|
+
target_path: exports_external.string().describe("The new path for the file").meta({ usageValue: "Target file path here" })
|
|
32651
|
+
}).meta({
|
|
32652
|
+
examples: [
|
|
32653
|
+
{
|
|
32654
|
+
description: "Request to rename a file",
|
|
32655
|
+
input: {
|
|
32656
|
+
source_path: "src/old-name.js",
|
|
32657
|
+
target_path: "src/new-name.js"
|
|
32658
|
+
}
|
|
32659
|
+
}
|
|
32660
|
+
]
|
|
32661
|
+
}),
|
|
32662
|
+
permissionLevel: 2 /* Write */
|
|
32663
|
+
};
|
|
32664
|
+
var handler10 = async (provider, args) => {
|
|
32665
|
+
if (!provider.renameFile) {
|
|
32666
|
+
return {
|
|
32667
|
+
type: "Error" /* Error */,
|
|
32668
|
+
message: "Not possible to rename file. Abort."
|
|
32669
|
+
};
|
|
32670
|
+
}
|
|
32671
|
+
const { source_path, target_path } = toolInfo10.parameters.parse(args);
|
|
32672
|
+
await provider.renameFile(source_path, target_path);
|
|
32673
|
+
return {
|
|
32674
|
+
type: "Reply" /* Reply */,
|
|
32675
|
+
message: `<rename_file_path>${target_path}</rename_file_path><status>Success</status>`
|
|
32676
|
+
};
|
|
32677
|
+
};
|
|
32678
|
+
var isAvailable10 = (provider) => {
|
|
32679
|
+
return !!provider.renameFile;
|
|
32680
|
+
};
|
|
32681
|
+
var renameFile_default = {
|
|
32682
|
+
...toolInfo10,
|
|
32683
|
+
handler: handler10,
|
|
32684
|
+
isAvailable: isAvailable10
|
|
32714
32685
|
};
|
|
32715
32686
|
// ../core/src/tools/utils/replaceInFile.ts
|
|
32716
32687
|
var replaceInFile = (fileContent, diff) => {
|
|
@@ -32787,7 +32758,7 @@ var replaceInFile = (fileContent, diff) => {
|
|
|
32787
32758
|
};
|
|
32788
32759
|
|
|
32789
32760
|
// ../core/src/tools/replaceInFile.ts
|
|
32790
|
-
var
|
|
32761
|
+
var toolInfo11 = {
|
|
32791
32762
|
name: "replace_in_file",
|
|
32792
32763
|
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.",
|
|
32793
32764
|
parameters: exports_external.object({
|
|
@@ -32816,18 +32787,13 @@ Critical rules:
|
|
|
32816
32787
|
4. Special operations:
|
|
32817
32788
|
* To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
|
|
32818
32789
|
* To delete code: Use empty REPLACE section`).meta({ usageValue: "Search and replace blocks here" })
|
|
32819
|
-
})
|
|
32820
|
-
|
|
32821
|
-
|
|
32822
|
-
|
|
32823
|
-
|
|
32824
|
-
|
|
32825
|
-
|
|
32826
|
-
value: "src/main.js"
|
|
32827
|
-
},
|
|
32828
|
-
{
|
|
32829
|
-
name: "diff",
|
|
32830
|
-
value: `<<<<<<< SEARCH
|
|
32790
|
+
}).meta({
|
|
32791
|
+
examples: [
|
|
32792
|
+
{
|
|
32793
|
+
description: "Request to replace sections of content in a file",
|
|
32794
|
+
input: {
|
|
32795
|
+
path: "src/main.js",
|
|
32796
|
+
diff: `<<<<<<< SEARCH
|
|
32831
32797
|
import React from 'react';
|
|
32832
32798
|
=======
|
|
32833
32799
|
import React, { useState } from 'react';
|
|
@@ -32855,35 +32821,23 @@ return (
|
|
|
32855
32821
|
<div>
|
|
32856
32822
|
>>>>>>> REPLACE`
|
|
32857
32823
|
}
|
|
32858
|
-
|
|
32859
|
-
|
|
32860
|
-
|
|
32861
|
-
|
|
32862
|
-
|
|
32863
|
-
|
|
32864
|
-
name: "path",
|
|
32865
|
-
value: "src/config.js"
|
|
32866
|
-
},
|
|
32867
|
-
{
|
|
32868
|
-
name: "diff",
|
|
32869
|
-
value: `<<<<<<< SEARCH
|
|
32824
|
+
},
|
|
32825
|
+
{
|
|
32826
|
+
description: "Request to perform a simple, single-line replacement",
|
|
32827
|
+
input: {
|
|
32828
|
+
path: "src/config.js",
|
|
32829
|
+
diff: `<<<<<<< SEARCH
|
|
32870
32830
|
const API_URL = 'https://api.example.com';
|
|
32871
32831
|
=======
|
|
32872
32832
|
const API_URL = 'https://api.staging.example.com';
|
|
32873
32833
|
>>>>>>> REPLACE`
|
|
32874
32834
|
}
|
|
32875
|
-
|
|
32876
|
-
|
|
32877
|
-
|
|
32878
|
-
|
|
32879
|
-
|
|
32880
|
-
|
|
32881
|
-
name: "path",
|
|
32882
|
-
value: "src/utils.js"
|
|
32883
|
-
},
|
|
32884
|
-
{
|
|
32885
|
-
name: "diff",
|
|
32886
|
-
value: `<<<<<<< SEARCH
|
|
32835
|
+
},
|
|
32836
|
+
{
|
|
32837
|
+
description: "Request to add a new function to a file",
|
|
32838
|
+
input: {
|
|
32839
|
+
path: "src/utils.js",
|
|
32840
|
+
diff: `<<<<<<< SEARCH
|
|
32887
32841
|
function helperA() {
|
|
32888
32842
|
// ...
|
|
32889
32843
|
}
|
|
@@ -32897,18 +32851,12 @@ function newHelper() {
|
|
|
32897
32851
|
}
|
|
32898
32852
|
>>>>>>> REPLACE`
|
|
32899
32853
|
}
|
|
32900
|
-
|
|
32901
|
-
|
|
32902
|
-
|
|
32903
|
-
|
|
32904
|
-
|
|
32905
|
-
|
|
32906
|
-
name: "path",
|
|
32907
|
-
value: "src/app.js"
|
|
32908
|
-
},
|
|
32909
|
-
{
|
|
32910
|
-
name: "diff",
|
|
32911
|
-
value: `<<<<<<< SEARCH
|
|
32854
|
+
},
|
|
32855
|
+
{
|
|
32856
|
+
description: "Request to delete a block of code from a file",
|
|
32857
|
+
input: {
|
|
32858
|
+
path: "src/app.js",
|
|
32859
|
+
diff: `<<<<<<< SEARCH
|
|
32912
32860
|
function oldFeature() {
|
|
32913
32861
|
// This is no longer needed
|
|
32914
32862
|
}
|
|
@@ -32916,12 +32864,12 @@ function oldFeature() {
|
|
|
32916
32864
|
=======
|
|
32917
32865
|
>>>>>>> REPLACE`
|
|
32918
32866
|
}
|
|
32919
|
-
|
|
32920
|
-
|
|
32921
|
-
|
|
32867
|
+
}
|
|
32868
|
+
]
|
|
32869
|
+
}),
|
|
32922
32870
|
permissionLevel: 2 /* Write */
|
|
32923
32871
|
};
|
|
32924
|
-
var
|
|
32872
|
+
var handler11 = async (provider, args) => {
|
|
32925
32873
|
if (!provider.readFile || !provider.writeFile) {
|
|
32926
32874
|
return {
|
|
32927
32875
|
type: "Error" /* Error */,
|
|
@@ -32929,7 +32877,7 @@ var handler8 = async (provider, args) => {
|
|
|
32929
32877
|
};
|
|
32930
32878
|
}
|
|
32931
32879
|
try {
|
|
32932
|
-
const { path, diff } =
|
|
32880
|
+
const { path, diff } = toolInfo11.parameters.parse(args);
|
|
32933
32881
|
const fileContent = await provider.readFile(path);
|
|
32934
32882
|
if (fileContent == null) {
|
|
32935
32883
|
return {
|
|
@@ -32966,16 +32914,16 @@ var handler8 = async (provider, args) => {
|
|
|
32966
32914
|
};
|
|
32967
32915
|
}
|
|
32968
32916
|
};
|
|
32969
|
-
var
|
|
32917
|
+
var isAvailable11 = (provider) => {
|
|
32970
32918
|
return !!provider.readFile && !!provider.writeFile;
|
|
32971
32919
|
};
|
|
32972
32920
|
var replaceInFile_default = {
|
|
32973
|
-
...
|
|
32974
|
-
handler:
|
|
32975
|
-
isAvailable:
|
|
32921
|
+
...toolInfo11,
|
|
32922
|
+
handler: handler11,
|
|
32923
|
+
isAvailable: isAvailable11
|
|
32976
32924
|
};
|
|
32977
32925
|
// ../core/src/tools/searchFiles.ts
|
|
32978
|
-
var
|
|
32926
|
+
var toolInfo12 = {
|
|
32979
32927
|
name: "search_files",
|
|
32980
32928
|
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.",
|
|
32981
32929
|
parameters: exports_external.object({
|
|
@@ -32986,29 +32934,21 @@ var toolInfo9 = {
|
|
|
32986
32934
|
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({
|
|
32987
32935
|
usageValue: "file pattern here (optional)"
|
|
32988
32936
|
})
|
|
32989
|
-
})
|
|
32990
|
-
|
|
32991
|
-
|
|
32992
|
-
|
|
32993
|
-
|
|
32994
|
-
|
|
32995
|
-
|
|
32996
|
-
|
|
32997
|
-
},
|
|
32998
|
-
{
|
|
32999
|
-
name: "regex",
|
|
33000
|
-
value: "^components/"
|
|
33001
|
-
},
|
|
33002
|
-
{
|
|
33003
|
-
name: "filePattern",
|
|
33004
|
-
value: "*.ts,*.tsx"
|
|
32937
|
+
}).meta({
|
|
32938
|
+
examples: [
|
|
32939
|
+
{
|
|
32940
|
+
description: "Request to perform a regex search across files",
|
|
32941
|
+
input: {
|
|
32942
|
+
path: "src",
|
|
32943
|
+
regex: "^components/",
|
|
32944
|
+
filePattern: "*.ts,*.tsx"
|
|
33005
32945
|
}
|
|
33006
|
-
|
|
33007
|
-
|
|
33008
|
-
|
|
32946
|
+
}
|
|
32947
|
+
]
|
|
32948
|
+
}),
|
|
33009
32949
|
permissionLevel: 1 /* Read */
|
|
33010
32950
|
};
|
|
33011
|
-
var
|
|
32951
|
+
var handler12 = async (provider, args) => {
|
|
33012
32952
|
if (!provider.searchFiles) {
|
|
33013
32953
|
return {
|
|
33014
32954
|
type: "Error" /* Error */,
|
|
@@ -33016,7 +32956,7 @@ var handler9 = async (provider, args) => {
|
|
|
33016
32956
|
};
|
|
33017
32957
|
}
|
|
33018
32958
|
try {
|
|
33019
|
-
const { path, regex, filePattern } =
|
|
32959
|
+
const { path, regex, filePattern } = toolInfo12.parameters.parse(args);
|
|
33020
32960
|
const files = await provider.searchFiles(path, regex, filePattern ?? "*");
|
|
33021
32961
|
return {
|
|
33022
32962
|
type: "Reply" /* Reply */,
|
|
@@ -33036,33 +32976,28 @@ ${files.join(`
|
|
|
33036
32976
|
};
|
|
33037
32977
|
}
|
|
33038
32978
|
};
|
|
33039
|
-
var
|
|
32979
|
+
var isAvailable12 = (provider) => {
|
|
33040
32980
|
return !!provider.searchFiles;
|
|
33041
32981
|
};
|
|
33042
32982
|
var searchFiles_default = {
|
|
33043
|
-
...
|
|
33044
|
-
handler:
|
|
33045
|
-
isAvailable:
|
|
32983
|
+
...toolInfo12,
|
|
32984
|
+
handler: handler12,
|
|
32985
|
+
isAvailable: isAvailable12
|
|
33046
32986
|
};
|
|
33047
32987
|
// ../core/src/tools/writeToFile.ts
|
|
33048
|
-
var
|
|
32988
|
+
var toolInfo13 = {
|
|
33049
32989
|
name: "write_to_file",
|
|
33050
32990
|
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.",
|
|
33051
32991
|
parameters: exports_external.object({
|
|
33052
32992
|
path: exports_external.string().describe("The path of the file to write to").meta({ usageValue: "File path here" }),
|
|
33053
32993
|
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" })
|
|
33054
|
-
})
|
|
33055
|
-
|
|
33056
|
-
|
|
33057
|
-
|
|
33058
|
-
|
|
33059
|
-
|
|
33060
|
-
|
|
33061
|
-
value: "src/main.js"
|
|
33062
|
-
},
|
|
33063
|
-
{
|
|
33064
|
-
name: "content",
|
|
33065
|
-
value: `import React from 'react';
|
|
32994
|
+
}).meta({
|
|
32995
|
+
examples: [
|
|
32996
|
+
{
|
|
32997
|
+
description: "Request to write content to a file",
|
|
32998
|
+
input: {
|
|
32999
|
+
path: "src/main.js",
|
|
33000
|
+
content: `import React from 'react';
|
|
33066
33001
|
|
|
33067
33002
|
function App() {
|
|
33068
33003
|
return (
|
|
@@ -33075,19 +33010,19 @@ function App() {
|
|
|
33075
33010
|
export default App;
|
|
33076
33011
|
`
|
|
33077
33012
|
}
|
|
33078
|
-
|
|
33079
|
-
|
|
33080
|
-
|
|
33013
|
+
}
|
|
33014
|
+
]
|
|
33015
|
+
}),
|
|
33081
33016
|
permissionLevel: 2 /* Write */
|
|
33082
33017
|
};
|
|
33083
|
-
var
|
|
33018
|
+
var handler13 = async (provider, args) => {
|
|
33084
33019
|
if (!provider.writeFile) {
|
|
33085
33020
|
return {
|
|
33086
33021
|
type: "Error" /* Error */,
|
|
33087
33022
|
message: "Not possible to write file. Abort."
|
|
33088
33023
|
};
|
|
33089
33024
|
}
|
|
33090
|
-
const parsed =
|
|
33025
|
+
const parsed = toolInfo13.parameters.safeParse(args);
|
|
33091
33026
|
if (!parsed.success) {
|
|
33092
33027
|
return {
|
|
33093
33028
|
type: "Invalid" /* Invalid */,
|
|
@@ -33104,171 +33039,10 @@ var handler10 = async (provider, args) => {
|
|
|
33104
33039
|
message: `<write_to_file_path>${path}</write_to_file_path><status>Success</status>`
|
|
33105
33040
|
};
|
|
33106
33041
|
};
|
|
33107
|
-
var
|
|
33042
|
+
var isAvailable13 = (provider) => {
|
|
33108
33043
|
return !!provider.writeFile;
|
|
33109
33044
|
};
|
|
33110
33045
|
var writeToFile_default = {
|
|
33111
|
-
...toolInfo10,
|
|
33112
|
-
handler: handler10,
|
|
33113
|
-
isAvailable: isAvailable10
|
|
33114
|
-
};
|
|
33115
|
-
// ../core/src/tools/handOver.ts
|
|
33116
|
-
var toolInfo11 = {
|
|
33117
|
-
name: "hand_over",
|
|
33118
|
-
description: "Hand over the current task to another agent to complete. This tool MUST NOT to be used with any other tool.",
|
|
33119
|
-
parameters: exports_external.object({
|
|
33120
|
-
agentName: exports_external.string().describe("The name of the agent to hand over the task to").meta({ usageValue: "Name of the target agent" }),
|
|
33121
|
-
task: exports_external.string().describe("The task to be completed by the target agent").meta({ usageValue: "Task description" }),
|
|
33122
|
-
context: exports_external.string().describe("The context information for the task").meta({ usageValue: "Context information" }),
|
|
33123
|
-
files: exports_external.preprocess((val) => {
|
|
33124
|
-
if (!val)
|
|
33125
|
-
return [];
|
|
33126
|
-
const values = Array.isArray(val) ? val : [val];
|
|
33127
|
-
return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
|
|
33128
|
-
}, exports_external.array(exports_external.string())).optional().describe("The files relevant to the task. Comma separated paths").meta({ usageValue: "Relevant files" })
|
|
33129
|
-
}),
|
|
33130
|
-
examples: [
|
|
33131
|
-
{
|
|
33132
|
-
description: "Hand over a coding task to the coder agent",
|
|
33133
|
-
parameters: [
|
|
33134
|
-
{
|
|
33135
|
-
name: "agentName",
|
|
33136
|
-
value: "coder"
|
|
33137
|
-
},
|
|
33138
|
-
{
|
|
33139
|
-
name: "task",
|
|
33140
|
-
value: "Implement the login feature"
|
|
33141
|
-
},
|
|
33142
|
-
{
|
|
33143
|
-
name: "context",
|
|
33144
|
-
value: "We need a secure login system with email and password"
|
|
33145
|
-
},
|
|
33146
|
-
{
|
|
33147
|
-
name: "files",
|
|
33148
|
-
value: "src/auth/login.ts,src/auth/types.ts"
|
|
33149
|
-
}
|
|
33150
|
-
]
|
|
33151
|
-
}
|
|
33152
|
-
],
|
|
33153
|
-
permissionLevel: 0 /* None */
|
|
33154
|
-
};
|
|
33155
|
-
var handler11 = async (_provider, args) => {
|
|
33156
|
-
const parsed = toolInfo11.parameters.safeParse(args);
|
|
33157
|
-
if (!parsed.success) {
|
|
33158
|
-
return {
|
|
33159
|
-
type: "Invalid" /* Invalid */,
|
|
33160
|
-
message: `Invalid arguments for hand_over: ${parsed.error.message}`
|
|
33161
|
-
};
|
|
33162
|
-
}
|
|
33163
|
-
const { agentName, task, context, files } = parsed.data;
|
|
33164
|
-
return {
|
|
33165
|
-
type: "HandOver" /* HandOver */,
|
|
33166
|
-
agentName,
|
|
33167
|
-
task,
|
|
33168
|
-
context,
|
|
33169
|
-
files: files ?? []
|
|
33170
|
-
};
|
|
33171
|
-
};
|
|
33172
|
-
var isAvailable11 = (_provider) => {
|
|
33173
|
-
return true;
|
|
33174
|
-
};
|
|
33175
|
-
var handOver_default = {
|
|
33176
|
-
...toolInfo11,
|
|
33177
|
-
handler: handler11,
|
|
33178
|
-
isAvailable: isAvailable11
|
|
33179
|
-
};
|
|
33180
|
-
// ../core/src/tools/removeFile.ts
|
|
33181
|
-
var toolInfo12 = {
|
|
33182
|
-
name: "remove_file",
|
|
33183
|
-
description: "Request to remove a file at the specified path.",
|
|
33184
|
-
parameters: exports_external.object({
|
|
33185
|
-
path: exports_external.string().describe("The path of the file to remove").meta({ usageValue: "File path here" })
|
|
33186
|
-
}),
|
|
33187
|
-
examples: [
|
|
33188
|
-
{
|
|
33189
|
-
description: "Request to remove a file",
|
|
33190
|
-
parameters: [
|
|
33191
|
-
{
|
|
33192
|
-
name: "path",
|
|
33193
|
-
value: "src/main.js"
|
|
33194
|
-
}
|
|
33195
|
-
]
|
|
33196
|
-
}
|
|
33197
|
-
],
|
|
33198
|
-
permissionLevel: 2 /* Write */
|
|
33199
|
-
};
|
|
33200
|
-
var handler12 = async (provider, args) => {
|
|
33201
|
-
if (!provider.removeFile) {
|
|
33202
|
-
return {
|
|
33203
|
-
type: "Error" /* Error */,
|
|
33204
|
-
message: "Not possible to remove file. Abort."
|
|
33205
|
-
};
|
|
33206
|
-
}
|
|
33207
|
-
const parsed = toolInfo12.parameters.safeParse(args);
|
|
33208
|
-
if (!parsed.success) {
|
|
33209
|
-
return {
|
|
33210
|
-
type: "Invalid" /* Invalid */,
|
|
33211
|
-
message: `Invalid arguments for remove_file: ${parsed.error.message}`
|
|
33212
|
-
};
|
|
33213
|
-
}
|
|
33214
|
-
const { path } = parsed.data;
|
|
33215
|
-
await provider.removeFile(path);
|
|
33216
|
-
return {
|
|
33217
|
-
type: "Reply" /* Reply */,
|
|
33218
|
-
message: `<remove_file_path>${path}</remove_file_path><status>Success</status>`
|
|
33219
|
-
};
|
|
33220
|
-
};
|
|
33221
|
-
var isAvailable12 = (provider) => {
|
|
33222
|
-
return !!provider.removeFile;
|
|
33223
|
-
};
|
|
33224
|
-
var removeFile_default = {
|
|
33225
|
-
...toolInfo12,
|
|
33226
|
-
handler: handler12,
|
|
33227
|
-
isAvailable: isAvailable12
|
|
33228
|
-
};
|
|
33229
|
-
// ../core/src/tools/renameFile.ts
|
|
33230
|
-
var toolInfo13 = {
|
|
33231
|
-
name: "rename_file",
|
|
33232
|
-
description: "Request to rename a file from source path to target path.",
|
|
33233
|
-
parameters: exports_external.object({
|
|
33234
|
-
source_path: exports_external.string().describe("The current path of the file").meta({ usageValue: "Source file path here" }),
|
|
33235
|
-
target_path: exports_external.string().describe("The new path for the file").meta({ usageValue: "Target file path here" })
|
|
33236
|
-
}),
|
|
33237
|
-
examples: [
|
|
33238
|
-
{
|
|
33239
|
-
description: "Request to rename a file",
|
|
33240
|
-
parameters: [
|
|
33241
|
-
{
|
|
33242
|
-
name: "source_path",
|
|
33243
|
-
value: "src/old-name.js"
|
|
33244
|
-
},
|
|
33245
|
-
{
|
|
33246
|
-
name: "target_path",
|
|
33247
|
-
value: "src/new-name.js"
|
|
33248
|
-
}
|
|
33249
|
-
]
|
|
33250
|
-
}
|
|
33251
|
-
],
|
|
33252
|
-
permissionLevel: 2 /* Write */
|
|
33253
|
-
};
|
|
33254
|
-
var handler13 = async (provider, args) => {
|
|
33255
|
-
if (!provider.renameFile) {
|
|
33256
|
-
return {
|
|
33257
|
-
type: "Error" /* Error */,
|
|
33258
|
-
message: "Not possible to rename file. Abort."
|
|
33259
|
-
};
|
|
33260
|
-
}
|
|
33261
|
-
const { source_path, target_path } = toolInfo13.parameters.parse(args);
|
|
33262
|
-
await provider.renameFile(source_path, target_path);
|
|
33263
|
-
return {
|
|
33264
|
-
type: "Reply" /* Reply */,
|
|
33265
|
-
message: `<rename_file_path>${target_path}</rename_file_path><status>Success</status>`
|
|
33266
|
-
};
|
|
33267
|
-
};
|
|
33268
|
-
var isAvailable13 = (provider) => {
|
|
33269
|
-
return !!provider.renameFile;
|
|
33270
|
-
};
|
|
33271
|
-
var renameFile_default = {
|
|
33272
33046
|
...toolInfo13,
|
|
33273
33047
|
handler: handler13,
|
|
33274
33048
|
isAvailable: isAvailable13
|
|
@@ -33298,43 +33072,140 @@ var getAvailableTools = ({
|
|
|
33298
33072
|
return tools;
|
|
33299
33073
|
};
|
|
33300
33074
|
|
|
33301
|
-
// ../core/src/
|
|
33302
|
-
|
|
33303
|
-
|
|
33304
|
-
|
|
33305
|
-
|
|
33306
|
-
|
|
33307
|
-
|
|
33308
|
-
|
|
33309
|
-
const
|
|
33310
|
-
|
|
33311
|
-
|
|
33312
|
-
|
|
33313
|
-
|
|
33314
|
-
|
|
33315
|
-
|
|
33316
|
-
|
|
33075
|
+
// ../core/src/UsageMeter.ts
|
|
33076
|
+
class UsageMeter {
|
|
33077
|
+
#totals = { input: 0, output: 0, cachedRead: 0, cost: 0 };
|
|
33078
|
+
#calls = 0;
|
|
33079
|
+
#modelInfos;
|
|
33080
|
+
#maxMessages;
|
|
33081
|
+
#maxCost;
|
|
33082
|
+
constructor(modelInfos = {}, opts = {}) {
|
|
33083
|
+
const infos = {};
|
|
33084
|
+
for (const [provider2, providerInfo] of Object.entries(modelInfos)) {
|
|
33085
|
+
for (const [model, modelInfo] of Object.entries(providerInfo)) {
|
|
33086
|
+
infos[`${provider2.split("-")[0]}:${model.replace(/[.-]/g, "")}`] = {
|
|
33087
|
+
inputPrice: modelInfo.inputPrice ?? 0,
|
|
33088
|
+
outputPrice: modelInfo.outputPrice ?? 0,
|
|
33089
|
+
cacheWritesPrice: modelInfo.cacheWritesPrice ?? 0,
|
|
33090
|
+
cacheReadsPrice: modelInfo.cacheReadsPrice ?? 0
|
|
33091
|
+
};
|
|
33092
|
+
}
|
|
33317
33093
|
}
|
|
33318
|
-
|
|
33319
|
-
|
|
33320
|
-
|
|
33321
|
-
|
|
33322
|
-
|
|
33323
|
-
|
|
33324
|
-
|
|
33094
|
+
this.#modelInfos = infos;
|
|
33095
|
+
this.#maxMessages = opts.maxMessages ?? 1000;
|
|
33096
|
+
this.#maxCost = opts.maxCost ?? 100;
|
|
33097
|
+
}
|
|
33098
|
+
#calculageUsage(usage, providerMetadata, modelInfo) {
|
|
33099
|
+
const providerMetadataKey = Object.keys(providerMetadata ?? {})[0];
|
|
33100
|
+
const metadata = providerMetadata?.[providerMetadataKey] ?? {};
|
|
33101
|
+
switch (providerMetadataKey) {
|
|
33102
|
+
case "openrouter":
|
|
33103
|
+
return {
|
|
33104
|
+
input: usage.inputTokens ?? 0,
|
|
33105
|
+
output: usage.outputTokens ?? 0,
|
|
33106
|
+
cachedRead: usage.cachedInputTokens ?? 0,
|
|
33107
|
+
cost: metadata.usage?.cost ?? 0
|
|
33108
|
+
};
|
|
33109
|
+
case "anthropic": {
|
|
33110
|
+
const cachedRead = usage.cachedInputTokens ?? 0;
|
|
33111
|
+
const cacheWrite = metadata?.promptCacheMissTokens ?? 0;
|
|
33112
|
+
const input = usage.inputTokens ?? 0;
|
|
33113
|
+
const output = usage.outputTokens ?? 0;
|
|
33114
|
+
return {
|
|
33115
|
+
input: input + cacheWrite + cachedRead,
|
|
33116
|
+
output,
|
|
33117
|
+
cachedRead,
|
|
33118
|
+
cost: (input * modelInfo.inputPrice + output * modelInfo.outputPrice + cacheWrite * modelInfo.cacheWritesPrice + cachedRead * modelInfo.cacheReadsPrice) / 1e6
|
|
33119
|
+
};
|
|
33120
|
+
}
|
|
33121
|
+
case "deepseek": {
|
|
33122
|
+
const cachedRead = usage.cachedInputTokens ?? 0;
|
|
33123
|
+
const cacheWrite = metadata.promptCacheMissTokens ?? 0;
|
|
33124
|
+
const input = usage.inputTokens ?? 0;
|
|
33125
|
+
const output = usage.outputTokens ?? 0;
|
|
33126
|
+
return {
|
|
33127
|
+
input,
|
|
33128
|
+
output,
|
|
33129
|
+
cachedRead,
|
|
33130
|
+
cost: (output * modelInfo.outputPrice + cacheWrite * modelInfo.inputPrice + cachedRead * modelInfo.cacheReadsPrice) / 1e6
|
|
33131
|
+
};
|
|
33132
|
+
}
|
|
33133
|
+
default: {
|
|
33134
|
+
const cachedRead = usage.cachedInputTokens ?? 0;
|
|
33135
|
+
const input = usage.inputTokens ?? 0;
|
|
33136
|
+
const output = usage.outputTokens ?? 0;
|
|
33137
|
+
return {
|
|
33138
|
+
input,
|
|
33139
|
+
output,
|
|
33140
|
+
cachedRead,
|
|
33141
|
+
cost: (input * modelInfo.inputPrice + output * modelInfo.outputPrice) / 1e6
|
|
33142
|
+
};
|
|
33325
33143
|
}
|
|
33326
33144
|
}
|
|
33327
|
-
parameters.push(param);
|
|
33328
33145
|
}
|
|
33329
|
-
|
|
33330
|
-
}
|
|
33331
|
-
|
|
33332
|
-
|
|
33333
|
-
|
|
33334
|
-
|
|
33335
|
-
|
|
33336
|
-
|
|
33337
|
-
|
|
33146
|
+
addUsage(llm, resp, options = {}) {
|
|
33147
|
+
const modelInfo = options.modelInfo ?? this.#modelInfos[`${llm.provider.split(".")[0]}:${llm.modelId.replace(/[.-]/g, "")}`] ?? {
|
|
33148
|
+
inputPrice: 0,
|
|
33149
|
+
outputPrice: 0,
|
|
33150
|
+
cacheWritesPrice: 0,
|
|
33151
|
+
cacheReadsPrice: 0
|
|
33152
|
+
};
|
|
33153
|
+
const usage = "totalUsage" in resp ? resp.totalUsage : resp.usage;
|
|
33154
|
+
const result = this.#calculageUsage(usage, resp.providerMetadata, modelInfo);
|
|
33155
|
+
this.#totals.input += result.input;
|
|
33156
|
+
this.#totals.output += result.output;
|
|
33157
|
+
this.#totals.cachedRead += result.cachedRead;
|
|
33158
|
+
this.#totals.cost += result.cost;
|
|
33159
|
+
this.#calls++;
|
|
33160
|
+
}
|
|
33161
|
+
setUsage(newUsage) {
|
|
33162
|
+
if (newUsage.input != null)
|
|
33163
|
+
this.#totals.input = newUsage.input;
|
|
33164
|
+
if (newUsage.output != null)
|
|
33165
|
+
this.#totals.output = newUsage.output;
|
|
33166
|
+
if (newUsage.cachedRead != null)
|
|
33167
|
+
this.#totals.cachedRead = newUsage.cachedRead;
|
|
33168
|
+
if (newUsage.cost != null)
|
|
33169
|
+
this.#totals.cost = newUsage.cost;
|
|
33170
|
+
if (newUsage.calls != null)
|
|
33171
|
+
this.#calls = newUsage.calls;
|
|
33172
|
+
}
|
|
33173
|
+
incrementMessageCount(n = 1) {
|
|
33174
|
+
this.#calls += n;
|
|
33175
|
+
}
|
|
33176
|
+
resetUsage() {
|
|
33177
|
+
this.#totals = { input: 0, output: 0, cachedRead: 0, cost: 0 };
|
|
33178
|
+
this.#calls = 0;
|
|
33179
|
+
}
|
|
33180
|
+
isLimitExceeded() {
|
|
33181
|
+
const messageCount = this.#maxMessages !== undefined && this.#calls >= this.#maxMessages;
|
|
33182
|
+
const cost = this.#maxCost !== undefined && this.#totals.cost >= this.#maxCost;
|
|
33183
|
+
return {
|
|
33184
|
+
messageCount,
|
|
33185
|
+
maxMessages: this.#maxMessages,
|
|
33186
|
+
cost,
|
|
33187
|
+
maxCost: this.#maxCost,
|
|
33188
|
+
result: messageCount || cost
|
|
33189
|
+
};
|
|
33190
|
+
}
|
|
33191
|
+
checkLimit() {
|
|
33192
|
+
const result = this.isLimitExceeded();
|
|
33193
|
+
if (result.result) {
|
|
33194
|
+
throw new Error(`Usage limit exceeded. Message count: ${result.messageCount}/${result.maxMessages}, cost: ${result.cost}/${result.maxCost}`);
|
|
33195
|
+
}
|
|
33196
|
+
}
|
|
33197
|
+
get usage() {
|
|
33198
|
+
return { ...this.#totals, messageCount: this.#calls };
|
|
33199
|
+
}
|
|
33200
|
+
printUsage() {
|
|
33201
|
+
const u = this.usage;
|
|
33202
|
+
console.log(`Usage - messages: ${u.messageCount}, input: ${u.input}, cached: ${u.cachedRead}, ` + `output: ${u.output}, cost: $${u.cost.toFixed(4)}`);
|
|
33203
|
+
}
|
|
33204
|
+
onFinishHandler(llm) {
|
|
33205
|
+
return (evt) => {
|
|
33206
|
+
this.addUsage(llm, evt);
|
|
33207
|
+
};
|
|
33208
|
+
}
|
|
33338
33209
|
}
|
|
33339
33210
|
|
|
33340
33211
|
// ../../node_modules/@ai-sdk/provider/dist/index.mjs
|
|
@@ -55868,6 +55739,53 @@ var JSONRPCMessageSchema = exports_external2.union([
|
|
|
55868
55739
|
JSONRPCErrorSchema
|
|
55869
55740
|
]);
|
|
55870
55741
|
|
|
55742
|
+
// ../core/src/Agent/AgentBase.ts
|
|
55743
|
+
var import_lodash = __toESM(require_lodash(), 1);
|
|
55744
|
+
|
|
55745
|
+
// ../core/src/tool-v1-compat.ts
|
|
55746
|
+
function zodSchemaToParameters(schema) {
|
|
55747
|
+
const parameters = [];
|
|
55748
|
+
const { shape } = schema;
|
|
55749
|
+
for (const name17 in shape) {
|
|
55750
|
+
const def = shape[name17];
|
|
55751
|
+
const isOptional = def.safeParse(undefined).success;
|
|
55752
|
+
const description = def.description || "";
|
|
55753
|
+
const param = {
|
|
55754
|
+
name: name17,
|
|
55755
|
+
description,
|
|
55756
|
+
required: !isOptional
|
|
55757
|
+
};
|
|
55758
|
+
const usageValue = def.meta()?.usageValue;
|
|
55759
|
+
if (usageValue) {
|
|
55760
|
+
param.usageValue = usageValue;
|
|
55761
|
+
}
|
|
55762
|
+
if (def instanceof exports_external.ZodObject) {
|
|
55763
|
+
param.children = zodSchemaToParameters(def);
|
|
55764
|
+
} else if (def instanceof exports_external.ZodArray) {
|
|
55765
|
+
param.allowMultiple = true;
|
|
55766
|
+
const element = def.element;
|
|
55767
|
+
if (element instanceof exports_external.ZodObject) {
|
|
55768
|
+
param.children = zodSchemaToParameters(element);
|
|
55769
|
+
}
|
|
55770
|
+
}
|
|
55771
|
+
parameters.push(param);
|
|
55772
|
+
}
|
|
55773
|
+
return parameters;
|
|
55774
|
+
}
|
|
55775
|
+
function toToolInfoV1(tool) {
|
|
55776
|
+
const { parameters: zodSchema2, ...rest } = tool;
|
|
55777
|
+
const v1Parameters = zodSchemaToParameters(zodSchema2);
|
|
55778
|
+
const examples = zodSchema2.meta()?.examples;
|
|
55779
|
+
const v1Tool = {
|
|
55780
|
+
...rest,
|
|
55781
|
+
parameters: v1Parameters
|
|
55782
|
+
};
|
|
55783
|
+
if (examples) {
|
|
55784
|
+
v1Tool.examples = examples;
|
|
55785
|
+
}
|
|
55786
|
+
return v1Tool;
|
|
55787
|
+
}
|
|
55788
|
+
|
|
55871
55789
|
// ../core/src/Agent/parseAssistantMessage.ts
|
|
55872
55790
|
function parseNestedParameters(content, parameterPrefix, childrenParams) {
|
|
55873
55791
|
const result = {};
|
|
@@ -56041,7 +55959,7 @@ var toolInfoExamplesPrompt = (tool, example, toolNamePrefix, parameterPrefix) =>
|
|
|
56041
55959
|
## Example: ${example.description}
|
|
56042
55960
|
|
|
56043
55961
|
<${toolNamePrefix}${tool.name}>
|
|
56044
|
-
${example.
|
|
55962
|
+
${Object.entries(example.input).map(([name17, value]) => renderParameterValue(name17, value, parameterPrefix)).join(`
|
|
56045
55963
|
`)}
|
|
56046
55964
|
</${toolNamePrefix}${tool.name}>
|
|
56047
55965
|
`;
|
|
@@ -56050,6 +55968,7 @@ var toolUsePrompt = (tools, toolNamePrefix) => {
|
|
|
56050
55968
|
return "";
|
|
56051
55969
|
}
|
|
56052
55970
|
const parameterPrefix = `${toolNamePrefix}parameter_`;
|
|
55971
|
+
const v1Tools = tools.map(toToolInfoV1);
|
|
56053
55972
|
return `
|
|
56054
55973
|
====
|
|
56055
55974
|
|
|
@@ -56108,11 +56027,11 @@ Always adhere to this format, ensuring every opening tag has a matching closing
|
|
|
56108
56027
|
NEVER surround tool use with triple backticks (\`\`\`).
|
|
56109
56028
|
|
|
56110
56029
|
# Tools
|
|
56111
|
-
${
|
|
56030
|
+
${v1Tools.map((tool) => toolInfoPrompt(tool, toolNamePrefix, parameterPrefix)).join(`
|
|
56112
56031
|
`)}
|
|
56113
56032
|
|
|
56114
56033
|
# Tool Use Examples
|
|
56115
|
-
${
|
|
56034
|
+
${v1Tools.map((tool) => {
|
|
56116
56035
|
let promp = "";
|
|
56117
56036
|
for (const example of tool.examples ?? []) {
|
|
56118
56037
|
promp += toolInfoExamplesPrompt(tool, example, toolNamePrefix, parameterPrefix);
|
|
@@ -56146,7 +56065,7 @@ ${agent.responsibilities.map((resp) => ` - ${resp}`).join(`
|
|
|
56146
56065
|
- **Current Agent Role**
|
|
56147
56066
|
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.
|
|
56148
56067
|
`;
|
|
56149
|
-
var capabilities = (
|
|
56068
|
+
var capabilities = (_toolNamePrefix) => `
|
|
56150
56069
|
====
|
|
56151
56070
|
|
|
56152
56071
|
CAPABILITIES
|
|
@@ -56205,6 +56124,8 @@ e.g. <tool_tool_name>tool_name</tool_tool_name>
|
|
|
56205
56124
|
Ensure the opening and closing tags are correctly nested and closed, and that you are using the correct tool name.
|
|
56206
56125
|
Avoid unnecessary text or symbols before or after the tool use.
|
|
56207
56126
|
Avoid unnecessary escape characters or special characters.
|
|
56127
|
+
`,
|
|
56128
|
+
requireUseToolNative: `Error: No tool use detected. You MUST use a tool before proceeding.
|
|
56208
56129
|
`,
|
|
56209
56130
|
toolResults: (tool, result) => {
|
|
56210
56131
|
if (typeof result === "string") {
|
|
@@ -56243,6 +56164,7 @@ class AgentBase {
|
|
|
56243
56164
|
config;
|
|
56244
56165
|
handlers;
|
|
56245
56166
|
#policies;
|
|
56167
|
+
#toolSet;
|
|
56246
56168
|
#messages = [];
|
|
56247
56169
|
#aborted = false;
|
|
56248
56170
|
#abortController;
|
|
@@ -56280,6 +56202,20 @@ ${instance.prompt}`;
|
|
|
56280
56202
|
role: "system",
|
|
56281
56203
|
content: this.config.systemPrompt
|
|
56282
56204
|
});
|
|
56205
|
+
if (this.config.toolFormat === "native") {
|
|
56206
|
+
const tools = {};
|
|
56207
|
+
for (const tool of Object.values(this.handlers)) {
|
|
56208
|
+
const toolName = import_lodash.camelCase(tool.name);
|
|
56209
|
+
tools[toolName] = {
|
|
56210
|
+
description: tool.description,
|
|
56211
|
+
inputSchema: jsonSchema(toJSONSchema(tool.parameters))
|
|
56212
|
+
};
|
|
56213
|
+
this.handlers[toolName] = tool;
|
|
56214
|
+
}
|
|
56215
|
+
this.#toolSet = tools;
|
|
56216
|
+
} else {
|
|
56217
|
+
this.#toolSet = {};
|
|
56218
|
+
}
|
|
56283
56219
|
}
|
|
56284
56220
|
abort() {
|
|
56285
56221
|
this.#aborted = true;
|
|
@@ -56307,13 +56243,19 @@ ${instance.prompt}`;
|
|
|
56307
56243
|
if (this.#messages.length === 0) {
|
|
56308
56244
|
this.#callback({ kind: "StartTask" /* StartTask */, agent: this, systemPrompt: this.config.systemPrompt });
|
|
56309
56245
|
}
|
|
56310
|
-
return await this.#request(
|
|
56246
|
+
return await this.#request({
|
|
56247
|
+
role: "user",
|
|
56248
|
+
content: prompt
|
|
56249
|
+
});
|
|
56311
56250
|
}
|
|
56312
56251
|
async handleStepResponse(response) {
|
|
56313
56252
|
return this.#handleResponse(response);
|
|
56314
56253
|
}
|
|
56315
56254
|
async#processLoop(userMessage) {
|
|
56316
|
-
let nextRequest =
|
|
56255
|
+
let nextRequest = {
|
|
56256
|
+
role: "user",
|
|
56257
|
+
content: userMessage
|
|
56258
|
+
};
|
|
56317
56259
|
while (true) {
|
|
56318
56260
|
if (this.#aborted) {
|
|
56319
56261
|
return { type: "Aborted" };
|
|
@@ -56342,10 +56284,7 @@ ${instance.prompt}`;
|
|
|
56342
56284
|
throw new Error("userMessage is missing");
|
|
56343
56285
|
}
|
|
56344
56286
|
await this.#callback({ kind: "StartRequest" /* StartRequest */, agent: this, userMessage });
|
|
56345
|
-
this.#messages.push(
|
|
56346
|
-
role: "user",
|
|
56347
|
-
content: userMessage
|
|
56348
|
-
});
|
|
56287
|
+
this.#messages.push(userMessage);
|
|
56349
56288
|
for (const instance of this.#policies) {
|
|
56350
56289
|
if (instance.onBeforeRequest) {
|
|
56351
56290
|
await instance.onBeforeRequest(this);
|
|
@@ -56357,11 +56296,11 @@ ${instance.prompt}`;
|
|
|
56357
56296
|
messages = await instance.prepareMessages(this, messages);
|
|
56358
56297
|
}
|
|
56359
56298
|
}
|
|
56360
|
-
let currentAssistantMessage = "";
|
|
56361
56299
|
const retryCount = this.config.retryCount ?? 5;
|
|
56362
|
-
const requestTimeoutSeconds = this.config.requestTimeoutSeconds ??
|
|
56300
|
+
const requestTimeoutSeconds = this.config.requestTimeoutSeconds ?? 90;
|
|
56301
|
+
let respMessages = [];
|
|
56363
56302
|
for (let i = 0;i < retryCount; i++) {
|
|
56364
|
-
|
|
56303
|
+
respMessages = [];
|
|
56365
56304
|
let timeout;
|
|
56366
56305
|
const resetTimeout = () => {
|
|
56367
56306
|
if (timeout) {
|
|
@@ -56375,40 +56314,22 @@ ${instance.prompt}`;
|
|
|
56375
56314
|
}
|
|
56376
56315
|
};
|
|
56377
56316
|
this.#abortController = new AbortController;
|
|
56378
|
-
const providerOptions = {};
|
|
56379
|
-
const thinkingBudgetTokens = this.config.parameters?.thinkingBudgetTokens;
|
|
56380
|
-
const enableThinking = thinkingBudgetTokens > 0;
|
|
56381
|
-
if (enableThinking) {
|
|
56382
|
-
providerOptions.anthropic = {
|
|
56383
|
-
thinking: { type: "enabled", budgetTokens: thinkingBudgetTokens }
|
|
56384
|
-
};
|
|
56385
|
-
providerOptions.openrouter = {
|
|
56386
|
-
reasoning: {
|
|
56387
|
-
max_tokens: thinkingBudgetTokens
|
|
56388
|
-
}
|
|
56389
|
-
};
|
|
56390
|
-
providerOptions.google = {
|
|
56391
|
-
thinkingConfig: {
|
|
56392
|
-
includeThoughts: true,
|
|
56393
|
-
thinkingBudget: thinkingBudgetTokens
|
|
56394
|
-
}
|
|
56395
|
-
};
|
|
56396
|
-
}
|
|
56397
56317
|
try {
|
|
56398
|
-
const
|
|
56318
|
+
const streamTextOptions = {
|
|
56399
56319
|
model: this.ai,
|
|
56400
56320
|
messages,
|
|
56401
|
-
providerOptions,
|
|
56321
|
+
providerOptions: this.config.parameters?.providerOptions,
|
|
56402
56322
|
onChunk: async ({ chunk }) => {
|
|
56403
56323
|
resetTimeout();
|
|
56404
56324
|
switch (chunk.type) {
|
|
56405
56325
|
case "text":
|
|
56406
|
-
currentAssistantMessage += chunk.text;
|
|
56407
56326
|
await this.#callback({ kind: "Text" /* Text */, agent: this, newText: chunk.text });
|
|
56408
56327
|
break;
|
|
56409
56328
|
case "reasoning":
|
|
56410
56329
|
await this.#callback({ kind: "Reasoning" /* Reasoning */, agent: this, newText: chunk.text });
|
|
56411
56330
|
break;
|
|
56331
|
+
case "tool-call":
|
|
56332
|
+
break;
|
|
56412
56333
|
}
|
|
56413
56334
|
},
|
|
56414
56335
|
onFinish: this.config.usageMeter.onFinishHandler(this.ai),
|
|
@@ -56416,8 +56337,18 @@ ${instance.prompt}`;
|
|
|
56416
56337
|
console.error("Error in stream:", error81);
|
|
56417
56338
|
},
|
|
56418
56339
|
abortSignal: this.#abortController.signal
|
|
56340
|
+
};
|
|
56341
|
+
if (this.config.toolFormat === "native") {
|
|
56342
|
+
streamTextOptions.tools = this.#toolSet;
|
|
56343
|
+
}
|
|
56344
|
+
const stream = streamText(streamTextOptions);
|
|
56345
|
+
await stream.consumeStream({
|
|
56346
|
+
onError: (error81) => {
|
|
56347
|
+
console.error("Error in stream:", error81);
|
|
56348
|
+
}
|
|
56419
56349
|
});
|
|
56420
|
-
await stream.
|
|
56350
|
+
const resp = await stream.response;
|
|
56351
|
+
respMessages = resp.messages;
|
|
56421
56352
|
} catch (error81) {
|
|
56422
56353
|
if (error81 instanceof Error && error81.name === "AbortError") {
|
|
56423
56354
|
break;
|
|
@@ -56428,7 +56359,7 @@ ${instance.prompt}`;
|
|
|
56428
56359
|
clearTimeout(timeout);
|
|
56429
56360
|
}
|
|
56430
56361
|
}
|
|
56431
|
-
if (
|
|
56362
|
+
if (respMessages.length > 0) {
|
|
56432
56363
|
break;
|
|
56433
56364
|
}
|
|
56434
56365
|
if (this.#aborted) {
|
|
@@ -56436,17 +56367,45 @@ ${instance.prompt}`;
|
|
|
56436
56367
|
}
|
|
56437
56368
|
console.debug(`Retrying request ${i + 1} of ${retryCount}`);
|
|
56438
56369
|
}
|
|
56439
|
-
if (
|
|
56370
|
+
if (respMessages.length === 0) {
|
|
56440
56371
|
if (this.#aborted) {
|
|
56441
56372
|
return [];
|
|
56442
56373
|
}
|
|
56443
56374
|
throw new Error("No assistant message received");
|
|
56444
56375
|
}
|
|
56445
|
-
|
|
56446
|
-
this
|
|
56447
|
-
|
|
56448
|
-
|
|
56449
|
-
|
|
56376
|
+
this.#messages.push(...respMessages);
|
|
56377
|
+
if (this.config.toolFormat === "native") {
|
|
56378
|
+
return respMessages.flatMap((msg) => {
|
|
56379
|
+
if (msg.role === "assistant") {
|
|
56380
|
+
const content = msg.content;
|
|
56381
|
+
if (typeof content === "string") {
|
|
56382
|
+
return [{ type: "text", content }];
|
|
56383
|
+
}
|
|
56384
|
+
return content.flatMap((part) => {
|
|
56385
|
+
if (part.type === "text") {
|
|
56386
|
+
return [{ type: "text", content: part.text }];
|
|
56387
|
+
}
|
|
56388
|
+
if (part.type === "tool-call") {
|
|
56389
|
+
return [{ type: "tool_use", id: part.toolCallId, name: part.toolName, params: part.input }];
|
|
56390
|
+
}
|
|
56391
|
+
return [];
|
|
56392
|
+
});
|
|
56393
|
+
}
|
|
56394
|
+
return [];
|
|
56395
|
+
});
|
|
56396
|
+
}
|
|
56397
|
+
const currentAssistantMessage = respMessages.map((msg) => {
|
|
56398
|
+
if (typeof msg.content === "string") {
|
|
56399
|
+
return msg.content;
|
|
56400
|
+
}
|
|
56401
|
+
return msg.content.map((part) => {
|
|
56402
|
+
if (part.type === "text") {
|
|
56403
|
+
return part.text;
|
|
56404
|
+
}
|
|
56405
|
+
return "";
|
|
56406
|
+
});
|
|
56407
|
+
}).join(`
|
|
56408
|
+
`);
|
|
56450
56409
|
const ret = parseAssistantMessage(currentAssistantMessage, this.config.tools.map(toToolInfoV1), this.config.toolNamePrefix);
|
|
56451
56410
|
await this.#callback({ kind: "EndRequest" /* EndRequest */, agent: this, message: currentAssistantMessage });
|
|
56452
56411
|
return ret;
|
|
@@ -56460,12 +56419,12 @@ ${instance.prompt}`;
|
|
|
56460
56419
|
case "text":
|
|
56461
56420
|
break;
|
|
56462
56421
|
case "tool_use": {
|
|
56463
|
-
await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name });
|
|
56422
|
+
await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name, content: content.params });
|
|
56464
56423
|
const toolResp = await this.#invokeTool(content.name, content.params);
|
|
56465
56424
|
switch (toolResp.type) {
|
|
56466
56425
|
case "Reply" /* Reply */: {
|
|
56467
|
-
await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name });
|
|
56468
|
-
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
56426
|
+
await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name, content: toolResp.message });
|
|
56427
|
+
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message, id: content.id });
|
|
56469
56428
|
break;
|
|
56470
56429
|
}
|
|
56471
56430
|
case "Exit" /* Exit */:
|
|
@@ -56474,17 +56433,17 @@ ${instance.prompt}`;
|
|
|
56474
56433
|
}
|
|
56475
56434
|
return { type: "exit", reason: toolResp };
|
|
56476
56435
|
case "Invalid" /* Invalid */: {
|
|
56477
|
-
await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name });
|
|
56478
|
-
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
56436
|
+
await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name, content: toolResp.message });
|
|
56437
|
+
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message, id: content.id });
|
|
56479
56438
|
break outer;
|
|
56480
56439
|
}
|
|
56481
56440
|
case "Error" /* Error */: {
|
|
56482
|
-
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name });
|
|
56483
|
-
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
56441
|
+
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, content: toolResp.message });
|
|
56442
|
+
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message, id: content.id });
|
|
56484
56443
|
break outer;
|
|
56485
56444
|
}
|
|
56486
56445
|
case "Interrupted" /* Interrupted */:
|
|
56487
|
-
await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name });
|
|
56446
|
+
await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name, content: toolResp.message });
|
|
56488
56447
|
return { type: "exit", reason: toolResp };
|
|
56489
56448
|
case "HandOver" /* HandOver */: {
|
|
56490
56449
|
if (toolResponses.length > 0) {
|
|
@@ -56518,7 +56477,7 @@ ${instance.prompt}`;
|
|
|
56518
56477
|
}
|
|
56519
56478
|
case "Pause" /* Pause */: {
|
|
56520
56479
|
await this.#callback({ kind: "ToolPause" /* ToolPause */, agent: this, tool: content.name, object: toolResp.object });
|
|
56521
|
-
toolResponses.push({ type: "pause", tool: content.name, object: toolResp.object });
|
|
56480
|
+
toolResponses.push({ type: "pause", tool: content.name, object: toolResp.object, id: content.id });
|
|
56522
56481
|
hasPause = true;
|
|
56523
56482
|
}
|
|
56524
56483
|
}
|
|
@@ -56530,10 +56489,49 @@ ${instance.prompt}`;
|
|
|
56530
56489
|
return { type: "exit", reason: { type: "Pause", responses: toolResponses } };
|
|
56531
56490
|
}
|
|
56532
56491
|
if (toolResponses.length === 0) {
|
|
56533
|
-
return {
|
|
56492
|
+
return {
|
|
56493
|
+
type: "reply",
|
|
56494
|
+
message: {
|
|
56495
|
+
role: "user",
|
|
56496
|
+
content: responsePrompts.requireUseToolNative
|
|
56497
|
+
}
|
|
56498
|
+
};
|
|
56499
|
+
}
|
|
56500
|
+
if (this.config.toolFormat === "native") {
|
|
56501
|
+
const toolResults = toolResponses.filter((resp) => resp.type === "response").map((resp) => ({
|
|
56502
|
+
type: "tool-result",
|
|
56503
|
+
toolCallId: resp.id,
|
|
56504
|
+
toolName: resp.tool,
|
|
56505
|
+
output: {
|
|
56506
|
+
type: "text",
|
|
56507
|
+
value: resp.response
|
|
56508
|
+
}
|
|
56509
|
+
}));
|
|
56510
|
+
return {
|
|
56511
|
+
type: "reply",
|
|
56512
|
+
message: {
|
|
56513
|
+
role: "tool",
|
|
56514
|
+
content: toolResults
|
|
56515
|
+
}
|
|
56516
|
+
};
|
|
56517
|
+
}
|
|
56518
|
+
if (toolResponses.length === 0) {
|
|
56519
|
+
return {
|
|
56520
|
+
type: "reply",
|
|
56521
|
+
message: {
|
|
56522
|
+
role: "user",
|
|
56523
|
+
content: responsePrompts.requireUseTool
|
|
56524
|
+
}
|
|
56525
|
+
};
|
|
56534
56526
|
}
|
|
56535
56527
|
const finalResp = toolResponses.filter((resp) => resp.type === "response").flatMap(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2));
|
|
56536
|
-
return {
|
|
56528
|
+
return {
|
|
56529
|
+
type: "reply",
|
|
56530
|
+
message: {
|
|
56531
|
+
role: "user",
|
|
56532
|
+
content: finalResp
|
|
56533
|
+
}
|
|
56534
|
+
};
|
|
56537
56535
|
}
|
|
56538
56536
|
async#invokeTool(name17, args) {
|
|
56539
56537
|
try {
|
|
@@ -56574,6 +56572,80 @@ ${instance.prompt}`;
|
|
|
56574
56572
|
}
|
|
56575
56573
|
}
|
|
56576
56574
|
|
|
56575
|
+
// ../core/src/Agent/AnalyzerAgent/prompts.ts
|
|
56576
|
+
var fullSystemPrompt = (info, tools, toolNamePrefix, instructions, scripts, useNativeTool) => `
|
|
56577
|
+
# Analyzer Agent
|
|
56578
|
+
|
|
56579
|
+
## Role
|
|
56580
|
+
You are the **Analyzer** agent, responsible for:
|
|
56581
|
+
1. **Project Structure Analysis** – Understand codebase organization and architecture.
|
|
56582
|
+
2. **Code Pattern Analysis** – Identify common patterns, conventions, and best practices.
|
|
56583
|
+
3. **Dependency Analysis** – Examine project dependencies and their usage.
|
|
56584
|
+
4. **Workflow Analysis** – Understand development tools, scripts, and processes.
|
|
56585
|
+
5. **Documentation Review** – Analyze documentation and code comments.
|
|
56586
|
+
|
|
56587
|
+
> **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.
|
|
56588
|
+
|
|
56589
|
+
## Rules
|
|
56590
|
+
1. **Thoroughness**: Conduct comprehensive analysis of relevant project aspects.
|
|
56591
|
+
2. **Pattern Recognition**: Identify recurring patterns, conventions, and architectural decisions.
|
|
56592
|
+
3. **Dependency Mapping**: Track and understand relationships between components.
|
|
56593
|
+
4. **Workflow Understanding**: Analyze build processes, testing approaches, and development tools.
|
|
56594
|
+
5. **Documentation Assessment**: Review documentation quality and completeness.
|
|
56595
|
+
6. **Non-Modification**: Never modify code or files - focus solely on analysis.
|
|
56596
|
+
|
|
56597
|
+
${useNativeTool ? "" : toolUsePrompt(tools, toolNamePrefix)}
|
|
56598
|
+
${capabilities(toolNamePrefix)}
|
|
56599
|
+
${systemInformation(info)}
|
|
56600
|
+
${customInstructions(instructions)}
|
|
56601
|
+
${customScripts(scripts)}
|
|
56602
|
+
`;
|
|
56603
|
+
|
|
56604
|
+
// ../core/src/Agent/AnalyzerAgent/index.ts
|
|
56605
|
+
class AnalyzerAgent extends AgentBase {
|
|
56606
|
+
constructor(options) {
|
|
56607
|
+
const combinedTools = [...options.additionalTools ?? [], ...Object.values(exports_allTools)];
|
|
56608
|
+
const tools = getAvailableTools({
|
|
56609
|
+
provider: options.provider,
|
|
56610
|
+
allTools: combinedTools,
|
|
56611
|
+
hasAgent: (options.agents?.length ?? 0) > 0,
|
|
56612
|
+
permissionLevel: 1 /* Read */,
|
|
56613
|
+
interactive: true
|
|
56614
|
+
});
|
|
56615
|
+
const toolNamePrefix = options.toolFormat === "native" ? "" : "tool_";
|
|
56616
|
+
const systemPrompt = fullSystemPrompt({
|
|
56617
|
+
os: options.os
|
|
56618
|
+
}, tools, toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {}, options.toolFormat === "native");
|
|
56619
|
+
super(analyzerAgentInfo.name, options.ai, {
|
|
56620
|
+
systemPrompt,
|
|
56621
|
+
tools,
|
|
56622
|
+
toolNamePrefix,
|
|
56623
|
+
provider: options.provider,
|
|
56624
|
+
interactive: options.interactive,
|
|
56625
|
+
agents: options.agents,
|
|
56626
|
+
scripts: options.scripts,
|
|
56627
|
+
callback: options.callback,
|
|
56628
|
+
policies: options.policies,
|
|
56629
|
+
toolFormat: options.toolFormat,
|
|
56630
|
+
parameters: options.parameters ?? {},
|
|
56631
|
+
usageMeter: options.usageMeter ?? new UsageMeter
|
|
56632
|
+
});
|
|
56633
|
+
}
|
|
56634
|
+
onBeforeInvokeTool() {
|
|
56635
|
+
return Promise.resolve(undefined);
|
|
56636
|
+
}
|
|
56637
|
+
}
|
|
56638
|
+
var analyzerAgentInfo = {
|
|
56639
|
+
name: "analyzer",
|
|
56640
|
+
responsibilities: [
|
|
56641
|
+
"Analyzing project structure and organization",
|
|
56642
|
+
"Identifying key source code files and their relationships",
|
|
56643
|
+
"Understanding common coding patterns and conventions",
|
|
56644
|
+
"Examining development workflow and tooling",
|
|
56645
|
+
"Analyzing dependencies and their usage patterns"
|
|
56646
|
+
]
|
|
56647
|
+
};
|
|
56648
|
+
|
|
56577
56649
|
// ../core/src/Agent/CodeFixerAgent/prompts.ts
|
|
56578
56650
|
var basePrompt = `You are a highly skilled software engineer specializing in debugging and fixing code issues. You have extensive experience with:
|
|
56579
56651
|
- Type systems and type checking
|
|
@@ -56640,7 +56712,7 @@ RETRY GUIDELINES
|
|
|
56640
56712
|
- Explain why the issue remains
|
|
56641
56713
|
- Suggest manual intervention steps
|
|
56642
56714
|
- Report any partial improvements`;
|
|
56643
|
-
var fullSystemPrompt3 = (info, tools, toolNamePrefix, instructions, scripts,
|
|
56715
|
+
var fullSystemPrompt3 = (info, tools, toolNamePrefix, instructions, scripts, _interactive, useNativeTool) => `
|
|
56644
56716
|
${basePrompt}
|
|
56645
56717
|
${useNativeTool ? "" : toolUsePrompt(tools, toolNamePrefix)}
|
|
56646
56718
|
${codeFixingStrategies}
|
|
@@ -56663,10 +56735,10 @@ class CodeFixerAgent extends AgentBase {
|
|
|
56663
56735
|
permissionLevel: 3 /* Arbitrary */,
|
|
56664
56736
|
interactive: true
|
|
56665
56737
|
});
|
|
56666
|
-
const toolNamePrefix = "tool_";
|
|
56738
|
+
const toolNamePrefix = options.toolFormat === "native" ? "" : "tool_";
|
|
56667
56739
|
const systemPrompt = fullSystemPrompt3({
|
|
56668
56740
|
os: options.os
|
|
56669
|
-
}, tools
|
|
56741
|
+
}, tools, toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {}, options.interactive, options.toolFormat === "native");
|
|
56670
56742
|
super(codeFixerAgentInfo.name, options.ai, {
|
|
56671
56743
|
systemPrompt,
|
|
56672
56744
|
tools,
|
|
@@ -56683,7 +56755,7 @@ class CodeFixerAgent extends AgentBase {
|
|
|
56683
56755
|
});
|
|
56684
56756
|
this.#maxRetries = options.maxRetries ?? 5;
|
|
56685
56757
|
}
|
|
56686
|
-
async onBeforeInvokeTool(name17,
|
|
56758
|
+
async onBeforeInvokeTool(name17, _args) {
|
|
56687
56759
|
if (name17 === attemptCompletion_default.name) {
|
|
56688
56760
|
if (this.#retryCount > this.#maxRetries) {
|
|
56689
56761
|
return;
|
|
@@ -56912,23 +56984,23 @@ var prompt = `You are an AiTool designed to assist users in creating new project
|
|
|
56912
56984
|
- Create a .gitattributes file with appropriate configurations:
|
|
56913
56985
|
- Mark lock files as generated and exclude them from diffs
|
|
56914
56986
|
- Example for different package managers:
|
|
56915
|
-
|
|
56987
|
+
|
|
56916
56988
|
# For Bun
|
|
56917
56989
|
bun.lock linguist-generated=true
|
|
56918
56990
|
bun.lock -diff
|
|
56919
|
-
|
|
56991
|
+
|
|
56920
56992
|
# For npm
|
|
56921
56993
|
package-lock.json linguist-generated=true
|
|
56922
56994
|
package-lock.json -diff
|
|
56923
|
-
|
|
56995
|
+
|
|
56924
56996
|
# For Yarn
|
|
56925
56997
|
yarn.lock linguist-generated=true
|
|
56926
56998
|
yarn.lock -diff
|
|
56927
|
-
|
|
56999
|
+
|
|
56928
57000
|
# For pnpm
|
|
56929
57001
|
pnpm-lock.yaml linguist-generated=true
|
|
56930
57002
|
pnpm-lock.yaml -diff
|
|
56931
|
-
|
|
57003
|
+
|
|
56932
57004
|
- Include other common configurations as needed based on project type
|
|
56933
57005
|
|
|
56934
57006
|
6. **Handover to Coder Agent:**
|
|
@@ -57184,6 +57256,184 @@ var generateProjectConfig_default = {
|
|
|
57184
57256
|
agent: "analyzer"
|
|
57185
57257
|
};
|
|
57186
57258
|
|
|
57259
|
+
// ../core/src/AiTool/tools/gitDiff.ts
|
|
57260
|
+
var toolInfo14 = {
|
|
57261
|
+
name: "git_diff",
|
|
57262
|
+
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.",
|
|
57263
|
+
parameters: exports_external.object({
|
|
57264
|
+
staged: exports_external.preprocess((val) => {
|
|
57265
|
+
if (typeof val === "string") {
|
|
57266
|
+
const lower = val.toLowerCase();
|
|
57267
|
+
if (lower === "false")
|
|
57268
|
+
return false;
|
|
57269
|
+
if (lower === "true")
|
|
57270
|
+
return true;
|
|
57271
|
+
}
|
|
57272
|
+
return val;
|
|
57273
|
+
}, exports_external.boolean().optional().default(false)).describe("Get staged changes instead of unstaged changes."),
|
|
57274
|
+
commitRange: exports_external.string().optional().describe('The commit range to get the diff for (e.g., "main...HEAD").'),
|
|
57275
|
+
file: exports_external.string().optional().describe("Get the diff for a specific file.")
|
|
57276
|
+
}),
|
|
57277
|
+
permissionLevel: 1 /* Read */
|
|
57278
|
+
};
|
|
57279
|
+
var handler14 = async (provider2, args) => {
|
|
57280
|
+
if (!provider2.executeCommand) {
|
|
57281
|
+
return {
|
|
57282
|
+
type: "Error" /* Error */,
|
|
57283
|
+
message: "Not possible to execute command. Abort."
|
|
57284
|
+
};
|
|
57285
|
+
}
|
|
57286
|
+
const { staged, file: file3, commitRange } = toolInfo14.parameters.parse(args);
|
|
57287
|
+
const commandParts = ["git", "diff", "--no-color"];
|
|
57288
|
+
if (staged) {
|
|
57289
|
+
commandParts.push("--staged");
|
|
57290
|
+
}
|
|
57291
|
+
if (commitRange) {
|
|
57292
|
+
commandParts.push(commitRange);
|
|
57293
|
+
}
|
|
57294
|
+
if (file3) {
|
|
57295
|
+
commandParts.push("--", file3);
|
|
57296
|
+
}
|
|
57297
|
+
const command = commandParts.join(" ");
|
|
57298
|
+
try {
|
|
57299
|
+
const result = await provider2.executeCommand(command, false);
|
|
57300
|
+
if (result.exitCode === 0) {
|
|
57301
|
+
if (!result.stdout.trim()) {
|
|
57302
|
+
return {
|
|
57303
|
+
type: "Reply" /* Reply */,
|
|
57304
|
+
message: "No diff found."
|
|
57305
|
+
};
|
|
57306
|
+
}
|
|
57307
|
+
return {
|
|
57308
|
+
type: "Reply" /* Reply */,
|
|
57309
|
+
message: `<diff file="${file3 ?? "all"}">
|
|
57310
|
+
${result.stdout}
|
|
57311
|
+
</diff>`
|
|
57312
|
+
};
|
|
57313
|
+
}
|
|
57314
|
+
return {
|
|
57315
|
+
type: "Error" /* Error */,
|
|
57316
|
+
message: `\`${command}\` exited with code ${result.exitCode}:
|
|
57317
|
+
${result.stderr}`
|
|
57318
|
+
};
|
|
57319
|
+
} catch (error81) {
|
|
57320
|
+
return {
|
|
57321
|
+
type: "Error" /* Error */,
|
|
57322
|
+
message: error81 instanceof Error ? error81.message : String(error81)
|
|
57323
|
+
};
|
|
57324
|
+
}
|
|
57325
|
+
};
|
|
57326
|
+
var isAvailable14 = (provider2) => {
|
|
57327
|
+
return !!provider2.executeCommand;
|
|
57328
|
+
};
|
|
57329
|
+
var gitDiff_default = {
|
|
57330
|
+
...toolInfo14,
|
|
57331
|
+
handler: handler14,
|
|
57332
|
+
isAvailable: isAvailable14
|
|
57333
|
+
};
|
|
57334
|
+
|
|
57335
|
+
// ../core/src/AiTool/reviewDiff.ts
|
|
57336
|
+
var prompt5 = `
|
|
57337
|
+
# Code Review Prompt
|
|
57338
|
+
|
|
57339
|
+
You are a senior software engineer reviewing code changes.
|
|
57340
|
+
|
|
57341
|
+
## Viewing Changes
|
|
57342
|
+
- Use **git_diff** to inspect code.
|
|
57343
|
+
- **Pull request**: use the provided commit range.
|
|
57344
|
+
- **Local changes**: diff staged or unstaged files.
|
|
57345
|
+
- If a pull request is present you may receive:
|
|
57346
|
+
- <pr_title>
|
|
57347
|
+
- <pr_description>
|
|
57348
|
+
- <commit_messages>
|
|
57349
|
+
- A <review_instructions> tag tells you the focus of the review.
|
|
57350
|
+
|
|
57351
|
+
## Focus Areas
|
|
57352
|
+
- Readability and maintainability
|
|
57353
|
+
- Correctness, edge cases, potential bugs
|
|
57354
|
+
- Performance implications
|
|
57355
|
+
- Clarity of intent
|
|
57356
|
+
- Best-practice adherence
|
|
57357
|
+
|
|
57358
|
+
## Output Format
|
|
57359
|
+
Do **not** include praise or positive feedback. Ignore generated files such as lock files.
|
|
57360
|
+
|
|
57361
|
+
Return your review as a JSON object inside a \`\`\`json block, wrapped like:
|
|
57362
|
+
<tool_attempt_completion>
|
|
57363
|
+
<tool_parameter_result>
|
|
57364
|
+
\`\`\`json
|
|
57365
|
+
{
|
|
57366
|
+
"overview": "Summary of overall concerns.",
|
|
57367
|
+
"specificReviews": [
|
|
57368
|
+
{
|
|
57369
|
+
"file": "path/filename.ext",
|
|
57370
|
+
"lines": "N or N-M",
|
|
57371
|
+
"review": "Describe the issue and actionable fix or improvement."
|
|
57372
|
+
}
|
|
57373
|
+
]
|
|
57374
|
+
}
|
|
57375
|
+
\`\`\`
|
|
57376
|
+
</tool_parameter_result>
|
|
57377
|
+
</tool_attempt_completion>
|
|
57378
|
+
`;
|
|
57379
|
+
var reviewDiff_default = {
|
|
57380
|
+
name: "reviewDiff",
|
|
57381
|
+
description: "Reviews a git diff",
|
|
57382
|
+
prompt: prompt5,
|
|
57383
|
+
formatInput: (params) => {
|
|
57384
|
+
const parts = [];
|
|
57385
|
+
if (params.pullRequestTitle) {
|
|
57386
|
+
parts.push(`<pr_title>
|
|
57387
|
+
${params.pullRequestTitle}
|
|
57388
|
+
</pr_title>`);
|
|
57389
|
+
}
|
|
57390
|
+
if (params.pullRequestDescription) {
|
|
57391
|
+
parts.push(`<pr_description>
|
|
57392
|
+
${params.pullRequestDescription}
|
|
57393
|
+
</pr_description>`);
|
|
57394
|
+
}
|
|
57395
|
+
if (params.commitMessages) {
|
|
57396
|
+
parts.push(`<commit_messages>
|
|
57397
|
+
${params.commitMessages}
|
|
57398
|
+
</commit_messages>`);
|
|
57399
|
+
}
|
|
57400
|
+
let instructions = "";
|
|
57401
|
+
if (params.commitRange) {
|
|
57402
|
+
instructions = `Review the pull request. Get the diff using the git_diff tool with the commit range '${params.commitRange}'.`;
|
|
57403
|
+
} else if (params.staged) {
|
|
57404
|
+
instructions = "Review the staged changes. Get the diff using the git_diff tool with staged: true.";
|
|
57405
|
+
} else {
|
|
57406
|
+
instructions = "Review the unstaged changes. Get the diff using the git_diff tool.";
|
|
57407
|
+
}
|
|
57408
|
+
parts.push(`<review_instructions>
|
|
57409
|
+
${instructions}
|
|
57410
|
+
</review_instructions>`);
|
|
57411
|
+
return parts.join(`
|
|
57412
|
+
`);
|
|
57413
|
+
},
|
|
57414
|
+
parseOutput: (output) => {
|
|
57415
|
+
const jsonBlockRegex = /```json\n([\s\S]*?)\n```/;
|
|
57416
|
+
const match = output.match(jsonBlockRegex);
|
|
57417
|
+
const content = match ? match[1] : output;
|
|
57418
|
+
try {
|
|
57419
|
+
return JSON.parse(content);
|
|
57420
|
+
} catch (error81) {
|
|
57421
|
+
console.error("Error parsing JSON output:", error81);
|
|
57422
|
+
return {
|
|
57423
|
+
overview: `Could not parse review output. Raw output:
|
|
57424
|
+
${output}`,
|
|
57425
|
+
specificReviews: []
|
|
57426
|
+
};
|
|
57427
|
+
}
|
|
57428
|
+
},
|
|
57429
|
+
agent: (options) => {
|
|
57430
|
+
return new AnalyzerAgent({
|
|
57431
|
+
...options,
|
|
57432
|
+
additionalTools: [gitDiff_default]
|
|
57433
|
+
});
|
|
57434
|
+
}
|
|
57435
|
+
};
|
|
57436
|
+
|
|
57187
57437
|
// ../core/src/AiTool/index.ts
|
|
57188
57438
|
var executeTool = async (definition, ai, params, usageMeter) => {
|
|
57189
57439
|
const resp = await generateText({
|
|
@@ -57199,10 +57449,7 @@ var executeTool = async (definition, ai, params, usageMeter) => {
|
|
|
57199
57449
|
usageMeter.addUsage(ai, resp);
|
|
57200
57450
|
return definition.parseOutput(resp.text);
|
|
57201
57451
|
};
|
|
57202
|
-
var
|
|
57203
|
-
if (!definition.agent) {
|
|
57204
|
-
throw new Error("Agent not specified");
|
|
57205
|
-
}
|
|
57452
|
+
var executeMultiAgentTool = async (definition, agent, params) => {
|
|
57206
57453
|
const exitReason = await agent.startTask({
|
|
57207
57454
|
agentName: definition.agent,
|
|
57208
57455
|
task: definition.prompt,
|
|
@@ -57213,22 +57460,38 @@ var executeAgentTool = async (definition, agent, params) => {
|
|
|
57213
57460
|
}
|
|
57214
57461
|
throw new Error(`Tool execution failed: ${exitReason.type}`);
|
|
57215
57462
|
};
|
|
57463
|
+
var executeAgentTool = async (definition, options, params) => {
|
|
57464
|
+
const agent = definition.agent(options);
|
|
57465
|
+
const exitReason = await agent.start(`${definition.prompt}
|
|
57466
|
+
|
|
57467
|
+
${definition.formatInput(params)}`);
|
|
57468
|
+
if (exitReason.type === "Exit" /* Exit */) {
|
|
57469
|
+
return definition.parseOutput(exitReason.message);
|
|
57470
|
+
}
|
|
57471
|
+
throw new Error(`Tool execution failed: ${exitReason.type}`);
|
|
57472
|
+
};
|
|
57216
57473
|
var makeTool = (definition) => {
|
|
57217
57474
|
return async (ai, params, usageMeter) => {
|
|
57218
57475
|
return executeTool(definition, ai, params, usageMeter);
|
|
57219
57476
|
};
|
|
57220
57477
|
};
|
|
57221
|
-
var
|
|
57478
|
+
var makeMultiAgentTool = (definition) => {
|
|
57222
57479
|
return async (agent, params) => {
|
|
57223
|
-
return
|
|
57480
|
+
return executeMultiAgentTool(definition, agent, params);
|
|
57481
|
+
};
|
|
57482
|
+
};
|
|
57483
|
+
var makeAgentTool = (definition) => {
|
|
57484
|
+
return async (options, params) => {
|
|
57485
|
+
return executeAgentTool(definition, options, params);
|
|
57224
57486
|
};
|
|
57225
57487
|
};
|
|
57226
57488
|
var generateGitCommitMessage = makeTool(generateGitCommitMessage_default);
|
|
57227
57489
|
var generateGithubPullRequestDetails = makeTool(generateGithubPullRequestDetails_default);
|
|
57228
|
-
var
|
|
57229
|
-
var
|
|
57490
|
+
var reviewDiff = makeAgentTool(reviewDiff_default);
|
|
57491
|
+
var generateProjectConfig = makeMultiAgentTool(generateProjectConfig_default);
|
|
57492
|
+
var createNewProject = makeMultiAgentTool(createNewProject_default);
|
|
57230
57493
|
// ../cli-shared/src/config.ts
|
|
57231
|
-
var
|
|
57494
|
+
var import_lodash2 = __toESM(require_lodash(), 1);
|
|
57232
57495
|
|
|
57233
57496
|
// ../cli-shared/node_modules/yaml/dist/index.js
|
|
57234
57497
|
var composer = require_composer();
|
|
@@ -61132,7 +61395,7 @@ function mergeConfigs(configs) {
|
|
|
61132
61395
|
return {};
|
|
61133
61396
|
}
|
|
61134
61397
|
const mergedConfig = configs.reduce((acc, config4) => {
|
|
61135
|
-
const merged =
|
|
61398
|
+
const merged = import_lodash2.merge({}, acc, config4);
|
|
61136
61399
|
let accRules = acc.rules ?? [];
|
|
61137
61400
|
if (typeof accRules === "string") {
|
|
61138
61401
|
accRules = [accRules];
|
|
@@ -61192,7 +61455,6 @@ var readConfig = (path) => {
|
|
|
61192
61455
|
return configSchema.parse(config4);
|
|
61193
61456
|
};
|
|
61194
61457
|
// ../cli-shared/src/provider.ts
|
|
61195
|
-
var import_ignore2 = __toESM(require_ignore(), 1);
|
|
61196
61458
|
import { spawn as spawn2 } from "node:child_process";
|
|
61197
61459
|
import { mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
61198
61460
|
import { dirname } from "node:path";
|
|
@@ -61757,15 +62019,15 @@ function useKeypress(userHandler) {
|
|
|
61757
62019
|
signal.current = userHandler;
|
|
61758
62020
|
useEffect((rl) => {
|
|
61759
62021
|
let ignore = false;
|
|
61760
|
-
const
|
|
62022
|
+
const handler15 = withUpdates((_input, event) => {
|
|
61761
62023
|
if (ignore)
|
|
61762
62024
|
return;
|
|
61763
62025
|
signal.current(event, rl);
|
|
61764
62026
|
});
|
|
61765
|
-
rl.input.on("keypress",
|
|
62027
|
+
rl.input.on("keypress", handler15);
|
|
61766
62028
|
return () => {
|
|
61767
62029
|
ignore = true;
|
|
61768
|
-
rl.input.removeListener("keypress",
|
|
62030
|
+
rl.input.removeListener("keypress", handler15);
|
|
61769
62031
|
};
|
|
61770
62032
|
}, []);
|
|
61771
62033
|
}
|
|
@@ -61924,16 +62186,16 @@ class Emitter {
|
|
|
61924
62186
|
|
|
61925
62187
|
class SignalExitBase {
|
|
61926
62188
|
}
|
|
61927
|
-
var signalExitWrap = (
|
|
62189
|
+
var signalExitWrap = (handler15) => {
|
|
61928
62190
|
return {
|
|
61929
62191
|
onExit(cb, opts) {
|
|
61930
|
-
return
|
|
62192
|
+
return handler15.onExit(cb, opts);
|
|
61931
62193
|
},
|
|
61932
62194
|
load() {
|
|
61933
|
-
return
|
|
62195
|
+
return handler15.load();
|
|
61934
62196
|
},
|
|
61935
62197
|
unload() {
|
|
61936
|
-
return
|
|
62198
|
+
return handler15.unload();
|
|
61937
62199
|
}
|
|
61938
62200
|
};
|
|
61939
62201
|
};
|
|
@@ -62089,11 +62351,11 @@ class ScreenManager {
|
|
|
62089
62351
|
render(content, bottomContent = "") {
|
|
62090
62352
|
const promptLine = lastLine(content);
|
|
62091
62353
|
const rawPromptLine = stripVTControlCharacters(promptLine);
|
|
62092
|
-
let
|
|
62354
|
+
let prompt6 = rawPromptLine;
|
|
62093
62355
|
if (this.rl.line.length > 0) {
|
|
62094
|
-
|
|
62356
|
+
prompt6 = prompt6.slice(0, -this.rl.line.length);
|
|
62095
62357
|
}
|
|
62096
|
-
this.rl.setPrompt(
|
|
62358
|
+
this.rl.setPrompt(prompt6);
|
|
62097
62359
|
this.cursorPos = this.rl.getCursorPos();
|
|
62098
62360
|
const width = readlineWidth();
|
|
62099
62361
|
content = breakLines(content, width);
|
|
@@ -62163,7 +62425,7 @@ function getCallSites() {
|
|
|
62163
62425
|
}
|
|
62164
62426
|
function createPrompt(view) {
|
|
62165
62427
|
const callSites = getCallSites();
|
|
62166
|
-
const
|
|
62428
|
+
const prompt6 = (config4, context = {}) => {
|
|
62167
62429
|
const { input = process.stdin, signal } = context;
|
|
62168
62430
|
const cleanups = new Set;
|
|
62169
62431
|
const output = new import_mute_stream.default;
|
|
@@ -62228,7 +62490,7 @@ function createPrompt(view) {
|
|
|
62228
62490
|
}).then(() => promise4), { cancel });
|
|
62229
62491
|
});
|
|
62230
62492
|
};
|
|
62231
|
-
return
|
|
62493
|
+
return prompt6;
|
|
62232
62494
|
}
|
|
62233
62495
|
// ../../node_modules/@inquirer/core/dist/esm/lib/Separator.js
|
|
62234
62496
|
var import_yoctocolors_cjs2 = __toESM(require_yoctocolors_cjs(), 1);
|
|
@@ -62470,6 +62732,9 @@ ${theme.style.description(selectedChoice.description)}` : ``;
|
|
|
62470
62732
|
return `${[prefix, message, helpTipTop].filter(Boolean).join(" ")}
|
|
62471
62733
|
${page}${helpTipBottom}${choiceDescription}${import_ansi_escapes2.default.cursorHide}`;
|
|
62472
62734
|
});
|
|
62735
|
+
// ../cli-shared/src/provider.ts
|
|
62736
|
+
var import_ignore2 = __toESM(require_ignore(), 1);
|
|
62737
|
+
|
|
62473
62738
|
// ../cli-shared/src/utils/checkRipgrep.ts
|
|
62474
62739
|
import { spawnSync } from "node:child_process";
|
|
62475
62740
|
var rgAvailability = {
|
|
@@ -62632,7 +62897,7 @@ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
|
|
|
62632
62897
|
}
|
|
62633
62898
|
|
|
62634
62899
|
// ../cli-shared/src/provider.ts
|
|
62635
|
-
var getProvider = (
|
|
62900
|
+
var getProvider = (_agentName, _config, options = {}) => {
|
|
62636
62901
|
const ig = import_ignore2.default().add(options.excludeFiles ?? []);
|
|
62637
62902
|
const provider2 = {
|
|
62638
62903
|
readFile: async (path) => {
|
|
@@ -62667,7 +62932,7 @@ var getProvider = (agentName, config4, options = {}) => {
|
|
|
62667
62932
|
listFiles: async (path, recursive, maxCount) => {
|
|
62668
62933
|
return await listFiles(path, recursive, maxCount, process.cwd(), options.excludeFiles);
|
|
62669
62934
|
},
|
|
62670
|
-
executeCommand: (command,
|
|
62935
|
+
executeCommand: (command, _needApprove) => {
|
|
62671
62936
|
return new Promise((resolve3, reject) => {
|
|
62672
62937
|
options.command?.onStarted(command);
|
|
62673
62938
|
const child = spawn2(command, [], {
|
|
@@ -62718,7 +62983,7 @@ var getProvider = (agentName, config4, options = {}) => {
|
|
|
62718
62983
|
}
|
|
62719
62984
|
return answerOptions[0] ?? "<warning>This is non-interactive mode, no answer can be provided.</warning>";
|
|
62720
62985
|
},
|
|
62721
|
-
attemptCompletion: async (
|
|
62986
|
+
attemptCompletion: async (_result) => {
|
|
62722
62987
|
return;
|
|
62723
62988
|
},
|
|
62724
62989
|
fetchUrl: async (url3) => {
|