@exodus/xqa 8.0.0 → 8.2.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 (3) hide show
  1. package/README.md +4 -0
  2. package/dist/xqa.cjs +1192 -931
  3. package/package.json +2 -2
package/dist/xqa.cjs CHANGED
@@ -164,7 +164,7 @@ var require_index_cjs = __commonJS({
164
164
  }, reject);
165
165
  }
166
166
  }
167
- var ResultAsync48 = class _ResultAsync {
167
+ var ResultAsync49 = class _ResultAsync {
168
168
  constructor(res) {
169
169
  this._promise = res;
170
170
  }
@@ -303,14 +303,14 @@ var require_index_cjs = __commonJS({
303
303
  }
304
304
  };
305
305
  function okAsync40(value) {
306
- return new ResultAsync48(Promise.resolve(new Ok(value)));
306
+ return new ResultAsync49(Promise.resolve(new Ok(value)));
307
307
  }
308
308
  function errAsync38(err60) {
309
- return new ResultAsync48(Promise.resolve(new Err(err60)));
309
+ return new ResultAsync49(Promise.resolve(new Err(err60)));
310
310
  }
311
- var fromPromise = ResultAsync48.fromPromise;
312
- var fromSafePromise = ResultAsync48.fromSafePromise;
313
- var fromAsyncThrowable12 = ResultAsync48.fromThrowable;
311
+ var fromPromise = ResultAsync49.fromPromise;
312
+ var fromSafePromise = ResultAsync49.fromSafePromise;
313
+ var fromAsyncThrowable12 = ResultAsync49.fromThrowable;
314
314
  var combineResultList = (resultList) => {
315
315
  let acc = ok59([]);
316
316
  for (const result of resultList) {
@@ -323,7 +323,7 @@ var require_index_cjs = __commonJS({
323
323
  }
324
324
  return acc;
325
325
  };
326
- var combineResultAsyncList = (asyncResultList) => ResultAsync48.fromSafePromise(Promise.all(asyncResultList)).andThen(combineResultList);
326
+ var combineResultAsyncList = (asyncResultList) => ResultAsync49.fromSafePromise(Promise.all(asyncResultList)).andThen(combineResultList);
327
327
  var combineResultListWithAllErrors = (resultList) => {
328
328
  let acc = ok59([]);
329
329
  for (const result of resultList) {
@@ -337,7 +337,7 @@ var require_index_cjs = __commonJS({
337
337
  }
338
338
  return acc;
339
339
  };
340
- var combineResultAsyncListWithAllErrors = (asyncResultList) => ResultAsync48.fromSafePromise(Promise.all(asyncResultList)).andThen(combineResultListWithAllErrors);
340
+ var combineResultAsyncListWithAllErrors = (asyncResultList) => ResultAsync49.fromSafePromise(Promise.all(asyncResultList)).andThen(combineResultListWithAllErrors);
341
341
  exports2.Result = void 0;
342
342
  (function(Result3) {
343
343
  function fromThrowable44(fn, errorFn) {
@@ -369,7 +369,7 @@ var require_index_cjs = __commonJS({
369
369
  function safeTry(body) {
370
370
  const n3 = body().next();
371
371
  if (n3 instanceof Promise) {
372
- return new ResultAsync48(n3.then((r4) => r4.value));
372
+ return new ResultAsync49(n3.then((r4) => r4.value));
373
373
  }
374
374
  return n3.value;
375
375
  }
@@ -420,7 +420,7 @@ var require_index_cjs = __commonJS({
420
420
  return f11(this.value).map(() => this.value);
421
421
  }
422
422
  asyncMap(f11) {
423
- return ResultAsync48.fromSafePromise(f11(this.value));
423
+ return ResultAsync49.fromSafePromise(f11(this.value));
424
424
  }
425
425
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
426
426
  unwrapOr(_v) {
@@ -524,7 +524,7 @@ var require_index_cjs = __commonJS({
524
524
  var fromThrowable43 = exports2.Result.fromThrowable;
525
525
  exports2.Err = Err;
526
526
  exports2.Ok = Ok;
527
- exports2.ResultAsync = ResultAsync48;
527
+ exports2.ResultAsync = ResultAsync49;
528
528
  exports2.err = err59;
529
529
  exports2.errAsync = errAsync38;
530
530
  exports2.fromAsyncThrowable = fromAsyncThrowable12;
@@ -2460,7 +2460,7 @@ ${indent}${line}` : "\n";
2460
2460
  str2 += ",";
2461
2461
  } else if (ctx.options.trailingComma) {
2462
2462
  if (ctx.options.lineWidth > 0) {
2463
- reqNewline || (reqNewline = lines.reduce((sum, line) => sum + line.length + 2, 2) + (str2.length + 2) > ctx.options.lineWidth);
2463
+ reqNewline || (reqNewline = lines.reduce((sum2, line) => sum2 + line.length + 2, 2) + (str2.length + 2) > ctx.options.lineWidth);
2464
2464
  }
2465
2465
  if (reqNewline) {
2466
2466
  str2 += ",";
@@ -2476,7 +2476,7 @@ ${indent}${line}` : "\n";
2476
2476
  return start + end;
2477
2477
  } else {
2478
2478
  if (!reqNewline) {
2479
- const len = lines.reduce((sum, line) => sum + line.length + 2, 2);
2479
+ const len = lines.reduce((sum2, line) => sum2 + line.length + 2, 2);
2480
2480
  reqNewline = ctx.options.lineWidth > 0 && len > ctx.options.lineWidth;
2481
2481
  }
2482
2482
  if (reqNewline) {
@@ -22806,9 +22806,9 @@ var require_bignumber = __commonJS({
22806
22806
  };
22807
22807
  })();
22808
22808
  BigNumber2.sum = function() {
22809
- var i4 = 1, args = arguments, sum = new BigNumber2(args[0]);
22810
- for (; i4 < args.length; ) sum = sum.plus(args[i4++]);
22811
- return sum;
22809
+ var i4 = 1, args = arguments, sum2 = new BigNumber2(args[0]);
22810
+ for (; i4 < args.length; ) sum2 = sum2.plus(args[i4++]);
22811
+ return sum2;
22812
22812
  };
22813
22813
  convertBase = /* @__PURE__ */ (function() {
22814
22814
  var decimal = "0123456789";
@@ -35485,14 +35485,14 @@ var require_sharp_phash = __commonJS({
35485
35485
  for (var u = 0; u < N; u++) {
35486
35486
  F11[u] = new Array(N);
35487
35487
  for (var v3 = 0; v3 < N; v3++) {
35488
- var sum = 0;
35488
+ var sum2 = 0;
35489
35489
  for (var i4 = 0; i4 < N; i4++) {
35490
35490
  for (var j = 0; j < N; j++) {
35491
- sum += COS[i4][u] * COS[j][v3] * f11[i4][j];
35491
+ sum2 += COS[i4][u] * COS[j][v3] * f11[i4][j];
35492
35492
  }
35493
35493
  }
35494
- sum *= SQRT[u] * SQRT[v3] / 4;
35495
- F11[u][v3] = sum;
35494
+ sum2 *= SQRT[u] * SQRT[v3] / 4;
35495
+ F11[u][v3] = sum2;
35496
35496
  }
35497
35497
  }
35498
35498
  return F11;
@@ -85278,7 +85278,7 @@ var {
85278
85278
  } = import_index.default;
85279
85279
 
85280
85280
  // src/bootstrap.ts
85281
- var import_neverthrow148 = __toESM(require_index_cjs(), 1);
85281
+ var import_neverthrow149 = __toESM(require_index_cjs(), 1);
85282
85282
 
85283
85283
  // src/config/error-formatter.ts
85284
85284
  function formatIssues(issues) {
@@ -102720,6 +102720,7 @@ function collectElements(elements, screen) {
102720
102720
  }
102721
102721
  var OCCLUDED_BY_OVERLAP_TAG = "[occluded-by-overlap]";
102722
102722
  var FULL_BBOX_CONTAINMENT_RATIO = 0.85;
102723
+ var LATER_UNION_COVERAGE_THRESHOLD = 0.7;
102723
102724
  function frameContainsPoint(frame, point) {
102724
102725
  return point.x >= frame.x && point.x < frame.x + frame.width && point.y >= frame.y && point.y < frame.y + frame.height;
102725
102726
  }
@@ -102796,6 +102797,78 @@ function fullyCoversBoundingBox(target, candidate) {
102796
102797
  }
102797
102798
  return intersectionArea(target.frame, candidate.frame) / targetArea >= FULL_BBOX_CONTAINMENT_RATIO;
102798
102799
  }
102800
+ function clipFrameToTarget(target, candidate) {
102801
+ const x1 = Math.max(target.x, candidate.x);
102802
+ const y12 = Math.max(target.y, candidate.y);
102803
+ const x22 = Math.min(target.x + target.width, candidate.x + candidate.width);
102804
+ const y22 = Math.min(target.y + target.height, candidate.y + candidate.height);
102805
+ if (x22 <= x1 || y22 <= y12) {
102806
+ return void 0;
102807
+ }
102808
+ return { x: x1, y: y12, width: x22 - x1, height: y22 - y12 };
102809
+ }
102810
+ function uniqueSorted(values) {
102811
+ return [...new Set(values)].toSorted((left, right) => left - right);
102812
+ }
102813
+ function rectCoversCell(rect, cell) {
102814
+ return rect.x <= cell.x1 && rect.x + rect.width >= cell.x2 && rect.y <= cell.y1 && rect.y + rect.height >= cell.y2;
102815
+ }
102816
+ function cellAt(grid, indices) {
102817
+ const x1 = grid.xs[indices.xIndex];
102818
+ const x22 = grid.xs[indices.xIndex + 1];
102819
+ const y12 = grid.ys[indices.yIndex];
102820
+ const y22 = grid.ys[indices.yIndex + 1];
102821
+ if (x1 === void 0 || x22 === void 0 || y12 === void 0 || y22 === void 0) {
102822
+ return void 0;
102823
+ }
102824
+ return { x1, y1: y12, x2: x22, y2: y22 };
102825
+ }
102826
+ function cellCoveredArea(grid, indices) {
102827
+ const cell = cellAt(grid, indices);
102828
+ if (!cell) {
102829
+ return 0;
102830
+ }
102831
+ const covered = grid.rects.some((rect) => rectCoversCell(rect, cell));
102832
+ return covered ? (cell.x2 - cell.x1) * (cell.y2 - cell.y1) : 0;
102833
+ }
102834
+ function sum(values) {
102835
+ return values.reduce((total, value) => total + value, 0);
102836
+ }
102837
+ function rowCoveredArea(grid, yIndex) {
102838
+ return sum(
102839
+ grid.xs.slice(0, -1).map((_value, xIndex) => cellCoveredArea(grid, { xIndex, yIndex }))
102840
+ );
102841
+ }
102842
+ function buildGrid(target, clipped) {
102843
+ const xs = uniqueSorted([
102844
+ target.x,
102845
+ target.x + target.width,
102846
+ ...clipped.flatMap((rect) => [rect.x, rect.x + rect.width])
102847
+ ]);
102848
+ const ys = uniqueSorted([
102849
+ target.y,
102850
+ target.y + target.height,
102851
+ ...clipped.flatMap((rect) => [rect.y, rect.y + rect.height])
102852
+ ]);
102853
+ return { rects: clipped, xs, ys };
102854
+ }
102855
+ function totalCoveredArea(grid) {
102856
+ return sum(grid.ys.slice(0, -1).map((_value, yIndex) => rowCoveredArea(grid, yIndex)));
102857
+ }
102858
+ function unionCoverageRatio(target, laterNodes) {
102859
+ const targetArea = frameArea(target.frame);
102860
+ if (targetArea <= 0) {
102861
+ return 0;
102862
+ }
102863
+ const clipped = laterNodes.map((node) => clipFrameToTarget(target.frame, node.frame)).filter((rect) => rect !== void 0);
102864
+ if (clipped.length === 0) {
102865
+ return 0;
102866
+ }
102867
+ return totalCoveredArea(buildGrid(target.frame, clipped)) / targetArea;
102868
+ }
102869
+ function coveredByLaterUnion(target, laterNodes) {
102870
+ return unionCoverageRatio(target, laterNodes) >= LATER_UNION_COVERAGE_THRESHOLD;
102871
+ }
102799
102872
  function isOccluder(target, candidate) {
102800
102873
  if (candidate.treeOrder <= target.treeOrder) {
102801
102874
  return false;
@@ -102808,8 +102881,16 @@ function isOccluder(target, candidate) {
102808
102881
  }
102809
102882
  return blocksTapPoint(target, candidate) || fullyCoversBoundingBox(target, candidate);
102810
102883
  }
102884
+ function laterNonRelativeNodes(target, nodes) {
102885
+ return nodes.filter(
102886
+ (candidate) => candidate.treeOrder > target.treeOrder && !candidate.ancestors.has(target.element) && !target.ancestors.has(candidate.element)
102887
+ );
102888
+ }
102811
102889
  function isOccluded(target, nodes) {
102812
- return nodes.some((candidate) => isOccluder(target, candidate));
102890
+ if (nodes.some((candidate) => isOccluder(target, candidate))) {
102891
+ return true;
102892
+ }
102893
+ return coveredByLaterUnion(target, laterNonRelativeNodes(target, nodes));
102813
102894
  }
102814
102895
  function detectOccludedElements(elements, screen) {
102815
102896
  const nodes = flatten(elements, screen);
@@ -103671,26 +103752,20 @@ function createSwipeTool(udid = "booted") {
103671
103752
  );
103672
103753
  }
103673
103754
  var MOBILE_KEYS_SCRIPT = "mobile: keys";
103674
- function splitCodePoints(text) {
103675
- return text.match(/[\s\S]/gu) ?? [];
103676
- }
103677
- function postKeys(input) {
103755
+ function typeText(input) {
103678
103756
  return wdaPost({
103679
103757
  baseUrl: input.baseUrl,
103680
- path: `/session/${input.sessionId}/execute/sync`,
103681
- body: { script: MOBILE_KEYS_SCRIPT, args: [{ keys: input.keys }] }
103758
+ path: `/session/${input.sessionId}/wda/keys`,
103759
+ body: { value: [input.text] }
103682
103760
  });
103683
103761
  }
103684
- function typeText(input) {
103685
- return postKeys({
103762
+ function pressEnter(input) {
103763
+ return wdaPost({
103686
103764
  baseUrl: input.baseUrl,
103687
- sessionId: input.sessionId,
103688
- keys: splitCodePoints(input.text)
103765
+ path: `/session/${input.sessionId}/execute/sync`,
103766
+ body: { script: MOBILE_KEYS_SCRIPT, args: [{ keys: ["\n"] }] }
103689
103767
  });
103690
103768
  }
103691
- function pressEnter(input) {
103692
- return postKeys({ baseUrl: input.baseUrl, sessionId: input.sessionId, keys: ["\n"] });
103693
- }
103694
103769
  var TYPE_TEXT_SCHEMA = { text: external_exports.string(), submit: external_exports.boolean().optional() };
103695
103770
  async function handleTypeText({ udid, text, submit }) {
103696
103771
  const result = await getOrCreateSession(APPIUM_BASE_URL, udid).andThen((sessionId) => {
@@ -105494,9 +105569,39 @@ function formatMemoryElements(elements) {
105494
105569
  (element) => `${element.label} [${String(Math.round(element.confidence * PCT_MULTIPLIER))}%${element.phase === "after-scroll" ? "\u2193" : ""}]`
105495
105570
  ).join(", ");
105496
105571
  }
105572
+ var MS_PER_SECOND22 = 1e3;
105573
+ function visualPassMarker(event) {
105574
+ if (event.outcome === "ok") {
105575
+ return "\xB7";
105576
+ }
105577
+ if (event.outcome === "skipped_similar") {
105578
+ return "\u21B7";
105579
+ }
105580
+ return "\u26A0";
105581
+ }
105582
+ function visualPassStyle(event) {
105583
+ if (event.outcome === "ok") {
105584
+ return "default";
105585
+ }
105586
+ if (event.outcome === "skipped_similar") {
105587
+ return "dim";
105588
+ }
105589
+ return "error";
105590
+ }
105591
+ function visualPassSummaryText(event) {
105592
+ if (event.outcome === "skipped_similar") {
105593
+ const distance = event.similarDistance ?? 0;
105594
+ return `${visualPassMarker(event)} ${event.agent} visual_pass skipped \u2014 similar to a previously analysed screen (distance ${String(distance)})`;
105595
+ }
105596
+ const duration3 = (event.durationMs / MS_PER_SECOND22).toFixed(1);
105597
+ return `${visualPassMarker(event)} ${event.agent} visual_pass ${event.outcome} \u2014 ${String(event.findingsEmitted)} finding(s) in ${duration3}s`;
105598
+ }
105599
+ function renderVisualPassRun(event) {
105600
+ return [{ kind: "text", style: visualPassStyle(event), text: visualPassSummaryText(event) }];
105601
+ }
105497
105602
  var HIDDEN_TOOL_ARGS = /* @__PURE__ */ new Set(["device"]);
105498
105603
  var SCREEN_PREVIEW_LENGTH = 80;
105499
- var MS_PER_SECOND22 = 1e3;
105604
+ var MS_PER_SECOND32 = 1e3;
105500
105605
  var COST_DECIMAL_PLACES = 4;
105501
105606
  function formatToolName(name) {
105502
105607
  return name.replace(/^mcp_(?:mobile_)?/, "").replace(/_on_screen$/, "");
@@ -105508,7 +105613,7 @@ function buildToolArgumentString(input) {
105508
105613
  return Object.entries(input).filter(([key]) => !HIDDEN_TOOL_ARGS.has(key)).map(([key, value]) => `${key}: ${String(value)}`).join(", ");
105509
105614
  }
105510
105615
  function normalizeTimeoutGraceEntered(event) {
105511
- const seconds = Math.round(event.gracePeriodMs / MS_PER_SECOND22);
105616
+ const seconds = Math.round(event.gracePeriodMs / MS_PER_SECOND32);
105512
105617
  return [
105513
105618
  {
105514
105619
  kind: "annotation",
@@ -105531,11 +105636,7 @@ function normalizeFindingReported(event) {
105531
105636
  ];
105532
105637
  }
105533
105638
  function normalizeVisualPassRun(event) {
105534
- const duration3 = (event.durationMs / MS_PER_SECOND22).toFixed(1);
105535
- const marker = event.outcome === "ok" ? "\xB7" : "\u26A0";
105536
- const summary = `${marker} ${event.agent} visual_pass ${event.outcome} \u2014 ${String(event.findingsEmitted)} finding(s) in ${duration3}s`;
105537
- const style = event.outcome === "ok" ? "default" : "error";
105538
- return [{ kind: "text", style, text: summary }];
105639
+ return renderVisualPassRun(event);
105539
105640
  }
105540
105641
  function normalizeStageStart(event) {
105541
105642
  return [
@@ -105544,7 +105645,7 @@ function normalizeStageStart(event) {
105544
105645
  ];
105545
105646
  }
105546
105647
  function normalizeStageEnd(event) {
105547
- const duration3 = (event.durationMs / MS_PER_SECOND22).toFixed(1);
105648
+ const duration3 = (event.durationMs / MS_PER_SECOND32).toFixed(1);
105548
105649
  return [
105549
105650
  { kind: "text", style: "dim", text: `${event.agent} done in ${duration3}s` },
105550
105651
  { kind: "group-close" }
@@ -143806,12 +143907,12 @@ function partitionClusters(clusters, rangeOf) {
143806
143907
  const unranged = clusters.filter((cluster) => rangeOf(cluster) === void 0);
143807
143908
  return { ranged, unranged };
143808
143909
  }
143809
- var MS_PER_SECOND32 = 1e3;
143910
+ var MS_PER_SECOND33 = 1e3;
143810
143911
  var SECONDS_PER_MINUTE2 = 60;
143811
143912
  var TIMESTAMP_PAD = 2;
143812
143913
  var TITLE_MAX_LENGTH2 = 120;
143813
143914
  function formatTimestamp2(ms) {
143814
- const totalSeconds = Math.max(0, Math.floor(ms / MS_PER_SECOND32));
143915
+ const totalSeconds = Math.max(0, Math.floor(ms / MS_PER_SECOND33));
143815
143916
  const minutes = Math.floor(totalSeconds / SECONDS_PER_MINUTE2);
143816
143917
  const seconds = totalSeconds % SECONDS_PER_MINUTE2;
143817
143918
  return `${String(minutes).padStart(TIMESTAMP_PAD, "0")}:${String(seconds).padStart(TIMESTAMP_PAD, "0")}`;
@@ -144499,7 +144600,7 @@ var analyserConfigSchema = agentBaseConfigSchema.extend({
144499
144600
  }).strict();
144500
144601
 
144501
144602
  // ../../packages/pipeline/dist/index.js
144502
- var import_neverthrow59 = __toESM(require_index_cjs(), 1);
144603
+ var import_neverthrow60 = __toESM(require_index_cjs(), 1);
144503
144604
 
144504
144605
  // ../../agents/consolidator/dist/index.js
144505
144606
  var import_neverthrow37 = __toESM(require_index_cjs(), 1);
@@ -150592,7 +150693,7 @@ function runConsolidator(input, config2) {
150592
150693
  var consolidatorConfigSchema = agentBaseConfigSchema.extend({ enabled: external_exports.boolean().default(true) }).strict();
150593
150694
 
150594
150695
  // ../../packages/pipeline/dist/index.js
150595
- var import_neverthrow60 = __toESM(require_index_cjs(), 1);
150696
+ var import_neverthrow61 = __toESM(require_index_cjs(), 1);
150596
150697
  var import_promises25 = require("node:timers/promises");
150597
150698
 
150598
150699
  // ../../agents/explorer/dist/index.js
@@ -150607,29 +150708,17 @@ var import_node_path13 = __toESM(require("node:path"), 1);
150607
150708
  var import_promises18 = require("node:fs/promises");
150608
150709
  var import_node_path14 = __toESM(require("node:path"), 1);
150609
150710
  var import_neverthrow44 = __toESM(require_index_cjs(), 1);
150610
- var import_node_child_process5 = require("node:child_process");
150711
+ var import_node_crypto2 = require("node:crypto");
150712
+ var import_neverthrow45 = __toESM(require_index_cjs(), 1);
150611
150713
  var import_promises19 = require("node:fs/promises");
150612
150714
  var import_node_path15 = __toESM(require("node:path"), 1);
150613
- var import_neverthrow45 = __toESM(require_index_cjs(), 1);
150614
150715
  var import_neverthrow46 = __toESM(require_index_cjs(), 1);
150615
150716
  var import_neverthrow47 = __toESM(require_index_cjs(), 1);
150616
- var import_promises20 = require("node:fs/promises");
150617
- var import_node_path16 = __toESM(require("node:path"), 1);
150618
150717
  var import_neverthrow48 = __toESM(require_index_cjs(), 1);
150619
- var import_neverthrow49 = __toESM(require_index_cjs(), 1);
150620
- var import_node_child_process6 = require("node:child_process");
150621
- var import_promises21 = require("node:fs/promises");
150622
- var import_node_path17 = __toESM(require("node:path"), 1);
150623
- var import_neverthrow50 = __toESM(require_index_cjs(), 1);
150624
- var import_node_child_process7 = require("node:child_process");
150625
- var import_node_fs5 = require("node:fs");
150626
- var import_node_path18 = __toESM(require("node:path"), 1);
150627
- var import_neverthrow51 = __toESM(require_index_cjs(), 1);
150628
- var import_node_crypto2 = require("node:crypto");
150629
- var import_neverthrow52 = __toESM(require_index_cjs(), 1);
150718
+ var import_node_child_process5 = require("node:child_process");
150630
150719
  var import_node_crypto3 = require("node:crypto");
150631
150720
  var import_sharp_phash = __toESM(require_sharp_phash(), 1);
150632
- var import_neverthrow53 = __toESM(require_index_cjs(), 1);
150721
+ var import_neverthrow49 = __toESM(require_index_cjs(), 1);
150633
150722
 
150634
150723
  // ../../node_modules/.pnpm/yocto-queue@1.2.2/node_modules/yocto-queue/index.js
150635
150724
  var Node = class {
@@ -150788,11 +150877,25 @@ function validateConcurrency(concurrency) {
150788
150877
  }
150789
150878
 
150790
150879
  // ../../agents/explorer/dist/index.js
150880
+ var import_promises20 = require("node:fs/promises");
150881
+ var import_node_path16 = __toESM(require("node:path"), 1);
150882
+ var import_neverthrow50 = __toESM(require_index_cjs(), 1);
150883
+ var import_neverthrow51 = __toESM(require_index_cjs(), 1);
150884
+ var import_sharp2 = __toESM(require("sharp"), 1);
150885
+ var import_promises21 = require("node:fs/promises");
150886
+ var import_node_path17 = __toESM(require("node:path"), 1);
150887
+ var import_neverthrow52 = __toESM(require_index_cjs(), 1);
150888
+ var import_neverthrow53 = __toESM(require_index_cjs(), 1);
150889
+ var import_node_child_process6 = require("node:child_process");
150791
150890
  var import_promises22 = require("node:fs/promises");
150792
- var import_node_path19 = __toESM(require("node:path"), 1);
150891
+ var import_node_path18 = __toESM(require("node:path"), 1);
150793
150892
  var import_neverthrow54 = __toESM(require_index_cjs(), 1);
150893
+ var import_node_child_process7 = require("node:child_process");
150894
+ var import_node_fs5 = require("node:fs");
150895
+ var import_node_path19 = __toESM(require("node:path"), 1);
150794
150896
  var import_neverthrow55 = __toESM(require_index_cjs(), 1);
150795
- var import_sharp2 = __toESM(require("sharp"), 1);
150897
+ var import_node_crypto4 = require("node:crypto");
150898
+ var import_neverthrow56 = __toESM(require_index_cjs(), 1);
150796
150899
  var import_promises23 = require("node:fs/promises");
150797
150900
  var import_node_path20 = __toESM(require("node:path"), 1);
150798
150901
 
@@ -153421,11 +153524,11 @@ var jsYaml = {
153421
153524
  };
153422
153525
 
153423
153526
  // ../../agents/explorer/dist/index.js
153424
- var import_neverthrow56 = __toESM(require_index_cjs(), 1);
153425
153527
  var import_neverthrow57 = __toESM(require_index_cjs(), 1);
153528
+ var import_neverthrow58 = __toESM(require_index_cjs(), 1);
153426
153529
  var import_promises24 = require("node:fs/promises");
153427
153530
  var import_node_path21 = __toESM(require("node:path"), 1);
153428
- var import_neverthrow58 = __toESM(require_index_cjs(), 1);
153531
+ var import_neverthrow59 = __toESM(require_index_cjs(), 1);
153429
153532
  var INTERRUPT_DRAIN_TIMEOUT_MS = 1e4;
153430
153533
  async function interruptOrTimeout(queryRunner) {
153431
153534
  await Promise.race([queryRunner.interrupt(), (0, import_promises16.setTimeout)(INTERRUPT_DRAIN_TIMEOUT_MS)]);
@@ -153988,122 +154091,7 @@ function captureFromUser(content, state) {
153988
154091
  captureToolResult(block, state);
153989
154092
  }
153990
154093
  }
153991
- function processMessage(message, state) {
153992
- if (message.type === "assistant" && Array.isArray(message.message.content)) {
153993
- captureFromAssistant(message.message.content, state);
153994
- }
153995
- if (message.type === "user" && Array.isArray(message.message.content)) {
153996
- captureFromUser(message.message.content, state);
153997
- }
153998
- if (message.type === "result") {
153999
- const resultMessage = message;
154000
- const { tokenUsage } = state;
154001
- tokenUsage.value = {
154002
- inputTokens: resultMessage.usage.input_tokens,
154003
- outputTokens: resultMessage.usage.output_tokens,
154004
- cacheReadInputTokens: resultMessage.usage.cache_read_input_tokens,
154005
- cacheCreationInputTokens: resultMessage.usage.cache_creation_input_tokens,
154006
- totalCostUsd: resultMessage.total_cost_usd
154007
- };
154008
- if (message.subtype !== "success" && !state.timedOut.value && !state.aborted.value) {
154009
- return (0, import_neverthrow42.err)(message.errors.join("; "));
154010
- }
154011
- return (0, import_neverthrow42.ok)(true);
154012
- }
154013
- return (0, import_neverthrow42.ok)(false);
154014
- }
154015
- async function processMessages(queryRunner, state) {
154016
- for await (const message of queryRunner) {
154017
- const result = processMessage(message, state);
154018
- if (result.isErr()) {
154019
- return (0, import_neverthrow42.err)(result.error);
154020
- }
154021
- if (result.value) {
154022
- break;
154023
- }
154024
- }
154025
- return (0, import_neverthrow42.ok)(null);
154026
- }
154027
- function buildSendMessageFunction(inputQueue) {
154028
- return (content) => {
154029
- const message = {
154030
- type: "user",
154031
- message: { role: "user", content },
154032
- parent_tool_use_id: null,
154033
- isSynthetic: true
154034
- };
154035
- inputQueue.enqueue(message);
154036
- };
154037
- }
154038
- function buildAgentState({
154039
- config: config2,
154040
- inputQueue
154041
- }) {
154042
- return {
154043
- pendingToolCallNames: /* @__PURE__ */ new Map(),
154044
- snapshots: [],
154045
- stepCounter: { value: 0 },
154046
- findings: [],
154047
- findingCounter: { value: 0 },
154048
- sendMessage: buildSendMessageFunction(inputQueue),
154049
- closeQueue: () => {
154050
- inputQueue.close();
154051
- },
154052
- timedOut: { value: false },
154053
- aborted: { value: false },
154054
- onEvent: config2.onEvent,
154055
- tokenUsage: { value: { ...EMPTY_TOKEN_USAGE } }
154056
- };
154057
- }
154058
- function spawnDetached(options) {
154059
- const child = (0, import_node_child_process5.spawn)(options.command, options.args, {
154060
- cwd: options.cwd,
154061
- env: options.env,
154062
- stdio: ["pipe", "pipe", "pipe"],
154063
- detached: true,
154064
- signal: options.signal
154065
- });
154066
- child.stderr.pipe(process.stderr);
154067
- return {
154068
- stdin: child.stdin,
154069
- stdout: child.stdout,
154070
- get killed() {
154071
- return child.killed;
154072
- },
154073
- get exitCode() {
154074
- return child.exitCode;
154075
- },
154076
- kill: child.kill.bind(child),
154077
- on: child.on.bind(child),
154078
- once: child.once.bind(child),
154079
- off: child.off.bind(child)
154080
- };
154081
- }
154082
- function buildBaseOptions(context) {
154083
- const { config: config2, mobileIosServer, allowedTools } = context;
154084
- return {
154085
- mcpServers: {
154086
- ...config2.mcpServers,
154087
- "mobile-ios": mobileIosServer
154088
- },
154089
- allowedTools,
154090
- tools: [],
154091
- permissionMode: "bypassPermissions",
154092
- allowDangerouslySkipPermissions: true,
154093
- spawnClaudeCodeProcess: spawnDetached,
154094
- thinking: { type: "adaptive" },
154095
- ...config2.cwd ? { cwd: config2.cwd } : {}
154096
- };
154097
- }
154098
- function buildQueryOptions(context) {
154099
- const base = buildBaseOptions(context);
154100
- if (!context.config.signal) {
154101
- return { options: base, linkedController: void 0 };
154102
- }
154103
- const linkedController = new AbortController();
154104
- return { options: { ...base, abortController: linkedController }, linkedController };
154105
- }
154106
- var safeWriteFile3 = (0, import_neverthrow45.fromAsyncThrowable)(
154094
+ var safeWriteFile3 = (0, import_neverthrow46.fromAsyncThrowable)(
154107
154095
  import_promises19.writeFile,
154108
154096
  (cause) => ({ type: "WRITE_FAILED", cause })
154109
154097
  );
@@ -154408,14 +154396,21 @@ function buildVisualScanTool() {
154408
154396
  return {
154409
154397
  name: VISUAL_SCAN_TOOL_NAME,
154410
154398
  description: VISUAL_SCAN_DESCRIPTION,
154411
- input_schema: external_exports.toJSONSchema(visualScanInputSchema)
154399
+ input_schema: external_exports.toJSONSchema(visualScanInputSchema),
154400
+ cache_control: { type: "ephemeral" }
154412
154401
  };
154413
154402
  }
154414
154403
  function buildVisualPassRequest(input) {
154415
154404
  return {
154416
154405
  model: input.model ?? VISUAL_PASS_DEFAULT_MODEL,
154417
154406
  max_tokens: input.maxTokens ?? VISUAL_PASS_DEFAULT_MAX_TOKENS,
154418
- system: buildVisualPassSystemPrompt(input.visualMode),
154407
+ system: [
154408
+ {
154409
+ type: "text",
154410
+ text: buildVisualPassSystemPrompt(input.visualMode),
154411
+ cache_control: { type: "ephemeral" }
154412
+ }
154413
+ ],
154419
154414
  tools: [buildVisualScanTool()],
154420
154415
  tool_choice: { type: "tool", name: VISUAL_SCAN_TOOL_NAME },
154421
154416
  messages: [buildUserMessage2(input)]
@@ -154436,18 +154431,18 @@ function checkConsistency(decisions, findings) {
154436
154431
  const emitDecisions = findEmitDecisions(decisions);
154437
154432
  const visualFindings = findings.filter((finding) => isVisualTrigger(finding));
154438
154433
  if (emitDecisions.length > 0 && visualFindings.length === 0) {
154439
- return (0, import_neverthrow47.err)({
154434
+ return (0, import_neverthrow48.err)({
154440
154435
  type: "VISUAL_PASS_INCONSISTENT",
154441
154436
  emitDecisions,
154442
154437
  findingCount: findings.length
154443
154438
  });
154444
154439
  }
154445
- return (0, import_neverthrow47.ok)(visualFindings);
154440
+ return (0, import_neverthrow48.ok)(visualFindings);
154446
154441
  }
154447
154442
  function parseVisualScanBlock(block) {
154448
154443
  const result = visualScanInputSchema.safeParse(block.input);
154449
154444
  if (!result.success) {
154450
- return (0, import_neverthrow47.err)({
154445
+ return (0, import_neverthrow48.err)({
154451
154446
  type: "VISUAL_PASS_INPUT_INVALID",
154452
154447
  issues: formatIssues2(result.error),
154453
154448
  raw: block.input
@@ -154468,11 +154463,18 @@ function parseVisualPassMessage(message) {
154468
154463
  const parsed = blocks.map((block) => parseVisualScanBlock(block));
154469
154464
  const failure = parsed.find((result) => result.isErr());
154470
154465
  if (failure?.isErr() === true) {
154471
- return (0, import_neverthrow47.err)(failure.error);
154466
+ return (0, import_neverthrow48.err)(failure.error);
154472
154467
  }
154473
- return (0, import_neverthrow47.ok)(parsed.flatMap((result) => result.isOk() ? result.value : []));
154468
+ return (0, import_neverthrow48.ok)(parsed.flatMap((result) => result.isOk() ? result.value : []));
154474
154469
  }
154475
154470
  var ANTHROPIC_MAX_RETRIES = 5;
154471
+ var EMPTY_VISUAL_PASS_USAGE = {
154472
+ model: "",
154473
+ inputTokens: 0,
154474
+ outputTokens: 0,
154475
+ cacheReadInputTokens: 0,
154476
+ cacheCreationInputTokens: 0
154477
+ };
154476
154478
  async function createMessage(input) {
154477
154479
  const client = new Anthropic({ maxRetries: ANTHROPIC_MAX_RETRIES });
154478
154480
  const request2 = buildVisualPassRequest({
@@ -154482,19 +154484,68 @@ async function createMessage(input) {
154482
154484
  });
154483
154485
  return client.messages.create(request2);
154484
154486
  }
154485
- function extractFindings(message) {
154487
+ function extractUsage(message) {
154488
+ return {
154489
+ model: message.model,
154490
+ inputTokens: message.usage.input_tokens,
154491
+ outputTokens: message.usage.output_tokens,
154492
+ cacheReadInputTokens: message.usage.cache_read_input_tokens ?? 0,
154493
+ cacheCreationInputTokens: message.usage.cache_creation_input_tokens ?? 0
154494
+ };
154495
+ }
154496
+ function extractOutput(message) {
154486
154497
  const parsed = parseVisualPassMessage(message);
154487
- return parsed.isOk() ? (0, import_neverthrow46.okAsync)(parsed.value) : (0, import_neverthrow46.errAsync)(parsed.error);
154498
+ if (parsed.isErr()) {
154499
+ return (0, import_neverthrow47.errAsync)(parsed.error);
154500
+ }
154501
+ return (0, import_neverthrow47.okAsync)({ findings: parsed.value, usage: extractUsage(message) });
154488
154502
  }
154489
154503
  function runVisualPass(input) {
154490
154504
  if (input.visualMode.kind === "disabled") {
154491
- return (0, import_neverthrow46.okAsync)([]);
154505
+ return (0, import_neverthrow47.okAsync)({ findings: [], usage: { ...EMPTY_VISUAL_PASS_USAGE } });
154492
154506
  }
154493
- const safeCreate = (0, import_neverthrow46.fromAsyncThrowable)(
154507
+ const safeCreate = (0, import_neverthrow47.fromAsyncThrowable)(
154494
154508
  createMessage,
154495
154509
  (cause) => ({ type: "VISUAL_PASS_API_FAILED", cause })
154496
154510
  );
154497
- return safeCreate(input).andThen(extractFindings);
154511
+ return safeCreate(input).andThen(extractOutput);
154512
+ }
154513
+ var MATCH_TOLERANCE_VALUES = ["strict", "balanced", "loose"];
154514
+ var STRICT_HAMMING_THRESHOLD = 6;
154515
+ var BALANCED_HAMMING_THRESHOLD = 12;
154516
+ var LOOSE_HAMMING_THRESHOLD = 20;
154517
+ var HAMMING_THRESHOLD_BY_TOLERANCE = {
154518
+ strict: STRICT_HAMMING_THRESHOLD,
154519
+ balanced: BALANCED_HAMMING_THRESHOLD,
154520
+ loose: LOOSE_HAMMING_THRESHOLD
154521
+ };
154522
+ function hammingDistance(left, right) {
154523
+ const xor2 = left ^ right;
154524
+ return (xor2.toString(2).match(/1/g) ?? []).length;
154525
+ }
154526
+ function selectTopK(input) {
154527
+ const scored = input.candidates.map(
154528
+ (candidate) => ({
154529
+ name: candidate.name,
154530
+ distance: hammingDistance(input.target, candidate.hash)
154531
+ })
154532
+ );
154533
+ const within = scored.filter((entry) => entry.distance <= input.threshold);
154534
+ const sorted = within.toSorted((left, right) => left.distance - right.distance);
154535
+ return sorted.slice(0, input.topK);
154536
+ }
154537
+ function pickClosestDistance(target, entries) {
154538
+ if (entries.length === 0) {
154539
+ return void 0;
154540
+ }
154541
+ return Math.min(...entries.map((hash2) => hammingDistance(target, hash2)));
154542
+ }
154543
+ function findSimilarAnalyzedScreen(input) {
154544
+ const closest = pickClosestDistance(input.targetHash, input.entries);
154545
+ if (closest === void 0 || closest > input.similarityThreshold) {
154546
+ return { matched: false };
154547
+ }
154548
+ return { matched: true, distance: closest };
154498
154549
  }
154499
154550
  function outcomeFromError(error48) {
154500
154551
  if (error48.type === "VISUAL_PASS_API_FAILED") {
@@ -154503,13 +154554,31 @@ function outcomeFromError(error48) {
154503
154554
  return "input_invalid";
154504
154555
  }
154505
154556
  function emitRunEvent(params) {
154506
- params.onEvent?.({
154557
+ const base = {
154507
154558
  type: "VISUAL_PASS_RUN",
154508
154559
  agent: "explorer",
154509
154560
  durationMs: params.durationMs,
154510
154561
  findingsEmitted: params.findingsEmitted,
154511
154562
  outcome: params.outcome
154563
+ };
154564
+ params.onEvent?.(
154565
+ params.similarDistance === void 0 ? base : { ...base, similarDistance: params.similarDistance }
154566
+ );
154567
+ }
154568
+ function nextUsage(current, usage) {
154569
+ const cost = calculateAnthropicCost(usage.model, {
154570
+ inputTokens: usage.inputTokens,
154571
+ outputTokens: usage.outputTokens,
154572
+ cacheReadInputTokens: usage.cacheReadInputTokens,
154573
+ cacheCreationInputTokens: usage.cacheCreationInputTokens
154512
154574
  });
154575
+ return {
154576
+ inputTokens: current.inputTokens + usage.inputTokens,
154577
+ outputTokens: current.outputTokens + usage.outputTokens,
154578
+ cacheReadInputTokens: current.cacheReadInputTokens + usage.cacheReadInputTokens,
154579
+ cacheCreationInputTokens: current.cacheCreationInputTokens + usage.cacheCreationInputTokens,
154580
+ totalCostUsd: current.totalCostUsd + cost
154581
+ };
154513
154582
  }
154514
154583
  async function recordFindingsIfAny(arguments_) {
154515
154584
  if (arguments_.findings.length === 0) {
@@ -154521,35 +154590,401 @@ async function recordFindingsIfAny(arguments_) {
154521
154590
  screenshotData: arguments_.screenshotData
154522
154591
  });
154523
154592
  }
154524
- async function runHookOnce(arguments_) {
154525
- const { context, input, now } = arguments_;
154526
- const start = now();
154593
+ function buildLookup(cache3, hash2) {
154594
+ return {
154595
+ hash: hash2,
154596
+ match: findSimilarAnalyzedScreen({
154597
+ targetHash: hash2,
154598
+ entries: cache3.store.entries(),
154599
+ similarityThreshold: cache3.similarityThreshold
154600
+ })
154601
+ };
154602
+ }
154603
+ async function lookupCache(cache3, screenshotBase64) {
154604
+ if (cache3 === void 0) {
154605
+ return void 0;
154606
+ }
154607
+ const safeCompute = import_neverthrow45.ResultAsync.fromThrowable(
154608
+ cache3.computeScreenshotPhash,
154609
+ () => ({ type: "PHASH_COMPUTE_FAILED" })
154610
+ );
154611
+ const computed = await safeCompute(Buffer.from(screenshotBase64, "base64"));
154612
+ if (computed.isErr()) {
154613
+ return void 0;
154614
+ }
154615
+ return buildLookup(cache3, computed.value);
154616
+ }
154617
+ function emitSkippedEvent(arguments_) {
154618
+ emitRunEvent({
154619
+ onEvent: arguments_.context.onEvent,
154620
+ durationMs: arguments_.durationMs,
154621
+ findingsEmitted: 0,
154622
+ outcome: "skipped_similar",
154623
+ similarDistance: arguments_.distance
154624
+ });
154625
+ }
154626
+ async function executeAndRecord(arguments_) {
154627
+ const { context, input, cacheLookup, start, now } = arguments_;
154527
154628
  const result = await runVisualPass({
154528
154629
  visualMode: context.visualMode,
154529
154630
  screenshotBase64: input.screenshotBase64,
154530
154631
  accessibilityTreeText: input.accessibilityTreeText
154531
154632
  });
154532
- const durationMs = now() - start;
154533
154633
  const outcome = result.isErr() ? outcomeFromError(result.error) : "ok";
154534
- const findings = result.isErr() ? [] : result.value;
154535
- await recordFindingsIfAny({
154536
- context,
154537
- findings,
154538
- screenshotData: input.screenshotBase64
154539
- });
154634
+ const findings = result.isErr() ? [] : result.value.findings;
154635
+ if (result.isOk()) {
154636
+ context.visualUsage.value = nextUsage(context.visualUsage.value, result.value.usage);
154637
+ }
154638
+ await recordFindingsIfAny({ context, findings, screenshotData: input.screenshotBase64 });
154639
+ if (cacheLookup !== void 0 && context.cache !== void 0 && result.isOk()) {
154640
+ context.cache.store.add(cacheLookup.hash);
154641
+ }
154540
154642
  emitRunEvent({
154541
154643
  onEvent: context.onEvent,
154542
- durationMs,
154644
+ durationMs: now() - start,
154543
154645
  findingsEmitted: findings.length,
154544
154646
  outcome
154545
154647
  });
154546
154648
  }
154649
+ async function runHookOnce(arguments_) {
154650
+ const { context, input, now } = arguments_;
154651
+ const start = now();
154652
+ const cacheLookup = await lookupCache(context.cache, input.screenshotBase64);
154653
+ if (cacheLookup?.match.matched === true) {
154654
+ emitSkippedEvent({
154655
+ context,
154656
+ durationMs: now() - start,
154657
+ distance: cacheLookup.match.distance
154658
+ });
154659
+ return;
154660
+ }
154661
+ await executeAndRecord({ context, input, cacheLookup, start, now });
154662
+ }
154663
+ function computeScreenDigest(input) {
154664
+ return (0, import_node_crypto2.createHash)("sha256").update(input.accessibilityTreeText).update(":").update(input.screenshotBase64).digest("hex");
154665
+ }
154666
+ async function runAfterPrevious(previous, arguments_) {
154667
+ await previous;
154668
+ await runHookOnce(arguments_);
154669
+ }
154670
+ async function drainVisualPassHook(pending) {
154671
+ await pending.value;
154672
+ }
154547
154673
  function createVisualPassHook(context) {
154548
154674
  if (context.visualMode.kind === "disabled") {
154549
154675
  return void 0;
154550
154676
  }
154551
154677
  const now = context.now ?? (() => Date.now());
154552
- return async (input) => runHookOnce({ context, input, now });
154678
+ const { lastDigest, pendingPasses } = context;
154679
+ return async (input) => {
154680
+ const digest = computeScreenDigest(input);
154681
+ if (digest === lastDigest.value) {
154682
+ return;
154683
+ }
154684
+ lastDigest.value = digest;
154685
+ pendingPasses.value = runAfterPrevious(pendingPasses.value, { context, input, now });
154686
+ await Promise.resolve();
154687
+ };
154688
+ }
154689
+ function sumTokenUsage(result, visual) {
154690
+ return {
154691
+ inputTokens: result.usage.input_tokens + visual.inputTokens,
154692
+ outputTokens: result.usage.output_tokens + visual.outputTokens,
154693
+ cacheReadInputTokens: result.usage.cache_read_input_tokens + visual.cacheReadInputTokens,
154694
+ cacheCreationInputTokens: result.usage.cache_creation_input_tokens + visual.cacheCreationInputTokens,
154695
+ totalCostUsd: result.total_cost_usd + visual.totalCostUsd
154696
+ };
154697
+ }
154698
+ async function processMessage(message, state) {
154699
+ if (message.type === "assistant" && Array.isArray(message.message.content)) {
154700
+ captureFromAssistant(message.message.content, state);
154701
+ }
154702
+ if (message.type === "user" && Array.isArray(message.message.content)) {
154703
+ captureFromUser(message.message.content, state);
154704
+ }
154705
+ if (message.type === "result") {
154706
+ await drainVisualPassHook(state.visualPassesPending);
154707
+ const resultMessage = message;
154708
+ const { tokenUsage } = state;
154709
+ tokenUsage.value = sumTokenUsage(resultMessage, state.visualUsage.value);
154710
+ if (message.subtype !== "success" && !state.timedOut.value && !state.aborted.value) {
154711
+ return (0, import_neverthrow42.err)(message.errors.join("; "));
154712
+ }
154713
+ return (0, import_neverthrow42.ok)(true);
154714
+ }
154715
+ return (0, import_neverthrow42.ok)(false);
154716
+ }
154717
+ async function processMessages(queryRunner, state) {
154718
+ for await (const message of queryRunner) {
154719
+ const result = await processMessage(message, state);
154720
+ if (result.isErr()) {
154721
+ return (0, import_neverthrow42.err)(result.error);
154722
+ }
154723
+ if (result.value) {
154724
+ break;
154725
+ }
154726
+ }
154727
+ return (0, import_neverthrow42.ok)(null);
154728
+ }
154729
+ function buildCloseQueueFunction(inputQueue) {
154730
+ return () => {
154731
+ inputQueue.close();
154732
+ };
154733
+ }
154734
+ function buildSendMessageFunction(inputQueue) {
154735
+ return (content) => {
154736
+ const message = {
154737
+ type: "user",
154738
+ message: { role: "user", content },
154739
+ parent_tool_use_id: null,
154740
+ isSynthetic: true
154741
+ };
154742
+ inputQueue.enqueue(message);
154743
+ };
154744
+ }
154745
+ function buildAgentState({
154746
+ config: config2,
154747
+ inputQueue
154748
+ }) {
154749
+ return {
154750
+ pendingToolCallNames: /* @__PURE__ */ new Map(),
154751
+ snapshots: [],
154752
+ stepCounter: { value: 0 },
154753
+ findings: [],
154754
+ findingCounter: { value: 0 },
154755
+ sendMessage: buildSendMessageFunction(inputQueue),
154756
+ closeQueue: buildCloseQueueFunction(inputQueue),
154757
+ timedOut: { value: false },
154758
+ aborted: { value: false },
154759
+ onEvent: config2.onEvent,
154760
+ tokenUsage: { value: { ...EMPTY_TOKEN_USAGE } },
154761
+ visualUsage: { value: { ...EMPTY_TOKEN_USAGE } },
154762
+ visualLastDigest: { value: void 0 },
154763
+ visualPassesPending: { value: Promise.resolve() }
154764
+ };
154765
+ }
154766
+ function spawnDetached(options) {
154767
+ const child = (0, import_node_child_process5.spawn)(options.command, options.args, {
154768
+ cwd: options.cwd,
154769
+ env: options.env,
154770
+ stdio: ["pipe", "pipe", "pipe"],
154771
+ detached: true,
154772
+ signal: options.signal
154773
+ });
154774
+ child.stderr.pipe(process.stderr);
154775
+ return {
154776
+ stdin: child.stdin,
154777
+ stdout: child.stdout,
154778
+ get killed() {
154779
+ return child.killed;
154780
+ },
154781
+ get exitCode() {
154782
+ return child.exitCode;
154783
+ },
154784
+ kill: child.kill.bind(child),
154785
+ on: child.on.bind(child),
154786
+ once: child.once.bind(child),
154787
+ off: child.off.bind(child)
154788
+ };
154789
+ }
154790
+ function buildBaseOptions(context) {
154791
+ const { config: config2, mobileIosServer, allowedTools } = context;
154792
+ return {
154793
+ mcpServers: {
154794
+ ...config2.mcpServers,
154795
+ "mobile-ios": mobileIosServer
154796
+ },
154797
+ allowedTools,
154798
+ tools: [],
154799
+ permissionMode: "bypassPermissions",
154800
+ allowDangerouslySkipPermissions: true,
154801
+ spawnClaudeCodeProcess: spawnDetached,
154802
+ thinking: { type: "adaptive" },
154803
+ ...config2.cwd ? { cwd: config2.cwd } : {}
154804
+ };
154805
+ }
154806
+ function buildQueryOptions(context) {
154807
+ const base = buildBaseOptions(context);
154808
+ if (!context.config.signal) {
154809
+ return { options: base, linkedController: void 0 };
154810
+ }
154811
+ const linkedController = new AbortController();
154812
+ return { options: { ...base, abortController: linkedController }, linkedController };
154813
+ }
154814
+ function createAnalyzedScreenStore() {
154815
+ const context = { entries: [] };
154816
+ return {
154817
+ entries: () => context.entries,
154818
+ add: (hash2) => {
154819
+ context.entries.push(hash2);
154820
+ }
154821
+ };
154822
+ }
154823
+ function emptyDirectoryError(directory) {
154824
+ return { type: "ARTBOARD_INDEX_BUILD_FAILED", reason: "EMPTY_DIRECTORY", directory };
154825
+ }
154826
+ function zeroSuccessesError(attempted) {
154827
+ return { type: "ARTBOARD_INDEX_BUILD_FAILED", reason: "ZERO_SUCCESSFUL_PHASHES", attempted };
154828
+ }
154829
+ function compactSuccesses(results) {
154830
+ return results.filter((entry) => entry !== void 0);
154831
+ }
154832
+ function buildArtboardPhashIndex(input) {
154833
+ if (input.artboardNames.length === 0) {
154834
+ return (0, import_neverthrow49.errAsync)(emptyDirectoryError(input.directory ?? ""));
154835
+ }
154836
+ const limit = pLimit(input.concurrency);
154837
+ const tasks = input.artboardNames.map(async (name) => limit(async () => input.computeOne(name)));
154838
+ return import_neverthrow49.ResultAsync.fromSafePromise(Promise.all(tasks)).andThen((results) => {
154839
+ const successful = compactSuccesses(results);
154840
+ if (successful.length === 0) {
154841
+ return (0, import_neverthrow49.errAsync)(zeroSuccessesError(input.artboardNames.length));
154842
+ }
154843
+ return (0, import_neverthrow49.okAsync)(successful);
154844
+ });
154845
+ }
154846
+ var PHASH_ALGO_VERSION = "v1";
154847
+ function wrapIoError(cause) {
154848
+ return { type: "PHASH_CACHE_IO_FAILED", cause };
154849
+ }
154850
+ function cacheFile(directory, key) {
154851
+ const filename = `${key.algoVersion}-${String(key.maxEdgePx)}-${key.fileSha256}.json`;
154852
+ return import_node_path16.default.join(directory, filename);
154853
+ }
154854
+ function isEnoent(cause) {
154855
+ return cause?.code === "ENOENT";
154856
+ }
154857
+ var safeReadFile = import_neverthrow50.ResultAsync.fromThrowable(
154858
+ import_promises20.readFile,
154859
+ wrapIoError
154860
+ );
154861
+ var safeWriteFile4 = import_neverthrow50.ResultAsync.fromThrowable(
154862
+ import_promises20.writeFile,
154863
+ wrapIoError
154864
+ );
154865
+ var safeMkdir2 = import_neverthrow50.ResultAsync.fromThrowable(
154866
+ import_promises20.mkdir,
154867
+ wrapIoError
154868
+ );
154869
+ var safeParsePayload = (0, import_neverthrow50.fromThrowable)(
154870
+ (raw) => JSON.parse(raw),
154871
+ wrapIoError
154872
+ );
154873
+ var safeBigInt = (0, import_neverthrow50.fromThrowable)(BigInt, wrapIoError);
154874
+ function readPhashCache(directory, key) {
154875
+ return safeReadFile(cacheFile(directory, key), "utf8").andThen((raw) => safeParsePayload(raw)).andThen((payload) => safeBigInt(payload.hash)).map((hash2) => hash2).orElse((error48) => {
154876
+ if (isEnoent(error48.cause)) {
154877
+ return (0, import_neverthrow50.okAsync)(void 0);
154878
+ }
154879
+ return (0, import_neverthrow50.errAsync)(error48);
154880
+ });
154881
+ }
154882
+ function writePhashCache(directory, entry) {
154883
+ return safeMkdir2(directory, { recursive: true }).andThen(
154884
+ () => safeWriteFile4(cacheFile(directory, entry.key), JSON.stringify({ hash: entry.hash.toString() }))
154885
+ );
154886
+ }
154887
+ function computeArtboardPhashFactory(deps) {
154888
+ return async (name) => {
154889
+ const buffer = await deps.loadArtboardBuffer(name);
154890
+ if (buffer === void 0) {
154891
+ return void 0;
154892
+ }
154893
+ const fileSha256 = await deps.sha256(buffer);
154894
+ const key = {
154895
+ fileSha256,
154896
+ maxEdgePx: deps.maxEdgePx,
154897
+ algoVersion: PHASH_ALGO_VERSION
154898
+ };
154899
+ const cached2 = await deps.readFromCache(deps.cacheDirectory, key);
154900
+ if (cached2 !== void 0) {
154901
+ return { name, hash: cached2 };
154902
+ }
154903
+ const preprocessed = await deps.preprocess(buffer, deps.maxEdgePx);
154904
+ const hash2 = await deps.computePhash(preprocessed);
154905
+ await deps.writeToCache(deps.cacheDirectory, { key, hash: hash2 });
154906
+ return { name, hash: hash2 };
154907
+ };
154908
+ }
154909
+ var PNG_COMPRESSION_LEVEL = 9;
154910
+ async function runSharp(input) {
154911
+ return (0, import_sharp2.default)(input.buffer).resize({
154912
+ width: input.maxEdgePx,
154913
+ height: input.maxEdgePx,
154914
+ fit: "inside",
154915
+ withoutEnlargement: true
154916
+ }).png({ compressionLevel: PNG_COMPRESSION_LEVEL }).toBuffer();
154917
+ }
154918
+ var safeRunSharp = import_neverthrow51.ResultAsync.fromThrowable(
154919
+ runSharp,
154920
+ (cause) => ({ type: "IMAGE_PREPROCESS_FAILED", cause })
154921
+ );
154922
+ function preprocessImage(input) {
154923
+ return safeRunSharp(input);
154924
+ }
154925
+ var INDEX_BUILD_CONCURRENCY = 4;
154926
+ var HEX_ENCODING = "hex";
154927
+ function returnUndefined() {
154928
+ return void 0;
154929
+ }
154930
+ function returnEmptyArray() {
154931
+ return [];
154932
+ }
154933
+ async function sha256(buffer) {
154934
+ return await Promise.resolve((0, import_node_crypto3.createHash)("sha256").update(buffer).digest(HEX_ENCODING));
154935
+ }
154936
+ async function preprocessForPhash(buffer, maxEdgePx) {
154937
+ const result = await preprocessImage({ buffer, maxEdgePx });
154938
+ return result.match(
154939
+ (preprocessed) => preprocessed,
154940
+ () => buffer
154941
+ );
154942
+ }
154943
+ async function readPhashFromDisk(cacheDirectory, key) {
154944
+ const result = await readPhashCache(cacheDirectory, key);
154945
+ return result.match((hash2) => hash2, returnUndefined);
154946
+ }
154947
+ async function writePhashToDisk(cacheDirectory, entry) {
154948
+ const result = await writePhashCache(cacheDirectory, entry);
154949
+ result.match(returnUndefined, returnUndefined);
154950
+ }
154951
+ async function loadArtboardBuffer(designStore, name) {
154952
+ const result = await designStore.getArtboard(name);
154953
+ return result.match((artboard) => artboard?.buffer, returnUndefined);
154954
+ }
154955
+ async function listArtboardNames(designStore) {
154956
+ const result = await designStore.listArtboards();
154957
+ return result.match(
154958
+ (names) => names,
154959
+ () => []
154960
+ );
154961
+ }
154962
+ function makeComputeOne(arguments_) {
154963
+ return computeArtboardPhashFactory({
154964
+ readFromCache: readPhashFromDisk,
154965
+ writeToCache: writePhashToDisk,
154966
+ loadArtboardBuffer: async (name) => loadArtboardBuffer(arguments_.designStore, name),
154967
+ preprocess: preprocessForPhash,
154968
+ computePhash: computeArtboardPhash,
154969
+ sha256,
154970
+ maxEdgePx: arguments_.maxEdgePx,
154971
+ cacheDirectory: arguments_.runCacheDirectory
154972
+ });
154973
+ }
154974
+ async function computeArtboardPhash(buffer) {
154975
+ const hashString = await (0, import_sharp_phash.default)(buffer);
154976
+ return BigInt(`0b${hashString}`);
154977
+ }
154978
+ async function buildArtboardIndex(arguments_) {
154979
+ const names = await listArtboardNames(arguments_.designStore);
154980
+ const computeOne = makeComputeOne(arguments_);
154981
+ const result = await buildArtboardPhashIndex({
154982
+ artboardNames: names,
154983
+ concurrency: INDEX_BUILD_CONCURRENCY,
154984
+ computeOne,
154985
+ directory: arguments_.runCacheDirectory
154986
+ });
154987
+ return result.match((artboards) => artboards, returnEmptyArray);
154553
154988
  }
154554
154989
  function buildReportFindingTool(input) {
154555
154990
  const findingScreenshotsDirectory = input.config.capabilities.findingScreenshots ? input.config.screenshotsDir : void 0;
@@ -154563,6 +154998,17 @@ function buildReportFindingTool(input) {
154563
154998
  visualMode: input.visualWiring?.mode
154564
154999
  });
154565
155000
  }
155001
+ function buildVisualPassCache(input) {
155002
+ const visual = input.config.visual;
155003
+ if (visual === void 0) {
155004
+ return void 0;
155005
+ }
155006
+ return {
155007
+ store: createAnalyzedScreenStore(),
155008
+ computeScreenshotPhash: computeArtboardPhash,
155009
+ similarityThreshold: HAMMING_THRESHOLD_BY_TOLERANCE[visual.cacheTolerance]
155010
+ };
155011
+ }
154566
155012
  function buildVisualPassHookForInput(input) {
154567
155013
  if (input.visualWiring === void 0 || input.visualWiring.mode.kind === "disabled") {
154568
155014
  return void 0;
@@ -154571,13 +155017,17 @@ function buildVisualPassHookForInput(input) {
154571
155017
  return createVisualPassHook({
154572
155018
  visualMode: input.visualWiring.mode,
154573
155019
  onEvent: input.config.onEvent,
155020
+ visualUsage: input.state.visualUsage,
155021
+ lastDigest: input.state.visualLastDigest,
155022
+ pendingPasses: input.state.visualPassesPending,
154574
155023
  recorder: {
154575
155024
  findings: input.state.findings,
154576
155025
  findingCounter: input.state.findingCounter,
154577
155026
  onEvent: input.config.onEvent,
154578
155027
  screenshotsDir: findingScreenshotsDirectory,
154579
155028
  findingsPath: input.config.findingsPath
154580
- }
155029
+ },
155030
+ cache: buildVisualPassCache(input)
154581
155031
  });
154582
155032
  }
154583
155033
  function buildViewUiTool(input) {
@@ -154763,12 +155213,12 @@ function buildFfmpegArguments(params) {
154763
155213
  }
154764
155214
  var TEMP_SUFFIX = ".compressed.mp4";
154765
155215
  function temporaryOutputFor(inputPath) {
154766
- const directory = import_node_path17.default.dirname(inputPath);
154767
- const base = import_node_path17.default.basename(inputPath, import_node_path17.default.extname(inputPath));
154768
- return import_node_path17.default.join(directory, `${base}${TEMP_SUFFIX}`);
155216
+ const directory = import_node_path18.default.dirname(inputPath);
155217
+ const base = import_node_path18.default.basename(inputPath, import_node_path18.default.extname(inputPath));
155218
+ return import_node_path18.default.join(directory, `${base}${TEMP_SUFFIX}`);
154769
155219
  }
154770
155220
  function spawnFfmpeg2(arguments_) {
154771
- const safeSpawn2 = (0, import_neverthrow50.fromThrowable)(
155221
+ const safeSpawn2 = (0, import_neverthrow54.fromThrowable)(
154772
155222
  (command, spawnArguments) => (0, import_node_child_process6.spawn)(command, spawnArguments),
154773
155223
  (cause) => cause
154774
155224
  );
@@ -154788,7 +155238,7 @@ function awaitFfmpegExit2(child) {
154788
155238
  child.once("exit", (code) => {
154789
155239
  resolve({ code: code ?? -1, stderr });
154790
155240
  });
154791
- return import_neverthrow50.ResultAsync.fromPromise(
155241
+ return import_neverthrow54.ResultAsync.fromPromise(
154792
155242
  promise2,
154793
155243
  (cause) => ({ type: "FFMPEG_SPAWN_FAILED", cause })
154794
155244
  );
@@ -154796,31 +155246,31 @@ function awaitFfmpegExit2(child) {
154796
155246
  function runFfmpeg2(arguments_) {
154797
155247
  const childOrError = spawnFfmpeg2(arguments_);
154798
155248
  if (childOrError instanceof Error) {
154799
- return (0, import_neverthrow50.errAsync)({ type: "FFMPEG_SPAWN_FAILED", cause: childOrError });
155249
+ return (0, import_neverthrow54.errAsync)({ type: "FFMPEG_SPAWN_FAILED", cause: childOrError });
154800
155250
  }
154801
155251
  return awaitFfmpegExit2(childOrError);
154802
155252
  }
154803
155253
  function ensureSuccess2(result) {
154804
155254
  if (result.code === 0) {
154805
- return (0, import_neverthrow50.okAsync)(true);
155255
+ return (0, import_neverthrow54.okAsync)(true);
154806
155256
  }
154807
- return (0, import_neverthrow50.errAsync)({
155257
+ return (0, import_neverthrow54.errAsync)({
154808
155258
  type: "FFMPEG_NONZERO_EXIT",
154809
155259
  code: result.code,
154810
155260
  stderr: result.stderr
154811
155261
  });
154812
155262
  }
154813
- var safeRename = import_neverthrow50.ResultAsync.fromThrowable(
154814
- import_promises21.rename,
155263
+ var safeRename = import_neverthrow54.ResultAsync.fromThrowable(
155264
+ import_promises22.rename,
154815
155265
  (cause) => ({ type: "FFMPEG_SPAWN_FAILED", cause })
154816
155266
  );
154817
155267
  function replaceFile(temporaryPath, finalPath) {
154818
155268
  return safeRename(temporaryPath, finalPath).map(() => finalPath);
154819
155269
  }
154820
155270
  var CLEANED = { type: "CLEANED" };
154821
- var safeUnlink = import_neverthrow50.ResultAsync.fromThrowable(import_promises21.unlink, () => CLEANED);
155271
+ var safeUnlink = import_neverthrow54.ResultAsync.fromThrowable(import_promises22.unlink, () => CLEANED);
154822
155272
  function cleanupTemporaryAndPropagate(temporaryPath, error48) {
154823
- return safeUnlink(temporaryPath).orElse(() => (0, import_neverthrow50.okAsync)(CLEANED)).andThen(() => (0, import_neverthrow50.errAsync)(error48));
155273
+ return safeUnlink(temporaryPath).orElse(() => (0, import_neverthrow54.okAsync)(CLEANED)).andThen(() => (0, import_neverthrow54.errAsync)(error48));
154824
155274
  }
154825
155275
  function compressRecording(inputPath, options = DEFAULT_VIDEO_COMPRESS_OPTIONS) {
154826
155276
  const temporaryPath = temporaryOutputFor(inputPath);
@@ -154828,12 +155278,12 @@ function compressRecording(inputPath, options = DEFAULT_VIDEO_COMPRESS_OPTIONS)
154828
155278
  return runFfmpeg2(arguments_).andThen(ensureSuccess2).andThen(() => replaceFile(temporaryPath, inputPath)).orElse((error48) => cleanupTemporaryAndPropagate(temporaryPath, error48));
154829
155279
  }
154830
155280
  function spawnRecorder(outputPath) {
154831
- const safeMkdirSync = (0, import_neverthrow51.fromThrowable)(import_node_fs5.mkdirSync, (cause) => cause);
154832
- const safeSpawn2 = (0, import_neverthrow51.fromThrowable)(
155281
+ const safeMkdirSync = (0, import_neverthrow55.fromThrowable)(import_node_fs5.mkdirSync, (cause) => cause);
155282
+ const safeSpawn2 = (0, import_neverthrow55.fromThrowable)(
154833
155283
  (command, arguments_) => (0, import_node_child_process7.spawn)(command, arguments_),
154834
155284
  (cause) => cause
154835
155285
  );
154836
- const mkdirResult = safeMkdirSync(import_node_path18.default.dirname(outputPath), { recursive: true });
155286
+ const mkdirResult = safeMkdirSync(import_node_path19.default.dirname(outputPath), { recursive: true });
154837
155287
  if (mkdirResult.isErr()) {
154838
155288
  return mkdirResult.error;
154839
155289
  }
@@ -154858,7 +155308,7 @@ function earlyExitError(code) {
154858
155308
  function waitForRecordingStart(proc) {
154859
155309
  const { stderr } = proc;
154860
155310
  if (!stderr) {
154861
- return (0, import_neverthrow51.errAsync)({ type: "SPAWN_FAILED", cause: new RangeError("proc has no stderr pipe") });
155311
+ return (0, import_neverthrow55.errAsync)({ type: "SPAWN_FAILED", cause: new RangeError("proc has no stderr pipe") });
154862
155312
  }
154863
155313
  const { promise: promise2, resolve, reject } = Promise.withResolvers();
154864
155314
  proc.once("error", reject);
@@ -154874,7 +155324,7 @@ function waitForRecordingStart(proc) {
154874
155324
  resolve({ process: proc, startedAt: Date.now() });
154875
155325
  }
154876
155326
  });
154877
- return import_neverthrow51.ResultAsync.fromPromise(
155327
+ return import_neverthrow55.ResultAsync.fromPromise(
154878
155328
  promise2,
154879
155329
  (cause) => ({ type: "SPAWN_FAILED", cause })
154880
155330
  );
@@ -154882,7 +155332,7 @@ function waitForRecordingStart(proc) {
154882
155332
  function startRecording(outputPath) {
154883
155333
  const procOrError = spawnRecorder(outputPath);
154884
155334
  if (procOrError instanceof Error) {
154885
- return (0, import_neverthrow51.errAsync)({ type: "SPAWN_FAILED", cause: procOrError });
155335
+ return (0, import_neverthrow55.errAsync)({ type: "SPAWN_FAILED", cause: procOrError });
154886
155336
  }
154887
155337
  return waitForRecordingStart(procOrError);
154888
155338
  }
@@ -154897,7 +155347,7 @@ function stopRecording(handle) {
154897
155347
  } else {
154898
155348
  resolve(true);
154899
155349
  }
154900
- return import_neverthrow51.ResultAsync.fromPromise(
155350
+ return import_neverthrow55.ResultAsync.fromPromise(
154901
155351
  promise2,
154902
155352
  (cause) => ({ type: "STOP_FAILED", cause })
154903
155353
  );
@@ -154907,7 +155357,7 @@ var toRecordingError = (cause) => ({
154907
155357
  cause
154908
155358
  });
154909
155359
  function stopAndPropagate(handle, originalError) {
154910
- return stopRecording(handle).mapErr(toRecordingError).andThen(() => (0, import_neverthrow49.errAsync)(originalError)).orElse(() => (0, import_neverthrow49.errAsync)(originalError));
155360
+ return stopRecording(handle).mapErr(toRecordingError).andThen(() => (0, import_neverthrow53.errAsync)(originalError)).orElse(() => (0, import_neverthrow53.errAsync)(originalError));
154911
155361
  }
154912
155362
  function compressIfRequested({
154913
155363
  videoPath,
@@ -154915,7 +155365,7 @@ function compressIfRequested({
154915
155365
  result
154916
155366
  }) {
154917
155367
  if (!shouldCompress) {
154918
- return (0, import_neverthrow49.okAsync)(result);
155368
+ return (0, import_neverthrow53.okAsync)(result);
154919
155369
  }
154920
155370
  return compressRecording(videoPath).map(() => result).mapErr((cause) => ({ type: "VIDEO_COMPRESS_FAILED", cause }));
154921
155371
  }
@@ -154945,196 +155395,6 @@ function startAndRun(params) {
154945
155395
  });
154946
155396
  });
154947
155397
  }
154948
- function emptyDirectoryError(directory) {
154949
- return { type: "ARTBOARD_INDEX_BUILD_FAILED", reason: "EMPTY_DIRECTORY", directory };
154950
- }
154951
- function zeroSuccessesError(attempted) {
154952
- return { type: "ARTBOARD_INDEX_BUILD_FAILED", reason: "ZERO_SUCCESSFUL_PHASHES", attempted };
154953
- }
154954
- function compactSuccesses(results) {
154955
- return results.filter((entry) => entry !== void 0);
154956
- }
154957
- function buildArtboardPhashIndex(input) {
154958
- if (input.artboardNames.length === 0) {
154959
- return (0, import_neverthrow53.errAsync)(emptyDirectoryError(input.directory ?? ""));
154960
- }
154961
- const limit = pLimit(input.concurrency);
154962
- const tasks = input.artboardNames.map(async (name) => limit(async () => input.computeOne(name)));
154963
- return import_neverthrow53.ResultAsync.fromSafePromise(Promise.all(tasks)).andThen((results) => {
154964
- const successful = compactSuccesses(results);
154965
- if (successful.length === 0) {
154966
- return (0, import_neverthrow53.errAsync)(zeroSuccessesError(input.artboardNames.length));
154967
- }
154968
- return (0, import_neverthrow53.okAsync)(successful);
154969
- });
154970
- }
154971
- var PHASH_ALGO_VERSION = "v1";
154972
- function wrapIoError(cause) {
154973
- return { type: "PHASH_CACHE_IO_FAILED", cause };
154974
- }
154975
- function cacheFile(directory, key) {
154976
- const filename = `${key.algoVersion}-${String(key.maxEdgePx)}-${key.fileSha256}.json`;
154977
- return import_node_path19.default.join(directory, filename);
154978
- }
154979
- function isEnoent(cause) {
154980
- return cause?.code === "ENOENT";
154981
- }
154982
- var safeReadFile = import_neverthrow54.ResultAsync.fromThrowable(
154983
- import_promises22.readFile,
154984
- wrapIoError
154985
- );
154986
- var safeWriteFile4 = import_neverthrow54.ResultAsync.fromThrowable(
154987
- import_promises22.writeFile,
154988
- wrapIoError
154989
- );
154990
- var safeMkdir2 = import_neverthrow54.ResultAsync.fromThrowable(
154991
- import_promises22.mkdir,
154992
- wrapIoError
154993
- );
154994
- var safeParsePayload = (0, import_neverthrow54.fromThrowable)(
154995
- (raw) => JSON.parse(raw),
154996
- wrapIoError
154997
- );
154998
- var safeBigInt = (0, import_neverthrow54.fromThrowable)(BigInt, wrapIoError);
154999
- function readPhashCache(directory, key) {
155000
- return safeReadFile(cacheFile(directory, key), "utf8").andThen((raw) => safeParsePayload(raw)).andThen((payload) => safeBigInt(payload.hash)).map((hash2) => hash2).orElse((error48) => {
155001
- if (isEnoent(error48.cause)) {
155002
- return (0, import_neverthrow54.okAsync)(void 0);
155003
- }
155004
- return (0, import_neverthrow54.errAsync)(error48);
155005
- });
155006
- }
155007
- function writePhashCache(directory, entry) {
155008
- return safeMkdir2(directory, { recursive: true }).andThen(
155009
- () => safeWriteFile4(cacheFile(directory, entry.key), JSON.stringify({ hash: entry.hash.toString() }))
155010
- );
155011
- }
155012
- function computeArtboardPhashFactory(deps) {
155013
- return async (name) => {
155014
- const buffer = await deps.loadArtboardBuffer(name);
155015
- if (buffer === void 0) {
155016
- return void 0;
155017
- }
155018
- const fileSha256 = await deps.sha256(buffer);
155019
- const key = {
155020
- fileSha256,
155021
- maxEdgePx: deps.maxEdgePx,
155022
- algoVersion: PHASH_ALGO_VERSION
155023
- };
155024
- const cached2 = await deps.readFromCache(deps.cacheDirectory, key);
155025
- if (cached2 !== void 0) {
155026
- return { name, hash: cached2 };
155027
- }
155028
- const preprocessed = await deps.preprocess(buffer, deps.maxEdgePx);
155029
- const hash2 = await deps.computePhash(preprocessed);
155030
- await deps.writeToCache(deps.cacheDirectory, { key, hash: hash2 });
155031
- return { name, hash: hash2 };
155032
- };
155033
- }
155034
- var PNG_COMPRESSION_LEVEL = 9;
155035
- async function runSharp(input) {
155036
- return (0, import_sharp2.default)(input.buffer).resize({
155037
- width: input.maxEdgePx,
155038
- height: input.maxEdgePx,
155039
- fit: "inside",
155040
- withoutEnlargement: true
155041
- }).png({ compressionLevel: PNG_COMPRESSION_LEVEL }).toBuffer();
155042
- }
155043
- var safeRunSharp = import_neverthrow55.ResultAsync.fromThrowable(
155044
- runSharp,
155045
- (cause) => ({ type: "IMAGE_PREPROCESS_FAILED", cause })
155046
- );
155047
- function preprocessImage(input) {
155048
- return safeRunSharp(input);
155049
- }
155050
- var INDEX_BUILD_CONCURRENCY = 4;
155051
- var HEX_ENCODING = "hex";
155052
- function returnUndefined() {
155053
- return void 0;
155054
- }
155055
- function returnEmptyArray() {
155056
- return [];
155057
- }
155058
- async function sha256(buffer) {
155059
- return await Promise.resolve((0, import_node_crypto3.createHash)("sha256").update(buffer).digest(HEX_ENCODING));
155060
- }
155061
- async function preprocessForPhash(buffer, maxEdgePx) {
155062
- const result = await preprocessImage({ buffer, maxEdgePx });
155063
- return result.match(
155064
- (preprocessed) => preprocessed,
155065
- () => buffer
155066
- );
155067
- }
155068
- async function readPhashFromDisk(cacheDirectory, key) {
155069
- const result = await readPhashCache(cacheDirectory, key);
155070
- return result.match((hash2) => hash2, returnUndefined);
155071
- }
155072
- async function writePhashToDisk(cacheDirectory, entry) {
155073
- const result = await writePhashCache(cacheDirectory, entry);
155074
- result.match(returnUndefined, returnUndefined);
155075
- }
155076
- async function loadArtboardBuffer(designStore, name) {
155077
- const result = await designStore.getArtboard(name);
155078
- return result.match((artboard) => artboard?.buffer, returnUndefined);
155079
- }
155080
- async function listArtboardNames(designStore) {
155081
- const result = await designStore.listArtboards();
155082
- return result.match(
155083
- (names) => names,
155084
- () => []
155085
- );
155086
- }
155087
- function makeComputeOne(arguments_) {
155088
- return computeArtboardPhashFactory({
155089
- readFromCache: readPhashFromDisk,
155090
- writeToCache: writePhashToDisk,
155091
- loadArtboardBuffer: async (name) => loadArtboardBuffer(arguments_.designStore, name),
155092
- preprocess: preprocessForPhash,
155093
- computePhash: computeArtboardPhash,
155094
- sha256,
155095
- maxEdgePx: arguments_.maxEdgePx,
155096
- cacheDirectory: arguments_.runCacheDirectory
155097
- });
155098
- }
155099
- async function computeArtboardPhash(buffer) {
155100
- const hashString = await (0, import_sharp_phash.default)(buffer);
155101
- return BigInt(`0b${hashString}`);
155102
- }
155103
- async function buildArtboardIndex(arguments_) {
155104
- const names = await listArtboardNames(arguments_.designStore);
155105
- const computeOne = makeComputeOne(arguments_);
155106
- const result = await buildArtboardPhashIndex({
155107
- artboardNames: names,
155108
- concurrency: INDEX_BUILD_CONCURRENCY,
155109
- computeOne,
155110
- directory: arguments_.runCacheDirectory
155111
- });
155112
- return result.match((artboards) => artboards, returnEmptyArray);
155113
- }
155114
- var MATCH_TOLERANCE_VALUES = ["strict", "balanced", "loose"];
155115
- var STRICT_HAMMING_THRESHOLD = 6;
155116
- var BALANCED_HAMMING_THRESHOLD = 12;
155117
- var LOOSE_HAMMING_THRESHOLD = 20;
155118
- var HAMMING_THRESHOLD_BY_TOLERANCE = {
155119
- strict: STRICT_HAMMING_THRESHOLD,
155120
- balanced: BALANCED_HAMMING_THRESHOLD,
155121
- loose: LOOSE_HAMMING_THRESHOLD
155122
- };
155123
- function hammingDistance(left, right) {
155124
- const xor2 = left ^ right;
155125
- return (xor2.toString(2).match(/1/g) ?? []).length;
155126
- }
155127
- function selectTopK(input) {
155128
- const scored = input.candidates.map(
155129
- (candidate) => ({
155130
- name: candidate.name,
155131
- distance: hammingDistance(input.target, candidate.hash)
155132
- })
155133
- );
155134
- const within = scored.filter((entry) => entry.distance <= input.threshold);
155135
- const sorted = within.toSorted((left, right) => left.distance - right.distance);
155136
- return sorted.slice(0, input.topK);
155137
- }
155138
155398
  function parseMeta(raw) {
155139
155399
  const parsed = jsYaml.load(raw);
155140
155400
  if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
@@ -155150,10 +155410,10 @@ async function readAndParseSidecar(sidecarPath) {
155150
155410
  return parseMeta(raw);
155151
155411
  }
155152
155412
  function readSidecarFile(sidecarPath) {
155153
- return (0, import_neverthrow56.fromAsyncThrowable)(
155413
+ return (0, import_neverthrow57.fromAsyncThrowable)(
155154
155414
  readAndParseSidecar,
155155
155415
  () => ({})
155156
- )(sidecarPath).orElse(() => (0, import_neverthrow56.okAsync)({}));
155416
+ )(sidecarPath).orElse(() => (0, import_neverthrow57.okAsync)({}));
155157
155417
  }
155158
155418
  function isEnoent2(error48) {
155159
155419
  return error48?.code === "ENOENT";
@@ -155162,13 +155422,13 @@ function wrapFsError(cause) {
155162
155422
  return { type: "FS_ERROR", cause };
155163
155423
  }
155164
155424
  function toFsError(fsError) {
155165
- return (0, import_neverthrow56.errAsync)(fsError);
155425
+ return (0, import_neverthrow57.errAsync)(fsError);
155166
155426
  }
155167
155427
  function missingBuffer() {
155168
- return (0, import_neverthrow56.okAsync)(void 0);
155428
+ return (0, import_neverthrow57.okAsync)(void 0);
155169
155429
  }
155170
155430
  function missingArtboard() {
155171
- return (0, import_neverthrow56.okAsync)(void 0);
155431
+ return (0, import_neverthrow57.okAsync)(void 0);
155172
155432
  }
155173
155433
  var FsDesignStore = class {
155174
155434
  designsDirectory;
@@ -155176,12 +155436,12 @@ var FsDesignStore = class {
155176
155436
  this.designsDirectory = designsDirectory;
155177
155437
  }
155178
155438
  listArtboards() {
155179
- return (0, import_neverthrow56.fromAsyncThrowable)(
155439
+ return (0, import_neverthrow57.fromAsyncThrowable)(
155180
155440
  import_promises23.readdir,
155181
155441
  wrapFsError
155182
155442
  )(this.designsDirectory).orElse((fsError) => {
155183
155443
  if (fsError.type === "FS_ERROR" && isEnoent2(fsError.cause)) {
155184
- return (0, import_neverthrow56.okAsync)([]);
155444
+ return (0, import_neverthrow57.okAsync)([]);
155185
155445
  }
155186
155446
  return toFsError(fsError);
155187
155447
  }).map(
@@ -155191,7 +155451,7 @@ var FsDesignStore = class {
155191
155451
  getArtboard(filename) {
155192
155452
  const pngPath = import_node_path20.default.join(this.designsDirectory, `${filename}.png`);
155193
155453
  const sidecarPath = import_node_path20.default.join(this.designsDirectory, `${filename}.meta.yaml`);
155194
- return (0, import_neverthrow56.fromAsyncThrowable)(
155454
+ return (0, import_neverthrow57.fromAsyncThrowable)(
155195
155455
  import_promises23.readFile,
155196
155456
  wrapFsError
155197
155457
  )(pngPath).orElse((fsError) => {
@@ -155385,7 +155645,7 @@ function toUndefined() {
155385
155645
  return void 0;
155386
155646
  }
155387
155647
  async function resolvePhashTarget(screenshot, compute) {
155388
- const safeCompute = import_neverthrow57.ResultAsync.fromThrowable(
155648
+ const safeCompute = import_neverthrow58.ResultAsync.fromThrowable(
155389
155649
  compute,
155390
155650
  (cause) => ({ type: "PHASH_COMPUTE_FAILED", cause })
155391
155651
  );
@@ -155409,7 +155669,7 @@ var SCREENSHOT_PHASH_CACHE_CAPACITY = 32;
155409
155669
  var TOKENS_PER_READ_ARTBOARD_FETCH = 2e3;
155410
155670
  var HEX_ENCODING2 = "hex";
155411
155671
  function bufferKey(buffer) {
155412
- return (0, import_node_crypto2.createHash)("sha256").update(buffer).digest(HEX_ENCODING2);
155672
+ return (0, import_node_crypto4.createHash)("sha256").update(buffer).digest(HEX_ENCODING2);
155413
155673
  }
155414
155674
  async function computeScreenshotPhashWithCache(buffer, context) {
155415
155675
  const key = bufferKey(buffer);
@@ -155424,9 +155684,9 @@ async function computeScreenshotPhashWithCache(buffer, context) {
155424
155684
  function adaptGetArtboard(designStore, name) {
155425
155685
  return designStore.getArtboard(name).andThen((artboard) => {
155426
155686
  if (artboard === void 0) {
155427
- return (0, import_neverthrow52.errAsync)({ type: "ARTBOARD_NOT_FOUND" });
155687
+ return (0, import_neverthrow56.errAsync)({ type: "ARTBOARD_NOT_FOUND" });
155428
155688
  }
155429
- return (0, import_neverthrow52.okAsync)({
155689
+ return (0, import_neverthrow56.okAsync)({
155430
155690
  buffer: artboard.buffer,
155431
155691
  lastUpdated: artboard.lastUpdated
155432
155692
  });
@@ -156100,25 +156360,25 @@ function direntToSpecEntry(directory, entry) {
156100
156360
  return [];
156101
156361
  }
156102
156362
  function scanDirectory(directory) {
156103
- const safeReaddir5 = (0, import_neverthrow58.fromAsyncThrowable)(
156363
+ const safeReaddir5 = (0, import_neverthrow59.fromAsyncThrowable)(
156104
156364
  async () => (0, import_promises24.readdir)(directory, { withFileTypes: true }),
156105
156365
  (cause) => ({ type: "DIR_READ_FAILED", dir: directory, cause })
156106
156366
  );
156107
- return safeReaddir5().orElse((error48) => isNotFound(error48.cause) ? (0, import_neverthrow58.okAsync)([]) : (0, import_neverthrow58.errAsync)(error48)).map(
156367
+ return safeReaddir5().orElse((error48) => isNotFound(error48.cause) ? (0, import_neverthrow59.okAsync)([]) : (0, import_neverthrow59.errAsync)(error48)).map(
156108
156368
  (entries) => entries.flatMap((entry) => direntToSpecEntry(directory, entry))
156109
156369
  );
156110
156370
  }
156111
156371
  function readEntries(entries) {
156112
- return import_neverthrow58.ResultAsync.combine(entries.map((entry) => readEntry2(entry))).map(
156372
+ return import_neverthrow59.ResultAsync.combine(entries.map((entry) => readEntry2(entry))).map(
156113
156373
  (results) => results.flat()
156114
156374
  );
156115
156375
  }
156116
156376
  function readEntry2(entry) {
156117
- const safeReadFile22 = (0, import_neverthrow58.fromAsyncThrowable)(
156377
+ const safeReadFile22 = (0, import_neverthrow59.fromAsyncThrowable)(
156118
156378
  async () => (0, import_promises24.readFile)(entry.path, "utf8"),
156119
156379
  (cause) => ({ type: "FILE_READ_FAILED", path: entry.path, cause })
156120
156380
  );
156121
- return safeReadFile22().map((content) => [{ name: entry.name, content }]).orElse((error48) => entry.required ? (0, import_neverthrow58.errAsync)(error48) : (0, import_neverthrow58.okAsync)([]));
156381
+ return safeReadFile22().map((content) => [{ name: entry.name, content }]).orElse((error48) => entry.required ? (0, import_neverthrow59.errAsync)(error48) : (0, import_neverthrow59.okAsync)([]));
156122
156382
  }
156123
156383
  function specNameFromPath(filePath) {
156124
156384
  const parts = filePath.split("/");
@@ -156161,7 +156421,7 @@ function toParsedSpec(name, raw) {
156161
156421
  })).mapErr((cause) => ({ type: "SPEC_PARSE_FAILED", specName: name, cause }));
156162
156422
  }
156163
156423
  function parseSpecs(resolvedSpecs) {
156164
- return import_neverthrow48.Result.combine(resolvedSpecs.map((spec) => toParsedSpec(spec.name, spec.content)));
156424
+ return import_neverthrow52.Result.combine(resolvedSpecs.map((spec) => toParsedSpec(spec.name, spec.content)));
156165
156425
  }
156166
156426
  function toArtifacts(result, runPaths) {
156167
156427
  return {
@@ -156217,7 +156477,7 @@ function collectAndFinalize({
156217
156477
  }
156218
156478
  function resolveAndParseSpecs(safeConfig) {
156219
156479
  if (safeConfig.mode === "freestyle") {
156220
- return (0, import_neverthrow48.okAsync)([]);
156480
+ return (0, import_neverthrow52.okAsync)([]);
156221
156481
  }
156222
156482
  return resolveSpecs(safeConfig).mapErr((cause) => ({ type: "SPEC_RESOLVE_FAILED", cause })).andThen((specs) => parseSpecs(specs));
156223
156483
  }
@@ -156235,7 +156495,7 @@ function runPipeline2({
156235
156495
  function resolveWiring(safeConfig, runPaths) {
156236
156496
  const visual = safeConfig.visual;
156237
156497
  if (visual === void 0) {
156238
- return import_neverthrow48.ResultAsync.fromSafePromise(
156498
+ return import_neverthrow52.ResultAsync.fromSafePromise(
156239
156499
  Promise.resolve({
156240
156500
  mode: { kind: "disabled" },
156241
156501
  tools: [],
@@ -156244,11 +156504,11 @@ function resolveWiring(safeConfig, runPaths) {
156244
156504
  );
156245
156505
  }
156246
156506
  const mode = resolveVisualMode({ enabled: visual.enabled, designsDir: visual.designsDir });
156247
- return import_neverthrow48.ResultAsync.fromSafePromise(
156507
+ return import_neverthrow52.ResultAsync.fromSafePromise(
156248
156508
  resolveExplorerVisualWiring({
156249
156509
  mode,
156250
156510
  visualConfig: visual,
156251
- runCacheDirectory: import_node_path16.default.join(runPaths.baseDir, PHASH_CACHE_SUBDIRECTORY)
156511
+ runCacheDirectory: import_node_path17.default.join(runPaths.baseDir, PHASH_CACHE_SUBDIRECTORY)
156252
156512
  })
156253
156513
  );
156254
156514
  }
@@ -156269,18 +156529,18 @@ function runExplorer(config2) {
156269
156529
  date: date5
156270
156530
  });
156271
156531
  if (runPathsResult.isErr()) {
156272
- return (0, import_neverthrow48.errAsync)({ type: "RUN_PATHS_FAILED", cause: runPathsResult.error });
156532
+ return (0, import_neverthrow52.errAsync)({ type: "RUN_PATHS_FAILED", cause: runPathsResult.error });
156273
156533
  }
156274
156534
  const runPaths = runPathsResult.value;
156275
156535
  if (config2.signal?.aborted) {
156276
- return (0, import_neverthrow48.okAsync)(
156536
+ return (0, import_neverthrow52.okAsync)(
156277
156537
  toArtifacts({ findings: [], snapshots: [], tokenUsage: EMPTY_TOKEN_USAGE }, runPaths)
156278
156538
  );
156279
156539
  }
156280
156540
  const safeConfig = buildSafeConfig(config2, runPaths);
156281
156541
  safeConfig.onEvent?.({ type: "STAGE_START", agent: "explorer" });
156282
- return import_neverthrow48.ResultAsync.fromSafePromise(
156283
- (0, import_promises20.mkdir)(runPaths.screenshotsDir, { recursive: true }).catch(() => null)
156542
+ return import_neverthrow52.ResultAsync.fromSafePromise(
156543
+ (0, import_promises21.mkdir)(runPaths.screenshotsDir, { recursive: true }).catch(() => null)
156284
156544
  ).andThen(() => resolveWiring(safeConfig, runPaths)).andThen((visualWiring) => runPipeline2({ safeConfig, runPaths, start, visualWiring }));
156285
156545
  }
156286
156546
  var MAX_CANDIDATE_COUNT = 10;
@@ -156300,7 +156560,8 @@ var visualConfigSchema = external_exports.object({
156300
156560
  candidateCount: external_exports.number().int().positive().max(MAX_CANDIDATE_COUNT).default(DEFAULT_CANDIDATE_COUNT),
156301
156561
  matchTolerance: external_exports.enum(MATCH_TOLERANCE_VALUES).default("balanced"),
156302
156562
  preprocessMaxEdgePx: external_exports.number().int().positive().default(DEFAULT_PREPROCESS_MAX_EDGE_PX),
156303
- readArtboardImageTokenBudget: external_exports.number().int().positive().default(DEFAULT_READ_ARTBOARD_IMAGE_TOKEN_BUDGET)
156563
+ readArtboardImageTokenBudget: external_exports.number().int().positive().default(DEFAULT_READ_ARTBOARD_IMAGE_TOKEN_BUDGET),
156564
+ cacheTolerance: external_exports.enum(MATCH_TOLERANCE_VALUES).default("strict")
156304
156565
  }).strict();
156305
156566
  var DEFAULT_VISUAL = visualConfigSchema.parse({});
156306
156567
  var explorerConfigSchema = agentBaseConfigSchema.extend({
@@ -156315,13 +156576,13 @@ var explorerConfigSchema = agentBaseConfigSchema.extend({
156315
156576
 
156316
156577
  // ../../packages/pipeline/dist/index.js
156317
156578
  var import_node_fs6 = require("node:fs");
156318
- var import_neverthrow61 = __toESM(require_index_cjs(), 1);
156319
156579
  var import_neverthrow62 = __toESM(require_index_cjs(), 1);
156320
156580
  var import_neverthrow63 = __toESM(require_index_cjs(), 1);
156321
- var import_node_fs7 = require("node:fs");
156322
156581
  var import_neverthrow64 = __toESM(require_index_cjs(), 1);
156323
- var import_node_fs8 = require("node:fs");
156582
+ var import_node_fs7 = require("node:fs");
156324
156583
  var import_neverthrow65 = __toESM(require_index_cjs(), 1);
156584
+ var import_node_fs8 = require("node:fs");
156585
+ var import_neverthrow66 = __toESM(require_index_cjs(), 1);
156325
156586
  function createDefaultMcpServers(udid) {
156326
156587
  return {
156327
156588
  "mobile-ios": createMobileIosServer(udid)
@@ -156346,7 +156607,7 @@ function analyserFallback({
156346
156607
  attempts: ANALYSER_RETRY_ATTEMPTS,
156347
156608
  cause
156348
156609
  });
156349
- return (0, import_neverthrow60.okAsync)(artifacts.findings);
156610
+ return (0, import_neverthrow61.okAsync)(artifacts.findings);
156350
156611
  }
156351
156612
  function runAnalyserWithFallback(params) {
156352
156613
  const { artifacts, config: config2, onEvent } = params;
@@ -156358,7 +156619,7 @@ function resolveVisualFindings({
156358
156619
  onEvent
156359
156620
  }) {
156360
156621
  if (config2.analyser === void 0 || config2.signal?.aborted) {
156361
- return (0, import_neverthrow60.okAsync)(artifacts.findings);
156622
+ return (0, import_neverthrow61.okAsync)(artifacts.findings);
156362
156623
  }
156363
156624
  return runAnalyserWithFallback({ artifacts, config: config2, onEvent });
156364
156625
  }
@@ -156368,7 +156629,7 @@ function unmergedFallback(allFindings, onEvent) {
156368
156629
  agent: CONSOLIDATOR_AGENT,
156369
156630
  message: "Consolidation failed, returning unmerged findings"
156370
156631
  });
156371
- return (0, import_neverthrow60.okAsync)({ findings: allFindings, dismissed: [] });
156632
+ return (0, import_neverthrow61.okAsync)({ findings: allFindings, dismissed: [] });
156372
156633
  }
156373
156634
  function mergeWithFallback(options) {
156374
156635
  const { artifacts, visualFindings, runId, dismissals, consolidatorConfig, onEvent } = options;
@@ -156387,7 +156648,7 @@ function consolidate(options) {
156387
156648
  const { artifacts, runId, dismissals, config: config2, consolidatorConfig, onEvent } = options;
156388
156649
  return resolveVisualFindings({ artifacts, config: config2, onEvent }).andThen((visualFindings) => {
156389
156650
  if (config2.signal?.aborted) {
156390
- return (0, import_neverthrow60.okAsync)({ findings: artifacts.findings, dismissed: [] });
156651
+ return (0, import_neverthrow61.okAsync)({ findings: artifacts.findings, dismissed: [] });
156391
156652
  }
156392
156653
  return mergeWithFallback({
156393
156654
  artifacts,
@@ -156434,7 +156695,7 @@ function filterByConfidence(findings, options) {
156434
156695
  dropped: findings.filter((finding) => !passes(finding, options)).map((finding) => ({ finding, reason: "low-confidence" }))
156435
156696
  };
156436
156697
  }
156437
- var writeOutputFile = (0, import_neverthrow61.fromThrowable)(
156698
+ var writeOutputFile = (0, import_neverthrow62.fromThrowable)(
156438
156699
  (params) => {
156439
156700
  const { findingsPath, outputDirectory, json: json3 } = params;
156440
156701
  (0, import_node_fs6.mkdirSync)(outputDirectory, { recursive: true });
@@ -156483,8 +156744,8 @@ function buildExplorerConfig({
156483
156744
  function getDismissalsPathOverride() {
156484
156745
  return process.env.QA_DISMISSALS_PATH;
156485
156746
  }
156486
- var safeReadFile2 = (0, import_neverthrow64.fromThrowable)((filePath) => (0, import_node_fs7.readFileSync)(filePath, "utf8"));
156487
- var safeParseJson2 = (0, import_neverthrow64.fromThrowable)(JSON.parse);
156747
+ var safeReadFile2 = (0, import_neverthrow65.fromThrowable)((filePath) => (0, import_node_fs7.readFileSync)(filePath, "utf8"));
156748
+ var safeParseJson2 = (0, import_neverthrow65.fromThrowable)(JSON.parse);
156488
156749
  function isEnoent3(error48) {
156489
156750
  if (!(error48 instanceof Error)) {
156490
156751
  return false;
@@ -156496,19 +156757,19 @@ function loadDismissals(filePath) {
156496
156757
  const readResult = safeReadFile2(filePath);
156497
156758
  if (readResult.isErr()) {
156498
156759
  if (isEnoent3(readResult.error)) {
156499
- return (0, import_neverthrow64.ok)([]);
156760
+ return (0, import_neverthrow65.ok)([]);
156500
156761
  }
156501
- return (0, import_neverthrow64.err)({ type: "DISMISSALS_LOAD_FAILED", cause: readResult.error });
156762
+ return (0, import_neverthrow65.err)({ type: "DISMISSALS_LOAD_FAILED", cause: readResult.error });
156502
156763
  }
156503
156764
  return safeParseJson2(readResult.value).mapErr((cause) => ({ type: "DISMISSALS_LOAD_FAILED", cause })).andThen((data) => {
156504
156765
  const store = data;
156505
156766
  if (!Array.isArray(store.dismissed)) {
156506
- return (0, import_neverthrow64.err)({
156767
+ return (0, import_neverthrow65.err)({
156507
156768
  type: "DISMISSALS_LOAD_FAILED",
156508
156769
  cause: "invalid shape: dismissed is not an array"
156509
156770
  });
156510
156771
  }
156511
- return (0, import_neverthrow64.ok)(store.dismissed);
156772
+ return (0, import_neverthrow65.ok)(store.dismissed);
156512
156773
  });
156513
156774
  }
156514
156775
  var ISO_DATE_LENGTH2 = 10;
@@ -156518,7 +156779,7 @@ function computeNextRunId(entries) {
156518
156779
  const max = parsed.length === 0 ? 0 : Math.max(...parsed);
156519
156780
  return String(max + 1).padStart(RUN_ID_PAD_LENGTH, "0");
156520
156781
  }
156521
- var safeReaddirSync = (0, import_neverthrow65.fromThrowable)((directory) => (0, import_node_fs8.readdirSync)(directory));
156782
+ var safeReaddirSync = (0, import_neverthrow66.fromThrowable)((directory) => (0, import_node_fs8.readdirSync)(directory));
156522
156783
  function nextRunId(outputDirectory, date5) {
156523
156784
  const entries = safeReaddirSync(`${outputDirectory}/${date5}`).unwrapOr([]);
156524
156785
  return computeNextRunId(entries);
@@ -156530,15 +156791,15 @@ function resolvePipelineConfig({
156530
156791
  const runId = config2.runId ?? nextRunId(config2.outputDir, date5);
156531
156792
  const runPathsResult = resolveRunPaths({ outputDirectory: config2.outputDir, runId, date: date5 });
156532
156793
  if (runPathsResult.isErr()) {
156533
- return (0, import_neverthrow63.err)({ type: "RUN_PATHS_FAILED", cause: runPathsResult.error });
156794
+ return (0, import_neverthrow64.err)({ type: "RUN_PATHS_FAILED", cause: runPathsResult.error });
156534
156795
  }
156535
156796
  const dismissalsResult = loadDismissals(
156536
156797
  dismissalsPath(config2.outputDir, getDismissalsPathOverride())
156537
156798
  );
156538
156799
  if (dismissalsResult.isErr()) {
156539
- return (0, import_neverthrow63.err)(dismissalsResult.error);
156800
+ return (0, import_neverthrow64.err)(dismissalsResult.error);
156540
156801
  }
156541
- return (0, import_neverthrow63.ok)({ runId, date: date5, runPaths: runPathsResult.value, dismissals: dismissalsResult.value });
156802
+ return (0, import_neverthrow64.ok)({ runId, date: date5, runPaths: runPathsResult.value, dismissals: dismissalsResult.value });
156542
156803
  }
156543
156804
  function assemblePipelineSetup({
156544
156805
  config: config2,
@@ -156568,10 +156829,10 @@ function buildPipelineSetup({
156568
156829
  }) {
156569
156830
  const resolvedResult = resolvePipelineConfig({ config: config2, date: date5 });
156570
156831
  if (resolvedResult.isErr()) {
156571
- return (0, import_neverthrow62.err)(resolvedResult.error);
156832
+ return (0, import_neverthrow63.err)(resolvedResult.error);
156572
156833
  }
156573
156834
  const { runId, runPaths, dismissals } = resolvedResult.value;
156574
- return (0, import_neverthrow62.ok)(assemblePipelineSetup({ config: config2, date: date5, runId, runPaths, dismissals }));
156835
+ return (0, import_neverthrow63.ok)(assemblePipelineSetup({ config: config2, date: date5, runId, runPaths, dismissals }));
156575
156836
  }
156576
156837
  function buildExplorerOptions(setup, config2) {
156577
156838
  return {
@@ -156598,7 +156859,7 @@ function runAgentPhases(setup, config2) {
156598
156859
  }
156599
156860
  function installAppIfRequested(udid, appPath) {
156600
156861
  if (appPath === void 0) {
156601
- return (0, import_neverthrow59.okAsync)(udid);
156862
+ return (0, import_neverthrow60.okAsync)(udid);
156602
156863
  }
156603
156864
  return installApp(udid, appPath).mapErr(
156604
156865
  (cause) => ({ type: "SIMULATOR_SETUP_FAILED", cause })
@@ -156606,11 +156867,11 @@ function installAppIfRequested(udid, appPath) {
156606
156867
  }
156607
156868
  function provisionSimulator(udid, appPath) {
156608
156869
  if (udid === "booted") {
156609
- return (0, import_neverthrow59.okAsync)(udid);
156870
+ return (0, import_neverthrow60.okAsync)(udid);
156610
156871
  }
156611
156872
  const parsed = parseUdid(udid);
156612
156873
  if (parsed.isErr()) {
156613
- return (0, import_neverthrow59.errAsync)({ type: "SIMULATOR_SETUP_FAILED", cause: parsed.error });
156874
+ return (0, import_neverthrow60.errAsync)({ type: "SIMULATOR_SETUP_FAILED", cause: parsed.error });
156614
156875
  }
156615
156876
  return bootAndAwait(parsed.value).mapErr((cause) => ({ type: "SIMULATOR_SETUP_FAILED", cause })).andThen((bootedUdid) => installAppIfRequested(bootedUdid, appPath)).map(String);
156616
156877
  }
@@ -156631,7 +156892,7 @@ function runPipeline3(config2) {
156631
156892
  const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, ISO_DATE_LENGTH2);
156632
156893
  const setupResult = buildPipelineSetup({ config: config2, date: date5 });
156633
156894
  if (setupResult.isErr()) {
156634
- return (0, import_neverthrow59.errAsync)(setupResult.error);
156895
+ return (0, import_neverthrow60.errAsync)(setupResult.error);
156635
156896
  }
156636
156897
  return executePipeline(setupResult.value, config2);
156637
156898
  }
@@ -156642,7 +156903,7 @@ function buildArtifacts(videoPath) {
156642
156903
  }
156643
156904
 
156644
156905
  // src/shell/debug-agent-events.ts
156645
- var import_neverthrow66 = __toESM(require_index_cjs(), 1);
156906
+ var import_neverthrow67 = __toESM(require_index_cjs(), 1);
156646
156907
 
156647
156908
  // src/constants.ts
156648
156909
  var MOBILE_IOS_TOOLS = [
@@ -156725,7 +156986,7 @@ function tryStringify(value) {
156725
156986
  const result = JSON.stringify(value);
156726
156987
  return result ?? UNSERIALIZABLE2;
156727
156988
  }
156728
- var safeStringify2 = (0, import_neverthrow66.fromThrowable)(tryStringify, () => ({
156989
+ var safeStringify2 = (0, import_neverthrow67.fromThrowable)(tryStringify, () => ({
156729
156990
  type: "STRINGIFY_FAILED"
156730
156991
  }));
156731
156992
  function toolKey(scope, event) {
@@ -157040,7 +157301,7 @@ var catalogSchema = external_exports.discriminatedUnion("type", [localCatalogSch
157040
157301
  var import_node_fs9 = __toESM(require("node:fs"), 1);
157041
157302
  var import_node_path22 = __toESM(require("node:path"), 1);
157042
157303
  var import_jiti = require("jiti");
157043
- var import_neverthrow67 = __toESM(require_index_cjs(), 1);
157304
+ var import_neverthrow68 = __toESM(require_index_cjs(), 1);
157044
157305
 
157045
157306
  // ../../packages/catalog/dist/core/validate-catalog.js
157046
157307
  var ZERO_ARITY = 0;
@@ -157068,8 +157329,8 @@ function isCatalog(value) {
157068
157329
  var WORLD_WRITABLE_MASK = 18;
157069
157330
  var ROOT_PATH_MIN_LENGTH = 2;
157070
157331
  var swallowError = () => false;
157071
- var safeRealpath = (0, import_neverthrow67.fromThrowable)((target) => import_node_fs9.default.realpathSync(target), swallowError);
157072
- var safeStat = (0, import_neverthrow67.fromThrowable)((target) => import_node_fs9.default.statSync(target), swallowError);
157332
+ var safeRealpath = (0, import_neverthrow68.fromThrowable)((target) => import_node_fs9.default.realpathSync(target), swallowError);
157333
+ var safeStat = (0, import_neverthrow68.fromThrowable)((target) => import_node_fs9.default.statSync(target), swallowError);
157073
157334
  function stripTrailingSeparator(value) {
157074
157335
  if (value.length > ROOT_PATH_MIN_LENGTH && value.endsWith(import_node_path22.default.sep)) {
157075
157336
  return value.slice(0, -1);
@@ -157156,13 +157417,13 @@ function resolveRealPaths(input) {
157156
157417
  const resolved = import_node_path22.default.resolve(input.configDir, input.modulePath);
157157
157418
  const realResolvedResult = safeRealpath(resolved);
157158
157419
  if (realResolvedResult.isErr()) {
157159
- return (0, import_neverthrow67.errAsync)({ type: "CATALOG_MODULE_NOT_FOUND", path: resolved });
157420
+ return (0, import_neverthrow68.errAsync)({ type: "CATALOG_MODULE_NOT_FOUND", path: resolved });
157160
157421
  }
157161
157422
  const realRepoRootResult = safeRealpath(input.repoRoot);
157162
157423
  if (realRepoRootResult.isErr()) {
157163
- return (0, import_neverthrow67.errAsync)(buildLoadFailedError(resolved, "repo root realpath failed"));
157424
+ return (0, import_neverthrow68.errAsync)(buildLoadFailedError(resolved, "repo root realpath failed"));
157164
157425
  }
157165
- return (0, import_neverthrow67.okAsync)({
157426
+ return (0, import_neverthrow68.okAsync)({
157166
157427
  realResolved: realResolvedResult.value,
157167
157428
  realRepoRoot: realRepoRootResult.value
157168
157429
  });
@@ -157204,7 +157465,7 @@ function runPreImportChecks(realResolved, realRepoRoot) {
157204
157465
  }
157205
157466
  function importModuleViaJiti(realResolved) {
157206
157467
  const jiti = (0, import_jiti.createJiti)(__importMetaUrl, { fsCache: false, moduleCache: false });
157207
- const wrapped = import_neverthrow67.ResultAsync.fromThrowable(async (target) => jiti.import(target, { default: true }), (cause) => ({
157468
+ const wrapped = import_neverthrow68.ResultAsync.fromThrowable(async (target) => jiti.import(target, { default: true }), (cause) => ({
157208
157469
  type: "CATALOG_MODULE_LOAD_FAILED",
157209
157470
  path: realResolved,
157210
157471
  cause: redactCause(cause)
@@ -157214,19 +157475,19 @@ function importModuleViaJiti(realResolved) {
157214
157475
  function verifyPostStatAndShape(input) {
157215
157476
  const postResult = safeStat(input.realResolved);
157216
157477
  if (postResult.isErr()) {
157217
- return (0, import_neverthrow67.errAsync)(buildLoadFailedError(input.realResolved, "post-stat failed"));
157478
+ return (0, import_neverthrow68.errAsync)(buildLoadFailedError(input.realResolved, "post-stat failed"));
157218
157479
  }
157219
157480
  if (!statsEqual(input.pre, statToPreStat(postResult.value))) {
157220
- return (0, import_neverthrow67.errAsync)(buildLoadFailedError(input.realResolved, "inode-changed"));
157481
+ return (0, import_neverthrow68.errAsync)(buildLoadFailedError(input.realResolved, "inode-changed"));
157221
157482
  }
157222
157483
  if (!isCatalog(input.imported)) {
157223
- return (0, import_neverthrow67.errAsync)({
157484
+ return (0, import_neverthrow68.errAsync)({
157224
157485
  type: "CATALOG_MODULE_INVALID_SHAPE",
157225
157486
  path: input.realResolved,
157226
157487
  reason: "default export does not satisfy Catalog interface"
157227
157488
  });
157228
157489
  }
157229
- return (0, import_neverthrow67.okAsync)(input.imported);
157490
+ return (0, import_neverthrow68.okAsync)(input.imported);
157230
157491
  }
157231
157492
  function loadAfterChecks(realResolved, pre) {
157232
157493
  return importModuleViaJiti(realResolved).andThen((imported) => verifyPostStatAndShape({ realResolved, pre, imported }));
@@ -157235,23 +157496,23 @@ function loadCatalog(input) {
157235
157496
  return resolveRealPaths(input).andThen(({ realResolved, realRepoRoot }) => {
157236
157497
  const checks = runPreImportChecks(realResolved, realRepoRoot);
157237
157498
  if ("error" in checks) {
157238
- return (0, import_neverthrow67.errAsync)(checks.error);
157499
+ return (0, import_neverthrow68.errAsync)(checks.error);
157239
157500
  }
157240
157501
  return loadAfterChecks(realResolved, checks.pre);
157241
157502
  });
157242
157503
  }
157243
157504
 
157244
157505
  // ../../packages/catalog/dist/shell/resolve-catalog.js
157245
- var import_node_crypto4 = require("node:crypto");
157506
+ var import_node_crypto5 = require("node:crypto");
157246
157507
  var import_promises30 = require("node:fs/promises");
157247
157508
  var import_node_path27 = __toESM(require("node:path"), 1);
157248
- var import_neverthrow81 = __toESM(require_index_cjs(), 1);
157509
+ var import_neverthrow82 = __toESM(require_index_cjs(), 1);
157249
157510
 
157250
157511
  // ../../packages/catalog/dist/shell/cleanup-cache.js
157251
157512
  var import_node_fs10 = require("node:fs");
157252
157513
  var import_promises26 = require("node:fs/promises");
157253
157514
  var import_node_path23 = __toESM(require("node:path"), 1);
157254
- var import_neverthrow68 = __toESM(require_index_cjs(), 1);
157515
+ var import_neverthrow69 = __toESM(require_index_cjs(), 1);
157255
157516
  var MS_PER_SECOND6 = 1e3;
157256
157517
  var SECONDS_PER_MINUTE4 = 60;
157257
157518
  var MINUTES_PER_HOUR = 60;
@@ -157262,7 +157523,7 @@ var LOCK_FILE_NAME = ".lock";
157262
157523
  var LINUX_BOOT_ID_PATH = "/proc/sys/kernel/random/boot_id";
157263
157524
  var PROBE_SIGNAL = 0;
157264
157525
  var swallowError2 = () => void 0;
157265
- var safeReadBootId = (0, import_neverthrow68.fromThrowable)(() => (0, import_node_fs10.readFileSync)(LINUX_BOOT_ID_PATH, "utf8").trim(), swallowError2);
157526
+ var safeReadBootId = (0, import_neverthrow69.fromThrowable)(() => (0, import_node_fs10.readFileSync)(LINUX_BOOT_ID_PATH, "utf8").trim(), swallowError2);
157266
157527
  function readBootId() {
157267
157528
  if (process.platform !== "linux") {
157268
157529
  return void 0;
@@ -157270,11 +157531,11 @@ function readBootId() {
157270
157531
  const result = safeReadBootId();
157271
157532
  return result.isOk() ? result.value : void 0;
157272
157533
  }
157273
- var safePidProbe = (0, import_neverthrow68.fromThrowable)((pid) => process.kill(pid, PROBE_SIGNAL), swallowError2);
157534
+ var safePidProbe = (0, import_neverthrow69.fromThrowable)((pid) => process.kill(pid, PROBE_SIGNAL), swallowError2);
157274
157535
  function isPidAlive2(pid) {
157275
157536
  return safePidProbe(pid).isOk();
157276
157537
  }
157277
- var safeJsonParse3 = (0, import_neverthrow68.fromThrowable)(JSON.parse, swallowError2);
157538
+ var safeJsonParse3 = (0, import_neverthrow69.fromThrowable)(JSON.parse, swallowError2);
157278
157539
  function isValidLock(value) {
157279
157540
  return value !== null && typeof value === "object" && typeof value.pid === "number" && typeof value.startedAtMs === "number";
157280
157541
  }
@@ -157287,7 +157548,7 @@ function parseLock(raw) {
157287
157548
  return isValidLock(value) ? value : void 0;
157288
157549
  }
157289
157550
  function safeReadLockText(lockPath) {
157290
- const wrapped = import_neverthrow68.ResultAsync.fromThrowable(async (target) => (0, import_promises26.readFile)(target, "utf8"), swallowError2);
157551
+ const wrapped = import_neverthrow69.ResultAsync.fromThrowable(async (target) => (0, import_promises26.readFile)(target, "utf8"), swallowError2);
157291
157552
  return wrapped(lockPath);
157292
157553
  }
157293
157554
  async function readLock(runDirectory) {
@@ -157297,9 +157558,9 @@ async function readLock(runDirectory) {
157297
157558
  }
157298
157559
  return parseLock(raw.value);
157299
157560
  }
157300
- var safeStat2 = import_neverthrow68.ResultAsync.fromThrowable(async (target) => (0, import_promises26.stat)(target), swallowError2);
157561
+ var safeStat2 = import_neverthrow69.ResultAsync.fromThrowable(async (target) => (0, import_promises26.stat)(target), swallowError2);
157301
157562
  function safeWriteLock(filePath, content) {
157302
- const wrapped = import_neverthrow68.ResultAsync.fromThrowable(async (target, body) => {
157563
+ const wrapped = import_neverthrow69.ResultAsync.fromThrowable(async (target, body) => {
157303
157564
  await (0, import_promises26.writeFile)(target, body);
157304
157565
  return void 0;
157305
157566
  }, (cause) => ({
@@ -157310,7 +157571,7 @@ function safeWriteLock(filePath, content) {
157310
157571
  return wrapped(filePath, content);
157311
157572
  }
157312
157573
  function safeReadDirectory(directoryPath) {
157313
- const wrapped = import_neverthrow68.ResultAsync.fromThrowable(async (target) => (0, import_promises26.readdir)(target, { withFileTypes: true, encoding: "utf8" }), (cause) => ({
157574
+ const wrapped = import_neverthrow69.ResultAsync.fromThrowable(async (target) => (0, import_promises26.readdir)(target, { withFileTypes: true, encoding: "utf8" }), (cause) => ({
157314
157575
  type: "CATALOG_CACHE_CLEANUP_FAILED",
157315
157576
  path: directoryPath,
157316
157577
  cause: redactCause(cause)
@@ -157318,7 +157579,7 @@ function safeReadDirectory(directoryPath) {
157318
157579
  return wrapped(directoryPath);
157319
157580
  }
157320
157581
  function safeRm(target) {
157321
- const wrapped = import_neverthrow68.ResultAsync.fromThrowable(async (targetPath) => {
157582
+ const wrapped = import_neverthrow69.ResultAsync.fromThrowable(async (targetPath) => {
157322
157583
  await (0, import_promises26.rm)(targetPath, { recursive: true, force: true });
157323
157584
  return void 0;
157324
157585
  }, (cause) => ({
@@ -157382,7 +157643,7 @@ async function reapAllEntries(context, entryNames) {
157382
157643
  return results.filter((entry) => entry !== void 0);
157383
157644
  }
157384
157645
  function reapDirectories(input) {
157385
- const wrapped = import_neverthrow68.ResultAsync.fromThrowable(async (request2) => reapAllEntries(request2.context, request2.directoryNames), (cause) => ({
157646
+ const wrapped = import_neverthrow69.ResultAsync.fromThrowable(async (request2) => reapAllEntries(request2.context, request2.directoryNames), (cause) => ({
157386
157647
  type: "CATALOG_CACHE_CLEANUP_FAILED",
157387
157648
  path: input.context.cacheRoot,
157388
157649
  cause: redactCause(cause)
@@ -157397,7 +157658,7 @@ function writeLockFile(runDirectory) {
157397
157658
  function reapStaleCacheDirectories(cacheRoot, options = {}) {
157398
157659
  const gracePeriodMs = options.gracePeriodMs ?? DEFAULT_GRACE_PERIOD_MS2;
157399
157660
  if (!(0, import_node_fs10.existsSync)(cacheRoot)) {
157400
- return (0, import_neverthrow68.okAsync)([]);
157661
+ return (0, import_neverthrow69.okAsync)([]);
157401
157662
  }
157402
157663
  const currentBootId = readBootId();
157403
157664
  const reapStartMs = Date.now();
@@ -157409,11 +157670,11 @@ function reapStaleCacheDirectories(cacheRoot, options = {}) {
157409
157670
  }
157410
157671
 
157411
157672
  // ../../packages/catalog/dist/shell/github/github-catalog.js
157412
- var import_neverthrow77 = __toESM(require_index_cjs(), 1);
157673
+ var import_neverthrow78 = __toESM(require_index_cjs(), 1);
157413
157674
 
157414
157675
  // ../../packages/catalog/dist/shell/github/build-spec.js
157415
157676
  var import_node_path24 = __toESM(require("node:path"), 1);
157416
- var import_neverthrow69 = __toESM(require_index_cjs(), 1);
157677
+ var import_neverthrow70 = __toESM(require_index_cjs(), 1);
157417
157678
  var SPEC_FILE_SUFFIX = ".test.md";
157418
157679
  function specParseErrorMessage(error48) {
157419
157680
  switch (error48.type) {
@@ -157437,7 +157698,7 @@ function buildSpec2(filePath, raw) {
157437
157698
  type: "CATALOG_FETCH_FAILED",
157438
157699
  phase: "specs",
157439
157700
  cause: redactCause(specParseErrorMessage(parseError))
157440
- })).andThen((parsed) => parsed.spec.id === expectedId ? (0, import_neverthrow69.ok)({ id: parsed.spec.id, spec: parsed.spec }) : (0, import_neverthrow69.err)({
157701
+ })).andThen((parsed) => parsed.spec.id === expectedId ? (0, import_neverthrow70.ok)({ id: parsed.spec.id, spec: parsed.spec }) : (0, import_neverthrow70.err)({
157441
157702
  type: "CATALOG_INVALID_ID",
157442
157703
  kind: "spec",
157443
157704
  id: parsed.spec.id
@@ -157446,9 +157707,9 @@ function buildSpec2(filePath, raw) {
157446
157707
 
157447
157708
  // ../../packages/catalog/dist/shell/github/build-suite.js
157448
157709
  var import_node_path25 = __toESM(require("node:path"), 1);
157449
- var import_neverthrow70 = __toESM(require_index_cjs(), 1);
157710
+ var import_neverthrow71 = __toESM(require_index_cjs(), 1);
157450
157711
  var SUITE_FILE_SUFFIX = ".suite.json";
157451
- var safeJsonParse4 = (0, import_neverthrow70.fromThrowable)(JSON.parse, (cause) => ({
157712
+ var safeJsonParse4 = (0, import_neverthrow71.fromThrowable)(JSON.parse, (cause) => ({
157452
157713
  type: "CATALOG_FETCH_FAILED",
157453
157714
  phase: "suites",
157454
157715
  cause: redactCause(cause)
@@ -157461,43 +157722,43 @@ function isFreestyleArray(value) {
157461
157722
  }
157462
157723
  function validateSpecs(value) {
157463
157724
  if (value === void 0) {
157464
- return (0, import_neverthrow70.ok)([]);
157725
+ return (0, import_neverthrow71.ok)([]);
157465
157726
  }
157466
157727
  if (!isStringArray(value)) {
157467
- return (0, import_neverthrow70.err)({
157728
+ return (0, import_neverthrow71.err)({
157468
157729
  type: "CATALOG_FETCH_FAILED",
157469
157730
  phase: "suites",
157470
157731
  cause: redactCause("suite.specs must be an array of strings")
157471
157732
  });
157472
157733
  }
157473
- return (0, import_neverthrow70.ok)(value);
157734
+ return (0, import_neverthrow71.ok)(value);
157474
157735
  }
157475
157736
  function validateFreestyle(value) {
157476
157737
  if (value === void 0) {
157477
- return (0, import_neverthrow70.ok)([]);
157738
+ return (0, import_neverthrow71.ok)([]);
157478
157739
  }
157479
157740
  if (!isFreestyleArray(value)) {
157480
- return (0, import_neverthrow70.err)({
157741
+ return (0, import_neverthrow71.err)({
157481
157742
  type: "CATALOG_FETCH_FAILED",
157482
157743
  phase: "suites",
157483
157744
  cause: redactCause("suite.freestyle must be an array")
157484
157745
  });
157485
157746
  }
157486
- return (0, import_neverthrow70.ok)(value);
157747
+ return (0, import_neverthrow71.ok)(value);
157487
157748
  }
157488
157749
  function validateHooks(value) {
157489
157750
  if (value === void 0) {
157490
157751
  const empty = void 0;
157491
- return (0, import_neverthrow70.ok)(empty);
157752
+ return (0, import_neverthrow71.ok)(empty);
157492
157753
  }
157493
157754
  if (typeof value !== "object" || value === null) {
157494
- return (0, import_neverthrow70.err)({
157755
+ return (0, import_neverthrow71.err)({
157495
157756
  type: "CATALOG_FETCH_FAILED",
157496
157757
  phase: "suites",
157497
157758
  cause: redactCause("suite.hooks must be an object")
157498
157759
  });
157499
157760
  }
157500
- return (0, import_neverthrow70.ok)(value);
157761
+ return (0, import_neverthrow71.ok)(value);
157501
157762
  }
157502
157763
  function assembleSuiteConfig(parts) {
157503
157764
  if (parts.hooks === void 0) {
@@ -157510,10 +157771,10 @@ function validateSuiteParts(candidate) {
157510
157771
  }
157511
157772
  function buildSuiteConfig(parsed) {
157512
157773
  if (parsed === null || parsed === void 0) {
157513
- return (0, import_neverthrow70.ok)({ specs: [], freestyle: [] });
157774
+ return (0, import_neverthrow71.ok)({ specs: [], freestyle: [] });
157514
157775
  }
157515
157776
  if (typeof parsed !== "object") {
157516
- return (0, import_neverthrow70.err)({
157777
+ return (0, import_neverthrow71.err)({
157517
157778
  type: "CATALOG_FETCH_FAILED",
157518
157779
  phase: "suites",
157519
157780
  cause: redactCause("suite file must contain an object")
@@ -157529,7 +157790,7 @@ function buildSuite(filePath, raw) {
157529
157790
  // ../../packages/catalog/dist/shell/github/exec-gh.js
157530
157791
  var import_node_child_process8 = require("node:child_process");
157531
157792
  var import_promises27 = require("node:timers/promises");
157532
- var import_neverthrow71 = __toESM(require_index_cjs(), 1);
157793
+ var import_neverthrow72 = __toESM(require_index_cjs(), 1);
157533
157794
  var KILOBYTE = 1024;
157534
157795
  var MEGABYTE = KILOBYTE * KILOBYTE;
157535
157796
  var MAX_BUFFER_MEGABYTES = 16;
@@ -157619,9 +157880,9 @@ function buildFetchError(cause, phase) {
157619
157880
  }
157620
157881
  function execGh(input) {
157621
157882
  if (input.token.length === 0) {
157622
- return (0, import_neverthrow71.errAsync)(buildFetchError({ message: "spec token required for github catalog (XQA_SPEC_TOKEN/LOCAL_XQA_SPEC_TOKEN)" }, input.phase));
157883
+ return (0, import_neverthrow72.errAsync)(buildFetchError({ message: "spec token required for github catalog (XQA_SPEC_TOKEN/LOCAL_XQA_SPEC_TOKEN)" }, input.phase));
157623
157884
  }
157624
- return import_neverthrow71.ResultAsync.fromSafePromise(runExecGhWithRetry(input)).andThen((outcome) => outcome.ok ? (0, import_neverthrow71.okAsync)(outcome.stdout) : (0, import_neverthrow71.errAsync)(buildFetchError(outcome.cause, input.phase)));
157885
+ return import_neverthrow72.ResultAsync.fromSafePromise(runExecGhWithRetry(input)).andThen((outcome) => outcome.ok ? (0, import_neverthrow72.okAsync)(outcome.stdout) : (0, import_neverthrow72.errAsync)(buildFetchError(outcome.cause, input.phase)));
157625
157886
  }
157626
157887
  function loadSpecTokenFromEnv() {
157627
157888
  return process.env.XQA_SPEC_TOKEN ?? process.env.LOCAL_XQA_SPEC_TOKEN ?? "";
@@ -157631,15 +157892,15 @@ function resolvePhase(phase) {
157631
157892
  }
157632
157893
 
157633
157894
  // ../../packages/catalog/dist/shell/github/fetch-blobs.js
157634
- var import_neverthrow72 = __toESM(require_index_cjs(), 1);
157895
+ var import_neverthrow73 = __toESM(require_index_cjs(), 1);
157635
157896
  var KILOBYTE2 = 1024;
157636
157897
  var MEGABYTE2 = KILOBYTE2 * KILOBYTE2;
157637
157898
  var MAX_FILE_BYTES = MEGABYTE2;
157638
157899
  var FETCH_CONCURRENCY_LIMIT = 8;
157639
- var tryParseJson = (0, import_neverthrow72.fromThrowable)(JSON.parse, (cause) => ({
157900
+ var tryParseJson = (0, import_neverthrow73.fromThrowable)(JSON.parse, (cause) => ({
157640
157901
  cause
157641
157902
  }));
157642
- var safeBase64Decode = (0, import_neverthrow72.fromThrowable)((text) => Buffer.from(text, "base64").toString("utf8"), (cause) => ({ cause }));
157903
+ var safeBase64Decode = (0, import_neverthrow73.fromThrowable)((text) => Buffer.from(text, "base64").toString("utf8"), (cause) => ({ cause }));
157643
157904
  function parseJson(stdout, phase) {
157644
157905
  return tryParseJson(stdout).mapErr(({ cause }) => buildFetchError(cause, phase));
157645
157906
  }
@@ -157652,16 +157913,16 @@ function isBlobResponse(value) {
157652
157913
  }
157653
157914
  function parseBlobResponse(parsed, phase) {
157654
157915
  if (!isBlobResponse(parsed)) {
157655
- return (0, import_neverthrow72.err)(buildFetchError("blob endpoint missing content/encoding", phase));
157916
+ return (0, import_neverthrow73.err)(buildFetchError("blob endpoint missing content/encoding", phase));
157656
157917
  }
157657
- return (0, import_neverthrow72.ok)(parsed);
157918
+ return (0, import_neverthrow73.ok)(parsed);
157658
157919
  }
157659
157920
  function decodeBlobContent(blob, phase) {
157660
157921
  if (blob.truncated === true) {
157661
- return (0, import_neverthrow72.err)(buildFetchError("blob truncated by GitHub API", phase));
157922
+ return (0, import_neverthrow73.err)(buildFetchError("blob truncated by GitHub API", phase));
157662
157923
  }
157663
157924
  if (blob.encoding !== "base64") {
157664
- return (0, import_neverthrow72.err)(buildFetchError(`unexpected encoding: ${blob.encoding}`, phase));
157925
+ return (0, import_neverthrow73.err)(buildFetchError(`unexpected encoding: ${blob.encoding}`, phase));
157665
157926
  }
157666
157927
  return safeBase64Decode(blob.content).mapErr(({ cause }) => buildFetchError(cause, phase));
157667
157928
  }
@@ -157670,7 +157931,7 @@ function buildBlobPath(input) {
157670
157931
  }
157671
157932
  function fetchBlob(input) {
157672
157933
  if (input.entry.size > MAX_FILE_BYTES) {
157673
- return (0, import_neverthrow72.errAsync)(buildFetchError(`file ${input.entry.path} exceeds size cap`, input.phase));
157934
+ return (0, import_neverthrow73.errAsync)(buildFetchError(`file ${input.entry.path} exceeds size cap`, input.phase));
157674
157935
  }
157675
157936
  const apiPath = buildBlobPath({ owner: input.owner, repo: input.repo, sha: input.entry.sha });
157676
157937
  return execGh({ apiPath, phase: input.phase, token: input.token, timeoutMs: input.timeoutMs }).andThen((stdout) => parseJson(stdout, input.phase)).andThen((parsed) => parseBlobResponse(parsed, input.phase)).andThen((blob) => decodeBlobContent(blob, input.phase));
@@ -157727,7 +157988,7 @@ async function runPool(factories, limit) {
157727
157988
  const workers = Array.from({ length: workerCount }, async () => runPoolWorker(driver.handle));
157728
157989
  await Promise.all(workers);
157729
157990
  const error48 = driver.readError();
157730
- return error48 === void 0 ? (0, import_neverthrow72.ok)(driver.readResults()) : (0, import_neverthrow72.err)(error48);
157991
+ return error48 === void 0 ? (0, import_neverthrow73.ok)(driver.readResults()) : (0, import_neverthrow73.err)(error48);
157731
157992
  }
157732
157993
  function buildFactories(input) {
157733
157994
  return input.entries.map((entry) => () => fetchBlob({
@@ -157740,15 +158001,15 @@ function buildFactories(input) {
157740
158001
  }).map((content) => ({ entry, content })));
157741
158002
  }
157742
158003
  function fetchBlobs(input) {
157743
- return import_neverthrow72.ResultAsync.fromSafePromise(runPool(buildFactories(input), FETCH_CONCURRENCY_LIMIT)).andThen((result) => result);
158004
+ return import_neverthrow73.ResultAsync.fromSafePromise(runPool(buildFactories(input), FETCH_CONCURRENCY_LIMIT)).andThen((result) => result);
157744
158005
  }
157745
158006
 
157746
158007
  // ../../packages/catalog/dist/shell/github/fetch-compat.js
157747
- var import_neverthrow74 = __toESM(require_index_cjs(), 1);
158008
+ var import_neverthrow75 = __toESM(require_index_cjs(), 1);
157748
158009
 
157749
158010
  // ../../packages/catalog/dist/core/xqa-compat.js
157750
- var import_neverthrow73 = __toESM(require_index_cjs(), 1);
157751
- var safeJsonParse5 = (0, import_neverthrow73.fromThrowable)(JSON.parse, (cause) => ({ type: "XQA_COMPAT_PARSE_FAILED", cause }));
158011
+ var import_neverthrow74 = __toESM(require_index_cjs(), 1);
158012
+ var safeJsonParse5 = (0, import_neverthrow74.fromThrowable)(JSON.parse, (cause) => ({ type: "XQA_COMPAT_PARSE_FAILED", cause }));
157752
158013
  function isXqaCompat(value) {
157753
158014
  if (typeof value !== "object" || value === null) {
157754
158015
  return false;
@@ -157757,13 +158018,13 @@ function isXqaCompat(value) {
157757
158018
  return Array.isArray(candidate.xqaMajor) && candidate.xqaMajor.every((entry) => typeof entry === "number");
157758
158019
  }
157759
158020
  function parseXqaCompat(raw) {
157760
- return safeJsonParse5(raw).andThen((value) => isXqaCompat(value) ? (0, import_neverthrow73.ok)(value) : (0, import_neverthrow73.err)({ type: "XQA_COMPAT_MISSING_FIELD" }));
158021
+ return safeJsonParse5(raw).andThen((value) => isXqaCompat(value) ? (0, import_neverthrow74.ok)(value) : (0, import_neverthrow74.err)({ type: "XQA_COMPAT_MISSING_FIELD" }));
157761
158022
  }
157762
158023
  function checkCompat(manifest, currentMajor) {
157763
158024
  if (manifest.xqaMajor.includes(currentMajor)) {
157764
- return (0, import_neverthrow73.ok)();
158025
+ return (0, import_neverthrow74.ok)();
157765
158026
  }
157766
- return (0, import_neverthrow73.err)({
158027
+ return (0, import_neverthrow74.err)({
157767
158028
  type: "XQA_COMPAT_MISMATCH",
157768
158029
  current: currentMajor,
157769
158030
  supported: manifest.xqaMajor
@@ -157772,10 +158033,10 @@ function checkCompat(manifest, currentMajor) {
157772
158033
 
157773
158034
  // ../../packages/catalog/dist/shell/github/fetch-compat.js
157774
158035
  var XQA_CURRENT_MAJOR = 6;
157775
- var safeJsonParse6 = (0, import_neverthrow74.fromThrowable)(JSON.parse, (cause) => ({
158036
+ var safeJsonParse6 = (0, import_neverthrow75.fromThrowable)(JSON.parse, (cause) => ({
157776
158037
  cause
157777
158038
  }));
157778
- var safeDecodeBase64 = (0, import_neverthrow74.fromThrowable)((text) => Buffer.from(text, "base64").toString("utf8"), (cause) => ({ cause }));
158039
+ var safeDecodeBase64 = (0, import_neverthrow75.fromThrowable)((text) => Buffer.from(text, "base64").toString("utf8"), (cause) => ({ cause }));
157779
158040
  function isGitHubContentsResponse(value) {
157780
158041
  if (typeof value !== "object" || value === null) {
157781
158042
  return false;
@@ -157789,9 +158050,9 @@ function buildApiPath(input) {
157789
158050
  }
157790
158051
  function validateContentsResponse(parsed) {
157791
158052
  if (!isGitHubContentsResponse(parsed)) {
157792
- return (0, import_neverthrow74.err)(buildFetchError("unexpected GitHub Contents API response shape", "compat"));
158053
+ return (0, import_neverthrow75.err)(buildFetchError("unexpected GitHub Contents API response shape", "compat"));
157793
158054
  }
157794
- return (0, import_neverthrow74.ok)(parsed);
158055
+ return (0, import_neverthrow75.ok)(parsed);
157795
158056
  }
157796
158057
  function mapCompatError(error48) {
157797
158058
  switch (error48.type) {
@@ -157819,8 +158080,8 @@ function fetchCompat(input) {
157819
158080
  }
157820
158081
 
157821
158082
  // ../../packages/catalog/dist/shell/github/fetch-tree.js
157822
- var import_neverthrow75 = __toESM(require_index_cjs(), 1);
157823
- var tryParseJson2 = (0, import_neverthrow75.fromThrowable)(JSON.parse, (cause) => ({
158083
+ var import_neverthrow76 = __toESM(require_index_cjs(), 1);
158084
+ var tryParseJson2 = (0, import_neverthrow76.fromThrowable)(JSON.parse, (cause) => ({
157824
158085
  cause
157825
158086
  }));
157826
158087
  function buildApiPath2(input) {
@@ -157844,17 +158105,17 @@ function parseJson2(stdout, phase) {
157844
158105
  }
157845
158106
  function extractAllBlobs(parsed, phase) {
157846
158107
  if (typeof parsed !== "object" || parsed === null) {
157847
- return (0, import_neverthrow75.err)(buildFetchError("tree endpoint did not return an object", phase));
158108
+ return (0, import_neverthrow76.err)(buildFetchError("tree endpoint did not return an object", phase));
157848
158109
  }
157849
158110
  const candidate = parsed;
157850
158111
  if (candidate.truncated === true) {
157851
- return (0, import_neverthrow75.err)(buildFetchError("TREE_TRUNCATED", phase));
158112
+ return (0, import_neverthrow76.err)(buildFetchError("TREE_TRUNCATED", phase));
157852
158113
  }
157853
158114
  if (!Array.isArray(candidate.tree)) {
157854
- return (0, import_neverthrow75.err)(buildFetchError("tree endpoint did not return an array", phase));
158115
+ return (0, import_neverthrow76.err)(buildFetchError("tree endpoint did not return an array", phase));
157855
158116
  }
157856
158117
  const entries = candidate.tree.filter((entry) => isTreeBlobEntry(entry));
157857
- return (0, import_neverthrow75.ok)(entries.filter((entry) => !entryHasTraversal(entry.path)));
158118
+ return (0, import_neverthrow76.ok)(entries.filter((entry) => !entryHasTraversal(entry.path)));
157858
158119
  }
157859
158120
  function fetchAllTreeBlobs(input) {
157860
158121
  const apiPath = buildApiPath2({ owner: input.owner, repo: input.repo, reference: input.ref });
@@ -157870,7 +158131,7 @@ function filterTreeEntries(input) {
157870
158131
  }
157871
158132
 
157872
158133
  // ../../packages/catalog/dist/core/github-config.js
157873
- var import_neverthrow76 = __toESM(require_index_cjs(), 1);
158134
+ var import_neverthrow77 = __toESM(require_index_cjs(), 1);
157874
158135
  function toPathArray(value) {
157875
158136
  return typeof value === "string" ? [value] : value;
157876
158137
  }
@@ -157888,9 +158149,9 @@ function normalizeGithubConfig(input) {
157888
158149
  const paths = toPathArray(input.path);
157889
158150
  const dup = findDuplicate(paths);
157890
158151
  if (dup !== void 0) {
157891
- return (0, import_neverthrow76.err)({ type: "GITHUB_CATALOG_DUPLICATE_PATH", value: dup });
158152
+ return (0, import_neverthrow77.err)({ type: "GITHUB_CATALOG_DUPLICATE_PATH", value: dup });
157892
158153
  }
157893
- return (0, import_neverthrow76.ok)({
158154
+ return (0, import_neverthrow77.ok)({
157894
158155
  owner: input.owner,
157895
158156
  repo: input.repo,
157896
158157
  ref: input.ref,
@@ -157901,13 +158162,13 @@ function normalizeGithubConfig(input) {
157901
158162
 
157902
158163
  // ../../packages/catalog/dist/shell/github/github-catalog.js
157903
158164
  function buildItems(files, builder) {
157904
- return import_neverthrow77.Result.combine(files.map((file2) => builder(file2.entry.path, file2.content)));
158165
+ return import_neverthrow78.Result.combine(files.map((file2) => builder(file2.entry.path, file2.content)));
157905
158166
  }
157906
158167
  function memoize(factory) {
157907
158168
  let pending;
157908
158169
  return () => {
157909
158170
  pending ??= factory().match((value) => ({ success: true, value }), (error48) => ({ success: false, error: error48 }));
157910
- return import_neverthrow77.ResultAsync.fromSafePromise(pending).andThen((entry) => entry.success ? (0, import_neverthrow77.okAsync)(entry.value) : (0, import_neverthrow77.errAsync)(entry.error));
158171
+ return import_neverthrow78.ResultAsync.fromSafePromise(pending).andThen((entry) => entry.success ? (0, import_neverthrow78.okAsync)(entry.value) : (0, import_neverthrow78.errAsync)(entry.error));
157911
158172
  };
157912
158173
  }
157913
158174
  function makeTreeLoader(context) {
@@ -157976,7 +158237,7 @@ function buildCatalog(pipeline2) {
157976
158237
  function createGithubCatalog(input) {
157977
158238
  const normalized = normalizeGithubConfig(input);
157978
158239
  if (normalized.isErr()) {
157979
- return (0, import_neverthrow77.errAsync)({
158240
+ return (0, import_neverthrow78.errAsync)({
157980
158241
  type: "CATALOG_FETCH_FAILED",
157981
158242
  phase: "specs",
157982
158243
  cause: redactCause(normalized.error.type)
@@ -157984,18 +158245,18 @@ function createGithubCatalog(input) {
157984
158245
  }
157985
158246
  const token = loadSpecTokenFromEnv();
157986
158247
  if (token.length === 0) {
157987
- return (0, import_neverthrow77.errAsync)({
158248
+ return (0, import_neverthrow78.errAsync)({
157988
158249
  type: "CATALOG_FETCH_FAILED",
157989
158250
  phase: "specs",
157990
158251
  cause: redactCause("spec token required for github catalog (XQA_SPEC_TOKEN/LOCAL_XQA_SPEC_TOKEN)")
157991
158252
  });
157992
158253
  }
157993
- return (0, import_neverthrow77.okAsync)(buildCatalog(buildPipeline(buildContext(normalized.value, token))));
158254
+ return (0, import_neverthrow78.okAsync)(buildCatalog(buildPipeline(buildContext(normalized.value, token))));
157994
158255
  }
157995
158256
 
157996
158257
  // ../../packages/catalog/dist/shell/with-timeout.js
157997
158258
  var import_promises28 = require("node:timers/promises");
157998
- var import_neverthrow78 = __toESM(require_index_cjs(), 1);
158259
+ var import_neverthrow79 = __toESM(require_index_cjs(), 1);
157999
158260
  async function buildOperationPromise(operation) {
158000
158261
  return operation.match((value) => ({ kind: "value", value }), (error48) => ({ kind: "error", error: error48 }));
158001
158262
  }
@@ -158008,14 +158269,14 @@ function withTimeout(input) {
158008
158269
  buildOperationPromise(input.operation),
158009
158270
  buildTimerPromise(input.timeoutMs)
158010
158271
  ]);
158011
- return import_neverthrow78.ResultAsync.fromSafePromise(racePromise).andThen((settlement) => {
158272
+ return import_neverthrow79.ResultAsync.fromSafePromise(racePromise).andThen((settlement) => {
158012
158273
  if (settlement.kind === "value") {
158013
- return (0, import_neverthrow78.okAsync)(settlement.value);
158274
+ return (0, import_neverthrow79.okAsync)(settlement.value);
158014
158275
  }
158015
158276
  if (settlement.kind === "error") {
158016
- return (0, import_neverthrow78.errAsync)(settlement.error);
158277
+ return (0, import_neverthrow79.errAsync)(settlement.error);
158017
158278
  }
158018
- return (0, import_neverthrow78.errAsync)({
158279
+ return (0, import_neverthrow79.errAsync)({
158019
158280
  type: "CATALOG_FETCH_TIMEOUT",
158020
158281
  phase: input.phase,
158021
158282
  timeoutMs: input.timeoutMs
@@ -158026,7 +158287,7 @@ function withTimeout(input) {
158026
158287
  // ../../packages/catalog/dist/shell/write-cache.js
158027
158288
  var import_promises29 = require("node:fs/promises");
158028
158289
  var import_node_path26 = __toESM(require("node:path"), 1);
158029
- var import_neverthrow79 = __toESM(require_index_cjs(), 1);
158290
+ var import_neverthrow80 = __toESM(require_index_cjs(), 1);
158030
158291
  var DIRECTORY_MODE = 448;
158031
158292
  var FILE_MODE2 = 384;
158032
158293
  async function runMkdir(directoryPath) {
@@ -158037,7 +158298,7 @@ async function runWriteFile(filePath, content) {
158037
158298
  return void 0;
158038
158299
  }
158039
158300
  function safeMkdir3(directoryPath) {
158040
- const wrapped = import_neverthrow79.ResultAsync.fromThrowable(runMkdir, (cause) => ({
158301
+ const wrapped = import_neverthrow80.ResultAsync.fromThrowable(runMkdir, (cause) => ({
158041
158302
  type: "CATALOG_CACHE_WRITE_FAILED",
158042
158303
  path: directoryPath,
158043
158304
  cause: redactCause(cause)
@@ -158045,7 +158306,7 @@ function safeMkdir3(directoryPath) {
158045
158306
  return wrapped(directoryPath);
158046
158307
  }
158047
158308
  function safeWriteFile5(filePath, content) {
158048
- const wrapped = import_neverthrow79.ResultAsync.fromThrowable(runWriteFile, (cause) => ({
158309
+ const wrapped = import_neverthrow80.ResultAsync.fromThrowable(runWriteFile, (cause) => ({
158049
158310
  type: "CATALOG_CACHE_WRITE_FAILED",
158050
158311
  path: filePath,
158051
158312
  cause: redactCause(cause)
@@ -158053,7 +158314,7 @@ function safeWriteFile5(filePath, content) {
158053
158314
  return wrapped(filePath, content);
158054
158315
  }
158055
158316
  function writeAllFiles(cacheRoot, files) {
158056
- return import_neverthrow79.ResultAsync.combine(Array.from(files.entries(), ([relativePath, content]) => safeWriteFile5(import_node_path26.default.join(cacheRoot, relativePath), content)));
158317
+ return import_neverthrow80.ResultAsync.combine(Array.from(files.entries(), ([relativePath, content]) => safeWriteFile5(import_node_path26.default.join(cacheRoot, relativePath), content)));
158057
158318
  }
158058
158319
  function writeCache(cacheRoot, files) {
158059
158320
  const specsDirectory = import_node_path26.default.join(cacheRoot, "specs");
@@ -158062,7 +158323,7 @@ function writeCache(cacheRoot, files) {
158062
158323
  }
158063
158324
 
158064
158325
  // ../../packages/catalog/dist/core/materialize.js
158065
- var import_neverthrow80 = __toESM(require_index_cjs(), 1);
158326
+ var import_neverthrow81 = __toESM(require_index_cjs(), 1);
158066
158327
  var CONTROL_CHAR_PATTERN = /[\u0000-\u0009\u000B\u000C\u000D\u000E-\u001F]/u;
158067
158328
  var JSON_INDENT3 = 2;
158068
158329
  function findControlCharsInStep(step) {
@@ -158097,48 +158358,48 @@ function revalidateSpecIds(specs) {
158097
158358
  for (const item of specs) {
158098
158359
  const reValidated = toSpecId(item.id);
158099
158360
  if (reValidated.isErr()) {
158100
- return (0, import_neverthrow80.err)(reValidated.error);
158361
+ return (0, import_neverthrow81.err)(reValidated.error);
158101
158362
  }
158102
158363
  }
158103
- return (0, import_neverthrow80.ok)();
158364
+ return (0, import_neverthrow81.ok)();
158104
158365
  }
158105
158366
  function revalidateSuiteIds(suites) {
158106
158367
  for (const item of suites) {
158107
158368
  const reValidated = toSuiteId(item.id);
158108
158369
  if (reValidated.isErr()) {
158109
- return (0, import_neverthrow80.err)(reValidated.error);
158370
+ return (0, import_neverthrow81.err)(reValidated.error);
158110
158371
  }
158111
158372
  }
158112
- return (0, import_neverthrow80.ok)();
158373
+ return (0, import_neverthrow81.ok)();
158113
158374
  }
158114
158375
  function checkUniqueSpecIds(specs) {
158115
158376
  const seen = /* @__PURE__ */ new Set();
158116
158377
  for (const item of specs) {
158117
158378
  if (seen.has(item.id)) {
158118
- return (0, import_neverthrow80.err)({ type: "CATALOG_DUPLICATE_ID", kind: "spec", id: item.id });
158379
+ return (0, import_neverthrow81.err)({ type: "CATALOG_DUPLICATE_ID", kind: "spec", id: item.id });
158119
158380
  }
158120
158381
  seen.add(item.id);
158121
158382
  }
158122
- return (0, import_neverthrow80.ok)();
158383
+ return (0, import_neverthrow81.ok)();
158123
158384
  }
158124
158385
  function checkUniqueSuiteIds(suites) {
158125
158386
  const seen = /* @__PURE__ */ new Set();
158126
158387
  for (const item of suites) {
158127
158388
  if (seen.has(item.id)) {
158128
- return (0, import_neverthrow80.err)({ type: "CATALOG_DUPLICATE_ID", kind: "suite", id: item.id });
158389
+ return (0, import_neverthrow81.err)({ type: "CATALOG_DUPLICATE_ID", kind: "suite", id: item.id });
158129
158390
  }
158130
158391
  seen.add(item.id);
158131
158392
  }
158132
- return (0, import_neverthrow80.ok)();
158393
+ return (0, import_neverthrow81.ok)();
158133
158394
  }
158134
158395
  function checkSpecContent(specs) {
158135
158396
  for (const item of specs) {
158136
158397
  const reason = findControlCharsInSpec(item);
158137
158398
  if (reason !== void 0) {
158138
- return (0, import_neverthrow80.err)({ type: "CATALOG_SPEC_CONTENT_REJECTED", kind: "spec", id: item.id, reason });
158399
+ return (0, import_neverthrow81.err)({ type: "CATALOG_SPEC_CONTENT_REJECTED", kind: "spec", id: item.id, reason });
158139
158400
  }
158140
158401
  }
158141
- return (0, import_neverthrow80.ok)();
158402
+ return (0, import_neverthrow81.ok)();
158142
158403
  }
158143
158404
  function buildSpecFile(catalogSpec) {
158144
158405
  return [`specs/${catalogSpec.id}.test.md`, renderSpec(catalogSpec.spec)];
@@ -158174,7 +158435,7 @@ function resolveLocal(catalog) {
158174
158435
  var CACHE_DIRECTORY_NAME = import_node_path27.default.join(".xqa", "cache");
158175
158436
  var RUN_DIRECTORY_MODE = 448;
158176
158437
  function safeCreateRunDirectory(target) {
158177
- const wrapped = import_neverthrow81.ResultAsync.fromThrowable(async (directoryPath) => {
158438
+ const wrapped = import_neverthrow82.ResultAsync.fromThrowable(async (directoryPath) => {
158178
158439
  await (0, import_promises30.mkdir)(directoryPath, { recursive: true, mode: RUN_DIRECTORY_MODE });
158179
158440
  }, (cause) => ({
158180
158441
  type: "CATALOG_CACHE_WRITE_FAILED",
@@ -158188,17 +158449,17 @@ function deriveCacheRoot(repoRoot) {
158188
158449
  }
158189
158450
  function enforceSizeBound(count, phase) {
158190
158451
  if (count > CATALOG_MAX_ITEMS_PER_KIND) {
158191
- return (0, import_neverthrow81.errAsync)({
158452
+ return (0, import_neverthrow82.errAsync)({
158192
158453
  type: "CATALOG_RESULT_TOO_LARGE",
158193
158454
  phase,
158194
158455
  count,
158195
158456
  limit: CATALOG_MAX_ITEMS_PER_KIND
158196
158457
  });
158197
158458
  }
158198
- return (0, import_neverthrow81.okAsync)();
158459
+ return (0, import_neverthrow82.okAsync)();
158199
158460
  }
158200
158461
  function fetchCatalogItems(catalog, options) {
158201
- return import_neverthrow81.ResultAsync.combine([
158462
+ return import_neverthrow82.ResultAsync.combine([
158202
158463
  withTimeout({
158203
158464
  operation: catalog.getSpecs(),
158204
158465
  timeoutMs: options.fetchTimeoutMs,
@@ -158235,7 +158496,7 @@ function runGithubPipeline(context) {
158235
158496
  }
158236
158497
  function buildRemoteContext(input, remote) {
158237
158498
  const cacheRoot = deriveCacheRoot(input.repoRoot);
158238
- const runDirectory = import_node_path27.default.join(cacheRoot, (0, import_node_crypto4.randomUUID)());
158499
+ const runDirectory = import_node_path27.default.join(cacheRoot, (0, import_node_crypto5.randomUUID)());
158239
158500
  return {
158240
158501
  remote,
158241
158502
  configDir: input.configDir,
@@ -158246,12 +158507,12 @@ function buildRemoteContext(input, remote) {
158246
158507
  }
158247
158508
  function buildGithubContext(input, github) {
158248
158509
  const cacheRoot = deriveCacheRoot(input.repoRoot);
158249
- const runDirectory = import_node_path27.default.join(cacheRoot, (0, import_node_crypto4.randomUUID)());
158510
+ const runDirectory = import_node_path27.default.join(cacheRoot, (0, import_node_crypto5.randomUUID)());
158250
158511
  return { github, runDirectory, cacheRoot };
158251
158512
  }
158252
158513
  function resolveCatalog(input) {
158253
158514
  if (input.catalog.type === "local") {
158254
- return (0, import_neverthrow81.okAsync)(resolveLocal(input.catalog));
158515
+ return (0, import_neverthrow82.okAsync)(resolveLocal(input.catalog));
158255
158516
  }
158256
158517
  if (input.catalog.type === "remote") {
158257
158518
  return runRemotePipeline(buildRemoteContext(input, input.catalog));
@@ -158260,7 +158521,7 @@ function resolveCatalog(input) {
158260
158521
  }
158261
158522
 
158262
158523
  // src/commands/catalog/dry-run.ts
158263
- var import_neverthrow82 = __toESM(require_index_cjs(), 1);
158524
+ var import_neverthrow83 = __toESM(require_index_cjs(), 1);
158264
158525
  var DEFAULT_FETCH_TIMEOUT_MS = 6e4;
158265
158526
  async function runGitToplevel() {
158266
158527
  const deferred = Promise.withResolvers();
@@ -158273,7 +158534,7 @@ async function runGitToplevel() {
158273
158534
  });
158274
158535
  return deferred.promise;
158275
158536
  }
158276
- var safeGitToplevel = import_neverthrow82.ResultAsync.fromThrowable(
158537
+ var safeGitToplevel = import_neverthrow83.ResultAsync.fromThrowable(
158277
158538
  runGitToplevel,
158278
158539
  (cause) => ({
158279
158540
  type: "CATALOG_MODULE_LOAD_FAILED",
@@ -158282,7 +158543,7 @@ var safeGitToplevel = import_neverthrow82.ResultAsync.fromThrowable(
158282
158543
  })
158283
158544
  );
158284
158545
  function fetchCounts(catalog, timeoutMs) {
158285
- return import_neverthrow82.ResultAsync.combine([
158546
+ return import_neverthrow83.ResultAsync.combine([
158286
158547
  withTimeout({ operation: catalog.getSpecs(), timeoutMs, phase: "specs" }),
158287
158548
  withTimeout({ operation: catalog.getSuites(), timeoutMs, phase: "suites" })
158288
158549
  ]).map(([specs, suites]) => ({ specsCount: specs.length, suitesCount: suites.length }));
@@ -158343,7 +158604,7 @@ function registerCatalogCommand(program3) {
158343
158604
  }
158344
158605
 
158345
158606
  // src/core/completion-generator.ts
158346
- var import_neverthrow83 = __toESM(require_index_cjs(), 1);
158607
+ var import_neverthrow84 = __toESM(require_index_cjs(), 1);
158347
158608
  function extractLongFlags(flags) {
158348
158609
  return flags.split(/[\s,]+/).filter((token) => token.startsWith("--"));
158349
158610
  }
@@ -158433,9 +158694,9 @@ complete -F _xqa_completion xqa`;
158433
158694
  }
158434
158695
  function generateCompletion(commands, shell) {
158435
158696
  if (shell !== "bash" && shell !== "zsh") {
158436
- return (0, import_neverthrow83.err)({ type: "UNSUPPORTED_SHELL", shell });
158697
+ return (0, import_neverthrow84.err)({ type: "UNSUPPORTED_SHELL", shell });
158437
158698
  }
158438
- return (0, import_neverthrow83.ok)(shell === "zsh" ? generateZshCompletion(commands) : generateBashCompletion(commands));
158699
+ return (0, import_neverthrow84.ok)(shell === "zsh" ? generateZshCompletion(commands) : generateBashCompletion(commands));
158439
158700
  }
158440
158701
 
158441
158702
  // src/commands/completion-command.ts
@@ -158514,17 +158775,17 @@ function parseVerboseOption(value) {
158514
158775
  // src/shell/xqa-directory.ts
158515
158776
  var import_node_fs11 = require("node:fs");
158516
158777
  var import_node_path28 = __toESM(require("node:path"), 1);
158517
- var import_neverthrow84 = __toESM(require_index_cjs(), 1);
158778
+ var import_neverthrow85 = __toESM(require_index_cjs(), 1);
158518
158779
  function findXqaDirectory(startDirectory) {
158519
158780
  let current = startDirectory;
158520
158781
  for (; ; ) {
158521
158782
  const candidate = import_node_path28.default.join(current, ".xqa");
158522
158783
  if ((0, import_node_fs11.existsSync)(candidate)) {
158523
- return (0, import_neverthrow84.ok)(candidate);
158784
+ return (0, import_neverthrow85.ok)(candidate);
158524
158785
  }
158525
158786
  const parent = import_node_path28.default.dirname(current);
158526
158787
  if (parent === current) {
158527
- return (0, import_neverthrow84.err)({ type: "XQA_NOT_INITIALIZED" });
158788
+ return (0, import_neverthrow85.err)({ type: "XQA_NOT_INITIALIZED" });
158528
158789
  }
158529
158790
  current = parent;
158530
158791
  }
@@ -158615,16 +158876,16 @@ function buildPipelineConfig({
158615
158876
  // src/core/last-path.ts
158616
158877
  var import_node_fs12 = require("node:fs");
158617
158878
  var import_node_path30 = __toESM(require("node:path"), 1);
158618
- var import_neverthrow85 = __toESM(require_index_cjs(), 1);
158879
+ var import_neverthrow86 = __toESM(require_index_cjs(), 1);
158619
158880
  function resolveLastPath(argument, stateContent) {
158620
158881
  if (argument !== void 0) {
158621
- return (0, import_neverthrow85.ok)(argument);
158882
+ return (0, import_neverthrow86.ok)(argument);
158622
158883
  }
158623
158884
  const trimmed = stateContent?.trim();
158624
158885
  if (trimmed) {
158625
- return (0, import_neverthrow85.ok)(trimmed);
158886
+ return (0, import_neverthrow86.ok)(trimmed);
158626
158887
  }
158627
- return (0, import_neverthrow85.err)({ type: "NO_ARG_AND_NO_STATE" });
158888
+ return (0, import_neverthrow86.err)({ type: "NO_ARG_AND_NO_STATE" });
158628
158889
  }
158629
158890
  function lastPathFilePath(xqaDirectoryectory) {
158630
158891
  return import_node_path30.default.join(xqaDirectoryectory, "last-findings-path");
@@ -158690,25 +158951,25 @@ ${cause}
158690
158951
  }
158691
158952
 
158692
158953
  // src/commands/explore/simulator.ts
158693
- var import_neverthrow87 = __toESM(require_index_cjs(), 1);
158954
+ var import_neverthrow88 = __toESM(require_index_cjs(), 1);
158694
158955
 
158695
158956
  // src/core/simulator-selector.ts
158696
- var import_neverthrow86 = __toESM(require_index_cjs(), 1);
158957
+ var import_neverthrow87 = __toESM(require_index_cjs(), 1);
158697
158958
  function matchesUdid(simulator, udid) {
158698
158959
  return simulator.udid.toLowerCase() === udid.toLowerCase();
158699
158960
  }
158700
158961
  function selectSimulators(simulators, udidOverride) {
158701
158962
  if (simulators.length === 0) {
158702
- return (0, import_neverthrow86.err)({ type: "NO_BOOTED_SIMULATORS" });
158963
+ return (0, import_neverthrow87.err)({ type: "NO_BOOTED_SIMULATORS" });
158703
158964
  }
158704
158965
  if (udidOverride === void 0) {
158705
- return (0, import_neverthrow86.ok)([...simulators]);
158966
+ return (0, import_neverthrow87.ok)([...simulators]);
158706
158967
  }
158707
158968
  const match2 = simulators.find((simulator) => matchesUdid(simulator, udidOverride));
158708
158969
  if (match2 === void 0) {
158709
- return (0, import_neverthrow86.err)({ type: "SIMULATOR_UDID_NOT_FOUND", udid: udidOverride });
158970
+ return (0, import_neverthrow87.err)({ type: "SIMULATOR_UDID_NOT_FOUND", udid: udidOverride });
158710
158971
  }
158711
- return (0, import_neverthrow86.ok)([match2]);
158972
+ return (0, import_neverthrow87.ok)([match2]);
158712
158973
  }
158713
158974
 
158714
158975
  // src/commands/explore/simulator.ts
@@ -158716,9 +158977,9 @@ var ITEM_ID2 = "explore";
158716
158977
  function firstUdid(selected) {
158717
158978
  const first = selected[0];
158718
158979
  if (first === void 0) {
158719
- return (0, import_neverthrow87.err)({ type: "NO_BOOTED_SIMULATORS" });
158980
+ return (0, import_neverthrow88.err)({ type: "NO_BOOTED_SIMULATORS" });
158720
158981
  }
158721
- return (0, import_neverthrow87.ok)(first.udid);
158982
+ return (0, import_neverthrow88.ok)(first.udid);
158722
158983
  }
158723
158984
  function buildItemName(simulatorUdid) {
158724
158985
  return `${simulatorUdid} - explorer`;
@@ -158752,7 +159013,7 @@ function buildExploreRunState({
158752
159013
  var import_node_path31 = __toESM(require("node:path"), 1);
158753
159014
  var import_node_url3 = require("node:url");
158754
159015
  var import_dotenv = __toESM(require_main(), 1);
158755
- var import_neverthrow88 = __toESM(require_index_cjs(), 1);
159016
+ var import_neverthrow89 = __toESM(require_index_cjs(), 1);
158756
159017
 
158757
159018
  // src/config-schema.ts
158758
159019
  var configSchema = external_exports.object({
@@ -158770,10 +159031,10 @@ function loadConfig2() {
158770
159031
  const messages = result.error.issues.map(
158771
159032
  (issue2) => ` - ${issue2.path.join(".")}: ${issue2.message}`
158772
159033
  );
158773
- return (0, import_neverthrow88.err)({ type: "INVALID_CONFIG", message: `Configuration error:
159034
+ return (0, import_neverthrow89.err)({ type: "INVALID_CONFIG", message: `Configuration error:
158774
159035
  ${messages.join("\n")}` });
158775
159036
  }
158776
- return (0, import_neverthrow88.ok)(result.data);
159037
+ return (0, import_neverthrow89.ok)(result.data);
158777
159038
  }
158778
159039
  function getGithubShaEnv() {
158779
159040
  return process.env.GITHUB_SHA;
@@ -158794,7 +159055,7 @@ function getAppiumUrlEnv() {
158794
159055
  // src/shell/app-context.ts
158795
159056
  var import_promises31 = require("node:fs/promises");
158796
159057
  var import_node_path32 = __toESM(require("node:path"), 1);
158797
- var import_neverthrow89 = __toESM(require_index_cjs(), 1);
159058
+ var import_neverthrow90 = __toESM(require_index_cjs(), 1);
158798
159059
  var HTML_COMMENT_PATTERN = /<!--[\s\S]*?-->/g;
158799
159060
  function isEnoentError(value) {
158800
159061
  return value !== null && typeof value === "object" && "code" in value && value.code === "ENOENT";
@@ -158804,9 +159065,9 @@ function toAppContextError(cause) {
158804
159065
  }
158805
159066
  function absentContext() {
158806
159067
  const absent = void 0;
158807
- return (0, import_neverthrow89.ok)(absent);
159068
+ return (0, import_neverthrow90.ok)(absent);
158808
159069
  }
158809
- var safeReadFile3 = import_neverthrow89.ResultAsync.fromThrowable(
159070
+ var safeReadFile3 = import_neverthrow90.ResultAsync.fromThrowable(
158810
159071
  async (filePath) => (0, import_promises31.readFile)(filePath, "utf8"),
158811
159072
  toAppContextError
158812
159073
  );
@@ -158820,7 +159081,7 @@ function readContextFile(xqaDirectory, filename) {
158820
159081
  if (isEnoentError(error48.cause)) {
158821
159082
  return absentContext();
158822
159083
  }
158823
- return (0, import_neverthrow89.err)(error48);
159084
+ return (0, import_neverthrow90.err)(error48);
158824
159085
  });
158825
159086
  }
158826
159087
  function readAppContext(xqaDirectory) {
@@ -158834,7 +159095,7 @@ function readExploreContext(xqaDirectory) {
158834
159095
  var import_node_fs13 = require("node:fs");
158835
159096
  var import_node_os3 = require("node:os");
158836
159097
  var import_node_path33 = __toESM(require("node:path"), 1);
158837
- var import_neverthrow90 = __toESM(require_index_cjs(), 1);
159098
+ var import_neverthrow91 = __toESM(require_index_cjs(), 1);
158838
159099
  function resolveDaemonPaths() {
158839
159100
  const home = import_node_path33.default.join((0, import_node_os3.homedir)(), XQA_HOME_DIR);
158840
159101
  (0, import_node_fs13.mkdirSync)(home, { recursive: true });
@@ -158856,7 +159117,7 @@ function ensureDaemonForAutoSpawn() {
158856
159117
  }
158857
159118
  function noDaemon() {
158858
159119
  const noInfo = void 0;
158859
- return (0, import_neverthrow90.okAsync)(noInfo);
159120
+ return (0, import_neverthrow91.okAsync)(noInfo);
158860
159121
  }
158861
159122
  function runPreflightChecks(options) {
158862
159123
  return checkAppiumAvailable().mapErr(() => ({ type: "APPIUM_NOT_FOUND" })).andThen(() => {
@@ -159142,34 +159403,34 @@ function registerInitCommand(program3) {
159142
159403
  var import_node_path40 = __toESM(require("node:path"), 1);
159143
159404
 
159144
159405
  // ../../agents/planner/dist/index.js
159145
- var import_neverthrow91 = __toESM(require_index_cjs(), 1);
159146
159406
  var import_neverthrow92 = __toESM(require_index_cjs(), 1);
159147
- var yaml3 = __toESM(require_dist(), 1);
159148
159407
  var import_neverthrow93 = __toESM(require_index_cjs(), 1);
159408
+ var yaml3 = __toESM(require_dist(), 1);
159409
+ var import_neverthrow94 = __toESM(require_index_cjs(), 1);
159149
159410
  var import_promises32 = require("node:fs/promises");
159150
159411
  var import_node_path36 = __toESM(require("node:path"), 1);
159151
- var import_neverthrow94 = __toESM(require_index_cjs(), 1);
159152
- var import_promises33 = require("node:fs/promises");
159153
159412
  var import_neverthrow95 = __toESM(require_index_cjs(), 1);
159413
+ var import_promises33 = require("node:fs/promises");
159154
159414
  var import_neverthrow96 = __toESM(require_index_cjs(), 1);
159155
159415
  var import_neverthrow97 = __toESM(require_index_cjs(), 1);
159416
+ var import_neverthrow98 = __toESM(require_index_cjs(), 1);
159156
159417
  var import_node_child_process11 = require("node:child_process");
159157
159418
  var import_node_util4 = require("node:util");
159158
- var import_neverthrow98 = __toESM(require_index_cjs(), 1);
159419
+ var import_neverthrow99 = __toESM(require_index_cjs(), 1);
159159
159420
  var import_node_process2 = require("node:process");
159160
159421
  var import_node_child_process12 = require("node:child_process");
159161
159422
  var import_node_util5 = require("node:util");
159162
- var import_neverthrow99 = __toESM(require_index_cjs(), 1);
159163
159423
  var import_neverthrow100 = __toESM(require_index_cjs(), 1);
159164
159424
  var import_neverthrow101 = __toESM(require_index_cjs(), 1);
159425
+ var import_neverthrow102 = __toESM(require_index_cjs(), 1);
159165
159426
  var import_promises34 = require("node:fs/promises");
159166
159427
  var import_node_path37 = __toESM(require("node:path"), 1);
159167
- var import_neverthrow102 = __toESM(require_index_cjs(), 1);
159428
+ var import_neverthrow103 = __toESM(require_index_cjs(), 1);
159168
159429
  var import_promises35 = require("node:fs/promises");
159169
159430
  var import_node_path38 = __toESM(require("node:path"), 1);
159170
- var import_neverthrow103 = __toESM(require_index_cjs(), 1);
159171
- var import_promises36 = require("node:fs/promises");
159172
159431
  var import_neverthrow104 = __toESM(require_index_cjs(), 1);
159432
+ var import_promises36 = require("node:fs/promises");
159433
+ var import_neverthrow105 = __toESM(require_index_cjs(), 1);
159173
159434
  function isEmptySummary(summary) {
159174
159435
  return summary.touchedFiles.length === 0 && summary.uncommittedFiles.length === 0;
159175
159436
  }
@@ -159487,15 +159748,15 @@ function branchReferenceToString(reference) {
159487
159748
  }
159488
159749
  function resolveBaseReference(context) {
159489
159750
  if (context.input.baseOverride !== void 0) {
159490
- return (0, import_neverthrow91.okAsync)(context.input.baseOverride);
159751
+ return (0, import_neverthrow92.okAsync)(context.input.baseOverride);
159491
159752
  }
159492
159753
  return context.deps.resolveBaseBranch(context.input.gitContext);
159493
159754
  }
159494
159755
  function assertNonEmptyDiff(state) {
159495
159756
  if (isEmptySummary(state.summary)) {
159496
- return (0, import_neverthrow91.err)({ type: "EMPTY_DIFF" });
159757
+ return (0, import_neverthrow92.err)({ type: "EMPTY_DIFF" });
159497
159758
  }
159498
- return (0, import_neverthrow91.ok)(state);
159759
+ return (0, import_neverthrow92.ok)(state);
159499
159760
  }
159500
159761
  function emitDrafts(input) {
159501
159762
  const { context, summary } = input;
@@ -159527,7 +159788,7 @@ function runEmitAndPersist(input) {
159527
159788
  return emitDrafts({ summary: state.summary, context }).andThen((drafts) => {
159528
159789
  context.deps.emitDebug?.(`[plan] drafts count=${String(drafts.length)}`);
159529
159790
  if (drafts.length === 0) {
159530
- return (0, import_neverthrow91.okAsync)({
159791
+ return (0, import_neverthrow92.okAsync)({
159531
159792
  specs: [],
159532
159793
  emptyReason: "model-abstained"
159533
159794
  });
@@ -159542,7 +159803,7 @@ function dispatchClassification(input) {
159542
159803
  const emitDebug = input.context.deps.emitDebug;
159543
159804
  if (classification.kind === "empty") {
159544
159805
  emitClassificationDebug({ emitDebug, kind: "empty", reason: classification.reason });
159545
- return (0, import_neverthrow91.okAsync)({ specs: [], emptyReason: classification.reason });
159806
+ return (0, import_neverthrow92.okAsync)({ specs: [], emptyReason: classification.reason });
159546
159807
  }
159547
159808
  emitClassificationDebug({ emitDebug, kind: "actionable" });
159548
159809
  return runEmitAndPersist(input);
@@ -159581,7 +159842,7 @@ function resolveHead(input) {
159581
159842
  function collectChangeSummary(input) {
159582
159843
  const diff = input.gitDiff({ context: input.gitContext, baseSha: input.baseRef });
159583
159844
  const status = input.gitStatusPorcelain(input.gitContext);
159584
- return import_neverthrow91.ResultAsync.combine([diff, status]).map(([rawDiff, porcelainLines]) => ({
159845
+ return import_neverthrow92.ResultAsync.combine([diff, status]).map(([rawDiff, porcelainLines]) => ({
159585
159846
  rawDiff,
159586
159847
  summary: summarizeDiff(rawDiff, extractUncommittedFiles(porcelainLines))
159587
159848
  }));
@@ -159596,9 +159857,9 @@ function toSpecSummaries(entries) {
159596
159857
  function recoverPlanMissing(result) {
159597
159858
  return result.orElse((error48) => {
159598
159859
  if (error48.type === "PLAN_DIR_MISSING") {
159599
- return (0, import_neverthrow91.okAsync)([]);
159860
+ return (0, import_neverthrow92.okAsync)([]);
159600
159861
  }
159601
- return (0, import_neverthrow91.errAsync)(error48);
159862
+ return (0, import_neverthrow92.errAsync)(error48);
159602
159863
  });
159603
159864
  }
159604
159865
  function generatePlan(input, deps) {
@@ -159741,13 +160002,13 @@ function loadExistingSpec(input) {
159741
160002
  }
159742
160003
  function assertOriginalMetaComplete(spec, path410) {
159743
160004
  if (!isMetaComplete(spec)) {
159744
- return (0, import_neverthrow92.err)({
160005
+ return (0, import_neverthrow93.err)({
159745
160006
  type: "SPEC_PARSE_FAILED",
159746
160007
  path: path410,
159747
160008
  reason: "missing required meta field"
159748
160009
  });
159749
160010
  }
159750
- return (0, import_neverthrow92.ok)(spec);
160011
+ return (0, import_neverthrow93.ok)(spec);
159751
160012
  }
159752
160013
  function buildApplyInput(input) {
159753
160014
  return {
@@ -159760,9 +160021,9 @@ function buildApplyInput(input) {
159760
160021
  function assertMetaPreserved(input) {
159761
160022
  const violated = IMMUTABLE_META_KEYS.find((key) => input.updated[key] !== input.original[key]);
159762
160023
  if (violated !== void 0) {
159763
- return (0, import_neverthrow92.err)({ type: "SCENARIO_ID_LOST_IN_EDIT", path: input.path });
160024
+ return (0, import_neverthrow93.err)({ type: "SCENARIO_ID_LOST_IN_EDIT", path: input.path });
159764
160025
  }
159765
- return (0, import_neverthrow92.ok)({
160026
+ return (0, import_neverthrow93.ok)({
159766
160027
  ...input.updated,
159767
160028
  scenarioId: input.original.scenarioId,
159768
160029
  baseCommit: input.original.baseCommit,
@@ -159824,12 +160085,12 @@ function editScenario(input, deps) {
159824
160085
  function loadEntries(context) {
159825
160086
  return context.deps.readPlan({ directory: context.input.outputDirectory }).andThen((entries) => {
159826
160087
  if (entries.length === 0) {
159827
- return (0, import_neverthrow93.errAsync)({
160088
+ return (0, import_neverthrow94.errAsync)({
159828
160089
  type: "PLAN_EMPTY",
159829
160090
  path: context.input.outputDirectory
159830
160091
  });
159831
160092
  }
159832
- return (0, import_neverthrow93.okAsync)(entries);
160093
+ return (0, import_neverthrow94.okAsync)(entries);
159833
160094
  });
159834
160095
  }
159835
160096
  function emitDrafts2(input) {
@@ -159872,7 +160133,7 @@ function runEmitAndPersist2(state, context) {
159872
160133
  return emitDrafts2({ summary: state.summary, entries: state.entries, context }).andThen(
159873
160134
  (drafts) => {
159874
160135
  if (drafts.length === 0) {
159875
- return (0, import_neverthrow93.okAsync)({
160136
+ return (0, import_neverthrow94.okAsync)({
159876
160137
  appended: [],
159877
160138
  emptyReason: "model-abstained"
159878
160139
  });
@@ -159888,11 +160149,11 @@ function runEmitAndPersist2(state, context) {
159888
160149
  }
159889
160150
  function dispatchState(state, context) {
159890
160151
  if (isEmptySummary(state.summary)) {
159891
- return (0, import_neverthrow93.okAsync)({ appended: [], emptyReason: "other" });
160152
+ return (0, import_neverthrow94.okAsync)({ appended: [], emptyReason: "other" });
159892
160153
  }
159893
160154
  const classification = classifyActionability(state.summary, state.rawDiff);
159894
160155
  if (classification.kind === "empty") {
159895
- return (0, import_neverthrow93.okAsync)({ appended: [], emptyReason: classification.reason });
160156
+ return (0, import_neverthrow94.okAsync)({ appended: [], emptyReason: classification.reason });
159896
160157
  }
159897
160158
  return runEmitAndPersist2(state, context);
159898
160159
  }
@@ -159915,14 +160176,14 @@ function pickSinceSha(entries) {
159915
160176
  }
159916
160177
  function ensureSinceShaExists(input) {
159917
160178
  if (input.sinceSha === void 0) {
159918
- return (0, import_neverthrow93.errAsync)({ type: "GIT_SINCE_SHA_UNRECORDED" });
160179
+ return (0, import_neverthrow94.errAsync)({ type: "GIT_SINCE_SHA_UNRECORDED" });
159919
160180
  }
159920
160181
  const sha = input.sinceSha;
159921
160182
  return input.gitCommitExists({ context: input.gitContext, sha }).andThen((exists) => {
159922
160183
  if (!exists) {
159923
- return (0, import_neverthrow93.errAsync)({ type: "GIT_SINCE_SHA_MISSING", sha });
160184
+ return (0, import_neverthrow94.errAsync)({ type: "GIT_SINCE_SHA_MISSING", sha });
159924
160185
  }
159925
- return (0, import_neverthrow93.okAsync)(sha);
160186
+ return (0, import_neverthrow94.okAsync)(sha);
159926
160187
  });
159927
160188
  }
159928
160189
  function extendPlan(input, deps) {
@@ -159934,7 +160195,7 @@ async function writeAndRename(input) {
159934
160195
  await (0, import_promises33.writeFile)(temporaryPath, input.content, "utf8");
159935
160196
  await (0, import_promises33.rename)(temporaryPath, input.path);
159936
160197
  }
159937
- var rawAtomicWrite = import_neverthrow95.ResultAsync.fromThrowable(
160198
+ var rawAtomicWrite = import_neverthrow96.ResultAsync.fromThrowable(
159938
160199
  writeAndRename,
159939
160200
  (cause) => ({ cause })
159940
160201
  );
@@ -159965,24 +160226,24 @@ function toScenarioMeta2(spec) {
159965
160226
  }
159966
160227
  function toScenario(entry) {
159967
160228
  if (!isMetaComplete(entry.spec)) {
159968
- return (0, import_neverthrow96.err)({
160229
+ return (0, import_neverthrow97.err)({
159969
160230
  type: "SPEC_PARSE_FAILED",
159970
160231
  path: entry.path,
159971
160232
  reason: "missing required meta field"
159972
160233
  });
159973
160234
  }
159974
- return (0, import_neverthrow96.ok)({ ...toScenarioDraft2(entry.spec), ...toScenarioMeta2(entry.spec) });
160235
+ return (0, import_neverthrow97.ok)({ ...toScenarioDraft2(entry.spec), ...toScenarioMeta2(entry.spec) });
159975
160236
  }
159976
160237
  function collectScenarios(entries) {
159977
160238
  const scenarios = [];
159978
160239
  for (const entry of entries) {
159979
160240
  const result = toScenario(entry);
159980
160241
  if (result.isErr()) {
159981
- return (0, import_neverthrow96.err)(result.error);
160242
+ return (0, import_neverthrow97.err)(result.error);
159982
160243
  }
159983
160244
  scenarios.push(result.value);
159984
160245
  }
159985
- return (0, import_neverthrow96.ok)(scenarios);
160246
+ return (0, import_neverthrow97.ok)(scenarios);
159986
160247
  }
159987
160248
  function buildFilesMap(entries) {
159988
160249
  const pairs2 = entries.flatMap((entry) => {
@@ -160083,11 +160344,11 @@ var REPORT_FILENAME = "report.json";
160083
160344
  var RUNS_FILENAME = "scenario-runs.json";
160084
160345
  var ENOENT_CODE = "ENOENT";
160085
160346
  var findingsArraySchema = external_exports.array(findingSchema);
160086
- var safeJsonParse7 = (0, import_neverthrow94.fromThrowable)(
160347
+ var safeJsonParse7 = (0, import_neverthrow95.fromThrowable)(
160087
160348
  JSON.parse,
160088
160349
  (cause) => ({ cause })
160089
160350
  );
160090
- var rawReadFile = import_neverthrow94.ResultAsync.fromThrowable(
160351
+ var rawReadFile = import_neverthrow95.ResultAsync.fromThrowable(
160091
160352
  async (filePath) => (0, import_promises32.readFile)(filePath, "utf8"),
160092
160353
  (cause) => ({ cause })
160093
160354
  );
@@ -160098,9 +160359,9 @@ function isEnoentError2(error48) {
160098
160359
  function readFileOptional(filePath) {
160099
160360
  return rawReadFile(filePath).map((content) => content).orElse(({ cause }) => {
160100
160361
  if (isEnoentError2(cause)) {
160101
- return (0, import_neverthrow94.ok)(void 0);
160362
+ return (0, import_neverthrow95.ok)(void 0);
160102
160363
  }
160103
- return (0, import_neverthrow94.err)({ type: "FINDINGS_READ_FAILED", path: filePath, cause });
160364
+ return (0, import_neverthrow95.err)({ type: "FINDINGS_READ_FAILED", path: filePath, cause });
160104
160365
  });
160105
160366
  }
160106
160367
  function parseFindingsJson(input) {
@@ -160111,9 +160372,9 @@ function parseFindingsJson(input) {
160111
160372
  function validateFindingsSchema(data, filePath) {
160112
160373
  const parsed = findingsArraySchema.safeParse(data);
160113
160374
  if (!parsed.success) {
160114
- return (0, import_neverthrow94.err)({ type: "FINDINGS_READ_FAILED", path: filePath, cause: parsed.error });
160375
+ return (0, import_neverthrow95.err)({ type: "FINDINGS_READ_FAILED", path: filePath, cause: parsed.error });
160115
160376
  }
160116
- return (0, import_neverthrow94.ok)(parsed.data);
160377
+ return (0, import_neverthrow95.ok)(parsed.data);
160117
160378
  }
160118
160379
  function validateFindings(input) {
160119
160380
  return parseFindingsJson(input).andThen((data) => validateFindingsSchema(data, input.path));
@@ -160121,12 +160382,12 @@ function validateFindings(input) {
160121
160382
  function parseRunsSchema(data, filePath) {
160122
160383
  const parsed = scenarioRunsFileSchema.safeParse(data);
160123
160384
  if (!parsed.success) {
160124
- return (0, import_neverthrow94.err)({ type: "FINDINGS_READ_FAILED", path: filePath, cause: parsed.error });
160385
+ return (0, import_neverthrow95.err)({ type: "FINDINGS_READ_FAILED", path: filePath, cause: parsed.error });
160125
160386
  }
160126
160387
  const entries = parsed.data.records.map(
160127
160388
  (record2) => [record2.scenarioId, record2]
160128
160389
  );
160129
- return (0, import_neverthrow94.ok)(Object.fromEntries(entries));
160390
+ return (0, import_neverthrow95.ok)(Object.fromEntries(entries));
160130
160391
  }
160131
160392
  function parseRunsJson(raw, filePath) {
160132
160393
  return safeJsonParse7(raw).mapErr(({ cause }) => ({ type: "FINDINGS_READ_FAILED", path: filePath, cause })).andThen((data) => parseRunsSchema(data, filePath));
@@ -160169,14 +160430,14 @@ function correlateAndPersist(input) {
160169
160430
  }
160170
160431
  function loadRunRecords(input) {
160171
160432
  if (input.readRunsFileFn === void 0) {
160172
- return import_neverthrow94.ResultAsync.fromSafePromise(
160433
+ return import_neverthrow95.ResultAsync.fromSafePromise(
160173
160434
  Promise.resolve(void 0)
160174
160435
  );
160175
160436
  }
160176
160437
  const resolvedRunsPath = runsPathFor(input.findingsPath, input.runsPath);
160177
160438
  return input.readRunsFileFn(resolvedRunsPath).andThen((raw) => {
160178
160439
  if (raw === void 0) {
160179
- return (0, import_neverthrow94.ok)(void 0);
160440
+ return (0, import_neverthrow95.ok)(void 0);
160180
160441
  }
160181
160442
  return parseRunsJson(raw, resolvedRunsPath);
160182
160443
  });
@@ -160243,13 +160504,13 @@ async function createMessage2(input) {
160243
160504
  function extractText(message, operation) {
160244
160505
  const firstBlock = message.content[0];
160245
160506
  if (firstBlock?.type !== "text") {
160246
- return (0, import_neverthrow97.err)({
160507
+ return (0, import_neverthrow98.err)({
160247
160508
  type: "AI_RESPONSE_INVALID",
160248
160509
  operation,
160249
160510
  raw: JSON.stringify(message.content)
160250
160511
  });
160251
160512
  }
160252
- return (0, import_neverthrow97.ok)(firstBlock.text);
160513
+ return (0, import_neverthrow98.ok)(firstBlock.text);
160253
160514
  }
160254
160515
  function buildClient(apiKey) {
160255
160516
  return new Anthropic({ apiKey });
@@ -160257,7 +160518,7 @@ function buildClient(apiKey) {
160257
160518
  function invokeAi(arguments_) {
160258
160519
  const { input, operation } = arguments_;
160259
160520
  const client = buildClient(input.config.apiKey);
160260
- const callMessage = (0, import_neverthrow97.fromAsyncThrowable)(
160521
+ const callMessage = (0, import_neverthrow98.fromAsyncThrowable)(
160261
160522
  createMessage2,
160262
160523
  (cause) => ({ type: "AI_CALL_FAILED", operation, cause })
160263
160524
  );
@@ -160308,7 +160569,7 @@ async function runGit(input) {
160308
160569
  }
160309
160570
  function execGit(commandArguments, context) {
160310
160571
  const command = `git ${commandArguments.join(" ")}`;
160311
- return (0, import_neverthrow98.fromAsyncThrowable)(
160572
+ return (0, import_neverthrow99.fromAsyncThrowable)(
160312
160573
  runGit,
160313
160574
  (cause) => toExecError(cause, command)
160314
160575
  )({ commandArguments, context });
@@ -160322,9 +160583,9 @@ function splitNonEmptyLines(value) {
160322
160583
  }
160323
160584
  function foldCommitExists(error48) {
160324
160585
  if (error48.type === "GIT_EXEC_FAILED") {
160325
- return (0, import_neverthrow98.okAsync)(false);
160586
+ return (0, import_neverthrow99.okAsync)(false);
160326
160587
  }
160327
- return (0, import_neverthrow98.errAsync)(error48);
160588
+ return (0, import_neverthrow99.errAsync)(error48);
160328
160589
  }
160329
160590
  function resolveDetachedHead(context) {
160330
160591
  return execGit(["rev-parse", "HEAD"], context).map(
@@ -160377,7 +160638,7 @@ async function runGh(input) {
160377
160638
  });
160378
160639
  return { stdout, stderr };
160379
160640
  }
160380
- var safeRunGh = (0, import_neverthrow99.fromAsyncThrowable)(
160641
+ var safeRunGh = (0, import_neverthrow100.fromAsyncThrowable)(
160381
160642
  runGh,
160382
160643
  (cause) => ({ type: "GH_PR_LOOKUP_FAILED", cause })
160383
160644
  );
@@ -160388,9 +160649,9 @@ function ghDetectPrBaseBranch(context) {
160388
160649
  }).andThen((result) => {
160389
160650
  const value = result.stdout.trim();
160390
160651
  if (value.length === 0) {
160391
- return (0, import_neverthrow99.errAsync)({ type: "GH_PR_LOOKUP_FAILED", cause: "empty-output" });
160652
+ return (0, import_neverthrow100.errAsync)({ type: "GH_PR_LOOKUP_FAILED", cause: "empty-output" });
160392
160653
  }
160393
- return (0, import_neverthrow99.okAsync)(value);
160654
+ return (0, import_neverthrow100.okAsync)(value);
160394
160655
  });
160395
160656
  }
160396
160657
  function resolveBaseBranch(gitContext, deps) {
@@ -160537,20 +160798,20 @@ var scenarioDraftSchema = external_exports.object({
160537
160798
  coverageNote: external_exports.string().optional()
160538
160799
  });
160539
160800
  var payloadSchema = external_exports.object({ scenarios: external_exports.array(scenarioDraftSchema) });
160540
- var safeParseJson3 = (0, import_neverthrow100.fromThrowable)(
160801
+ var safeParseJson3 = (0, import_neverthrow101.fromThrowable)(
160541
160802
  (raw) => JSON.parse(raw),
160542
160803
  () => ({ type: "AI_RESPONSE_JSON_PARSE" })
160543
160804
  );
160544
160805
  function validatePayload(raw) {
160545
160806
  const parsed = safeParseJson3(raw);
160546
160807
  if (parsed.isErr()) {
160547
- return (0, import_neverthrow100.err)({ type: "AI_RESPONSE_INVALID", operation: "scenario-emit", raw });
160808
+ return (0, import_neverthrow101.err)({ type: "AI_RESPONSE_INVALID", operation: "scenario-emit", raw });
160548
160809
  }
160549
160810
  const validated = payloadSchema.safeParse(parsed.value);
160550
160811
  if (!validated.success) {
160551
- return (0, import_neverthrow100.err)({ type: "AI_RESPONSE_INVALID", operation: "scenario-emit", raw });
160812
+ return (0, import_neverthrow101.err)({ type: "AI_RESPONSE_INVALID", operation: "scenario-emit", raw });
160552
160813
  }
160553
- return (0, import_neverthrow100.ok)(validated.data.scenarios);
160814
+ return (0, import_neverthrow101.ok)(validated.data.scenarios);
160554
160815
  }
160555
160816
  function emitScenarios(input, deps) {
160556
160817
  const prompt = buildScenarioEmitterPrompt({
@@ -160632,14 +160893,14 @@ function validateCandidate(validateInput) {
160632
160893
  const { raw, existingSpec, specPath } = validateInput;
160633
160894
  const parsed = parseSpec(raw, specPath);
160634
160895
  if (parsed.isErr()) {
160635
- return (0, import_neverthrow101.err)({ type: "AI_RESPONSE_INVALID", operation: "edit-apply", raw });
160896
+ return (0, import_neverthrow102.err)({ type: "AI_RESPONSE_INVALID", operation: "edit-apply", raw });
160636
160897
  }
160637
160898
  const candidate = parsed.value;
160638
160899
  const violated = findMissingOrChangedKey(candidate, existingSpec);
160639
160900
  if (violated !== void 0) {
160640
- return (0, import_neverthrow101.err)({ type: "SCENARIO_ID_LOST_IN_EDIT", path: specPath });
160901
+ return (0, import_neverthrow102.err)({ type: "SCENARIO_ID_LOST_IN_EDIT", path: specPath });
160641
160902
  }
160642
- return (0, import_neverthrow101.ok)(candidate);
160903
+ return (0, import_neverthrow102.ok)(candidate);
160643
160904
  }
160644
160905
  function applyEdit(input, deps) {
160645
160906
  const prompt = buildEditApplierPrompt(input.existingSpec, input.userFeedback);
@@ -160657,14 +160918,14 @@ function mapReaddirError(input) {
160657
160918
  }
160658
160919
  return { type: "SPEC_READ_FAILED", path: input.directory, cause: input.cause };
160659
160920
  }
160660
- var rawReaddir = import_neverthrow102.ResultAsync.fromThrowable(
160921
+ var rawReaddir = import_neverthrow103.ResultAsync.fromThrowable(
160661
160922
  async (directory) => (0, import_promises34.readdir)(directory),
160662
160923
  (cause) => ({ cause })
160663
160924
  );
160664
160925
  function safeReaddir(directory) {
160665
160926
  return rawReaddir(directory).mapErr(({ cause }) => mapReaddirError({ directory, cause }));
160666
160927
  }
160667
- var rawReadFile2 = import_neverthrow102.ResultAsync.fromThrowable(
160928
+ var rawReadFile2 = import_neverthrow103.ResultAsync.fromThrowable(
160668
160929
  async (input) => (0, import_promises34.readFile)(input.path, "utf8"),
160669
160930
  (cause) => ({ cause })
160670
160931
  );
@@ -160684,17 +160945,17 @@ function readEntry3(input) {
160684
160945
  }
160685
160946
  function readEntries2(directory, filenames) {
160686
160947
  const tasks = filenames.map((filename) => readEntry3({ directory, filename }));
160687
- return import_neverthrow102.ResultAsync.combine([...tasks]);
160948
+ return import_neverthrow103.ResultAsync.combine([...tasks]);
160688
160949
  }
160689
160950
  function readPlan(input) {
160690
160951
  return safeReaddir(input.directory).map((filenames) => filterAndSortSpecs(filenames)).andThen((filenames) => readEntries2(input.directory, filenames));
160691
160952
  }
160692
160953
  var SCENARIO_FILENAME_PATTERN = /^scenario-(\d+)\.test\.md$/;
160693
- var safeMkdir4 = import_neverthrow103.ResultAsync.fromThrowable(
160954
+ var safeMkdir4 = import_neverthrow104.ResultAsync.fromThrowable(
160694
160955
  async (path410) => (0, import_promises35.mkdir)(path410, { recursive: true }),
160695
160956
  (cause) => ({ type: "SPEC_WRITE_FAILED", path: "", cause })
160696
160957
  );
160697
- var safeReaddir2 = import_neverthrow103.ResultAsync.fromThrowable(
160958
+ var safeReaddir2 = import_neverthrow104.ResultAsync.fromThrowable(
160698
160959
  async (path410) => (0, import_promises35.readdir)(path410),
160699
160960
  (cause) => ({ type: "SPEC_WRITE_FAILED", path: "", cause })
160700
160961
  );
@@ -160745,12 +161006,12 @@ function writeAllScenarios(input, startIndex) {
160745
161006
  context: input.context
160746
161007
  })
160747
161008
  );
160748
- return import_neverthrow103.ResultAsync.combine([...tasks]);
161009
+ return import_neverthrow104.ResultAsync.combine([...tasks]);
160749
161010
  }
160750
161011
  function writeScenarios(input) {
160751
161012
  return ensureDirectory(input.directory).andThen(() => listScenarioIndices(input.directory)).map((indices) => computeNextIndex(indices)).andThen((startIndex) => writeAllScenarios(input, startIndex));
160752
161013
  }
160753
- var readFileByPath = import_neverthrow104.ResultAsync.fromThrowable(
161014
+ var readFileByPath = import_neverthrow105.ResultAsync.fromThrowable(
160754
161015
  async (path410) => (0, import_promises36.readFile)(path410, "utf8"),
160755
161016
  (cause) => ({ cause })
160756
161017
  );
@@ -160786,10 +161047,10 @@ var EXIT_PLAN_EMPTY = 45;
160786
161047
  var EXIT_SCENARIO_ID_LOST_IN_EDIT = 51;
160787
161048
 
160788
161049
  // src/commands/plan/format-diagnostic.ts
160789
- var import_neverthrow105 = __toESM(require_index_cjs(), 1);
161050
+ var import_neverthrow106 = __toESM(require_index_cjs(), 1);
160790
161051
  var RAW_TRUNCATION_LIMIT = 200;
160791
161052
  var UNSERIALIZABLE3 = "[unserializable]";
160792
- var safeStringify3 = (0, import_neverthrow105.fromThrowable)(
161053
+ var safeStringify3 = (0, import_neverthrow106.fromThrowable)(
160793
161054
  (value) => JSON.stringify(value),
160794
161055
  () => UNSERIALIZABLE3
160795
161056
  );
@@ -160903,7 +161164,7 @@ function runPlanEdit(input, options) {
160903
161164
  }
160904
161165
 
160905
161166
  // ../../node_modules/.pnpm/ulid@3.0.2/node_modules/ulid/dist/node/index.js
160906
- var import_node_crypto5 = __toESM(require("node:crypto"), 1);
161167
+ var import_node_crypto6 = __toESM(require("node:crypto"), 1);
160907
161168
  var ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
160908
161169
  var ENCODING_LEN = 32;
160909
161170
  var RANDOM_LEN = 16;
@@ -160935,7 +161196,7 @@ function randomChar(prng) {
160935
161196
  }
160936
161197
  function detectPRNG(root) {
160937
161198
  const rootLookup = detectRoot();
160938
- const globalCrypto = rootLookup && (rootLookup.crypto || rootLookup.msCrypto) || (typeof import_node_crypto5.default !== "undefined" ? import_node_crypto5.default : null);
161199
+ const globalCrypto = rootLookup && (rootLookup.crypto || rootLookup.msCrypto) || (typeof import_node_crypto6.default !== "undefined" ? import_node_crypto6.default : null);
160939
161200
  if (typeof globalCrypto?.getRandomValues === "function") {
160940
161201
  return () => {
160941
161202
  const buffer = new Uint8Array(1);
@@ -160944,8 +161205,8 @@ function detectPRNG(root) {
160944
161205
  };
160945
161206
  } else if (typeof globalCrypto?.randomBytes === "function") {
160946
161207
  return () => globalCrypto.randomBytes(1).readUInt8() / 256;
160947
- } else if (import_node_crypto5.default?.randomBytes) {
160948
- return () => import_node_crypto5.default.randomBytes(1).readUInt8() / 256;
161208
+ } else if (import_node_crypto6.default?.randomBytes) {
161209
+ return () => import_node_crypto6.default.randomBytes(1).readUInt8() / 256;
160949
161210
  }
160950
161211
  throw new ULIDError(ULIDErrorCode.PRNGDetectFailure, "Failed to find a reliable PRNG");
160951
161212
  }
@@ -161166,11 +161427,11 @@ function registerPlanCommand(program3, loader2) {
161166
161427
  }
161167
161428
 
161168
161429
  // ../../packages/reporter-github/dist/index.js
161169
- var import_neverthrow108 = __toESM(require_index_cjs(), 1);
161170
161430
  var import_neverthrow109 = __toESM(require_index_cjs(), 1);
161171
- var import_node_buffer3 = require("node:buffer");
161172
161431
  var import_neverthrow110 = __toESM(require_index_cjs(), 1);
161432
+ var import_node_buffer3 = require("node:buffer");
161173
161433
  var import_neverthrow111 = __toESM(require_index_cjs(), 1);
161434
+ var import_neverthrow112 = __toESM(require_index_cjs(), 1);
161174
161435
 
161175
161436
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
161176
161437
  var external_exports2 = {};
@@ -168762,7 +169023,7 @@ var Octokit2 = Octokit.plugin(requestLog, legacyRestEndpointMethods, paginateRes
168762
169023
 
168763
169024
  // ../../packages/reporter-github/dist/index.js
168764
169025
  var import_node_fs16 = require("node:fs");
168765
- var import_neverthrow112 = __toESM(require_index_cjs(), 1);
169026
+ var import_neverthrow113 = __toESM(require_index_cjs(), 1);
168766
169027
  var import_node_fs17 = require("node:fs");
168767
169028
  var import_node_path42 = __toESM(require("node:path"), 1);
168768
169029
 
@@ -170100,29 +170361,29 @@ var completeMultipartUpload2 = createCompleteMultipartUploadMethod({
170100
170361
  });
170101
170362
 
170102
170363
  // ../../packages/artifacts/dist/shell/put-artifact.js
170103
- var import_neverthrow107 = __toESM(require_index_cjs(), 1);
170364
+ var import_neverthrow108 = __toESM(require_index_cjs(), 1);
170104
170365
 
170105
170366
  // ../../packages/artifacts/dist/core/validate-key.js
170106
- var import_neverthrow106 = __toESM(require_index_cjs(), 1);
170367
+ var import_neverthrow107 = __toESM(require_index_cjs(), 1);
170107
170368
  var KEY_MAX_LENGTH = 1024;
170108
170369
  var KEY_REGEX = /^[a-zA-Z0-9._\-/]+$/;
170109
170370
  function validateKey(key) {
170110
170371
  if (key.length === 0) {
170111
- return (0, import_neverthrow106.err)({ type: "INVALID_KEY", key, reason: "EMPTY" });
170372
+ return (0, import_neverthrow107.err)({ type: "INVALID_KEY", key, reason: "EMPTY" });
170112
170373
  }
170113
170374
  if (key.length > KEY_MAX_LENGTH) {
170114
- return (0, import_neverthrow106.err)({ type: "INVALID_KEY", key, reason: "TOO_LONG" });
170375
+ return (0, import_neverthrow107.err)({ type: "INVALID_KEY", key, reason: "TOO_LONG" });
170115
170376
  }
170116
170377
  if (key.startsWith("/") || key.endsWith("/")) {
170117
- return (0, import_neverthrow106.err)({ type: "INVALID_KEY", key, reason: "EDGE_SLASH" });
170378
+ return (0, import_neverthrow107.err)({ type: "INVALID_KEY", key, reason: "EDGE_SLASH" });
170118
170379
  }
170119
170380
  if (key.includes("..")) {
170120
- return (0, import_neverthrow106.err)({ type: "INVALID_KEY", key, reason: "PARENT_TRAVERSAL" });
170381
+ return (0, import_neverthrow107.err)({ type: "INVALID_KEY", key, reason: "PARENT_TRAVERSAL" });
170121
170382
  }
170122
170383
  if (!KEY_REGEX.test(key)) {
170123
- return (0, import_neverthrow106.err)({ type: "INVALID_KEY", key, reason: "DISALLOWED_CHARACTERS" });
170384
+ return (0, import_neverthrow107.err)({ type: "INVALID_KEY", key, reason: "DISALLOWED_CHARACTERS" });
170124
170385
  }
170125
- return (0, import_neverthrow106.ok)(key);
170386
+ return (0, import_neverthrow107.ok)(key);
170126
170387
  }
170127
170388
 
170128
170389
  // ../../packages/artifacts/dist/shell/put-artifact.js
@@ -170146,7 +170407,7 @@ function toUploadError(cause) {
170146
170407
  };
170147
170408
  }
170148
170409
  function callBlobPut(deps, input) {
170149
- const safePut = import_neverthrow107.ResultAsync.fromThrowable(deps.put, toUploadError);
170410
+ const safePut = import_neverthrow108.ResultAsync.fromThrowable(deps.put, toUploadError);
170150
170411
  return safePut({
170151
170412
  key: input.key,
170152
170413
  content: input.content,
@@ -170156,30 +170417,30 @@ function callBlobPut(deps, input) {
170156
170417
  }
170157
170418
  function putArtifact(input, dependencies = defaultDependencies) {
170158
170419
  if (input.token.length === 0) {
170159
- return (0, import_neverthrow107.errAsync)({ type: "EMPTY_TOKEN" });
170420
+ return (0, import_neverthrow108.errAsync)({ type: "EMPTY_TOKEN" });
170160
170421
  }
170161
170422
  if (input.content.length === 0) {
170162
- return (0, import_neverthrow107.errAsync)({ type: "EMPTY_CONTENT" });
170423
+ return (0, import_neverthrow108.errAsync)({ type: "EMPTY_CONTENT" });
170163
170424
  }
170164
170425
  return validateKey(input.key).asyncAndThen(() => callBlobPut(dependencies, input));
170165
170426
  }
170166
170427
 
170167
170428
  // ../../packages/reporter-github/dist/index.js
170168
- var import_neverthrow113 = __toESM(require_index_cjs(), 1);
170429
+ var import_neverthrow114 = __toESM(require_index_cjs(), 1);
170169
170430
  var import_node_child_process13 = require("node:child_process");
170170
170431
  var import_node_fs18 = require("node:fs");
170171
- var import_neverthrow114 = __toESM(require_index_cjs(), 1);
170172
- var import_node_child_process14 = require("node:child_process");
170173
170432
  var import_neverthrow115 = __toESM(require_index_cjs(), 1);
170433
+ var import_node_child_process14 = require("node:child_process");
170434
+ var import_neverthrow116 = __toESM(require_index_cjs(), 1);
170174
170435
  var import_node_child_process15 = require("node:child_process");
170175
170436
  var import_node_fs19 = require("node:fs");
170176
- var import_neverthrow116 = __toESM(require_index_cjs(), 1);
170177
170437
  var import_neverthrow117 = __toESM(require_index_cjs(), 1);
170438
+ var import_neverthrow118 = __toESM(require_index_cjs(), 1);
170178
170439
  var import_node_fs20 = require("node:fs");
170179
170440
  var import_node_path43 = __toESM(require("node:path"), 1);
170180
- var import_neverthrow118 = __toESM(require_index_cjs(), 1);
170181
170441
  var import_neverthrow119 = __toESM(require_index_cjs(), 1);
170182
170442
  var import_neverthrow120 = __toESM(require_index_cjs(), 1);
170443
+ var import_neverthrow121 = __toESM(require_index_cjs(), 1);
170183
170444
  var __defProp2 = Object.defineProperty;
170184
170445
  var __export2 = (target, all) => {
170185
170446
  for (var name in all)
@@ -170205,9 +170466,9 @@ function isValidAnchorId(id) {
170205
170466
  }
170206
170467
  function buildAnchor(input) {
170207
170468
  if (!isValidAnchorId(input.id)) {
170208
- return (0, import_neverthrow108.err)({ type: "INVALID_ANCHOR_ID", id: input.id });
170469
+ return (0, import_neverthrow109.err)({ type: "INVALID_ANCHOR_ID", id: input.id });
170209
170470
  }
170210
- return (0, import_neverthrow108.ok)({
170471
+ return (0, import_neverthrow109.ok)({
170211
170472
  start: `<!-- xqa:${input.kind}:${input.id}:start -->`,
170212
170473
  end: `<!-- xqa:${input.kind}:${input.id}:end -->`
170213
170474
  });
@@ -170256,7 +170517,7 @@ function suiteLabel(items) {
170256
170517
  }
170257
170518
  var MS_PER_SECOND7 = 1e3;
170258
170519
  function totalDurationSeconds(items) {
170259
- const ms = items.reduce((sum, item) => sum + item.durationMs, 0);
170520
+ const ms = items.reduce((sum2, item) => sum2 + item.durationMs, 0);
170260
170521
  return Math.round(ms / MS_PER_SECOND7);
170261
170522
  }
170262
170523
  function metaLine(input) {
@@ -170270,7 +170531,7 @@ function buildCleanSuiteBody(input) {
170270
170531
  const markdown = `${header2}
170271
170532
 
170272
170533
  ${metaLine(input)}`;
170273
- return (0, import_neverthrow109.ok)({ markdown, truncated: [] });
170534
+ return (0, import_neverthrow110.ok)({ markdown, truncated: [] });
170274
170535
  }
170275
170536
  var THUMBNAIL_WIDTH_PX = 180;
170276
170537
  var HTTPS_PREFIX = "https://";
@@ -170321,10 +170582,10 @@ function passCount(items) {
170321
170582
  return items.filter((item) => item.status === "completed" && item.findings.length === 0).length;
170322
170583
  }
170323
170584
  function findingsTotal(items) {
170324
- return items.reduce((sum, item) => sum + item.findings.length, 0);
170585
+ return items.reduce((sum2, item) => sum2 + item.findings.length, 0);
170325
170586
  }
170326
170587
  function totalDurationSeconds2(items) {
170327
- return Math.round(items.reduce((sum, item) => sum + item.durationMs, 0) / MS_PER_SECOND24);
170588
+ return Math.round(items.reduce((sum2, item) => sum2 + item.durationMs, 0) / MS_PER_SECOND24);
170328
170589
  }
170329
170590
  function itemNeedsBody(item) {
170330
170591
  if (item.status !== "completed") {
@@ -170475,7 +170736,7 @@ function buildSuiteBodyWithOverflow(input) {
170475
170736
  const initialRendered = new Map(initialEntries);
170476
170737
  const initialParts = partsFor({ headerString, blocks, renderedById: initialRendered });
170477
170738
  if (totalSize(initialParts) <= input.maxBodyBytes) {
170478
- return (0, import_neverthrow110.ok)({ markdown: initialParts.join("\n\n"), truncated: [] });
170739
+ return (0, import_neverthrow111.ok)({ markdown: initialParts.join("\n\n"), truncated: [] });
170479
170740
  }
170480
170741
  const final = findFittingState({
170481
170742
  headerString,
@@ -170487,9 +170748,9 @@ function buildSuiteBodyWithOverflow(input) {
170487
170748
  const finalParts = partsFor({ headerString, blocks, renderedById: final.renderedById });
170488
170749
  const finalSize = totalSize(finalParts);
170489
170750
  if (finalSize > input.maxBodyBytes) {
170490
- return (0, import_neverthrow110.err)({ type: "BODY_TOO_LARGE", size: finalSize, max: input.maxBodyBytes });
170751
+ return (0, import_neverthrow111.err)({ type: "BODY_TOO_LARGE", size: finalSize, max: input.maxBodyBytes });
170491
170752
  }
170492
- return (0, import_neverthrow110.ok)({ markdown: finalParts.join("\n\n"), truncated: final.truncated });
170753
+ return (0, import_neverthrow111.ok)({ markdown: finalParts.join("\n\n"), truncated: final.truncated });
170493
170754
  }
170494
170755
  function isCleanSuite(suite) {
170495
170756
  return suite.items.every(
@@ -170683,7 +170944,7 @@ function listComments(reference) {
170683
170944
  issue_number: reference.context.prNumber,
170684
170945
  per_page: PAGE_SIZE
170685
170946
  });
170686
- return import_neverthrow111.ResultAsync.fromPromise(
170947
+ return import_neverthrow112.ResultAsync.fromPromise(
170687
170948
  promise2,
170688
170949
  makeRedactedErrorFactory("COMMENT_FETCH_FAILED", reference.context.token)
170689
170950
  );
@@ -170695,7 +170956,7 @@ function createComment(payload) {
170695
170956
  issue_number: payload.reference.context.prNumber,
170696
170957
  body: payload.body
170697
170958
  });
170698
- return import_neverthrow111.ResultAsync.fromPromise(
170959
+ return import_neverthrow112.ResultAsync.fromPromise(
170699
170960
  promise2,
170700
170961
  makeRedactedErrorFactory("COMMENT_WRITE_FAILED", payload.reference.context.token)
170701
170962
  ).map(({ data }) => ({ commentUrl: data.html_url }));
@@ -170707,7 +170968,7 @@ function updateComment(payload) {
170707
170968
  comment_id: payload.commentId,
170708
170969
  body: payload.body
170709
170970
  });
170710
- return import_neverthrow111.ResultAsync.fromPromise(
170971
+ return import_neverthrow112.ResultAsync.fromPromise(
170711
170972
  promise2,
170712
170973
  makeRedactedErrorFactory("COMMENT_WRITE_FAILED", payload.reference.context.token)
170713
170974
  ).map(({ data }) => ({ commentUrl: data.html_url }));
@@ -170731,7 +170992,7 @@ function patchExistingAfterRace(reference, firstError) {
170731
170992
  return listComments(commentReference).andThen((retryComments) => {
170732
170993
  const after = findExistingXqaComment(retryComments);
170733
170994
  if (after === void 0) {
170734
- return (0, import_neverthrow111.errAsync)(firstError);
170995
+ return (0, import_neverthrow112.errAsync)(firstError);
170735
170996
  }
170736
170997
  const body = mergeIntoExisting({
170737
170998
  existing: after,
@@ -170764,7 +171025,7 @@ function createWithRaceRetry(reference) {
170764
171025
  const body = buildNewBody(reference.anchor, reference.blockBody);
170765
171026
  return createComment({ reference: toCommentReference(reference), body }).orElse((firstError) => {
170766
171027
  if (!isDuplicateCommentError(firstError)) {
170767
- return (0, import_neverthrow111.errAsync)(firstError);
171028
+ return (0, import_neverthrow112.errAsync)(firstError);
170768
171029
  }
170769
171030
  return patchExistingAfterRace(reference, firstError);
170770
171031
  });
@@ -170815,7 +171076,7 @@ var rootSchema = external_exports2.object({
170815
171076
  async function readUtf8(filePath) {
170816
171077
  return import_node_fs16.promises.readFile(filePath, "utf8");
170817
171078
  }
170818
- var safeRead = import_neverthrow112.ResultAsync.fromThrowable(readUtf8, () => void 0);
171079
+ var safeRead = import_neverthrow113.ResultAsync.fromThrowable(readUtf8, () => void 0);
170819
171080
  function parseYaml(raw) {
170820
171081
  return jsYaml.load(raw) ?? {};
170821
171082
  }
@@ -170837,12 +171098,12 @@ function toResolved(parsed) {
170837
171098
  function validate(data) {
170838
171099
  const parsed = rootSchema.safeParse(data);
170839
171100
  if (parsed.success) {
170840
- return (0, import_neverthrow112.okAsync)(toResolved(parsed.data.report.github));
171101
+ return (0, import_neverthrow113.okAsync)(toResolved(parsed.data.report.github));
170841
171102
  }
170842
- return (0, import_neverthrow112.errAsync)({ type: "CONFIG_LOAD_FAILED", cause: parsed.error });
171103
+ return (0, import_neverthrow113.errAsync)({ type: "CONFIG_LOAD_FAILED", cause: parsed.error });
170843
171104
  }
170844
171105
  function loadReportConfig(options) {
170845
- return safeRead(options.configPath).map((raw) => parseYaml(raw)).orElse(() => (0, import_neverthrow112.okAsync)({})).andThen((data) => validate(data));
171106
+ return safeRead(options.configPath).map((raw) => parseYaml(raw)).orElse(() => (0, import_neverthrow113.okAsync)({})).andThen((data) => validate(data));
170846
171107
  }
170847
171108
  var defaultDependencies2 = {
170848
171109
  putArtifact
@@ -170856,9 +171117,9 @@ async function statIsDirectory(directory) {
170856
171117
  const stat6 = await import_node_fs17.promises.stat(directory);
170857
171118
  return stat6.isDirectory();
170858
171119
  }
170859
- var safeStatIsDirectory = (0, import_neverthrow113.fromAsyncThrowable)(statIsDirectory, () => void 0);
171120
+ var safeStatIsDirectory = (0, import_neverthrow114.fromAsyncThrowable)(statIsDirectory, () => void 0);
170860
171121
  function statDirectory(directory) {
170861
- return safeStatIsDirectory(directory).orElse(() => (0, import_neverthrow113.okAsync)(false));
171122
+ return safeStatIsDirectory(directory).orElse(() => (0, import_neverthrow114.okAsync)(false));
170862
171123
  }
170863
171124
  function shouldSkipItem(item) {
170864
171125
  if (item.findings.length === 0) {
@@ -170902,7 +171163,7 @@ function selectReferencedFiles(arguments_) {
170902
171163
  return [...arguments_.files].filter((name) => referenced.has(name)).toSorted().map((name) => import_node_path42.default.join(arguments_.screenshotsDirectory, name));
170903
171164
  }
170904
171165
  function gatherFiles(arguments_) {
170905
- const safeReadDirectory2 = (0, import_neverthrow113.fromAsyncThrowable)(
171166
+ const safeReadDirectory2 = (0, import_neverthrow114.fromAsyncThrowable)(
170906
171167
  readDirectoryEntries,
170907
171168
  toReadError(arguments_.itemId)
170908
171169
  );
@@ -170922,7 +171183,7 @@ function toUploadError2(error48) {
170922
171183
  return { type: "SCREENSHOT_UPLOAD_FAILED", reason: "BLOB_FAILURE", cause: error48.type };
170923
171184
  }
170924
171185
  function uploadFile(deps, arguments_) {
170925
- const safeRead3 = (0, import_neverthrow113.fromAsyncThrowable)(readBinary, toReadError(arguments_.itemId));
171186
+ const safeRead3 = (0, import_neverthrow114.fromAsyncThrowable)(readBinary, toReadError(arguments_.itemId));
170926
171187
  return safeRead3(arguments_.filePath).andThen(
170927
171188
  (content) => deps.putArtifact({
170928
171189
  key: buildKey(arguments_),
@@ -170941,12 +171202,12 @@ function uploadFiles(deps, arguments_) {
170941
171202
  filePath
170942
171203
  }).map((result) => result.url)
170943
171204
  );
170944
- return import_neverthrow113.ResultAsync.combine(tasks);
171205
+ return import_neverthrow114.ResultAsync.combine(tasks);
170945
171206
  }
170946
171207
  function uploadItemFiles(deps, arguments_) {
170947
171208
  const runId = deriveRunId(arguments_.item.findingsPath);
170948
171209
  if (!PATH_COMPONENT_REGEX.test(runId)) {
170949
- return (0, import_neverthrow113.errAsync)({ type: "SCREENSHOT_INVALID_PATH", component: "runId", value: runId });
171210
+ return (0, import_neverthrow114.errAsync)({ type: "SCREENSHOT_INVALID_PATH", component: "runId", value: runId });
170950
171211
  }
170951
171212
  return gatherFiles({
170952
171213
  itemId: arguments_.item.id,
@@ -170961,7 +171222,7 @@ function uploadValidatedItem(deps, arguments_) {
170961
171222
  return statDirectory(screenshotsDirectory).andThen(
170962
171223
  (exists) => {
170963
171224
  if (!exists) {
170964
- return (0, import_neverthrow113.errAsync)({
171225
+ return (0, import_neverthrow114.errAsync)({
170965
171226
  type: "SCREENSHOT_DIR_NOT_FOUND",
170966
171227
  itemId: arguments_.item.id,
170967
171228
  expected: screenshotsDirectory
@@ -170977,11 +171238,11 @@ function uploadValidatedItem(deps, arguments_) {
170977
171238
  }
170978
171239
  function processItem(deps, arguments_) {
170979
171240
  if (shouldSkipItem(arguments_.item)) {
170980
- return (0, import_neverthrow113.okAsync)({ id: arguments_.item.id, urls: [] });
171241
+ return (0, import_neverthrow114.okAsync)({ id: arguments_.item.id, urls: [] });
170981
171242
  }
170982
171243
  const validationError = validatePathInputs(arguments_);
170983
171244
  if (validationError !== void 0) {
170984
- return (0, import_neverthrow113.errAsync)(validationError);
171245
+ return (0, import_neverthrow114.errAsync)(validationError);
170985
171246
  }
170986
171247
  return uploadValidatedItem(deps, arguments_);
170987
171248
  }
@@ -170993,10 +171254,10 @@ function emptyUrlMap(items) {
170993
171254
  }
170994
171255
  function uploadScreenshots(input, dependencies = defaultDependencies2) {
170995
171256
  if (input.blobToken.length === 0) {
170996
- return (0, import_neverthrow113.okAsync)(emptyUrlMap(input.items));
171257
+ return (0, import_neverthrow114.okAsync)(emptyUrlMap(input.items));
170997
171258
  }
170998
171259
  const tasks = input.items.map((item) => processItem(dependencies, { input, item }));
170999
- return import_neverthrow113.ResultAsync.combine(tasks).map((entries) => combineEntries(entries));
171260
+ return import_neverthrow114.ResultAsync.combine(tasks).map((entries) => combineEntries(entries));
171000
171261
  }
171001
171262
  var DEFAULT_CONFIG_PATH = ".xqa/config.yaml";
171002
171263
  var KIND_HANDLERS = {
@@ -171081,13 +171342,13 @@ async function readEventFile(eventPath) {
171081
171342
  const number_ = data.pull_request?.number;
171082
171343
  return typeof number_ === "number" ? number_ : void 0;
171083
171344
  }
171084
- var safeReadEventFile = (0, import_neverthrow114.fromAsyncThrowable)(readEventFile, () => void 0);
171345
+ var safeReadEventFile = (0, import_neverthrow115.fromAsyncThrowable)(readEventFile, () => void 0);
171085
171346
  function fromEventPath() {
171086
171347
  const eventPath = getGithubEventPathEnv();
171087
171348
  if (eventPath === void 0) {
171088
- return (0, import_neverthrow114.okAsync)(NO_PR);
171349
+ return (0, import_neverthrow115.okAsync)(NO_PR);
171089
171350
  }
171090
- return safeReadEventFile(eventPath).orElse(() => (0, import_neverthrow114.okAsync)(NO_PR));
171351
+ return safeReadEventFile(eventPath).orElse(() => (0, import_neverthrow115.okAsync)(NO_PR));
171091
171352
  }
171092
171353
  function fromReference() {
171093
171354
  const reference = getGithubReferenceEnv();
@@ -171111,12 +171372,12 @@ function filterCandidates(prs, context) {
171111
171372
  }
171112
171373
  function resolveFiltered(filtered) {
171113
171374
  if (filtered.length === 0) {
171114
- return (0, import_neverthrow114.okAsync)(NO_PR);
171375
+ return (0, import_neverthrow115.okAsync)(NO_PR);
171115
171376
  }
171116
171377
  if (filtered.length === 1) {
171117
- return (0, import_neverthrow114.okAsync)(filtered[0]?.number);
171378
+ return (0, import_neverthrow115.okAsync)(filtered[0]?.number);
171118
171379
  }
171119
- return (0, import_neverthrow114.errAsync)({
171380
+ return (0, import_neverthrow115.errAsync)({
171120
171381
  type: "PR_AMBIGUOUS",
171121
171382
  candidates: filtered.map((candidate) => candidate.number)
171122
171383
  });
@@ -171130,7 +171391,7 @@ async function fetchAssociatedPrs(input, sha) {
171130
171391
  });
171131
171392
  return response.data;
171132
171393
  }
171133
- var safeFetchAssociatedPrs = (0, import_neverthrow114.fromAsyncThrowable)(fetchAssociatedPrs, (cause) => cause);
171394
+ var safeFetchAssociatedPrs = (0, import_neverthrow115.fromAsyncThrowable)(fetchAssociatedPrs, (cause) => cause);
171134
171395
  function toFetchPrError(token) {
171135
171396
  return (cause) => {
171136
171397
  const safeCause = cause instanceof Error ? redactToken(cause, token) : void 0;
@@ -171144,7 +171405,7 @@ function fromAssocList(input) {
171144
171405
  const sha = getGithubShaEnv2();
171145
171406
  const repoFull = getGithubRepositoryEnv2();
171146
171407
  if (sha === void 0 || repoFull === void 0) {
171147
- return (0, import_neverthrow114.okAsync)(NO_PR);
171408
+ return (0, import_neverthrow115.okAsync)(NO_PR);
171148
171409
  }
171149
171410
  return safeFetchAssociatedPrs(input, sha).mapErr(toFetchPrError(input.token)).andThen(
171150
171411
  (prs) => resolveFiltered(filterCandidates(prs, { expectedSha: sha, expectedRepo: repoFull }))
@@ -171176,7 +171437,7 @@ function toGhPrViewError(token) {
171176
171437
  return { type: "PR_NOT_RESOLVED", reason: "CANNOT_INFER", cause: safeCause };
171177
171438
  };
171178
171439
  }
171179
- var safeReadGhPrView = (0, import_neverthrow114.fromAsyncThrowable)(readGhPrView, (cause) => cause);
171440
+ var safeReadGhPrView = (0, import_neverthrow115.fromAsyncThrowable)(readGhPrView, (cause) => cause);
171180
171441
  function parseGhPrView(stdout) {
171181
171442
  const data = JSON.parse(stdout);
171182
171443
  return typeof data.number === "number" ? data.number : void 0;
@@ -171186,13 +171447,13 @@ function fromGhPrView(token) {
171186
171447
  }
171187
171448
  function finalizeResolution(maybe, token) {
171188
171449
  if (maybe !== void 0) {
171189
- return (0, import_neverthrow114.okAsync)(maybe);
171450
+ return (0, import_neverthrow115.okAsync)(maybe);
171190
171451
  }
171191
171452
  return fromGhPrView(token).andThen((ghResult) => {
171192
171453
  if (ghResult !== void 0) {
171193
- return (0, import_neverthrow114.okAsync)(ghResult);
171454
+ return (0, import_neverthrow115.okAsync)(ghResult);
171194
171455
  }
171195
- return (0, import_neverthrow114.errAsync)({
171456
+ return (0, import_neverthrow115.errAsync)({
171196
171457
  type: "PR_NOT_RESOLVED",
171197
171458
  reason: "NO_SOURCE"
171198
171459
  });
@@ -171201,18 +171462,18 @@ function finalizeResolution(maybe, token) {
171201
171462
  function resolveFromEnv(input) {
171202
171463
  return fromEventPath().andThen((eventPr) => {
171203
171464
  if (eventPr !== void 0) {
171204
- return (0, import_neverthrow114.okAsync)(eventPr);
171465
+ return (0, import_neverthrow115.okAsync)(eventPr);
171205
171466
  }
171206
171467
  const referencePr = fromReference();
171207
171468
  if (referencePr !== void 0) {
171208
- return (0, import_neverthrow114.okAsync)(referencePr);
171469
+ return (0, import_neverthrow115.okAsync)(referencePr);
171209
171470
  }
171210
171471
  return fromAssocList(input);
171211
171472
  });
171212
171473
  }
171213
171474
  function resolvePr(input) {
171214
171475
  if (input.explicitPr !== void 0) {
171215
- return (0, import_neverthrow114.okAsync)(input.explicitPr);
171476
+ return (0, import_neverthrow115.okAsync)(input.explicitPr);
171216
171477
  }
171217
171478
  return resolveFromEnv(input).andThen((maybe) => finalizeResolution(maybe, input.token));
171218
171479
  }
@@ -171254,24 +171515,24 @@ async function readGitRemote() {
171254
171515
  });
171255
171516
  return promise2;
171256
171517
  }
171257
- var safeReadGitRemote = (0, import_neverthrow115.fromAsyncThrowable)(
171518
+ var safeReadGitRemote = (0, import_neverthrow116.fromAsyncThrowable)(
171258
171519
  readGitRemote,
171259
171520
  () => ({ type: "REPO_NOT_RESOLVED" })
171260
171521
  );
171261
171522
  function resolveRepo(input) {
171262
171523
  if (input.owner !== void 0 && input.repo !== void 0) {
171263
- return (0, import_neverthrow115.okAsync)({ owner: input.owner, repo: input.repo });
171524
+ return (0, import_neverthrow116.okAsync)({ owner: input.owner, repo: input.repo });
171264
171525
  }
171265
171526
  const env3 = fromEnv();
171266
171527
  if (env3 !== void 0) {
171267
- return (0, import_neverthrow115.okAsync)(env3);
171528
+ return (0, import_neverthrow116.okAsync)(env3);
171268
171529
  }
171269
171530
  return safeReadGitRemote().andThen((stdout) => {
171270
171531
  const parsed = parseRemote(stdout);
171271
171532
  if (parsed === void 0) {
171272
- return (0, import_neverthrow115.errAsync)({ type: "REPO_NOT_RESOLVED" });
171533
+ return (0, import_neverthrow116.errAsync)({ type: "REPO_NOT_RESOLVED" });
171273
171534
  }
171274
- return (0, import_neverthrow115.okAsync)(parsed);
171535
+ return (0, import_neverthrow116.okAsync)(parsed);
171275
171536
  });
171276
171537
  }
171277
171538
  var TRAILING_WHITESPACE_REGEX = /\s+$/;
@@ -171282,7 +171543,7 @@ function trimTrailing(value) {
171282
171543
  async function readTokenFile(filePath) {
171283
171544
  return import_node_fs19.promises.readFile(filePath, "utf8");
171284
171545
  }
171285
- var safeReadTokenFile = (0, import_neverthrow116.fromAsyncThrowable)(
171546
+ var safeReadTokenFile = (0, import_neverthrow117.fromAsyncThrowable)(
171286
171547
  readTokenFile,
171287
171548
  () => ({ type: "TOKEN_NOT_RESOLVED" })
171288
171549
  );
@@ -171297,7 +171558,7 @@ async function readGhAuthToken() {
171297
171558
  });
171298
171559
  return promise2;
171299
171560
  }
171300
- var safeReadGhAuthToken = (0, import_neverthrow116.fromAsyncThrowable)(
171561
+ var safeReadGhAuthToken = (0, import_neverthrow117.fromAsyncThrowable)(
171301
171562
  readGhAuthToken,
171302
171563
  () => ({ type: "TOKEN_NOT_RESOLVED" })
171303
171564
  );
@@ -171312,11 +171573,11 @@ function resolveToken(input) {
171312
171573
  }
171313
171574
  if (input.token !== void 0) {
171314
171575
  emitDeprecation(input.onWarn);
171315
- return (0, import_neverthrow116.okAsync)(trimTrailing(input.token));
171576
+ return (0, import_neverthrow117.okAsync)(trimTrailing(input.token));
171316
171577
  }
171317
171578
  const env3 = getGithubTokenEnv();
171318
171579
  if (env3 !== void 0 && env3.length > 0) {
171319
- return (0, import_neverthrow116.okAsync)(env3);
171580
+ return (0, import_neverthrow117.okAsync)(env3);
171320
171581
  }
171321
171582
  return safeReadGhAuthToken().map((value) => trimTrailing(value));
171322
171583
  }
@@ -171341,14 +171602,14 @@ function listCurrentLabels(reference) {
171341
171602
  issue_number: reference.issueNumber,
171342
171603
  per_page: PAGE_SIZE2
171343
171604
  });
171344
- return import_neverthrow117.ResultAsync.fromPromise(
171605
+ return import_neverthrow118.ResultAsync.fromPromise(
171345
171606
  promise2,
171346
171607
  makeRedactedErrorFactory("LABEL_APPLY_FAILED", reference.token)
171347
171608
  ).map((labels) => labels.map((label) => label.name));
171348
171609
  }
171349
171610
  function addLabels(reference, labels) {
171350
171611
  if (labels.length === 0) {
171351
- return (0, import_neverthrow117.okAsync)();
171612
+ return (0, import_neverthrow118.okAsync)();
171352
171613
  }
171353
171614
  const promise2 = reference.client.rest.issues.addLabels({
171354
171615
  owner: reference.owner,
@@ -171356,7 +171617,7 @@ function addLabels(reference, labels) {
171356
171617
  issue_number: reference.issueNumber,
171357
171618
  labels: [...labels]
171358
171619
  });
171359
- return import_neverthrow117.ResultAsync.fromPromise(
171620
+ return import_neverthrow118.ResultAsync.fromPromise(
171360
171621
  promise2,
171361
171622
  makeRedactedErrorFactory("LABEL_APPLY_FAILED", reference.token)
171362
171623
  );
@@ -171368,17 +171629,17 @@ function removeOne(reference, name) {
171368
171629
  issue_number: reference.issueNumber,
171369
171630
  name
171370
171631
  });
171371
- return import_neverthrow117.ResultAsync.fromPromise(
171632
+ return import_neverthrow118.ResultAsync.fromPromise(
171372
171633
  promise2,
171373
171634
  makeRedactedErrorFactory("LABEL_APPLY_FAILED", reference.token)
171374
171635
  );
171375
171636
  }
171376
171637
  function removeLabels(reference, labels) {
171377
171638
  if (labels.length === 0) {
171378
- return (0, import_neverthrow117.okAsync)([]);
171639
+ return (0, import_neverthrow118.okAsync)([]);
171379
171640
  }
171380
171641
  const removals = labels.map((name) => removeOne(reference, name));
171381
- return import_neverthrow117.ResultAsync.combine(removals);
171642
+ return import_neverthrow118.ResultAsync.combine(removals);
171382
171643
  }
171383
171644
  function computeDiff(input, current) {
171384
171645
  if (input.removeStale === true) {
@@ -171416,29 +171677,29 @@ function looksLikePipeline(record2) {
171416
171677
  }
171417
171678
  function fromOverride(kindOverride) {
171418
171679
  if (kindOverride === "suite") {
171419
- return (0, import_neverthrow119.ok)(kindOverride);
171680
+ return (0, import_neverthrow120.ok)(kindOverride);
171420
171681
  }
171421
- return (0, import_neverthrow119.err)({ type: "KIND_NOT_IMPLEMENTED", kind: kindOverride });
171682
+ return (0, import_neverthrow120.err)({ type: "KIND_NOT_IMPLEMENTED", kind: kindOverride });
171422
171683
  }
171423
171684
  function fromExplicitField(explicit) {
171424
171685
  if (explicit === "suite") {
171425
- return (0, import_neverthrow119.ok)(explicit);
171686
+ return (0, import_neverthrow120.ok)(explicit);
171426
171687
  }
171427
- return (0, import_neverthrow119.err)({ type: "KIND_NOT_IMPLEMENTED", kind: explicit });
171688
+ return (0, import_neverthrow120.err)({ type: "KIND_NOT_IMPLEMENTED", kind: explicit });
171428
171689
  }
171429
171690
  function fromStructure(record2, path310) {
171430
171691
  const isSuite = looksLikeSuite(record2);
171431
171692
  const isPipeline = looksLikePipeline(record2);
171432
171693
  if (isSuite && isPipeline) {
171433
- return (0, import_neverthrow119.err)({ type: "INPUT_INVALID", path: path310, cause: "ambiguous shape" });
171694
+ return (0, import_neverthrow120.err)({ type: "INPUT_INVALID", path: path310, cause: "ambiguous shape" });
171434
171695
  }
171435
171696
  if (isSuite) {
171436
- return (0, import_neverthrow119.ok)("suite");
171697
+ return (0, import_neverthrow120.ok)("suite");
171437
171698
  }
171438
171699
  if (isPipeline) {
171439
- return (0, import_neverthrow119.err)({ type: "KIND_NOT_IMPLEMENTED", kind: "pipeline" });
171700
+ return (0, import_neverthrow120.err)({ type: "KIND_NOT_IMPLEMENTED", kind: "pipeline" });
171440
171701
  }
171441
- return (0, import_neverthrow119.err)({ type: "INPUT_INVALID", path: path310, cause: "unknown shape" });
171702
+ return (0, import_neverthrow120.err)({ type: "INPUT_INVALID", path: path310, cause: "unknown shape" });
171442
171703
  }
171443
171704
  function sniffKind(input) {
171444
171705
  const path310 = input.path ?? FALLBACK_PATH;
@@ -171446,7 +171707,7 @@ function sniffKind(input) {
171446
171707
  return fromOverride(input.kindOverride);
171447
171708
  }
171448
171709
  if (!isRecord(input.data)) {
171449
- return (0, import_neverthrow119.err)({ type: "INPUT_INVALID", path: path310, cause: "not an object" });
171710
+ return (0, import_neverthrow120.err)({ type: "INPUT_INVALID", path: path310, cause: "not an object" });
171450
171711
  }
171451
171712
  const explicit = input.data.kind;
171452
171713
  if (typeof explicit === "string") {
@@ -171473,7 +171734,7 @@ function workspaceCheck(absolutePath) {
171473
171734
  async function lstatPath(filePath) {
171474
171735
  return import_node_fs20.promises.lstat(filePath);
171475
171736
  }
171476
- var safeLstat = import_neverthrow118.ResultAsync.fromThrowable(
171737
+ var safeLstat = import_neverthrow119.ResultAsync.fromThrowable(
171477
171738
  lstatPath,
171478
171739
  (cause) => ({
171479
171740
  type: "INPUT_READ_FAILED",
@@ -171484,7 +171745,7 @@ var safeLstat = import_neverthrow118.ResultAsync.fromThrowable(
171484
171745
  async function readUtf82(filePath) {
171485
171746
  return import_node_fs20.promises.readFile(filePath, "utf8");
171486
171747
  }
171487
- var safeRead2 = import_neverthrow118.ResultAsync.fromThrowable(
171748
+ var safeRead2 = import_neverthrow119.ResultAsync.fromThrowable(
171488
171749
  readUtf82,
171489
171750
  (cause) => ({
171490
171751
  type: "INPUT_READ_FAILED",
@@ -171492,7 +171753,7 @@ var safeRead2 = import_neverthrow118.ResultAsync.fromThrowable(
171492
171753
  cause
171493
171754
  })
171494
171755
  );
171495
- var safeJsonParse8 = (0, import_neverthrow118.fromThrowable)(
171756
+ var safeJsonParse8 = (0, import_neverthrow119.fromThrowable)(
171496
171757
  (raw) => JSON.parse(raw),
171497
171758
  (cause) => ({
171498
171759
  type: "INPUT_INVALID",
@@ -171508,21 +171769,21 @@ function fixPath(error48, absolutePath) {
171508
171769
  }
171509
171770
  function checkStat(stat6, absolutePath) {
171510
171771
  if (stat6.isSymbolicLink()) {
171511
- return (0, import_neverthrow118.err)({
171772
+ return (0, import_neverthrow119.err)({
171512
171773
  type: "INPUT_READ_FAILED",
171513
171774
  path: absolutePath,
171514
171775
  cause: "symlink not allowed"
171515
171776
  });
171516
171777
  }
171517
171778
  if (stat6.size > INPUT_MAX_BYTES) {
171518
- return (0, import_neverthrow118.err)({
171779
+ return (0, import_neverthrow119.err)({
171519
171780
  type: "INPUT_TOO_LARGE",
171520
171781
  path: absolutePath,
171521
171782
  size: stat6.size,
171522
171783
  max: INPUT_MAX_BYTES
171523
171784
  });
171524
171785
  }
171525
- return (0, import_neverthrow118.ok)(stat6);
171786
+ return (0, import_neverthrow119.ok)(stat6);
171526
171787
  }
171527
171788
  function buildSniffInput(arguments_) {
171528
171789
  if (arguments_.kindOverride === void 0) {
@@ -171551,15 +171812,15 @@ function buildArguments(input) {
171551
171812
  }
171552
171813
  function liftBuilt(built) {
171553
171814
  if (built.isErr()) {
171554
- return (0, import_neverthrow118.errAsync)(built.error);
171815
+ return (0, import_neverthrow119.errAsync)(built.error);
171555
171816
  }
171556
- return (0, import_neverthrow118.okAsync)(built.value);
171817
+ return (0, import_neverthrow119.okAsync)(built.value);
171557
171818
  }
171558
171819
  function readReportInput(options) {
171559
171820
  const absolutePath = import_node_path43.default.resolve(options.path);
171560
171821
  const workspaceError = workspaceCheck(absolutePath);
171561
171822
  if (workspaceError !== void 0) {
171562
- return (0, import_neverthrow118.errAsync)(workspaceError);
171823
+ return (0, import_neverthrow119.errAsync)(workspaceError);
171563
171824
  }
171564
171825
  return safeLstat(absolutePath).mapErr((error48) => fixPath(error48, absolutePath)).andThen((stat6) => checkStat(stat6, absolutePath)).andThen(() => safeRead2(absolutePath).mapErr((error48) => fixPath(error48, absolutePath))).andThen(
171565
171826
  (raw) => liftBuilt(
@@ -171579,12 +171840,12 @@ function fetchLabel(reference) {
171579
171840
  name: reference.name
171580
171841
  });
171581
171842
  const toError = makeRedactedErrorFactory("LABEL_SYNC_FAILED", reference.token);
171582
- return import_neverthrow120.ResultAsync.fromPromise(promise2, (cause) => {
171843
+ return import_neverthrow121.ResultAsync.fromPromise(promise2, (cause) => {
171583
171844
  if (isHttpStatus(cause, HTTP_NOT_FOUND)) {
171584
171845
  return "NOT_FOUND";
171585
171846
  }
171586
171847
  return toError(cause);
171587
- }).map((response) => ({ kind: "found", label: response.data })).orElse((error48) => error48 === "NOT_FOUND" ? (0, import_neverthrow120.okAsync)(MISSING_OUTCOME) : (0, import_neverthrow120.errAsync)(error48));
171848
+ }).map((response) => ({ kind: "found", label: response.data })).orElse((error48) => error48 === "NOT_FOUND" ? (0, import_neverthrow121.okAsync)(MISSING_OUTCOME) : (0, import_neverthrow121.errAsync)(error48));
171588
171849
  }
171589
171850
  function isMatching(existing, spec) {
171590
171851
  const descriptionMatches = (existing.description ?? "") === (spec.description ?? "");
@@ -171604,7 +171865,7 @@ function createLabel(reference) {
171604
171865
  repo: reference.repo,
171605
171866
  ...payload
171606
171867
  });
171607
- return import_neverthrow120.ResultAsync.fromPromise(
171868
+ return import_neverthrow121.ResultAsync.fromPromise(
171608
171869
  promise2,
171609
171870
  makeRedactedErrorFactory("LABEL_SYNC_FAILED", reference.token)
171610
171871
  ).map(() => "created");
@@ -171619,14 +171880,14 @@ function updateLabel(reference) {
171619
171880
  color: payload.color,
171620
171881
  ...payload.description === void 0 ? {} : { description: payload.description }
171621
171882
  });
171622
- return import_neverthrow120.ResultAsync.fromPromise(
171883
+ return import_neverthrow121.ResultAsync.fromPromise(
171623
171884
  promise2,
171624
171885
  makeRedactedErrorFactory("LABEL_SYNC_FAILED", reference.token)
171625
171886
  ).map(() => "updated");
171626
171887
  }
171627
171888
  function reconcileExisting(reference, existing) {
171628
171889
  if (isMatching(existing, reference.spec)) {
171629
- return (0, import_neverthrow120.okAsync)("unchanged");
171890
+ return (0, import_neverthrow121.okAsync)("unchanged");
171630
171891
  }
171631
171892
  return updateLabel(reference);
171632
171893
  }
@@ -171672,7 +171933,7 @@ function syncLabelSet(input) {
171672
171933
  (outcome) => [spec.name, outcome]
171673
171934
  )
171674
171935
  );
171675
- return import_neverthrow120.ResultAsync.combine(reconciliations).map((entries) => classifyOutcomes(entries));
171936
+ return import_neverthrow121.ResultAsync.combine(reconciliations).map((entries) => classifyOutcomes(entries));
171676
171937
  }
171677
171938
 
171678
171939
  // src/commands/error-exit-mapping.ts
@@ -171979,20 +172240,20 @@ async function runWithContext2(options) {
171979
172240
  }
171980
172241
 
171981
172242
  // src/shell/resolve-commit-sha.ts
171982
- var import_neverthrow121 = __toESM(require_index_cjs(), 1);
172243
+ var import_neverthrow122 = __toESM(require_index_cjs(), 1);
171983
172244
  function resolveCommitSha(input) {
171984
172245
  if (input.explicitSha !== void 0 && input.explicitSha.length > 0) {
171985
- return (0, import_neverthrow121.okAsync)(input.explicitSha);
172246
+ return (0, import_neverthrow122.okAsync)(input.explicitSha);
171986
172247
  }
171987
172248
  const env3 = getGithubShaEnv();
171988
172249
  if (env3 !== void 0 && env3.length > 0) {
171989
- return (0, import_neverthrow121.okAsync)(env3);
172250
+ return (0, import_neverthrow122.okAsync)(env3);
171990
172251
  }
171991
- return (0, import_neverthrow121.errAsync)({ type: "COMMIT_SHA_NOT_RESOLVED" });
172252
+ return (0, import_neverthrow122.errAsync)({ type: "COMMIT_SHA_NOT_RESOLVED" });
171992
172253
  }
171993
172254
 
171994
172255
  // src/shell/resolve-report-links.ts
171995
- var import_neverthrow122 = __toESM(require_index_cjs(), 1);
172256
+ var import_neverthrow123 = __toESM(require_index_cjs(), 1);
171996
172257
  var SHA_SHORT_LENGTH = 7;
171997
172258
  var SERVER_URL_PATTERN = /^https:\/\/[a-z0-9.-]+$/i;
171998
172259
  var REPOSITORY_PATTERN = /^[\w.-]+\/[\w.-]+$/;
@@ -172028,14 +172289,14 @@ function checkEnv() {
172028
172289
  reasons.push("NO_REPOSITORY");
172029
172290
  }
172030
172291
  if (!nonEmpty(runId) || !nonEmpty(serverUrl) || !nonEmpty(repository)) {
172031
- return (0, import_neverthrow122.err)(reasons);
172292
+ return (0, import_neverthrow123.err)(reasons);
172032
172293
  }
172033
172294
  const env3 = { runId, serverUrl, repository };
172034
172295
  const formatReasons = collectFormatReasons(env3);
172035
172296
  if (formatReasons.length > 0) {
172036
- return (0, import_neverthrow122.err)(formatReasons);
172297
+ return (0, import_neverthrow123.err)(formatReasons);
172037
172298
  }
172038
- return (0, import_neverthrow122.ok)(env3);
172299
+ return (0, import_neverthrow123.ok)(env3);
172039
172300
  }
172040
172301
  function buildLinks(env3, commitSha) {
172041
172302
  return {
@@ -172242,7 +172503,7 @@ function registerReportCommand(program3) {
172242
172503
  // src/commands/review-command.ts
172243
172504
  var import_node_fs21 = require("node:fs");
172244
172505
  var import_node_path45 = __toESM(require("node:path"), 1);
172245
- var import_neverthrow124 = __toESM(require_index_cjs(), 1);
172506
+ var import_neverthrow125 = __toESM(require_index_cjs(), 1);
172246
172507
 
172247
172508
  // ../../node_modules/.pnpm/@inquirer+core@10.3.2_@types+node@22.19.15/node_modules/@inquirer/core/dist/esm/lib/key.js
172248
172509
  var isUpKey = (key, keybindings = []) => (
@@ -173582,7 +173843,7 @@ var import_child_process3 = require("child_process");
173582
173843
  var import_fs3 = require("fs");
173583
173844
  var import_node_path44 = __toESM(require("node:path"), 1);
173584
173845
  var import_node_os4 = __toESM(require("node:os"), 1);
173585
- var import_node_crypto6 = require("node:crypto");
173846
+ var import_node_crypto7 = require("node:crypto");
173586
173847
  var import_iconv_lite = __toESM(require_lib4(), 1);
173587
173848
 
173588
173849
  // ../../node_modules/.pnpm/@inquirer+external-editor@1.0.3_@types+node@22.19.15/node_modules/@inquirer/external-editor/dist/esm/errors/CreateFileError.js
@@ -173712,7 +173973,7 @@ var ExternalEditor = class {
173712
173973
  createTemporaryFile() {
173713
173974
  try {
173714
173975
  const baseDir = this.fileOptions.dir ?? import_node_os4.default.tmpdir();
173715
- const id = (0, import_node_crypto6.randomUUID)();
173976
+ const id = (0, import_node_crypto7.randomUUID)();
173716
173977
  const prefix = sanitizeAffix(this.fileOptions.prefix);
173717
173978
  const postfix = sanitizeAffix(this.fileOptions.postfix);
173718
173979
  const filename = `${prefix}${id}${postfix}`;
@@ -174647,7 +174908,7 @@ var esm_default11 = createPrompt((config2, done) => {
174647
174908
  });
174648
174909
 
174649
174910
  // src/review-session.ts
174650
- var import_neverthrow123 = __toESM(require_index_cjs(), 1);
174911
+ var import_neverthrow124 = __toESM(require_index_cjs(), 1);
174651
174912
  var FLOW_COL_WIDTH = 35;
174652
174913
  var TRIGGER_COL_WIDTH = 16;
174653
174914
  var CONFIDENCE_COL_WIDTH = 6;
@@ -174800,15 +175061,15 @@ async function runInteractiveLoop(findings, existing) {
174800
175061
  }
174801
175062
  return { staged: state.staged, undoneKeys: state.undoneKeys };
174802
175063
  }
174803
- var safeRunInteractiveLoop = (0, import_neverthrow123.fromAsyncThrowable)(
175064
+ var safeRunInteractiveLoop = (0, import_neverthrow124.fromAsyncThrowable)(
174804
175065
  runInteractiveLoop,
174805
175066
  (error48) => error48 instanceof Error && error48.name === "ExitPromptError" ? "exit-prompt" : "unexpected"
174806
175067
  );
174807
175068
 
174808
175069
  // src/commands/review-command.ts
174809
- var safeReadFile5 = (0, import_neverthrow124.fromThrowable)((filePath) => (0, import_node_fs21.readFileSync)(filePath, "utf8"));
174810
- var safeParseJson4 = (0, import_neverthrow124.fromThrowable)(JSON.parse);
174811
- var safeWrite = (0, import_neverthrow124.fromThrowable)((filePath, content) => {
175070
+ var safeReadFile5 = (0, import_neverthrow125.fromThrowable)((filePath) => (0, import_node_fs21.readFileSync)(filePath, "utf8"));
175071
+ var safeParseJson4 = (0, import_neverthrow125.fromThrowable)(JSON.parse);
175072
+ var safeWrite = (0, import_neverthrow125.fromThrowable)((filePath, content) => {
174812
175073
  (0, import_node_fs21.writeFileSync)(filePath, content);
174813
175074
  });
174814
175075
  function readLastPath(xqaDirectory) {
@@ -174825,13 +175086,13 @@ function isPipelineOutput(data) {
174825
175086
  function readFindings(filePath) {
174826
175087
  const readResult = safeReadFile5(filePath);
174827
175088
  if (readResult.isErr()) {
174828
- return (0, import_neverthrow124.err)("not-found");
175089
+ return (0, import_neverthrow125.err)("not-found");
174829
175090
  }
174830
175091
  return safeParseJson4(readResult.value).mapErr(() => "invalid").andThen((data) => {
174831
175092
  if (!isPipelineOutput(data)) {
174832
- return (0, import_neverthrow124.err)("invalid");
175093
+ return (0, import_neverthrow125.err)("invalid");
174833
175094
  }
174834
- return (0, import_neverthrow124.ok)(data);
175095
+ return (0, import_neverthrow125.ok)(data);
174835
175096
  });
174836
175097
  }
174837
175098
  function loadExistingDismissals(filePath) {
@@ -174904,7 +175165,7 @@ function resolveAndReadFindings(findingsPath, xqaDirectory) {
174904
175165
  "No findings path provided and no last path found. Run: xqa review <findings-path>\n"
174905
175166
  );
174906
175167
  process.exit(1);
174907
- return (0, import_neverthrow124.err)();
175168
+ return (0, import_neverthrow125.err)();
174908
175169
  }
174909
175170
  const resolvedPath = resolvedPathResult.value;
174910
175171
  const findingsResult = readFindings(resolvedPath);
@@ -174917,9 +175178,9 @@ function resolveAndReadFindings(findingsPath, xqaDirectory) {
174917
175178
  `);
174918
175179
  }
174919
175180
  process.exit(1);
174920
- return (0, import_neverthrow124.err)();
175181
+ return (0, import_neverthrow125.err)();
174921
175182
  }
174922
- return (0, import_neverthrow124.ok)({ resolvedPath, output: findingsResult.value });
175183
+ return (0, import_neverthrow125.ok)({ resolvedPath, output: findingsResult.value });
174923
175184
  }
174924
175185
  async function runReviewLoop({
174925
175186
  findings,
@@ -174992,11 +175253,11 @@ function discoverSimulators(udidOverride) {
174992
175253
  var import_promises37 = __toESM(require("node:fs/promises"), 1);
174993
175254
  var import_node_path46 = __toESM(require("node:path"), 1);
174994
175255
  var import_fast_glob = __toESM(require_out4(), 1);
174995
- var import_neverthrow127 = __toESM(require_index_cjs(), 1);
175256
+ var import_neverthrow128 = __toESM(require_index_cjs(), 1);
174996
175257
 
174997
175258
  // src/suite/core/suite-config-parser.ts
174998
- var import_neverthrow125 = __toESM(require_index_cjs(), 1);
174999
175259
  var import_neverthrow126 = __toESM(require_index_cjs(), 1);
175260
+ var import_neverthrow127 = __toESM(require_index_cjs(), 1);
175000
175261
  var RESERVED_HOOK_ENV_KEYS = [
175001
175262
  "XQA_SIM_UDID",
175002
175263
  "XQA_ITEM_ID",
@@ -175050,7 +175311,7 @@ var suiteConfigSchema = external_exports.object({
175050
175311
  }).refine((data) => data.specs.length > 0 || data.freestyle.length > 0, {
175051
175312
  message: "Suite must declare at least one spec or freestyle entry"
175052
175313
  });
175053
- var safeJsonParse9 = (0, import_neverthrow125.fromThrowable)(
175314
+ var safeJsonParse9 = (0, import_neverthrow126.fromThrowable)(
175054
175315
  JSON.parse,
175055
175316
  (cause) => ({
175056
175317
  type: "INVALID_SUITE_CONFIG",
@@ -175086,16 +175347,16 @@ function parseSuiteConfig(raw) {
175086
175347
  return safeJsonParse9(raw).andThen((data) => {
175087
175348
  const parsed = suiteConfigSchema.safeParse(data);
175088
175349
  if (!parsed.success) {
175089
- return (0, import_neverthrow126.err)({ type: "INVALID_SUITE_CONFIG", cause: parsed.error });
175350
+ return (0, import_neverthrow127.err)({ type: "INVALID_SUITE_CONFIG", cause: parsed.error });
175090
175351
  }
175091
175352
  const hooks = normalizeHooks(parsed.data.hooks);
175092
175353
  if (hooks === void 0) {
175093
- return (0, import_neverthrow126.ok)({
175354
+ return (0, import_neverthrow127.ok)({
175094
175355
  specs: parsed.data.specs,
175095
175356
  freestyle: parsed.data.freestyle
175096
175357
  });
175097
175358
  }
175098
- return (0, import_neverthrow126.ok)({
175359
+ return (0, import_neverthrow127.ok)({
175099
175360
  specs: parsed.data.specs,
175100
175361
  freestyle: parsed.data.freestyle,
175101
175362
  hooks
@@ -175143,7 +175404,7 @@ function buildFreestyleItems(entries) {
175143
175404
  }
175144
175405
 
175145
175406
  // src/suite/commands/run/resolve-work-items.ts
175146
- var safeReadFile6 = import_neverthrow127.ResultAsync.fromThrowable(
175407
+ var safeReadFile6 = import_neverthrow128.ResultAsync.fromThrowable(
175147
175408
  async (filePath) => import_promises37.default.readFile(filePath, "utf8"),
175148
175409
  () => "READ_FAILED"
175149
175410
  );
@@ -175231,7 +175492,7 @@ async function resolveAndFilterItems(input) {
175231
175492
  }
175232
175493
 
175233
175494
  // src/suite/shell/worker-pool.ts
175234
- var import_neverthrow130 = __toESM(require_index_cjs(), 1);
175495
+ var import_neverthrow131 = __toESM(require_index_cjs(), 1);
175235
175496
 
175236
175497
  // src/suite/core/priority-queue.ts
175237
175498
  var PriorityQueue = class {
@@ -175478,7 +175739,7 @@ function recordHookFailure(input) {
175478
175739
  }
175479
175740
 
175480
175741
  // src/suite/shell/hook-invoker.ts
175481
- var import_neverthrow129 = __toESM(require_index_cjs(), 1);
175742
+ var import_neverthrow130 = __toESM(require_index_cjs(), 1);
175482
175743
 
175483
175744
  // src/suite/core/hook-env-builder.ts
175484
175745
  function buildReservedKeys(input) {
@@ -175505,7 +175766,7 @@ function buildHookEnv(input) {
175505
175766
 
175506
175767
  // src/suite/shell/hook-runner.ts
175507
175768
  var import_node_child_process16 = require("node:child_process");
175508
- var import_neverthrow128 = __toESM(require_index_cjs(), 1);
175769
+ var import_neverthrow129 = __toESM(require_index_cjs(), 1);
175509
175770
  function makeDeferred() {
175510
175771
  const raw = Promise.withResolvers();
175511
175772
  return { promise: raw.promise, resolve: raw.resolve };
@@ -175535,7 +175796,7 @@ var HookRuntime = class {
175535
175796
  this.deferred = makeDeferred();
175536
175797
  this.onAbort = () => {
175537
175798
  this.child.kill("SIGTERM");
175538
- this.settle((0, import_neverthrow128.err)({ type: "HOOK_ABORTED" }));
175799
+ this.settle((0, import_neverthrow129.err)({ type: "HOOK_ABORTED" }));
175539
175800
  };
175540
175801
  }
175541
175802
  async start() {
@@ -175560,20 +175821,20 @@ var HookRuntime = class {
175560
175821
  attachTimeout() {
175561
175822
  this.timeoutHandle = setTimeout(() => {
175562
175823
  this.child.kill("SIGTERM");
175563
- this.settle((0, import_neverthrow128.err)({ type: "HOOK_TIMEOUT", timeoutMs: this.timeoutMs }));
175824
+ this.settle((0, import_neverthrow129.err)({ type: "HOOK_TIMEOUT", timeoutMs: this.timeoutMs }));
175564
175825
  }, this.timeoutMs);
175565
175826
  }
175566
175827
  attachChildListeners() {
175567
175828
  this.child.on("error", (cause) => {
175568
- this.settle((0, import_neverthrow128.err)({ type: "HOOK_SPAWN_FAILED", cause }));
175829
+ this.settle((0, import_neverthrow129.err)({ type: "HOOK_SPAWN_FAILED", cause }));
175569
175830
  });
175570
175831
  this.child.on("exit", (code) => {
175571
175832
  if (code === 0) {
175572
- this.settle((0, import_neverthrow128.ok)());
175833
+ this.settle((0, import_neverthrow129.ok)());
175573
175834
  return;
175574
175835
  }
175575
175836
  this.settle(
175576
- (0, import_neverthrow128.err)({
175837
+ (0, import_neverthrow129.err)({
175577
175838
  type: "HOOK_EXIT_NONZERO",
175578
175839
  code: code ?? -1,
175579
175840
  stderr: this.stderrBuffer
@@ -175596,7 +175857,7 @@ var HookRuntime = class {
175596
175857
  this.signal.removeEventListener("abort", this.onAbort);
175597
175858
  }
175598
175859
  };
175599
- var safeSpawn = import_neverthrow128.ResultAsync.fromThrowable(
175860
+ var safeSpawn = import_neverthrow129.ResultAsync.fromThrowable(
175600
175861
  spawnHook,
175601
175862
  (cause) => ({ type: "HOOK_SPAWN_FAILED", cause })
175602
175863
  );
@@ -175662,7 +175923,7 @@ function buildAttemptContext(input) {
175662
175923
  }
175663
175924
  function invokeHook(input) {
175664
175925
  const context = buildAttemptContext(input);
175665
- return import_neverthrow129.ResultAsync.fromSafePromise(runAllAttempts(context)).andThen((result) => result);
175926
+ return import_neverthrow130.ResultAsync.fromSafePromise(runAllAttempts(context)).andThen((result) => result);
175666
175927
  }
175667
175928
  function isRetryableHookError(error48) {
175668
175929
  return RETRYABLE_HOOK_ERROR_TYPES.has(error48.type);
@@ -175670,7 +175931,7 @@ function isRetryableHookError(error48) {
175670
175931
  function maybeInvokeHook(input) {
175671
175932
  const { hook: hook2 } = input;
175672
175933
  if (hook2 === void 0) {
175673
- return (0, import_neverthrow129.okAsync)();
175934
+ return (0, import_neverthrow130.okAsync)();
175674
175935
  }
175675
175936
  return invokeHook({ ...input, hook: hook2 });
175676
175937
  }
@@ -175765,7 +176026,7 @@ async function processItem2(workerContext, item) {
175765
176026
  workerContext.inFlight.delete(item.id);
175766
176027
  return failCount;
175767
176028
  }
175768
- var safeProcessItem = import_neverthrow130.ResultAsync.fromThrowable(
176029
+ var safeProcessItem = import_neverthrow131.ResultAsync.fromThrowable(
175769
176030
  processItem2,
175770
176031
  (cause) => ({
175771
176032
  type: "PROCESS_ITEM_FAILED",
@@ -175815,7 +176076,7 @@ async function runAllWorkers(runContext) {
175815
176076
  fallbackUdid: config2.simulatorUdids[0] ?? ""
175816
176077
  });
175817
176078
  }
175818
- const totalFindings = results.reduce((sum, item) => sum + item.findings.length, 0);
176079
+ const totalFindings = results.reduce((sum2, item) => sum2 + item.findings.length, 0);
175819
176080
  config2.observer({
175820
176081
  type: "SUITE_COMPLETED",
175821
176082
  totalItems: results.length,
@@ -175830,7 +176091,7 @@ function runWorkerPool(config2) {
175830
176091
  const results = [];
175831
176092
  const inFlight = /* @__PURE__ */ new Map();
175832
176093
  const suiteStartMs = Date.now();
175833
- const safeRun = import_neverthrow130.ResultAsync.fromThrowable(
176094
+ const safeRun = import_neverthrow131.ResultAsync.fromThrowable(
175834
176095
  async () => runAllWorkers({ config: config2, queue, results, suiteStartMs, inFlight }),
175835
176096
  (cause) => ({ type: "WORKER_POOL_FAILED", cause })
175836
176097
  );
@@ -176016,8 +176277,8 @@ function buildSuiteFindings(input) {
176016
176277
 
176017
176278
  // src/suite/shell/spec-scenario-id-reader.ts
176018
176279
  var import_promises38 = require("node:fs/promises");
176019
- var import_neverthrow131 = __toESM(require_index_cjs(), 1);
176020
- var safeReadFile7 = import_neverthrow131.ResultAsync.fromThrowable(
176280
+ var import_neverthrow132 = __toESM(require_index_cjs(), 1);
176281
+ var safeReadFile7 = import_neverthrow132.ResultAsync.fromThrowable(
176021
176282
  async (filePath) => (0, import_promises38.readFile)(filePath, "utf8"),
176022
176283
  (cause) => ({ specPath: "", cause })
176023
176284
  );
@@ -176040,17 +176301,17 @@ function entriesToRecord(results) {
176040
176301
  const entries = [];
176041
176302
  for (const result of results) {
176042
176303
  if (result.isErr()) {
176043
- return (0, import_neverthrow131.err)(result.error);
176304
+ return (0, import_neverthrow132.err)(result.error);
176044
176305
  }
176045
176306
  entries.push(result.value);
176046
176307
  }
176047
- return (0, import_neverthrow131.ok)(Object.fromEntries(entries));
176308
+ return (0, import_neverthrow132.ok)(Object.fromEntries(entries));
176048
176309
  }
176049
176310
  function readScenarioIdsBySpecPaths(specPaths) {
176050
176311
  if (specPaths.length === 0) {
176051
- return import_neverthrow131.ResultAsync.fromSafePromise(Promise.resolve({}));
176312
+ return import_neverthrow132.ResultAsync.fromSafePromise(Promise.resolve({}));
176052
176313
  }
176053
- const awaitAll = import_neverthrow131.ResultAsync.fromSafePromise(
176314
+ const awaitAll = import_neverthrow132.ResultAsync.fromSafePromise(
176054
176315
  Promise.all(specPaths.map((specPath) => readOneSpecEntry(specPath)))
176055
176316
  );
176056
176317
  return awaitAll.andThen(entriesToRecord);
@@ -176059,7 +176320,7 @@ function readScenarioIdsBySpecPaths(specPaths) {
176059
176320
  // src/suite/shell/suite-findings-writer.ts
176060
176321
  var import_promises39 = __toESM(require("node:fs/promises"), 1);
176061
176322
  var import_node_path48 = __toESM(require("node:path"), 1);
176062
- var import_neverthrow132 = __toESM(require_index_cjs(), 1);
176323
+ var import_neverthrow133 = __toESM(require_index_cjs(), 1);
176063
176324
  var INDENT_SPACES = 2;
176064
176325
  function writeSuiteFindings(findings, options) {
176065
176326
  const directory = import_node_path48.default.join(
@@ -176071,7 +176332,7 @@ function writeSuiteFindings(findings, options) {
176071
176332
  );
176072
176333
  const finalPath = import_node_path48.default.join(directory, "findings.json");
176073
176334
  const temporaryPath = `${finalPath}.tmp`;
176074
- const safeWriteAtomically = import_neverthrow132.ResultAsync.fromThrowable(
176335
+ const safeWriteAtomically = import_neverthrow133.ResultAsync.fromThrowable(
176075
176336
  async () => {
176076
176337
  await import_promises39.default.mkdir(directory, { recursive: true });
176077
176338
  await import_promises39.default.writeFile(temporaryPath, JSON.stringify(findings, void 0, INDENT_SPACES));
@@ -176086,7 +176347,7 @@ function writeSuiteFindings(findings, options) {
176086
176347
  // src/suite/shell/suite-runs-writer.ts
176087
176348
  var import_promises40 = __toESM(require("node:fs/promises"), 1);
176088
176349
  var import_node_path49 = __toESM(require("node:path"), 1);
176089
- var import_neverthrow133 = __toESM(require_index_cjs(), 1);
176350
+ var import_neverthrow134 = __toESM(require_index_cjs(), 1);
176090
176351
  var INDENT_SPACES2 = 2;
176091
176352
  var RUNS_FILENAME2 = "scenario-runs.json";
176092
176353
  function writeSuiteRuns(runsFile, options) {
@@ -176099,7 +176360,7 @@ function writeSuiteRuns(runsFile, options) {
176099
176360
  );
176100
176361
  const finalPath = import_node_path49.default.join(directory, RUNS_FILENAME2);
176101
176362
  const temporaryPath = `${finalPath}.tmp`;
176102
- const safeWriteAtomically = import_neverthrow133.ResultAsync.fromThrowable(
176363
+ const safeWriteAtomically = import_neverthrow134.ResultAsync.fromThrowable(
176103
176364
  async () => {
176104
176365
  await import_promises40.default.mkdir(directory, { recursive: true });
176105
176366
  await import_promises40.default.writeFile(temporaryPath, JSON.stringify(runsFile, void 0, INDENT_SPACES2));
@@ -176154,7 +176415,7 @@ async function writeAndReport(input) {
176154
176415
  // src/suite/commands/suite-run-context.ts
176155
176416
  var import_promises41 = __toESM(require("node:fs/promises"), 1);
176156
176417
  var import_node_path50 = __toESM(require("node:path"), 1);
176157
- var import_neverthrow134 = __toESM(require_index_cjs(), 1);
176418
+ var import_neverthrow135 = __toESM(require_index_cjs(), 1);
176158
176419
 
176159
176420
  // src/suite/core/run-id.ts
176160
176421
  var RUN_ID_PAD_LENGTH2 = 4;
@@ -176189,7 +176450,7 @@ function deriveSuiteId(input) {
176189
176450
 
176190
176451
  // src/suite/commands/suite-run-context.ts
176191
176452
  var ISO_DATE_LENGTH3 = 10;
176192
- var safeReaddir3 = import_neverthrow134.ResultAsync.fromThrowable(
176453
+ var safeReaddir3 = import_neverthrow135.ResultAsync.fromThrowable(
176193
176454
  async (directoryPath) => {
176194
176455
  const entries = await import_promises41.default.readdir(directoryPath, { withFileTypes: true });
176195
176456
  return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
@@ -176337,18 +176598,18 @@ async function runSuiteCommand(input) {
176337
176598
  }
176338
176599
 
176339
176600
  // src/suite/commands/validate-run-arguments.ts
176340
- var import_neverthrow135 = __toESM(require_index_cjs(), 1);
176601
+ var import_neverthrow136 = __toESM(require_index_cjs(), 1);
176341
176602
  function validateRunArguments(options) {
176342
176603
  if (options.suite === void 0 && options.spec === void 0) {
176343
- return (0, import_neverthrow135.err)({ type: "MISSING_SUITE_OR_SPEC" });
176604
+ return (0, import_neverthrow136.err)({ type: "MISSING_SUITE_OR_SPEC" });
176344
176605
  }
176345
176606
  if (options.suite !== void 0 && options.spec !== void 0) {
176346
- return (0, import_neverthrow135.err)({ type: "BOTH_SUITE_AND_SPEC" });
176607
+ return (0, import_neverthrow136.err)({ type: "BOTH_SUITE_AND_SPEC" });
176347
176608
  }
176348
176609
  if (options.only !== void 0 && options.suite === void 0) {
176349
- return (0, import_neverthrow135.err)({ type: "ONLY_REQUIRES_SUITE" });
176610
+ return (0, import_neverthrow136.err)({ type: "ONLY_REQUIRES_SUITE" });
176350
176611
  }
176351
- return (0, import_neverthrow135.ok)(
176612
+ return (0, import_neverthrow136.ok)(
176352
176613
  options.suite === void 0 ? { type: "spec", globs: options.spec ?? [] } : { type: "suite", name: options.suite }
176353
176614
  );
176354
176615
  }
@@ -176492,13 +176753,13 @@ function deriveSpecSlug(specFilePath) {
176492
176753
  // src/commands/spec-resolver.ts
176493
176754
  var import_node_fs23 = require("node:fs");
176494
176755
  var import_node_path53 = __toESM(require("node:path"), 1);
176495
- var import_neverthrow136 = __toESM(require_index_cjs(), 1);
176496
- var safeReadFile8 = (0, import_neverthrow136.fromThrowable)((filePath) => (0, import_node_fs23.readFileSync)(filePath, "utf8"));
176497
- var safeReaddir4 = (0, import_neverthrow136.fromThrowable)(
176756
+ var import_neverthrow137 = __toESM(require_index_cjs(), 1);
176757
+ var safeReadFile8 = (0, import_neverthrow137.fromThrowable)((filePath) => (0, import_node_fs23.readFileSync)(filePath, "utf8"));
176758
+ var safeReaddir4 = (0, import_neverthrow137.fromThrowable)(
176498
176759
  (directory) => (0, import_node_fs23.readdirSync)(directory, { recursive: true, encoding: "utf8" })
176499
176760
  );
176500
176761
  var CANCEL = "xqa:cancel";
176501
- var safeSelect = import_neverthrow136.ResultAsync.fromThrowable(
176762
+ var safeSelect = import_neverthrow137.ResultAsync.fromThrowable(
176502
176763
  esm_default11,
176503
176764
  (error48) => error48 instanceof Error && error48.name === "ExitPromptError" ? "cancelled" : "failed"
176504
176765
  );
@@ -176635,10 +176896,10 @@ async function runSpecCommand(input, options) {
176635
176896
  var import_promises44 = __toESM(require("node:fs/promises"), 1);
176636
176897
  var import_node_path56 = __toESM(require("node:path"), 1);
176637
176898
  var import_fast_glob2 = __toESM(require_out4(), 1);
176638
- var import_neverthrow142 = __toESM(require_index_cjs(), 1);
176899
+ var import_neverthrow143 = __toESM(require_index_cjs(), 1);
176639
176900
 
176640
176901
  // ../../agents/triager/dist/index.js
176641
- var import_neverthrow137 = __toESM(require_index_cjs(), 1);
176902
+ var import_neverthrow138 = __toESM(require_index_cjs(), 1);
176642
176903
 
176643
176904
  // ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
176644
176905
  var balanced = (a3, b2, str2) => {
@@ -178443,14 +178704,14 @@ minimatch.escape = escape2;
178443
178704
  minimatch.unescape = unescape2;
178444
178705
 
178445
178706
  // ../../agents/triager/dist/index.js
178446
- var import_neverthrow138 = __toESM(require_index_cjs(), 1);
178447
- var import_promises42 = require("node:fs/promises");
178448
178707
  var import_neverthrow139 = __toESM(require_index_cjs(), 1);
178708
+ var import_promises42 = require("node:fs/promises");
178709
+ var import_neverthrow140 = __toESM(require_index_cjs(), 1);
178449
178710
  var import_node_child_process17 = require("node:child_process");
178450
178711
  var import_promises43 = require("node:fs/promises");
178451
178712
  var import_node_path55 = __toESM(require("node:path"), 1);
178452
- var import_neverthrow140 = __toESM(require_index_cjs(), 1);
178453
178713
  var import_neverthrow141 = __toESM(require_index_cjs(), 1);
178714
+ var import_neverthrow142 = __toESM(require_index_cjs(), 1);
178454
178715
  function resolveConfidence2(selected) {
178455
178716
  if (selected.some((pick2) => pick2.confidence === "HIGH")) {
178456
178717
  return "high";
@@ -179115,7 +179376,7 @@ async function drainMessages(runner, state) {
179115
179376
  }
179116
179377
  }
179117
179378
  }
179118
- var safeDrainMessages = import_neverthrow138.ResultAsync.fromThrowable(
179379
+ var safeDrainMessages = import_neverthrow139.ResultAsync.fromThrowable(
179119
179380
  drainMessages,
179120
179381
  (cause) => ({ type: "AI_CALL_FAILED", cause })
179121
179382
  );
@@ -179141,25 +179402,25 @@ function finalizeRun(bootstrap) {
179141
179402
  const telemetry = buildTelemetry(bootstrap.telemetryInput, bootstrap.state);
179142
179403
  const error48 = resolveError(bootstrap.state);
179143
179404
  if (error48 !== void 0) {
179144
- return (0, import_neverthrow138.errAsync)(error48);
179405
+ return (0, import_neverthrow139.errAsync)(error48);
179145
179406
  }
179146
179407
  const output = bootstrap.state.output;
179147
179408
  if (output === void 0) {
179148
- return (0, import_neverthrow138.errAsync)({ type: "AI_NO_FINAL_TOOL_CALL" });
179409
+ return (0, import_neverthrow139.errAsync)({ type: "AI_NO_FINAL_TOOL_CALL" });
179149
179410
  }
179150
179411
  bootstrap.reportTelemetry(telemetry);
179151
- return (0, import_neverthrow138.okAsync)({ picks: output.picks, metaPr: output.metaPr, telemetry });
179412
+ return (0, import_neverthrow139.okAsync)({ picks: output.picks, metaPr: output.metaPr, telemetry });
179152
179413
  }
179153
179414
  function launchQuery(input) {
179154
- const safeLaunch = (0, import_neverthrow138.fromThrowable)(
179415
+ const safeLaunch = (0, import_neverthrow139.fromThrowable)(
179155
179416
  input.queryRunner,
179156
179417
  (cause) => ({ type: "AI_CALL_FAILED", cause })
179157
179418
  );
179158
179419
  const result = safeLaunch({ prompt: input.inputQueue, options: input.queryOptions });
179159
179420
  if (result.isErr()) {
179160
- return (0, import_neverthrow138.errAsync)(result.error);
179421
+ return (0, import_neverthrow139.errAsync)(result.error);
179161
179422
  }
179162
- return (0, import_neverthrow138.okAsync)(result.value);
179423
+ return (0, import_neverthrow139.okAsync)(result.value);
179163
179424
  }
179164
179425
  function runPipeline4(bootstrap) {
179165
179426
  return launchQuery({
@@ -179213,9 +179474,9 @@ var STATIC_ONLY_FIELDS = {
179213
179474
  freestyleByGroup: /* @__PURE__ */ new Map(),
179214
179475
  appIndex: [],
179215
179476
  handlers: {
179216
- readSpec: () => (0, import_neverthrow137.errAsync)({ type: "FILE_NOT_FOUND", path: "" }),
179217
- readAppSection: () => (0, import_neverthrow137.errAsync)({ type: "FILE_NOT_FOUND", path: "" }),
179218
- grepCodebase: () => (0, import_neverthrow137.errAsync)({ type: "FILE_NOT_FOUND", path: "" })
179477
+ readSpec: () => (0, import_neverthrow138.errAsync)({ type: "FILE_NOT_FOUND", path: "" }),
179478
+ readAppSection: () => (0, import_neverthrow138.errAsync)({ type: "FILE_NOT_FOUND", path: "" }),
179479
+ grepCodebase: () => (0, import_neverthrow138.errAsync)({ type: "FILE_NOT_FOUND", path: "" })
179219
179480
  }
179220
179481
  };
179221
179482
  function resolveAiFields(config2) {
@@ -179336,15 +179597,15 @@ function runAiTiebreaker(context, staticPicks) {
179336
179597
  function runTriager(options) {
179337
179598
  const { groups, config: config2 } = options;
179338
179599
  if (groups.length === 0) {
179339
- return (0, import_neverthrow137.errAsync)({ type: "NO_GROUPS" });
179600
+ return (0, import_neverthrow138.errAsync)({ type: "NO_GROUPS" });
179340
179601
  }
179341
179602
  if (config2?.useAi === true && config2.ai === void 0) {
179342
- return (0, import_neverthrow137.errAsync)({ type: "AI_CONFIG_MISSING" });
179603
+ return (0, import_neverthrow138.errAsync)({ type: "AI_CONFIG_MISSING" });
179343
179604
  }
179344
179605
  const context = buildContext3(options);
179345
179606
  const staticPicks = scoreGroups(context.diff, context.groups);
179346
179607
  if (!context.useAi) {
179347
- return (0, import_neverthrow137.okAsync)(buildDecision({ picks: staticPicks, metaPr: false }));
179608
+ return (0, import_neverthrow138.okAsync)(buildDecision({ picks: staticPicks, metaPr: false }));
179348
179609
  }
179349
179610
  return runAiTiebreaker(context, staticPicks);
179350
179611
  }
@@ -179405,9 +179666,9 @@ function parseSections(text) {
179405
179666
  function lookupSection(sections, screenName) {
179406
179667
  const section = sections.get(screenName);
179407
179668
  if (section === void 0) {
179408
- return (0, import_neverthrow139.errAsync)({ type: "SECTION_NOT_FOUND", screenName });
179669
+ return (0, import_neverthrow140.errAsync)({ type: "SECTION_NOT_FOUND", screenName });
179409
179670
  }
179410
- return (0, import_neverthrow139.okAsync)(section);
179671
+ return (0, import_neverthrow140.okAsync)(section);
179411
179672
  }
179412
179673
  async function readUtf8File(filePath) {
179413
179674
  return (0, import_promises42.readFile)(filePath, UTF8);
@@ -179415,7 +179676,7 @@ async function readUtf8File(filePath) {
179415
179676
  function createAppMdReader(options) {
179416
179677
  const filePath = options.path;
179417
179678
  let sectionCache;
179418
- const safeReadFile10 = import_neverthrow139.ResultAsync.fromThrowable(
179679
+ const safeReadFile10 = import_neverthrow140.ResultAsync.fromThrowable(
179419
179680
  readUtf8File,
179420
179681
  (cause) => classifyReadError(cause, filePath)
179421
179682
  );
@@ -179533,15 +179794,15 @@ async function invokeRipgrep(options) {
179533
179794
  return runExecFile({ binary: binary2, arguments_, cwd });
179534
179795
  }
179535
179796
  function execRipgrepRaw(options) {
179536
- const safeExec = import_neverthrow140.ResultAsync.fromThrowable(invokeRipgrep, classifyRawExecError);
179797
+ const safeExec = import_neverthrow141.ResultAsync.fromThrowable(invokeRipgrep, classifyRawExecError);
179537
179798
  return safeExec(options);
179538
179799
  }
179539
179800
  function handleExecResult(options) {
179540
179801
  return execRipgrepRaw(options).orElse((error48) => {
179541
179802
  if (error48.type === "GREP_FAILED" && error48.cause.code === RIPGREP_NO_MATCH_CODE) {
179542
- return (0, import_neverthrow140.ok)({ stdout: "", stderr: "" });
179803
+ return (0, import_neverthrow141.ok)({ stdout: "", stderr: "" });
179543
179804
  }
179544
- return (0, import_neverthrow140.err)(error48);
179805
+ return (0, import_neverthrow141.err)(error48);
179545
179806
  });
179546
179807
  }
179547
179808
  async function readUtf8File2(filePath) {
@@ -179550,7 +179811,7 @@ async function readUtf8File2(filePath) {
179550
179811
  function makeReadFile(cwd) {
179551
179812
  return (filePath) => {
179552
179813
  const resolvedPath = resolveFilePath(filePath, cwd);
179553
- const safeRead3 = import_neverthrow140.ResultAsync.fromThrowable(
179814
+ const safeRead3 = import_neverthrow141.ResultAsync.fromThrowable(
179554
179815
  readUtf8File2,
179555
179816
  (cause) => classifyReadError2(cause, resolvedPath)
179556
179817
  );
@@ -179617,9 +179878,9 @@ function applyHeading(state, screenName) {
179617
179878
  function handleHeading(state, indexed) {
179618
179879
  const screenName = indexed.text.slice(LEVEL_2_HEADING_MARKER.length).trim();
179619
179880
  if (screenName.length === 0) {
179620
- return (0, import_neverthrow141.err)({ type: "APP_MD_MALFORMED", line: indexed.number });
179881
+ return (0, import_neverthrow142.err)({ type: "APP_MD_MALFORMED", line: indexed.number });
179621
179882
  }
179622
- return (0, import_neverthrow141.ok)(applyHeading(state, screenName));
179883
+ return (0, import_neverthrow142.ok)(applyHeading(state, screenName));
179623
179884
  }
179624
179885
  function handleFenceLine(state, lineNumber) {
179625
179886
  if (state.insideFence) {
@@ -179653,23 +179914,23 @@ function isLevel2Heading(line) {
179653
179914
  }
179654
179915
  function processLine2(state, indexed) {
179655
179916
  if (indexed.text.startsWith(FENCE_MARKER)) {
179656
- return (0, import_neverthrow141.ok)(handleFenceLine(state, indexed.number));
179917
+ return (0, import_neverthrow142.ok)(handleFenceLine(state, indexed.number));
179657
179918
  }
179658
179919
  if (state.insideFence) {
179659
- return (0, import_neverthrow141.ok)(state);
179920
+ return (0, import_neverthrow142.ok)(state);
179660
179921
  }
179661
179922
  if (isLevel2Heading(indexed.text)) {
179662
179923
  return handleHeading(state, indexed);
179663
179924
  }
179664
179925
  if (indexed.text.trim().length === 0) {
179665
- return (0, import_neverthrow141.ok)(handleBlankLine(state));
179926
+ return (0, import_neverthrow142.ok)(handleBlankLine(state));
179666
179927
  }
179667
- return (0, import_neverthrow141.ok)(handleContentLine(state, indexed.text));
179928
+ return (0, import_neverthrow142.ok)(handleContentLine(state, indexed.text));
179668
179929
  }
179669
179930
  function processIndexedLines(indexedLines, state) {
179670
179931
  const [head, ...tail] = indexedLines;
179671
179932
  if (head === void 0) {
179672
- return (0, import_neverthrow141.ok)(state);
179933
+ return (0, import_neverthrow142.ok)(state);
179673
179934
  }
179674
179935
  return processLine2(state, head).andThen((next) => processIndexedLines(tail, next));
179675
179936
  }
@@ -179681,9 +179942,9 @@ function buildFinalEntries(state) {
179681
179942
  }
179682
179943
  function finaliseState(state) {
179683
179944
  if (state.insideFence) {
179684
- return (0, import_neverthrow141.err)({ type: "APP_MD_MALFORMED", line: state.fenceOpenLine });
179945
+ return (0, import_neverthrow142.err)({ type: "APP_MD_MALFORMED", line: state.fenceOpenLine });
179685
179946
  }
179686
- return (0, import_neverthrow141.ok)([...buildFinalEntries(state)]);
179947
+ return (0, import_neverthrow142.ok)([...buildFinalEntries(state)]);
179687
179948
  }
179688
179949
  function buildAppIndex(appMd) {
179689
179950
  const indexedLines = toIndexedLines(appMd.split("\n"));
@@ -179761,11 +180022,11 @@ var rootConfigSchema = external_exports.object({
179761
180022
  var DEFAULT_SPECS_DIR = ".xqa/specs";
179762
180023
  var SPEC_GLOB_SUFFIX = "**/*.test.md";
179763
180024
  var GLOB_CHARS = /[*?{}[\]!]/;
179764
- var safeReadFile9 = import_neverthrow142.ResultAsync.fromThrowable(
180025
+ var safeReadFile9 = import_neverthrow143.ResultAsync.fromThrowable(
179765
180026
  async (filePath) => import_promises44.default.readFile(filePath, "utf8"),
179766
180027
  (cause) => ({ type: "READ_FAILED", cause })
179767
180028
  );
179768
- var safeStat3 = import_neverthrow142.ResultAsync.fromThrowable(
180029
+ var safeStat3 = import_neverthrow143.ResultAsync.fromThrowable(
179769
180030
  async (filePath) => import_promises44.default.stat(filePath),
179770
180031
  (cause) => ({ type: "STAT_FAILED", cause })
179771
180032
  );
@@ -179994,11 +180255,11 @@ function registerSyncLabelsCommand(program3, loader2) {
179994
180255
  }
179995
180256
 
179996
180257
  // src/commands/triage-command.ts
179997
- var import_neverthrow146 = __toESM(require_index_cjs(), 1);
180258
+ var import_neverthrow147 = __toESM(require_index_cjs(), 1);
179998
180259
 
179999
180260
  // src/triage/ai-context-builder.ts
180000
180261
  var import_node_path57 = __toESM(require("node:path"), 1);
180001
- var import_neverthrow143 = __toESM(require_index_cjs(), 1);
180262
+ var import_neverthrow144 = __toESM(require_index_cjs(), 1);
180002
180263
  var PROMPT_VERSION = "v1";
180003
180264
  var MAX_GREP_PATTERN_LENGTH = 200;
180004
180265
  var DENIED_SAMPLE_PATHS = [
@@ -180077,7 +180338,7 @@ function isDeniedGlob(pathGlob) {
180077
180338
  return normalized !== pathGlob && matchesDeniedSample(normalized);
180078
180339
  }
180079
180340
  function pathDenied(reason) {
180080
- return (0, import_neverthrow143.errAsync)({ type: "PATH_DENIED", reason });
180341
+ return (0, import_neverthrow144.errAsync)({ type: "PATH_DENIED", reason });
180081
180342
  }
180082
180343
  function buildHandlers(cwd, validSpecIds) {
180083
180344
  const reader = createCodebaseReader({ cwd });
@@ -180110,13 +180371,13 @@ function loadAppIndex(appMdPath) {
180110
180371
  return appMdReader.readFile(appMdPath).mapErr(() => ({ type: "SPEC_NOT_FOUND", path: appMdPath })).andThen((content) => {
180111
180372
  const indexResult = buildAppIndex(content);
180112
180373
  if (indexResult.isErr()) {
180113
- return (0, import_neverthrow143.errAsync)({
180374
+ return (0, import_neverthrow144.errAsync)({
180114
180375
  type: "SUITE_INVALID",
180115
180376
  path: appMdPath,
180116
180377
  cause: indexResult.error
180117
180378
  });
180118
180379
  }
180119
- return (0, import_neverthrow143.okAsync)(indexResult.value);
180380
+ return (0, import_neverthrow144.okAsync)(indexResult.value);
180120
180381
  });
180121
180382
  }
180122
180383
  function collectSpecIds(specSummariesByGroup) {
@@ -180184,7 +180445,7 @@ function toXqaError(error48) {
180184
180445
  }
180185
180446
 
180186
180447
  // src/triage/github-pr-fetcher.ts
180187
- var import_neverthrow144 = __toESM(require_index_cjs(), 1);
180448
+ var import_neverthrow145 = __toESM(require_index_cjs(), 1);
180188
180449
  var STATUS_MAP = {
180189
180450
  added: "added",
180190
180451
  modified: "modified",
@@ -180220,11 +180481,11 @@ async function runListFiles(octokit, options) {
180220
180481
  per_page: 100
180221
180482
  });
180222
180483
  }
180223
- var safeGet = import_neverthrow144.ResultAsync.fromThrowable(
180484
+ var safeGet = import_neverthrow145.ResultAsync.fromThrowable(
180224
180485
  runPullRequestGet,
180225
180486
  (cause) => ({ type: "PR_FETCH_FAILED", cause })
180226
180487
  );
180227
- var safeList = import_neverthrow144.ResultAsync.fromThrowable(
180488
+ var safeList = import_neverthrow145.ResultAsync.fromThrowable(
180228
180489
  runListFiles,
180229
180490
  (cause) => ({ type: "PR_FETCH_FAILED", cause })
180230
180491
  );
@@ -180238,7 +180499,7 @@ function toDiff(summary, files) {
180238
180499
  }
180239
180500
  function fetchPullRequestDiff(options) {
180240
180501
  const octokit = new Octokit2({ auth: options.token });
180241
- return import_neverthrow144.ResultAsync.combine([safeGet(octokit, options), safeList(octokit, options)]).map(
180502
+ return import_neverthrow145.ResultAsync.combine([safeGet(octokit, options), safeList(octokit, options)]).map(
180242
180503
  ([summary, files]) => toDiff(summary, files)
180243
180504
  );
180244
180505
  }
@@ -180274,7 +180535,7 @@ function formatXqaLabels(decision) {
180274
180535
  // src/triage/suite-loader.ts
180275
180536
  var import_promises45 = require("node:fs/promises");
180276
180537
  var import_node_path58 = __toESM(require("node:path"), 1);
180277
- var import_neverthrow145 = __toESM(require_index_cjs(), 1);
180538
+ var import_neverthrow146 = __toESM(require_index_cjs(), 1);
180278
180539
  var SUITE_FILE_SUFFIX2 = ".suite.json";
180279
180540
  var freestyleEntrySchema2 = external_exports.object({
180280
180541
  timeoutSeconds: external_exports.number().int().positive(),
@@ -180285,7 +180546,7 @@ var suiteFileSchema = external_exports.object({
180285
180546
  freestyle: external_exports.array(freestyleEntrySchema2).optional(),
180286
180547
  hooks: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
180287
180548
  });
180288
- var safeJsonParse10 = (0, import_neverthrow145.fromThrowable)(JSON.parse);
180549
+ var safeJsonParse10 = (0, import_neverthrow146.fromThrowable)(JSON.parse);
180289
180550
  async function runReadFile(filePath) {
180290
180551
  return (0, import_promises45.readFile)(filePath, "utf8");
180291
180552
  }
@@ -180296,28 +180557,28 @@ async function runReadDirectory(filePath) {
180296
180557
  return (0, import_promises45.readdir)(filePath);
180297
180558
  }
180298
180559
  function readSuiteFile(filePath) {
180299
- const safeRead3 = import_neverthrow145.ResultAsync.fromThrowable(
180560
+ const safeRead3 = import_neverthrow146.ResultAsync.fromThrowable(
180300
180561
  runReadFile,
180301
180562
  (cause) => ({ type: "SUITE_READ_FAILED", path: filePath, cause })
180302
180563
  );
180303
180564
  return safeRead3(filePath);
180304
180565
  }
180305
180566
  function readSpecFile2(filePath) {
180306
- const safeRead3 = import_neverthrow145.ResultAsync.fromThrowable(
180567
+ const safeRead3 = import_neverthrow146.ResultAsync.fromThrowable(
180307
180568
  runReadFile,
180308
180569
  () => ({ type: "SPEC_NOT_FOUND", path: filePath })
180309
180570
  );
180310
180571
  return safeRead3(filePath);
180311
180572
  }
180312
180573
  function statDirectory2(directory) {
180313
- const safeStat4 = import_neverthrow145.ResultAsync.fromThrowable(
180574
+ const safeStat4 = import_neverthrow146.ResultAsync.fromThrowable(
180314
180575
  runStat,
180315
180576
  () => ({ type: "SUITE_DIR_MISSING", path: directory })
180316
180577
  );
180317
180578
  return safeStat4(directory);
180318
180579
  }
180319
180580
  function readDirectoryEntries2(directory) {
180320
- const safeReadDirectory2 = import_neverthrow145.ResultAsync.fromThrowable(
180581
+ const safeReadDirectory2 = import_neverthrow146.ResultAsync.fromThrowable(
180321
180582
  runReadDirectory,
180322
180583
  (cause) => ({ type: "SUITE_READ_FAILED", path: directory, cause })
180323
180584
  );
@@ -180326,7 +180587,7 @@ function readDirectoryEntries2(directory) {
180326
180587
  function listSuiteFiles(directory) {
180327
180588
  return statDirectory2(directory).andThen((stats) => {
180328
180589
  if (!stats.isDirectory()) {
180329
- return (0, import_neverthrow145.errAsync)({ type: "SUITE_DIR_MISSING", path: directory });
180590
+ return (0, import_neverthrow146.errAsync)({ type: "SUITE_DIR_MISSING", path: directory });
180330
180591
  }
180331
180592
  return readDirectoryEntries2(directory);
180332
180593
  }).map(
@@ -180336,13 +180597,13 @@ function listSuiteFiles(directory) {
180336
180597
  function parseSuiteFile(filePath, raw) {
180337
180598
  const parsed = safeJsonParse10(raw);
180338
180599
  if (parsed.isErr()) {
180339
- return (0, import_neverthrow145.err)({ type: "SUITE_INVALID", path: filePath, cause: parsed.error });
180600
+ return (0, import_neverthrow146.err)({ type: "SUITE_INVALID", path: filePath, cause: parsed.error });
180340
180601
  }
180341
180602
  const validated = suiteFileSchema.safeParse(parsed.value);
180342
180603
  if (!validated.success) {
180343
- return (0, import_neverthrow145.err)({ type: "SUITE_INVALID", path: filePath, cause: validated.error });
180604
+ return (0, import_neverthrow146.err)({ type: "SUITE_INVALID", path: filePath, cause: validated.error });
180344
180605
  }
180345
- return (0, import_neverthrow145.ok)(validated.data);
180606
+ return (0, import_neverthrow146.ok)(validated.data);
180346
180607
  }
180347
180608
  function suiteIdFromPath(filePath) {
180348
180609
  const name = import_node_path58.default.basename(filePath);
@@ -180353,7 +180614,7 @@ function loadSpecReference(xqaDirectory, specPath) {
180353
180614
  return readSpecFile2(absolute).andThen((raw) => {
180354
180615
  const parsed = parseSpecShared(raw);
180355
180616
  if (parsed.isErr()) {
180356
- return (0, import_neverthrow145.err)({
180617
+ return (0, import_neverthrow146.err)({
180357
180618
  type: "SPEC_FRONTMATTER_INVALID",
180358
180619
  path: absolute,
180359
180620
  cause: parsed.error
@@ -180361,16 +180622,16 @@ function loadSpecReference(xqaDirectory, specPath) {
180361
180622
  }
180362
180623
  const { feature, timeoutSeconds } = parsed.value.spec;
180363
180624
  if (timeoutSeconds === void 0) {
180364
- return (0, import_neverthrow145.ok)({ path: specPath, feature });
180625
+ return (0, import_neverthrow146.ok)({ path: specPath, feature });
180365
180626
  }
180366
- return (0, import_neverthrow145.ok)({ path: specPath, feature, timeoutSeconds });
180627
+ return (0, import_neverthrow146.ok)({ path: specPath, feature, timeoutSeconds });
180367
180628
  });
180368
180629
  }
180369
180630
  function loadSpecReferences(xqaDirectory, specs) {
180370
180631
  if (specs.length === 0) {
180371
- return (0, import_neverthrow145.okAsync)([]);
180632
+ return (0, import_neverthrow146.okAsync)([]);
180372
180633
  }
180373
- return import_neverthrow145.ResultAsync.combine(specs.map((specPath) => loadSpecReference(xqaDirectory, specPath)));
180634
+ return import_neverthrow146.ResultAsync.combine(specs.map((specPath) => loadSpecReference(xqaDirectory, specPath)));
180374
180635
  }
180375
180636
  function addSpecTokens(tokens, spec) {
180376
180637
  const stem = import_node_path58.default.basename(spec.path).replace(/\.test\.md$/u, "");
@@ -180449,9 +180710,9 @@ function loadXqaSuites(directory) {
180449
180710
  const xqaDirectory = import_node_path58.default.dirname(import_node_path58.default.resolve(directory));
180450
180711
  return listSuiteFiles(directory).andThen((files) => {
180451
180712
  if (files.length === 0) {
180452
- return (0, import_neverthrow145.okAsync)([]);
180713
+ return (0, import_neverthrow146.okAsync)([]);
180453
180714
  }
180454
- return import_neverthrow145.ResultAsync.combine(files.map((file2) => loadSuite(file2, xqaDirectory)));
180715
+ return import_neverthrow146.ResultAsync.combine(files.map((file2) => loadSuite(file2, xqaDirectory)));
180455
180716
  });
180456
180717
  }
180457
180718
 
@@ -180462,27 +180723,27 @@ function parseRepo(input) {
180462
180723
  const parts = input.split("/");
180463
180724
  const [owner, repo] = parts;
180464
180725
  if (parts.length !== 2 || owner === void 0 || owner === "" || repo === void 0 || repo === "") {
180465
- return (0, import_neverthrow146.err)({ type: "CLI_INVALID_ARG", message: `invalid --repo value: ${input}` });
180726
+ return (0, import_neverthrow147.err)({ type: "CLI_INVALID_ARG", message: `invalid --repo value: ${input}` });
180466
180727
  }
180467
- return (0, import_neverthrow146.ok)({ owner, repo });
180728
+ return (0, import_neverthrow147.ok)({ owner, repo });
180468
180729
  }
180469
180730
  function parsePrNumber3(input) {
180470
180731
  const parsed = Number.parseInt(input, 10);
180471
180732
  if (!Number.isFinite(parsed) || parsed <= 0) {
180472
- return (0, import_neverthrow146.err)({ type: "CLI_INVALID_ARG", message: `invalid --pr value: ${input}` });
180733
+ return (0, import_neverthrow147.err)({ type: "CLI_INVALID_ARG", message: `invalid --pr value: ${input}` });
180473
180734
  }
180474
- return (0, import_neverthrow146.ok)(parsed);
180735
+ return (0, import_neverthrow147.ok)(parsed);
180475
180736
  }
180476
180737
  function parseCliInputs(options) {
180477
180738
  const repoResult = parseRepo(options.repo);
180478
180739
  if (repoResult.isErr()) {
180479
- return (0, import_neverthrow146.err)(repoResult.error);
180740
+ return (0, import_neverthrow147.err)(repoResult.error);
180480
180741
  }
180481
180742
  const prResult = parsePrNumber3(options.pr);
180482
180743
  if (prResult.isErr()) {
180483
- return (0, import_neverthrow146.err)(prResult.error);
180744
+ return (0, import_neverthrow147.err)(prResult.error);
180484
180745
  }
180485
- return (0, import_neverthrow146.ok)({
180746
+ return (0, import_neverthrow147.ok)({
180486
180747
  owner: repoResult.value.owner,
180487
180748
  repo: repoResult.value.repo,
180488
180749
  prNumber: prResult.value
@@ -180490,23 +180751,23 @@ function parseCliInputs(options) {
180490
180751
  }
180491
180752
  function resolveGithubToken(context) {
180492
180753
  if (!context.rootConfig.agents.triager.enabled) {
180493
- return (0, import_neverthrow146.err)({ type: "TRIAGER_DISABLED" });
180754
+ return (0, import_neverthrow147.err)({ type: "TRIAGER_DISABLED" });
180494
180755
  }
180495
180756
  if (context.config.GITHUB_TOKEN === void 0) {
180496
- return (0, import_neverthrow146.err)({ type: "CONFIG_MISSING", key: "GITHUB_TOKEN" });
180757
+ return (0, import_neverthrow147.err)({ type: "CONFIG_MISSING", key: "GITHUB_TOKEN" });
180497
180758
  }
180498
- return (0, import_neverthrow146.ok)(context.config.GITHUB_TOKEN);
180759
+ return (0, import_neverthrow147.ok)(context.config.GITHUB_TOKEN);
180499
180760
  }
180500
180761
  function buildPartialInputs(options, context) {
180501
180762
  const tokenResult = resolveGithubToken(context);
180502
180763
  if (tokenResult.isErr()) {
180503
- return (0, import_neverthrow146.err)(tokenResult.error);
180764
+ return (0, import_neverthrow147.err)(tokenResult.error);
180504
180765
  }
180505
180766
  const parsed = parseCliInputs(options);
180506
180767
  if (parsed.isErr()) {
180507
- return (0, import_neverthrow146.err)(parsed.error);
180768
+ return (0, import_neverthrow147.err)(parsed.error);
180508
180769
  }
180509
- return (0, import_neverthrow146.ok)({
180770
+ return (0, import_neverthrow147.ok)({
180510
180771
  owner: parsed.value.owner,
180511
180772
  repo: parsed.value.repo,
180512
180773
  prNumber: parsed.value.prNumber,
@@ -180515,7 +180776,7 @@ function buildPartialInputs(options, context) {
180515
180776
  }
180516
180777
  function resolveSuitesDirectory2(options, context) {
180517
180778
  if (options.suitesDir !== void 0) {
180518
- return import_neverthrow146.ResultAsync.fromSafePromise(Promise.resolve(options.suitesDir));
180779
+ return import_neverthrow147.ResultAsync.fromSafePromise(Promise.resolve(options.suitesDir));
180519
180780
  }
180520
180781
  const cwd = process.cwd();
180521
180782
  return resolveCatalog({
@@ -180552,7 +180813,7 @@ function callTriager(options) {
180552
180813
  }
180553
180814
  function maybeApplyLabels(inputs, labels) {
180554
180815
  if (!inputs.applyLabels || labels.length === 0) {
180555
- return import_neverthrow146.ResultAsync.fromSafePromise(Promise.resolve(labels));
180816
+ return import_neverthrow147.ResultAsync.fromSafePromise(Promise.resolve(labels));
180556
180817
  }
180557
180818
  return applyTriageLabels({
180558
180819
  context: {
@@ -180565,7 +180826,7 @@ function maybeApplyLabels(inputs, labels) {
180565
180826
  }).map(() => labels).mapErr(toXqaError);
180566
180827
  }
180567
180828
  function runPipeline5(inputs) {
180568
- return import_neverthrow146.ResultAsync.combine([
180829
+ return import_neverthrow147.ResultAsync.combine([
180569
180830
  loadXqaSuites(inputs.suitesDir),
180570
180831
  fetchPullRequestDiff({
180571
180832
  owner: inputs.owner,
@@ -180632,7 +180893,7 @@ function registerUpdateCommand(program3) {
180632
180893
 
180633
180894
  // src/pid-lock.ts
180634
180895
  var import_node_fs24 = require("node:fs");
180635
- var import_neverthrow147 = __toESM(require_index_cjs(), 1);
180896
+ var import_neverthrow148 = __toESM(require_index_cjs(), 1);
180636
180897
  var PID_FILE = "/tmp/xqa.pid";
180637
180898
  var SIGINT_EXIT_CODE = 130;
180638
180899
  var SIGTERM_EXIT_CODE = 143;
@@ -180641,7 +180902,7 @@ var HARD_TIMEOUT_MS = 1e4;
180641
180902
  var cleanup = () => {
180642
180903
  (0, import_node_fs24.rmSync)(PID_FILE, { force: true });
180643
180904
  };
180644
- var checkProcessRunning = (0, import_neverthrow147.fromThrowable)(
180905
+ var checkProcessRunning = (0, import_neverthrow148.fromThrowable)(
180645
180906
  (pid) => {
180646
180907
  process.kill(pid, 0);
180647
180908
  return true;
@@ -180708,16 +180969,16 @@ function acquireLock() {
180708
180969
  function loadCliContext(signal) {
180709
180970
  const configResult = loadConfig2();
180710
180971
  if (configResult.isErr()) {
180711
- return (0, import_neverthrow148.err)(configResult.error);
180972
+ return (0, import_neverthrow149.err)(configResult.error);
180712
180973
  }
180713
180974
  const rootConfigResult = loadConfigSync({
180714
180975
  cwd: process.cwd(),
180715
180976
  schema: rootConfigSchema
180716
180977
  });
180717
180978
  if (rootConfigResult.isErr()) {
180718
- return (0, import_neverthrow148.err)(rootConfigResult.error);
180979
+ return (0, import_neverthrow149.err)(rootConfigResult.error);
180719
180980
  }
180720
- return (0, import_neverthrow148.ok)({
180981
+ return (0, import_neverthrow149.ok)({
180721
180982
  config: configResult.value,
180722
180983
  rootConfig: rootConfigResult.value,
180723
180984
  signal
@@ -180754,7 +181015,7 @@ function buildProgram(options) {
180754
181015
 
180755
181016
  // src/index.ts
180756
181017
  process.title = "xqa";
180757
- var version2 = `${"8.0.0"}${false ? ` (dev build +${"c960939"})` : ""}`;
181018
+ var version2 = `${"8.2.0"}${false ? ` (dev build +${"36aae72"})` : ""}`;
180758
181019
  var program2 = buildProgram({ version: version2 });
180759
181020
  void program2.parseAsync(process.argv);
180760
181021
  /*! Bundled license information: