@zaly/agent 0.2.0 → 0.3.1

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 (54) hide show
  1. package/dist/{agent-DlhEEMPU.mjs → agent-GXRF7DUP.mjs} +7 -11
  2. package/dist/agent-GXRF7DUP.mjs.map +1 -0
  3. package/dist/{bash-DSy03sAj.mjs → bash-CB_VXpyd.mjs} +2 -2
  4. package/dist/{bash-DSy03sAj.mjs.map → bash-CB_VXpyd.mjs.map} +1 -1
  5. package/dist/{compactions-BpvQk4CG.mjs → compactions-92bMlcxJ.mjs} +3 -3
  6. package/dist/{compactions-BpvQk4CG.mjs.map → compactions-92bMlcxJ.mjs.map} +1 -1
  7. package/dist/{edit-DT672zIy.mjs → edit-gkb6MCW-.mjs} +2 -2
  8. package/dist/{edit-DT672zIy.mjs.map → edit-gkb6MCW-.mjs.map} +1 -1
  9. package/dist/{fetch-BrtIqrid.mjs → fetch-D_GzL2yy.mjs} +4 -4
  10. package/dist/{fetch-BrtIqrid.mjs.map → fetch-D_GzL2yy.mjs.map} +1 -1
  11. package/dist/{find-B-vvdlHu.mjs → find-DlrYUTXT.mjs} +2 -2
  12. package/dist/{find-B-vvdlHu.mjs.map → find-DlrYUTXT.mjs.map} +1 -1
  13. package/dist/{grep-rvZ5S319.mjs → grep-BI8Rou2q.mjs} +2 -2
  14. package/dist/{grep-rvZ5S319.mjs.map → grep-BI8Rou2q.mjs.map} +1 -1
  15. package/dist/{html-VrAsoGBK.mjs → html-B-Lr-9W6.mjs} +9457 -4826
  16. package/dist/html-B-Lr-9W6.mjs.map +1 -0
  17. package/dist/{index-node-esm-BwaOzhXB.mjs → index-node-esm-75XSYyIw.mjs} +16 -13
  18. package/dist/index-node-esm-75XSYyIw.mjs.map +1 -0
  19. package/dist/index.d.mts +11 -4
  20. package/dist/index.d.mts.map +1 -1
  21. package/dist/index.mjs +2 -2
  22. package/dist/{manager-1zEE5WiA.mjs → manager-CEociHy_.mjs} +2 -2
  23. package/dist/{manager-1zEE5WiA.mjs.map → manager-CEociHy_.mjs.map} +1 -1
  24. package/dist/{masker-B97uwYXG.mjs → masker-DWuL2Fjs.mjs} +16 -5
  25. package/dist/{masker-B97uwYXG.mjs.map → masker-DWuL2Fjs.mjs.map} +1 -1
  26. package/dist/{read-C5keKntU.mjs → read-DLtNq4XJ.mjs} +2 -2
  27. package/dist/{read-C5keKntU.mjs.map → read-DLtNq4XJ.mjs.map} +1 -1
  28. package/dist/{registry-CntkeXlo.mjs → registry-7mJQhyBA.mjs} +3 -3
  29. package/dist/{registry-CntkeXlo.mjs.map → registry-7mJQhyBA.mjs.map} +1 -1
  30. package/dist/{rolldown-runtime-DYf_mQCB.mjs → rolldown-runtime-BVN1G_yT.mjs} +4 -4
  31. package/dist/{session-CUE48QWX.mjs → session-C5ra-Hi1.mjs} +2 -2
  32. package/dist/{session-CUE48QWX.mjs.map → session-C5ra-Hi1.mjs.map} +1 -1
  33. package/dist/{session-DY9mF9Vb.d.mts → session-WtXqtAaq.d.mts} +2 -2
  34. package/dist/{session-DY9mF9Vb.d.mts.map → session-WtXqtAaq.d.mts.map} +1 -1
  35. package/dist/session.d.mts +1 -1
  36. package/dist/session.mjs +1 -1
  37. package/dist/{src-DJoqT9yP.mjs → src-Di-H3Oya.mjs} +71 -41
  38. package/dist/src-Di-H3Oya.mjs.map +1 -0
  39. package/dist/{subagent-D-TYaX38.mjs → subagent-BOK4GFd4.mjs} +3 -3
  40. package/dist/{subagent-D-TYaX38.mjs.map → subagent-BOK4GFd4.mjs.map} +1 -1
  41. package/dist/{tasks-Dgsiuh0Q.mjs → tasks-BUFqFoh6.mjs} +2 -2
  42. package/dist/{tasks-Dgsiuh0Q.mjs.map → tasks-BUFqFoh6.mjs.map} +1 -1
  43. package/dist/{tasks-D76WXWr2.mjs → tasks-CkDWJk_3.mjs} +4 -4
  44. package/dist/tasks-CkDWJk_3.mjs.map +1 -0
  45. package/dist/{tools-DmoUYORG.mjs → tools-Ca7VsMg3.mjs} +2 -2
  46. package/dist/{tools-DmoUYORG.mjs.map → tools-Ca7VsMg3.mjs.map} +1 -1
  47. package/dist/{write-BRQFfWAn.mjs → write-y93TC5ng.mjs} +2 -2
  48. package/dist/{write-BRQFfWAn.mjs.map → write-y93TC5ng.mjs.map} +1 -1
  49. package/package.json +11 -11
  50. package/dist/agent-DlhEEMPU.mjs.map +0 -1
  51. package/dist/html-VrAsoGBK.mjs.map +0 -1
  52. package/dist/index-node-esm-BwaOzhXB.mjs.map +0 -1
  53. package/dist/src-DJoqT9yP.mjs.map +0 -1
  54. package/dist/tasks-D76WXWr2.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import vm from "node:vm";
2
- // ../../node_modules/.bun/jsonpath-plus@11.2.1/node_modules/jsonpath-plus/dist/index-node-esm.js
2
+ // ../../node_modules/.bun/jsonpath-plus@11.3.0/node_modules/jsonpath-plus/dist/index-node-esm.js
3
3
  /**
4
4
  * @implements {IHooks}
5
5
  */
@@ -80,7 +80,7 @@ var Jsep = class Jsep {
80
80
  * @returns {string}
81
81
  */
82
82
  static get version() {
83
- return "1.4.0";
83
+ return "1.6.0";
84
84
  }
85
85
  /**
86
86
  * @returns {string}
@@ -1750,7 +1750,7 @@ var JSONPathClass = class {
1750
1750
  this._handleCallback(retObj, callback, "property");
1751
1751
  return retObj;
1752
1752
  } else if (loc === "$") addRet(this._trace(x, val, path, null, null, callback, hasArrExpr));
1753
- else if (/^(-?\d*):(-?\d*):?(\d*)$/v.test(loc)) {
1753
+ else if (/^(-?\d*):(-?\d*):?(-?\d*)$/v.test(loc)) {
1754
1754
  const sliceResult = this._slice(loc, x, val, path, parent, parentPropName, callback);
1755
1755
  if (sliceResult) addRet(sliceResult);
1756
1756
  } else if (loc.indexOf("?(") === 0) {
@@ -1910,13 +1910,18 @@ var JSONPathClass = class {
1910
1910
  */
1911
1911
  _slice(loc, expr, val, path, parent, parentPropName, callback) {
1912
1912
  if (!Array.isArray(val)) return;
1913
- const len = val.length, parts = loc.split(":"), step = parts[2] && Number(parts[2]) || 1;
1914
- let start = parts[0] && Number(parts[0]) || 0, end = parts[1] ? Number(parts[1]) : len;
1915
- start = start < 0 ? Math.max(0, start + len) : Math.min(len, start);
1916
- end = end < 0 ? Math.max(0, end + len) : Math.min(len, end);
1913
+ const len = val.length, parts = loc.split(":"), step = parts[2] ? Number(parts[2]) : 1;
1917
1914
  /** @type {ReturnObject[]} */
1918
1915
  const ret = [];
1919
- for (let i = start; i < end; i += step) {
1916
+ if (step === 0) return ret;
1917
+ /**
1918
+ * @param {number} index
1919
+ * @returns {number}
1920
+ */
1921
+ const normalize = (index) => index < 0 ? index + len : index;
1922
+ const start = normalize(parts[0] ? Number(parts[0]) : step > 0 ? 0 : len - 1), end = normalize(parts[1] ? Number(parts[1]) : step > 0 ? len : -len - 1);
1923
+ const [from, to] = step > 0 ? [Math.min(Math.max(start, 0), len), Math.min(Math.max(end, 0), len)] : [Math.min(Math.max(start, -1), len - 1), Math.min(Math.max(end, -1), len - 1)];
1924
+ for (let i = from; step > 0 ? i < to : i > to; i += step) {
1920
1925
  const tmp = this._trace(unshift(i, expr), val, path, parent, parentPropName, callback, true);
1921
1926
  (Array.isArray(tmp) ? tmp : [tmp]).forEach((t) => {
1922
1927
  ret.push(t);
@@ -1941,8 +1946,7 @@ var JSONPathClass = class {
1941
1946
  this.currSandbox._$_root = this.json;
1942
1947
  this.currSandbox._$_v = _v;
1943
1948
  }
1944
- const containsPath = code.includes("@path");
1945
- if (containsPath) {
1949
+ if (code.includes("@path")) {
1946
1950
  /* c8 ignore next -- Unreachable: currSandbox set in evaluate() before _eval */
1947
1951
  const currSandbox = this.currSandbox ?? {};
1948
1952
  currSandbox._$_path = JSONPath.toPathString(
@@ -1952,8 +1956,7 @@ var JSONPathClass = class {
1952
1956
  }
1953
1957
  const scriptCacheKey = this.currEval + "Script:" + code;
1954
1958
  if (!scriptCache.has(scriptCacheKey)) {
1955
- let script = code.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/('(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|(?<=(?:^|[\(,=:\[!\|?\{\};+\-*%<>~^]|&)\s*)\/(?:\\.|\[(?:\\.|[^\]\\])*\]|[^\/\\\[])+\/[dgimsuvy]*)|@(?![\w$])/gv, (_, literal) => literal ?? "_$_v");
1956
- if (containsPath) script = script.replaceAll("@path", "_$_path");
1959
+ const script = code.replaceAll(/('(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|(?<=(?:^|[\(,=:\[!\|?\{\};+\-*%<>~^]|&)\s*)\/(?:\\.|\[(?:\\.|[^\]\\])*\]|[^\/\\\[])+\/[dgimsuvy]*)|@(?:(parentProperty|parent|property|root|path)|(?![\w$]))/gv, (_, literal, name) => literal ?? "_$_" + (name ?? "v"));
1957
1960
  const evalType = this.currEval;
1958
1961
  if ([
1959
1962
  "safe",
@@ -2112,4 +2115,4 @@ JSONPath.toPathArray = function(expr) {
2112
2115
  JSONPathClass.prototype.vm = vm;
2113
2116
  export { JSONPath };
2114
2117
 
2115
- //# sourceMappingURL=index-node-esm-BwaOzhXB.mjs.map
2118
+ //# sourceMappingURL=index-node-esm-75XSYyIw.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-node-esm-75XSYyIw.mjs","names":["error"],"sources":["../../../node_modules/.bun/jsonpath-plus@11.3.0/node_modules/jsonpath-plus/dist/index-node-esm.js"],"sourcesContent":["import vm from 'node:vm';\n\n/**\n * @implements {IHooks}\n */\nclass Hooks {\n /**\n * @callback HookCallback\n * @this {*|Jsep} this\n * @param {Jsep} env\n * @returns: void\n */\n /**\n * Adds the given callback to the list of callbacks for the given hook.\n *\n * The callback will be invoked when the hook it is registered for is run.\n *\n * One callback function can be registered to multiple hooks and the same hook multiple times.\n *\n * @param {string|object} name The name of the hook, or an object of callbacks keyed by name\n * @param {HookCallback|boolean} callback The callback function which is given environment variables.\n * @param {?boolean} [first=false] Will add the hook to the top of the list (defaults to the bottom)\n * @public\n */\n add(name, callback, first) {\n if (typeof arguments[0] != 'string') {\n // Multiple hook callbacks, keyed by name\n for (let name in arguments[0]) {\n this.add(name, arguments[0][name], arguments[1]);\n }\n } else {\n (Array.isArray(name) ? name : [name]).forEach(function (name) {\n this[name] = this[name] || [];\n if (callback) {\n this[name][first ? 'unshift' : 'push'](callback);\n }\n }, this);\n }\n }\n\n /**\n * Runs a hook invoking all registered callbacks with the given environment variables.\n *\n * Callbacks will be invoked synchronously and in the order in which they were registered.\n *\n * @param {string} name The name of the hook.\n * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.\n * @public\n */\n run(name, env) {\n this[name] = this[name] || [];\n this[name].forEach(function (callback) {\n callback.call(env && env.context ? env.context : env, env);\n });\n }\n}\n\n/**\n * @implements {IPlugins}\n */\nclass Plugins {\n constructor(jsep) {\n this.jsep = jsep;\n this.registered = {};\n }\n\n /**\n * @callback PluginSetup\n * @this {Jsep} jsep\n * @returns: void\n */\n /**\n * Adds the given plugin(s) to the registry\n *\n * @param {object} plugins\n * @param {string} plugins.name The name of the plugin\n * @param {PluginSetup} plugins.init The init function\n * @public\n */\n register(...plugins) {\n plugins.forEach(plugin => {\n if (typeof plugin !== 'object' || !plugin.name || !plugin.init) {\n throw new Error('Invalid JSEP plugin format');\n }\n if (this.registered[plugin.name]) {\n // already registered. Ignore.\n return;\n }\n plugin.init(this.jsep);\n this.registered[plugin.name] = plugin;\n });\n }\n}\n\n// JavaScript Expression Parser (JSEP) 1.6.0\n// JSEP may be freely distributed under the MIT License\n// https://ericsmekens.github.io/jsep/\n\nclass Jsep {\n /**\n * @returns {string}\n */\n static get version() {\n // To be filled in by the template\n return '1.6.0';\n }\n\n /**\n * @returns {string}\n */\n static toString() {\n return 'JavaScript Expression Parser (JSEP) v' + Jsep.version;\n }\n // ==================== CONFIG ================================\n /**\n * @method addUnaryOp\n * @param {string} op_name The name of the unary op to add\n * @returns {Jsep}\n */\n static addUnaryOp(op_name) {\n Jsep.max_unop_len = Math.max(op_name.length, Jsep.max_unop_len);\n Jsep.unary_ops[op_name] = 1;\n return Jsep;\n }\n\n /**\n * @method jsep.addBinaryOp\n * @param {string} op_name The name of the binary op to add\n * @param {number} precedence The precedence of the binary op (can be a float). Higher number = higher precedence\n * @param {boolean} [isRightAssociative=false] whether operator is right-associative\n * @returns {Jsep}\n */\n static addBinaryOp(op_name, precedence, isRightAssociative) {\n Jsep.max_binop_len = Math.max(op_name.length, Jsep.max_binop_len);\n Jsep.binary_ops[op_name] = precedence;\n if (isRightAssociative) {\n Jsep.right_associative.add(op_name);\n } else {\n Jsep.right_associative.delete(op_name);\n }\n return Jsep;\n }\n\n /**\n * @method addIdentifierChar\n * @param {string} char The additional character to treat as a valid part of an identifier\n * @returns {Jsep}\n */\n static addIdentifierChar(char) {\n Jsep.additional_identifier_chars.add(char);\n return Jsep;\n }\n\n /**\n * @method addLiteral\n * @param {string} literal_name The name of the literal to add\n * @param {*} literal_value The value of the literal\n * @returns {Jsep}\n */\n static addLiteral(literal_name, literal_value) {\n Jsep.literals[literal_name] = literal_value;\n return Jsep;\n }\n\n /**\n * @method removeUnaryOp\n * @param {string} op_name The name of the unary op to remove\n * @returns {Jsep}\n */\n static removeUnaryOp(op_name) {\n delete Jsep.unary_ops[op_name];\n if (op_name.length === Jsep.max_unop_len) {\n Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);\n }\n return Jsep;\n }\n\n /**\n * @method removeAllUnaryOps\n * @returns {Jsep}\n */\n static removeAllUnaryOps() {\n Jsep.unary_ops = {};\n Jsep.max_unop_len = 0;\n return Jsep;\n }\n\n /**\n * @method removeIdentifierChar\n * @param {string} char The additional character to stop treating as a valid part of an identifier\n * @returns {Jsep}\n */\n static removeIdentifierChar(char) {\n Jsep.additional_identifier_chars.delete(char);\n return Jsep;\n }\n\n /**\n * @method removeBinaryOp\n * @param {string} op_name The name of the binary op to remove\n * @returns {Jsep}\n */\n static removeBinaryOp(op_name) {\n delete Jsep.binary_ops[op_name];\n if (op_name.length === Jsep.max_binop_len) {\n Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);\n }\n Jsep.right_associative.delete(op_name);\n return Jsep;\n }\n\n /**\n * @method removeAllBinaryOps\n * @returns {Jsep}\n */\n static removeAllBinaryOps() {\n Jsep.binary_ops = {};\n Jsep.max_binop_len = 0;\n return Jsep;\n }\n\n /**\n * @method removeLiteral\n * @param {string} literal_name The name of the literal to remove\n * @returns {Jsep}\n */\n static removeLiteral(literal_name) {\n delete Jsep.literals[literal_name];\n return Jsep;\n }\n\n /**\n * @method removeAllLiterals\n * @returns {Jsep}\n */\n static removeAllLiterals() {\n Jsep.literals = {};\n return Jsep;\n }\n // ==================== END CONFIG ============================\n\n /**\n * @returns {string}\n */\n get char() {\n return this.expr.charAt(this.index);\n }\n\n /**\n * @returns {number}\n */\n get code() {\n return this.expr.charCodeAt(this.index);\n }\n /**\n * @param {string} expr a string with the passed in express\n * @returns Jsep\n */\n constructor(expr) {\n // `index` stores the character number we are currently at\n // All of the gobbles below will modify `index` as we move along\n this.expr = expr;\n this.index = 0;\n }\n\n /**\n * static top-level parser\n * @returns {jsep.Expression}\n */\n static parse(expr) {\n return new Jsep(expr).parse();\n }\n\n /**\n * Get the longest key length of any object\n * @param {object} obj\n * @returns {number}\n */\n static getMaxKeyLen(obj) {\n return Math.max(0, ...Object.keys(obj).map(k => k.length));\n }\n\n /**\n * `ch` is a character code in the next three functions\n * @param {number} ch\n * @returns {boolean}\n */\n static isDecimalDigit(ch) {\n return ch >= 48 && ch <= 57; // 0...9\n }\n\n /**\n * Returns the precedence of a binary operator or `0` if it isn't a binary operator. Can be float.\n * @param {string} op_val\n * @returns {number}\n */\n static binaryPrecedence(op_val) {\n return Jsep.binary_ops[op_val] || 0;\n }\n\n /**\n * Looks for start of identifier\n * @param {number} ch\n * @returns {boolean}\n */\n static isIdentifierStart(ch) {\n return ch >= 65 && ch <= 90 ||\n // A...Z\n ch >= 97 && ch <= 122 ||\n // a...z\n ch >= 128 && !Jsep.binary_ops[String.fromCharCode(ch)] ||\n // any non-ASCII that is not an operator\n Jsep.additional_identifier_chars.has(String.fromCharCode(ch)); // additional characters\n }\n\n /**\n * @param {number} ch\n * @returns {boolean}\n */\n static isIdentifierPart(ch) {\n return Jsep.isIdentifierStart(ch) || Jsep.isDecimalDigit(ch);\n }\n\n /**\n * throw error at index of the expression\n * @param {string} message\n * @throws\n */\n throwError(message) {\n const error = new Error(message + ' at character ' + this.index);\n error.index = this.index;\n error.description = message;\n throw error;\n }\n\n /**\n * Run a given hook\n * @param {string} name\n * @param {jsep.Expression|false} [node]\n * @returns {?jsep.Expression}\n */\n runHook(name, node) {\n if (Jsep.hooks[name]) {\n const env = {\n context: this,\n node\n };\n Jsep.hooks.run(name, env);\n return env.node;\n }\n return node;\n }\n\n /**\n * Runs a given hook until one returns a node\n * @param {string} name\n * @returns {?jsep.Expression}\n */\n searchHook(name) {\n if (Jsep.hooks[name]) {\n const env = {\n context: this\n };\n Jsep.hooks[name].find(function (callback) {\n callback.call(env.context, env);\n return env.node;\n });\n return env.node;\n }\n }\n\n /**\n * Push `index` up to the next non-space character\n */\n gobbleSpaces() {\n let ch = this.code;\n // Whitespace\n while (ch === Jsep.SPACE_CODE || ch === Jsep.TAB_CODE || ch === Jsep.LF_CODE || ch === Jsep.CR_CODE) {\n ch = this.expr.charCodeAt(++this.index);\n }\n this.runHook('gobble-spaces');\n }\n\n /**\n * Top-level method to parse all expressions and returns compound or single node\n * @returns {jsep.Expression}\n */\n parse() {\n this.runHook('before-all');\n const nodes = this.gobbleExpressions();\n\n // If there's only one expression just try returning the expression\n const node = nodes.length === 1 ? nodes[0] : {\n type: Jsep.COMPOUND,\n body: nodes\n };\n return this.runHook('after-all', node);\n }\n\n /**\n * top-level parser (but can be reused within as well)\n * @param {number} [untilICode]\n * @returns {jsep.Expression[]}\n */\n gobbleExpressions(untilICode) {\n let nodes = [],\n ch_i,\n node;\n while (this.index < this.expr.length) {\n ch_i = this.code;\n\n // Expressions can be separated by semicolons, commas, or just inferred without any\n // separators\n if (ch_i === Jsep.SEMCOL_CODE || ch_i === Jsep.COMMA_CODE) {\n this.index++; // ignore separators\n } else {\n // Try to gobble each expression individually\n if (node = this.gobbleExpression()) {\n nodes.push(node);\n // If we weren't able to find a binary expression and are out of room, then\n // the expression passed in probably has too much\n } else if (this.index < this.expr.length) {\n if (ch_i === untilICode) {\n break;\n }\n this.throwError('Unexpected \"' + this.char + '\"');\n }\n }\n }\n return nodes;\n }\n\n /**\n * The main parsing function.\n * @returns {?jsep.Expression}\n */\n gobbleExpression() {\n const node = this.searchHook('gobble-expression') || this.gobbleBinaryExpression();\n this.gobbleSpaces();\n return this.runHook('after-expression', node);\n }\n\n /**\n * Search for the operation portion of the string (e.g. `+`, `===`)\n * Start by taking the longest possible binary operations (3 characters: `===`, `!==`, `>>>`)\n * and move down from 3 to 2 to 1 character until a matching binary operation is found\n * then, return that binary operation\n * @returns {string|boolean}\n */\n gobbleBinaryOp() {\n this.gobbleSpaces();\n let to_check = this.expr.substr(this.index, Jsep.max_binop_len);\n let tc_len = to_check.length;\n while (tc_len > 0) {\n // Don't accept a binary op when it is an identifier.\n // Binary ops that start with a identifier-valid character must be followed\n // by a non identifier-part valid character\n if (Jsep.binary_ops.hasOwnProperty(to_check) && (!Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {\n this.index += tc_len;\n return to_check;\n }\n to_check = to_check.substr(0, --tc_len);\n }\n return false;\n }\n\n /**\n * This function is responsible for gobbling an individual expression,\n * e.g. `1`, `1+2`, `a+(b*2)-Math.sqrt(2)`\n * @returns {?jsep.BinaryExpression}\n */\n gobbleBinaryExpression() {\n let node, biop, prec, stack, biop_info, left, right, i, cur_biop;\n\n // First, try to get the leftmost thing\n // Then, check to see if there's a binary operator operating on that leftmost thing\n // Don't gobbleBinaryOp without a left-hand-side\n left = this.gobbleToken();\n if (!left) {\n return left;\n }\n biop = this.gobbleBinaryOp();\n\n // If there wasn't a binary operator, just return the leftmost node\n if (!biop) {\n return left;\n }\n\n // Otherwise, we need to start a stack to properly place the binary operations in their\n // precedence structure\n biop_info = {\n value: biop,\n prec: Jsep.binaryPrecedence(biop),\n right_a: Jsep.right_associative.has(biop)\n };\n right = this.gobbleToken();\n if (!right) {\n this.throwError(\"Expected expression after \" + biop);\n }\n stack = [left, biop_info, right];\n\n // Properly deal with precedence using [recursive descent](http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm)\n while (biop = this.gobbleBinaryOp()) {\n prec = Jsep.binaryPrecedence(biop);\n if (prec === 0) {\n this.index -= biop.length;\n break;\n }\n biop_info = {\n value: biop,\n prec,\n right_a: Jsep.right_associative.has(biop)\n };\n cur_biop = biop;\n\n // Reduce: make a binary expression from the three topmost entries.\n const comparePrev = prev => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec;\n while (stack.length > 2 && comparePrev(stack[stack.length - 2])) {\n right = stack.pop();\n biop = stack.pop().value;\n left = stack.pop();\n node = {\n type: Jsep.BINARY_EXP,\n operator: biop,\n left,\n right\n };\n stack.push(node);\n }\n node = this.gobbleToken();\n if (!node) {\n this.throwError(\"Expected expression after \" + cur_biop);\n }\n stack.push(biop_info, node);\n }\n i = stack.length - 1;\n node = stack[i];\n while (i > 1) {\n node = {\n type: Jsep.BINARY_EXP,\n operator: stack[i - 1].value,\n left: stack[i - 2],\n right: node\n };\n i -= 2;\n }\n return node;\n }\n\n /**\n * An individual part of a binary expression:\n * e.g. `foo.bar(baz)`, `1`, `\"abc\"`, `(a % 2)` (because it's in parenthesis)\n * @returns {boolean|jsep.Expression}\n */\n gobbleToken() {\n let ch, to_check, tc_len, node;\n this.gobbleSpaces();\n node = this.searchHook('gobble-token');\n if (node) {\n return this.runHook('after-token', node);\n }\n ch = this.code;\n if (Jsep.isDecimalDigit(ch) || ch === Jsep.PERIOD_CODE) {\n // Char code 46 is a dot `.` which can start off a numeric literal\n return this.gobbleNumericLiteral();\n }\n if (ch === Jsep.SQUOTE_CODE || ch === Jsep.DQUOTE_CODE) {\n // Single or double quotes\n node = this.gobbleStringLiteral();\n } else if (ch === Jsep.OBRACK_CODE) {\n node = this.gobbleArray();\n } else {\n to_check = this.expr.substr(this.index, Jsep.max_unop_len);\n tc_len = to_check.length;\n while (tc_len > 0) {\n // Don't accept an unary op when it is an identifier.\n // Unary ops that start with a identifier-valid character must be followed\n // by a non identifier-part valid character\n if (Jsep.unary_ops.hasOwnProperty(to_check) && (!Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {\n this.index += tc_len;\n const argument = this.gobbleToken();\n if (!argument) {\n this.throwError('missing unaryOp argument');\n }\n return this.runHook('after-token', {\n type: Jsep.UNARY_EXP,\n operator: to_check,\n argument,\n prefix: true\n });\n }\n to_check = to_check.substr(0, --tc_len);\n }\n if (Jsep.isIdentifierStart(ch)) {\n node = this.gobbleIdentifier();\n if (Jsep.literals.hasOwnProperty(node.name)) {\n node = {\n type: Jsep.LITERAL,\n value: Jsep.literals[node.name],\n raw: node.name\n };\n } else if (node.name === Jsep.this_str) {\n node = {\n type: Jsep.THIS_EXP\n };\n }\n } else if (ch === Jsep.OPAREN_CODE) {\n // open parenthesis\n node = this.gobbleGroup();\n }\n }\n if (!node) {\n return this.runHook('after-token', false);\n }\n node = this.gobbleTokenProperty(node);\n return this.runHook('after-token', node);\n }\n\n /**\n * Gobble properties of of identifiers/strings/arrays/groups.\n * e.g. `foo`, `bar.baz`, `foo['bar'].baz`\n * It also gobbles function calls:\n * e.g. `Math.acos(obj.angle)`\n * @param {jsep.Expression} node\n * @returns {jsep.Expression}\n */\n gobbleTokenProperty(node) {\n this.gobbleSpaces();\n let ch = this.code;\n while (ch === Jsep.PERIOD_CODE || ch === Jsep.OBRACK_CODE || ch === Jsep.OPAREN_CODE || ch === Jsep.QUMARK_CODE) {\n let optional;\n if (ch === Jsep.QUMARK_CODE) {\n if (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE) {\n break;\n }\n optional = true;\n this.index += 2;\n this.gobbleSpaces();\n ch = this.code;\n }\n this.index++;\n if (ch === Jsep.OBRACK_CODE) {\n node = {\n type: Jsep.MEMBER_EXP,\n computed: true,\n object: node,\n property: this.gobbleExpression()\n };\n if (!node.property) {\n this.throwError('Unexpected \"' + this.char + '\"');\n }\n this.gobbleSpaces();\n ch = this.code;\n if (ch !== Jsep.CBRACK_CODE) {\n this.throwError('Unclosed [');\n }\n this.index++;\n } else if (ch === Jsep.OPAREN_CODE) {\n // A function call is being made; gobble all the arguments\n node = {\n type: Jsep.CALL_EXP,\n 'arguments': this.gobbleArguments(Jsep.CPAREN_CODE),\n callee: node\n };\n } else if (ch === Jsep.PERIOD_CODE || optional) {\n if (optional) {\n this.index--;\n }\n this.gobbleSpaces();\n node = {\n type: Jsep.MEMBER_EXP,\n computed: false,\n object: node,\n property: this.gobbleIdentifier()\n };\n }\n if (optional) {\n node.optional = true;\n } // else leave undefined for compatibility with esprima\n\n this.gobbleSpaces();\n ch = this.code;\n }\n return node;\n }\n\n /**\n * Parse simple numeric literals: `12`, `3.4`, `.5`. Do this by using a string to\n * keep track of everything in the numeric literal and then calling `parseFloat` on that string\n * @returns {jsep.Literal}\n */\n gobbleNumericLiteral() {\n let number = '',\n ch,\n chCode;\n while (Jsep.isDecimalDigit(this.code)) {\n number += this.expr.charAt(this.index++);\n }\n if (this.code === Jsep.PERIOD_CODE) {\n // can start with a decimal marker\n number += this.expr.charAt(this.index++);\n while (Jsep.isDecimalDigit(this.code)) {\n number += this.expr.charAt(this.index++);\n }\n }\n ch = this.char;\n if (ch === 'e' || ch === 'E') {\n // exponent marker\n number += this.expr.charAt(this.index++);\n ch = this.char;\n if (ch === '+' || ch === '-') {\n // exponent sign\n number += this.expr.charAt(this.index++);\n }\n while (Jsep.isDecimalDigit(this.code)) {\n // exponent itself\n number += this.expr.charAt(this.index++);\n }\n if (!Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1))) {\n this.throwError('Expected exponent (' + number + this.char + ')');\n }\n }\n chCode = this.code;\n\n // Check to make sure this isn't a variable name that start with a number (123abc)\n if (Jsep.isIdentifierStart(chCode)) {\n this.throwError('Variable names cannot start with a number (' + number + this.char + ')');\n } else if (chCode === Jsep.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === Jsep.PERIOD_CODE) {\n this.throwError('Unexpected period');\n }\n return {\n type: Jsep.LITERAL,\n value: parseFloat(number),\n raw: number\n };\n }\n\n /**\n * Parses a string literal, staring with single or double quotes with basic support for escape codes\n * e.g. `\"hello world\"`, `'this is\\nJSEP'`\n * @returns {jsep.Literal}\n */\n gobbleStringLiteral() {\n let str = '';\n const startIndex = this.index;\n const quote = this.expr.charAt(this.index++);\n let closed = false;\n while (this.index < this.expr.length) {\n let ch = this.expr.charAt(this.index++);\n if (ch === quote) {\n closed = true;\n break;\n } else if (ch === '\\\\') {\n // Check for all of the common escape codes\n ch = this.expr.charAt(this.index++);\n switch (ch) {\n case 'n':\n str += '\\n';\n break;\n case 'r':\n str += '\\r';\n break;\n case 't':\n str += '\\t';\n break;\n case 'b':\n str += '\\b';\n break;\n case 'f':\n str += '\\f';\n break;\n case 'v':\n str += '\\x0B';\n break;\n default:\n str += ch;\n }\n } else {\n str += ch;\n }\n }\n if (!closed) {\n this.throwError('Unclosed quote after \"' + str + '\"');\n }\n return {\n type: Jsep.LITERAL,\n value: str,\n raw: this.expr.substring(startIndex, this.index)\n };\n }\n\n /**\n * Gobbles only identifiers\n * e.g.: `foo`, `_value`, `$x1`\n * Also, this function checks if that identifier is a literal:\n * (e.g. `true`, `false`, `null`) or `this`\n * @returns {jsep.Identifier}\n */\n gobbleIdentifier() {\n let ch = this.code,\n start = this.index;\n if (Jsep.isIdentifierStart(ch)) {\n this.index++;\n } else {\n this.throwError('Unexpected ' + this.char);\n }\n while (this.index < this.expr.length) {\n ch = this.code;\n if (Jsep.isIdentifierPart(ch)) {\n this.index++;\n } else {\n break;\n }\n }\n return {\n type: Jsep.IDENTIFIER,\n name: this.expr.slice(start, this.index)\n };\n }\n\n /**\n * Gobbles a list of arguments within the context of a function call\n * or array literal. This function also assumes that the opening character\n * `(` or `[` has already been gobbled, and gobbles expressions and commas\n * until the terminator character `)` or `]` is encountered.\n * e.g. `foo(bar, baz)`, `my_func()`, or `[bar, baz]`\n * @param {number} termination\n * @returns {jsep.Expression[]}\n */\n gobbleArguments(termination) {\n const args = [];\n let closed = false;\n let separator_count = 0;\n while (this.index < this.expr.length) {\n this.gobbleSpaces();\n let ch_i = this.code;\n if (ch_i === termination) {\n // done parsing\n closed = true;\n this.index++;\n if (termination === Jsep.CPAREN_CODE && separator_count && separator_count >= args.length) {\n this.throwError('Unexpected token ' + String.fromCharCode(termination));\n }\n break;\n } else if (ch_i === Jsep.COMMA_CODE) {\n // between expressions\n this.index++;\n separator_count++;\n if (separator_count !== args.length) {\n // missing argument\n if (termination === Jsep.CPAREN_CODE) {\n this.throwError('Unexpected token ,');\n } else if (termination === Jsep.CBRACK_CODE) {\n for (let arg = args.length; arg < separator_count; arg++) {\n args.push(null);\n }\n }\n }\n } else if (args.length !== separator_count && separator_count !== 0) {\n // NOTE: `&& separator_count !== 0` allows for either all commas, or all spaces as arguments\n this.throwError('Expected comma');\n } else {\n const node = this.gobbleExpression();\n if (!node || node.type === Jsep.COMPOUND) {\n this.throwError('Expected comma');\n }\n args.push(node);\n }\n }\n if (!closed) {\n this.throwError('Expected ' + String.fromCharCode(termination));\n }\n return args;\n }\n\n /**\n * Responsible for parsing a group of things within parentheses `()`\n * that have no identifier in front (so not a function call)\n * This function assumes that it needs to gobble the opening parenthesis\n * and then tries to gobble everything within that parenthesis, assuming\n * that the next thing it should see is the close parenthesis. If not,\n * then the expression probably doesn't have a `)`\n * @returns {boolean|jsep.Expression}\n */\n gobbleGroup() {\n this.index++;\n let nodes = this.gobbleExpressions(Jsep.CPAREN_CODE);\n if (this.code === Jsep.CPAREN_CODE) {\n this.index++;\n if (nodes.length === 1) {\n return nodes[0];\n } else if (!nodes.length) {\n return false;\n } else {\n return {\n type: Jsep.SEQUENCE_EXP,\n expressions: nodes\n };\n }\n } else {\n this.throwError('Unclosed (');\n }\n }\n\n /**\n * Responsible for parsing Array literals `[1, 2, 3]`\n * This function assumes that it needs to gobble the opening bracket\n * and then tries to gobble the expressions as arguments.\n * @returns {jsep.ArrayExpression}\n */\n gobbleArray() {\n this.index++;\n return {\n type: Jsep.ARRAY_EXP,\n elements: this.gobbleArguments(Jsep.CBRACK_CODE)\n };\n }\n}\n\n// Static fields:\nconst hooks = new Hooks();\nObject.assign(Jsep, {\n hooks,\n plugins: new Plugins(Jsep),\n // Node Types\n // ----------\n // This is the full set of types that any JSEP node can be.\n // Store them here to save space when minified\n COMPOUND: 'Compound',\n SEQUENCE_EXP: 'SequenceExpression',\n IDENTIFIER: 'Identifier',\n MEMBER_EXP: 'MemberExpression',\n LITERAL: 'Literal',\n THIS_EXP: 'ThisExpression',\n CALL_EXP: 'CallExpression',\n UNARY_EXP: 'UnaryExpression',\n BINARY_EXP: 'BinaryExpression',\n ARRAY_EXP: 'ArrayExpression',\n TAB_CODE: 9,\n LF_CODE: 10,\n CR_CODE: 13,\n SPACE_CODE: 32,\n PERIOD_CODE: 46,\n // '.'\n COMMA_CODE: 44,\n // ','\n SQUOTE_CODE: 39,\n // single quote\n DQUOTE_CODE: 34,\n // double quotes\n OPAREN_CODE: 40,\n // (\n CPAREN_CODE: 41,\n // )\n OBRACK_CODE: 91,\n // [\n CBRACK_CODE: 93,\n // ]\n QUMARK_CODE: 63,\n // ?\n SEMCOL_CODE: 59,\n // ;\n COLON_CODE: 58,\n // :\n\n // Operations\n // ----------\n // Use a quickly-accessible map to store all of the unary operators\n // Values are set to `1` (it really doesn't matter)\n unary_ops: {\n '-': 1,\n '!': 1,\n '~': 1,\n '+': 1\n },\n // Also use a map for the binary operations but set their values to their\n // binary precedence for quick reference (higher number = higher precedence)\n // see [Order of operations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence)\n binary_ops: {\n '||': 1,\n '??': 1,\n '&&': 2,\n '|': 3,\n '^': 4,\n '&': 5,\n '==': 6,\n '!=': 6,\n '===': 6,\n '!==': 6,\n '<': 7,\n '>': 7,\n '<=': 7,\n '>=': 7,\n '<<': 8,\n '>>': 8,\n '>>>': 8,\n '+': 9,\n '-': 9,\n '*': 10,\n '/': 10,\n '%': 10,\n '**': 11\n },\n // sets specific binary_ops as right-associative\n right_associative: new Set(['**']),\n // Additional valid identifier chars, apart from a-z, A-Z and 0-9 (except on the starting char)\n additional_identifier_chars: new Set(['$', '_']),\n // Literals\n // ----------\n // Store the values to return for the various literals we may encounter\n literals: {\n 'true': true,\n 'false': false,\n 'null': null\n },\n // Except for `this`, which is special. This could be changed to something like `'self'` as well\n this_str: 'this'\n});\nJsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);\nJsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);\n\n// Backward Compatibility:\nconst jsep = expr => new Jsep(expr).parse();\nconst stdClassProps = Object.getOwnPropertyNames(class Test {});\nObject.getOwnPropertyNames(Jsep).filter(prop => !stdClassProps.includes(prop) && jsep[prop] === undefined).forEach(m => {\n jsep[m] = Jsep[m];\n});\njsep.Jsep = Jsep; // allows for const { Jsep } = require('jsep');\n\nconst CONDITIONAL_EXP = 'ConditionalExpression';\nvar ternary = {\n name: 'ternary',\n init(jsep) {\n // Ternary expression: test ? consequent : alternate\n jsep.hooks.add('after-expression', function gobbleTernary(env) {\n if (env.node && this.code === jsep.QUMARK_CODE) {\n this.index++;\n const test = env.node;\n const consequent = this.gobbleExpression();\n if (!consequent) {\n this.throwError('Expected expression');\n }\n this.gobbleSpaces();\n if (this.code === jsep.COLON_CODE) {\n this.index++;\n const alternate = this.gobbleExpression();\n if (!alternate) {\n this.throwError('Expected expression');\n }\n env.node = {\n type: CONDITIONAL_EXP,\n test,\n consequent,\n alternate\n };\n\n // check for operators of higher priority than ternary (i.e. assignment)\n // jsep sets || at 1, and assignment at 0.9, and conditional should be between them\n if (test.operator && jsep.binary_ops[test.operator] <= 0.9) {\n let newTest = test;\n while (newTest.right.operator && jsep.binary_ops[newTest.right.operator] <= 0.9) {\n newTest = newTest.right;\n }\n env.node.test = newTest.right;\n newTest.right = env.node;\n env.node = test;\n }\n } else {\n this.throwError('Expected :');\n }\n }\n });\n }\n};\n\n// Add default plugins:\n\njsep.plugins.register(ternary);\n\nconst FSLASH_CODE = 47; // '/'\nconst BSLASH_CODE = 92; // '\\\\'\n\nvar index = {\n name: 'regex',\n init(jsep) {\n // Regex literal: /abc123/ig\n jsep.hooks.add('gobble-token', function gobbleRegexLiteral(env) {\n if (this.code === FSLASH_CODE) {\n const patternIndex = ++this.index;\n let inCharSet = false;\n while (this.index < this.expr.length) {\n if (this.code === FSLASH_CODE && !inCharSet) {\n const pattern = this.expr.slice(patternIndex, this.index);\n let flags = '';\n while (++this.index < this.expr.length) {\n const code = this.code;\n if (code >= 97 && code <= 122 // a...z\n || code >= 65 && code <= 90 // A...Z\n || code >= 48 && code <= 57) {\n // 0-9\n flags += this.char;\n } else {\n break;\n }\n }\n let value;\n try {\n value = new RegExp(pattern, flags);\n } catch (e) {\n this.throwError(e.message);\n }\n env.node = {\n type: jsep.LITERAL,\n value,\n raw: this.expr.slice(patternIndex - 1, this.index)\n };\n\n // allow . [] and () after regex: /regex/.test(a)\n env.node = this.gobbleTokenProperty(env.node);\n return env.node;\n }\n if (this.code === jsep.OBRACK_CODE) {\n inCharSet = true;\n } else if (inCharSet && this.code === jsep.CBRACK_CODE) {\n inCharSet = false;\n }\n this.index += this.code === BSLASH_CODE ? 2 : 1;\n }\n this.throwError('Unclosed Regex');\n }\n });\n }\n};\n\nconst PLUS_CODE = 43; // +\nconst MINUS_CODE = 45; // -\n\nconst plugin = {\n name: 'assignment',\n assignmentOperators: new Set(['=', '*=', '**=', '/=', '%=', '+=', '-=', '<<=', '>>=', '>>>=', '&=', '^=', '|=', '||=', '&&=', '??=']),\n updateOperators: [PLUS_CODE, MINUS_CODE],\n assignmentPrecedence: 0.9,\n init(jsep) {\n const updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP];\n plugin.assignmentOperators.forEach(op => jsep.addBinaryOp(op, plugin.assignmentPrecedence, true));\n jsep.hooks.add('gobble-token', function gobbleUpdatePrefix(env) {\n const code = this.code;\n if (plugin.updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\n this.index += 2;\n env.node = {\n type: 'UpdateExpression',\n operator: code === PLUS_CODE ? '++' : '--',\n argument: this.gobbleTokenProperty(this.gobbleIdentifier()),\n prefix: true\n };\n if (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {\n this.throwError(`Unexpected ${env.node.operator}`);\n }\n }\n });\n jsep.hooks.add('after-token', function gobbleUpdatePostfix(env) {\n if (env.node) {\n const code = this.code;\n if (plugin.updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\n if (!updateNodeTypes.includes(env.node.type)) {\n this.throwError(`Unexpected ${env.node.operator}`);\n }\n this.index += 2;\n env.node = {\n type: 'UpdateExpression',\n operator: code === PLUS_CODE ? '++' : '--',\n argument: env.node,\n prefix: false\n };\n }\n }\n });\n jsep.hooks.add('after-expression', function gobbleAssignment(env) {\n if (env.node) {\n // Note: Binaries can be chained in a single expression to respect\n // operator precedence (i.e. a = b = 1 + 2 + 3)\n // Update all binary assignment nodes in the tree\n updateBinariesToAssignments(env.node);\n }\n });\n function updateBinariesToAssignments(node) {\n if (plugin.assignmentOperators.has(node.operator)) {\n node.type = 'AssignmentExpression';\n updateBinariesToAssignments(node.left);\n updateBinariesToAssignments(node.right);\n } else if (!node.operator) {\n Object.values(node).forEach(val => {\n if (val && typeof val === 'object') {\n updateBinariesToAssignments(val);\n }\n });\n }\n }\n }\n};\n\n/* eslint-disable unicorn/no-top-level-side-effects -- Temporary? */\n/* eslint-disable no-bitwise -- Convenient */\n\n/**\n * @import {EvaluatedResult, UnknownResult} from './jsonpath.js';\n */\n\n/**\n * @typedef {any} AssignmentExpression\n */\n\n/**\n * @typedef {any} Substitution\n */\n\n/**\n * @typedef {any} AnyParameter\n */\n\n/**\n * @typedef {Record<string, Substitution>} Substitutions\n */\n\n// register plugins\njsep.plugins.register(index, plugin);\njsep.addUnaryOp('typeof');\njsep.addUnaryOp('void');\njsep.addLiteral('null', null);\njsep.addLiteral('undefined', undefined);\nconst BLOCKED_PROTO_PROPERTIES = new Set(['constructor', '__proto__', '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__']);\n\n// Every function-constructor variant, along with the invocation helpers which\n// could otherwise reach them indirectly, e.g., `Function.call(0, 'code')()`,\n// plus whichever BLOCKED_PROTO_PROPERTIES names resolve to an own method on\n// Object.prototype (e.g. `__defineGetter__`) - an own-property access on a\n// shared prototype (`@.prototype.__defineGetter__`) bypasses the\n// inherited-only name check below, so those methods need blocking by value.\n/** @type {WeakSet<object>} */\nconst BLOCKED_FUNCTIONS = new WeakSet([Function,\n// eslint-disable-next-line no-empty-function -- Only need the constructor\nfunction* () {}.constructor,\n// eslint-disable-next-line no-empty-function -- Only need the constructor\nasync function () {}.constructor,\n// eslint-disable-next-line no-empty-function -- Only need the constructor\nasync function* () {}.constructor, Function.prototype.call, Function.prototype.apply, Function.prototype.bind, Reflect.apply, Reflect.construct, ...[...BLOCKED_PROTO_PROPERTIES].map(name => Reflect.get(Object.prototype, name)).filter(value => typeof value === 'function')]);\n\n/**\n * @param {UnknownResult} value\n * @returns {boolean}\n */\nconst isBlockedFunction = value => {\n return typeof value === 'function' && BLOCKED_FUNCTIONS.has(value);\n};\n\n/**\n * Guarded `obj[prop]`, applying the same restrictions as a MemberExpression.\n * @param {UnknownResult} obj\n * @param {string} prop\n * @returns {UnknownResult}\n */\nconst getSafeProperty = (obj, prop) => {\n if (obj === undefined || obj === null) {\n throw new TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);\n }\n if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) {\n throw new TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);\n }\n const result = /** @type {Record<string, UnknownResult>} */obj[prop];\n if (isBlockedFunction(result)) {\n throw new TypeError('Function constructor is disabled');\n }\n return result;\n};\n\n/**\n * @typedef {Record<\n * string,\n * (a: AnyParameter, b: AnyParameter) => UnknownResult\n * >} OperatorTable\n */\n\n// eslint-disable-next-line @stylistic/max-len -- Long\nconst BINOPS = Object.assign(Object.create(null), /** @type {OperatorTable} */{\n '||': (a, b) => a || b(),\n '??': (a, b) => a ?? b(),\n '&&': (a, b) => a && b(),\n '|': (a, b) => a | b(),\n '^': (a, b) => a ^ b(),\n '&': (a, b) => a & b(),\n // eslint-disable-next-line eqeqeq -- API\n '==': (a, b) => a == b(),\n // eslint-disable-next-line eqeqeq -- API\n '!=': (a, b) => a != b(),\n '===': (a, b) => a === b(),\n '!==': (a, b) => a !== b(),\n '<': (a, b) => a < b(),\n '>': (a, b) => a > b(),\n '<=': (a, b) => a <= b(),\n '>=': (a, b) => a >= b(),\n '<<': (a, b) => a << b(),\n '>>': (a, b) => a >> b(),\n '>>>': (a, b) => a >>> b(),\n '+': (a, b) => a + b(),\n '-': (a, b) => a - b(),\n '*': (a, b) => a * b(),\n '/': (a, b) => a / b(),\n '%': (a, b) => a % b(),\n '**': (a, b) => a ** b()\n});\n\n/**\n * @typedef {{\n * [key: string]: (a: AnyParameter) => UnknownResult\n * }} UnaryOperatorTable\n */\n\n// eslint-disable-next-line @stylistic/max-len -- Long\nconst UNOPS = Object.assign(Object.create(null), /** @type {UnaryOperatorTable} */{\n '-': a => -(/** @type {EvaluatedResult} */a),\n '!': a => !a,\n '~': a => ~(/** @type {EvaluatedResult} */a),\n // eslint-disable-next-line no-implicit-coercion -- API\n '+': a => +(/** @type {EvaluatedResult} */a),\n typeof: a => typeof a,\n void: () => undefined\n});\nconst SafeEval = {\n /**\n * @param {jsep.Expression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalAst(ast, subs) {\n switch (ast.type) {\n case 'BinaryExpression':\n case 'LogicalExpression':\n return SafeEval.evalBinaryExpression(/** @type {jsep.BinaryExpression} */ast, subs);\n case 'Compound':\n return SafeEval.evalCompound(/** @type {jsep.Compound} */ast, subs);\n case 'ConditionalExpression':\n return SafeEval.evalConditionalExpression(/** @type {jsep.ConditionalExpression} */ast, subs);\n case 'Identifier':\n return SafeEval.evalIdentifier(/** @type {jsep.Identifier} */ast, subs);\n case 'Literal':\n return SafeEval.evalLiteral(/** @type {jsep.Literal} */ast);\n case 'MemberExpression':\n return SafeEval.evalMemberExpression(/** @type {jsep.MemberExpression} */ast, subs);\n case 'UnaryExpression':\n return SafeEval.evalUnaryExpression(/** @type {jsep.UnaryExpression} */ast, subs);\n case 'ArrayExpression':\n return SafeEval.evalArrayExpression(/** @type {jsep.ArrayExpression} */ast, subs);\n case 'CallExpression':\n return SafeEval.evalCallExpression(/** @type {jsep.CallExpression} */ast, subs);\n case 'AssignmentExpression':\n return SafeEval.evalAssignmentExpression(/** @type {AssignmentExpression} */ast, subs);\n default:\n throw new SyntaxError('Unexpected expression', {\n cause: ast\n });\n }\n },\n /**\n * @param {jsep.BinaryExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalBinaryExpression(ast, subs) {\n /* c8 ignore next 3 -- Defensive guard for malformed ASTs */\n if (!Object.hasOwn(BINOPS, ast.operator)) {\n throw new SyntaxError(`Unknown binary operator: ${ast.operator}`);\n }\n const result = BINOPS[ast.operator](SafeEval.evalAst(ast.left, subs), () => SafeEval.evalAst(ast.right, subs));\n return result;\n },\n /**\n * @param {jsep.Compound} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalCompound(ast, subs) {\n let last;\n for (let i = 0; i < ast.body.length; i++) {\n if (ast.body[i].type === 'Identifier' && ['var', 'let', 'const'].includes(/** @type {jsep.Identifier} */\n ast.body[i].name) && Object.hasOwn(ast.body, i + 1) && ast.body[i + 1].type === 'AssignmentExpression') {\n // var x=2; is detected as\n // [{Identifier var}, {AssignmentExpression x=2}]\n i += 1;\n }\n const expr = ast.body[i];\n last = SafeEval.evalAst(expr, subs);\n }\n return last;\n },\n /**\n * @param {jsep.ConditionalExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalConditionalExpression(ast, subs) {\n return SafeEval.evalAst(ast.test, subs) ? SafeEval.evalAst(ast.consequent, subs) : SafeEval.evalAst(ast.alternate, subs);\n },\n /**\n * @param {jsep.Identifier} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalIdentifier(ast, subs) {\n if (Object.hasOwn(subs, ast.name)) {\n return subs[ast.name];\n }\n throw new ReferenceError(`${ast.name} is not defined`);\n },\n /**\n * @param {jsep.Literal} ast\n * @returns {UnknownResult}\n */\n evalLiteral(ast) {\n return ast.value;\n },\n /**\n * @param {jsep.MemberExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalMemberExpression(ast, subs) {\n const prop = String(\n // NOTE: `String(value)` throws error when\n // value has overwritten the toString method to return non-string\n // i.e. `value = {toString: () => []}`\n ast.computed ? SafeEval.evalAst(ast.property, subs) // `object[property]`\n : ast.property.name // `object.property` property is Identifier\n );\n const obj = SafeEval.evalAst(ast.object, subs);\n const result = getSafeProperty(obj, prop);\n if (typeof result === 'function') {\n return result.bind(obj); // arrow functions aren't affected by bind.\n }\n return result;\n },\n /**\n * @param {jsep.UnaryExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalUnaryExpression(ast, subs) {\n /* c8 ignore next 3 -- Defensive guard for malformed ASTs */\n if (!Object.hasOwn(UNOPS, ast.operator)) {\n throw new SyntaxError(`Unknown unary operator: ${ast.operator}`);\n }\n const operand = SafeEval.evalAst(ast.argument, subs);\n return UNOPS[ast.operator](operand);\n },\n /**\n * @param {jsep.ArrayExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalArrayExpression(ast, subs) {\n return ast.elements.map(el => SafeEval.evalAst(/** @type {jsep.Expression} */\n el, subs));\n },\n /**\n * @param {jsep.CallExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalCallExpression(ast, subs) {\n const args = ast.arguments.map(arg => SafeEval.evalAst(arg, subs));\n const func = SafeEval.evalAst(ast.callee, subs);\n if (isBlockedFunction(func) || args.some(arg => isBlockedFunction(arg))) {\n throw new Error('Function constructor is disabled');\n }\n return (/** @type {(...args: AnyParameter[]) => UnknownResult} */\n func)(...args);\n },\n /**\n * @param {AssignmentExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalAssignmentExpression(ast, subs) {\n if (ast.left.type !== 'Identifier') {\n throw new SyntaxError('Invalid left-hand side in assignment');\n }\n const id = /** @type {jsep.Identifier} */ast.left.name;\n const value = SafeEval.evalAst(ast.right, subs);\n subs[id] = value;\n return subs[id];\n }\n};\n\n/**\n * A replacement for NodeJS' VM.Script which is also {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | Content Security Policy} friendly.\n */\nclass SafeScript {\n /**\n * @param {string} expr Expression to evaluate\n */\n constructor(expr) {\n this.code = expr;\n this.ast = /** @type {unknown} */jsep(this.code);\n }\n\n /**\n * @param {object} context Object whose items will be added\n * to evaluation\n * @returns {EvaluatedResult} Result of evaluated code\n */\n runInNewContext(context) {\n // `Object.create(null)` creates a prototypeless object\n const keyMap = Object.assign(Object.create(null), context);\n return SafeEval.evalAst(/** @type {jsep.Expression} */this.ast, keyMap);\n }\n}\n\n/**\n * @param {unknown} val\n */\nconst toStringTag = val => {\n return Object.prototype.toString.call(val).slice(8, -1);\n};\n\n/* eslint-disable camelcase -- Convenient for escaping */\n/* eslint-disable class-methods-use-this -- Consistent monkey-patching */\n/* eslint-disable unicorn/prefer-private-class-fields -- Allow\n monkey-patching */\nconst scriptCache = new Map();\nconst pathCache = new Map();\n\n/**\n * @typedef {any} AnyInput\n */\n\n/**\n * @typedef {((...args: any[]) => any)} SandboxCallback\n */\n\n/**\n * @typedef {any|SandboxCallback} SandboxPropertyValue\n */\n\n/**\n * @typedef {(string|number)[]} ExpressionArray\n */\n\n/**\n * @typedef {\"scalar\"|\"boolean\"|\"string\"|\"undefined\"\n * |\"function\"|\"integer\"|\"number\"|\"nonFinite\"|\"object\"\n * |\"array\"|\"other\"|\"null\"|\"symbol\"|\"Promise\"|\"BigInt\"\n * |\"jsonReference\"} ValueType\n */\n\n/**\n * @typedef {unknown} ParentValue\n */\n\n/**\n * @typedef {unknown} UnknownResult\n */\n\n/**\n * @typedef {string|number|null} ParentProperty\n */\n\n/**\n * @typedef {ReturnObject|string|number|boolean|null|unknown[]\n * |Record<string, unknown>} PreferredOutput\n */\n\n/**\n * Copies array and then pushes item into it.\n * @param {ExpressionArray} arr Array to copy and into which to push\n * @param {string|number} item Array item to add (to end)\n * @returns {ExpressionArray} Copy of the original array\n */\nfunction push(arr, item) {\n arr = arr.slice();\n arr.push(item);\n return arr;\n}\n/**\n * Copies array and then unshifts item into it.\n * @param {string|number} item Array item to add (to beginning)\n * @param {ExpressionArray} arr Array to copy and into which to unshift\n * @returns {ExpressionArray} Copy of the original array\n */\nfunction unshift(item, arr) {\n arr = arr.slice();\n arr.unshift(item);\n return arr;\n}\n\n/**\n * @typedef {object} ReturnObject\n * @property {ExpressionArray|string} path\n * @property {unknown} value\n * @property {ParentValue} parent\n * @property {ParentProperty} parentProperty\n * @property {boolean} [isParentSelector]\n * @property {boolean} [hasArrExpr]\n * @property {ExpressionArray} [expr]\n * @property {string} [pointer]\n */\n\n/**\n * @callback JSONPathCallback\n * @param {any} preferredOutput Using `any` type instead of `PreferredOutput` so\n * that user can supply flexible type\n * @param {\"value\"|\"property\"} type\n * @param {ReturnObject} fullRetObj\n * @returns {void}\n */\n\n/**\n * @callback OtherTypeCallback\n * @param {unknown} val\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {string|number|null} parentPropName\n * @param {string} arg\n * @returns {boolean|null}\n */\n\n/**\n * @typedef {any} ContextItem\n */\n\n/**\n * @typedef {any} EvaluatedResult\n */\n\n/**\n * @callback EvalCallback\n * @param {string} code\n * @param {ContextItem} context\n * @returns {EvaluatedResult}\n */\n\n/**\n * @typedef {new (expr: string) => {\n * runInNewContext: (context: object) => EvaluatedResult\n * }} ScriptConstructor\n */\n\n/**\n * @typedef {ScriptConstructor} EvalClass\n */\n\n/**\n * @typedef {\"value\"|\"path\"|\"pointer\"|\"parent\"|\"parentProperty\"\n * |\"all\"} ResultType\n */\n\n/**\n * @typedef {EvalCallback|EvalClass|'safe'|'native'|boolean} EvalValue\n */\n\n/**\n * @typedef {string|string[]} PathType\n */\n\n/**\n * @typedef {{Script: ScriptConstructor}} SafeScriptType\n */\n\n/**\n * @typedef {{Script: ScriptConstructor}} ScriptType\n */\n\n/**\n * @typedef {{\n * _$_path?: string,\n * _$_parentProperty?: ParentProperty,\n * _$_parent?: ParentValue,\n * _$_property?: string|number,\n * _$_root?: AnyInput,\n * _$_v?: unknown,\n * [key: string]: SandboxPropertyValue\n * }} SandboxType\n */\n\n/**\n * @typedef {object} JSONPathOptions\n * @property {AnyInput} [json]\n * @property {PathType} [path]\n * @property {ResultType} [resultType=\"value\"]\n * @property {boolean} [flatten=false]\n * @property {boolean} [wrap=true]\n * @property {SandboxType} [sandbox={}]\n * @property {EvalValue} [eval='safe']\n * @property {any|null} [parent=null]\n * @property {ParentProperty} [parentProperty=null]\n * @property {JSONPathCallback} [callback]\n * @property {OtherTypeCallback} [otherTypeCallback] Defaults to\n * function which throws on encountering `@other`\n * @property {Record<string, OtherTypeCallback>} [customTypes] Map of\n * custom type operator names to their evaluation callbacks\n * @property {boolean} [autostart=true]\n * @property {boolean} [ignoreEvalErrors=false]\n */\n\n/**\n * @overload\n * @param {string} opts JSON path to evaluate\n * @param {AnyInput} [expr] JSON object to evaluate against\n * @param {JSONPathCallback} [obj] Passed 3 arguments: 1) desired\n * payload per `resultType`, 2) `\"value\"|\"property\"`, 3) Full returned\n * object with all payloads\n * @param {OtherTypeCallback} [callback] If `@other()` is at the\n * end of one's query, this will be invoked with the value of the item,\n * its path, its parent, and its parent's property name, and it should\n * return a boolean indicating whether the supplied value belongs to the\n * \"other\" type or not (or it may handle transformations and return\n * `false`).\n * @param {undefined} [otherTypeCallback]\n * @returns {unknown} The string form always has `autostart` implicitly\n * `true`, so the result is the evaluated value, not a `JSONPathClass`\n */\n/**\n * @overload\n * @param {JSONPathOptions & {autostart: false}} opts An options object\n * with `autostart` explicitly set to `false` defers evaluation and\n * returns the `JSONPathClass` instance instead\n * @returns {JSONPathClass}\n */\n/**\n * @overload\n * @param {JSONPathOptions} opts If a string, will be treated as\n * `expr`\n * @returns {unknown}\n */\n/**\n * @param {JSONPathOptions|string} opts If a string, will be treated as `expr`\n * @param {string|AnyInput} [expr] JSON path to evaluate\n * @param {AnyInput|JSONPathCallback} [obj] JSON object to evaluate against\n * @param {JSONPathCallback|OtherTypeCallback} [callback] Passed 3\n * arguments: 1) desired payload per `resultType`,\n * 2) `\"value\"|\"property\"`, 3) Full returned object with\n * all payloads\n * @param {OtherTypeCallback} [otherTypeCallback] If `@other()` is at the end\n * of one's query, this will be invoked with the value of the item, its\n * path, its parent, and its parent's property name, and it should return\n * a boolean indicating whether the supplied value belongs to the \"other\"\n * type or not (or it may handle transformations and return `false`).\n * @throws {Error}\n * @returns {unknown|JSONPathClass}\n */\nfunction JSONPath(opts, expr, obj, callback, otherTypeCallback) {\n try {\n if (opts && typeof opts === 'object') {\n return new JSONPathClass(opts);\n }\n return new JSONPathClass(opts, expr, /** @type {JSONPathCallback|undefined} */obj, /** @type {OtherTypeCallback|undefined} */callback, /** @type {undefined} */otherTypeCallback);\n } catch (e) {\n if (new.target) {\n throw e;\n }\n if (e && typeof e === 'object' && 'value' in e) {\n return /** @type {{value: UnknownResult}} */e.value;\n }\n throw e;\n }\n}\n\n/**\n *\n */\nclass JSONPathClass {\n /**\n * @overload\n * @param {string} opts JSON path to evaluate\n * @param {AnyInput} [expr] JSON object to evaluate against\n * @param {JSONPathCallback} [obj] Passed 3 arguments: 1) desired\n * payload per `resultType`, 2) `\"value\"|\"property\"`, 3) Full returned\n * object with all payloads\n * @param {OtherTypeCallback} [callback] If `@other()` is at the\n * end of one's query, this will be invoked with the value of the item,\n * its path, its parent, and its parent's property name, and it should\n * return a boolean indicating whether the supplied value belongs to the\n * \"other\" type or not (or it may handle transformations and return\n * `false`).\n * @param {undefined} [otherTypeCallback]\n */\n /**\n * @overload\n * @param {JSONPathOptions} opts If a string, will be treated as\n * `expr`\n */\n /**\n * @param {null|string|JSONPathOptions} opts If a string, will be treated as\n * `expr`\n * @param {string|AnyInput} [expr] JSON path to evaluate\n * @param {AnyInput|JSONPathCallback} [obj] JSON object to evaluate against\n * @param {JSONPathCallback|OtherTypeCallback} [callback] Passed 3\n * arguments: 1) desired payload per `resultType`,\n * 2) `\"value\"|\"property\"`, 3) Full returned\n * object with all payloads\n * @param {OtherTypeCallback} [otherTypeCallback] If `@other()` is at the\n * end of one's query, this will be invoked with the value of the item,\n * its path, its parent, and its parent's property name, and it should\n * return a boolean indicating whether the supplied value belongs to the\n * \"other\" type or not (or it may handle transformations and return\n * `false`).\n */\n constructor(opts, expr, obj, callback, otherTypeCallback) {\n if (typeof opts === 'string') {\n otherTypeCallback = /** @type {OtherTypeCallback} */\n callback;\n callback = /** @type {JSONPathCallback} */\n obj;\n obj = expr;\n expr = opts;\n opts = null;\n }\n const optObj = opts && typeof opts === 'object';\n opts ||= /** @type {JSONPathOptions} */{};\n /** @type {ResultType|undefined} */\n this.currResultType = undefined;\n\n /** @type {EvalValue|undefined} */\n this.currEval = undefined;\n\n /** @type {OtherTypeCallback|undefined} */\n this.currOtherTypeCallback = undefined;\n\n /** @type {Record<string, OtherTypeCallback>|undefined} */\n this.currCustomTypes = undefined;\n\n /** @type {SandboxType|undefined} */\n this.currSandbox = undefined;\n this._hasParentSelector = false;\n this.json = opts.json || obj;\n this.path = opts.path || expr;\n this.resultType = opts.resultType || 'value';\n this.flatten = Object.hasOwn(opts, 'flatten') && opts.flatten;\n this.wrap = !Object.hasOwn(opts, 'wrap') || opts.wrap;\n this.sandbox = opts.sandbox || {};\n this.eval = opts.eval === undefined ? 'safe' : opts.eval;\n this.ignoreEvalErrors = typeof opts.ignoreEvalErrors !== 'undefined' && opts.ignoreEvalErrors;\n this.parent = Object.hasOwn(opts, 'parent') ? opts.parent : null;\n this.parentProperty = Object.hasOwn(opts, 'parentProperty') ? opts.parentProperty : null;\n this.callback = opts.callback || (/** @type {JSONPathCallback} */\n callback) || null;\n this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function () {\n throw new TypeError('You must supply an otherTypeCallback callback option ' + 'with the @other() operator.');\n };\n this.customTypes = opts.customTypes || {};\n if (opts.autostart === false) {\n return;\n }\n const args = /** @type {JSONPathOptions} */{\n path: optObj ? opts.path : expr\n };\n if (!optObj && obj !== undefined) {\n args.json = obj;\n } else if ('json' in opts) {\n args.json = opts.json;\n }\n const ret = this.evaluate(args);\n if (!ret || typeof ret !== 'object') {\n const err = /** @type {Error & {value: UnknownResult}} */\n new Error('JSONPath should not be called with \"new\" (it ' + 'prevents return of (unwrapped) scalar values)');\n err.value = ret;\n throw err;\n }\n\n // @ts-expect-error - Constructor returns evaluate result for legacy API\n // eslint-disable-next-line @stylistic/max-len -- Long\n // eslint-disable-next-line consistent-return, no-constructor-return -- Legacy API\n return ret;\n }\n\n // PUBLIC METHODS\n\n /**\n * @overload\n * @param {JSONPathOptions} [expr]\n * @returns {ReturnObject|ReturnObject[]|undefined|unknown}\n */\n\n /**\n * @overload\n * @param {PathType|undefined} [expr]\n * @param {AnyInput} [json]\n * @param {JSONPathCallback|null} [callback]\n * @param {OtherTypeCallback} [otherTypeCallback]\n * @returns {ReturnObject|ReturnObject[]|undefined|unknown}\n */\n\n /**\n * @param {PathType|JSONPathOptions|undefined} [expr]\n * @param {AnyInput} [json]\n * @param {JSONPathCallback|null} [callback]\n * @param {OtherTypeCallback} [otherTypeCallback]\n * @returns {ReturnObject|ReturnObject[]|undefined|unknown}\n */\n evaluate(expr, json, callback, otherTypeCallback) {\n let currParent = this.parent,\n currParentProperty = this.parentProperty;\n let {\n flatten,\n wrap\n } = this;\n this.currResultType = this.resultType;\n this.currEval = this.eval;\n this.currSandbox = this.sandbox;\n callback ||= this.callback;\n this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback;\n this.currCustomTypes = this.customTypes;\n if (expr && typeof expr === 'object' && !Array.isArray(expr)) {\n const exprObj = expr;\n if (!exprObj.path && exprObj.path !== '') {\n throw new TypeError('You must supply a \"path\" property when providing an ' + 'object argument to JSONPath.evaluate().');\n }\n if (!Object.hasOwn(exprObj, 'json')) {\n throw new TypeError('You must supply a \"json\" property when providing an ' + 'object argument to JSONPath.evaluate().');\n }\n ({\n json\n } = exprObj);\n flatten = Object.hasOwn(exprObj, 'flatten') ? exprObj.flatten : flatten;\n this.currResultType = Object.hasOwn(exprObj, 'resultType') ? exprObj.resultType : this.currResultType;\n this.currSandbox = Object.hasOwn(exprObj, 'sandbox') ? exprObj.sandbox : this.currSandbox;\n wrap = Object.hasOwn(exprObj, 'wrap') ? exprObj.wrap : wrap;\n this.currEval = Object.hasOwn(exprObj, 'eval') ? exprObj.eval : this.currEval;\n callback = Object.hasOwn(exprObj, 'callback') ? exprObj.callback : callback;\n this.currOtherTypeCallback = Object.hasOwn(exprObj, 'otherTypeCallback') ? exprObj.otherTypeCallback : this.currOtherTypeCallback;\n this.currCustomTypes = Object.hasOwn(exprObj, 'customTypes') ? exprObj.customTypes : this.currCustomTypes;\n currParent = Object.hasOwn(exprObj, 'parent') ? exprObj.parent : currParent;\n currParentProperty = Object.hasOwn(exprObj, 'parentProperty') ? exprObj.parentProperty : currParentProperty;\n expr = exprObj.path;\n } else {\n json ||= this.json;\n expr ||= this.path;\n }\n currParent ||= null;\n currParentProperty ||= null;\n if (Array.isArray(expr)) {\n expr = JSONPath.toPathString(expr);\n }\n if (!json || !expr && expr !== '') {\n return undefined;\n }\n const exprList = JSONPath.toPathArray(/** @type {string} */\n expr);\n if (exprList[0] === '$' && exprList.length > 1) {\n exprList.shift();\n }\n this._hasParentSelector = false;\n const traceResult = this._trace(exprList, json, ['$'], currParent, currParentProperty, callback ?? undefined, undefined);\n\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next 2 -- Unreachable: _trace returns array when hasArrExpr set */\n const result = (Array.isArray(traceResult) ? traceResult : [traceResult]).filter(ea => {\n return ea && !ea.isParentSelector;\n });\n if (!result.length) {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next -- Unreachable: valid queries always produce results */\n return wrap ? [] : undefined;\n }\n if (!wrap && result.length === 1 && !result[0].hasArrExpr) {\n const preferredOutput = this._getPreferredOutput(result[0]);\n return preferredOutput;\n }\n const reduced = result.reduce((rslt, ea) => {\n const valOrPath = this._getPreferredOutput(ea);\n if (flatten && Array.isArray(valOrPath)) {\n rslt = rslt.concat(valOrPath);\n } else {\n rslt.push(valOrPath);\n }\n return rslt;\n }, /** @type {UnknownResult[]} */\n []);\n return reduced;\n }\n\n // PRIVATE METHODS\n\n /**\n * @param {ReturnObject} ea\n * @returns {PreferredOutput}\n */\n _getPreferredOutput(ea) {\n const resultType = this.currResultType;\n switch (resultType) {\n case 'all':\n {\n const path = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);\n ea.pointer = JSONPath.toPointer(/** @type {string[]} */path);\n ea.path = typeof ea.path === 'string' ? ea.path : JSONPath.toPathString(/** @type {string[]} */ea.path);\n return ea;\n }\n case 'value':\n case 'parent':\n case 'parentProperty':\n return /** @type {PreferredOutput} */ea[resultType];\n case 'path':\n if (typeof ea.path === 'string') {\n return ea.path;\n }\n return JSONPath.toPathString(/** @type {string[]} */ea.path);\n case 'pointer':\n {\n const pathArray = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);\n return JSONPath.toPointer(/** @type {string[]} */pathArray);\n }\n default:\n throw new TypeError('Unknown result type');\n }\n }\n\n /**\n * @param {ReturnObject} fullRetObj\n * @param {JSONPathCallback|undefined} callback\n * @param {\"value\"|\"property\"} type\n * @returns {void}\n */\n _handleCallback(fullRetObj, callback, type) {\n // Early return if no callback provided (defensive\n // check for internal calls)\n if (!callback) {\n return;\n }\n const preferredOutput = this._getPreferredOutput(fullRetObj);\n if (Array.isArray(fullRetObj.path)) {\n fullRetObj.path = JSONPath.toPathString(/** @type {string[]} */fullRetObj.path);\n }\n callback(preferredOutput, type, fullRetObj);\n }\n\n /**\n *\n * @param {ExpressionArray} expr\n * @param {unknown} val\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {ParentProperty} parentPropName\n * @param {JSONPathCallback|undefined} callback\n * @param {boolean|undefined} hasArrExpr\n * @param {boolean} [literalPriority]\n * @returns {ReturnObject|ReturnObject[]}\n */\n _trace(expr, val, path, parent, parentPropName, callback, hasArrExpr, literalPriority) {\n // No expr to follow? return path and value as the result of\n // this trace branch\n let retObj;\n if (!expr.length) {\n retObj = {\n path,\n value: val,\n parent,\n parentProperty: parentPropName,\n hasArrExpr\n };\n this._handleCallback(retObj, callback, 'value');\n return retObj;\n }\n const loc = /** @type {string} */expr[0],\n x = expr.slice(1);\n\n // We need to gather the return value of recursive trace calls in order\n // to do the parent sel computation.\n /** @type {ReturnObject[]} */\n const ret = [];\n /**\n *\n * @param {ReturnObject|ReturnObject[]} elems\n * @returns {void}\n */\n function addRet(elems) {\n if (Array.isArray(elems)) {\n // This was causing excessive stack size in Node (with or\n // without Babel) against our performance test:\n // `ret.push(...elems);`\n elems.forEach(t => {\n ret.push(t);\n });\n } else {\n ret.push(elems);\n }\n }\n if (val && (typeof loc !== 'string' || literalPriority) && Object.hasOwn(val, /** @type {PropertyKey} */loc)) {\n // simple case--directly follow property\n const valObj = /** @type {Record<string, unknown>} */val;\n addRet(this._trace(x, valObj[(/** @type {string} */loc)], push(path, loc), val, /** @type {string|number} */loc, callback, hasArrExpr));\n // eslint-disable-next-line unicorn/prefer-switch -- Part of larger `if`\n } else if (loc === '*') {\n // all child properties\n this._walk(val, m => {\n const valObj = /** @type {Record<string, unknown>} */val;\n addRet(this._trace(x, valObj[m], push(path, m), val, m, callback, true, true));\n });\n } else if (loc === '..') {\n // all descendent parent properties\n // Check remaining expression with val's immediate children\n addRet(this._trace(x, val, path, parent, parentPropName, callback, hasArrExpr));\n this._walk(val, m => {\n // We don't join m and x here because we only want parents,\n // not scalar values\n const valObj = /** @type {Record<string, unknown>} */val;\n if (typeof valObj[m] === 'object') {\n // Keep going with recursive descent on val's\n // object children\n addRet(this._trace(expr.slice(), valObj[m], push(path, m), val, m, callback, true));\n }\n });\n // The parent sel computation is handled in the frame above using the\n // ancestor object of val\n } else if (loc === '^') {\n // This is not a final endpoint, so we do not invoke the\n // callback here\n this._hasParentSelector = true;\n return /** @type {ReturnObject} */{\n path: path.slice(0, -1),\n expr: x,\n isParentSelector: true,\n value: undefined,\n parent: undefined,\n parentProperty: null\n };\n } else if (loc === '~') {\n // property name\n retObj = {\n path: push(path, loc),\n value: parentPropName,\n parent,\n parentProperty: null\n };\n this._handleCallback(retObj, callback, 'property');\n return retObj;\n } else if (loc === '$') {\n // root only\n addRet(this._trace(x, val, path, null, null, callback, hasArrExpr));\n } else if (/^(-?\\d*):(-?\\d*):?(-?\\d*)$/v.test(loc)) {\n // [start:end:step] Python slice syntax\n const sliceResult = this._slice(loc, x, val, path, parent, parentPropName, callback);\n if (sliceResult) {\n addRet(sliceResult);\n }\n } else if (loc.indexOf('?(') === 0) {\n // [?(expr)] (filtering)\n if (this.currEval === false) {\n throw new Error('Eval [?(expr)] prevented in JSONPath expression.');\n }\n const safeLoc = loc.replace(/^\\?\\((.*?)\\)$/v, '$1');\n // check for a nested filter expression\n\n const nested = /@.?([^?]*)[\\['](\\??\\(.*?\\))(?!.\\)\\])[\\]']/gv.exec(safeLoc);\n if (nested) {\n // find if there are matches in the nested expression\n // add them to the result set if there is at least one match\n this._walk(val, m => {\n const npath = [nested[2]];\n const valObj2 = /** @type {Record<string, unknown>} */\n val;\n // guard against nested[1] resolving to `constructor`\n const nvalue = /** @type {ValueType} */nested[1] ? getSafeProperty(/** @type {Record<string, unknown>} */\n valObj2[m], nested[1]) : valObj2[m];\n const filterResults = this._trace(npath, nvalue, path, parent, parentPropName, callback, true);\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next 3 -- Unreachable: _trace always returns array for nested filters */\n const filterArray = Array.isArray(filterResults) ? filterResults : [filterResults];\n if (filterArray.length > 0) {\n addRet(this._trace(x, valObj2[m], push(path, m), val, m, callback, true));\n }\n });\n } else {\n const valObj3 = /** @type {Record<string, unknown>} */val;\n this._walk(val, m => {\n if (this._eval(safeLoc, valObj3[m], m, path, parent, parentPropName)) {\n addRet(this._trace(x, valObj3[m], push(path, m), val, m, callback, true));\n }\n });\n }\n } else if (loc[0] === '(') {\n // [(expr)] (dynamic property/index)\n if (this.currEval === false) {\n throw new Error('Eval [(expr)] prevented in JSONPath expression.');\n }\n // As this will resolve to a property name (but we don't know it\n // yet), property and parent information is relative to the\n const evalResult = this._eval(/** @type {string} */loc, val, /** @type {string|number} */path.at(-1), path.slice(0, -1), parent, parentPropName);\n const exprToUse = /** @type {string|number} */\n evalResult !== undefined ? evalResult : '';\n addRet(this._trace(unshift(exprToUse, x), val, path, parent, parentPropName, callback, hasArrExpr));\n } else if (loc[0] === '@') {\n // value type: @boolean(), etc.\n // eslint-disable-next-line no-useless-assignment -- ESLint bug\n let addType = false;\n const parenthIndex = loc.indexOf('(');\n const valueType = /** @type {ValueType|string} */loc.slice(1, parenthIndex);\n const lastParenth = loc.lastIndexOf(')');\n const argRaw = loc.slice(parenthIndex + 1, lastParenth);\n const arg = argRaw ? JSON.parse(argRaw) : undefined;\n switch (valueType) {\n case 'scalar':\n addType = !val || !['object', 'function'].includes(typeof val);\n break;\n case 'boolean':\n case 'string':\n case 'undefined':\n case 'function':\n addType = typeof val === valueType;\n break;\n case 'integer':\n addType = Number.isFinite(val) && !(/** @type {number} */val % 1);\n break;\n case 'number':\n addType = Number.isFinite(val);\n break;\n case 'nonFinite':\n addType = typeof val === 'number' && !Number.isFinite(val);\n break;\n case 'object':\n addType = Boolean(val) && typeof val === valueType;\n break;\n case 'array':\n addType = Array.isArray(val);\n break;\n case 'other':\n addType = /** @type {OtherTypeCallback} */this.currOtherTypeCallback(val, path, parent, parentPropName, arg) || false;\n break;\n case 'null':\n addType = val === null;\n break;\n case 'symbol':\n addType = typeof val === 'symbol';\n break;\n case 'BigInt':\n addType = typeof val === 'bigint';\n break;\n case 'Promise':\n addType = toStringTag(val) === 'Promise';\n break;\n case 'jsonReference':\n addType = Boolean(val) && typeof val === 'object' && Object.hasOwn(/** @type {object} */val, '$ref');\n break;\n default:\n if (this.currCustomTypes && Object.hasOwn(this.currCustomTypes, valueType)) {\n addType = this.currCustomTypes[valueType](val, path, parent, parentPropName, arg) || false;\n } else {\n throw new TypeError('Unknown value type ' + valueType);\n }\n }\n if (addType) {\n retObj = {\n path,\n value: val,\n parent,\n parentProperty: parentPropName\n };\n this._handleCallback(retObj, callback, 'value');\n return retObj;\n }\n // `-escaped property\n } else if (val && loc[0] === '`' && Object.hasOwn(val, loc.slice(1))) {\n const locProp = loc.slice(1);\n const valObj = /** @type {Record<string, unknown>} */val;\n addRet(this._trace(x, valObj[locProp], push(path, locProp), val, locProp, callback, hasArrExpr, true));\n } else if (loc[0] === \"'\" || loc[0] === '\"') {\n // ['name1','name2',...]\n // Quoted members are literal property names\n for (const [, single, double] of loc.matchAll(/'((?:\\\\.|[^'\\\\])*)'|\"((?:\\\\.|[^\"\\\\])*)\"/gv)) {\n const prop = (single ?? double).replaceAll(/\\\\(['\"\\\\])/gv, '$1');\n if (!val || !Object.hasOwn(val, prop)) {\n continue;\n }\n const valObj = /** @type {Record<string, unknown>} */val;\n addRet(this._trace(x, valObj[prop], push(path, prop), val, prop, callback, true));\n }\n } else if (loc.includes(',')) {\n // [name1,name2,...]\n const parts = loc.split(',');\n for (const part of parts) {\n addRet(this._trace(unshift(part, x), val, path, parent, parentPropName, callback, true));\n }\n // simple case--directly follow property\n } else if (!literalPriority && val && Object.hasOwn(val, loc)) {\n const valObj = /** @type {Record<string, unknown>} */val;\n addRet(this._trace(x, valObj[loc], push(path, loc), val, loc, callback, hasArrExpr, true));\n }\n\n // We check the resulting values for parent selections. For parent\n // selections we discard the value object and continue the trace with\n // the current val object\n if (this._hasParentSelector) {\n for (let t = 0; t < ret.length; t++) {\n const rett = ret[t];\n if (!rett || !rett.isParentSelector) {\n continue;\n }\n const exprToUse = /** @type {ExpressionArray} */\n rett.expr;\n const pathToUse = /** @type {ExpressionArray} */\n rett.path;\n const tmp = this._trace(exprToUse, val, pathToUse, parent, parentPropName, callback, hasArrExpr);\n if (Array.isArray(tmp)) {\n ret[t] = tmp[0];\n const tl = tmp.length;\n for (let tt = 1; tt < tl; tt++) {\n t++;\n ret.splice(t, 0, tmp[tt]);\n }\n } else {\n ret[t] = tmp;\n }\n }\n }\n return ret;\n }\n\n /**\n * @param {unknown} val\n * @param {(prop: string|number) => void} f\n * @returns {void}\n */\n _walk(val, f) {\n if (Array.isArray(val)) {\n const n = val.length;\n for (let i = 0; i < n; i++) {\n f(i);\n }\n } else if (val && typeof val === 'object') {\n Object.keys(val).forEach(m => {\n f(m);\n });\n }\n }\n\n /**\n * @param {string} loc\n * @param {ExpressionArray} expr\n * @param {unknown} val\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {ParentProperty} parentPropName\n * @param {JSONPathCallback|undefined} callback\n * @returns {ReturnObject[]|undefined}\n */\n _slice(loc, expr, val, path, parent, parentPropName, callback) {\n if (!Array.isArray(val)) {\n return undefined;\n }\n const len = val.length,\n parts = loc.split(':'),\n step = parts[2] ? Number(parts[2]) : 1;\n /** @type {ReturnObject[]} */\n const ret = [];\n // A step of zero selects nothing (RFC 9535 section 2.3.4.2.2)\n if (step === 0) {\n return ret;\n }\n /**\n * @param {number} index\n * @returns {number}\n */\n const normalize = index => index < 0 ? index + len : index;\n // With a negative step the defaults run backwards: from the last\n // item to (and including) the first\n const start = normalize(parts[0] ? Number(parts[0]) : step > 0 ? 0 : len - 1),\n end = normalize(parts[1] ? Number(parts[1]) : step > 0 ? len : -len - 1);\n // The first and last positions to visit, whichever way we are going\n const [from, to] = step > 0 ? [Math.min(Math.max(start, 0), len), Math.min(Math.max(end, 0), len)] : [Math.min(Math.max(start, -1), len - 1), Math.min(Math.max(end, -1), len - 1)];\n for (let i = from; step > 0 ? i < to : i > to; i += step) {\n const tmp = this._trace(unshift(i, expr), val, path, parent, parentPropName, callback, true);\n // Should only be possible to be an array here since first part of\n // ``unshift(i, expr)` passed in above would not be empty,\n // nor `~`, nor begin with `@` (as could return objects)\n // This was causing excessive stack size in Node (with or\n // without Babel) against our performance test: `ret.push(...tmp);`\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next -- Unreachable: _trace returns array when expr non-empty */\n const tmpArray = Array.isArray(tmp) ? tmp : [tmp];\n tmpArray.forEach(t => {\n ret.push(t);\n });\n }\n return ret;\n }\n\n /**\n * @param {string} code\n * @param {unknown} _v\n * @param {string|number} _vname\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {ParentProperty} parentPropName\n * @returns {UnknownResult}\n */\n _eval(code, _v, _vname, path, parent, parentPropName) {\n if (this.currSandbox) {\n this.currSandbox._$_parentProperty = parentPropName;\n this.currSandbox._$_parent = parent;\n this.currSandbox._$_property = _vname;\n this.currSandbox._$_root = this.json;\n this.currSandbox._$_v = _v;\n }\n const containsPath = code.includes('@path');\n if (containsPath) {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next -- Unreachable: currSandbox set in evaluate() before _eval */\n const currSandbox = this.currSandbox ?? {};\n currSandbox._$_path = JSONPath.toPathString(/** @type {string[]} */path.concat([_vname]));\n }\n const scriptCacheKey = this.currEval + 'Script:' + code;\n if (!scriptCache.has(scriptCacheKey)) {\n // Replace `@parentProperty`, `@parent`, `@property`, `@root`,\n // `@path` and a bare `@` (not followed by an identifier\n // character) while leaving quoted string literals and\n // regex literals (a `/` where an operand is expected,\n // as opposed to division) intact\n const script = code.replaceAll(/('(?:\\\\.|[^'\\\\])*'|\"(?:\\\\.|[^\"\\\\])*\"|(?<=(?:^|[\\(,=:\\[!\\|?\\{\\};+\\-*%<>~^]|&)\\s*)\\/(?:\\\\.|\\[(?:\\\\.|[^\\]\\\\])*\\]|[^\\/\\\\\\[])+\\/[dgimsuvy]*)|@(?:(parentProperty|parent|property|root|path)|(?![\\w$]))/gv, (_, literal, name) => literal ?? '_$_' + (name ?? 'v'));\n const evalType = /** @type {string|boolean|undefined} */\n this.currEval;\n if (['safe', true, undefined].includes(evalType)) {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-disable unicorn/no-undeclared-class-members -- Prototype members */\n scriptCache.set(scriptCacheKey, new (\n /**\n * @type {JSONPathClass & {\n * safeVm: SafeScriptType,\n * vm: ScriptType\n * }}\n */ /** @type {unknown} */\n this).safeVm.Script(script));\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-enable unicorn/no-undeclared-class-members -- End prototype member scope */\n } else if (this.currEval === 'native') {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-disable unicorn/no-undeclared-class-members -- Prototype members */\n scriptCache.set(scriptCacheKey, new (\n /**\n * @type {JSONPathClass & {\n * safeVm: SafeScriptType,\n * vm: ScriptType\n * }}\n */ /** @type {unknown} */\n this).vm.Script(script));\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-enable unicorn/no-undeclared-class-members -- End prototype member scope */\n } else if (typeof this.currEval === 'function' && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, 'runInNewContext')) {\n const CurrEval = this.currEval;\n // eslint-disable-next-line @stylistic/max-len -- Long\n // @ts-expect-error - Type checked above to have proper constructor\n scriptCache.set(scriptCacheKey, new CurrEval(script));\n } else if (typeof this.currEval === 'function') {\n // Type narrowing: at this point currEval is a function\n // but not a constructor\n const evalFunc = /** @type {EvalCallback} */this.currEval;\n scriptCache.set(scriptCacheKey, {\n runInNewContext: (/** @type {ContextItem} */context) => evalFunc(script, context)\n });\n } else {\n throw new TypeError(`Unknown \"eval\" property \"${this.currEval}\"`);\n }\n }\n try {\n /**\n * @typedef {{\n * runInNewContext: (\n * ctx: SandboxType|undefined\n * ) => EvaluatedResult\n * }} RunInNewContext\n */\n\n return /** @type {RunInNewContext} */scriptCache.get(scriptCacheKey).runInNewContext(this.currSandbox);\n } catch (e) {\n if (this.ignoreEvalErrors) {\n return false;\n }\n const error = /** @type {Error} */e;\n throw new Error('jsonPath: ' + error.message + ': ' + code, {\n cause: e\n });\n }\n }\n}\n\n/** @type {{safeVm: SafeScriptType}} */\n(/** @type {unknown} */JSONPathClass.prototype).safeVm = {\n Script: SafeScript\n};\nJSONPath.prototype = JSONPathClass.prototype;\n\n// PUBLIC CLASS PROPERTIES AND METHODS\n\n/**\n * Clears cached parsed paths and compiled scripts.\n * @returns {void}\n */\nJSONPath.clearCache = function () {\n pathCache.clear();\n scriptCache.clear();\n};\n\n/**\n * @param {string[]} pathArr Array to convert\n * @returns {string} The path string\n */\nJSONPath.toPathString = function (pathArr) {\n const x = pathArr,\n n = x.length;\n let p = '$';\n for (let i = 1; i < n; i++) {\n if (!/^(~|\\^|@.*?\\(\\))$/v.test(x[i])) {\n p += /^[0-9*]+$/v.test(x[i]) ? '[' + x[i] + ']' : \"['\" + String(x[i]).replaceAll(/['\\\\]/gv, String.raw`\\$&`) + \"']\";\n }\n }\n return p;\n};\n\n/**\n * @param {string[]} pointer JSON Path array\n * @returns {string} JSON Pointer\n */\nJSONPath.toPointer = function (pointer) {\n const x = pointer,\n n = x.length;\n let p = '';\n for (let i = 1; i < n; i++) {\n if (!/^(~|\\^|@.*?\\(\\))$/v.test(x[i])) {\n p += '/' + x[i].toString().replaceAll('~', '~0').replaceAll('/', '~1');\n }\n }\n return p;\n};\n\n/**\n * @param {string} expr Expression to convert\n * @returns {string[]}\n */\nJSONPath.toPathArray = function (expr) {\n if (pathCache.has(expr)) {\n return /** @type {string[]} */pathCache.get(expr).concat();\n }\n /** @type {string[]} */\n const subx = [];\n const normalized = expr\n // Properties\n .replaceAll(/@[\\w$\\-]+\\([^\\)]*\\)/gv, ';$&;')\n // Parenthetical evaluations (filtering and otherwise), directly\n // within brackets or single quotes\n .replaceAll(/[\\['](\\??\\(.*?\\))[\\]'](?!.\\])/gv, function ($0, $1) {\n return '[#' + (\n // eslint-disable-next-line @stylistic/max-len -- Long\n // eslint-disable-next-line unicorn/no-return-array-push -- Optimization\n subx.push($1) - 1) + ']';\n })\n // Unions of quoted property names (e.g., `['x','y']`) and quoted\n // names with commas or backslash escapes, kept intact (with\n // quotes) so their members survive tokenization\n .replaceAll(/\\[\\s*((?:'(?:\\\\.|[^'\\\\])*'|\"(?:\\\\.|[^\"\\\\])*\")(?:\\s*,\\s*(?:'(?:\\\\.|[^'\\\\])*'|\"(?:\\\\.|[^\"\\\\])*\"))*)\\s*\\]/gv, function ($0, $1) {\n if (!/[,\\\\]/v.test($1)) {\n return $0;\n }\n // eslint-disable-next-line @stylistic/max-len -- Long\n // eslint-disable-next-line unicorn/no-return-array-push -- Optimization\n return '[#' + (subx.push($1) - 1) + ']';\n })\n // Escape periods and tildes within properties\n .replaceAll(/\\[['\"]([^'\\]]*)['\"]\\]/gv, function ($0, prop) {\n return \"['\" + prop.replaceAll('.', '%@%').replaceAll('~', '%%@@%%') + \"']\";\n })\n // Properties operator\n .replaceAll('~', ';~;')\n // Split by property boundaries\n .replaceAll(/['\"]?\\.['\"]?(?![^\\[]*\\])|\\[['\"]?/gv, ';')\n // Reinsert periods within properties\n .replaceAll('%@%', '.')\n // Reinsert tildes within properties\n .replaceAll('%%@@%%', '~')\n // Parent\n .replaceAll(/(?:;)?(\\^+)(?:;)?/gv, function ($0, ups) {\n return ';' + ups.split('').join(';') + ';';\n })\n // Descendents\n .replaceAll(/;;;|;;/gv, ';..;')\n // Remove trailing\n .replaceAll(/;$|'?\\]|'$/gv, '');\n const exprList = normalized.split(';').map(function (exp) {\n const match = exp.match(/#(\\d+)/v);\n return !match || !match[1] ? exp : subx[Number(match[1])];\n });\n pathCache.set(expr, exprList);\n return /** @type {string[]} */pathCache.get(expr).concat();\n};\n\n/**\n * @typedef {import('./jsonpath.js').AnyInput} AnyInput\n */\n/**\n * @typedef {import('./jsonpath.js').SandboxCallback} SandboxCallback\n */\n/**\n * @typedef {import('./jsonpath.js').SandboxPropertyValue} SandboxPropertyValue\n */\n/**\n * @typedef {import('./jsonpath.js').ExpressionArray} ExpressionArray\n */\n/**\n * @typedef {import('./jsonpath.js').ValueType} ValueType\n */\n/**\n * @typedef {import('./jsonpath.js').ParentValue} ParentValue\n */\n/**\n * @typedef {import('./jsonpath.js').UnknownResult} UnknownResult\n */\n/**\n * @typedef {import('./jsonpath.js').ParentProperty} ParentProperty\n */\n/**\n * @typedef {import('./jsonpath.js').PreferredOutput} PreferredOutput\n */\n/**\n * @typedef {import('./jsonpath.js').ReturnObject} ReturnObject\n */\n/**\n * @typedef {import('./jsonpath.js').JSONPathCallback} JSONPathCallback\n */\n/**\n * @typedef {import('./jsonpath.js').OtherTypeCallback} OtherTypeCallback\n */\n/**\n * @typedef {import('./jsonpath.js').ContextItem} ContextItem\n */\n/**\n * @typedef {import('./jsonpath.js').EvaluatedResult} EvaluatedResult\n */\n/**\n * @typedef {import('./jsonpath.js').EvalCallback} EvalCallback\n */\n/**\n * @typedef {import('./jsonpath.js').EvalClass} EvalClass\n */\n/**\n * @typedef {import('./jsonpath.js').ResultType} ResultType\n */\n/**\n * @typedef {import('./jsonpath.js').EvalValue} EvalValue\n */\n/**\n * @typedef {import('./jsonpath.js').PathType} PathType\n */\n/**\n * @typedef {import('./jsonpath.js').SafeScriptType} SafeScriptType\n */\n/**\n * @typedef {import('./jsonpath.js').ScriptType} ScriptType\n */\n/**\n * @typedef {import('./jsonpath.js').SandboxType} SandboxType\n */\n/**\n * @typedef {import('./jsonpath.js').JSONPathOptions} JSONPathOptions\n */\n\n// Node's vm module shape is wider than ScriptType, but is compatible for\n// the properties actually used (Script) -- kept Node-specific here so\n// `node:vm` types don't leak into the shared/browser declarations.\n/** @type {{vm: ScriptType}} */\n(/** @type {unknown} */JSONPathClass.prototype).vm = /** @type {ScriptType} */\n/** @type {unknown} */vm;\n\nexport { JSONPath, JSONPathClass };\n"],"ignoreList":[0],"mappings":";;;;;AAKA,IAAM,QAAN,MAAY;;;;;;;;;;;;;;;;;;;CAmBV,IAAI,MAAM,UAAU,OAAO;EACzB,IAAI,OAAO,UAAU,MAAM,UAEzB,KAAK,IAAI,QAAQ,UAAU,IACzB,KAAK,IAAI,MAAM,UAAU,EAAE,CAAC,OAAO,UAAU,EAAE;OAGjD,CAAC,MAAM,QAAQ,IAAI,IAAI,OAAO,CAAC,IAAI,EAAA,CAAG,QAAQ,SAAU,MAAM;GAC5D,KAAK,QAAQ,KAAK,SAAS,CAAC;GAC5B,IAAI,UACF,KAAK,KAAK,CAAC,QAAQ,YAAY,OAAO,CAAC,QAAQ;EAEnD,GAAG,IAAI;CAEX;;;;;;;;;;CAWA,IAAI,MAAM,KAAK;EACb,KAAK,QAAQ,KAAK,SAAS,CAAC;EAC5B,KAAK,KAAK,CAAC,QAAQ,SAAU,UAAU;GACrC,SAAS,KAAK,OAAO,IAAI,UAAU,IAAI,UAAU,KAAK,GAAG;EAC3D,CAAC;CACH;AACF;;;;AAKA,IAAM,UAAN,MAAc;CACZ,YAAY,MAAM;EAChB,KAAK,OAAO;EACZ,KAAK,aAAa,CAAC;CACrB;;;;;;;;;;;;;;CAeA,SAAS,GAAG,SAAS;EACnB,QAAQ,SAAQ,WAAU;GACxB,IAAI,OAAO,WAAW,YAAY,CAAC,OAAO,QAAQ,CAAC,OAAO,MACxD,MAAM,IAAI,MAAM,4B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O,MAAM,EAAE;CACzD,CAAC;CACD,UAAU,IAAI,MAAM,QAAQ;CAC5B,OAA8B,UAAU,IAAI,IAAI,CAAC,CAAC,OAAO;AAC3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,cAAqC,UAAW,KAC1B"}
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
- import { p as SessionOptions, t as Session } from "./session-DY9mF9Vb.mjs";
1
+ import { p as SessionOptions, t as Session } from "./session-WtXqtAaq.mjs";
2
+ import { AnyPart, AnyType, AssistantMessage, Attachment, CollectOptions, Content, FinishReason, Message, MetaOf, MetaPart, Model, ModelSpec, ParamsOf, ReasoningEffort, Role, StreamEvent, StreamOptions, TokenCount as TokenCount$1, Tool, ToolCallPart, ToolContext, ToolResult, ToolResultPart, Usage } from "@zaly/ai";
2
3
  import { Emitter, Envelope, MaybeGetter } from "@zaly/shared";
3
4
  import { BaseCollection } from "@zaly/shared/collection";
4
5
  import { AnyKey } from "@zaly/shared/registry";
5
- import { AnyPart, AnyType, AssistantMessage, Attachment, CollectOptions, Content, FinishReason, Message, MetaOf, MetaPart, Model, ParamsOf, ReasoningEffort, Role, StreamEvent, StreamOptions, TokenCount as TokenCount$1, Tool, ToolCallPart, ToolContext, ToolResult, ToolResultPart, Usage } from "@zaly/ai";
6
6
  import { Logger } from "@zaly/shared/logger";
7
7
  import { ArgsOpts, ArgsResult } from "@zaly/shared/args";
8
8
  /** Status of an agent session — at most one transition per moment.
@@ -1566,6 +1566,13 @@ export declare class Commands {
1566
1566
  get(name: string): Command | undefined;
1567
1567
  format(input: string | ArgsResult, cmd: Command): Promise<string>;
1568
1568
  }
1569
+ export type TokenContext = {
1570
+ reasoning?: ReasoningEffort | boolean;
1571
+ model?: ModelSpec;
1572
+ };
1573
+ export type MessageTokenContext = TokenContext & {
1574
+ message?: Message;
1575
+ };
1569
1576
  export type TokenCount = {
1570
1577
  type: AnyType | Message["role"] | "prompt" | "tool-schema" | "system-prompt";
1571
1578
  kind?: string;
@@ -1578,12 +1585,12 @@ export type TokenStats = {
1578
1585
  count: number;
1579
1586
  children?: Map<string, TokenStats>;
1580
1587
  };
1581
- export declare function estimatePart(p: AnyPart): TokenCount;
1588
+ export declare function estimatePart(p: AnyPart, ctx?: MessageTokenContext): TokenCount;
1582
1589
  export declare function tokenStats(msgs: readonly Message[], opts?: {
1583
1590
  prompt?: (string | Prompt<string>)[];
1584
1591
  tools?: Tool[];
1585
1592
  expand?: (c: TokenCount) => boolean;
1586
- }): TokenStats;
1593
+ } & TokenContext): TokenStats;
1587
1594
  export declare function formatTokenStats(s: TokenStats, indent?: number): string;
1588
1595
  export type { Agent, AgentContext, AgentContextEvents, AgentEvents, AgentInit, AgentOptions, AgentStatus, AgentStop, AgentStopKind, AnyScope, BashTool, BuiltinScope, CheckResult, ContextPressure, DoneTaskInfo, EditTool, EditToolMeta, FetchTool, FetchToolMeta, FileMeta, FileTool, FindTool, FindToolMeta, GrepTool, GrepToolMeta, PermissionContext, PermissionHandler, PermissionManager, PermissionOptions, PermissionPreset, PermissionPresetName, PermissionRequest, PermissionScope, PermissionScopes, PromptCollection, ReadTool, ReadToolMeta, Rule, SendMode, StepKind, StepResult, StopOptions, StopPolicy, Suggestion, TaskInfo, TaskMeta, TaskStatus, Tasks, TasksEvents, TokenUsage, ToolCollection, TurnResult, Verdict, WriteTool, WriteToolMeta, addUsage, createAgentContext, taskCompletionMessage, taskInfoPart };
1589
1596
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":["TokenCount","TokenCount","builtin","TokenCount","TokenCount","builtin"],"sources":["../src/events.ts","../src/masker.ts","../src/permissions/types.ts","../src/permissions/presets.ts","../src/permissions/manager.ts","../src/skills.ts","../src/swarm.ts","../src/ctx.ts","../src/tasks.ts","../src/utils/usage.ts","../src/agent.ts","../src/compaction/utils.ts","../src/compaction/compactions.ts","../src/notify.ts","../src/permissions/handlers/registry.ts","../src/stop.ts","../src/types.ts","../src/prompt/registry.ts","../src/tools/registry.ts","../src/tools/bash.ts","../src/tools/read.ts","../src/tools/edit.ts","../src/tools/fetch.ts","../src/tools/find.ts","../src/tools/grep.ts","../src/tools/write.ts","../src/utils/uuid.ts","../src/commands.ts","../src/context/tokens.ts"],"mappings":";;;;;;;;;;KAOY;;;KAIA;;;;KAcA;KAEA;EACV,MAAM;EACN;EACA,QAAQ;;;;;;;;KASE;EACV;IAAU,QAAQ;;EAClB;EACA;IAAkB,OAAO;;EACzB;IAAe,MAAM;;EACrB;IAAgB,OAAO;;EACvB;IAAiB,MAAM;IAAc,QAAQ;;EAC7C;IAAgB;;EAChB;IAAc;IAAc,SAAS;;EACrC;IAAgB;;EAChB;IAAc;IAAc,SAAS;IAAe;;EACpD,MAAM;IACJ,OAAOA;IACP,QAAQ;;EAEV;IACE;IACA;IACA;IACA,OAAO;IACP,UAAU;;EAEZ;IAAW,UAAU;;;;KClDX;EACV;;;;;EAKA;;;EAGA;;;EAGA;;EAEA;;KAGU;EACV;EACA;EACA;EACA,QAAQ;EACR;;;;;;;;;;;;;;;;;cA0BW;;EAOX,YAAY,OAAO,OAAO,OAAM,YAAY;MAWxC;EAoBJ;MAMI,SAAS,IAAI,MAAM;;MAKnB;EAIJ,SAAS,eAAe;;;;;;;EAalB,KAAK,mBAAmB,WAAW,OAAO,WAAW,QAAQ;;;;;;;;;;;;;;;;;;;KC5GzD;KAEA,KAAK;EACf,OAAO;EACP;EACA,QAAQ;;;;;;;;;;;;KAaE;EACN;EAAc;EAAe;EAAiB;;EAC9C;EAAmB;EAAc;;KAE3B;EACN;;EAEA;EACA;;;;;EAKA,cAAc;;EAGd;EACA;EACA;EACA,cAAc;;UAGH,kBAAkB;;;EAGjC,OAAO;;EAEP,aAAa;;EAEb,gBAAgB,KAAK;;;;;EAKrB;;;;EAIA;;;;;EAKA,WAAW,eAAe,kBAAkB;;UAG7B,kBAAkB;EAEjC,S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Q;;;;YA2HnB;KCxKU,kBAAkB;KAClB,eAAe;;EAEzB;;EAEA;;;;;;;;;;;;;;;;;;;;cAsBW,6BAAQ;;;;;;YAgDnB;KC1EU,mBAAmB;KACnB;EACV;EACA;EACA,eAAe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IAAc;IAAwB;IAAoB;;;;;;;;;;;;cAa/C,8BAAS;;;;;;;;;YAoLpB;KC5MU,kBAAkB;KAClB;EACV;EACA;EACA;EACA;;cAIW,6BAAQ;;;;;;YAiGnB;KCvGU,kBAAkB;KAClB;EACV;EACA;EACA;EACA;;cAIW,6BAAQ;;;;;;;YA2HnB;KCzIU,mBAAmB;KAEnB,gBAAgB;;;;EAI1B;;;;;;;;;;;;;;;;;cAmBW,8BAAS;;;YAgDpB;;;;;;;;;;;;wBCpEc;wBA+CA,SAAS;wBAIT,aAAa;YC3DjB;EACV;EACA;EACA;EACA;EACA,MAAM;;iBAGS;;EAEf;EACA,SAAS;;;;;EAKT;;EAEA;;qBAUW;;WAEF,SAAO,YAAA;EAGhB,YAAY,OAAM;EAKZ,QAAQ;EAMR,IAAI,eAAe;EAyCzB,IAAI,eAAe;EAIb,OAAO,gBAAgB,YAAY,KAAK,UAAU;;YC3F9C;EACV,MAAM,UAAU;EAChB;EACA;EACA,WAAW;;YAGD;EACV;EACA;EACA;EACA,WAAW,YAAY;;wBAsBT,aAAa,GAAG,UAAU;wBAgH1B,WACd,eAAe,WACf;EACE,mBAAmB;EACnB,QAAQ;EACR,UAAU,GAAG;IAEd;wBAoBa,iBAAiB,GAAG,YAAY"}
1
+ {"version":3,"file":"index.d.mts","names":["TokenCount","TokenCount","builtin","TokenCount","TokenCount","builtin"],"sources":["../src/events.ts","../src/masker.ts","../src/permissions/types.ts","../src/permissions/presets.ts","../src/permissions/manager.ts","../src/skills.ts","../src/swarm.ts","../src/ctx.ts","../src/tasks.ts","../src/utils/usage.ts","../src/agent.ts","../src/compaction/utils.ts","../src/compaction/compactions.ts","../src/notify.ts","../src/permissions/handlers/registry.ts","../src/stop.ts","../src/types.ts","../src/prompt/registry.ts","../src/tools/registry.ts","../src/tools/bash.ts","../src/tools/read.ts","../src/tools/edit.ts","../src/tools/fetch.ts","../src/tools/find.ts","../src/tools/grep.ts","../src/tools/write.ts","../src/utils/uuid.ts","../src/commands.ts","../src/context/tokens.ts"],"mappings":";;;;;;;;;;KAOY;;;KAIA;;;;KAcA;KAEA;EACV,MAAM;EACN;EACA,QAAQ;;;;;;;;KASE;EACV;IAAU,QAAQ;;EAClB;EACA;IAAkB,OAAO;;EACzB;IAAe,MAAM;;EACrB;IAAgB,OAAO;;EACvB;IAAiB,MAAM;IAAc,QAAQ;;EAC7C;IAAgB;;EAChB;IAAc;IAAc,SAAS;;EACrC;IAAgB;;EAChB;IAAc;IAAc,SAAS;IAAe;;EACpD,MAAM;IACJ,OAAOA;IACP,QAAQ;;EAEV;IACE;IACA;IACA;IACA,OAAO;IACP,UAAU;;EAEZ;IAAW,UAAU;;;;KClDX;EACV;;;;;EAKA;;;EAGA;;;EAGA;;EAEA;;KAGU;EACV;EACA;EACA;EACA,QAAQ;EACR;;;;;;;;;;;;;;;;;cA0BW;;EAOX,YAAY,OAAO,OAAO,OAAM,YAAY;MAWxC;EAoBJ;MAMI,SAAS,IAAI,MAAM;;MAKnB;EAIJ,SAAS,eAAe;;;;;;;EAalB,KAAK,mBAAmB,WAAW,OAAO,WAAW,QAAQ;;;;;;;;;;;;;;;;;;;KC5GzD;KAEA,KAAK;EACf,OAAO;EACP;EACA,QAAQ;;;;;;;;;;;;KAaE;EACN;EAAc;EAAe;EAAiB;;EAC9C;EAAmB;EAAc;;KAE3B;EACN;;EAEA;EACA;;;;;EAKA,cAAc;;EAGd;EACA;EACA;EACA,cAAc;;UAGH,kBAAkB;;;EAGjC,OAAO;;EAEP,aAAa;;EAEb,gBAAgB,KAAK;;;;;EAKrB;;;;EAIA;;;;;EAKA,WAAW,eAAe,kBAAkB;;UAG7B,kBAAkB;EAEj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UAAQ;;;;YA2HnB;KCxKU,kBAAkB;KAClB,eAAe;;EAEzB;;EAEA;;;;;;;;;;;;;;;;;;;;cAsBW,6BAAQ;;;;;;YAgDnB;KC1EU,mBAAmB;KACnB;EACV;EACA;EACA,eAAe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IAAc;IAAwB;IAAoB;;;;;;;;;;;;cAa/C,8BAAS;;;;;;;;;YAoLpB;KC5MU,kBAAkB;KAClB;EACV;EACA;EACA;EACA;;cAIW,6BAAQ;;;;;;YAiGnB;KCvGU,kBAAkB;KAClB;EACV;EACA;EACA;EACA;;cAIW,6BAAQ;;;;;;;YA2HnB;KCzIU,mBAAmB;KAEnB,gBAAgB;;;;EAI1B;;;;;;;;;;;;;;;;;cAmBW,8BAAS;;;YAgDpB;;;;;;;;;;;;wBCpEc;wBA+CA,SAAS;wBAIT,aAAa;YC3DjB;EACV;EACA;EACA;EACA;EACA,MAAM;;iBAGS;;EAEf;EACA,SAAS;;;;;EAKT;;EAEA;;qBAUW;;WAEF,SAAO,YAAA;EAGhB,YAAY,OAAM;EAKZ,QAAQ;EAMR,IAAI,eAAe;EAyCzB,IAAI,eAAe;EAIb,OAAO,gBAAgB,YAAY,KAAK,UAAU;;YClF9C;EACV,YAAY;EACZ,QAAQ;;YAGE,sBAAsB;EAChC,UAAU;;YAGA;EACV,MAAM,UAAU;EAChB;EACA;EACA,WAAW;;YAGD;EACV;EACA;EACA;EACA,WAAW,YAAY;;wBA8DT,aAAa,GAAG,SAAS,MAAK,sBAA2B;wBAqHzD,WACd,eAAe,WACf;EACE,mBAAmB;EACnB,QAAQ;EACR,UAAU,GAAG;IACX,eACH;wBAoBa,iBAAiB,GAAG,YAAY"}
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as extractConversation, c as formatFileUsage, d as Commands, f as toolCollection, g as createAgent, h as promptRegistry, i as extractBashUsage, l as messageTail, m as promptCollection, n as formatTokenStats, o as extractFileUsage, p as toolRegistry, r as tokenStats, s as formatBashUsage, t as estimatePart, u as Skills } from "./src-DJoqT9yP.mjs";
2
- import { t as handlerRegistry } from "./registry-CntkeXlo.mjs";
1
+ import { a as extractConversation, c as formatFileUsage, d as Commands, f as toolCollection, g as createAgent, h as promptRegistry, i as extractBashUsage, l as messageTail, m as promptCollection, n as formatTokenStats, o as extractFileUsage, p as toolRegistry, r as tokenStats, s as formatBashUsage, t as estimatePart, u as Skills } from "./src-Di-H3Oya.mjs";
2
+ import { t as handlerRegistry } from "./registry-7mJQhyBA.mjs";
3
3
  import { n as isUuidv7Like, r as uuidv7, t as isUuidv7 } from "./uuid-rfbQ9ad2.mjs";
4
4
  export { Commands, Skills, createAgent, estimatePart, extractBashUsage, extractConversation, extractFileUsage, formatBashUsage, formatFileUsage, formatTokenStats, handlerRegistry, isUuidv7, isUuidv7Like, messageTail, promptCollection, promptRegistry, tokenStats, toolCollection, toolRegistry, uuidv7 };
@@ -1,4 +1,4 @@
1
- import { t as handlerRegistry } from "./registry-CntkeXlo.mjs";
1
+ import { t as handlerRegistry } from "./registry-7mJQhyBA.mjs";
2
2
  import { normPath } from "@zaly/shared";
3
3
  // src/permissions/presets.ts
4
4
  /** Native tools that only inspect session state or workspace files. */
@@ -276,4 +276,4 @@ function parseRules(rules) {
276
276
  }
277
277
  export { PermissionManager };
278
278
 
279
- //# sourceMappingURL=manager-1zEE5WiA.mjs.map
279
+ //# sourceMappingURL=manager-CEociHy_.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"manager-1zEE5WiA.mjs","names":[],"sources":["../src/permissions/presets.ts","../src/permissions/manager.ts"],"sourcesContent":["import type { Verdict } from \"./types.ts\"\n\n/**\n * Permission presets — verdict-keyed pattern lists in the same shape\n * `parseRules` accepts. The TUI exposes these as `--preset strict`,\n * `--preset readonly`, etc.; the manager resolves the chosen preset to\n * the structured `Rule<string>[]` at construction.\n *\n * Pattern grammar:\n * \"bash(ls:*)\" → bash command pattern\n * \"read(/src/**)\" → workspace-relative gitignore pattern\n * \"read(*)\" → matches every read in any workspace\n * \"bash\" → bare scope, equivalent to `bash(*)` (match any cmd)\n *\n * Scope names are exact matches against the tool name they gate\n * (snake_case). Underscored scopes work too (`task_stop`, `task_poll`).\n */\nexport type PermissionPresetName = \"strict\" | \"readonly\" | \"permissive\" | \"yolo\"\n\nexport interface PermissionPreset {\n description: string\n rules: Partial<Record<Verdict, string[]>>\n}\n\n// ── Pattern groups ─────────────────────────────────────────────────────────\n\n/** Native tools that only inspect session state or workspace files. */\nconst READONLY_TOOLS = [\n \"tool(read)\",\n \"tool(grep)\",\n \"tool(find)\",\n \"tool(task_list)\",\n \"tool(task_poll)\",\n]\n\n/** Read-only utilities the model can run without surprises: file\n * inspection, search, metadata. None of these modify state on their own.\n * (`sed`/`awk` writes still gated by Write rules via the bash handler's\n * composition with the file handler.) */\nconst READONLY_BASH = [\n \"bash(ls:*)\",\n \"bash(cat:*)\",\n \"bash(head:*)\",\n \"bash(tail:*)\",\n \"bash(wc:*)\",\n \"bash(find:*)\",\n \"bash(grep:*)\",\n \"bash(rg:*)\",\n \"bash(fd:*)\",\n \"bash(sort:*)\",\n \"bash(uniq:*)\",\n \"bash(cut:*)\",\n \"bash(diff:*)\",\n \"bash(stat:*)\",\n \"bash(file:*)\",\n \"bash(realpath:*)\",\n \"bash(readlink:*)\",\n \"bash(basename:*)\",\n \"bash(dirname:*)\",\n \"bash(echo:*)\",\n \"bash(printf:*)\",\n \"bash(sed:*)\",\n \"bash(awk:*)\",\n \"bash(xxd:*)\",\n \"bash(hexdump:*)\",\n \"bash(od:*)\",\n \"bash(tree:*)\",\n \"bash(pwd)\",\n \"bash(true)\",\n \"bash(false)\",\n \"bash(which:*)\",\n \"bash(type:*)\",\n \"bash(command:*)\",\n \"bash(test:*)\",\n \"bash(cd:*)\",\n]\n\n/** Read-only git + GitHub CLI subcommands. */\nconst READONLY_GIT = [\n \"bash(git status:*)\",\n \"bash(git log:*)\",\n \"bash(git diff:*)\",\n \"bash(git show:*)\",\n \"bash(git show-ref:*)\",\n \"bash(git branch:*)\",\n \"bash(git remote:*)\",\n \"bash(git rev-parse:*)\",\n \"bash(git config --get:*)\",\n \"bash(gh issue list:*)\",\n \"bash(gh issue view:*)\",\n \"bash(gh pr list:*)\",\n \"bash(gh pr view:*)\",\n \"bash(gh repo view:*)\",\n]\n\n/** Common dev-workflow commands — build, test, typecheck. Excludes\n * package management (`npm install`, `bun add`) which can drag arbitrary\n * code in over the network. */\nconst DEV_BASIC = [\n \"bash(bun test:*)\",\n \"bash(bun test:node:*)\",\n \"bash(bun test:bun:*)\",\n \"bash(bun check:*)\",\n \"bash(bun run:*)\",\n \"bash(bun build:*)\",\n \"bash(bunx tsc:*)\",\n \"bash(bun tsc:*)\",\n \"bash(bun x tsc:*)\",\n \"bash(bunx vitest:*)\",\n \"bash(bun x vitest:*)\",\n \"bash(bunx oxlint:*)\",\n \"bash(bun x oxlint:*)\",\n \"bash(oxlint:*)\",\n]\n\n/** Hard denies — never auto-allowed, regardless of preset. */\nconst HARD_DENIES = [\"bash(sudo:*)\"]\n\n/** Broader rules unlocked by the permissive preset. Trades some safety\n * for speed — appropriate for frontier models with strong instruction\n * following. Includes ad-hoc bun/node evals and git mutations. */\nconst PERMISSIVE_EXTRAS = [\n \"bash(bun -e:*)\",\n \"bash(bun:*)\",\n \"bash(node:*)\",\n \"bash(node -e:*)\",\n \"bash(make:*)\",\n \"bash(mkdir:*)\",\n \"bash(cp:*)\",\n \"bash(mv:*)\",\n \"bash(touch:*)\",\n \"bash(ln:*)\",\n \"bash(chmod:*)\",\n \"bash(git add:*)\",\n \"bash(git commit:*)\",\n \"bash(git checkout:*)\",\n \"bash(git restore:*)\",\n \"bash(git stash:*)\",\n \"bash(git fetch:*)\",\n \"bash(git pull:*)\",\n \"bash(curl:*)\",\n \"bash(jq:*)\",\n \"bash(perl -e:*)\",\n \"bash(timeout:*)\",\n \"bash(for:*)\",\n \"bash(while:*)\",\n]\n\n// ── Presets ────────────────────────────────────────────────────────────────\n\n// oxlint-disable sort-keys\nexport const permissionPresets = {\n strict: {\n description: \"Ask for everything. No commands or file ops auto-allowed.\",\n rules: {\n deny: HARD_DENIES,\n // Override the tool/file handlers' default allows.\n ask: [\"tool(*)\", \"read(*)\", \"write(*)\"],\n },\n },\n readonly: {\n description:\n \"Auto-allow read-only utilities, git read-only ops, and common build/test commands. \" +\n \"Reads inside the workspace are allowed (sensitive paths denied); writes always ask.\",\n rules: {\n deny: HARD_DENIES,\n allow: [...READONLY_TOOLS, ...READONLY_BASH, ...READONLY_GIT, ...DEV_BASIC],\n ask: [\"tool(*)\", \"write(*)\"],\n },\n },\n permissive: {\n description:\n \"Readonly preset plus broader dev commands (file moves, ad-hoc bun/node evals, \" +\n \"git mutations, network fetches) and writes inside the workspace.\",\n rules: {\n deny: HARD_DENIES,\n allow: [\n \"tool(*)\",\n ...READONLY_BASH,\n ...READONLY_GIT,\n ...DEV_BASIC,\n ...PERMISSIVE_EXTRAS,\n // Allow writes inside any workspace (sensitive paths still denied\n // by the file handler before rule resolution).\n \"write(*)\",\n ],\n },\n },\n yolo: {\n description: \"Allow everything. No prompts. Use only when you trust the model and the task.\",\n rules: {\n allow: [\"bash\", \"read(*)\", \"write(*)\", \"tool(*)\"],\n },\n },\n} as const satisfies Record<PermissionPresetName, PermissionPreset>\n","import type { PermissionPresetName } from \"./presets.ts\"\nimport type { CheckResult, Rule, Verdict } from \"./types.ts\"\n\nimport { normPath } from \"@zaly/shared\"\nimport { handlerRegistry } from \"./handlers/registry.ts\"\nimport { permissionPresets } from \"./presets.ts\"\n\nexport type PermissionOptions = {\n /** Session cwd — anchor for resolving relative paths and the default\n * spawn cwd for bash subprocesses. Pinned at construction; the agent\n * never mutates `process.cwd()`, and there's no `cd` tool. Defaults\n * to `process.cwd()`. */\n cwd?: string\n /** Named preset — supplies a baseline rule set. Explicit `rules` win\n * over preset rules on conflict (first-match-wins resolution; user\n * rules are listed before preset rules at construction). */\n preset?: PermissionPresetName\n rules?: Rule[] | Partial<Record<Verdict, string[] | undefined>>\n /** Initial workspace list. `cwd` is auto-added so the user doesn't\n * have to repeat it. Pass paths absolute (or relative — they'll be\n * resolved against `cwd`). */\n workspaces?: readonly string[]\n}\n\n/**\n * Owns per-session permission state and dispatches `validate(scope, input)`\n * to the registered handler for `scope`. Handlers receive rules\n * pre-filtered to their scope plus the shared workspace list.\n *\n * Mutators (`addWorkspace`, `addRule`, …) are how the prompt UI promotes\n * an `ask` verdict — once the user picks \"allow `Bash(git push:*)` for\n * this session\", the TUI calls `manager.addRule(...)` and subsequent\n * `validate()` calls pick it up via the filter.\n */\nexport class PermissionManager {\n readonly cwd: string\n #rules: Rule[] = []\n #workspaces: string[]\n\n constructor(opts?: PermissionOptions) {\n this.cwd = normPath(opts?.cwd)\n if (opts?.rules) {\n const more = Array.isArray(opts.rules) ? opts.rules : parseRules(opts.rules)\n this.#rules.push(...more)\n }\n if (opts?.preset) this.#rules.push(...parseRules(permissionPresets[opts.preset].rules))\n this.#workspaces = (opts?.workspaces ?? []).map((p) => normPath(this.cwd, p))\n // Auto-include cwd so users don't have to repeat it. Listed first so\n // longest-prefix lookup in handlers stays predictable.\n if (!this.#workspaces.includes(this.cwd)) this.#workspaces.unshift(this.cwd)\n }\n\n // ── Workspaces ──────────────────────────────────────────────────────\n\n get workspaces(): readonly string[] {\n return this.#workspaces\n }\n\n addWorkspace(path: string): void {\n const abs = normPath(this.cwd, path)\n if (!this.#workspaces.includes(abs)) this.#workspaces.push(abs)\n }\n\n removeWorkspace(path: string): void {\n const abs = normPath(this.cwd, path)\n const i = this.#workspaces.indexOf(abs)\n if (i !== -1) this.#workspaces.splice(i, 1)\n }\n\n // ── Rules ───────────────────────────────────────────────────────────\n\n get rules(): readonly Rule[] {\n return this.#rules\n }\n\n /** Rules whose scope has no registered handler — surfaces config\n * errors (typos, unknown scopes, malformed pattern strings). The TUI\n * can render these as a startup warning. */\n get invalidRules(): readonly Rule[] {\n return this.#rules.filter((r) => !handlerRegistry.has(r.scope))\n }\n\n addRule(rule: Rule): void {\n this.#rules.unshift(rule)\n }\n\n // ── Dispatch ────────────────────────────────────────────────────────\n\n /** True only when a blanket allow has no earlier restrictive exceptions. */\n allowsAll(scope: string): boolean {\n for (const rule of this.#rules) {\n if (rule.scope !== scope) continue\n if (rule.policy !== \"allow\") return false\n if (rule.pattern === \"*\") return true\n }\n return false\n }\n\n validate(scope: string, input: string): CheckResult {\n if (!handlerRegistry.has(scope)) {\n throw new Error(`no permission handler registered for scope \"${scope}\"`)\n }\n const handler = handlerRegistry.load(scope)\n const rules = this.#rules.filter((r) => r.scope === scope)\n return handler.validate(input, {\n allowsAll: this.allowsAll.bind(this),\n cwd: this.cwd,\n rules,\n scope,\n validate: this.validate.bind(this),\n workspaces: this.#workspaces,\n })\n }\n}\n\n/** Parse Claude-Code-style permission config (a verdict-keyed map of\n * pattern strings) into structured `Rule<string>[]`.\n *\n * Pattern shapes accepted:\n * \"Bash(ls:*)\" → { scope: \"bash\", pattern: \"ls:*\" }\n * \"WebSearch\" → { scope: \"websearch\", pattern: \"*\" } // bare name = scope-wide\n *\n * Scopes are normalized to lower-case so config can use either\n * TitleCase (\"Bash\") or lowercase (\"bash\") interchangeably.\n *\n * Malformed entries are pushed verbatim so `manager.invalidRules`\n * surfaces them — typos in the scope (\"Bahs(...)\") are caught the same\n * way (no handler registered → flagged invalid). */\nexport function parseRules(rules: Partial<Record<Verdict, string[] | undefined>>): Rule[] {\n const ret: Rule[] = []\n for (const policy of Object.keys(rules) as Verdict[]) {\n const patterns = rules[policy]\n if (!Array.isArray(patterns)) continue\n for (const raw of patterns) {\n const m = raw.match(/^(\\w+)(?:\\((.+)\\))?$/)\n if (m) {\n const [, scope, pat = \"*\"] = m\n ret.push({ pattern: pat, policy, scope: scope.toLowerCase() })\n } else {\n // Truly malformed — preserve verbatim so invalidRules surfaces it.\n ret.push({ pattern: raw, policy, scope: \"invalid\" })\n }\n }\n }\n return ret\n}\n"],"mappings":";;;;AA2BA,MAAM,iBAAiB;CACrB;CACA;CACA;CACA;CACA;AACF;;;;;AAMA,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;AAKA,MAAM,YAAY;CAChB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAM,cAAc,CAAC,cAAc;;;;AAKnC,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAKA,MAAa,oBAAoB;CAC/B,QAAQ;EACN,aAAa;EACb,OAAO;GACL,MAAM;GAEN,KAAK;IAAC;IAAW;IAAW;GAAU;EACxC;CACF;CACA,UAAU;EACR,aACE;EAEF,OAAO;GACL,MAAM;GACN,OAAO;IAAC,GAAG;IAAgB,GAAG;IAAe,GAAG;IAAc,GAAG;GAAS;GAC1E,KAAK,CAAC,WAAW,UAAU;EAC7B;CACF;CACA,YAAY;EACV,aACE;EAEF,OAAO;GACL,MAAM;GACN,OAAO;IACL;IACA,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IAGH;GACF;EACF;CACF;CACA,MAAM;EACJ,aAAa;EACb,OAAO,EACL,OAAO;GAAC;GAAQ;GAAW;GAAY;EAAS,EAClD;CACF;AACF;;;;;;;;;;;;AChKA,IAAa,oBAAb,MAA+B;CAC7B;CACA,SAAiB,CAAC;CAClB;CAEA,YAAY,MAA0B;EACpC,KAAK,MAAM,SAAS,MAAM,GAAG;EAC7B,IAAI,MAAM,OAAO;G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+CAA+C,MAAM,EAAE;EAEzE,MAAM,UAAU,gBAAgB,KAAK,KAAK;EAC1C,MAAM,QAAQ,KAAK,OAAO,QAAQ,MAAM,EAAE,UAAU,KAAK;EACzD,OAAO,QAAQ,SAAS,OAAO;GAC7B,WAAW,KAAK,UAAU,KAAK,IAAI;GACnC,KAAK,KAAK;GACV;GACA;GACA,UAAU,KAAK,SAAS,KAAK,IAAI;GACjC,YAAY,KAAK;EACnB,CAAC;CACH;AACF;;;;;;;;;;;;;;AAeA,SAAgB,WAAW,OAA+D;CACxF,MAAM,MAAc,CAAC;CACrB,KAAK,MAAM,UAAU,OAAO,KAAK,KAAK,GAAgB;EACpD,MAAM,WAAW,MAAM;EACvB,IAAI,CAAC,MAAM,QAAQ,QAAQ,GAAG;EAC9B,KAAK,MAAM,OAAO,UAAU;GAC1B,MAAM,IAAI,IAAI,MAAM,sBAAsB;GAC1C,IAAI,GAAG;IACL,MAAM,GAAG,OAAO,MAAM,OAAO;IAC7B,IAAI,KAAK;KAAE,SAAS;KAAK;KAAQ,OAAO,MAAM,YAAY;IAAE,CAAC;GAC/D,OAEE,IAAI,KAAK;IAAE,SAAS;IAAK;IAAQ,OAAO;GAAU,CAAC;EAEvD;CACF;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"manager-CEociHy_.mjs","names":[],"sources":["../src/permissions/presets.ts","../src/permissions/manager.ts"],"sourcesContent":["import type { Verdict } from \"./types.ts\"\n\n/**\n * Permission presets — verdict-keyed pattern lists in the same shape\n * `parseRules` accepts. The TUI exposes these as `--preset strict`,\n * `--preset readonly`, etc.; the manager resolves the chosen preset to\n * the structured `Rule<string>[]` at construction.\n *\n * Pattern grammar:\n * \"bash(ls:*)\" → bash command pattern\n * \"read(/src/**)\" → workspace-relative gitignore pattern\n * \"read(*)\" → matches every read in any workspace\n * \"bash\" → bare scope, equivalent to `bash(*)` (match any cmd)\n *\n * Scope names are exact matches against the tool name they gate\n * (snake_case). Underscored scopes work too (`task_stop`, `task_poll`).\n */\nexport type PermissionPresetName = \"strict\" | \"readonly\" | \"permissive\" | \"yolo\"\n\nexport interface PermissionPreset {\n description: string\n rules: Partial<Record<Verdict, string[]>>\n}\n\n// ── Pattern groups ─────────────────────────────────────────────────────────\n\n/** Native tools that only inspect session state or workspace files. */\nconst READONLY_TOOLS = [\n \"tool(read)\",\n \"tool(grep)\",\n \"tool(find)\",\n \"tool(task_list)\",\n \"tool(task_poll)\",\n]\n\n/** Read-only utilities the model can run without surprises: file\n * inspection, search, metadata. None of these modify state on their own.\n * (`sed`/`awk` writes still gated by Write rules via the bash handler's\n * composition with the file handler.) */\nconst READONLY_BASH = [\n \"bash(ls:*)\",\n \"bash(cat:*)\",\n \"bash(head:*)\",\n \"bash(tail:*)\",\n \"bash(wc:*)\",\n \"bash(find:*)\",\n \"bash(grep:*)\",\n \"bash(rg:*)\",\n \"bash(fd:*)\",\n \"bash(sort:*)\",\n \"bash(uniq:*)\",\n \"bash(cut:*)\",\n \"bash(diff:*)\",\n \"bash(stat:*)\",\n \"bash(file:*)\",\n \"bash(realpath:*)\",\n \"bash(readlink:*)\",\n \"bash(basename:*)\",\n \"bash(dirname:*)\",\n \"bash(echo:*)\",\n \"bash(printf:*)\",\n \"bash(sed:*)\",\n \"bash(awk:*)\",\n \"bash(xxd:*)\",\n \"bash(hexdump:*)\",\n \"bash(od:*)\",\n \"bash(tree:*)\",\n \"bash(pwd)\",\n \"bash(true)\",\n \"bash(false)\",\n \"bash(which:*)\",\n \"bash(type:*)\",\n \"bash(command:*)\",\n \"bash(test:*)\",\n \"bash(cd:*)\",\n]\n\n/** Read-only git + GitHub CLI subcommands. */\nconst READONLY_GIT = [\n \"bash(git status:*)\",\n \"bash(git log:*)\",\n \"bash(git diff:*)\",\n \"bash(git show:*)\",\n \"bash(git show-ref:*)\",\n \"bash(git branch:*)\",\n \"bash(git remote:*)\",\n \"bash(git rev-parse:*)\",\n \"bash(git config --get:*)\",\n \"bash(gh issue list:*)\",\n \"bash(gh issue view:*)\",\n \"bash(gh pr list:*)\",\n \"bash(gh pr view:*)\",\n \"bash(gh repo view:*)\",\n]\n\n/** Common dev-workflow commands — build, test, typecheck. Excludes\n * package management (`npm install`, `bun add`) which can drag arbitrary\n * code in over the network. */\nconst DEV_BASIC = [\n \"bash(bun test:*)\",\n \"bash(bun test:node:*)\",\n \"bash(bun test:bun:*)\",\n \"bash(bun check:*)\",\n \"bash(bun run:*)\",\n \"bash(bun build:*)\",\n \"bash(bunx tsc:*)\",\n \"bash(bun tsc:*)\",\n \"bash(bun x tsc:*)\",\n \"bash(bunx vitest:*)\",\n \"bash(bun x vitest:*)\",\n \"bash(bunx oxlint:*)\",\n \"bash(bun x oxlint:*)\",\n \"bash(oxlint:*)\",\n]\n\n/** Hard denies — never auto-allowed, regardless of preset. */\nconst HARD_DENIES = [\"bash(sudo:*)\"]\n\n/** Broader rules unlocked by the permissive preset. Trades some safety\n * for speed — appropriate for frontier models with strong instruction\n * following. Includes ad-hoc bun/node evals and git mutations. */\nconst PERMISSIVE_EXTRAS = [\n \"bash(bun -e:*)\",\n \"bash(bun:*)\",\n \"bash(node:*)\",\n \"bash(node -e:*)\",\n \"bash(make:*)\",\n \"bash(mkdir:*)\",\n \"bash(cp:*)\",\n \"bash(mv:*)\",\n \"bash(touch:*)\",\n \"bash(ln:*)\",\n \"bash(chmod:*)\",\n \"bash(git add:*)\",\n \"bash(git commit:*)\",\n \"bash(git checkout:*)\",\n \"bash(git restore:*)\",\n \"bash(git stash:*)\",\n \"bash(git fetch:*)\",\n \"bash(git pull:*)\",\n \"bash(curl:*)\",\n \"bash(jq:*)\",\n \"bash(perl -e:*)\",\n \"bash(timeout:*)\",\n \"bash(for:*)\",\n \"bash(while:*)\",\n]\n\n// ── Presets ────────────────────────────────────────────────────────────────\n\n// oxlint-disable sort-keys\nexport const permissionPresets = {\n strict: {\n description: \"Ask for everything. No commands or file ops auto-allowed.\",\n rules: {\n deny: HARD_DENIES,\n // Override the tool/file handlers' default allows.\n ask: [\"tool(*)\", \"read(*)\", \"write(*)\"],\n },\n },\n readonly: {\n description:\n \"Auto-allow read-only utilities, git read-only ops, and common build/test commands. \" +\n \"Reads inside the workspace are allowed (sensitive paths denied); writes always ask.\",\n rules: {\n deny: HARD_DENIES,\n allow: [...READONLY_TOOLS, ...READONLY_BASH, ...READONLY_GIT, ...DEV_BASIC],\n ask: [\"tool(*)\", \"write(*)\"],\n },\n },\n permissive: {\n description:\n \"Readonly preset plus broader dev commands (file moves, ad-hoc bun/node evals, \" +\n \"git mutations, network fetches) and writes inside the workspace.\",\n rules: {\n deny: HARD_DENIES,\n allow: [\n \"tool(*)\",\n ...READONLY_BASH,\n ...READONLY_GIT,\n ...DEV_BASIC,\n ...PERMISSIVE_EXTRAS,\n // Allow writes inside any workspace (sensitive paths still denied\n // by the file handler before rule resolution).\n \"write(*)\",\n ],\n },\n },\n yolo: {\n description: \"Allow everything. No prompts. Use only when you trust the model and the task.\",\n rules: {\n allow: [\"bash\", \"read(*)\", \"write(*)\", \"tool(*)\"],\n },\n },\n} as const satisfies Record<PermissionPresetName, PermissionPreset>\n","import type { PermissionPresetName } from \"./presets.ts\"\nimport type { CheckResult, Rule, Verdict } from \"./types.ts\"\n\nimport { normPath } from \"@zaly/shared\"\nimport { handlerRegistry } from \"./handlers/registry.ts\"\nimport { permissionPresets } from \"./presets.ts\"\n\nexport type PermissionOptions = {\n /** Session cwd — anchor for resolving relative paths and the default\n * spawn cwd for bash subprocesses. Pinned at construction; the agent\n * never mutates `process.cwd()`, and there's no `cd` tool. Defaults\n * to `process.cwd()`. */\n cwd?: string\n /** Named preset — supplies a baseline rule set. Explicit `rules` win\n * over preset rules on conflict (first-match-wins resolution; user\n * rules are listed before preset rules at construction). */\n preset?: PermissionPresetName\n rules?: Rule[] | Partial<Record<Verdict, string[] | undefined>>\n /** Initial workspace list. `cwd` is auto-added so the user doesn't\n * have to repeat it. Pass paths absolute (or relative — they'll be\n * resolved against `cwd`). */\n workspaces?: readonly string[]\n}\n\n/**\n * Owns per-session permission state and dispatches `validate(scope, input)`\n * to the registered handler for `scope`. Handlers receive rules\n * pre-filtered to their scope plus the shared workspace list.\n *\n * Mutators (`addWorkspace`, `addRule`, …) are how the prompt UI promotes\n * an `ask` verdict — once the user picks \"allow `Bash(git push:*)` for\n * this session\", the TUI calls `manager.addRule(...)` and subsequent\n * `validate()` calls pick it up via the filter.\n */\nexport class PermissionManager {\n readonly cwd: string\n #rules: Rule[] = []\n #workspaces: string[]\n\n constructor(opts?: PermissionOptions) {\n this.cwd = normPath(opts?.cwd)\n if (opts?.rules) {\n const more = Array.isArray(opts.rules) ? opts.rules : parseRules(opts.rules)\n this.#rules.push(...more)\n }\n if (opts?.preset) this.#rules.push(...parseRules(permissionPresets[opts.preset].rules))\n this.#workspaces = (opts?.workspaces ?? []).map((p) => normPath(this.cwd, p))\n // Auto-include cwd so users don't have to repeat it. Listed first so\n // longest-prefix lookup in handlers stays predictable.\n if (!this.#workspaces.includes(this.cwd)) this.#workspaces.unshift(this.cwd)\n }\n\n // ── Workspaces ──────────────────────────────────────────────────────\n\n get workspaces(): readonly string[] {\n return this.#workspaces\n }\n\n addWorkspace(path: string): void {\n const abs = normPath(this.cwd, path)\n if (!this.#workspaces.includes(abs)) this.#workspaces.push(abs)\n }\n\n removeWorkspace(path: string): void {\n const abs = normPath(this.cwd, path)\n const i = this.#workspaces.indexOf(abs)\n if (i !== -1) this.#workspaces.splice(i, 1)\n }\n\n // ── Rules ───────────────────────────────────────────────────────────\n\n get rules(): readonly Rule[] {\n return this.#rules\n }\n\n /** Rules whose scope has no registered handler — surfaces config\n * errors (typos, unknown scopes, malformed pattern strings). The TUI\n * can render these as a startup warning. */\n get invalidRules(): readonly Rule[] {\n return this.#rules.filter((r) => !handlerRegistry.has(r.scope))\n }\n\n addRule(rule: Rule): void {\n this.#rules.unshift(rule)\n }\n\n // ── Dispatch ────────────────────────────────────────────────────────\n\n /** True only when a blanket allow has no earlier restrictive exceptions. */\n allowsAll(scope: string): boolean {\n for (const rule of this.#rules) {\n if (rule.scope !== scope) continue\n if (rule.policy !== \"allow\") return false\n if (rule.pattern === \"*\") return true\n }\n return false\n }\n\n validate(scope: string, input: string): CheckResult {\n if (!handlerRegistry.has(scope)) {\n throw new Error(`no permission handler registered for scope \"${scope}\"`)\n }\n const handler = handlerRegistry.load(scope)\n const rules = this.#rules.filter((r) => r.scope === scope)\n return handler.validate(input, {\n allowsAll: this.allowsAll.bind(this),\n cwd: this.cwd,\n rules,\n scope,\n validate: this.validate.bind(this),\n workspaces: this.#workspaces,\n })\n }\n}\n\n/** Parse Claude-Code-style permission config (a verdict-keyed map of\n * pattern strings) into structured `Rule<string>[]`.\n *\n * Pattern shapes accepted:\n * \"Bash(ls:*)\" → { scope: \"bash\", pattern: \"ls:*\" }\n * \"WebSearch\" → { scope: \"websearch\", pattern: \"*\" } // bare name = scope-wide\n *\n * Scopes are normalized to lower-case so config can use either\n * TitleCase (\"Bash\") or lowercase (\"bash\") interchangeably.\n *\n * Malformed entries are pushed verbatim so `manager.invalidRules`\n * surfaces them — typos in the scope (\"Bahs(...)\") are caught the same\n * way (no handler registered → flagged invalid). */\nexport function parseRules(rules: Partial<Record<Verdict, string[] | undefined>>): Rule[] {\n const ret: Rule[] = []\n for (const policy of Object.keys(rules) as Verdict[]) {\n const patterns = rules[policy]\n if (!Array.isArray(patterns)) continue\n for (const raw of patterns) {\n const m = raw.match(/^(\\w+)(?:\\((.+)\\))?$/)\n if (m) {\n const [, scope, pat = \"*\"] = m\n ret.push({ pattern: pat, policy, scope: scope.toLowerCase() })\n } else {\n // Truly malformed — preserve verbatim so invalidRules surfaces it.\n ret.push({ pattern: raw, policy, scope: \"invalid\" })\n }\n }\n }\n return ret\n}\n"],"mappings":";;;;AA2BA,MAAM,iBAAiB;CACrB;CACA;CACA;CACA;CACA;AACF;;;;;AAMA,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;AAKA,MAAM,YAAY;CAChB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAM,cAAc,CAAC,cAAc;;;;AAKnC,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAKA,MAAa,oBAAoB;CAC/B,QAAQ;EACN,aAAa;EACb,OAAO;GACL,MAAM;GAEN,KAAK;IAAC;IAAW;IAAW;GAAU;EACxC;CACF;CACA,UAAU;EACR,aACE;EAEF,OAAO;GACL,MAAM;GACN,OAAO;IAAC,GAAG;IAAgB,GAAG;IAAe,GAAG;IAAc,GAAG;GAAS;GAC1E,KAAK,CAAC,WAAW,UAAU;EAC7B;CACF;CACA,YAAY;EACV,aACE;EAEF,OAAO;GACL,MAAM;GACN,OAAO;IACL;IACA,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IAGH;GACF;EACF;CACF;CACA,MAAM;EACJ,aAAa;EACb,OAAO,EACL,OAAO;GAAC;GAAQ;GAAW;GAAY;EAAS,EAClD;CACF;AACF;;;;;;;;;;;;AChKA,IAAa,oBAAb,MAA+B;CAC7B;CACA,SAAiB,CAAC;CAClB;CAEA,YAAY,MAA0B;EACpC,KAAK,MAAM,SAAS,MAAM,GAAG;EAC7B,IAAI,MAAM,OAAO;GACf,MAAM,OAAO,MAAM,QAAQ,KAAK,KAAK,IAAI,KAAK,QAAQ,WAAW,KAAK,KAAK;GAC3E,KAAK,OAAO,KAAK,GAAG,IAAI;EAC1B;EACA,IAAI,MAAM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