@probelabs/probe 0.6.0-rc233 → 0.6.0-rc234

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.
@@ -36512,7 +36512,7 @@ Manage tasks for tracking progress during code exploration and problem-solving.
36512
36512
 
36513
36513
  Parameters:
36514
36514
  - action: (required) The action to perform: create, update, complete, delete, list
36515
- - tasks: (optional) JSON array for batch operations - alternative to single-task params
36515
+ - tasks: (optional) Array of task objects for batch operations. Place raw JSON array directly between tags.
36516
36516
  - id: (optional) Task ID for single operations (e.g., "task-1")
36517
36517
  - title: (optional) Task title for create/update
36518
36518
  - description: (optional) Task description for create/update
@@ -36521,6 +36521,11 @@ Parameters:
36521
36521
  - dependencies: (optional) JSON array of task IDs that must be completed first
36522
36522
  - after: (optional) Task ID to insert the new task after (for ordering). By default, new tasks are appended to the end
36523
36523
 
36524
+ IMPORTANT - JSON Format:
36525
+ Place raw JSON arrays directly between tags without quotes or escaping:
36526
+ CORRECT: <tasks>[{"title": "Do X"}]</tasks>
36527
+ INCORRECT: <tasks>"[{"title": "Do X"}]"</tasks>
36528
+
36524
36529
  Usage Examples:
36525
36530
 
36526
36531
  Creating a single task:
@@ -39509,6 +39514,8 @@ var require_utils = __commonJS({
39509
39514
  var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {
39510
39515
  }).constructor;
39511
39516
  var SandboxGlobal = function SandboxGlobal2(globals) {
39517
+ if (globals === globalThis)
39518
+ return globalThis;
39512
39519
  for (const i4 in globals) {
39513
39520
  this[i4] = globals[i4];
39514
39521
  }
@@ -39537,9 +39544,7 @@ var require_utils = __commonJS({
39537
39544
  prototypeWhitelist: new Map([...options.prototypeWhitelist].map((a4) => [a4[0].prototype, a4[1]])),
39538
39545
  options,
39539
39546
  globalScope: new Scope3(null, options.globals, sandboxGlobal),
39540
- sandboxGlobal,
39541
- ticks: { ticks: 0n, tickLimit: options.executionQuota },
39542
- sandboxedFunctions: /* @__PURE__ */ new WeakSet()
39547
+ sandboxGlobal
39543
39548
  };
39544
39549
  context.prototypeWhitelist.set(Object.getPrototypeOf([][Symbol.iterator]()), /* @__PURE__ */ new Set());
39545
39550
  return context;
@@ -39554,15 +39559,9 @@ var require_utils = __commonJS({
39554
39559
  evals.set(AsyncFunction, asyncFunc);
39555
39560
  evals.set(GeneratorFunction, func);
39556
39561
  evals.set(AsyncGeneratorFunction, asyncFunc);
39557
- evals.set(eval, evalContext.sandboxedEval(func, execContext));
39558
- evals.set(setTimeout, evalContext.sandboxedSetTimeout(func, execContext));
39559
- evals.set(setInterval, evalContext.sandboxedSetInterval(func, execContext));
39560
- evals.set(clearTimeout, evalContext.sandboxedClearTimeout(execContext));
39561
- evals.set(clearInterval, evalContext.sandboxedClearInterval(execContext));
39562
- for (const [key, value] of evals) {
39563
- sandbox.context.prototypeWhitelist.set(value.prototype, /* @__PURE__ */ new Set());
39564
- sandbox.context.prototypeWhitelist.set(key.prototype, /* @__PURE__ */ new Set());
39565
- }
39562
+ evals.set(eval, evalContext.sandboxedEval(func));
39563
+ evals.set(setTimeout, evalContext.sandboxedSetTimeout(func));
39564
+ evals.set(setInterval, evalContext.sandboxedSetInterval(func));
39566
39565
  }
39567
39566
  return execContext;
39568
39567
  }
@@ -39659,45 +39658,34 @@ var require_utils = __commonJS({
39659
39658
  return ret;
39660
39659
  }
39661
39660
  var reservedWords2 = /* @__PURE__ */ new Set([
39662
- "await",
39663
- "break",
39664
- "case",
39665
- "catch",
39666
- "class",
39667
- "const",
39668
- "continue",
39669
- "debugger",
39670
- "default",
39671
- "delete",
39672
- "do",
39673
- "else",
39674
- "enum",
39675
- "export",
39676
- "extends",
39677
- "false",
39678
- "finally",
39679
- "for",
39680
- "function",
39681
- "if",
39682
- "implements",
39683
- "import",
39684
- "in",
39685
39661
  "instanceof",
39686
- "let",
39687
- "new",
39688
- "null",
39662
+ "typeof",
39689
39663
  "return",
39690
- "super",
39691
- "switch",
39692
- "this",
39693
39664
  "throw",
39694
- "true",
39695
39665
  "try",
39696
- "typeof",
39666
+ "catch",
39667
+ "if",
39668
+ "finally",
39669
+ "else",
39670
+ "in",
39671
+ "of",
39697
39672
  "var",
39698
- "void",
39673
+ "let",
39674
+ "const",
39675
+ "for",
39676
+ "delete",
39677
+ "false",
39678
+ "true",
39699
39679
  "while",
39700
- "with"
39680
+ "do",
39681
+ "break",
39682
+ "continue",
39683
+ "new",
39684
+ "function",
39685
+ "async",
39686
+ "await",
39687
+ "switch",
39688
+ "case"
39701
39689
  ]);
39702
39690
  var Scope3 = class {
39703
39691
  constructor(parent, vars = {}, functionThis) {
@@ -39712,16 +39700,25 @@ var require_utils = __commonJS({
39712
39700
  this.globals = parent === null ? keysOnly(vars) : {};
39713
39701
  this.functionThis = functionThis;
39714
39702
  }
39715
- get(key) {
39716
- const isThis = key === "this";
39717
- const scope = this.getWhereValScope(key, isThis);
39718
- if (scope && isThis) {
39719
- return new Prop({ this: scope.functionThis }, key, false, false, true);
39703
+ get(key, functionScope = false) {
39704
+ const functionThis = this.functionThis;
39705
+ if (key === "this" && functionThis !== void 0) {
39706
+ return new Prop({ this: functionThis }, key, true, false, true);
39720
39707
  }
39721
- if (!scope) {
39722
- return new Prop(void 0, key);
39708
+ if (reservedWords2.has(key))
39709
+ throw new SyntaxError("Unexepected token '" + key + "'");
39710
+ if (this.parent === null || !functionScope || functionThis !== void 0) {
39711
+ if (this.globals.hasOwnProperty(key)) {
39712
+ return new Prop(functionThis, key, false, true, true);
39713
+ }
39714
+ if (key in this.allVars && (!(key in {}) || this.allVars.hasOwnProperty(key))) {
39715
+ return new Prop(this.allVars, key, this.const.hasOwnProperty(key), this.globals.hasOwnProperty(key), true);
39716
+ }
39717
+ if (this.parent === null) {
39718
+ return new Prop(void 0, key);
39719
+ }
39723
39720
  }
39724
- return new Prop(scope.allVars, key, key in scope.const, key in scope.globals, true);
39721
+ return this.parent.get(key, functionScope);
39725
39722
  }
39726
39723
  set(key, val) {
39727
39724
  if (key === "this")
@@ -39732,72 +39729,34 @@ var require_utils = __commonJS({
39732
39729
  if (prop.context === void 0) {
39733
39730
  throw new ReferenceError(`Variable '${key}' was not declared.`);
39734
39731
  }
39735
- if (prop.context === null) {
39736
- throw new TypeError(`Cannot set properties of null, (setting '${key}')`);
39737
- }
39738
39732
  if (prop.isConst) {
39739
39733
  throw new TypeError(`Cannot assign to const variable '${key}'`);
39740
39734
  }
39741
39735
  if (prop.isGlobal) {
39742
39736
  throw new SandboxError(`Cannot override global variable '${key}'`);
39743
39737
  }
39738
+ if (!(prop.context instanceof Object))
39739
+ throw new SandboxError("Scope is not an object");
39744
39740
  prop.context[prop.prop] = val;
39745
39741
  return prop;
39746
39742
  }
39747
- getWhereValScope(key, isThis) {
39748
- if (isThis) {
39749
- if (this.functionThis !== void 0) {
39750
- return this;
39751
- } else {
39752
- return this.parent?.getWhereValScope(key, isThis) || null;
39753
- }
39754
- }
39755
- if (key in this.allVars && !(key in {} && !hasOwnProperty19(this.allVars, key))) {
39756
- return this;
39757
- }
39758
- return this.parent?.getWhereValScope(key, isThis) || null;
39759
- }
39760
- getWhereVarScope(key, localScope = false) {
39761
- if (key in this.allVars && !(key in {} && !hasOwnProperty19(this.allVars, key))) {
39762
- return this;
39763
- }
39764
- if (this.parent === null || localScope || this.functionThis !== void 0) {
39765
- return this;
39766
- }
39767
- return this.parent.getWhereVarScope(key, localScope);
39768
- }
39769
39743
  declare(key, type, value = void 0, isGlobal = false) {
39770
39744
  if (key === "this")
39771
39745
  throw new SyntaxError('"this" cannot be declared');
39772
39746
  if (reservedWords2.has(key))
39773
39747
  throw new SyntaxError("Unexepected token '" + key + "'");
39774
- const existingScope = this.getWhereVarScope(
39775
- key,
39776
- type !== "var"
39777
- /* VarType.var */
39778
- );
39779
- if (type === "var") {
39780
- if (existingScope.var[key]) {
39781
- existingScope.allVars[key] = value;
39782
- if (!isGlobal) {
39783
- delete existingScope.globals[key];
39784
- } else {
39785
- existingScope.globals[key] = true;
39786
- }
39787
- return new Prop(existingScope.allVars, key, false, existingScope.globals[key], true);
39788
- } else if (key in existingScope.allVars) {
39789
- throw new SyntaxError(`Identifier '${key}' has already been declared`);
39790
- }
39791
- }
39792
- if (key in existingScope.allVars) {
39793
- throw new SyntaxError(`Identifier '${key}' has already been declared`);
39794
- }
39795
- if (isGlobal) {
39796
- existingScope.globals[key] = true;
39748
+ if (type === "var" && this.functionThis === void 0 && this.parent !== null) {
39749
+ return this.parent.declare(key, type, value, isGlobal);
39750
+ } else if (this[type].hasOwnProperty(key) && type !== "const" && !this.globals.hasOwnProperty(key) || !(key in this.allVars)) {
39751
+ if (isGlobal) {
39752
+ this.globals[key] = true;
39753
+ }
39754
+ this[type][key] = true;
39755
+ this.allVars[key] = value;
39756
+ } else {
39757
+ throw new SandboxError(`Identifier '${key}' has already been declared`);
39797
39758
  }
39798
- existingScope[type][key] = true;
39799
- existingScope.allVars[key] = value;
39800
- return new Prop(this.allVars, key, type === "const", isGlobal, true);
39759
+ return new Prop(this.allVars, key, this.const.hasOwnProperty(key), isGlobal);
39801
39760
  }
39802
39761
  };
39803
39762
  var FunctionScope = class {
@@ -39806,16 +39765,8 @@ var require_utils = __commonJS({
39806
39765
  };
39807
39766
  var SandboxError = class extends Error {
39808
39767
  };
39809
- var SandboxExecutionQuotaExceededError = class extends SandboxError {
39810
- };
39811
- var SandboxExecutionTreeError = class extends SandboxError {
39812
- };
39813
- var SandboxCapabilityError = class extends SandboxError {
39814
- };
39815
- var SandboxAccessError = class extends SandboxError {
39816
- };
39817
39768
  function isLisp(item) {
39818
- return Array.isArray(item) && typeof item[0] === "number" && item[0] !== 0 && item[0] !== 88;
39769
+ return Array.isArray(item) && typeof item[0] === "number" && item[0] !== 0 && item[0] !== 89;
39819
39770
  }
39820
39771
  var Prop = class {
39821
39772
  constructor(context, prop, isConst = false, isGlobal = false, isVariable = false) {
@@ -39828,16 +39779,13 @@ var require_utils = __commonJS({
39828
39779
  get(context) {
39829
39780
  const ctx = this.context;
39830
39781
  if (ctx === void 0)
39831
- throw new ReferenceError(`${this.prop.toString()} is not defined`);
39782
+ throw new ReferenceError(`${this.prop} is not defined`);
39832
39783
  if (ctx === null)
39833
- throw new TypeError(`Cannot read properties of null, (reading '${this.prop.toString()}')`);
39834
- context.getSubscriptions.forEach((cb) => cb(ctx, this.prop.toString()));
39784
+ throw new TypeError(`Cannot read properties of null, (reading '${this.prop}')`);
39785
+ context.getSubscriptions.forEach((cb) => cb(ctx, this.prop));
39835
39786
  return ctx[this.prop];
39836
39787
  }
39837
39788
  };
39838
- function hasOwnProperty19(obj, prop) {
39839
- return Object.prototype.hasOwnProperty.call(obj, prop);
39840
- }
39841
39789
  exports2.AsyncFunction = AsyncFunction;
39842
39790
  exports2.AsyncGeneratorFunction = AsyncGeneratorFunction;
39843
39791
  exports2.CodeString = CodeString;
@@ -39846,18 +39794,12 @@ var require_utils = __commonJS({
39846
39794
  exports2.GeneratorFunction = GeneratorFunction;
39847
39795
  exports2.LocalScope = LocalScope;
39848
39796
  exports2.Prop = Prop;
39849
- exports2.SandboxAccessError = SandboxAccessError;
39850
- exports2.SandboxCapabilityError = SandboxCapabilityError;
39851
39797
  exports2.SandboxError = SandboxError;
39852
- exports2.SandboxExecutionQuotaExceededError = SandboxExecutionQuotaExceededError;
39853
- exports2.SandboxExecutionTreeError = SandboxExecutionTreeError;
39854
39798
  exports2.SandboxGlobal = SandboxGlobal;
39855
39799
  exports2.Scope = Scope3;
39856
39800
  exports2.createContext = createContext;
39857
39801
  exports2.createExecContext = createExecContext;
39858
- exports2.hasOwnProperty = hasOwnProperty19;
39859
39802
  exports2.isLisp = isLisp;
39860
- exports2.reservedWords = reservedWords2;
39861
39803
  }
39862
39804
  });
39863
39805
 
@@ -39887,9 +39829,10 @@ var require_executor = __commonJS({
39887
39829
  });
39888
39830
  return vars;
39889
39831
  }
39832
+ var sandboxedFunctions = /* @__PURE__ */ new WeakSet();
39890
39833
  function createFunction(argNames, parsed, ticks, context, scope, name14) {
39891
39834
  if (context.ctx.options.forbidFunctionCreation) {
39892
- throw new utils.SandboxCapabilityError("Function creation is forbidden");
39835
+ throw new utils.SandboxError("Function creation is forbidden");
39893
39836
  }
39894
39837
  let func;
39895
39838
  if (name14 === void 0) {
@@ -39906,15 +39849,15 @@ var require_executor = __commonJS({
39906
39849
  };
39907
39850
  }
39908
39851
  context.registerSandboxFunction(func);
39909
- context.ctx.sandboxedFunctions.add(func);
39852
+ sandboxedFunctions.add(func);
39910
39853
  return func;
39911
39854
  }
39912
39855
  function createFunctionAsync(argNames, parsed, ticks, context, scope, name14) {
39913
39856
  if (context.ctx.options.forbidFunctionCreation) {
39914
- throw new utils.SandboxCapabilityError("Function creation is forbidden");
39857
+ throw new utils.SandboxError("Function creation is forbidden");
39915
39858
  }
39916
39859
  if (!context.ctx.prototypeWhitelist?.has(Promise.prototype)) {
39917
- throw new utils.SandboxCapabilityError("Async/await not permitted");
39860
+ throw new utils.SandboxError("Async/await not permitted");
39918
39861
  }
39919
39862
  let func;
39920
39863
  if (name14 === void 0) {
@@ -39931,40 +39874,43 @@ var require_executor = __commonJS({
39931
39874
  };
39932
39875
  }
39933
39876
  context.registerSandboxFunction(func);
39934
- context.ctx.sandboxedFunctions.add(func);
39877
+ sandboxedFunctions.add(func);
39935
39878
  return func;
39936
39879
  }
39937
39880
  function assignCheck(obj, context, op2 = "assign") {
39938
39881
  if (obj.context === void 0) {
39939
39882
  throw new ReferenceError(`Cannot ${op2} value to undefined.`);
39940
39883
  }
39884
+ if (typeof obj.context !== "object" && typeof obj.context !== "function") {
39885
+ throw new SyntaxError(`Cannot ${op2} value to a primitive.`);
39886
+ }
39941
39887
  if (obj.isConst) {
39942
- throw new TypeError(`Assignment to constant variable.`);
39888
+ throw new TypeError(`Cannot set value to const variable '${obj.prop}'`);
39943
39889
  }
39944
39890
  if (obj.isGlobal) {
39945
- throw new utils.SandboxAccessError(`Cannot ${op2} property '${obj.prop.toString()}' of a global object`);
39891
+ throw new utils.SandboxError(`Cannot ${op2} property '${obj.prop}' of a global object`);
39946
39892
  }
39947
39893
  if (obj.context === null) {
39948
39894
  throw new TypeError("Cannot set properties of null");
39949
39895
  }
39950
- if (typeof obj.context[obj.prop] === "function" && !utils.hasOwnProperty(obj.context, obj.prop)) {
39951
- throw new utils.SandboxAccessError(`Override prototype property '${obj.prop.toString()}' not allowed`);
39896
+ if (typeof obj.context[obj.prop] === "function" && !obj.context.hasOwnProperty(obj.prop)) {
39897
+ throw new utils.SandboxError(`Override prototype property '${obj.prop}' not allowed`);
39952
39898
  }
39953
39899
  if (op2 === "delete") {
39954
- if (utils.hasOwnProperty(obj.context, obj.prop)) {
39955
- context.changeSubscriptions.get(obj.context)?.forEach((cb) => cb({ type: "delete", prop: obj.prop.toString() }));
39956
- context.changeSubscriptionsGlobal.get(obj.context)?.forEach((cb) => cb({ type: "delete", prop: obj.prop.toString() }));
39900
+ if (obj.context.hasOwnProperty(obj.prop)) {
39901
+ context.changeSubscriptions.get(obj.context)?.forEach((cb) => cb({ type: "delete", prop: obj.prop }));
39902
+ context.changeSubscriptionsGlobal.get(obj.context)?.forEach((cb) => cb({ type: "delete", prop: obj.prop }));
39957
39903
  }
39958
- } else if (utils.hasOwnProperty(obj.context, obj.prop)) {
39959
- context.setSubscriptions.get(obj.context)?.get(obj.prop.toString())?.forEach((cb) => cb({
39904
+ } else if (obj.context.hasOwnProperty(obj.prop)) {
39905
+ context.setSubscriptions.get(obj.context)?.get(obj.prop)?.forEach((cb) => cb({
39960
39906
  type: "replace"
39961
39907
  }));
39962
- context.setSubscriptionsGlobal.get(obj.context)?.get(obj.prop.toString())?.forEach((cb) => cb({
39908
+ context.setSubscriptionsGlobal.get(obj.context)?.get(obj.prop)?.forEach((cb) => cb({
39963
39909
  type: "replace"
39964
39910
  }));
39965
39911
  } else {
39966
- context.changeSubscriptions.get(obj.context)?.forEach((cb) => cb({ type: "create", prop: obj.prop.toString() }));
39967
- context.changeSubscriptionsGlobal.get(obj.context)?.forEach((cb) => cb({ type: "create", prop: obj.prop.toString() }));
39912
+ context.changeSubscriptions.get(obj.context)?.forEach((cb) => cb({ type: "create", prop: obj.prop }));
39913
+ context.changeSubscriptionsGlobal.get(obj.context)?.forEach((cb) => cb({ type: "create", prop: obj.prop }));
39968
39914
  }
39969
39915
  }
39970
39916
  var arrayChange = /* @__PURE__ */ new Set([
@@ -40004,128 +39950,107 @@ var require_executor = __commonJS({
40004
39950
  function addOps(type, cb) {
40005
39951
  ops.set(type, cb);
40006
39952
  }
40007
- var prorptyKeyTypes = ["string", "number", "symbol"];
40008
- function isPropertyKey(val) {
40009
- return prorptyKeyTypes.includes(typeof val);
40010
- }
40011
- function hasPossibleProperties(val) {
40012
- return val !== null && val !== void 0;
40013
- }
40014
- addOps(1, ({ done, a: a4, b: b4, obj, context, scope }) => {
39953
+ addOps(1, (exec6, done, ticks, a4, b4, obj, context, scope) => {
40015
39954
  if (a4 === null) {
40016
- throw new TypeError(`Cannot read properties of null (reading '${b4?.toString()}')`);
39955
+ throw new TypeError(`Cannot get property ${b4} of null`);
40017
39956
  }
40018
- if (!isPropertyKey(b4)) {
40019
- b4 = `${b4}`;
40020
- }
40021
- if (a4 === void 0 && obj === void 0 && typeof b4 === "string") {
39957
+ const type = typeof a4;
39958
+ if (type === "undefined" && obj === void 0) {
40022
39959
  const prop = scope.get(b4);
40023
39960
  if (prop.context === context.ctx.sandboxGlobal) {
40024
39961
  if (context.ctx.options.audit) {
40025
39962
  context.ctx.auditReport?.globalsAccess.add(b4);
40026
39963
  }
39964
+ const rep = context.ctx.globalsWhitelist.has(context.ctx.sandboxGlobal[b4]) ? context.evals.get(context.ctx.sandboxGlobal[b4]) : void 0;
39965
+ if (rep) {
39966
+ done(void 0, rep);
39967
+ return;
39968
+ }
40027
39969
  }
40028
- const val2 = prop.context ? prop.context[prop.prop] : void 0;
40029
- const p5 = getGlobalProp(val2, context, prop) || prop;
40030
- done(void 0, p5);
39970
+ if (prop.context && prop.context[b4] === globalThis) {
39971
+ done(void 0, context.ctx.globalScope.get("this"));
39972
+ return;
39973
+ }
39974
+ done(void 0, prop);
40031
39975
  return;
40032
39976
  } else if (a4 === void 0) {
40033
- throw new TypeError(`Cannot read properties of undefined (reading '${b4.toString()}')`);
39977
+ throw new utils.SandboxError("Cannot get property '" + b4 + "' of undefined");
40034
39978
  }
40035
- if (!hasPossibleProperties(a4)) {
39979
+ if (type !== "object") {
39980
+ if (type === "number") {
39981
+ a4 = new Number(a4);
39982
+ } else if (type === "string") {
39983
+ a4 = new String(a4);
39984
+ } else if (type === "boolean") {
39985
+ a4 = new Boolean(a4);
39986
+ }
39987
+ } else if (typeof a4.hasOwnProperty === "undefined") {
40036
39988
  done(void 0, new utils.Prop(void 0, b4));
40037
39989
  return;
40038
39990
  }
40039
- const prototypeAccess = typeof a4 === "function" || !utils.hasOwnProperty(a4, b4);
39991
+ const isFunction2 = type === "function";
39992
+ const prototypeAccess = isFunction2 || !(a4.hasOwnProperty(b4) || typeof b4 === "number");
40040
39993
  if (context.ctx.options.audit && prototypeAccess) {
40041
- let prot = Object.getPrototypeOf(a4);
40042
- do {
40043
- if (utils.hasOwnProperty(prot, b4)) {
40044
- if (context.ctx.auditReport && !context.ctx.auditReport.prototypeAccess[prot.constructor.name]) {
40045
- context.ctx.auditReport.prototypeAccess[prot.constructor.name] = /* @__PURE__ */ new Set();
39994
+ if (typeof b4 === "string") {
39995
+ let prot = Object.getPrototypeOf(a4);
39996
+ do {
39997
+ if (prot.hasOwnProperty(b4)) {
39998
+ if (context.ctx.auditReport && !context.ctx.auditReport.prototypeAccess[prot.constructor.name]) {
39999
+ context.ctx.auditReport.prototypeAccess[prot.constructor.name] = /* @__PURE__ */ new Set();
40000
+ }
40001
+ context.ctx.auditReport?.prototypeAccess[prot.constructor.name].add(b4);
40046
40002
  }
40047
- context.ctx.auditReport?.prototypeAccess[prot.constructor.name].add(b4);
40048
- }
40049
- } while (prot = Object.getPrototypeOf(prot));
40003
+ } while (prot = Object.getPrototypeOf(prot));
40004
+ }
40050
40005
  }
40051
40006
  if (prototypeAccess) {
40052
- if (typeof a4 === "function") {
40053
- if (utils.hasOwnProperty(a4, b4)) {
40007
+ if (isFunction2) {
40008
+ if (!["name", "length", "constructor"].includes(b4) && a4.hasOwnProperty(b4)) {
40054
40009
  const whitelist = context.ctx.prototypeWhitelist.get(a4.prototype);
40055
40010
  const replace = context.ctx.options.prototypeReplacements.get(a4);
40056
40011
  if (replace) {
40057
40012
  done(void 0, new utils.Prop(replace(a4, true), b4));
40058
40013
  return;
40059
40014
  }
40060
- if (!(whitelist && (!whitelist.size || whitelist.has(b4))) && !context.ctx.sandboxedFunctions.has(a4)) {
40061
- throw new utils.SandboxAccessError(`Static method or property access not permitted: ${a4.name}.${b4.toString()}`);
40015
+ if (!(whitelist && (!whitelist.size || whitelist.has(b4)))) {
40016
+ throw new utils.SandboxError(`Static method or property access not permitted: ${a4.name}.${b4}`);
40062
40017
  }
40063
40018
  }
40064
40019
  }
40065
- let prot = a4;
40066
- while (prot = Object.getPrototypeOf(prot)) {
40067
- if (utils.hasOwnProperty(prot, b4) || b4 === "__proto__") {
40068
- const whitelist = context.ctx.prototypeWhitelist.get(prot);
40069
- const replace = context.ctx.options.prototypeReplacements.get(prot.constructor);
40070
- if (replace) {
40071
- done(void 0, new utils.Prop(replace(a4, false), b4));
40072
- return;
40073
- }
40074
- if (whitelist && (!whitelist.size || whitelist.has(b4)) || context.ctx.sandboxedFunctions.has(prot.constructor)) {
40075
- break;
40076
- }
40077
- if (b4 === "__proto__") {
40078
- throw new utils.SandboxAccessError(`Access to prototype of global object is not permitted`);
40020
+ if (b4 !== "constructor") {
40021
+ let prot = a4;
40022
+ while (prot = Object.getPrototypeOf(prot)) {
40023
+ if (prot.hasOwnProperty(b4)) {
40024
+ const whitelist = context.ctx.prototypeWhitelist.get(prot);
40025
+ const replace = context.ctx.options.prototypeReplacements.get(prot.constuctor);
40026
+ if (replace) {
40027
+ done(void 0, new utils.Prop(replace(a4, false), b4));
40028
+ return;
40029
+ }
40030
+ if (whitelist && (!whitelist.size || whitelist.has(b4))) {
40031
+ break;
40032
+ }
40033
+ throw new utils.SandboxError(`Method or property access not permitted: ${prot.constructor.name}.${b4}`);
40079
40034
  }
40080
- throw new utils.SandboxAccessError(`Method or property access not permitted: ${prot.constructor.name}.${b4.toString()}`);
40081
40035
  }
40082
40036
  }
40083
40037
  }
40084
- const val = a4[b4];
40085
- if (typeof a4 === "function") {
40086
- if (b4 === "prototype" && !context.ctx.sandboxedFunctions.has(a4)) {
40087
- throw new utils.SandboxAccessError(`Access to prototype of global object is not permitted`);
40088
- }
40089
- }
40090
- if (b4 === "__proto__" && !context.ctx.sandboxedFunctions.has(val?.constructor)) {
40091
- throw new utils.SandboxAccessError(`Access to prototype of global object is not permitted`);
40092
- }
40093
- const p4 = getGlobalProp(val, context);
40094
- if (p4) {
40095
- done(void 0, p4);
40038
+ if (context.evals.has(a4[b4])) {
40039
+ done(void 0, context.evals.get(a4[b4]));
40096
40040
  return;
40097
40041
  }
40098
- const g4 = obj instanceof utils.Prop && obj.isGlobal || typeof a4 === "function" && !context.ctx.sandboxedFunctions.has(a4) || context.ctx.globalsWhitelist.has(a4);
40099
- done(void 0, new utils.Prop(a4, b4, false, g4, false));
40100
- });
40101
- function getGlobalProp(val, context, prop) {
40102
- if (!val)
40042
+ if (a4[b4] === globalThis) {
40043
+ done(void 0, context.ctx.globalScope.get("this"));
40103
40044
  return;
40104
- const isFunc = typeof val === "function";
40105
- if (val instanceof utils.Prop) {
40106
- if (!prop) {
40107
- prop = val;
40108
- }
40109
- val = val.get(context);
40110
40045
  }
40111
- const p4 = prop?.prop || "prop";
40112
- if (val === globalThis) {
40113
- return new utils.Prop({
40114
- [p4]: context.ctx.sandboxGlobal
40115
- }, p4, prop?.isConst || false, false, prop?.isVariable || false);
40116
- }
40117
- const evl = isFunc && context.evals.get(val);
40118
- if (evl) {
40119
- return new utils.Prop({
40120
- [p4]: evl
40121
- }, p4, prop?.isConst || false, true, prop?.isVariable || false);
40122
- }
40123
- }
40124
- addOps(5, ({ done, a: a4, b: b4, obj, context }) => {
40046
+ const g4 = obj.isGlobal || isFunction2 && !sandboxedFunctions.has(a4) || context.ctx.globalsWhitelist.has(a4);
40047
+ done(void 0, new utils.Prop(a4, b4, false, g4));
40048
+ });
40049
+ addOps(5, (exec6, done, ticks, a4, b4, obj, context) => {
40125
40050
  if (context.ctx.options.forbidFunctionCalls)
40126
- throw new utils.SandboxCapabilityError("Function invocations are not allowed");
40051
+ throw new utils.SandboxError("Function invocations are not allowed");
40127
40052
  if (typeof a4 !== "function") {
40128
- throw new TypeError(`${typeof obj?.prop === "symbol" ? "Symbol" : obj?.prop} is not a function`);
40053
+ throw new TypeError(`${typeof obj.prop === "symbol" ? "Symbol" : obj.prop} is not a function`);
40129
40054
  }
40130
40055
  const vals = b4.map((item) => {
40131
40056
  if (item instanceof SpreadArray) {
@@ -40135,9 +40060,7 @@ var require_executor = __commonJS({
40135
40060
  }
40136
40061
  }).flat().map((item) => valueOrProp(item, context));
40137
40062
  if (typeof obj === "function") {
40138
- let ret2 = obj(...vals);
40139
- ret2 = getGlobalProp(ret2, context) || ret2;
40140
- done(void 0, ret2);
40063
+ done(void 0, obj(...vals));
40141
40064
  return;
40142
40065
  }
40143
40066
  if (obj.context[obj.prop] === JSON.stringify && context.getSubscriptions.size) {
@@ -40209,11 +40132,9 @@ var require_executor = __commonJS({
40209
40132
  }
40210
40133
  }
40211
40134
  obj.get(context);
40212
- let ret = obj.context[obj.prop](...vals);
40213
- ret = getGlobalProp(ret, context) || ret;
40214
- done(void 0, ret);
40135
+ done(void 0, obj.context[obj.prop](...vals));
40215
40136
  });
40216
- addOps(22, ({ done, b: b4 }) => {
40137
+ addOps(22, (exec6, done, ticks, a4, b4) => {
40217
40138
  let res = {};
40218
40139
  for (const item of b4) {
40219
40140
  if (item.key instanceof SpreadObject) {
@@ -40224,8 +40145,8 @@ var require_executor = __commonJS({
40224
40145
  }
40225
40146
  done(void 0, res);
40226
40147
  });
40227
- addOps(6, ({ done, a: a4, b: b4 }) => done(void 0, new KeyVal(a4, b4)));
40228
- addOps(12, ({ done, b: b4, context }) => {
40148
+ addOps(6, (exec6, done, ticks, a4, b4) => done(void 0, new KeyVal(a4, b4)));
40149
+ addOps(12, (exec6, done, ticks, a4, b4, obj, context) => {
40229
40150
  const items = b4.map((item) => {
40230
40151
  if (item instanceof SpreadArray) {
40231
40152
  return [...item.item];
@@ -40235,8 +40156,8 @@ var require_executor = __commonJS({
40235
40156
  }).flat().map((item) => valueOrProp(item, context));
40236
40157
  done(void 0, items);
40237
40158
  });
40238
- addOps(23, ({ done, b: b4 }) => done(void 0, b4));
40239
- addOps(35, ({ done, b: b4 }) => {
40159
+ addOps(23, (exec6, done, ticks, a4, b4) => done(void 0, b4));
40160
+ addOps(35, (exec6, done, ticks, a4, b4) => {
40240
40161
  switch (b4) {
40241
40162
  case "true":
40242
40163
  return done(void 0, true);
@@ -40253,18 +40174,18 @@ var require_executor = __commonJS({
40253
40174
  }
40254
40175
  done(new Error("Unknown symbol: " + b4));
40255
40176
  });
40256
- addOps(7, ({ done, b: b4 }) => done(void 0, Number(b4.replace(/_/g, ""))));
40257
- addOps(83, ({ done, b: b4 }) => done(void 0, BigInt(b4.replace(/_/g, ""))));
40258
- addOps(2, ({ done, b: b4, context }) => done(void 0, context.constants.strings[parseInt(b4)]));
40259
- addOps(85, ({ done, b: b4, context }) => {
40177
+ addOps(7, (exec6, done, ticks, a4, b4) => done(void 0, Number(b4)));
40178
+ addOps(83, (exec6, done, ticks, a4, b4) => done(void 0, BigInt(b4)));
40179
+ addOps(2, (exec6, done, ticks, a4, b4, obj, context) => done(void 0, context.constants.strings[parseInt(b4)]));
40180
+ addOps(86, (exec6, done, ticks, a4, b4, obj, context) => {
40260
40181
  const reg = context.constants.regexes[parseInt(b4)];
40261
40182
  if (!context.ctx.globalsWhitelist.has(RegExp)) {
40262
- throw new utils.SandboxCapabilityError("Regex not permitted");
40183
+ throw new utils.SandboxError("Regex not permitted");
40263
40184
  } else {
40264
40185
  done(void 0, new RegExp(reg.regex, reg.flags));
40265
40186
  }
40266
40187
  });
40267
- addOps(84, ({ exec: exec6, done, ticks, b: b4, context, scope }) => {
40188
+ addOps(84, (exec6, done, ticks, a4, b4, obj, context, scope) => {
40268
40189
  const item = context.constants.literals[parseInt(b4)];
40269
40190
  const [, name14, js] = item;
40270
40191
  const found = [];
@@ -40276,13 +40197,12 @@ var require_executor = __commonJS({
40276
40197
  resnums.push(f4[3]);
40277
40198
  }
40278
40199
  }
40279
- exec6(ticks, found, scope, context, (...args) => {
40200
+ exec6(ticks, found, scope, context, (err, processed) => {
40280
40201
  const reses = {};
40281
- if (args.length === 1) {
40282
- done(args[0]);
40202
+ if (err) {
40203
+ done(err);
40283
40204
  return;
40284
40205
  }
40285
- const processed = args[1];
40286
40206
  for (const i4 of Object.keys(processed)) {
40287
40207
  const num = resnums[i4];
40288
40208
  reses[num] = processed[i4];
@@ -40295,146 +40215,115 @@ var require_executor = __commonJS({
40295
40215
  }));
40296
40216
  });
40297
40217
  });
40298
- addOps(18, ({ done, b: b4 }) => {
40218
+ addOps(18, (exec6, done, ticks, a4, b4) => {
40299
40219
  done(void 0, new SpreadArray(b4));
40300
40220
  });
40301
- addOps(17, ({ done, b: b4 }) => {
40221
+ addOps(17, (exec6, done, ticks, a4, b4) => {
40302
40222
  done(void 0, new SpreadObject(b4));
40303
40223
  });
40304
- addOps(24, ({ done, b: b4 }) => done(void 0, !b4));
40305
- addOps(64, ({ done, b: b4 }) => done(void 0, ~b4));
40306
- addOps(25, ({ done, obj, context }) => {
40224
+ addOps(24, (exec6, done, ticks, a4, b4) => done(void 0, !b4));
40225
+ addOps(64, (exec6, done, ticks, a4, b4) => done(void 0, ~b4));
40226
+ addOps(25, (exec6, done, ticks, a4, b4, obj, context) => {
40307
40227
  assignCheck(obj, context);
40308
40228
  done(void 0, ++obj.context[obj.prop]);
40309
40229
  });
40310
- addOps(26, ({ done, obj, context }) => {
40230
+ addOps(26, (exec6, done, ticks, a4, b4, obj, context) => {
40311
40231
  assignCheck(obj, context);
40312
40232
  done(void 0, obj.context[obj.prop]++);
40313
40233
  });
40314
- addOps(27, ({ done, obj, context }) => {
40234
+ addOps(27, (exec6, done, ticks, a4, b4, obj, context) => {
40315
40235
  assignCheck(obj, context);
40316
40236
  done(void 0, --obj.context[obj.prop]);
40317
40237
  });
40318
- addOps(28, ({ done, obj, context }) => {
40238
+ addOps(28, (exec6, done, ticks, a4, b4, obj, context) => {
40319
40239
  assignCheck(obj, context);
40320
40240
  done(void 0, obj.context[obj.prop]--);
40321
40241
  });
40322
- addOps(9, ({ done, b: b4, obj, context, scope, bobj }) => {
40242
+ addOps(9, (exec6, done, ticks, a4, b4, obj, context) => {
40323
40243
  assignCheck(obj, context);
40324
- obj.isGlobal = bobj?.isGlobal || false;
40325
- if (obj.isVariable) {
40326
- const s4 = scope.getWhereValScope(obj.prop, obj.prop === "this");
40327
- if (s4 === null) {
40328
- throw new ReferenceError(`Cannot assign to undeclared variable '${obj.prop.toString()}'`);
40329
- }
40330
- s4.set(obj.prop, b4);
40331
- if (obj.isGlobal) {
40332
- s4.globals[obj.prop.toString()] = true;
40333
- } else {
40334
- delete s4.globals[obj.prop.toString()];
40335
- }
40336
- done(void 0, b4);
40337
- return;
40338
- }
40339
40244
  done(void 0, obj.context[obj.prop] = b4);
40340
40245
  });
40341
- addOps(66, ({ done, b: b4, obj, context }) => {
40246
+ addOps(66, (exec6, done, ticks, a4, b4, obj, context) => {
40342
40247
  assignCheck(obj, context);
40343
40248
  done(void 0, obj.context[obj.prop] += b4);
40344
40249
  });
40345
- addOps(65, ({ done, b: b4, obj, context }) => {
40250
+ addOps(65, (exec6, done, ticks, a4, b4, obj, context) => {
40346
40251
  assignCheck(obj, context);
40347
40252
  done(void 0, obj.context[obj.prop] -= b4);
40348
40253
  });
40349
- addOps(67, ({ done, b: b4, obj, context }) => {
40254
+ addOps(67, (exec6, done, ticks, a4, b4, obj, context) => {
40350
40255
  assignCheck(obj, context);
40351
40256
  done(void 0, obj.context[obj.prop] /= b4);
40352
40257
  });
40353
- addOps(69, ({ done, b: b4, obj, context }) => {
40258
+ addOps(69, (exec6, done, ticks, a4, b4, obj, context) => {
40354
40259
  assignCheck(obj, context);
40355
40260
  done(void 0, obj.context[obj.prop] *= b4);
40356
40261
  });
40357
- addOps(68, ({ done, b: b4, obj, context }) => {
40262
+ addOps(68, (exec6, done, ticks, a4, b4, obj, context) => {
40358
40263
  assignCheck(obj, context);
40359
40264
  done(void 0, obj.context[obj.prop] **= b4);
40360
40265
  });
40361
- addOps(70, ({ done, b: b4, obj, context }) => {
40266
+ addOps(70, (exec6, done, ticks, a4, b4, obj, context) => {
40362
40267
  assignCheck(obj, context);
40363
40268
  done(void 0, obj.context[obj.prop] %= b4);
40364
40269
  });
40365
- addOps(71, ({ done, b: b4, obj, context }) => {
40270
+ addOps(71, (exec6, done, ticks, a4, b4, obj, context) => {
40366
40271
  assignCheck(obj, context);
40367
40272
  done(void 0, obj.context[obj.prop] ^= b4);
40368
40273
  });
40369
- addOps(72, ({ done, b: b4, obj, context }) => {
40274
+ addOps(72, (exec6, done, ticks, a4, b4, obj, context) => {
40370
40275
  assignCheck(obj, context);
40371
40276
  done(void 0, obj.context[obj.prop] &= b4);
40372
40277
  });
40373
- addOps(73, ({ done, b: b4, obj, context }) => {
40278
+ addOps(73, (exec6, done, ticks, a4, b4, obj, context) => {
40374
40279
  assignCheck(obj, context);
40375
40280
  done(void 0, obj.context[obj.prop] |= b4);
40376
40281
  });
40377
- addOps(76, ({ done, b: b4, obj, context }) => {
40282
+ addOps(76, (exec6, done, ticks, a4, b4, obj, context) => {
40378
40283
  assignCheck(obj, context);
40379
40284
  done(void 0, obj.context[obj.prop] <<= b4);
40380
40285
  });
40381
- addOps(75, ({ done, b: b4, obj, context }) => {
40286
+ addOps(75, (exec6, done, ticks, a4, b4, obj, context) => {
40382
40287
  assignCheck(obj, context);
40383
40288
  done(void 0, obj.context[obj.prop] >>= b4);
40384
40289
  });
40385
- addOps(74, ({ done, b: b4, obj, context }) => {
40290
+ addOps(74, (exec6, done, ticks, a4, b4, obj, context) => {
40386
40291
  assignCheck(obj, context);
40387
- done(void 0, obj.context[obj.prop] >>>= b4);
40388
- });
40389
- addOps(90, ({ done, b: b4, obj, context }) => {
40390
- var _a16, _b;
40391
- assignCheck(obj, context);
40392
- done(void 0, (_a16 = obj.context)[_b = obj.prop] && (_a16[_b] = b4));
40393
- });
40394
- addOps(91, ({ done, b: b4, obj, context }) => {
40395
- var _a16, _b;
40396
- assignCheck(obj, context);
40397
- done(void 0, (_a16 = obj.context)[_b = obj.prop] || (_a16[_b] = b4));
40398
- });
40399
- addOps(92, ({ done, b: b4, obj, context }) => {
40400
- var _a16, _b;
40401
- assignCheck(obj, context);
40402
- done(void 0, (_a16 = obj.context)[_b = obj.prop] ?? (_a16[_b] = b4));
40292
+ done(void 0, obj.context[obj.prop] >>= b4);
40403
40293
  });
40404
- addOps(57, ({ done, a: a4, b: b4 }) => done(void 0, a4 > b4));
40405
- addOps(56, ({ done, a: a4, b: b4 }) => done(void 0, a4 < b4));
40406
- addOps(55, ({ done, a: a4, b: b4 }) => done(void 0, a4 >= b4));
40407
- addOps(54, ({ done, a: a4, b: b4 }) => done(void 0, a4 <= b4));
40408
- addOps(52, ({ done, a: a4, b: b4 }) => done(void 0, a4 == b4));
40409
- addOps(32, ({ done, a: a4, b: b4 }) => done(void 0, a4 === b4));
40410
- addOps(53, ({ done, a: a4, b: b4 }) => done(void 0, a4 != b4));
40411
- addOps(31, ({ done, a: a4, b: b4 }) => done(void 0, a4 !== b4));
40412
- addOps(29, ({ done, a: a4, b: b4 }) => done(void 0, a4 && b4));
40413
- addOps(30, ({ done, a: a4, b: b4 }) => done(void 0, a4 || b4));
40414
- addOps(89, ({ done, a: a4, b: b4 }) => done(void 0, a4 ?? b4));
40415
- addOps(77, ({ done, a: a4, b: b4 }) => done(void 0, a4 & b4));
40416
- addOps(78, ({ done, a: a4, b: b4 }) => done(void 0, a4 | b4));
40417
- addOps(33, ({ done, a: a4, b: b4 }) => done(void 0, a4 + b4));
40418
- addOps(47, ({ done, a: a4, b: b4 }) => done(void 0, a4 - b4));
40419
- addOps(59, ({ done, b: b4 }) => done(void 0, +b4));
40420
- addOps(58, ({ done, b: b4 }) => done(void 0, -b4));
40421
- addOps(48, ({ done, a: a4, b: b4 }) => done(void 0, a4 / b4));
40422
- addOps(49, ({ done, a: a4, b: b4 }) => done(void 0, a4 ** b4));
40423
- addOps(79, ({ done, a: a4, b: b4 }) => done(void 0, a4 ^ b4));
40424
- addOps(50, ({ done, a: a4, b: b4 }) => done(void 0, a4 * b4));
40425
- addOps(51, ({ done, a: a4, b: b4 }) => done(void 0, a4 % b4));
40426
- addOps(80, ({ done, a: a4, b: b4 }) => done(void 0, a4 << b4));
40427
- addOps(81, ({ done, a: a4, b: b4 }) => done(void 0, a4 >> b4));
40428
- addOps(82, ({ done, a: a4, b: b4 }) => done(void 0, a4 >>> b4));
40429
- addOps(60, ({ exec: exec6, done, ticks, b: b4, context, scope }) => {
40294
+ addOps(57, (exec6, done, ticks, a4, b4) => done(void 0, a4 > b4));
40295
+ addOps(56, (exec6, done, ticks, a4, b4) => done(void 0, a4 < b4));
40296
+ addOps(55, (exec6, done, ticks, a4, b4) => done(void 0, a4 >= b4));
40297
+ addOps(54, (exec6, done, ticks, a4, b4) => done(void 0, a4 <= b4));
40298
+ addOps(52, (exec6, done, ticks, a4, b4) => done(void 0, a4 == b4));
40299
+ addOps(32, (exec6, done, ticks, a4, b4) => done(void 0, a4 === b4));
40300
+ addOps(53, (exec6, done, ticks, a4, b4) => done(void 0, a4 != b4));
40301
+ addOps(31, (exec6, done, ticks, a4, b4) => done(void 0, a4 !== b4));
40302
+ addOps(29, (exec6, done, ticks, a4, b4) => done(void 0, a4 && b4));
40303
+ addOps(30, (exec6, done, ticks, a4, b4) => done(void 0, a4 || b4));
40304
+ addOps(85, (exec6, done, ticks, a4, b4) => done(void 0, a4 ?? b4));
40305
+ addOps(77, (exec6, done, ticks, a4, b4) => done(void 0, a4 & b4));
40306
+ addOps(78, (exec6, done, ticks, a4, b4) => done(void 0, a4 | b4));
40307
+ addOps(33, (exec6, done, ticks, a4, b4) => done(void 0, a4 + b4));
40308
+ addOps(47, (exec6, done, ticks, a4, b4) => done(void 0, a4 - b4));
40309
+ addOps(59, (exec6, done, ticks, a4, b4) => done(void 0, +b4));
40310
+ addOps(58, (exec6, done, ticks, a4, b4) => done(void 0, -b4));
40311
+ addOps(48, (exec6, done, ticks, a4, b4) => done(void 0, a4 / b4));
40312
+ addOps(79, (exec6, done, ticks, a4, b4) => done(void 0, a4 ^ b4));
40313
+ addOps(50, (exec6, done, ticks, a4, b4) => done(void 0, a4 * b4));
40314
+ addOps(51, (exec6, done, ticks, a4, b4) => done(void 0, a4 % b4));
40315
+ addOps(80, (exec6, done, ticks, a4, b4) => done(void 0, a4 << b4));
40316
+ addOps(81, (exec6, done, ticks, a4, b4) => done(void 0, a4 >> b4));
40317
+ addOps(82, (exec6, done, ticks, a4, b4) => done(void 0, a4 >>> b4));
40318
+ addOps(60, (exec6, done, ticks, a4, b4, obj, context, scope) => {
40430
40319
  exec6(ticks, b4, scope, context, (e4, prop) => {
40431
40320
  done(void 0, typeof valueOrProp(prop, context));
40432
40321
  });
40433
40322
  });
40434
- addOps(62, ({ done, a: a4, b: b4 }) => done(void 0, a4 instanceof b4));
40435
- addOps(63, ({ done, a: a4, b: b4 }) => done(void 0, a4 in b4));
40436
- addOps(61, ({ done, context, bobj }) => {
40437
- if (!(bobj instanceof utils.Prop)) {
40323
+ addOps(62, (exec6, done, ticks, a4, b4) => done(void 0, a4 instanceof b4));
40324
+ addOps(63, (exec6, done, ticks, a4, b4) => done(void 0, a4 in b4));
40325
+ addOps(61, (exec6, done, ticks, a4, b4, obj, context, scope, bobj) => {
40326
+ if (bobj.context === void 0) {
40438
40327
  done(void 0, true);
40439
40328
  return;
40440
40329
  }
@@ -40445,23 +40334,23 @@ var require_executor = __commonJS({
40445
40334
  }
40446
40335
  done(void 0, delete bobj.context?.[bobj.prop]);
40447
40336
  });
40448
- addOps(8, ({ done, b: b4 }) => done(void 0, b4));
40449
- addOps(34, ({ done, a: a4, b: b4, scope, bobj }) => {
40450
- done(void 0, scope.declare(a4, "var", b4, bobj?.isGlobal || false));
40337
+ addOps(8, (exec6, done, ticks, a4, b4) => done(void 0, b4));
40338
+ addOps(34, (exec6, done, ticks, a4, b4, obj, context, scope) => {
40339
+ done(void 0, scope.declare(a4, "var", b4));
40451
40340
  });
40452
- addOps(3, ({ done, a: a4, b: b4, scope, bobj }) => {
40453
- done(void 0, scope.declare(a4, "let", b4, bobj?.isGlobal || false));
40341
+ addOps(3, (exec6, done, ticks, a4, b4, obj, context, scope, bobj) => {
40342
+ done(void 0, scope.declare(a4, "let", b4, bobj && bobj.isGlobal));
40454
40343
  });
40455
- addOps(4, ({ done, a: a4, b: b4, scope, bobj }) => {
40456
- done(void 0, scope.declare(a4, "const", b4, bobj?.isGlobal || false));
40344
+ addOps(4, (exec6, done, ticks, a4, b4, obj, context, scope) => {
40345
+ done(void 0, scope.declare(a4, "const", b4));
40457
40346
  });
40458
- addOps(11, ({ done, ticks, a: a4, b: b4, obj, context, scope }) => {
40347
+ addOps(11, (exec6, done, ticks, a4, b4, obj, context, scope) => {
40459
40348
  a4 = [...a4];
40460
40349
  if (typeof obj[2] === "string" || obj[2] instanceof utils.CodeString) {
40461
40350
  if (context.allowJit && context.evalContext) {
40462
40351
  obj[2] = b4 = context.evalContext.lispifyFunction(new utils.CodeString(obj[2]), context.constants);
40463
40352
  } else {
40464
- throw new utils.SandboxCapabilityError("Unevaluated code detected, JIT not allowed");
40353
+ throw new utils.SandboxError("Unevaluated code detected, JIT not allowed");
40465
40354
  }
40466
40355
  }
40467
40356
  if (a4.shift()) {
@@ -40470,18 +40359,18 @@ var require_executor = __commonJS({
40470
40359
  done(void 0, createFunction(a4, b4, ticks, context, scope));
40471
40360
  }
40472
40361
  });
40473
- addOps(37, ({ done, ticks, a: a4, b: b4, obj, context, scope }) => {
40362
+ addOps(37, (exec6, done, ticks, a4, b4, obj, context, scope) => {
40474
40363
  if (typeof obj[2] === "string" || obj[2] instanceof utils.CodeString) {
40475
40364
  if (context.allowJit && context.evalContext) {
40476
40365
  obj[2] = b4 = context.evalContext.lispifyFunction(new utils.CodeString(obj[2]), context.constants);
40477
40366
  } else {
40478
- throw new utils.SandboxCapabilityError("Unevaluated code detected, JIT not allowed");
40367
+ throw new utils.SandboxError("Unevaluated code detected, JIT not allowed");
40479
40368
  }
40480
40369
  }
40481
40370
  const isAsync2 = a4.shift();
40482
40371
  const name14 = a4.shift();
40483
40372
  let func;
40484
- if (isAsync2 === 88) {
40373
+ if (isAsync2 === 89) {
40485
40374
  func = createFunctionAsync(a4, b4, ticks, context, scope, name14);
40486
40375
  } else {
40487
40376
  func = createFunction(a4, b4, ticks, context, scope, name14);
@@ -40491,12 +40380,12 @@ var require_executor = __commonJS({
40491
40380
  }
40492
40381
  done(void 0, func);
40493
40382
  });
40494
- addOps(10, ({ done, ticks, a: a4, b: b4, obj, context, scope }) => {
40383
+ addOps(10, (exec6, done, ticks, a4, b4, obj, context, scope) => {
40495
40384
  if (typeof obj[2] === "string" || obj[2] instanceof utils.CodeString) {
40496
40385
  if (context.allowJit && context.evalContext) {
40497
40386
  obj[2] = b4 = context.evalContext.lispifyFunction(new utils.CodeString(obj[2]), context.constants);
40498
40387
  } else {
40499
- throw new utils.SandboxCapabilityError("Unevaluated code detected, JIT not allowed");
40388
+ throw new utils.SandboxError("Unevaluated code detected, JIT not allowed");
40500
40389
  }
40501
40390
  }
40502
40391
  const isAsync2 = a4.shift();
@@ -40505,7 +40394,7 @@ var require_executor = __commonJS({
40505
40394
  scope = new utils.Scope(scope, {});
40506
40395
  }
40507
40396
  let func;
40508
- if (isAsync2 === 88) {
40397
+ if (isAsync2 === 89) {
40509
40398
  func = createFunctionAsync(a4, b4, ticks, context, scope, name14);
40510
40399
  } else {
40511
40400
  func = createFunction(a4, b4, ticks, context, scope, name14);
@@ -40515,7 +40404,7 @@ var require_executor = __commonJS({
40515
40404
  }
40516
40405
  done(void 0, func);
40517
40406
  });
40518
- addOps(38, ({ exec: exec6, done, ticks, a: a4, b: b4, context, scope }) => {
40407
+ addOps(38, (exec6, done, ticks, a4, b4, obj, context, scope) => {
40519
40408
  const [checkFirst, startInternal, getIterator, startStep, step, condition, beforeStep] = a4;
40520
40409
  let loop = true;
40521
40410
  const loopScope = new utils.Scope(scope, {});
@@ -40571,27 +40460,26 @@ var require_executor = __commonJS({
40571
40460
  done();
40572
40461
  }
40573
40462
  });
40574
- addOps(86, ({ done, a: a4, context, inLoopOrSwitch }) => {
40463
+ addOps(87, (exec6, done, ticks, a4, b4, obj, context, scope, bobj, inLoopOrSwitch) => {
40575
40464
  if (inLoopOrSwitch === "switch" && a4 === "continue" || !inLoopOrSwitch) {
40576
- throw new TypeError("Illegal " + a4 + " statement");
40465
+ throw new utils.SandboxError("Illegal " + a4 + " statement");
40577
40466
  }
40578
40467
  done(void 0, new ExecReturn(context.ctx.auditReport, void 0, false, a4 === "break", a4 === "continue"));
40579
40468
  });
40580
- addOps(13, ({ exec: exec6, done, ticks, a: a4, b: b4, context, scope, inLoopOrSwitch }) => {
40469
+ addOps(13, (exec6, done, ticks, a4, b4, obj, context, scope, bobj, inLoopOrSwitch) => {
40581
40470
  exec6(ticks, valueOrProp(a4, context) ? b4.t : b4.f, scope, context, done, inLoopOrSwitch);
40582
40471
  });
40583
- addOps(15, ({ exec: exec6, done, ticks, a: a4, b: b4, context, scope }) => {
40584
- exec6(ticks, valueOrProp(a4, context) ? b4.t : b4.f, scope, context, done, void 0);
40472
+ addOps(15, (exec6, done, ticks, a4, b4, obj, context, scope, bobj, inLoopOrSwitch) => {
40473
+ exec6(ticks, valueOrProp(a4, context) ? b4.t : b4.f, scope, context, done, inLoopOrSwitch);
40585
40474
  });
40586
- addOps(16, ({ done, a: a4, b: b4 }) => done(void 0, new If(a4, b4)));
40587
- addOps(14, ({ done, a: a4, b: b4 }) => done(void 0, new If(a4, b4)));
40588
- addOps(40, ({ exec: exec6, done, ticks, a: a4, b: b4, context, scope }) => {
40589
- exec6(ticks, a4, scope, context, (...args) => {
40590
- if (args.length === 1) {
40591
- done(args[0]);
40475
+ addOps(16, (exec6, done, ticks, a4, b4) => done(void 0, new If(a4, b4)));
40476
+ addOps(14, (exec6, done, ticks, a4, b4) => done(void 0, new If(a4, b4)));
40477
+ addOps(40, (exec6, done, ticks, a4, b4, obj, context, scope) => {
40478
+ exec6(ticks, a4, scope, context, (err, toTest) => {
40479
+ if (err) {
40480
+ done(err);
40592
40481
  return;
40593
40482
  }
40594
- let toTest = args[1];
40595
40483
  toTest = valueOrProp(toTest, context);
40596
40484
  if (exec6 === execSync) {
40597
40485
  let res;
@@ -40639,79 +40527,34 @@ var require_executor = __commonJS({
40639
40527
  }
40640
40528
  });
40641
40529
  });
40642
- addOps(39, ({ exec: exec6, done, ticks, a: a4, b: b4, context, scope, inLoopOrSwitch }) => {
40530
+ addOps(39, (exec6, done, ticks, a4, b4, obj, context, scope, bobj, inLoopOrSwitch) => {
40643
40531
  const [exception, catchBody, finallyBody] = b4;
40644
- executeTreeWithDone(exec6, (...tryArgs) => {
40645
- const tryHadError = tryArgs.length === 1;
40646
- const tryError = tryHadError ? tryArgs[0] : void 0;
40647
- const tryResult = !tryHadError && tryArgs.length > 1 ? tryArgs[1] : void 0;
40648
- const executeFinallyAndComplete = (hadError, errorOrResult) => {
40649
- if (finallyBody && finallyBody.length > 0) {
40650
- executeTreeWithDone(exec6, (...finallyArgs) => {
40651
- const finallyHadError = finallyArgs.length === 1;
40652
- const finallyResult = !finallyHadError && finallyArgs.length > 1 ? finallyArgs[1] : void 0;
40653
- if (finallyHadError) {
40654
- done(finallyArgs[0]);
40655
- return;
40656
- }
40657
- if (finallyResult instanceof ExecReturn && (finallyResult.returned || finallyResult.breakLoop || finallyResult.continueLoop)) {
40658
- done(void 0, finallyResult);
40659
- return;
40660
- }
40661
- if (hadError) {
40662
- done(errorOrResult);
40663
- } else if (errorOrResult instanceof ExecReturn) {
40664
- if (errorOrResult.returned || errorOrResult.breakLoop || errorOrResult.continueLoop) {
40665
- done(void 0, errorOrResult);
40666
- } else {
40667
- done();
40668
- }
40669
- } else {
40670
- done();
40671
- }
40672
- }, ticks, context, finallyBody, [new utils.Scope(scope, {})], inLoopOrSwitch);
40532
+ executeTreeWithDone(exec6, (err, res) => {
40533
+ executeTreeWithDone(exec6, (e4) => {
40534
+ if (e4)
40535
+ done(e4);
40536
+ else if (err) {
40537
+ executeTreeWithDone(exec6, done, ticks, context, catchBody, [new utils.Scope(scope)], inLoopOrSwitch);
40673
40538
  } else {
40674
- if (hadError) {
40675
- done(errorOrResult);
40676
- } else if (errorOrResult instanceof ExecReturn) {
40677
- if (errorOrResult.returned || errorOrResult.breakLoop || errorOrResult.continueLoop) {
40678
- done(void 0, errorOrResult);
40679
- } else {
40680
- done();
40681
- }
40682
- } else {
40683
- done();
40684
- }
40539
+ done(void 0, res);
40685
40540
  }
40686
- };
40687
- if (tryHadError && catchBody && catchBody.length > 0) {
40688
- const sc = {};
40689
- if (exception)
40690
- sc[exception] = tryError;
40691
- executeTreeWithDone(exec6, (...catchArgs) => {
40692
- const catchHadError = catchArgs.length === 1;
40693
- const catchErrorOrResult = catchHadError ? catchArgs[0] : catchArgs.length > 1 ? catchArgs[1] : void 0;
40694
- executeFinallyAndComplete(catchHadError, catchErrorOrResult);
40695
- }, ticks, context, catchBody, [new utils.Scope(scope, sc)], inLoopOrSwitch);
40696
- } else {
40697
- executeFinallyAndComplete(tryHadError, tryHadError ? tryError : tryResult);
40698
- }
40541
+ }, ticks, context, finallyBody, [new utils.Scope(scope, {})]);
40699
40542
  }, ticks, context, a4, [new utils.Scope(scope)], inLoopOrSwitch);
40700
40543
  });
40701
- addOps(87, ({ done }) => {
40544
+ addOps(88, (exec6, done) => {
40702
40545
  done();
40703
40546
  });
40704
- addOps(45, ({ done, a: a4, b: b4, context }) => {
40705
- if (!context.ctx.globalsWhitelist.has(a4) && !context.ctx.sandboxedFunctions.has(a4)) {
40706
- throw new utils.SandboxAccessError(`Object construction not allowed: ${a4.constructor.name}`);
40547
+ addOps(45, (exec6, done, ticks, a4, b4, obj, context) => {
40548
+ if (!context.ctx.globalsWhitelist.has(a4) && !sandboxedFunctions.has(a4)) {
40549
+ throw new utils.SandboxError(`Object construction not allowed: ${a4.constructor.name}`);
40707
40550
  }
40708
40551
  done(void 0, new a4(...b4));
40709
40552
  });
40710
- addOps(46, ({ done, b: b4 }) => {
40553
+ addOps(46, (exec6, done, ticks, a4, b4) => {
40711
40554
  done(b4);
40712
40555
  });
40713
- addOps(43, ({ done, a: a4 }) => done(void 0, a4.pop()));
40714
- addOps(0, ({ done }) => done());
40556
+ addOps(43, (exec6, done, ticks, a4) => done(void 0, a4.pop()));
40557
+ addOps(0, (exec6, done) => done());
40715
40558
  function valueOrProp(a4, context) {
40716
40559
  if (a4 instanceof utils.Prop)
40717
40560
  return a4.get(context);
@@ -40729,7 +40572,13 @@ var require_executor = __commonJS({
40729
40572
  function _execManySync(ticks, tree, done, scope, context, inLoopOrSwitch) {
40730
40573
  const ret = [];
40731
40574
  for (let i4 = 0; i4 < tree.length; i4++) {
40732
- let res = syncDone((d4) => execSync(ticks, tree[i4], scope, context, d4, inLoopOrSwitch)).result;
40575
+ let res;
40576
+ try {
40577
+ res = syncDone((d4) => execSync(ticks, tree[i4], scope, context, d4, inLoopOrSwitch)).result;
40578
+ } catch (e4) {
40579
+ done(e4);
40580
+ return;
40581
+ }
40733
40582
  if (res instanceof ExecReturn && (res.returned || res.breakLoop || res.continueLoop)) {
40734
40583
  done(void 0, res);
40735
40584
  return;
@@ -40769,13 +40618,13 @@ var require_executor = __commonJS({
40769
40618
  let isInstant = false;
40770
40619
  let instant;
40771
40620
  const p4 = new Promise((resolve7, reject2) => {
40772
- callback((...args) => {
40773
- if (args.length === 1)
40774
- reject2(args[0]);
40621
+ callback((err, result) => {
40622
+ if (err)
40623
+ reject2(err);
40775
40624
  else {
40776
40625
  isInstant = true;
40777
- instant = args[1];
40778
- resolve7({ result: args[1] });
40626
+ instant = result;
40627
+ resolve7({ result });
40779
40628
  }
40780
40629
  });
40781
40630
  });
@@ -40788,19 +40637,19 @@ var require_executor = __commonJS({
40788
40637
  function syncDone(callback) {
40789
40638
  let result;
40790
40639
  let err;
40791
- callback((...args) => {
40792
- err = args.length === 1 ? { error: args[0] } : void 0;
40793
- result = args[1];
40640
+ callback((e4, r4) => {
40641
+ err = e4;
40642
+ result = r4;
40794
40643
  });
40795
40644
  if (err)
40796
- throw err.error;
40645
+ throw err;
40797
40646
  return { result };
40798
40647
  }
40799
40648
  async function execAsync4(ticks, tree, scope, context, doneOriginal, inLoopOrSwitch) {
40800
40649
  let done = doneOriginal;
40801
40650
  const p4 = new Promise((resolve7) => {
40802
- done = (...args) => {
40803
- doneOriginal(...args);
40651
+ done = (e4, r4) => {
40652
+ doneOriginal(e4, r4);
40804
40653
  resolve7();
40805
40654
  };
40806
40655
  });
@@ -40836,10 +40685,6 @@ var require_executor = __commonJS({
40836
40685
  a4 = void 0;
40837
40686
  }
40838
40687
  }
40839
- if (op2 === 89 && a4 !== void 0 && a4 !== null) {
40840
- done(void 0, a4);
40841
- return;
40842
- }
40843
40688
  let bobj;
40844
40689
  try {
40845
40690
  let ad;
@@ -40858,28 +40703,35 @@ var require_executor = __commonJS({
40858
40703
  if (b4 === optional) {
40859
40704
  b4 = void 0;
40860
40705
  }
40861
- performOp({
40862
- op: op2,
40863
- exec: execAsync4,
40864
- done,
40865
- ticks,
40866
- a: a4,
40867
- b: b4,
40868
- obj,
40869
- context,
40870
- scope,
40871
- bobj,
40872
- inLoopOrSwitch,
40873
- tree
40874
- });
40706
+ if (ops.has(op2)) {
40707
+ try {
40708
+ ops.get(op2)?.(execAsync4, done, ticks, a4, b4, obj, context, scope, bobj, inLoopOrSwitch);
40709
+ } catch (err) {
40710
+ done(err);
40711
+ }
40712
+ } else {
40713
+ done(new SyntaxError("Unknown operator: " + op2));
40714
+ }
40875
40715
  }
40876
40716
  await p4;
40877
40717
  }
40878
40718
  function execSync(ticks, tree, scope, context, done, inLoopOrSwitch) {
40879
40719
  if (!_execNoneRecurse(ticks, tree, scope, context, done, false, inLoopOrSwitch) && utils.isLisp(tree)) {
40880
40720
  let op2 = tree[0];
40881
- let obj = syncDone((d4) => execSync(ticks, tree[1], scope, context, d4, inLoopOrSwitch)).result;
40882
- let a4 = obj instanceof utils.Prop ? obj.get(context) : obj;
40721
+ let obj;
40722
+ try {
40723
+ obj = syncDone((d4) => execSync(ticks, tree[1], scope, context, d4, inLoopOrSwitch)).result;
40724
+ } catch (e4) {
40725
+ done(e4);
40726
+ return;
40727
+ }
40728
+ let a4 = obj;
40729
+ try {
40730
+ a4 = obj instanceof utils.Prop ? obj.get(context) : obj;
40731
+ } catch (e4) {
40732
+ done(e4);
40733
+ return;
40734
+ }
40883
40735
  if (op2 === 20 || op2 === 21) {
40884
40736
  if (a4 === void 0 || a4 === null) {
40885
40737
  done(void 0, optional);
@@ -40895,129 +40747,31 @@ var require_executor = __commonJS({
40895
40747
  a4 = void 0;
40896
40748
  }
40897
40749
  }
40898
- if (op2 === 89 && a4 !== void 0 && a4 !== null) {
40899
- done(void 0, a4);
40750
+ let bobj;
40751
+ try {
40752
+ bobj = syncDone((d4) => execSync(ticks, tree[2], scope, context, d4, inLoopOrSwitch)).result;
40753
+ } catch (e4) {
40754
+ done(e4);
40755
+ return;
40756
+ }
40757
+ let b4 = bobj;
40758
+ try {
40759
+ b4 = bobj instanceof utils.Prop ? bobj.get(context) : bobj;
40760
+ } catch (e4) {
40761
+ done(e4);
40900
40762
  return;
40901
40763
  }
40902
- let bobj = syncDone((d4) => execSync(ticks, tree[2], scope, context, d4, inLoopOrSwitch)).result;
40903
- let b4 = bobj instanceof utils.Prop ? bobj.get(context) : bobj;
40904
40764
  if (b4 === optional) {
40905
40765
  b4 = void 0;
40906
40766
  }
40907
- performOp({
40908
- op: op2,
40909
- exec: execSync,
40910
- done,
40911
- ticks,
40912
- a: a4,
40913
- b: b4,
40914
- obj,
40915
- context,
40916
- scope,
40917
- bobj,
40918
- inLoopOrSwitch,
40919
- tree
40920
- });
40921
- }
40922
- }
40923
- function checkHaltExpectedTicks(params, expectTicks = 0) {
40924
- const sandbox = params.context.ctx.sandbox;
40925
- const options = params.context.ctx.options;
40926
- const { ticks, scope, context, done, op: op2 } = params;
40927
- if (sandbox.halted) {
40928
- const sub = sandbox.subscribeResume(() => {
40929
- sub.unsubscribe();
40930
- try {
40931
- const o4 = ops.get(op2);
40932
- if (!o4) {
40933
- done(new SyntaxError("Unknown operator: " + op2));
40934
- return;
40935
- }
40936
- o4(params);
40937
- } catch (err) {
40938
- if (options.haltOnSandboxError && err instanceof utils.SandboxError) {
40939
- const sub2 = sandbox.subscribeResume(() => {
40940
- sub2.unsubscribe();
40941
- done(err);
40942
- });
40943
- sandbox.haltExecution({
40944
- error: err,
40945
- ticks,
40946
- scope,
40947
- context
40948
- });
40949
- } else {
40950
- done(err);
40951
- }
40952
- }
40953
- });
40954
- return true;
40955
- } else if (ticks.tickLimit && ticks.tickLimit <= ticks.ticks + BigInt(expectTicks)) {
40956
- const sub = sandbox.subscribeResume(() => {
40957
- sub.unsubscribe();
40767
+ if (ops.has(op2)) {
40958
40768
  try {
40959
- const o4 = ops.get(op2);
40960
- if (!o4) {
40961
- done(new SyntaxError("Unknown operator: " + op2));
40962
- return;
40963
- }
40964
- o4(params);
40769
+ ops.get(op2)?.(execSync, done, ticks, a4, b4, obj, context, scope, bobj, inLoopOrSwitch);
40965
40770
  } catch (err) {
40966
- if (context.ctx.options.haltOnSandboxError && err instanceof utils.SandboxError) {
40967
- const sub2 = sandbox.subscribeResume(() => {
40968
- sub2.unsubscribe();
40969
- done(err);
40970
- });
40971
- sandbox.haltExecution({
40972
- error: err,
40973
- ticks,
40974
- scope,
40975
- context
40976
- });
40977
- } else {
40978
- done(err);
40979
- }
40980
- }
40981
- });
40982
- const error2 = new utils.SandboxExecutionQuotaExceededError("Execution quota exceeded");
40983
- sandbox.haltExecution({
40984
- error: error2,
40985
- ticks,
40986
- scope,
40987
- context
40988
- });
40989
- return true;
40990
- }
40991
- return false;
40992
- }
40993
- function performOp(params) {
40994
- const { done, op: op2, ticks, context, scope } = params;
40995
- ticks.ticks++;
40996
- const sandbox = context.ctx.sandbox;
40997
- if (checkHaltExpectedTicks(params)) {
40998
- return;
40999
- }
41000
- try {
41001
- const o4 = ops.get(op2);
41002
- if (!o4) {
41003
- done(new utils.SandboxExecutionTreeError("Unknown operator: " + op2));
41004
- return;
41005
- }
41006
- o4(params);
41007
- } catch (err) {
41008
- if (context.ctx.options.haltOnSandboxError && err instanceof utils.SandboxError) {
41009
- const sub = sandbox.subscribeResume(() => {
41010
- sub.unsubscribe();
41011
40771
  done(err);
41012
- });
41013
- sandbox.haltExecution({
41014
- error: err,
41015
- ticks,
41016
- scope,
41017
- context
41018
- });
40772
+ }
41019
40773
  } else {
41020
- done(err);
40774
+ done(new SyntaxError("Unknown operator: " + op2));
41021
40775
  }
41022
40776
  }
41023
40777
  }
@@ -41035,9 +40789,20 @@ var require_executor = __commonJS({
41035
40789
  var currentTicks = { current: { ticks: BigInt(0) } };
41036
40790
  function _execNoneRecurse(ticks, tree, scope, context, done, isAsync2, inLoopOrSwitch) {
41037
40791
  const exec6 = isAsync2 ? execAsync4 : execSync;
40792
+ if (context.ctx.options.executionQuota && context.ctx.options.executionQuota <= ticks.ticks) {
40793
+ if (!(typeof context.ctx.options.onExecutionQuotaReached === "function" && context.ctx.options.onExecutionQuotaReached(ticks, scope, context, tree))) {
40794
+ done(new utils.SandboxError("Execution quota exceeded"));
40795
+ return true;
40796
+ }
40797
+ }
40798
+ ticks.ticks++;
41038
40799
  currentTicks.current = ticks;
41039
40800
  if (tree instanceof utils.Prop) {
41040
- done(void 0, tree.get(context));
40801
+ try {
40802
+ done(void 0, tree.get(context));
40803
+ } catch (err) {
40804
+ done(err);
40805
+ }
41041
40806
  } else if (tree === optional) {
41042
40807
  done();
41043
40808
  } else if (Array.isArray(tree) && !utils.isLisp(tree)) {
@@ -41052,36 +40817,27 @@ var require_executor = __commonJS({
41052
40817
  execMany(ticks, exec6, tree[1], done, scope, context, inLoopOrSwitch);
41053
40818
  } else if (tree[0] === 44) {
41054
40819
  if (!isAsync2) {
41055
- done(new SyntaxError("Illegal use of 'await', must be inside async function"));
40820
+ done(new utils.SandboxError("Illegal use of 'await', must be inside async function"));
41056
40821
  } else if (context.ctx.prototypeWhitelist?.has(Promise.prototype)) {
41057
- execAsync4(ticks, tree[1], scope, context, async (...args) => {
41058
- if (args.length === 1)
41059
- done(args[0]);
40822
+ execAsync4(ticks, tree[1], scope, context, async (e4, r4) => {
40823
+ if (e4)
40824
+ done(e4);
41060
40825
  else
41061
40826
  try {
41062
- done(void 0, await valueOrProp(args[1], context));
40827
+ done(void 0, await valueOrProp(r4, context));
41063
40828
  } catch (err) {
41064
40829
  done(err);
41065
40830
  }
41066
40831
  }, inLoopOrSwitch).catch(done);
41067
40832
  } else {
41068
- done(new utils.SandboxCapabilityError("Async/await is not permitted"));
40833
+ done(new utils.SandboxError("Async/await is not permitted"));
41069
40834
  }
41070
40835
  } else if (unexecTypes.has(tree[0])) {
41071
- performOp({
41072
- op: tree[0],
41073
- exec: exec6,
41074
- done,
41075
- ticks,
41076
- a: tree[1],
41077
- b: tree[2],
41078
- obj: tree,
41079
- tree,
41080
- context,
41081
- scope,
41082
- bobj: void 0,
41083
- inLoopOrSwitch
41084
- });
40836
+ try {
40837
+ ops.get(tree[0])?.(exec6, done, ticks, tree[1], tree[2], tree, context, scope, void 0, inLoopOrSwitch);
40838
+ } catch (err) {
40839
+ done(err);
40840
+ }
41085
40841
  } else {
41086
40842
  return false;
41087
40843
  }
@@ -41134,17 +40890,15 @@ var require_executor = __commonJS({
41134
40890
  let err;
41135
40891
  const current2 = executionTree[i4];
41136
40892
  try {
41137
- execSync(ticks, current2, scope, context, (...args) => {
41138
- if (args.length === 1)
41139
- err = { error: args[0] };
41140
- else
41141
- res = args[1];
40893
+ execSync(ticks, current2, scope, context, (e4, r4) => {
40894
+ err = e4;
40895
+ res = r4;
41142
40896
  }, inLoopOrSwitch);
41143
40897
  } catch (e4) {
41144
- err = { error: e4 };
40898
+ err = e4;
41145
40899
  }
41146
40900
  if (err) {
41147
- done(err.error);
40901
+ done(err);
41148
40902
  return;
41149
40903
  }
41150
40904
  if (res instanceof ExecReturn) {
@@ -41167,17 +40921,15 @@ var require_executor = __commonJS({
41167
40921
  let err;
41168
40922
  const current2 = executionTree[i4];
41169
40923
  try {
41170
- await execAsync4(ticks, current2, scope, context, (...args) => {
41171
- if (args.length === 1)
41172
- err = { error: args[0] };
41173
- else
41174
- res = args[1];
40924
+ await execAsync4(ticks, current2, scope, context, (e4, r4) => {
40925
+ err = e4;
40926
+ res = r4;
41175
40927
  }, inLoopOrSwitch);
41176
40928
  } catch (e4) {
41177
- err = { error: e4 };
40929
+ err = e4;
41178
40930
  }
41179
40931
  if (err) {
41180
- done(err.error);
40932
+ done(err);
41181
40933
  return;
41182
40934
  }
41183
40935
  if (res instanceof ExecReturn) {
@@ -41208,6 +40960,7 @@ var require_executor = __commonJS({
41208
40960
  exports2.executeTree = executeTree;
41209
40961
  exports2.executeTreeAsync = executeTreeAsync;
41210
40962
  exports2.ops = ops;
40963
+ exports2.sandboxedFunctions = sandboxedFunctions;
41211
40964
  exports2.syncDone = syncDone;
41212
40965
  }
41213
40966
  });
@@ -41322,29 +41075,23 @@ var require_parser = __commonJS({
41322
41075
  var expectTypes = {
41323
41076
  splitter: {
41324
41077
  types: {
41325
- power: /^(\*\*)(?!=)/,
41326
- opHigh: /^(\/|\*(?!\*)|%)(?!=)/,
41078
+ opHigh: /^(\/|\*\*|\*(?!\*)|%)(?!=)/,
41327
41079
  op: /^(\+(?!(\+))|-(?!(-)))(?!=)/,
41328
41080
  comparitor: /^(<=|>=|<(?!<)|>(?!>)|!==|!=(?!=)|===|==)/,
41329
- bitwiseShift: /^(<<|>>(?!>)|>>>)(?!=)/,
41330
- bitwiseAnd: /^(&(?!&))(?!=)/,
41331
- bitwiseXor: /^(\^)(?!=)/,
41332
- bitwiseOr: /^(\|(?!\|))(?!=)/,
41333
- boolOpAnd: /^(&&)(?!=)/,
41334
- boolOpOr: /^(\|\|(?!=)|instanceof(?![\w$])|in(?![\w$]))/,
41335
- nullishCoalescing: /^\?\?(?!=)/
41081
+ boolOp: /^(&&|\|\||\?\?|instanceof(?![\w$])|in(?![\w$]))/,
41082
+ bitwise: /^(&(?!&)|\|(?!\|)|\^|<<|>>(?!>)|>>>)(?!=)/
41336
41083
  },
41337
41084
  next: ["modifier", "value", "prop", "incrementerBefore"]
41338
41085
  },
41339
41086
  inlineIf: {
41340
41087
  types: {
41341
- inlineIf: /^\?(?!\.(?!\d))/
41088
+ inlineIf: /^\?(?!\?|\.(?!\d))/
41342
41089
  },
41343
41090
  next: ["expEnd"]
41344
41091
  },
41345
41092
  assignment: {
41346
41093
  types: {
41347
- assignModify: /^(-=|\+=|\/=|\*\*=|\*=|%=|\^=|&=|\|=|>>>=|>>=|<<=|&&=|\|\|=|\?\?=)/,
41094
+ assignModify: /^(-=|\+=|\/=|\*\*=|\*=|%=|\^=|&=|\|=|>>>=|>>=|<<=)/,
41348
41095
  assign: /^(=)(?!=)/
41349
41096
  },
41350
41097
  next: ["modifier", "value", "prop", "incrementerBefore"]
@@ -41356,8 +41103,7 @@ var require_parser = __commonJS({
41356
41103
  expEdge: {
41357
41104
  types: {
41358
41105
  call: /^(\?\.)?[(]/,
41359
- incrementerAfter: /^(\+\+|--)/,
41360
- taggedTemplate: /^`(\d+)`/
41106
+ incrementerAfter: /^(\+\+|--)/
41361
41107
  },
41362
41108
  next: ["splitter", "expEdge", "dot", "inlineIf", "expEnd"]
41363
41109
  },
@@ -41389,7 +41135,7 @@ var require_parser = __commonJS({
41389
41135
  types: {
41390
41136
  createObject: /^\{/,
41391
41137
  createArray: /^\[/,
41392
- 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,
41138
+ number: /^(0x[\da-f]+(_[\da-f]+)*|(\d+(_\d+)*(\.\d+(_\d+)*)?|\.\d+(_\d+)*))(e[+-]?\d+(_\d+)*)?(n)?(?!\d)/i,
41393
41139
  string: /^"(\d+)"/,
41394
41140
  literal: /^`(\d+)`/,
41395
41141
  regex: /^\/(\d+)\/r(?![\w$])/,
@@ -41497,8 +41243,6 @@ var require_parser = __commonJS({
41497
41243
  let isOneLiner = false;
41498
41244
  let i4;
41499
41245
  let lastInertedSemi = false;
41500
- let seenKeyword = false;
41501
- let skipNextWord = false;
41502
41246
  for (i4 = 0; i4 < part.length && !done; i4++) {
41503
41247
  let char = part.char(i4);
41504
41248
  if (quote === '"' || quote === "'" || quote === "`") {
@@ -41555,15 +41299,6 @@ var require_parser = __commonJS({
41555
41299
  if (foundNumber = aNumber.exec(sub)) {
41556
41300
  i4 += foundNumber[0].length - 1;
41557
41301
  sub = part.substring(i4).toString();
41558
- if (closingsTests) {
41559
- let found;
41560
- if (found = testMultiple(sub, closingsTests)) {
41561
- details.regRes = found;
41562
- i4++;
41563
- done = true;
41564
- break;
41565
- }
41566
- }
41567
41302
  } else if (lastChar != char) {
41568
41303
  let found = null;
41569
41304
  if (char === ";" || insertedSemis[i4 + part.start] && !isStart && !lastInertedSemi) {
@@ -41587,16 +41322,6 @@ var require_parser = __commonJS({
41587
41322
  }
41588
41323
  if (!done && (foundWord = wordReg.exec(sub))) {
41589
41324
  isOneLiner = true;
41590
- if (foundWord[2]) {
41591
- seenKeyword = true;
41592
- skipNextWord = true;
41593
- } else if (seenKeyword) {
41594
- if (skipNextWord) {
41595
- skipNextWord = false;
41596
- } else {
41597
- details.bodyContentAfterKeyword = true;
41598
- }
41599
- }
41600
41325
  if (foundWord[0].length > 1) {
41601
41326
  details.words.push(foundWord[1]);
41602
41327
  details.lastAnyWord = foundWord[1];
@@ -41706,18 +41431,10 @@ var require_parser = __commonJS({
41706
41431
  } else {
41707
41432
  const extract3 = restOfExp(constants, str, [/^:/]);
41708
41433
  key = lispify(constants, extract3, [...next, "spreadObject"]);
41709
- if (utils.isLisp(key) && key[0] === 17) {
41710
- value = NullLisp;
41711
- } else {
41712
- if (key[0] === 1) {
41713
- key = key[2];
41714
- }
41715
- if (str.length > extract3.length && str.char(extract3.length) === ":") {
41716
- value = lispify(constants, str.substring(extract3.length + 1));
41717
- } else {
41718
- value = lispify(constants, extract3, next);
41719
- }
41434
+ if (key[0] === 1) {
41435
+ key = key[2];
41720
41436
  }
41437
+ value = lispify(constants, str.substring(extract3.length + 1));
41721
41438
  }
41722
41439
  return createLisp({
41723
41440
  op: 6,
@@ -41744,72 +41461,12 @@ var require_parser = __commonJS({
41744
41461
  };
41745
41462
  setLispType(["inverse", "not", "negative", "positive", "typeof", "delete"], (constants, type, part, res, expect, ctx) => {
41746
41463
  const extract2 = restOfExp(constants, part.substring(res[0].length), [/^([^\s.?\w$]|\?[^.])/]);
41747
- const remainingAfterOperand = part.substring(extract2.length + res[0].length);
41748
- const remainingStr = remainingAfterOperand.trim().toString();
41749
- if (remainingStr.startsWith("**")) {
41750
- throw new SyntaxError("Unary operator used immediately before exponentiation expression. Parenthesis must be used to disambiguate operator precedence");
41751
- }
41752
41464
  ctx.lispTree = lispify(constants, part.substring(extract2.length + res[0].length), restOfExp.next, createLisp({
41753
41465
  op: modifierTypes[type],
41754
41466
  a: ctx.lispTree,
41755
41467
  b: lispify(constants, extract2, expectTypes[expect].next)
41756
41468
  }));
41757
41469
  });
41758
- setLispType(["taggedTemplate"], (constants, type, part, res, expect, ctx) => {
41759
- const literalIndex = res[1];
41760
- const literal2 = constants.literals[parseInt(literalIndex)];
41761
- const [, templateStr, jsExprs] = literal2;
41762
- const stringParts = [];
41763
- const expressions = [];
41764
- let currentStr = "";
41765
- let i4 = 0;
41766
- while (i4 < templateStr.length) {
41767
- if (templateStr.substring(i4, i4 + 2) === "${") {
41768
- let j4 = i4 + 2;
41769
- let exprIndex = "";
41770
- let isValidPlaceholder = false;
41771
- while (j4 < templateStr.length && templateStr[j4] !== "}") {
41772
- exprIndex += templateStr[j4];
41773
- j4++;
41774
- }
41775
- if (j4 < templateStr.length && templateStr[j4] === "}" && /^\d+$/.test(exprIndex)) {
41776
- isValidPlaceholder = true;
41777
- }
41778
- if (isValidPlaceholder) {
41779
- stringParts.push(currentStr);
41780
- currentStr = "";
41781
- expressions.push(jsExprs[parseInt(exprIndex)]);
41782
- i4 = j4 + 1;
41783
- } else {
41784
- currentStr += templateStr[i4];
41785
- i4++;
41786
- }
41787
- } else {
41788
- currentStr += templateStr[i4];
41789
- i4++;
41790
- }
41791
- }
41792
- stringParts.push(currentStr);
41793
- const stringsArray = stringParts.map((str) => createLisp({
41794
- op: 2,
41795
- a: 0,
41796
- b: String(constants.strings.push(str) - 1)
41797
- }));
41798
- const stringsArrayLisp = createLisp({
41799
- op: 12,
41800
- a: createLisp({
41801
- op: 0,
41802
- a: 0,
41803
- b: 0
41804
- }),
41805
- b: stringsArray
41806
- });
41807
- ctx.lispTree = lispify(constants, part.substring(res[0].length), expectTypes[expect].next, createLisp({
41808
- op: 5,
41809
- a: ctx.lispTree,
41810
- b: [stringsArrayLisp, ...expressions]
41811
- }));
41812
- });
41813
41470
  var incrementTypes = {
41814
41471
  "++$": 25,
41815
41472
  "--$": 27,
@@ -41834,7 +41491,7 @@ var require_parser = __commonJS({
41834
41491
  var adderTypes = {
41835
41492
  "&&": 29,
41836
41493
  "||": 30,
41837
- "??": 89,
41494
+ "??": 85,
41838
41495
  instanceof: 62,
41839
41496
  in: 63,
41840
41497
  "=": 9,
@@ -41849,12 +41506,9 @@ var require_parser = __commonJS({
41849
41506
  "|=": 73,
41850
41507
  ">>>=": 74,
41851
41508
  "<<=": 76,
41852
- ">>=": 75,
41853
- "&&=": 90,
41854
- "||=": 91,
41855
- "??=": 92
41509
+ ">>=": 75
41856
41510
  };
41857
- setLispType(["assign", "assignModify", "nullishCoalescing"], (constants, type, part, res, expect, ctx) => {
41511
+ setLispType(["assign", "assignModify", "boolOp"], (constants, type, part, res, expect, ctx) => {
41858
41512
  ctx.lispTree = createLisp({
41859
41513
  op: adderTypes[res[0]],
41860
41514
  a: ctx.lispTree,
@@ -41881,46 +41535,20 @@ var require_parser = __commonJS({
41881
41535
  "/": 48,
41882
41536
  "**": 49,
41883
41537
  "*": 50,
41884
- "%": 51,
41885
- "&&": 29,
41886
- "||": 30,
41887
- instanceof: 62,
41888
- in: 63
41889
- };
41890
- setLispType([
41891
- "power",
41892
- "opHigh",
41893
- "op",
41894
- "comparitor",
41895
- "bitwiseShift",
41896
- "bitwiseAnd",
41897
- "bitwiseXor",
41898
- "bitwiseOr",
41899
- "boolOpAnd",
41900
- "boolOpOr"
41901
- ], (constants, type, part, res, expect, ctx) => {
41538
+ "%": 51
41539
+ };
41540
+ setLispType(["opHigh", "op", "comparitor", "bitwise"], (constants, type, part, res, expect, ctx) => {
41902
41541
  const next = [expectTypes.inlineIf.types.inlineIf, inlineIfElse];
41903
41542
  switch (type) {
41904
- case "power":
41905
- break;
41906
41543
  case "opHigh":
41907
41544
  next.push(expectTypes.splitter.types.opHigh);
41908
41545
  case "op":
41909
41546
  next.push(expectTypes.splitter.types.op);
41910
41547
  case "comparitor":
41911
41548
  next.push(expectTypes.splitter.types.comparitor);
41912
- case "bitwiseShift":
41913
- next.push(expectTypes.splitter.types.bitwiseShift);
41914
- case "bitwiseAnd":
41915
- next.push(expectTypes.splitter.types.bitwiseAnd);
41916
- case "bitwiseXor":
41917
- next.push(expectTypes.splitter.types.bitwiseXor);
41918
- case "bitwiseOr":
41919
- next.push(expectTypes.splitter.types.bitwiseOr);
41920
- case "boolOpAnd":
41921
- next.push(expectTypes.splitter.types.boolOpAnd);
41922
- case "boolOpOr":
41923
- next.push(expectTypes.splitter.types.boolOpOr);
41549
+ case "bitwise":
41550
+ next.push(expectTypes.splitter.types.bitwise);
41551
+ next.push(expectTypes.splitter.types.boolOp);
41924
41552
  }
41925
41553
  const extract2 = restOfExp(constants, part.substring(res[0].length), next);
41926
41554
  ctx.lispTree = lispify(constants, part.substring(extract2.length + res[0].length), restOfExp.next, createLisp({
@@ -42094,11 +41722,7 @@ var require_parser = __commonJS({
42094
41722
  prop = matches[0];
42095
41723
  index = prop.length + res[0].length;
42096
41724
  } else {
42097
- throw new SyntaxError("Hanging dot");
42098
- }
42099
- } else {
42100
- if (utils.reservedWords.has(prop) && prop !== "this") {
42101
- throw new SyntaxError(`Unexpected token '${prop}'`);
41725
+ throw new SyntaxError("Hanging dot");
42102
41726
  }
42103
41727
  }
42104
41728
  ctx.lispTree = lispify(constants, part.substring(index), expectTypes[expect].next, createLisp({
@@ -42123,14 +41747,14 @@ var require_parser = __commonJS({
42123
41747
  });
42124
41748
  setLispType(["number", "boolean", "null", "und", "NaN", "Infinity"], (constants, type, part, res, expect, ctx) => {
42125
41749
  ctx.lispTree = lispify(constants, part.substring(res[0].length), expectTypes[expect].next, createLisp({
42126
- op: type === "number" ? res[12] ? 83 : 7 : 35,
41750
+ op: type === "number" ? res[10] ? 83 : 7 : 35,
42127
41751
  a: 0,
42128
- b: res[12] ? res[1] : res[0]
41752
+ b: res[10] ? res[1] : res[0]
42129
41753
  }));
42130
41754
  });
42131
41755
  setLispType(["string", "literal", "regex"], (constants, type, part, res, expect, ctx) => {
42132
41756
  ctx.lispTree = lispify(constants, part.substring(res[0].length), expectTypes[expect].next, createLisp({
42133
- op: type === "string" ? 2 : type === "literal" ? 84 : 85,
41757
+ op: type === "string" ? 2 : type === "literal" ? 84 : 86,
42134
41758
  a: 0,
42135
41759
  b: res[1]
42136
41760
  }));
@@ -42155,7 +41779,7 @@ var require_parser = __commonJS({
42155
41779
  const isArrow = type !== "function" && type !== "inlineFunction";
42156
41780
  const isReturn = isArrow && !res[res.length - 1];
42157
41781
  const argPos = isArrow ? 2 : 3;
42158
- const isAsync2 = res[1] ? 88 : 0;
41782
+ const isAsync2 = res[1] ? 89 : 0;
42159
41783
  const args = res[argPos] ? res[argPos].replace(/\s+/g, "").split(/,/g) : [];
42160
41784
  if (!isArrow) {
42161
41785
  args.unshift((res[2] || "").trimStart());
@@ -42169,11 +41793,6 @@ var require_parser = __commonJS({
42169
41793
  });
42170
41794
  const f4 = restOfExp(constants, part.substring(res[0].length), !isReturn ? [/^}/] : [/^[,)}\]]/, semiColon]);
42171
41795
  const func = isReturn ? "return " + f4 : f4.toString();
42172
- args.forEach((arg) => {
42173
- if (utils.reservedWords.has(arg.replace(/^\.\.\./, ""))) {
42174
- throw new SyntaxError(`Unexpected token '${arg}'`);
42175
- }
42176
- });
42177
41796
  ctx.lispTree = lispify(constants, part.substring(res[0].length + func.length + 1), expectTypes[expect].next, createLisp({
42178
41797
  op: isArrow ? 11 : type === "function" ? 37 : 10,
42179
41798
  a: [isAsync2, ...args],
@@ -42183,13 +41802,13 @@ var require_parser = __commonJS({
42183
41802
  var iteratorRegex = /^((let|var|const)\s+)?\s*([a-zA-Z$_][a-zA-Z\d$_]*)\s+(in|of)(?![\w$])/;
42184
41803
  setLispType(["for", "do", "while"], (constants, type, part, res, expect, ctx) => {
42185
41804
  let i4 = 0;
42186
- let startStep = 88;
41805
+ let startStep = 89;
42187
41806
  let startInternal = [];
42188
41807
  let getIterator = 0;
42189
41808
  let beforeStep = 0;
42190
- let checkFirst = 88;
41809
+ let checkFirst = 89;
42191
41810
  let condition;
42192
- let step = 88;
41811
+ let step = 89;
42193
41812
  let body;
42194
41813
  switch (type) {
42195
41814
  case "while": {
@@ -42269,7 +41888,7 @@ var require_parser = __commonJS({
42269
41888
  });
42270
41889
  setLispType(["loopAction"], (constants, type, part, res, expect, ctx) => {
42271
41890
  ctx.lispTree = createLisp({
42272
- op: 86,
41891
+ op: 87,
42273
41892
  a: res[1],
42274
41893
  b: 0
42275
41894
  });
@@ -42284,7 +41903,7 @@ var require_parser = __commonJS({
42284
41903
  let offset2 = 0;
42285
41904
  if (catchRes[1].startsWith("catch")) {
42286
41905
  catchRes = catchReg.exec(part.substring(res[0].length + body.length + 1).toString());
42287
- exception = catchRes[3] || "";
41906
+ exception = catchRes[2];
42288
41907
  catchBody = restOfExp(constants, part.substring(res[0].length + body.length + 1 + catchRes[0].length), [], "{");
42289
41908
  offset2 = res[0].length + body.length + 1 + catchRes[0].length + catchBody.length + 1;
42290
41909
  if ((catchRes = catchReg.exec(part.substring(offset2).toString())) && catchRes[1].startsWith("finally")) {
@@ -42307,7 +41926,7 @@ var require_parser = __commonJS({
42307
41926
  setLispType(["void", "await"], (constants, type, part, res, expect, ctx) => {
42308
41927
  const extract2 = restOfExp(constants, part.substring(res[0].length), [/^([^\s.?\w$]|\?[^.])/]);
42309
41928
  ctx.lispTree = lispify(constants, part.substring(res[0].length + extract2.length), expectTypes[expect].next, createLisp({
42310
- op: type === "void" ? 87 : 44,
41929
+ op: type === "void" ? 88 : 44,
42311
41930
  a: lispify(constants, extract2),
42312
41931
  b: 0
42313
41932
  }));
@@ -42524,7 +42143,6 @@ var require_parser = __commonJS({
42524
42143
  let rest = str;
42525
42144
  let sub = emptyString;
42526
42145
  let details = {};
42527
- let pendingDoWhile = false;
42528
42146
  const inserted = insertedSemicolons.get(str.ref) || new Array(str.ref.str.length);
42529
42147
  while ((sub = restOfExp(constants, rest, [], void 0, void 0, [colonsRegex], details)).length) {
42530
42148
  let valid = false;
@@ -42539,12 +42157,7 @@ var require_parser = __commonJS({
42539
42157
  const res = closingsNoInsertion.exec(rest.substring(sub.length - 1).toString());
42540
42158
  if (res) {
42541
42159
  if (res[2] === "while") {
42542
- if (details.lastWord === "do") {
42543
- valid = false;
42544
- pendingDoWhile = true;
42545
- } else {
42546
- valid = true;
42547
- }
42160
+ valid = details.lastWord !== "do";
42548
42161
  } else {
42549
42162
  valid = false;
42550
42163
  }
@@ -42552,11 +42165,8 @@ var require_parser = __commonJS({
42552
42165
  valid = false;
42553
42166
  }
42554
42167
  } else if (a4) {
42555
- if (pendingDoWhile && details.lastWord === "while") {
42556
- valid = true;
42557
- pendingDoWhile = false;
42558
- } else if (details.lastWord === "if" || details.lastWord === "while" || details.lastWord === "for" || details.lastWord === "else") {
42559
- valid = !!details.bodyContentAfterKeyword;
42168
+ if (details.lastWord === "if" || details.lastWord === "while" || details.lastWord === "for" || details.lastWord === "else") {
42169
+ valid = false;
42560
42170
  }
42561
42171
  }
42562
42172
  }
@@ -42618,7 +42228,6 @@ var require_parser = __commonJS({
42618
42228
  i4++;
42619
42229
  } else if (comment === "\n") {
42620
42230
  comment = "";
42621
- strRes.push("\n");
42622
42231
  }
42623
42232
  }
42624
42233
  } else {
@@ -42727,6 +42336,8 @@ var require_SandboxExec = __commonJS({
42727
42336
  var executor = require_executor();
42728
42337
  var utils = require_utils();
42729
42338
  function subscribeSet(obj, name14, callback, context) {
42339
+ if (!(obj instanceof Object))
42340
+ throw new Error("Invalid subscription object, got " + (typeof obj === "object" ? "null" : typeof obj));
42730
42341
  const names = context.setSubscriptions.get(obj) || /* @__PURE__ */ new Map();
42731
42342
  context.setSubscriptions.set(obj, names);
42732
42343
  const callbacks = names.get(name14) || /* @__PURE__ */ new Set();
@@ -42752,12 +42363,6 @@ var require_SandboxExec = __commonJS({
42752
42363
  this.setSubscriptions = /* @__PURE__ */ new WeakMap();
42753
42364
  this.changeSubscriptions = /* @__PURE__ */ new WeakMap();
42754
42365
  this.sandboxFunctions = /* @__PURE__ */ new WeakMap();
42755
- this.haltSubscriptions = /* @__PURE__ */ new Set();
42756
- this.resumeSubscriptions = /* @__PURE__ */ new Set();
42757
- this.halted = false;
42758
- this.timeoutHandleCounter = 0;
42759
- this.setTimeoutHandles = /* @__PURE__ */ new Map();
42760
- this.setIntervalHandles = /* @__PURE__ */ new Map();
42761
42366
  const opt = Object.assign({
42762
42367
  audit: false,
42763
42368
  forbidFunctionCalls: false,
@@ -42770,9 +42375,7 @@ var require_SandboxExec = __commonJS({
42770
42375
  }
42771
42376
  static get SAFE_GLOBALS() {
42772
42377
  return {
42773
- globalThis,
42774
42378
  Function,
42775
- eval,
42776
42379
  console: {
42777
42380
  debug: console.debug,
42778
42381
  error: console.error,
@@ -42860,8 +42463,6 @@ var require_SandboxExec = __commonJS({
42860
42463
  map3.set(proto, /* @__PURE__ */ new Set());
42861
42464
  });
42862
42465
  map3.set(Object, /* @__PURE__ */ new Set([
42863
- "constructor",
42864
- "name",
42865
42466
  "entries",
42866
42467
  "fromEntries",
42867
42468
  "getOwnPropertyNames",
@@ -42887,56 +42488,20 @@ var require_SandboxExec = __commonJS({
42887
42488
  subscribeSetGlobal(obj, name14, callback) {
42888
42489
  return subscribeSet(obj, name14, callback, this);
42889
42490
  }
42890
- subscribeHalt(cb) {
42891
- this.haltSubscriptions.add(cb);
42892
- return {
42893
- unsubscribe: () => {
42894
- this.haltSubscriptions.delete(cb);
42895
- }
42896
- };
42897
- }
42898
- subscribeResume(cb) {
42899
- this.resumeSubscriptions.add(cb);
42900
- return {
42901
- unsubscribe: () => {
42902
- this.resumeSubscriptions.delete(cb);
42903
- }
42904
- };
42905
- }
42906
- haltExecution(haltContext) {
42907
- if (this.halted)
42908
- return;
42909
- this.halted = true;
42910
- for (const cb of this.haltSubscriptions) {
42911
- cb(haltContext);
42912
- }
42913
- }
42914
- resumeExecution() {
42915
- if (!this.halted)
42916
- return;
42917
- if (this.context.ticks.tickLimit && this.context.ticks.ticks >= this.context.ticks.tickLimit) {
42918
- throw new utils.SandboxExecutionQuotaExceededError("Cannot resume execution: tick limit exceeded");
42919
- }
42920
- this.halted = false;
42921
- for (const cb of this.resumeSubscriptions) {
42922
- cb();
42923
- }
42924
- }
42925
42491
  getContext(fn) {
42926
42492
  return this.sandboxFunctions.get(fn);
42927
42493
  }
42928
42494
  executeTree(context, scopes = []) {
42929
- return executor.executeTree(context.ctx.ticks, context, context.tree, scopes);
42495
+ return executor.executeTree({
42496
+ ticks: BigInt(0)
42497
+ }, context, context.tree, scopes);
42930
42498
  }
42931
42499
  executeTreeAsync(context, scopes = []) {
42932
- return executor.executeTreeAsync(context.ctx.ticks, context, context.tree, scopes);
42500
+ return executor.executeTreeAsync({
42501
+ ticks: BigInt(0)
42502
+ }, context, context.tree, scopes);
42933
42503
  }
42934
42504
  };
42935
- exports2.LocalScope = utils.LocalScope;
42936
- exports2.SandboxAccessError = utils.SandboxAccessError;
42937
- exports2.SandboxCapabilityError = utils.SandboxCapabilityError;
42938
- exports2.SandboxError = utils.SandboxError;
42939
- exports2.SandboxExecutionTreeError = utils.SandboxExecutionTreeError;
42940
42505
  exports2.default = SandboxExec;
42941
42506
  }
42942
42507
  });
@@ -42957,15 +42522,10 @@ var require_Sandbox = __commonJS({
42957
42522
  sandboxedEval,
42958
42523
  sandboxedSetTimeout,
42959
42524
  sandboxedSetInterval,
42960
- sandboxedClearTimeout,
42961
- sandboxedClearInterval,
42962
42525
  lispifyFunction: parser.lispifyFunction
42963
42526
  };
42964
42527
  }
42965
- function SB() {
42966
- }
42967
42528
  function sandboxFunction(context, ticks) {
42968
- SandboxFunction.prototype = SB.prototype;
42969
42529
  return SandboxFunction;
42970
42530
  function SandboxFunction(...params) {
42971
42531
  const code = params.pop() || "";
@@ -42977,10 +42537,7 @@ var require_Sandbox = __commonJS({
42977
42537
  }, void 0, "anonymous");
42978
42538
  }
42979
42539
  }
42980
- function SAF() {
42981
- }
42982
42540
  function sandboxAsyncFunction(context, ticks) {
42983
- SandboxAsyncFunction.prototype = SAF.prototype;
42984
42541
  return SandboxAsyncFunction;
42985
42542
  function SandboxAsyncFunction(...params) {
42986
42543
  const code = params.pop() || "";
@@ -42992,172 +42549,25 @@ var require_Sandbox = __commonJS({
42992
42549
  }, void 0, "anonymous");
42993
42550
  }
42994
42551
  }
42995
- function SE() {
42996
- }
42997
- function sandboxedEval(func, context) {
42998
- sandboxEval.prototype = SE.prototype;
42552
+ function sandboxedEval(func) {
42999
42553
  return sandboxEval;
43000
42554
  function sandboxEval(code) {
43001
- const parsed = parser.default(code);
43002
- const tree = wrapLastStatementInReturn(parsed.tree);
43003
- return executor.createFunction([], tree, executor.currentTicks.current, {
43004
- ...context,
43005
- constants: parsed.constants,
43006
- tree
43007
- }, void 0, "anonymous")();
43008
- }
43009
- }
43010
- function wrapLastStatementInReturn(tree) {
43011
- if (tree.length === 0)
43012
- return tree;
43013
- const newTree = [...tree];
43014
- const lastIndex = newTree.length - 1;
43015
- const lastStmt = newTree[lastIndex];
43016
- if (Array.isArray(lastStmt) && lastStmt.length >= 1) {
43017
- const op2 = lastStmt[0];
43018
- if (op2 === 8 || op2 === 46) {
43019
- return newTree;
43020
- }
43021
- const statementTypes = [
43022
- 3,
43023
- // 3
43024
- 4,
43025
- // 4
43026
- 34,
43027
- // 35
43028
- 37,
43029
- // 38
43030
- 13,
43031
- // 14
43032
- 38,
43033
- // 39
43034
- 39,
43035
- // 40
43036
- 40,
43037
- // 41
43038
- 42,
43039
- // 43
43040
- 43
43041
- // 44
43042
- ];
43043
- if (statementTypes.includes(op2)) {
43044
- return newTree;
43045
- }
43046
- newTree[lastIndex] = [8, 0, lastStmt];
43047
- }
43048
- return newTree;
43049
- }
43050
- function sST() {
43051
- }
43052
- function sandboxedSetTimeout(func, context) {
43053
- sandboxSetTimeout.prototype = sST.prototype;
43054
- return sandboxSetTimeout;
43055
- function sandboxSetTimeout(handler, timeout, ...args) {
43056
- const sandbox = context.ctx.sandbox;
43057
- const exec6 = (...a4) => {
43058
- const h4 = typeof handler === "string" ? func(handler) : handler;
43059
- haltsub.unsubscribe();
43060
- contsub.unsubscribe();
43061
- sandbox.setTimeoutHandles.delete(sandBoxhandle);
43062
- return h4(...a4);
43063
- };
43064
- const sandBoxhandle = ++sandbox.timeoutHandleCounter;
43065
- let start = Date.now();
43066
- let handle = setTimeout(exec6, timeout, ...args);
43067
- let elapsed = 0;
43068
- const haltsub = sandbox.subscribeHalt(() => {
43069
- elapsed = Date.now() - start + elapsed;
43070
- clearTimeout(handle);
43071
- });
43072
- const contsub = sandbox.subscribeResume(() => {
43073
- start = Date.now();
43074
- const remaining = Math.floor((timeout || 0) - elapsed);
43075
- handle = setTimeout(exec6, remaining, ...args);
43076
- sandbox.setTimeoutHandles.set(sandBoxhandle, {
43077
- handle,
43078
- haltsub,
43079
- contsub
43080
- });
43081
- });
43082
- sandbox.setTimeoutHandles.set(sandBoxhandle, {
43083
- handle,
43084
- haltsub,
43085
- contsub
43086
- });
43087
- return sandBoxhandle;
42555
+ return func(code)();
43088
42556
  }
43089
42557
  }
43090
- function sCT() {
43091
- }
43092
- function sandboxedClearTimeout(context) {
43093
- sandboxClearTimeout.prototype = sCT.prototype;
43094
- return sandboxClearTimeout;
43095
- function sandboxClearTimeout(handle) {
43096
- const sandbox = context.ctx.sandbox;
43097
- const timeoutHandle = sandbox.setTimeoutHandles.get(handle);
43098
- if (timeoutHandle) {
43099
- clearTimeout(timeoutHandle.handle);
43100
- timeoutHandle.haltsub.unsubscribe();
43101
- timeoutHandle.contsub.unsubscribe();
43102
- sandbox.setTimeoutHandles.delete(handle);
43103
- }
43104
- }
43105
- }
43106
- function sCI() {
43107
- }
43108
- function sandboxedClearInterval(context) {
43109
- sandboxClearInterval.prototype = sCI.prototype;
43110
- return sandboxClearInterval;
43111
- function sandboxClearInterval(handle) {
43112
- const sandbox = context.ctx.sandbox;
43113
- const intervalHandle = sandbox.setIntervalHandles.get(handle);
43114
- if (intervalHandle) {
43115
- clearInterval(intervalHandle.handle);
43116
- intervalHandle.haltsub.unsubscribe();
43117
- intervalHandle.contsub.unsubscribe();
43118
- sandbox.setIntervalHandles.delete(handle);
43119
- }
43120
- }
43121
- }
43122
- function sSI() {
42558
+ function sandboxedSetTimeout(func) {
42559
+ return function sandboxSetTimeout(handler, ...args) {
42560
+ if (typeof handler !== "string")
42561
+ return setTimeout(handler, ...args);
42562
+ return setTimeout(func(handler), ...args);
42563
+ };
43123
42564
  }
43124
- function sandboxedSetInterval(func, context) {
43125
- sandboxSetInterval.prototype = sSI.prototype;
43126
- return sandboxSetInterval;
43127
- function sandboxSetInterval(handler, timeout, ...args) {
43128
- const sandbox = context.ctx.sandbox;
43129
- const h4 = typeof handler === "string" ? func(handler) : handler;
43130
- const exec6 = (...a4) => {
43131
- start = Date.now();
43132
- elapsed = 0;
43133
- return h4(...a4);
43134
- };
43135
- const sandBoxhandle = ++sandbox.timeoutHandleCounter;
43136
- let start = Date.now();
43137
- let handle = setInterval(exec6, timeout, ...args);
43138
- let elapsed = 0;
43139
- const haltsub = sandbox.subscribeHalt(() => {
43140
- elapsed = Date.now() - start + elapsed;
43141
- clearInterval(handle);
43142
- });
43143
- const contsub = sandbox.subscribeResume(() => {
43144
- start = Date.now();
43145
- handle = setTimeout(() => {
43146
- start = Date.now();
43147
- elapsed = 0;
43148
- handle = setInterval(exec6, timeout, ...args);
43149
- exec6(...args);
43150
- }, Math.floor((timeout || 0) - elapsed), ...args);
43151
- handlObj.handle = handle;
43152
- });
43153
- const handlObj = {
43154
- handle,
43155
- haltsub,
43156
- contsub
43157
- };
43158
- sandbox.setIntervalHandles.set(sandBoxhandle, handlObj);
43159
- return sandBoxhandle;
43160
- }
42565
+ function sandboxedSetInterval(func) {
42566
+ return function sandboxSetInterval(handler, ...args) {
42567
+ if (typeof handler !== "string")
42568
+ return setInterval(handler, ...args);
42569
+ return setInterval(func(handler), ...args);
42570
+ };
43161
42571
  }
43162
42572
  var Sandbox2 = class extends SandboxExec.default {
43163
42573
  constructor(options) {
@@ -43216,11 +42626,6 @@ var require_Sandbox = __commonJS({
43216
42626
  return exec6;
43217
42627
  }
43218
42628
  };
43219
- exports2.LocalScope = utils.LocalScope;
43220
- exports2.SandboxAccessError = utils.SandboxAccessError;
43221
- exports2.SandboxCapabilityError = utils.SandboxCapabilityError;
43222
- exports2.SandboxError = utils.SandboxError;
43223
- exports2.SandboxExecutionTreeError = utils.SandboxExecutionTreeError;
43224
42629
  exports2.default = Sandbox2;
43225
42630
  }
43226
42631
  });
@@ -95322,9 +94727,11 @@ __export(schemaUtils_exports, {
95322
94727
  isJsonSchema: () => isJsonSchema,
95323
94728
  isJsonSchemaDefinition: () => isJsonSchemaDefinition,
95324
94729
  isMermaidSchema: () => isMermaidSchema,
94730
+ isSimpleTextWrapperSchema: () => isSimpleTextWrapperSchema,
95325
94731
  processSchemaResponse: () => processSchemaResponse,
95326
94732
  replaceMermaidDiagramsInJson: () => replaceMermaidDiagramsInJson,
95327
94733
  replaceMermaidDiagramsInMarkdown: () => replaceMermaidDiagramsInMarkdown,
94734
+ tryAutoWrapForSimpleSchema: () => tryAutoWrapForSimpleSchema,
95328
94735
  tryMaidAutoFix: () => tryMaidAutoFix,
95329
94736
  validateAndFixMermaidResponse: () => validateAndFixMermaidResponse,
95330
94737
  validateJsonResponse: () => validateJsonResponse,
@@ -95842,6 +95249,46 @@ function isJsonSchemaDefinition(jsonString, options = {}) {
95842
95249
  return false;
95843
95250
  }
95844
95251
  }
95252
+ function isSimpleTextWrapperSchema(schema) {
95253
+ if (!schema || typeof schema !== "string") {
95254
+ return null;
95255
+ }
95256
+ const trimmed = schema.trim();
95257
+ const simplePatterns = [
95258
+ /^\{\s*["']?(\w+)["']?\s*:\s*["']?string["']?\s*\}$/i,
95259
+ /^\{\s*["']?type["']?\s*:\s*["']?object["']?\s*,\s*["']?properties["']?\s*:\s*\{\s*["']?(\w+)["']?\s*:\s*\{\s*["']?type["']?\s*:\s*["']?string["']?\s*\}\s*\}\s*\}$/i
95260
+ ];
95261
+ for (const pattern of simplePatterns) {
95262
+ const match2 = trimmed.match(pattern);
95263
+ if (match2) {
95264
+ return { fieldName: match2[1] };
95265
+ }
95266
+ }
95267
+ return null;
95268
+ }
95269
+ function tryAutoWrapForSimpleSchema(response, schema, options = {}) {
95270
+ const { debug = false } = options;
95271
+ const wrapperInfo = isSimpleTextWrapperSchema(schema);
95272
+ if (!wrapperInfo) {
95273
+ if (debug) {
95274
+ console.log(`[DEBUG] Auto-wrap: Schema is not a simple text wrapper`);
95275
+ }
95276
+ return null;
95277
+ }
95278
+ try {
95279
+ JSON.parse(response);
95280
+ if (debug) {
95281
+ console.log(`[DEBUG] Auto-wrap: Response is already valid JSON, skipping`);
95282
+ }
95283
+ return null;
95284
+ } catch {
95285
+ }
95286
+ const wrapped = JSON.stringify({ [wrapperInfo.fieldName]: response });
95287
+ if (debug) {
95288
+ console.log(`[DEBUG] Auto-wrap: Wrapped plain text in {"${wrapperInfo.fieldName}": ...} (${response.length} chars)`);
95289
+ }
95290
+ return wrapped;
95291
+ }
95845
95292
  function createJsonCorrectionPrompt(invalidResponse, schema, errorOrValidation, retryCount = 0) {
95846
95293
  let errorMessage;
95847
95294
  let enhancedError;
@@ -95873,7 +95320,7 @@ function createJsonCorrectionPrompt(invalidResponse, schema, errorOrValidation,
95873
95320
  const currentLevel = strengthLevels[level];
95874
95321
  let prompt = `${currentLevel.prefix} Your previous response is not valid JSON and cannot be parsed. Here's what you returned:
95875
95322
 
95876
- ${invalidResponse.substring(0, 500)}${invalidResponse.length > 500 ? "..." : ""}
95323
+ ${invalidResponse}
95877
95324
 
95878
95325
  Error: ${enhancedError}
95879
95326
 
@@ -111543,6 +110990,16 @@ Convert your previous response content into actual JSON data that follows this s
111543
110990
  validation = validateJsonResponse(finalResult);
111544
110991
  retryCount = 1;
111545
110992
  }
110993
+ if (!validation.isValid) {
110994
+ const autoWrapped = tryAutoWrapForSimpleSchema(finalResult, options.schema, { debug: this.debug });
110995
+ if (autoWrapped) {
110996
+ if (this.debug) {
110997
+ console.log(`[DEBUG] JSON validation: Auto-wrapped plain text for simple schema`);
110998
+ }
110999
+ finalResult = autoWrapped;
111000
+ validation = validateJsonResponse(finalResult, { debug: this.debug });
111001
+ }
111002
+ }
111546
111003
  while (!validation.isValid && retryCount < maxRetries) {
111547
111004
  if (this.debug) {
111548
111005
  console.log(`[DEBUG] JSON validation: attempt_completion validation failed (attempt ${retryCount + 1}/${maxRetries}):`, validation.error);