poe-code 10.0.3 → 11.0.0

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 (32) hide show
  1. package/dist/cli/commands/harness.js +27 -1
  2. package/dist/cli/commands/harness.js.map +1 -1
  3. package/dist/index.js +1125 -888
  4. package/dist/index.js.map +4 -4
  5. package/dist/metafile.json +1 -1
  6. package/package.json +1 -1
  7. package/packages/agent-harness/dist/loader/run.js +4 -1
  8. package/packages/safejs/dist/chunks/{chunk-MRH5YDMR.js → chunk-ARFGEQTM.js} +213 -51
  9. package/packages/safejs/dist/chunks/chunk-ARFGEQTM.js.map +7 -0
  10. package/packages/safejs/dist/chunks/{chunk-A2XBEN3H.js → chunk-DKXGPEOM.js} +182 -133
  11. package/packages/safejs/dist/chunks/{chunk-A2XBEN3H.js.map → chunk-DKXGPEOM.js.map} +3 -3
  12. package/packages/safejs/dist/cli.js +51 -2
  13. package/packages/safejs/dist/cli.js.map +2 -2
  14. package/packages/safejs/dist/core.js +1 -1
  15. package/packages/safejs/dist/index.d.ts +3 -0
  16. package/packages/safejs/dist/index.js +8 -2
  17. package/packages/safejs/dist/index.js.map +1 -1
  18. package/packages/safejs/dist/interp/interpreter.js +73 -127
  19. package/packages/safejs/dist/interp/scope.js +3 -3
  20. package/packages/safejs/dist/migrate.d.ts +33 -0
  21. package/packages/safejs/dist/migrate.js +70 -0
  22. package/packages/safejs/dist/migration-file.d.ts +55 -0
  23. package/packages/safejs/dist/migration-file.js +79 -0
  24. package/packages/safejs/dist/restore.d.ts +2 -0
  25. package/packages/safejs/dist/restore.js +2 -0
  26. package/packages/safejs/dist/run.js +18 -2
  27. package/packages/safejs/dist/snapshot/dump-format.d.ts +1 -1
  28. package/packages/safejs/dist/snapshot/dump-format.js +1 -1
  29. package/packages/safejs/dist/snapshot/migration.d.ts +34 -0
  30. package/packages/safejs/dist/snapshot/migration.js +92 -0
  31. package/packages/safejs/dist/snapshot/validation.js +0 -4
  32. package/packages/safejs/dist/chunks/chunk-MRH5YDMR.js.map +0 -7
package/dist/index.js CHANGED
@@ -67,9 +67,9 @@ function applyStyles(text5, styles) {
67
67
  if (!supportsColor() || styles.length === 0) {
68
68
  return text5;
69
69
  }
70
- const open8 = styles.map((style) => style.open).join("");
71
- const output = text5.includes(reset) ? replaceAll(text5, reset, `${reset}${open8}`) : text5;
72
- return `${open8}${output}${reset}`;
70
+ const open9 = styles.map((style) => style.open).join("");
71
+ const output = text5.includes(reset) ? replaceAll(text5, reset, `${reset}${open9}`) : text5;
72
+ return `${open9}${output}${reset}`;
73
73
  }
74
74
  function clampRgb(value) {
75
75
  if (Number.isNaN(value)) {
@@ -1867,14 +1867,14 @@ function parseTemplate(template2) {
1867
1867
  let tokens = root;
1868
1868
  let index = 0;
1869
1869
  while (index < template2.length) {
1870
- const open8 = template2.indexOf("{{", index);
1871
- if (open8 === -1) {
1870
+ const open9 = template2.indexOf("{{", index);
1871
+ if (open9 === -1) {
1872
1872
  appendText(tokens, template2.slice(index), index);
1873
1873
  break;
1874
1874
  }
1875
- appendText(tokens, template2.slice(index, open8), index);
1876
- const parsed = parseTag(template2, open8);
1877
- const standalone = getStandalone(template2, open8, parsed.end, parsed.kind);
1875
+ appendText(tokens, template2.slice(index, open9), index);
1876
+ const parsed = parseTag(template2, open9);
1877
+ const standalone = getStandalone(template2, open9, parsed.end, parsed.kind);
1878
1878
  if (standalone !== void 0) {
1879
1879
  trimTextAfter(tokens, standalone.lineStart);
1880
1880
  }
@@ -1891,7 +1891,7 @@ function parseTemplate(template2) {
1891
1891
  name: parsed.name,
1892
1892
  children: [],
1893
1893
  rawStart: parsed.end,
1894
- rawEnd: standalone?.lineStart ?? open8
1894
+ rawEnd: standalone?.lineStart ?? open9
1895
1895
  };
1896
1896
  tokens.push(token);
1897
1897
  stack.push({ token, parent: tokens });
@@ -1903,7 +1903,7 @@ function parseTemplate(template2) {
1903
1903
  tokens.push({
1904
1904
  type: "partial",
1905
1905
  name: parsed.name,
1906
- indent: standalone === void 0 ? "" : template2.slice(standalone.lineStart, open8)
1906
+ indent: standalone === void 0 ? "" : template2.slice(standalone.lineStart, open9)
1907
1907
  });
1908
1908
  index = standalone?.nextIndex ?? parsed.end;
1909
1909
  continue;
@@ -1916,12 +1916,12 @@ function parseTemplate(template2) {
1916
1916
  if (frame2.token.name !== parsed.name) {
1917
1917
  throw new Error(`Unclosed section "${frame2.token.name}" before closing "${parsed.name}"`);
1918
1918
  }
1919
- frame2.token.rawEnd = open8;
1919
+ frame2.token.rawEnd = open9;
1920
1920
  tokens = frame2.parent;
1921
1921
  index = standalone?.nextIndex ?? parsed.end;
1922
1922
  continue;
1923
1923
  }
1924
- tokens.push({ type: parsed.kind, name: parsed.name, raw: template2.slice(open8, parsed.end) });
1924
+ tokens.push({ type: parsed.kind, name: parsed.name, raw: template2.slice(open9, parsed.end) });
1925
1925
  index = parsed.end;
1926
1926
  }
1927
1927
  const frame = stack.pop();
@@ -1930,19 +1930,19 @@ function parseTemplate(template2) {
1930
1930
  }
1931
1931
  return root;
1932
1932
  }
1933
- function parseTag(template2, open8) {
1934
- if (template2.startsWith("{{{", open8)) {
1935
- const close2 = template2.indexOf("}}}", open8 + 3);
1933
+ function parseTag(template2, open9) {
1934
+ if (template2.startsWith("{{{", open9)) {
1935
+ const close2 = template2.indexOf("}}}", open9 + 3);
1936
1936
  if (close2 === -1) {
1937
- throw unclosedTagError(template2, open8, "}}}");
1937
+ throw unclosedTagError(template2, open9, "}}}");
1938
1938
  }
1939
- return { kind: "unescaped", name: template2.slice(open8 + 3, close2).trim(), end: close2 + 3 };
1939
+ return { kind: "unescaped", name: template2.slice(open9 + 3, close2).trim(), end: close2 + 3 };
1940
1940
  }
1941
- const close = template2.indexOf("}}", open8 + 2);
1941
+ const close = template2.indexOf("}}", open9 + 2);
1942
1942
  if (close === -1) {
1943
- throw unclosedTagError(template2, open8, "}}");
1943
+ throw unclosedTagError(template2, open9, "}}");
1944
1944
  }
1945
- const raw = template2.slice(open8 + 2, close).trim();
1945
+ const raw = template2.slice(open9 + 2, close).trim();
1946
1946
  const sigil = raw[0];
1947
1947
  const name = sigil === void 0 ? "" : raw.slice(1).trim();
1948
1948
  const end = close + 2;
@@ -1955,14 +1955,14 @@ function parseTag(template2, open8) {
1955
1955
  if (sigil === "=" && raw.endsWith("=")) return { kind: "delimiter", name, end };
1956
1956
  return { kind: "name", name: raw, end };
1957
1957
  }
1958
- function unclosedTagError(template2, open8, expected) {
1959
- const before = template2.slice(0, open8);
1960
- const lineEnd = template2.indexOf("\n", open8);
1961
- const opened = template2.slice(open8, lineEnd === -1 ? template2.length : lineEnd).trimEnd();
1958
+ function unclosedTagError(template2, open9, expected) {
1959
+ const before = template2.slice(0, open9);
1960
+ const lineEnd = template2.indexOf("\n", open9);
1961
+ const opened = template2.slice(open9, lineEnd === -1 ? template2.length : lineEnd).trimEnd();
1962
1962
  const tag = opened.length > MAX_TAG_EXCERPT_LENGTH ? `${opened.slice(0, MAX_TAG_EXCERPT_LENGTH)}...` : opened;
1963
1963
  return new TemplateParseError(`Unclosed tag "${tag}": expected "${expected}"`, {
1964
1964
  line: before.split("\n").length,
1965
- column: open8 - (before.lastIndexOf("\n") + 1) + 1
1965
+ column: open9 - (before.lastIndexOf("\n") + 1) + 1
1966
1966
  });
1967
1967
  }
1968
1968
  function getStandalone(template2, tagStart, tagEnd, kind) {
@@ -2170,12 +2170,12 @@ function expandTemplatePartials(template2, partials, partialStack) {
2170
2170
  let output = "";
2171
2171
  let index = 0;
2172
2172
  while (index < template2.length) {
2173
- const open8 = template2.indexOf("{{", index);
2174
- if (open8 === -1) {
2173
+ const open9 = template2.indexOf("{{", index);
2174
+ if (open9 === -1) {
2175
2175
  output += template2.slice(index);
2176
2176
  break;
2177
2177
  }
2178
- const parsed = parseTag(template2, open8);
2178
+ const parsed = parseTag(template2, open9);
2179
2179
  if (parsed.kind !== "partial") {
2180
2180
  output += template2.slice(index, parsed.end);
2181
2181
  index = parsed.end;
@@ -2192,9 +2192,9 @@ function expandTemplatePartials(template2, partials, partialStack) {
2192
2192
  if (partialStack.length >= MAX_PARTIAL_DEPTH) {
2193
2193
  throw new Error(`Maximum partial depth exceeded (${MAX_PARTIAL_DEPTH}).`);
2194
2194
  }
2195
- const standalone = getStandalone(template2, open8, parsed.end, parsed.kind);
2196
- const beforePartial = standalone === void 0 ? template2.slice(index, open8) : template2.slice(index, standalone.lineStart);
2197
- const indent = standalone === void 0 ? "" : template2.slice(standalone.lineStart, open8);
2195
+ const standalone = getStandalone(template2, open9, parsed.end, parsed.kind);
2196
+ const beforePartial = standalone === void 0 ? template2.slice(index, open9) : template2.slice(index, standalone.lineStart);
2197
+ const indent = standalone === void 0 ? "" : template2.slice(standalone.lineStart, open9);
2198
2198
  const partial = indentPartial(partials[parsed.name], indent);
2199
2199
  output += beforePartial + expandTemplatePartials(partial, partials, [...partialStack, parsed.name]);
2200
2200
  index = standalone?.nextIndex ?? parsed.end;
@@ -2826,11 +2826,11 @@ function parseInline(raw, options = {}) {
2826
2826
  index = footnoteReference.end;
2827
2827
  continue;
2828
2828
  }
2829
- const link3 = parseLink(raw, index, footnoteLabels, offsets);
2830
- if (link3 !== null) {
2829
+ const link4 = parseLink(raw, index, footnoteLabels, offsets);
2830
+ if (link4 !== null) {
2831
2831
  flushText();
2832
- nodes.push(link3.node);
2833
- index = link3.end;
2832
+ nodes.push(link4.node);
2833
+ index = link4.end;
2834
2834
  continue;
2835
2835
  }
2836
2836
  }
@@ -10694,7 +10694,7 @@ function createFrameWriter(stream, options = {}) {
10694
10694
  close();
10695
10695
  process.kill(process.pid, signal);
10696
10696
  }
10697
- function open8() {
10697
+ function open9() {
10698
10698
  if (opened) return;
10699
10699
  opened = true;
10700
10700
  stream.write(`${OPEN}${options.mouse === false ? CLOSE_MOUSE : OPEN_MOUSE}\x1B[?7l`);
@@ -10711,7 +10711,7 @@ function createFrameWriter(stream, options = {}) {
10711
10711
  stream.write(`\x1B[0m\x1B[?7h${options.mouse === false ? "" : CLOSE_MOUSE}${CLOSE}`);
10712
10712
  }
10713
10713
  return {
10714
- open: open8,
10714
+ open: open9,
10715
10715
  close,
10716
10716
  writeFrame(ansi) {
10717
10717
  if (!opened || ansi.length === 0) return;
@@ -16370,17 +16370,17 @@ function validate(schema, value) {
16370
16370
  }
16371
16371
  return { ok: true, value: result.present ? result.value : void 0 };
16372
16372
  }
16373
- function walkSchema(schema, value, path190, state) {
16373
+ function walkSchema(schema, value, path191, state) {
16374
16374
  if (schema.kind === "optional") {
16375
- return walkOptional(schema, value, path190, state);
16375
+ return walkOptional(schema, value, path191, state);
16376
16376
  }
16377
16377
  if (value === missingValue) {
16378
16378
  addIssue(
16379
16379
  state,
16380
- path190,
16380
+ path191,
16381
16381
  expectedFor(schema),
16382
16382
  "missing",
16383
- `Expected ${expectedFor(schema)} at ${formatPath(path190)}`
16383
+ `Expected ${expectedFor(schema)} at ${formatPath(path191)}`
16384
16384
  );
16385
16385
  return { present: false };
16386
16386
  }
@@ -16389,149 +16389,149 @@ function walkSchema(schema, value, path190, state) {
16389
16389
  }
16390
16390
  switch (schema.kind) {
16391
16391
  case "string":
16392
- return walkString(schema, value, path190, state);
16392
+ return walkString(schema, value, path191, state);
16393
16393
  case "number":
16394
- return walkNumber(schema, value, path190, state);
16394
+ return walkNumber(schema, value, path191, state);
16395
16395
  case "boolean":
16396
- return walkBoolean(value, path190, state);
16396
+ return walkBoolean(value, path191, state);
16397
16397
  case "enum":
16398
- return walkEnum(schema, value, path190, state);
16398
+ return walkEnum(schema, value, path191, state);
16399
16399
  case "array":
16400
- return walkArray(schema, value, path190, state);
16400
+ return walkArray(schema, value, path191, state);
16401
16401
  case "object":
16402
- return walkObject(schema, value, path190, state);
16402
+ return walkObject(schema, value, path191, state);
16403
16403
  case "oneOf":
16404
- return walkOneOf(schema, value, path190, state);
16404
+ return walkOneOf(schema, value, path191, state);
16405
16405
  case "union":
16406
- return walkUnion(schema, value, path190, state);
16406
+ return walkUnion(schema, value, path191, state);
16407
16407
  case "record":
16408
- return walkRecord(schema, value, path190, state);
16408
+ return walkRecord(schema, value, path191, state);
16409
16409
  case "json":
16410
- return walkJson(value, path190, state);
16410
+ return walkJson(value, path191, state);
16411
16411
  }
16412
16412
  }
16413
- function walkOptional(schema, value, path190, state) {
16413
+ function walkOptional(schema, value, path191, state) {
16414
16414
  if (value === missingValue || value === void 0) {
16415
16415
  const defaultValue = getDefault(schema.inner);
16416
16416
  if (defaultValue.present) {
16417
- return walkSchema(schema.inner, cloneDefault(defaultValue.value), path190, state);
16417
+ return walkSchema(schema.inner, cloneDefault(defaultValue.value), path191, state);
16418
16418
  }
16419
16419
  return { present: false };
16420
16420
  }
16421
- return walkSchema(schema.inner, value, path190, state);
16421
+ return walkSchema(schema.inner, value, path191, state);
16422
16422
  }
16423
- function walkString(schema, value, path190, state) {
16423
+ function walkString(schema, value, path191, state) {
16424
16424
  if (typeof value !== "string") {
16425
- addExpectedIssue(state, path190, "string", value);
16425
+ addExpectedIssue(state, path191, "string", value);
16426
16426
  return { present: true, value };
16427
16427
  }
16428
16428
  if (schema.minLength !== void 0 && value.length < schema.minLength) {
16429
16429
  const expected = `string with length at least ${schema.minLength}`;
16430
16430
  addIssue(
16431
16431
  state,
16432
- path190,
16432
+ path191,
16433
16433
  expected,
16434
16434
  `string with length ${value.length}`,
16435
- `Expected ${expected} at ${formatPath(path190)}`
16435
+ `Expected ${expected} at ${formatPath(path191)}`
16436
16436
  );
16437
16437
  }
16438
16438
  if (schema.maxLength !== void 0 && value.length > schema.maxLength) {
16439
16439
  const expected = `string with length at most ${schema.maxLength}`;
16440
16440
  addIssue(
16441
16441
  state,
16442
- path190,
16442
+ path191,
16443
16443
  expected,
16444
16444
  `string with length ${value.length}`,
16445
- `Expected ${expected} at ${formatPath(path190)}`
16445
+ `Expected ${expected} at ${formatPath(path191)}`
16446
16446
  );
16447
16447
  }
16448
16448
  if (schema.pattern !== void 0) {
16449
16449
  const pattern = compilePattern(schema.pattern);
16450
16450
  if (pattern === void 0 || !pattern.test(value)) {
16451
16451
  const expected = `string matching pattern ${schema.pattern}`;
16452
- addIssue(state, path190, expected, value, `Expected ${expected} at ${formatPath(path190)}`);
16452
+ addIssue(state, path191, expected, value, `Expected ${expected} at ${formatPath(path191)}`);
16453
16453
  }
16454
16454
  }
16455
16455
  return { present: true, value };
16456
16456
  }
16457
- function walkNumber(schema, value, path190, state) {
16457
+ function walkNumber(schema, value, path191, state) {
16458
16458
  if (typeof value !== "number" || !Number.isFinite(value)) {
16459
- addExpectedIssue(state, path190, schema.jsonType === "integer" ? "integer" : "number", value);
16459
+ addExpectedIssue(state, path191, schema.jsonType === "integer" ? "integer" : "number", value);
16460
16460
  return { present: true, value };
16461
16461
  }
16462
16462
  if (schema.jsonType === "integer" && !Number.isInteger(value)) {
16463
- addExpectedIssue(state, path190, "integer", value);
16463
+ addExpectedIssue(state, path191, "integer", value);
16464
16464
  }
16465
16465
  if (schema.minimum !== void 0 && value < schema.minimum) {
16466
16466
  const expected = `number greater than or equal to ${schema.minimum}`;
16467
- addIssue(state, path190, expected, String(value), `Expected ${expected} at ${formatPath(path190)}`);
16467
+ addIssue(state, path191, expected, String(value), `Expected ${expected} at ${formatPath(path191)}`);
16468
16468
  }
16469
16469
  if (schema.maximum !== void 0 && value > schema.maximum) {
16470
16470
  const expected = `number less than or equal to ${schema.maximum}`;
16471
- addIssue(state, path190, expected, String(value), `Expected ${expected} at ${formatPath(path190)}`);
16471
+ addIssue(state, path191, expected, String(value), `Expected ${expected} at ${formatPath(path191)}`);
16472
16472
  }
16473
16473
  return { present: true, value };
16474
16474
  }
16475
- function walkBoolean(value, path190, state) {
16475
+ function walkBoolean(value, path191, state) {
16476
16476
  if (typeof value !== "boolean") {
16477
- addExpectedIssue(state, path190, "boolean", value);
16477
+ addExpectedIssue(state, path191, "boolean", value);
16478
16478
  }
16479
16479
  return { present: true, value };
16480
16480
  }
16481
- function walkEnum(schema, value, path190, state) {
16481
+ function walkEnum(schema, value, path191, state) {
16482
16482
  if (!schema.values.includes(value)) {
16483
16483
  const expected = `one of ${schema.values.join(", ")}`;
16484
16484
  addIssue(
16485
16485
  state,
16486
- path190,
16486
+ path191,
16487
16487
  expected,
16488
16488
  receivedValue(value),
16489
- `Expected ${expected} at ${formatPath(path190)}`
16489
+ `Expected ${expected} at ${formatPath(path191)}`
16490
16490
  );
16491
16491
  }
16492
16492
  return { present: true, value };
16493
16493
  }
16494
- function walkArray(schema, value, path190, state) {
16494
+ function walkArray(schema, value, path191, state) {
16495
16495
  if (!Array.isArray(value)) {
16496
- addExpectedIssue(state, path190, "array", value);
16496
+ addExpectedIssue(state, path191, "array", value);
16497
16497
  return { present: true, value };
16498
16498
  }
16499
16499
  if (schema.minItems !== void 0 && value.length < schema.minItems) {
16500
16500
  const expected = `array with at least ${schema.minItems} items`;
16501
16501
  addIssue(
16502
16502
  state,
16503
- path190,
16503
+ path191,
16504
16504
  expected,
16505
16505
  `array with ${value.length} items`,
16506
- `Expected ${expected} at ${formatPath(path190)}`
16506
+ `Expected ${expected} at ${formatPath(path191)}`
16507
16507
  );
16508
16508
  }
16509
16509
  if (schema.maxItems !== void 0 && value.length > schema.maxItems) {
16510
16510
  const expected = `array with at most ${schema.maxItems} items`;
16511
16511
  addIssue(
16512
16512
  state,
16513
- path190,
16513
+ path191,
16514
16514
  expected,
16515
16515
  `array with ${value.length} items`,
16516
- `Expected ${expected} at ${formatPath(path190)}`
16516
+ `Expected ${expected} at ${formatPath(path191)}`
16517
16517
  );
16518
16518
  }
16519
16519
  const nextValue = value.map((item, index) => {
16520
- const result = walkSchema(schema.item, item, [...path190, String(index)], state);
16520
+ const result = walkSchema(schema.item, item, [...path191, String(index)], state);
16521
16521
  return result.present ? result.value : item;
16522
16522
  });
16523
16523
  return { present: true, value: nextValue };
16524
16524
  }
16525
- function walkObject(schema, value, path190, state, injectedProperties = {}) {
16525
+ function walkObject(schema, value, path191, state, injectedProperties = {}) {
16526
16526
  if (!isPlainRecord3(value)) {
16527
- addExpectedIssue(state, path190, "object", value);
16527
+ addExpectedIssue(state, path191, "object", value);
16528
16528
  return { present: true, value };
16529
16529
  }
16530
16530
  const nextValue = {};
16531
16531
  const allowedKeys = /* @__PURE__ */ new Set([...Object.keys(schema.shape), ...Object.keys(injectedProperties)]);
16532
16532
  for (const [key3, propertySchema] of Object.entries(schema.shape)) {
16533
16533
  const propertyValue = Object.hasOwn(value, key3) ? value[key3] : missingValue;
16534
- const result = walkSchema(propertySchema, propertyValue, [...path190, key3], state);
16534
+ const result = walkSchema(propertySchema, propertyValue, [...path191, key3], state);
16535
16535
  if (result.present) {
16536
16536
  setOwnValue(nextValue, key3, result.value);
16537
16537
  }
@@ -16550,18 +16550,18 @@ function walkObject(schema, value, path190, state, injectedProperties = {}) {
16550
16550
  if (schema.additionalProperties === true) {
16551
16551
  setOwnValue(nextValue, key3, propertyValue);
16552
16552
  } else {
16553
- addUnexpectedPropertyIssue(state, [...path190, key3]);
16553
+ addUnexpectedPropertyIssue(state, [...path191, key3]);
16554
16554
  }
16555
16555
  }
16556
16556
  return { present: true, value: nextValue };
16557
16557
  }
16558
- function walkOneOf(schema, value, path190, state) {
16558
+ function walkOneOf(schema, value, path191, state) {
16559
16559
  if (!isPlainRecord3(value)) {
16560
- addExpectedIssue(state, path190, "object", value);
16560
+ addExpectedIssue(state, path191, "object", value);
16561
16561
  return { present: true, value };
16562
16562
  }
16563
16563
  const discriminatorValue = value[schema.discriminator];
16564
- const discriminatorPath = [...path190, schema.discriminator];
16564
+ const discriminatorPath = [...path191, schema.discriminator];
16565
16565
  const branchValues = Object.keys(schema.branches);
16566
16566
  const expected = `one of ${branchValues.join(", ")}`;
16567
16567
  if (!Object.hasOwn(value, schema.discriminator)) {
@@ -16570,7 +16570,7 @@ function walkOneOf(schema, value, path190, state) {
16570
16570
  discriminatorPath,
16571
16571
  expected,
16572
16572
  "missing",
16573
- `Missing discriminator "${schema.discriminator}" at ${formatPath(path190)}. Expected one of: ${branchValues.join(", ")}.`
16573
+ `Missing discriminator "${schema.discriminator}" at ${formatPath(path191)}. Expected one of: ${branchValues.join(", ")}.`
16574
16574
  );
16575
16575
  return { present: true, value };
16576
16576
  }
@@ -16584,21 +16584,21 @@ function walkOneOf(schema, value, path190, state) {
16584
16584
  );
16585
16585
  return { present: true, value };
16586
16586
  }
16587
- return walkObject(schema.branches[discriminatorValue], value, path190, state, {
16587
+ return walkObject(schema.branches[discriminatorValue], value, path191, state, {
16588
16588
  [schema.discriminator]: discriminatorValue
16589
16589
  });
16590
16590
  }
16591
- function walkUnion(schema, value, path190, state) {
16591
+ function walkUnion(schema, value, path191, state) {
16592
16592
  if (isPlainRecord3(value)) {
16593
16593
  const candidateBranches = schema.branches.filter((branch) => hasRequiredKeys(branch, value));
16594
16594
  if (candidateBranches.length === 1) {
16595
- return walkObject(candidateBranches[0], value, path190, state);
16595
+ return walkObject(candidateBranches[0], value, path191, state);
16596
16596
  }
16597
16597
  }
16598
16598
  const matches = [];
16599
16599
  for (const branch of schema.branches) {
16600
16600
  const branchState = { issues: [] };
16601
- const result = walkObject(branch, value, path190, branchState);
16601
+ const result = walkObject(branch, value, path191, branchState);
16602
16602
  if (branchState.issues.length === 0 && result.present) {
16603
16603
  matches.push({ fingerprint: getRequiredKeyFingerprint(branch), value: result.value });
16604
16604
  }
@@ -16610,19 +16610,19 @@ function walkUnion(schema, value, path190, state) {
16610
16610
  const branchDescriptions = schema.branches.map((branch) => getRequiredKeyFingerprint(branch));
16611
16611
  addIssueWithMessage(
16612
16612
  state,
16613
- path190,
16613
+ path191,
16614
16614
  "exactly one union branch",
16615
16615
  "0 matching branches",
16616
- `No union branch matched at ${formatPath(path190)}. Tried ${schema.branches.length} branches. Expected one of: ${branchDescriptions.join(" | ")}.`
16616
+ `No union branch matched at ${formatPath(path191)}. Tried ${schema.branches.length} branches. Expected one of: ${branchDescriptions.join(" | ")}.`
16617
16617
  );
16618
16618
  return { present: true, value };
16619
16619
  }
16620
16620
  addIssueWithMessage(
16621
16621
  state,
16622
- path190,
16622
+ path191,
16623
16623
  "exactly one union branch",
16624
16624
  `${matches.length} matching branches`,
16625
- `Expected exactly one union branch at ${formatPath(path190)}, but matched more than one branch: ${matches.map((match) => match.fingerprint).join(" | ")}`
16625
+ `Expected exactly one union branch at ${formatPath(path191)}, but matched more than one branch: ${matches.map((match) => match.fingerprint).join(" | ")}`
16626
16626
  );
16627
16627
  return { present: true, value };
16628
16628
  }
@@ -16634,25 +16634,25 @@ function hasRequiredKeys(schema, value) {
16634
16634
  }
16635
16635
  return true;
16636
16636
  }
16637
- function walkRecord(schema, value, path190, state) {
16637
+ function walkRecord(schema, value, path191, state) {
16638
16638
  if (!isPlainRecord3(value)) {
16639
- addExpectedIssue(state, path190, "object", value);
16639
+ addExpectedIssue(state, path191, "object", value);
16640
16640
  return { present: true, value };
16641
16641
  }
16642
16642
  const nextValue = {};
16643
16643
  for (const [key3, propertyValue] of Object.entries(value)) {
16644
- const result = walkSchema(schema.value, propertyValue, [...path190, key3], state);
16644
+ const result = walkSchema(schema.value, propertyValue, [...path191, key3], state);
16645
16645
  if (result.present) {
16646
16646
  setOwnValue(nextValue, key3, result.value);
16647
16647
  }
16648
16648
  }
16649
16649
  return { present: true, value: nextValue };
16650
16650
  }
16651
- function walkJson(value, path190, state) {
16651
+ function walkJson(value, path191, state) {
16652
16652
  if (isJsonValue(value)) {
16653
16653
  return { present: true, value };
16654
16654
  }
16655
- addExpectedIssue(state, path190, "JSON value", value);
16655
+ addExpectedIssue(state, path191, "JSON value", value);
16656
16656
  return { present: true, value };
16657
16657
  }
16658
16658
  function getDefault(schema) {
@@ -16730,45 +16730,45 @@ function expectedFor(schema) {
16730
16730
  return expectedFor(schema.inner);
16731
16731
  }
16732
16732
  }
16733
- function addExpectedIssue(state, path190, expected, value) {
16733
+ function addExpectedIssue(state, path191, expected, value) {
16734
16734
  addIssue(
16735
16735
  state,
16736
- path190,
16736
+ path191,
16737
16737
  expected,
16738
16738
  receivedType(value),
16739
- `Expected ${expected} at ${formatPath(path190)}`
16739
+ `Expected ${expected} at ${formatPath(path191)}`
16740
16740
  );
16741
16741
  }
16742
- function addUnexpectedPropertyIssue(state, path190) {
16742
+ function addUnexpectedPropertyIssue(state, path191) {
16743
16743
  addIssue(
16744
16744
  state,
16745
- path190,
16745
+ path191,
16746
16746
  "no additional properties",
16747
16747
  "unknown property",
16748
- `Unexpected property ${formatPath(path190)}`
16748
+ `Unexpected property ${formatPath(path191)}`
16749
16749
  );
16750
16750
  }
16751
- function addIssue(state, path190, expected, received, _message) {
16751
+ function addIssue(state, path191, expected, received, _message) {
16752
16752
  state.issues.push({
16753
- path: path190,
16753
+ path: path191,
16754
16754
  expected,
16755
16755
  received,
16756
- message: formatIssueMessage(expected, path190, received)
16756
+ message: formatIssueMessage(expected, path191, received)
16757
16757
  });
16758
16758
  }
16759
- function addIssueWithMessage(state, path190, expected, received, message2) {
16759
+ function addIssueWithMessage(state, path191, expected, received, message2) {
16760
16760
  state.issues.push({
16761
- path: path190,
16761
+ path: path191,
16762
16762
  expected,
16763
16763
  received,
16764
16764
  message: message2
16765
16765
  });
16766
16766
  }
16767
- function formatIssueMessage(expected, path190, received) {
16768
- return `Expected ${expected} at ${formatPath(path190)}, got ${received}`;
16767
+ function formatIssueMessage(expected, path191, received) {
16768
+ return `Expected ${expected} at ${formatPath(path191)}, got ${received}`;
16769
16769
  }
16770
- function formatPath(path190) {
16771
- return path190.length === 0 ? "value" : path190.join(".");
16770
+ function formatPath(path191) {
16771
+ return path191.length === 0 ? "value" : path191.join(".");
16772
16772
  }
16773
16773
  function compilePattern(pattern) {
16774
16774
  try {
@@ -16882,8 +16882,8 @@ function receivedType2(value) {
16882
16882
  }
16883
16883
  return typeof value;
16884
16884
  }
16885
- function issue(path190, expected, value, message2, keyword = keywordFor(expected)) {
16886
- return { path: path190, expected, received: receivedType2(value), message: message2, keyword };
16885
+ function issue(path191, expected, value, message2, keyword = keywordFor(expected)) {
16886
+ return { path: path191, expected, received: receivedType2(value), message: message2, keyword };
16887
16887
  }
16888
16888
  function keywordFor(expected) {
16889
16889
  if (["null", "boolean", "object", "array", "number", "integer", "string"].includes(expected)) {
@@ -17715,44 +17715,44 @@ function evaluateArrayApplicators(graph, node, schema, value, context) {
17715
17715
  }
17716
17716
  return results;
17717
17717
  }
17718
- function evaluateValidationKeywords(node, schema, value, path190) {
17718
+ function evaluateValidationKeywords(node, schema, value, path191) {
17719
17719
  const results = [];
17720
17720
  if (schema.nullable === true && value === null) {
17721
17721
  return results;
17722
17722
  }
17723
17723
  const types2 = typeof schema.type === "string" ? [schema.type] : Array.isArray(schema.type) ? schema.type : [];
17724
17724
  if (types2.length > 0 && !types2.some((type) => typeof type === "string" && typeMatches(type, value))) {
17725
- results.push(invalidResult(issue(path190, types2.join(","), value, `must be ${types2.join(",")}`)));
17725
+ results.push(invalidResult(issue(path191, types2.join(","), value, `must be ${types2.join(",")}`)));
17726
17726
  return results;
17727
17727
  }
17728
17728
  if (schema.const !== void 0 && !deepEqual(schema.const, value)) {
17729
- results.push(invalidResult(issue(path190, "const", value, "must be equal to constant")));
17729
+ results.push(invalidResult(issue(path191, "const", value, "must be equal to constant")));
17730
17730
  }
17731
17731
  if (Array.isArray(schema.enum) && !schema.enum.some((entry) => deepEqual(entry, value))) {
17732
17732
  results.push(
17733
- invalidResult(issue(path190, "enum", value, "must be equal to one of the allowed values"))
17733
+ invalidResult(issue(path191, "enum", value, "must be equal to one of the allowed values"))
17734
17734
  );
17735
17735
  }
17736
17736
  if (typeof value === "number" && Number.isFinite(value)) {
17737
- evaluateNumberKeywords(schema, value, path190, results);
17737
+ evaluateNumberKeywords(schema, value, path191, results);
17738
17738
  }
17739
17739
  if (typeof value === "string") {
17740
- evaluateStringKeywords(schema, value, path190, results);
17740
+ evaluateStringKeywords(schema, value, path191, results);
17741
17741
  }
17742
17742
  if (Array.isArray(value)) {
17743
- evaluateArrayKeywords(schema, value, path190, results);
17743
+ evaluateArrayKeywords(schema, value, path191, results);
17744
17744
  }
17745
17745
  if (isObject(value)) {
17746
- evaluateObjectKeywords(node, schema, value, path190, results);
17746
+ evaluateObjectKeywords(node, schema, value, path191, results);
17747
17747
  }
17748
17748
  return results;
17749
17749
  }
17750
- function evaluateNumberKeywords(schema, value, path190, results) {
17750
+ function evaluateNumberKeywords(schema, value, path191, results) {
17751
17751
  if (typeof schema.multipleOf === "number" && !isMultipleOf(value, schema.multipleOf)) {
17752
17752
  results.push(
17753
17753
  invalidResult(
17754
17754
  issue(
17755
- path190,
17755
+ path191,
17756
17756
  `multiple of ${schema.multipleOf}`,
17757
17757
  value,
17758
17758
  `must be multiple of ${schema.multipleOf}`
@@ -17762,36 +17762,36 @@ function evaluateNumberKeywords(schema, value, path190, results) {
17762
17762
  }
17763
17763
  if (typeof schema.maximum === "number" && value > schema.maximum) {
17764
17764
  results.push(
17765
- invalidResult(issue(path190, `<= ${schema.maximum}`, value, `must be <= ${schema.maximum}`))
17765
+ invalidResult(issue(path191, `<= ${schema.maximum}`, value, `must be <= ${schema.maximum}`))
17766
17766
  );
17767
17767
  }
17768
17768
  if (typeof schema.minimum === "number" && value < schema.minimum) {
17769
17769
  results.push(
17770
- invalidResult(issue(path190, `>= ${schema.minimum}`, value, `must be >= ${schema.minimum}`))
17770
+ invalidResult(issue(path191, `>= ${schema.minimum}`, value, `must be >= ${schema.minimum}`))
17771
17771
  );
17772
17772
  }
17773
17773
  if (typeof schema.exclusiveMaximum === "number" && value >= schema.exclusiveMaximum) {
17774
17774
  results.push(
17775
17775
  invalidResult(
17776
- issue(path190, `< ${schema.exclusiveMaximum}`, value, `must be < ${schema.exclusiveMaximum}`)
17776
+ issue(path191, `< ${schema.exclusiveMaximum}`, value, `must be < ${schema.exclusiveMaximum}`)
17777
17777
  )
17778
17778
  );
17779
17779
  }
17780
17780
  if (typeof schema.exclusiveMinimum === "number" && value <= schema.exclusiveMinimum) {
17781
17781
  results.push(
17782
17782
  invalidResult(
17783
- issue(path190, `> ${schema.exclusiveMinimum}`, value, `must be > ${schema.exclusiveMinimum}`)
17783
+ issue(path191, `> ${schema.exclusiveMinimum}`, value, `must be > ${schema.exclusiveMinimum}`)
17784
17784
  )
17785
17785
  );
17786
17786
  }
17787
17787
  }
17788
- function evaluateStringKeywords(schema, value, path190, results) {
17788
+ function evaluateStringKeywords(schema, value, path191, results) {
17789
17789
  const length = unicodeLength(value);
17790
17790
  if (typeof schema.maxLength === "number" && length > schema.maxLength) {
17791
17791
  results.push(
17792
17792
  invalidResult(
17793
17793
  issue(
17794
- path190,
17794
+ path191,
17795
17795
  `length <= ${schema.maxLength}`,
17796
17796
  value,
17797
17797
  `must NOT have more than ${schema.maxLength} characters`
@@ -17803,7 +17803,7 @@ function evaluateStringKeywords(schema, value, path190, results) {
17803
17803
  results.push(
17804
17804
  invalidResult(
17805
17805
  issue(
17806
- path190,
17806
+ path191,
17807
17807
  `length >= ${schema.minLength}`,
17808
17808
  value,
17809
17809
  `must NOT have fewer than ${schema.minLength} characters`
@@ -17814,17 +17814,17 @@ function evaluateStringKeywords(schema, value, path190, results) {
17814
17814
  if (typeof schema.pattern === "string" && !new RegExp(schema.pattern, "u").test(value)) {
17815
17815
  results.push(
17816
17816
  invalidResult(
17817
- issue(path190, `pattern ${schema.pattern}`, value, `must match pattern ${schema.pattern}`)
17817
+ issue(path191, `pattern ${schema.pattern}`, value, `must match pattern ${schema.pattern}`)
17818
17818
  )
17819
17819
  );
17820
17820
  }
17821
17821
  }
17822
- function evaluateArrayKeywords(schema, value, path190, results) {
17822
+ function evaluateArrayKeywords(schema, value, path191, results) {
17823
17823
  if (typeof schema.maxItems === "number" && value.length > schema.maxItems) {
17824
17824
  results.push(
17825
17825
  invalidResult(
17826
17826
  issue(
17827
- path190,
17827
+ path191,
17828
17828
  `items <= ${schema.maxItems}`,
17829
17829
  value,
17830
17830
  `must NOT have more than ${schema.maxItems} items`
@@ -17836,7 +17836,7 @@ function evaluateArrayKeywords(schema, value, path190, results) {
17836
17836
  results.push(
17837
17837
  invalidResult(
17838
17838
  issue(
17839
- path190,
17839
+ path191,
17840
17840
  `items >= ${schema.minItems}`,
17841
17841
  value,
17842
17842
  `must NOT have fewer than ${schema.minItems} items`
@@ -17849,7 +17849,7 @@ function evaluateArrayKeywords(schema, value, path190, results) {
17849
17849
  for (let right = left + 1; right < value.length; right += 1) {
17850
17850
  if (deepEqual(value[left], value[right])) {
17851
17851
  results.push(
17852
- invalidResult(issue(path190, "unique items", value, "must NOT have duplicate items"))
17852
+ invalidResult(issue(path191, "unique items", value, "must NOT have duplicate items"))
17853
17853
  );
17854
17854
  return;
17855
17855
  }
@@ -17857,13 +17857,13 @@ function evaluateArrayKeywords(schema, value, path190, results) {
17857
17857
  }
17858
17858
  }
17859
17859
  }
17860
- function evaluateObjectKeywords(node, schema, value, path190, results) {
17860
+ function evaluateObjectKeywords(node, schema, value, path191, results) {
17861
17861
  const keys = Object.keys(value);
17862
17862
  if (typeof schema.maxProperties === "number" && keys.length > schema.maxProperties) {
17863
17863
  results.push(
17864
17864
  invalidResult(
17865
17865
  issue(
17866
- path190,
17866
+ path191,
17867
17867
  `properties <= ${schema.maxProperties}`,
17868
17868
  value,
17869
17869
  `must NOT have more than ${schema.maxProperties} properties`
@@ -17875,7 +17875,7 @@ function evaluateObjectKeywords(node, schema, value, path190, results) {
17875
17875
  results.push(
17876
17876
  invalidResult(
17877
17877
  issue(
17878
- path190,
17878
+ path191,
17879
17879
  `properties >= ${schema.minProperties}`,
17880
17880
  value,
17881
17881
  `must NOT have fewer than ${schema.minProperties} properties`
@@ -17888,7 +17888,7 @@ function evaluateObjectKeywords(node, schema, value, path190, results) {
17888
17888
  if (typeof key3 === "string" && !Object.prototype.hasOwnProperty.call(value, key3)) {
17889
17889
  results.push(
17890
17890
  invalidResult(
17891
- issue([...path190, key3], "required", void 0, `must have required property '${key3}'`)
17891
+ issue([...path191, key3], "required", void 0, `must have required property '${key3}'`)
17892
17892
  )
17893
17893
  );
17894
17894
  }
@@ -17897,24 +17897,24 @@ function evaluateObjectKeywords(node, schema, value, path190, results) {
17897
17897
  const dependentRequired = isObject(schema.dependentRequired) ? schema.dependentRequired : {};
17898
17898
  for (const [key3, dependencies] of Object.entries(dependentRequired)) {
17899
17899
  if (Object.prototype.hasOwnProperty.call(value, key3) && Array.isArray(dependencies)) {
17900
- addMissingDependencies(value, dependencies, path190, results);
17900
+ addMissingDependencies(value, dependencies, path191, results);
17901
17901
  }
17902
17902
  }
17903
17903
  if (node.dialect === "draft7" && isObject(schema.dependencies)) {
17904
17904
  for (const [key3, dependencies] of Object.entries(schema.dependencies)) {
17905
17905
  if (Object.prototype.hasOwnProperty.call(value, key3) && Array.isArray(dependencies)) {
17906
- addMissingDependencies(value, dependencies, path190, results);
17906
+ addMissingDependencies(value, dependencies, path191, results);
17907
17907
  }
17908
17908
  }
17909
17909
  }
17910
17910
  }
17911
- function addMissingDependencies(value, dependencies, path190, results) {
17911
+ function addMissingDependencies(value, dependencies, path191, results) {
17912
17912
  for (const dependency of dependencies) {
17913
17913
  if (typeof dependency === "string" && !Object.prototype.hasOwnProperty.call(value, dependency)) {
17914
17914
  results.push(
17915
17915
  invalidResult(
17916
17916
  issue(
17917
- [...path190, dependency],
17917
+ [...path191, dependency],
17918
17918
  "dependency",
17919
17919
  void 0,
17920
17920
  `must have property '${dependency}'`
@@ -18036,8 +18036,8 @@ function compileJsonSchema(schema, options = {}) {
18036
18036
  }
18037
18037
  function formatIssues(issues) {
18038
18038
  return issues.map((current) => {
18039
- const path190 = current.path.length === 0 ? "data" : `data/${current.path.join("/")}`;
18040
- return `${path190} ${current.message}`;
18039
+ const path191 = current.path.length === 0 ? "data" : `data/${current.path.join("/")}`;
18040
+ return `${path191} ${current.message}`;
18041
18041
  }).join(", ");
18042
18042
  }
18043
18043
  var init_json_schema = __esm({
@@ -18547,11 +18547,11 @@ function mergeLayers(layers) {
18547
18547
  }
18548
18548
  return mergeObjectLayers(layers, []);
18549
18549
  }
18550
- function mergeObjectLayers(layers, path190) {
18550
+ function mergeObjectLayers(layers, path191) {
18551
18551
  const data = {};
18552
18552
  const sources = {};
18553
18553
  for (const key3 of collectKeys(layers)) {
18554
- const resolved = resolveKey(layers, key3, path190);
18554
+ const resolved = resolveKey(layers, key3, path191);
18555
18555
  if (resolved === void 0) {
18556
18556
  continue;
18557
18557
  }
@@ -18571,7 +18571,7 @@ function collectKeys(layers) {
18571
18571
  }
18572
18572
  return [...keys];
18573
18573
  }
18574
- function resolveKey(layers, key3, path190) {
18574
+ function resolveKey(layers, key3, path191) {
18575
18575
  let winningSource;
18576
18576
  let winningValue;
18577
18577
  const objectLayers = [];
@@ -18604,9 +18604,9 @@ function resolveKey(layers, key3, path190) {
18604
18604
  if (winningValue === null) {
18605
18605
  return void 0;
18606
18606
  }
18607
- const fullPath = buildPath(path190, key3);
18607
+ const fullPath = buildPath(path191, key3);
18608
18608
  if (isPlainObject(winningValue)) {
18609
- const merged = mergeObjectLayers(objectLayers, [...path190, key3]);
18609
+ const merged = mergeObjectLayers(objectLayers, [...path191, key3]);
18610
18610
  return {
18611
18611
  value: merged.data,
18612
18612
  sources: {
@@ -18634,8 +18634,8 @@ function isWinningCandidate(key3, value) {
18634
18634
  function getOwnEntry2(record2, key3) {
18635
18635
  return Object.prototype.hasOwnProperty.call(record2, key3) ? record2[key3] : void 0;
18636
18636
  }
18637
- function buildPath(path190, key3) {
18638
- return [...path190, key3].map(escapePathSegment).join(".");
18637
+ function buildPath(path191, key3) {
18638
+ return [...path191, key3].map(escapePathSegment).join(".");
18639
18639
  }
18640
18640
  function escapePathSegment(segment) {
18641
18641
  return segment.replaceAll("\\", "\\\\").replaceAll(".", "\\.");
@@ -19499,22 +19499,22 @@ function prune2(obj, shape) {
19499
19499
  }
19500
19500
  return { changed, result };
19501
19501
  }
19502
- function modifyAtPath(content, path190, value) {
19502
+ function modifyAtPath(content, path191, value) {
19503
19503
  const indent = detectIndent(content);
19504
19504
  const formattingOptions = {
19505
19505
  tabSize: indent === " " ? 1 : indent.length,
19506
19506
  insertSpaces: indent !== " ",
19507
19507
  eol: "\n"
19508
19508
  };
19509
- const edits = jsonc.modify(content, path190, value, { formattingOptions });
19509
+ const edits = jsonc.modify(content, path191, value, { formattingOptions });
19510
19510
  let result = jsonc.applyEdits(content, edits);
19511
19511
  if (!result.endsWith("\n")) {
19512
19512
  result += "\n";
19513
19513
  }
19514
19514
  return result;
19515
19515
  }
19516
- function removeAtPath(content, path190) {
19517
- return modifyAtPath(content, path190, void 0);
19516
+ function removeAtPath(content, path191) {
19517
+ return modifyAtPath(content, path191, void 0);
19518
19518
  }
19519
19519
  function serializeUpdate(content, current, next) {
19520
19520
  let result = content || "{}";
@@ -19524,15 +19524,15 @@ function serializeUpdate(content, current, next) {
19524
19524
  }
19525
19525
  return result;
19526
19526
  }
19527
- function applyObjectUpdate(content, path190, current, next) {
19527
+ function applyObjectUpdate(content, path191, current, next) {
19528
19528
  let result = content;
19529
19529
  for (const key3 of Object.keys(current)) {
19530
19530
  if (!hasConfigEntry(next, key3)) {
19531
- result = removeAtPath(result, [...path190, key3]);
19531
+ result = removeAtPath(result, [...path191, key3]);
19532
19532
  }
19533
19533
  }
19534
19534
  for (const [key3, nextValue] of Object.entries(next)) {
19535
- const nextPath = [...path190, key3];
19535
+ const nextPath = [...path191, key3];
19536
19536
  const hasCurrent = hasConfigEntry(current, key3);
19537
19537
  const currentValue = hasCurrent ? current[key3] : void 0;
19538
19538
  if (hasCurrent && isConfigObject(currentValue) && isConfigObject(nextValue)) {
@@ -19739,16 +19739,16 @@ function getConfigFormat(pathOrFormat) {
19739
19739
  }
19740
19740
  return formatRegistry[formatName];
19741
19741
  }
19742
- function detectFormat2(path190) {
19743
- const ext = getExtension(path190);
19742
+ function detectFormat2(path191) {
19743
+ const ext = getExtension(path191);
19744
19744
  return extensionMap[ext];
19745
19745
  }
19746
- function getExtension(path190) {
19747
- const lastDot = path190.lastIndexOf(".");
19746
+ function getExtension(path191) {
19747
+ const lastDot = path191.lastIndexOf(".");
19748
19748
  if (lastDot === -1) {
19749
19749
  return "";
19750
19750
  }
19751
- return path190.slice(lastDot).toLowerCase();
19751
+ return path191.slice(lastDot).toLowerCase();
19752
19752
  }
19753
19753
  var formatRegistry, extensionMap;
19754
19754
  var init_formats = __esm({
@@ -21138,7 +21138,7 @@ function mergeScope(scope, baseScope, overrideScope) {
21138
21138
  }
21139
21139
  return merged;
21140
21140
  }
21141
- function mergeRuntimeScope(baseScope, overrideScope, path190 = []) {
21141
+ function mergeRuntimeScope(baseScope, overrideScope, path191 = []) {
21142
21142
  const merged = {};
21143
21143
  const keys = /* @__PURE__ */ new Set([...Object.keys(baseScope), ...Object.keys(overrideScope)]);
21144
21144
  for (const key3 of keys) {
@@ -21151,7 +21151,7 @@ function mergeRuntimeScope(baseScope, overrideScope, path190 = []) {
21151
21151
  continue;
21152
21152
  }
21153
21153
  if (isRecord4(baseValue) && isRecord4(overrideValue)) {
21154
- setOwnEntry(merged, key3, mergeRuntimeScope(baseValue, overrideValue, [...path190, key3]));
21154
+ setOwnEntry(merged, key3, mergeRuntimeScope(baseValue, overrideValue, [...path191, key3]));
21155
21155
  continue;
21156
21156
  }
21157
21157
  setOwnEntry(merged, key3, overrideValue);
@@ -22742,45 +22742,45 @@ import { createTwoFilesPatch } from "diff";
22742
22742
  import chalk from "chalk";
22743
22743
  function createDryRunFileSystem(base, recorder) {
22744
22744
  const proxy = {
22745
- async readFile(path190, encoding) {
22745
+ async readFile(path191, encoding) {
22746
22746
  if (encoding) {
22747
- return base.readFile(path190, encoding);
22747
+ return base.readFile(path191, encoding);
22748
22748
  }
22749
- return base.readFile(path190);
22749
+ return base.readFile(path191);
22750
22750
  },
22751
- async writeFile(path190, data, options) {
22752
- const previousContent = await tryReadText(base, path190);
22751
+ async writeFile(path191, data, options) {
22752
+ const previousContent = await tryReadText(base, path191);
22753
22753
  const nextContent = formatData(data, options?.encoding);
22754
22754
  recorder.record({
22755
22755
  type: "writeFile",
22756
- path: path190,
22756
+ path: path191,
22757
22757
  nextContent,
22758
22758
  previousContent
22759
22759
  });
22760
22760
  },
22761
- async symlink(target, path190) {
22762
- recorder.record({ type: "symlink", target, path: path190 });
22761
+ async symlink(target, path191) {
22762
+ recorder.record({ type: "symlink", target, path: path191 });
22763
22763
  },
22764
- async readlink(path190) {
22765
- return base.readlink(path190);
22764
+ async readlink(path191) {
22765
+ return base.readlink(path191);
22766
22766
  },
22767
- async realpath(path190) {
22768
- return base.realpath(path190);
22767
+ async realpath(path191) {
22768
+ return base.realpath(path191);
22769
22769
  },
22770
- async mkdir(path190, options) {
22770
+ async mkdir(path191, options) {
22771
22771
  recorder.record({
22772
22772
  type: "mkdir",
22773
- path: path190,
22773
+ path: path191,
22774
22774
  options,
22775
22775
  // Matches how the mutation layer itself decides the mkdir is a no-op.
22776
- existing: await pathExists(base, path190)
22776
+ existing: await pathExists(base, path191)
22777
22777
  });
22778
22778
  },
22779
- async stat(path190) {
22780
- return base.stat(path190);
22779
+ async stat(path191) {
22780
+ return base.stat(path191);
22781
22781
  },
22782
- async lstat(path190) {
22783
- return base.lstat(path190);
22782
+ async lstat(path191) {
22783
+ return base.lstat(path191);
22784
22784
  },
22785
22785
  async rename(from, to) {
22786
22786
  const staged = recorder.takeStagedWrite(from);
@@ -22795,16 +22795,16 @@ function createDryRunFileSystem(base, recorder) {
22795
22795
  }
22796
22796
  recorder.record({ type: "rename", from, to });
22797
22797
  },
22798
- async unlink(path190) {
22799
- recorder.record({ type: "unlink", path: path190 });
22798
+ async unlink(path191) {
22799
+ recorder.record({ type: "unlink", path: path191 });
22800
22800
  },
22801
- async readdir(path190) {
22802
- return base.readdir(path190);
22801
+ async readdir(path191) {
22802
+ return base.readdir(path191);
22803
22803
  }
22804
22804
  };
22805
22805
  if (typeof base.rm === "function") {
22806
- proxy.rm = async (path190, options) => {
22807
- recorder.record({ type: "rm", path: path190, options });
22806
+ proxy.rm = async (path191, options) => {
22807
+ recorder.record({ type: "rm", path: path191, options });
22808
22808
  };
22809
22809
  }
22810
22810
  if (typeof base.copyFile === "function") {
@@ -22949,8 +22949,8 @@ function describeWriteChange(previous, next) {
22949
22949
  }
22950
22950
  return "update";
22951
22951
  }
22952
- function renderWriteCommand(path190, change) {
22953
- const command = `cat > ${quoteShellArgument(path190)}`;
22952
+ function renderWriteCommand(path191, change) {
22953
+ const command = `cat > ${quoteShellArgument(path191)}`;
22954
22954
  if (change === "create") {
22955
22955
  return renderOperationCommand(command, chalk.green, "# create");
22956
22956
  }
@@ -23157,9 +23157,9 @@ function describesChange(operation) {
23157
23157
  }
23158
23158
  return true;
23159
23159
  }
23160
- async function tryReadText(base, path190) {
23160
+ async function tryReadText(base, path191) {
23161
23161
  try {
23162
- return await base.readFile(path190, "utf8");
23162
+ return await base.readFile(path191, "utf8");
23163
23163
  } catch (error3) {
23164
23164
  if (isNotFound(error3)) {
23165
23165
  return null;
@@ -23213,10 +23213,10 @@ var init_dry_run = __esm({
23213
23213
  // Atomic writers stage content in a temp file and rename it over the target.
23214
23214
  // Pulling the staged write back out lets the rename re-record it against the
23215
23215
  // real target, so the preview diffs the delta instead of the whole file.
23216
- takeStagedWrite(path190) {
23216
+ takeStagedWrite(path191) {
23217
23217
  for (let index = this.operations.length - 1; index >= 0; index -= 1) {
23218
23218
  const operation = this.operations[index];
23219
- if (operation.type === "writeFile" && operation.path === path190) {
23219
+ if (operation.type === "writeFile" && operation.path === path191) {
23220
23220
  this.operations.splice(index, 1);
23221
23221
  return operation;
23222
23222
  }
@@ -34906,21 +34906,21 @@ async function* adaptClaude(lines) {
34906
34906
  if (blockType !== "tool_result") continue;
34907
34907
  const kind = toolKindsById.get(item.tool_use_id);
34908
34908
  toolKindsById.delete(item.tool_use_id);
34909
- let path190;
34909
+ let path191;
34910
34910
  if (typeof item.content === "string") {
34911
- path190 = item.content;
34911
+ path191 = item.content;
34912
34912
  } else {
34913
34913
  try {
34914
- path190 = JSON.stringify(item.content);
34914
+ path191 = JSON.stringify(item.content);
34915
34915
  } catch {
34916
- path190 = String(item.content);
34916
+ path191 = String(item.content);
34917
34917
  }
34918
34918
  }
34919
34919
  yield {
34920
34920
  event: "tool_complete",
34921
34921
  id: item.tool_use_id,
34922
34922
  kind,
34923
- path: path190
34923
+ path: path191
34924
34924
  };
34925
34925
  }
34926
34926
  }
@@ -35043,10 +35043,10 @@ async function* adaptCodex(lines) {
35043
35043
  const kindFromStart = toolKindById.get(item.id);
35044
35044
  const kind = kindFromStart ?? (itemType === "command_execution" ? "exec" : itemType === "file_edit" ? "edit" : "other");
35045
35045
  const titleFromEvent = isNonEmptyString(item.path) ? item.path : itemType === "mcp_tool_call" ? `${isNonEmptyString(item.server) ? item.server : "unknown"}.${isNonEmptyString(item.tool) ? item.tool : "unknown"}` : void 0;
35046
- const path190 = titleFromEvent ?? toolTitleById.get(item.id) ?? "";
35046
+ const path191 = titleFromEvent ?? toolTitleById.get(item.id) ?? "";
35047
35047
  toolTitleById.delete(item.id);
35048
35048
  toolKindById.delete(item.id);
35049
- yield { event: "tool_complete", id: item.id, kind, path: path190 };
35049
+ yield { event: "tool_complete", id: item.id, kind, path: path191 };
35050
35050
  }
35051
35051
  }
35052
35052
  }
@@ -35425,14 +35425,14 @@ function toolInfo(event) {
35425
35425
  const [toolName = "tool", rawTool = {}] = Object.entries(toolCall)[0] ?? [];
35426
35426
  const tool = asObject2(rawTool) ?? {};
35427
35427
  const args = asObject2(tool.args) ?? asObject2(tool.arguments) ?? tool;
35428
- const path190 = typeof args.path === "string" ? args.path : "";
35428
+ const path191 = typeof args.path === "string" ? args.path : "";
35429
35429
  const kinds = {
35430
35430
  editToolCall: "edit",
35431
35431
  readToolCall: "read",
35432
35432
  shellToolCall: "exec",
35433
35433
  bashToolCall: "exec"
35434
35434
  };
35435
- return { kind: kinds[toolName] ?? "other", title: path190 || toolName, path: path190 };
35435
+ return { kind: kinds[toolName] ?? "other", title: path191 || toolName, path: path191 };
35436
35436
  }
35437
35437
  async function* adaptCursor(lines) {
35438
35438
  for await (const rawLine of lines) {
@@ -37783,8 +37783,8 @@ function resourceNotFound(resource) {
37783
37783
  `Resource not found: ${resource}`
37784
37784
  );
37785
37785
  }
37786
- function assertAbsolutePath(path190) {
37787
- if (!isAbsolute(path190)) {
37786
+ function assertAbsolutePath(path191) {
37787
+ if (!isAbsolute(path191)) {
37788
37788
  throw invalidParams('"path" must be an absolute path');
37789
37789
  }
37790
37790
  }
@@ -39196,7 +39196,7 @@ function updateSessionFromEvent(ctx, event, toolCallsById) {
39196
39196
  }
39197
39197
  const id = readString(event.id);
39198
39198
  const kind = readString(event.kind);
39199
- const path190 = readString(event.path);
39199
+ const path191 = readString(event.path);
39200
39200
  let toolCall = id ? toolCallsById.get(id) : void 0;
39201
39201
  if (!toolCall) {
39202
39202
  toolCall = {};
@@ -39211,8 +39211,8 @@ function updateSessionFromEvent(ctx, event, toolCallsById) {
39211
39211
  if (kind) {
39212
39212
  toolCall.kind = kind;
39213
39213
  }
39214
- if (path190) {
39215
- toolCall.path = path190;
39214
+ if (path191) {
39215
+ toolCall.path = path191;
39216
39216
  }
39217
39217
  }
39218
39218
  var sessionCapture;
@@ -55184,7 +55184,7 @@ function isWorktree(value) {
55184
55184
  return false;
55185
55185
  }
55186
55186
  const name = getOwnEntry18(value, "name");
55187
- const path190 = getOwnEntry18(value, "path");
55187
+ const path191 = getOwnEntry18(value, "path");
55188
55188
  const branch = getOwnEntry18(value, "branch");
55189
55189
  const baseBranch = getOwnEntry18(value, "baseBranch");
55190
55190
  const createdAt2 = getOwnEntry18(value, "createdAt");
@@ -55198,7 +55198,7 @@ function isWorktree(value) {
55198
55198
  const baseHead = getOwnEntry18(value, "baseHead");
55199
55199
  const reconciledAt = getOwnEntry18(value, "reconciledAt");
55200
55200
  const reconciliation = getOwnEntry18(value, "reconciliation");
55201
- return typeof name === "string" && typeof path190 === "string" && typeof branch === "string" && typeof baseBranch === "string" && typeof createdAt2 === "string" && typeof source === "string" && typeof agent3 === "string" && (status === "active" || status === "reconciling" || status === "conflicted" || status === "cleanup_failed" || status === "done" || status === "failed" || status === "removing") && (storyId === void 0 || typeof storyId === "string") && (planPath === void 0 || typeof planPath === "string") && (prompt === void 0 || typeof prompt === "string") && (sourceCwd === void 0 || typeof sourceCwd === "string") && (baseHead === void 0 || typeof baseHead === "string") && (reconciledAt === void 0 || typeof reconciledAt === "string") && (reconciliation === void 0 || isReconciliationSummary(reconciliation));
55201
+ return typeof name === "string" && typeof path191 === "string" && typeof branch === "string" && typeof baseBranch === "string" && typeof createdAt2 === "string" && typeof source === "string" && typeof agent3 === "string" && (status === "active" || status === "reconciling" || status === "conflicted" || status === "cleanup_failed" || status === "done" || status === "failed" || status === "removing") && (storyId === void 0 || typeof storyId === "string") && (planPath === void 0 || typeof planPath === "string") && (prompt === void 0 || typeof prompt === "string") && (sourceCwd === void 0 || typeof sourceCwd === "string") && (baseHead === void 0 || typeof baseHead === "string") && (reconciledAt === void 0 || typeof reconciledAt === "string") && (reconciliation === void 0 || isReconciliationSummary(reconciliation));
55202
55202
  }
55203
55203
  function isReconciliationSummary(value) {
55204
55204
  if (typeof value !== "object" || value === null) {
@@ -55639,9 +55639,9 @@ function parsePorcelainPaths(output) {
55639
55639
  const entries = output.split("\0").filter((entry) => entry.length > 0);
55640
55640
  for (let index = 0; index < entries.length; index += 1) {
55641
55641
  const entry = entries[index];
55642
- const path190 = entry.length > 3 ? entry.slice(3) : entry;
55643
- if (path190.length > 0) {
55644
- paths.push(path190);
55642
+ const path191 = entry.length > 3 ? entry.slice(3) : entry;
55643
+ if (path191.length > 0) {
55644
+ paths.push(path191);
55645
55645
  }
55646
55646
  if ((entry.startsWith("R ") || entry.startsWith("C ")) && index + 1 < entries.length) {
55647
55647
  const sourcePath = entries[index + 1];
@@ -57992,14 +57992,14 @@ function formatTimestamp2(timestamp) {
57992
57992
  }
57993
57993
  function editPlan(dashboard, absolutePath, env, openInEditor) {
57994
57994
  const editor = resolveEditor(env);
57995
- const open8 = openInEditor ?? openInEditorWithSystem;
57995
+ const open9 = openInEditor ?? openInEditorWithSystem;
57996
57996
  if (editor.mode === "gui") {
57997
- open8(absolutePath, env);
57997
+ open9(absolutePath, env);
57998
57998
  return;
57999
57999
  }
58000
58000
  dashboard.stop();
58001
58001
  try {
58002
- open8(absolutePath, env);
58002
+ open9(absolutePath, env);
58003
58003
  } finally {
58004
58004
  dashboard.start();
58005
58005
  }
@@ -59063,10 +59063,10 @@ function parseReviewDiff(diffText) {
59063
59063
  finalizeFile();
59064
59064
  const paths = parseDiffGitPaths(line);
59065
59065
  const previousPath = paths?.previousPath ?? "";
59066
- const path190 = paths?.path ?? previousPath;
59066
+ const path191 = paths?.path ?? previousPath;
59067
59067
  currentFile = {
59068
- path: path190,
59069
- previousPath: previousPath && previousPath !== path190 ? previousPath : null,
59068
+ path: path191,
59069
+ previousPath: previousPath && previousPath !== path191 ? previousPath : null,
59070
59070
  status: "modified",
59071
59071
  hunks: [],
59072
59072
  reviewableLines: [],
@@ -59096,9 +59096,9 @@ function parseReviewDiff(diffText) {
59096
59096
  continue;
59097
59097
  }
59098
59098
  if (line.startsWith("+++ ")) {
59099
- const path190 = normalizeDiffPath(line.slice(4).trim());
59100
- if (path190) {
59101
- currentFile.path = path190;
59099
+ const path191 = normalizeDiffPath(line.slice(4).trim());
59100
+ if (path191) {
59101
+ currentFile.path = path191;
59102
59102
  }
59103
59103
  continue;
59104
59104
  }
@@ -59157,31 +59157,31 @@ function validateInlineComments(comments, context) {
59157
59157
  const accepted = [];
59158
59158
  const seen = /* @__PURE__ */ new Set();
59159
59159
  for (const comment of comments) {
59160
- const path190 = comment.path;
59160
+ const path191 = comment.path;
59161
59161
  const body = comment.body.trim();
59162
- if (path190.length === 0 || !body || !Number.isInteger(comment.line) || comment.line < 1) {
59162
+ if (path191.length === 0 || !body || !Number.isInteger(comment.line) || comment.line < 1) {
59163
59163
  throw new Error("Inline review comments require path, positive line, and body.");
59164
59164
  }
59165
59165
  if (comment.side === "LEFT") {
59166
59166
  throw new Error(
59167
- `Inline comment target ${path190}:${comment.line} is a left-side diff target; only right-side comments are supported.`
59167
+ `Inline comment target ${path191}:${comment.line} is a left-side diff target; only right-side comments are supported.`
59168
59168
  );
59169
59169
  }
59170
- if (!context.reviewableLinesByPath.get(path190)?.has(comment.line)) {
59170
+ if (!context.reviewableLinesByPath.get(path191)?.has(comment.line)) {
59171
59171
  throw new Error(
59172
- `Inline comment target ${path190}:${comment.line} is not a valid right-side diff target.`
59172
+ `Inline comment target ${path191}:${comment.line} is not a valid right-side diff target.`
59173
59173
  );
59174
59174
  }
59175
- if (!comment.side && context.leftLinesByPath.get(path190)?.has(comment.line) && context.rightContextLinesByPath.get(path190)?.has(comment.line)) {
59175
+ if (!comment.side && context.leftLinesByPath.get(path191)?.has(comment.line) && context.rightContextLinesByPath.get(path191)?.has(comment.line)) {
59176
59176
  throw new Error(
59177
- `Inline comment target ${path190}:${comment.line} is ambiguous; specify side RIGHT to target the right-side diff line.`
59177
+ `Inline comment target ${path191}:${comment.line} is ambiguous; specify side RIGHT to target the right-side diff line.`
59178
59178
  );
59179
59179
  }
59180
- const key3 = `${path190}\0${comment.line}\0${body}`;
59180
+ const key3 = `${path191}\0${comment.line}\0${body}`;
59181
59181
  if (!seen.has(key3)) {
59182
59182
  seen.add(key3);
59183
59183
  accepted.push({
59184
- path: path190,
59184
+ path: path191,
59185
59185
  line: comment.line,
59186
59186
  ...comment.side ? { side: comment.side } : {},
59187
59187
  body
@@ -59682,9 +59682,9 @@ function reviewEndpoint(prUrl) {
59682
59682
  }
59683
59683
  function normalizeReviewComments(comments) {
59684
59684
  return comments.map((comment) => {
59685
- const path190 = comment.path.trim();
59685
+ const path191 = comment.path.trim();
59686
59686
  const body = comment.body.trim();
59687
- if (!path190) {
59687
+ if (!path191) {
59688
59688
  throw new Error("Review comment path must be non-empty.");
59689
59689
  }
59690
59690
  if (!Number.isSafeInteger(comment.line) || comment.line <= 0) {
@@ -59693,7 +59693,7 @@ function normalizeReviewComments(comments) {
59693
59693
  if (!body) {
59694
59694
  throw new Error("Review comment body must be non-empty.");
59695
59695
  }
59696
- return { path: path190, line: comment.line, body };
59696
+ return { path: path191, line: comment.line, body };
59697
59697
  });
59698
59698
  }
59699
59699
  function submissionFromResponse(response) {
@@ -59988,10 +59988,10 @@ var init_review_history = __esm({
59988
59988
  kind,
59989
59989
  body
59990
59990
  };
59991
- const path190 = text4(record2, "path");
59991
+ const path191 = text4(record2, "path");
59992
59992
  const line = integer(record2, "line") ?? integer(record2, "original_line");
59993
59993
  const diffHunk = text4(record2, "diff_hunk");
59994
- if (path190) normalized.path = path190;
59994
+ if (path191) normalized.path = path191;
59995
59995
  if (line !== null) normalized.line = line;
59996
59996
  if (diffHunk) normalized.diffHunk = diffHunk;
59997
59997
  return normalized;
@@ -60701,9 +60701,9 @@ function containedPath(directory, name) {
60701
60701
  }
60702
60702
  return target;
60703
60703
  }
60704
- async function pathExists7(path190) {
60704
+ async function pathExists7(path191) {
60705
60705
  try {
60706
- await access(path190);
60706
+ await access(path191);
60707
60707
  return true;
60708
60708
  } catch (error3) {
60709
60709
  if (isMissingFileError4(error3)) {
@@ -64100,9 +64100,9 @@ function normalizeToolResult2(handlerResult, outputSchema) {
64100
64100
  structuredContent
64101
64101
  };
64102
64102
  }
64103
- function assertObjectRootSchema(schema, path190) {
64103
+ function assertObjectRootSchema(schema, path191) {
64104
64104
  if (schema.type !== "object") {
64105
- throw new Error(`${path190} root type must be "object"`);
64105
+ throw new Error(`${path191} root type must be "object"`);
64106
64106
  }
64107
64107
  }
64108
64108
  function isJsonObject(value) {
@@ -64441,23 +64441,23 @@ function extractFieldErrors(body) {
64441
64441
  const flattened = candidates.flatMap((candidate) => flattenFieldErrors(candidate, []));
64442
64442
  return flattened.length === 0 ? void 0 : flattened;
64443
64443
  }
64444
- function flattenFieldErrors(value, path190) {
64444
+ function flattenFieldErrors(value, path191) {
64445
64445
  if (typeof value === "string") {
64446
- return [{ path: formatPath2(path190), message: value }];
64446
+ return [{ path: formatPath2(path191), message: value }];
64447
64447
  }
64448
64448
  if (Array.isArray(value)) {
64449
64449
  if (value.every((entry) => typeof entry === "string")) {
64450
- return value.map((message2) => ({ path: formatPath2(path190), message: message2 }));
64450
+ return value.map((message2) => ({ path: formatPath2(path191), message: message2 }));
64451
64451
  }
64452
- return value.flatMap((entry, index) => flattenFieldErrors(entry, [...path190, String(index)]));
64452
+ return value.flatMap((entry, index) => flattenFieldErrors(entry, [...path191, String(index)]));
64453
64453
  }
64454
64454
  if (!isPlainObject4(value)) {
64455
64455
  return [];
64456
64456
  }
64457
- return Object.entries(value).flatMap(([key3, nested]) => flattenFieldErrors(nested, [...path190, key3]));
64457
+ return Object.entries(value).flatMap(([key3, nested]) => flattenFieldErrors(nested, [...path191, key3]));
64458
64458
  }
64459
- function formatPath2(path190) {
64460
- return path190.length === 0 ? "error" : path190.join(".");
64459
+ function formatPath2(path191) {
64460
+ return path191.length === 0 ? "error" : path191.join(".");
64461
64461
  }
64462
64462
  function extractFirstString(body, fields) {
64463
64463
  if (!isPlainObject4(body)) {
@@ -64999,12 +64999,12 @@ function mergeApprovalsRoot(root, options) {
64999
64999
  }
65000
65000
  return options.humanInLoop.mergeApprovalsGroup(root);
65001
65001
  }
65002
- function findHumanInLoopCommandPath(node, path190) {
65002
+ function findHumanInLoopCommandPath(node, path191) {
65003
65003
  if (node.kind === "command") {
65004
- return node.humanInLoop ? path190.join(".") || node.name : void 0;
65004
+ return node.humanInLoop ? path191.join(".") || node.name : void 0;
65005
65005
  }
65006
65006
  for (const child of node.children) {
65007
- const found = findHumanInLoopCommandPath(child, [...path190, child.name]);
65007
+ const found = findHumanInLoopCommandPath(child, [...path191, child.name]);
65008
65008
  if (found !== void 0) {
65009
65009
  return found;
65010
65010
  }
@@ -65039,13 +65039,13 @@ function convertJsonSchema(schema) {
65039
65039
  }
65040
65040
  return convertSchema(schema, schema, []);
65041
65041
  }
65042
- function convertSchema(schema, root, path190) {
65043
- const resolvedSchema = resolveReferencedSchema(schema, root, path190);
65042
+ function convertSchema(schema, root, path191) {
65043
+ const resolvedSchema = resolveReferencedSchema(schema, root, path191);
65044
65044
  const normalizedSchema = normalizeNullability(resolvedSchema);
65045
65045
  const composition = getComposition(normalizedSchema.schema);
65046
65046
  if (Array.isArray(normalizedSchema.schema.type)) {
65047
65047
  throw new Error(
65048
- `JSON Schema "${formatJsonSchemaPath(path190)}" has an unsupported type "${formatJsonSchemaType(
65048
+ `JSON Schema "${formatJsonSchemaPath(path191)}" has an unsupported type "${formatJsonSchemaType(
65049
65049
  normalizedSchema.schema.type
65050
65050
  )}". Supported: string, number, integer, boolean, array, object.`
65051
65051
  );
@@ -65057,13 +65057,13 @@ function convertSchema(schema, root, path190) {
65057
65057
  return convertEnumSchema(resolvedSchema, normalizedSchema.nullable);
65058
65058
  }
65059
65059
  if (composition !== void 0) {
65060
- return convertCompositionSchema(normalizedSchema.schema, root, normalizedSchema.nullable, path190);
65060
+ return convertCompositionSchema(normalizedSchema.schema, root, normalizedSchema.nullable, path191);
65061
65061
  }
65062
65062
  if (isRecordSchema(normalizedSchema.schema)) {
65063
65063
  return applyMetadata(
65064
65064
  S.Record(
65065
65065
  convertSchema(normalizedSchema.schema.additionalProperties, root, [
65066
- ...path190,
65066
+ ...path191,
65067
65067
  "additionalProperties"
65068
65068
  ])
65069
65069
  ),
@@ -65112,12 +65112,12 @@ function convertSchema(schema, root, path190) {
65112
65112
  if (normalizedSchema.schema.items === void 0) {
65113
65113
  throw new Error(
65114
65114
  `JSON Schema "${formatJsonSchemaPath(
65115
- path190
65115
+ path191
65116
65116
  )}" is an array but is missing the "items" field. Add "items": { ... } to declare the element type.`
65117
65117
  );
65118
65118
  }
65119
65119
  return S.Array(
65120
- convertSchema(normalizedSchema.schema.items, root, [...path190, "items"]),
65120
+ convertSchema(normalizedSchema.schema.items, root, [...path191, "items"]),
65121
65121
  createCommonOptions(
65122
65122
  normalizedSchema.schema,
65123
65123
  normalizedSchema.nullable,
@@ -65127,7 +65127,7 @@ function convertSchema(schema, root, path190) {
65127
65127
  case "object":
65128
65128
  return convertObjectSchema(normalizedSchema.schema, root, {
65129
65129
  nullable: normalizedSchema.nullable,
65130
- path: path190
65130
+ path: path191
65131
65131
  });
65132
65132
  case "null":
65133
65133
  return applyMetadata(S.Json(), normalizedSchema.schema, {
@@ -65142,12 +65142,12 @@ function convertSchema(schema, root, path190) {
65142
65142
  }
65143
65143
  throw new Error(
65144
65144
  `JSON Schema "${formatJsonSchemaPath(
65145
- path190
65145
+ path191
65146
65146
  )}" must declare one of: "type", "enum", "const", "oneOf", "anyOf", or "allOf".`
65147
65147
  );
65148
65148
  }
65149
65149
  throw new Error(
65150
- `JSON Schema "${formatJsonSchemaPath(path190)}" has an unsupported type "${formatJsonSchemaType(
65150
+ `JSON Schema "${formatJsonSchemaPath(path191)}" has an unsupported type "${formatJsonSchemaType(
65151
65151
  normalizedSchema.schema.type
65152
65152
  )}". Supported: string, number, integer, boolean, array, object.`
65153
65153
  );
@@ -65191,21 +65191,21 @@ function convertEnumSchema(schema, nullable) {
65191
65191
  )
65192
65192
  });
65193
65193
  }
65194
- function convertCompositionSchema(schema, root, nullable, path190) {
65194
+ function convertCompositionSchema(schema, root, nullable, path191) {
65195
65195
  const composition = getComposition(schema);
65196
65196
  const branchSchemas = composition?.branches ?? [];
65197
65197
  const keyword = composition?.keyword ?? "oneOf";
65198
65198
  const branches = branchSchemas.map(
65199
- (branch, index) => resolveReferencedSchema(branch, root, [...path190, keyword, String(index)])
65199
+ (branch, index) => resolveReferencedSchema(branch, root, [...path191, keyword, String(index)])
65200
65200
  );
65201
- const discriminator = findDiscriminator(branches, root, path190);
65201
+ const discriminator = findDiscriminator(branches, root, path191);
65202
65202
  if (discriminator !== void 0) {
65203
65203
  const convertedBranches = Object.fromEntries(
65204
65204
  branches.map((branch, index) => [
65205
65205
  getDiscriminatorLiteral(branch, discriminator, root),
65206
65206
  convertObjectSchema(branch, root, {
65207
65207
  omitProperty: discriminator,
65208
- path: [...path190, keyword, String(index)]
65208
+ path: [...path191, keyword, String(index)]
65209
65209
  })
65210
65210
  ])
65211
65211
  );
@@ -65224,7 +65224,7 @@ function convertCompositionSchema(schema, root, nullable, path190) {
65224
65224
  S.Union(
65225
65225
  branches.map(
65226
65226
  (branch, index) => convertObjectSchema(branch, root, {
65227
- path: [...path190, keyword, String(index)]
65227
+ path: [...path191, keyword, String(index)]
65228
65228
  })
65229
65229
  )
65230
65230
  ),
@@ -65338,11 +65338,11 @@ function getComposition(schema) {
65338
65338
  }
65339
65339
  return void 0;
65340
65340
  }
65341
- function formatJsonSchemaPath(path190) {
65342
- if (path190.length === 0) {
65341
+ function formatJsonSchemaPath(path191) {
65342
+ if (path191.length === 0) {
65343
65343
  return "#";
65344
65344
  }
65345
- return `#/${path190.map(escapeJsonPointerSegment).join("/")}`;
65345
+ return `#/${path191.map(escapeJsonPointerSegment).join("/")}`;
65346
65346
  }
65347
65347
  function formatJsonSchemaType(type) {
65348
65348
  return Array.isArray(type) ? JSON.stringify(type) : String(type);
@@ -65358,11 +65358,11 @@ function isRecordSchema(schema) {
65358
65358
  const propertyKeys = Object.keys(schema.properties ?? {});
65359
65359
  return schema.type === "object" && propertyKeys.length === 0 && typeof schema.additionalProperties === "object" && schema.additionalProperties !== null;
65360
65360
  }
65361
- function findDiscriminator(branches, root, path190) {
65361
+ function findDiscriminator(branches, root, path191) {
65362
65362
  const [firstBranch] = branches;
65363
65363
  if (firstBranch === void 0) {
65364
65364
  throw new Error(
65365
- `JSON Schema "${formatJsonSchemaPath(path190)}" uses oneOf/anyOf/allOf but has no branches.`
65365
+ `JSON Schema "${formatJsonSchemaPath(path191)}" uses oneOf/anyOf/allOf but has no branches.`
65366
65366
  );
65367
65367
  }
65368
65368
  const candidateKeys = Object.keys(firstBranch.properties ?? {});
@@ -65402,19 +65402,19 @@ function getDiscriminatorLiteral(branch, key3, root) {
65402
65402
  }
65403
65403
  return void 0;
65404
65404
  }
65405
- function resolveReferencedSchema(schema, root, path190) {
65405
+ function resolveReferencedSchema(schema, root, path191) {
65406
65406
  if (schema.$ref === void 0) {
65407
65407
  return schema;
65408
65408
  }
65409
65409
  const resolvedTarget = resolveLocalRef(root, schema.$ref);
65410
65410
  if (resolvedTarget === void 0) {
65411
65411
  throw new Error(
65412
- `JSON Schema "${formatJsonSchemaPath(path190)}" uses "$ref": ${schema.$ref}. toolcraft only supports internal refs like "#/components/schemas/Foo".`
65412
+ `JSON Schema "${formatJsonSchemaPath(path191)}" uses "$ref": ${schema.$ref}. toolcraft only supports internal refs like "#/components/schemas/Foo".`
65413
65413
  );
65414
65414
  }
65415
65415
  const { $ref: ignoredRef, ...siblingKeywords } = schema;
65416
65416
  void ignoredRef;
65417
- const resolvedSchema = resolveReferencedSchema(resolvedTarget, root, path190);
65417
+ const resolvedSchema = resolveReferencedSchema(resolvedTarget, root, path191);
65418
65418
  if (Object.keys(siblingKeywords).length === 0) {
65419
65419
  return resolvedSchema;
65420
65420
  }
@@ -65438,9 +65438,9 @@ function mergeJsonSchemas(base, overlay) {
65438
65438
  ...mergedRequired === void 0 ? {} : { required: mergedRequired }
65439
65439
  };
65440
65440
  }
65441
- function hasSelfReferencingRef(schema, root, path190 = "#", activePaths = /* @__PURE__ */ new Set()) {
65441
+ function hasSelfReferencingRef(schema, root, path191 = "#", activePaths = /* @__PURE__ */ new Set()) {
65442
65442
  const nextActivePaths = new Set(activePaths);
65443
- nextActivePaths.add(path190);
65443
+ nextActivePaths.add(path191);
65444
65444
  const localRefPath = getLocalRefPath(schema.$ref);
65445
65445
  if (localRefPath !== void 0) {
65446
65446
  if (nextActivePaths.has(localRefPath)) {
@@ -65451,13 +65451,13 @@ function hasSelfReferencingRef(schema, root, path190 = "#", activePaths = /* @__
65451
65451
  return true;
65452
65452
  }
65453
65453
  }
65454
- if (schema.items !== void 0 && hasSelfReferencingRef(schema.items, root, `${path190}/items`, nextActivePaths)) {
65454
+ if (schema.items !== void 0 && hasSelfReferencingRef(schema.items, root, `${path191}/items`, nextActivePaths)) {
65455
65455
  return true;
65456
65456
  }
65457
65457
  if (typeof schema.additionalProperties === "object" && schema.additionalProperties !== null && hasSelfReferencingRef(
65458
65458
  schema.additionalProperties,
65459
65459
  root,
65460
- `${path190}/additionalProperties`,
65460
+ `${path191}/additionalProperties`,
65461
65461
  nextActivePaths
65462
65462
  )) {
65463
65463
  return true;
@@ -65466,7 +65466,7 @@ function hasSelfReferencingRef(schema, root, path190 = "#", activePaths = /* @__
65466
65466
  if (hasSelfReferencingRef(
65467
65467
  childSchema,
65468
65468
  root,
65469
- `${path190}/properties/${escapeJsonPointerSegment(key3)}`,
65469
+ `${path191}/properties/${escapeJsonPointerSegment(key3)}`,
65470
65470
  nextActivePaths
65471
65471
  )) {
65472
65472
  return true;
@@ -65476,24 +65476,24 @@ function hasSelfReferencingRef(schema, root, path190 = "#", activePaths = /* @__
65476
65476
  if (hasSelfReferencingRef(
65477
65477
  childSchema,
65478
65478
  root,
65479
- `${path190}/$defs/${escapeJsonPointerSegment(key3)}`,
65479
+ `${path191}/$defs/${escapeJsonPointerSegment(key3)}`,
65480
65480
  nextActivePaths
65481
65481
  )) {
65482
65482
  return true;
65483
65483
  }
65484
65484
  }
65485
65485
  for (const [index, childSchema] of (schema.oneOf ?? []).entries()) {
65486
- if (hasSelfReferencingRef(childSchema, root, `${path190}/oneOf/${index}`, nextActivePaths)) {
65486
+ if (hasSelfReferencingRef(childSchema, root, `${path191}/oneOf/${index}`, nextActivePaths)) {
65487
65487
  return true;
65488
65488
  }
65489
65489
  }
65490
65490
  for (const [index, childSchema] of (schema.anyOf ?? []).entries()) {
65491
- if (hasSelfReferencingRef(childSchema, root, `${path190}/anyOf/${index}`, nextActivePaths)) {
65491
+ if (hasSelfReferencingRef(childSchema, root, `${path191}/anyOf/${index}`, nextActivePaths)) {
65492
65492
  return true;
65493
65493
  }
65494
65494
  }
65495
65495
  for (const [index, childSchema] of (schema.allOf ?? []).entries()) {
65496
- if (hasSelfReferencingRef(childSchema, root, `${path190}/allOf/${index}`, nextActivePaths)) {
65496
+ if (hasSelfReferencingRef(childSchema, root, `${path191}/allOf/${index}`, nextActivePaths)) {
65497
65497
  return true;
65498
65498
  }
65499
65499
  }
@@ -65509,14 +65509,14 @@ function getLocalRefPath(ref) {
65509
65509
  return ref.startsWith("#/") ? ref : void 0;
65510
65510
  }
65511
65511
  function resolveLocalRef(root, ref) {
65512
- const path190 = getLocalRefPath(ref);
65513
- if (path190 === void 0) {
65512
+ const path191 = getLocalRefPath(ref);
65513
+ if (path191 === void 0) {
65514
65514
  return void 0;
65515
65515
  }
65516
- if (path190 === "#") {
65516
+ if (path191 === "#") {
65517
65517
  return root;
65518
65518
  }
65519
- const segments = path190.slice(2).split("/").map(unescapeJsonPointerSegment);
65519
+ const segments = path191.slice(2).split("/").map(unescapeJsonPointerSegment);
65520
65520
  let current = root;
65521
65521
  for (const segment of segments) {
65522
65522
  if (Array.isArray(current)) {
@@ -66269,21 +66269,21 @@ function createFs(fs31) {
66269
66269
  return fs31;
66270
66270
  }
66271
66271
  return {
66272
- readFile: async (path190, encoding = "utf8") => readFile13(path190, { encoding }),
66273
- writeFile: async (path190, contents, options) => {
66274
- await writeFile9(path190, contents, options);
66272
+ readFile: async (path191, encoding = "utf8") => readFile13(path191, { encoding }),
66273
+ writeFile: async (path191, contents, options) => {
66274
+ await writeFile9(path191, contents, options);
66275
66275
  },
66276
- exists: async (path190) => {
66276
+ exists: async (path191) => {
66277
66277
  try {
66278
- await access2(path190);
66278
+ await access2(path191);
66279
66279
  return true;
66280
66280
  } catch {
66281
66281
  return false;
66282
66282
  }
66283
66283
  },
66284
- lstat: async (path190) => lstat12(path190),
66284
+ lstat: async (path191) => lstat12(path191),
66285
66285
  rename: async (fromPath, toPath) => rename10(fromPath, toPath),
66286
- unlink: async (path190) => unlink9(path190)
66286
+ unlink: async (path191) => unlink9(path191)
66287
66287
  };
66288
66288
  }
66289
66289
  function createEnv(values = process.env) {
@@ -66421,11 +66421,11 @@ function applySchemaCasing(schema, casing) {
66421
66421
  ...oneOf === void 0 ? {} : { oneOf }
66422
66422
  };
66423
66423
  }
66424
- function collectParamSummaries(schema, casing, path190 = [], inheritedOptional = false) {
66424
+ function collectParamSummaries(schema, casing, path191 = [], inheritedOptional = false) {
66425
66425
  const summaries = [];
66426
66426
  for (const [key3, rawChildSchema] of Object.entries(schema.shape)) {
66427
66427
  const childSchema = unwrapOptional3(rawChildSchema);
66428
- const nextPath = [...path190, formatSegment(key3, casing)];
66428
+ const nextPath = [...path191, formatSegment(key3, casing)];
66429
66429
  const optional = inheritedOptional || isOptional(rawChildSchema);
66430
66430
  if (childSchema.kind === "object") {
66431
66431
  summaries.push(...collectParamSummaries(childSchema, casing, nextPath, optional));
@@ -66469,8 +66469,8 @@ function matchesAllowlist(toolName, allowlist) {
66469
66469
  const candidates = segments.map((_segment, index) => segments.slice(0, index + 1).join("__"));
66470
66470
  return candidates.some((candidate) => allowlist.includes(candidate));
66471
66471
  }
66472
- function formatToolName(path190) {
66473
- return path190.map((segment) => formatSegment(segment, "snake")).join("__");
66472
+ function formatToolName(path191) {
66473
+ return path191.map((segment) => formatSegment(segment, "snake")).join("__");
66474
66474
  }
66475
66475
  function validateUniqueMCPParameterFields(schema, casing) {
66476
66476
  const sourceKeysByField = /* @__PURE__ */ new Map();
@@ -69066,14 +69066,14 @@ function parseDockerLocator(input) {
69066
69066
  throw new Error(`Invalid docker workspace locator "${input}".`);
69067
69067
  }
69068
69068
  const container = input.slice(0, slashIndex);
69069
- const path190 = input.slice(slashIndex);
69070
- if (container.length === 0 || path190.length === 0) {
69069
+ const path191 = input.slice(slashIndex);
69070
+ if (container.length === 0 || path191.length === 0) {
69071
69071
  throw new Error(`Invalid docker workspace locator "${input}".`);
69072
69072
  }
69073
69073
  return {
69074
69074
  scheme: "docker",
69075
69075
  container,
69076
- path: path190
69076
+ path: path191
69077
69077
  };
69078
69078
  }
69079
69079
  function splitOnce(input, separator) {
@@ -69937,8 +69937,8 @@ async function checkAuth(options) {
69937
69937
  }
69938
69938
  function createCurrentBalanceUrl(baseUrl) {
69939
69939
  const url = new URL(baseUrl);
69940
- const path190 = url.pathname.endsWith("/") ? url.pathname.slice(0, -1) : url.pathname;
69941
- url.pathname = `${path190}/usage/current_balance`;
69940
+ const path191 = url.pathname.endsWith("/") ? url.pathname.slice(0, -1) : url.pathname;
69941
+ url.pathname = `${path191}/usage/current_balance`;
69942
69942
  return url.toString();
69943
69943
  }
69944
69944
  function isCurrentBalanceResponse(value) {
@@ -71404,26 +71404,26 @@ function createSdkContainer(options) {
71404
71404
  });
71405
71405
  loggerFactory.setErrorLogger(errorLogger);
71406
71406
  const asyncFs = {
71407
- readFile: ((path190, encoding) => {
71407
+ readFile: ((path191, encoding) => {
71408
71408
  if (encoding) {
71409
- return fs9.readFile(path190, encoding);
71409
+ return fs9.readFile(path191, encoding);
71410
71410
  }
71411
- return fs9.readFile(path190);
71411
+ return fs9.readFile(path191);
71412
71412
  }),
71413
- symlink: (target, path190) => fs9.symlink(target, path190),
71414
- readlink: (path190) => fs9.readlink(path190, { encoding: "utf8" }),
71415
- realpath: (path190) => fs9.realpath(path190),
71416
- writeFile: (path190, data, opts) => fs9.writeFile(path190, data, opts),
71417
- mkdir: (path190, opts) => fs9.mkdir(path190, opts).then(() => {
71413
+ symlink: (target, path191) => fs9.symlink(target, path191),
71414
+ readlink: (path191) => fs9.readlink(path191, { encoding: "utf8" }),
71415
+ realpath: (path191) => fs9.realpath(path191),
71416
+ writeFile: (path191, data, opts) => fs9.writeFile(path191, data, opts),
71417
+ mkdir: (path191, opts) => fs9.mkdir(path191, opts).then(() => {
71418
71418
  }),
71419
- stat: (path190) => fs9.stat(path190),
71420
- lstat: (path190) => fs9.lstat(path190),
71419
+ stat: (path191) => fs9.stat(path191),
71420
+ lstat: (path191) => fs9.lstat(path191),
71421
71421
  rename: (oldPath, newPath) => fs9.rename(oldPath, newPath),
71422
- rm: (path190, opts) => fs9.rm(path190, opts),
71423
- unlink: (path190) => fs9.unlink(path190),
71424
- readdir: (path190) => fs9.readdir(path190),
71422
+ rm: (path191, opts) => fs9.rm(path191, opts),
71423
+ unlink: (path191) => fs9.unlink(path191),
71424
+ readdir: (path191) => fs9.readdir(path191),
71425
71425
  copyFile: (src, dest) => fs9.copyFile(src, dest),
71426
- chmod: (path190, mode) => fs9.chmod(path190, mode)
71426
+ chmod: (path191, mode) => fs9.chmod(path191, mode)
71427
71427
  };
71428
71428
  const contextFactory = createCommandContextFactory({ fs: asyncFs });
71429
71429
  const authProviders = allAuthProviders;
@@ -73574,7 +73574,7 @@ function selectNextExecution(plan, taskId) {
73574
73574
  function describeExecutionContext(selection) {
73575
73575
  return selection.stepName ? `task "${selection.task.id}" step "${selection.stepName}"` : `task "${selection.task.id}"`;
73576
73576
  }
73577
- async function resolveFileIncludes(template2, cwd, readFile59) {
73577
+ async function resolveFileIncludes(template2, cwd, readFile60) {
73578
73578
  const matches = [...template2.matchAll(FILE_INCLUDE_PATTERN)];
73579
73579
  if (matches.length === 0) {
73580
73580
  return template2;
@@ -73586,7 +73586,7 @@ async function resolveFileIncludes(template2, cwd, readFile59) {
73586
73586
  if (relativePath === ".." || relativePath.startsWith(`..${path82.sep}`) || path82.isAbsolute(relativePath)) {
73587
73587
  throw new Error(`Pipeline file include resolves outside the project root: ${match[1]}`);
73588
73588
  }
73589
- const content = await readFile59(absolutePath, "utf8");
73589
+ const content = await readFile60(absolutePath, "utf8");
73590
73590
  result = result.replace(match[0], content);
73591
73591
  }
73592
73592
  return result;
@@ -73660,15 +73660,15 @@ async function resolveDocVarFromPath(options) {
73660
73660
  );
73661
73661
  }
73662
73662
  }
73663
- async function resolvePipelineVars(vars, cwd, readFile59) {
73663
+ async function resolvePipelineVars(vars, cwd, readFile60) {
73664
73664
  const resolved = {};
73665
73665
  for (const [key3, value] of Object.entries(vars)) {
73666
73666
  if (key3.endsWith("_doc") && looksLikeDocPath(value)) {
73667
- const docContent = await resolveDocVarFromPath({ key: key3, value, cwd, readFile: readFile59 });
73668
- defineRecordEntry3(resolved, key3, await resolveFileIncludes(docContent, cwd, readFile59));
73667
+ const docContent = await resolveDocVarFromPath({ key: key3, value, cwd, readFile: readFile60 });
73668
+ defineRecordEntry3(resolved, key3, await resolveFileIncludes(docContent, cwd, readFile60));
73669
73669
  continue;
73670
73670
  }
73671
- defineRecordEntry3(resolved, key3, await resolveFileIncludes(value, cwd, readFile59));
73671
+ defineRecordEntry3(resolved, key3, await resolveFileIncludes(value, cwd, readFile60));
73672
73672
  }
73673
73673
  return resolved;
73674
73674
  }
@@ -84438,9 +84438,9 @@ async function openTraceIndex(options) {
84438
84438
  stats2.removed += shard.count;
84439
84439
  delete manifest.shards[directory];
84440
84440
  manifestDirty = true;
84441
- const unlink26 = fs31.unlink;
84442
- if (typeof unlink26 === "function") {
84443
- await unlink26.call(fs31, path112.join(shardsDir, shard.file)).catch(() => void 0);
84441
+ const unlink27 = fs31.unlink;
84442
+ if (typeof unlink27 === "function") {
84443
+ await unlink27.call(fs31, path112.join(shardsDir, shard.file)).catch(() => void 0);
84444
84444
  }
84445
84445
  }
84446
84446
  }
@@ -84484,13 +84484,13 @@ async function openTraceIndex(options) {
84484
84484
  return results.map(referenceFromRecord);
84485
84485
  };
84486
84486
  const rebuild = async (syncOptions) => {
84487
- const unlink26 = fs31.unlink;
84488
- if (typeof unlink26 === "function") {
84487
+ const unlink27 = fs31.unlink;
84488
+ if (typeof unlink27 === "function") {
84489
84489
  const names = await fs31.readdir(shardsDir).catch(() => []);
84490
84490
  for (const name of names) {
84491
- await unlink26.call(fs31, path112.join(shardsDir, name)).catch(() => void 0);
84491
+ await unlink27.call(fs31, path112.join(shardsDir, name)).catch(() => void 0);
84492
84492
  }
84493
- await unlink26.call(fs31, manifestPath).catch(() => void 0);
84493
+ await unlink27.call(fs31, manifestPath).catch(() => void 0);
84494
84494
  } else {
84495
84495
  await writeAtomic(manifestPath, JSON.stringify({ version: MANIFEST_VERSION, shards: {} }));
84496
84496
  }
@@ -88043,15 +88043,15 @@ async function publishFiles(fs31, files) {
88043
88043
  function isAlreadyExistsError12(error3) {
88044
88044
  return hasOwnErrorCode24(error3, "EEXIST");
88045
88045
  }
88046
- async function assertNotSymbolicLinkIfSet(fs31, path190) {
88047
- if (path190 !== void 0 && path190 !== "") {
88048
- await assertNotSymbolicLink2(fs31, path190);
88046
+ async function assertNotSymbolicLinkIfSet(fs31, path191) {
88047
+ if (path191 !== void 0 && path191 !== "") {
88048
+ await assertNotSymbolicLink2(fs31, path191);
88049
88049
  }
88050
88050
  }
88051
- async function assertNotSymbolicLink2(fs31, path190) {
88051
+ async function assertNotSymbolicLink2(fs31, path191) {
88052
88052
  try {
88053
- if ((await fs31.lstat(path190)).isSymbolicLink()) {
88054
- throw new UserError2(`Refusing to use symbolic link path: ${path190}`);
88053
+ if ((await fs31.lstat(path191)).isSymbolicLink()) {
88054
+ throw new UserError2(`Refusing to use symbolic link path: ${path191}`);
88055
88055
  }
88056
88056
  } catch (error3) {
88057
88057
  if (isMissingFileError8(error3)) {
@@ -89459,12 +89459,12 @@ function validateNonBlankStrings(value) {
89459
89459
  }
89460
89460
  return issues;
89461
89461
  }
89462
- function blankStringIssue(path190, value) {
89462
+ function blankStringIssue(path191, value) {
89463
89463
  return {
89464
- path: path190,
89464
+ path: path191,
89465
89465
  expected: "non-blank string",
89466
89466
  received: JSON.stringify(value),
89467
- message: `${path190.join(".")} must not be blank.`
89467
+ message: `${path191.join(".")} must not be blank.`
89468
89468
  };
89469
89469
  }
89470
89470
  function validateTarget(target) {
@@ -89515,8 +89515,8 @@ function validateMetrics(metrics) {
89515
89515
  function formatIssues2(filePath, issues) {
89516
89516
  return issues.map((issue2) => `${filePath} (${formatPath3(issue2.path)}): ${issue2.message}`).join("\n");
89517
89517
  }
89518
- function formatPath3(path190) {
89519
- return path190.join(".") || "value";
89518
+ function formatPath3(path191) {
89519
+ return path191.join(".") || "value";
89520
89520
  }
89521
89521
  var nonEmptyString2, positiveInteger, nonNegativeInteger, scoringWeight, metricEvaluatorSchema, metricSchema, evalYamlSchema, EvalYamlValidationError;
89522
89522
  var init_schema5 = __esm({
@@ -89920,9 +89920,9 @@ async function loadEval(source, id, fs31 = nodeFs17) {
89920
89920
  plan
89921
89921
  };
89922
89922
  }
89923
- async function isFile2(path190, fs31) {
89923
+ async function isFile2(path191, fs31) {
89924
89924
  try {
89925
- const stat36 = await fs31.stat(path190);
89925
+ const stat36 = await fs31.stat(path191);
89926
89926
  return typeof stat36.isFile === "function" ? stat36.isFile() : !stat36.isDirectory();
89927
89927
  } catch (error3) {
89928
89928
  if (isMissingPath4(error3)) {
@@ -91805,19 +91805,19 @@ function validateRunResult(value, filePath) {
91805
91805
  requireRecord2(result.cheatReport, filePath, "result.json", ["cheatReport"]);
91806
91806
  return result;
91807
91807
  }
91808
- function validateScoringComponent(value, filePath, path190) {
91809
- const component = requireRecord2(value, filePath, "result.json", path190);
91810
- requireBoolean(component.configured, filePath, "result.json", [...path190, "configured"]);
91811
- requireBoolean(component.required, filePath, "result.json", [...path190, "required"]);
91808
+ function validateScoringComponent(value, filePath, path191) {
91809
+ const component = requireRecord2(value, filePath, "result.json", path191);
91810
+ requireBoolean(component.configured, filePath, "result.json", [...path191, "configured"]);
91811
+ requireBoolean(component.required, filePath, "result.json", [...path191, "required"]);
91812
91812
  requireRange(component.configuredWeight, 0, 1, filePath, "result.json", [
91813
- ...path190,
91813
+ ...path191,
91814
91814
  "configuredWeight"
91815
91815
  ]);
91816
91816
  requireRange(component.effectiveWeight, 0, 1, filePath, "result.json", [
91817
- ...path190,
91817
+ ...path191,
91818
91818
  "effectiveWeight"
91819
91819
  ]);
91820
- requireString(component.status, filePath, "result.json", [...path190, "status"]);
91820
+ requireString(component.status, filePath, "result.json", [...path191, "status"]);
91821
91821
  }
91822
91822
  function validateTrace(value, filePath) {
91823
91823
  const trace = requireRecord2(value, filePath, "trace.json", []);
@@ -91826,48 +91826,48 @@ function validateTrace(value, filePath) {
91826
91826
  }
91827
91827
  return trace;
91828
91828
  }
91829
- function requireRecord2(value, filePath, artifact, path190) {
91829
+ function requireRecord2(value, filePath, artifact, path191) {
91830
91830
  if (typeof value === "object" && value !== null && !Array.isArray(value)) {
91831
91831
  return value;
91832
91832
  }
91833
- throw invalidArtifactField(filePath, artifact, path190, "object", value);
91833
+ throw invalidArtifactField(filePath, artifact, path191, "object", value);
91834
91834
  }
91835
- function requireString(value, filePath, artifact, path190) {
91835
+ function requireString(value, filePath, artifact, path191) {
91836
91836
  if (typeof value === "string" && value.length > 0) {
91837
91837
  return value;
91838
91838
  }
91839
- throw invalidArtifactField(filePath, artifact, path190, "non-empty string", value);
91839
+ throw invalidArtifactField(filePath, artifact, path191, "non-empty string", value);
91840
91840
  }
91841
- function requireBoolean(value, filePath, artifact, path190) {
91841
+ function requireBoolean(value, filePath, artifact, path191) {
91842
91842
  if (typeof value !== "boolean") {
91843
- throw invalidArtifactField(filePath, artifact, path190, "boolean", value);
91843
+ throw invalidArtifactField(filePath, artifact, path191, "boolean", value);
91844
91844
  }
91845
91845
  }
91846
- function requireNonNegativeInteger2(value, filePath, artifact, path190) {
91846
+ function requireNonNegativeInteger2(value, filePath, artifact, path191) {
91847
91847
  if (typeof value === "number" && Number.isInteger(value) && value >= 0) {
91848
91848
  return value;
91849
91849
  }
91850
- throw invalidArtifactField(filePath, artifact, path190, "non-negative integer", value);
91850
+ throw invalidArtifactField(filePath, artifact, path191, "non-negative integer", value);
91851
91851
  }
91852
- function requireNonNegativeNumber(value, filePath, artifact, path190) {
91852
+ function requireNonNegativeNumber(value, filePath, artifact, path191) {
91853
91853
  if (typeof value === "number" && Number.isFinite(value) && value >= 0) {
91854
91854
  return value;
91855
91855
  }
91856
- throw invalidArtifactField(filePath, artifact, path190, "non-negative number", value);
91856
+ throw invalidArtifactField(filePath, artifact, path191, "non-negative number", value);
91857
91857
  }
91858
- function requireRange(value, min, max, filePath, artifact, path190) {
91858
+ function requireRange(value, min, max, filePath, artifact, path191) {
91859
91859
  if (typeof value === "number" && Number.isFinite(value) && value >= min && value <= max) {
91860
91860
  return;
91861
91861
  }
91862
- throw invalidArtifactField(filePath, artifact, path190, `number from ${min} through ${max}`, value);
91862
+ throw invalidArtifactField(filePath, artifact, path191, `number from ${min} through ${max}`, value);
91863
91863
  }
91864
- function invalidArtifactField(filePath, artifact, path190, expected, received) {
91864
+ function invalidArtifactField(filePath, artifact, path191, expected, received) {
91865
91865
  return new Error(
91866
- `Invalid ${artifact} in ${filePath} (${formatIssuePath(path190)}): expected ${expected}, received ${formatReceived2(received)}.`
91866
+ `Invalid ${artifact} in ${filePath} (${formatIssuePath(path191)}): expected ${expected}, received ${formatReceived2(received)}.`
91867
91867
  );
91868
91868
  }
91869
- function formatIssuePath(path190) {
91870
- return path190.join(".") || "value";
91869
+ function formatIssuePath(path191) {
91870
+ return path191.join(".") || "value";
91871
91871
  }
91872
91872
  function formatReceived2(value) {
91873
91873
  if (typeof value === "string") {
@@ -96660,11 +96660,11 @@ function formatSegment2(segment, casing) {
96660
96660
  const separator = casing === "snake" ? "_" : "-";
96661
96661
  return splitWords4(segment).join(separator);
96662
96662
  }
96663
- function toOptionFlag(path190, casing) {
96664
- return `--${path190.map((segment) => formatSegment2(segment, casing)).join(".")}`;
96663
+ function toOptionFlag(path191, casing) {
96664
+ return `--${path191.map((segment) => formatSegment2(segment, casing)).join(".")}`;
96665
96665
  }
96666
- function toOptionAttribute(path190, casing) {
96667
- return path190.map((segment) => {
96666
+ function toOptionAttribute(path191, casing) {
96667
+ return path191.map((segment) => {
96668
96668
  const formatted = formatSegment2(segment, casing);
96669
96669
  if (casing === "snake") {
96670
96670
  return formatted;
@@ -96675,23 +96675,23 @@ function toOptionAttribute(path190, casing) {
96675
96675
  ).join("");
96676
96676
  }).join(".");
96677
96677
  }
96678
- function toDisplayPath(path190) {
96679
- return path190.join(".");
96678
+ function toDisplayPath(path191) {
96679
+ return path191.join(".");
96680
96680
  }
96681
- function toUnionKindControlPath(path190) {
96682
- if (path190.length === 0) {
96681
+ function toUnionKindControlPath(path191) {
96682
+ if (path191.length === 0) {
96683
96683
  return ["kind"];
96684
96684
  }
96685
- const head = path190.slice(0, -1);
96686
- const tail = path190[path190.length - 1] ?? "";
96685
+ const head = path191.slice(0, -1);
96686
+ const tail = path191[path191.length - 1] ?? "";
96687
96687
  return [...head, `${tail}Kind`];
96688
96688
  }
96689
- function toUnionKindDisplayPath(path190) {
96690
- if (path190.length === 0) {
96689
+ function toUnionKindDisplayPath(path191) {
96690
+ if (path191.length === 0) {
96691
96691
  return "kind";
96692
96692
  }
96693
- const head = path190.slice(0, -1);
96694
- const tail = path190[path190.length - 1] ?? "";
96693
+ const head = path191.slice(0, -1);
96694
+ const tail = path191[path191.length - 1] ?? "";
96695
96695
  return [...head, `${tail}-kind`].join(".");
96696
96696
  }
96697
96697
  function createSyntheticEnumSchema(values) {
@@ -96707,14 +96707,14 @@ function getRequiredBranchFingerprint(branch, casing) {
96707
96707
  const requiredKeys = Object.entries(branch.shape).filter(([, schema]) => schema.kind !== "optional").map(([key3]) => formatSegment2(key3, casing)).sort();
96708
96708
  return requiredKeys.join("+");
96709
96709
  }
96710
- function collectFields(schema, casing, globalLongOptionFlags, path190 = [], inheritedOptional = false, variantContext) {
96710
+ function collectFields(schema, casing, globalLongOptionFlags, path191 = [], inheritedOptional = false, variantContext) {
96711
96711
  const collected = {
96712
96712
  dynamicFields: [],
96713
96713
  fields: [],
96714
96714
  variants: []
96715
96715
  };
96716
96716
  for (const [key3, rawChildSchema] of Object.entries(schema.shape)) {
96717
- const nextPath = [...path190, key3];
96717
+ const nextPath = [...path191, key3];
96718
96718
  const runtimeOptional = inheritedOptional || rawChildSchema.kind === "optional";
96719
96719
  const childSchema = unwrapOptional4(rawChildSchema);
96720
96720
  const requiredWhenActive = rawChildSchema.kind !== "optional" && childSchema.default === void 0;
@@ -96900,9 +96900,9 @@ function collectFields(schema, casing, globalLongOptionFlags, path190 = [], inhe
96900
96900
  }
96901
96901
  return collected;
96902
96902
  }
96903
- function toCommanderOptionAttribute(path190, casing, globalLongOptionFlags) {
96904
- const optionAttribute = toOptionAttribute(path190, casing);
96905
- const optionFlag = toOptionFlag(path190, casing);
96903
+ function toCommanderOptionAttribute(path191, casing, globalLongOptionFlags) {
96904
+ const optionAttribute = toOptionAttribute(path191, casing);
96905
+ const optionFlag = toOptionFlag(path191, casing);
96906
96906
  if (!globalLongOptionFlags.has(optionFlag)) {
96907
96907
  return optionAttribute;
96908
96908
  }
@@ -98496,10 +98496,10 @@ function writeCLIDiagnosticEvent(event) {
98496
98496
  process.stderr.write(`${event.message}
98497
98497
  `);
98498
98498
  }
98499
- function setNestedValue(target, path190, value) {
98499
+ function setNestedValue(target, path191, value) {
98500
98500
  let cursor2 = target;
98501
- for (let index = 0; index < path190.length - 1; index += 1) {
98502
- const segment = path190[index] ?? "";
98501
+ for (let index = 0; index < path191.length - 1; index += 1) {
98502
+ const segment = path191[index] ?? "";
98503
98503
  const existing = Object.prototype.hasOwnProperty.call(cursor2, segment) ? cursor2[segment] : void 0;
98504
98504
  if (typeof existing === "object" && existing !== null) {
98505
98505
  cursor2 = existing;
@@ -98514,7 +98514,7 @@ function setNestedValue(target, path190, value) {
98514
98514
  });
98515
98515
  cursor2 = next;
98516
98516
  }
98517
- const leaf = path190[path190.length - 1];
98517
+ const leaf = path191[path191.length - 1];
98518
98518
  if (leaf !== void 0) {
98519
98519
  Object.defineProperty(cursor2, leaf, {
98520
98520
  value,
@@ -98696,9 +98696,9 @@ function isPlainObject8(value) {
98696
98696
  function hasFieldValue(value) {
98697
98697
  return value !== void 0;
98698
98698
  }
98699
- function hasNestedField(fields, path190) {
98699
+ function hasNestedField(fields, path191) {
98700
98700
  return fields.some(
98701
- (field) => path190.length < field.path.length && path190.every((segment, index) => field.path[index] === segment)
98701
+ (field) => path191.length < field.path.length && path191.every((segment, index) => field.path[index] === segment)
98702
98702
  );
98703
98703
  }
98704
98704
  function describeExpectedPresetValue(schema) {
@@ -98827,9 +98827,9 @@ async function loadPresetValues(fields, presetPath) {
98827
98827
  }
98828
98828
  const fieldByPath = new Map(fields.map((field) => [field.displayPath, field]));
98829
98829
  const presetValues = {};
98830
- function visitObject(current, path190) {
98830
+ function visitObject(current, path191) {
98831
98831
  for (const [key3, value] of Object.entries(current)) {
98832
- const nextPath = [...path190, key3];
98832
+ const nextPath = [...path191, key3];
98833
98833
  const displayPath = toDisplayPath(nextPath);
98834
98834
  const field = fieldByPath.get(displayPath);
98835
98835
  if (field !== void 0) {
@@ -99212,8 +99212,8 @@ This is a bug in toolcraft or in the command definition; it cannot be worked aro
99212
99212
  }
99213
99213
  process.exitCode = 1;
99214
99214
  }
99215
- function getNestedValue(target, path190) {
99216
- return path190.reduce(
99215
+ function getNestedValue(target, path191) {
99216
+ return path191.reduce(
99217
99217
  (current, segment) => current !== null && typeof current === "object" ? current[segment] : void 0,
99218
99218
  target
99219
99219
  );
@@ -101277,13 +101277,13 @@ function formatAvailableApprovalCommandPaths(root) {
101277
101277
  }
101278
101278
  function enumerateApprovalCommandPaths(root) {
101279
101279
  const paths = [];
101280
- const visit = (node, path190) => {
101280
+ const visit = (node, path191) => {
101281
101281
  if (node.kind === "command") {
101282
- paths.push(path190.join("."));
101282
+ paths.push(path191.join("."));
101283
101283
  return;
101284
101284
  }
101285
101285
  for (const child of getVisibleCliChildren(node)) {
101286
- visit(child, [...path190, child.name]);
101286
+ visit(child, [...path191, child.name]);
101287
101287
  }
101288
101288
  };
101289
101289
  if (root.kind === "command") {
@@ -102799,12 +102799,12 @@ function createOverlayFileSystem(base) {
102799
102799
  }
102800
102800
  return { kind: "file", content: await base.readFile(filePath, "utf8") };
102801
102801
  };
102802
- async function readFile59(filePath, encoding) {
102802
+ async function readFile60(filePath, encoding) {
102803
102803
  const content = await readOverlayText(filePath);
102804
102804
  return encoding ? content : Buffer.from(content);
102805
102805
  }
102806
102806
  const fs31 = {
102807
- readFile: readFile59,
102807
+ readFile: readFile60,
102808
102808
  async writeFile(filePath, content, options) {
102809
102809
  await assertOverlayParentDirectory(filePath);
102810
102810
  if (options?.flag === "wx" && await overlayPathExists(filePath)) {
@@ -105158,9 +105158,9 @@ var init_config8 = __esm({
105158
105158
 
105159
105159
  // src/cli/commands/utils-symlink-ops.ts
105160
105160
  import { dirname as dirname10 } from "node:path";
105161
- async function tryLstat(fs31, path190) {
105161
+ async function tryLstat(fs31, path191) {
105162
105162
  try {
105163
- return await fs31.lstat(path190);
105163
+ return await fs31.lstat(path191);
105164
105164
  } catch (error3) {
105165
105165
  if (isNotFound(error3)) {
105166
105166
  return null;
@@ -105244,13 +105244,13 @@ function formatUnknownError6(error3) {
105244
105244
  }
105245
105245
  return String(error3);
105246
105246
  }
105247
- async function isSymlinkPointingTo(fs31, path190, expectedTarget) {
105247
+ async function isSymlinkPointingTo(fs31, path191, expectedTarget) {
105248
105248
  try {
105249
- const stats2 = await fs31.lstat(path190);
105249
+ const stats2 = await fs31.lstat(path191);
105250
105250
  if (!stats2.isSymbolicLink()) {
105251
105251
  return false;
105252
105252
  }
105253
- return await fs31.readlink(path190) === expectedTarget;
105253
+ return await fs31.readlink(path191) === expectedTarget;
105254
105254
  } catch (error3) {
105255
105255
  if (isNotFound(error3)) {
105256
105256
  return false;
@@ -108716,11 +108716,11 @@ function registerPipelineCommand(program, container) {
108716
108716
  if (typeof t.status === "string") return t.status === "done";
108717
108717
  return Object.values(t.status).every((s) => s === "done");
108718
108718
  }).length;
108719
- const readFile59 = container.fs.readFile.bind(container.fs);
108719
+ const readFile60 = container.fs.readFile.bind(container.fs);
108720
108720
  const resolvedVars = await resolvePipelineVars(
108721
108721
  plan.vars ?? {},
108722
108722
  container.env.cwd,
108723
- readFile59
108723
+ readFile60
108724
108724
  );
108725
108725
  const resolvedSetup = plan.setup === null ? void 0 : plan.setup ?? steps.setup;
108726
108726
  const resolvedTeardown = plan.teardown === null ? void 0 : plan.teardown ?? steps.teardown;
@@ -108742,7 +108742,7 @@ function registerPipelineCommand(program, container) {
108742
108742
  if (opts.preview) {
108743
108743
  if (resolvedSetup) {
108744
108744
  const raw = interpolatePipelineVars(resolvedSetup.prompt, resolvedVars, "setup");
108745
- const expanded = await resolveFileIncludes(raw, container.env.cwd, readFile59);
108745
+ const expanded = await resolveFileIncludes(raw, container.env.cwd, readFile60);
108746
108746
  resources.logger.resolved("setup", expanded);
108747
108747
  }
108748
108748
  for (const task of plan.tasks) {
@@ -108755,7 +108755,7 @@ function registerPipelineCommand(program, container) {
108755
108755
  vars: resolvedVars
108756
108756
  }),
108757
108757
  container.env.cwd,
108758
- readFile59
108758
+ readFile60
108759
108759
  );
108760
108760
  resources.logger.resolved(`task: ${task.id} \u2014 ${task.title}`, expanded);
108761
108761
  } else {
@@ -108768,7 +108768,7 @@ function registerPipelineCommand(program, container) {
108768
108768
  vars: resolvedVars
108769
108769
  }),
108770
108770
  container.env.cwd,
108771
- readFile59
108771
+ readFile60
108772
108772
  );
108773
108773
  resources.logger.resolved(`task: ${task.id} / ${stepName}`, expanded);
108774
108774
  }
@@ -108776,7 +108776,7 @@ function registerPipelineCommand(program, container) {
108776
108776
  }
108777
108777
  if (resolvedTeardown) {
108778
108778
  const raw = interpolatePipelineVars(resolvedTeardown.prompt, resolvedVars, "teardown");
108779
- const expanded = await resolveFileIncludes(raw, container.env.cwd, readFile59);
108779
+ const expanded = await resolveFileIncludes(raw, container.env.cwd, readFile60);
108780
108780
  resources.logger.resolved("teardown", expanded);
108781
108781
  }
108782
108782
  }
@@ -109721,28 +109721,28 @@ function detectTraceFile(firstLine) {
109721
109721
  }
109722
109722
  return void 0;
109723
109723
  }
109724
- async function loadTraceFromFile(path190, options) {
109725
- const stat36 = await options.fs.stat(path190).catch(() => void 0);
109724
+ async function loadTraceFromFile(path191, options) {
109725
+ const stat36 = await options.fs.stat(path191).catch(() => void 0);
109726
109726
  if (stat36 === void 0) {
109727
109727
  throw new UserError(
109728
- `Trace file not found: ${path190}
109728
+ `Trace file not found: ${path191}
109729
109729
  Pass a path to an existing trace file, or run "poe-code traces" to list the traces found.`
109730
109730
  );
109731
109731
  }
109732
109732
  if (stat36.isDirectory()) {
109733
109733
  throw new UserError(
109734
- `Trace path is a directory: ${path190}
109734
+ `Trace path is a directory: ${path191}
109735
109735
  Pass a path to a trace file, or run "poe-code traces" to list the traces found.`
109736
109736
  );
109737
109737
  }
109738
- const contents = await options.fs.readFile(path190, "utf8");
109738
+ const contents = await options.fs.readFile(path191, "utf8");
109739
109739
  const firstLineEnd = contents.indexOf("\n");
109740
109740
  const firstLine = firstLineEnd === -1 ? contents : contents.slice(0, firstLineEnd);
109741
109741
  const source = detectTraceFile(firstLine);
109742
109742
  if (source === void 0) {
109743
- throw new Error(`Unable to detect trace source for file: ${path190}`);
109743
+ throw new Error(`Unable to detect trace source for file: ${path191}`);
109744
109744
  }
109745
- return loadTrace({ source, id: path190, path: path190 }, options);
109745
+ return loadTrace({ source, id: path191, path: path191 }, options);
109746
109746
  }
109747
109747
  function dateValue(date) {
109748
109748
  return date?.getTime() ?? 0;
@@ -111255,8 +111255,8 @@ var init_write_html = __esm({
111255
111255
  import { pathToFileURL as pathToFileURL2 } from "node:url";
111256
111256
  async function openTraceHtml(tree, options) {
111257
111257
  const written = await writeTraceHtml(tree, options);
111258
- const open8 = options.open ?? ((target) => openExternal(target));
111259
- await open8(pathToFileURL2(written.path).href);
111258
+ const open9 = options.open ?? ((target) => openExternal(target));
111259
+ await open9(pathToFileURL2(written.path).href);
111260
111260
  return written;
111261
111261
  }
111262
111262
  var init_open_html = __esm({
@@ -111658,9 +111658,9 @@ async function exportTraceHtml(tree, options, output) {
111658
111658
  writeLine5(output, `Wrote ${written.path}`);
111659
111659
  return;
111660
111660
  }
111661
- const open8 = options.openExternal ?? ((target) => openExternal(target));
111661
+ const open9 = options.openExternal ?? ((target) => openExternal(target));
111662
111662
  try {
111663
- await open8(pathToFileURL3(written.path).href);
111663
+ await open9(pathToFileURL3(written.path).href);
111664
111664
  writeLine5(output, `Opened ${written.path}`);
111665
111665
  } catch (error3) {
111666
111666
  writeLine5(output, `Wrote ${written.path}`);
@@ -111745,16 +111745,16 @@ function registerTracesCommand(program, container) {
111745
111745
  const options = this.opts();
111746
111746
  const flags = resolveCommandFlags(program);
111747
111747
  const json = options.json === true;
111748
- const open8 = options.open === true;
111748
+ const open9 = options.open === true;
111749
111749
  const htmlOut = options.htmlOut;
111750
- if ((open8 || htmlOut !== void 0) && pathArg === void 0) {
111750
+ if ((open9 || htmlOut !== void 0) && pathArg === void 0) {
111751
111751
  throw new ValidationError(
111752
- open8 ? "--open requires a trace path." : "--html-out requires a trace path."
111752
+ open9 ? "--open requires a trace path." : "--html-out requires a trace path."
111753
111753
  );
111754
111754
  }
111755
- if ((open8 || htmlOut !== void 0) && json) {
111755
+ if ((open9 || htmlOut !== void 0) && json) {
111756
111756
  throw new ValidationError(
111757
- open8 ? "--open cannot be used with --json." : "--html-out cannot be used with --json."
111757
+ open9 ? "--open cannot be used with --json." : "--html-out cannot be used with --json."
111758
111758
  );
111759
111759
  }
111760
111760
  const viewerOptions = {
@@ -111768,7 +111768,7 @@ function registerTracesCommand(program, container) {
111768
111768
  limit: parseLimit2(options.limit),
111769
111769
  json,
111770
111770
  fullTitles: options.fullTitles === true,
111771
- open: open8,
111771
+ open: open9,
111772
111772
  htmlOut,
111773
111773
  rebuildIndex: options.rebuildIndex === true
111774
111774
  };
@@ -111784,11 +111784,11 @@ function registerTracesCommand(program, container) {
111784
111784
  if (pathArg === void 0 && viewerOptions.rebuildIndex) {
111785
111785
  logger2.dryRun("Dry run: would rebuild the trace index.");
111786
111786
  }
111787
- if (open8 || htmlOut !== void 0) {
111787
+ if (open9 || htmlOut !== void 0) {
111788
111788
  logger2.dryRun(
111789
111789
  `Dry run: would export trace ${pathArg} as HTML${htmlOut !== void 0 ? ` to ${htmlOut}` : ""}.`
111790
111790
  );
111791
- if (open8) {
111791
+ if (open9) {
111792
111792
  logger2.dryRun("Dry run: would open the HTML in a browser.");
111793
111793
  }
111794
111794
  } else {
@@ -114351,7 +114351,7 @@ function parseSources(value) {
114351
114351
  'Invalid "sources" frontmatter. Expected each source to be a string or object.'
114352
114352
  );
114353
114353
  }
114354
- const path190 = readRequiredString(getOwnEntry35(item, "path"), "sources[].path");
114354
+ const path191 = readRequiredString(getOwnEntry35(item, "path"), "sources[].path");
114355
114355
  const startLine = readOptionalPositiveInteger(
114356
114356
  getOwnEntry35(item, "startLine"),
114357
114357
  "sources[].startLine"
@@ -114359,7 +114359,7 @@ function parseSources(value) {
114359
114359
  const endLine = readOptionalPositiveInteger(getOwnEntry35(item, "endLine"), "sources[].endLine");
114360
114360
  return parseSourceRef(
114361
114361
  serializeSourceRef({
114362
- path: path190,
114362
+ path: path191,
114363
114363
  ...startLine === void 0 ? {} : { startLine },
114364
114364
  ...endLine === void 0 ? {} : { endLine }
114365
114365
  })
@@ -130879,9 +130879,9 @@ function findPathToModule(currentModuleName, targetModuleName, dependencyGraph,
130879
130879
  }
130880
130880
  visited.add(currentModuleName);
130881
130881
  for (const dependencyModuleName of dependencyGraph.get(currentModuleName) ?? []) {
130882
- const path190 = findPathToModule(dependencyModuleName, targetModuleName, dependencyGraph, visited);
130883
- if (path190 !== void 0) {
130884
- return [currentModuleName, ...path190];
130882
+ const path191 = findPathToModule(dependencyModuleName, targetModuleName, dependencyGraph, visited);
130883
+ if (path191 !== void 0) {
130884
+ return [currentModuleName, ...path191];
130885
130885
  }
130886
130886
  }
130887
130887
  visited.delete(currentModuleName);
@@ -136264,11 +136264,11 @@ function assertSandboxDataDepth(depth) {
136264
136264
  throw new SandboxError({ budget: "dataDepth", current: depth, limit: MAX_DATA_DEPTH });
136265
136265
  }
136266
136266
  }
136267
- function assertSnapshotDataDepth(depth, path190) {
136268
- if (depth > MAX_DATA_DEPTH) throw new SnapshotBudgetError(path190, depth);
136267
+ function assertSnapshotDataDepth(depth, path191) {
136268
+ if (depth > MAX_DATA_DEPTH) throw new SnapshotBudgetError(path191, depth);
136269
136269
  }
136270
136270
  function assertSnapshotGraphDepth(value, rootPath = "$") {
136271
- walkGraphDepth(value, rootPath, (depth, path190) => assertSnapshotDataDepth(depth, path190));
136271
+ walkGraphDepth(value, rootPath, (depth, path191) => assertSnapshotDataDepth(depth, path191));
136272
136272
  }
136273
136273
  function assertSandboxGraphDepth(value) {
136274
136274
  walkGraphDepth(value, "<root>", (depth) => assertSandboxDataDepth(depth));
@@ -136335,12 +136335,12 @@ var init_graph_depth = __esm({
136335
136335
  current;
136336
136336
  limit;
136337
136337
  path;
136338
- constructor(path190, current, limit = MAX_DATA_DEPTH) {
136339
- super(`Snapshot budget exceeded for dataDepth at ${path190}: ${current} > ${limit}.`);
136338
+ constructor(path191, current, limit = MAX_DATA_DEPTH) {
136339
+ super(`Snapshot budget exceeded for dataDepth at ${path191}: ${current} > ${limit}.`);
136340
136340
  this.name = "SnapshotBudgetError";
136341
136341
  this.current = current;
136342
136342
  this.limit = limit;
136343
- this.path = path190;
136343
+ this.path = path191;
136344
136344
  replaceErrorStack(this);
136345
136345
  }
136346
136346
  };
@@ -136423,7 +136423,7 @@ function createDumpFile(snapshot2) {
136423
136423
  }
136424
136424
  return dumped;
136425
136425
  }
136426
- function serializeDumpValue(value, path190, state) {
136426
+ function serializeDumpValue(value, path191, state) {
136427
136427
  if (value === null || typeof value === "string" || typeof value === "boolean") {
136428
136428
  return value;
136429
136429
  }
@@ -136440,22 +136440,22 @@ function serializeDumpValue(value, path190, state) {
136440
136440
  return SKIP_VALUE;
136441
136441
  }
136442
136442
  if (Array.isArray(value)) {
136443
- const reference2 = serializeHeapReference(value, path190, state);
136443
+ const reference2 = serializeHeapReference(value, path191, state);
136444
136444
  if (reference2 !== void 0) {
136445
136445
  return reference2;
136446
136446
  }
136447
- return serializeArrayItems(value, path190, state);
136447
+ return serializeArrayItems(value, path191, state);
136448
136448
  }
136449
136449
  if (!isPlainObject9(value)) {
136450
136450
  return SKIP_VALUE;
136451
136451
  }
136452
- const reference = serializeHeapReference(value, path190, state);
136452
+ const reference = serializeHeapReference(value, path191, state);
136453
136453
  if (reference !== void 0) {
136454
136454
  return reference;
136455
136455
  }
136456
- return serializeObjectEntries(value, path190, state);
136456
+ return serializeObjectEntries(value, path191, state);
136457
136457
  }
136458
- function serializeHeapReference(value, path190, state) {
136458
+ function serializeHeapReference(value, path191, state) {
136459
136459
  const id = state.heapIds.get(value);
136460
136460
  if (id === void 0) {
136461
136461
  return void 0;
@@ -136464,19 +136464,19 @@ function serializeHeapReference(value, path190, state) {
136464
136464
  state.serializedHeapIds.add(id);
136465
136465
  if (isSandboxArguments(value)) {
136466
136466
  state.heap[String(id)] = serializeArguments(value, (entry, key3) => {
136467
- const serialized = serializeDumpValue(entry, `${path190}.${key3}`, state);
136467
+ const serialized = serializeDumpValue(entry, `${path191}.${key3}`, state);
136468
136468
  return serialized === SKIP_VALUE ? { kind: "undefined" } : serialized;
136469
136469
  });
136470
136470
  } else if (Array.isArray(value)) {
136471
136471
  state.heap[String(id)] = {
136472
136472
  kind: "array",
136473
- items: serializeArrayItems(value, path190, state)
136473
+ items: serializeArrayItems(value, path191, state)
136474
136474
  };
136475
136475
  } else {
136476
136476
  const errorType = sandboxErrorTypes.get(value);
136477
136477
  state.heap[String(id)] = {
136478
136478
  kind: "object",
136479
- entries: serializeObjectEntries(value, path190, state),
136479
+ entries: serializeObjectEntries(value, path191, state),
136480
136480
  ...errorType === void 0 ? {} : { errorType }
136481
136481
  };
136482
136482
  }
@@ -136486,10 +136486,10 @@ function serializeHeapReference(value, path190, state) {
136486
136486
  id
136487
136487
  };
136488
136488
  }
136489
- function serializeObjectEntries(value, path190, state) {
136489
+ function serializeObjectEntries(value, path191, state) {
136490
136490
  const serialized = {};
136491
136491
  for (const [key3, entry] of getEnumerableDataEntries(value)) {
136492
- const dumped = serializeDumpValue(entry, `${path190}.${key3}`, state);
136492
+ const dumped = serializeDumpValue(entry, `${path191}.${key3}`, state);
136493
136493
  if (dumped !== SKIP_VALUE) {
136494
136494
  serialized[key3] = dumped;
136495
136495
  }
@@ -136551,9 +136551,9 @@ function isPlainObject9(value) {
136551
136551
  const prototype = Object.getPrototypeOf(value);
136552
136552
  return prototype === Object.prototype || prototype === null;
136553
136553
  }
136554
- function serializeArrayItems(value, path190, state) {
136554
+ function serializeArrayItems(value, path191, state) {
136555
136555
  return getArrayDataItems(value).map((entry, index) => {
136556
- const serialized = serializeDumpValue(entry, `${path190}[${index}]`, state);
136556
+ const serialized = serializeDumpValue(entry, `${path191}[${index}]`, state);
136557
136557
  return serialized === SKIP_VALUE ? { kind: "undefined" } : serialized;
136558
136558
  });
136559
136559
  }
@@ -136587,7 +136587,7 @@ var init_dump_format = __esm({
136587
136587
  init_arguments();
136588
136588
  init_arguments2();
136589
136589
  DUMP_FORMAT_VERSION = 1;
136590
- EXECUTION_SEMANTICS = "jobs-v5";
136590
+ EXECUTION_SEMANTICS = "jobs-v6";
136591
136591
  SKIP_VALUE = /* @__PURE__ */ Symbol("SafeJS.skip-dump-value");
136592
136592
  }
136593
136593
  });
@@ -136634,44 +136634,44 @@ function validateDumpHeap(root, state) {
136634
136634
  const heap = root.heap === void 0 ? /* @__PURE__ */ Object.create(null) : requireRecord3(root.heap, "$.heap");
136635
136635
  const heapIds = /* @__PURE__ */ new Set();
136636
136636
  for (const [key3, value] of Object.entries(heap)) {
136637
- const path190 = `$.heap${formatKey(key3)}`;
136638
- const id = parseHeapId(key3, path190);
136639
- addUnique2(heapIds, id, path190);
136640
- const entry = requireRecord3(value, path190);
136641
- validateErrorType(entry, path190);
136637
+ const path191 = `$.heap${formatKey(key3)}`;
136638
+ const id = parseHeapId(key3, path191);
136639
+ addUnique2(heapIds, id, path191);
136640
+ const entry = requireRecord3(value, path191);
136641
+ validateErrorType(entry, path191);
136642
136642
  if (entry.kind === "arguments") {
136643
- validateArgumentsProperties(entry, path190);
136643
+ validateArgumentsProperties(entry, path191);
136644
136644
  continue;
136645
136645
  }
136646
136646
  if (entry.kind === "array") {
136647
- requireArray(entry.items, `${path190}.items`, state);
136647
+ requireArray(entry.items, `${path191}.items`, state);
136648
136648
  continue;
136649
136649
  }
136650
136650
  if (entry.kind === "object") {
136651
- requireRecord3(entry.entries, `${path190}.entries`);
136651
+ requireRecord3(entry.entries, `${path191}.entries`);
136652
136652
  continue;
136653
136653
  }
136654
- fail2("unknownTag", `${path190}.kind`, "unknown dump heap tag");
136654
+ fail2("unknownTag", `${path191}.kind`, "unknown dump heap tag");
136655
136655
  }
136656
136656
  validateDumpReferences(root, "$", 0, state, heapIds);
136657
136657
  }
136658
- function validateDumpReferences(value, path190, depth, state, heapIds) {
136658
+ function validateDumpReferences(value, path191, depth, state, heapIds) {
136659
136659
  if (value === null || typeof value !== "object") return;
136660
136660
  if (depth > state.limits.maxDepth)
136661
- fail2("budgetExceeded", path190, `exceeds nesting limit ${state.limits.maxDepth}`);
136661
+ fail2("budgetExceeded", path191, `exceeds nesting limit ${state.limits.maxDepth}`);
136662
136662
  if (Array.isArray(value)) {
136663
136663
  value.forEach(
136664
- (entry, index) => validateDumpReferences(entry, `${path190}[${index}]`, depth + 1, state, heapIds)
136664
+ (entry, index) => validateDumpReferences(entry, `${path191}[${index}]`, depth + 1, state, heapIds)
136665
136665
  );
136666
136666
  return;
136667
136667
  }
136668
136668
  const record2 = value;
136669
136669
  if (record2.kind === "ref") {
136670
- const id = requireSafeInteger(record2.id, `${path190}.id`, 1);
136671
- if (!heapIds.has(id)) fail2("danglingReference", `${path190}.id`, `unknown heap value ${id}`);
136670
+ const id = requireSafeInteger(record2.id, `${path191}.id`, 1);
136671
+ if (!heapIds.has(id)) fail2("danglingReference", `${path191}.id`, `unknown heap value ${id}`);
136672
136672
  }
136673
136673
  for (const [key3, entry] of Object.entries(record2)) {
136674
- validateDumpReferences(entry, `${path190}${formatKey(key3)}`, depth + 1, state, heapIds);
136674
+ validateDumpReferences(entry, `${path191}${formatKey(key3)}`, depth + 1, state, heapIds);
136675
136675
  }
136676
136676
  }
136677
136677
  function validateRunSnapshotState(root, state) {
@@ -136690,64 +136690,64 @@ function validateRunSnapshotState(root, state) {
136690
136690
  if (root.loopIterations !== void 0) {
136691
136691
  const iterations = requireRecord3(root.loopIterations, "$.loopIterations");
136692
136692
  for (const [nodeId, value] of Object.entries(iterations)) {
136693
- const path190 = `$.loopIterations${formatKey(nodeId)}`;
136694
- requireSafeInteger(Number(nodeId), `${path190}#key`, 0);
136693
+ const path191 = `$.loopIterations${formatKey(nodeId)}`;
136694
+ requireSafeInteger(Number(nodeId), `${path191}#key`, 0);
136695
136695
  if (typeof value === "number") {
136696
- requireSafeInteger(value, path190, 0);
136696
+ requireSafeInteger(value, path191, 0);
136697
136697
  continue;
136698
136698
  }
136699
- const iteration = requireRecord3(value, path190);
136700
- requireSafeInteger(iteration.index, `${path190}.index`, 0);
136701
- requireArray(iteration.values, `${path190}.values`, state);
136699
+ const iteration = requireRecord3(value, path191);
136700
+ requireSafeInteger(iteration.index, `${path191}.index`, 0);
136701
+ requireArray(iteration.values, `${path191}.values`, state);
136702
136702
  }
136703
136703
  }
136704
136704
  if (root.pendingAwaits !== void 0) {
136705
136705
  const pendingAwaits = requireArray(root.pendingAwaits, "$.pendingAwaits", state);
136706
136706
  pendingAwaits.forEach((value, index) => {
136707
- const path190 = `$.pendingAwaits[${index}]`;
136708
- const pending = requireRecord3(value, path190);
136709
- if (pending.nodeId !== void 0) requireSafeInteger(pending.nodeId, `${path190}.nodeId`, 0);
136710
- const span = requireRecord3(pending.span, `${path190}.span`);
136711
- const start = validatePosition(span.start, `${path190}.span.start`);
136712
- const end = validatePosition(span.end, `${path190}.span.end`);
136707
+ const path191 = `$.pendingAwaits[${index}]`;
136708
+ const pending = requireRecord3(value, path191);
136709
+ if (pending.nodeId !== void 0) requireSafeInteger(pending.nodeId, `${path191}.nodeId`, 0);
136710
+ const span = requireRecord3(pending.span, `${path191}.span`);
136711
+ const start = validatePosition(span.start, `${path191}.span.start`);
136712
+ const end = validatePosition(span.end, `${path191}.span.end`);
136713
136713
  if (start > end) {
136714
- fail2("invalidValue", `${path190}.span`, "start must not exceed end");
136714
+ fail2("invalidValue", `${path191}.span`, "start must not exceed end");
136715
136715
  }
136716
136716
  });
136717
136717
  }
136718
136718
  }
136719
- function validatePosition(value, path190) {
136720
- const position = requireRecord3(value, path190);
136721
- requireSafeInteger(position.line, `${path190}.line`, 1);
136722
- requireSafeInteger(position.column, `${path190}.column`, 0);
136723
- return requireSafeInteger(position.offset, `${path190}.offset`, 0);
136719
+ function validatePosition(value, path191) {
136720
+ const position = requireRecord3(value, path191);
136721
+ requireSafeInteger(position.line, `${path191}.line`, 1);
136722
+ requireSafeInteger(position.column, `${path191}.column`, 0);
136723
+ return requireSafeInteger(position.offset, `${path191}.offset`, 0);
136724
136724
  }
136725
- function validateTaggedValue(record2, path190, state) {
136725
+ function validateTaggedValue(record2, path191, state) {
136726
136726
  switch (record2.kind) {
136727
136727
  case "undefined":
136728
136728
  return;
136729
136729
  case "number":
136730
136730
  if (!["-Infinity", "Infinity", "NaN"].includes(String(record2.value))) {
136731
- fail2("invalidValue", `${path190}.value`, "unknown non-finite number value");
136731
+ fail2("invalidValue", `${path191}.value`, "unknown non-finite number value");
136732
136732
  }
136733
136733
  return;
136734
136734
  case "fn":
136735
- requireSafeInteger(record2.astNodeId, `${path190}.astNodeId`, 0);
136736
- requireSnapshotId(record2.capturedScopeId, `${path190}.capturedScopeId`);
136735
+ requireSafeInteger(record2.astNodeId, `${path191}.astNodeId`, 0);
136736
+ requireSnapshotId(record2.capturedScopeId, `${path191}.capturedScopeId`);
136737
136737
  return;
136738
136738
  case "generator":
136739
- validateGeneratorShape(record2, path190, state);
136739
+ validateGeneratorShape(record2, path191, state);
136740
136740
  return;
136741
136741
  case "promise":
136742
- requireSnapshotId(record2.id, `${path190}.id`);
136742
+ requireSnapshotId(record2.id, `${path191}.id`);
136743
136743
  return;
136744
136744
  case "ref":
136745
- requireSafeInteger(record2.id, `${path190}.id`, 1);
136745
+ requireSafeInteger(record2.id, `${path191}.id`, 1);
136746
136746
  return;
136747
136747
  case "regex":
136748
- requireString2(record2.source, `${path190}.source`, state.limits);
136749
- requireString2(record2.flags, `${path190}.flags`, state.limits);
136750
- requireSafeInteger(record2.lastIndex, `${path190}.lastIndex`, 0);
136748
+ requireString2(record2.source, `${path191}.source`, state.limits);
136749
+ requireString2(record2.flags, `${path191}.flags`, state.limits);
136750
+ requireSafeInteger(record2.lastIndex, `${path191}.lastIndex`, 0);
136751
136751
  return;
136752
136752
  case "array":
136753
136753
  case "arguments":
@@ -136757,28 +136757,28 @@ function validateTaggedValue(record2, path190, state) {
136757
136757
  return;
136758
136758
  }
136759
136759
  }
136760
- function validateGeneratorShape(record2, path190, state) {
136760
+ function validateGeneratorShape(record2, path191, state) {
136761
136761
  if (!["start", "suspended", "done"].includes(String(record2.state))) {
136762
- fail2("invalidState", `${path190}.state`, "unknown generator state");
136762
+ fail2("invalidState", `${path191}.state`, "unknown generator state");
136763
136763
  }
136764
136764
  if (record2.state === "done") {
136765
136765
  if (record2.astNodeId !== void 0 || record2.capturedScopeId !== void 0 || record2.sent !== void 0 || record2.yieldNodeId !== void 0) {
136766
- fail2("invalidState", path190, "done generator cannot contain resume state");
136766
+ fail2("invalidState", path191, "done generator cannot contain resume state");
136767
136767
  }
136768
136768
  return;
136769
136769
  }
136770
- requireSafeInteger(record2.astNodeId, `${path190}.astNodeId`, 0);
136771
- requireSnapshotId(record2.capturedScopeId, `${path190}.capturedScopeId`);
136770
+ requireSafeInteger(record2.astNodeId, `${path191}.astNodeId`, 0);
136771
+ requireSnapshotId(record2.capturedScopeId, `${path191}.capturedScopeId`);
136772
136772
  if (record2.state === "start") {
136773
136773
  if (record2.sent !== void 0 || record2.yieldNodeId !== void 0) {
136774
- fail2("invalidState", path190, "unstarted generator cannot contain a resume cursor");
136774
+ fail2("invalidState", path191, "unstarted generator cannot contain a resume cursor");
136775
136775
  }
136776
136776
  return;
136777
136777
  }
136778
- requireSafeInteger(record2.yieldNodeId, `${path190}.yieldNodeId`, 0);
136779
- const sent = requireArray(record2.sent, `${path190}.sent`, state);
136778
+ requireSafeInteger(record2.yieldNodeId, `${path191}.yieldNodeId`, 0);
136779
+ const sent = requireArray(record2.sent, `${path191}.sent`, state);
136780
136780
  sent.forEach((completion, index) => {
136781
- const completionPath = `${path190}.sent[${index}]`;
136781
+ const completionPath = `${path191}.sent[${index}]`;
136782
136782
  const candidate = requireRecord3(completion, completionPath);
136783
136783
  if (!Object.hasOwn(candidate, "type")) {
136784
136784
  fail2("invalidValue", `${completionPath}.type`, "completion type is required");
@@ -136791,41 +136791,41 @@ function validateGeneratorShape(record2, path190, state) {
136791
136791
  }
136792
136792
  });
136793
136793
  }
136794
- function validateErrorType(record2, path190) {
136794
+ function validateErrorType(record2, path191) {
136795
136795
  if (!Object.hasOwn(record2, "errorType")) return;
136796
136796
  if (record2.kind !== "object" || !sandboxErrorNames.includes(record2.errorType)) {
136797
- fail2("invalidValue", `${path190}.errorType`, "invalid error metadata");
136797
+ fail2("invalidValue", `${path191}.errorType`, "invalid error metadata");
136798
136798
  }
136799
136799
  }
136800
- function validateArgumentsProperties(record2, path190) {
136800
+ function validateArgumentsProperties(record2, path191) {
136801
136801
  if (typeof record2.extensible !== "boolean") {
136802
- fail2("invalidType", `${path190}.extensible`, "expected boolean");
136802
+ fail2("invalidType", `${path191}.extensible`, "expected boolean");
136803
136803
  }
136804
136804
  if (typeof record2.lengthBeforeCallee !== "boolean") {
136805
- fail2("invalidType", `${path190}.lengthBeforeCallee`, "expected boolean");
136805
+ fail2("invalidType", `${path191}.lengthBeforeCallee`, "expected boolean");
136806
136806
  }
136807
- const properties = requireRecord3(record2.properties, `${path190}.properties`);
136807
+ const properties = requireRecord3(record2.properties, `${path191}.properties`);
136808
136808
  if (record2.iterator !== null) {
136809
- const iterator = requireRecord3(record2.iterator, `${path190}.iterator`);
136809
+ const iterator = requireRecord3(record2.iterator, `${path191}.iterator`);
136810
136810
  for (const key3 of Object.keys(iterator)) {
136811
136811
  if (!["configurable", "enumerable", "writable"].includes(key3)) {
136812
136812
  fail2(
136813
136813
  "invalidValue",
136814
- `${path190}.iterator${formatKey(key3)}`,
136814
+ `${path191}.iterator${formatKey(key3)}`,
136815
136815
  "unknown iterator descriptor field"
136816
136816
  );
136817
136817
  }
136818
136818
  }
136819
136819
  for (const flag of ["configurable", "enumerable", "writable"]) {
136820
136820
  if (typeof iterator[flag] !== "boolean")
136821
- fail2("invalidType", `${path190}.iterator.${flag}`, "expected boolean");
136821
+ fail2("invalidType", `${path191}.iterator.${flag}`, "expected boolean");
136822
136822
  }
136823
136823
  }
136824
136824
  if (record2.lengthBeforeCallee && !Object.hasOwn(properties, "length")) {
136825
- fail2("invalidValue", `${path190}.properties`, "initial length property is required");
136825
+ fail2("invalidValue", `${path191}.properties`, "initial length property is required");
136826
136826
  }
136827
136827
  for (const [key3, value] of Object.entries(properties)) {
136828
- const propertyPath = `${path190}.properties${formatKey(key3)}`;
136828
+ const propertyPath = `${path191}.properties${formatKey(key3)}`;
136829
136829
  if (key3 === "callee")
136830
136830
  fail2("invalidValue", propertyPath, "strict callee accessor cannot be replaced");
136831
136831
  const descriptor = requireRecord3(value, propertyPath);
@@ -136846,71 +136846,68 @@ function validateArgumentsProperties(record2, path190) {
136846
136846
  }
136847
136847
  }
136848
136848
  }
136849
- function validateGenericValue(value, path190, depth, state) {
136849
+ function validateGenericValue(value, path191, depth, state) {
136850
136850
  if (state.dataPropertiesOnly && types.isProxy(value)) {
136851
- fail2("invalidType", path190, "proxy objects are not snapshot data");
136851
+ fail2("invalidType", path191, "proxy objects are not snapshot data");
136852
136852
  }
136853
136853
  if (depth > state.limits.maxDepth)
136854
- fail2("budgetExceeded", path190, `exceeds nesting limit ${state.limits.maxDepth}`);
136854
+ fail2("budgetExceeded", path191, `exceeds nesting limit ${state.limits.maxDepth}`);
136855
136855
  state.entries += 1;
136856
136856
  if (state.entries > state.limits.maxAggregateEntries)
136857
136857
  fail2(
136858
136858
  "budgetExceeded",
136859
- path190,
136859
+ path191,
136860
136860
  `exceeds aggregate entry limit ${state.limits.maxAggregateEntries}`
136861
136861
  );
136862
136862
  if (typeof value === "string") {
136863
- requireString2(value, path190, state.limits);
136863
+ requireString2(value, path191, state.limits);
136864
136864
  state.dataSize += value.length;
136865
- } else if (typeof value === "number") {
136866
- if (Number.isInteger(value) && !Number.isSafeInteger(value))
136867
- fail2("invalidValue", path190, "integer must be safe");
136868
136865
  } else if (Array.isArray(value)) {
136869
- if (value.length > state.limits.maxEntries) fail2("budgetExceeded", path190, "array is too large");
136866
+ if (value.length > state.limits.maxEntries) fail2("budgetExceeded", path191, "array is too large");
136870
136867
  if (state.dataPropertiesOnly) {
136871
- const entries = snapshotDataEntries(value, path190).filter(([key3]) => key3 !== "length");
136868
+ const entries = snapshotDataEntries(value, path191).filter(([key3]) => key3 !== "length");
136872
136869
  if (entries.length !== value.length)
136873
- fail2("invalidType", path190, "snapshot arrays must be dense");
136870
+ fail2("invalidType", path191, "snapshot arrays must be dense");
136874
136871
  for (const [key3, entry] of entries) {
136875
136872
  const index = Number(key3);
136876
136873
  if (!Number.isInteger(index) || index < 0 || index >= value.length || String(index) !== key3) {
136877
- fail2("invalidType", path190, "snapshot arrays cannot have named properties");
136874
+ fail2("invalidType", path191, "snapshot arrays cannot have named properties");
136878
136875
  }
136879
- validateGenericValue(entry, `${path190}[${key3}]`, depth + 1, state);
136876
+ validateGenericValue(entry, `${path191}[${key3}]`, depth + 1, state);
136880
136877
  }
136881
136878
  } else {
136882
136879
  value.forEach(
136883
- (entry, index) => validateGenericValue(entry, `${path190}[${index}]`, depth + 1, state)
136880
+ (entry, index) => validateGenericValue(entry, `${path191}[${index}]`, depth + 1, state)
136884
136881
  );
136885
136882
  }
136886
136883
  } else if (value !== null && typeof value === "object") {
136887
136884
  const record2 = value;
136888
136885
  if (state.validateTaggedPayloads && isTaggedValueShape(record2)) {
136889
- validateTaggedValue(record2, path190, state);
136886
+ validateTaggedValue(record2, path191, state);
136890
136887
  }
136891
- const entries = state.dataPropertiesOnly ? snapshotDataEntries(value, path190) : Object.entries(value);
136888
+ const entries = state.dataPropertiesOnly ? snapshotDataEntries(value, path191) : Object.entries(value);
136892
136889
  for (const [key3, entry] of entries) {
136893
- requireString2(key3, `${path190}${formatKey(key3)}`, state.limits);
136890
+ requireString2(key3, `${path191}${formatKey(key3)}`, state.limits);
136894
136891
  state.dataSize += key3.length;
136895
- validateGenericValue(entry, `${path190}${formatKey(key3)}`, depth + 1, state);
136892
+ validateGenericValue(entry, `${path191}${formatKey(key3)}`, depth + 1, state);
136896
136893
  }
136897
136894
  } else if (!["boolean", "number"].includes(typeof value) && !(state.allowFunctions && typeof value === "function") && !(state.allowUndefined && value === void 0) && value !== null) {
136898
- fail2("invalidType", path190, "contains an unsupported value");
136895
+ fail2("invalidType", path191, "contains an unsupported value");
136899
136896
  }
136900
136897
  if (state.dataSize > state.limits.maxDataSize)
136901
- fail2("budgetExceeded", path190, `exceeds aggregate data limit ${state.limits.maxDataSize}`);
136898
+ fail2("budgetExceeded", path191, `exceeds aggregate data limit ${state.limits.maxDataSize}`);
136902
136899
  }
136903
- function snapshotDataEntries(value, path190) {
136900
+ function snapshotDataEntries(value, path191) {
136904
136901
  const prototype = Object.getPrototypeOf(value);
136905
136902
  if (prototype !== null && prototype !== (Array.isArray(value) ? Array.prototype : Object.prototype)) {
136906
- fail2("invalidType", path190, "snapshot data must not have a custom prototype");
136903
+ fail2("invalidType", path191, "snapshot data must not have a custom prototype");
136907
136904
  }
136908
136905
  if (Object.getOwnPropertySymbols(value).length > 0) {
136909
- fail2("invalidType", path190, "snapshot data must not have symbol properties");
136906
+ fail2("invalidType", path191, "snapshot data must not have symbol properties");
136910
136907
  }
136911
136908
  return Object.entries(Object.getOwnPropertyDescriptors(value)).map(([key3, descriptor]) => {
136912
136909
  if (!("value" in descriptor))
136913
- fail2("invalidType", `${path190}${formatKey(key3)}`, "snapshot data must not have accessors");
136910
+ fail2("invalidType", `${path191}${formatKey(key3)}`, "snapshot data must not have accessors");
136914
136911
  return [key3, descriptor.value];
136915
136912
  });
136916
136913
  }
@@ -136924,48 +136921,48 @@ function defaultLimits() {
136924
136921
  maxDataSize: DEFAULT_MAX_DATA_SIZE
136925
136922
  };
136926
136923
  }
136927
- function requireArray(value, path190, state) {
136928
- if (!Array.isArray(value)) fail2("invalidType", path190, "must be an array");
136924
+ function requireArray(value, path191, state) {
136925
+ if (!Array.isArray(value)) fail2("invalidType", path191, "must be an array");
136929
136926
  if (value.length > state.limits.maxEntries)
136930
- fail2("budgetExceeded", path190, `exceeds collection entry limit ${state.limits.maxEntries}`);
136927
+ fail2("budgetExceeded", path191, `exceeds collection entry limit ${state.limits.maxEntries}`);
136931
136928
  return value;
136932
136929
  }
136933
- function requireRecord3(value, path190) {
136930
+ function requireRecord3(value, path191) {
136934
136931
  if (typeof value !== "object" || value === null || Array.isArray(value))
136935
- fail2("invalidType", path190, "must be an object");
136932
+ fail2("invalidType", path191, "must be an object");
136936
136933
  return value;
136937
136934
  }
136938
- function requireSnapshotId(value, path190) {
136935
+ function requireSnapshotId(value, path191) {
136939
136936
  if (typeof value === "string") {
136940
- if (value.length === 0) fail2("invalidValue", path190, "id must not be empty");
136937
+ if (value.length === 0) fail2("invalidValue", path191, "id must not be empty");
136941
136938
  return value;
136942
136939
  }
136943
- return requireSafeInteger(value, path190, 0);
136940
+ return requireSafeInteger(value, path191, 0);
136944
136941
  }
136945
- function requireSafeInteger(value, path190, minimum) {
136942
+ function requireSafeInteger(value, path191, minimum) {
136946
136943
  if (typeof value !== "number" || !Number.isSafeInteger(value) || value < minimum)
136947
- fail2("invalidValue", path190, `must be a safe integer >= ${minimum}`);
136944
+ fail2("invalidValue", path191, `must be a safe integer >= ${minimum}`);
136948
136945
  return value;
136949
136946
  }
136950
- function requireNonEmptyString5(value, path190, limits) {
136951
- const text5 = requireString2(value, path190, limits);
136952
- if (text5.length === 0) fail2("invalidValue", path190, "must not be empty");
136947
+ function requireNonEmptyString5(value, path191, limits) {
136948
+ const text5 = requireString2(value, path191, limits);
136949
+ if (text5.length === 0) fail2("invalidValue", path191, "must not be empty");
136953
136950
  return text5;
136954
136951
  }
136955
- function requireString2(value, path190, limits) {
136956
- if (typeof value !== "string") fail2("invalidType", path190, "must be a string");
136952
+ function requireString2(value, path191, limits) {
136953
+ if (typeof value !== "string") fail2("invalidType", path191, "must be a string");
136957
136954
  if (value.length > limits.maxStringLength)
136958
- fail2("budgetExceeded", path190, `exceeds string limit ${limits.maxStringLength}`);
136955
+ fail2("budgetExceeded", path191, `exceeds string limit ${limits.maxStringLength}`);
136959
136956
  return value;
136960
136957
  }
136961
- function addUnique2(values, value, path190) {
136962
- if (values.has(value)) fail2("duplicateId", path190, `duplicate id ${String(value)}`);
136958
+ function addUnique2(values, value, path191) {
136959
+ if (values.has(value)) fail2("duplicateId", path191, `duplicate id ${String(value)}`);
136963
136960
  values.add(value);
136964
136961
  }
136965
- function parseHeapId(value, path190) {
136962
+ function parseHeapId(value, path191) {
136966
136963
  if (String(Number(value)) !== value)
136967
- fail2("invalidValue", path190, "heap key must be a canonical positive integer");
136968
- return requireSafeInteger(Number(value), path190, 1);
136964
+ fail2("invalidValue", path191, "heap key must be a canonical positive integer");
136965
+ return requireSafeInteger(Number(value), path191, 1);
136969
136966
  }
136970
136967
  function formatKey(key3) {
136971
136968
  return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key3) ? `.${key3}` : `[${JSON.stringify(key3)}]`;
@@ -136973,8 +136970,8 @@ function formatKey(key3) {
136973
136970
  function isTaggedValueShape(value) {
136974
136971
  return typeof value.kind === "string" && TAGGED_VALUE_KINDS.has(value.kind);
136975
136972
  }
136976
- function fail2(code, path190, detail) {
136977
- throw new SnapshotValidationError(code, path190, detail);
136973
+ function fail2(code, path191, detail) {
136974
+ throw new SnapshotValidationError(code, path191, detail);
136978
136975
  }
136979
136976
  var DEFAULT_MAX_DEPTH, DEFAULT_MAX_ENTRIES, DEFAULT_MAX_STRING_LENGTH, DEFAULT_MAX_DATA_SIZE, TAGGED_VALUE_KINDS, SnapshotValidationError;
136980
136977
  var init_validation = __esm({
@@ -137005,11 +137002,11 @@ var init_validation = __esm({
137005
137002
  SnapshotValidationError = class extends Error {
137006
137003
  code;
137007
137004
  path;
137008
- constructor(code, path190, detail) {
137009
- super(`Invalid snapshot at ${path190}: ${detail}`);
137005
+ constructor(code, path191, detail) {
137006
+ super(`Invalid snapshot at ${path191}: ${detail}`);
137010
137007
  this.name = "SnapshotValidationError";
137011
137008
  this.code = code;
137012
- this.path = path190;
137009
+ this.path = path191;
137013
137010
  replaceErrorStack(this);
137014
137011
  }
137015
137012
  };
@@ -137374,7 +137371,7 @@ var init_promise_replay = __esm({
137374
137371
  function encodeReplayData(value, options = {}) {
137375
137372
  const nodes = [];
137376
137373
  const seen = /* @__PURE__ */ new WeakMap();
137377
- const encode = (entry, depth, path190) => {
137374
+ const encode = (entry, depth, path191) => {
137378
137375
  if (depth > MAX_DATA_DEPTH) throw new TypeError("Replay data exceeds the nesting limit.");
137379
137376
  if (entry === null || typeof entry === "boolean" || typeof entry === "string") return entry;
137380
137377
  if (entry === void 0) return { tag: "undefined" };
@@ -137387,12 +137384,12 @@ function encodeReplayData(value, options = {}) {
137387
137384
  };
137388
137385
  }
137389
137386
  if (isSandboxPromise(entry)) {
137390
- const id2 = options.identifyPromise?.(entry, path190);
137387
+ const id2 = options.identifyPromise?.(entry, path191);
137391
137388
  if (typeof id2 === "string" && id2.length > 0) return { tag: "promise-capability", id: id2 };
137392
137389
  }
137393
137390
  let capabilityId;
137394
137391
  if (isSandboxClosure(entry)) {
137395
- capabilityId = options.identifyCapability?.(entry, path190);
137392
+ capabilityId = options.identifyCapability?.(entry, path191);
137396
137393
  if (typeof capabilityId !== "string" || capabilityId.length === 0)
137397
137394
  throw new MissingReplayCapabilityError("A callable needs an explicit resume capability.");
137398
137395
  if (!options.captureCapabilityProperties) return { tag: "capability", id: capabilityId };
@@ -137407,7 +137404,7 @@ function encodeReplayData(value, options = {}) {
137407
137404
  const id = nodes.length;
137408
137405
  seen.set(entry, id);
137409
137406
  nodes.push(void 0);
137410
- const child = (value2, key3) => encode(value2, depth + 1, [...path190, key3]);
137407
+ const child = (value2, key3) => encode(value2, depth + 1, [...path191, key3]);
137411
137408
  if (isSandboxClosure(entry)) {
137412
137409
  nodes[id] = {
137413
137410
  kind: "capability",
@@ -137725,8 +137722,8 @@ function restoreReplayCalls(input, encodedOutcomes, callbackSizes, requiredHostC
137725
137722
  }
137726
137723
  const resolveCapability = (id) => {
137727
137724
  if (!capabilities.has(id) && id.startsWith("host:")) {
137728
- const path190 = JSON.parse(id.slice(5));
137729
- if (!Array.isArray(path190) || path190.length < 2 || path190.some((value) => typeof value !== "string"))
137725
+ const path191 = JSON.parse(id.slice(5));
137726
+ if (!Array.isArray(path191) || path191.length < 2 || path191.some((value) => typeof value !== "string"))
137730
137727
  throw new TypeError("Invalid host capability identity.");
137731
137728
  requiredHostCapabilities.add(id);
137732
137729
  capabilities.set(
@@ -138125,8 +138122,8 @@ var init_host_call = __esm({
138125
138122
  if (!this.capabilityIds.has(closure)) this.capabilityIds.set(closure, identity);
138126
138123
  this.nativeClosures.set(native, closure);
138127
138124
  }
138128
- registerHostCapability(path190, closure, native) {
138129
- const identity = `host:${path190}`;
138125
+ registerHostCapability(path191, closure, native) {
138126
+ const identity = `host:${path191}`;
138130
138127
  const existing = this.capabilities.get(identity);
138131
138128
  if (existing !== void 0 && existing !== closure)
138132
138129
  throw new TypeError(`Conflicting replay capability '${identity}'.`);
@@ -140082,7 +140079,7 @@ function deepCopyFromSandbox(value, options = {}) {
140082
140079
  options
140083
140080
  );
140084
140081
  }
140085
- function copyToSandbox(value, state, path190 = "<root>", cloneSandboxCollections = false, depth = 0) {
140082
+ function copyToSandbox(value, state, path191 = "<root>", cloneSandboxCollections = false, depth = 0) {
140086
140083
  assertSandboxDataDepth(depth);
140087
140084
  if (isSandboxPrimitive(value)) {
140088
140085
  return value;
@@ -140098,8 +140095,8 @@ function copyToSandbox(value, state, path190 = "<root>", cloneSandboxCollections
140098
140095
  state.seen.set(value, copy);
140099
140096
  for (const [key3, entry] of value.entries) {
140100
140097
  copy.entries.set(
140101
- copyToSandbox(key3, state, `${path190}.<key>`, true, depth + 1),
140102
- copyToSandbox(entry, state, `${path190}.<value>`, true, depth + 1)
140098
+ copyToSandbox(key3, state, `${path191}.<key>`, true, depth + 1),
140099
+ copyToSandbox(entry, state, `${path191}.<value>`, true, depth + 1)
140103
140100
  );
140104
140101
  }
140105
140102
  return copy;
@@ -140111,7 +140108,7 @@ function copyToSandbox(value, state, path190 = "<root>", cloneSandboxCollections
140111
140108
  const copy = createSandboxSet();
140112
140109
  state.seen.set(value, copy);
140113
140110
  for (const entry of value.values) {
140114
- copy.values.add(copyToSandbox(entry, state, `${path190}.<value>`, true, depth + 1));
140111
+ copy.values.add(copyToSandbox(entry, state, `${path191}.<value>`, true, depth + 1));
140115
140112
  }
140116
140113
  return copy;
140117
140114
  }
@@ -140137,8 +140134,8 @@ function copyToSandbox(value, state, path190 = "<root>", cloneSandboxCollections
140137
140134
  state.seen.set(value, copy);
140138
140135
  for (const [key3, entry] of value) {
140139
140136
  copy.entries.set(
140140
- copyToSandbox(key3, state, `${path190}.<key>`, cloneSandboxCollections, depth + 1),
140141
- copyToSandbox(entry, state, `${path190}.<value>`, cloneSandboxCollections, depth + 1)
140137
+ copyToSandbox(key3, state, `${path191}.<key>`, cloneSandboxCollections, depth + 1),
140138
+ copyToSandbox(entry, state, `${path191}.<value>`, cloneSandboxCollections, depth + 1)
140142
140139
  );
140143
140140
  }
140144
140141
  return copy;
@@ -140152,7 +140149,7 @@ function copyToSandbox(value, state, path190 = "<root>", cloneSandboxCollections
140152
140149
  state.seen.set(value, copy);
140153
140150
  for (const entry of value) {
140154
140151
  copy.values.add(
140155
- copyToSandbox(entry, state, `${path190}.<value>`, cloneSandboxCollections, depth + 1)
140152
+ copyToSandbox(entry, state, `${path191}.<value>`, cloneSandboxCollections, depth + 1)
140156
140153
  );
140157
140154
  }
140158
140155
  return copy;
@@ -140164,14 +140161,14 @@ function copyToSandbox(value, state, path190 = "<root>", cloneSandboxCollections
140164
140161
  }
140165
140162
  const copy = new Array(value.length);
140166
140163
  state.seen.set(value, copy);
140167
- for (const entry of getEnumerableArrayEntries(value, path190)) {
140164
+ for (const entry of getEnumerableArrayEntries(value, path191)) {
140168
140165
  defineOwnDataProperty(
140169
140166
  copy,
140170
140167
  entry.key,
140171
140168
  copyToSandbox(
140172
140169
  entry.value,
140173
140170
  state,
140174
- joinArrayPath(path190, entry.key),
140171
+ joinArrayPath(path191, entry.key),
140175
140172
  cloneSandboxCollections,
140176
140173
  depth + 1
140177
140174
  )
@@ -140187,7 +140184,7 @@ function copyToSandbox(value, state, path190 = "<root>", cloneSandboxCollections
140187
140184
  copySandboxArgumentProperties(
140188
140185
  value,
140189
140186
  copy,
140190
- (entry, key3) => copyToSandbox(entry, state, joinPath(path190, key3), cloneSandboxCollections, depth + 1)
140187
+ (entry, key3) => copyToSandbox(entry, state, joinPath(path191, key3), cloneSandboxCollections, depth + 1)
140191
140188
  );
140192
140189
  return copy;
140193
140190
  }
@@ -140200,14 +140197,14 @@ function copyToSandbox(value, state, path190 = "<root>", cloneSandboxCollections
140200
140197
  state.seen.set(value, copy);
140201
140198
  const errorType = sandboxErrorTypes.get(value);
140202
140199
  if (errorType !== void 0) sandboxErrorTypes.set(copy, errorType);
140203
- for (const entry of getEnumerableObjectEntries(value, path190)) {
140200
+ for (const entry of getEnumerableObjectEntries(value, path191)) {
140204
140201
  defineOwnDataProperty(
140205
140202
  copy,
140206
140203
  entry.key,
140207
140204
  copyToSandbox(
140208
140205
  entry.value,
140209
140206
  state,
140210
- joinPath(path190, entry.key),
140207
+ joinPath(path191, entry.key),
140211
140208
  cloneSandboxCollections,
140212
140209
  depth + 1
140213
140210
  )
@@ -140215,9 +140212,9 @@ function copyToSandbox(value, state, path190 = "<root>", cloneSandboxCollections
140215
140212
  }
140216
140213
  return copy;
140217
140214
  }
140218
- throw new TypeError(`Unsupported sandbox value at ${path190}: ${describeValue(value)}`);
140215
+ throw new TypeError(`Unsupported sandbox value at ${path191}: ${describeValue(value)}`);
140219
140216
  }
140220
- function copyFromSandbox(value, state, path190 = "<root>", options, depth = 0) {
140217
+ function copyFromSandbox(value, state, path191 = "<root>", options, depth = 0) {
140221
140218
  assertSandboxDataDepth(depth);
140222
140219
  if (isSandboxPrimitive(value)) {
140223
140220
  return value;
@@ -140262,8 +140259,8 @@ function copyFromSandbox(value, state, path190 = "<root>", options, depth = 0) {
140262
140259
  state.seen.set(value, copy);
140263
140260
  for (const [key3, entry] of value.entries) {
140264
140261
  copy.set(
140265
- copyFromSandbox(key3, state, `${path190}.<key>`, options, depth + 1),
140266
- copyFromSandbox(entry, state, `${path190}.<value>`, options, depth + 1)
140262
+ copyFromSandbox(key3, state, `${path191}.<key>`, options, depth + 1),
140263
+ copyFromSandbox(entry, state, `${path191}.<value>`, options, depth + 1)
140267
140264
  );
140268
140265
  }
140269
140266
  return copy;
@@ -140276,7 +140273,7 @@ function copyFromSandbox(value, state, path190 = "<root>", options, depth = 0) {
140276
140273
  const copy = /* @__PURE__ */ new Set();
140277
140274
  state.seen.set(value, copy);
140278
140275
  for (const entry of value.values) {
140279
- copy.add(copyFromSandbox(entry, state, `${path190}.<value>`, options, depth + 1));
140276
+ copy.add(copyFromSandbox(entry, state, `${path191}.<value>`, options, depth + 1));
140280
140277
  }
140281
140278
  return copy;
140282
140279
  }
@@ -140287,11 +140284,11 @@ function copyFromSandbox(value, state, path190 = "<root>", options, depth = 0) {
140287
140284
  }
140288
140285
  const copy = new Array(value.length);
140289
140286
  state.seen.set(value, copy);
140290
- for (const entry of getEnumerableArrayEntries(value, path190)) {
140287
+ for (const entry of getEnumerableArrayEntries(value, path191)) {
140291
140288
  defineOwnDataProperty(
140292
140289
  copy,
140293
140290
  entry.key,
140294
- copyFromSandbox(entry.value, state, joinArrayPath(path190, entry.key), options, depth + 1)
140291
+ copyFromSandbox(entry.value, state, joinArrayPath(path191, entry.key), options, depth + 1)
140295
140292
  );
140296
140293
  }
140297
140294
  return copy;
@@ -140304,7 +140301,7 @@ function copyFromSandbox(value, state, path190 = "<root>", options, depth = 0) {
140304
140301
  copySandboxArgumentProperties(
140305
140302
  value,
140306
140303
  copy,
140307
- (entry, key3) => copyFromSandbox(entry, state, joinPath(path190, key3), options, depth + 1)
140304
+ (entry, key3) => copyFromSandbox(entry, state, joinPath(path191, key3), options, depth + 1)
140308
140305
  );
140309
140306
  return copy;
140310
140307
  }
@@ -140315,16 +140312,16 @@ function copyFromSandbox(value, state, path190 = "<root>", options, depth = 0) {
140315
140312
  }
140316
140313
  const copy = createPlainObject(Object.getPrototypeOf(value) === null);
140317
140314
  state.seen.set(value, copy);
140318
- for (const entry of getEnumerableObjectEntries(value, path190)) {
140315
+ for (const entry of getEnumerableObjectEntries(value, path191)) {
140319
140316
  defineOwnDataProperty(
140320
140317
  copy,
140321
140318
  entry.key,
140322
- copyFromSandbox(entry.value, state, joinPath(path190, entry.key), options, depth + 1)
140319
+ copyFromSandbox(entry.value, state, joinPath(path191, entry.key), options, depth + 1)
140323
140320
  );
140324
140321
  }
140325
140322
  return copy;
140326
140323
  }
140327
- throw new TypeError(`Unsupported sandbox value at ${path190}: ${describeValue(value)}`);
140324
+ throw new TypeError(`Unsupported sandbox value at ${path191}: ${describeValue(value)}`);
140328
140325
  }
140329
140326
  function isSandboxPrimitive(value) {
140330
140327
  return value === null || value === void 0 || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
@@ -140404,7 +140401,7 @@ function defineOwnDataProperty(target, key3, value) {
140404
140401
  value
140405
140402
  });
140406
140403
  }
140407
- function getEnumerableObjectEntries(value, path190) {
140404
+ function getEnumerableObjectEntries(value, path191) {
140408
140405
  const descriptors = Object.getOwnPropertyDescriptors(value);
140409
140406
  const entries = [];
140410
140407
  for (const [key3, descriptor] of Object.entries(descriptors)) {
@@ -140412,7 +140409,7 @@ function getEnumerableObjectEntries(value, path190) {
140412
140409
  continue;
140413
140410
  }
140414
140411
  if ("get" in descriptor || "set" in descriptor) {
140415
- throw new TypeError(`Unsupported sandbox value at ${joinPath(path190, key3)}: accessor property`);
140412
+ throw new TypeError(`Unsupported sandbox value at ${joinPath(path191, key3)}: accessor property`);
140416
140413
  }
140417
140414
  entries.push({
140418
140415
  key: key3,
@@ -140421,7 +140418,7 @@ function getEnumerableObjectEntries(value, path190) {
140421
140418
  }
140422
140419
  return entries;
140423
140420
  }
140424
- function getEnumerableArrayEntries(value, path190) {
140421
+ function getEnumerableArrayEntries(value, path191) {
140425
140422
  const descriptors = Object.getOwnPropertyDescriptors(value);
140426
140423
  const entries = [];
140427
140424
  for (const [key3, descriptor] of Object.entries(descriptors)) {
@@ -140430,7 +140427,7 @@ function getEnumerableArrayEntries(value, path190) {
140430
140427
  }
140431
140428
  if ("get" in descriptor || "set" in descriptor) {
140432
140429
  throw new TypeError(
140433
- `Unsupported sandbox value at ${joinArrayPath(path190, key3)}: accessor property`
140430
+ `Unsupported sandbox value at ${joinArrayPath(path191, key3)}: accessor property`
140434
140431
  );
140435
140432
  }
140436
140433
  entries.push({
@@ -140459,11 +140456,11 @@ function describeValue(value) {
140459
140456
  }
140460
140457
  return typeof value;
140461
140458
  }
140462
- function joinPath(path190, key3) {
140463
- return path190 === "<root>" ? `<root>.${key3}` : `${path190}.${key3}`;
140459
+ function joinPath(path191, key3) {
140460
+ return path191 === "<root>" ? `<root>.${key3}` : `${path191}.${key3}`;
140464
140461
  }
140465
- function joinArrayPath(path190, key3) {
140466
- return isArrayIndexKey(key3) ? `${path190}[${key3}]` : joinPath(path190, key3);
140462
+ function joinArrayPath(path191, key3) {
140463
+ return isArrayIndexKey(key3) ? `${path191}[${key3}]` : joinPath(path191, key3);
140467
140464
  }
140468
140465
  var sandboxClosureBrand, sandboxGeneratorBrand, sandboxMapBrand, sandboxPromiseBrand, sandboxRegexBrand, sandboxRegexPattern, sandboxSetBrand, sandboxRetainedValues;
140469
140466
  var init_values = __esm({
@@ -140601,10 +140598,102 @@ var init_random = __esm({
140601
140598
  }
140602
140599
  });
140603
140600
 
140601
+ // packages/safejs/src/snapshot/migration.ts
140602
+ function validateMigrationSemantics(value) {
140603
+ if (!["jobs-v1", "jobs-v2", "jobs-v3", "jobs-v4", "jobs-v5", "jobs-v6"].includes(value))
140604
+ throw new TypeError(
140605
+ "Migration requires a supported execution-semantics marker (jobs-v1 through jobs-v6)."
140606
+ );
140607
+ }
140608
+ function validateMigrationJournal(sourceHash, replay, hostCalls = []) {
140609
+ if (replay === void 0)
140610
+ throw new TypeError("Migration requires a complete host replay journal.");
140611
+ if (!Array.isArray(hostCalls)) throw new TypeError("Invalid migration hostCalls.");
140612
+ const journal = new HostCallJournal(sourceHash, hostCalls, void 0, replay);
140613
+ try {
140614
+ const restored = journal.snapshotReplay();
140615
+ for (const call of restored.calls) {
140616
+ if (["created", "running"].includes(call.lifecycle) && call.outcome !== void 0)
140617
+ throw new TypeError("Unresolved migration calls cannot contain a recorded outcome.");
140618
+ for (const callback of call.callbacks ?? []) {
140619
+ if (!call.functions?.includes(callback.id))
140620
+ throw new TypeError("Migration callback has no registered source function.");
140621
+ }
140622
+ }
140623
+ return restored;
140624
+ } finally {
140625
+ journal.dispose();
140626
+ }
140627
+ }
140628
+ function validateMigrationReconciliation(value, checkpointDigest, calls) {
140629
+ validateSnapshotData(value);
140630
+ const receipt = value;
140631
+ if (receipt === null || typeof receipt !== "object" || receipt.checkpointDigest !== checkpointDigest || !isCheckpointDigest(receipt.checkpointDigest))
140632
+ throw new TypeError("Migration reconciliation must identify this exact checkpoint digest.");
140633
+ if (receipt.quiescent !== true)
140634
+ throw new TypeError(
140635
+ "Migration requires explicit host confirmation that execution, operations, and callbacks are quiescent."
140636
+ );
140637
+ if (!Array.isArray(receipt.calls))
140638
+ throw new TypeError("Migration reconciliation calls must be an array.");
140639
+ const pending = new Map(
140640
+ calls.filter((call) => !["settled", "consumed"].includes(call.lifecycle)).map((call) => [call.id, call])
140641
+ );
140642
+ for (const resolution of receipt.calls) {
140643
+ if (resolution === null || typeof resolution !== "object" || !pending.has(resolution.callId))
140644
+ throw new TypeError("Migration contains an unknown or duplicate call resolution.");
140645
+ if (!["not-performed", "fulfilled", "rejected"].includes(resolution.disposition) || resolution.disposition === "fulfilled" && !Object.hasOwn(resolution, "value") || resolution.disposition === "rejected" && !Object.hasOwn(resolution, "reason"))
140646
+ throw new TypeError(
140647
+ "Migration call resolution requires a reconciled outcome or confirmed non-performance."
140648
+ );
140649
+ pending.delete(resolution.callId);
140650
+ }
140651
+ if (pending.size > 0)
140652
+ throw new TypeError(
140653
+ `Migration requires external reconciliation for: ${[...pending.keys()].join(", ")}`
140654
+ );
140655
+ }
140656
+ function validateSnapshotMigration(value, sourceHash) {
140657
+ if (value === void 0) return void 0;
140658
+ validateSnapshotData(value);
140659
+ const migration = value;
140660
+ if (migration === null || typeof migration !== "object" || migration.version !== 1 || !Array.isArray(migration.history) || migration.history.length === 0)
140661
+ throw new TypeError("Invalid snapshot migration history.");
140662
+ decodeReplayData(migration.state);
140663
+ let previousTarget;
140664
+ for (const entry of migration.history) {
140665
+ if (entry === null || typeof entry !== "object" || typeof entry.sourceHash !== "string" || entry.sourceHash.length === 0 || typeof entry.targetSourceHash !== "string" || entry.targetSourceHash.length === 0 || previousTarget !== void 0 && previousTarget !== entry.sourceHash)
140666
+ throw new TypeError("Invalid snapshot migration ancestry.");
140667
+ validateMigrationSemantics(entry.executionSemantics);
140668
+ const replay = validateMigrationJournal(entry.sourceHash, entry.replay);
140669
+ validateMigrationReconciliation(
140670
+ entry.reconciliation,
140671
+ entry.reconciliation?.checkpointDigest,
140672
+ replay.calls
140673
+ );
140674
+ previousTarget = entry.targetSourceHash;
140675
+ }
140676
+ if (previousTarget !== sourceHash)
140677
+ throw new TypeError("Migration ancestry does not match the target source.");
140678
+ return migration;
140679
+ }
140680
+ function isCheckpointDigest(value) {
140681
+ return typeof value === "string" && value.length === 64 && [...value].every((character2) => "0123456789abcdef".includes(character2));
140682
+ }
140683
+ var init_migration = __esm({
140684
+ "packages/safejs/src/snapshot/migration.ts"() {
140685
+ "use strict";
140686
+ init_host_call();
140687
+ init_replay_data();
140688
+ init_validation();
140689
+ }
140690
+ });
140691
+
140604
140692
  // packages/safejs/src/restore.ts
140605
140693
  function restore2(snapshot2, options) {
140606
140694
  assertSnapshotInactive(snapshot2);
140607
140695
  validateDumpEnvelope(snapshot2);
140696
+ validateSnapshotMigration(snapshot2.migration, snapshot2.sourceHash);
140608
140697
  if (snapshot2.executionSemantics !== EXECUTION_SEMANTICS && (snapshot2.executionSemantics !== void 0 || snapshot2.promiseReplay !== void 0 || snapshot2.replay !== void 0 || snapshot2.initialInputs !== void 0)) {
140609
140698
  throw new SnapshotValidationError(
140610
140699
  "unsupportedVersion",
@@ -140627,6 +140716,7 @@ var init_restore = __esm({
140627
140716
  init_validation();
140628
140717
  init_dump_format();
140629
140718
  init_running_state();
140719
+ init_migration();
140630
140720
  SnapshotMismatchError = class extends Error {
140631
140721
  actualHash;
140632
140722
  expectedHash;
@@ -141791,7 +141881,7 @@ function wrapHostPromiseWithSignal(promise, signal) {
141791
141881
  );
141792
141882
  });
141793
141883
  }
141794
- function copyHostValueToSandbox(value, stackFrames, options, state, path190) {
141884
+ function copyHostValueToSandbox(value, stackFrames, options, state, path191) {
141795
141885
  const { budget } = options;
141796
141886
  if (value === null || value === void 0 || typeof value === "number" || typeof value === "boolean") {
141797
141887
  return value;
@@ -141817,11 +141907,11 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path190) {
141817
141907
  return existing;
141818
141908
  }
141819
141909
  return wrapCallerInjectedFunction(
141820
- callable.name.length > 0 ? callable.name : readPathName(path190),
141910
+ callable.name.length > 0 ? callable.name : readPathName(path191),
141821
141911
  callable,
141822
141912
  {
141823
141913
  ...options,
141824
- operation: path190.startsWith("<root>") ? `${options.operation ?? "<root>"}${path190.slice(6)}` : path190
141914
+ operation: path191.startsWith("<root>") ? `${options.operation ?? "<root>"}${path191.slice(6)}` : path191
141825
141915
  },
141826
141916
  state
141827
141917
  );
@@ -141873,14 +141963,14 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path190) {
141873
141963
  const descriptor = Object.getOwnPropertyDescriptor(value, String(index));
141874
141964
  if (descriptor === void 0) continue;
141875
141965
  if (!("value" in descriptor)) {
141876
- throw new TypeError(`Unsupported sandbox value at ${path190}[${index}]: accessor property`);
141966
+ throw new TypeError(`Unsupported sandbox value at ${path191}[${index}]: accessor property`);
141877
141967
  }
141878
141968
  copy[index] = copyHostValueToSandbox(
141879
141969
  descriptor.value,
141880
141970
  stackFrames,
141881
141971
  { ...options, capabilityPath: [...options.capabilityPath ?? [], String(index)] },
141882
141972
  state,
141883
- `${path190}[${index}]`
141973
+ `${path191}[${index}]`
141884
141974
  );
141885
141975
  }
141886
141976
  return copy;
@@ -141901,14 +141991,14 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path190) {
141901
141991
  stackFrames,
141902
141992
  { ...options, capabilityPath: [...options.capabilityPath ?? [], `key:${ordinal}`] },
141903
141993
  state,
141904
- `${path190}.<key>`
141994
+ `${path191}.<key>`
141905
141995
  ),
141906
141996
  copyHostValueToSandbox(
141907
141997
  entry,
141908
141998
  stackFrames,
141909
141999
  { ...options, capabilityPath: [...options.capabilityPath ?? [], `value:${ordinal}`] },
141910
142000
  state,
141911
- `${path190}.<value>`
142001
+ `${path191}.<value>`
141912
142002
  )
141913
142003
  );
141914
142004
  }
@@ -141932,7 +142022,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path190) {
141932
142022
  capabilityPath: [...options.capabilityPath ?? [], String(copy.values.size)]
141933
142023
  },
141934
142024
  state,
141935
- `${path190}.<value>`
142025
+ `${path191}.<value>`
141936
142026
  )
141937
142027
  );
141938
142028
  }
@@ -141951,7 +142041,7 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path190) {
141951
142041
  }
141952
142042
  if ("get" in descriptor || "set" in descriptor) {
141953
142043
  throw new TypeError(
141954
- `Unsupported sandbox value at ${joinPath2(path190, key3)}: accessor property`
142044
+ `Unsupported sandbox value at ${joinPath2(path191, key3)}: accessor property`
141955
142045
  );
141956
142046
  }
141957
142047
  Object.defineProperty(copy, budget.allocateString(key3), {
@@ -141963,13 +142053,13 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path190) {
141963
142053
  stackFrames,
141964
142054
  { ...options, capabilityPath: [...options.capabilityPath ?? [], key3] },
141965
142055
  state,
141966
- joinPath2(path190, key3)
142056
+ joinPath2(path191, key3)
141967
142057
  )
141968
142058
  });
141969
142059
  }
141970
142060
  return copy;
141971
142061
  }
141972
- throw new TypeError(`Unsupported sandbox value at ${path190}: ${describeValue2(value)}`);
142062
+ throw new TypeError(`Unsupported sandbox value at ${path191}: ${describeValue2(value)}`);
141973
142063
  }
141974
142064
  function readAbortReason2(signal) {
141975
142065
  return signal.reason ?? createAbortError11();
@@ -142018,7 +142108,7 @@ function readStringProperty(value, key3) {
142018
142108
  const entry = value[key3];
142019
142109
  return typeof entry === "string" ? entry : void 0;
142020
142110
  }
142021
- function copyFunctionProperties(callable, stackFrames, options, state, path190) {
142111
+ function copyFunctionProperties(callable, stackFrames, options, state, path191) {
142022
142112
  const properties = {};
142023
142113
  for (const key3 of Object.getOwnPropertyNames(callable)) {
142024
142114
  const descriptor = Object.getOwnPropertyDescriptor(callable, key3);
@@ -142036,7 +142126,7 @@ function copyFunctionProperties(callable, stackFrames, options, state, path190)
142036
142126
  stackFrames,
142037
142127
  { ...options, capabilityPath: [...options.capabilityPath ?? [], key3] },
142038
142128
  state,
142039
- joinPath2(path190, key3)
142129
+ joinPath2(path191, key3)
142040
142130
  );
142041
142131
  }
142042
142132
  return Object.keys(properties).length > 0 ? properties : void 0;
@@ -142048,11 +142138,11 @@ function isPlainObject11(value) {
142048
142138
  const prototype = Object.getPrototypeOf(value);
142049
142139
  return prototype === Object.prototype || prototype === null;
142050
142140
  }
142051
- function joinPath2(path190, key3) {
142052
- return /^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(key3) ? `${path190}.${key3}` : `${path190}[${JSON.stringify(key3)}]`;
142141
+ function joinPath2(path191, key3) {
142142
+ return /^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(key3) ? `${path191}.${key3}` : `${path191}[${JSON.stringify(key3)}]`;
142053
142143
  }
142054
- function readPathName(path190) {
142055
- const segment = path190.replace(/^.*\./u, "");
142144
+ function readPathName(path191) {
142145
+ const segment = path191.replace(/^.*\./u, "");
142056
142146
  return segment === "<root>" ? "host" : segment;
142057
142147
  }
142058
142148
  function describeValue2(value) {
@@ -144536,15 +144626,15 @@ var init_scope = __esm({
144536
144626
  throw new ReferenceError(`Cannot assign to undeclared binding '${name}'.`);
144537
144627
  }
144538
144628
  const binding = scope.#bindings.get(name);
144539
- if (binding?.kind === "const") {
144540
- throw new TypeError(`Cannot assign to const binding '${name}'.`);
144541
- }
144542
144629
  if (binding === void 0) {
144543
144630
  throw new ReferenceError(`Cannot assign to undeclared binding '${name}'.`);
144544
144631
  }
144545
144632
  if (binding.value === uninitialized) {
144546
144633
  throw new ReferenceError(`Cannot access '${name}' before initialization.`);
144547
144634
  }
144635
+ if (binding.kind === "const") {
144636
+ throw new TypeError(`Cannot assign to const binding '${name}'.`);
144637
+ }
144548
144638
  scope.#bindings.set(name, {
144549
144639
  kind: binding.kind,
144550
144640
  value
@@ -145009,39 +145099,37 @@ async function evaluateAssignmentExpression(node, context) {
145009
145099
  )
145010
145100
  };
145011
145101
  }
145012
- const binding = context.scope.lookup(node.left.name);
145013
- if (!binding.found) {
145102
+ const binding = node.operator === "=" ? void 0 : context.scope.lookup(node.left.name);
145103
+ if (binding?.found === false) {
145014
145104
  throw new ReferenceError(`Cannot assign to undeclared binding '${node.left.name}'.`);
145015
145105
  }
145016
- if (binding.kind === "const") {
145017
- throw new TypeError(`Cannot assign to const '${node.left.name}'`);
145018
- }
145019
- if (node.operator === "&&=" && !isTruthy(binding.value)) {
145106
+ const current = binding?.value;
145107
+ if (node.operator === "&&=" && !isTruthy(current)) {
145020
145108
  return {
145021
145109
  kind: "normal",
145022
145110
  hasValue: true,
145023
- value: binding.value
145111
+ value: current
145024
145112
  };
145025
145113
  }
145026
- if (node.operator === "||=" && isTruthy(binding.value)) {
145114
+ if (node.operator === "||=" && isTruthy(current)) {
145027
145115
  return {
145028
145116
  kind: "normal",
145029
145117
  hasValue: true,
145030
- value: binding.value
145118
+ value: current
145031
145119
  };
145032
145120
  }
145033
- if (node.operator === "??=" && binding.value !== null && binding.value !== void 0) {
145121
+ if (node.operator === "??=" && current !== null && current !== void 0) {
145034
145122
  return {
145035
145123
  kind: "normal",
145036
145124
  hasValue: true,
145037
- value: binding.value
145125
+ value: current
145038
145126
  };
145039
145127
  }
145040
145128
  const right = await evaluateNode2(node.right, context);
145041
145129
  if (right.kind !== "normal") {
145042
145130
  return right;
145043
145131
  }
145044
- const value = node.operator === "=" || node.operator === "&&=" || node.operator === "||=" || node.operator === "??=" ? right.value : applyCompoundAssignmentOperator(node.operator, binding.value, right.value, context);
145132
+ const value = node.operator === "=" || node.operator === "&&=" || node.operator === "||=" || node.operator === "??=" ? right.value : await applyCompoundAssignmentOperator(node.operator, current, right.value, context);
145045
145133
  context.scope.assign(node.left.name, value);
145046
145134
  return {
145047
145135
  kind: "normal",
@@ -145063,45 +145151,33 @@ async function evaluateMemberAssignmentExpression(node, context) {
145063
145151
  if (member.kind === "nullish") {
145064
145152
  throw new TypeError("Cannot assign properties of null or undefined.");
145065
145153
  }
145066
- if (isSandboxRegex(member.object)) {
145067
- if (node.operator !== "=") {
145068
- throw new TypeError("RegExp properties only support direct assignment.");
145069
- }
145070
- const right2 = await evaluateNode2(node.right, context);
145071
- if (right2.kind !== "normal") return right2;
145072
- setRegexMember(member.object, member.property, right2.value);
145073
- return { kind: "normal", hasValue: true, value: right2.value };
145074
- }
145075
- if (!isIndexableSandboxValue(member.object)) {
145076
- throw new TypeError("Assignment expressions require a sandbox object property.");
145077
- }
145078
- if (node.operator === "&&=" && !isTruthy(getMemberValue(member.object, member.property, context))) {
145154
+ const current = node.operator === "=" ? void 0 : getPropertyValue(member.object, member.property, context);
145155
+ if (node.operator === "&&=" && !isTruthy(current)) {
145079
145156
  return {
145080
145157
  kind: "normal",
145081
145158
  hasValue: true,
145082
- value: getMemberValue(member.object, member.property, context)
145159
+ value: current
145083
145160
  };
145084
145161
  }
145085
- if (node.operator === "||=" && isTruthy(getMemberValue(member.object, member.property, context))) {
145162
+ if (node.operator === "||=" && isTruthy(current)) {
145086
145163
  return {
145087
145164
  kind: "normal",
145088
145165
  hasValue: true,
145089
- value: getMemberValue(member.object, member.property, context)
145166
+ value: current
145090
145167
  };
145091
145168
  }
145092
- if (node.operator === "??=" && getMemberValue(member.object, member.property, context) !== null && getMemberValue(member.object, member.property, context) !== void 0) {
145169
+ if (node.operator === "??=" && current !== null && current !== void 0) {
145093
145170
  return {
145094
145171
  kind: "normal",
145095
145172
  hasValue: true,
145096
- value: getMemberValue(member.object, member.property, context)
145173
+ value: current
145097
145174
  };
145098
145175
  }
145099
145176
  const right = await evaluateNode2(node.right, context);
145100
145177
  if (right.kind !== "normal") {
145101
145178
  return right;
145102
145179
  }
145103
- const current = getMemberValue(member.object, member.property, context);
145104
- const value = node.operator === "=" || node.operator === "&&=" || node.operator === "||=" || node.operator === "??=" ? right.value : applyCompoundAssignmentOperator(node.operator, current, right.value, context);
145180
+ const value = node.operator === "=" || node.operator === "&&=" || node.operator === "||=" || node.operator === "??=" ? right.value : await applyCompoundAssignmentOperator(node.operator, current, right.value, context);
145105
145181
  setSandboxProperty(member.object, member.property, value);
145106
145182
  return {
145107
145183
  kind: "normal",
@@ -146068,10 +146144,7 @@ async function evaluateIdentifierUpdateExpression(node, context) {
146068
146144
  )
146069
146145
  };
146070
146146
  }
146071
- if (binding.kind === "const") {
146072
- throw new TypeError(`Cannot assign to const '${node.argument.name}'`);
146073
- }
146074
- const current = Number(binding.value);
146147
+ const current = toNumber(await toNumericPrimitive(binding.value, context));
146075
146148
  const next = node.operator === "++" ? current + 1 : current - 1;
146076
146149
  context.scope.assign(node.argument.name, next);
146077
146150
  return {
@@ -146094,10 +146167,9 @@ async function evaluateMemberUpdateExpression(node, context) {
146094
146167
  if (member.kind === "nullish") {
146095
146168
  throw new TypeError("Cannot update properties of null or undefined.");
146096
146169
  }
146097
- if (!isIndexableSandboxValue(member.object)) {
146098
- throw new TypeError("Update expressions require a sandbox object property.");
146099
- }
146100
- const current = Number(getMemberValue(member.object, member.property, context));
146170
+ const current = toNumber(
146171
+ await toNumericPrimitive(getPropertyValue(member.object, member.property, context), context)
146172
+ );
146101
146173
  const next = node.operator === "++" ? current + 1 : current - 1;
146102
146174
  setSandboxProperty(member.object, member.property, next);
146103
146175
  return {
@@ -146108,93 +146180,32 @@ async function evaluateMemberUpdateExpression(node, context) {
146108
146180
  }
146109
146181
  async function evaluateMemberExpression(node, context) {
146110
146182
  const member = await evaluateMemberAccess(node, context);
146111
- if (member.kind === "error") {
146112
- return member;
146113
- }
146114
- if (member.kind === "completion") {
146115
- return member.result;
146116
- }
146183
+ if (member.kind === "error") return member;
146184
+ if (member.kind === "completion") return member.result;
146117
146185
  if (member.kind === "nullish") {
146118
- if (node.optional) {
146119
- return {
146120
- kind: "normal",
146121
- hasValue: true,
146122
- value: void 0
146123
- };
146124
- }
146186
+ if (node.optional) return { kind: "normal", hasValue: true, value: void 0 };
146125
146187
  throw new TypeError("Cannot read properties of null or undefined.");
146126
146188
  }
146127
- if (typeof member.object === "string") {
146128
- return {
146129
- kind: "normal",
146130
- hasValue: true,
146131
- value: getStringMember(member.object, member.property, context.budget)
146132
- };
146133
- }
146134
- if (typeof member.object === "number") {
146135
- return {
146136
- kind: "normal",
146137
- hasValue: true,
146138
- value: getNumberMember(member.object, member.property, context.budget)
146139
- };
146140
- }
146141
- if (Array.isArray(member.object)) {
146142
- return {
146143
- kind: "normal",
146144
- hasValue: true,
146145
- value: getArrayMemberValue(member.object, member.property, context)
146146
- };
146147
- }
146148
- if (isSandboxMap(member.object)) {
146149
- return {
146150
- kind: "normal",
146151
- hasValue: true,
146152
- value: getMapMember(member.object, member.property, createMapMethodOptions(context))
146153
- };
146154
- }
146155
- if (isSandboxSet(member.object)) {
146156
- return {
146157
- kind: "normal",
146158
- hasValue: true,
146159
- value: getSetMember(member.object, member.property, createSetMethodOptions(context))
146160
- };
146161
- }
146162
- if (isSandboxGenerator(member.object)) {
146163
- return {
146164
- kind: "normal",
146165
- hasValue: true,
146166
- value: getGeneratorMember(member.object, member.property, context.budget)
146167
- };
146168
- }
146169
- if (isSandboxClosure(member.object)) {
146170
- return {
146171
- kind: "normal",
146172
- hasValue: true,
146173
- value: getClosureMemberValue(member.object, member.property, context)
146174
- };
146175
- }
146176
- if (isSandboxPromise(member.object)) {
146177
- return {
146178
- kind: "normal",
146179
- hasValue: true,
146180
- value: getPromiseMember(member.property, context.budget)
146181
- };
146182
- }
146183
- if (isSandboxRegex(member.object)) {
146184
- return {
146185
- kind: "normal",
146186
- hasValue: true,
146187
- value: getRegexMember(member.object, member.property)
146188
- };
146189
- }
146190
- if (!isIndexableSandboxValue(member.object)) {
146191
- throw new TypeError("Attempted to read a property from a non-object value.");
146192
- }
146193
146189
  return {
146194
146190
  kind: "normal",
146195
146191
  hasValue: true,
146196
- value: getMemberValue(member.object, member.property, context)
146197
- };
146192
+ value: getPropertyValue(member.object, member.property, context)
146193
+ };
146194
+ }
146195
+ function getPropertyValue(target, property, context) {
146196
+ if (typeof target === "string") return getStringMember(target, property, context.budget);
146197
+ if (typeof target === "number") return getNumberMember(target, property, context.budget);
146198
+ if (typeof target === "boolean") return void 0;
146199
+ if (isSandboxMap(target)) return getMapMember(target, property, createMapMethodOptions(context));
146200
+ if (isSandboxSet(target)) return getSetMember(target, property, createSetMethodOptions(context));
146201
+ if (isSandboxGenerator(target)) return getGeneratorMember(target, property, context.budget);
146202
+ if (isSandboxClosure(target)) return getClosureMemberValue(target, property, context);
146203
+ if (isSandboxPromise(target)) return getPromiseMember(property, context.budget);
146204
+ if (isSandboxRegex(target)) return getRegexMember(target, property);
146205
+ if (!isIndexableSandboxValue(target)) {
146206
+ throw new TypeError("Attempted to read a property from a non-object value.");
146207
+ }
146208
+ return getMemberValue(target, property, context);
146198
146209
  }
146199
146210
  async function evaluateCallExpression(node, context) {
146200
146211
  if (node.callee.type === "MemberExpression") {
@@ -146671,7 +146682,9 @@ function applyBinaryOperator(node, left, right, context) {
146671
146682
  throw createError("UNSUPPORTED_NODE", node, "Binary operator 'in' is not supported.");
146672
146683
  }
146673
146684
  }
146674
- function applyCompoundAssignmentOperator(operator, left, right, context) {
146685
+ async function applyCompoundAssignmentOperator(operator, left, right, context) {
146686
+ left = await toNumericPrimitive(left, context);
146687
+ right = await toNumericPrimitive(right, context);
146675
146688
  switch (operator) {
146676
146689
  case "+=":
146677
146690
  return applyAdditionOperator(left, right, context);
@@ -146798,6 +146811,9 @@ async function toNumericPrimitive(value, context) {
146798
146811
  if (isIndexableSandboxValue(value)) {
146799
146812
  for (const methodName of ["valueOf", "toString"]) {
146800
146813
  const method = getMemberValue(value, methodName, context);
146814
+ if (methodName === "toString" && method === void 0 && !Object.hasOwn(value, methodName)) {
146815
+ return toString(value);
146816
+ }
146801
146817
  if (!isSandboxClosure(method)) {
146802
146818
  continue;
146803
146819
  }
@@ -146813,6 +146829,7 @@ async function toNumericPrimitive(value, context) {
146813
146829
  return result;
146814
146830
  }
146815
146831
  }
146832
+ throw new TypeError("Cannot convert object to primitive value.");
146816
146833
  }
146817
146834
  return toString(value);
146818
146835
  }
@@ -146867,17 +146884,30 @@ function getArrayMemberValue(target, property, context) {
146867
146884
  return getArrayMember(target, property, createArrayMethodOptions(context));
146868
146885
  }
146869
146886
  function setSandboxProperty(target, property, value) {
146887
+ if (isSandboxRegex(target)) {
146888
+ setRegexMember(target, property, value);
146889
+ return;
146890
+ }
146891
+ if (!isIndexableSandboxValue(target)) {
146892
+ throw new TypeError("Assignment expressions require a sandbox object property.");
146893
+ }
146894
+ const key3 = String(property);
146870
146895
  if (Array.isArray(target)) {
146871
146896
  assertCollectionMutable(target);
146872
- const key3 = String(property);
146873
146897
  if (key3 === "length" || isArrayIndexKey3(key3)) {
146874
146898
  target[key3] = value;
146875
146899
  return;
146876
146900
  }
146901
+ }
146902
+ const descriptor = Object.getOwnPropertyDescriptor(target, key3);
146903
+ if (descriptor !== void 0) {
146904
+ if (descriptor.writable !== true) {
146905
+ throw new TypeError(`Cannot assign to read only property '${key3}'.`);
146906
+ }
146907
+ Object.defineProperty(target, key3, { value });
146908
+ } else {
146877
146909
  defineSandboxProperty(target, key3, value);
146878
- return;
146879
146910
  }
146880
- defineSandboxProperty(target, String(property), value);
146881
146911
  }
146882
146912
  function deleteSandboxProperty(target, property) {
146883
146913
  if (Array.isArray(target)) {
@@ -147568,16 +147598,16 @@ async function writeSnapshotOnce(temporaryPath, snapshotPath, contents) {
147568
147598
  }
147569
147599
  }
147570
147600
  }
147571
- async function enqueueOperation(path190, operation) {
147572
- const previous = pendingOperations.get(path190) ?? Promise.resolve();
147601
+ async function enqueueOperation(path191, operation) {
147602
+ const previous = pendingOperations.get(path191) ?? Promise.resolve();
147573
147603
  const pending = previous.catch(() => void 0).then(operation);
147574
147604
  const queued = pending.catch(() => void 0);
147575
- pendingOperations.set(path190, queued);
147605
+ pendingOperations.set(path191, queued);
147576
147606
  try {
147577
147607
  await pending;
147578
147608
  } finally {
147579
- if (pendingOperations.get(path190) === queued) {
147580
- pendingOperations.delete(path190);
147609
+ if (pendingOperations.get(path191) === queued) {
147610
+ pendingOperations.delete(path191);
147581
147611
  }
147582
147612
  }
147583
147613
  }
@@ -147614,8 +147644,8 @@ var init_backend = __esm({
147614
147644
  LOCKED_FILE_ERROR_CODES = /* @__PURE__ */ new Set(["EACCES", "EBUSY", "EPERM"]);
147615
147645
  pendingOperations = /* @__PURE__ */ new Map();
147616
147646
  FileSnapshotBackend = class {
147617
- constructor(path190, options = {}) {
147618
- this.path = path190;
147647
+ constructor(path191, options = {}) {
147648
+ this.path = path191;
147619
147649
  this.#writeMaxAttempts = options.writeMaxAttempts ?? DEFAULT_WRITE_MAX_ATTEMPTS;
147620
147650
  this.#writeRetryDelayMs = options.writeRetryDelayMs ?? DEFAULT_WRITE_RETRY_DELAY_MS;
147621
147651
  }
@@ -147763,12 +147793,12 @@ var init_serialize = __esm({
147763
147793
  init_values();
147764
147794
  UnsnapshotableValueError = class extends Error {
147765
147795
  path;
147766
- constructor(path190) {
147796
+ constructor(path191) {
147767
147797
  super(
147768
147798
  "Cannot snapshot a generator suspended mid-iteration; drain or discard it before the await boundary."
147769
147799
  );
147770
147800
  this.name = "UnsnapshotableValueError";
147771
- this.path = path190;
147801
+ this.path = path191;
147772
147802
  }
147773
147803
  };
147774
147804
  }
@@ -147782,15 +147812,15 @@ function prepareReplayInputs(current, saved, preparePromise, onCapabilityRestore
147782
147812
  if (saved === void 0) {
147783
147813
  const snapshot2 = encodeReplayData(current, {
147784
147814
  captureCapabilityProperties: true,
147785
- identifyCapability: (closure, path190) => {
147786
- const id = identities.get(closure) ?? JSON.stringify(path190);
147815
+ identifyCapability: (closure, path191) => {
147816
+ const id = identities.get(closure) ?? JSON.stringify(path191);
147787
147817
  identities.set(closure, id);
147788
147818
  capabilities.set(id, closure);
147789
147819
  return id;
147790
147820
  },
147791
- identifyPromise: (promise, path190) => {
147821
+ identifyPromise: (promise, path191) => {
147792
147822
  if (preparePromise === void 0) return void 0;
147793
- const id = identities.get(promise) ?? JSON.stringify(path190);
147823
+ const id = identities.get(promise) ?? JSON.stringify(path191);
147794
147824
  identities.set(promise, id);
147795
147825
  if (!promises.has(id)) promises.set(id, preparePromise(promise, id));
147796
147826
  return id;
@@ -147805,11 +147835,11 @@ function prepareReplayInputs(current, saved, preparePromise, onCapabilityRestore
147805
147835
  };
147806
147836
  }
147807
147837
  const readCapability = (id) => {
147808
- const path190 = JSON.parse(id);
147809
- if (!Array.isArray(path190) || path190.length === 0 || path190.some((key3) => typeof key3 !== "string"))
147838
+ const path191 = JSON.parse(id);
147839
+ if (!Array.isArray(path191) || path191.length === 0 || path191.some((key3) => typeof key3 !== "string"))
147810
147840
  throw new TypeError("Invalid replay input capability path.");
147811
147841
  let value = current;
147812
- for (const key3 of path190) {
147842
+ for (const key3 of path191) {
147813
147843
  if (isSandboxMap(value)) {
147814
147844
  const [kind, ordinal] = key3.split(":");
147815
147845
  const index = Number(ordinal);
@@ -147960,6 +147990,17 @@ function run(source, options = {}) {
147960
147990
  }),
147961
147991
  ...createRegexGlobals()
147962
147992
  };
147993
+ const importMeta = deepCopyToSandbox(options.importMeta ?? {});
147994
+ if (restoredSnapshot?.migration !== void 0) {
147995
+ if (Object.hasOwn(importMeta, "migration"))
147996
+ throw new TypeError("import.meta.migration is reserved for migrated checkpoint state.");
147997
+ Object.defineProperty(importMeta, "migration", {
147998
+ value: decodeReplayData(restoredSnapshot.migration.state),
147999
+ enumerable: true,
148000
+ configurable: true,
148001
+ writable: true
148002
+ });
148003
+ }
147963
148004
  const initialInputs = prepareReplayInputs(
147964
148005
  {
147965
148006
  bindings: callerBindings,
@@ -147970,7 +148011,7 @@ function run(source, options = {}) {
147970
148011
  allowMissing: restoredSnapshot?.initialInputs !== void 0
147971
148012
  }),
147972
148013
  entryPointArgs: options.entryPointArgs === void 0 ? void 0 : deepCopyToSandbox([...options.entryPointArgs]),
147973
- importMeta: deepCopyToSandbox(options.importMeta ?? {})
148014
+ importMeta
147974
148015
  },
147975
148016
  restoredSnapshot?.initialInputs,
147976
148017
  (promise, id) => {
@@ -148035,6 +148076,7 @@ function run(source, options = {}) {
148035
148076
  });
148036
148077
  snapshotScheduler = activeSnapshotScheduler;
148037
148078
  createFailureSnapshot = () => createRunSnapshot({
148079
+ migration: restoredSnapshot?.migration,
148038
148080
  bindings: executionScope.snapshot().bindings,
148039
148081
  clock: options.clock,
148040
148082
  hostCalls: hostCalls.snapshot(),
@@ -148060,6 +148102,7 @@ function run(source, options = {}) {
148060
148102
  }
148061
148103
  const interpreterSnapshot2 = yieldPoint.snapshot();
148062
148104
  snapshot3 = createRunSnapshot({
148105
+ migration: restoredSnapshot?.migration,
148063
148106
  bindings: interpreterSnapshot2.bindings,
148064
148107
  clock: options.clock,
148065
148108
  hostCalls: hostCalls.snapshot(),
@@ -148101,6 +148144,7 @@ function run(source, options = {}) {
148101
148144
  }
148102
148145
  const interpreterSnapshot2 = yieldPoint.snapshot();
148103
148146
  snapshot3 = createRunSnapshot({
148147
+ migration: restoredSnapshot?.migration,
148104
148148
  bindings: interpreterSnapshot2.bindings,
148105
148149
  clock: options.clock,
148106
148150
  hostCalls: hostCalls.snapshot(),
@@ -148134,6 +148178,7 @@ function run(source, options = {}) {
148134
148178
  replayError = error3.message;
148135
148179
  }
148136
148180
  const snapshot2 = createRunSnapshot({
148181
+ migration: restoredSnapshot?.migration,
148137
148182
  bindings: executionScope.snapshot().bindings,
148138
148183
  clock: options.clock,
148139
148184
  hostCalls: hostCalls.snapshot(),
@@ -148303,6 +148348,7 @@ function createRunSnapshot(input) {
148303
148348
  version: DUMP_FORMAT_VERSION,
148304
148349
  executionSemantics: EXECUTION_SEMANTICS,
148305
148350
  sourceHash: input.sourceHash,
148351
+ ...input.migration === void 0 ? {} : { migration: structuredClone(input.migration) },
148306
148352
  bindings: input.bindings,
148307
148353
  clock: input.clock?.snapshot(),
148308
148354
  ...input.hostCalls === void 0 || input.hostCalls.length === 0 ? {} : { hostCalls: input.hostCalls },
@@ -148423,6 +148469,173 @@ var init_dump2 = __esm({
148423
148469
  }
148424
148470
  });
148425
148471
 
148472
+ // packages/safejs/src/migrate.ts
148473
+ import { createHash as createHash14 } from "node:crypto";
148474
+ function inspectSnapshotMigration(snapshot2, options) {
148475
+ assertSnapshotInactive(snapshot2);
148476
+ validateSnapshotData(snapshot2);
148477
+ validateDumpEnvelope(snapshot2);
148478
+ validateMigrationSemantics(snapshot2.executionSemantics);
148479
+ const sourceHash = hashSource(options.source);
148480
+ if (snapshot2.sourceHash !== sourceHash)
148481
+ throw new TypeError(
148482
+ `Migration requires the original executable source (checkpoint hash ${snapshot2.sourceHash}, supplied ${sourceHash}). Preserve the checkpoint; do not replace its hash.`
148483
+ );
148484
+ validateSnapshotMigration(snapshot2.migration, sourceHash);
148485
+ const replay = validateMigrationJournal(sourceHash, snapshot2.replay, snapshot2.hostCalls);
148486
+ return {
148487
+ checkpointDigest: createHash14("sha256").update(canonicalData(snapshot2)).digest("hex"),
148488
+ sourceHash,
148489
+ executionSemantics: snapshot2.executionSemantics,
148490
+ calls: replay.calls,
148491
+ unresolvedCalls: replay.calls.filter(
148492
+ (call) => !["settled", "consumed"].includes(call.lifecycle)
148493
+ )
148494
+ };
148495
+ }
148496
+ function migrateSnapshot(snapshot2, options) {
148497
+ if (!Object.hasOwn(options, "state"))
148498
+ throw new TypeError("Migration requires explicit application state.");
148499
+ const inspection = inspectSnapshotMigration(snapshot2, { source: options.source });
148500
+ parseModule(options.targetSource);
148501
+ const targetSourceHash = hashSource(options.targetSource);
148502
+ validateMigrationReconciliation(
148503
+ options.reconciliation,
148504
+ inspection.checkpointDigest,
148505
+ inspection.calls
148506
+ );
148507
+ const state = encodeReplayData(deepCopyToSandbox(options.state));
148508
+ const previous = snapshot2.migration;
148509
+ const migration = {
148510
+ version: 1,
148511
+ state,
148512
+ history: [
148513
+ ...structuredClone(previous?.history ?? []),
148514
+ {
148515
+ sourceHash: inspection.sourceHash,
148516
+ targetSourceHash,
148517
+ executionSemantics: inspection.executionSemantics,
148518
+ replay: { version: 1, calls: inspection.calls },
148519
+ reconciliation: structuredClone(options.reconciliation)
148520
+ }
148521
+ ]
148522
+ };
148523
+ validateSnapshotMigration(migration, targetSourceHash);
148524
+ return {
148525
+ version: DUMP_FORMAT_VERSION,
148526
+ executionSemantics: EXECUTION_SEMANTICS,
148527
+ sourceHash: targetSourceHash,
148528
+ bindings: {},
148529
+ replay: { version: 1, calls: [] },
148530
+ migration
148531
+ };
148532
+ }
148533
+ function canonicalData(value) {
148534
+ if (Array.isArray(value)) return `[${value.map(canonicalData).join(",")}]`;
148535
+ if (value !== null && typeof value === "object")
148536
+ return `{${Object.keys(value).sort().map(
148537
+ (key3) => `${JSON.stringify(key3)}:${canonicalData(value[key3])}`
148538
+ ).join(",")}}`;
148539
+ return JSON.stringify(value);
148540
+ }
148541
+ var init_migrate = __esm({
148542
+ "packages/safejs/src/migrate.ts"() {
148543
+ "use strict";
148544
+ init_running_state();
148545
+ init_values();
148546
+ init_hash();
148547
+ init_parser3();
148548
+ init_dump_format();
148549
+ init_migration();
148550
+ init_replay_data();
148551
+ init_validation();
148552
+ }
148553
+ });
148554
+
148555
+ // packages/safejs/src/migration-file.ts
148556
+ import { randomUUID as randomUUID51 } from "node:crypto";
148557
+ import { link as link3, open as open8, readFile as readFile53, unlink as unlink25 } from "node:fs/promises";
148558
+ import path184 from "node:path";
148559
+ async function migrateSnapshotFile(options) {
148560
+ const cwd = options.cwd ?? process.cwd();
148561
+ const resolvePath3 = (value, label) => {
148562
+ if (typeof value !== "string" || value.trim().length === 0)
148563
+ throw new TypeError(`Migration requires ${label}.`);
148564
+ return path184.resolve(cwd, value);
148565
+ };
148566
+ const snapshotPath = resolvePath3(options.snapshotPath, "a snapshot path");
148567
+ const sourcePath = resolvePath3(options.sourcePath, "--from <original.ajs>");
148568
+ if (options.inspect && [options.targetSourcePath, options.planPath, options.outputPath].some(
148569
+ (value) => value !== void 0
148570
+ ))
148571
+ throw new TypeError("Migration --inspect cannot be combined with --to, --plan, or --output.");
148572
+ const outputPath = options.inspect ? void 0 : resolvePath3(options.outputPath, "--output <new-checkpoint.json>");
148573
+ const targetSourcePath = options.inspect ? void 0 : resolvePath3(options.targetSourcePath, "--to <continuation.ajs>");
148574
+ const planPath = options.inspect ? void 0 : resolvePath3(options.planPath, "--plan <migration.json>");
148575
+ for (const filepath of [sourcePath, targetSourcePath]) {
148576
+ if (filepath !== void 0 && ![".ajs", ".safejs"].includes(path184.extname(filepath)))
148577
+ throw new TypeError(
148578
+ "Migration source paths must name executable .ajs or .safejs files, not harness Markdown."
148579
+ );
148580
+ }
148581
+ const snapshot2 = JSON.parse(await readFile53(snapshotPath, "utf8"));
148582
+ const source = await readFile53(sourcePath, "utf8");
148583
+ const inspection = inspectSnapshotMigration(snapshot2, { source });
148584
+ if (options.inspect) return { inspection };
148585
+ const plan = JSON.parse(await readFile53(planPath, "utf8"));
148586
+ if (plan === null || typeof plan !== "object" || !Object.hasOwn(plan, "state") || !Object.hasOwn(plan, "reconciliation"))
148587
+ throw new TypeError("Migration plan requires explicit state and reconciliation fields.");
148588
+ const targetSource = await readFile53(targetSourcePath, "utf8");
148589
+ const migrated = migrateSnapshot(snapshot2, {
148590
+ source,
148591
+ targetSource,
148592
+ state: plan.state,
148593
+ reconciliation: plan.reconciliation
148594
+ });
148595
+ const contents = serializeSafeJSSnapshot(migrated);
148596
+ if (!options.dryRun) {
148597
+ const temporaryPath = path184.join(
148598
+ path184.dirname(outputPath),
148599
+ `.safejs-migration-${randomUUID51()}.tmp`
148600
+ );
148601
+ let created = false;
148602
+ try {
148603
+ const handle = await open8(temporaryPath, "wx", 384);
148604
+ created = true;
148605
+ try {
148606
+ await handle.writeFile(contents, "utf8");
148607
+ await handle.sync();
148608
+ } finally {
148609
+ await handle.close();
148610
+ }
148611
+ try {
148612
+ await link3(temporaryPath, outputPath);
148613
+ } catch (error3) {
148614
+ if (hasOwnErrorCode29(error3, "EEXIST"))
148615
+ throw Object.assign(
148616
+ new Error(
148617
+ `Migration output already exists: ${JSON.stringify(outputPath)}. Choose a new output path; existing files are never overwritten.`,
148618
+ { cause: error3 }
148619
+ ),
148620
+ { code: "EEXIST" }
148621
+ );
148622
+ throw error3;
148623
+ }
148624
+ } finally {
148625
+ if (created) await unlink25(temporaryPath);
148626
+ }
148627
+ }
148628
+ return { inspection, outputPath, dryRun: options.dryRun === true };
148629
+ }
148630
+ var init_migration_file = __esm({
148631
+ "packages/safejs/src/migration-file.ts"() {
148632
+ "use strict";
148633
+ init_error_codes22();
148634
+ init_migrate();
148635
+ init_dump_format();
148636
+ }
148637
+ });
148638
+
148426
148639
  // packages/safejs/src/error/format.ts
148427
148640
  var init_format3 = __esm({
148428
148641
  "packages/safejs/src/error/format.ts"() {
@@ -148512,7 +148725,7 @@ var init_runtime_modules = __esm({
148512
148725
  });
148513
148726
 
148514
148727
  // packages/safejs/src/runner/run-harness.ts
148515
- import { readFile as readFile53, stat as stat34 } from "node:fs/promises";
148728
+ import { readFile as readFile54, stat as stat34 } from "node:fs/promises";
148516
148729
  import { extname } from "node:path";
148517
148730
  var init_run_harness = __esm({
148518
148731
  "packages/safejs/src/runner/run-harness.ts"() {
@@ -149606,9 +149819,9 @@ var init_fail = __esm({
149606
149819
 
149607
149820
  // packages/safejs/src/modules/canonical-path.ts
149608
149821
  import { basename as basename8, dirname as dirname13, isAbsolute as isAbsolute9, relative as relative7, resolve as resolve13, sep as sep6 } from "node:path";
149609
- async function resolveCanonicalPath({ realpath: realpath20, readlink: readlink5 }, path190) {
149822
+ async function resolveCanonicalPath({ realpath: realpath20, readlink: readlink5 }, path191) {
149610
149823
  const missingSegments = [];
149611
- let current = path190;
149824
+ let current = path191;
149612
149825
  let follows = 0;
149613
149826
  while (true) {
149614
149827
  try {
@@ -149621,23 +149834,23 @@ async function resolveCanonicalPath({ realpath: realpath20, readlink: readlink5
149621
149834
  const target = await readSymlinkTarget2(readlink5, current);
149622
149835
  if (target !== void 0) {
149623
149836
  if (++follows > MAX_SYMLINK_FOLLOWS) {
149624
- throw createLoopError(path190);
149837
+ throw createLoopError(path191);
149625
149838
  }
149626
149839
  current = isAbsolute9(target) ? resolve13(target) : resolve13(dirname13(current), target);
149627
149840
  continue;
149628
149841
  }
149629
149842
  const parent = dirname13(current);
149630
149843
  if (parent === current) {
149631
- return resolve13(path190);
149844
+ return resolve13(path191);
149632
149845
  }
149633
149846
  missingSegments.push(basename8(current));
149634
149847
  current = parent;
149635
149848
  }
149636
149849
  }
149637
149850
  }
149638
- async function readSymlinkTarget2(readlink5, path190) {
149851
+ async function readSymlinkTarget2(readlink5, path191) {
149639
149852
  try {
149640
- return await readlink5(path190);
149853
+ return await readlink5(path191);
149641
149854
  } catch (error3) {
149642
149855
  if (NOT_A_SYMLINK_CODES.includes(getOwnErrorCode2(error3) ?? "")) {
149643
149856
  return void 0;
@@ -149645,9 +149858,9 @@ async function readSymlinkTarget2(readlink5, path190) {
149645
149858
  throw error3;
149646
149859
  }
149647
149860
  }
149648
- function createLoopError(path190) {
149861
+ function createLoopError(path191) {
149649
149862
  const error3 = new Error(
149650
- `ELOOP: too many symbolic links encountered, realpath '${path190}'`
149863
+ `ELOOP: too many symbolic links encountered, realpath '${path191}'`
149651
149864
  );
149652
149865
  error3.code = "ELOOP";
149653
149866
  return error3;
@@ -149690,9 +149903,9 @@ async function descendsFromRoot(stat36, canonicalRoot, canonicalPath) {
149690
149903
  current = parent;
149691
149904
  }
149692
149905
  }
149693
- async function readIdentity(stat36, path190) {
149906
+ async function readIdentity(stat36, path191) {
149694
149907
  try {
149695
- const { dev, ino } = await stat36(path190);
149908
+ const { dev, ino } = await stat36(path191);
149696
149909
  return { dev, ino };
149697
149910
  } catch (error3) {
149698
149911
  if (MISSING_PATH_CODES.includes(getOwnErrorCode2(error3) ?? "")) {
@@ -149840,32 +150053,32 @@ async function resolvePathArguments(fs31, root, name, args) {
149840
150053
  return resolved;
149841
150054
  }
149842
150055
  const paths = FS_PATH_ARGUMENTS[name].map((_, index) => {
149843
- const path190 = readPath(canonicalRoot, args[index]);
149844
- resolved[index] = path190;
149845
- return path190;
150056
+ const path191 = readPath(canonicalRoot, args[index]);
150057
+ resolved[index] = path191;
150058
+ return path191;
149846
150059
  });
149847
150060
  await assertInsideRoot2(fs31, canonicalRoot, name, paths);
149848
150061
  return resolved;
149849
150062
  }
149850
150063
  async function assertInsideRoot2(fs31, canonicalRoot, name, paths) {
149851
- for (const path190 of paths) {
149852
- if (await escapesRoot(fs31, canonicalRoot, path190)) {
150064
+ for (const path191 of paths) {
150065
+ if (await escapesRoot(fs31, canonicalRoot, path191)) {
149853
150066
  throw createAccessDeniedError(name, paths[0], paths[1]);
149854
150067
  }
149855
150068
  }
149856
150069
  }
149857
- async function escapesRoot(fs31, canonicalRoot, path190) {
149858
- const canonicalPath = await resolveCanonicalPath(readCanonicalPathFs(fs31), path190);
150070
+ async function escapesRoot(fs31, canonicalRoot, path191) {
150071
+ const canonicalPath = await resolveCanonicalPath(readCanonicalPathFs(fs31), path191);
149859
150072
  return !await containsPath(readStat(fs31), canonicalRoot, canonicalPath);
149860
150073
  }
149861
150074
  function readCanonicalPathFs(fs31) {
149862
150075
  return {
149863
- realpath: async (path190) => await invoke(fs31, "realpath", [path190]),
149864
- readlink: async (path190) => await invoke(fs31, "readlink", [path190])
150076
+ realpath: async (path191) => await invoke(fs31, "realpath", [path191]),
150077
+ readlink: async (path191) => await invoke(fs31, "readlink", [path191])
149865
150078
  };
149866
150079
  }
149867
150080
  function readStat(fs31) {
149868
- return async (path190) => await invoke(fs31, "stat", [path190]);
150081
+ return async (path191) => await invoke(fs31, "stat", [path191]);
149869
150082
  }
149870
150083
  function assertSupportedPath(name, argument, value) {
149871
150084
  if (typeof value === "string") {
@@ -149916,19 +150129,19 @@ function describeReceivedValue(value) {
149916
150129
  return `type ${typeof value} (${inspect(value)})`;
149917
150130
  }
149918
150131
  function readPath(base, value) {
149919
- const path190 = value;
149920
- return isAbsolute10(path190) ? resolve14(path190) : resolve14(base, path190);
150132
+ const path191 = value;
150133
+ return isAbsolute10(path191) ? resolve14(path191) : resolve14(base, path191);
149921
150134
  }
149922
- function createAccessDeniedError(name, path190, dest) {
150135
+ function createAccessDeniedError(name, path191, dest) {
149923
150136
  const syscall = FS_SYSCALLS[name];
149924
- const target = dest === void 0 ? `'${path190}'` : `'${path190}' -> '${dest}'`;
150137
+ const target = dest === void 0 ? `'${path191}'` : `'${path191}' -> '${dest}'`;
149925
150138
  const error3 = new Error(
149926
150139
  `${ACCESS_DENIED_CODE}: ${ACCESS_DENIED_MESSAGE}, ${syscall} ${target}`
149927
150140
  );
149928
150141
  error3.code = ACCESS_DENIED_CODE;
149929
150142
  error3.errno = ACCESS_DENIED_ERRNO;
149930
150143
  error3.syscall = syscall;
149931
- error3.path = path190;
150144
+ error3.path = path191;
149932
150145
  if (dest !== void 0) {
149933
150146
  error3.dest = dest;
149934
150147
  }
@@ -150286,9 +150499,9 @@ function makeGitModule(cwd) {
150286
150499
  branch: normalizedBranch
150287
150500
  };
150288
150501
  },
150289
- async worktreeRemove(path190) {
150502
+ async worktreeRemove(path191) {
150290
150503
  const repoRoot = await getRepoRoot(normalizedCwd);
150291
- const worktreePath = await resolveWorktreePath(repoRoot, path190, "Git worktree path");
150504
+ const worktreePath = await resolveWorktreePath(repoRoot, path191, "Git worktree path");
150292
150505
  const worktrees = await listWorktrees2(normalizedCwd);
150293
150506
  if (!worktrees.some((worktree) => resolve15(worktree.path) === worktreePath)) {
150294
150507
  return;
@@ -150335,10 +150548,10 @@ function normalizeWorktreeCreateOptions(options) {
150335
150548
  throw new Error("Git worktree create options must be an object.");
150336
150549
  }
150337
150550
  const base = getOwnProperty8(options, "base");
150338
- const path190 = getOwnProperty8(options, "path");
150551
+ const path191 = getOwnProperty8(options, "path");
150339
150552
  return {
150340
150553
  base: base === void 0 ? "HEAD" : readNonEmptyString6(base, "Git worktree create options base"),
150341
- path: path190 === void 0 ? void 0 : readNonEmptyString6(path190, "Git worktree create options path")
150554
+ path: path191 === void 0 ? void 0 : readNonEmptyString6(path191, "Git worktree create options path")
150342
150555
  };
150343
150556
  }
150344
150557
  function createSavepointRef() {
@@ -150398,9 +150611,9 @@ function parseBranchRef(ref) {
150398
150611
  const branchPrefix = "refs/heads/";
150399
150612
  return ref.startsWith(branchPrefix) ? ref.slice(branchPrefix.length) : ref;
150400
150613
  }
150401
- async function resolveWorktreePath(repoRoot, path190, label) {
150614
+ async function resolveWorktreePath(repoRoot, path191, label) {
150402
150615
  const resolvedRoot = resolve15(repoRoot);
150403
- const resolvedPath = isAbsolute11(path190) ? resolve15(path190) : resolve15(resolvedRoot, path190);
150616
+ const resolvedPath = isAbsolute11(path191) ? resolve15(path191) : resolve15(resolvedRoot, path191);
150404
150617
  const canonicalRoot = await realpath19(resolvedRoot);
150405
150618
  const canonicalPath = await resolveCanonicalPath({ realpath: realpath19, readlink: readlink4 }, resolvedPath);
150406
150619
  const [inside, isRootItself] = await Promise.all([
@@ -150768,7 +150981,7 @@ var init_metric = __esm({
150768
150981
 
150769
150982
  // packages/safejs/src/modules/mcp-transport.ts
150770
150983
  import { spawn as spawn11 } from "node:child_process";
150771
- import path184 from "node:path";
150984
+ import path185 from "node:path";
150772
150985
  function parseMcpConfig3(source, directory) {
150773
150986
  const parsed = JSON.parse(source);
150774
150987
  const options = normalizeMcpOptions(parsed, [
@@ -150779,9 +150992,9 @@ function parseMcpConfig3(source, directory) {
150779
150992
  ]);
150780
150993
  for (const server of Object.values(options.servers)) {
150781
150994
  if ("command" in server) {
150782
- server.cwd = path184.resolve(directory, server.cwd ?? ".");
150995
+ server.cwd = path185.resolve(directory, server.cwd ?? ".");
150783
150996
  if (server.command.includes("/") || server.command.includes("\\")) {
150784
- server.command = path184.resolve(directory, server.command);
150997
+ server.command = path185.resolve(directory, server.command);
150785
150998
  }
150786
150999
  }
150787
151000
  }
@@ -151506,6 +151719,8 @@ var init_src49 = __esm({
151506
151719
  init_policy();
151507
151720
  init_dump2();
151508
151721
  init_restore();
151722
+ init_migrate();
151723
+ init_migration_file();
151509
151724
  init_validation();
151510
151725
  init_budget2();
151511
151726
  init_format3();
@@ -151647,9 +151862,9 @@ var init_extract_schema = __esm({
151647
151862
  });
151648
151863
 
151649
151864
  // packages/agent-harness/src/codegen/emit-schemas.ts
151650
- import { randomUUID as randomUUID51 } from "node:crypto";
151865
+ import { randomUUID as randomUUID52 } from "node:crypto";
151651
151866
  import * as nodeFs21 from "node:fs/promises";
151652
- import path185 from "node:path";
151867
+ import path186 from "node:path";
151653
151868
  import { fileURLToPath as fileURLToPath14 } from "node:url";
151654
151869
  var init_emit_schemas = __esm({
151655
151870
  "packages/agent-harness/src/codegen/emit-schemas.ts"() {
@@ -151707,23 +151922,23 @@ var init_pair = __esm({
151707
151922
  MissingPairError = class extends UserError {
151708
151923
  side;
151709
151924
  path;
151710
- constructor(side, path190) {
151925
+ constructor(side, path191) {
151711
151926
  super(
151712
- `Missing harness ${side} file: ${path190}
151927
+ `Missing harness ${side} file: ${path191}
151713
151928
  Run \`poe-code harness list\` to see available harnesses, or \`poe-code harness new <name>\` to scaffold this pair.`
151714
151929
  );
151715
151930
  this.side = side;
151716
- this.path = path190;
151931
+ this.path = path191;
151717
151932
  }
151718
151933
  };
151719
151934
  InvalidPairExtensionError = class extends Error {
151720
151935
  extension;
151721
151936
  path;
151722
- constructor(path190, extension) {
151723
- super(`Harness pair input must be a .md or .ajs file: ${path190}`);
151937
+ constructor(path191, extension) {
151938
+ super(`Harness pair input must be a .md or .ajs file: ${path191}`);
151724
151939
  this.name = "InvalidPairExtensionError";
151725
151940
  this.extension = extension;
151726
- this.path = path190;
151941
+ this.path = path191;
151727
151942
  }
151728
151943
  };
151729
151944
  }
@@ -151790,8 +152005,8 @@ function validateFrontmatter(schema, frontmatter, mdPath) {
151790
152005
  function formatIssues3(mdPath, issues) {
151791
152006
  return issues.map((issue2) => `${mdPath} (${formatPath4(issue2.path)}): ${issue2.message}`).join("\n");
151792
152007
  }
151793
- function formatPath4(path190) {
151794
- return path190.join(".") || "frontmatter";
152008
+ function formatPath4(path191) {
152009
+ return path191.join(".") || "frontmatter";
151795
152010
  }
151796
152011
  var FrontmatterValidationError;
151797
152012
  var init_validate4 = __esm({
@@ -151810,8 +152025,8 @@ var init_validate4 = __esm({
151810
152025
  });
151811
152026
 
151812
152027
  // packages/agent-harness/src/loader/run.ts
151813
- import { createHash as createHash14, randomUUID as randomUUID52 } from "node:crypto";
151814
- import { lstat as lstat34, mkdir as mkdir39, readFile as readFile55, rename as rename28, unlink as unlink25, writeFile as writeFile29 } from "node:fs/promises";
152028
+ import { createHash as createHash15, randomUUID as randomUUID53 } from "node:crypto";
152029
+ import { lstat as lstat34, mkdir as mkdir39, readFile as readFile56, rename as rename28, unlink as unlink26, writeFile as writeFile29 } from "node:fs/promises";
151815
152030
  import os25 from "node:os";
151816
152031
  import { dirname as dirname17, join as join17, parse as parse16, resolve as resolve16, sep as sep7 } from "node:path";
151817
152032
  async function runHarnessPair2(mdPath, options) {
@@ -151932,7 +152147,9 @@ async function runHarnessPair2(mdPath, options) {
151932
152147
  throw error3;
151933
152148
  }
151934
152149
  await hostCallReplay.flush();
151935
- if (result.ok && options.preserveSnapshotOnSuccess !== true) {
152150
+ if (result.ok && result.snapshot.migration !== void 0) {
152151
+ await snapshotBackend.write(result.snapshot);
152152
+ } else if (result.ok && options.preserveSnapshotOnSuccess !== true) {
151936
152153
  await cleanupCompletedSnapshot(snapshotBackend, snapshotPath);
151937
152154
  }
151938
152155
  const usage = usageAccumulator.snapshot();
@@ -152141,7 +152358,7 @@ async function createHostCallReplay(snapshotPath, statefulBindings = {}, opts =
152141
152358
  }
152142
152359
  async function readHostCallRecords(storePath) {
152143
152360
  try {
152144
- const parsed = JSON.parse(await readFile55(storePath, "utf8"));
152361
+ const parsed = JSON.parse(await readFile56(storePath, "utf8"));
152145
152362
  return Array.isArray(parsed) ? parsed : [];
152146
152363
  } catch (error3) {
152147
152364
  if (hasErrorCode6(error3, "ENOENT")) {
@@ -152161,7 +152378,7 @@ async function writeHostCallRecords(storePath, records) {
152161
152378
  await writeTextFileAtomically2(storePath, serialized);
152162
152379
  }
152163
152380
  async function writeTextFileAtomically2(filePath, content) {
152164
- const temporaryPath = `${filePath}.${process.pid}.${randomUUID52()}.tmp`;
152381
+ const temporaryPath = `${filePath}.${process.pid}.${randomUUID53()}.tmp`;
152165
152382
  let temporaryCreated = false;
152166
152383
  try {
152167
152384
  await writeFile29(temporaryPath, content, { encoding: "utf8", flag: "wx" });
@@ -152177,9 +152394,9 @@ async function writeTextFileAtomically2(filePath, content) {
152177
152394
  async function cleanupCompletedSnapshot(snapshotBackend, snapshotPath) {
152178
152395
  await Promise.all([snapshotBackend.remove(), unlinkIfExists(hostCallStorePath(snapshotPath))]);
152179
152396
  }
152180
- async function unlinkIfExists(path190) {
152397
+ async function unlinkIfExists(path191) {
152181
152398
  try {
152182
- await unlink25(path190);
152399
+ await unlink26(path191);
152183
152400
  } catch (error3) {
152184
152401
  if (!hasErrorCode6(error3, "ENOENT")) {
152185
152402
  throw error3;
@@ -152215,7 +152432,7 @@ function listModuleExports(moduleExports) {
152215
152432
  return exportNames.filter((exportName) => exportName.length > 0).sort((left, right) => left.localeCompare(right));
152216
152433
  }
152217
152434
  function resolveSnapshotPath(mdPath, snapshotPath) {
152218
- const documentKey = createHash14("sha256").update(resolve16(mdPath)).digest("hex").slice(0, 12);
152435
+ const documentKey = createHash15("sha256").update(resolve16(mdPath)).digest("hex").slice(0, 12);
152219
152436
  return snapshotPath ?? join17(
152220
152437
  resolveRunLogDir({
152221
152438
  planPath: mdPath,
@@ -152243,8 +152460,8 @@ async function assertDefaultSnapshotPathIsRegular(snapshotPath) {
152243
152460
  }
152244
152461
  }
152245
152462
  }
152246
- async function readTextFile(path190) {
152247
- const source = await readFile55(path190, "utf8");
152463
+ async function readTextFile(path191) {
152464
+ const source = await readFile56(path191, "utf8");
152248
152465
  return source.startsWith("\uFEFF") ? source.slice(1) : source;
152249
152466
  }
152250
152467
  function formatLintErrorMessage(diagnostics) {
@@ -152302,7 +152519,7 @@ var init_run8 = __esm({
152302
152519
  });
152303
152520
 
152304
152521
  // packages/agent-harness/src/testing/replay-equivalence.ts
152305
- import { mkdir as mkdir40, readFile as readFile56, rm as rm17, writeFile as writeFile30 } from "node:fs/promises";
152522
+ import { mkdir as mkdir40, readFile as readFile57, rm as rm17, writeFile as writeFile30 } from "node:fs/promises";
152306
152523
  import os26 from "node:os";
152307
152524
  import { join as join18 } from "node:path";
152308
152525
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
@@ -152399,8 +152616,8 @@ var init_harness_spawn_retry = __esm({
152399
152616
  });
152400
152617
 
152401
152618
  // src/cli/commands/harness.ts
152402
- import path186 from "node:path";
152403
- import { readFile as readFile57 } from "node:fs/promises";
152619
+ import path187 from "node:path";
152620
+ import { readFile as readFile58 } from "node:fs/promises";
152404
152621
  import { Argument } from "commander";
152405
152622
  function registerHarnessCommand(program, container) {
152406
152623
  const harness = program.command("harness").description("Run and manage agent harness pairs.");
@@ -152426,6 +152643,26 @@ function registerHarnessCommand(program, container) {
152426
152643
  await executeHarnessRun(program, container, mdPath, options);
152427
152644
  }
152428
152645
  });
152646
+ harness.command("migrate").description("Inspect or explicitly migrate a checkpoint to continuation source.").argument("<snapshot-path>", "Original checkpoint JSON; never overwritten").requiredOption("--from <path>", "Original executable .ajs source").option("--inspect", "Inspect identities and unresolved calls without writing").option("--to <path>", "New continuation .ajs source").option("--plan <path>", "JSON application state and digest-bound reconciliation").option("--output <path>", "New checkpoint path; must not already exist").action(
152647
+ async (snapshotPath, options) => {
152648
+ const flags = resolveHarnessFlags(program, void 0);
152649
+ const result = await withSpinner({
152650
+ message: options.inspect ? "Inspecting checkpoint" : "Validating checkpoint migration",
152651
+ fn: () => migrateSnapshotFile({
152652
+ snapshotPath,
152653
+ sourcePath: options.from,
152654
+ targetSourcePath: options.to,
152655
+ planPath: options.plan,
152656
+ outputPath: options.output,
152657
+ inspect: options.inspect,
152658
+ dryRun: flags.dryRun,
152659
+ cwd: container.env.cwd
152660
+ })
152661
+ });
152662
+ process.stdout.write(`${JSON.stringify(result, null, 2)}
152663
+ `);
152664
+ }
152665
+ );
152429
152666
  harness.command("new").description("Scaffold a harness pair from a built-in template.").addArgument(new Argument("<kind>", "Built-in template kind").choices(builtinKinds())).argument("<basename>", "New harness basename").option("--dir <path>", "Output directory for the harness pair").option("-y, --yes", "Accept defaults without prompting.").action(async (kind, basename10, options) => {
152430
152667
  await executeHarnessNew(program, container, kind, basename10, options);
152431
152668
  });
@@ -152441,20 +152678,20 @@ async function executeHarnessRun(program, container, mdPath, options) {
152441
152678
  if (options.envConfig !== void 0) {
152442
152679
  if (options.envConfig.trim().length === 0)
152443
152680
  throw new ValidationError("--env-config needs a JSON file path.");
152444
- const configPath = path186.resolve(container.env.cwd, options.envConfig);
152681
+ const configPath = path187.resolve(container.env.cwd, options.envConfig);
152445
152682
  envOptions = parseEnvConfig(await container.fs.readFile(configPath, "utf8"));
152446
152683
  }
152447
152684
  let mcpOptions;
152448
152685
  if (options.mcpConfig !== void 0) {
152449
152686
  if (options.mcpConfig.trim().length === 0)
152450
152687
  throw new ValidationError("--mcp-config needs a JSON file path.");
152451
- const configPath = path186.resolve(container.env.cwd, options.mcpConfig);
152688
+ const configPath = path187.resolve(container.env.cwd, options.mcpConfig);
152452
152689
  mcpOptions = parseMcpConfig3(
152453
152690
  await container.fs.readFile(configPath, "utf8"),
152454
- path186.dirname(configPath)
152691
+ path187.dirname(configPath)
152455
152692
  );
152456
152693
  }
152457
- const selectedPath = mdPath ? path186.resolve(container.env.cwd, mdPath) : (await resolveDiscoveredHarness(container, options.dir, flags.assumeYes)).mdPath;
152694
+ const selectedPath = mdPath ? path187.resolve(container.env.cwd, mdPath) : (await resolveDiscoveredHarness(container, options.dir, flags.assumeYes)).mdPath;
152458
152695
  if (flags.dryRun) {
152459
152696
  await resolvePair(selectedPath, container.fs);
152460
152697
  resources.logger.dryRun(
@@ -152462,7 +152699,7 @@ async function executeHarnessRun(program, container, mdPath, options) {
152462
152699
  );
152463
152700
  if (fsOptions !== void 0) {
152464
152701
  resources.logger.dryRun(
152465
- `Dry run: would enable the fs module rooted at ${formatDisplayPath3(container, resolveFsRoot(fsOptions, path186.dirname(selectedPath)))}.`
152702
+ `Dry run: would enable the fs module rooted at ${formatDisplayPath3(container, resolveFsRoot(fsOptions, path187.dirname(selectedPath)))}.`
152466
152703
  );
152467
152704
  }
152468
152705
  return;
@@ -152578,9 +152815,9 @@ async function resolveHarnessWorktreeAgent(container, selectedPath, options) {
152578
152815
  );
152579
152816
  }
152580
152817
  function mapSourcePathIntoWorktree3(sourceCwd, sourcePath, worktreeCwd) {
152581
- const relativePath = path186.relative(sourceCwd, sourcePath);
152582
- if (relativePath === "" || !relativePath.startsWith("..") && !path186.isAbsolute(relativePath)) {
152583
- return path186.join(worktreeCwd, relativePath);
152818
+ const relativePath = path187.relative(sourceCwd, sourcePath);
152819
+ if (relativePath === "" || !relativePath.startsWith("..") && !path187.isAbsolute(relativePath)) {
152820
+ return path187.join(worktreeCwd, relativePath);
152584
152821
  }
152585
152822
  return sourcePath;
152586
152823
  }
@@ -152731,10 +152968,10 @@ function buildAgentFrontmatterOverrides(options) {
152731
152968
  }
152732
152969
  function resolveRunSnapshotPath(container, mdPath, snapshotPath) {
152733
152970
  if (snapshotPath !== void 0) {
152734
- return path186.resolve(container.env.cwd, snapshotPath);
152971
+ return path187.resolve(container.env.cwd, snapshotPath);
152735
152972
  }
152736
- const basename10 = path186.basename(mdPath, path186.extname(mdPath));
152737
- return path186.join(container.env.cwd, ".poe-code", "harnesses", basename10, "snapshot.json");
152973
+ const basename10 = path187.basename(mdPath, path187.extname(mdPath));
152974
+ return path187.join(container.env.cwd, ".poe-code", "harnesses", basename10, "snapshot.json");
152738
152975
  }
152739
152976
  async function prepareHarnessSnapshot(container, mdPath, snapshotPath, resumeRequested) {
152740
152977
  const snapshotExists = await pathExists17(container, snapshotPath);
@@ -152803,8 +153040,8 @@ function formatRunMessage(baseMessage, progress) {
152803
153040
  return progress === void 0 ? baseMessage : `${baseMessage} (${progress})`;
152804
153041
  }
152805
153042
  function resolveAjsPath(mdPath) {
152806
- const parsed = path186.parse(mdPath);
152807
- return path186.join(parsed.dir, `${parsed.name}.ajs`);
153043
+ const parsed = path187.parse(mdPath);
153044
+ return path187.join(parsed.dir, `${parsed.name}.ajs`);
152808
153045
  }
152809
153046
  async function pathExists17(container, targetPath) {
152810
153047
  try {
@@ -152830,16 +153067,16 @@ async function executeHarnessNew(program, container, kind, basename10, options)
152830
153067
  `Unknown harness template "${kind}". Available kinds: ${builtinKinds().join(", ")}.`
152831
153068
  );
152832
153069
  }
152833
- if (basename10.length === 0 || basename10 === "." || basename10 === ".." || path186.basename(basename10) !== basename10) {
153070
+ if (basename10.length === 0 || basename10 === "." || basename10 === ".." || path187.basename(basename10) !== basename10) {
152834
153071
  throw new ValidationError(
152835
153072
  `Invalid harness basename "${basename10}". Use a single directory name.`
152836
153073
  );
152837
153074
  }
152838
- const defaultDir = path186.join(".poe-code", "harnesses", basename10);
153075
+ const defaultDir = path187.join(".poe-code", "harnesses", basename10);
152839
153076
  const outputDir = options.dir ?? await resolveOutputDir(defaultDir, flags.assumeYes);
152840
- const resolvedDir = path186.resolve(container.env.cwd, outputDir);
152841
- const mdPath = path186.join(resolvedDir, `${basename10}.md`);
152842
- const ajsPath = path186.join(resolvedDir, `${basename10}.ajs`);
153077
+ const resolvedDir = path187.resolve(container.env.cwd, outputDir);
153078
+ const mdPath = path187.join(resolvedDir, `${basename10}.md`);
153079
+ const ajsPath = path187.join(resolvedDir, `${basename10}.ajs`);
152843
153080
  await assertFilesDoNotExist(container, [mdPath, ajsPath]);
152844
153081
  if (flags.dryRun) {
152845
153082
  resources.logger.dryRun(`Would create ${formatDisplayPath3(container, mdPath)}`);
@@ -152847,8 +153084,8 @@ async function executeHarnessNew(program, container, kind, basename10, options)
152847
153084
  return;
152848
153085
  }
152849
153086
  const [mdSource, ajsSource] = await Promise.all([
152850
- readFile57(template2.mdPath, "utf8"),
152851
- readFile57(template2.ajsPath, "utf8")
153087
+ readFile58(template2.mdPath, "utf8"),
153088
+ readFile58(template2.ajsPath, "utf8")
152852
153089
  ]);
152853
153090
  await container.fs.mkdir(resolvedDir, { recursive: true });
152854
153091
  const createdPaths = [];
@@ -152957,10 +153194,10 @@ async function resolveDiscoveredHarness(container, dir, assumeYes) {
152957
153194
  }
152958
153195
  function harnessDiscoveryRoots(container, dir) {
152959
153196
  const roots = [
152960
- path186.join(container.env.cwd, ".poe-code", "harnesses"),
152961
- path186.join(container.env.homeDir, ".poe-code", "harnesses")
153197
+ path187.join(container.env.cwd, ".poe-code", "harnesses"),
153198
+ path187.join(container.env.homeDir, ".poe-code", "harnesses")
152962
153199
  ];
152963
- return dir === void 0 ? roots : [path186.resolve(container.env.cwd, dir), ...roots];
153200
+ return dir === void 0 ? roots : [path187.resolve(container.env.cwd, dir), ...roots];
152964
153201
  }
152965
153202
  function formatSearchedRoots(container, dir) {
152966
153203
  return harnessDiscoveryRoots(container, dir).map((root) => formatDisplayPath3(container, root)).join(", ");
@@ -152982,7 +153219,7 @@ async function discoverPairsDirectlyIn(container, root) {
152982
153219
  for (const entry of entries.filter((name) => name.endsWith(".md")).sort()) {
152983
153220
  try {
152984
153221
  pairs.push(
152985
- await resolvePair(path186.join(root, entry), container.fs)
153222
+ await resolvePair(path187.join(root, entry), container.fs)
152986
153223
  );
152987
153224
  } catch (error3) {
152988
153225
  if (error3 instanceof MissingPairError) {
@@ -153004,7 +153241,7 @@ async function discoverProjectThenUserHarnesses(container, dir) {
153004
153241
  const stat36 = await container.fs.stat(pair.mdPath);
153005
153242
  discovered.push({
153006
153243
  ...pair,
153007
- dir: path186.dirname(pair.mdPath),
153244
+ dir: path187.dirname(pair.mdPath),
153008
153245
  mdMtimeMs: stat36.mtimeMs
153009
153246
  });
153010
153247
  }
@@ -153060,7 +153297,7 @@ function resolveHarnessFsOptions(container, options) {
153060
153297
  "--fs-root needs a directory path. Pass --fs-root <path> to confine the harness to that directory, or drop --fs-root to confine it to the harness directory."
153061
153298
  );
153062
153299
  }
153063
- return { root: path186.resolve(container.env.cwd, options.fsRoot) };
153300
+ return { root: path187.resolve(container.env.cwd, options.fsRoot) };
153064
153301
  }
153065
153302
  function resolveFsRoot(fsOptions, harnessDir) {
153066
153303
  return fsOptions.root ?? harnessDir;
@@ -153220,8 +153457,8 @@ function toModuleExports(moduleExports) {
153220
153457
  return new Map(Object.entries(moduleExports));
153221
153458
  }
153222
153459
  function formatDisplayPath3(container, filePath) {
153223
- const relative8 = path186.relative(container.env.cwd, filePath);
153224
- return relative8.length > 0 && !relative8.startsWith("..") && !path186.isAbsolute(relative8) ? relative8 : filePath.replace(container.env.homeDir, "~");
153460
+ const relative8 = path187.relative(container.env.cwd, filePath);
153461
+ return relative8.length > 0 && !relative8.startsWith("..") && !path187.isAbsolute(relative8) ? relative8 : filePath.replace(container.env.homeDir, "~");
153225
153462
  }
153226
153463
  var init_harness3 = __esm({
153227
153464
  async "src/cli/commands/harness.ts"() {
@@ -153528,7 +153765,7 @@ import { Argument as Argument2 } from "commander";
153528
153765
  function isVisible(command) {
153529
153766
  return Reflect.get(command, "_hidden") !== true;
153530
153767
  }
153531
- function collectNodes(command, path190 = []) {
153768
+ function collectNodes(command, path191 = []) {
153532
153769
  const children2 = command.commands.filter(isVisible).map((child) => ({
153533
153770
  name: child.name(),
153534
153771
  aliases: [...child.aliases()],
@@ -153559,10 +153796,10 @@ function collectNodes(command, path190 = []) {
153559
153796
  return [];
153560
153797
  }
153561
153798
  return [
153562
- { path: path190, children: children2, options, requiredValueFlags, isPositionalLeaf, positionalChildren },
153799
+ { path: path191, children: children2, options, requiredValueFlags, isPositionalLeaf, positionalChildren },
153563
153800
  ...command.commands.filter(isVisible).flatMap(
153564
153801
  (child) => [child.name(), ...child.aliases()].flatMap(
153565
- (name) => collectNodes(child, [...path190, name])
153802
+ (name) => collectNodes(child, [...path191, name])
153566
153803
  )
153567
153804
  )
153568
153805
  ];
@@ -153694,8 +153931,8 @@ function renderZsh(nodes) {
153694
153931
  function quoteFish(value) {
153695
153932
  return `'${value.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
153696
153933
  }
153697
- function fishCondition(path190) {
153698
- return path190.length === 0 ? '"__fish_use_subcommand"' : `"__fish_seen_subcommand_from ${path190.at(-1)}"`;
153934
+ function fishCondition(path191) {
153935
+ return path191.length === 0 ? '"__fish_use_subcommand"' : `"__fish_seen_subcommand_from ${path191.at(-1)}"`;
153699
153936
  }
153700
153937
  function renderFish(nodes) {
153701
153938
  const lines = nodes.flatMap((node) => {
@@ -153752,7 +153989,7 @@ var init_completion = __esm({
153752
153989
 
153753
153990
  // src/cli/commands/tasks-options.ts
153754
153991
  import * as fsPromises27 from "node:fs/promises";
153755
- import path187 from "node:path";
153992
+ import path188 from "node:path";
153756
153993
  async function resolveWorkflowTaskListOptions(workflowPath) {
153757
153994
  const frontmatter = await readWorkflowFrontmatter(workflowPath);
153758
153995
  return readTaskListOptions(frontmatter, workflowPath);
@@ -153990,7 +154227,7 @@ function resolveStringValue2(value) {
153990
154227
  return process.env[value.slice(envPrefix.length)] ?? value;
153991
154228
  }
153992
154229
  function resolveWorkflowRelativePath(value, workflowPath) {
153993
- return path187.isAbsolute(value) ? value : path187.resolve(path187.dirname(workflowPath), value);
154230
+ return path188.isAbsolute(value) ? value : path188.resolve(path188.dirname(workflowPath), value);
153994
154231
  }
153995
154232
  function asRecord6(value) {
153996
154233
  return isPlainRecord6(value) ? value : void 0;
@@ -154035,7 +154272,7 @@ var init_tasks_options = __esm({
154035
154272
  });
154036
154273
 
154037
154274
  // src/cli/commands/tasks.ts
154038
- import path188 from "node:path";
154275
+ import path189 from "node:path";
154039
154276
  function registerTasksCommand(program, container) {
154040
154277
  const tasks = program.command("tasks").description("Read and mutate configured workflow tasks.");
154041
154278
  tasks.command("verify").description("Verify a task GitHub Project.").argument("<list>", "Project list in <owner>/<number> format.").option("--workflow <path>", "Workflow file path.", "./WORKFLOW.md").option("--repo <owner/name>", "GitHub repository owner/name.").option("--project <owner/number>", "GitHub project owner/number.").option("--states <csv>", "Required task state names.").option("--json", jsonOptionDescription).action(async (list2, options, command) => {
@@ -154185,7 +154422,7 @@ async function runImport(options, container) {
154185
154422
  const limit = options.limit === void 0 ? void 0 : parseNonNegativeInteger3(options.limit, "--limit");
154186
154423
  const source = {
154187
154424
  type: "markdown-dir",
154188
- path: path188.resolve(options.from),
154425
+ path: path189.resolve(options.from),
154189
154426
  singleList: "import",
154190
154427
  frontmatterMode: "passthrough"
154191
154428
  };
@@ -154619,7 +154856,7 @@ var init_tasks2 = __esm({
154619
154856
  });
154620
154857
 
154621
154858
  // src/cli/commands/gaslight.ts
154622
- import path189 from "node:path";
154859
+ import path190 from "node:path";
154623
154860
  import { Option as Option10 } from "commander";
154624
154861
  async function resolveGaslightCommandConfig(container) {
154625
154862
  const configDoc = await readMergedDocumentReadonly(
@@ -154638,9 +154875,9 @@ async function resolveGaslightCommandConfig(container) {
154638
154875
  }
154639
154876
  function resolveConfiguredPath(cwd, homeDir, value) {
154640
154877
  if (value.startsWith("~/")) {
154641
- return path189.join(homeDir, value.slice(2));
154878
+ return path190.join(homeDir, value.slice(2));
154642
154879
  }
154643
- return path189.isAbsolute(value) ? value : path189.resolve(cwd, value);
154880
+ return path190.isAbsolute(value) ? value : path190.resolve(cwd, value);
154644
154881
  }
154645
154882
  function formatPlanDirectoryDetails(container, planDirectory, absoluteDirectory) {
154646
154883
  return [
@@ -154755,7 +154992,7 @@ function formatCompletedPlans(result) {
154755
154992
  return [
154756
154993
  "Completed plans:",
154757
154994
  ...result.plans.map(
154758
- (plan) => `- ${path189.basename(plan.planPath)}${plan.durationMs === void 0 ? "" : ` \xB7 ${formatDuration3(plan.durationMs)}`}`
154995
+ (plan) => `- ${path190.basename(plan.planPath)}${plan.durationMs === void 0 ? "" : ` \xB7 ${formatDuration3(plan.durationMs)}`}`
154759
154996
  )
154760
154997
  ].join("\n");
154761
154998
  }
@@ -154821,8 +155058,8 @@ async function resolveInstallScope(options, assumeYes) {
154821
155058
  }
154822
155059
  async function scaffoldConfig(container, scope, force, dryRun) {
154823
155060
  const root = scope === "global" ? container.env.homeDir : container.env.cwd;
154824
- const configPath = path189.join(root, ".poe-code", "gaslight.yaml");
154825
- const configDirectory = path189.dirname(configPath);
155061
+ const configPath = path190.join(root, ".poe-code", "gaslight.yaml");
155062
+ const configDirectory = path190.dirname(configPath);
154826
155063
  try {
154827
155064
  const stats2 = await container.fs.lstat(configDirectory);
154828
155065
  if (stats2.isSymbolicLink()) {
@@ -155217,7 +155454,7 @@ var init_package2 = __esm({
155217
155454
  "package.json"() {
155218
155455
  package_default2 = {
155219
155456
  name: "poe-code",
155220
- version: "10.0.3",
155457
+ version: "11.0.0",
155221
155458
  description: "CLI tool to configure Poe API for developer workflows.",
155222
155459
  license: "MIT",
155223
155460
  type: "module",
@@ -155851,11 +156088,11 @@ function readCommandTreeOption(command, optionName) {
155851
156088
  }
155852
156089
  return void 0;
155853
156090
  }
155854
- function assertPathIsNotOptionName(path190, command) {
155855
- const named = command.options.find((option) => option.long === `--${path190}`);
156091
+ function assertPathIsNotOptionName(path191, command) {
156092
+ const named = command.options.find((option) => option.long === `--${path191}`);
155856
156093
  if (named !== void 0) {
155857
156094
  throw new ValidationError(
155858
- `\`${path190}\` is not a workflow path. Did you mean \`${named.long}\`?`
156095
+ `\`${path191}\` is not a workflow path. Did you mean \`${named.long}\`?`
155859
156096
  );
155860
156097
  }
155861
156098
  }
@@ -155916,14 +156153,14 @@ function registerMaestroCommand(program, container) {
155916
156153
  "--log-level <level>",
155917
156154
  maestroCommandSchema.shape.logLevel.description ?? "Log level"
155918
156155
  ).choices(maestroCommandSchema.shape.logLevel.values.map(String)).default(maestroCommandSchema.shape.logLevel.default)
155919
- ).action(async (path190, options, command) => {
155920
- assertPathIsNotOptionName(path190, command);
156156
+ ).action(async (path191, options, command) => {
156157
+ assertPathIsNotOptionName(path191, command);
155921
156158
  const mergedOptions = {
155922
156159
  ...options,
155923
156160
  ...command.optsWithGlobals()
155924
156161
  };
155925
156162
  await runMaestro({
155926
- workflowPath: mergedOptions.config ?? path190,
156163
+ workflowPath: mergedOptions.config ?? path191,
155927
156164
  maxConcurrent: mergedOptions.maxConcurrent,
155928
156165
  pollIntervalMs: mergedOptions.pollIntervalMs,
155929
156166
  list: mergedOptions.list,
@@ -156084,7 +156321,7 @@ function createProgram(dependencies) {
156084
156321
  }
156085
156322
  function assertKnownHelpPath(program, container, argv) {
156086
156323
  let target = program;
156087
- const path190 = [];
156324
+ const path191 = [];
156088
156325
  for (const token of argv.filter((arg) => !arg.startsWith("-"))) {
156089
156326
  if (target.commands.length === 0) {
156090
156327
  return;
@@ -156092,7 +156329,7 @@ function assertKnownHelpPath(program, container, argv) {
156092
156329
  const child = findCommand2(target, token);
156093
156330
  if (child !== void 0) {
156094
156331
  target = child;
156095
- path190.push(token);
156332
+ path191.push(token);
156096
156333
  continue;
156097
156334
  }
156098
156335
  if (target !== program && target.registeredArguments.length > 0) {
@@ -156102,7 +156339,7 @@ function assertKnownHelpPath(program, container, argv) {
156102
156339
  container,
156103
156340
  scope: target === program ? "cli" : target.name(),
156104
156341
  unknownCommand: token,
156105
- helpArgs: [...path190, "--help"],
156342
+ helpArgs: [...path191, "--help"],
156106
156343
  candidates: commandCandidates(target),
156107
156344
  moduleUrl: import.meta.url
156108
156345
  });
@@ -156133,16 +156370,16 @@ function commandCandidates(parent) {
156133
156370
  return parent.commands.flatMap((command) => [command.name(), ...command.aliases()]);
156134
156371
  }
156135
156372
  function registerHelpCommand(program, container) {
156136
- program.command("help").description("Display help for a command.").argument("[command...]", "Command path to describe, for example `maestro tui`.").action((path190) => {
156373
+ program.command("help").description("Display help for a command.").argument("[command...]", "Command path to describe, for example `maestro tui`.").action((path191) => {
156137
156374
  let target = program;
156138
- for (const name of path190) {
156375
+ for (const name of path191) {
156139
156376
  const child = findCommand2(target, name);
156140
156377
  if (child === void 0) {
156141
156378
  throwCommandNotFound({
156142
156379
  container,
156143
156380
  scope: "cli",
156144
156381
  unknownCommand: name,
156145
- helpArgs: [...path190.slice(0, path190.indexOf(name)), "--help"],
156382
+ helpArgs: [...path191.slice(0, path191.indexOf(name)), "--help"],
156146
156383
  candidates: commandCandidates(target),
156147
156384
  moduleUrl: import.meta.url
156148
156385
  });