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