@exodus/xqa 1.10.0 → 1.11.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 +31 -0
  2. package/dist/xqa.cjs +854 -527
  3. package/package.json +3 -3
package/dist/xqa.cjs CHANGED
@@ -1194,8 +1194,8 @@ var require_command = __commonJS({
1194
1194
  "../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/lib/command.js"(exports2) {
1195
1195
  var EventEmitter = require("node:events").EventEmitter;
1196
1196
  var childProcess = require("node:child_process");
1197
- var path23 = require("node:path");
1198
- var fs3 = require("node:fs");
1197
+ var path24 = require("node:path");
1198
+ var fs4 = require("node:fs");
1199
1199
  var process6 = require("node:process");
1200
1200
  var { Argument: Argument2, humanReadableArgName } = require_argument();
1201
1201
  var { CommanderError: CommanderError2 } = require_error();
@@ -1621,9 +1621,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
1621
1621
  if (fn) {
1622
1622
  this._exitCallback = fn;
1623
1623
  } else {
1624
- this._exitCallback = (err19) => {
1625
- if (err19.code !== "commander.executeSubCommandAsync") {
1626
- throw err19;
1624
+ this._exitCallback = (err20) => {
1625
+ if (err20.code !== "commander.executeSubCommandAsync") {
1626
+ throw err20;
1627
1627
  } else {
1628
1628
  }
1629
1629
  };
@@ -1699,12 +1699,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
1699
1699
  _callParseArg(target, value, previous, invalidArgumentMessage) {
1700
1700
  try {
1701
1701
  return target.parseArg(value, previous);
1702
- } catch (err19) {
1703
- if (err19.code === "commander.invalidArgument") {
1704
- const message = `${invalidArgumentMessage} ${err19.message}`;
1705
- this.error(message, { exitCode: err19.exitCode, code: err19.code });
1702
+ } catch (err20) {
1703
+ if (err20.code === "commander.invalidArgument") {
1704
+ const message = `${invalidArgumentMessage} ${err20.message}`;
1705
+ this.error(message, { exitCode: err20.exitCode, code: err20.code });
1706
1706
  }
1707
- throw err19;
1707
+ throw err20;
1708
1708
  }
1709
1709
  }
1710
1710
  /**
@@ -2189,7 +2189,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2189
2189
  * @param {string} subcommandName
2190
2190
  */
2191
2191
  _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
2192
- if (fs3.existsSync(executableFile)) return;
2192
+ if (fs4.existsSync(executableFile)) return;
2193
2193
  const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
2194
2194
  const executableMissing = `'${executableFile}' does not exist
2195
2195
  - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
@@ -2207,11 +2207,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
2207
2207
  let launchWithNode = false;
2208
2208
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
2209
2209
  function findFile(baseDir, baseName) {
2210
- const localBin = path23.resolve(baseDir, baseName);
2211
- if (fs3.existsSync(localBin)) return localBin;
2212
- if (sourceExt.includes(path23.extname(baseName))) return void 0;
2210
+ const localBin = path24.resolve(baseDir, baseName);
2211
+ if (fs4.existsSync(localBin)) return localBin;
2212
+ if (sourceExt.includes(path24.extname(baseName))) return void 0;
2213
2213
  const foundExt = sourceExt.find(
2214
- (ext) => fs3.existsSync(`${localBin}${ext}`)
2214
+ (ext) => fs4.existsSync(`${localBin}${ext}`)
2215
2215
  );
2216
2216
  if (foundExt) return `${localBin}${foundExt}`;
2217
2217
  return void 0;
@@ -2223,21 +2223,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
2223
2223
  if (this._scriptPath) {
2224
2224
  let resolvedScriptPath;
2225
2225
  try {
2226
- resolvedScriptPath = fs3.realpathSync(this._scriptPath);
2226
+ resolvedScriptPath = fs4.realpathSync(this._scriptPath);
2227
2227
  } catch {
2228
2228
  resolvedScriptPath = this._scriptPath;
2229
2229
  }
2230
- executableDir = path23.resolve(
2231
- path23.dirname(resolvedScriptPath),
2230
+ executableDir = path24.resolve(
2231
+ path24.dirname(resolvedScriptPath),
2232
2232
  executableDir
2233
2233
  );
2234
2234
  }
2235
2235
  if (executableDir) {
2236
2236
  let localFile = findFile(executableDir, executableFile);
2237
2237
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
2238
- const legacyName = path23.basename(
2238
+ const legacyName = path24.basename(
2239
2239
  this._scriptPath,
2240
- path23.extname(this._scriptPath)
2240
+ path24.extname(this._scriptPath)
2241
2241
  );
2242
2242
  if (legacyName !== this._name) {
2243
2243
  localFile = findFile(
@@ -2248,7 +2248,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2248
2248
  }
2249
2249
  executableFile = localFile || executableFile;
2250
2250
  }
2251
- launchWithNode = sourceExt.includes(path23.extname(executableFile));
2251
+ launchWithNode = sourceExt.includes(path24.extname(executableFile));
2252
2252
  let proc;
2253
2253
  if (process6.platform !== "win32") {
2254
2254
  if (launchWithNode) {
@@ -2293,14 +2293,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
2293
2293
  );
2294
2294
  }
2295
2295
  });
2296
- proc.on("error", (err19) => {
2297
- if (err19.code === "ENOENT") {
2296
+ proc.on("error", (err20) => {
2297
+ if (err20.code === "ENOENT") {
2298
2298
  this._checkForMissingExecutable(
2299
2299
  executableFile,
2300
2300
  executableDir,
2301
2301
  subcommand._name
2302
2302
  );
2303
- } else if (err19.code === "EACCES") {
2303
+ } else if (err20.code === "EACCES") {
2304
2304
  throw new Error(`'${executableFile}' not executable`);
2305
2305
  }
2306
2306
  if (!exitCallback) {
@@ -2311,7 +2311,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2311
2311
  "commander.executeSubCommandAsync",
2312
2312
  "(error)"
2313
2313
  );
2314
- wrappedError.nestedError = err19;
2314
+ wrappedError.nestedError = err20;
2315
2315
  exitCallback(wrappedError);
2316
2316
  }
2317
2317
  });
@@ -3163,7 +3163,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3163
3163
  * @return {Command}
3164
3164
  */
3165
3165
  nameFromFilename(filename) {
3166
- this._name = path23.basename(filename, path23.extname(filename));
3166
+ this._name = path24.basename(filename, path24.extname(filename));
3167
3167
  return this;
3168
3168
  }
3169
3169
  /**
@@ -3177,9 +3177,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
3177
3177
  * @param {string} [path]
3178
3178
  * @return {(string|null|Command)}
3179
3179
  */
3180
- executableDir(path24) {
3181
- if (path24 === void 0) return this._executableDir;
3182
- this._executableDir = path24;
3180
+ executableDir(path25) {
3181
+ if (path25 === void 0) return this._executableDir;
3182
+ this._executableDir = path25;
3183
3183
  return this;
3184
3184
  }
3185
3185
  /**
@@ -3539,11 +3539,11 @@ var require_index_cjs = __commonJS({
3539
3539
  try {
3540
3540
  step(g3[n3](v2));
3541
3541
  } catch (e3) {
3542
- settle(q4[0][3], e3);
3542
+ settle2(q4[0][3], e3);
3543
3543
  }
3544
3544
  }
3545
3545
  function step(r3) {
3546
- r3.value instanceof __await2 ? Promise.resolve(r3.value.v).then(fulfill, reject) : settle(q4[0][2], r3);
3546
+ r3.value instanceof __await2 ? Promise.resolve(r3.value.v).then(fulfill, reject) : settle2(q4[0][2], r3);
3547
3547
  }
3548
3548
  function fulfill(value) {
3549
3549
  resume("next", value);
@@ -3551,7 +3551,7 @@ var require_index_cjs = __commonJS({
3551
3551
  function reject(value) {
3552
3552
  resume("throw", value);
3553
3553
  }
3554
- function settle(f6, v2) {
3554
+ function settle2(f6, v2) {
3555
3555
  if (f6(v2), q4.shift(), q4.length) resume(q4[0][0], q4[0][1]);
3556
3556
  }
3557
3557
  }
@@ -3577,17 +3577,17 @@ var require_index_cjs = __commonJS({
3577
3577
  function verb(n3) {
3578
3578
  i3[n3] = o3[n3] && function(v2) {
3579
3579
  return new Promise(function(resolve, reject) {
3580
- v2 = o3[n3](v2), settle(resolve, reject, v2.done, v2.value);
3580
+ v2 = o3[n3](v2), settle2(resolve, reject, v2.done, v2.value);
3581
3581
  });
3582
3582
  };
3583
3583
  }
3584
- function settle(resolve, reject, d, v2) {
3584
+ function settle2(resolve, reject, d, v2) {
3585
3585
  Promise.resolve(v2).then(function(v3) {
3586
3586
  resolve({ value: v3, done: d });
3587
3587
  }, reject);
3588
3588
  }
3589
3589
  }
3590
- var ResultAsync12 = class _ResultAsync {
3590
+ var ResultAsync14 = class _ResultAsync {
3591
3591
  constructor(res) {
3592
3592
  this._promise = res;
3593
3593
  }
@@ -3688,8 +3688,8 @@ var require_index_cjs = __commonJS({
3688
3688
  return new Ok(res.value);
3689
3689
  })));
3690
3690
  }
3691
- match(ok20, _err) {
3692
- return this._promise.then((res) => res.match(ok20, _err));
3691
+ match(ok24, _err) {
3692
+ return this._promise.then((res) => res.match(ok24, _err));
3693
3693
  }
3694
3694
  unwrapOr(t) {
3695
3695
  return this._promise.then((res) => res.unwrapOr(t));
@@ -3726,19 +3726,19 @@ var require_index_cjs = __commonJS({
3726
3726
  }
3727
3727
  };
3728
3728
  function okAsync8(value) {
3729
- return new ResultAsync12(Promise.resolve(new Ok(value)));
3729
+ return new ResultAsync14(Promise.resolve(new Ok(value)));
3730
3730
  }
3731
- function errAsync8(err20) {
3732
- return new ResultAsync12(Promise.resolve(new Err(err20)));
3731
+ function errAsync8(err21) {
3732
+ return new ResultAsync14(Promise.resolve(new Err(err21)));
3733
3733
  }
3734
- var fromPromise = ResultAsync12.fromPromise;
3735
- var fromSafePromise2 = ResultAsync12.fromSafePromise;
3736
- var fromAsyncThrowable10 = ResultAsync12.fromThrowable;
3734
+ var fromPromise = ResultAsync14.fromPromise;
3735
+ var fromSafePromise2 = ResultAsync14.fromSafePromise;
3736
+ var fromAsyncThrowable10 = ResultAsync14.fromThrowable;
3737
3737
  var combineResultList = (resultList) => {
3738
- let acc = ok19([]);
3738
+ let acc = ok21([]);
3739
3739
  for (const result of resultList) {
3740
3740
  if (result.isErr()) {
3741
- acc = err19(result.error);
3741
+ acc = err20(result.error);
3742
3742
  break;
3743
3743
  } else {
3744
3744
  acc.map((list) => list.push(result.value));
@@ -3746,30 +3746,30 @@ var require_index_cjs = __commonJS({
3746
3746
  }
3747
3747
  return acc;
3748
3748
  };
3749
- var combineResultAsyncList = (asyncResultList) => ResultAsync12.fromSafePromise(Promise.all(asyncResultList)).andThen(combineResultList);
3749
+ var combineResultAsyncList = (asyncResultList) => ResultAsync14.fromSafePromise(Promise.all(asyncResultList)).andThen(combineResultList);
3750
3750
  var combineResultListWithAllErrors = (resultList) => {
3751
- let acc = ok19([]);
3751
+ let acc = ok21([]);
3752
3752
  for (const result of resultList) {
3753
3753
  if (result.isErr() && acc.isErr()) {
3754
3754
  acc.error.push(result.error);
3755
3755
  } else if (result.isErr() && acc.isOk()) {
3756
- acc = err19([result.error]);
3756
+ acc = err20([result.error]);
3757
3757
  } else if (result.isOk() && acc.isOk()) {
3758
3758
  acc.value.push(result.value);
3759
3759
  }
3760
3760
  }
3761
3761
  return acc;
3762
3762
  };
3763
- var combineResultAsyncListWithAllErrors = (asyncResultList) => ResultAsync12.fromSafePromise(Promise.all(asyncResultList)).andThen(combineResultListWithAllErrors);
3763
+ var combineResultAsyncListWithAllErrors = (asyncResultList) => ResultAsync14.fromSafePromise(Promise.all(asyncResultList)).andThen(combineResultListWithAllErrors);
3764
3764
  exports2.Result = void 0;
3765
3765
  (function(Result3) {
3766
3766
  function fromThrowable16(fn, errorFn) {
3767
3767
  return (...args) => {
3768
3768
  try {
3769
3769
  const result = fn(...args);
3770
- return ok19(result);
3770
+ return ok21(result);
3771
3771
  } catch (e3) {
3772
- return err19(errorFn ? errorFn(e3) : e3);
3772
+ return err20(errorFn ? errorFn(e3) : e3);
3773
3773
  }
3774
3774
  };
3775
3775
  }
@@ -3783,16 +3783,16 @@ var require_index_cjs = __commonJS({
3783
3783
  }
3784
3784
  Result3.combineWithAllErrors = combineWithAllErrors;
3785
3785
  })(exports2.Result || (exports2.Result = {}));
3786
- function ok19(value) {
3786
+ function ok21(value) {
3787
3787
  return new Ok(value);
3788
3788
  }
3789
- function err19(err20) {
3790
- return new Err(err20);
3789
+ function err20(err21) {
3790
+ return new Err(err21);
3791
3791
  }
3792
3792
  function safeTry(body) {
3793
3793
  const n3 = body().next();
3794
3794
  if (n3 instanceof Promise) {
3795
- return new ResultAsync12(n3.then((r3) => r3.value));
3795
+ return new ResultAsync14(n3.then((r3) => r3.value));
3796
3796
  }
3797
3797
  return n3.value;
3798
3798
  }
@@ -3807,11 +3807,11 @@ var require_index_cjs = __commonJS({
3807
3807
  return !this.isOk();
3808
3808
  }
3809
3809
  map(f6) {
3810
- return ok19(f6(this.value));
3810
+ return ok21(f6(this.value));
3811
3811
  }
3812
3812
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
3813
3813
  mapErr(_f) {
3814
- return ok19(this.value);
3814
+ return ok21(this.value);
3815
3815
  }
3816
3816
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
3817
3817
  andThen(f6) {
@@ -3826,14 +3826,14 @@ var require_index_cjs = __commonJS({
3826
3826
  f6(this.value);
3827
3827
  } catch (e3) {
3828
3828
  }
3829
- return ok19(this.value);
3829
+ return ok21(this.value);
3830
3830
  }
3831
3831
  orTee(_f) {
3832
- return ok19(this.value);
3832
+ return ok21(this.value);
3833
3833
  }
3834
3834
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
3835
3835
  orElse(_f) {
3836
- return ok19(this.value);
3836
+ return ok21(this.value);
3837
3837
  }
3838
3838
  asyncAndThen(f6) {
3839
3839
  return f6(this.value);
@@ -3843,15 +3843,15 @@ var require_index_cjs = __commonJS({
3843
3843
  return f6(this.value).map(() => this.value);
3844
3844
  }
3845
3845
  asyncMap(f6) {
3846
- return ResultAsync12.fromSafePromise(f6(this.value));
3846
+ return ResultAsync14.fromSafePromise(f6(this.value));
3847
3847
  }
3848
3848
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
3849
3849
  unwrapOr(_v) {
3850
3850
  return this.value;
3851
3851
  }
3852
3852
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
3853
- match(ok20, _err) {
3854
- return ok20(this.value);
3853
+ match(ok24, _err) {
3854
+ return ok24(this.value);
3855
3855
  }
3856
3856
  safeUnwrap() {
3857
3857
  const value = this.value;
@@ -3882,27 +3882,27 @@ var require_index_cjs = __commonJS({
3882
3882
  }
3883
3883
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
3884
3884
  map(_f) {
3885
- return err19(this.error);
3885
+ return err20(this.error);
3886
3886
  }
3887
3887
  mapErr(f6) {
3888
- return err19(f6(this.error));
3888
+ return err20(f6(this.error));
3889
3889
  }
3890
3890
  andThrough(_f) {
3891
- return err19(this.error);
3891
+ return err20(this.error);
3892
3892
  }
3893
3893
  andTee(_f) {
3894
- return err19(this.error);
3894
+ return err20(this.error);
3895
3895
  }
3896
3896
  orTee(f6) {
3897
3897
  try {
3898
3898
  f6(this.error);
3899
3899
  } catch (e3) {
3900
3900
  }
3901
- return err19(this.error);
3901
+ return err20(this.error);
3902
3902
  }
3903
3903
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
3904
3904
  andThen(_f) {
3905
- return err19(this.error);
3905
+ return err20(this.error);
3906
3906
  }
3907
3907
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
3908
3908
  orElse(f6) {
@@ -3922,13 +3922,13 @@ var require_index_cjs = __commonJS({
3922
3922
  unwrapOr(v2) {
3923
3923
  return v2;
3924
3924
  }
3925
- match(_ok, err20) {
3926
- return err20(this.error);
3925
+ match(_ok, err21) {
3926
+ return err21(this.error);
3927
3927
  }
3928
3928
  safeUnwrap() {
3929
3929
  const error48 = this.error;
3930
3930
  return (function* () {
3931
- yield err19(error48);
3931
+ yield err20(error48);
3932
3932
  throw new Error("Do not use this generator out of `safeTry`");
3933
3933
  })();
3934
3934
  }
@@ -3947,14 +3947,14 @@ var require_index_cjs = __commonJS({
3947
3947
  var fromThrowable15 = exports2.Result.fromThrowable;
3948
3948
  exports2.Err = Err;
3949
3949
  exports2.Ok = Ok;
3950
- exports2.ResultAsync = ResultAsync12;
3951
- exports2.err = err19;
3950
+ exports2.ResultAsync = ResultAsync14;
3951
+ exports2.err = err20;
3952
3952
  exports2.errAsync = errAsync8;
3953
3953
  exports2.fromAsyncThrowable = fromAsyncThrowable10;
3954
3954
  exports2.fromPromise = fromPromise;
3955
3955
  exports2.fromSafePromise = fromSafePromise2;
3956
3956
  exports2.fromThrowable = fromThrowable15;
3957
- exports2.ok = ok19;
3957
+ exports2.ok = ok21;
3958
3958
  exports2.okAsync = okAsync8;
3959
3959
  exports2.safeTry = safeTry;
3960
3960
  }
@@ -5052,15 +5052,15 @@ var require_route = __commonJS({
5052
5052
  };
5053
5053
  }
5054
5054
  function wrapConversion(toModel, graph) {
5055
- const path23 = [graph[toModel].parent, toModel];
5055
+ const path24 = [graph[toModel].parent, toModel];
5056
5056
  let fn = conversions[graph[toModel].parent][toModel];
5057
5057
  let cur = graph[toModel].parent;
5058
5058
  while (graph[cur].parent) {
5059
- path23.unshift(graph[cur].parent);
5059
+ path24.unshift(graph[cur].parent);
5060
5060
  fn = link(conversions[graph[cur].parent][cur], fn);
5061
5061
  cur = graph[cur].parent;
5062
5062
  }
5063
- fn.conversion = path23;
5063
+ fn.conversion = path24;
5064
5064
  return fn;
5065
5065
  }
5066
5066
  module2.exports = function(fromModel) {
@@ -11116,13 +11116,13 @@ var require_lib2 = __commonJS({
11116
11116
  exports2.analyse = analyse;
11117
11117
  var detectFile = (filepath, opts = {}) => new Promise((resolve, reject) => {
11118
11118
  let fd;
11119
- const fs3 = (0, node_1.default)();
11120
- const handler = (err19, buffer) => {
11119
+ const fs4 = (0, node_1.default)();
11120
+ const handler = (err20, buffer) => {
11121
11121
  if (fd) {
11122
- fs3.closeSync(fd);
11122
+ fs4.closeSync(fd);
11123
11123
  }
11124
- if (err19) {
11125
- reject(err19);
11124
+ if (err20) {
11125
+ reject(err20);
11126
11126
  } else if (buffer) {
11127
11127
  resolve((0, exports2.detect)(buffer));
11128
11128
  } else {
@@ -11131,11 +11131,11 @@ var require_lib2 = __commonJS({
11131
11131
  };
11132
11132
  const sampleSize = (opts === null || opts === void 0 ? void 0 : opts.sampleSize) || 0;
11133
11133
  if (sampleSize > 0) {
11134
- fd = fs3.openSync(filepath, "r");
11134
+ fd = fs4.openSync(filepath, "r");
11135
11135
  let sample = Buffer.allocUnsafe(sampleSize);
11136
- fs3.read(fd, sample, 0, sampleSize, opts.offset, (err19, bytesRead) => {
11137
- if (err19) {
11138
- handler(err19, null);
11136
+ fs4.read(fd, sample, 0, sampleSize, opts.offset, (err20, bytesRead) => {
11137
+ if (err20) {
11138
+ handler(err20, null);
11139
11139
  } else {
11140
11140
  if (bytesRead < sampleSize) {
11141
11141
  sample = sample.subarray(0, bytesRead);
@@ -11145,22 +11145,22 @@ var require_lib2 = __commonJS({
11145
11145
  });
11146
11146
  return;
11147
11147
  }
11148
- fs3.readFile(filepath, handler);
11148
+ fs4.readFile(filepath, handler);
11149
11149
  });
11150
11150
  exports2.detectFile = detectFile;
11151
11151
  var detectFileSync = (filepath, opts = {}) => {
11152
- const fs3 = (0, node_1.default)();
11152
+ const fs4 = (0, node_1.default)();
11153
11153
  if (opts && opts.sampleSize) {
11154
- const fd = fs3.openSync(filepath, "r");
11154
+ const fd = fs4.openSync(filepath, "r");
11155
11155
  let sample = Buffer.allocUnsafe(opts.sampleSize);
11156
- const bytesRead = fs3.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
11156
+ const bytesRead = fs4.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
11157
11157
  if (bytesRead < opts.sampleSize) {
11158
11158
  sample = sample.subarray(0, bytesRead);
11159
11159
  }
11160
- fs3.closeSync(fd);
11160
+ fs4.closeSync(fd);
11161
11161
  return (0, exports2.detect)(sample);
11162
11162
  }
11163
- return (0, exports2.detect)(fs3.readFileSync(filepath));
11163
+ return (0, exports2.detect)(fs4.readFileSync(filepath));
11164
11164
  };
11165
11165
  exports2.detectFileSync = detectFileSync;
11166
11166
  exports2.default = {
@@ -15025,8 +15025,8 @@ var require_package = __commonJS({
15025
15025
  // ../../node_modules/.pnpm/dotenv@16.6.1/node_modules/dotenv/lib/main.js
15026
15026
  var require_main = __commonJS({
15027
15027
  "../../node_modules/.pnpm/dotenv@16.6.1/node_modules/dotenv/lib/main.js"(exports2, module2) {
15028
- var fs3 = require("fs");
15029
- var path23 = require("path");
15028
+ var fs4 = require("fs");
15029
+ var path24 = require("path");
15030
15030
  var os4 = require("os");
15031
15031
  var crypto = require("crypto");
15032
15032
  var packageJson = require_package();
@@ -15057,9 +15057,9 @@ var require_main = __commonJS({
15057
15057
  options.path = vaultPath;
15058
15058
  const result = DotenvModule.configDotenv(options);
15059
15059
  if (!result.parsed) {
15060
- const err19 = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
15061
- err19.code = "MISSING_DATA";
15062
- throw err19;
15060
+ const err20 = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
15061
+ err20.code = "MISSING_DATA";
15062
+ throw err20;
15063
15063
  }
15064
15064
  const keys = _dotenvKey(options).split(",");
15065
15065
  const length = keys.length;
@@ -15102,30 +15102,30 @@ var require_main = __commonJS({
15102
15102
  uri = new URL(dotenvKey);
15103
15103
  } catch (error48) {
15104
15104
  if (error48.code === "ERR_INVALID_URL") {
15105
- const err19 = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
15106
- err19.code = "INVALID_DOTENV_KEY";
15107
- throw err19;
15105
+ const err20 = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
15106
+ err20.code = "INVALID_DOTENV_KEY";
15107
+ throw err20;
15108
15108
  }
15109
15109
  throw error48;
15110
15110
  }
15111
15111
  const key = uri.password;
15112
15112
  if (!key) {
15113
- const err19 = new Error("INVALID_DOTENV_KEY: Missing key part");
15114
- err19.code = "INVALID_DOTENV_KEY";
15115
- throw err19;
15113
+ const err20 = new Error("INVALID_DOTENV_KEY: Missing key part");
15114
+ err20.code = "INVALID_DOTENV_KEY";
15115
+ throw err20;
15116
15116
  }
15117
15117
  const environment = uri.searchParams.get("environment");
15118
15118
  if (!environment) {
15119
- const err19 = new Error("INVALID_DOTENV_KEY: Missing environment part");
15120
- err19.code = "INVALID_DOTENV_KEY";
15121
- throw err19;
15119
+ const err20 = new Error("INVALID_DOTENV_KEY: Missing environment part");
15120
+ err20.code = "INVALID_DOTENV_KEY";
15121
+ throw err20;
15122
15122
  }
15123
15123
  const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
15124
15124
  const ciphertext = result.parsed[environmentKey];
15125
15125
  if (!ciphertext) {
15126
- const err19 = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
15127
- err19.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
15128
- throw err19;
15126
+ const err20 = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
15127
+ err20.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
15128
+ throw err20;
15129
15129
  }
15130
15130
  return { ciphertext, key };
15131
15131
  }
@@ -15134,7 +15134,7 @@ var require_main = __commonJS({
15134
15134
  if (options && options.path && options.path.length > 0) {
15135
15135
  if (Array.isArray(options.path)) {
15136
15136
  for (const filepath of options.path) {
15137
- if (fs3.existsSync(filepath)) {
15137
+ if (fs4.existsSync(filepath)) {
15138
15138
  possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
15139
15139
  }
15140
15140
  }
@@ -15142,15 +15142,15 @@ var require_main = __commonJS({
15142
15142
  possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
15143
15143
  }
15144
15144
  } else {
15145
- possibleVaultPath = path23.resolve(process.cwd(), ".env.vault");
15145
+ possibleVaultPath = path24.resolve(process.cwd(), ".env.vault");
15146
15146
  }
15147
- if (fs3.existsSync(possibleVaultPath)) {
15147
+ if (fs4.existsSync(possibleVaultPath)) {
15148
15148
  return possibleVaultPath;
15149
15149
  }
15150
15150
  return null;
15151
15151
  }
15152
15152
  function _resolveHome(envPath) {
15153
- return envPath[0] === "~" ? path23.join(os4.homedir(), envPath.slice(1)) : envPath;
15153
+ return envPath[0] === "~" ? path24.join(os4.homedir(), envPath.slice(1)) : envPath;
15154
15154
  }
15155
15155
  function _configVault(options) {
15156
15156
  const debug = Boolean(options && options.debug);
@@ -15167,7 +15167,7 @@ var require_main = __commonJS({
15167
15167
  return { parsed };
15168
15168
  }
15169
15169
  function configDotenv(options) {
15170
- const dotenvPath = path23.resolve(process.cwd(), ".env");
15170
+ const dotenvPath = path24.resolve(process.cwd(), ".env");
15171
15171
  let encoding = "utf8";
15172
15172
  const debug = Boolean(options && options.debug);
15173
15173
  const quiet = options && "quiet" in options ? options.quiet : true;
@@ -15191,13 +15191,13 @@ var require_main = __commonJS({
15191
15191
  }
15192
15192
  let lastError;
15193
15193
  const parsedAll = {};
15194
- for (const path24 of optionPaths) {
15194
+ for (const path25 of optionPaths) {
15195
15195
  try {
15196
- const parsed = DotenvModule.parse(fs3.readFileSync(path24, { encoding }));
15196
+ const parsed = DotenvModule.parse(fs4.readFileSync(path25, { encoding }));
15197
15197
  DotenvModule.populate(parsedAll, parsed, options);
15198
15198
  } catch (e3) {
15199
15199
  if (debug) {
15200
- _debug(`Failed to load ${path24} ${e3.message}`);
15200
+ _debug(`Failed to load ${path25} ${e3.message}`);
15201
15201
  }
15202
15202
  lastError = e3;
15203
15203
  }
@@ -15212,7 +15212,7 @@ var require_main = __commonJS({
15212
15212
  const shortPaths = [];
15213
15213
  for (const filePath of optionPaths) {
15214
15214
  try {
15215
- const relative = path23.relative(process.cwd(), filePath);
15215
+ const relative = path24.relative(process.cwd(), filePath);
15216
15216
  shortPaths.push(relative);
15217
15217
  } catch (e3) {
15218
15218
  if (debug) {
@@ -15255,13 +15255,13 @@ var require_main = __commonJS({
15255
15255
  const invalidKeyLength = error48.message === "Invalid key length";
15256
15256
  const decryptionFailed = error48.message === "Unsupported state or unable to authenticate data";
15257
15257
  if (isRange || invalidKeyLength) {
15258
- const err19 = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
15259
- err19.code = "INVALID_DOTENV_KEY";
15260
- throw err19;
15258
+ const err20 = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
15259
+ err20.code = "INVALID_DOTENV_KEY";
15260
+ throw err20;
15261
15261
  } else if (decryptionFailed) {
15262
- const err19 = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
15263
- err19.code = "DECRYPTION_FAILED";
15264
- throw err19;
15262
+ const err20 = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
15263
+ err20.code = "DECRYPTION_FAILED";
15264
+ throw err20;
15265
15265
  } else {
15266
15266
  throw error48;
15267
15267
  }
@@ -15271,9 +15271,9 @@ var require_main = __commonJS({
15271
15271
  const debug = Boolean(options && options.debug);
15272
15272
  const override = Boolean(options && options.override);
15273
15273
  if (typeof parsed !== "object") {
15274
- const err19 = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
15275
- err19.code = "OBJECT_REQUIRED";
15276
- throw err19;
15274
+ const err20 = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
15275
+ err20.code = "OBJECT_REQUIRED";
15276
+ throw err20;
15277
15277
  }
15278
15278
  for (const key of Object.keys(parsed)) {
15279
15279
  if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
@@ -15384,7 +15384,7 @@ var require_path = __commonJS({
15384
15384
  Object.defineProperty(exports2, "__esModule", { value: true });
15385
15385
  exports2.convertPosixPathToPattern = exports2.convertWindowsPathToPattern = exports2.convertPathToPattern = exports2.escapePosixPath = exports2.escapeWindowsPath = exports2.escape = exports2.removeLeadingDotSegment = exports2.makeAbsolute = exports2.unixify = void 0;
15386
15386
  var os4 = require("os");
15387
- var path23 = require("path");
15387
+ var path24 = require("path");
15388
15388
  var IS_WINDOWS_PLATFORM = os4.platform() === "win32";
15389
15389
  var LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2;
15390
15390
  var POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
@@ -15396,7 +15396,7 @@ var require_path = __commonJS({
15396
15396
  }
15397
15397
  exports2.unixify = unixify;
15398
15398
  function makeAbsolute(cwd, filepath) {
15399
- return path23.resolve(cwd, filepath);
15399
+ return path24.resolve(cwd, filepath);
15400
15400
  }
15401
15401
  exports2.makeAbsolute = makeAbsolute;
15402
15402
  function removeLeadingDotSegment(entry) {
@@ -16693,7 +16693,7 @@ var require_braces = __commonJS({
16693
16693
  var require_constants2 = __commonJS({
16694
16694
  "../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/constants.js"(exports2, module2) {
16695
16695
  "use strict";
16696
- var path23 = require("path");
16696
+ var path24 = require("path");
16697
16697
  var WIN_SLASH = "\\\\/";
16698
16698
  var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
16699
16699
  var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
@@ -16867,7 +16867,7 @@ var require_constants2 = __commonJS({
16867
16867
  /* | */
16868
16868
  CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
16869
16869
  /* \uFEFF */
16870
- SEP: path23.sep,
16870
+ SEP: path24.sep,
16871
16871
  /**
16872
16872
  * Create EXTGLOB_CHARS
16873
16873
  */
@@ -16894,7 +16894,7 @@ var require_constants2 = __commonJS({
16894
16894
  var require_utils3 = __commonJS({
16895
16895
  "../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/utils.js"(exports2) {
16896
16896
  "use strict";
16897
- var path23 = require("path");
16897
+ var path24 = require("path");
16898
16898
  var win32 = process.platform === "win32";
16899
16899
  var {
16900
16900
  REGEX_BACKSLASH,
@@ -16923,7 +16923,7 @@ var require_utils3 = __commonJS({
16923
16923
  if (options && typeof options.windows === "boolean") {
16924
16924
  return options.windows;
16925
16925
  }
16926
- return win32 === true || path23.sep === "\\";
16926
+ return win32 === true || path24.sep === "\\";
16927
16927
  };
16928
16928
  exports2.escapeLast = (input, char, lastIdx) => {
16929
16929
  const idx = input.lastIndexOf(char, lastIdx);
@@ -18287,7 +18287,7 @@ var require_parse2 = __commonJS({
18287
18287
  var require_picomatch = __commonJS({
18288
18288
  "../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/picomatch.js"(exports2, module2) {
18289
18289
  "use strict";
18290
- var path23 = require("path");
18290
+ var path24 = require("path");
18291
18291
  var scan = require_scan();
18292
18292
  var parse3 = require_parse2();
18293
18293
  var utils = require_utils3();
@@ -18372,7 +18372,7 @@ var require_picomatch = __commonJS({
18372
18372
  };
18373
18373
  picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
18374
18374
  const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
18375
- return regex.test(path23.basename(input));
18375
+ return regex.test(path24.basename(input));
18376
18376
  };
18377
18377
  picomatch.isMatch = (str2, patterns, options) => picomatch(patterns, options)(str2);
18378
18378
  picomatch.parse = (pattern, options) => {
@@ -18414,8 +18414,8 @@ var require_picomatch = __commonJS({
18414
18414
  try {
18415
18415
  const opts = options || {};
18416
18416
  return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
18417
- } catch (err19) {
18418
- if (options && options.debug === true) throw err19;
18417
+ } catch (err20) {
18418
+ if (options && options.debug === true) throw err20;
18419
18419
  return /$^/;
18420
18420
  }
18421
18421
  };
@@ -18599,7 +18599,7 @@ var require_pattern = __commonJS({
18599
18599
  "use strict";
18600
18600
  Object.defineProperty(exports2, "__esModule", { value: true });
18601
18601
  exports2.isAbsolute = exports2.partitionAbsoluteAndRelative = exports2.removeDuplicateSlashes = exports2.matchAny = exports2.convertPatternsToRe = exports2.makeRe = exports2.getPatternParts = exports2.expandBraceExpansion = exports2.expandPatternsWithBraceExpansion = exports2.isAffectDepthOfReadingPattern = exports2.endsWithSlashGlobStar = exports2.hasGlobStar = exports2.getBaseDirectory = exports2.isPatternRelatedToParentDirectory = exports2.getPatternsOutsideCurrentDirectory = exports2.getPatternsInsideCurrentDirectory = exports2.getPositivePatterns = exports2.getNegativePatterns = exports2.isPositivePattern = exports2.isNegativePattern = exports2.convertToNegativePattern = exports2.convertToPositivePattern = exports2.isDynamicPattern = exports2.isStaticPattern = void 0;
18602
- var path23 = require("path");
18602
+ var path24 = require("path");
18603
18603
  var globParent = require_glob_parent();
18604
18604
  var micromatch = require_micromatch();
18605
18605
  var GLOBSTAR = "**";
@@ -18694,7 +18694,7 @@ var require_pattern = __commonJS({
18694
18694
  }
18695
18695
  exports2.endsWithSlashGlobStar = endsWithSlashGlobStar;
18696
18696
  function isAffectDepthOfReadingPattern(pattern) {
18697
- const basename = path23.basename(pattern);
18697
+ const basename = path24.basename(pattern);
18698
18698
  return endsWithSlashGlobStar(pattern) || isStaticPattern(basename);
18699
18699
  }
18700
18700
  exports2.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
@@ -18752,7 +18752,7 @@ var require_pattern = __commonJS({
18752
18752
  }
18753
18753
  exports2.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
18754
18754
  function isAbsolute(pattern) {
18755
- return path23.isAbsolute(pattern);
18755
+ return path24.isAbsolute(pattern);
18756
18756
  }
18757
18757
  exports2.isAbsolute = isAbsolute;
18758
18758
  }
@@ -18822,8 +18822,8 @@ var require_merge2 = __commonJS({
18822
18822
  }
18823
18823
  next();
18824
18824
  }
18825
- function onerror(err19) {
18826
- mergedStream.emit("error", err19);
18825
+ function onerror(err20) {
18826
+ mergedStream.emit("error", err20);
18827
18827
  }
18828
18828
  if (stream._readableState.endEmitted) {
18829
18829
  return next();
@@ -18927,10 +18927,10 @@ var require_utils4 = __commonJS({
18927
18927
  exports2.array = array2;
18928
18928
  var errno = require_errno();
18929
18929
  exports2.errno = errno;
18930
- var fs3 = require_fs();
18931
- exports2.fs = fs3;
18932
- var path23 = require_path();
18933
- exports2.path = path23;
18930
+ var fs4 = require_fs();
18931
+ exports2.fs = fs4;
18932
+ var path24 = require_path();
18933
+ exports2.path = path24;
18934
18934
  var pattern = require_pattern();
18935
18935
  exports2.pattern = pattern;
18936
18936
  var stream = require_stream();
@@ -19042,8 +19042,8 @@ var require_async = __commonJS({
19042
19042
  "use strict";
19043
19043
  Object.defineProperty(exports2, "__esModule", { value: true });
19044
19044
  exports2.read = void 0;
19045
- function read(path23, settings, callback) {
19046
- settings.fs.lstat(path23, (lstatError, lstat) => {
19045
+ function read(path24, settings, callback) {
19046
+ settings.fs.lstat(path24, (lstatError, lstat) => {
19047
19047
  if (lstatError !== null) {
19048
19048
  callFailureCallback(callback, lstatError);
19049
19049
  return;
@@ -19052,7 +19052,7 @@ var require_async = __commonJS({
19052
19052
  callSuccessCallback(callback, lstat);
19053
19053
  return;
19054
19054
  }
19055
- settings.fs.stat(path23, (statError, stat2) => {
19055
+ settings.fs.stat(path24, (statError, stat2) => {
19056
19056
  if (statError !== null) {
19057
19057
  if (settings.throwErrorOnBrokenSymbolicLink) {
19058
19058
  callFailureCallback(callback, statError);
@@ -19084,13 +19084,13 @@ var require_sync = __commonJS({
19084
19084
  "use strict";
19085
19085
  Object.defineProperty(exports2, "__esModule", { value: true });
19086
19086
  exports2.read = void 0;
19087
- function read(path23, settings) {
19088
- const lstat = settings.fs.lstatSync(path23);
19087
+ function read(path24, settings) {
19088
+ const lstat = settings.fs.lstatSync(path24);
19089
19089
  if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
19090
19090
  return lstat;
19091
19091
  }
19092
19092
  try {
19093
- const stat2 = settings.fs.statSync(path23);
19093
+ const stat2 = settings.fs.statSync(path24);
19094
19094
  if (settings.markSymbolicLink) {
19095
19095
  stat2.isSymbolicLink = () => true;
19096
19096
  }
@@ -19112,12 +19112,12 @@ var require_fs2 = __commonJS({
19112
19112
  "use strict";
19113
19113
  Object.defineProperty(exports2, "__esModule", { value: true });
19114
19114
  exports2.createFileSystemAdapter = exports2.FILE_SYSTEM_ADAPTER = void 0;
19115
- var fs3 = require("fs");
19115
+ var fs4 = require("fs");
19116
19116
  exports2.FILE_SYSTEM_ADAPTER = {
19117
- lstat: fs3.lstat,
19118
- stat: fs3.stat,
19119
- lstatSync: fs3.lstatSync,
19120
- statSync: fs3.statSync
19117
+ lstat: fs4.lstat,
19118
+ stat: fs4.stat,
19119
+ lstatSync: fs4.lstatSync,
19120
+ statSync: fs4.statSync
19121
19121
  };
19122
19122
  function createFileSystemAdapter(fsMethods) {
19123
19123
  if (fsMethods === void 0) {
@@ -19134,12 +19134,12 @@ var require_settings = __commonJS({
19134
19134
  "../../node_modules/.pnpm/@nodelib+fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/settings.js"(exports2) {
19135
19135
  "use strict";
19136
19136
  Object.defineProperty(exports2, "__esModule", { value: true });
19137
- var fs3 = require_fs2();
19137
+ var fs4 = require_fs2();
19138
19138
  var Settings = class {
19139
19139
  constructor(_options = {}) {
19140
19140
  this._options = _options;
19141
19141
  this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true);
19142
- this.fs = fs3.createFileSystemAdapter(this._options.fs);
19142
+ this.fs = fs4.createFileSystemAdapter(this._options.fs);
19143
19143
  this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false);
19144
19144
  this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
19145
19145
  }
@@ -19161,17 +19161,17 @@ var require_out = __commonJS({
19161
19161
  var sync = require_sync();
19162
19162
  var settings_1 = require_settings();
19163
19163
  exports2.Settings = settings_1.default;
19164
- function stat2(path23, optionsOrSettingsOrCallback, callback) {
19164
+ function stat2(path24, optionsOrSettingsOrCallback, callback) {
19165
19165
  if (typeof optionsOrSettingsOrCallback === "function") {
19166
- async.read(path23, getSettings(), optionsOrSettingsOrCallback);
19166
+ async.read(path24, getSettings(), optionsOrSettingsOrCallback);
19167
19167
  return;
19168
19168
  }
19169
- async.read(path23, getSettings(optionsOrSettingsOrCallback), callback);
19169
+ async.read(path24, getSettings(optionsOrSettingsOrCallback), callback);
19170
19170
  }
19171
19171
  exports2.stat = stat2;
19172
- function statSync2(path23, optionsOrSettings) {
19172
+ function statSync2(path24, optionsOrSettings) {
19173
19173
  const settings = getSettings(optionsOrSettings);
19174
- return sync.read(path23, settings);
19174
+ return sync.read(path24, settings);
19175
19175
  }
19176
19176
  exports2.statSync = statSync2;
19177
19177
  function getSettings(settingsOrOptions = {}) {
@@ -19187,8 +19187,8 @@ var require_out = __commonJS({
19187
19187
  var require_queue_microtask = __commonJS({
19188
19188
  "../../node_modules/.pnpm/queue-microtask@1.2.3/node_modules/queue-microtask/index.js"(exports2, module2) {
19189
19189
  var promise2;
19190
- module2.exports = typeof queueMicrotask === "function" ? queueMicrotask.bind(typeof window !== "undefined" ? window : global) : (cb2) => (promise2 || (promise2 = Promise.resolve())).then(cb2).catch((err19) => setTimeout(() => {
19191
- throw err19;
19190
+ module2.exports = typeof queueMicrotask === "function" ? queueMicrotask.bind(typeof window !== "undefined" ? window : global) : (cb2) => (promise2 || (promise2 = Promise.resolve())).then(cb2).catch((err20) => setTimeout(() => {
19191
+ throw err20;
19192
19192
  }, 0));
19193
19193
  }
19194
19194
  });
@@ -19209,32 +19209,32 @@ var require_run_parallel = __commonJS({
19209
19209
  results = {};
19210
19210
  pending = keys.length;
19211
19211
  }
19212
- function done(err19) {
19212
+ function done(err20) {
19213
19213
  function end() {
19214
- if (cb2) cb2(err19, results);
19214
+ if (cb2) cb2(err20, results);
19215
19215
  cb2 = null;
19216
19216
  }
19217
19217
  if (isSync) queueMicrotask2(end);
19218
19218
  else end();
19219
19219
  }
19220
- function each(i3, err19, result) {
19220
+ function each(i3, err20, result) {
19221
19221
  results[i3] = result;
19222
- if (--pending === 0 || err19) {
19223
- done(err19);
19222
+ if (--pending === 0 || err20) {
19223
+ done(err20);
19224
19224
  }
19225
19225
  }
19226
19226
  if (!pending) {
19227
19227
  done(null);
19228
19228
  } else if (keys) {
19229
19229
  keys.forEach(function(key) {
19230
- tasks[key](function(err19, result) {
19231
- each(key, err19, result);
19230
+ tasks[key](function(err20, result) {
19231
+ each(key, err20, result);
19232
19232
  });
19233
19233
  });
19234
19234
  } else {
19235
19235
  tasks.forEach(function(task, i3) {
19236
- task(function(err19, result) {
19237
- each(i3, err19, result);
19236
+ task(function(err20, result) {
19237
+ each(i3, err20, result);
19238
19238
  });
19239
19239
  });
19240
19240
  }
@@ -19294,8 +19294,8 @@ var require_utils5 = __commonJS({
19294
19294
  "use strict";
19295
19295
  Object.defineProperty(exports2, "__esModule", { value: true });
19296
19296
  exports2.fs = void 0;
19297
- var fs3 = require_fs3();
19298
- exports2.fs = fs3;
19297
+ var fs4 = require_fs3();
19298
+ exports2.fs = fs4;
19299
19299
  }
19300
19300
  });
19301
19301
 
@@ -19387,16 +19387,16 @@ var require_async2 = __commonJS({
19387
19387
  return;
19388
19388
  }
19389
19389
  const tasks = names.map((name) => {
19390
- const path23 = common3.joinPathSegments(directory, name, settings.pathSegmentSeparator);
19390
+ const path24 = common3.joinPathSegments(directory, name, settings.pathSegmentSeparator);
19391
19391
  return (done) => {
19392
- fsStat.stat(path23, settings.fsStatSettings, (error48, stats) => {
19392
+ fsStat.stat(path24, settings.fsStatSettings, (error48, stats) => {
19393
19393
  if (error48 !== null) {
19394
19394
  done(error48);
19395
19395
  return;
19396
19396
  }
19397
19397
  const entry = {
19398
19398
  name,
19399
- path: path23,
19399
+ path: path24,
19400
19400
  dirent: utils.fs.createDirentFromStats(name, stats)
19401
19401
  };
19402
19402
  if (settings.stats) {
@@ -19490,14 +19490,14 @@ var require_fs4 = __commonJS({
19490
19490
  "use strict";
19491
19491
  Object.defineProperty(exports2, "__esModule", { value: true });
19492
19492
  exports2.createFileSystemAdapter = exports2.FILE_SYSTEM_ADAPTER = void 0;
19493
- var fs3 = require("fs");
19493
+ var fs4 = require("fs");
19494
19494
  exports2.FILE_SYSTEM_ADAPTER = {
19495
- lstat: fs3.lstat,
19496
- stat: fs3.stat,
19497
- lstatSync: fs3.lstatSync,
19498
- statSync: fs3.statSync,
19499
- readdir: fs3.readdir,
19500
- readdirSync: fs3.readdirSync
19495
+ lstat: fs4.lstat,
19496
+ stat: fs4.stat,
19497
+ lstatSync: fs4.lstatSync,
19498
+ statSync: fs4.statSync,
19499
+ readdir: fs4.readdir,
19500
+ readdirSync: fs4.readdirSync
19501
19501
  };
19502
19502
  function createFileSystemAdapter(fsMethods) {
19503
19503
  if (fsMethods === void 0) {
@@ -19514,15 +19514,15 @@ var require_settings2 = __commonJS({
19514
19514
  "../../node_modules/.pnpm/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/settings.js"(exports2) {
19515
19515
  "use strict";
19516
19516
  Object.defineProperty(exports2, "__esModule", { value: true });
19517
- var path23 = require("path");
19517
+ var path24 = require("path");
19518
19518
  var fsStat = require_out();
19519
- var fs3 = require_fs4();
19519
+ var fs4 = require_fs4();
19520
19520
  var Settings = class {
19521
19521
  constructor(_options = {}) {
19522
19522
  this._options = _options;
19523
19523
  this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
19524
- this.fs = fs3.createFileSystemAdapter(this._options.fs);
19525
- this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path23.sep);
19524
+ this.fs = fs4.createFileSystemAdapter(this._options.fs);
19525
+ this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path24.sep);
19526
19526
  this.stats = this._getValue(this._options.stats, false);
19527
19527
  this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
19528
19528
  this.fsStatSettings = new fsStat.Settings({
@@ -19549,17 +19549,17 @@ var require_out2 = __commonJS({
19549
19549
  var sync = require_sync2();
19550
19550
  var settings_1 = require_settings2();
19551
19551
  exports2.Settings = settings_1.default;
19552
- function scandir(path23, optionsOrSettingsOrCallback, callback) {
19552
+ function scandir(path24, optionsOrSettingsOrCallback, callback) {
19553
19553
  if (typeof optionsOrSettingsOrCallback === "function") {
19554
- async.read(path23, getSettings(), optionsOrSettingsOrCallback);
19554
+ async.read(path24, getSettings(), optionsOrSettingsOrCallback);
19555
19555
  return;
19556
19556
  }
19557
- async.read(path23, getSettings(optionsOrSettingsOrCallback), callback);
19557
+ async.read(path24, getSettings(optionsOrSettingsOrCallback), callback);
19558
19558
  }
19559
19559
  exports2.scandir = scandir;
19560
- function scandirSync(path23, optionsOrSettings) {
19560
+ function scandirSync(path24, optionsOrSettings) {
19561
19561
  const settings = getSettings(optionsOrSettings);
19562
- return sync.read(path23, settings);
19562
+ return sync.read(path24, settings);
19563
19563
  }
19564
19564
  exports2.scandirSync = scandirSync;
19565
19565
  function getSettings(settingsOrOptions = {}) {
@@ -19623,8 +19623,8 @@ var require_queue = __commonJS({
19623
19623
  var errorHandler = null;
19624
19624
  var self2 = {
19625
19625
  push,
19626
- drain: noop2,
19627
- saturated: noop2,
19626
+ drain: noop3,
19627
+ saturated: noop3,
19628
19628
  pause,
19629
19629
  paused: false,
19630
19630
  get concurrency() {
@@ -19647,7 +19647,7 @@ var require_queue = __commonJS({
19647
19647
  length,
19648
19648
  getQueue,
19649
19649
  unshift,
19650
- empty: noop2,
19650
+ empty: noop3,
19651
19651
  kill,
19652
19652
  killAndDrain,
19653
19653
  error: error48,
@@ -19699,7 +19699,7 @@ var require_queue = __commonJS({
19699
19699
  current.context = context;
19700
19700
  current.release = release;
19701
19701
  current.value = value;
19702
- current.callback = done || noop2;
19702
+ current.callback = done || noop3;
19703
19703
  current.errorHandler = errorHandler;
19704
19704
  if (_running >= _concurrency || self2.paused) {
19705
19705
  if (queueTail) {
@@ -19720,7 +19720,7 @@ var require_queue = __commonJS({
19720
19720
  current.context = context;
19721
19721
  current.release = release;
19722
19722
  current.value = value;
19723
- current.callback = done || noop2;
19723
+ current.callback = done || noop3;
19724
19724
  current.errorHandler = errorHandler;
19725
19725
  if (_running >= _concurrency || self2.paused) {
19726
19726
  if (queueHead) {
@@ -19762,13 +19762,13 @@ var require_queue = __commonJS({
19762
19762
  function kill() {
19763
19763
  queueHead = null;
19764
19764
  queueTail = null;
19765
- self2.drain = noop2;
19765
+ self2.drain = noop3;
19766
19766
  }
19767
19767
  function killAndDrain() {
19768
19768
  queueHead = null;
19769
19769
  queueTail = null;
19770
19770
  self2.drain();
19771
- self2.drain = noop2;
19771
+ self2.drain = noop3;
19772
19772
  }
19773
19773
  function abort() {
19774
19774
  var current = queueHead;
@@ -19781,7 +19781,7 @@ var require_queue = __commonJS({
19781
19781
  var val = current.value;
19782
19782
  var context2 = current.context;
19783
19783
  current.value = null;
19784
- current.callback = noop2;
19784
+ current.callback = noop3;
19785
19785
  current.errorHandler = null;
19786
19786
  if (errorHandler2) {
19787
19787
  errorHandler2(new Error("abort"), val);
@@ -19790,32 +19790,32 @@ var require_queue = __commonJS({
19790
19790
  current.release(current);
19791
19791
  current = next;
19792
19792
  }
19793
- self2.drain = noop2;
19793
+ self2.drain = noop3;
19794
19794
  }
19795
19795
  function error48(handler) {
19796
19796
  errorHandler = handler;
19797
19797
  }
19798
19798
  }
19799
- function noop2() {
19799
+ function noop3() {
19800
19800
  }
19801
19801
  function Task3() {
19802
19802
  this.value = null;
19803
- this.callback = noop2;
19803
+ this.callback = noop3;
19804
19804
  this.next = null;
19805
- this.release = noop2;
19805
+ this.release = noop3;
19806
19806
  this.context = null;
19807
19807
  this.errorHandler = null;
19808
19808
  var self2 = this;
19809
- this.worked = function worked(err19, result) {
19809
+ this.worked = function worked(err20, result) {
19810
19810
  var callback = self2.callback;
19811
19811
  var errorHandler = self2.errorHandler;
19812
19812
  var val = self2.value;
19813
19813
  self2.value = null;
19814
- self2.callback = noop2;
19814
+ self2.callback = noop3;
19815
19815
  if (self2.errorHandler) {
19816
- errorHandler(err19, val);
19816
+ errorHandler(err20, val);
19817
19817
  }
19818
- callback.call(self2.context, err19, result);
19818
+ callback.call(self2.context, err20, result);
19819
19819
  self2.release(self2);
19820
19820
  };
19821
19821
  }
@@ -19839,28 +19839,28 @@ var require_queue = __commonJS({
19839
19839
  return queue;
19840
19840
  function push(value) {
19841
19841
  var p = new Promise(function(resolve, reject) {
19842
- pushCb(value, function(err19, result) {
19843
- if (err19) {
19844
- reject(err19);
19842
+ pushCb(value, function(err20, result) {
19843
+ if (err20) {
19844
+ reject(err20);
19845
19845
  return;
19846
19846
  }
19847
19847
  resolve(result);
19848
19848
  });
19849
19849
  });
19850
- p.catch(noop2);
19850
+ p.catch(noop3);
19851
19851
  return p;
19852
19852
  }
19853
19853
  function unshift(value) {
19854
19854
  var p = new Promise(function(resolve, reject) {
19855
- unshiftCb(value, function(err19, result) {
19856
- if (err19) {
19857
- reject(err19);
19855
+ unshiftCb(value, function(err20, result) {
19856
+ if (err20) {
19857
+ reject(err20);
19858
19858
  return;
19859
19859
  }
19860
19860
  resolve(result);
19861
19861
  });
19862
19862
  });
19863
- p.catch(noop2);
19863
+ p.catch(noop3);
19864
19864
  return p;
19865
19865
  }
19866
19866
  function drained() {
@@ -20206,7 +20206,7 @@ var require_settings3 = __commonJS({
20206
20206
  "../../node_modules/.pnpm/@nodelib+fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/settings.js"(exports2) {
20207
20207
  "use strict";
20208
20208
  Object.defineProperty(exports2, "__esModule", { value: true });
20209
- var path23 = require("path");
20209
+ var path24 = require("path");
20210
20210
  var fsScandir = require_out2();
20211
20211
  var Settings = class {
20212
20212
  constructor(_options = {}) {
@@ -20216,7 +20216,7 @@ var require_settings3 = __commonJS({
20216
20216
  this.deepFilter = this._getValue(this._options.deepFilter, null);
20217
20217
  this.entryFilter = this._getValue(this._options.entryFilter, null);
20218
20218
  this.errorFilter = this._getValue(this._options.errorFilter, null);
20219
- this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path23.sep);
20219
+ this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path24.sep);
20220
20220
  this.fsScandirSettings = new fsScandir.Settings({
20221
20221
  followSymbolicLinks: this._options.followSymbolicLinks,
20222
20222
  fs: this._options.fs,
@@ -20278,7 +20278,7 @@ var require_reader2 = __commonJS({
20278
20278
  "../../node_modules/.pnpm/fast-glob@3.3.3/node_modules/fast-glob/out/readers/reader.js"(exports2) {
20279
20279
  "use strict";
20280
20280
  Object.defineProperty(exports2, "__esModule", { value: true });
20281
- var path23 = require("path");
20281
+ var path24 = require("path");
20282
20282
  var fsStat = require_out();
20283
20283
  var utils = require_utils4();
20284
20284
  var Reader = class {
@@ -20291,7 +20291,7 @@ var require_reader2 = __commonJS({
20291
20291
  });
20292
20292
  }
20293
20293
  _getFullEntryPath(filepath) {
20294
- return path23.resolve(this._settings.cwd, filepath);
20294
+ return path24.resolve(this._settings.cwd, filepath);
20295
20295
  }
20296
20296
  _makeEntry(stats, pattern) {
20297
20297
  const entry = {
@@ -20707,7 +20707,7 @@ var require_provider = __commonJS({
20707
20707
  "../../node_modules/.pnpm/fast-glob@3.3.3/node_modules/fast-glob/out/providers/provider.js"(exports2) {
20708
20708
  "use strict";
20709
20709
  Object.defineProperty(exports2, "__esModule", { value: true });
20710
- var path23 = require("path");
20710
+ var path24 = require("path");
20711
20711
  var deep_1 = require_deep();
20712
20712
  var entry_1 = require_entry();
20713
20713
  var error_1 = require_error2();
@@ -20721,7 +20721,7 @@ var require_provider = __commonJS({
20721
20721
  this.entryTransformer = new entry_2.default(this._settings);
20722
20722
  }
20723
20723
  _getRootDirectory(task) {
20724
- return path23.resolve(this._settings.cwd, task.base);
20724
+ return path24.resolve(this._settings.cwd, task.base);
20725
20725
  }
20726
20726
  _getReaderOptions(task) {
20727
20727
  const basePath = task.base === "." ? "" : task.base;
@@ -20902,16 +20902,16 @@ var require_settings4 = __commonJS({
20902
20902
  "use strict";
20903
20903
  Object.defineProperty(exports2, "__esModule", { value: true });
20904
20904
  exports2.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
20905
- var fs3 = require("fs");
20905
+ var fs4 = require("fs");
20906
20906
  var os4 = require("os");
20907
20907
  var CPU_COUNT = Math.max(os4.cpus().length, 1);
20908
20908
  exports2.DEFAULT_FILE_SYSTEM_ADAPTER = {
20909
- lstat: fs3.lstat,
20910
- lstatSync: fs3.lstatSync,
20911
- stat: fs3.stat,
20912
- statSync: fs3.statSync,
20913
- readdir: fs3.readdir,
20914
- readdirSync: fs3.readdirSync
20909
+ lstat: fs4.lstat,
20910
+ lstatSync: fs4.lstatSync,
20911
+ stat: fs4.stat,
20912
+ statSync: fs4.statSync,
20913
+ readdir: fs4.readdir,
20914
+ readdirSync: fs4.readdirSync
20915
20915
  };
20916
20916
  var Settings = class {
20917
20917
  constructor(_options = {}) {
@@ -24368,9 +24368,9 @@ var tq = k((oq) => {
24368
24368
  });
24369
24369
  var sq = k((aq) => {
24370
24370
  Object.defineProperty(aq, "__esModule", { value: true });
24371
- var ok19 = Q$(), tk = { keyword: "not", schemaType: ["object", "boolean"], trackErrors: true, code($) {
24371
+ var ok21 = Q$(), tk = { keyword: "not", schemaType: ["object", "boolean"], trackErrors: true, code($) {
24372
24372
  let { gen: X, schema: J, it: Q } = $;
24373
- if ((0, ok19.alwaysValidSchema)(Q, J)) {
24373
+ if ((0, ok21.alwaysValidSchema)(Q, J)) {
24374
24374
  $.fail();
24375
24375
  return;
24376
24376
  }
@@ -38981,10 +38981,10 @@ function mergeDefs(...defs) {
38981
38981
  function cloneDef(schema2) {
38982
38982
  return mergeDefs(schema2._zod.def);
38983
38983
  }
38984
- function getElementAtPath(obj, path23) {
38985
- if (!path23)
38984
+ function getElementAtPath(obj, path24) {
38985
+ if (!path24)
38986
38986
  return obj;
38987
- return path23.reduce((acc, key) => acc?.[key], obj);
38987
+ return path24.reduce((acc, key) => acc?.[key], obj);
38988
38988
  }
38989
38989
  function promiseAllObject(promisesObj) {
38990
38990
  const keys = Object.keys(promisesObj);
@@ -39367,11 +39367,11 @@ function aborted(x, startIndex = 0) {
39367
39367
  }
39368
39368
  return false;
39369
39369
  }
39370
- function prefixIssues(path23, issues) {
39370
+ function prefixIssues(path24, issues) {
39371
39371
  return issues.map((iss) => {
39372
39372
  var _a3;
39373
39373
  (_a3 = iss).path ?? (_a3.path = []);
39374
- iss.path.unshift(path23);
39374
+ iss.path.unshift(path24);
39375
39375
  return iss;
39376
39376
  });
39377
39377
  }
@@ -39554,7 +39554,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
39554
39554
  }
39555
39555
  function treeifyError(error48, mapper = (issue2) => issue2.message) {
39556
39556
  const result = { errors: [] };
39557
- const processError = (error49, path23 = []) => {
39557
+ const processError = (error49, path24 = []) => {
39558
39558
  var _a3, _b2;
39559
39559
  for (const issue2 of error49.issues) {
39560
39560
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -39564,7 +39564,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
39564
39564
  } else if (issue2.code === "invalid_element") {
39565
39565
  processError({ issues: issue2.issues }, issue2.path);
39566
39566
  } else {
39567
- const fullpath = [...path23, ...issue2.path];
39567
+ const fullpath = [...path24, ...issue2.path];
39568
39568
  if (fullpath.length === 0) {
39569
39569
  result.errors.push(mapper(issue2));
39570
39570
  continue;
@@ -39596,8 +39596,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
39596
39596
  }
39597
39597
  function toDotPath(_path) {
39598
39598
  const segs = [];
39599
- const path23 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
39600
- for (const seg of path23) {
39599
+ const path24 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
39600
+ for (const seg of path24) {
39601
39601
  if (typeof seg === "number")
39602
39602
  segs.push(`[${seg}]`);
39603
39603
  else if (typeof seg === "symbol")
@@ -51574,13 +51574,13 @@ function resolveRef(ref, ctx) {
51574
51574
  if (!ref.startsWith("#")) {
51575
51575
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
51576
51576
  }
51577
- const path23 = ref.slice(1).split("/").filter(Boolean);
51578
- if (path23.length === 0) {
51577
+ const path24 = ref.slice(1).split("/").filter(Boolean);
51578
+ if (path24.length === 0) {
51579
51579
  return ctx.rootSchema;
51580
51580
  }
51581
51581
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
51582
- if (path23[0] === defsKey) {
51583
- const key = path23[1];
51582
+ if (path24[0] === defsKey) {
51583
+ const key = path24[1];
51584
51584
  if (!key || !ctx.defs[key]) {
51585
51585
  throw new Error(`Reference not found: ${ref}`);
51586
51586
  }
@@ -52604,16 +52604,21 @@ function captureScreenshot(udid = "booted") {
52604
52604
  );
52605
52605
  }
52606
52606
  function createScreenshotTool(udid = "booted") {
52607
- return _x("screenshot", "Take a screenshot of the current screen.", {}, async () => {
52608
- const result = await captureScreenshot(udid);
52609
- if (result.isErr()) {
52610
- return {
52611
- content: [{ type: "text", text: String(result.error.cause) }],
52612
- isError: true
52613
- };
52607
+ return _x(
52608
+ "screenshot",
52609
+ "Capture a screenshot of the current screen. Use for passive visual verification \u2014 confirming a screen transition occurred, loading finished, or an expected visual outcome is present \u2014 when you do not need element labels, tap coordinates, or accessibility attributes. Does not return a <screen_id>; cannot be used for stuck-loop detection or element-targeted assertions. Do not call this immediately before or after `view_ui` for the same state.",
52610
+ {},
52611
+ async () => {
52612
+ const result = await captureScreenshot(udid);
52613
+ if (result.isErr()) {
52614
+ return {
52615
+ content: [{ type: "text", text: String(result.error.cause) }],
52616
+ isError: true
52617
+ };
52618
+ }
52619
+ return { content: [{ type: "image", data: result.value, mimeType: "image/png" }] };
52614
52620
  }
52615
- return { content: [{ type: "image", data: result.value, mimeType: "image/png" }] };
52616
- });
52621
+ );
52617
52622
  }
52618
52623
  var screenshotTool = createScreenshotTool();
52619
52624
  var MIN_WAIT_SECONDS = 1;
@@ -54738,15 +54743,15 @@ async function makeRequest(url2, fetchOptions, fetchFn = fetch) {
54738
54743
  return response;
54739
54744
  }
54740
54745
  function handleResponseError(e3, url2) {
54741
- let err19 = e3;
54742
- if (err19.name === "AbortError") {
54743
- err19 = new GoogleGenerativeAIAbortError(`Request aborted when fetching ${url2.toString()}: ${e3.message}`);
54744
- err19.stack = e3.stack;
54746
+ let err20 = e3;
54747
+ if (err20.name === "AbortError") {
54748
+ err20 = new GoogleGenerativeAIAbortError(`Request aborted when fetching ${url2.toString()}: ${e3.message}`);
54749
+ err20.stack = e3.stack;
54745
54750
  } else if (!(e3 instanceof GoogleGenerativeAIFetchError || e3 instanceof GoogleGenerativeAIRequestInputError)) {
54746
- err19 = new GoogleGenerativeAIError(`Error fetching from ${url2.toString()}: ${e3.message}`);
54747
- err19.stack = e3.stack;
54751
+ err20 = new GoogleGenerativeAIError(`Error fetching from ${url2.toString()}: ${e3.message}`);
54752
+ err20.stack = e3.stack;
54748
54753
  }
54749
- throw err19;
54754
+ throw err20;
54750
54755
  }
54751
54756
  async function handleResponseNotOk(response, url2) {
54752
54757
  let message = "";
@@ -54912,11 +54917,11 @@ function __asyncGenerator(thisArg, _arguments, generator) {
54912
54917
  try {
54913
54918
  step(g3[n3](v2));
54914
54919
  } catch (e3) {
54915
- settle(q4[0][3], e3);
54920
+ settle2(q4[0][3], e3);
54916
54921
  }
54917
54922
  }
54918
54923
  function step(r3) {
54919
- r3.value instanceof __await ? Promise.resolve(r3.value.v).then(fulfill, reject) : settle(q4[0][2], r3);
54924
+ r3.value instanceof __await ? Promise.resolve(r3.value.v).then(fulfill, reject) : settle2(q4[0][2], r3);
54920
54925
  }
54921
54926
  function fulfill(value) {
54922
54927
  resume("next", value);
@@ -54924,7 +54929,7 @@ function __asyncGenerator(thisArg, _arguments, generator) {
54924
54929
  function reject(value) {
54925
54930
  resume("throw", value);
54926
54931
  }
54927
- function settle(f6, v2) {
54932
+ function settle2(f6, v2) {
54928
54933
  if (f6(v2), q4.shift(), q4.length) resume(q4[0][0], q4[0][1]);
54929
54934
  }
54930
54935
  }
@@ -54993,14 +54998,14 @@ function getResponseStream(inputStream) {
54993
54998
  }
54994
54999
  return pump();
54995
55000
  }).catch((e3) => {
54996
- let err19 = e3;
54997
- err19.stack = e3.stack;
54998
- if (err19.name === "AbortError") {
54999
- err19 = new GoogleGenerativeAIAbortError("Request aborted when reading from the stream");
55001
+ let err20 = e3;
55002
+ err20.stack = e3.stack;
55003
+ if (err20.name === "AbortError") {
55004
+ err20 = new GoogleGenerativeAIAbortError("Request aborted when reading from the stream");
55000
55005
  } else {
55001
- err19 = new GoogleGenerativeAIError("Error reading from the stream");
55006
+ err20 = new GoogleGenerativeAIError("Error reading from the stream");
55002
55007
  }
55003
- throw err19;
55008
+ throw err20;
55004
55009
  });
55005
55010
  }
55006
55011
  }
@@ -55596,15 +55601,15 @@ async function makeRequest2(url2, fetchOptions, fetchFn = fetch) {
55596
55601
  return response;
55597
55602
  }
55598
55603
  function handleResponseError2(e3, url2) {
55599
- let err19 = e3;
55600
- if (err19.name === "AbortError") {
55601
- err19 = new GoogleGenerativeAIAbortError2(`Request aborted when fetching ${url2.toString()}: ${e3.message}`);
55602
- err19.stack = e3.stack;
55604
+ let err20 = e3;
55605
+ if (err20.name === "AbortError") {
55606
+ err20 = new GoogleGenerativeAIAbortError2(`Request aborted when fetching ${url2.toString()}: ${e3.message}`);
55607
+ err20.stack = e3.stack;
55603
55608
  } else if (!(e3 instanceof GoogleGenerativeAIFetchError2 || e3 instanceof GoogleGenerativeAIRequestInputError2)) {
55604
- err19 = new GoogleGenerativeAIError2(`Error fetching from ${url2.toString()}: ${e3.message}`);
55605
- err19.stack = e3.stack;
55609
+ err20 = new GoogleGenerativeAIError2(`Error fetching from ${url2.toString()}: ${e3.message}`);
55610
+ err20.stack = e3.stack;
55606
55611
  }
55607
- throw err19;
55612
+ throw err20;
55608
55613
  }
55609
55614
  async function handleResponseNotOk2(response, url2) {
55610
55615
  let message = "";
@@ -55643,8 +55648,8 @@ var ServerRequestUrl = class {
55643
55648
  this.apiKey = apiKey;
55644
55649
  this.requestOptions = requestOptions;
55645
55650
  }
55646
- appendPath(path23) {
55647
- this._url.pathname = this._url.pathname + `/${path23}`;
55651
+ appendPath(path24) {
55652
+ this._url.pathname = this._url.pathname + `/${path24}`;
55648
55653
  }
55649
55654
  appendParam(key, value) {
55650
55655
  this._url.searchParams.append(key, value);
@@ -56200,34 +56205,34 @@ var uuid42 = function() {
56200
56205
  };
56201
56206
 
56202
56207
  // ../../node_modules/.pnpm/@anthropic-ai+sdk@0.87.0_zod@4.3.6/node_modules/@anthropic-ai/sdk/internal/errors.mjs
56203
- function isAbortError(err19) {
56204
- return typeof err19 === "object" && err19 !== null && // Spec-compliant fetch implementations
56205
- ("name" in err19 && err19.name === "AbortError" || // Expo fetch
56206
- "message" in err19 && String(err19.message).includes("FetchRequestCanceledException"));
56207
- }
56208
- var castToError = (err19) => {
56209
- if (err19 instanceof Error)
56210
- return err19;
56211
- if (typeof err19 === "object" && err19 !== null) {
56208
+ function isAbortError(err20) {
56209
+ return typeof err20 === "object" && err20 !== null && // Spec-compliant fetch implementations
56210
+ ("name" in err20 && err20.name === "AbortError" || // Expo fetch
56211
+ "message" in err20 && String(err20.message).includes("FetchRequestCanceledException"));
56212
+ }
56213
+ var castToError = (err20) => {
56214
+ if (err20 instanceof Error)
56215
+ return err20;
56216
+ if (typeof err20 === "object" && err20 !== null) {
56212
56217
  try {
56213
- if (Object.prototype.toString.call(err19) === "[object Error]") {
56214
- const error48 = new Error(err19.message, err19.cause ? { cause: err19.cause } : {});
56215
- if (err19.stack)
56216
- error48.stack = err19.stack;
56217
- if (err19.cause && !error48.cause)
56218
- error48.cause = err19.cause;
56219
- if (err19.name)
56220
- error48.name = err19.name;
56218
+ if (Object.prototype.toString.call(err20) === "[object Error]") {
56219
+ const error48 = new Error(err20.message, err20.cause ? { cause: err20.cause } : {});
56220
+ if (err20.stack)
56221
+ error48.stack = err20.stack;
56222
+ if (err20.cause && !error48.cause)
56223
+ error48.cause = err20.cause;
56224
+ if (err20.name)
56225
+ error48.name = err20.name;
56221
56226
  return error48;
56222
56227
  }
56223
56228
  } catch {
56224
56229
  }
56225
56230
  try {
56226
- return new Error(JSON.stringify(err19));
56231
+ return new Error(JSON.stringify(err20));
56227
56232
  } catch {
56228
56233
  }
56229
56234
  }
56230
- return new Error(err19);
56235
+ return new Error(err20);
56231
56236
  };
56232
56237
 
56233
56238
  // ../../node_modules/.pnpm/@anthropic-ai+sdk@0.87.0_zod@4.3.6/node_modules/@anthropic-ai/sdk/core/error.mjs
@@ -56357,7 +56362,7 @@ var validatePositiveInteger = (name, n3) => {
56357
56362
  var safeJSON = (text) => {
56358
56363
  try {
56359
56364
  return JSON.parse(text);
56360
- } catch (err19) {
56365
+ } catch (err20) {
56361
56366
  return void 0;
56362
56367
  }
56363
56368
  };
@@ -56921,8 +56926,8 @@ var Stream = class _Stream {
56921
56926
  return ctrl.close();
56922
56927
  const bytes = encodeUTF8(JSON.stringify(value) + "\n");
56923
56928
  ctrl.enqueue(bytes);
56924
- } catch (err19) {
56925
- ctrl.error(err19);
56929
+ } catch (err20) {
56930
+ ctrl.error(err20);
56926
56931
  }
56927
56932
  },
56928
56933
  async cancel() {
@@ -57470,12 +57475,12 @@ function encodeURIPath(str2) {
57470
57475
  return str2.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
57471
57476
  }
57472
57477
  var EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
57473
- var createPathTagFunction = (pathEncoder = encodeURIPath) => function path23(statics, ...params) {
57478
+ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path24(statics, ...params) {
57474
57479
  if (statics.length === 1)
57475
57480
  return statics[0];
57476
57481
  let postPath = false;
57477
57482
  const invalidSegments = [];
57478
- const path24 = statics.reduce((previousValue, currentValue, index) => {
57483
+ const path25 = statics.reduce((previousValue, currentValue, index) => {
57479
57484
  if (/[?#]/.test(currentValue)) {
57480
57485
  postPath = true;
57481
57486
  }
@@ -57492,7 +57497,7 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path23(sta
57492
57497
  }
57493
57498
  return previousValue + currentValue + (index === params.length ? "" : encoded);
57494
57499
  }, "");
57495
- const pathOnly = path24.split(/[?#]/, 1)[0];
57500
+ const pathOnly = path25.split(/[?#]/, 1)[0];
57496
57501
  const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
57497
57502
  let match;
57498
57503
  while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
@@ -57513,10 +57518,10 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path23(sta
57513
57518
  }, "");
57514
57519
  throw new AnthropicError(`Path parameters result in path with invalid segments:
57515
57520
  ${invalidSegments.map((e3) => e3.error).join("\n")}
57516
- ${path24}
57521
+ ${path25}
57517
57522
  ${underline}`);
57518
57523
  }
57519
- return path24;
57524
+ return path25;
57520
57525
  };
57521
57526
  var path4 = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
57522
57527
 
@@ -58829,8 +58834,8 @@ var BetaMessageStream = class _BetaMessageStream {
58829
58834
  if (jsonBuf) {
58830
58835
  try {
58831
58836
  newContent.input = partialParse(jsonBuf);
58832
- } catch (err19) {
58833
- const error48 = new AnthropicError(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${err19}. JSON: ${jsonBuf}`);
58837
+ } catch (err20) {
58838
+ const error48 = new AnthropicError(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${err20}. JSON: ${jsonBuf}`);
58834
58839
  __classPrivateFieldGet(this, _BetaMessageStream_handleError, "f").call(this, error48);
58835
58840
  }
58836
58841
  }
@@ -58892,17 +58897,17 @@ var BetaMessageStream = class _BetaMessageStream {
58892
58897
  }
58893
58898
  readQueue.length = 0;
58894
58899
  });
58895
- this.on("abort", (err19) => {
58900
+ this.on("abort", (err20) => {
58896
58901
  done = true;
58897
58902
  for (const reader of readQueue) {
58898
- reader.reject(err19);
58903
+ reader.reject(err20);
58899
58904
  }
58900
58905
  readQueue.length = 0;
58901
58906
  });
58902
- this.on("error", (err19) => {
58907
+ this.on("error", (err20) => {
58903
58908
  done = true;
58904
58909
  for (const reader of readQueue) {
58905
- reader.reject(err19);
58910
+ reader.reject(err20);
58906
58911
  }
58907
58912
  readQueue.length = 0;
58908
58913
  });
@@ -61145,17 +61150,17 @@ var MessageStream = class _MessageStream {
61145
61150
  }
61146
61151
  readQueue.length = 0;
61147
61152
  });
61148
- this.on("abort", (err19) => {
61153
+ this.on("abort", (err20) => {
61149
61154
  done = true;
61150
61155
  for (const reader of readQueue) {
61151
- reader.reject(err19);
61156
+ reader.reject(err20);
61152
61157
  }
61153
61158
  readQueue.length = 0;
61154
61159
  });
61155
- this.on("error", (err19) => {
61160
+ this.on("error", (err20) => {
61156
61161
  done = true;
61157
61162
  for (const reader of readQueue) {
61158
- reader.reject(err19);
61163
+ reader.reject(err20);
61159
61164
  }
61160
61165
  readQueue.length = 0;
61161
61166
  });
@@ -61604,9 +61609,9 @@ var BaseAnthropic = class {
61604
61609
  makeStatusError(status, error48, message, headers) {
61605
61610
  return APIError.generate(status, error48, message, headers);
61606
61611
  }
61607
- buildURL(path23, query, defaultBaseURL) {
61612
+ buildURL(path24, query, defaultBaseURL) {
61608
61613
  const baseURL = !__classPrivateFieldGet(this, _BaseAnthropic_instances, "m", _BaseAnthropic_baseURLOverridden).call(this) && defaultBaseURL || this.baseURL;
61609
- const url2 = isAbsoluteURL(path23) ? new URL(path23) : new URL(baseURL + (baseURL.endsWith("/") && path23.startsWith("/") ? path23.slice(1) : path23));
61614
+ const url2 = isAbsoluteURL(path24) ? new URL(path24) : new URL(baseURL + (baseURL.endsWith("/") && path24.startsWith("/") ? path24.slice(1) : path24));
61610
61615
  const defaultQuery = this.defaultQuery();
61611
61616
  const pathQuery = Object.fromEntries(url2.searchParams);
61612
61617
  if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
@@ -61638,24 +61643,24 @@ var BaseAnthropic = class {
61638
61643
  */
61639
61644
  async prepareRequest(request, { url: url2, options }) {
61640
61645
  }
61641
- get(path23, opts) {
61642
- return this.methodRequest("get", path23, opts);
61646
+ get(path24, opts) {
61647
+ return this.methodRequest("get", path24, opts);
61643
61648
  }
61644
- post(path23, opts) {
61645
- return this.methodRequest("post", path23, opts);
61649
+ post(path24, opts) {
61650
+ return this.methodRequest("post", path24, opts);
61646
61651
  }
61647
- patch(path23, opts) {
61648
- return this.methodRequest("patch", path23, opts);
61652
+ patch(path24, opts) {
61653
+ return this.methodRequest("patch", path24, opts);
61649
61654
  }
61650
- put(path23, opts) {
61651
- return this.methodRequest("put", path23, opts);
61655
+ put(path24, opts) {
61656
+ return this.methodRequest("put", path24, opts);
61652
61657
  }
61653
- delete(path23, opts) {
61654
- return this.methodRequest("delete", path23, opts);
61658
+ delete(path24, opts) {
61659
+ return this.methodRequest("delete", path24, opts);
61655
61660
  }
61656
- methodRequest(method, path23, opts) {
61661
+ methodRequest(method, path24, opts) {
61657
61662
  return this.request(Promise.resolve(opts).then((opts2) => {
61658
- return { method, path: path23, ...opts2 };
61663
+ return { method, path: path24, ...opts2 };
61659
61664
  }));
61660
61665
  }
61661
61666
  request(options, remainingRetries = null) {
@@ -61735,7 +61740,7 @@ var BaseAnthropic = class {
61735
61740
  }
61736
61741
  const retryMessage = shouldRetry ? `error; no more retries left` : `error; not retryable`;
61737
61742
  loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
61738
- const errText = await response.text().catch((err20) => castToError(err20).message);
61743
+ const errText = await response.text().catch((err21) => castToError(err21).message);
61739
61744
  const errJSON = safeJSON(errText);
61740
61745
  const errMessage = errJSON ? void 0 : errText;
61741
61746
  loggerFor(this).debug(`[${requestLogID}] response error (${retryMessage})`, formatRequestDetails({
@@ -61746,8 +61751,8 @@ var BaseAnthropic = class {
61746
61751
  message: errMessage,
61747
61752
  durationMs: Date.now() - startTime
61748
61753
  }));
61749
- const err19 = this.makeStatusError(response.status, errJSON, errMessage, response.headers);
61750
- throw err19;
61754
+ const err20 = this.makeStatusError(response.status, errJSON, errMessage, response.headers);
61755
+ throw err20;
61751
61756
  }
61752
61757
  loggerFor(this).info(responseInfo);
61753
61758
  loggerFor(this).debug(`[${requestLogID}] response start`, formatRequestDetails({
@@ -61759,8 +61764,8 @@ var BaseAnthropic = class {
61759
61764
  }));
61760
61765
  return { response, options, controller: controller2, requestLogID, retryOfRequestLogID, startTime };
61761
61766
  }
61762
- getAPIList(path23, Page2, opts) {
61763
- return this.requestAPIList(Page2, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path23, ...opts2 })) : { method: "get", path: path23, ...opts });
61767
+ getAPIList(path24, Page2, opts) {
61768
+ return this.requestAPIList(Page2, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path24, ...opts2 })) : { method: "get", path: path24, ...opts });
61764
61769
  }
61765
61770
  requestAPIList(Page2, options) {
61766
61771
  const request = this.makeRequest(options, null, void 0);
@@ -61848,8 +61853,8 @@ var BaseAnthropic = class {
61848
61853
  }
61849
61854
  async buildRequest(inputOptions, { retryCount = 0 } = {}) {
61850
61855
  const options = { ...inputOptions };
61851
- const { method, path: path23, query, defaultBaseURL } = options;
61852
- const url2 = this.buildURL(path23, query, defaultBaseURL);
61856
+ const { method, path: path24, query, defaultBaseURL } = options;
61857
+ const url2 = this.buildURL(path24, query, defaultBaseURL);
61853
61858
  if ("timeout" in options)
61854
61859
  validatePositiveInteger("timeout", options.timeout);
61855
61860
  options.timeout = options.timeout ?? this.timeout;
@@ -62224,7 +62229,7 @@ async function runFfmpeg(arguments_) {
62224
62229
  }
62225
62230
  function spawnRecorder(outputPath) {
62226
62231
  const safeMkdirSync = (0, import_neverthrow15.fromThrowable)(import_node_fs.mkdirSync, (cause) => cause);
62227
- const safeSpawn = (0, import_neverthrow15.fromThrowable)(
62232
+ const safeSpawn2 = (0, import_neverthrow15.fromThrowable)(
62228
62233
  (command, arguments_) => (0, import_node_child_process3.spawn)(command, arguments_),
62229
62234
  (cause) => cause
62230
62235
  );
@@ -62232,7 +62237,7 @@ function spawnRecorder(outputPath) {
62232
62237
  if (mkdirResult.isErr()) {
62233
62238
  return mkdirResult.error;
62234
62239
  }
62235
- const spawnResult = safeSpawn("xcrun", [
62240
+ const spawnResult = safeSpawn2("xcrun", [
62236
62241
  "simctl",
62237
62242
  "io",
62238
62243
  "booted",
@@ -62309,9 +62314,11 @@ function speedUpVideo({
62309
62314
  );
62310
62315
  }
62311
62316
  var VIEW_UI_TOOL_NAME = "mcp__mobile-ios__view_ui";
62312
- var VIEW_UI_DESCRIPTION = `Capture the current screen state: accessibility snapshot (element list with positions) and screenshot. Call this after every action to observe the result.
62317
+ var VIEW_UI_DESCRIPTION = `Capture current screen state: accessibility tree (element labels, positions, attributes) and screenshot in one call. Use when you need to tap an element, assert element presence or labels, check attributes, or track screen identity via <screen_id>.
62318
+
62319
+ The result begins with a <screen_id> tag containing the current screen identifier. Use this to detect screen changes and track navigation history.
62313
62320
 
62314
- The result begins with a <screen_id> tag containing the current screen identifier. Use this to track which screen you are on.
62321
+ Do not call \`screenshot\` immediately before or after this tool for the same state \u2014 this tool already includes the screenshot.
62315
62322
 
62316
62323
  IMPORTANT: Snapshot coordinates and screenshot pixels are in the same logical point space. Do not apply any scaling factor (no 2x retina adjustment).`;
62317
62324
  function deriveScreenLabel(tree, stepIndex) {
@@ -62636,32 +62643,11 @@ function spawnDetached(options) {
62636
62643
  off: child.off.bind(child)
62637
62644
  };
62638
62645
  }
62639
- var cachedAllTools;
62640
- async function fetchAllTools() {
62641
- if (cachedAllTools !== void 0) {
62642
- return cachedAllTools;
62643
- }
62644
- const probe = Qs({ prompt: "", options: { settingSources: ["user"] } });
62645
- for await (const message of probe) {
62646
- if (message.type === "system" && message.subtype === "init") {
62647
- probe.close();
62648
- cachedAllTools = message.tools;
62649
- return cachedAllTools;
62650
- }
62651
- }
62652
- return [];
62653
- }
62654
- async function resolveDisallowedTools(allowedTools) {
62655
- const allTools = await fetchAllTools();
62656
- const allowedSet = new Set(allowedTools);
62657
- return allTools.filter((tool2) => !allowedSet.has(tool2));
62658
- }
62659
62646
  function buildQueryOptions({
62660
62647
  config: config3,
62661
62648
  outputTools,
62662
62649
  mobileIosServer,
62663
- allowedTools,
62664
- disallowedTools
62650
+ allowedTools
62665
62651
  }) {
62666
62652
  const base = {
62667
62653
  mcpServers: {
@@ -62670,8 +62656,9 @@ function buildQueryOptions({
62670
62656
  output: outputTools.server
62671
62657
  },
62672
62658
  allowedTools,
62673
- disallowedTools,
62674
- settingSources: ["user"],
62659
+ tools: [],
62660
+ permissionMode: "bypassPermissions",
62661
+ allowDangerouslySkipPermissions: true,
62675
62662
  spawnClaudeCodeProcess: spawnDetached,
62676
62663
  ...config3.cwd ? { cwd: config3.cwd } : {}
62677
62664
  };
@@ -62722,14 +62709,13 @@ function buildMobileIosServer(config3, state) {
62722
62709
  });
62723
62710
  return createMobileIosServer(config3.udid ?? "booted", [viewUiTool]);
62724
62711
  }
62725
- async function setupQuery(config3, outputTools) {
62712
+ function setupQuery(config3, outputTools) {
62726
62713
  const allowedTools = [
62727
62714
  ...config3.allowedTools ?? [],
62728
62715
  ...outputTools.allowedToolNames,
62729
62716
  VIEW_UI_TOOL_NAME,
62730
62717
  WAIT_SECONDS_TOOL_NAME
62731
- ];
62732
- const disallowedTools = await resolveDisallowedTools(allowedTools);
62718
+ ].filter((tool2) => typeof tool2 === "string");
62733
62719
  const inputQueue = new MessageQueue();
62734
62720
  const state = buildAgentState({ config: config3, outputTools, inputQueue });
62735
62721
  const mobileIosServer = buildMobileIosServer(config3, state);
@@ -62737,8 +62723,7 @@ async function setupQuery(config3, outputTools) {
62737
62723
  config: config3,
62738
62724
  outputTools,
62739
62725
  mobileIosServer,
62740
- allowedTools,
62741
- disallowedTools
62726
+ allowedTools
62742
62727
  });
62743
62728
  return { inputQueue, state, options, linkedController };
62744
62729
  }
@@ -62854,16 +62839,16 @@ function startQueryTimers(config3, context) {
62854
62839
  inputQueue.close();
62855
62840
  };
62856
62841
  }
62857
- function awaitMessagesAndResolve({ queryRunner, state }, { cleanup: cleanup2, getOutput }) {
62842
+ function awaitMessagesAndResolve({ queryRunner, state }, { cleanup: cleanup3, getOutput }) {
62858
62843
  const messagesPromise = processMessages(queryRunner, state);
62859
62844
  return import_neverthrow16.ResultAsync.fromPromise(messagesPromise, String).andThen((innerResult) => {
62860
- cleanup2();
62845
+ cleanup3();
62861
62846
  if (innerResult.isErr()) {
62862
62847
  return (0, import_neverthrow16.err)(innerResult.error);
62863
62848
  }
62864
62849
  return (0, import_neverthrow16.ok)(getOutput());
62865
62850
  }).orElse((sdkError) => {
62866
- cleanup2();
62851
+ cleanup3();
62867
62852
  if (!state.timedOut.value && !state.aborted.value) {
62868
62853
  return (0, import_neverthrow16.err)(sdkError);
62869
62854
  }
@@ -62886,21 +62871,19 @@ function executeQuery({
62886
62871
  return (0, import_neverthrow16.errAsync)(queryRunnerResult.error);
62887
62872
  }
62888
62873
  const queryRunner = queryRunnerResult.value;
62889
- const cleanup2 = startQueryTimers(config3, { state, queryRunner, inputQueue, linkedController });
62874
+ const cleanup3 = startQueryTimers(config3, { state, queryRunner, inputQueue, linkedController });
62890
62875
  const getOutput = () => ({
62891
62876
  findings: (outputTools.getOutput()?.findings ?? []).map(
62892
62877
  (raw) => stampExplorerAgent(raw)
62893
62878
  ),
62894
62879
  snapshots: state.snapshots
62895
62880
  });
62896
- return awaitMessagesAndResolve({ queryRunner, state }, { cleanup: cleanup2, getOutput });
62881
+ return awaitMessagesAndResolve({ queryRunner, state }, { cleanup: cleanup3, getOutput });
62897
62882
  }
62898
62883
  function runQuery(prompt, config3) {
62899
62884
  const outputTools = createOutputTool({ findings: external_exports.array(EXPLORER_FINDING_SCHEMA) });
62900
- const setupPromise = setupQuery(config3, outputTools);
62901
- return import_neverthrow16.ResultAsync.fromPromise(setupPromise, String).andThen(
62902
- (setup) => executeQuery({ prompt, config: config3, outputTools, setup })
62903
- );
62885
+ const setup = setupQuery(config3, outputTools);
62886
+ return executeQuery({ prompt, config: config3, outputTools, setup });
62904
62887
  }
62905
62888
  function collectAgentOutput(prompt, config3) {
62906
62889
  return runQuery(prompt, config3).mapErr((cause) => ({ type: "QUERY_FAILED", cause }));
@@ -62952,6 +62935,12 @@ function startAndRun(params) {
62952
62935
  }).andThen((result) => applySpeedUpVariants({ result, params, toRecordingError }));
62953
62936
  });
62954
62937
  }
62938
+ var TOOL_SELECTION_SECTION = `## Tool Selection
62939
+
62940
+ - \`view_ui\` \u2014 returns accessibility tree (element labels, positions, attributes) AND screenshot; use when you need to tap, assert element presence, or read labels
62941
+ - \`screenshot\` \u2014 returns screenshot only; use for passive visual verification (confirm transition occurred, loading finished, outcome visible) when you do not need element data
62942
+ - Never call \`screenshot\` immediately before or after \`view_ui\` for the same state \u2014 \`view_ui\` already includes the screenshot
62943
+ - \`screenshot\` calls do not emit a \`<screen_id>\` and do not advance the stuck-loop counter; if screen identity tracking matters, use \`view_ui\``;
62955
62944
  var DEV_ENVIRONMENT_SECTION = `## Environment
62956
62945
 
62957
62946
  This is a development build. Debug overlays and internal messages are expected artifacts \u2014 do not report them as findings.`;
@@ -62964,9 +62953,9 @@ At every reasoning step, maintain a mental ledger:
62964
62953
 
62965
62954
  Consult the ledger before every action. Always prefer navigating to a QUEUE screen over a VISITED one.`;
62966
62955
  var SESSION_START_RULE = `Before taking any other action \u2014 including initializing the Working State ledger or emitting findings \u2014 call \`view_ui\` once to observe the starting screen`;
62967
- var BACK_NAV_RULE = `After navigating forward to any new screen: tap back, call \`view_ui\`, confirm you returned to the expected parent in PATH \u2014 if not, emit a \`back-nav-failure\` finding, then navigate forward again to continue`;
62968
- var STUCK_LOOP_RULE = `Stuck loop: emit a \`stuck-loop\` finding when any of these occur: (1) \`view_ui\` returns the same screen state 3 or more consecutive steps, (2) the same element has been tapped more than twice with no screen change, (3) PATH shows the same screen at two non-adjacent positions \u2014 before emitting, try one alternative action (scroll, long-press, swipe) to rule out a gesture mismatch`;
62969
- var LOADING_STATE_RULE = `Transient loading state: when \`view_ui\` reveals spinners, skeleton screens, progress bars, "Loading..." text, or placeholder content NOT described in spec or app context, wait and retry \`view_ui\` up to 3 times before treating screen as final \u2014 if loading persists after 3 retries, proceed with what is visible; if spec or app context explicitly describes a loading screen as a step, do not retry \u2014 inspect and assert normally`;
62956
+ var BACK_NAV_RULE = `After navigating forward to any new screen: tap back, then confirm you returned to the expected parent in PATH \u2014 use \`screenshot\` if the parent screen is visually unambiguous, \`view_ui\` if you need element labels or coordinates to verify or to act next \u2014 if confirmation fails, emit a \`back-nav-failure\` finding, then navigate forward again to continue`;
62957
+ var STUCK_LOOP_RULE = `Stuck loop: emit a \`stuck-loop\` finding when any of these occur: (1) \`view_ui\` returns the same \`<screen_id>\` across 3 or more consecutive \`view_ui\` calls, (2) the same element has been tapped more than twice with no screen change confirmed by \`view_ui\`, (3) PATH shows the same screen at two non-adjacent positions \u2014 before emitting, try one alternative action (scroll, long-press, swipe) to rule out a gesture mismatch \u2014 note: \`screenshot\`-only calls do not update the stuck-loop counter; only \`view_ui\` calls count`;
62958
+ var LOADING_STATE_RULE = `Transient loading state: when the screen shows spinners, skeleton screens, progress bars, "Loading..." text, or placeholder content NOT described in spec or app context \u2014 use \`screenshot\` to poll for resolution (up to 3 retries); switch to \`view_ui\` only on the final check or when you need element data to act \u2014 if loading persists after 3 retries, proceed with what is visible; if spec or app context explicitly describes a loading screen as a step, do not retry \u2014 call \`view_ui\` and assert normally`;
62970
62959
  var EXPECTED_CONTENT_MISSING_RULE = `Expected content missing: when \`view_ui\` shows no loading indicator yet omits an element named or strongly implied by spec or app context \u2014 and its absence is not semantically consistent with the current screen \u2014 call \`wait_seconds\` with 2\u20135 seconds and retry \`view_ui\` up to 2 times; if element remains absent, emit a \`missing-content\` finding stating what was expected and what was observed`;
62971
62960
  var CLIPPED_ELEMENT_RULE = `Never tap an element tagged \`[clipped-top]\`, \`[clipped-bottom]\`, \`[clipped-left]\`, or \`[clipped-right]\` \u2014 scroll to fully reveal it first, then re-call \`view_ui\` before tapping`;
62972
62961
  var WHAT_TO_TEST_SECTION = `## What to Test
@@ -63009,7 +62998,7 @@ Each step has this shape:
63009
62998
  <intent> [\u2192 <outcome>] [hint: <advisory>]
63010
62999
 
63011
63000
  - The intent phrase is your goal. Achieve it by any reasonable UI path.
63012
- - If an outcome state is present, it is your verification target. After acting, call \`view_ui\` and confirm the outcome is met before marking the step complete. If no outcome is given, proceed when the action succeeds.
63001
+ - If an outcome state is present, it is your verification target. After acting, confirm the outcome is met before marking the step complete \u2014 use \`screenshot\` when the outcome is purely visual (screen transition visible, element gone, content appeared); use \`view_ui\` when the outcome requires asserting element labels, attributes, or coordinates. If no outcome is given, proceed when the action succeeds.
63013
63002
  - A hint is advisory only. Prefer an element matching the hint, but if no literal match exists, use intent and visual context to select the best candidate. Never fail a step solely because a hint label is absent.
63014
63003
  - Infer element role (primary action, secondary action, dismissal) from visual hierarchy, position, and hint text. Authors do not specify role.
63015
63004
  - If no element satisfies the intent after exhausting visible UI, emit a \`spec-deviation\` finding and halt that step.`;
@@ -63042,14 +63031,15 @@ ${initialState2}` : void 0,
63042
63031
  var SPEC_RULES_SECTION = `## Rules
63043
63032
 
63044
63033
  - ${SESSION_START_RULE}
63045
- - ALWAYS call \`view_ui\` after every action before deciding what to do next \u2014 it is your only way to observe the screen
63034
+ - After any action, observe the screen before deciding next step \u2014 use \`screenshot\` when confirming a purely visual outcome (transition occurred, element disappeared, content appeared, loading finished); use \`view_ui\` when you need element labels, tap coordinates, or accessibility attributes
63035
+ - Never call both \`screenshot\` and \`view_ui\` back-to-back for the same observation \u2014 \`view_ui\` includes a screenshot; if you need both tree and image, one \`view_ui\` call suffices
63046
63036
  - ${BACK_NAV_RULE}
63047
63037
  - Before selecting any action, prefer navigating to a QUEUE screen over re-exploring a VISITED one
63048
63038
  - ${STUCK_LOOP_RULE}
63049
63039
  - ${LOADING_STATE_RULE}
63050
63040
  - ${EXPECTED_CONTENT_MISSING_RULE}
63051
63041
  - ${CLIPPED_ELEMENT_RULE}
63052
- - Each item in \`**Assertions**\` is a mandatory pass/fail check \u2014 verify using \`view_ui\`; if the accessibility tree cannot confirm, emit a \`spec-deviation\` finding based on what is observable
63042
+ - Each item in \`**Assertions**\` is a mandatory pass/fail check \u2014 verify using \`view_ui\` when the assertion targets an element attribute, label, or presence in the tree; use \`screenshot\` when the assertion is purely visual; if neither can confirm, emit a \`spec-deviation\` finding based on what is observable
63053
63043
  - Flag crash dialogs, unexpected system errors, or navigation failures that occur as a direct result of executing a spec step; if you observe a visibly broken element in passing while navigating, note it without interacting with it`;
63054
63044
  function buildSpecModeBody({
63055
63045
  specContent,
@@ -63062,6 +63052,8 @@ Verify app against specs below.
63062
63052
 
63063
63053
  ${contextBlock}
63064
63054
 
63055
+ ${TOOL_SELECTION_SECTION}
63056
+
63065
63057
  ${SPEC_RULES_SECTION}
63066
63058
 
63067
63059
  ## Execution Strategy
@@ -63101,10 +63093,13 @@ ${DEV_ENVIRONMENT_SECTION}` : "";
63101
63093
 
63102
63094
  ${contextBlock}
63103
63095
 
63096
+ ${TOOL_SELECTION_SECTION}
63097
+
63104
63098
  ## Rules
63105
63099
 
63106
63100
  - ${SESSION_START_RULE}
63107
- - ALWAYS call \`view_ui\` after every action before deciding what to do next \u2014 it is your only way to observe the screen
63101
+ - After any action, observe the screen before deciding next step \u2014 use \`screenshot\` when confirming a purely visual outcome (transition occurred, element disappeared, content appeared, loading finished); use \`view_ui\` when you need element labels, tap coordinates, or accessibility attributes
63102
+ - Never call both \`screenshot\` and \`view_ui\` back-to-back for the same observation \u2014 \`view_ui\` includes a screenshot; if you need both tree and image, one \`view_ui\` call suffices
63108
63103
  - ${BACK_NAV_RULE}
63109
63104
  - Before selecting any action, prefer navigating to a QUEUE screen over re-exploring a VISITED one
63110
63105
  - ${STUCK_LOOP_RULE}
@@ -64445,7 +64440,7 @@ var directiveHandlers = {
64445
64440
  }
64446
64441
  try {
64447
64442
  prefix = decodeURIComponent(prefix);
64448
- } catch (err19) {
64443
+ } catch (err20) {
64449
64444
  throwError(state, "tag prefix is malformed: " + prefix);
64450
64445
  }
64451
64446
  state.tagMap[handle] = prefix;
@@ -65126,7 +65121,7 @@ function readTagProperty(state) {
65126
65121
  }
65127
65122
  try {
65128
65123
  tagName = decodeURIComponent(tagName);
65129
- } catch (err19) {
65124
+ } catch (err20) {
65130
65125
  throwError(state, "tag name is malformed: " + tagName);
65131
65126
  }
65132
65127
  if (isVerbatim) {
@@ -69394,7 +69389,7 @@ function createPrompt(view) {
69394
69389
  effectScheduler.clearAll();
69395
69390
  throw error48;
69396
69391
  }).finally(() => {
69397
- cleanups.forEach((cleanup2) => cleanup2());
69392
+ cleanups.forEach((cleanup3) => cleanup3());
69398
69393
  screen.done({ clearContent: Boolean(context.clearPromptOnDone) });
69399
69394
  output.end();
69400
69395
  }).then(() => promise2), { cancel });
@@ -69654,9 +69649,9 @@ var RemoveFileError = class extends Error {
69654
69649
  // ../../node_modules/.pnpm/@inquirer+external-editor@1.0.3_@types+node@22.19.15/node_modules/@inquirer/external-editor/dist/esm/index.js
69655
69650
  function editAsync(text = "", callback, fileOptions) {
69656
69651
  const editor = new ExternalEditor(text, fileOptions);
69657
- editor.runAsync((err19, result) => {
69658
- if (err19) {
69659
- setImmediate(callback, err19, void 0);
69652
+ editor.runAsync((err20, result) => {
69653
+ if (err20) {
69654
+ setImmediate(callback, err20, void 0);
69660
69655
  } else {
69661
69656
  try {
69662
69657
  editor.cleanup();
@@ -71753,8 +71748,8 @@ function getErrorMap2() {
71753
71748
 
71754
71749
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
71755
71750
  var makeIssue = (params) => {
71756
- const { data, path: path23, errorMaps, issueData } = params;
71757
- const fullPath = [...path23, ...issueData.path || []];
71751
+ const { data, path: path24, errorMaps, issueData } = params;
71752
+ const fullPath = [...path24, ...issueData.path || []];
71758
71753
  const fullIssue = {
71759
71754
  ...issueData,
71760
71755
  path: fullPath
@@ -71870,11 +71865,11 @@ var errorUtil;
71870
71865
 
71871
71866
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
71872
71867
  var ParseInputLazyPath = class {
71873
- constructor(parent, value, path23, key) {
71868
+ constructor(parent, value, path24, key) {
71874
71869
  this._cachedPath = [];
71875
71870
  this.parent = parent;
71876
71871
  this.data = value;
71877
- this._path = path23;
71872
+ this._path = path24;
71878
71873
  this._key = key;
71879
71874
  }
71880
71875
  get path() {
@@ -72013,8 +72008,8 @@ var ZodType2 = class {
72013
72008
  } : {
72014
72009
  issues: ctx.common.issues
72015
72010
  };
72016
- } catch (err19) {
72017
- if (err19?.message?.toLowerCase()?.includes("encountered")) {
72011
+ } catch (err20) {
72012
+ if (err20?.message?.toLowerCase()?.includes("encountered")) {
72018
72013
  this["~standard"].async = true;
72019
72014
  }
72020
72015
  ctx.common = {
@@ -75462,34 +75457,23 @@ function findXqaDirectory(startDirectory) {
75462
75457
  }
75463
75458
 
75464
75459
  // src/suite/commands/run-command.ts
75465
- var import_promises20 = __toESM(require("node:fs/promises"), 1);
75466
- var import_node_path22 = __toESM(require("node:path"), 1);
75460
+ var import_promises21 = __toESM(require("node:fs/promises"), 1);
75461
+ var import_node_path23 = __toESM(require("node:path"), 1);
75467
75462
  var import_fast_glob = __toESM(require_out4(), 1);
75468
- var import_neverthrow52 = __toESM(require_index_cjs(), 1);
75469
-
75470
- // src/suite/core/run-id.ts
75471
- var RUN_ID_PAD_LENGTH2 = 4;
75472
- function toNumeric(name) {
75473
- const parsed = Number(name);
75474
- return Number.isInteger(parsed) && parsed > 0 ? parsed : void 0;
75475
- }
75476
- function highestNumeric(directories) {
75477
- let highest = 0;
75478
- for (const name of directories) {
75479
- const numeric = toNumeric(name);
75480
- if (numeric !== void 0 && numeric > highest) {
75481
- highest = numeric;
75482
- }
75483
- }
75484
- return highest;
75485
- }
75486
- function computeNextRunId(existingDirectories) {
75487
- return String(highestNumeric(existingDirectories) + 1).padStart(RUN_ID_PAD_LENGTH2, "0");
75488
- }
75463
+ var import_neverthrow55 = __toESM(require_index_cjs(), 1);
75489
75464
 
75490
75465
  // src/suite/core/suite-config-parser.ts
75491
75466
  var import_neverthrow48 = __toESM(require_index_cjs(), 1);
75492
75467
  var import_neverthrow49 = __toESM(require_index_cjs(), 1);
75468
+ var RESERVED_HOOK_ENV_KEYS = [
75469
+ "XQA_SIM_UDID",
75470
+ "XQA_ITEM_ID",
75471
+ "XQA_ITEM_TYPE",
75472
+ "XQA_ITEM_NAME",
75473
+ "XQA_SPEC_PATH",
75474
+ "XQA_SUITE"
75475
+ ];
75476
+ var reservedKeySet = new Set(RESERVED_HOOK_ENV_KEYS);
75493
75477
  var freestyleEntrySchema = external_exports2.object({
75494
75478
  prompt: external_exports2.string().optional(),
75495
75479
  timeoutSeconds: external_exports2.number().int().positive()
@@ -75504,9 +75488,31 @@ var freestyleSchema = external_exports2.union([external_exports2.number().int().
75504
75488
  }
75505
75489
  return value;
75506
75490
  });
75491
+ var hookConfigSchema = external_exports2.object({
75492
+ script: external_exports2.string().min(1),
75493
+ env: external_exports2.record(external_exports2.string(), external_exports2.string()).optional(),
75494
+ timeoutSeconds: external_exports2.number().int().positive().optional()
75495
+ }).superRefine((data, context) => {
75496
+ if (data.env === void 0) {
75497
+ return;
75498
+ }
75499
+ for (const key of Object.keys(data.env)) {
75500
+ if (reservedKeySet.has(key)) {
75501
+ context.addIssue({
75502
+ code: external_exports2.ZodIssueCode.custom,
75503
+ path: ["env", key],
75504
+ message: `Reserved xqa-owned key: ${key}`
75505
+ });
75506
+ }
75507
+ }
75508
+ });
75509
+ var suiteHooksSchema = external_exports2.object({
75510
+ beforeEach: hookConfigSchema.optional()
75511
+ });
75507
75512
  var suiteConfigSchema = external_exports2.object({
75508
75513
  specs: external_exports2.array(external_exports2.string()).nonempty(),
75509
- freestyle: freestyleSchema
75514
+ freestyle: freestyleSchema,
75515
+ hooks: suiteHooksSchema.optional()
75510
75516
  });
75511
75517
  var safeJsonParse4 = (0, import_neverthrow48.fromThrowable)(
75512
75518
  JSON.parse,
@@ -75515,13 +75521,47 @@ var safeJsonParse4 = (0, import_neverthrow48.fromThrowable)(
75515
75521
  cause
75516
75522
  })
75517
75523
  );
75524
+ function buildHookConfig(parsed) {
75525
+ const { script, env: env2, timeoutSeconds } = parsed;
75526
+ if (env2 !== void 0 && timeoutSeconds !== void 0) {
75527
+ return { script, env: env2, timeoutSeconds };
75528
+ }
75529
+ if (env2 !== void 0) {
75530
+ return { script, env: env2 };
75531
+ }
75532
+ if (timeoutSeconds !== void 0) {
75533
+ return { script, timeoutSeconds };
75534
+ }
75535
+ return { script };
75536
+ }
75537
+ function normalizeHooks(hooks) {
75538
+ if (hooks === void 0) {
75539
+ return void 0;
75540
+ }
75541
+ const { beforeEach } = hooks;
75542
+ if (beforeEach === void 0) {
75543
+ return {};
75544
+ }
75545
+ return { beforeEach: buildHookConfig(beforeEach) };
75546
+ }
75518
75547
  function parseSuiteConfig(raw) {
75519
75548
  return safeJsonParse4(raw).andThen((data) => {
75520
75549
  const parsed = suiteConfigSchema.safeParse(data);
75521
75550
  if (!parsed.success) {
75522
75551
  return (0, import_neverthrow49.err)({ type: "INVALID_SUITE_CONFIG", cause: parsed.error });
75523
75552
  }
75524
- return (0, import_neverthrow49.ok)({ specs: parsed.data.specs, freestyle: parsed.data.freestyle });
75553
+ const hooks = normalizeHooks(parsed.data.hooks);
75554
+ if (hooks === void 0) {
75555
+ return (0, import_neverthrow49.ok)({
75556
+ specs: parsed.data.specs,
75557
+ freestyle: parsed.data.freestyle
75558
+ });
75559
+ }
75560
+ return (0, import_neverthrow49.ok)({
75561
+ specs: parsed.data.specs,
75562
+ freestyle: parsed.data.freestyle,
75563
+ hooks
75564
+ });
75525
75565
  });
75526
75566
  }
75527
75567
 
@@ -75534,17 +75574,6 @@ function buildSuiteFindings(input) {
75534
75574
  return base;
75535
75575
  }
75536
75576
 
75537
- // src/suite/core/suite-id.ts
75538
- function slugify2(glob) {
75539
- return glob.replaceAll(/[^a-zA-Z0-9]+/g, "-").replaceAll(/-+/g, "-").replaceAll(/^-|-$/g, "");
75540
- }
75541
- function deriveSuiteId(input) {
75542
- if (input.mode === "suite") {
75543
- return input.name;
75544
- }
75545
- return input.globs.toSorted().map((glob) => slugify2(glob)).join("+");
75546
- }
75547
-
75548
75577
  // src/suite/core/work-item-builder.ts
75549
75578
  var DEFAULT_FREESTYLE_TIMEOUT_SECONDS = 300;
75550
75579
  function deriveSpecName(filePath) {
@@ -75612,7 +75641,29 @@ function writeSuiteFindings(findings, options) {
75612
75641
  }
75613
75642
 
75614
75643
  // src/suite/shell/worker-pool.ts
75615
- var import_neverthrow51 = __toESM(require_index_cjs(), 1);
75644
+ var import_neverthrow53 = __toESM(require_index_cjs(), 1);
75645
+
75646
+ // src/suite/core/priority-queue.ts
75647
+ var PriorityQueue = class {
75648
+ entries = [];
75649
+ get size() {
75650
+ return this.entries.length;
75651
+ }
75652
+ get isEmpty() {
75653
+ return this.entries.length === 0;
75654
+ }
75655
+ enqueue(item, priority) {
75656
+ const insertIndex = this.entries.findIndex((entry) => entry.priority > priority);
75657
+ if (insertIndex === -1) {
75658
+ this.entries.push({ item, priority });
75659
+ } else {
75660
+ this.entries.splice(insertIndex, 0, { item, priority });
75661
+ }
75662
+ }
75663
+ dequeue() {
75664
+ return this.entries.shift()?.item;
75665
+ }
75666
+ };
75616
75667
 
75617
75668
  // src/suite/shell/item-result-builder.ts
75618
75669
  function getErrorMessage(cause) {
@@ -75686,33 +75737,7 @@ function buildAbortedItem(item, simulatorUdid) {
75686
75737
  };
75687
75738
  }
75688
75739
 
75689
- // src/suite/core/priority-queue.ts
75690
- var PriorityQueue = class {
75691
- entries = [];
75692
- get size() {
75693
- return this.entries.length;
75694
- }
75695
- get isEmpty() {
75696
- return this.entries.length === 0;
75697
- }
75698
- enqueue(item, priority) {
75699
- const insertIndex = this.entries.findIndex((entry) => entry.priority > priority);
75700
- if (insertIndex === -1) {
75701
- this.entries.push({ item, priority });
75702
- } else {
75703
- this.entries.splice(insertIndex, 0, { item, priority });
75704
- }
75705
- }
75706
- dequeue() {
75707
- return this.entries.shift()?.item;
75708
- }
75709
- };
75710
-
75711
- // src/suite/shell/worker-pool.ts
75712
- var CONSECUTIVE_FAILURES_THRESHOLD = 2;
75713
- function isTimeoutError(error48) {
75714
- return error48.type.toUpperCase().includes("TIMEOUT");
75715
- }
75740
+ // src/suite/shell/item-result-recorder.ts
75716
75741
  function buildNotifyBase(itemContext) {
75717
75742
  return {
75718
75743
  itemId: itemContext.item.id,
@@ -75721,6 +75746,9 @@ function buildNotifyBase(itemContext) {
75721
75746
  at: Date.now()
75722
75747
  };
75723
75748
  }
75749
+ function isTimeoutError(error48) {
75750
+ return error48.type.toUpperCase().includes("TIMEOUT");
75751
+ }
75724
75752
  function notifyItemResult(context, observer) {
75725
75753
  const base = buildNotifyBase(context.itemContext);
75726
75754
  if (context.result.isOk()) {
@@ -75741,12 +75769,12 @@ function notifyItemResult(context, observer) {
75741
75769
  error: getErrorMessage(context.result.error.cause)
75742
75770
  });
75743
75771
  }
75744
- function recordItemResult(context, workerContext) {
75772
+ function recordItemResult(input) {
75773
+ const { context, results, observer } = input;
75745
75774
  const { itemContext, result } = context;
75746
- const { results, config: config3 } = workerContext;
75747
75775
  if (result.isOk()) {
75748
75776
  results.push(buildCompletedItem(itemContext, result.value));
75749
- notifyItemResult(context, config3.observer);
75777
+ notifyItemResult(context, observer);
75750
75778
  return 0;
75751
75779
  }
75752
75780
  if (isTimeoutError(result.error)) {
@@ -75754,9 +75782,202 @@ function recordItemResult(context, workerContext) {
75754
75782
  } else {
75755
75783
  results.push(buildFailedItem(itemContext, getErrorMessage(result.error.cause)));
75756
75784
  }
75757
- notifyItemResult(context, config3.observer);
75785
+ notifyItemResult(context, observer);
75786
+ return 1;
75787
+ }
75788
+
75789
+ // src/suite/shell/hook-failure-recorder.ts
75790
+ function formatHookError(error48) {
75791
+ switch (error48.type) {
75792
+ case "HOOK_SPAWN_FAILED": {
75793
+ return `Hook spawn failed: ${getErrorMessage(error48.cause)}`;
75794
+ }
75795
+ case "HOOK_EXIT_NONZERO": {
75796
+ return `Hook exited with code ${String(error48.code)}: ${error48.stderr.trim()}`;
75797
+ }
75798
+ case "HOOK_TIMEOUT": {
75799
+ return `Hook timed out after ${String(error48.timeoutMs)}ms`;
75800
+ }
75801
+ case "HOOK_ABORTED": {
75802
+ return "Hook aborted";
75803
+ }
75804
+ }
75805
+ }
75806
+ function emitHookTimeout(input) {
75807
+ const base = buildNotifyBase(input.itemContext);
75808
+ input.results.push(buildTimedOutItem(input.itemContext));
75809
+ const event = { type: "ITEM_TIMEOUT", ...base };
75810
+ input.observer(event);
75811
+ }
75812
+ function emitHookFailed(input, message) {
75813
+ const base = buildNotifyBase(input.itemContext);
75814
+ input.results.push(buildFailedItem(input.itemContext, message));
75815
+ const event = { type: "ITEM_FAILED", ...base, error: message };
75816
+ input.observer(event);
75817
+ }
75818
+ function recordHookFailure(input) {
75819
+ if (input.error.type === "HOOK_TIMEOUT") {
75820
+ emitHookTimeout(input);
75821
+ return 1;
75822
+ }
75823
+ emitHookFailed(input, formatHookError(input.error));
75758
75824
  return 1;
75759
75825
  }
75826
+
75827
+ // src/suite/shell/hook-invoker.ts
75828
+ var import_neverthrow52 = __toESM(require_index_cjs(), 1);
75829
+
75830
+ // src/suite/core/hook-env-builder.ts
75831
+ function buildReservedKeys(input) {
75832
+ const { item, simulatorUdid, suiteName } = input;
75833
+ const base = {
75834
+ XQA_SIM_UDID: simulatorUdid,
75835
+ XQA_ITEM_ID: item.id,
75836
+ XQA_ITEM_TYPE: item.type,
75837
+ XQA_ITEM_NAME: item.name,
75838
+ XQA_SUITE: suiteName
75839
+ };
75840
+ if (item.type === "spec") {
75841
+ return { ...base, XQA_SPEC_PATH: item.specPath };
75842
+ }
75843
+ return base;
75844
+ }
75845
+ function buildHookEnv(input) {
75846
+ const reserved = buildReservedKeys(input);
75847
+ if (input.suiteEnv === void 0) {
75848
+ return reserved;
75849
+ }
75850
+ return { ...input.suiteEnv, ...reserved };
75851
+ }
75852
+
75853
+ // src/suite/shell/hook-runner.ts
75854
+ var import_node_child_process7 = require("node:child_process");
75855
+ var import_neverthrow51 = __toESM(require_index_cjs(), 1);
75856
+ var noop2 = () => void 0;
75857
+ function cleanup2(context) {
75858
+ clearTimeout(context.timeoutHandle);
75859
+ context.signal.removeEventListener("abort", context.onAbort);
75860
+ }
75861
+ function settle(context, outcome) {
75862
+ if (context.settled.value) {
75863
+ return;
75864
+ }
75865
+ context.settled.value = true;
75866
+ cleanup2(context);
75867
+ context.deferred.resolve(outcome);
75868
+ }
75869
+ function makeDeferred() {
75870
+ const raw = Promise.withResolvers();
75871
+ return { promise: raw.promise, resolve: raw.resolve };
75872
+ }
75873
+ function collectStderr(child, stderrReference) {
75874
+ if (child.stderr === null) {
75875
+ return;
75876
+ }
75877
+ child.stderr.on("data", (chunk) => {
75878
+ stderrReference.value += chunk.toString();
75879
+ });
75880
+ }
75881
+ function buildOnAbort(context) {
75882
+ return () => {
75883
+ context.child.kill("SIGTERM");
75884
+ settle(context, (0, import_neverthrow51.err)({ type: "HOOK_ABORTED" }));
75885
+ };
75886
+ }
75887
+ function attachChildListeners(context) {
75888
+ const { child, stderrReference } = context;
75889
+ child.on("error", (cause) => {
75890
+ settle(context, (0, import_neverthrow51.err)({ type: "HOOK_SPAWN_FAILED", cause }));
75891
+ });
75892
+ child.on("exit", (code) => {
75893
+ if (code === 0) {
75894
+ settle(context, (0, import_neverthrow51.ok)());
75895
+ return;
75896
+ }
75897
+ settle(
75898
+ context,
75899
+ (0, import_neverthrow51.err)({
75900
+ type: "HOOK_EXIT_NONZERO",
75901
+ code: code ?? -1,
75902
+ stderr: stderrReference.value
75903
+ })
75904
+ );
75905
+ });
75906
+ }
75907
+ function attachTimeout(context, timeoutMs) {
75908
+ clearTimeout(context.timeoutHandle);
75909
+ context.timeoutHandle = setTimeout(() => {
75910
+ context.child.kill("SIGTERM");
75911
+ settle(context, (0, import_neverthrow51.err)({ type: "HOOK_TIMEOUT", timeoutMs }));
75912
+ }, timeoutMs);
75913
+ }
75914
+ function buildContext2(options) {
75915
+ const { script, cwd, env: env2, baseEnv, nodeExecPath } = options;
75916
+ const deferred = makeDeferred();
75917
+ const stderrReference = { value: "" };
75918
+ const child = (0, import_node_child_process7.spawn)(nodeExecPath, [script], {
75919
+ cwd,
75920
+ env: { ...baseEnv, ...env2 },
75921
+ stdio: ["ignore", "inherit", "pipe"]
75922
+ });
75923
+ collectStderr(child, stderrReference);
75924
+ return {
75925
+ child,
75926
+ signal: options.signal,
75927
+ timeoutHandle: setTimeout(noop2, 0),
75928
+ onAbort: noop2,
75929
+ deferred,
75930
+ stderrReference,
75931
+ settled: { value: false }
75932
+ };
75933
+ }
75934
+ async function spawnHook(options) {
75935
+ const context = buildContext2(options);
75936
+ attachTimeout(context, options.timeoutMs);
75937
+ context.onAbort = buildOnAbort(context);
75938
+ if (options.signal.aborted) {
75939
+ context.onAbort();
75940
+ return context.deferred.promise;
75941
+ }
75942
+ options.signal.addEventListener("abort", context.onAbort, { once: true });
75943
+ attachChildListeners(context);
75944
+ return context.deferred.promise;
75945
+ }
75946
+ var safeSpawn = import_neverthrow51.ResultAsync.fromThrowable(
75947
+ spawnHook,
75948
+ (cause) => ({ type: "HOOK_SPAWN_FAILED", cause })
75949
+ );
75950
+ function runHook(options) {
75951
+ return safeSpawn(options).andThen((outcome) => outcome);
75952
+ }
75953
+
75954
+ // src/suite/shell/hook-invoker.ts
75955
+ var DEFAULT_HOOK_TIMEOUT_SECONDS = 120;
75956
+ var MS_PER_SECOND5 = 1e3;
75957
+ async function invokeHook(input) {
75958
+ const { hook, item, simulatorUdid, suiteName, hookCwd, hookBaseEnv, hookNodeExecPath, signal } = input;
75959
+ const env2 = buildHookEnv({ item, simulatorUdid, suiteName, suiteEnv: hook.env });
75960
+ const timeoutSeconds = hook.timeoutSeconds ?? DEFAULT_HOOK_TIMEOUT_SECONDS;
75961
+ return runHook({
75962
+ script: hook.script,
75963
+ cwd: hookCwd,
75964
+ env: env2,
75965
+ baseEnv: hookBaseEnv,
75966
+ nodeExecPath: hookNodeExecPath,
75967
+ timeoutMs: timeoutSeconds * MS_PER_SECOND5,
75968
+ signal
75969
+ });
75970
+ }
75971
+ async function maybeInvokeHook(input) {
75972
+ const { hook } = input;
75973
+ if (hook === void 0) {
75974
+ return (0, import_neverthrow52.ok)();
75975
+ }
75976
+ return invokeHook({ ...input, hook });
75977
+ }
75978
+
75979
+ // src/suite/shell/worker-pool.ts
75980
+ var CONSECUTIVE_FAILURES_THRESHOLD = 2;
75760
75981
  function buildExecuteOptions(workerContext, item) {
75761
75982
  const { simulatorUdid, config: config3 } = workerContext;
75762
75983
  const base = { item, simulatorUdid, signal: config3.signal };
@@ -75766,21 +75987,70 @@ function buildExecuteOptions(workerContext, item) {
75766
75987
  }
75767
75988
  return base;
75768
75989
  }
75769
- async function processItem(workerContext, item) {
75770
- const { simulatorUdid, config: config3 } = workerContext;
75771
- const startedAt = (/* @__PURE__ */ new Date()).toISOString();
75772
- const startMs = Date.now();
75773
- config3.observer({
75990
+ function buildHookInvokeInput(workerContext, item) {
75991
+ const { config: config3, simulatorUdid } = workerContext;
75992
+ return {
75993
+ hook: config3.hook,
75994
+ item,
75995
+ simulatorUdid,
75996
+ suiteName: config3.suiteName,
75997
+ hookCwd: config3.hookCwd,
75998
+ hookBaseEnv: config3.hookBaseEnv,
75999
+ hookNodeExecPath: config3.hookNodeExecPath,
76000
+ signal: config3.signal
76001
+ };
76002
+ }
76003
+ function emitItemStarted(state) {
76004
+ const { workerContext, item, startMs } = state;
76005
+ workerContext.config.observer({
75774
76006
  type: "ITEM_STARTED",
75775
76007
  itemId: item.id,
75776
76008
  itemName: item.name,
75777
- simulatorUdid,
76009
+ simulatorUdid: workerContext.simulatorUdid,
75778
76010
  at: startMs
75779
76011
  });
75780
- const result = await config3.executeItem(buildExecuteOptions(workerContext, item));
76012
+ }
76013
+ async function runAndRecordItem(state) {
76014
+ const { workerContext, item, startedAt, startMs } = state;
76015
+ const { simulatorUdid } = workerContext;
76016
+ const result = await workerContext.config.executeItem(buildExecuteOptions(workerContext, item));
75781
76017
  const durationMs = Date.now() - startMs;
75782
76018
  const itemContext = { item, simulatorUdid, startedAt, durationMs };
75783
- return recordItemResult({ itemContext, result }, workerContext);
76019
+ return recordItemResult({
76020
+ context: { itemContext, result },
76021
+ results: workerContext.results,
76022
+ observer: workerContext.config.observer
76023
+ });
76024
+ }
76025
+ function handleHookFailure(state, error48) {
76026
+ const { workerContext, item, startedAt, startMs } = state;
76027
+ const durationMs = Date.now() - startMs;
76028
+ const itemContext = {
76029
+ item,
76030
+ simulatorUdid: workerContext.simulatorUdid,
76031
+ startedAt,
76032
+ durationMs
76033
+ };
76034
+ return recordHookFailure({
76035
+ itemContext,
76036
+ error: error48,
76037
+ results: workerContext.results,
76038
+ observer: workerContext.config.observer
76039
+ });
76040
+ }
76041
+ async function processItem(workerContext, item) {
76042
+ const state = {
76043
+ workerContext,
76044
+ item,
76045
+ startedAt: (/* @__PURE__ */ new Date()).toISOString(),
76046
+ startMs: Date.now()
76047
+ };
76048
+ emitItemStarted(state);
76049
+ const hookOutcome = await maybeInvokeHook(buildHookInvokeInput(workerContext, item));
76050
+ if (hookOutcome.isErr()) {
76051
+ return handleHookFailure(state, hookOutcome.error);
76052
+ }
76053
+ return runAndRecordItem(state);
75784
76054
  }
75785
76055
  async function runWorker(workerContext) {
75786
76056
  const { simulatorUdid, queue, config: config3 } = workerContext;
@@ -75840,7 +76110,7 @@ function runWorkerPool(config3) {
75840
76110
  const queue = setupQueue(config3);
75841
76111
  const results = [];
75842
76112
  const suiteStartMs = Date.now();
75843
- const safeRun = import_neverthrow51.ResultAsync.fromThrowable(
76113
+ const safeRun = import_neverthrow53.ResultAsync.fromThrowable(
75844
76114
  async () => runAllWorkers({ config: config3, queue, results, suiteStartMs }),
75845
76115
  (cause) => ({ type: "WORKER_POOL_FAILED", cause })
75846
76116
  );
@@ -75925,30 +76195,88 @@ function makeExecuteItem(context) {
75925
76195
  };
75926
76196
  }
75927
76197
 
75928
- // src/suite/commands/run-command.ts
76198
+ // src/suite/commands/suite-run-context.ts
76199
+ var import_promises20 = __toESM(require("node:fs/promises"), 1);
76200
+ var import_node_path22 = __toESM(require("node:path"), 1);
76201
+ var import_neverthrow54 = __toESM(require_index_cjs(), 1);
76202
+
76203
+ // src/suite/core/run-id.ts
76204
+ var RUN_ID_PAD_LENGTH2 = 4;
76205
+ function toNumeric(name) {
76206
+ const parsed = Number(name);
76207
+ return Number.isInteger(parsed) && parsed > 0 ? parsed : void 0;
76208
+ }
76209
+ function highestNumeric(directories) {
76210
+ let highest = 0;
76211
+ for (const name of directories) {
76212
+ const numeric = toNumeric(name);
76213
+ if (numeric !== void 0 && numeric > highest) {
76214
+ highest = numeric;
76215
+ }
76216
+ }
76217
+ return highest;
76218
+ }
76219
+ function computeNextRunId(existingDirectories) {
76220
+ return String(highestNumeric(existingDirectories) + 1).padStart(RUN_ID_PAD_LENGTH2, "0");
76221
+ }
76222
+
76223
+ // src/suite/core/suite-id.ts
76224
+ function slugify2(glob) {
76225
+ return glob.replaceAll(/[^a-zA-Z0-9]+/g, "-").replaceAll(/-+/g, "-").replaceAll(/^-|-$/g, "");
76226
+ }
76227
+ function deriveSuiteId(input) {
76228
+ if (input.mode === "suite") {
76229
+ return input.name;
76230
+ }
76231
+ return input.globs.toSorted().map((glob) => slugify2(glob)).join("+");
76232
+ }
76233
+
76234
+ // src/suite/commands/suite-run-context.ts
75929
76235
  var ISO_DATE_LENGTH3 = 10;
75930
- var safeReaddir2 = import_neverthrow52.ResultAsync.fromThrowable(
76236
+ var safeReaddir2 = import_neverthrow54.ResultAsync.fromThrowable(
75931
76237
  async (directoryPath) => {
75932
76238
  const entries = await import_promises20.default.readdir(directoryPath, { withFileTypes: true });
75933
76239
  return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
75934
76240
  },
75935
76241
  () => "READDIR_FAILED"
75936
76242
  );
75937
- var safeReadFile5 = import_neverthrow52.ResultAsync.fromThrowable(
75938
- async (filePath) => import_promises20.default.readFile(filePath, "utf8"),
75939
- () => "READ_FAILED"
75940
- );
75941
76243
  async function listRunDirectories(input) {
75942
76244
  const { outputDirectory, suiteId, date: date5 } = input;
75943
76245
  const directoryPath = import_node_path22.default.join(outputDirectory, "suite", suiteId, date5);
75944
76246
  const result = await safeReaddir2(directoryPath);
75945
76247
  return result.unwrapOr([]);
75946
76248
  }
76249
+ function deriveSuiteIdFromMode(mode) {
76250
+ if (mode.type === "suite") {
76251
+ return deriveSuiteId({ mode: "suite", name: mode.name });
76252
+ }
76253
+ return deriveSuiteId({ mode: "spec", globs: mode.globs });
76254
+ }
76255
+ async function buildSuiteRunContext(input) {
76256
+ const suiteId = deriveSuiteIdFromMode(input.mode);
76257
+ const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, ISO_DATE_LENGTH3);
76258
+ const outputDirectory = import_node_path22.default.join(input.xqaDirectory, "output");
76259
+ const existingDirectories = await listRunDirectories({ outputDirectory, suiteId, date: date5 });
76260
+ const runId = computeNextRunId(existingDirectories);
76261
+ const context = {
76262
+ config: input.config,
76263
+ xqaDirectory: input.xqaDirectory,
76264
+ runId,
76265
+ date: date5
76266
+ };
76267
+ return { suiteId, date: date5, outputDirectory, runId, context };
76268
+ }
76269
+
76270
+ // src/suite/commands/run-command.ts
76271
+ var safeReadFile5 = import_neverthrow55.ResultAsync.fromThrowable(
76272
+ async (filePath) => import_promises21.default.readFile(filePath, "utf8"),
76273
+ () => "READ_FAILED"
76274
+ );
75947
76275
  async function resolveGlobs(input) {
75948
76276
  return (0, import_fast_glob.default)(input.globs, { cwd: input.cwd, absolute: true });
75949
76277
  }
75950
76278
  async function loadSuiteConfig(xqaDirectory, name) {
75951
- const suitePath = import_node_path22.default.join(xqaDirectory, "suites", `${name}.suite.json`);
76279
+ const suitePath = import_node_path23.default.join(xqaDirectory, "suites", `${name}.suite.json`);
75952
76280
  const contentResult = await safeReadFile5(suitePath);
75953
76281
  if (contentResult.isErr()) {
75954
76282
  return;
@@ -75971,7 +76299,10 @@ async function resolveSuiteModeItems(input) {
75971
76299
  process.stderr.write("No spec files matched\n");
75972
76300
  return;
75973
76301
  }
75974
- return [...buildSpecItems(specPaths), ...buildFreestyleItems(suiteConfig.freestyle)];
76302
+ return {
76303
+ items: [...buildSpecItems(specPaths), ...buildFreestyleItems(suiteConfig.freestyle)],
76304
+ hook: suiteConfig.hooks?.beforeEach
76305
+ };
75975
76306
  }
75976
76307
  async function resolveSpecModeItems(input) {
75977
76308
  const specPaths = await resolveGlobs({ globs: input.mode.globs, cwd: input.xqaDirectory });
@@ -75979,7 +76310,7 @@ async function resolveSpecModeItems(input) {
75979
76310
  process.stderr.write("No spec files matched\n");
75980
76311
  return;
75981
76312
  }
75982
- return buildSpecItems(specPaths);
76313
+ return { items: buildSpecItems(specPaths), hook: void 0 };
75983
76314
  }
75984
76315
  async function resolveWorkItems(input) {
75985
76316
  if (input.mode.type === "suite") {
@@ -75987,12 +76318,6 @@ async function resolveWorkItems(input) {
75987
76318
  }
75988
76319
  return resolveSpecModeItems({ ...input, mode: input.mode });
75989
76320
  }
75990
- function deriveSuiteIdFromMode(mode) {
75991
- if (mode.type === "suite") {
75992
- return deriveSuiteId({ mode: "suite", name: mode.name });
75993
- }
75994
- return deriveSuiteId({ mode: "spec", globs: mode.globs });
75995
- }
75996
76321
  async function discoverSimulators() {
75997
76322
  const result = await discoverBootedSimulators();
75998
76323
  if (result.isErr()) {
@@ -76006,25 +76331,34 @@ async function discoverSimulators() {
76006
76331
  }
76007
76332
  return { simulators: result.value, exitCode: 0 };
76008
76333
  }
76009
- async function runPool(input) {
76010
- const { context, items, simulatorUdids, debug, signal } = input;
76011
- const display = createSuiteDisplay();
76334
+ function buildPoolConfig(input, display) {
76335
+ const { context, items, simulatorUdids, debug, signal, suiteName, hookCwd } = input;
76012
76336
  const debugLogger = createDebugLogger({ enabled: debug });
76013
76337
  const baseObserver = (event) => {
76014
76338
  display.onEvent(event);
76015
76339
  };
76016
76340
  const observer = debugLogger.wrapSuiteHandler(baseObserver);
76017
- const buildItemHandler = (itemId) => debugLogger.wrapAgentHandler((event) => {
76341
+ const onEvent = (itemId) => debugLogger.wrapAgentHandler((event) => {
76018
76342
  display.onEvent({ ...event, itemId });
76019
76343
  }, itemId);
76020
- const poolResult = await runWorkerPool({
76344
+ return {
76021
76345
  items,
76022
76346
  simulatorUdids,
76023
76347
  observer,
76024
- onEvent: buildItemHandler,
76348
+ onEvent,
76025
76349
  executeItem: makeExecuteItem(context),
76026
- signal
76027
- });
76350
+ signal,
76351
+ suiteName,
76352
+ hookCwd,
76353
+ hookBaseEnv: process.env,
76354
+ hookNodeExecPath: process.execPath
76355
+ };
76356
+ }
76357
+ async function runPool(input) {
76358
+ const { hook } = input;
76359
+ const display = createSuiteDisplay();
76360
+ const poolConfig = buildPoolConfig(input, display);
76361
+ const poolResult = hook === void 0 ? await runWorkerPool(poolConfig) : await runWorkerPool({ ...poolConfig, hook });
76028
76362
  display.cleanup();
76029
76363
  return poolResult;
76030
76364
  }
@@ -76045,29 +76379,21 @@ async function writeAndReport(input) {
76045
76379
  const hasFindings = items.some((item) => item.findings.length > 0);
76046
76380
  return hasFindings ? 1 : 0;
76047
76381
  }
76048
- async function buildSuiteRunContext(input) {
76049
- const suiteId = deriveSuiteIdFromMode(input.mode);
76050
- const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, ISO_DATE_LENGTH3);
76051
- const outputDirectory = import_node_path22.default.join(input.xqaDirectory, "output");
76052
- const existingDirectories = await listRunDirectories({ outputDirectory, suiteId, date: date5 });
76053
- const runId = computeNextRunId(existingDirectories);
76054
- const context = {
76055
- config: input.config,
76056
- xqaDirectory: input.xqaDirectory,
76057
- runId,
76058
- date: date5
76382
+ function derivePoolInput(input, context) {
76383
+ const suiteName = input.mode.type === "suite" ? input.mode.name : "specs";
76384
+ return {
76385
+ context,
76386
+ items: input.items,
76387
+ simulatorUdids: input.simulatorUdids,
76388
+ debug: input.debug,
76389
+ signal: input.signal,
76390
+ suiteName,
76391
+ hook: input.hook,
76392
+ hookCwd: input.xqaDirectory
76059
76393
  };
76060
- return { suiteId, date: date5, outputDirectory, runId, context };
76061
76394
  }
76062
76395
  async function executePool(input, runContext) {
76063
- const { items, simulatorUdids, debug, signal } = input;
76064
- return runPool({
76065
- context: runContext.context,
76066
- items,
76067
- simulatorUdids,
76068
- debug,
76069
- signal
76070
- });
76396
+ return runPool(derivePoolInput(input, runContext.context));
76071
76397
  }
76072
76398
  async function runSuite(input) {
76073
76399
  const runContext = await buildSuiteRunContext(input);
@@ -76091,8 +76417,8 @@ async function runSuiteCommand(input) {
76091
76417
  if (preflightExit !== void 0) {
76092
76418
  return preflightExit;
76093
76419
  }
76094
- const items = await resolveWorkItems(input);
76095
- if (items === void 0) {
76420
+ const resolved = await resolveWorkItems(input);
76421
+ if (resolved === void 0) {
76096
76422
  return 1;
76097
76423
  }
76098
76424
  const simulatorResolution = await discoverSimulators();
@@ -76106,8 +76432,9 @@ async function runSuiteCommand(input) {
76106
76432
  }
76107
76433
  return runSuite({
76108
76434
  ...input,
76109
- items,
76110
- simulatorUdids: simulators.map((sim) => sim.udid)
76435
+ items: resolved.items,
76436
+ simulatorUdids: simulators.map((sim) => sim.udid),
76437
+ hook: resolved.hook
76111
76438
  });
76112
76439
  }
76113
76440
 
@@ -76129,7 +76456,7 @@ function resolveXqaDirectory() {
76129
76456
  return result.value;
76130
76457
  }
76131
76458
  var program2 = new Command();
76132
- program2.name("xqa").description("AI-powered QA agent CLI").version(`${"1.10.0"}${false ? ` (dev build +${"e25bb70"})` : ""}`);
76459
+ program2.name("xqa").description("AI-powered QA agent CLI").version(`${"1.11.0"}${false ? ` (dev build +${"1f9f698"})` : ""}`);
76133
76460
  program2.command("init").description("Initialize a new xqa project in the current directory").action(() => {
76134
76461
  runInitCommand();
76135
76462
  });