@polka-codes/runner 0.9.0 → 0.9.2

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.
Files changed (2) hide show
  1. package/dist/index.js +671 -661
  2. 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"];
@@ -21008,7 +21008,7 @@ var {
21008
21008
  Help
21009
21009
  } = import__.default;
21010
21010
  // package.json
21011
- var version = "0.9.0";
21011
+ var version = "0.9.2";
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, {
@@ -32353,7 +32222,7 @@ var handler2 = async (provider, args) => {
32353
32222
  message: `<user_message>${moreMessage}</user_message>`
32354
32223
  };
32355
32224
  };
32356
- var isAvailable2 = (provider) => {
32225
+ var isAvailable2 = (_provider) => {
32357
32226
  return true;
32358
32227
  };
32359
32228
  var attemptCompletion_default = {
@@ -32580,8 +32449,73 @@ var fetchUrl_default = {
32580
32449
  handler: handler5,
32581
32450
  isAvailable: isAvailable5
32582
32451
  };
32583
- // ../core/src/tools/listFiles.ts
32452
+ // ../core/src/tools/handOver.ts
32584
32453
  var toolInfo6 = {
32454
+ name: "hand_over",
32455
+ description: "Hand over the current task to another agent to complete. This tool MUST NOT to be used with any other tool.",
32456
+ parameters: exports_external.object({
32457
+ agentName: exports_external.string().describe("The name of the agent to hand over the task to").meta({ usageValue: "Name of the target agent" }),
32458
+ task: exports_external.string().describe("The task to be completed by the target agent").meta({ usageValue: "Task description" }),
32459
+ context: exports_external.string().describe("The context information for the task").meta({ usageValue: "Context information" }),
32460
+ files: exports_external.preprocess((val) => {
32461
+ if (!val)
32462
+ return [];
32463
+ const values = Array.isArray(val) ? val : [val];
32464
+ return values.flatMap((i) => typeof i === "string" ? i.split(",") : []).filter((s) => s.length > 0);
32465
+ }, exports_external.array(exports_external.string())).optional().describe("The files relevant to the task. Comma separated paths").meta({ usageValue: "Relevant files" })
32466
+ }),
32467
+ examples: [
32468
+ {
32469
+ description: "Hand over a coding task to the coder agent",
32470
+ parameters: [
32471
+ {
32472
+ name: "agentName",
32473
+ value: "coder"
32474
+ },
32475
+ {
32476
+ name: "task",
32477
+ value: "Implement the login feature"
32478
+ },
32479
+ {
32480
+ name: "context",
32481
+ value: "We need a secure login system with email and password"
32482
+ },
32483
+ {
32484
+ name: "files",
32485
+ value: "src/auth/login.ts,src/auth/types.ts"
32486
+ }
32487
+ ]
32488
+ }
32489
+ ],
32490
+ permissionLevel: 0 /* None */
32491
+ };
32492
+ var handler6 = async (_provider, args) => {
32493
+ const parsed = toolInfo6.parameters.safeParse(args);
32494
+ if (!parsed.success) {
32495
+ return {
32496
+ type: "Invalid" /* Invalid */,
32497
+ message: `Invalid arguments for hand_over: ${parsed.error.message}`
32498
+ };
32499
+ }
32500
+ const { agentName, task, context, files } = parsed.data;
32501
+ return {
32502
+ type: "HandOver" /* HandOver */,
32503
+ agentName,
32504
+ task,
32505
+ context,
32506
+ files: files ?? []
32507
+ };
32508
+ };
32509
+ var isAvailable6 = (_provider) => {
32510
+ return true;
32511
+ };
32512
+ var handOver_default = {
32513
+ ...toolInfo6,
32514
+ handler: handler6,
32515
+ isAvailable: isAvailable6
32516
+ };
32517
+ // ../core/src/tools/listFiles.ts
32518
+ var toolInfo7 = {
32585
32519
  name: "list_files",
32586
32520
  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
32521
  parameters: exports_external.object({
@@ -32615,14 +32549,14 @@ var toolInfo6 = {
32615
32549
  ],
32616
32550
  permissionLevel: 1 /* Read */
32617
32551
  };
32618
- var handler6 = async (provider, args) => {
32552
+ var handler7 = async (provider, args) => {
32619
32553
  if (!provider.listFiles) {
32620
32554
  return {
32621
32555
  type: "Error" /* Error */,
32622
32556
  message: "Not possible to list files. Abort."
32623
32557
  };
32624
32558
  }
32625
- const { path, maxCount, recursive } = toolInfo6.parameters.parse(args);
32559
+ const { path, maxCount, recursive } = toolInfo7.parameters.parse(args);
32626
32560
  const [files, limitReached] = await provider.listFiles(path, recursive, maxCount);
32627
32561
  return {
32628
32562
  type: "Reply" /* Reply */,
@@ -32634,16 +32568,16 @@ ${files.join(`
32634
32568
  <list_files_truncated>${limitReached}</list_files_truncated>`
32635
32569
  };
32636
32570
  };
32637
- var isAvailable6 = (provider) => {
32571
+ var isAvailable7 = (provider) => {
32638
32572
  return !!provider.listFiles;
32639
32573
  };
32640
32574
  var listFiles_default = {
32641
- ...toolInfo6,
32642
- handler: handler6,
32643
- isAvailable: isAvailable6
32575
+ ...toolInfo7,
32576
+ handler: handler7,
32577
+ isAvailable: isAvailable7
32644
32578
  };
32645
32579
  // ../core/src/tools/readFile.ts
32646
- var toolInfo7 = {
32580
+ var toolInfo8 = {
32647
32581
  name: "read_file",
32648
32582
  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
32583
  parameters: exports_external.object({
@@ -32676,14 +32610,14 @@ var toolInfo7 = {
32676
32610
  ],
32677
32611
  permissionLevel: 1 /* Read */
32678
32612
  };
32679
- var handler7 = async (provider, args) => {
32613
+ var handler8 = async (provider, args) => {
32680
32614
  if (!provider.readFile) {
32681
32615
  return {
32682
32616
  type: "Error" /* Error */,
32683
32617
  message: "Not possible to read file. Abort."
32684
32618
  };
32685
32619
  }
32686
- const { path: paths } = toolInfo7.parameters.parse(args);
32620
+ const { path: paths } = toolInfo8.parameters.parse(args);
32687
32621
  const resp = [];
32688
32622
  for (const path of paths) {
32689
32623
  const fileContent = await provider.readFile(path);
@@ -32704,13 +32638,109 @@ var handler7 = async (provider, args) => {
32704
32638
  `)
32705
32639
  };
32706
32640
  };
32707
- var isAvailable7 = (provider) => {
32641
+ var isAvailable8 = (provider) => {
32708
32642
  return !!provider.readFile;
32709
32643
  };
32710
32644
  var readFile_default = {
32711
- ...toolInfo7,
32712
- handler: handler7,
32713
- isAvailable: isAvailable7
32645
+ ...toolInfo8,
32646
+ handler: handler8,
32647
+ isAvailable: isAvailable8
32648
+ };
32649
+ // ../core/src/tools/removeFile.ts
32650
+ var toolInfo9 = {
32651
+ name: "remove_file",
32652
+ description: "Request to remove a file at the specified path.",
32653
+ parameters: exports_external.object({
32654
+ path: exports_external.string().describe("The path of the file to remove").meta({ usageValue: "File path here" })
32655
+ }),
32656
+ examples: [
32657
+ {
32658
+ description: "Request to remove a file",
32659
+ parameters: [
32660
+ {
32661
+ name: "path",
32662
+ value: "src/main.js"
32663
+ }
32664
+ ]
32665
+ }
32666
+ ],
32667
+ permissionLevel: 2 /* Write */
32668
+ };
32669
+ var handler9 = async (provider, args) => {
32670
+ if (!provider.removeFile) {
32671
+ return {
32672
+ type: "Error" /* Error */,
32673
+ message: "Not possible to remove file. Abort."
32674
+ };
32675
+ }
32676
+ const parsed = toolInfo9.parameters.safeParse(args);
32677
+ if (!parsed.success) {
32678
+ return {
32679
+ type: "Invalid" /* Invalid */,
32680
+ message: `Invalid arguments for remove_file: ${parsed.error.message}`
32681
+ };
32682
+ }
32683
+ const { path } = parsed.data;
32684
+ await provider.removeFile(path);
32685
+ return {
32686
+ type: "Reply" /* Reply */,
32687
+ message: `<remove_file_path>${path}</remove_file_path><status>Success</status>`
32688
+ };
32689
+ };
32690
+ var isAvailable9 = (provider) => {
32691
+ return !!provider.removeFile;
32692
+ };
32693
+ var removeFile_default = {
32694
+ ...toolInfo9,
32695
+ handler: handler9,
32696
+ isAvailable: isAvailable9
32697
+ };
32698
+ // ../core/src/tools/renameFile.ts
32699
+ var toolInfo10 = {
32700
+ name: "rename_file",
32701
+ description: "Request to rename a file from source path to target path.",
32702
+ parameters: exports_external.object({
32703
+ source_path: exports_external.string().describe("The current path of the file").meta({ usageValue: "Source file path here" }),
32704
+ target_path: exports_external.string().describe("The new path for the file").meta({ usageValue: "Target file path here" })
32705
+ }),
32706
+ examples: [
32707
+ {
32708
+ description: "Request to rename a file",
32709
+ parameters: [
32710
+ {
32711
+ name: "source_path",
32712
+ value: "src/old-name.js"
32713
+ },
32714
+ {
32715
+ name: "target_path",
32716
+ value: "src/new-name.js"
32717
+ }
32718
+ ]
32719
+ }
32720
+ ],
32721
+ permissionLevel: 2 /* Write */
32722
+ };
32723
+ var handler10 = async (provider, args) => {
32724
+ if (!provider.renameFile) {
32725
+ return {
32726
+ type: "Error" /* Error */,
32727
+ message: "Not possible to rename file. Abort."
32728
+ };
32729
+ }
32730
+ const { source_path, target_path } = toolInfo10.parameters.parse(args);
32731
+ await provider.renameFile(source_path, target_path);
32732
+ return {
32733
+ type: "Reply" /* Reply */,
32734
+ message: `<rename_file_path>${target_path}</rename_file_path><status>Success</status>`
32735
+ };
32736
+ };
32737
+ var isAvailable10 = (provider) => {
32738
+ return !!provider.renameFile;
32739
+ };
32740
+ var renameFile_default = {
32741
+ ...toolInfo10,
32742
+ handler: handler10,
32743
+ isAvailable: isAvailable10
32714
32744
  };
32715
32745
  // ../core/src/tools/utils/replaceInFile.ts
32716
32746
  var replaceInFile = (fileContent, diff) => {
@@ -32787,7 +32817,7 @@ var replaceInFile = (fileContent, diff) => {
32787
32817
  };
32788
32818
 
32789
32819
  // ../core/src/tools/replaceInFile.ts
32790
- var toolInfo8 = {
32820
+ var toolInfo11 = {
32791
32821
  name: "replace_in_file",
32792
32822
  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
32823
  parameters: exports_external.object({
@@ -32921,7 +32951,7 @@ function oldFeature() {
32921
32951
  ],
32922
32952
  permissionLevel: 2 /* Write */
32923
32953
  };
32924
- var handler8 = async (provider, args) => {
32954
+ var handler11 = async (provider, args) => {
32925
32955
  if (!provider.readFile || !provider.writeFile) {
32926
32956
  return {
32927
32957
  type: "Error" /* Error */,
@@ -32929,7 +32959,7 @@ var handler8 = async (provider, args) => {
32929
32959
  };
32930
32960
  }
32931
32961
  try {
32932
- const { path, diff } = toolInfo8.parameters.parse(args);
32962
+ const { path, diff } = toolInfo11.parameters.parse(args);
32933
32963
  const fileContent = await provider.readFile(path);
32934
32964
  if (fileContent == null) {
32935
32965
  return {
@@ -32966,16 +32996,16 @@ var handler8 = async (provider, args) => {
32966
32996
  };
32967
32997
  }
32968
32998
  };
32969
- var isAvailable8 = (provider) => {
32999
+ var isAvailable11 = (provider) => {
32970
33000
  return !!provider.readFile && !!provider.writeFile;
32971
33001
  };
32972
33002
  var replaceInFile_default = {
32973
- ...toolInfo8,
32974
- handler: handler8,
32975
- isAvailable: isAvailable8
33003
+ ...toolInfo11,
33004
+ handler: handler11,
33005
+ isAvailable: isAvailable11
32976
33006
  };
32977
33007
  // ../core/src/tools/searchFiles.ts
32978
- var toolInfo9 = {
33008
+ var toolInfo12 = {
32979
33009
  name: "search_files",
32980
33010
  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
33011
  parameters: exports_external.object({
@@ -33008,7 +33038,7 @@ var toolInfo9 = {
33008
33038
  ],
33009
33039
  permissionLevel: 1 /* Read */
33010
33040
  };
33011
- var handler9 = async (provider, args) => {
33041
+ var handler12 = async (provider, args) => {
33012
33042
  if (!provider.searchFiles) {
33013
33043
  return {
33014
33044
  type: "Error" /* Error */,
@@ -33016,7 +33046,7 @@ var handler9 = async (provider, args) => {
33016
33046
  };
33017
33047
  }
33018
33048
  try {
33019
- const { path, regex, filePattern } = toolInfo9.parameters.parse(args);
33049
+ const { path, regex, filePattern } = toolInfo12.parameters.parse(args);
33020
33050
  const files = await provider.searchFiles(path, regex, filePattern ?? "*");
33021
33051
  return {
33022
33052
  type: "Reply" /* Reply */,
@@ -33036,16 +33066,16 @@ ${files.join(`
33036
33066
  };
33037
33067
  }
33038
33068
  };
33039
- var isAvailable9 = (provider) => {
33069
+ var isAvailable12 = (provider) => {
33040
33070
  return !!provider.searchFiles;
33041
33071
  };
33042
33072
  var searchFiles_default = {
33043
- ...toolInfo9,
33044
- handler: handler9,
33045
- isAvailable: isAvailable9
33073
+ ...toolInfo12,
33074
+ handler: handler12,
33075
+ isAvailable: isAvailable12
33046
33076
  };
33047
33077
  // ../core/src/tools/writeToFile.ts
33048
- var toolInfo10 = {
33078
+ var toolInfo13 = {
33049
33079
  name: "write_to_file",
33050
33080
  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 `&lt;`, `&gt;`, or `&amp;`. Also ensure there is no unwanted CDATA tags in the content.",
33051
33081
  parameters: exports_external.object({
@@ -33080,14 +33110,14 @@ export default App;
33080
33110
  ],
33081
33111
  permissionLevel: 2 /* Write */
33082
33112
  };
33083
- var handler10 = async (provider, args) => {
33113
+ var handler13 = async (provider, args) => {
33084
33114
  if (!provider.writeFile) {
33085
33115
  return {
33086
33116
  type: "Error" /* Error */,
33087
33117
  message: "Not possible to write file. Abort."
33088
33118
  };
33089
33119
  }
33090
- const parsed = toolInfo10.parameters.safeParse(args);
33120
+ const parsed = toolInfo13.parameters.safeParse(args);
33091
33121
  if (!parsed.success) {
33092
33122
  return {
33093
33123
  type: "Invalid" /* Invalid */,
@@ -33104,171 +33134,10 @@ var handler10 = async (provider, args) => {
33104
33134
  message: `<write_to_file_path>${path}</write_to_file_path><status>Success</status>`
33105
33135
  };
33106
33136
  };
33107
- var isAvailable10 = (provider) => {
33137
+ var isAvailable13 = (provider) => {
33108
33138
  return !!provider.writeFile;
33109
33139
  };
33110
33140
  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
33141
  ...toolInfo13,
33273
33142
  handler: handler13,
33274
33143
  isAvailable: isAvailable13
@@ -33337,6 +33206,142 @@ function toToolInfoV1(tool) {
33337
33206
  };
33338
33207
  }
33339
33208
 
33209
+ // ../core/src/UsageMeter.ts
33210
+ class UsageMeter {
33211
+ #totals = { input: 0, output: 0, cachedRead: 0, cost: 0 };
33212
+ #calls = 0;
33213
+ #modelInfos;
33214
+ #maxMessages;
33215
+ #maxCost;
33216
+ constructor(modelInfos = {}, opts = {}) {
33217
+ const infos = {};
33218
+ for (const [provider2, providerInfo] of Object.entries(modelInfos)) {
33219
+ for (const [model, modelInfo] of Object.entries(providerInfo)) {
33220
+ infos[`${provider2.split("-")[0]}:${model.replace(/[.-]/g, "")}`] = {
33221
+ inputPrice: modelInfo.inputPrice ?? 0,
33222
+ outputPrice: modelInfo.outputPrice ?? 0,
33223
+ cacheWritesPrice: modelInfo.cacheWritesPrice ?? 0,
33224
+ cacheReadsPrice: modelInfo.cacheReadsPrice ?? 0
33225
+ };
33226
+ }
33227
+ }
33228
+ this.#modelInfos = infos;
33229
+ this.#maxMessages = opts.maxMessages ?? 1000;
33230
+ this.#maxCost = opts.maxCost ?? 100;
33231
+ }
33232
+ #calculageUsage(usage, providerMetadata, modelInfo) {
33233
+ const providerMetadataKey = Object.keys(providerMetadata ?? {})[0];
33234
+ const metadata = providerMetadata?.[providerMetadataKey] ?? {};
33235
+ switch (providerMetadataKey) {
33236
+ case "openrouter":
33237
+ return {
33238
+ input: usage.inputTokens ?? 0,
33239
+ output: usage.outputTokens ?? 0,
33240
+ cachedRead: usage.cachedInputTokens ?? 0,
33241
+ cost: metadata.usage?.cost ?? 0
33242
+ };
33243
+ case "anthropic": {
33244
+ const cachedRead = usage.cachedInputTokens ?? 0;
33245
+ const cacheWrite = metadata?.promptCacheMissTokens ?? 0;
33246
+ const input = usage.inputTokens ?? 0;
33247
+ const output = usage.outputTokens ?? 0;
33248
+ return {
33249
+ input: input + cacheWrite + cachedRead,
33250
+ output,
33251
+ cachedRead,
33252
+ cost: (input * modelInfo.inputPrice + output * modelInfo.outputPrice + cacheWrite * modelInfo.cacheWritesPrice + cachedRead * modelInfo.cacheReadsPrice) / 1e6
33253
+ };
33254
+ }
33255
+ case "deepseek": {
33256
+ const cachedRead = usage.cachedInputTokens ?? 0;
33257
+ const cacheWrite = metadata.promptCacheMissTokens ?? 0;
33258
+ const input = usage.inputTokens ?? 0;
33259
+ const output = usage.outputTokens ?? 0;
33260
+ return {
33261
+ input,
33262
+ output,
33263
+ cachedRead,
33264
+ cost: (output * modelInfo.outputPrice + cacheWrite * modelInfo.inputPrice + cachedRead * modelInfo.cacheReadsPrice) / 1e6
33265
+ };
33266
+ }
33267
+ default: {
33268
+ const cachedRead = usage.cachedInputTokens ?? 0;
33269
+ const input = usage.inputTokens ?? 0;
33270
+ const output = usage.outputTokens ?? 0;
33271
+ return {
33272
+ input,
33273
+ output,
33274
+ cachedRead,
33275
+ cost: (input * modelInfo.inputPrice + output * modelInfo.outputPrice) / 1e6
33276
+ };
33277
+ }
33278
+ }
33279
+ }
33280
+ addUsage(llm, resp, options = {}) {
33281
+ const modelInfo = options.modelInfo ?? this.#modelInfos[`${llm.provider.split(".")[0]}:${llm.modelId.replace(/[.-]/g, "")}`] ?? {
33282
+ inputPrice: 0,
33283
+ outputPrice: 0,
33284
+ cacheWritesPrice: 0,
33285
+ cacheReadsPrice: 0
33286
+ };
33287
+ const usage = "totalUsage" in resp ? resp.totalUsage : resp.usage;
33288
+ const result = this.#calculageUsage(usage, resp.providerMetadata, modelInfo);
33289
+ this.#totals.input += result.input;
33290
+ this.#totals.output += result.output;
33291
+ this.#totals.cachedRead += result.cachedRead;
33292
+ this.#totals.cost += result.cost;
33293
+ this.#calls++;
33294
+ }
33295
+ setUsage(newUsage) {
33296
+ if (newUsage.input != null)
33297
+ this.#totals.input = newUsage.input;
33298
+ if (newUsage.output != null)
33299
+ this.#totals.output = newUsage.output;
33300
+ if (newUsage.cachedRead != null)
33301
+ this.#totals.cachedRead = newUsage.cachedRead;
33302
+ if (newUsage.cost != null)
33303
+ this.#totals.cost = newUsage.cost;
33304
+ if (newUsage.calls != null)
33305
+ this.#calls = newUsage.calls;
33306
+ }
33307
+ incrementMessageCount(n = 1) {
33308
+ this.#calls += n;
33309
+ }
33310
+ resetUsage() {
33311
+ this.#totals = { input: 0, output: 0, cachedRead: 0, cost: 0 };
33312
+ this.#calls = 0;
33313
+ }
33314
+ isLimitExceeded() {
33315
+ const messageCount = this.#maxMessages !== undefined && this.#calls >= this.#maxMessages;
33316
+ const cost = this.#maxCost !== undefined && this.#totals.cost >= this.#maxCost;
33317
+ return {
33318
+ messageCount,
33319
+ maxMessages: this.#maxMessages,
33320
+ cost,
33321
+ maxCost: this.#maxCost,
33322
+ result: messageCount || cost
33323
+ };
33324
+ }
33325
+ checkLimit() {
33326
+ const result = this.isLimitExceeded();
33327
+ if (result.result) {
33328
+ throw new Error(`Usage limit exceeded. Message count: ${result.messageCount}/${result.maxMessages}, cost: ${result.cost}/${result.maxCost}`);
33329
+ }
33330
+ }
33331
+ get usage() {
33332
+ return { ...this.#totals, messageCount: this.#calls };
33333
+ }
33334
+ printUsage() {
33335
+ const u = this.usage;
33336
+ console.log(`Usage - messages: ${u.messageCount}, input: ${u.input}, cached: ${u.cachedRead}, ` + `output: ${u.output}, cost: $${u.cost.toFixed(4)}`);
33337
+ }
33338
+ onFinishHandler(llm) {
33339
+ return (evt) => {
33340
+ this.addUsage(llm, evt);
33341
+ };
33342
+ }
33343
+ }
33344
+
33340
33345
  // ../../node_modules/@ai-sdk/provider/dist/index.mjs
33341
33346
  var marker = "vercel.ai.error";
33342
33347
  var symbol2 = Symbol.for(marker);
@@ -56146,7 +56151,7 @@ ${agent.responsibilities.map((resp) => ` - ${resp}`).join(`
56146
56151
  - **Current Agent Role**
56147
56152
  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
56153
  `;
56149
- var capabilities = (toolNamePrefix) => `
56154
+ var capabilities = (_toolNamePrefix) => `
56150
56155
  ====
56151
56156
 
56152
56157
  CAPABILITIES
@@ -56640,7 +56645,7 @@ RETRY GUIDELINES
56640
56645
  - Explain why the issue remains
56641
56646
  - Suggest manual intervention steps
56642
56647
  - Report any partial improvements`;
56643
- var fullSystemPrompt3 = (info, tools, toolNamePrefix, instructions, scripts, interactive, useNativeTool) => `
56648
+ var fullSystemPrompt3 = (info, tools, toolNamePrefix, instructions, scripts, _interactive, useNativeTool) => `
56644
56649
  ${basePrompt}
56645
56650
  ${useNativeTool ? "" : toolUsePrompt(tools, toolNamePrefix)}
56646
56651
  ${codeFixingStrategies}
@@ -56683,7 +56688,7 @@ class CodeFixerAgent extends AgentBase {
56683
56688
  });
56684
56689
  this.#maxRetries = options.maxRetries ?? 5;
56685
56690
  }
56686
- async onBeforeInvokeTool(name17, args) {
56691
+ async onBeforeInvokeTool(name17, _args) {
56687
56692
  if (name17 === attemptCompletion_default.name) {
56688
56693
  if (this.#retryCount > this.#maxRetries) {
56689
56694
  return;
@@ -56832,7 +56837,10 @@ var configSchema = exports_external.object({
56832
56837
  providers: exports_external.record(exports_external.string(), exports_external.object({
56833
56838
  apiKey: exports_external.string().optional(),
56834
56839
  defaultModel: exports_external.string().optional(),
56835
- defaultParameters: exports_external.record(exports_external.string(), exports_external.any()).optional()
56840
+ defaultParameters: exports_external.record(exports_external.string(), exports_external.any()).optional(),
56841
+ location: exports_external.string().optional(),
56842
+ project: exports_external.string().optional(),
56843
+ keyFile: exports_external.string().optional()
56836
56844
  })).optional(),
56837
56845
  defaultProvider: exports_external.string().optional(),
56838
56846
  defaultModel: exports_external.string().optional(),
@@ -61189,7 +61197,6 @@ var readConfig = (path) => {
61189
61197
  return configSchema.parse(config4);
61190
61198
  };
61191
61199
  // ../cli-shared/src/provider.ts
61192
- var import_ignore2 = __toESM(require_ignore(), 1);
61193
61200
  import { spawn as spawn2 } from "node:child_process";
61194
61201
  import { mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
61195
61202
  import { dirname } from "node:path";
@@ -62467,6 +62474,9 @@ ${theme.style.description(selectedChoice.description)}` : ``;
62467
62474
  return `${[prefix, message, helpTipTop].filter(Boolean).join(" ")}
62468
62475
  ${page}${helpTipBottom}${choiceDescription}${import_ansi_escapes2.default.cursorHide}`;
62469
62476
  });
62477
+ // ../cli-shared/src/provider.ts
62478
+ var import_ignore2 = __toESM(require_ignore(), 1);
62479
+
62470
62480
  // ../cli-shared/src/utils/checkRipgrep.ts
62471
62481
  import { spawnSync } from "node:child_process";
62472
62482
  var rgAvailability = {
@@ -62629,7 +62639,7 @@ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
62629
62639
  }
62630
62640
 
62631
62641
  // ../cli-shared/src/provider.ts
62632
- var getProvider = (agentName, config4, options = {}) => {
62642
+ var getProvider = (_agentName, _config, options = {}) => {
62633
62643
  const ig = import_ignore2.default().add(options.excludeFiles ?? []);
62634
62644
  const provider2 = {
62635
62645
  readFile: async (path) => {
@@ -62664,7 +62674,7 @@ var getProvider = (agentName, config4, options = {}) => {
62664
62674
  listFiles: async (path, recursive, maxCount) => {
62665
62675
  return await listFiles(path, recursive, maxCount, process.cwd(), options.excludeFiles);
62666
62676
  },
62667
- executeCommand: (command, needApprove) => {
62677
+ executeCommand: (command, _needApprove) => {
62668
62678
  return new Promise((resolve3, reject) => {
62669
62679
  options.command?.onStarted(command);
62670
62680
  const child = spawn2(command, [], {
@@ -62715,7 +62725,7 @@ var getProvider = (agentName, config4, options = {}) => {
62715
62725
  }
62716
62726
  return answerOptions[0] ?? "<warning>This is non-interactive mode, no answer can be provided.</warning>";
62717
62727
  },
62718
- attemptCompletion: async (result) => {
62728
+ attemptCompletion: async (_result) => {
62719
62729
  return;
62720
62730
  },
62721
62731
  fetchUrl: async (url3) => {