@probelabs/probe 0.6.0-rc233 → 0.6.0-rc235

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.
@@ -9401,7 +9401,7 @@ Manage tasks for tracking progress during code exploration and problem-solving.
9401
9401
 
9402
9402
  Parameters:
9403
9403
  - action: (required) The action to perform: create, update, complete, delete, list
9404
- - tasks: (optional) JSON array for batch operations - alternative to single-task params
9404
+ - tasks: (optional) Array of task objects for batch operations. Place raw JSON array directly between tags.
9405
9405
  - id: (optional) Task ID for single operations (e.g., "task-1")
9406
9406
  - title: (optional) Task title for create/update
9407
9407
  - description: (optional) Task description for create/update
@@ -9410,6 +9410,11 @@ Parameters:
9410
9410
  - dependencies: (optional) JSON array of task IDs that must be completed first
9411
9411
  - after: (optional) Task ID to insert the new task after (for ordering). By default, new tasks are appended to the end
9412
9412
 
9413
+ IMPORTANT - JSON Format:
9414
+ Place raw JSON arrays directly between tags without quotes or escaping:
9415
+ CORRECT: <tasks>[{"title": "Do X"}]</tasks>
9416
+ INCORRECT: <tasks>"[{"title": "Do X"}]"</tasks>
9417
+
9413
9418
  Usage Examples:
9414
9419
 
9415
9420
  Creating a single task:
@@ -12397,6 +12402,8 @@ var require_utils = __commonJS({
12397
12402
  var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {
12398
12403
  }).constructor;
12399
12404
  var SandboxGlobal = function SandboxGlobal2(globals) {
12405
+ if (globals === globalThis)
12406
+ return globalThis;
12400
12407
  for (const i in globals) {
12401
12408
  this[i] = globals[i];
12402
12409
  }
@@ -12425,9 +12432,7 @@ var require_utils = __commonJS({
12425
12432
  prototypeWhitelist: new Map([...options.prototypeWhitelist].map((a) => [a[0].prototype, a[1]])),
12426
12433
  options,
12427
12434
  globalScope: new Scope3(null, options.globals, sandboxGlobal),
12428
- sandboxGlobal,
12429
- ticks: { ticks: 0n, tickLimit: options.executionQuota },
12430
- sandboxedFunctions: /* @__PURE__ */ new WeakSet()
12435
+ sandboxGlobal
12431
12436
  };
12432
12437
  context.prototypeWhitelist.set(Object.getPrototypeOf([][Symbol.iterator]()), /* @__PURE__ */ new Set());
12433
12438
  return context;
@@ -12442,15 +12447,9 @@ var require_utils = __commonJS({
12442
12447
  evals.set(AsyncFunction, asyncFunc);
12443
12448
  evals.set(GeneratorFunction, func);
12444
12449
  evals.set(AsyncGeneratorFunction, asyncFunc);
12445
- evals.set(eval, evalContext.sandboxedEval(func, execContext));
12446
- evals.set(setTimeout, evalContext.sandboxedSetTimeout(func, execContext));
12447
- evals.set(setInterval, evalContext.sandboxedSetInterval(func, execContext));
12448
- evals.set(clearTimeout, evalContext.sandboxedClearTimeout(execContext));
12449
- evals.set(clearInterval, evalContext.sandboxedClearInterval(execContext));
12450
- for (const [key, value] of evals) {
12451
- sandbox.context.prototypeWhitelist.set(value.prototype, /* @__PURE__ */ new Set());
12452
- sandbox.context.prototypeWhitelist.set(key.prototype, /* @__PURE__ */ new Set());
12453
- }
12450
+ evals.set(eval, evalContext.sandboxedEval(func));
12451
+ evals.set(setTimeout, evalContext.sandboxedSetTimeout(func));
12452
+ evals.set(setInterval, evalContext.sandboxedSetInterval(func));
12454
12453
  }
12455
12454
  return execContext;
12456
12455
  }
@@ -12547,45 +12546,34 @@ var require_utils = __commonJS({
12547
12546
  return ret;
12548
12547
  }
12549
12548
  var reservedWords2 = /* @__PURE__ */ new Set([
12550
- "await",
12551
- "break",
12552
- "case",
12553
- "catch",
12554
- "class",
12555
- "const",
12556
- "continue",
12557
- "debugger",
12558
- "default",
12559
- "delete",
12560
- "do",
12561
- "else",
12562
- "enum",
12563
- "export",
12564
- "extends",
12565
- "false",
12566
- "finally",
12567
- "for",
12568
- "function",
12569
- "if",
12570
- "implements",
12571
- "import",
12572
- "in",
12573
12549
  "instanceof",
12574
- "let",
12575
- "new",
12576
- "null",
12550
+ "typeof",
12577
12551
  "return",
12578
- "super",
12579
- "switch",
12580
- "this",
12581
12552
  "throw",
12582
- "true",
12583
12553
  "try",
12584
- "typeof",
12554
+ "catch",
12555
+ "if",
12556
+ "finally",
12557
+ "else",
12558
+ "in",
12559
+ "of",
12585
12560
  "var",
12586
- "void",
12561
+ "let",
12562
+ "const",
12563
+ "for",
12564
+ "delete",
12565
+ "false",
12566
+ "true",
12587
12567
  "while",
12588
- "with"
12568
+ "do",
12569
+ "break",
12570
+ "continue",
12571
+ "new",
12572
+ "function",
12573
+ "async",
12574
+ "await",
12575
+ "switch",
12576
+ "case"
12589
12577
  ]);
12590
12578
  var Scope3 = class {
12591
12579
  constructor(parent, vars = {}, functionThis) {
@@ -12600,16 +12588,25 @@ var require_utils = __commonJS({
12600
12588
  this.globals = parent === null ? keysOnly(vars) : {};
12601
12589
  this.functionThis = functionThis;
12602
12590
  }
12603
- get(key) {
12604
- const isThis = key === "this";
12605
- const scope = this.getWhereValScope(key, isThis);
12606
- if (scope && isThis) {
12607
- return new Prop({ this: scope.functionThis }, key, false, false, true);
12591
+ get(key, functionScope = false) {
12592
+ const functionThis = this.functionThis;
12593
+ if (key === "this" && functionThis !== void 0) {
12594
+ return new Prop({ this: functionThis }, key, true, false, true);
12608
12595
  }
12609
- if (!scope) {
12610
- return new Prop(void 0, key);
12596
+ if (reservedWords2.has(key))
12597
+ throw new SyntaxError("Unexepected token '" + key + "'");
12598
+ if (this.parent === null || !functionScope || functionThis !== void 0) {
12599
+ if (this.globals.hasOwnProperty(key)) {
12600
+ return new Prop(functionThis, key, false, true, true);
12601
+ }
12602
+ if (key in this.allVars && (!(key in {}) || this.allVars.hasOwnProperty(key))) {
12603
+ return new Prop(this.allVars, key, this.const.hasOwnProperty(key), this.globals.hasOwnProperty(key), true);
12604
+ }
12605
+ if (this.parent === null) {
12606
+ return new Prop(void 0, key);
12607
+ }
12611
12608
  }
12612
- return new Prop(scope.allVars, key, key in scope.const, key in scope.globals, true);
12609
+ return this.parent.get(key, functionScope);
12613
12610
  }
12614
12611
  set(key, val) {
12615
12612
  if (key === "this")
@@ -12620,72 +12617,34 @@ var require_utils = __commonJS({
12620
12617
  if (prop.context === void 0) {
12621
12618
  throw new ReferenceError(`Variable '${key}' was not declared.`);
12622
12619
  }
12623
- if (prop.context === null) {
12624
- throw new TypeError(`Cannot set properties of null, (setting '${key}')`);
12625
- }
12626
12620
  if (prop.isConst) {
12627
12621
  throw new TypeError(`Cannot assign to const variable '${key}'`);
12628
12622
  }
12629
12623
  if (prop.isGlobal) {
12630
12624
  throw new SandboxError(`Cannot override global variable '${key}'`);
12631
12625
  }
12626
+ if (!(prop.context instanceof Object))
12627
+ throw new SandboxError("Scope is not an object");
12632
12628
  prop.context[prop.prop] = val;
12633
12629
  return prop;
12634
12630
  }
12635
- getWhereValScope(key, isThis) {
12636
- if (isThis) {
12637
- if (this.functionThis !== void 0) {
12638
- return this;
12639
- } else {
12640
- return this.parent?.getWhereValScope(key, isThis) || null;
12641
- }
12642
- }
12643
- if (key in this.allVars && !(key in {} && !hasOwnProperty19(this.allVars, key))) {
12644
- return this;
12645
- }
12646
- return this.parent?.getWhereValScope(key, isThis) || null;
12647
- }
12648
- getWhereVarScope(key, localScope = false) {
12649
- if (key in this.allVars && !(key in {} && !hasOwnProperty19(this.allVars, key))) {
12650
- return this;
12651
- }
12652
- if (this.parent === null || localScope || this.functionThis !== void 0) {
12653
- return this;
12654
- }
12655
- return this.parent.getWhereVarScope(key, localScope);
12656
- }
12657
12631
  declare(key, type, value = void 0, isGlobal = false) {
12658
12632
  if (key === "this")
12659
12633
  throw new SyntaxError('"this" cannot be declared');
12660
12634
  if (reservedWords2.has(key))
12661
12635
  throw new SyntaxError("Unexepected token '" + key + "'");
12662
- const existingScope = this.getWhereVarScope(
12663
- key,
12664
- type !== "var"
12665
- /* VarType.var */
12666
- );
12667
- if (type === "var") {
12668
- if (existingScope.var[key]) {
12669
- existingScope.allVars[key] = value;
12670
- if (!isGlobal) {
12671
- delete existingScope.globals[key];
12672
- } else {
12673
- existingScope.globals[key] = true;
12674
- }
12675
- return new Prop(existingScope.allVars, key, false, existingScope.globals[key], true);
12676
- } else if (key in existingScope.allVars) {
12677
- throw new SyntaxError(`Identifier '${key}' has already been declared`);
12678
- }
12679
- }
12680
- if (key in existingScope.allVars) {
12681
- throw new SyntaxError(`Identifier '${key}' has already been declared`);
12682
- }
12683
- if (isGlobal) {
12684
- existingScope.globals[key] = true;
12636
+ if (type === "var" && this.functionThis === void 0 && this.parent !== null) {
12637
+ return this.parent.declare(key, type, value, isGlobal);
12638
+ } else if (this[type].hasOwnProperty(key) && type !== "const" && !this.globals.hasOwnProperty(key) || !(key in this.allVars)) {
12639
+ if (isGlobal) {
12640
+ this.globals[key] = true;
12641
+ }
12642
+ this[type][key] = true;
12643
+ this.allVars[key] = value;
12644
+ } else {
12645
+ throw new SandboxError(`Identifier '${key}' has already been declared`);
12685
12646
  }
12686
- existingScope[type][key] = true;
12687
- existingScope.allVars[key] = value;
12688
- return new Prop(this.allVars, key, type === "const", isGlobal, true);
12647
+ return new Prop(this.allVars, key, this.const.hasOwnProperty(key), isGlobal);
12689
12648
  }
12690
12649
  };
12691
12650
  var FunctionScope = class {
@@ -12694,16 +12653,8 @@ var require_utils = __commonJS({
12694
12653
  };
12695
12654
  var SandboxError = class extends Error {
12696
12655
  };
12697
- var SandboxExecutionQuotaExceededError = class extends SandboxError {
12698
- };
12699
- var SandboxExecutionTreeError = class extends SandboxError {
12700
- };
12701
- var SandboxCapabilityError = class extends SandboxError {
12702
- };
12703
- var SandboxAccessError = class extends SandboxError {
12704
- };
12705
12656
  function isLisp(item) {
12706
- return Array.isArray(item) && typeof item[0] === "number" && item[0] !== 0 && item[0] !== 88;
12657
+ return Array.isArray(item) && typeof item[0] === "number" && item[0] !== 0 && item[0] !== 89;
12707
12658
  }
12708
12659
  var Prop = class {
12709
12660
  constructor(context, prop, isConst = false, isGlobal = false, isVariable = false) {
@@ -12716,16 +12667,13 @@ var require_utils = __commonJS({
12716
12667
  get(context) {
12717
12668
  const ctx = this.context;
12718
12669
  if (ctx === void 0)
12719
- throw new ReferenceError(`${this.prop.toString()} is not defined`);
12670
+ throw new ReferenceError(`${this.prop} is not defined`);
12720
12671
  if (ctx === null)
12721
- throw new TypeError(`Cannot read properties of null, (reading '${this.prop.toString()}')`);
12722
- context.getSubscriptions.forEach((cb) => cb(ctx, this.prop.toString()));
12672
+ throw new TypeError(`Cannot read properties of null, (reading '${this.prop}')`);
12673
+ context.getSubscriptions.forEach((cb) => cb(ctx, this.prop));
12723
12674
  return ctx[this.prop];
12724
12675
  }
12725
12676
  };
12726
- function hasOwnProperty19(obj, prop) {
12727
- return Object.prototype.hasOwnProperty.call(obj, prop);
12728
- }
12729
12677
  exports2.AsyncFunction = AsyncFunction;
12730
12678
  exports2.AsyncGeneratorFunction = AsyncGeneratorFunction;
12731
12679
  exports2.CodeString = CodeString;
@@ -12734,18 +12682,12 @@ var require_utils = __commonJS({
12734
12682
  exports2.GeneratorFunction = GeneratorFunction;
12735
12683
  exports2.LocalScope = LocalScope;
12736
12684
  exports2.Prop = Prop;
12737
- exports2.SandboxAccessError = SandboxAccessError;
12738
- exports2.SandboxCapabilityError = SandboxCapabilityError;
12739
12685
  exports2.SandboxError = SandboxError;
12740
- exports2.SandboxExecutionQuotaExceededError = SandboxExecutionQuotaExceededError;
12741
- exports2.SandboxExecutionTreeError = SandboxExecutionTreeError;
12742
12686
  exports2.SandboxGlobal = SandboxGlobal;
12743
12687
  exports2.Scope = Scope3;
12744
12688
  exports2.createContext = createContext;
12745
12689
  exports2.createExecContext = createExecContext;
12746
- exports2.hasOwnProperty = hasOwnProperty19;
12747
12690
  exports2.isLisp = isLisp;
12748
- exports2.reservedWords = reservedWords2;
12749
12691
  }
12750
12692
  });
12751
12693
 
@@ -12775,9 +12717,10 @@ var require_executor = __commonJS({
12775
12717
  });
12776
12718
  return vars;
12777
12719
  }
12720
+ var sandboxedFunctions = /* @__PURE__ */ new WeakSet();
12778
12721
  function createFunction(argNames, parsed, ticks, context, scope, name) {
12779
12722
  if (context.ctx.options.forbidFunctionCreation) {
12780
- throw new utils.SandboxCapabilityError("Function creation is forbidden");
12723
+ throw new utils.SandboxError("Function creation is forbidden");
12781
12724
  }
12782
12725
  let func;
12783
12726
  if (name === void 0) {
@@ -12794,15 +12737,15 @@ var require_executor = __commonJS({
12794
12737
  };
12795
12738
  }
12796
12739
  context.registerSandboxFunction(func);
12797
- context.ctx.sandboxedFunctions.add(func);
12740
+ sandboxedFunctions.add(func);
12798
12741
  return func;
12799
12742
  }
12800
12743
  function createFunctionAsync(argNames, parsed, ticks, context, scope, name) {
12801
12744
  if (context.ctx.options.forbidFunctionCreation) {
12802
- throw new utils.SandboxCapabilityError("Function creation is forbidden");
12745
+ throw new utils.SandboxError("Function creation is forbidden");
12803
12746
  }
12804
12747
  if (!context.ctx.prototypeWhitelist?.has(Promise.prototype)) {
12805
- throw new utils.SandboxCapabilityError("Async/await not permitted");
12748
+ throw new utils.SandboxError("Async/await not permitted");
12806
12749
  }
12807
12750
  let func;
12808
12751
  if (name === void 0) {
@@ -12819,40 +12762,43 @@ var require_executor = __commonJS({
12819
12762
  };
12820
12763
  }
12821
12764
  context.registerSandboxFunction(func);
12822
- context.ctx.sandboxedFunctions.add(func);
12765
+ sandboxedFunctions.add(func);
12823
12766
  return func;
12824
12767
  }
12825
12768
  function assignCheck(obj, context, op = "assign") {
12826
12769
  if (obj.context === void 0) {
12827
12770
  throw new ReferenceError(`Cannot ${op} value to undefined.`);
12828
12771
  }
12772
+ if (typeof obj.context !== "object" && typeof obj.context !== "function") {
12773
+ throw new SyntaxError(`Cannot ${op} value to a primitive.`);
12774
+ }
12829
12775
  if (obj.isConst) {
12830
- throw new TypeError(`Assignment to constant variable.`);
12776
+ throw new TypeError(`Cannot set value to const variable '${obj.prop}'`);
12831
12777
  }
12832
12778
  if (obj.isGlobal) {
12833
- throw new utils.SandboxAccessError(`Cannot ${op} property '${obj.prop.toString()}' of a global object`);
12779
+ throw new utils.SandboxError(`Cannot ${op} property '${obj.prop}' of a global object`);
12834
12780
  }
12835
12781
  if (obj.context === null) {
12836
12782
  throw new TypeError("Cannot set properties of null");
12837
12783
  }
12838
- if (typeof obj.context[obj.prop] === "function" && !utils.hasOwnProperty(obj.context, obj.prop)) {
12839
- throw new utils.SandboxAccessError(`Override prototype property '${obj.prop.toString()}' not allowed`);
12784
+ if (typeof obj.context[obj.prop] === "function" && !obj.context.hasOwnProperty(obj.prop)) {
12785
+ throw new utils.SandboxError(`Override prototype property '${obj.prop}' not allowed`);
12840
12786
  }
12841
12787
  if (op === "delete") {
12842
- if (utils.hasOwnProperty(obj.context, obj.prop)) {
12843
- context.changeSubscriptions.get(obj.context)?.forEach((cb) => cb({ type: "delete", prop: obj.prop.toString() }));
12844
- context.changeSubscriptionsGlobal.get(obj.context)?.forEach((cb) => cb({ type: "delete", prop: obj.prop.toString() }));
12788
+ if (obj.context.hasOwnProperty(obj.prop)) {
12789
+ context.changeSubscriptions.get(obj.context)?.forEach((cb) => cb({ type: "delete", prop: obj.prop }));
12790
+ context.changeSubscriptionsGlobal.get(obj.context)?.forEach((cb) => cb({ type: "delete", prop: obj.prop }));
12845
12791
  }
12846
- } else if (utils.hasOwnProperty(obj.context, obj.prop)) {
12847
- context.setSubscriptions.get(obj.context)?.get(obj.prop.toString())?.forEach((cb) => cb({
12792
+ } else if (obj.context.hasOwnProperty(obj.prop)) {
12793
+ context.setSubscriptions.get(obj.context)?.get(obj.prop)?.forEach((cb) => cb({
12848
12794
  type: "replace"
12849
12795
  }));
12850
- context.setSubscriptionsGlobal.get(obj.context)?.get(obj.prop.toString())?.forEach((cb) => cb({
12796
+ context.setSubscriptionsGlobal.get(obj.context)?.get(obj.prop)?.forEach((cb) => cb({
12851
12797
  type: "replace"
12852
12798
  }));
12853
12799
  } else {
12854
- context.changeSubscriptions.get(obj.context)?.forEach((cb) => cb({ type: "create", prop: obj.prop.toString() }));
12855
- context.changeSubscriptionsGlobal.get(obj.context)?.forEach((cb) => cb({ type: "create", prop: obj.prop.toString() }));
12800
+ context.changeSubscriptions.get(obj.context)?.forEach((cb) => cb({ type: "create", prop: obj.prop }));
12801
+ context.changeSubscriptionsGlobal.get(obj.context)?.forEach((cb) => cb({ type: "create", prop: obj.prop }));
12856
12802
  }
12857
12803
  }
12858
12804
  var arrayChange = /* @__PURE__ */ new Set([
@@ -12892,128 +12838,107 @@ var require_executor = __commonJS({
12892
12838
  function addOps(type, cb) {
12893
12839
  ops.set(type, cb);
12894
12840
  }
12895
- var prorptyKeyTypes = ["string", "number", "symbol"];
12896
- function isPropertyKey(val) {
12897
- return prorptyKeyTypes.includes(typeof val);
12898
- }
12899
- function hasPossibleProperties(val) {
12900
- return val !== null && val !== void 0;
12901
- }
12902
- addOps(1, ({ done, a, b, obj, context, scope }) => {
12841
+ addOps(1, (exec6, done, ticks, a, b, obj, context, scope) => {
12903
12842
  if (a === null) {
12904
- throw new TypeError(`Cannot read properties of null (reading '${b?.toString()}')`);
12905
- }
12906
- if (!isPropertyKey(b)) {
12907
- b = `${b}`;
12843
+ throw new TypeError(`Cannot get property ${b} of null`);
12908
12844
  }
12909
- if (a === void 0 && obj === void 0 && typeof b === "string") {
12845
+ const type = typeof a;
12846
+ if (type === "undefined" && obj === void 0) {
12910
12847
  const prop = scope.get(b);
12911
12848
  if (prop.context === context.ctx.sandboxGlobal) {
12912
12849
  if (context.ctx.options.audit) {
12913
12850
  context.ctx.auditReport?.globalsAccess.add(b);
12914
12851
  }
12852
+ const rep = context.ctx.globalsWhitelist.has(context.ctx.sandboxGlobal[b]) ? context.evals.get(context.ctx.sandboxGlobal[b]) : void 0;
12853
+ if (rep) {
12854
+ done(void 0, rep);
12855
+ return;
12856
+ }
12857
+ }
12858
+ if (prop.context && prop.context[b] === globalThis) {
12859
+ done(void 0, context.ctx.globalScope.get("this"));
12860
+ return;
12915
12861
  }
12916
- const val2 = prop.context ? prop.context[prop.prop] : void 0;
12917
- const p2 = getGlobalProp(val2, context, prop) || prop;
12918
- done(void 0, p2);
12862
+ done(void 0, prop);
12919
12863
  return;
12920
12864
  } else if (a === void 0) {
12921
- throw new TypeError(`Cannot read properties of undefined (reading '${b.toString()}')`);
12865
+ throw new utils.SandboxError("Cannot get property '" + b + "' of undefined");
12922
12866
  }
12923
- if (!hasPossibleProperties(a)) {
12867
+ if (type !== "object") {
12868
+ if (type === "number") {
12869
+ a = new Number(a);
12870
+ } else if (type === "string") {
12871
+ a = new String(a);
12872
+ } else if (type === "boolean") {
12873
+ a = new Boolean(a);
12874
+ }
12875
+ } else if (typeof a.hasOwnProperty === "undefined") {
12924
12876
  done(void 0, new utils.Prop(void 0, b));
12925
12877
  return;
12926
12878
  }
12927
- const prototypeAccess = typeof a === "function" || !utils.hasOwnProperty(a, b);
12879
+ const isFunction2 = type === "function";
12880
+ const prototypeAccess = isFunction2 || !(a.hasOwnProperty(b) || typeof b === "number");
12928
12881
  if (context.ctx.options.audit && prototypeAccess) {
12929
- let prot = Object.getPrototypeOf(a);
12930
- do {
12931
- if (utils.hasOwnProperty(prot, b)) {
12932
- if (context.ctx.auditReport && !context.ctx.auditReport.prototypeAccess[prot.constructor.name]) {
12933
- context.ctx.auditReport.prototypeAccess[prot.constructor.name] = /* @__PURE__ */ new Set();
12882
+ if (typeof b === "string") {
12883
+ let prot = Object.getPrototypeOf(a);
12884
+ do {
12885
+ if (prot.hasOwnProperty(b)) {
12886
+ if (context.ctx.auditReport && !context.ctx.auditReport.prototypeAccess[prot.constructor.name]) {
12887
+ context.ctx.auditReport.prototypeAccess[prot.constructor.name] = /* @__PURE__ */ new Set();
12888
+ }
12889
+ context.ctx.auditReport?.prototypeAccess[prot.constructor.name].add(b);
12934
12890
  }
12935
- context.ctx.auditReport?.prototypeAccess[prot.constructor.name].add(b);
12936
- }
12937
- } while (prot = Object.getPrototypeOf(prot));
12891
+ } while (prot = Object.getPrototypeOf(prot));
12892
+ }
12938
12893
  }
12939
12894
  if (prototypeAccess) {
12940
- if (typeof a === "function") {
12941
- if (utils.hasOwnProperty(a, b)) {
12895
+ if (isFunction2) {
12896
+ if (!["name", "length", "constructor"].includes(b) && a.hasOwnProperty(b)) {
12942
12897
  const whitelist = context.ctx.prototypeWhitelist.get(a.prototype);
12943
12898
  const replace = context.ctx.options.prototypeReplacements.get(a);
12944
12899
  if (replace) {
12945
12900
  done(void 0, new utils.Prop(replace(a, true), b));
12946
12901
  return;
12947
12902
  }
12948
- if (!(whitelist && (!whitelist.size || whitelist.has(b))) && !context.ctx.sandboxedFunctions.has(a)) {
12949
- throw new utils.SandboxAccessError(`Static method or property access not permitted: ${a.name}.${b.toString()}`);
12903
+ if (!(whitelist && (!whitelist.size || whitelist.has(b)))) {
12904
+ throw new utils.SandboxError(`Static method or property access not permitted: ${a.name}.${b}`);
12950
12905
  }
12951
12906
  }
12952
12907
  }
12953
- let prot = a;
12954
- while (prot = Object.getPrototypeOf(prot)) {
12955
- if (utils.hasOwnProperty(prot, b) || b === "__proto__") {
12956
- const whitelist = context.ctx.prototypeWhitelist.get(prot);
12957
- const replace = context.ctx.options.prototypeReplacements.get(prot.constructor);
12958
- if (replace) {
12959
- done(void 0, new utils.Prop(replace(a, false), b));
12960
- return;
12961
- }
12962
- if (whitelist && (!whitelist.size || whitelist.has(b)) || context.ctx.sandboxedFunctions.has(prot.constructor)) {
12963
- break;
12964
- }
12965
- if (b === "__proto__") {
12966
- throw new utils.SandboxAccessError(`Access to prototype of global object is not permitted`);
12908
+ if (b !== "constructor") {
12909
+ let prot = a;
12910
+ while (prot = Object.getPrototypeOf(prot)) {
12911
+ if (prot.hasOwnProperty(b)) {
12912
+ const whitelist = context.ctx.prototypeWhitelist.get(prot);
12913
+ const replace = context.ctx.options.prototypeReplacements.get(prot.constuctor);
12914
+ if (replace) {
12915
+ done(void 0, new utils.Prop(replace(a, false), b));
12916
+ return;
12917
+ }
12918
+ if (whitelist && (!whitelist.size || whitelist.has(b))) {
12919
+ break;
12920
+ }
12921
+ throw new utils.SandboxError(`Method or property access not permitted: ${prot.constructor.name}.${b}`);
12967
12922
  }
12968
- throw new utils.SandboxAccessError(`Method or property access not permitted: ${prot.constructor.name}.${b.toString()}`);
12969
12923
  }
12970
12924
  }
12971
12925
  }
12972
- const val = a[b];
12973
- if (typeof a === "function") {
12974
- if (b === "prototype" && !context.ctx.sandboxedFunctions.has(a)) {
12975
- throw new utils.SandboxAccessError(`Access to prototype of global object is not permitted`);
12976
- }
12977
- }
12978
- if (b === "__proto__" && !context.ctx.sandboxedFunctions.has(val?.constructor)) {
12979
- throw new utils.SandboxAccessError(`Access to prototype of global object is not permitted`);
12980
- }
12981
- const p = getGlobalProp(val, context);
12982
- if (p) {
12983
- done(void 0, p);
12926
+ if (context.evals.has(a[b])) {
12927
+ done(void 0, context.evals.get(a[b]));
12984
12928
  return;
12985
12929
  }
12986
- const g = obj instanceof utils.Prop && obj.isGlobal || typeof a === "function" && !context.ctx.sandboxedFunctions.has(a) || context.ctx.globalsWhitelist.has(a);
12987
- done(void 0, new utils.Prop(a, b, false, g, false));
12988
- });
12989
- function getGlobalProp(val, context, prop) {
12990
- if (!val)
12930
+ if (a[b] === globalThis) {
12931
+ done(void 0, context.ctx.globalScope.get("this"));
12991
12932
  return;
12992
- const isFunc = typeof val === "function";
12993
- if (val instanceof utils.Prop) {
12994
- if (!prop) {
12995
- prop = val;
12996
- }
12997
- val = val.get(context);
12998
- }
12999
- const p = prop?.prop || "prop";
13000
- if (val === globalThis) {
13001
- return new utils.Prop({
13002
- [p]: context.ctx.sandboxGlobal
13003
- }, p, prop?.isConst || false, false, prop?.isVariable || false);
13004
- }
13005
- const evl = isFunc && context.evals.get(val);
13006
- if (evl) {
13007
- return new utils.Prop({
13008
- [p]: evl
13009
- }, p, prop?.isConst || false, true, prop?.isVariable || false);
13010
12933
  }
13011
- }
13012
- addOps(5, ({ done, a, b, obj, context }) => {
12934
+ const g = obj.isGlobal || isFunction2 && !sandboxedFunctions.has(a) || context.ctx.globalsWhitelist.has(a);
12935
+ done(void 0, new utils.Prop(a, b, false, g));
12936
+ });
12937
+ addOps(5, (exec6, done, ticks, a, b, obj, context) => {
13013
12938
  if (context.ctx.options.forbidFunctionCalls)
13014
- throw new utils.SandboxCapabilityError("Function invocations are not allowed");
12939
+ throw new utils.SandboxError("Function invocations are not allowed");
13015
12940
  if (typeof a !== "function") {
13016
- throw new TypeError(`${typeof obj?.prop === "symbol" ? "Symbol" : obj?.prop} is not a function`);
12941
+ throw new TypeError(`${typeof obj.prop === "symbol" ? "Symbol" : obj.prop} is not a function`);
13017
12942
  }
13018
12943
  const vals = b.map((item) => {
13019
12944
  if (item instanceof SpreadArray) {
@@ -13023,9 +12948,7 @@ var require_executor = __commonJS({
13023
12948
  }
13024
12949
  }).flat().map((item) => valueOrProp(item, context));
13025
12950
  if (typeof obj === "function") {
13026
- let ret2 = obj(...vals);
13027
- ret2 = getGlobalProp(ret2, context) || ret2;
13028
- done(void 0, ret2);
12951
+ done(void 0, obj(...vals));
13029
12952
  return;
13030
12953
  }
13031
12954
  if (obj.context[obj.prop] === JSON.stringify && context.getSubscriptions.size) {
@@ -13097,11 +13020,9 @@ var require_executor = __commonJS({
13097
13020
  }
13098
13021
  }
13099
13022
  obj.get(context);
13100
- let ret = obj.context[obj.prop](...vals);
13101
- ret = getGlobalProp(ret, context) || ret;
13102
- done(void 0, ret);
13023
+ done(void 0, obj.context[obj.prop](...vals));
13103
13024
  });
13104
- addOps(22, ({ done, b }) => {
13025
+ addOps(22, (exec6, done, ticks, a, b) => {
13105
13026
  let res = {};
13106
13027
  for (const item of b) {
13107
13028
  if (item.key instanceof SpreadObject) {
@@ -13112,8 +13033,8 @@ var require_executor = __commonJS({
13112
13033
  }
13113
13034
  done(void 0, res);
13114
13035
  });
13115
- addOps(6, ({ done, a, b }) => done(void 0, new KeyVal(a, b)));
13116
- addOps(12, ({ done, b, context }) => {
13036
+ addOps(6, (exec6, done, ticks, a, b) => done(void 0, new KeyVal(a, b)));
13037
+ addOps(12, (exec6, done, ticks, a, b, obj, context) => {
13117
13038
  const items = b.map((item) => {
13118
13039
  if (item instanceof SpreadArray) {
13119
13040
  return [...item.item];
@@ -13123,8 +13044,8 @@ var require_executor = __commonJS({
13123
13044
  }).flat().map((item) => valueOrProp(item, context));
13124
13045
  done(void 0, items);
13125
13046
  });
13126
- addOps(23, ({ done, b }) => done(void 0, b));
13127
- addOps(35, ({ done, b }) => {
13047
+ addOps(23, (exec6, done, ticks, a, b) => done(void 0, b));
13048
+ addOps(35, (exec6, done, ticks, a, b) => {
13128
13049
  switch (b) {
13129
13050
  case "true":
13130
13051
  return done(void 0, true);
@@ -13141,18 +13062,18 @@ var require_executor = __commonJS({
13141
13062
  }
13142
13063
  done(new Error("Unknown symbol: " + b));
13143
13064
  });
13144
- addOps(7, ({ done, b }) => done(void 0, Number(b.replace(/_/g, ""))));
13145
- addOps(83, ({ done, b }) => done(void 0, BigInt(b.replace(/_/g, ""))));
13146
- addOps(2, ({ done, b, context }) => done(void 0, context.constants.strings[parseInt(b)]));
13147
- addOps(85, ({ done, b, context }) => {
13065
+ addOps(7, (exec6, done, ticks, a, b) => done(void 0, Number(b)));
13066
+ addOps(83, (exec6, done, ticks, a, b) => done(void 0, BigInt(b)));
13067
+ addOps(2, (exec6, done, ticks, a, b, obj, context) => done(void 0, context.constants.strings[parseInt(b)]));
13068
+ addOps(86, (exec6, done, ticks, a, b, obj, context) => {
13148
13069
  const reg = context.constants.regexes[parseInt(b)];
13149
13070
  if (!context.ctx.globalsWhitelist.has(RegExp)) {
13150
- throw new utils.SandboxCapabilityError("Regex not permitted");
13071
+ throw new utils.SandboxError("Regex not permitted");
13151
13072
  } else {
13152
13073
  done(void 0, new RegExp(reg.regex, reg.flags));
13153
13074
  }
13154
13075
  });
13155
- addOps(84, ({ exec: exec6, done, ticks, b, context, scope }) => {
13076
+ addOps(84, (exec6, done, ticks, a, b, obj, context, scope) => {
13156
13077
  const item = context.constants.literals[parseInt(b)];
13157
13078
  const [, name, js] = item;
13158
13079
  const found = [];
@@ -13164,13 +13085,12 @@ var require_executor = __commonJS({
13164
13085
  resnums.push(f[3]);
13165
13086
  }
13166
13087
  }
13167
- exec6(ticks, found, scope, context, (...args) => {
13088
+ exec6(ticks, found, scope, context, (err, processed) => {
13168
13089
  const reses = {};
13169
- if (args.length === 1) {
13170
- done(args[0]);
13090
+ if (err) {
13091
+ done(err);
13171
13092
  return;
13172
13093
  }
13173
- const processed = args[1];
13174
13094
  for (const i of Object.keys(processed)) {
13175
13095
  const num = resnums[i];
13176
13096
  reses[num] = processed[i];
@@ -13183,146 +13103,115 @@ var require_executor = __commonJS({
13183
13103
  }));
13184
13104
  });
13185
13105
  });
13186
- addOps(18, ({ done, b }) => {
13106
+ addOps(18, (exec6, done, ticks, a, b) => {
13187
13107
  done(void 0, new SpreadArray(b));
13188
13108
  });
13189
- addOps(17, ({ done, b }) => {
13109
+ addOps(17, (exec6, done, ticks, a, b) => {
13190
13110
  done(void 0, new SpreadObject(b));
13191
13111
  });
13192
- addOps(24, ({ done, b }) => done(void 0, !b));
13193
- addOps(64, ({ done, b }) => done(void 0, ~b));
13194
- addOps(25, ({ done, obj, context }) => {
13112
+ addOps(24, (exec6, done, ticks, a, b) => done(void 0, !b));
13113
+ addOps(64, (exec6, done, ticks, a, b) => done(void 0, ~b));
13114
+ addOps(25, (exec6, done, ticks, a, b, obj, context) => {
13195
13115
  assignCheck(obj, context);
13196
13116
  done(void 0, ++obj.context[obj.prop]);
13197
13117
  });
13198
- addOps(26, ({ done, obj, context }) => {
13118
+ addOps(26, (exec6, done, ticks, a, b, obj, context) => {
13199
13119
  assignCheck(obj, context);
13200
13120
  done(void 0, obj.context[obj.prop]++);
13201
13121
  });
13202
- addOps(27, ({ done, obj, context }) => {
13122
+ addOps(27, (exec6, done, ticks, a, b, obj, context) => {
13203
13123
  assignCheck(obj, context);
13204
13124
  done(void 0, --obj.context[obj.prop]);
13205
13125
  });
13206
- addOps(28, ({ done, obj, context }) => {
13126
+ addOps(28, (exec6, done, ticks, a, b, obj, context) => {
13207
13127
  assignCheck(obj, context);
13208
13128
  done(void 0, obj.context[obj.prop]--);
13209
13129
  });
13210
- addOps(9, ({ done, b, obj, context, scope, bobj }) => {
13130
+ addOps(9, (exec6, done, ticks, a, b, obj, context) => {
13211
13131
  assignCheck(obj, context);
13212
- obj.isGlobal = bobj?.isGlobal || false;
13213
- if (obj.isVariable) {
13214
- const s = scope.getWhereValScope(obj.prop, obj.prop === "this");
13215
- if (s === null) {
13216
- throw new ReferenceError(`Cannot assign to undeclared variable '${obj.prop.toString()}'`);
13217
- }
13218
- s.set(obj.prop, b);
13219
- if (obj.isGlobal) {
13220
- s.globals[obj.prop.toString()] = true;
13221
- } else {
13222
- delete s.globals[obj.prop.toString()];
13223
- }
13224
- done(void 0, b);
13225
- return;
13226
- }
13227
13132
  done(void 0, obj.context[obj.prop] = b);
13228
13133
  });
13229
- addOps(66, ({ done, b, obj, context }) => {
13134
+ addOps(66, (exec6, done, ticks, a, b, obj, context) => {
13230
13135
  assignCheck(obj, context);
13231
13136
  done(void 0, obj.context[obj.prop] += b);
13232
13137
  });
13233
- addOps(65, ({ done, b, obj, context }) => {
13138
+ addOps(65, (exec6, done, ticks, a, b, obj, context) => {
13234
13139
  assignCheck(obj, context);
13235
13140
  done(void 0, obj.context[obj.prop] -= b);
13236
13141
  });
13237
- addOps(67, ({ done, b, obj, context }) => {
13142
+ addOps(67, (exec6, done, ticks, a, b, obj, context) => {
13238
13143
  assignCheck(obj, context);
13239
13144
  done(void 0, obj.context[obj.prop] /= b);
13240
13145
  });
13241
- addOps(69, ({ done, b, obj, context }) => {
13146
+ addOps(69, (exec6, done, ticks, a, b, obj, context) => {
13242
13147
  assignCheck(obj, context);
13243
13148
  done(void 0, obj.context[obj.prop] *= b);
13244
13149
  });
13245
- addOps(68, ({ done, b, obj, context }) => {
13150
+ addOps(68, (exec6, done, ticks, a, b, obj, context) => {
13246
13151
  assignCheck(obj, context);
13247
13152
  done(void 0, obj.context[obj.prop] **= b);
13248
13153
  });
13249
- addOps(70, ({ done, b, obj, context }) => {
13154
+ addOps(70, (exec6, done, ticks, a, b, obj, context) => {
13250
13155
  assignCheck(obj, context);
13251
13156
  done(void 0, obj.context[obj.prop] %= b);
13252
13157
  });
13253
- addOps(71, ({ done, b, obj, context }) => {
13158
+ addOps(71, (exec6, done, ticks, a, b, obj, context) => {
13254
13159
  assignCheck(obj, context);
13255
13160
  done(void 0, obj.context[obj.prop] ^= b);
13256
13161
  });
13257
- addOps(72, ({ done, b, obj, context }) => {
13162
+ addOps(72, (exec6, done, ticks, a, b, obj, context) => {
13258
13163
  assignCheck(obj, context);
13259
13164
  done(void 0, obj.context[obj.prop] &= b);
13260
13165
  });
13261
- addOps(73, ({ done, b, obj, context }) => {
13166
+ addOps(73, (exec6, done, ticks, a, b, obj, context) => {
13262
13167
  assignCheck(obj, context);
13263
13168
  done(void 0, obj.context[obj.prop] |= b);
13264
13169
  });
13265
- addOps(76, ({ done, b, obj, context }) => {
13170
+ addOps(76, (exec6, done, ticks, a, b, obj, context) => {
13266
13171
  assignCheck(obj, context);
13267
13172
  done(void 0, obj.context[obj.prop] <<= b);
13268
13173
  });
13269
- addOps(75, ({ done, b, obj, context }) => {
13174
+ addOps(75, (exec6, done, ticks, a, b, obj, context) => {
13270
13175
  assignCheck(obj, context);
13271
13176
  done(void 0, obj.context[obj.prop] >>= b);
13272
13177
  });
13273
- addOps(74, ({ done, b, obj, context }) => {
13274
- assignCheck(obj, context);
13275
- done(void 0, obj.context[obj.prop] >>>= b);
13276
- });
13277
- addOps(90, ({ done, b, obj, context }) => {
13278
- var _a, _b;
13279
- assignCheck(obj, context);
13280
- done(void 0, (_a = obj.context)[_b = obj.prop] && (_a[_b] = b));
13281
- });
13282
- addOps(91, ({ done, b, obj, context }) => {
13283
- var _a, _b;
13284
- assignCheck(obj, context);
13285
- done(void 0, (_a = obj.context)[_b = obj.prop] || (_a[_b] = b));
13286
- });
13287
- addOps(92, ({ done, b, obj, context }) => {
13288
- var _a, _b;
13178
+ addOps(74, (exec6, done, ticks, a, b, obj, context) => {
13289
13179
  assignCheck(obj, context);
13290
- done(void 0, (_a = obj.context)[_b = obj.prop] ?? (_a[_b] = b));
13180
+ done(void 0, obj.context[obj.prop] >>= b);
13291
13181
  });
13292
- addOps(57, ({ done, a, b }) => done(void 0, a > b));
13293
- addOps(56, ({ done, a, b }) => done(void 0, a < b));
13294
- addOps(55, ({ done, a, b }) => done(void 0, a >= b));
13295
- addOps(54, ({ done, a, b }) => done(void 0, a <= b));
13296
- addOps(52, ({ done, a, b }) => done(void 0, a == b));
13297
- addOps(32, ({ done, a, b }) => done(void 0, a === b));
13298
- addOps(53, ({ done, a, b }) => done(void 0, a != b));
13299
- addOps(31, ({ done, a, b }) => done(void 0, a !== b));
13300
- addOps(29, ({ done, a, b }) => done(void 0, a && b));
13301
- addOps(30, ({ done, a, b }) => done(void 0, a || b));
13302
- addOps(89, ({ done, a, b }) => done(void 0, a ?? b));
13303
- addOps(77, ({ done, a, b }) => done(void 0, a & b));
13304
- addOps(78, ({ done, a, b }) => done(void 0, a | b));
13305
- addOps(33, ({ done, a, b }) => done(void 0, a + b));
13306
- addOps(47, ({ done, a, b }) => done(void 0, a - b));
13307
- addOps(59, ({ done, b }) => done(void 0, +b));
13308
- addOps(58, ({ done, b }) => done(void 0, -b));
13309
- addOps(48, ({ done, a, b }) => done(void 0, a / b));
13310
- addOps(49, ({ done, a, b }) => done(void 0, a ** b));
13311
- addOps(79, ({ done, a, b }) => done(void 0, a ^ b));
13312
- addOps(50, ({ done, a, b }) => done(void 0, a * b));
13313
- addOps(51, ({ done, a, b }) => done(void 0, a % b));
13314
- addOps(80, ({ done, a, b }) => done(void 0, a << b));
13315
- addOps(81, ({ done, a, b }) => done(void 0, a >> b));
13316
- addOps(82, ({ done, a, b }) => done(void 0, a >>> b));
13317
- addOps(60, ({ exec: exec6, done, ticks, b, context, scope }) => {
13182
+ addOps(57, (exec6, done, ticks, a, b) => done(void 0, a > b));
13183
+ addOps(56, (exec6, done, ticks, a, b) => done(void 0, a < b));
13184
+ addOps(55, (exec6, done, ticks, a, b) => done(void 0, a >= b));
13185
+ addOps(54, (exec6, done, ticks, a, b) => done(void 0, a <= b));
13186
+ addOps(52, (exec6, done, ticks, a, b) => done(void 0, a == b));
13187
+ addOps(32, (exec6, done, ticks, a, b) => done(void 0, a === b));
13188
+ addOps(53, (exec6, done, ticks, a, b) => done(void 0, a != b));
13189
+ addOps(31, (exec6, done, ticks, a, b) => done(void 0, a !== b));
13190
+ addOps(29, (exec6, done, ticks, a, b) => done(void 0, a && b));
13191
+ addOps(30, (exec6, done, ticks, a, b) => done(void 0, a || b));
13192
+ addOps(85, (exec6, done, ticks, a, b) => done(void 0, a ?? b));
13193
+ addOps(77, (exec6, done, ticks, a, b) => done(void 0, a & b));
13194
+ addOps(78, (exec6, done, ticks, a, b) => done(void 0, a | b));
13195
+ addOps(33, (exec6, done, ticks, a, b) => done(void 0, a + b));
13196
+ addOps(47, (exec6, done, ticks, a, b) => done(void 0, a - b));
13197
+ addOps(59, (exec6, done, ticks, a, b) => done(void 0, +b));
13198
+ addOps(58, (exec6, done, ticks, a, b) => done(void 0, -b));
13199
+ addOps(48, (exec6, done, ticks, a, b) => done(void 0, a / b));
13200
+ addOps(79, (exec6, done, ticks, a, b) => done(void 0, a ^ b));
13201
+ addOps(50, (exec6, done, ticks, a, b) => done(void 0, a * b));
13202
+ addOps(51, (exec6, done, ticks, a, b) => done(void 0, a % b));
13203
+ addOps(80, (exec6, done, ticks, a, b) => done(void 0, a << b));
13204
+ addOps(81, (exec6, done, ticks, a, b) => done(void 0, a >> b));
13205
+ addOps(82, (exec6, done, ticks, a, b) => done(void 0, a >>> b));
13206
+ addOps(60, (exec6, done, ticks, a, b, obj, context, scope) => {
13318
13207
  exec6(ticks, b, scope, context, (e, prop) => {
13319
13208
  done(void 0, typeof valueOrProp(prop, context));
13320
13209
  });
13321
13210
  });
13322
- addOps(62, ({ done, a, b }) => done(void 0, a instanceof b));
13323
- addOps(63, ({ done, a, b }) => done(void 0, a in b));
13324
- addOps(61, ({ done, context, bobj }) => {
13325
- if (!(bobj instanceof utils.Prop)) {
13211
+ addOps(62, (exec6, done, ticks, a, b) => done(void 0, a instanceof b));
13212
+ addOps(63, (exec6, done, ticks, a, b) => done(void 0, a in b));
13213
+ addOps(61, (exec6, done, ticks, a, b, obj, context, scope, bobj) => {
13214
+ if (bobj.context === void 0) {
13326
13215
  done(void 0, true);
13327
13216
  return;
13328
13217
  }
@@ -13333,23 +13222,23 @@ var require_executor = __commonJS({
13333
13222
  }
13334
13223
  done(void 0, delete bobj.context?.[bobj.prop]);
13335
13224
  });
13336
- addOps(8, ({ done, b }) => done(void 0, b));
13337
- addOps(34, ({ done, a, b, scope, bobj }) => {
13338
- done(void 0, scope.declare(a, "var", b, bobj?.isGlobal || false));
13225
+ addOps(8, (exec6, done, ticks, a, b) => done(void 0, b));
13226
+ addOps(34, (exec6, done, ticks, a, b, obj, context, scope) => {
13227
+ done(void 0, scope.declare(a, "var", b));
13339
13228
  });
13340
- addOps(3, ({ done, a, b, scope, bobj }) => {
13341
- done(void 0, scope.declare(a, "let", b, bobj?.isGlobal || false));
13229
+ addOps(3, (exec6, done, ticks, a, b, obj, context, scope, bobj) => {
13230
+ done(void 0, scope.declare(a, "let", b, bobj && bobj.isGlobal));
13342
13231
  });
13343
- addOps(4, ({ done, a, b, scope, bobj }) => {
13344
- done(void 0, scope.declare(a, "const", b, bobj?.isGlobal || false));
13232
+ addOps(4, (exec6, done, ticks, a, b, obj, context, scope) => {
13233
+ done(void 0, scope.declare(a, "const", b));
13345
13234
  });
13346
- addOps(11, ({ done, ticks, a, b, obj, context, scope }) => {
13235
+ addOps(11, (exec6, done, ticks, a, b, obj, context, scope) => {
13347
13236
  a = [...a];
13348
13237
  if (typeof obj[2] === "string" || obj[2] instanceof utils.CodeString) {
13349
13238
  if (context.allowJit && context.evalContext) {
13350
13239
  obj[2] = b = context.evalContext.lispifyFunction(new utils.CodeString(obj[2]), context.constants);
13351
13240
  } else {
13352
- throw new utils.SandboxCapabilityError("Unevaluated code detected, JIT not allowed");
13241
+ throw new utils.SandboxError("Unevaluated code detected, JIT not allowed");
13353
13242
  }
13354
13243
  }
13355
13244
  if (a.shift()) {
@@ -13358,18 +13247,18 @@ var require_executor = __commonJS({
13358
13247
  done(void 0, createFunction(a, b, ticks, context, scope));
13359
13248
  }
13360
13249
  });
13361
- addOps(37, ({ done, ticks, a, b, obj, context, scope }) => {
13250
+ addOps(37, (exec6, done, ticks, a, b, obj, context, scope) => {
13362
13251
  if (typeof obj[2] === "string" || obj[2] instanceof utils.CodeString) {
13363
13252
  if (context.allowJit && context.evalContext) {
13364
13253
  obj[2] = b = context.evalContext.lispifyFunction(new utils.CodeString(obj[2]), context.constants);
13365
13254
  } else {
13366
- throw new utils.SandboxCapabilityError("Unevaluated code detected, JIT not allowed");
13255
+ throw new utils.SandboxError("Unevaluated code detected, JIT not allowed");
13367
13256
  }
13368
13257
  }
13369
13258
  const isAsync2 = a.shift();
13370
13259
  const name = a.shift();
13371
13260
  let func;
13372
- if (isAsync2 === 88) {
13261
+ if (isAsync2 === 89) {
13373
13262
  func = createFunctionAsync(a, b, ticks, context, scope, name);
13374
13263
  } else {
13375
13264
  func = createFunction(a, b, ticks, context, scope, name);
@@ -13379,12 +13268,12 @@ var require_executor = __commonJS({
13379
13268
  }
13380
13269
  done(void 0, func);
13381
13270
  });
13382
- addOps(10, ({ done, ticks, a, b, obj, context, scope }) => {
13271
+ addOps(10, (exec6, done, ticks, a, b, obj, context, scope) => {
13383
13272
  if (typeof obj[2] === "string" || obj[2] instanceof utils.CodeString) {
13384
13273
  if (context.allowJit && context.evalContext) {
13385
13274
  obj[2] = b = context.evalContext.lispifyFunction(new utils.CodeString(obj[2]), context.constants);
13386
13275
  } else {
13387
- throw new utils.SandboxCapabilityError("Unevaluated code detected, JIT not allowed");
13276
+ throw new utils.SandboxError("Unevaluated code detected, JIT not allowed");
13388
13277
  }
13389
13278
  }
13390
13279
  const isAsync2 = a.shift();
@@ -13393,7 +13282,7 @@ var require_executor = __commonJS({
13393
13282
  scope = new utils.Scope(scope, {});
13394
13283
  }
13395
13284
  let func;
13396
- if (isAsync2 === 88) {
13285
+ if (isAsync2 === 89) {
13397
13286
  func = createFunctionAsync(a, b, ticks, context, scope, name);
13398
13287
  } else {
13399
13288
  func = createFunction(a, b, ticks, context, scope, name);
@@ -13403,7 +13292,7 @@ var require_executor = __commonJS({
13403
13292
  }
13404
13293
  done(void 0, func);
13405
13294
  });
13406
- addOps(38, ({ exec: exec6, done, ticks, a, b, context, scope }) => {
13295
+ addOps(38, (exec6, done, ticks, a, b, obj, context, scope) => {
13407
13296
  const [checkFirst, startInternal, getIterator, startStep, step, condition, beforeStep] = a;
13408
13297
  let loop = true;
13409
13298
  const loopScope = new utils.Scope(scope, {});
@@ -13459,27 +13348,26 @@ var require_executor = __commonJS({
13459
13348
  done();
13460
13349
  }
13461
13350
  });
13462
- addOps(86, ({ done, a, context, inLoopOrSwitch }) => {
13351
+ addOps(87, (exec6, done, ticks, a, b, obj, context, scope, bobj, inLoopOrSwitch) => {
13463
13352
  if (inLoopOrSwitch === "switch" && a === "continue" || !inLoopOrSwitch) {
13464
- throw new TypeError("Illegal " + a + " statement");
13353
+ throw new utils.SandboxError("Illegal " + a + " statement");
13465
13354
  }
13466
13355
  done(void 0, new ExecReturn(context.ctx.auditReport, void 0, false, a === "break", a === "continue"));
13467
13356
  });
13468
- addOps(13, ({ exec: exec6, done, ticks, a, b, context, scope, inLoopOrSwitch }) => {
13357
+ addOps(13, (exec6, done, ticks, a, b, obj, context, scope, bobj, inLoopOrSwitch) => {
13469
13358
  exec6(ticks, valueOrProp(a, context) ? b.t : b.f, scope, context, done, inLoopOrSwitch);
13470
13359
  });
13471
- addOps(15, ({ exec: exec6, done, ticks, a, b, context, scope }) => {
13472
- exec6(ticks, valueOrProp(a, context) ? b.t : b.f, scope, context, done, void 0);
13360
+ addOps(15, (exec6, done, ticks, a, b, obj, context, scope, bobj, inLoopOrSwitch) => {
13361
+ exec6(ticks, valueOrProp(a, context) ? b.t : b.f, scope, context, done, inLoopOrSwitch);
13473
13362
  });
13474
- addOps(16, ({ done, a, b }) => done(void 0, new If(a, b)));
13475
- addOps(14, ({ done, a, b }) => done(void 0, new If(a, b)));
13476
- addOps(40, ({ exec: exec6, done, ticks, a, b, context, scope }) => {
13477
- exec6(ticks, a, scope, context, (...args) => {
13478
- if (args.length === 1) {
13479
- done(args[0]);
13363
+ addOps(16, (exec6, done, ticks, a, b) => done(void 0, new If(a, b)));
13364
+ addOps(14, (exec6, done, ticks, a, b) => done(void 0, new If(a, b)));
13365
+ addOps(40, (exec6, done, ticks, a, b, obj, context, scope) => {
13366
+ exec6(ticks, a, scope, context, (err, toTest) => {
13367
+ if (err) {
13368
+ done(err);
13480
13369
  return;
13481
13370
  }
13482
- let toTest = args[1];
13483
13371
  toTest = valueOrProp(toTest, context);
13484
13372
  if (exec6 === execSync) {
13485
13373
  let res;
@@ -13527,79 +13415,34 @@ var require_executor = __commonJS({
13527
13415
  }
13528
13416
  });
13529
13417
  });
13530
- addOps(39, ({ exec: exec6, done, ticks, a, b, context, scope, inLoopOrSwitch }) => {
13418
+ addOps(39, (exec6, done, ticks, a, b, obj, context, scope, bobj, inLoopOrSwitch) => {
13531
13419
  const [exception, catchBody, finallyBody] = b;
13532
- executeTreeWithDone(exec6, (...tryArgs) => {
13533
- const tryHadError = tryArgs.length === 1;
13534
- const tryError = tryHadError ? tryArgs[0] : void 0;
13535
- const tryResult = !tryHadError && tryArgs.length > 1 ? tryArgs[1] : void 0;
13536
- const executeFinallyAndComplete = (hadError, errorOrResult) => {
13537
- if (finallyBody && finallyBody.length > 0) {
13538
- executeTreeWithDone(exec6, (...finallyArgs) => {
13539
- const finallyHadError = finallyArgs.length === 1;
13540
- const finallyResult = !finallyHadError && finallyArgs.length > 1 ? finallyArgs[1] : void 0;
13541
- if (finallyHadError) {
13542
- done(finallyArgs[0]);
13543
- return;
13544
- }
13545
- if (finallyResult instanceof ExecReturn && (finallyResult.returned || finallyResult.breakLoop || finallyResult.continueLoop)) {
13546
- done(void 0, finallyResult);
13547
- return;
13548
- }
13549
- if (hadError) {
13550
- done(errorOrResult);
13551
- } else if (errorOrResult instanceof ExecReturn) {
13552
- if (errorOrResult.returned || errorOrResult.breakLoop || errorOrResult.continueLoop) {
13553
- done(void 0, errorOrResult);
13554
- } else {
13555
- done();
13556
- }
13557
- } else {
13558
- done();
13559
- }
13560
- }, ticks, context, finallyBody, [new utils.Scope(scope, {})], inLoopOrSwitch);
13420
+ executeTreeWithDone(exec6, (err, res) => {
13421
+ executeTreeWithDone(exec6, (e) => {
13422
+ if (e)
13423
+ done(e);
13424
+ else if (err) {
13425
+ executeTreeWithDone(exec6, done, ticks, context, catchBody, [new utils.Scope(scope)], inLoopOrSwitch);
13561
13426
  } else {
13562
- if (hadError) {
13563
- done(errorOrResult);
13564
- } else if (errorOrResult instanceof ExecReturn) {
13565
- if (errorOrResult.returned || errorOrResult.breakLoop || errorOrResult.continueLoop) {
13566
- done(void 0, errorOrResult);
13567
- } else {
13568
- done();
13569
- }
13570
- } else {
13571
- done();
13572
- }
13427
+ done(void 0, res);
13573
13428
  }
13574
- };
13575
- if (tryHadError && catchBody && catchBody.length > 0) {
13576
- const sc = {};
13577
- if (exception)
13578
- sc[exception] = tryError;
13579
- executeTreeWithDone(exec6, (...catchArgs) => {
13580
- const catchHadError = catchArgs.length === 1;
13581
- const catchErrorOrResult = catchHadError ? catchArgs[0] : catchArgs.length > 1 ? catchArgs[1] : void 0;
13582
- executeFinallyAndComplete(catchHadError, catchErrorOrResult);
13583
- }, ticks, context, catchBody, [new utils.Scope(scope, sc)], inLoopOrSwitch);
13584
- } else {
13585
- executeFinallyAndComplete(tryHadError, tryHadError ? tryError : tryResult);
13586
- }
13429
+ }, ticks, context, finallyBody, [new utils.Scope(scope, {})]);
13587
13430
  }, ticks, context, a, [new utils.Scope(scope)], inLoopOrSwitch);
13588
13431
  });
13589
- addOps(87, ({ done }) => {
13432
+ addOps(88, (exec6, done) => {
13590
13433
  done();
13591
13434
  });
13592
- addOps(45, ({ done, a, b, context }) => {
13593
- if (!context.ctx.globalsWhitelist.has(a) && !context.ctx.sandboxedFunctions.has(a)) {
13594
- throw new utils.SandboxAccessError(`Object construction not allowed: ${a.constructor.name}`);
13435
+ addOps(45, (exec6, done, ticks, a, b, obj, context) => {
13436
+ if (!context.ctx.globalsWhitelist.has(a) && !sandboxedFunctions.has(a)) {
13437
+ throw new utils.SandboxError(`Object construction not allowed: ${a.constructor.name}`);
13595
13438
  }
13596
13439
  done(void 0, new a(...b));
13597
13440
  });
13598
- addOps(46, ({ done, b }) => {
13441
+ addOps(46, (exec6, done, ticks, a, b) => {
13599
13442
  done(b);
13600
13443
  });
13601
- addOps(43, ({ done, a }) => done(void 0, a.pop()));
13602
- addOps(0, ({ done }) => done());
13444
+ addOps(43, (exec6, done, ticks, a) => done(void 0, a.pop()));
13445
+ addOps(0, (exec6, done) => done());
13603
13446
  function valueOrProp(a, context) {
13604
13447
  if (a instanceof utils.Prop)
13605
13448
  return a.get(context);
@@ -13617,7 +13460,13 @@ var require_executor = __commonJS({
13617
13460
  function _execManySync(ticks, tree, done, scope, context, inLoopOrSwitch) {
13618
13461
  const ret = [];
13619
13462
  for (let i = 0; i < tree.length; i++) {
13620
- let res = syncDone((d) => execSync(ticks, tree[i], scope, context, d, inLoopOrSwitch)).result;
13463
+ let res;
13464
+ try {
13465
+ res = syncDone((d) => execSync(ticks, tree[i], scope, context, d, inLoopOrSwitch)).result;
13466
+ } catch (e) {
13467
+ done(e);
13468
+ return;
13469
+ }
13621
13470
  if (res instanceof ExecReturn && (res.returned || res.breakLoop || res.continueLoop)) {
13622
13471
  done(void 0, res);
13623
13472
  return;
@@ -13657,13 +13506,13 @@ var require_executor = __commonJS({
13657
13506
  let isInstant = false;
13658
13507
  let instant;
13659
13508
  const p = new Promise((resolve8, reject2) => {
13660
- callback((...args) => {
13661
- if (args.length === 1)
13662
- reject2(args[0]);
13509
+ callback((err, result) => {
13510
+ if (err)
13511
+ reject2(err);
13663
13512
  else {
13664
13513
  isInstant = true;
13665
- instant = args[1];
13666
- resolve8({ result: args[1] });
13514
+ instant = result;
13515
+ resolve8({ result });
13667
13516
  }
13668
13517
  });
13669
13518
  });
@@ -13676,19 +13525,19 @@ var require_executor = __commonJS({
13676
13525
  function syncDone(callback) {
13677
13526
  let result;
13678
13527
  let err;
13679
- callback((...args) => {
13680
- err = args.length === 1 ? { error: args[0] } : void 0;
13681
- result = args[1];
13528
+ callback((e, r) => {
13529
+ err = e;
13530
+ result = r;
13682
13531
  });
13683
13532
  if (err)
13684
- throw err.error;
13533
+ throw err;
13685
13534
  return { result };
13686
13535
  }
13687
13536
  async function execAsync4(ticks, tree, scope, context, doneOriginal, inLoopOrSwitch) {
13688
13537
  let done = doneOriginal;
13689
13538
  const p = new Promise((resolve8) => {
13690
- done = (...args) => {
13691
- doneOriginal(...args);
13539
+ done = (e, r) => {
13540
+ doneOriginal(e, r);
13692
13541
  resolve8();
13693
13542
  };
13694
13543
  });
@@ -13724,10 +13573,6 @@ var require_executor = __commonJS({
13724
13573
  a = void 0;
13725
13574
  }
13726
13575
  }
13727
- if (op === 89 && a !== void 0 && a !== null) {
13728
- done(void 0, a);
13729
- return;
13730
- }
13731
13576
  let bobj;
13732
13577
  try {
13733
13578
  let ad;
@@ -13746,28 +13591,35 @@ var require_executor = __commonJS({
13746
13591
  if (b === optional) {
13747
13592
  b = void 0;
13748
13593
  }
13749
- performOp({
13750
- op,
13751
- exec: execAsync4,
13752
- done,
13753
- ticks,
13754
- a,
13755
- b,
13756
- obj,
13757
- context,
13758
- scope,
13759
- bobj,
13760
- inLoopOrSwitch,
13761
- tree
13762
- });
13594
+ if (ops.has(op)) {
13595
+ try {
13596
+ ops.get(op)?.(execAsync4, done, ticks, a, b, obj, context, scope, bobj, inLoopOrSwitch);
13597
+ } catch (err) {
13598
+ done(err);
13599
+ }
13600
+ } else {
13601
+ done(new SyntaxError("Unknown operator: " + op));
13602
+ }
13763
13603
  }
13764
13604
  await p;
13765
13605
  }
13766
13606
  function execSync(ticks, tree, scope, context, done, inLoopOrSwitch) {
13767
13607
  if (!_execNoneRecurse(ticks, tree, scope, context, done, false, inLoopOrSwitch) && utils.isLisp(tree)) {
13768
13608
  let op = tree[0];
13769
- let obj = syncDone((d) => execSync(ticks, tree[1], scope, context, d, inLoopOrSwitch)).result;
13770
- let a = obj instanceof utils.Prop ? obj.get(context) : obj;
13609
+ let obj;
13610
+ try {
13611
+ obj = syncDone((d) => execSync(ticks, tree[1], scope, context, d, inLoopOrSwitch)).result;
13612
+ } catch (e) {
13613
+ done(e);
13614
+ return;
13615
+ }
13616
+ let a = obj;
13617
+ try {
13618
+ a = obj instanceof utils.Prop ? obj.get(context) : obj;
13619
+ } catch (e) {
13620
+ done(e);
13621
+ return;
13622
+ }
13771
13623
  if (op === 20 || op === 21) {
13772
13624
  if (a === void 0 || a === null) {
13773
13625
  done(void 0, optional);
@@ -13783,129 +13635,31 @@ var require_executor = __commonJS({
13783
13635
  a = void 0;
13784
13636
  }
13785
13637
  }
13786
- if (op === 89 && a !== void 0 && a !== null) {
13787
- done(void 0, a);
13638
+ let bobj;
13639
+ try {
13640
+ bobj = syncDone((d) => execSync(ticks, tree[2], scope, context, d, inLoopOrSwitch)).result;
13641
+ } catch (e) {
13642
+ done(e);
13643
+ return;
13644
+ }
13645
+ let b = bobj;
13646
+ try {
13647
+ b = bobj instanceof utils.Prop ? bobj.get(context) : bobj;
13648
+ } catch (e) {
13649
+ done(e);
13788
13650
  return;
13789
13651
  }
13790
- let bobj = syncDone((d) => execSync(ticks, tree[2], scope, context, d, inLoopOrSwitch)).result;
13791
- let b = bobj instanceof utils.Prop ? bobj.get(context) : bobj;
13792
13652
  if (b === optional) {
13793
13653
  b = void 0;
13794
13654
  }
13795
- performOp({
13796
- op,
13797
- exec: execSync,
13798
- done,
13799
- ticks,
13800
- a,
13801
- b,
13802
- obj,
13803
- context,
13804
- scope,
13805
- bobj,
13806
- inLoopOrSwitch,
13807
- tree
13808
- });
13809
- }
13810
- }
13811
- function checkHaltExpectedTicks(params, expectTicks = 0) {
13812
- const sandbox = params.context.ctx.sandbox;
13813
- const options = params.context.ctx.options;
13814
- const { ticks, scope, context, done, op } = params;
13815
- if (sandbox.halted) {
13816
- const sub = sandbox.subscribeResume(() => {
13817
- sub.unsubscribe();
13655
+ if (ops.has(op)) {
13818
13656
  try {
13819
- const o = ops.get(op);
13820
- if (!o) {
13821
- done(new SyntaxError("Unknown operator: " + op));
13822
- return;
13823
- }
13824
- o(params);
13657
+ ops.get(op)?.(execSync, done, ticks, a, b, obj, context, scope, bobj, inLoopOrSwitch);
13825
13658
  } catch (err) {
13826
- if (options.haltOnSandboxError && err instanceof utils.SandboxError) {
13827
- const sub2 = sandbox.subscribeResume(() => {
13828
- sub2.unsubscribe();
13829
- done(err);
13830
- });
13831
- sandbox.haltExecution({
13832
- error: err,
13833
- ticks,
13834
- scope,
13835
- context
13836
- });
13837
- } else {
13838
- done(err);
13839
- }
13840
- }
13841
- });
13842
- return true;
13843
- } else if (ticks.tickLimit && ticks.tickLimit <= ticks.ticks + BigInt(expectTicks)) {
13844
- const sub = sandbox.subscribeResume(() => {
13845
- sub.unsubscribe();
13846
- try {
13847
- const o = ops.get(op);
13848
- if (!o) {
13849
- done(new SyntaxError("Unknown operator: " + op));
13850
- return;
13851
- }
13852
- o(params);
13853
- } catch (err) {
13854
- if (context.ctx.options.haltOnSandboxError && err instanceof utils.SandboxError) {
13855
- const sub2 = sandbox.subscribeResume(() => {
13856
- sub2.unsubscribe();
13857
- done(err);
13858
- });
13859
- sandbox.haltExecution({
13860
- error: err,
13861
- ticks,
13862
- scope,
13863
- context
13864
- });
13865
- } else {
13866
- done(err);
13867
- }
13868
- }
13869
- });
13870
- const error = new utils.SandboxExecutionQuotaExceededError("Execution quota exceeded");
13871
- sandbox.haltExecution({
13872
- error,
13873
- ticks,
13874
- scope,
13875
- context
13876
- });
13877
- return true;
13878
- }
13879
- return false;
13880
- }
13881
- function performOp(params) {
13882
- const { done, op, ticks, context, scope } = params;
13883
- ticks.ticks++;
13884
- const sandbox = context.ctx.sandbox;
13885
- if (checkHaltExpectedTicks(params)) {
13886
- return;
13887
- }
13888
- try {
13889
- const o = ops.get(op);
13890
- if (!o) {
13891
- done(new utils.SandboxExecutionTreeError("Unknown operator: " + op));
13892
- return;
13893
- }
13894
- o(params);
13895
- } catch (err) {
13896
- if (context.ctx.options.haltOnSandboxError && err instanceof utils.SandboxError) {
13897
- const sub = sandbox.subscribeResume(() => {
13898
- sub.unsubscribe();
13899
13659
  done(err);
13900
- });
13901
- sandbox.haltExecution({
13902
- error: err,
13903
- ticks,
13904
- scope,
13905
- context
13906
- });
13660
+ }
13907
13661
  } else {
13908
- done(err);
13662
+ done(new SyntaxError("Unknown operator: " + op));
13909
13663
  }
13910
13664
  }
13911
13665
  }
@@ -13923,9 +13677,20 @@ var require_executor = __commonJS({
13923
13677
  var currentTicks = { current: { ticks: BigInt(0) } };
13924
13678
  function _execNoneRecurse(ticks, tree, scope, context, done, isAsync2, inLoopOrSwitch) {
13925
13679
  const exec6 = isAsync2 ? execAsync4 : execSync;
13680
+ if (context.ctx.options.executionQuota && context.ctx.options.executionQuota <= ticks.ticks) {
13681
+ if (!(typeof context.ctx.options.onExecutionQuotaReached === "function" && context.ctx.options.onExecutionQuotaReached(ticks, scope, context, tree))) {
13682
+ done(new utils.SandboxError("Execution quota exceeded"));
13683
+ return true;
13684
+ }
13685
+ }
13686
+ ticks.ticks++;
13926
13687
  currentTicks.current = ticks;
13927
13688
  if (tree instanceof utils.Prop) {
13928
- done(void 0, tree.get(context));
13689
+ try {
13690
+ done(void 0, tree.get(context));
13691
+ } catch (err) {
13692
+ done(err);
13693
+ }
13929
13694
  } else if (tree === optional) {
13930
13695
  done();
13931
13696
  } else if (Array.isArray(tree) && !utils.isLisp(tree)) {
@@ -13940,36 +13705,27 @@ var require_executor = __commonJS({
13940
13705
  execMany(ticks, exec6, tree[1], done, scope, context, inLoopOrSwitch);
13941
13706
  } else if (tree[0] === 44) {
13942
13707
  if (!isAsync2) {
13943
- done(new SyntaxError("Illegal use of 'await', must be inside async function"));
13708
+ done(new utils.SandboxError("Illegal use of 'await', must be inside async function"));
13944
13709
  } else if (context.ctx.prototypeWhitelist?.has(Promise.prototype)) {
13945
- execAsync4(ticks, tree[1], scope, context, async (...args) => {
13946
- if (args.length === 1)
13947
- done(args[0]);
13710
+ execAsync4(ticks, tree[1], scope, context, async (e, r) => {
13711
+ if (e)
13712
+ done(e);
13948
13713
  else
13949
13714
  try {
13950
- done(void 0, await valueOrProp(args[1], context));
13715
+ done(void 0, await valueOrProp(r, context));
13951
13716
  } catch (err) {
13952
13717
  done(err);
13953
13718
  }
13954
13719
  }, inLoopOrSwitch).catch(done);
13955
13720
  } else {
13956
- done(new utils.SandboxCapabilityError("Async/await is not permitted"));
13721
+ done(new utils.SandboxError("Async/await is not permitted"));
13957
13722
  }
13958
13723
  } else if (unexecTypes.has(tree[0])) {
13959
- performOp({
13960
- op: tree[0],
13961
- exec: exec6,
13962
- done,
13963
- ticks,
13964
- a: tree[1],
13965
- b: tree[2],
13966
- obj: tree,
13967
- tree,
13968
- context,
13969
- scope,
13970
- bobj: void 0,
13971
- inLoopOrSwitch
13972
- });
13724
+ try {
13725
+ ops.get(tree[0])?.(exec6, done, ticks, tree[1], tree[2], tree, context, scope, void 0, inLoopOrSwitch);
13726
+ } catch (err) {
13727
+ done(err);
13728
+ }
13973
13729
  } else {
13974
13730
  return false;
13975
13731
  }
@@ -14022,17 +13778,15 @@ var require_executor = __commonJS({
14022
13778
  let err;
14023
13779
  const current2 = executionTree[i];
14024
13780
  try {
14025
- execSync(ticks, current2, scope, context, (...args) => {
14026
- if (args.length === 1)
14027
- err = { error: args[0] };
14028
- else
14029
- res = args[1];
13781
+ execSync(ticks, current2, scope, context, (e, r) => {
13782
+ err = e;
13783
+ res = r;
14030
13784
  }, inLoopOrSwitch);
14031
13785
  } catch (e) {
14032
- err = { error: e };
13786
+ err = e;
14033
13787
  }
14034
13788
  if (err) {
14035
- done(err.error);
13789
+ done(err);
14036
13790
  return;
14037
13791
  }
14038
13792
  if (res instanceof ExecReturn) {
@@ -14055,17 +13809,15 @@ var require_executor = __commonJS({
14055
13809
  let err;
14056
13810
  const current2 = executionTree[i];
14057
13811
  try {
14058
- await execAsync4(ticks, current2, scope, context, (...args) => {
14059
- if (args.length === 1)
14060
- err = { error: args[0] };
14061
- else
14062
- res = args[1];
13812
+ await execAsync4(ticks, current2, scope, context, (e, r) => {
13813
+ err = e;
13814
+ res = r;
14063
13815
  }, inLoopOrSwitch);
14064
13816
  } catch (e) {
14065
- err = { error: e };
13817
+ err = e;
14066
13818
  }
14067
13819
  if (err) {
14068
- done(err.error);
13820
+ done(err);
14069
13821
  return;
14070
13822
  }
14071
13823
  if (res instanceof ExecReturn) {
@@ -14096,6 +13848,7 @@ var require_executor = __commonJS({
14096
13848
  exports2.executeTree = executeTree;
14097
13849
  exports2.executeTreeAsync = executeTreeAsync;
14098
13850
  exports2.ops = ops;
13851
+ exports2.sandboxedFunctions = sandboxedFunctions;
14099
13852
  exports2.syncDone = syncDone;
14100
13853
  }
14101
13854
  });
@@ -14210,29 +13963,23 @@ var require_parser = __commonJS({
14210
13963
  var expectTypes = {
14211
13964
  splitter: {
14212
13965
  types: {
14213
- power: /^(\*\*)(?!=)/,
14214
- opHigh: /^(\/|\*(?!\*)|%)(?!=)/,
13966
+ opHigh: /^(\/|\*\*|\*(?!\*)|%)(?!=)/,
14215
13967
  op: /^(\+(?!(\+))|-(?!(-)))(?!=)/,
14216
13968
  comparitor: /^(<=|>=|<(?!<)|>(?!>)|!==|!=(?!=)|===|==)/,
14217
- bitwiseShift: /^(<<|>>(?!>)|>>>)(?!=)/,
14218
- bitwiseAnd: /^(&(?!&))(?!=)/,
14219
- bitwiseXor: /^(\^)(?!=)/,
14220
- bitwiseOr: /^(\|(?!\|))(?!=)/,
14221
- boolOpAnd: /^(&&)(?!=)/,
14222
- boolOpOr: /^(\|\|(?!=)|instanceof(?![\w$])|in(?![\w$]))/,
14223
- nullishCoalescing: /^\?\?(?!=)/
13969
+ boolOp: /^(&&|\|\||\?\?|instanceof(?![\w$])|in(?![\w$]))/,
13970
+ bitwise: /^(&(?!&)|\|(?!\|)|\^|<<|>>(?!>)|>>>)(?!=)/
14224
13971
  },
14225
13972
  next: ["modifier", "value", "prop", "incrementerBefore"]
14226
13973
  },
14227
13974
  inlineIf: {
14228
13975
  types: {
14229
- inlineIf: /^\?(?!\.(?!\d))/
13976
+ inlineIf: /^\?(?!\?|\.(?!\d))/
14230
13977
  },
14231
13978
  next: ["expEnd"]
14232
13979
  },
14233
13980
  assignment: {
14234
13981
  types: {
14235
- assignModify: /^(-=|\+=|\/=|\*\*=|\*=|%=|\^=|&=|\|=|>>>=|>>=|<<=|&&=|\|\|=|\?\?=)/,
13982
+ assignModify: /^(-=|\+=|\/=|\*\*=|\*=|%=|\^=|&=|\|=|>>>=|>>=|<<=)/,
14236
13983
  assign: /^(=)(?!=)/
14237
13984
  },
14238
13985
  next: ["modifier", "value", "prop", "incrementerBefore"]
@@ -14244,8 +13991,7 @@ var require_parser = __commonJS({
14244
13991
  expEdge: {
14245
13992
  types: {
14246
13993
  call: /^(\?\.)?[(]/,
14247
- incrementerAfter: /^(\+\+|--)/,
14248
- taggedTemplate: /^`(\d+)`/
13994
+ incrementerAfter: /^(\+\+|--)/
14249
13995
  },
14250
13996
  next: ["splitter", "expEdge", "dot", "inlineIf", "expEnd"]
14251
13997
  },
@@ -14277,7 +14023,7 @@ var require_parser = __commonJS({
14277
14023
  types: {
14278
14024
  createObject: /^\{/,
14279
14025
  createArray: /^\[/,
14280
- number: /^(0b[01]+(_[01]+)*|0o[0-7]+(_[0-7]+)*|0x[\da-f]+(_[\da-f]+)*|(\d+(_\d+)*(\.\d+(_\d+)*)?|\.\d+(_\d+)*))(e[+-]?\d+(_\d+)*)?(n)?(?!\d)/i,
14026
+ number: /^(0x[\da-f]+(_[\da-f]+)*|(\d+(_\d+)*(\.\d+(_\d+)*)?|\.\d+(_\d+)*))(e[+-]?\d+(_\d+)*)?(n)?(?!\d)/i,
14281
14027
  string: /^"(\d+)"/,
14282
14028
  literal: /^`(\d+)`/,
14283
14029
  regex: /^\/(\d+)\/r(?![\w$])/,
@@ -14385,8 +14131,6 @@ var require_parser = __commonJS({
14385
14131
  let isOneLiner = false;
14386
14132
  let i;
14387
14133
  let lastInertedSemi = false;
14388
- let seenKeyword = false;
14389
- let skipNextWord = false;
14390
14134
  for (i = 0; i < part.length && !done; i++) {
14391
14135
  let char = part.char(i);
14392
14136
  if (quote === '"' || quote === "'" || quote === "`") {
@@ -14443,15 +14187,6 @@ var require_parser = __commonJS({
14443
14187
  if (foundNumber = aNumber.exec(sub)) {
14444
14188
  i += foundNumber[0].length - 1;
14445
14189
  sub = part.substring(i).toString();
14446
- if (closingsTests) {
14447
- let found;
14448
- if (found = testMultiple(sub, closingsTests)) {
14449
- details.regRes = found;
14450
- i++;
14451
- done = true;
14452
- break;
14453
- }
14454
- }
14455
14190
  } else if (lastChar != char) {
14456
14191
  let found = null;
14457
14192
  if (char === ";" || insertedSemis[i + part.start] && !isStart && !lastInertedSemi) {
@@ -14475,16 +14210,6 @@ var require_parser = __commonJS({
14475
14210
  }
14476
14211
  if (!done && (foundWord = wordReg.exec(sub))) {
14477
14212
  isOneLiner = true;
14478
- if (foundWord[2]) {
14479
- seenKeyword = true;
14480
- skipNextWord = true;
14481
- } else if (seenKeyword) {
14482
- if (skipNextWord) {
14483
- skipNextWord = false;
14484
- } else {
14485
- details.bodyContentAfterKeyword = true;
14486
- }
14487
- }
14488
14213
  if (foundWord[0].length > 1) {
14489
14214
  details.words.push(foundWord[1]);
14490
14215
  details.lastAnyWord = foundWord[1];
@@ -14594,18 +14319,10 @@ var require_parser = __commonJS({
14594
14319
  } else {
14595
14320
  const extract3 = restOfExp(constants, str, [/^:/]);
14596
14321
  key = lispify(constants, extract3, [...next, "spreadObject"]);
14597
- if (utils.isLisp(key) && key[0] === 17) {
14598
- value = NullLisp;
14599
- } else {
14600
- if (key[0] === 1) {
14601
- key = key[2];
14602
- }
14603
- if (str.length > extract3.length && str.char(extract3.length) === ":") {
14604
- value = lispify(constants, str.substring(extract3.length + 1));
14605
- } else {
14606
- value = lispify(constants, extract3, next);
14607
- }
14322
+ if (key[0] === 1) {
14323
+ key = key[2];
14608
14324
  }
14325
+ value = lispify(constants, str.substring(extract3.length + 1));
14609
14326
  }
14610
14327
  return createLisp({
14611
14328
  op: 6,
@@ -14632,72 +14349,12 @@ var require_parser = __commonJS({
14632
14349
  };
14633
14350
  setLispType(["inverse", "not", "negative", "positive", "typeof", "delete"], (constants, type, part, res, expect, ctx) => {
14634
14351
  const extract2 = restOfExp(constants, part.substring(res[0].length), [/^([^\s.?\w$]|\?[^.])/]);
14635
- const remainingAfterOperand = part.substring(extract2.length + res[0].length);
14636
- const remainingStr = remainingAfterOperand.trim().toString();
14637
- if (remainingStr.startsWith("**")) {
14638
- throw new SyntaxError("Unary operator used immediately before exponentiation expression. Parenthesis must be used to disambiguate operator precedence");
14639
- }
14640
14352
  ctx.lispTree = lispify(constants, part.substring(extract2.length + res[0].length), restOfExp.next, createLisp({
14641
14353
  op: modifierTypes[type],
14642
14354
  a: ctx.lispTree,
14643
14355
  b: lispify(constants, extract2, expectTypes[expect].next)
14644
14356
  }));
14645
14357
  });
14646
- setLispType(["taggedTemplate"], (constants, type, part, res, expect, ctx) => {
14647
- const literalIndex = res[1];
14648
- const literal2 = constants.literals[parseInt(literalIndex)];
14649
- const [, templateStr, jsExprs] = literal2;
14650
- const stringParts = [];
14651
- const expressions = [];
14652
- let currentStr = "";
14653
- let i = 0;
14654
- while (i < templateStr.length) {
14655
- if (templateStr.substring(i, i + 2) === "${") {
14656
- let j = i + 2;
14657
- let exprIndex = "";
14658
- let isValidPlaceholder = false;
14659
- while (j < templateStr.length && templateStr[j] !== "}") {
14660
- exprIndex += templateStr[j];
14661
- j++;
14662
- }
14663
- if (j < templateStr.length && templateStr[j] === "}" && /^\d+$/.test(exprIndex)) {
14664
- isValidPlaceholder = true;
14665
- }
14666
- if (isValidPlaceholder) {
14667
- stringParts.push(currentStr);
14668
- currentStr = "";
14669
- expressions.push(jsExprs[parseInt(exprIndex)]);
14670
- i = j + 1;
14671
- } else {
14672
- currentStr += templateStr[i];
14673
- i++;
14674
- }
14675
- } else {
14676
- currentStr += templateStr[i];
14677
- i++;
14678
- }
14679
- }
14680
- stringParts.push(currentStr);
14681
- const stringsArray = stringParts.map((str) => createLisp({
14682
- op: 2,
14683
- a: 0,
14684
- b: String(constants.strings.push(str) - 1)
14685
- }));
14686
- const stringsArrayLisp = createLisp({
14687
- op: 12,
14688
- a: createLisp({
14689
- op: 0,
14690
- a: 0,
14691
- b: 0
14692
- }),
14693
- b: stringsArray
14694
- });
14695
- ctx.lispTree = lispify(constants, part.substring(res[0].length), expectTypes[expect].next, createLisp({
14696
- op: 5,
14697
- a: ctx.lispTree,
14698
- b: [stringsArrayLisp, ...expressions]
14699
- }));
14700
- });
14701
14358
  var incrementTypes = {
14702
14359
  "++$": 25,
14703
14360
  "--$": 27,
@@ -14722,7 +14379,7 @@ var require_parser = __commonJS({
14722
14379
  var adderTypes = {
14723
14380
  "&&": 29,
14724
14381
  "||": 30,
14725
- "??": 89,
14382
+ "??": 85,
14726
14383
  instanceof: 62,
14727
14384
  in: 63,
14728
14385
  "=": 9,
@@ -14737,12 +14394,9 @@ var require_parser = __commonJS({
14737
14394
  "|=": 73,
14738
14395
  ">>>=": 74,
14739
14396
  "<<=": 76,
14740
- ">>=": 75,
14741
- "&&=": 90,
14742
- "||=": 91,
14743
- "??=": 92
14397
+ ">>=": 75
14744
14398
  };
14745
- setLispType(["assign", "assignModify", "nullishCoalescing"], (constants, type, part, res, expect, ctx) => {
14399
+ setLispType(["assign", "assignModify", "boolOp"], (constants, type, part, res, expect, ctx) => {
14746
14400
  ctx.lispTree = createLisp({
14747
14401
  op: adderTypes[res[0]],
14748
14402
  a: ctx.lispTree,
@@ -14769,46 +14423,20 @@ var require_parser = __commonJS({
14769
14423
  "/": 48,
14770
14424
  "**": 49,
14771
14425
  "*": 50,
14772
- "%": 51,
14773
- "&&": 29,
14774
- "||": 30,
14775
- instanceof: 62,
14776
- in: 63
14777
- };
14778
- setLispType([
14779
- "power",
14780
- "opHigh",
14781
- "op",
14782
- "comparitor",
14783
- "bitwiseShift",
14784
- "bitwiseAnd",
14785
- "bitwiseXor",
14786
- "bitwiseOr",
14787
- "boolOpAnd",
14788
- "boolOpOr"
14789
- ], (constants, type, part, res, expect, ctx) => {
14426
+ "%": 51
14427
+ };
14428
+ setLispType(["opHigh", "op", "comparitor", "bitwise"], (constants, type, part, res, expect, ctx) => {
14790
14429
  const next = [expectTypes.inlineIf.types.inlineIf, inlineIfElse];
14791
14430
  switch (type) {
14792
- case "power":
14793
- break;
14794
14431
  case "opHigh":
14795
14432
  next.push(expectTypes.splitter.types.opHigh);
14796
14433
  case "op":
14797
14434
  next.push(expectTypes.splitter.types.op);
14798
14435
  case "comparitor":
14799
14436
  next.push(expectTypes.splitter.types.comparitor);
14800
- case "bitwiseShift":
14801
- next.push(expectTypes.splitter.types.bitwiseShift);
14802
- case "bitwiseAnd":
14803
- next.push(expectTypes.splitter.types.bitwiseAnd);
14804
- case "bitwiseXor":
14805
- next.push(expectTypes.splitter.types.bitwiseXor);
14806
- case "bitwiseOr":
14807
- next.push(expectTypes.splitter.types.bitwiseOr);
14808
- case "boolOpAnd":
14809
- next.push(expectTypes.splitter.types.boolOpAnd);
14810
- case "boolOpOr":
14811
- next.push(expectTypes.splitter.types.boolOpOr);
14437
+ case "bitwise":
14438
+ next.push(expectTypes.splitter.types.bitwise);
14439
+ next.push(expectTypes.splitter.types.boolOp);
14812
14440
  }
14813
14441
  const extract2 = restOfExp(constants, part.substring(res[0].length), next);
14814
14442
  ctx.lispTree = lispify(constants, part.substring(extract2.length + res[0].length), restOfExp.next, createLisp({
@@ -14982,11 +14610,7 @@ var require_parser = __commonJS({
14982
14610
  prop = matches[0];
14983
14611
  index = prop.length + res[0].length;
14984
14612
  } else {
14985
- throw new SyntaxError("Hanging dot");
14986
- }
14987
- } else {
14988
- if (utils.reservedWords.has(prop) && prop !== "this") {
14989
- throw new SyntaxError(`Unexpected token '${prop}'`);
14613
+ throw new SyntaxError("Hanging dot");
14990
14614
  }
14991
14615
  }
14992
14616
  ctx.lispTree = lispify(constants, part.substring(index), expectTypes[expect].next, createLisp({
@@ -15011,14 +14635,14 @@ var require_parser = __commonJS({
15011
14635
  });
15012
14636
  setLispType(["number", "boolean", "null", "und", "NaN", "Infinity"], (constants, type, part, res, expect, ctx) => {
15013
14637
  ctx.lispTree = lispify(constants, part.substring(res[0].length), expectTypes[expect].next, createLisp({
15014
- op: type === "number" ? res[12] ? 83 : 7 : 35,
14638
+ op: type === "number" ? res[10] ? 83 : 7 : 35,
15015
14639
  a: 0,
15016
- b: res[12] ? res[1] : res[0]
14640
+ b: res[10] ? res[1] : res[0]
15017
14641
  }));
15018
14642
  });
15019
14643
  setLispType(["string", "literal", "regex"], (constants, type, part, res, expect, ctx) => {
15020
14644
  ctx.lispTree = lispify(constants, part.substring(res[0].length), expectTypes[expect].next, createLisp({
15021
- op: type === "string" ? 2 : type === "literal" ? 84 : 85,
14645
+ op: type === "string" ? 2 : type === "literal" ? 84 : 86,
15022
14646
  a: 0,
15023
14647
  b: res[1]
15024
14648
  }));
@@ -15043,7 +14667,7 @@ var require_parser = __commonJS({
15043
14667
  const isArrow = type !== "function" && type !== "inlineFunction";
15044
14668
  const isReturn = isArrow && !res[res.length - 1];
15045
14669
  const argPos = isArrow ? 2 : 3;
15046
- const isAsync2 = res[1] ? 88 : 0;
14670
+ const isAsync2 = res[1] ? 89 : 0;
15047
14671
  const args = res[argPos] ? res[argPos].replace(/\s+/g, "").split(/,/g) : [];
15048
14672
  if (!isArrow) {
15049
14673
  args.unshift((res[2] || "").trimStart());
@@ -15057,11 +14681,6 @@ var require_parser = __commonJS({
15057
14681
  });
15058
14682
  const f = restOfExp(constants, part.substring(res[0].length), !isReturn ? [/^}/] : [/^[,)}\]]/, semiColon]);
15059
14683
  const func = isReturn ? "return " + f : f.toString();
15060
- args.forEach((arg) => {
15061
- if (utils.reservedWords.has(arg.replace(/^\.\.\./, ""))) {
15062
- throw new SyntaxError(`Unexpected token '${arg}'`);
15063
- }
15064
- });
15065
14684
  ctx.lispTree = lispify(constants, part.substring(res[0].length + func.length + 1), expectTypes[expect].next, createLisp({
15066
14685
  op: isArrow ? 11 : type === "function" ? 37 : 10,
15067
14686
  a: [isAsync2, ...args],
@@ -15071,13 +14690,13 @@ var require_parser = __commonJS({
15071
14690
  var iteratorRegex = /^((let|var|const)\s+)?\s*([a-zA-Z$_][a-zA-Z\d$_]*)\s+(in|of)(?![\w$])/;
15072
14691
  setLispType(["for", "do", "while"], (constants, type, part, res, expect, ctx) => {
15073
14692
  let i = 0;
15074
- let startStep = 88;
14693
+ let startStep = 89;
15075
14694
  let startInternal = [];
15076
14695
  let getIterator = 0;
15077
14696
  let beforeStep = 0;
15078
- let checkFirst = 88;
14697
+ let checkFirst = 89;
15079
14698
  let condition;
15080
- let step = 88;
14699
+ let step = 89;
15081
14700
  let body;
15082
14701
  switch (type) {
15083
14702
  case "while": {
@@ -15157,7 +14776,7 @@ var require_parser = __commonJS({
15157
14776
  });
15158
14777
  setLispType(["loopAction"], (constants, type, part, res, expect, ctx) => {
15159
14778
  ctx.lispTree = createLisp({
15160
- op: 86,
14779
+ op: 87,
15161
14780
  a: res[1],
15162
14781
  b: 0
15163
14782
  });
@@ -15172,7 +14791,7 @@ var require_parser = __commonJS({
15172
14791
  let offset2 = 0;
15173
14792
  if (catchRes[1].startsWith("catch")) {
15174
14793
  catchRes = catchReg.exec(part.substring(res[0].length + body.length + 1).toString());
15175
- exception = catchRes[3] || "";
14794
+ exception = catchRes[2];
15176
14795
  catchBody = restOfExp(constants, part.substring(res[0].length + body.length + 1 + catchRes[0].length), [], "{");
15177
14796
  offset2 = res[0].length + body.length + 1 + catchRes[0].length + catchBody.length + 1;
15178
14797
  if ((catchRes = catchReg.exec(part.substring(offset2).toString())) && catchRes[1].startsWith("finally")) {
@@ -15195,7 +14814,7 @@ var require_parser = __commonJS({
15195
14814
  setLispType(["void", "await"], (constants, type, part, res, expect, ctx) => {
15196
14815
  const extract2 = restOfExp(constants, part.substring(res[0].length), [/^([^\s.?\w$]|\?[^.])/]);
15197
14816
  ctx.lispTree = lispify(constants, part.substring(res[0].length + extract2.length), expectTypes[expect].next, createLisp({
15198
- op: type === "void" ? 87 : 44,
14817
+ op: type === "void" ? 88 : 44,
15199
14818
  a: lispify(constants, extract2),
15200
14819
  b: 0
15201
14820
  }));
@@ -15412,7 +15031,6 @@ var require_parser = __commonJS({
15412
15031
  let rest = str;
15413
15032
  let sub = emptyString;
15414
15033
  let details = {};
15415
- let pendingDoWhile = false;
15416
15034
  const inserted = insertedSemicolons.get(str.ref) || new Array(str.ref.str.length);
15417
15035
  while ((sub = restOfExp(constants, rest, [], void 0, void 0, [colonsRegex], details)).length) {
15418
15036
  let valid = false;
@@ -15427,12 +15045,7 @@ var require_parser = __commonJS({
15427
15045
  const res = closingsNoInsertion.exec(rest.substring(sub.length - 1).toString());
15428
15046
  if (res) {
15429
15047
  if (res[2] === "while") {
15430
- if (details.lastWord === "do") {
15431
- valid = false;
15432
- pendingDoWhile = true;
15433
- } else {
15434
- valid = true;
15435
- }
15048
+ valid = details.lastWord !== "do";
15436
15049
  } else {
15437
15050
  valid = false;
15438
15051
  }
@@ -15440,11 +15053,8 @@ var require_parser = __commonJS({
15440
15053
  valid = false;
15441
15054
  }
15442
15055
  } else if (a) {
15443
- if (pendingDoWhile && details.lastWord === "while") {
15444
- valid = true;
15445
- pendingDoWhile = false;
15446
- } else if (details.lastWord === "if" || details.lastWord === "while" || details.lastWord === "for" || details.lastWord === "else") {
15447
- valid = !!details.bodyContentAfterKeyword;
15056
+ if (details.lastWord === "if" || details.lastWord === "while" || details.lastWord === "for" || details.lastWord === "else") {
15057
+ valid = false;
15448
15058
  }
15449
15059
  }
15450
15060
  }
@@ -15506,7 +15116,6 @@ var require_parser = __commonJS({
15506
15116
  i++;
15507
15117
  } else if (comment === "\n") {
15508
15118
  comment = "";
15509
- strRes.push("\n");
15510
15119
  }
15511
15120
  }
15512
15121
  } else {
@@ -15615,6 +15224,8 @@ var require_SandboxExec = __commonJS({
15615
15224
  var executor = require_executor();
15616
15225
  var utils = require_utils();
15617
15226
  function subscribeSet(obj, name, callback, context) {
15227
+ if (!(obj instanceof Object))
15228
+ throw new Error("Invalid subscription object, got " + (typeof obj === "object" ? "null" : typeof obj));
15618
15229
  const names = context.setSubscriptions.get(obj) || /* @__PURE__ */ new Map();
15619
15230
  context.setSubscriptions.set(obj, names);
15620
15231
  const callbacks = names.get(name) || /* @__PURE__ */ new Set();
@@ -15640,12 +15251,6 @@ var require_SandboxExec = __commonJS({
15640
15251
  this.setSubscriptions = /* @__PURE__ */ new WeakMap();
15641
15252
  this.changeSubscriptions = /* @__PURE__ */ new WeakMap();
15642
15253
  this.sandboxFunctions = /* @__PURE__ */ new WeakMap();
15643
- this.haltSubscriptions = /* @__PURE__ */ new Set();
15644
- this.resumeSubscriptions = /* @__PURE__ */ new Set();
15645
- this.halted = false;
15646
- this.timeoutHandleCounter = 0;
15647
- this.setTimeoutHandles = /* @__PURE__ */ new Map();
15648
- this.setIntervalHandles = /* @__PURE__ */ new Map();
15649
15254
  const opt = Object.assign({
15650
15255
  audit: false,
15651
15256
  forbidFunctionCalls: false,
@@ -15658,9 +15263,7 @@ var require_SandboxExec = __commonJS({
15658
15263
  }
15659
15264
  static get SAFE_GLOBALS() {
15660
15265
  return {
15661
- globalThis,
15662
15266
  Function,
15663
- eval,
15664
15267
  console: {
15665
15268
  debug: console.debug,
15666
15269
  error: console.error,
@@ -15748,8 +15351,6 @@ var require_SandboxExec = __commonJS({
15748
15351
  map2.set(proto, /* @__PURE__ */ new Set());
15749
15352
  });
15750
15353
  map2.set(Object, /* @__PURE__ */ new Set([
15751
- "constructor",
15752
- "name",
15753
15354
  "entries",
15754
15355
  "fromEntries",
15755
15356
  "getOwnPropertyNames",
@@ -15775,56 +15376,20 @@ var require_SandboxExec = __commonJS({
15775
15376
  subscribeSetGlobal(obj, name, callback) {
15776
15377
  return subscribeSet(obj, name, callback, this);
15777
15378
  }
15778
- subscribeHalt(cb) {
15779
- this.haltSubscriptions.add(cb);
15780
- return {
15781
- unsubscribe: () => {
15782
- this.haltSubscriptions.delete(cb);
15783
- }
15784
- };
15785
- }
15786
- subscribeResume(cb) {
15787
- this.resumeSubscriptions.add(cb);
15788
- return {
15789
- unsubscribe: () => {
15790
- this.resumeSubscriptions.delete(cb);
15791
- }
15792
- };
15793
- }
15794
- haltExecution(haltContext) {
15795
- if (this.halted)
15796
- return;
15797
- this.halted = true;
15798
- for (const cb of this.haltSubscriptions) {
15799
- cb(haltContext);
15800
- }
15801
- }
15802
- resumeExecution() {
15803
- if (!this.halted)
15804
- return;
15805
- if (this.context.ticks.tickLimit && this.context.ticks.ticks >= this.context.ticks.tickLimit) {
15806
- throw new utils.SandboxExecutionQuotaExceededError("Cannot resume execution: tick limit exceeded");
15807
- }
15808
- this.halted = false;
15809
- for (const cb of this.resumeSubscriptions) {
15810
- cb();
15811
- }
15812
- }
15813
15379
  getContext(fn) {
15814
15380
  return this.sandboxFunctions.get(fn);
15815
15381
  }
15816
15382
  executeTree(context, scopes = []) {
15817
- return executor.executeTree(context.ctx.ticks, context, context.tree, scopes);
15383
+ return executor.executeTree({
15384
+ ticks: BigInt(0)
15385
+ }, context, context.tree, scopes);
15818
15386
  }
15819
15387
  executeTreeAsync(context, scopes = []) {
15820
- return executor.executeTreeAsync(context.ctx.ticks, context, context.tree, scopes);
15388
+ return executor.executeTreeAsync({
15389
+ ticks: BigInt(0)
15390
+ }, context, context.tree, scopes);
15821
15391
  }
15822
15392
  };
15823
- exports2.LocalScope = utils.LocalScope;
15824
- exports2.SandboxAccessError = utils.SandboxAccessError;
15825
- exports2.SandboxCapabilityError = utils.SandboxCapabilityError;
15826
- exports2.SandboxError = utils.SandboxError;
15827
- exports2.SandboxExecutionTreeError = utils.SandboxExecutionTreeError;
15828
15393
  exports2.default = SandboxExec;
15829
15394
  }
15830
15395
  });
@@ -15845,15 +15410,10 @@ var require_Sandbox = __commonJS({
15845
15410
  sandboxedEval,
15846
15411
  sandboxedSetTimeout,
15847
15412
  sandboxedSetInterval,
15848
- sandboxedClearTimeout,
15849
- sandboxedClearInterval,
15850
15413
  lispifyFunction: parser.lispifyFunction
15851
15414
  };
15852
15415
  }
15853
- function SB() {
15854
- }
15855
15416
  function sandboxFunction(context, ticks) {
15856
- SandboxFunction.prototype = SB.prototype;
15857
15417
  return SandboxFunction;
15858
15418
  function SandboxFunction(...params) {
15859
15419
  const code = params.pop() || "";
@@ -15865,10 +15425,7 @@ var require_Sandbox = __commonJS({
15865
15425
  }, void 0, "anonymous");
15866
15426
  }
15867
15427
  }
15868
- function SAF() {
15869
- }
15870
15428
  function sandboxAsyncFunction(context, ticks) {
15871
- SandboxAsyncFunction.prototype = SAF.prototype;
15872
15429
  return SandboxAsyncFunction;
15873
15430
  function SandboxAsyncFunction(...params) {
15874
15431
  const code = params.pop() || "";
@@ -15880,172 +15437,25 @@ var require_Sandbox = __commonJS({
15880
15437
  }, void 0, "anonymous");
15881
15438
  }
15882
15439
  }
15883
- function SE() {
15884
- }
15885
- function sandboxedEval(func, context) {
15886
- sandboxEval.prototype = SE.prototype;
15440
+ function sandboxedEval(func) {
15887
15441
  return sandboxEval;
15888
15442
  function sandboxEval(code) {
15889
- const parsed = parser.default(code);
15890
- const tree = wrapLastStatementInReturn(parsed.tree);
15891
- return executor.createFunction([], tree, executor.currentTicks.current, {
15892
- ...context,
15893
- constants: parsed.constants,
15894
- tree
15895
- }, void 0, "anonymous")();
15896
- }
15897
- }
15898
- function wrapLastStatementInReturn(tree) {
15899
- if (tree.length === 0)
15900
- return tree;
15901
- const newTree = [...tree];
15902
- const lastIndex = newTree.length - 1;
15903
- const lastStmt = newTree[lastIndex];
15904
- if (Array.isArray(lastStmt) && lastStmt.length >= 1) {
15905
- const op = lastStmt[0];
15906
- if (op === 8 || op === 46) {
15907
- return newTree;
15908
- }
15909
- const statementTypes = [
15910
- 3,
15911
- // 3
15912
- 4,
15913
- // 4
15914
- 34,
15915
- // 35
15916
- 37,
15917
- // 38
15918
- 13,
15919
- // 14
15920
- 38,
15921
- // 39
15922
- 39,
15923
- // 40
15924
- 40,
15925
- // 41
15926
- 42,
15927
- // 43
15928
- 43
15929
- // 44
15930
- ];
15931
- if (statementTypes.includes(op)) {
15932
- return newTree;
15933
- }
15934
- newTree[lastIndex] = [8, 0, lastStmt];
15935
- }
15936
- return newTree;
15937
- }
15938
- function sST() {
15939
- }
15940
- function sandboxedSetTimeout(func, context) {
15941
- sandboxSetTimeout.prototype = sST.prototype;
15942
- return sandboxSetTimeout;
15943
- function sandboxSetTimeout(handler, timeout, ...args) {
15944
- const sandbox = context.ctx.sandbox;
15945
- const exec6 = (...a) => {
15946
- const h = typeof handler === "string" ? func(handler) : handler;
15947
- haltsub.unsubscribe();
15948
- contsub.unsubscribe();
15949
- sandbox.setTimeoutHandles.delete(sandBoxhandle);
15950
- return h(...a);
15951
- };
15952
- const sandBoxhandle = ++sandbox.timeoutHandleCounter;
15953
- let start = Date.now();
15954
- let handle = setTimeout(exec6, timeout, ...args);
15955
- let elapsed = 0;
15956
- const haltsub = sandbox.subscribeHalt(() => {
15957
- elapsed = Date.now() - start + elapsed;
15958
- clearTimeout(handle);
15959
- });
15960
- const contsub = sandbox.subscribeResume(() => {
15961
- start = Date.now();
15962
- const remaining = Math.floor((timeout || 0) - elapsed);
15963
- handle = setTimeout(exec6, remaining, ...args);
15964
- sandbox.setTimeoutHandles.set(sandBoxhandle, {
15965
- handle,
15966
- haltsub,
15967
- contsub
15968
- });
15969
- });
15970
- sandbox.setTimeoutHandles.set(sandBoxhandle, {
15971
- handle,
15972
- haltsub,
15973
- contsub
15974
- });
15975
- return sandBoxhandle;
15443
+ return func(code)();
15976
15444
  }
15977
15445
  }
15978
- function sCT() {
15979
- }
15980
- function sandboxedClearTimeout(context) {
15981
- sandboxClearTimeout.prototype = sCT.prototype;
15982
- return sandboxClearTimeout;
15983
- function sandboxClearTimeout(handle) {
15984
- const sandbox = context.ctx.sandbox;
15985
- const timeoutHandle = sandbox.setTimeoutHandles.get(handle);
15986
- if (timeoutHandle) {
15987
- clearTimeout(timeoutHandle.handle);
15988
- timeoutHandle.haltsub.unsubscribe();
15989
- timeoutHandle.contsub.unsubscribe();
15990
- sandbox.setTimeoutHandles.delete(handle);
15991
- }
15992
- }
15993
- }
15994
- function sCI() {
15995
- }
15996
- function sandboxedClearInterval(context) {
15997
- sandboxClearInterval.prototype = sCI.prototype;
15998
- return sandboxClearInterval;
15999
- function sandboxClearInterval(handle) {
16000
- const sandbox = context.ctx.sandbox;
16001
- const intervalHandle = sandbox.setIntervalHandles.get(handle);
16002
- if (intervalHandle) {
16003
- clearInterval(intervalHandle.handle);
16004
- intervalHandle.haltsub.unsubscribe();
16005
- intervalHandle.contsub.unsubscribe();
16006
- sandbox.setIntervalHandles.delete(handle);
16007
- }
16008
- }
16009
- }
16010
- function sSI() {
15446
+ function sandboxedSetTimeout(func) {
15447
+ return function sandboxSetTimeout(handler, ...args) {
15448
+ if (typeof handler !== "string")
15449
+ return setTimeout(handler, ...args);
15450
+ return setTimeout(func(handler), ...args);
15451
+ };
16011
15452
  }
16012
- function sandboxedSetInterval(func, context) {
16013
- sandboxSetInterval.prototype = sSI.prototype;
16014
- return sandboxSetInterval;
16015
- function sandboxSetInterval(handler, timeout, ...args) {
16016
- const sandbox = context.ctx.sandbox;
16017
- const h = typeof handler === "string" ? func(handler) : handler;
16018
- const exec6 = (...a) => {
16019
- start = Date.now();
16020
- elapsed = 0;
16021
- return h(...a);
16022
- };
16023
- const sandBoxhandle = ++sandbox.timeoutHandleCounter;
16024
- let start = Date.now();
16025
- let handle = setInterval(exec6, timeout, ...args);
16026
- let elapsed = 0;
16027
- const haltsub = sandbox.subscribeHalt(() => {
16028
- elapsed = Date.now() - start + elapsed;
16029
- clearInterval(handle);
16030
- });
16031
- const contsub = sandbox.subscribeResume(() => {
16032
- start = Date.now();
16033
- handle = setTimeout(() => {
16034
- start = Date.now();
16035
- elapsed = 0;
16036
- handle = setInterval(exec6, timeout, ...args);
16037
- exec6(...args);
16038
- }, Math.floor((timeout || 0) - elapsed), ...args);
16039
- handlObj.handle = handle;
16040
- });
16041
- const handlObj = {
16042
- handle,
16043
- haltsub,
16044
- contsub
16045
- };
16046
- sandbox.setIntervalHandles.set(sandBoxhandle, handlObj);
16047
- return sandBoxhandle;
16048
- }
15453
+ function sandboxedSetInterval(func) {
15454
+ return function sandboxSetInterval(handler, ...args) {
15455
+ if (typeof handler !== "string")
15456
+ return setInterval(handler, ...args);
15457
+ return setInterval(func(handler), ...args);
15458
+ };
16049
15459
  }
16050
15460
  var Sandbox2 = class extends SandboxExec.default {
16051
15461
  constructor(options) {
@@ -16104,11 +15514,6 @@ var require_Sandbox = __commonJS({
16104
15514
  return exec6;
16105
15515
  }
16106
15516
  };
16107
- exports2.LocalScope = utils.LocalScope;
16108
- exports2.SandboxAccessError = utils.SandboxAccessError;
16109
- exports2.SandboxCapabilityError = utils.SandboxCapabilityError;
16110
- exports2.SandboxError = utils.SandboxError;
16111
- exports2.SandboxExecutionTreeError = utils.SandboxExecutionTreeError;
16112
15517
  exports2.default = Sandbox2;
16113
15518
  }
16114
15519
  });
@@ -68643,9 +68048,11 @@ __export(schemaUtils_exports, {
68643
68048
  isJsonSchema: () => isJsonSchema,
68644
68049
  isJsonSchemaDefinition: () => isJsonSchemaDefinition,
68645
68050
  isMermaidSchema: () => isMermaidSchema,
68051
+ isSimpleTextWrapperSchema: () => isSimpleTextWrapperSchema,
68646
68052
  processSchemaResponse: () => processSchemaResponse,
68647
68053
  replaceMermaidDiagramsInJson: () => replaceMermaidDiagramsInJson,
68648
68054
  replaceMermaidDiagramsInMarkdown: () => replaceMermaidDiagramsInMarkdown,
68055
+ tryAutoWrapForSimpleSchema: () => tryAutoWrapForSimpleSchema,
68649
68056
  tryMaidAutoFix: () => tryMaidAutoFix,
68650
68057
  validateAndFixMermaidResponse: () => validateAndFixMermaidResponse,
68651
68058
  validateJsonResponse: () => validateJsonResponse,
@@ -69163,6 +68570,46 @@ function isJsonSchemaDefinition(jsonString, options = {}) {
69163
68570
  return false;
69164
68571
  }
69165
68572
  }
68573
+ function isSimpleTextWrapperSchema(schema) {
68574
+ if (!schema || typeof schema !== "string") {
68575
+ return null;
68576
+ }
68577
+ const trimmed = schema.trim();
68578
+ const simplePatterns = [
68579
+ /^\{\s*["']?(\w+)["']?\s*:\s*["']?string["']?\s*\}$/i,
68580
+ /^\{\s*["']?type["']?\s*:\s*["']?object["']?\s*,\s*["']?properties["']?\s*:\s*\{\s*["']?(\w+)["']?\s*:\s*\{\s*["']?type["']?\s*:\s*["']?string["']?\s*\}\s*\}\s*\}$/i
68581
+ ];
68582
+ for (const pattern of simplePatterns) {
68583
+ const match2 = trimmed.match(pattern);
68584
+ if (match2) {
68585
+ return { fieldName: match2[1] };
68586
+ }
68587
+ }
68588
+ return null;
68589
+ }
68590
+ function tryAutoWrapForSimpleSchema(response, schema, options = {}) {
68591
+ const { debug = false } = options;
68592
+ const wrapperInfo = isSimpleTextWrapperSchema(schema);
68593
+ if (!wrapperInfo) {
68594
+ if (debug) {
68595
+ console.log(`[DEBUG] Auto-wrap: Schema is not a simple text wrapper`);
68596
+ }
68597
+ return null;
68598
+ }
68599
+ try {
68600
+ JSON.parse(response);
68601
+ if (debug) {
68602
+ console.log(`[DEBUG] Auto-wrap: Response is already valid JSON, skipping`);
68603
+ }
68604
+ return null;
68605
+ } catch {
68606
+ }
68607
+ const wrapped = JSON.stringify({ [wrapperInfo.fieldName]: response });
68608
+ if (debug) {
68609
+ console.log(`[DEBUG] Auto-wrap: Wrapped plain text in {"${wrapperInfo.fieldName}": ...} (${response.length} chars)`);
68610
+ }
68611
+ return wrapped;
68612
+ }
69166
68613
  function createJsonCorrectionPrompt(invalidResponse, schema, errorOrValidation, retryCount = 0) {
69167
68614
  let errorMessage;
69168
68615
  let enhancedError;
@@ -69194,7 +68641,7 @@ function createJsonCorrectionPrompt(invalidResponse, schema, errorOrValidation,
69194
68641
  const currentLevel = strengthLevels[level];
69195
68642
  let prompt = `${currentLevel.prefix} Your previous response is not valid JSON and cannot be parsed. Here's what you returned:
69196
68643
 
69197
- ${invalidResponse.substring(0, 500)}${invalidResponse.length > 500 ? "..." : ""}
68644
+ ${invalidResponse}
69198
68645
 
69199
68646
  Error: ${enhancedError}
69200
68647
 
@@ -84232,6 +83679,14 @@ ${errorXml}
84232
83679
  });
84233
83680
  const executeToolCall = async () => {
84234
83681
  if (toolName === "delegate") {
83682
+ let allowedToolsForDelegate = null;
83683
+ if (this.allowedTools.mode === "whitelist") {
83684
+ allowedToolsForDelegate = [...this.allowedTools.allowed];
83685
+ } else if (this.allowedTools.mode === "none") {
83686
+ allowedToolsForDelegate = [];
83687
+ } else if (this.allowedTools.mode === "all" && this.allowedTools.exclusions?.length > 0) {
83688
+ allowedToolsForDelegate = ["*", ...this.allowedTools.exclusions.map((t) => "!" + t)];
83689
+ }
84235
83690
  const enhancedParams = {
84236
83691
  ...toolParams,
84237
83692
  currentIteration,
@@ -84247,6 +83702,18 @@ ${errorXml}
84247
83702
  searchDelegate: this.searchDelegate,
84248
83703
  enableTasks: this.enableTasks,
84249
83704
  // Inherit task management (subagent gets isolated TaskManager)
83705
+ enableMcp: !!this.mcpBridge,
83706
+ // Inherit MCP enablement
83707
+ mcpConfig: this.mcpConfig,
83708
+ // Inherit MCP configuration
83709
+ mcpConfigPath: this.mcpConfigPath,
83710
+ // Inherit MCP config path
83711
+ enableBash: this.enableBash,
83712
+ // Inherit bash enablement
83713
+ bashConfig: this.bashConfig,
83714
+ // Inherit bash configuration
83715
+ allowedTools: allowedToolsForDelegate,
83716
+ // Inherit allowed tools from parent
84250
83717
  debug: this.debug,
84251
83718
  tracer: this.tracer
84252
83719
  };
@@ -84865,6 +84332,16 @@ Convert your previous response content into actual JSON data that follows this s
84865
84332
  validation = validateJsonResponse(finalResult);
84866
84333
  retryCount = 1;
84867
84334
  }
84335
+ if (!validation.isValid) {
84336
+ const autoWrapped = tryAutoWrapForSimpleSchema(finalResult, options.schema, { debug: this.debug });
84337
+ if (autoWrapped) {
84338
+ if (this.debug) {
84339
+ console.log(`[DEBUG] JSON validation: Auto-wrapped plain text for simple schema`);
84340
+ }
84341
+ finalResult = autoWrapped;
84342
+ validation = validateJsonResponse(finalResult, { debug: this.debug });
84343
+ }
84344
+ }
84868
84345
  while (!validation.isValid && retryCount < maxRetries) {
84869
84346
  if (this.debug) {
84870
84347
  console.log(`[DEBUG] JSON validation: attempt_completion validation failed (attempt ${retryCount + 1}/${maxRetries}):`, validation.error);