poe-code 14.0.60 → 14.0.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/index.js +313 -135
  2. package/dist/index.js.map +4 -4
  3. package/dist/metafile.json +1 -1
  4. package/package.json +1 -1
  5. package/packages/safe-js/dist/chunks/{chunk-C7UCTQDN.js → chunk-F7TJSPDZ.js} +7 -3
  6. package/packages/safe-js/dist/chunks/chunk-F7TJSPDZ.js.map +7 -0
  7. package/packages/safe-js/dist/chunks/{chunk-MKJBQPBH.js → chunk-VKGWGZBH.js} +268 -126
  8. package/packages/safe-js/dist/chunks/chunk-VKGWGZBH.js.map +7 -0
  9. package/packages/safe-js/dist/cli.js +2 -2
  10. package/packages/safe-js/dist/core.js +1 -1
  11. package/packages/safe-js/dist/index.js +2 -2
  12. package/packages/safe-js/dist/interp/async.js +3 -0
  13. package/packages/safe-js/dist/interp/function-string.d.ts +2 -0
  14. package/packages/safe-js/dist/interp/function-string.js +21 -0
  15. package/packages/safe-js/dist/interp/globals/misc.js +11 -12
  16. package/packages/safe-js/dist/interp/globals/numeric-parsers.d.ts +5 -0
  17. package/packages/safe-js/dist/interp/globals/numeric-parsers.js +47 -0
  18. package/packages/safe-js/dist/interp/globals/object-array.js +2 -10
  19. package/packages/safe-js/dist/interp/interpreter.js +9 -14
  20. package/packages/safe-js/dist/interp/methods/function.d.ts +2 -0
  21. package/packages/safe-js/dist/interp/methods/function.js +10 -1
  22. package/packages/safe-js/dist/interp/methods/string.js +18 -0
  23. package/packages/safe-js/dist/interp/resources.d.ts +3 -0
  24. package/packages/safe-js/dist/interp/resources.js +11 -0
  25. package/packages/safe-js/dist/interp/string-coercion.js +16 -4
  26. package/packages/safe-js/dist/interp/values.d.ts +3 -0
  27. package/packages/safe-js/dist/interp/values.js +3 -0
  28. package/packages/safe-js/dist/migrate.js +1 -1
  29. package/packages/safe-js/dist/parse/function-source.d.ts +7 -0
  30. package/packages/safe-js/dist/parse/function-source.js +1 -0
  31. package/packages/safe-js/dist/parse/hash.d.ts +2 -2
  32. package/packages/safe-js/dist/parse/hash.js +23 -9
  33. package/packages/safe-js/dist/parse/parser.js +36 -23
  34. package/packages/safe-js/dist/restore.js +2 -1
  35. package/packages/safe-js/dist/run.js +16 -5
  36. package/packages/safe-js/dist/snapshot/dump-format.d.ts +1 -1
  37. package/packages/safe-js/dist/snapshot/dump-format.js +1 -1
  38. package/packages/safe-js/dist/snapshot/migration.js +2 -2
  39. package/packages/safe-js/dist/snapshot/restore.js +2 -0
  40. package/packages/safe-js/dist/chunks/chunk-C7UCTQDN.js.map +0 -7
  41. package/packages/safe-js/dist/chunks/chunk-MKJBQPBH.js.map +0 -7
package/dist/index.js CHANGED
@@ -107711,7 +107711,7 @@ function registerUsageCommand(program, container) {
107711
107711
  const modelName = entry.bot_name.length > modelMaxWidth ? entry.bot_name.slice(0, modelMaxWidth - 1) + "\u2026" : entry.bot_name;
107712
107712
  const costText = `$${entry.cost_usd} (${entry.cost_points} points)`;
107713
107713
  const bd = entry.cost_breakdown_in_points;
107714
- const parseTokens2 = (s) => {
107714
+ const parseTokens = (s) => {
107715
107715
  if (!s) return "-";
107716
107716
  const start = s.indexOf("(");
107717
107717
  const end = s.indexOf(" tokens");
@@ -107722,9 +107722,9 @@ function registerUsageCommand(program, container) {
107722
107722
  Date: theme.muted(formatted),
107723
107723
  Model: theme.accent(modelName),
107724
107724
  Cost: entry.cost_points < 0 ? theme.error(costText) : theme.success(costText),
107725
- Input: theme.muted(parseTokens2(bd?.Input)),
107726
- Output: theme.muted(parseTokens2(bd?.Output)),
107727
- Cached: theme.muted(parseTokens2(bd?.["Cache discount"]))
107725
+ Input: theme.muted(parseTokens(bd?.Input)),
107726
+ Output: theme.muted(parseTokens(bd?.Output)),
107727
+ Cached: theme.muted(parseTokens(bd?.["Cache discount"]))
107728
107728
  };
107729
107729
  };
107730
107730
  let totalFetched = 0;
@@ -121455,6 +121455,15 @@ var init_assign_ids = __esm({
121455
121455
  }
121456
121456
  });
121457
121457
 
121458
+ // packages/safe-js/src/parse/function-source.ts
121459
+ var functionSources;
121460
+ var init_function_source = __esm({
121461
+ "packages/safe-js/src/parse/function-source.ts"() {
121462
+ "use strict";
121463
+ functionSources = /* @__PURE__ */ new WeakMap();
121464
+ }
121465
+ });
121466
+
121458
121467
  // packages/safe-js/src/parse/format-error.ts
121459
121468
  function formatParseError(source, filename, error3) {
121460
121469
  const location = parseErrorLocation(error3.message);
@@ -122095,7 +122104,11 @@ function parse15(source, filename = "<input>", owner) {
122095
122104
  const compilation = new CompileScope(owner);
122096
122105
  try {
122097
122106
  const result = assignIds(
122098
- parseTokens(tokenize3(source, { allowRegexLiterals: true, compilation }), compilation)
122107
+ new Parser(
122108
+ tokenize3(source, { allowRegexLiterals: true, compilation }),
122109
+ source,
122110
+ compilation
122111
+ ).parseTopLevel()
122099
122112
  );
122100
122113
  const regexLiteral = findRegexLiteral(result);
122101
122114
  if (regexLiteral !== void 0) {
@@ -122121,7 +122134,11 @@ function parseModule(source, filename = "<input>", owner) {
122121
122134
  const compilation = new CompileScope(owner);
122122
122135
  try {
122123
122136
  return assignIds(
122124
- parseModuleTokens(tokenize3(source, { allowRegexLiterals: true, compilation }), compilation)
122137
+ new Parser(
122138
+ tokenize3(source, { allowRegexLiterals: true, compilation }),
122139
+ source,
122140
+ compilation
122141
+ ).parseModule()
122125
122142
  );
122126
122143
  } catch (error3) {
122127
122144
  if (error3 instanceof DisallowedSyntaxError || error3 instanceof SandboxError) {
@@ -122139,7 +122156,11 @@ function parseExecutableModule(source, filename = "<input>", owner) {
122139
122156
  const compilation = new CompileScope(owner);
122140
122157
  try {
122141
122158
  const result = assignIds(
122142
- parseModuleTokens(tokenize3(source, { allowRegexLiterals: true, compilation }), compilation)
122159
+ new Parser(
122160
+ tokenize3(source, { allowRegexLiterals: true, compilation }),
122161
+ source,
122162
+ compilation
122163
+ ).parseModule()
122143
122164
  );
122144
122165
  throwIfImportMetaAssignment(result);
122145
122166
  return result;
@@ -122155,12 +122176,6 @@ function parseExecutableModule(source, filename = "<input>", owner) {
122155
122176
  compilation.dispose();
122156
122177
  }
122157
122178
  }
122158
- function parseTokens(tokens, compilation) {
122159
- return new Parser(tokens, compilation).parseTopLevel();
122160
- }
122161
- function parseModuleTokens(tokens, compilation) {
122162
- return new Parser(tokens, compilation).parseModule();
122163
- }
122164
122179
  function createIdentifier2(token) {
122165
122180
  return {
122166
122181
  type: "Identifier",
@@ -122469,6 +122484,7 @@ function createTemplateLiteral(token, options, compilation) {
122469
122484
  raw.slice(expressionStart, expressionEnd),
122470
122485
  positionWithinRaw(token.start, raw, expressionStart),
122471
122486
  options.functionContext,
122487
+ options.source,
122472
122488
  compilation
122473
122489
  )
122474
122490
  );
@@ -122831,13 +122847,13 @@ function decodeHexEscape(value, start) {
122831
122847
  end: index + 2
122832
122848
  };
122833
122849
  }
122834
- function parseEmbeddedExpression(source, base, functionContext, compilation) {
122850
+ function parseEmbeddedExpression(source, base, functionContext, fullSource, compilation) {
122835
122851
  const tokens = tokenize3(source, { allowRegexLiterals: true, compilation }).map((token) => ({
122836
122852
  ...token,
122837
122853
  start: rebasePosition(token.start, base),
122838
122854
  end: rebasePosition(token.end, base)
122839
122855
  }));
122840
- return new Parser(tokens, compilation, functionContext).parseExpressionOnly();
122856
+ return new Parser(tokens, fullSource, compilation, functionContext).parseExpressionOnly();
122841
122857
  }
122842
122858
  function findRegexLiteral(node) {
122843
122859
  if (node === null || node === void 0) {
@@ -122983,6 +122999,7 @@ var init_parser3 = __esm({
122983
122999
  init_bindings();
122984
123000
  init_tokenizer2();
122985
123001
  init_assign_ids();
123002
+ init_function_source();
122986
123003
  init_format_error();
122987
123004
  init_parse_export();
122988
123005
  init_parse_import_meta();
@@ -123022,13 +123039,15 @@ var init_parser3 = __esm({
123022
123039
  "while"
123023
123040
  ]);
123024
123041
  Parser = class {
123025
- constructor(tokens, compilation, functionContext = "normal") {
123042
+ constructor(tokens, source, compilation, functionContext = "normal") {
123026
123043
  this.tokens = tokens;
123044
+ this.source = source;
123027
123045
  this.compilation = compilation;
123028
123046
  this.functionContext = functionContext;
123029
123047
  this.functionScopes.add(this.scopes[0]);
123030
123048
  }
123031
123049
  tokens;
123050
+ source;
123032
123051
  compilation;
123033
123052
  functionContext;
123034
123053
  index = 0;
@@ -123039,6 +123058,14 @@ var init_parser3 = __esm({
123039
123058
  scopes = [/* @__PURE__ */ new Map()];
123040
123059
  functionScopes = /* @__PURE__ */ new WeakSet();
123041
123060
  varNames = /* @__PURE__ */ new WeakMap();
123061
+ withFunctionSource(node) {
123062
+ functionSources.set(node, {
123063
+ text: this.source,
123064
+ start: node.span.start.offset,
123065
+ end: node.span.end.offset
123066
+ });
123067
+ return node;
123068
+ }
123042
123069
  parseTopLevel() {
123043
123070
  if (this.isExportToken(this.currentToken())) {
123044
123071
  throw new DisallowedSyntaxError("export", this.currentToken().start);
@@ -123180,14 +123207,14 @@ var init_parser3 = __esm({
123180
123207
  });
123181
123208
  this.expectPunctuator("=>");
123182
123209
  const body = this.parseArrowFunctionBody(params);
123183
- return {
123210
+ return this.withFunctionSource({
123184
123211
  type: "ArrowFunctionExpression",
123185
123212
  async: isAsync,
123186
123213
  body,
123187
123214
  expression: body.type !== "BlockStatement",
123188
123215
  params,
123189
123216
  span: createSpan2(start, body.span.end)
123190
- };
123217
+ });
123191
123218
  }
123192
123219
  parseConditionalExpression() {
123193
123220
  if (this.conditionalExpressionDepth >= MAX_CONDITIONAL_EXPRESSION_DEPTH) {
@@ -123827,8 +123854,11 @@ var init_parser3 = __esm({
123827
123854
  return parsedParams;
123828
123855
  });
123829
123856
  const generator = generatorToken !== void 0;
123830
- const body = this.withFunctionContext(generator ? "generator" : "normal", () => this.parseBlockStatement(params));
123831
- return {
123857
+ const body = this.withFunctionContext(
123858
+ generator ? "generator" : "normal",
123859
+ () => this.parseBlockStatement(params)
123860
+ );
123861
+ return this.withFunctionSource({
123832
123862
  type: "FunctionDeclaration",
123833
123863
  async: asyncToken !== void 0,
123834
123864
  body,
@@ -123836,7 +123866,7 @@ var init_parser3 = __esm({
123836
123866
  id,
123837
123867
  params,
123838
123868
  span: createSpan2(asyncToken?.start ?? functionToken.start, body.span.end)
123839
- };
123869
+ });
123840
123870
  }
123841
123871
  parseVariableDeclarator(kind) {
123842
123872
  const id = this.parseBindingTarget();
@@ -124604,7 +124634,11 @@ var init_parser3 = __esm({
124604
124634
  if (this.currentToken().type === "template") {
124605
124635
  const quasi = createTemplateLiteral(
124606
124636
  this.currentToken(),
124607
- { allowMalformedEscapes: true, functionContext: this.functionContext },
124637
+ {
124638
+ allowMalformedEscapes: true,
124639
+ functionContext: this.functionContext,
124640
+ source: this.source
124641
+ },
124608
124642
  this.compilation
124609
124643
  );
124610
124644
  this.index += 1;
@@ -124693,7 +124727,11 @@ var init_parser3 = __esm({
124693
124727
  return {
124694
124728
  node: createTemplateLiteral(
124695
124729
  token,
124696
- { allowMalformedEscapes: false, functionContext: this.functionContext },
124730
+ {
124731
+ allowMalformedEscapes: false,
124732
+ functionContext: this.functionContext,
124733
+ source: this.source
124734
+ },
124697
124735
  this.compilation
124698
124736
  ),
124699
124737
  parenthesized: false
@@ -124778,7 +124816,8 @@ var init_parser3 = __esm({
124778
124816
  break;
124779
124817
  }
124780
124818
  const optional = this.consumePunctuator("?.");
124781
- if (optional !== void 0) throw new DisallowedSyntaxError("new optional chain", optional.start);
124819
+ if (optional !== void 0)
124820
+ throw new DisallowedSyntaxError("new optional chain", optional.start);
124782
124821
  const args = this.consumePunctuator("(") === void 0 ? [] : this.parseArguments();
124783
124822
  const end = this.previousToken();
124784
124823
  return {
@@ -124811,8 +124850,11 @@ var init_parser3 = __esm({
124811
124850
  return parsedParams;
124812
124851
  });
124813
124852
  const generator = generatorToken !== void 0;
124814
- const body = this.withFunctionContext(generator ? "generator" : "normal", () => this.parseBlockStatement(params));
124815
- return {
124853
+ const body = this.withFunctionContext(
124854
+ generator ? "generator" : "normal",
124855
+ () => this.parseBlockStatement(params)
124856
+ );
124857
+ return this.withFunctionSource({
124816
124858
  type: "FunctionExpression",
124817
124859
  async: asyncToken !== void 0,
124818
124860
  body,
@@ -124820,7 +124862,7 @@ var init_parser3 = __esm({
124820
124862
  id,
124821
124863
  params,
124822
124864
  span: createSpan2(asyncToken?.start ?? functionToken.start, body.span.end)
124823
- };
124865
+ });
124824
124866
  }
124825
124867
  parseArrayExpression() {
124826
124868
  const start = this.expectPunctuator("[");
@@ -125056,7 +125098,7 @@ var init_parser3 = __esm({
125056
125098
  return parsedParams;
125057
125099
  });
125058
125100
  const body = this.withFunctionContext("normal", () => this.parseBlockStatement(params));
125059
- return {
125101
+ return this.withFunctionSource({
125060
125102
  type: "FunctionExpression",
125061
125103
  async: asyncToken !== void 0,
125062
125104
  body,
@@ -125065,7 +125107,7 @@ var init_parser3 = __esm({
125065
125107
  method: true,
125066
125108
  params,
125067
125109
  span: createSpan2(asyncToken?.start ?? methodStart, body.span.end)
125068
- };
125110
+ });
125069
125111
  }
125070
125112
  parseIdentifierName() {
125071
125113
  const token = this.currentToken();
@@ -125624,19 +125666,19 @@ var init_parser3 = __esm({
125624
125666
  });
125625
125667
 
125626
125668
  // packages/safe-js/src/parse/hash.ts
125627
- function hashSource(source, owner) {
125669
+ function hashSource(source, owner, includeFunctionSource = true) {
125628
125670
  try {
125629
- return hashParsedAst(parse15(source, "<input>", owner));
125671
+ return hashParsedAst(parse15(source, "<input>", owner), includeFunctionSource);
125630
125672
  } catch (error3) {
125631
125673
  if (error3 instanceof SandboxError) throw error3;
125632
- return hashParsedAst(parseModule(source, "<input>", owner));
125674
+ return hashParsedAst(parseModule(source, "<input>", owner), includeFunctionSource);
125633
125675
  }
125634
125676
  }
125635
- function hashParsedAst(ast) {
125677
+ function hashParsedAst(ast, includeFunctionSource = true) {
125636
125678
  let hash = FNV_OFFSET_BASIS;
125637
125679
  visit(ast);
125638
125680
  return hash.toString(16).padStart(8, "0");
125639
- function visit(value, includeTemplateRaw = false) {
125681
+ function visit(value, includeTemplateRaw = false, enclosingSource) {
125640
125682
  if (value === null) {
125641
125683
  write2("null");
125642
125684
  return;
@@ -125648,7 +125690,7 @@ function hashParsedAst(ast) {
125648
125690
  if (Array.isArray(value)) {
125649
125691
  write2("[");
125650
125692
  for (const entry of value) {
125651
- visit(entry, includeTemplateRaw);
125693
+ visit(entry, includeTemplateRaw, enclosingSource);
125652
125694
  write2(",");
125653
125695
  }
125654
125696
  write2("]");
@@ -125666,12 +125708,23 @@ function hashParsedAst(ast) {
125666
125708
  return;
125667
125709
  case "object": {
125668
125710
  const record2 = value;
125711
+ const source = includeFunctionSource ? functionSources.get(value) : void 0;
125712
+ if (source !== void 0 && !(enclosingSource !== void 0 && source.text === enclosingSource.text && source.start >= enclosingSource.start && source.end <= enclosingSource.end)) {
125713
+ write2("function-source:");
125714
+ write2(String(source.end - source.start));
125715
+ write2(":");
125716
+ write2(source.text, source.start, source.end);
125717
+ }
125669
125718
  const keys = Object.keys(value).filter((key3) => shouldHashKey(record2, key3, includeTemplateRaw)).sort();
125670
125719
  write2("{");
125671
125720
  for (const key3 of keys) {
125672
125721
  write2(JSON.stringify(key3));
125673
125722
  write2(":");
125674
- visit(record2[key3], shouldIncludeTemplateRaw(record2, key3, includeTemplateRaw));
125723
+ visit(
125724
+ record2[key3],
125725
+ shouldIncludeTemplateRaw(record2, key3, includeTemplateRaw),
125726
+ source ?? enclosingSource
125727
+ );
125675
125728
  write2(",");
125676
125729
  }
125677
125730
  write2("}");
@@ -125681,8 +125734,8 @@ function hashParsedAst(ast) {
125681
125734
  throw new TypeError(`Unsupported AST value type: ${typeof value}`);
125682
125735
  }
125683
125736
  }
125684
- function write2(chunk) {
125685
- for (let index = 0; index < chunk.length; index += 1) {
125737
+ function write2(chunk, start = 0, end = chunk.length) {
125738
+ for (let index = start; index < end; index += 1) {
125686
125739
  hash ^= chunk.charCodeAt(index);
125687
125740
  hash = Math.imul(hash, FNV_PRIME) >>> 0;
125688
125741
  }
@@ -125712,6 +125765,7 @@ var init_hash = __esm({
125712
125765
  "use strict";
125713
125766
  init_parser3();
125714
125767
  init_budget2();
125768
+ init_function_source();
125715
125769
  FNV_OFFSET_BASIS = 2166136261;
125716
125770
  FNV_PRIME = 16777619;
125717
125771
  IGNORED_KEYS = /* @__PURE__ */ new Set(["nodeId", "raw", "span"]);
@@ -128613,6 +128667,83 @@ var init_regex = __esm({
128613
128667
  }
128614
128668
  });
128615
128669
 
128670
+ // packages/safe-js/src/interp/resources.ts
128671
+ import { AsyncLocalStorage as AsyncLocalStorage6 } from "node:async_hooks";
128672
+ function retainValues(budget, values) {
128673
+ const retained = {};
128674
+ budget.setRetainedValues(retained, values);
128675
+ const pending = runResources.getStore()?.referenceReleases;
128676
+ const release2 = () => {
128677
+ budget.setRetainedValues(retained, void 0);
128678
+ pending?.delete(release2);
128679
+ };
128680
+ pending?.add(release2);
128681
+ return release2;
128682
+ }
128683
+ async function withRunResources(signal, execute2) {
128684
+ const controller = new AbortController();
128685
+ const cancel2 = () => controller.abort(signal?.reason);
128686
+ const cleanups = /* @__PURE__ */ new Set();
128687
+ const resources = {
128688
+ signal: controller.signal,
128689
+ referenceReleases: /* @__PURE__ */ new Set(),
128690
+ add(close) {
128691
+ cleanups.add(close);
128692
+ }
128693
+ };
128694
+ signal?.addEventListener("abort", cancel2, { once: true });
128695
+ if (signal?.aborted) cancel2();
128696
+ let result;
128697
+ let failure;
128698
+ let errors2 = [];
128699
+ try {
128700
+ result = await runResources.run(resources, execute2);
128701
+ } catch (error3) {
128702
+ failure = { reason: error3 };
128703
+ } finally {
128704
+ signal?.removeEventListener("abort", cancel2);
128705
+ controller.abort(new Error("SafeJS run finished."));
128706
+ for (const release2 of resources.referenceReleases) release2();
128707
+ resources.referenceReleases.clear();
128708
+ const outcomes = await Promise.allSettled(
128709
+ [...cleanups].map((close) => Promise.resolve().then(close))
128710
+ );
128711
+ errors2 = outcomes.flatMap((outcome) => outcome.status === "rejected" ? [outcome.reason] : []);
128712
+ }
128713
+ if (failure !== void 0) throw failure.reason;
128714
+ if (errors2.length > 0) throw new AggregateError(errors2, "SafeJS resource cleanup failed.");
128715
+ return result;
128716
+ }
128717
+ var runResources;
128718
+ var init_resources = __esm({
128719
+ "packages/safe-js/src/interp/resources.ts"() {
128720
+ "use strict";
128721
+ runResources = new AsyncLocalStorage6();
128722
+ }
128723
+ });
128724
+
128725
+ // packages/safe-js/src/interp/function-string.ts
128726
+ function functionString(value) {
128727
+ if (runResources.getStore()?.functionSourceText === false) return "[object Object]";
128728
+ const source = value.sourceRange;
128729
+ if (source !== void 0) return source.text.slice(source.start, source.end);
128730
+ let name = value.boundTarget === void 0 ? value.name?.split("#").at(-1) ?? "" : "";
128731
+ for (let index = 0; index < name.length; index++) {
128732
+ const code = name.charCodeAt(index);
128733
+ if (!(code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 36 || code === 95 || index > 0 && code >= 48 && code <= 57)) {
128734
+ name = "";
128735
+ break;
128736
+ }
128737
+ }
128738
+ return `function ${name}() { [native code] }`;
128739
+ }
128740
+ var init_function_string = __esm({
128741
+ "packages/safe-js/src/interp/function-string.ts"() {
128742
+ "use strict";
128743
+ init_resources();
128744
+ }
128745
+ });
128746
+
128616
128747
  // packages/safe-js/src/interp/string-coercion.ts
128617
128748
  function sandboxNumber(value, budget, context) {
128618
128749
  if (value === null || typeof value !== "object") {
@@ -128678,6 +128809,7 @@ function conversionHook(value, name, budget) {
128678
128809
  return void 0;
128679
128810
  }
128680
128811
  async function defaultToString(value, budget, context, joining) {
128812
+ if (isSandboxClosure(value)) return budget.allocateString(functionString(value));
128681
128813
  if (isSandboxMap(value)) return "[object Map]";
128682
128814
  if (isSandboxSet(value)) return "[object Set]";
128683
128815
  if (isSandboxCollectionIterator(value)) return collectionIteratorState(value).collectionKind === "map" ? "[object Map Iterator]" : "[object Set Iterator]";
@@ -128697,9 +128829,10 @@ async function defaultToString(value, budget, context, joining) {
128697
128829
  }
128698
128830
  if (joining.has(value)) return "";
128699
128831
  joining.add(value);
128832
+ let text5 = "";
128833
+ const release2 = retainValues(budget, () => [text5]);
128700
128834
  try {
128701
128835
  const length = isFloat32Array(value) ? float32Storage(value).length : value.length;
128702
- let text5 = "";
128703
128836
  for (let index = 0; index < length; index++) {
128704
128837
  budget.visitNode();
128705
128838
  const element = ownDataValue(value, String(index));
@@ -128708,15 +128841,21 @@ async function defaultToString(value, budget, context, joining) {
128708
128841
  }
128709
128842
  return text5;
128710
128843
  } finally {
128844
+ release2();
128711
128845
  joining.delete(value);
128712
128846
  }
128713
128847
  }
128714
128848
  if (sandboxErrorTypes.has(value)) {
128715
128849
  const nameValue = ownDataValue(value, "name");
128716
128850
  const name = nameValue === void 0 ? "Error" : await sandboxString(nameValue, budget, context, joining);
128717
- const messageValue2 = ownDataValue(value, "message");
128718
- const message2 = messageValue2 === void 0 ? "" : await sandboxString(messageValue2, budget, context, joining);
128719
- return name === "" ? message2 : message2 === "" ? name : `${name}: ${message2}`;
128851
+ const release2 = retainValues(budget, () => [name]);
128852
+ try {
128853
+ const messageValue2 = ownDataValue(value, "message");
128854
+ const message2 = messageValue2 === void 0 ? "" : await sandboxString(messageValue2, budget, context, joining);
128855
+ return name === "" ? message2 : message2 === "" ? name : `${name}: ${message2}`;
128856
+ } finally {
128857
+ release2();
128858
+ }
128720
128859
  }
128721
128860
  return isSandboxPromise(value) ? "[object Promise]" : "[object Object]";
128722
128861
  }
@@ -128740,6 +128879,8 @@ var init_string_coercion = __esm({
128740
128879
  init_collection_iterator();
128741
128880
  init_object_model();
128742
128881
  init_regex();
128882
+ init_resources();
128883
+ init_function_string();
128743
128884
  init_values();
128744
128885
  defaultStringHook = /* @__PURE__ */ Symbol("defaultStringHook");
128745
128886
  defaultValueHook = /* @__PURE__ */ Symbol("defaultValueHook");
@@ -129380,7 +129521,7 @@ var init_iteration = __esm({
129380
129521
  });
129381
129522
 
129382
129523
  // packages/safe-js/src/interp/jobs.ts
129383
- import { AsyncLocalStorage as AsyncLocalStorage6 } from "node:async_hooks";
129524
+ import { AsyncLocalStorage as AsyncLocalStorage7 } from "node:async_hooks";
129384
129525
  function runPromiseJob(task) {
129385
129526
  const job = activeJob.getStore();
129386
129527
  return job === void 0 ? Promise.resolve().then(task) : job.queue.run(task);
@@ -129414,7 +129555,7 @@ var activeJob, SandboxJobQueue;
129414
129555
  var init_jobs4 = __esm({
129415
129556
  "packages/safe-js/src/interp/jobs.ts"() {
129416
129557
  "use strict";
129417
- activeJob = new AsyncLocalStorage6();
129558
+ activeJob = new AsyncLocalStorage7();
129418
129559
  SandboxJobQueue = class {
129419
129560
  running = false;
129420
129561
  pending = [];
@@ -130228,7 +130369,7 @@ var init_promise = __esm({
130228
130369
  });
130229
130370
 
130230
130371
  // packages/safe-js/src/interp/cancel.ts
130231
- import { AsyncLocalStorage as AsyncLocalStorage7 } from "node:async_hooks";
130372
+ import { AsyncLocalStorage as AsyncLocalStorage8 } from "node:async_hooks";
130232
130373
  function withCancellationSignal(signal, task) {
130233
130374
  return activeCancellation.run({ signal, host: false }, task);
130234
130375
  }
@@ -130413,7 +130554,7 @@ var init_cancel2 = __esm({
130413
130554
  init_promise_tracker();
130414
130555
  init_shape();
130415
130556
  init_promise();
130416
- activeCancellation = new AsyncLocalStorage7();
130557
+ activeCancellation = new AsyncLocalStorage8();
130417
130558
  sandboxPromises = /* @__PURE__ */ new WeakSet();
130418
130559
  cancelableOutcomes = /* @__PURE__ */ new WeakMap();
130419
130560
  }
@@ -130435,6 +130576,9 @@ function createSandboxClosure(input) {
130435
130576
  enumerable: false,
130436
130577
  value: true
130437
130578
  });
130579
+ if (input.sourceRange !== void 0) {
130580
+ Object.defineProperty(closure, "sourceRange", { value: input.sourceRange });
130581
+ }
130438
130582
  if (input.sandbox === true) {
130439
130583
  Object.defineProperty(closure, "sandbox", { value: true });
130440
130584
  }
@@ -131745,7 +131889,7 @@ var init_dump_format = __esm({
131745
131889
  init_float32array();
131746
131890
  init_date();
131747
131891
  DUMP_FORMAT_VERSION = 1;
131748
- EXECUTION_SEMANTICS = "jobs-v7";
131892
+ EXECUTION_SEMANTICS = "jobs-v8";
131749
131893
  SKIP_VALUE = /* @__PURE__ */ Symbol("SafeJS.skip-dump-value");
131750
131894
  }
131751
131895
  });
@@ -132226,11 +132370,11 @@ var init_validation = __esm({
132226
132370
 
132227
132371
  // packages/safe-js/src/snapshot/migration.ts
132228
132372
  function validateMigrationSemantics(value) {
132229
- if (!["jobs-v1", "jobs-v2", "jobs-v3", "jobs-v4", "jobs-v5", "jobs-v6", "jobs-v7"].includes(
132373
+ if (!["jobs-v1", "jobs-v2", "jobs-v3", "jobs-v4", "jobs-v5", "jobs-v6", "jobs-v7", "jobs-v8"].includes(
132230
132374
  value
132231
132375
  ))
132232
132376
  throw new TypeError(
132233
- "Migration requires a supported execution-semantics marker (jobs-v1 through jobs-v7)."
132377
+ "Migration requires a supported execution-semantics marker (jobs-v1 through jobs-v8)."
132234
132378
  );
132235
132379
  }
132236
132380
  function validateMigrationJournal(sourceHash, replay, hostCalls = [], owner) {
@@ -132335,14 +132479,18 @@ function restore2(snapshot2, options, owner) {
132335
132479
  assertSnapshotInactive(snapshot2);
132336
132480
  validateDumpEnvelope(snapshot2);
132337
132481
  validateSnapshotMigration(snapshot2.migration, snapshot2.sourceHash, owner);
132338
- if (snapshot2.executionSemantics !== EXECUTION_SEMANTICS && snapshot2.executionSemantics !== "jobs-v6" && (snapshot2.executionSemantics !== void 0 || snapshot2.promiseReplay !== void 0 || snapshot2.replay !== void 0 || snapshot2.initialInputs !== void 0)) {
132482
+ if (snapshot2.executionSemantics !== EXECUTION_SEMANTICS && snapshot2.executionSemantics !== "jobs-v6" && snapshot2.executionSemantics !== "jobs-v7" && (snapshot2.executionSemantics !== void 0 || snapshot2.promiseReplay !== void 0 || snapshot2.replay !== void 0 || snapshot2.initialInputs !== void 0)) {
132339
132483
  throw new SnapshotValidationError(
132340
132484
  "unsupportedVersion",
132341
132485
  "$.executionSemantics",
132342
132486
  "incompatible execution semantics; resume with the SafeJS version that created this snapshot. Migration requires explicit reconciliation, not changing its version marker."
132343
132487
  );
132344
132488
  }
132345
- const currentSourceHash = hashSource(options.source, owner);
132489
+ const currentSourceHash = hashSource(
132490
+ options.source,
132491
+ owner,
132492
+ snapshot2.executionSemantics !== "jobs-v6" && snapshot2.executionSemantics !== "jobs-v7"
132493
+ );
132346
132494
  if (snapshot2.sourceHash !== currentSourceHash) {
132347
132495
  throw new SnapshotMismatchError(snapshot2.sourceHash, currentSourceHash);
132348
132496
  }
@@ -144094,50 +144242,6 @@ var init_var_hoist = __esm({
144094
144242
  }
144095
144243
  });
144096
144244
 
144097
- // packages/safe-js/src/interp/resources.ts
144098
- import { AsyncLocalStorage as AsyncLocalStorage8 } from "node:async_hooks";
144099
- async function withRunResources(signal, execute2) {
144100
- const controller = new AbortController();
144101
- const cancel2 = () => controller.abort(signal?.reason);
144102
- const cleanups = /* @__PURE__ */ new Set();
144103
- const resources = {
144104
- signal: controller.signal,
144105
- referenceReleases: /* @__PURE__ */ new Set(),
144106
- add(close) {
144107
- cleanups.add(close);
144108
- }
144109
- };
144110
- signal?.addEventListener("abort", cancel2, { once: true });
144111
- if (signal?.aborted) cancel2();
144112
- let result;
144113
- let failure;
144114
- let errors2 = [];
144115
- try {
144116
- result = await runResources.run(resources, execute2);
144117
- } catch (error3) {
144118
- failure = { reason: error3 };
144119
- } finally {
144120
- signal?.removeEventListener("abort", cancel2);
144121
- controller.abort(new Error("SafeJS run finished."));
144122
- for (const release2 of resources.referenceReleases) release2();
144123
- resources.referenceReleases.clear();
144124
- const outcomes = await Promise.allSettled(
144125
- [...cleanups].map((close) => Promise.resolve().then(close))
144126
- );
144127
- errors2 = outcomes.flatMap((outcome) => outcome.status === "rejected" ? [outcome.reason] : []);
144128
- }
144129
- if (failure !== void 0) throw failure.reason;
144130
- if (errors2.length > 0) throw new AggregateError(errors2, "SafeJS resource cleanup failed.");
144131
- return result;
144132
- }
144133
- var runResources;
144134
- var init_resources = __esm({
144135
- "packages/safe-js/src/interp/resources.ts"() {
144136
- "use strict";
144137
- runResources = new AsyncLocalStorage8();
144138
- }
144139
- });
144140
-
144141
144245
  // packages/safe-js/src/interp/methods/array.ts
144142
144246
  function getArrayMember(value, property, options) {
144143
144247
  const index = getArrayIndex(property);
@@ -144939,12 +145043,14 @@ function getFunctionMember(target, property, options) {
144939
145043
  if (property === "length") {
144940
145044
  return target.length;
144941
145045
  }
145046
+ if (property === "toString" && runResources.getStore()?.functionSourceText === false) return void 0;
144942
145047
  if (!isFunctionMethodName(property)) {
144943
145048
  return void 0;
144944
145049
  }
144945
145050
  return createSandboxClosure({
144946
145051
  sandbox: true,
144947
145052
  name: `Function#${property}`,
145053
+ ...property === "toString" ? { length: 0 } : {},
144948
145054
  call: (args, context) => callFunctionMethod(context?.thisValue, property, args, options, context?.stack ?? [])
144949
145055
  });
144950
145056
  }
@@ -144955,6 +145061,10 @@ function callFunctionMethod(target, methodName, args, options, stack) {
144955
145061
  if (!isSandboxClosure(target)) {
144956
145062
  throw new TypeError(`Function#${methodName} requires a callable receiver.`);
144957
145063
  }
145064
+ if (methodName === "toString") {
145065
+ const text5 = functionString(target);
145066
+ return options.budget?.allocateString(text5) ?? text5;
145067
+ }
144958
145068
  const thisValue = args[0];
144959
145069
  if (methodName === "bind") {
144960
145070
  const boundArgs = args.slice(1);
@@ -144995,7 +145105,9 @@ var init_function = __esm({
144995
145105
  "use strict";
144996
145106
  init_values();
144997
145107
  init_object_model();
144998
- functionMethodNames = /* @__PURE__ */ new Set(["apply", "bind", "call"]);
145108
+ init_function_string();
145109
+ init_resources();
145110
+ functionMethodNames = /* @__PURE__ */ new Set(["apply", "bind", "call", "toString"]);
144999
145111
  }
145000
145112
  });
145001
145113
 
@@ -145301,6 +145413,9 @@ function isStringMethodName(property) {
145301
145413
  function validateStringMethodArguments(_methodName, _args) {
145302
145414
  }
145303
145415
  function callStringMethod(value, methodName, args, budget, callClosure = async (closure, closureArgs) => await closure.call(closureArgs), parent, context) {
145416
+ if (methodName === "concat" && args.some((argument) => argument !== null && typeof argument === "object")) {
145417
+ return callConcat(value, args, budget, context);
145418
+ }
145304
145419
  if (methodName === "isWellFormed") {
145305
145420
  for (let index = 0; index < value.length; index++) {
145306
145421
  const codeUnit = value.charCodeAt(index);
@@ -145456,6 +145571,19 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
145456
145571
  operation.release();
145457
145572
  }
145458
145573
  }
145574
+ async function callConcat(value, args, budget, context) {
145575
+ let result = budget.allocateString(value);
145576
+ const release2 = retainValues(budget, () => [result]);
145577
+ try {
145578
+ for (const argument of args) {
145579
+ const text5 = sandboxString(argument, budget, context);
145580
+ result = budget.allocateString(result + (typeof text5 === "string" ? text5 : await text5));
145581
+ }
145582
+ return result;
145583
+ } finally {
145584
+ release2();
145585
+ }
145586
+ }
145459
145587
  function callReplaceLikeMethod(value, methodName, args, budget, callClosure, context) {
145460
145588
  const search = args[0];
145461
145589
  const replacement = args[1];
@@ -145709,6 +145837,7 @@ var init_string = __esm({
145709
145837
  init_compile_guard();
145710
145838
  init_engine2();
145711
145839
  init_string_coercion();
145840
+ init_resources();
145712
145841
  init_values();
145713
145842
  init_regex();
145714
145843
  SPLIT_STRING_MESSAGE = "String#split only supports string separator values.";
@@ -146993,14 +147122,18 @@ function isObjectPrototypeSetterProperty(property, key3) {
146993
147122
  }
146994
147123
  async function evaluateTemplateLiteral(node, context) {
146995
147124
  let value = context.budget.allocateString(node.quasis[0]?.value.cooked ?? "");
146996
- const release2 = retainValues(context.budget, () => [value]);
147125
+ let input = void 0;
147126
+ const release2 = retainValues(context.budget, () => [value, input]);
146997
147127
  try {
146998
147128
  for (let index = 0; index < node.expressions.length; index += 1) {
146999
147129
  const expression = await evaluateNode2(node.expressions[index], context);
147000
147130
  if (expression.kind !== "normal") {
147001
147131
  return expression;
147002
147132
  }
147003
- const expressionText = context.budget.allocateString(String(expression.value));
147133
+ input = expression.value;
147134
+ const text5 = sandboxString(input, context.budget, createCoercionContext(context));
147135
+ const expressionText = typeof text5 === "string" ? text5 : await text5;
147136
+ input = void 0;
147004
147137
  value = context.budget.allocateString(value + expressionText);
147005
147138
  const quasiText = context.budget.allocateString(node.quasis[index + 1]?.value.cooked ?? "");
147006
147139
  value = context.budget.allocateString(value + quasiText);
@@ -148447,17 +148580,6 @@ async function evaluateMemberAccess(node, context, consume) {
148447
148580
  release2();
148448
148581
  }
148449
148582
  }
148450
- function retainValues(budget, values) {
148451
- const retained = {};
148452
- budget.setRetainedValues(retained, values);
148453
- const pending = runResources.getStore()?.referenceReleases;
148454
- const release2 = () => {
148455
- budget.setRetainedValues(retained, void 0);
148456
- pending?.delete(release2);
148457
- };
148458
- pending?.add(release2);
148459
- return release2;
148460
- }
148461
148583
  async function evaluateMemberProperty(node, context) {
148462
148584
  const property = await evaluateNode2(node, context);
148463
148585
  if (property.kind !== "normal") {
@@ -149215,6 +149337,7 @@ function createSetMethodOptions(context) {
149215
149337
  }
149216
149338
  function createFunctionMethodOptions(context) {
149217
149339
  return {
149340
+ budget: context.budget,
149218
149341
  callClosure: (closure, args, stack, thisValue, construct) => invokeSandboxClosure(closure, args, context, stack, void 0, thisValue, construct)
149219
149342
  };
149220
149343
  }
@@ -149407,6 +149530,7 @@ var init_interpreter = __esm({
149407
149530
  init_jobs4();
149408
149531
  init_cancel2();
149409
149532
  init_resources();
149533
+ init_string_coercion();
149410
149534
  init_shape();
149411
149535
  init_async();
149412
149536
  init_host_call();
@@ -149547,6 +149671,7 @@ function createInterpretedClosure(node, context, evaluateNode3) {
149547
149671
  return isConstructResult(result) ? result : thisValue;
149548
149672
  } : void 0;
149549
149673
  const closure = createSandboxClosure({
149674
+ sourceRange: functionSources.get(node),
149550
149675
  guest: true,
149551
149676
  sandbox: true,
149552
149677
  length: getFunctionLength(node.params),
@@ -149609,6 +149734,7 @@ function executeAsyncFunction(execute2, budget, signal) {
149609
149734
  }
149610
149735
  function createGeneratorClosure(node, context, evaluateNode3) {
149611
149736
  return createSandboxClosure({
149737
+ sourceRange: functionSources.get(node),
149612
149738
  guest: true,
149613
149739
  generator: true,
149614
149740
  sandbox: true,
@@ -149800,6 +149926,7 @@ var init_async = __esm({
149800
149926
  init_var_hoist();
149801
149927
  init_interpreter();
149802
149928
  init_object_model();
149929
+ init_function_source();
149803
149930
  init_bindings();
149804
149931
  init_values();
149805
149932
  }
@@ -151262,6 +151389,54 @@ var init_regex2 = __esm({
151262
151389
  }
151263
151390
  });
151264
151391
 
151392
+ // packages/safe-js/src/interp/globals/numeric-parsers.ts
151393
+ function createNumericParsers(budget) {
151394
+ return {
151395
+ parseInt: createSandboxClosure({
151396
+ sandbox: true,
151397
+ name: "parseInt",
151398
+ call: ([value, radix], context) => {
151399
+ const parse18 = (text6) => {
151400
+ const release2 = retainValues(budget, () => [text6]);
151401
+ let convertedRadix;
151402
+ try {
151403
+ convertedRadix = sandboxNumber(radix, budget, context);
151404
+ } catch (error3) {
151405
+ release2();
151406
+ throw error3;
151407
+ }
151408
+ if (typeof convertedRadix === "number") {
151409
+ try {
151410
+ return globalThis.parseInt(text6, convertedRadix);
151411
+ } finally {
151412
+ release2();
151413
+ }
151414
+ }
151415
+ return convertedRadix.then((number) => globalThis.parseInt(text6, number)).finally(release2);
151416
+ };
151417
+ const text5 = sandboxString(value, budget, context);
151418
+ return typeof text5 === "string" ? parse18(text5) : text5.then(parse18);
151419
+ }
151420
+ }),
151421
+ parseFloat: createSandboxClosure({
151422
+ sandbox: true,
151423
+ name: "parseFloat",
151424
+ call: ([value], context) => {
151425
+ const text5 = sandboxString(value, budget, context);
151426
+ return typeof text5 === "string" ? globalThis.parseFloat(text5) : text5.then(globalThis.parseFloat);
151427
+ }
151428
+ })
151429
+ };
151430
+ }
151431
+ var init_numeric_parsers = __esm({
151432
+ "packages/safe-js/src/interp/globals/numeric-parsers.ts"() {
151433
+ "use strict";
151434
+ init_resources();
151435
+ init_string_coercion();
151436
+ init_values();
151437
+ }
151438
+ });
151439
+
151265
151440
  // packages/safe-js/src/interp/globals/misc.ts
151266
151441
  function createMiscGlobals(options) {
151267
151442
  return {
@@ -151270,24 +151445,21 @@ function createMiscGlobals(options) {
151270
151445
  call: ([value], context) => structuredCloneSandboxValue(value, options.budget, context?.compilation),
151271
151446
  name: "structuredClone"
151272
151447
  }),
151273
- parseInt: createSandboxClosure({
151274
- sandbox: true,
151275
- call: (args) => Reflect.apply(globalThis.parseInt, globalThis, [...args]),
151276
- name: "parseInt"
151277
- }),
151278
- parseFloat: createSandboxClosure({
151279
- sandbox: true,
151280
- call: (args) => Reflect.apply(globalThis.parseFloat, globalThis, [...args]),
151281
- name: "parseFloat"
151282
- }),
151448
+ ...createNumericParsers(options.budget),
151283
151449
  isNaN: createSandboxClosure({
151284
151450
  sandbox: true,
151285
- call: ([value]) => globalThis.isNaN(value),
151451
+ call: ([value], context) => {
151452
+ const number = sandboxNumber(value, options.budget, context);
151453
+ return typeof number === "number" ? Number.isNaN(number) : number.then(Number.isNaN);
151454
+ },
151286
151455
  name: "isNaN"
151287
151456
  }),
151288
151457
  isFinite: createSandboxClosure({
151289
151458
  sandbox: true,
151290
- call: ([value]) => globalThis.isFinite(value),
151459
+ call: ([value], context) => {
151460
+ const number = sandboxNumber(value, options.budget, context);
151461
+ return typeof number === "number" ? Number.isFinite(number) : number.then(Number.isFinite);
151462
+ },
151291
151463
  name: "isFinite"
151292
151464
  })
151293
151465
  };
@@ -151338,6 +151510,8 @@ var init_misc = __esm({
151338
151510
  init_collection_iterator();
151339
151511
  init_graph_depth();
151340
151512
  init_compile_guard();
151513
+ init_numeric_parsers();
151514
+ init_string_coercion();
151341
151515
  init_values();
151342
151516
  }
151343
151517
  });
@@ -151550,16 +151724,7 @@ function createObjectArrayGlobals(options) {
151550
151724
  call: ([value]) => typeof value === "number" && Number.isInteger(value),
151551
151725
  name: "isInteger"
151552
151726
  }),
151553
- parseInt: createSandboxClosure({
151554
- sandbox: true,
151555
- call: (args) => Reflect.apply(Number.parseInt, Number, [...args]),
151556
- name: "parseInt"
151557
- }),
151558
- parseFloat: createSandboxClosure({
151559
- sandbox: true,
151560
- call: (args) => Reflect.apply(Number.parseFloat, Number, [...args]),
151561
- name: "parseFloat"
151562
- }),
151727
+ ...createNumericParsers(options.budget),
151563
151728
  isSafeInteger: createSandboxClosure({
151564
151729
  sandbox: true,
151565
151730
  call: ([value]) => typeof value === "number" && Number.isSafeInteger(value),
@@ -151835,6 +152000,7 @@ var init_object_array = __esm({
151835
152000
  init_interpreter();
151836
152001
  init_iteration();
151837
152002
  init_string_coercion();
152003
+ init_numeric_parsers();
151838
152004
  init_object_model();
151839
152005
  init_values();
151840
152006
  }
@@ -153472,7 +153638,8 @@ function run(source, options = {}) {
153472
153638
  options.signal?.addEventListener("abort", captureCancellationSnapshot, { once: true });
153473
153639
  try {
153474
153640
  const restoredSnapshot = options.snapshot === void 0 ? void 0 : restore2(options.snapshot, { source }, operation.owner);
153475
- const executionSemantics = restoredSnapshot?.executionSemantics === "jobs-v6" ? "jobs-v6" : EXECUTION_SEMANTICS;
153641
+ const executionSemantics = restoredSnapshot?.executionSemantics === "jobs-v6" || restoredSnapshot?.executionSemantics === "jobs-v7" ? restoredSnapshot.executionSemantics : EXECUTION_SEMANTICS;
153642
+ runResources.getStore().functionSourceText = executionSemantics === EXECUTION_SEMANTICS;
153476
153643
  const convertInitialInput = (convert) => executionSemantics === "jobs-v6" ? convert() : promiseReplayContext.exit(convert);
153477
153644
  if (restoredSnapshot !== void 0) {
153478
153645
  leaveSnapshotRun = enterSnapshotRun(restoredSnapshot);
@@ -153481,7 +153648,7 @@ function run(source, options = {}) {
153481
153648
  const filename = options.filename ?? "<input>";
153482
153649
  const module = parseExecutableModule(source, filename, operation.owner);
153483
153650
  promiseReplay.validateNodes(module);
153484
- const sourceHash = findRegexLiteral(module) === void 0 ? hashSource(source, operation.owner) : hashParsedAst(module);
153651
+ const sourceHash = findRegexLiteral(module) === void 0 ? hashSource(source, operation.owner, executionSemantics === EXECUTION_SEMANTICS) : hashParsedAst(module, executionSemantics === EXECUTION_SEMANTICS);
153485
153652
  const hostCalls = new HostCallJournal(
153486
153653
  sourceHash,
153487
153654
  readHostCallSnapshot(restoredSnapshot),
@@ -153508,7 +153675,14 @@ function run(source, options = {}) {
153508
153675
  lifecycle
153509
153676
  })
153510
153677
  );
153511
- const builtinBindings = createBuiltinBindings({ compileOwner: operation.owner, budget, hostCalls, sink: options.sink, random: random?.generator.next, clock: options.clock });
153678
+ const builtinBindings = createBuiltinBindings({
153679
+ compileOwner: operation.owner,
153680
+ budget,
153681
+ hostCalls,
153682
+ sink: options.sink,
153683
+ random: random?.generator.next,
153684
+ clock: options.clock
153685
+ });
153512
153686
  const importMeta = convertInitialInput(
153513
153687
  () => deepCopyToSandbox(options.importMeta ?? {})
153514
153688
  );
@@ -154023,7 +154197,11 @@ function inspectSnapshotMigration(snapshot2, options) {
154023
154197
  validateSnapshotData(snapshot2);
154024
154198
  validateDumpEnvelope(snapshot2);
154025
154199
  validateMigrationSemantics(snapshot2.executionSemantics);
154026
- const sourceHash = hashSource(options.source);
154200
+ const sourceHash = hashSource(
154201
+ options.source,
154202
+ void 0,
154203
+ snapshot2.executionSemantics === EXECUTION_SEMANTICS
154204
+ );
154027
154205
  if (snapshot2.sourceHash !== sourceHash)
154028
154206
  throw new TypeError(
154029
154207
  `Migration requires the original executable source (checkpoint hash ${snapshot2.sourceHash}, supplied ${sourceHash}). Preserve the checkpoint; do not replace its hash.`