@swmansion/argent 0.33.1-next.2 → 0.33.1-next.21

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 (36) hide show
  1. package/bin/argent-android-devtools-0.4.0.apk +0 -0
  2. package/bin/darwin/argent-macos-helper +0 -0
  3. package/bin/darwin/ax-service +0 -0
  4. package/bin/darwin/tvos-ax-service +0 -0
  5. package/bin/darwin/tvos-hid-daemon +0 -0
  6. package/bin/network-inspector/network-inspector.jar +0 -0
  7. package/bin/tcp/ax-service +0 -0
  8. package/dist/cli-cmds.mjs +267 -70
  9. package/dist/client.js +253 -56
  10. package/dist/flow-script-runner.mjs +148 -5
  11. package/dist/installer.mjs +52 -26
  12. package/dist/ios-device-runner/ArgentRunner/ArgentRunnerUITests/ArgentRunnerSession+Snapshot.swift +110 -4
  13. package/dist/mcp-server.mjs +327 -68
  14. package/dist/tool-args.generated.d.ts +3 -1
  15. package/dist/tool-server.cjs +1367 -698
  16. package/dylibs/libArgentInjectionBootstrap.dylib +0 -0
  17. package/dylibs/libKeyboardPatch.dylib +0 -0
  18. package/dylibs/libNativeDevtoolsIos.dylib +0 -0
  19. package/dylibs/macos/libArgentInjectionBootstrap.dylib +0 -0
  20. package/dylibs/macos/libNativeDevtoolsMacos.dylib +0 -0
  21. package/dylibs/tcp/libArgentInjectionBootstrap.dylib +0 -0
  22. package/dylibs/tcp/libKeyboardPatch.dylib +0 -0
  23. package/dylibs/tcp/libNativeDevtoolsIos.dylib +0 -0
  24. package/dylibs/tvos/libArgentInjectionBootstrap.dylib +0 -0
  25. package/dylibs/tvos/libKeyboardPatch.dylib +0 -0
  26. package/dylibs/tvos/libNativeDevtoolsIos.dylib +0 -0
  27. package/package.json +2 -3
  28. package/rules/argent.md +1 -1
  29. package/skills/argent-create-e2e/references/e2e-yaml.md +11 -1
  30. package/skills/argent-create-e2e/references/reliability-and-recovery.md +1 -1
  31. package/skills/argent-device-interact/SKILL.md +2 -2
  32. package/skills/argent-device-interact/references/harmonyos.md +1 -1
  33. package/skills/argent-react-native-app-workflow/SKILL.md +1 -1
  34. package/skills/argent-test-ui-flow/SKILL.md +6 -8
  35. package/assets/trace-processor/SHA256SUMS +0 -4
  36. package/assets/trace-processor/engine.mjs +0 -42423
@@ -1244,7 +1244,7 @@ function toolStepFiles(specs, args) {
1244
1244
  function isClientFileArgument({ spec, path: path63 }) {
1245
1245
  return spec.kind === "file" && spec.path === `\${${spec.target}}` && path63.startsWith("/") && hasToolFileExtension(path63);
1246
1246
  }
1247
- var FILE_INPUT_MARKER, FLOW_NAME_CHARSET, FLOW_NAME_PATTERN, FLOW_FILE_NAME_PATTERN, SCRIPT_FILE_NAME_PATTERN, CLIENT_FILE_MARKER, TOOL_FILE_EXTENSIONS;
1247
+ var FILE_INPUT_MARKER, FLOW_NAME_CHARSET, FLOW_NAME_PATTERN, FLOW_FILE_NAME_PATTERN, SCRIPT_FILE_EXTENSIONS, SCRIPT_FILE_NAME_PATTERN, CLIENT_FILE_MARKER, TOOL_FILE_EXTENSIONS;
1248
1248
  var init_file_inputs = __esm({
1249
1249
  "../registry/src/file-inputs.ts"() {
1250
1250
  "use strict";
@@ -1252,7 +1252,10 @@ var init_file_inputs = __esm({
1252
1252
  FLOW_NAME_CHARSET = "[A-Za-z0-9_-]+";
1253
1253
  FLOW_NAME_PATTERN = new RegExp(`^${FLOW_NAME_CHARSET}$`);
1254
1254
  FLOW_FILE_NAME_PATTERN = new RegExp(`^${FLOW_NAME_CHARSET}\\.yaml$`);
1255
- SCRIPT_FILE_NAME_PATTERN = new RegExp(`^${FLOW_NAME_CHARSET}\\.mjs$`);
1255
+ SCRIPT_FILE_EXTENSIONS = [".mjs", ".mts", ".js", ".ts"];
1256
+ SCRIPT_FILE_NAME_PATTERN = new RegExp(
1257
+ `^${FLOW_NAME_CHARSET}(?:${SCRIPT_FILE_EXTENSIONS.map((ext) => `\\${ext}`).join("|")})$`
1258
+ );
1256
1259
  CLIENT_FILE_MARKER = "__argentClientFile";
1257
1260
  TOOL_FILE_EXTENSIONS = [".png", ".yaml"];
1258
1261
  }
@@ -1770,6 +1773,8 @@ var init_failure_codes = __esm({
1770
1773
  FLOW_DEVICE_RESOLUTION: "FLOW_DEVICE_RESOLUTION",
1771
1774
  // The target does not satisfy the test's `requires:` block; a directory run skips it.
1772
1775
  FLOW_REQUIREMENTS_UNMET: "FLOW_REQUIREMENTS_UNMET",
1776
+ // The tool-server's Node.js cannot run a TypeScript `script:` step the test holds.
1777
+ FLOW_SCRIPT_TYPESCRIPT_UNSUPPORTED: "FLOW_SCRIPT_TYPESCRIPT_UNSUPPORTED",
1773
1778
  PROFILER_QUERY_MODE_INVALID: "PROFILER_QUERY_MODE_INVALID",
1774
1779
  PROFILER_QUERY_REQUIRED_PARAM_MISSING: "PROFILER_QUERY_REQUIRED_PARAM_MISSING",
1775
1780
  PROFILER_DATA_NOT_LOADED: "PROFILER_DATA_NOT_LOADED",
@@ -2980,9 +2985,9 @@ function $constructor(name, initializer3, proto, params) {
2980
2985
  function _(def) {
2981
2986
  const inst = params?.Parent ? newError(Definition) : this;
2982
2987
  init2(inst, def);
2983
- const deferred = inst._zod.deferred;
2984
- if (deferred) {
2985
- for (const fn of deferred) {
2988
+ const deferred2 = inst._zod.deferred;
2989
+ if (deferred2) {
2990
+ for (const fn of deferred2) {
2986
2991
  fn();
2987
2992
  }
2988
2993
  inst._zod.deferred = void 0;
@@ -4537,7 +4542,7 @@ function handleIntersectionResults(result, left, right) {
4537
4542
  const unrecKeys = /* @__PURE__ */ new Map();
4538
4543
  let unrecIssue;
4539
4544
  const keyIssues = /* @__PURE__ */ new Map();
4540
- const collect = (iss, side) => {
4545
+ const collect2 = (iss, side) => {
4541
4546
  let keys;
4542
4547
  if (iss.code === "unrecognized_keys" && !iss.path?.length) {
4543
4548
  unrecIssue ?? (unrecIssue = iss);
@@ -4558,11 +4563,11 @@ function handleIntersectionResults(result, left, right) {
4558
4563
  return true;
4559
4564
  };
4560
4565
  for (const iss of left.issues) {
4561
- if (!collect(iss, "l"))
4566
+ if (!collect2(iss, "l"))
4562
4567
  result.issues.push(iss);
4563
4568
  }
4564
4569
  for (const iss of right.issues) {
4565
- if (!collect(iss, "r"))
4570
+ if (!collect2(iss, "r"))
4566
4571
  result.issues.push(iss);
4567
4572
  }
4568
4573
  const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
@@ -39588,7 +39593,7 @@ var require_read = __commonJS({
39588
39593
  var getBody = require_raw_body();
39589
39594
  var iconv = require_lib();
39590
39595
  var onFinished = require_on_finished();
39591
- var zlib3 = require("node:zlib");
39596
+ var zlib4 = require("node:zlib");
39592
39597
  var hasBody = require_type_is().hasBody;
39593
39598
  var { getCharset } = require_utils();
39594
39599
  module2.exports = read;
@@ -39713,13 +39718,13 @@ var require_read = __commonJS({
39713
39718
  switch (encoding) {
39714
39719
  case "deflate":
39715
39720
  debug("inflate body");
39716
- return zlib3.createInflate();
39721
+ return zlib4.createInflate();
39717
39722
  case "gzip":
39718
39723
  debug("gunzip body");
39719
- return zlib3.createGunzip();
39724
+ return zlib4.createGunzip();
39720
39725
  case "br":
39721
39726
  debug("brotli decompress body");
39722
- return zlib3.createBrotliDecompress();
39727
+ return zlib4.createBrotliDecompress();
39723
39728
  default:
39724
39729
  throw createError(415, 'unsupported content encoding "' + encoding + '"', {
39725
39730
  encoding,
@@ -42509,11 +42514,11 @@ var require_parse = __commonJS({
42509
42514
  segments[segments.length] = parent;
42510
42515
  }
42511
42516
  var n = key2.length;
42512
- var open4 = first;
42517
+ var open5 = first;
42513
42518
  var collected = 0;
42514
- while (open4 >= 0 && collected < options.depth) {
42519
+ while (open5 >= 0 && collected < options.depth) {
42515
42520
  var level = 1;
42516
- var i = open4 + 1;
42521
+ var i = open5 + 1;
42517
42522
  var close = -1;
42518
42523
  while (i < n && close < 0) {
42519
42524
  var cu = key2.charCodeAt(i);
@@ -42528,23 +42533,23 @@ var require_parse = __commonJS({
42528
42533
  i += 1;
42529
42534
  }
42530
42535
  if (close < 0) {
42531
- segments[segments.length] = "[" + key2.slice(open4) + "]";
42536
+ segments[segments.length] = "[" + key2.slice(open5) + "]";
42532
42537
  return segments;
42533
42538
  }
42534
- var seg = key2.slice(open4, close + 1);
42539
+ var seg = key2.slice(open5, close + 1);
42535
42540
  var content = seg.slice(1, -1);
42536
42541
  if (!options.plainObjects && has.call(Object.prototype, content) && !options.allowPrototypes) {
42537
42542
  return;
42538
42543
  }
42539
42544
  segments[segments.length] = seg;
42540
42545
  collected += 1;
42541
- open4 = key2.indexOf("[", close + 1);
42546
+ open5 = key2.indexOf("[", close + 1);
42542
42547
  }
42543
- if (open4 >= 0) {
42548
+ if (open5 >= 0) {
42544
42549
  if (options.strictDepth === true) {
42545
42550
  throw new RangeError("Input depth exceeded depth option of " + options.depth + " and strictDepth is true");
42546
42551
  }
42547
- segments[segments.length] = "[" + key2.slice(open4) + "]";
42552
+ segments[segments.length] = "[" + key2.slice(open5) + "]";
42548
42553
  }
42549
42554
  return segments;
42550
42555
  };
@@ -75577,7 +75582,7 @@ var require_send = __commonJS({
75577
75582
  var join68 = path63.join;
75578
75583
  var normalize = path63.normalize;
75579
75584
  var resolve19 = path63.resolve;
75580
- var sep10 = path63.sep;
75585
+ var sep11 = path63.sep;
75581
75586
  var BYTES_RANGE_REGEXP = /^ *bytes=/;
75582
75587
  var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
75583
75588
  var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
@@ -75738,14 +75743,14 @@ var require_send = __commonJS({
75738
75743
  var parts2;
75739
75744
  if (root !== null) {
75740
75745
  if (path64) {
75741
- path64 = normalize("." + sep10 + path64);
75746
+ path64 = normalize("." + sep11 + path64);
75742
75747
  }
75743
75748
  if (UP_PATH_REGEXP.test(path64)) {
75744
75749
  debug('malicious path "%s"', path64);
75745
75750
  this.error(403);
75746
75751
  return res;
75747
75752
  }
75748
- parts2 = path64.split(sep10);
75753
+ parts2 = path64.split(sep11);
75749
75754
  path64 = normalize(join68(root, path64));
75750
75755
  } else {
75751
75756
  if (UP_PATH_REGEXP.test(path64)) {
@@ -75753,7 +75758,7 @@ var require_send = __commonJS({
75753
75758
  this.error(403);
75754
75759
  return res;
75755
75760
  }
75756
- parts2 = normalize(path64).split(sep10);
75761
+ parts2 = normalize(path64).split(sep11);
75757
75762
  path64 = resolve19(path64);
75758
75763
  }
75759
75764
  if (containsDotFile(parts2)) {
@@ -75847,7 +75852,7 @@ var require_send = __commonJS({
75847
75852
  var self2 = this;
75848
75853
  debug('stat "%s"', path64);
75849
75854
  fs78.stat(path64, function onstat(err, stat10) {
75850
- var pathEndsWithSep = path64[path64.length - 1] === sep10;
75855
+ var pathEndsWithSep = path64[path64.length - 1] === sep11;
75851
75856
  if (err && err.code === "ENOENT" && !extname7(path64) && !pathEndsWithSep) {
75852
75857
  return next(err);
75853
75858
  }
@@ -76738,8 +76743,8 @@ async function commandOnPath(name) {
76738
76743
  try {
76739
76744
  if (process.platform === "win32") {
76740
76745
  const { stdout: stdout2 } = await execFileAsync("where", [name], { timeout: 2e3 });
76741
- const cwd = import_node_path3.win32.resolve(process.cwd()).toLowerCase();
76742
- const match = stdout2.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).find((candidate) => import_node_path3.win32.resolve(import_node_path3.win32.dirname(candidate)).toLowerCase() !== cwd);
76746
+ const cwd = import_node_path4.win32.resolve(process.cwd()).toLowerCase();
76747
+ const match = stdout2.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).find((candidate) => import_node_path4.win32.resolve(import_node_path4.win32.dirname(candidate)).toLowerCase() !== cwd);
76743
76748
  return match ?? null;
76744
76749
  }
76745
76750
  const { stdout } = await execFileAsync("/bin/sh", ["-c", `command -v ${name}`], {
@@ -76751,14 +76756,14 @@ async function commandOnPath(name) {
76751
76756
  return null;
76752
76757
  }
76753
76758
  }
76754
- var import_node_child_process2, import_node_util, import_node_path3, execFileAsync;
76759
+ var import_node_child_process3, import_node_util, import_node_path4, execFileAsync;
76755
76760
  var init_command_on_path = __esm({
76756
76761
  "../tool-server/src/utils/command-on-path.ts"() {
76757
76762
  "use strict";
76758
- import_node_child_process2 = require("node:child_process");
76763
+ import_node_child_process3 = require("node:child_process");
76759
76764
  import_node_util = require("node:util");
76760
- import_node_path3 = require("node:path");
76761
- execFileAsync = (0, import_node_util.promisify)(import_node_child_process2.execFile);
76765
+ import_node_path4 = require("node:path");
76766
+ execFileAsync = (0, import_node_util.promisify)(import_node_child_process3.execFile);
76762
76767
  }
76763
76768
  });
76764
76769
 
@@ -76778,9 +76783,9 @@ async function probe(name) {
76778
76783
  const onPath = await commandOnPath(name);
76779
76784
  if (onPath) return onPath;
76780
76785
  for (const root of androidRoots()) {
76781
- const candidate = (0, import_node_path4.join)(root, SUBDIR[name], binFileName(name));
76786
+ const candidate = (0, import_node_path5.join)(root, SUBDIR[name], binFileName(name));
76782
76787
  try {
76783
- await (0, import_promises2.access)(candidate, import_node_fs2.constants.X_OK);
76788
+ await (0, import_promises4.access)(candidate, import_node_fs3.constants.X_OK);
76784
76789
  return candidate;
76785
76790
  } catch {
76786
76791
  }
@@ -76798,11 +76803,11 @@ function androidRoots() {
76798
76803
  function defaultAndroidRoots() {
76799
76804
  const home = (0, import_node_os2.homedir)();
76800
76805
  const roots = [
76801
- (0, import_node_path4.join)(home, "Library", "Android", "sdk"),
76806
+ (0, import_node_path5.join)(home, "Library", "Android", "sdk"),
76802
76807
  // macOS Android Studio default
76803
- (0, import_node_path4.join)(home, "Android", "Sdk"),
76808
+ (0, import_node_path5.join)(home, "Android", "Sdk"),
76804
76809
  // Linux Android Studio default
76805
- (0, import_node_path4.join)(home, "android-sdk"),
76810
+ (0, import_node_path5.join)(home, "android-sdk"),
76806
76811
  // manual-install convention; no installer picks it
76807
76812
  "/opt/android-sdk",
76808
76813
  "/usr/lib/android-sdk",
@@ -76817,19 +76822,19 @@ function defaultAndroidRoots() {
76817
76822
  ];
76818
76823
  if (process.platform === "win32") {
76819
76824
  const localAppData = process.env.LOCALAPPDATA?.trim();
76820
- if (localAppData) roots.push((0, import_node_path4.join)(localAppData, "Android", "Sdk"));
76821
- roots.push((0, import_node_path4.join)(home, "AppData", "Local", "Android", "Sdk"));
76825
+ if (localAppData) roots.push((0, import_node_path5.join)(localAppData, "Android", "Sdk"));
76826
+ roots.push((0, import_node_path5.join)(home, "AppData", "Local", "Android", "Sdk"));
76822
76827
  }
76823
76828
  return roots;
76824
76829
  }
76825
- var import_promises2, import_node_fs2, import_node_os2, import_node_path4, SUBDIR, BIN_EXT, CACHE_TTL_MS, cache2;
76830
+ var import_promises4, import_node_fs3, import_node_os2, import_node_path5, SUBDIR, BIN_EXT, CACHE_TTL_MS, cache2;
76826
76831
  var init_android_binary = __esm({
76827
76832
  "../tool-server/src/utils/android-binary.ts"() {
76828
76833
  "use strict";
76829
- import_promises2 = require("node:fs/promises");
76830
- import_node_fs2 = require("node:fs");
76834
+ import_promises4 = require("node:fs/promises");
76835
+ import_node_fs3 = require("node:fs");
76831
76836
  import_node_os2 = require("node:os");
76832
- import_node_path4 = require("node:path");
76837
+ import_node_path5 = require("node:path");
76833
76838
  init_src();
76834
76839
  init_command_on_path();
76835
76840
  SUBDIR = {
@@ -79996,7 +80001,7 @@ var require_buffer_util = __commonJS({
79996
80001
  "use strict";
79997
80002
  var { EMPTY_BUFFER } = require_constants2();
79998
80003
  var FastBuffer = Buffer[Symbol.species];
79999
- function concat2(list, totalLength) {
80004
+ function concat3(list, totalLength) {
80000
80005
  if (list.length === 0) return EMPTY_BUFFER;
80001
80006
  if (list.length === 1) return list[0];
80002
80007
  const target = Buffer.allocUnsafe(totalLength);
@@ -80042,7 +80047,7 @@ var require_buffer_util = __commonJS({
80042
80047
  return buf;
80043
80048
  }
80044
80049
  module2.exports = {
80045
- concat: concat2,
80050
+ concat: concat3,
80046
80051
  mask: _mask,
80047
80052
  toArrayBuffer,
80048
80053
  toBuffer,
@@ -80119,7 +80124,7 @@ var require_limiter = __commonJS({
80119
80124
  var require_permessage_deflate = __commonJS({
80120
80125
  "../../node_modules/ws/lib/permessage-deflate.js"(exports2, module2) {
80121
80126
  "use strict";
80122
- var zlib3 = require("zlib");
80127
+ var zlib4 = require("zlib");
80123
80128
  var bufferUtil = require_buffer_util();
80124
80129
  var Limiter = require_limiter();
80125
80130
  var { kStatusCode } = require_constants2();
@@ -80386,8 +80391,8 @@ var require_permessage_deflate = __commonJS({
80386
80391
  const endpoint = this._isServer ? "client" : "server";
80387
80392
  if (!this._inflate) {
80388
80393
  const key2 = `${endpoint}_max_window_bits`;
80389
- const windowBits = typeof this.params[key2] !== "number" ? zlib3.Z_DEFAULT_WINDOWBITS : this.params[key2];
80390
- this._inflate = zlib3.createInflateRaw({
80394
+ const windowBits = typeof this.params[key2] !== "number" ? zlib4.Z_DEFAULT_WINDOWBITS : this.params[key2];
80395
+ this._inflate = zlib4.createInflateRaw({
80391
80396
  ...this._options.zlibInflateOptions,
80392
80397
  windowBits
80393
80398
  });
@@ -80437,8 +80442,8 @@ var require_permessage_deflate = __commonJS({
80437
80442
  const endpoint = this._isServer ? "server" : "client";
80438
80443
  if (!this._deflate) {
80439
80444
  const key2 = `${endpoint}_max_window_bits`;
80440
- const windowBits = typeof this.params[key2] !== "number" ? zlib3.Z_DEFAULT_WINDOWBITS : this.params[key2];
80441
- this._deflate = zlib3.createDeflateRaw({
80445
+ const windowBits = typeof this.params[key2] !== "number" ? zlib4.Z_DEFAULT_WINDOWBITS : this.params[key2];
80446
+ this._deflate = zlib4.createDeflateRaw({
80442
80447
  ...this._options.zlibDeflateOptions,
80443
80448
  windowBits
80444
80449
  });
@@ -80448,7 +80453,7 @@ var require_permessage_deflate = __commonJS({
80448
80453
  }
80449
80454
  this._deflate[kCallback] = callback;
80450
80455
  this._deflate.write(data);
80451
- this._deflate.flush(zlib3.Z_SYNC_FLUSH, () => {
80456
+ this._deflate.flush(zlib4.Z_SYNC_FLUSH, () => {
80452
80457
  if (!this._deflate) {
80453
80458
  return;
80454
80459
  }
@@ -80703,7 +80708,7 @@ var require_validation = __commonJS({
80703
80708
  var require_receiver = __commonJS({
80704
80709
  "../../node_modules/ws/lib/receiver.js"(exports2, module2) {
80705
80710
  "use strict";
80706
- var { Writable } = require("stream");
80711
+ var { Writable: Writable2 } = require("stream");
80707
80712
  var PerMessageDeflate2 = require_permessage_deflate();
80708
80713
  var {
80709
80714
  BINARY_TYPES,
@@ -80711,7 +80716,7 @@ var require_receiver = __commonJS({
80711
80716
  kStatusCode,
80712
80717
  kWebSocket
80713
80718
  } = require_constants2();
80714
- var { concat: concat2, toArrayBuffer, unmask } = require_buffer_util();
80719
+ var { concat: concat3, toArrayBuffer, unmask } = require_buffer_util();
80715
80720
  var { isValidStatusCode, isValidUTF8 } = require_validation();
80716
80721
  var FastBuffer = Buffer[Symbol.species];
80717
80722
  var GET_INFO = 0;
@@ -80721,7 +80726,7 @@ var require_receiver = __commonJS({
80721
80726
  var GET_DATA = 4;
80722
80727
  var INFLATING = 5;
80723
80728
  var DEFER_EVENT = 6;
80724
- var Receiver2 = class extends Writable {
80729
+ var Receiver2 = class extends Writable2 {
80725
80730
  /**
80726
80731
  * Creates a Receiver instance.
80727
80732
  *
@@ -81188,9 +81193,9 @@ var require_receiver = __commonJS({
81188
81193
  if (this._opcode === 2) {
81189
81194
  let data;
81190
81195
  if (this._binaryType === "nodebuffer") {
81191
- data = concat2(fragments, messageLength);
81196
+ data = concat3(fragments, messageLength);
81192
81197
  } else if (this._binaryType === "arraybuffer") {
81193
- data = toArrayBuffer(concat2(fragments, messageLength));
81198
+ data = toArrayBuffer(concat3(fragments, messageLength));
81194
81199
  } else if (this._binaryType === "blob") {
81195
81200
  data = new Blob(fragments);
81196
81201
  } else {
@@ -81208,7 +81213,7 @@ var require_receiver = __commonJS({
81208
81213
  });
81209
81214
  }
81210
81215
  } else {
81211
- const buf = concat2(fragments, messageLength);
81216
+ const buf = concat3(fragments, messageLength);
81212
81217
  if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
81213
81218
  const error63 = this.createError(
81214
81219
  Error,
@@ -83168,7 +83173,7 @@ var require_stream = __commonJS({
83168
83173
  };
83169
83174
  duplex._final = function(callback) {
83170
83175
  if (ws.readyState === ws.CONNECTING) {
83171
- ws.once("open", function open4() {
83176
+ ws.once("open", function open5() {
83172
83177
  duplex._final(callback);
83173
83178
  });
83174
83179
  return;
@@ -83189,7 +83194,7 @@ var require_stream = __commonJS({
83189
83194
  };
83190
83195
  duplex._write = function(chunk, encoding, callback) {
83191
83196
  if (ws.readyState === ws.CONNECTING) {
83192
- ws.once("open", function open4() {
83197
+ ws.once("open", function open5() {
83193
83198
  duplex._write(chunk, encoding, callback);
83194
83199
  });
83195
83200
  return;
@@ -84054,7 +84059,7 @@ async function adbShellInput(serial, shellCommand, input2, options = {}) {
84054
84059
  const adbPath = await resolveAdbOrThrow();
84055
84060
  const argv = adbArgv(["-s", serial, "shell", shellCommand]);
84056
84061
  return new Promise((resolve19, reject) => {
84057
- const child = (0, import_node_child_process17.execFile)(
84062
+ const child = (0, import_node_child_process18.execFile)(
84058
84063
  adbPath,
84059
84064
  argv,
84060
84065
  {
@@ -84333,7 +84338,7 @@ function avdRootCandidates() {
84333
84338
  process.env.ANDROID_SDK_HOME ? `${process.env.ANDROID_SDK_HOME}/.android/avd` : null,
84334
84339
  home ? `${home}/.android/avd` : null
84335
84340
  ];
84336
- return candidates.filter((p) => Boolean(p && (0, import_node_path9.isAbsolute)(p)));
84341
+ return candidates.filter((p) => Boolean(p && (0, import_node_path10.isAbsolute)(p)));
84337
84342
  }
84338
84343
  async function resolveAvdPath(avdName) {
84339
84344
  const { readFile: readFile21 } = await import("node:fs/promises");
@@ -84343,7 +84348,7 @@ async function resolveAvdPath(avdName) {
84343
84348
  const raw = (0, import_ini.parse)(content).path;
84344
84349
  if (typeof raw !== "string") continue;
84345
84350
  const trimmed = raw.trim();
84346
- if (!(0, import_node_path9.isAbsolute)(trimmed)) continue;
84351
+ if (!(0, import_node_path10.isAbsolute)(trimmed)) continue;
84347
84352
  return trimmed;
84348
84353
  } catch {
84349
84354
  }
@@ -84378,20 +84383,20 @@ async function hasDefaultBootSnapshot(avdName) {
84378
84383
  return false;
84379
84384
  }
84380
84385
  }
84381
- var import_node_child_process17, import_node_util13, import_node_os5, import_node_path9, import_ini, execFileAsync13, emulatorFlagSupportCache, ADB_KILL_SIGNAL, ADB_DEVICE_STATES, ADB_DEVICES_TIMEOUT_MS, ENRICH_TIMEOUT_MS, androidRuntimeKindCache, TERMINAL_ADB_ERROR_PATTERNS, AVD_NAME_PATTERN;
84386
+ var import_node_child_process18, import_node_util13, import_node_os5, import_node_path10, import_ini, execFileAsync13, emulatorFlagSupportCache, ADB_KILL_SIGNAL, ADB_DEVICE_STATES, ADB_DEVICES_TIMEOUT_MS, ENRICH_TIMEOUT_MS, androidRuntimeKindCache, TERMINAL_ADB_ERROR_PATTERNS, AVD_NAME_PATTERN;
84382
84387
  var init_adb = __esm({
84383
84388
  "../tool-server/src/utils/adb.ts"() {
84384
84389
  "use strict";
84385
- import_node_child_process17 = require("node:child_process");
84390
+ import_node_child_process18 = require("node:child_process");
84386
84391
  import_node_util13 = require("node:util");
84387
84392
  import_node_os5 = require("node:os");
84388
- import_node_path9 = require("node:path");
84393
+ import_node_path10 = require("node:path");
84389
84394
  import_ini = __toESM(require_ini());
84390
84395
  init_src2();
84391
84396
  init_android_binary();
84392
84397
  init_subprocess_error();
84393
84398
  init_external_devices();
84394
- execFileAsync13 = (0, import_node_util13.promisify)(import_node_child_process17.execFile);
84399
+ execFileAsync13 = (0, import_node_util13.promisify)(import_node_child_process18.execFile);
84395
84400
  emulatorFlagSupportCache = /* @__PURE__ */ new Map();
84396
84401
  ADB_KILL_SIGNAL = "SIGKILL";
84397
84402
  ADB_DEVICE_STATES = /* @__PURE__ */ new Set([
@@ -85458,7 +85463,7 @@ var require_parser_async = __commonJS({
85458
85463
  "../../node_modules/pngjs/lib/parser-async.js"(exports2, module2) {
85459
85464
  "use strict";
85460
85465
  var util = require("util");
85461
- var zlib3 = require("zlib");
85466
+ var zlib4 = require("zlib");
85462
85467
  var ChunkStream = require_chunkstream();
85463
85468
  var FilterAsync = require_filter_parse_async();
85464
85469
  var Parser2 = require_parser();
@@ -85500,15 +85505,15 @@ var require_parser_async = __commonJS({
85500
85505
  ParserAsync.prototype._inflateData = function(data) {
85501
85506
  if (!this._inflate) {
85502
85507
  if (this._bitmapInfo.interlace) {
85503
- this._inflate = zlib3.createInflate();
85508
+ this._inflate = zlib4.createInflate();
85504
85509
  this._inflate.on("error", this.emit.bind(this, "error"));
85505
85510
  this._filter.on("complete", this._complete.bind(this));
85506
85511
  this._inflate.pipe(this._filter);
85507
85512
  } else {
85508
85513
  let rowSize = (this._bitmapInfo.width * this._bitmapInfo.bpp * this._bitmapInfo.depth + 7 >> 3) + 1;
85509
85514
  let imageSize = rowSize * this._bitmapInfo.height;
85510
- let chunkSize = Math.max(imageSize, zlib3.Z_MIN_CHUNK);
85511
- this._inflate = zlib3.createInflate({ chunkSize });
85515
+ let chunkSize = Math.max(imageSize, zlib4.Z_MIN_CHUNK);
85516
+ this._inflate = zlib4.createInflate({ chunkSize });
85512
85517
  let leftToInflate = imageSize;
85513
85518
  let emitError = this.emit.bind(this, "error");
85514
85519
  this._inflate.on("error", function(err) {
@@ -85883,14 +85888,14 @@ var require_packer = __commonJS({
85883
85888
  var CrcStream = require_crc();
85884
85889
  var bitPacker = require_bitpacker();
85885
85890
  var filter = require_filter_pack();
85886
- var zlib3 = require("zlib");
85891
+ var zlib4 = require("zlib");
85887
85892
  var Packer = module2.exports = function(options) {
85888
85893
  this._options = options;
85889
85894
  options.deflateChunkSize = options.deflateChunkSize || 32 * 1024;
85890
85895
  options.deflateLevel = options.deflateLevel != null ? options.deflateLevel : 9;
85891
85896
  options.deflateStrategy = options.deflateStrategy != null ? options.deflateStrategy : 3;
85892
85897
  options.inputHasAlpha = options.inputHasAlpha != null ? options.inputHasAlpha : true;
85893
- options.deflateFactory = options.deflateFactory || zlib3.createDeflate;
85898
+ options.deflateFactory = options.deflateFactory || zlib4.createDeflate;
85894
85899
  options.bitDepth = options.bitDepth || 8;
85895
85900
  options.colorType = typeof options.colorType === "number" ? options.colorType : constants3.COLORTYPE_COLOR_ALPHA;
85896
85901
  options.inputColorType = typeof options.inputColorType === "number" ? options.inputColorType : constants3.COLORTYPE_COLOR_ALPHA;
@@ -86022,17 +86027,17 @@ var require_sync_inflate = __commonJS({
86022
86027
  "../../node_modules/pngjs/lib/sync-inflate.js"(exports2, module2) {
86023
86028
  "use strict";
86024
86029
  var assert2 = require("assert").ok;
86025
- var zlib3 = require("zlib");
86030
+ var zlib4 = require("zlib");
86026
86031
  var util = require("util");
86027
86032
  var kMaxLength = require("buffer").kMaxLength;
86028
86033
  function Inflate(opts) {
86029
86034
  if (!(this instanceof Inflate)) {
86030
86035
  return new Inflate(opts);
86031
86036
  }
86032
- if (opts && opts.chunkSize < zlib3.Z_MIN_CHUNK) {
86033
- opts.chunkSize = zlib3.Z_MIN_CHUNK;
86037
+ if (opts && opts.chunkSize < zlib4.Z_MIN_CHUNK) {
86038
+ opts.chunkSize = zlib4.Z_MIN_CHUNK;
86034
86039
  }
86035
- zlib3.Inflate.call(this, opts);
86040
+ zlib4.Inflate.call(this, opts);
86036
86041
  this._offset = this._offset === void 0 ? this._outOffset : this._offset;
86037
86042
  this._buffer = this._buffer || this._outBuffer;
86038
86043
  if (opts && opts.maxLength != null) {
@@ -86054,7 +86059,7 @@ var require_sync_inflate = __commonJS({
86054
86059
  }
86055
86060
  Inflate.prototype._processChunk = function(chunk, flushFlag, asyncCb) {
86056
86061
  if (typeof asyncCb === "function") {
86057
- return zlib3.Inflate._processChunk.call(this, chunk, flushFlag, asyncCb);
86062
+ return zlib4.Inflate._processChunk.call(this, chunk, flushFlag, asyncCb);
86058
86063
  }
86059
86064
  let self2 = this;
86060
86065
  let availInBefore = chunk && chunk.length;
@@ -86130,7 +86135,7 @@ var require_sync_inflate = __commonJS({
86130
86135
  _close(this);
86131
86136
  return buf;
86132
86137
  };
86133
- util.inherits(Inflate, zlib3.Inflate);
86138
+ util.inherits(Inflate, zlib4.Inflate);
86134
86139
  function zlibBufferSync(engine, buffer) {
86135
86140
  if (typeof buffer === "string") {
86136
86141
  buffer = Buffer.from(buffer);
@@ -86140,7 +86145,7 @@ var require_sync_inflate = __commonJS({
86140
86145
  }
86141
86146
  let flushFlag = engine._finishFlushFlag;
86142
86147
  if (flushFlag == null) {
86143
- flushFlag = zlib3.Z_FINISH;
86148
+ flushFlag = zlib4.Z_FINISH;
86144
86149
  }
86145
86150
  return engine._processChunk(buffer, flushFlag);
86146
86151
  }
@@ -86221,9 +86226,9 @@ var require_parser_sync = __commonJS({
86221
86226
  "../../node_modules/pngjs/lib/parser-sync.js"(exports2, module2) {
86222
86227
  "use strict";
86223
86228
  var hasSyncZlib = true;
86224
- var zlib3 = require("zlib");
86229
+ var zlib4 = require("zlib");
86225
86230
  var inflateSync = require_sync_inflate();
86226
- if (!zlib3.deflateSync) {
86231
+ if (!zlib4.deflateSync) {
86227
86232
  hasSyncZlib = false;
86228
86233
  }
86229
86234
  var SyncReader = require_sync_reader();
@@ -86282,7 +86287,7 @@ var require_parser_sync = __commonJS({
86282
86287
  inflateDataList.length = 0;
86283
86288
  let inflatedData;
86284
86289
  if (metaData.interlace) {
86285
- inflatedData = zlib3.inflateSync(inflateData);
86290
+ inflatedData = zlib4.inflateSync(inflateData);
86286
86291
  } else {
86287
86292
  let rowSize = (metaData.width * metaData.bpp * metaData.depth + 7 >> 3) + 1;
86288
86293
  let imageSize = rowSize * metaData.height;
@@ -86316,8 +86321,8 @@ var require_packer_sync = __commonJS({
86316
86321
  "../../node_modules/pngjs/lib/packer-sync.js"(exports2, module2) {
86317
86322
  "use strict";
86318
86323
  var hasSyncZlib = true;
86319
- var zlib3 = require("zlib");
86320
- if (!zlib3.deflateSync) {
86324
+ var zlib4 = require("zlib");
86325
+ if (!zlib4.deflateSync) {
86321
86326
  hasSyncZlib = false;
86322
86327
  }
86323
86328
  var constants3 = require_constants3();
@@ -86341,7 +86346,7 @@ var require_packer_sync = __commonJS({
86341
86346
  metaData.width,
86342
86347
  metaData.height
86343
86348
  );
86344
- let compressedData = zlib3.deflateSync(
86349
+ let compressedData = zlib4.deflateSync(
86345
86350
  filteredData,
86346
86351
  packer.getDeflateOptions()
86347
86352
  );
@@ -87679,7 +87684,7 @@ var require_minimatch = __commonJS({
87679
87684
  var require_path_is_absolute = __commonJS({
87680
87685
  "../../node_modules/path-is-absolute/index.js"(exports2, module2) {
87681
87686
  "use strict";
87682
- function posix8(path63) {
87687
+ function posix7(path63) {
87683
87688
  return path63.charAt(0) === "/";
87684
87689
  }
87685
87690
  function win322(path63) {
@@ -87689,8 +87694,8 @@ var require_path_is_absolute = __commonJS({
87689
87694
  var isUnc = Boolean(device && device.charAt(1) !== ":");
87690
87695
  return Boolean(result[2] || isUnc);
87691
87696
  }
87692
- module2.exports = process.platform === "win32" ? win322 : posix8;
87693
- module2.exports.posix = posix8;
87697
+ module2.exports = process.platform === "win32" ? win322 : posix7;
87698
+ module2.exports.posix = posix7;
87694
87699
  module2.exports.win32 = win322;
87695
87700
  }
87696
87701
  });
@@ -94343,10 +94348,10 @@ var require_resolve_block_map = __commonJS({
94343
94348
  let offset = bm.offset;
94344
94349
  let commentEnd = null;
94345
94350
  for (const collItem of bm.items) {
94346
- const { start: start2, key: key2, sep: sep10, value } = collItem;
94351
+ const { start: start2, key: key2, sep: sep11, value } = collItem;
94347
94352
  const keyProps = resolveProps.resolveProps(start2, {
94348
94353
  indicator: "explicit-key-ind",
94349
- next: key2 ?? sep10?.[0],
94354
+ next: key2 ?? sep11?.[0],
94350
94355
  offset,
94351
94356
  onError,
94352
94357
  parentIndent: bm.indent,
@@ -94360,7 +94365,7 @@ var require_resolve_block_map = __commonJS({
94360
94365
  else if ("indent" in key2 && key2.indent !== bm.indent)
94361
94366
  onError(offset, "BAD_INDENT", startColMsg);
94362
94367
  }
94363
- if (!keyProps.anchor && !keyProps.tag && !sep10) {
94368
+ if (!keyProps.anchor && !keyProps.tag && !sep11) {
94364
94369
  commentEnd = keyProps.end;
94365
94370
  if (keyProps.comment) {
94366
94371
  if (map2.comment)
@@ -94384,7 +94389,7 @@ var require_resolve_block_map = __commonJS({
94384
94389
  ctx.atKey = false;
94385
94390
  if (utilMapIncludes.mapIncludes(ctx, map2.items, keyNode))
94386
94391
  onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
94387
- const valueProps = resolveProps.resolveProps(sep10 ?? [], {
94392
+ const valueProps = resolveProps.resolveProps(sep11 ?? [], {
94388
94393
  indicator: "map-value-ind",
94389
94394
  next: value,
94390
94395
  offset: keyNode.range[2],
@@ -94400,7 +94405,7 @@ var require_resolve_block_map = __commonJS({
94400
94405
  if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
94401
94406
  onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
94402
94407
  }
94403
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep10, null, valueProps, onError);
94408
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep11, null, valueProps, onError);
94404
94409
  if (ctx.schema.compat)
94405
94410
  utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
94406
94411
  offset = valueNode.range[2];
@@ -94491,7 +94496,7 @@ var require_resolve_end = __commonJS({
94491
94496
  let comment = "";
94492
94497
  if (end) {
94493
94498
  let hasSpace = false;
94494
- let sep10 = "";
94499
+ let sep11 = "";
94495
94500
  for (const token of end) {
94496
94501
  const { source, type } = token;
94497
94502
  switch (type) {
@@ -94505,13 +94510,13 @@ var require_resolve_end = __commonJS({
94505
94510
  if (!comment)
94506
94511
  comment = cb;
94507
94512
  else
94508
- comment += sep10 + cb;
94509
- sep10 = "";
94513
+ comment += sep11 + cb;
94514
+ sep11 = "";
94510
94515
  break;
94511
94516
  }
94512
94517
  case "newline":
94513
94518
  if (comment)
94514
- sep10 += source;
94519
+ sep11 += source;
94515
94520
  hasSpace = true;
94516
94521
  break;
94517
94522
  default:
@@ -94554,18 +94559,18 @@ var require_resolve_flow_collection = __commonJS({
94554
94559
  let offset = fc.offset + fc.start.source.length;
94555
94560
  for (let i = 0; i < fc.items.length; ++i) {
94556
94561
  const collItem = fc.items[i];
94557
- const { start: start2, key: key2, sep: sep10, value } = collItem;
94562
+ const { start: start2, key: key2, sep: sep11, value } = collItem;
94558
94563
  const props = resolveProps.resolveProps(start2, {
94559
94564
  flow: fcName,
94560
94565
  indicator: "explicit-key-ind",
94561
- next: key2 ?? sep10?.[0],
94566
+ next: key2 ?? sep11?.[0],
94562
94567
  offset,
94563
94568
  onError,
94564
94569
  parentIndent: fc.indent,
94565
94570
  startOnNewline: false
94566
94571
  });
94567
94572
  if (!props.found) {
94568
- if (!props.anchor && !props.tag && !sep10 && !value) {
94573
+ if (!props.anchor && !props.tag && !sep11 && !value) {
94569
94574
  if (i === 0 && props.comma)
94570
94575
  onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
94571
94576
  else if (i < fc.items.length - 1)
@@ -94619,8 +94624,8 @@ var require_resolve_flow_collection = __commonJS({
94619
94624
  }
94620
94625
  }
94621
94626
  }
94622
- if (!isMap && !sep10 && !props.found) {
94623
- const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep10, null, props, onError);
94627
+ if (!isMap && !sep11 && !props.found) {
94628
+ const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep11, null, props, onError);
94624
94629
  coll.items.push(valueNode);
94625
94630
  offset = valueNode.range[2];
94626
94631
  if (isBlock(value))
@@ -94632,7 +94637,7 @@ var require_resolve_flow_collection = __commonJS({
94632
94637
  if (isBlock(key2))
94633
94638
  onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
94634
94639
  ctx.atKey = false;
94635
- const valueProps = resolveProps.resolveProps(sep10 ?? [], {
94640
+ const valueProps = resolveProps.resolveProps(sep11 ?? [], {
94636
94641
  flow: fcName,
94637
94642
  indicator: "map-value-ind",
94638
94643
  next: value,
@@ -94643,8 +94648,8 @@ var require_resolve_flow_collection = __commonJS({
94643
94648
  });
94644
94649
  if (valueProps.found) {
94645
94650
  if (!isMap && !props.found && ctx.options.strict) {
94646
- if (sep10)
94647
- for (const st of sep10) {
94651
+ if (sep11)
94652
+ for (const st of sep11) {
94648
94653
  if (st === valueProps.found)
94649
94654
  break;
94650
94655
  if (st.type === "newline") {
@@ -94661,7 +94666,7 @@ var require_resolve_flow_collection = __commonJS({
94661
94666
  else
94662
94667
  onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
94663
94668
  }
94664
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep10, null, valueProps, onError) : null;
94669
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep11, null, valueProps, onError) : null;
94665
94670
  if (valueNode) {
94666
94671
  if (isBlock(value))
94667
94672
  onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
@@ -94841,7 +94846,7 @@ var require_resolve_block_scalar = __commonJS({
94841
94846
  chompStart = i + 1;
94842
94847
  }
94843
94848
  let value = "";
94844
- let sep10 = "";
94849
+ let sep11 = "";
94845
94850
  let prevMoreIndented = false;
94846
94851
  for (let i = 0; i < contentStart; ++i)
94847
94852
  value += lines[i][0].slice(trimIndent) + "\n";
@@ -94858,24 +94863,24 @@ var require_resolve_block_scalar = __commonJS({
94858
94863
  indent = "";
94859
94864
  }
94860
94865
  if (type === Scalar.Scalar.BLOCK_LITERAL) {
94861
- value += sep10 + indent.slice(trimIndent) + content;
94862
- sep10 = "\n";
94866
+ value += sep11 + indent.slice(trimIndent) + content;
94867
+ sep11 = "\n";
94863
94868
  } else if (indent.length > trimIndent || content[0] === " ") {
94864
- if (sep10 === " ")
94865
- sep10 = "\n";
94866
- else if (!prevMoreIndented && sep10 === "\n")
94867
- sep10 = "\n\n";
94868
- value += sep10 + indent.slice(trimIndent) + content;
94869
- sep10 = "\n";
94869
+ if (sep11 === " ")
94870
+ sep11 = "\n";
94871
+ else if (!prevMoreIndented && sep11 === "\n")
94872
+ sep11 = "\n\n";
94873
+ value += sep11 + indent.slice(trimIndent) + content;
94874
+ sep11 = "\n";
94870
94875
  prevMoreIndented = true;
94871
94876
  } else if (content === "") {
94872
- if (sep10 === "\n")
94877
+ if (sep11 === "\n")
94873
94878
  value += "\n";
94874
94879
  else
94875
- sep10 = "\n";
94880
+ sep11 = "\n";
94876
94881
  } else {
94877
- value += sep10 + content;
94878
- sep10 = " ";
94882
+ value += sep11 + content;
94883
+ sep11 = " ";
94879
94884
  prevMoreIndented = false;
94880
94885
  }
94881
94886
  }
@@ -95058,25 +95063,25 @@ var require_resolve_flow_scalar = __commonJS({
95058
95063
  trimBoth = /^[ \t]+|[ \t]+$/g;
95059
95064
  }
95060
95065
  let res = match[1].replace(trimEnd, "");
95061
- let sep10 = " ";
95066
+ let sep11 = " ";
95062
95067
  let pos = line.lastIndex;
95063
95068
  while (match = line.exec(source)) {
95064
95069
  const lm = match[1].replace(trimBoth, "");
95065
95070
  if (lm === "") {
95066
- if (sep10 === "\n")
95067
- res += sep10;
95071
+ if (sep11 === "\n")
95072
+ res += sep11;
95068
95073
  else
95069
- sep10 = "\n";
95074
+ sep11 = "\n";
95070
95075
  } else {
95071
- res += sep10 + lm;
95072
- sep10 = " ";
95076
+ res += sep11 + lm;
95077
+ sep11 = " ";
95073
95078
  }
95074
95079
  pos = line.lastIndex;
95075
95080
  }
95076
95081
  const last = /[ \t]*(.*)/sy;
95077
95082
  last.lastIndex = pos;
95078
95083
  match = last.exec(source);
95079
- return res + sep10 + (match?.[1] ?? "");
95084
+ return res + sep11 + (match?.[1] ?? "");
95080
95085
  }
95081
95086
  function doubleQuotedValue(source, onError) {
95082
95087
  let res = "";
@@ -95886,14 +95891,14 @@ var require_cst_stringify = __commonJS({
95886
95891
  }
95887
95892
  }
95888
95893
  }
95889
- function stringifyItem({ start: start2, key: key2, sep: sep10, value }) {
95894
+ function stringifyItem({ start: start2, key: key2, sep: sep11, value }) {
95890
95895
  let res = "";
95891
95896
  for (const st of start2)
95892
95897
  res += st.source;
95893
95898
  if (key2)
95894
95899
  res += stringifyToken(key2);
95895
- if (sep10)
95896
- for (const st of sep10)
95900
+ if (sep11)
95901
+ for (const st of sep11)
95897
95902
  res += st.source;
95898
95903
  if (value)
95899
95904
  res += stringifyToken(value);
@@ -97060,18 +97065,18 @@ var require_parser2 = __commonJS({
97060
97065
  if (this.type === "map-value-ind") {
97061
97066
  const prev = getPrevProps(this.peek(2));
97062
97067
  const start2 = getFirstKeyStartProps(prev);
97063
- let sep10;
97068
+ let sep11;
97064
97069
  if (scalar.end) {
97065
- sep10 = scalar.end;
97066
- sep10.push(this.sourceToken);
97070
+ sep11 = scalar.end;
97071
+ sep11.push(this.sourceToken);
97067
97072
  delete scalar.end;
97068
97073
  } else
97069
- sep10 = [this.sourceToken];
97074
+ sep11 = [this.sourceToken];
97070
97075
  const map2 = {
97071
97076
  type: "block-map",
97072
97077
  offset: scalar.offset,
97073
97078
  indent: scalar.indent,
97074
- items: [{ start: start2, key: scalar, sep: sep10 }]
97079
+ items: [{ start: start2, key: scalar, sep: sep11 }]
97075
97080
  };
97076
97081
  this.onKeyLine = true;
97077
97082
  this.stack[this.stack.length - 1] = map2;
@@ -97224,15 +97229,15 @@ var require_parser2 = __commonJS({
97224
97229
  } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
97225
97230
  const start3 = getFirstKeyStartProps(it.start);
97226
97231
  const key2 = it.key;
97227
- const sep10 = it.sep;
97228
- sep10.push(this.sourceToken);
97232
+ const sep11 = it.sep;
97233
+ sep11.push(this.sourceToken);
97229
97234
  delete it.key;
97230
97235
  delete it.sep;
97231
97236
  this.stack.push({
97232
97237
  type: "block-map",
97233
97238
  offset: this.offset,
97234
97239
  indent: this.indent,
97235
- items: [{ start: start3, key: key2, sep: sep10 }]
97240
+ items: [{ start: start3, key: key2, sep: sep11 }]
97236
97241
  });
97237
97242
  } else if (start2.length > 0) {
97238
97243
  it.sep = it.sep.concat(start2, this.sourceToken);
@@ -97426,13 +97431,13 @@ var require_parser2 = __commonJS({
97426
97431
  const prev = getPrevProps(parent);
97427
97432
  const start2 = getFirstKeyStartProps(prev);
97428
97433
  fixFlowSeqItems(fc);
97429
- const sep10 = fc.end.splice(1, fc.end.length);
97430
- sep10.push(this.sourceToken);
97434
+ const sep11 = fc.end.splice(1, fc.end.length);
97435
+ sep11.push(this.sourceToken);
97431
97436
  const map2 = {
97432
97437
  type: "block-map",
97433
97438
  offset: fc.offset,
97434
97439
  indent: fc.indent,
97435
- items: [{ start: start2, key: fc, sep: sep10 }]
97440
+ items: [{ start: start2, key: fc, sep: sep11 }]
97436
97441
  };
97437
97442
  this.onKeyLine = true;
97438
97443
  this.stack[this.stack.length - 1] = map2;
@@ -101273,7 +101278,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
101273
101278
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
101274
101279
  function readCliVersion() {
101275
101280
  if (true) {
101276
- return "0.33.1-next.2";
101281
+ return "0.33.1-next.21";
101277
101282
  }
101278
101283
  return "0.0.0";
101279
101284
  }
@@ -102108,12 +102113,277 @@ async function shutdown(timeoutMs = SHORT_FLUSH_TIMEOUT_MS) {
102108
102113
  // ../tool-server/src/http.ts
102109
102114
  var import_express3 = __toESM(require_express2());
102110
102115
  var import_bytes2 = __toESM(require_bytes());
102111
- var import_node_fs11 = require("node:fs");
102112
- var import_promises12 = require("node:fs/promises");
102116
+ var import_node_fs12 = require("node:fs");
102117
+ var import_promises13 = require("node:fs/promises");
102113
102118
  var import_node_os11 = require("node:os");
102114
102119
  var import_node_path15 = require("node:path");
102115
102120
  init_src();
102116
102121
  var import_node_crypto11 = require("node:crypto");
102122
+
102123
+ // ../archive/src/index.ts
102124
+ var import_node_child_process2 = require("node:child_process");
102125
+ var import_node_fs2 = require("node:fs");
102126
+ var import_promises2 = require("node:fs/promises");
102127
+ var import_node_path3 = require("node:path");
102128
+ var import_node_stream = require("node:stream");
102129
+ var import_promises3 = require("node:stream/promises");
102130
+ var import_node_zlib = __toESM(require("node:zlib"), 1);
102131
+ var ArchiveError = class extends Error {
102132
+ };
102133
+ var ARCHIVE_FORMATS = typeof import_node_zlib.default.createZstdCompress === "function" ? ["zstd", "gzip"] : ["gzip"];
102134
+ var ARCHIVE_CONTENT_TYPES = {
102135
+ zstd: "application/zstd",
102136
+ gzip: "application/gzip"
102137
+ };
102138
+ function pickArchiveFormat(peerFormats) {
102139
+ return ARCHIVE_FORMATS.find((f) => peerFormats?.includes(f)) ?? "gzip";
102140
+ }
102141
+ function archiveFormatsFromAccept(accept2) {
102142
+ const accepted = /* @__PURE__ */ new Set();
102143
+ for (const range of accept2?.split(",") ?? []) {
102144
+ const [type = "", ...params] = range.split(";").map((part) => part.trim().toLowerCase());
102145
+ const q = params.find((param) => param.startsWith("q="));
102146
+ if (q === void 0 || Number(q.slice(2)) > 0) accepted.add(type);
102147
+ }
102148
+ return ARCHIVE_FORMATS.filter((f) => accepted.has(ARCHIVE_CONTENT_TYPES[f]));
102149
+ }
102150
+ var CHUNK_BYTES = 1 << 20;
102151
+ function createCompressor(format) {
102152
+ return format === "zstd" ? import_node_zlib.default.createZstdCompress({
102153
+ chunkSize: CHUNK_BYTES,
102154
+ // Lets the decoder detect corruption.
102155
+ params: { [import_node_zlib.default.constants.ZSTD_c_checksumFlag]: 1 }
102156
+ }) : import_node_zlib.default.createGzip({ chunkSize: CHUNK_BYTES });
102157
+ }
102158
+ function createTarArgs(sourcePath) {
102159
+ const name = (0, import_node_path3.basename)(sourcePath);
102160
+ return ["-cf", "-", "-C", (0, import_node_path3.dirname)(sourcePath), /^[-@]/.test(name) ? `./${name}` : name];
102161
+ }
102162
+ var MAX_LISTING_BYTES = 32 << 20;
102163
+ var MAX_LISTING_LINES = 1 << 18;
102164
+ var MAX_STDERR_BYTES = 16 << 10;
102165
+ var MAX_UNREAD_BYTES = 16 << 20;
102166
+ function collect(stream, maxBytes, { maxLines = Infinity, onOverflow } = {}) {
102167
+ const chunks = [];
102168
+ let bytes = 0;
102169
+ let lines = 0;
102170
+ let overflowed = false;
102171
+ stream?.on("data", (chunk) => {
102172
+ if (overflowed) return;
102173
+ chunks.push(chunk.subarray(0, maxBytes - bytes));
102174
+ bytes += chunk.length;
102175
+ for (let i = chunk.indexOf(10); i !== -1 && lines <= maxLines; i = chunk.indexOf(10, i + 1)) {
102176
+ lines++;
102177
+ }
102178
+ if (bytes > maxBytes || lines > maxLines) {
102179
+ overflowed = true;
102180
+ onOverflow?.();
102181
+ }
102182
+ });
102183
+ return {
102184
+ overflowed: () => overflowed,
102185
+ text: () => Buffer.concat(chunks).toString("utf8") + (overflowed ? "\u2026" : "")
102186
+ };
102187
+ }
102188
+ async function sniffFormat(archivePath) {
102189
+ const fh = await (0, import_promises2.open)(archivePath, "r");
102190
+ try {
102191
+ const { buffer, bytesRead } = await fh.read(Buffer.alloc(4), 0, 4, 0);
102192
+ const magic = buffer.subarray(0, bytesRead).toString("hex");
102193
+ if (magic.startsWith("1f8b")) return "gzip";
102194
+ if (magic === "28b52ffd" && ARCHIVE_FORMATS.includes("zstd")) return "zstd";
102195
+ throw new ArchiveError("unrecognized compression");
102196
+ } finally {
102197
+ await fh.close();
102198
+ }
102199
+ }
102200
+ var ZSTD_FRAME_MAGIC = 4247762216;
102201
+ async function assertSingleCompleteZstdFrame(archivePath) {
102202
+ const fh = await (0, import_promises2.open)(archivePath, "r");
102203
+ try {
102204
+ const { size } = await fh.stat();
102205
+ const window2 = Buffer.alloc(4096);
102206
+ let windowStart = 0;
102207
+ let windowEnd = 0;
102208
+ let pos = 0;
102209
+ const read = async (n) => {
102210
+ if (pos < windowStart || pos + n > windowEnd) {
102211
+ const { bytesRead } = await fh.read(window2, 0, window2.length, pos);
102212
+ windowStart = pos;
102213
+ windowEnd = pos + bytesRead;
102214
+ if (bytesRead < n) throw new ArchiveError("truncated zstd frame");
102215
+ }
102216
+ return window2.subarray(pos - windowStart, pos - windowStart + n);
102217
+ };
102218
+ for (let frame2 = 0; pos < size; frame2++) {
102219
+ const header = await read(5);
102220
+ if (header.readUInt32LE(0) !== ZSTD_FRAME_MAGIC) throw new ArchiveError("bad zstd frame");
102221
+ const descriptor = header[4];
102222
+ const singleSegment = descriptor >> 5 & 1;
102223
+ pos += 5 + (singleSegment ? 0 : 1) + // window descriptor
102224
+ [0, 1, 2, 4][descriptor & 3] + // dictionary id
102225
+ [singleSegment, 2, 4, 8][descriptor >> 6];
102226
+ let hasData = false;
102227
+ for (let last = 0; !last; ) {
102228
+ const block = (await read(3)).readUIntLE(0, 3);
102229
+ last = block & 1;
102230
+ const type = block >> 1 & 3;
102231
+ const blockSize = block >> 3;
102232
+ if (blockSize > 0) hasData = true;
102233
+ pos += 3 + (type === 1 ? 1 : blockSize);
102234
+ }
102235
+ if (descriptor >> 2 & 1) pos += 4;
102236
+ if (hasData && frame2 > 0) throw new ArchiveError("multi-frame zstd");
102237
+ }
102238
+ if (pos !== size) throw new ArchiveError("truncated zstd frame");
102239
+ } finally {
102240
+ await fh.close();
102241
+ }
102242
+ }
102243
+ var TAR_LOCALE = process.platform === "darwin" ? "en_US.UTF-8" : "C.UTF-8";
102244
+ function tarEnv(env) {
102245
+ const characterType = env.LC_ALL || env.LC_CTYPE || env.LANG || "";
102246
+ return /utf-?8/i.test(characterType) ? env : { ...env, LC_ALL: TAR_LOCALE };
102247
+ }
102248
+ async function runTar(archive, args) {
102249
+ const child = (0, import_node_child_process2.spawn)("tar", [...args, "-f", "-"], {
102250
+ env: tarEnv(process.env)
102251
+ });
102252
+ const exited = new Promise((res, rej) => {
102253
+ child.on("error", rej);
102254
+ child.on("close", res);
102255
+ });
102256
+ const stdout = collect(child.stdout, MAX_LISTING_BYTES, {
102257
+ maxLines: MAX_LISTING_LINES,
102258
+ onOverflow: () => child.kill()
102259
+ });
102260
+ const stderr = collect(child.stderr, MAX_STDERR_BYTES);
102261
+ child.stdin?.on("error", () => {
102262
+ });
102263
+ const unreadLimit = new Error("unread limit");
102264
+ let unread = 0;
102265
+ const fed = (0, import_promises3.pipeline)(
102266
+ (0, import_node_fs2.createReadStream)(archive.path, { highWaterMark: CHUNK_BYTES }),
102267
+ archive.format === "zstd" ? import_node_zlib.default.createZstdDecompress({ chunkSize: CHUNK_BYTES }) : import_node_zlib.default.createGunzip({ chunkSize: CHUNK_BYTES }),
102268
+ new import_node_stream.Writable({
102269
+ write(chunk, _encoding, done) {
102270
+ if (child.stdin?.writable) return void child.stdin.write(chunk, () => done());
102271
+ unread += chunk.length;
102272
+ done(unread > MAX_UNREAD_BYTES ? unreadLimit : null);
102273
+ },
102274
+ final(done) {
102275
+ child.stdin?.end();
102276
+ done();
102277
+ },
102278
+ destroy(err, done) {
102279
+ if (err) child.stdin?.destroy();
102280
+ done(err);
102281
+ }
102282
+ })
102283
+ ).then(
102284
+ () => null,
102285
+ (err) => err
102286
+ );
102287
+ const [code, feedError] = await Promise.all([exited, fed]);
102288
+ if (stdout.overflowed()) {
102289
+ throw new Error(
102290
+ `tar ${args.join(" ")} listed more than ${MAX_LISTING_LINES} members or ${MAX_LISTING_BYTES >> 20} MiB`
102291
+ );
102292
+ }
102293
+ if (feedError && feedError !== unreadLimit) throw feedError;
102294
+ if (code !== 0)
102295
+ throw new Error(`tar ${args.join(" ")} exited with code ${code}: ${stderr.text().trim()}`);
102296
+ return stdout.text();
102297
+ }
102298
+ function normalizeTarMemberPath(memberPath2) {
102299
+ return memberPath2.replace(/^\.\//, "").replace(/\\/g, "/");
102300
+ }
102301
+ function isContainedPath(path63, windows = process.platform === "win32") {
102302
+ const slashed = path63.replace(/\\/g, "/");
102303
+ const drive = windows ? /^[A-Za-z]:/ : /^[A-Za-z]:\//;
102304
+ return !slashed.startsWith("/") && !drive.test(slashed) && !slashed.split("/").includes("..");
102305
+ }
102306
+ function isSafeTarMember(memberPath2, destDir) {
102307
+ const normalized = normalizeTarMemberPath(memberPath2);
102308
+ if (!isContainedPath(normalized)) return false;
102309
+ const root = (0, import_node_path3.resolve)(destDir);
102310
+ return (0, import_node_path3.resolve)(destDir, normalized).startsWith(root + import_node_path3.sep);
102311
+ }
102312
+ async function readListing(archive, args) {
102313
+ try {
102314
+ return await runTar(archive, args);
102315
+ } catch (err) {
102316
+ throw new ArchiveError(
102317
+ `Could not read archive: ${err instanceof Error ? err.message : String(err)}`
102318
+ );
102319
+ }
102320
+ }
102321
+ async function listTarMembers(archive) {
102322
+ const stdout = await readListing(archive, ["-t"]);
102323
+ return stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
102324
+ }
102325
+ async function assertSafeMemberTypes(archive) {
102326
+ const stdout = await readListing(archive, ["-tv"]);
102327
+ for (const line of stdout.split("\n")) {
102328
+ if (!line.trim()) continue;
102329
+ const type = line[0];
102330
+ if (type === "-" || type === "d") continue;
102331
+ if (type === "l") {
102332
+ const parts2 = line.split(" -> ");
102333
+ const target = parts2.length === 2 ? parts2[1].trim() : "";
102334
+ if (parts2.length !== 2 || !target || !isContainedPath(target)) {
102335
+ throw new ArchiveError(
102336
+ `Archive contains a symlink whose target could not be confirmed safe: "${line.trim()}".`
102337
+ );
102338
+ }
102339
+ continue;
102340
+ }
102341
+ throw new ArchiveError(
102342
+ `Archive contains an unsupported member type "${type}" (hardlink/device/\u2026) \u2014 refusing extraction.`
102343
+ );
102344
+ }
102345
+ }
102346
+ async function assertSafeArchive(archive, destDir) {
102347
+ const members2 = await listTarMembers(archive);
102348
+ if (members2.length === 0) {
102349
+ throw new ArchiveError("Archive is empty.");
102350
+ }
102351
+ for (const member of members2) {
102352
+ if (!isSafeTarMember(member, destDir)) {
102353
+ throw new ArchiveError(`Archive contains an unsafe path "${member}" \u2014 refusing extraction.`);
102354
+ }
102355
+ }
102356
+ await assertSafeMemberTypes(archive);
102357
+ }
102358
+ async function resolveMember(destDir, expectedName) {
102359
+ const entries = await (0, import_promises2.readdir)(destDir);
102360
+ if (entries.includes(expectedName)) {
102361
+ return (0, import_node_path3.join)(destDir, expectedName);
102362
+ }
102363
+ const real = entries.filter((e) => !e.startsWith("._"));
102364
+ if (real.length !== 1) {
102365
+ throw new ArchiveError(
102366
+ `Could not identify the extracted member (expected "${expectedName}", found ${real.length} entries).`
102367
+ );
102368
+ }
102369
+ return (0, import_node_path3.join)(destDir, real[0]);
102370
+ }
102371
+ async function safeExtractArchive(archivePath, destDir, expectedName) {
102372
+ let archive;
102373
+ try {
102374
+ archive = { path: archivePath, format: await sniffFormat(archivePath) };
102375
+ if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath);
102376
+ } catch (err) {
102377
+ throw new ArchiveError(
102378
+ `Could not read archive: ${err instanceof Error ? err.message : String(err)}`
102379
+ );
102380
+ }
102381
+ await assertSafeArchive(archive, destDir);
102382
+ await runTar(archive, ["-x", "-C", destDir]);
102383
+ return resolveMember(destDir, expectedName);
102384
+ }
102385
+
102386
+ // ../tool-server/src/http.ts
102117
102387
  init_src2();
102118
102388
  init_src2();
102119
102389
 
@@ -102155,21 +102425,21 @@ function createIdleTimer(timeoutMs, onIdle) {
102155
102425
  init_android_binary();
102156
102426
 
102157
102427
  // ../tool-server/src/utils/vega-cli.ts
102158
- var import_node_child_process4 = require("node:child_process");
102428
+ var import_node_child_process5 = require("node:child_process");
102159
102429
  var import_node_util3 = require("node:util");
102160
- var import_node_fs4 = require("node:fs");
102161
- var import_promises3 = require("node:fs/promises");
102430
+ var import_node_fs5 = require("node:fs");
102431
+ var import_promises5 = require("node:fs/promises");
102162
102432
  var import_node_os3 = require("node:os");
102163
- var import_node_path5 = require("node:path");
102433
+ var import_node_path6 = require("node:path");
102164
102434
  init_src2();
102165
102435
  init_subprocess_error();
102166
102436
 
102167
102437
  // ../tool-server/src/utils/vega-process.ts
102168
- var import_node_child_process3 = require("node:child_process");
102438
+ var import_node_child_process4 = require("node:child_process");
102169
102439
  var import_node_util2 = require("node:util");
102170
- var import_node_fs3 = require("node:fs");
102171
- var execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process3.execFile);
102172
- var PS_BIN = ["/bin/ps", "/usr/bin/ps"].find((p) => (0, import_node_fs3.existsSync)(p)) ?? "ps";
102440
+ var import_node_fs4 = require("node:fs");
102441
+ var execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process4.execFile);
102442
+ var PS_BIN = ["/bin/ps", "/usr/bin/ps"].find((p) => (0, import_node_fs4.existsSync)(p)) ?? "ps";
102173
102443
  var PS_ARGS = ["-A", "-ww", "-o", "command="];
102174
102444
  var PS_ARGS_WITH_PID = ["-A", "-ww", "-o", "pid=,command="];
102175
102445
  var VVD_PROCESS_RE = /(?:^|\/)(?:vega|kepler)-virtual-device(?:\s|$)/;
@@ -102234,12 +102504,12 @@ async function listRunningVvdPids() {
102234
102504
 
102235
102505
  // ../tool-server/src/utils/vega-cli.ts
102236
102506
  init_command_on_path();
102237
- var execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process4.execFile);
102507
+ var execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process5.execFile);
102238
102508
  var VEGA_BINARY_TTL_MS = 6e4;
102239
102509
  var cachedVegaBinary;
102240
102510
  async function isExecutable(p) {
102241
102511
  try {
102242
- await (0, import_promises3.access)(p, import_node_fs4.constants.X_OK);
102512
+ await (0, import_promises5.access)(p, import_node_fs5.constants.X_OK);
102243
102513
  return true;
102244
102514
  } catch {
102245
102515
  return false;
@@ -102251,7 +102521,7 @@ async function resolveVegaBinary() {
102251
102521
  return cachedVegaBinary.path;
102252
102522
  }
102253
102523
  const onPath = await commandOnPath("vega") ?? await commandOnPath("kepler");
102254
- const fallback = (0, import_node_path5.join)((0, import_node_os3.homedir)(), "vega", "bin", "vega");
102524
+ const fallback = (0, import_node_path6.join)((0, import_node_os3.homedir)(), "vega", "bin", "vega");
102255
102525
  const path63 = onPath ?? (await isExecutable(fallback) ? fallback : null);
102256
102526
  cachedVegaBinary = { path: path63, checkedAt: now };
102257
102527
  return path63;
@@ -102358,7 +102628,7 @@ async function reapLingeringGroupMembers(pid) {
102358
102628
  } catch {
102359
102629
  }
102360
102630
  }
102361
- function resolveSpawnCwd(getCwd = () => process.cwd(), dirExists = import_node_fs4.existsSync, fallback = (0, import_node_os3.tmpdir)()) {
102631
+ function resolveSpawnCwd(getCwd = () => process.cwd(), dirExists = import_node_fs5.existsSync, fallback = (0, import_node_os3.tmpdir)()) {
102362
102632
  try {
102363
102633
  const cwd = getCwd();
102364
102634
  if (dirExists(cwd)) return cwd;
@@ -102390,7 +102660,7 @@ async function runVega(args, options = {}) {
102390
102660
  return new Promise((resolve19, reject) => {
102391
102661
  let child;
102392
102662
  try {
102393
- child = (0, import_node_child_process4.spawn)(vegaPath, args, {
102663
+ child = (0, import_node_child_process5.spawn)(vegaPath, args, {
102394
102664
  cwd: resolveSpawnCwd(),
102395
102665
  detached: true,
102396
102666
  stdio: ["ignore", "pipe", "pipe"]
@@ -102530,26 +102800,26 @@ async function vegaDevice(serial, subcommand, options = {}) {
102530
102800
  }
102531
102801
 
102532
102802
  // ../tool-server/src/utils/harmony-cli.ts
102533
- var import_node_child_process5 = require("node:child_process");
102803
+ var import_node_child_process6 = require("node:child_process");
102534
102804
  var import_node_util4 = require("node:util");
102535
- var import_promises4 = require("node:fs/promises");
102536
- var import_node_path6 = require("node:path");
102805
+ var import_promises6 = require("node:fs/promises");
102806
+ var import_node_path7 = require("node:path");
102537
102807
  init_src2();
102538
102808
  init_subprocess_error();
102539
- var execFileAsync4 = (0, import_node_util4.promisify)(import_node_child_process5.execFile);
102809
+ var execFileAsync4 = (0, import_node_util4.promisify)(import_node_child_process6.execFile);
102540
102810
  var HARMONY_EMPTY_SENTINEL = "[Empty]";
102541
102811
  var MACOS_DEVECO_APP = "/Applications/DevEco-Studio.app";
102542
- var EMULATOR_RELATIVE = (0, import_node_path6.join)("tools", "emulator", "Emulator");
102812
+ var EMULATOR_RELATIVE = (0, import_node_path7.join)("tools", "emulator", "Emulator");
102543
102813
  function devecoRoots() {
102544
102814
  const roots = [];
102545
102815
  const configured = process.env.DEVECO_STUDIO_HOME?.trim();
102546
102816
  if (configured) roots.push(configured);
102547
102817
  if (process.platform === "darwin") roots.push(MACOS_DEVECO_APP);
102548
- return roots.flatMap((root) => [root, (0, import_node_path6.join)(root, "Contents")]);
102818
+ return roots.flatMap((root) => [root, (0, import_node_path7.join)(root, "Contents")]);
102549
102819
  }
102550
102820
  async function isExecutable2(p) {
102551
102821
  try {
102552
- await (0, import_promises4.access)(p, import_promises4.constants.X_OK);
102822
+ await (0, import_promises6.access)(p, import_promises6.constants.X_OK);
102553
102823
  return true;
102554
102824
  } catch {
102555
102825
  return false;
@@ -102557,7 +102827,7 @@ async function isExecutable2(p) {
102557
102827
  }
102558
102828
  async function resolveDevecoBinary(relative9) {
102559
102829
  for (const root of devecoRoots()) {
102560
- const candidate = (0, import_node_path6.join)(root, relative9) + BIN_EXT2;
102830
+ const candidate = (0, import_node_path7.join)(root, relative9) + BIN_EXT2;
102561
102831
  if (await isExecutable2(candidate)) return candidate;
102562
102832
  }
102563
102833
  return null;
@@ -102636,17 +102906,17 @@ function isChinaOnlyRestriction(diagnostic) {
102636
102906
  }
102637
102907
 
102638
102908
  // ../tool-server/src/utils/harmony-hdc.ts
102639
- var import_node_child_process6 = require("node:child_process");
102909
+ var import_node_child_process7 = require("node:child_process");
102640
102910
  var import_node_util5 = require("node:util");
102641
- var import_node_path7 = require("node:path");
102911
+ var import_node_path8 = require("node:path");
102642
102912
  init_src2();
102643
102913
  init_subprocess_error();
102644
102914
  init_command_on_path();
102645
- var execFileAsync5 = (0, import_node_util5.promisify)(import_node_child_process6.execFile);
102915
+ var execFileAsync5 = (0, import_node_util5.promisify)(import_node_child_process7.execFile);
102646
102916
  var HDC_FAILURE_PREFIX = "[Fail]";
102647
102917
  var HDC_EMPTY_SENTINEL = "[Empty]";
102648
102918
  var RC_SENTINEL = "__argent_hdc_rc";
102649
- var HDC_RELATIVE = (0, import_node_path7.join)("sdk", "default", "openharmony", "toolchains", "hdc");
102919
+ var HDC_RELATIVE = (0, import_node_path8.join)("sdk", "default", "openharmony", "toolchains", "hdc");
102650
102920
  var BINARY_TTL_MS2 = 6e4;
102651
102921
  var cachedHdc;
102652
102922
  async function resolveHdc() {
@@ -102778,7 +103048,7 @@ init_src2();
102778
103048
  // ../tool-server/src/utils/xcode-first-launch.ts
102779
103049
  var fs11 = __toESM(require("node:fs"));
102780
103050
  var path11 = __toESM(require("node:path"));
102781
- var import_node_child_process7 = require("node:child_process");
103051
+ var import_node_child_process8 = require("node:child_process");
102782
103052
  var WRAPPER_DEVICES = {
102783
103053
  simctl: "local iOS simulators",
102784
103054
  devicectl: "physical iPhones"
@@ -102863,7 +103133,7 @@ function readBundleVersion(plistPath) {
102863
103133
  var PLUTIL_TIMEOUT_MS = 1e3;
102864
103134
  function readBinaryPlistVersion(plistPath) {
102865
103135
  try {
102866
- const version3 = (0, import_node_child_process7.execFileSync)(
103136
+ const version3 = (0, import_node_child_process8.execFileSync)(
102867
103137
  "/usr/bin/plutil",
102868
103138
  ["-extract", "CFBundleVersion", "raw", "-o", "-", plistPath],
102869
103139
  {
@@ -103037,9 +103307,9 @@ function toSimulatorNetworkError(toolLabel, err, apiUrl, fallbackHint) {
103037
103307
  }
103038
103308
 
103039
103309
  // ../tool-server/src/utils/update-checker.ts
103040
- var import_node_fs5 = __toESM(require("node:fs"));
103310
+ var import_node_fs6 = __toESM(require("node:fs"));
103041
103311
  var import_node_os4 = __toESM(require("node:os"));
103042
- var import_node_path8 = __toESM(require("node:path"));
103312
+ var import_node_path9 = __toESM(require("node:path"));
103043
103313
  var import_semver2 = __toESM(require_semver2());
103044
103314
 
103045
103315
  // ../tool-server/package.json
@@ -103051,11 +103321,11 @@ var PACKAGE_NAME = "@swmansion/argent";
103051
103321
  var REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}`;
103052
103322
  var CHECK_INTERVAL_MS = 60 * 60 * 1e3 * 24;
103053
103323
  function getSuppressionFilePath() {
103054
- return import_node_path8.default.join(import_node_os4.default.homedir(), ".argent", "update-suppression.json");
103324
+ return import_node_path9.default.join(import_node_os4.default.homedir(), ".argent", "update-suppression.json");
103055
103325
  }
103056
103326
  function loadSuppressUntil() {
103057
103327
  try {
103058
- const raw = import_node_fs5.default.readFileSync(getSuppressionFilePath(), "utf8");
103328
+ const raw = import_node_fs6.default.readFileSync(getSuppressionFilePath(), "utf8");
103059
103329
  const parsed = JSON.parse(raw);
103060
103330
  const value = parsed.suppressUntil;
103061
103331
  return typeof value === "number" && Number.isFinite(value) ? value : 0;
@@ -103065,13 +103335,13 @@ function loadSuppressUntil() {
103065
103335
  }
103066
103336
  function persistSuppressUntil(value) {
103067
103337
  const filePath = getSuppressionFilePath();
103068
- import_node_fs5.default.mkdirSync(import_node_path8.default.dirname(filePath), { recursive: true });
103338
+ import_node_fs6.default.mkdirSync(import_node_path9.default.dirname(filePath), { recursive: true });
103069
103339
  const tempPath = `${filePath}.${process.pid}.tmp`;
103070
103340
  try {
103071
- import_node_fs5.default.writeFileSync(tempPath, JSON.stringify({ suppressUntil: value }));
103072
- import_node_fs5.default.renameSync(tempPath, filePath);
103341
+ import_node_fs6.default.writeFileSync(tempPath, JSON.stringify({ suppressUntil: value }));
103342
+ import_node_fs6.default.renameSync(tempPath, filePath);
103073
103343
  } catch (error63) {
103074
- import_node_fs5.default.rmSync(tempPath, { force: true });
103344
+ import_node_fs6.default.rmSync(tempPath, { force: true });
103075
103345
  throw error63;
103076
103346
  }
103077
103347
  }
@@ -103211,10 +103481,10 @@ function buildScreenRecordingNote(recordings2, nowMs) {
103211
103481
  }
103212
103482
 
103213
103483
  // ../tool-server/src/utils/ios-device/team-detect.ts
103214
- var import_node_child_process8 = require("node:child_process");
103484
+ var import_node_child_process9 = require("node:child_process");
103215
103485
  var import_node_util6 = require("node:util");
103216
103486
  var import_node_crypto5 = require("node:crypto");
103217
- var execFileAsync6 = (0, import_node_util6.promisify)(import_node_child_process8.execFile);
103487
+ var execFileAsync6 = (0, import_node_util6.promisify)(import_node_child_process9.execFile);
103218
103488
  var SIGNING_CERT_COMMON_NAMES = ["Apple Development", "iPhone Developer"];
103219
103489
  var SECURITY_TIMEOUT_MS = 15e3;
103220
103490
  async function listCertificatePem(commonName) {
@@ -103352,14 +103622,14 @@ function consumePendingSigningDetectionNote(udid) {
103352
103622
  }
103353
103623
 
103354
103624
  // ../tool-server/src/preview.ts
103355
- var import_node_fs8 = __toESM(require("node:fs"));
103625
+ var import_node_fs9 = __toESM(require("node:fs"));
103356
103626
  var import_node_os7 = __toESM(require("node:os"));
103357
- var import_node_path11 = __toESM(require("node:path"));
103627
+ var import_node_path12 = __toESM(require("node:path"));
103358
103628
  var import_express = __toESM(require_express2());
103359
103629
  init_src();
103360
103630
 
103361
103631
  // ../tool-server/src/blueprints/simulator-server.ts
103362
- var import_node_child_process16 = require("node:child_process");
103632
+ var import_node_child_process17 = require("node:child_process");
103363
103633
  var readline = __toESM(require("node:readline"));
103364
103634
  init_src2();
103365
103635
  init_src();
@@ -103515,7 +103785,7 @@ init_src2();
103515
103785
  init_external_devices();
103516
103786
 
103517
103787
  // ../tool-server/src/utils/ios-host.ts
103518
- var import_node_child_process13 = require("node:child_process");
103788
+ var import_node_child_process14 = require("node:child_process");
103519
103789
  var import_node_events = require("node:events");
103520
103790
  var fs16 = __toESM(require("node:fs"));
103521
103791
  var path16 = __toESM(require("node:path"));
@@ -103527,12 +103797,12 @@ var SIMCTL_KILL_SIGNAL = "SIGKILL";
103527
103797
 
103528
103798
  // ../tool-server/src/utils/ios-device-sets.ts
103529
103799
  var fs14 = __toESM(require("node:fs"));
103530
- var import_node_child_process9 = require("node:child_process");
103800
+ var import_node_child_process10 = require("node:child_process");
103531
103801
  var import_node_util7 = require("node:util");
103532
103802
  init_src2();
103533
103803
  init_src();
103534
103804
  init_external_devices();
103535
- var execFileAsync7 = (0, import_node_util7.promisify)(import_node_child_process9.execFile);
103805
+ var execFileAsync7 = (0, import_node_util7.promisify)(import_node_child_process10.execFile);
103536
103806
  var deviceSetByUdid = /* @__PURE__ */ new Map();
103537
103807
  function configuredAdditionalDeviceSets() {
103538
103808
  try {
@@ -103629,11 +103899,11 @@ function nativeArgs(udid, args) {
103629
103899
  // ../tool-server/src/utils/ios-devices.ts
103630
103900
  var fs15 = __toESM(require("node:fs"));
103631
103901
  var path14 = __toESM(require("node:path"));
103632
- var import_node_child_process10 = require("node:child_process");
103902
+ var import_node_child_process11 = require("node:child_process");
103633
103903
  var import_node_util8 = require("node:util");
103634
103904
  init_external_devices();
103635
103905
  init_device_info();
103636
- var execFileAsync8 = (0, import_node_util8.promisify)(import_node_child_process10.execFile);
103906
+ var execFileAsync8 = (0, import_node_util8.promisify)(import_node_child_process11.execFile);
103637
103907
  var SIMCTL_LIST_TIMEOUT_MS = 1e4;
103638
103908
  function simctlListTimeoutAdvice(retry) {
103639
103909
  return `\`xcrun simctl list\` did not answer within ${SIMCTL_LIST_TIMEOUT_MS / 1e3}s. CoreSimulatorService is probably still starting, which can take about a minute after a reboot, so call ${retry} again shortly. If it keeps timing out and Xcode was just updated, ask the user to ${xcodeInstallInstruction()}; otherwise restart CoreSimulatorService.`;
@@ -103792,9 +104062,9 @@ async function isFoldableSimulator(udid) {
103792
104062
  var fsAsync = __toESM(require("node:fs/promises"));
103793
104063
  var os4 = __toESM(require("node:os"));
103794
104064
  var path15 = __toESM(require("node:path"));
103795
- var import_node_child_process11 = require("node:child_process");
104065
+ var import_node_child_process12 = require("node:child_process");
103796
104066
  var import_node_util9 = require("node:util");
103797
- var execFileAsync9 = (0, import_node_util9.promisify)(import_node_child_process11.execFile);
104067
+ var execFileAsync9 = (0, import_node_util9.promisify)(import_node_child_process12.execFile);
103798
104068
  async function ensureAutomationEnabled(udid) {
103799
104069
  await execFileAsync9(
103800
104070
  "xcrun",
@@ -103865,10 +104135,10 @@ async function setAccessibilityPrefsPreBoot(udid) {
103865
104135
  }
103866
104136
 
103867
104137
  // ../tool-server/src/utils/sim-remote.ts
103868
- var import_node_child_process12 = require("node:child_process");
104138
+ var import_node_child_process13 = require("node:child_process");
103869
104139
  var import_node_util10 = require("node:util");
103870
104140
  init_device_info();
103871
- var execFileAsync10 = (0, import_node_util10.promisify)(import_node_child_process12.execFile);
104141
+ var execFileAsync10 = (0, import_node_util10.promisify)(import_node_child_process13.execFile);
103872
104142
  var SIM_REMOTE_TIMEOUT_MS = 3e4;
103873
104143
  function simRemoteExecError(err) {
103874
104144
  return err.cause ?? err;
@@ -104048,7 +104318,7 @@ async function moqInfo(udid) {
104048
104318
  }
104049
104319
 
104050
104320
  // ../tool-server/src/utils/ios-host.ts
104051
- var execFileAsync11 = (0, import_node_util11.promisify)(import_node_child_process13.execFile);
104321
+ var execFileAsync11 = (0, import_node_util11.promisify)(import_node_child_process14.execFile);
104052
104322
  var ARGENT_BOOTSTRAP_DYLIB_BASENAMES = /* @__PURE__ */ new Set(["libArgentInjectionBootstrap.dylib"]);
104053
104323
  var RECOGNISED_BOOTSTRAP_DYLIB_BASENAMES = /* @__PURE__ */ new Set([
104054
104324
  ...ARGENT_BOOTSTRAP_DYLIB_BASENAMES,
@@ -104279,7 +104549,7 @@ function spawnAxDaemonLocal(udid, endpoint) {
104279
104549
  }
104280
104550
  const endpointArgs = endpoint.transport === "tcp" ? ["--port", String(endpoint.port)] : ["--socket", endpoint.socketPath];
104281
104551
  const axTarget = simctlTargetForUdidSync(udid, { granted: "ax-service" });
104282
- const proc = (0, import_node_child_process13.execFile)(
104552
+ const proc = (0, import_node_child_process14.execFile)(
104283
104553
  "xcrun",
104284
104554
  [
104285
104555
  ...axTarget.prefix,
@@ -105567,11 +105837,11 @@ __export(path_exports, {
105567
105837
  encode: () => encode3,
105568
105838
  from: () => from,
105569
105839
  hasPrefix: () => hasPrefix,
105570
- join: () => join17,
105840
+ join: () => join18,
105571
105841
  normalizeRelative: () => normalizeRelative,
105572
105842
  parts: () => parts,
105573
105843
  relative: () => relative,
105574
- resolve: () => resolve7,
105844
+ resolve: () => resolve8,
105575
105845
  stripPrefix: () => stripPrefix,
105576
105846
  tryResolve: () => tryResolve
105577
105847
  });
@@ -105617,7 +105887,7 @@ function stripPrefix(prefix, path63) {
105617
105887
  }
105618
105888
  return path63.slice(prefix.length + 1);
105619
105889
  }
105620
- function join17(path63, other) {
105890
+ function join18(path63, other) {
105621
105891
  if (path63 === "") {
105622
105892
  return other;
105623
105893
  } else if (other === "") {
@@ -105634,7 +105904,7 @@ function normalizeRelative(rel) {
105634
105904
  const normalized = raw.filter((s) => s !== "" && s !== ".").join("/");
105635
105905
  return normalized === "" && raw.includes(".") ? "." : normalized;
105636
105906
  }
105637
- function resolve7(base, rel) {
105907
+ function resolve8(base, rel) {
105638
105908
  if (rel === "")
105639
105909
  return base;
105640
105910
  const segments = base === "" ? [] : base.split("/");
@@ -108182,9 +108452,9 @@ var Writer = class _Writer {
108182
108452
  */
108183
108453
  static async tryOpen(quic, options) {
108184
108454
  const cancelled = options.cancel.then(() => void 0, () => void 0);
108185
- const open4 = _Writer.open(quic, options);
108455
+ const open5 = _Writer.open(quic, options);
108186
108456
  try {
108187
- const stream = await Promise.race([cancelled, open4]);
108457
+ const stream = await Promise.race([cancelled, open5]);
108188
108458
  if (stream)
108189
108459
  return stream;
108190
108460
  } catch (err) {
@@ -108193,7 +108463,7 @@ var Writer = class _Writer {
108193
108463
  return void 0;
108194
108464
  }
108195
108465
  const abandoned = new Error("abandoned waiting for a stream slot");
108196
- open4.then((w) => w.reset(abandoned)).catch(() => void 0);
108466
+ open5.then((w) => w.reset(abandoned)).catch(() => void 0);
108197
108467
  return void 0;
108198
108468
  }
108199
108469
  };
@@ -114384,7 +114654,7 @@ var Publisher = class {
114384
114654
  }
114385
114655
  const advertise2 = async (suffix) => {
114386
114656
  if (legacy) {
114387
- return await this.#advertise(join17(prefix, suffix), requests, refused);
114657
+ return await this.#advertise(join18(prefix, suffix), requests, refused);
114388
114658
  }
114389
114659
  await stream.writer.u53(SubscribeNamespaceEntry.id);
114390
114660
  await new SubscribeNamespaceEntry({ suffix, cluster: this.#advert }).encode(stream.writer, version3);
@@ -114392,7 +114662,7 @@ var Publisher = class {
114392
114662
  };
114393
114663
  const withdraw = async (suffix) => {
114394
114664
  if (legacy) {
114395
- await this.#withdraw(join17(prefix, suffix), requests);
114665
+ await this.#withdraw(join18(prefix, suffix), requests);
114396
114666
  } else {
114397
114667
  await stream.writer.u53(SubscribeNamespaceEntryDone.id);
114398
114668
  await new SubscribeNamespaceEntryDone({ suffix }).encode(stream.writer, version3);
@@ -114418,7 +114688,7 @@ var Publisher = class {
114418
114688
  continue;
114419
114689
  updated.set(suffix, producer);
114420
114690
  }
114421
- const live = new Set([...updated.keys()].map((suffix) => join17(prefix, suffix)));
114691
+ const live = new Set([...updated.keys()].map((suffix) => join18(prefix, suffix)));
114422
114692
  for (const path63 of [...refused.keys()]) {
114423
114693
  if (!live.has(path63))
114424
114694
  refused.delete(path63);
@@ -114433,13 +114703,13 @@ var Publisher = class {
114433
114703
  for (const [suffix, producer] of updated) {
114434
114704
  if (active.get(suffix) === producer)
114435
114705
  continue;
114436
- if (this.#offerable(join17(prefix, suffix), refused)) {
114706
+ if (this.#offerable(join18(prefix, suffix), refused)) {
114437
114707
  if (await advertise2(suffix))
114438
114708
  held.set(suffix, producer);
114439
114709
  }
114440
114710
  }
114441
114711
  active = held;
114442
- const outstanding = [...updated].some(([suffix, producer]) => active.get(suffix) !== producer && this.#pending(join17(prefix, suffix), refused));
114712
+ const outstanding = [...updated].some(([suffix, producer]) => active.get(suffix) !== producer && this.#pending(join18(prefix, suffix), refused));
114443
114713
  retry = outstanding ? Math.min(retry ? retry * 2 : RETRY_BASE, RETRY_MAX) : 0;
114444
114714
  const next = await (retry ? Promise.race([changed, stream.reader.closed, retryAfter(retry).then(() => broadcasts)]) : Promise.race([changed, stream.reader.closed]));
114445
114715
  dispose();
@@ -115085,7 +115355,7 @@ var Subscriber2 = class {
115085
115355
  const entry = await SubscribeNamespaceEntry.decode(stream.reader, version3, negotiated(this.#cluster));
115086
115356
  if (released)
115087
115357
  break;
115088
- const path63 = join17(prefix, entry.suffix);
115358
+ const path63 = join18(prefix, entry.suffix);
115089
115359
  if (this.#reflected(entry.cluster)) {
115090
115360
  console.debug(`dropping reflected namespace: broadcast=${path63}`);
115091
115361
  if (live.delete(path63))
@@ -115100,7 +115370,7 @@ var Subscriber2 = class {
115100
115370
  const entry = await SubscribeNamespaceEntryDone.decode(stream.reader, version3);
115101
115371
  if (released)
115102
115372
  break;
115103
- const path63 = join17(prefix, entry.suffix);
115373
+ const path63 = join18(prefix, entry.suffix);
115104
115374
  if (live.delete(path63)) {
115105
115375
  this.#detachAnnounce(path63);
115106
115376
  }
@@ -117895,7 +118165,7 @@ var Subscriber3 = class {
117895
118165
  case Version2.DRAFT_02: {
117896
118166
  const init2 = await AnnounceInit.decode(stream.reader, this.version);
117897
118167
  for (const suffix of init2.suffixes) {
117898
- const path63 = join17(prefix, suffix);
118168
+ const path63 = join18(prefix, suffix);
117899
118169
  if (advertised.has(suffix)) {
117900
118170
  throw new ProtocolViolation(`duplicate announce for ${path63}`);
117901
118171
  }
@@ -117954,7 +118224,7 @@ var Subscriber3 = class {
117954
118224
  break;
117955
118225
  }
117956
118226
  }
117957
- const path63 = join17(prefix, suffix);
118227
+ const path63 = join18(prefix, suffix);
117958
118228
  const duplicateIsRestart = restartSupported(this.version) && !hasAnnounceId(this.version);
117959
118229
  if (announce.status === "active" && !duplicateIsRestart && advertised.has(suffix)) {
117960
118230
  throw new ProtocolViolation(`duplicate announce for ${path63}`);
@@ -122945,11 +123215,11 @@ function captureOnDemandDropped(deviceId, endpoint) {
122945
123215
  }
122946
123216
 
122947
123217
  // ../tool-server/src/utils/foldable.ts
122948
- var import_node_child_process14 = require("node:child_process");
123218
+ var import_node_child_process15 = require("node:child_process");
122949
123219
  var fs18 = __toESM(require("node:fs"));
122950
123220
  var import_node_util12 = require("node:util");
122951
123221
  init_external_devices();
122952
- var execFileAsync12 = (0, import_node_util12.promisify)(import_node_child_process14.execFile);
123222
+ var execFileAsync12 = (0, import_node_util12.promisify)(import_node_child_process15.execFile);
122953
123223
  var MAIN_SCREEN_ID = 1;
122954
123224
  var AX_LIVE_PANEL_TIMEOUT_MS = 2e3;
122955
123225
  var DEVICECTL_TIMEOUT_MS = 5e3;
@@ -123719,7 +123989,7 @@ var NATIVE_DEVTOOLS_NAMESPACE = "NativeDevtools";
123719
123989
  function isInjectableBundleId(bundleId) {
123720
123990
  return !bundleId.toLowerCase().startsWith("com.apple.");
123721
123991
  }
123722
- var NON_INJECTABLE_NATIVE_WARNING = "Do not fall back to the native-devtools feature tools (native-find-views, native-full-hierarchy, native-network-logs, native-view-at-point, native-user-interactable-view-at-point): they run the same injection precheck and fail with the same non-injectable error.";
123992
+ var NON_INJECTABLE_NATIVE_WARNING = "Do not fall back to the native-devtools feature tools (native-find-views, native-full-hierarchy, native-network-logs, native-view-at-point): they run the same injection precheck and fail with the same non-injectable error.";
123723
123993
  var NON_INJECTABLE_RECOVERY = "Use the standard `describe` tool (its accessibility path reads the screen without injection) or `screenshot` (then interact by coordinate). " + NON_INJECTABLE_NATIVE_WARNING;
123724
123994
  var MAX_NATIVE_DEVTOOLS_INIT_ATTEMPTS = 3;
123725
123995
  var NATIVE_DEVTOOLS_AGE_SLOP_MS = 3e3;
@@ -124288,7 +124558,7 @@ var nativeDevtoolsBlueprint = {
124288
124558
  init_external_devices();
124289
124559
 
124290
124560
  // ../tool-server/src/utils/simctl-exec.ts
124291
- var import_node_child_process15 = require("node:child_process");
124561
+ var import_node_child_process16 = require("node:child_process");
124292
124562
 
124293
124563
  // ../tool-server/src/utils/process-kill.ts
124294
124564
  function signalGroup(pid, signal) {
@@ -124352,7 +124622,7 @@ function execSimctl(args, options = {}) {
124352
124622
  reject(new Error(`xcrun ${args.join(" ")} aborted`));
124353
124623
  return;
124354
124624
  }
124355
- const child = (0, import_node_child_process15.spawn)("xcrun", args, { detached: true, stdio: ["ignore", "pipe", "pipe"] });
124625
+ const child = (0, import_node_child_process16.spawn)("xcrun", args, { detached: true, stdio: ["ignore", "pipe", "pipe"] });
124356
124626
  let stdout = "";
124357
124627
  let stderr = "";
124358
124628
  let settled = false;
@@ -124702,7 +124972,7 @@ async function spawnSimulatorServerProcess(udid, subcommand) {
124702
124972
  if (sdkRoot)
124703
124973
  process.stderr.write(`[sim ${udid.slice(0, 8)}] android.sdkRoot \u2192 ANDROID_HOME=${sdkRoot}
124704
124974
  `);
124705
- const proc = (0, import_node_child_process16.spawn)(BINARY_PATH, args, {
124975
+ const proc = (0, import_node_child_process17.spawn)(BINARY_PATH, args, {
124706
124976
  cwd: RUN_DIR,
124707
124977
  stdio: ["pipe", "pipe", "pipe"],
124708
124978
  ...sdkRoot ? { env: { ...process.env, ANDROID_HOME: sdkRoot } } : {}
@@ -124978,11 +125248,11 @@ function classifyDeviceForTelemetry(deviceId) {
124978
125248
  }
124979
125249
 
124980
125250
  // ../tool-server/src/utils/device-shutdown.ts
124981
- var import_node_child_process18 = require("node:child_process");
125251
+ var import_node_child_process19 = require("node:child_process");
124982
125252
  var import_node_util14 = require("node:util");
124983
125253
  init_device_info();
124984
125254
  init_android_binary();
124985
- var execFileAsync14 = (0, import_node_util14.promisify)(import_node_child_process18.execFile);
125255
+ var execFileAsync14 = (0, import_node_util14.promisify)(import_node_child_process19.execFile);
124986
125256
  var SHUTDOWN_EXEC_OPTIONS = { timeout: 3e4, killSignal: "SIGKILL" };
124987
125257
  async function shutdownOwnedDevice(id) {
124988
125258
  let platform;
@@ -125132,7 +125402,7 @@ function adbCommandPrefix(env) {
125132
125402
  }
125133
125403
 
125134
125404
  // ../tool-server/src/utils/ios-device/devicectl.ts
125135
- var import_node_child_process19 = require("node:child_process");
125405
+ var import_node_child_process20 = require("node:child_process");
125136
125406
  var import_node_util15 = require("node:util");
125137
125407
  var fs22 = __toESM(require("node:fs/promises"));
125138
125408
  var os6 = __toESM(require("node:os"));
@@ -125396,7 +125666,7 @@ function invalidXmlError(detail) {
125396
125666
  }
125397
125667
 
125398
125668
  // ../tool-server/src/utils/ios-device/devicectl.ts
125399
- var execFileAsync15 = (0, import_node_util15.promisify)(import_node_child_process19.execFile);
125669
+ var execFileAsync15 = (0, import_node_util15.promisify)(import_node_child_process20.execFile);
125400
125670
  var DEVICECTL_TIMEOUT_MS2 = 2e4;
125401
125671
  var DEVICECTL_INSTALL_TIMEOUT_MS = 12e4;
125402
125672
  var DEVICECTL_LIST_TIMEOUT_MS = 8e3;
@@ -125702,7 +125972,7 @@ async function listTargets(strict, timeoutMs) {
125702
125972
  init_harmony_flag();
125703
125973
 
125704
125974
  // ../tool-server/src/utils/macos-apps.ts
125705
- var import_node_child_process20 = require("node:child_process");
125975
+ var import_node_child_process21 = require("node:child_process");
125706
125976
  var import_node_crypto8 = require("node:crypto");
125707
125977
  var fs23 = __toESM(require("node:fs"));
125708
125978
  var os7 = __toESM(require("node:os"));
@@ -125712,7 +125982,7 @@ init_src();
125712
125982
  init_src2();
125713
125983
  init_capability();
125714
125984
  init_device_info();
125715
- var execFileAsync16 = (0, import_node_util16.promisify)(import_node_child_process20.execFile);
125985
+ var execFileAsync16 = (0, import_node_util16.promisify)(import_node_child_process21.execFile);
125716
125986
  function isMacosAppsEnabled() {
125717
125987
  return isFeatureEnabled(MACOS_APPS_FLAG);
125718
125988
  }
@@ -125835,19 +126105,19 @@ async function librarySourceInstalled(dir, name) {
125835
126105
  async function removeUnusedLibraries(libRoot, keep) {
125836
126106
  try {
125837
126107
  const root = fs23.realpathSync(libRoot);
125838
- let open4;
126108
+ let open5;
125839
126109
  try {
125840
- ({ stdout: open4 } = await execFileAsync16("lsof", ["-Fn", "+D", root], {
126110
+ ({ stdout: open5 } = await execFileAsync16("lsof", ["-Fn", "+D", root], {
125841
126111
  timeout: 3e4,
125842
126112
  maxBuffer: 16 * 1024 * 1024
125843
126113
  }));
125844
126114
  } catch (err) {
125845
126115
  const { code, stdout } = err;
125846
126116
  if (code !== 1) return;
125847
- open4 = stdout ?? "";
126117
+ open5 = stdout ?? "";
125848
126118
  }
125849
126119
  const used = new Set(
125850
- open4.split("\n").filter((line) => line.startsWith(`n${root}/`)).map((line) => line.slice(root.length + 2).split("/")[0])
126120
+ open5.split("\n").filter((line) => line.startsWith(`n${root}/`)).map((line) => line.slice(root.length + 2).split("/")[0])
125851
126121
  );
125852
126122
  for (const name of fs23.readdirSync(root)) {
125853
126123
  if (name.startsWith(keep) || used.has(name)) continue;
@@ -127366,8 +127636,8 @@ async function captureScreenshot(ctx, opts = {}) {
127366
127636
  if (scale) dropped.push("scale");
127367
127637
  dropReason = "sharp-missing";
127368
127638
  } else {
127369
- let pipeline = sharp(bytes);
127370
- if (rotation) pipeline = pipeline.rotate(ROTATION_DEGREES2[rotation]);
127639
+ let pipeline2 = sharp(bytes);
127640
+ if (rotation) pipeline2 = pipeline2.rotate(ROTATION_DEGREES2[rotation]);
127371
127641
  if (scale) {
127372
127642
  const dims = readPngSize(bytes);
127373
127643
  if (dims) {
@@ -127376,7 +127646,7 @@ async function captureScreenshot(ctx, opts = {}) {
127376
127646
  const rotatedH = quarterTurn ? dims.width : dims.height;
127377
127647
  const targetW = Math.max(1, Math.round(rotatedW * scale));
127378
127648
  const targetH = Math.max(1, Math.round(rotatedH * scale));
127379
- pipeline = pipeline.resize(targetW, targetH, {
127649
+ pipeline2 = pipeline2.resize(targetW, targetH, {
127380
127650
  kernel: DOWNSCALER_TO_KERNEL[opts.downscaler ?? "lanczos3"],
127381
127651
  fit: "fill"
127382
127652
  });
@@ -127385,7 +127655,7 @@ async function captureScreenshot(ctx, opts = {}) {
127385
127655
  dropReason = "png-header-unreadable";
127386
127656
  }
127387
127657
  }
127388
- bytes = Buffer.from(await pipeline.png({ compressionLevel: 6 }).toBuffer());
127658
+ bytes = Buffer.from(await pipeline2.png({ compressionLevel: 6 }).toBuffer());
127389
127659
  }
127390
127660
  }
127391
127661
  const stem = opts.id ?? `${Date.now()}-${process.pid}`;
@@ -127537,7 +127807,7 @@ function createTabsManager(deps) {
127537
127807
  });
127538
127808
  }
127539
127809
  }
127540
- async function open4(opts) {
127810
+ async function open5(opts) {
127541
127811
  const url2 = opts?.url ?? "about:blank";
127542
127812
  const created = await withBrowserClient(async (browser) => {
127543
127813
  let out;
@@ -127601,7 +127871,7 @@ function createTabsManager(deps) {
127601
127871
  return {
127602
127872
  list,
127603
127873
  select,
127604
- open: open4,
127874
+ open: open5,
127605
127875
  close,
127606
127876
  activeTargetId: () => activeTargetId
127607
127877
  };
@@ -128043,14 +128313,14 @@ async function discoverChromiumDevices(options) {
128043
128313
  init_src2();
128044
128314
 
128045
128315
  // ../tool-server/src/utils/vega-sdk.ts
128046
- var import_promises5 = require("node:fs/promises");
128047
- var import_node_fs6 = require("node:fs");
128316
+ var import_promises7 = require("node:fs/promises");
128317
+ var import_node_fs7 = require("node:fs");
128048
128318
  var import_node_os6 = require("node:os");
128049
- var import_node_path10 = require("node:path");
128319
+ var import_node_path11 = require("node:path");
128050
128320
  var import_semver3 = __toESM(require_semver2());
128051
128321
  async function readVegaConfig() {
128052
128322
  try {
128053
- const raw = await (0, import_promises5.readFile)((0, import_node_path10.join)((0, import_node_os6.homedir)(), "vega", "config.json"), "utf-8");
128323
+ const raw = await (0, import_promises7.readFile)((0, import_node_path11.join)((0, import_node_os6.homedir)(), "vega", "config.json"), "utf-8");
128054
128324
  return JSON.parse(raw);
128055
128325
  } catch {
128056
128326
  return {};
@@ -128061,15 +128331,15 @@ function bareVersion(version3) {
128061
128331
  }
128062
128332
  function sdkComponentRoots(config2) {
128063
128333
  const roots = [
128064
- config2.sdkPath && (0, import_node_path10.join)(config2.sdkPath, "vega-sdk"),
128065
- (0, import_node_path10.join)((0, import_node_os6.homedir)(), "vega", "sdk", "vega-sdk")
128334
+ config2.sdkPath && (0, import_node_path11.join)(config2.sdkPath, "vega-sdk"),
128335
+ (0, import_node_path11.join)((0, import_node_os6.homedir)(), "vega", "sdk", "vega-sdk")
128066
128336
  ].filter((p) => Boolean(p));
128067
128337
  return Array.from(new Set(roots));
128068
128338
  }
128069
128339
  async function resolveVersion(channelDir, preferred) {
128070
- if (preferred && (0, import_node_fs6.existsSync)((0, import_node_path10.join)(channelDir, preferred))) return preferred;
128340
+ if (preferred && (0, import_node_fs7.existsSync)((0, import_node_path11.join)(channelDir, preferred))) return preferred;
128071
128341
  try {
128072
- const versions = (await (0, import_promises5.readdir)(channelDir)).filter((e) => import_semver3.default.valid(e)).sort(import_semver3.default.rcompare);
128342
+ const versions = (await (0, import_promises7.readdir)(channelDir)).filter((e) => import_semver3.default.valid(e)).sort(import_semver3.default.rcompare);
128073
128343
  return versions[0] ?? null;
128074
128344
  } catch {
128075
128345
  return null;
@@ -128081,11 +128351,11 @@ async function resolveVegaSdkImagesDir() {
128081
128351
  const channel = config2.defaultChannel || "main";
128082
128352
  const preferred = bareVersion(config2.defaultVersion);
128083
128353
  for (const root of sdkComponentRoots(config2)) {
128084
- const channelDir = (0, import_node_path10.join)(root, channel);
128354
+ const channelDir = (0, import_node_path11.join)(root, channel);
128085
128355
  const version3 = await resolveVersion(channelDir, preferred);
128086
128356
  if (!version3) continue;
128087
- const imagesDir = (0, import_node_path10.join)(channelDir, version3, "vvd", "images");
128088
- if ((0, import_node_fs6.existsSync)(imagesDir)) return imagesDir;
128357
+ const imagesDir = (0, import_node_path11.join)(channelDir, version3, "vvd", "images");
128358
+ if ((0, import_node_fs7.existsSync)(imagesDir)) return imagesDir;
128089
128359
  }
128090
128360
  return null;
128091
128361
  }
@@ -128093,8 +128363,8 @@ async function listVvdImages() {
128093
128363
  const dir = await resolveVegaSdkImagesDir();
128094
128364
  if (!dir) return [];
128095
128365
  try {
128096
- const entries = await (0, import_promises5.readdir)(dir, { withFileTypes: true });
128097
- return entries.filter((e) => e.isDirectory()).map((e) => ({ name: e.name, path: (0, import_node_path10.join)(dir, e.name) })).sort((a, b) => a.name.localeCompare(b.name));
128366
+ const entries = await (0, import_promises7.readdir)(dir, { withFileTypes: true });
128367
+ return entries.filter((e) => e.isDirectory()).map((e) => ({ name: e.name, path: (0, import_node_path11.join)(dir, e.name) })).sort((a, b) => a.name.localeCompare(b.name));
128098
128368
  } catch {
128099
128369
  return [];
128100
128370
  }
@@ -128107,11 +128377,11 @@ function parseVegaDeviceList(stdout) {
128107
128377
  const devices = [];
128108
128378
  for (const raw of stdout.split("\n")) {
128109
128379
  const line = raw.trim();
128110
- const sep10 = line.indexOf(" : ");
128111
- if (sep10 < 0) continue;
128112
- const type = line.slice(0, sep10).trim();
128380
+ const sep11 = line.indexOf(" : ");
128381
+ if (sep11 < 0) continue;
128382
+ const type = line.slice(0, sep11).trim();
128113
128383
  if (!/^[A-Za-z]+$/.test(type)) continue;
128114
- const rhs = line.slice(sep10 + 3).trim();
128384
+ const rhs = line.slice(sep11 + 3).trim();
128115
128385
  const parts2 = rhs.split(/\s+-\s+/);
128116
128386
  const serial = parts2[parts2.length - 1]?.trim();
128117
128387
  if (!serial) continue;
@@ -129906,7 +130176,7 @@ function parseUiAutomatorDump(rawOutput, screenW, screenH, options = {}) {
129906
130176
  }
129907
130177
 
129908
130178
  // ../tool-server/src/blueprints/android-devtools.ts
129909
- var import_node_child_process21 = require("node:child_process");
130179
+ var import_node_child_process22 = require("node:child_process");
129910
130180
  var readline2 = __toESM(require("node:readline"));
129911
130181
  init_src2();
129912
130182
 
@@ -129943,11 +130213,326 @@ var TraceProcessorUnavailableError = class _TraceProcessorUnavailableError exten
129943
130213
  };
129944
130214
 
129945
130215
  // ../native-devtools-android/src/wasm-trace-processor.ts
129946
- var import_node_fs7 = require("node:fs");
129947
- var import_promises6 = require("node:fs/promises");
130216
+ var import_node_fs8 = require("node:fs");
130217
+ var import_promises8 = require("node:fs/promises");
129948
130218
  var path23 = __toESM(require("node:path"));
129949
130219
  var import_node_url2 = require("node:url");
129950
130220
  var import_node_vm = __toESM(require("node:vm"));
130221
+
130222
+ // ../native-devtools-android/src/trace-processor-rpc.ts
130223
+ var TPM_APPEND_TRACE_DATA = 1;
130224
+ var TPM_FINALIZE_TRACE_DATA = 2;
130225
+ var TPM_QUERY_STREAMING = 3;
130226
+ var CELL_NULL = 1;
130227
+ var CELL_VARINT = 2;
130228
+ var CELL_FLOAT64 = 3;
130229
+ var CELL_STRING = 4;
130230
+ var CELL_BLOB = 5;
130231
+ var WIRE_VARINT2 = 0;
130232
+ var WIRE_I64 = 1;
130233
+ var WIRE_LEN2 = 2;
130234
+ var WIRE_I32 = 5;
130235
+ var MAX_MSG_SIZE = 1024 * 1024 * 1024;
130236
+ var utf8Encoder = new TextEncoder();
130237
+ var cellDecoder = new TextDecoder();
130238
+ var fieldDecoder = new TextDecoder("utf-8", { ignoreBOM: true });
130239
+ function varintBytes(n) {
130240
+ const out = [];
130241
+ while (n >= 128) {
130242
+ out.push(n % 128 | 128);
130243
+ n = Math.floor(n / 128);
130244
+ }
130245
+ out.push(n);
130246
+ return out;
130247
+ }
130248
+ function concat2(parts2) {
130249
+ let len = 0;
130250
+ for (const p of parts2) len += p.length;
130251
+ const out = new Uint8Array(len);
130252
+ let off = 0;
130253
+ for (const p of parts2) {
130254
+ out.set(p, off);
130255
+ off += p.length;
130256
+ }
130257
+ return out;
130258
+ }
130259
+ function lenField(field, payload) {
130260
+ return [varintBytes(field * 8 + WIRE_LEN2), varintBytes(payload.length), payload];
130261
+ }
130262
+ function encodeRpcRequest(seq, method, argsField, args) {
130263
+ const parts2 = [[8], varintBytes(seq), [16], varintBytes(method)];
130264
+ if (argsField !== void 0 && args) parts2.push(...lenField(argsField, args));
130265
+ const rpc = concat2(parts2);
130266
+ return concat2(lenField(1, rpc));
130267
+ }
130268
+ var Reader2 = class {
130269
+ constructor(buf, pos = 0, end = buf.length) {
130270
+ this.buf = buf;
130271
+ this.end = end;
130272
+ this.pos = pos;
130273
+ }
130274
+ buf;
130275
+ end;
130276
+ pos;
130277
+ varint() {
130278
+ let result = 0;
130279
+ let mul = 1;
130280
+ for (; ; ) {
130281
+ if (this.pos >= this.end) throw new Error("Index out of range");
130282
+ const b = this.buf[this.pos++];
130283
+ result += (b & 127) * mul;
130284
+ if (b < 128) return result;
130285
+ mul *= 128;
130286
+ }
130287
+ }
130288
+ /** Signed 64-bit varint as a bigint (two's complement, like proto int64). */
130289
+ int64() {
130290
+ const buf = this.buf;
130291
+ let lo = 0;
130292
+ let hi = 0;
130293
+ for (let i = 0; i < 10; i++) {
130294
+ if (this.pos >= this.end) throw new Error("Index out of range");
130295
+ const b = buf[this.pos++];
130296
+ if (i < 4) lo |= (b & 127) << i * 7;
130297
+ else if (i === 4) {
130298
+ lo |= (b & 127) << 28;
130299
+ hi = (b & 127) >> 4;
130300
+ } else hi |= (b & 127) << (i - 5) * 7 + 3;
130301
+ if (b < 128) {
130302
+ return BigInt.asIntN(64, BigInt(hi >>> 0) << 32n | BigInt(lo >>> 0));
130303
+ }
130304
+ }
130305
+ throw new Error("invalid varint encoding");
130306
+ }
130307
+ bytes() {
130308
+ const len = this.varint();
130309
+ const start2 = this.pos;
130310
+ this.pos += len;
130311
+ if (this.pos > this.end) throw new Error("Index out of range");
130312
+ return this.buf.subarray(start2, this.pos);
130313
+ }
130314
+ skip(wireType) {
130315
+ if (wireType === WIRE_VARINT2) this.varint();
130316
+ else if (wireType === WIRE_I64) this.pos += 8;
130317
+ else if (wireType === WIRE_LEN2) this.bytes();
130318
+ else if (wireType === WIRE_I32) this.pos += 4;
130319
+ else throw new Error(`invalid wire type ${wireType} at offset ${this.pos}`);
130320
+ }
130321
+ };
130322
+ function lenOnly(wireType) {
130323
+ if (wireType !== WIRE_LEN2) throw new Error("Failed assertion");
130324
+ }
130325
+ function decodeBatch(batch, numColumns) {
130326
+ const r = new Reader2(batch);
130327
+ let cellTypes = new Uint8Array(0);
130328
+ let varints = new Reader2(batch, 0, 0);
130329
+ let floats = new Float64Array(0);
130330
+ const blobs = [];
130331
+ let strings = [];
130332
+ let last = false;
130333
+ while (r.pos < r.end) {
130334
+ const tag3 = r.varint();
130335
+ const field = Math.floor(tag3 / 8);
130336
+ const wire = tag3 & 7;
130337
+ if (field >= 1 && field <= 5) lenOnly(wire);
130338
+ if (field === 1) cellTypes = r.bytes();
130339
+ else if (field === 2) {
130340
+ const packed = r.bytes();
130341
+ varints = new Reader2(batch, packed.byteOffset - batch.byteOffset, r.pos);
130342
+ } else if (field === 3) {
130343
+ const packed = r.bytes();
130344
+ if (packed.length % 8 !== 0) throw new Error("Failed assertion");
130345
+ floats = new Float64Array(packed.slice().buffer);
130346
+ } else if (field === 4) blobs.push(r.bytes().slice());
130347
+ else if (field === 5) strings = cellDecoder.decode(r.bytes()).split("\0");
130348
+ else if (field === 6) last = r.varint() !== 0;
130349
+ else r.skip(wire);
130350
+ }
130351
+ const numCells = cellTypes.length;
130352
+ if (numColumns === 0 ? numCells !== 0 : numCells % numColumns !== 0) {
130353
+ throw new Error("Failed assertion");
130354
+ }
130355
+ const rows = [];
130356
+ let f = 0;
130357
+ let s = 0;
130358
+ let b = 0;
130359
+ for (let i = 0; i < numCells; i += numColumns) {
130360
+ const row = new Array(numColumns);
130361
+ for (let c = 0; c < numColumns; c++) {
130362
+ const type = cellTypes[i + c];
130363
+ if (type === CELL_NULL) row[c] = null;
130364
+ else if (type === CELL_VARINT) row[c] = varints.int64();
130365
+ else if (type === CELL_FLOAT64) row[c] = floats[f++];
130366
+ else if (type === CELL_STRING) row[c] = strings[s++];
130367
+ else if (type === CELL_BLOB) row[c] = blobs[b++];
130368
+ else throw new Error(`Invalid cell type ${type}`);
130369
+ }
130370
+ rows.push(row);
130371
+ }
130372
+ return { rows, last };
130373
+ }
130374
+ function deferred() {
130375
+ let resolve19;
130376
+ let reject;
130377
+ const promise2 = new Promise((res, rej) => {
130378
+ resolve19 = res;
130379
+ reject = rej;
130380
+ });
130381
+ return { promise: promise2, resolve: resolve19, reject };
130382
+ }
130383
+ var PendingQuery = class {
130384
+ constructor(done) {
130385
+ this.done = done;
130386
+ }
130387
+ done;
130388
+ result = { columns: [], rows: [] };
130389
+ error;
130390
+ complete = false;
130391
+ /** Appends one proto-encoded QueryResult message. */
130392
+ append(msg) {
130393
+ const r = new Reader2(msg);
130394
+ const { columns } = this.result;
130395
+ const columnsEmptyAtStart = columns.length === 0;
130396
+ const seen = /* @__PURE__ */ new Set();
130397
+ while (r.pos < r.end) {
130398
+ const tag3 = r.varint();
130399
+ const field = Math.floor(tag3 / 8);
130400
+ if (field === 1) {
130401
+ if (!columnsEmptyAtStart) throw new Error("Failed assertion");
130402
+ const orig = fieldDecoder.decode(r.bytes());
130403
+ let name = orig;
130404
+ for (let i = 1; seen.has(name); i++) name = `${orig}_${i}`;
130405
+ seen.add(name);
130406
+ columns.push(name);
130407
+ } else if (field === 2) {
130408
+ const err = fieldDecoder.decode(r.bytes());
130409
+ this.error = err.length ? err : void 0;
130410
+ } else if (field === 3) {
130411
+ const batch = decodeBatch(r.bytes(), columns.length);
130412
+ this.complete = batch.last;
130413
+ for (const row of batch.rows) this.result.rows.push(row);
130414
+ } else r.skip(tag3 & 7);
130415
+ }
130416
+ }
130417
+ };
130418
+ var TraceProcessorRpc = class {
130419
+ txSeqId = 0;
130420
+ rxSeqId = 0;
130421
+ rxBuf = new Uint8Array(0);
130422
+ pendingParses = [];
130423
+ pendingEofs = [];
130424
+ pendingQueries = [];
130425
+ /** Reason of the first fatal failure, if any. */
130426
+ failed;
130427
+ /** Pushes a chunk of trace data. Each call must stay under 64 MiB. */
130428
+ parse(data) {
130429
+ const d = deferred();
130430
+ this.pendingParses.push(d);
130431
+ this.send(TPM_APPEND_TRACE_DATA, 101, data);
130432
+ return d.promise;
130433
+ }
130434
+ /** Signals the end of the trace, after the last parse(). */
130435
+ notifyEof() {
130436
+ const d = deferred();
130437
+ this.pendingEofs.push(d);
130438
+ this.send(TPM_FINALIZE_TRACE_DATA);
130439
+ return d.promise;
130440
+ }
130441
+ /** Runs SQL; resolves once every batch arrived, rejects with the SQL error. */
130442
+ query(sql) {
130443
+ const d = deferred();
130444
+ this.pendingQueries.push(new PendingQuery(d));
130445
+ this.send(TPM_QUERY_STREAMING, 103, concat2(lenField(1, utf8Encoder.encode(sql))));
130446
+ return d.promise;
130447
+ }
130448
+ send(method, argsField, args) {
130449
+ this.rpcSendRequestBytes(encodeRpcRequest(this.txSeqId++, method, argsField, args));
130450
+ }
130451
+ onRpcResponseBytes(data) {
130452
+ const buf = this.rxBuf.length ? concat2([this.rxBuf, data]) : data;
130453
+ let pos = 0;
130454
+ for (; ; ) {
130455
+ const msg = this.nextFrame(buf, pos);
130456
+ if (!msg) break;
130457
+ pos = msg.byteOffset - buf.byteOffset + msg.length;
130458
+ this.onRpcResponseMessage(msg);
130459
+ }
130460
+ this.rxBuf = buf.slice(pos);
130461
+ }
130462
+ // A frame is a TraceProcessorRpcStream.msg field: tag 0x0a, varint size, body.
130463
+ nextFrame(buf, pos) {
130464
+ if (pos >= buf.length) return void 0;
130465
+ const tag3 = buf[pos];
130466
+ if (tag3 >= 128 || (tag3 & 7) !== WIRE_LEN2) {
130467
+ throw new Error(`RPC framing error, unexpected tag ${tag3} @ offset ${pos}`);
130468
+ }
130469
+ const r = new Reader2(buf, pos + 1);
130470
+ let len;
130471
+ try {
130472
+ len = r.varint();
130473
+ } catch {
130474
+ return void 0;
130475
+ }
130476
+ if (len >= MAX_MSG_SIZE) {
130477
+ throw new Error(`RPC framing error, message too large (${len} > ${MAX_MSG_SIZE}`);
130478
+ }
130479
+ if (r.pos + len > buf.length) return void 0;
130480
+ return buf.subarray(r.pos, r.pos + len);
130481
+ }
130482
+ onRpcResponseMessage(msg) {
130483
+ const r = new Reader2(msg);
130484
+ let seq = 0;
130485
+ let fatalError;
130486
+ let response;
130487
+ let args;
130488
+ while (r.pos < r.end) {
130489
+ const tag3 = r.varint();
130490
+ const field = Math.floor(tag3 / 8);
130491
+ if (field === 1) seq = r.varint();
130492
+ else if (field === 5) fatalError = fieldDecoder.decode(r.bytes());
130493
+ else if (field === 3) response = r.varint();
130494
+ else if (field === 201 || field === 203 || field === 212) args = r.bytes();
130495
+ else r.skip(tag3 & 7);
130496
+ }
130497
+ if (fatalError) this.fail(fatalError);
130498
+ if (seq !== this.rxSeqId + 1 && this.rxSeqId !== 0 && seq !== 0) {
130499
+ this.fail(`RPC sequence id mismatch cur=${seq} last=${this.rxSeqId} (ERR:rpc_seq)`);
130500
+ }
130501
+ this.rxSeqId = seq;
130502
+ if (response === TPM_APPEND_TRACE_DATA || response === TPM_FINALIZE_TRACE_DATA) {
130503
+ const errorField = response === TPM_APPEND_TRACE_DATA ? 2 : 1;
130504
+ const queue = response === TPM_APPEND_TRACE_DATA ? this.pendingParses : this.pendingEofs;
130505
+ const pending = queue.shift();
130506
+ if (!pending) throw new Error(`Unexpected response ${response} with no pending request`);
130507
+ let error63 = "";
130508
+ if (args) {
130509
+ const a = new Reader2(args);
130510
+ while (a.pos < a.end) {
130511
+ const tag3 = a.varint();
130512
+ if (Math.floor(tag3 / 8) === errorField) error63 = fieldDecoder.decode(a.bytes());
130513
+ else a.skip(tag3 & 7);
130514
+ }
130515
+ }
130516
+ if (error63.length > 0) pending.reject(new Error(error63));
130517
+ else pending.resolve();
130518
+ } else if (response === TPM_QUERY_STREAMING) {
130519
+ const pending = this.pendingQueries[0];
130520
+ if (!pending) throw new Error("Unexpected query result with no pending query");
130521
+ pending.append(args ?? new Uint8Array(0));
130522
+ if (pending.complete) {
130523
+ this.pendingQueries.shift();
130524
+ if (pending.error === void 0) pending.done.resolve(pending.result);
130525
+ else pending.done.reject(new Error(pending.error));
130526
+ }
130527
+ }
130528
+ }
130529
+ fail(reason2) {
130530
+ this.failed = reason2;
130531
+ throw new Error(reason2);
130532
+ }
130533
+ };
130534
+
130535
+ // ../native-devtools-android/src/wasm-trace-processor.ts
129951
130536
  var DEFAULT_INIT_MS = 1500;
129952
130537
  var MAX_WARM_ENGINES = 3;
129953
130538
  var IDLE_DISPOSE_MS = 5 * 6e4;
@@ -129958,13 +130543,12 @@ function engineGlobals() {
129958
130543
  function resolveTraceProcessorAssets() {
129959
130544
  const dir = path23.join(__dirname, "..", "assets", "trace-processor");
129960
130545
  const wasmOverride = process.env.ARGENT_TRACE_PROCESSOR_WASM;
129961
- if (wasmOverride && !(0, import_node_fs7.existsSync)(wasmOverride)) {
130546
+ if (wasmOverride && !(0, import_node_fs8.existsSync)(wasmOverride)) {
129962
130547
  throw new TraceProcessorUnavailableError("wasm_path_invalid", { path: wasmOverride });
129963
130548
  }
129964
130549
  return {
129965
130550
  wasmPath: wasmOverride ?? path23.join(dir, "trace_processor.wasm"),
129966
- gluePath: path23.join(dir, "engine_bundle.node.js"),
129967
- enginePath: path23.join(dir, "engine.mjs")
130551
+ gluePath: path23.join(dir, "engine_bundle.node.js")
129968
130552
  };
129969
130553
  }
129970
130554
  function patchGlueForNode(src) {
@@ -129987,17 +130571,8 @@ function patchGlueForNode(src) {
129987
130571
  }
129988
130572
  return src;
129989
130573
  }
129990
- var engineModulePromise = null;
129991
- var wasmEngineClass = null;
129992
130574
  var workerScopeReady = false;
129993
- var decoderWarningSilenced = false;
129994
130575
  var createMutex = Promise.resolve();
129995
- function loadEngineModule(enginePath) {
129996
- if (!engineModulePromise) {
129997
- engineModulePromise = import((0, import_node_url2.pathToFileURL)(enginePath).href);
129998
- }
129999
- return engineModulePromise;
130000
- }
130001
130576
  function setupWorkerScope(assetsDir) {
130002
130577
  if (workerScopeReady) return;
130003
130578
  const g = engineGlobals();
@@ -130021,56 +130596,40 @@ function setupWorkerScope(assetsDir) {
130021
130596
  }
130022
130597
  workerScopeReady = true;
130023
130598
  }
130024
- function silenceDecoderWarning() {
130025
- if (decoderWarningSilenced) return;
130026
- decoderWarningSilenced = true;
130027
- const orig = console.warn.bind(console);
130028
- console.warn = (...args) => {
130029
- if (/Unexpected QueryResult field/.test(JSON.stringify(args[0] ?? ""))) return;
130030
- orig(...args);
130031
- };
130032
- }
130033
- function makeWasmEngineClass(Base) {
130034
- if (wasmEngineClass) return wasmEngineClass;
130035
- class WasmEngine extends Base {
130036
- mode = "WASM";
130037
- id = "v55.3";
130038
- port;
130039
- disposed = false;
130040
- fatal;
130041
- rejectFatal;
130042
- constructor(port) {
130043
- super();
130044
- this.port = port;
130045
- this.fatal = new Promise((_resolve, reject) => {
130046
- this.rejectFatal = reject;
130047
- });
130048
- this.fatal.catch(() => {
130049
- });
130050
- this.port.onmessage = (m) => {
130051
- if (!(m.data instanceof Uint8Array)) return;
130052
- try {
130053
- this.onRpcResponseBytes(m.data);
130054
- } catch (err) {
130055
- const e = err instanceof Error ? err : new Error(String(err));
130056
- this.rejectFatal(e);
130057
- this.dispose();
130058
- }
130059
- };
130060
- }
130061
- rpcSendRequestBytes(data) {
130062
- this.port.postMessage(data);
130063
- }
130064
- dispose() {
130065
- if (this.disposed) return;
130066
- this.disposed = true;
130067
- this.port.onmessage = null;
130068
- this.port.close();
130069
- }
130599
+ var WasmEngine = class extends TraceProcessorRpc {
130600
+ port;
130601
+ disposed = false;
130602
+ fatal;
130603
+ rejectFatal;
130604
+ constructor(port) {
130605
+ super();
130606
+ this.port = port;
130607
+ this.fatal = new Promise((_resolve, reject) => {
130608
+ this.rejectFatal = reject;
130609
+ });
130610
+ this.fatal.catch(() => {
130611
+ });
130612
+ this.port.onmessage = (m) => {
130613
+ if (!(m.data instanceof Uint8Array)) return;
130614
+ try {
130615
+ this.onRpcResponseBytes(m.data);
130616
+ } catch (err) {
130617
+ const e = err instanceof Error ? err : new Error(String(err));
130618
+ this.rejectFatal(e);
130619
+ this.dispose();
130620
+ }
130621
+ };
130070
130622
  }
130071
- wasmEngineClass = WasmEngine;
130072
- return wasmEngineClass;
130073
- }
130623
+ rpcSendRequestBytes(data) {
130624
+ this.port.postMessage(data);
130625
+ }
130626
+ dispose() {
130627
+ if (this.disposed) return;
130628
+ this.disposed = true;
130629
+ this.port.onmessage = null;
130630
+ this.port.close();
130631
+ }
130632
+ };
130074
130633
  async function createEngine() {
130075
130634
  const prev = createMutex;
130076
130635
  let release2;
@@ -130078,21 +130637,18 @@ async function createEngine() {
130078
130637
  await prev.catch(() => {
130079
130638
  });
130080
130639
  try {
130081
- const { wasmPath, gluePath, enginePath } = resolveTraceProcessorAssets();
130640
+ const { wasmPath, gluePath } = resolveTraceProcessorAssets();
130082
130641
  const dir = path23.dirname(wasmPath);
130083
130642
  const initMs = Number(process.env.ARGENT_TRACE_PROCESSOR_INIT_MS) || DEFAULT_INIT_MS;
130084
- const { EngineBase } = await loadEngineModule(enginePath);
130085
130643
  setupWorkerScope(dir);
130086
- silenceDecoderWarning();
130087
130644
  const g = engineGlobals();
130088
- g.__TP_WASM_BYTES = new Uint8Array((0, import_node_fs7.readFileSync)(wasmPath));
130089
- const src = patchGlueForNode((0, import_node_fs7.readFileSync)(gluePath, "utf8"));
130645
+ g.__TP_WASM_BYTES = new Uint8Array((0, import_node_fs8.readFileSync)(wasmPath));
130646
+ const src = patchGlueForNode((0, import_node_fs8.readFileSync)(gluePath, "utf8"));
130090
130647
  import_node_vm.default.runInThisContext(src, { filename: "engine_bundle.node.patched.js" });
130091
130648
  const bridge = g.__TP_bridge;
130092
130649
  if (!bridge) throw new Error("patched glue did not expose globalThis.__TP_bridge");
130093
130650
  const channel = new MessageChannel();
130094
130651
  bridge.initialize(channel.port1);
130095
- const WasmEngine = makeWasmEngineClass(EngineBase);
130096
130652
  const engine = new WasmEngine(channel.port2);
130097
130653
  await new Promise((r) => setTimeout(r, initMs));
130098
130654
  g.__TP_bridge = void 0;
@@ -130144,7 +130700,7 @@ function getWarmEngine(tracePath) {
130144
130700
  }
130145
130701
  const enginePromise = (async () => {
130146
130702
  const engine = await createEngine();
130147
- const bytes = new Uint8Array(await (0, import_promises6.readFile)(tracePath));
130703
+ const bytes = new Uint8Array(await (0, import_promises8.readFile)(tracePath));
130148
130704
  const load = (async () => {
130149
130705
  for (let offset = 0; offset < bytes.length; offset += TRACE_PARSE_CHUNK_BYTES) {
130150
130706
  await engine.parse(bytes.subarray(offset, offset + TRACE_PARSE_CHUNK_BYTES));
@@ -130173,27 +130729,22 @@ function readCell(v) {
130173
130729
  }
130174
130730
  return v;
130175
130731
  }
130176
- function decodeRows(result) {
130177
- const cols = result.columns();
130178
- const rows = [];
130179
- for (const it = result.iter({}); it.valid(); it.next()) {
130732
+ function decodeRows({ columns, rows }) {
130733
+ return rows.map((cells) => {
130180
130734
  const row = {};
130181
- for (const c of cols) row[c] = readCell(it.get(c));
130182
- rows.push(row);
130183
- }
130184
- return rows;
130735
+ columns.forEach((c, i) => row[c] = readCell(cells[i]));
130736
+ return row;
130737
+ });
130185
130738
  }
130186
130739
  async function queryWarm(tracePath, sql) {
130187
130740
  const engine = await getWarmEngine(tracePath);
130188
130741
  let result;
130189
130742
  try {
130190
130743
  result = await Promise.race([engine.query(sql), engine.fatal]);
130191
- } catch (err2) {
130744
+ } catch (err) {
130192
130745
  await disposeWarmEngine(tracePath);
130193
- throw err2;
130746
+ throw err;
130194
130747
  }
130195
- const err = result.error();
130196
- if (err) throw new Error(err);
130197
130748
  return decodeRows(result);
130198
130749
  }
130199
130750
  async function disposeWarmEngine(tracePath) {
@@ -130445,6 +130996,7 @@ function androidDevtoolsRef(device) {
130445
130996
  var READY_TIMEOUT_MS2 = 3e4;
130446
130997
  var EXIT_GRACE_MS = 200;
130447
130998
  var HELPER_EXIT_TIMEOUT_MS = 3e3;
130999
+ var DISPOSE_FORCE_STOP_WAIT_MS = 2e3;
130448
131000
  var HELPER_PORT_MARKER = /^INSTRUMENTATION_STATUS:\s*port=(\d+)/;
130449
131001
  var ADB_FORWARD_PORT_MARKER = /^(\d+)\s*$/;
130450
131002
  var HELPER_STATUS_MARKER = /^INSTRUMENTATION_STATUS:\s*Error=/;
@@ -130474,7 +131026,7 @@ async function spawnHelper(serial) {
130474
131026
  }
130475
131027
  );
130476
131028
  }
130477
- const proc = (0, import_node_child_process21.spawn)(
131029
+ const proc = (0, import_node_child_process22.spawn)(
130478
131030
  adbPath,
130479
131031
  ["-s", serial, "shell", "am", "instrument", "-w", manifest.instrumentationRunner],
130480
131032
  { stdio: ["ignore", "pipe", "pipe"] }
@@ -130755,6 +131307,14 @@ var androidDevtoolsBlueprint = {
130755
131307
  spawned.proc.on("error", (err) => {
130756
131308
  if (!disposed) events.emit("terminated", err);
130757
131309
  });
131310
+ let forceStopping;
131311
+ const forceStopHelper = () => forceStopping ??= runAdb(
131312
+ ["-s", serial, "shell", "am", "force-stop", helperManifest().packageName],
131313
+ { timeoutMs: 5e3 }
131314
+ ).then(
131315
+ () => void 0,
131316
+ () => void 0
131317
+ );
130758
131318
  const reconnect = async () => {
130759
131319
  let opened;
130760
131320
  try {
@@ -130762,7 +131322,12 @@ var androidDevtoolsBlueprint = {
130762
131322
  await opened.client.request("ping");
130763
131323
  } catch (err) {
130764
131324
  opened?.client.close();
130765
- if (!disposed) events.emit("terminated", err instanceof Error ? err : void 0);
131325
+ if (!disposed) {
131326
+ events.emit("terminated", err instanceof Error ? err : void 0);
131327
+ if (getFailureSignal(err)?.error_code === FAILURE_CODES.ANDROID_DEVTOOLS_RPC_TIMEOUT) {
131328
+ await forceStopHelper();
131329
+ }
131330
+ }
130766
131331
  throw err;
130767
131332
  }
130768
131333
  if (disposed) {
@@ -130788,23 +131353,28 @@ var androidDevtoolsBlueprint = {
130788
131353
  resolve19();
130789
131354
  });
130790
131355
  });
130791
- const request3 = async (method, params) => {
130792
- let current = client2;
130793
- if (socketLost && !disposed && !procExited) {
130794
- reconnecting ??= reconnect().finally(() => {
130795
- reconnecting = null;
130796
- });
130797
- current = await reconnecting;
130798
- }
131356
+ const connected = async () => {
131357
+ if (!socketLost || disposed || procExited) return client2;
131358
+ reconnecting ??= reconnect().finally(() => {
131359
+ reconnecting = null;
131360
+ });
131361
+ return reconnecting;
131362
+ };
131363
+ const send = async (current, method, params) => {
130799
131364
  try {
130800
131365
  return await current.request(method, params);
130801
131366
  } catch (err) {
130802
131367
  if (!disposed && getFailureSignal(err)?.error_code === FAILURE_CODES.ANDROID_DEVTOOLS_RPC_ERROR && err instanceof Error && err.message.includes("UiAutomation not connected")) {
130803
131368
  events.emit("terminated", err);
130804
131369
  }
131370
+ if (!disposed && method !== "setText" && getFailureSignal(err)?.error_code === FAILURE_CODES.ANDROID_DEVTOOLS_RPC_TIMEOUT) {
131371
+ events.emit("terminated", err instanceof Error ? err : void 0);
131372
+ await forceStopHelper();
131373
+ }
130805
131374
  throw err;
130806
131375
  }
130807
131376
  };
131377
+ const request3 = async (method, params) => send(await connected(), method, params);
130808
131378
  const api = {
130809
131379
  isReady: () => ready2 && !disposed,
130810
131380
  getHierarchy(getOpts = {}) {
@@ -130822,9 +131392,10 @@ var androidDevtoolsBlueprint = {
130822
131392
  return request3("ping");
130823
131393
  },
130824
131394
  async setText(text, setOpts = {}) {
131395
+ const current = await connected();
130825
131396
  let result;
130826
131397
  try {
130827
- result = await request3("setText", {
131398
+ result = await send(current, "setText", {
130828
131399
  text,
130829
131400
  ...setOpts.check ? { check: true } : {}
130830
131401
  });
@@ -130881,6 +131452,16 @@ var androidDevtoolsBlueprint = {
130881
131452
  }
130882
131453
  }
130883
131454
  if (acknowledged) await waitForHelperExit(HELPER_EXIT_TIMEOUT_MS);
131455
+ else if (!procExited) {
131456
+ let timer;
131457
+ await Promise.race([
131458
+ forceStopHelper(),
131459
+ new Promise((resolve19) => {
131460
+ timer = setTimeout(resolve19, DISPOSE_FORCE_STOP_WAIT_MS);
131461
+ })
131462
+ ]);
131463
+ clearTimeout(timer);
131464
+ }
130884
131465
  void opening?.then(
130885
131466
  (opened) => opened.client.close(),
130886
131467
  () => void 0
@@ -130982,18 +131563,18 @@ function hasUnreadWebView(node2) {
130982
131563
  // ../tool-server/src/preview.ts
130983
131564
  function findUiFile(name) {
130984
131565
  const candidates = [
130985
- import_node_path11.default.join(__dirname, "preview-ui", name),
130986
- import_node_path11.default.resolve(__dirname, "..", "..", "..", "ui", name),
130987
- import_node_path11.default.resolve(__dirname, "..", "..", "ui", name)
131566
+ import_node_path12.default.join(__dirname, "preview-ui", name),
131567
+ import_node_path12.default.resolve(__dirname, "..", "..", "..", "ui", name),
131568
+ import_node_path12.default.resolve(__dirname, "..", "..", "ui", name)
130988
131569
  ];
130989
131570
  for (const p of candidates) {
130990
- if (import_node_fs8.default.existsSync(p)) return p;
131571
+ if (import_node_fs9.default.existsSync(p)) return p;
130991
131572
  }
130992
131573
  return null;
130993
131574
  }
130994
131575
  function serveUiFile(res, filePath, contentType) {
130995
131576
  res.set("Cache-Control", "no-store, must-revalidate");
130996
- res.type(contentType).sendFile(import_node_path11.default.basename(filePath), { root: import_node_path11.default.dirname(filePath) });
131577
+ res.type(contentType).sendFile(import_node_path12.default.basename(filePath), { root: import_node_path12.default.dirname(filePath) });
130997
131578
  }
130998
131579
  function wsUrlFromHttp(httpUrl2) {
130999
131580
  const u = new URL(httpUrl2);
@@ -131325,7 +131906,7 @@ data: ${JSON.stringify(data)}
131325
131906
  const roots = /* @__PURE__ */ new Set();
131326
131907
  for (const r of [import_node_os7.default.tmpdir(), process.cwd(), "/tmp"]) {
131327
131908
  try {
131328
- roots.add(import_node_fs8.default.realpathSync(r));
131909
+ roots.add(import_node_fs9.default.realpathSync(r));
131329
131910
  } catch {
131330
131911
  }
131331
131912
  }
@@ -131344,8 +131925,8 @@ data: ${JSON.stringify(data)}
131344
131925
  let real;
131345
131926
  let size;
131346
131927
  try {
131347
- real = import_node_fs8.default.realpathSync(src);
131348
- const st = import_node_fs8.default.statSync(real);
131928
+ real = import_node_fs9.default.realpathSync(src);
131929
+ const st = import_node_fs9.default.statSync(real);
131349
131930
  if (!st.isFile()) throw new Error("not a file");
131350
131931
  size = st.size;
131351
131932
  } catch {
@@ -131353,16 +131934,16 @@ data: ${JSON.stringify(data)}
131353
131934
  return;
131354
131935
  }
131355
131936
  const contained = allowedRoots.some(
131356
- (root) => real === root || real.startsWith(root + import_node_path11.default.sep)
131937
+ (root) => real === root || real.startsWith(root + import_node_path12.default.sep)
131357
131938
  );
131358
- const mime = IMG_MIME[import_node_path11.default.extname(real).toLowerCase()];
131939
+ const mime = IMG_MIME[import_node_path12.default.extname(real).toLowerCase()];
131359
131940
  if (!contained || !mime || size > MAX_PREVIEW_BYTES) {
131360
131941
  res.status(404).end();
131361
131942
  return;
131362
131943
  }
131363
131944
  res.set("Cache-Control", "no-store");
131364
131945
  res.type(mime);
131365
- import_node_fs8.default.createReadStream(real).on("error", () => {
131946
+ import_node_fs9.default.createReadStream(real).on("error", () => {
131366
131947
  if (!res.headersSent) res.status(404).end();
131367
131948
  }).pipe(res);
131368
131949
  });
@@ -131414,104 +131995,9 @@ data: ${JSON.stringify(data)}
131414
131995
  }
131415
131996
 
131416
131997
  // ../tool-server/src/artifacts.ts
131417
- var import_node_fs9 = require("node:fs");
131418
- var import_promises8 = require("node:fs/promises");
131998
+ var import_node_fs10 = require("node:fs");
131999
+ var import_promises9 = require("node:fs/promises");
131419
132000
  var import_node_child_process23 = require("node:child_process");
131420
-
131421
- // ../archive/src/index.ts
131422
- var import_node_child_process22 = require("node:child_process");
131423
- var import_promises7 = require("node:fs/promises");
131424
- var import_node_path12 = require("node:path");
131425
- var import_node_util17 = require("node:util");
131426
- var execFileAsync17 = (0, import_node_util17.promisify)(import_node_child_process22.execFile);
131427
- var ArchiveError = class extends Error {
131428
- };
131429
- function createTarGzArgs(sourcePath, target) {
131430
- return ["-czf", target, "-C", (0, import_node_path12.dirname)(sourcePath), (0, import_node_path12.basename)(sourcePath)];
131431
- }
131432
- function normalizeTarMemberPath(memberPath2) {
131433
- return memberPath2.replace(/^\.\//, "").replace(/\\/g, "/");
131434
- }
131435
- function isSafeTarMember(memberPath2, destDir) {
131436
- const normalized = normalizeTarMemberPath(memberPath2);
131437
- if (!normalized || normalized === "." || normalized === "./") return false;
131438
- if (normalized.startsWith("/") || /^[A-Za-z]:[\\/]/.test(normalized)) return false;
131439
- const relative9 = import_node_path12.posix.normalize(normalized);
131440
- if (relative9 === ".." || relative9.startsWith("../") || relative9.split("/").includes("..")) {
131441
- return false;
131442
- }
131443
- const root = (0, import_node_path12.resolve)(destDir);
131444
- const resolved = (0, import_node_path12.resolve)(destDir, relative9);
131445
- return resolved === root || resolved.startsWith(root + import_node_path12.sep);
131446
- }
131447
- async function listTarMembers(tarPath) {
131448
- const { stdout } = await execFileAsync17("tar", ["-tzf", tarPath]);
131449
- return stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
131450
- }
131451
- function isEscapingLinkTarget(target) {
131452
- if (target.startsWith("/") || /^[A-Za-z]:[\\/]/.test(target)) return true;
131453
- return import_node_path12.posix.normalize(target.replace(/\\/g, "/")).split("/").includes("..");
131454
- }
131455
- async function assertSafeMemberTypes(tarPath) {
131456
- const { stdout } = await execFileAsync17("tar", ["-tzvf", tarPath]);
131457
- for (const line of stdout.split("\n")) {
131458
- if (!line.trim()) continue;
131459
- const type = line[0];
131460
- if (type === "-" || type === "d") continue;
131461
- if (type === "l") {
131462
- const parts2 = line.split(" -> ");
131463
- const target = parts2.length === 2 ? parts2[1].trim() : "";
131464
- if (parts2.length !== 2 || !target || isEscapingLinkTarget(target)) {
131465
- throw new ArchiveError(
131466
- `Archive contains a symlink whose target could not be confirmed safe: "${line.trim()}".`
131467
- );
131468
- }
131469
- continue;
131470
- }
131471
- throw new ArchiveError(
131472
- `Archive contains an unsupported member type "${type}" (hardlink/device/\u2026) \u2014 refusing extraction.`
131473
- );
131474
- }
131475
- }
131476
- async function assertSafeArchive(tarPath, destDir) {
131477
- let members2;
131478
- try {
131479
- members2 = await listTarMembers(tarPath);
131480
- } catch (err) {
131481
- throw new ArchiveError(
131482
- `Could not read archive: ${err instanceof Error ? err.message : String(err)}`
131483
- );
131484
- }
131485
- if (members2.length === 0) {
131486
- throw new ArchiveError("Archive is empty.");
131487
- }
131488
- for (const member of members2) {
131489
- if (!isSafeTarMember(member, destDir)) {
131490
- throw new ArchiveError(`Archive contains an unsafe path "${member}" \u2014 refusing extraction.`);
131491
- }
131492
- }
131493
- await assertSafeMemberTypes(tarPath);
131494
- }
131495
- async function resolveMember(destDir, expectedName) {
131496
- const entries = await (0, import_promises7.readdir)(destDir);
131497
- if (entries.includes(expectedName)) {
131498
- return (0, import_node_path12.join)(destDir, expectedName);
131499
- }
131500
- const real = entries.filter((e) => !e.startsWith("._"));
131501
- if (real.length !== 1) {
131502
- throw new ArchiveError(
131503
- `Could not identify the extracted member (expected "${expectedName}", found ${real.length} entries).`
131504
- );
131505
- }
131506
- return (0, import_node_path12.join)(destDir, real[0]);
131507
- }
131508
- async function safeExtractTarGz(tarPath, destDir, expectedName) {
131509
- await assertSafeArchive(tarPath, destDir);
131510
- await execFileAsync17("tar", ["-xzf", tarPath, "-C", destDir]);
131511
- return resolveMember(destDir, expectedName);
131512
- }
131513
-
131514
- // ../tool-server/src/artifacts.ts
131515
132001
  init_src2();
131516
132002
  function requireArtifacts(ctx) {
131517
132003
  if (!ctx?.artifacts) {
@@ -131530,19 +132016,19 @@ function makeArtifactRoute(registry2) {
131530
132016
  return;
131531
132017
  }
131532
132018
  try {
131533
- await (0, import_promises8.access)(entry.path);
132019
+ await (0, import_promises9.access)(entry.path);
131534
132020
  } catch {
131535
132021
  res.status(410).json({ error: `Artifact "${id}" file no longer exists on the tool-server host` });
131536
132022
  return;
131537
132023
  }
131538
132024
  if (entry.isDirectory) {
131539
- streamDirectoryAsTarGz(id, entry, res);
132025
+ streamDirectoryAsArchive(id, entry, req, res);
131540
132026
  return;
131541
132027
  }
131542
132028
  res.setHeader("Content-Type", entry.mimeType);
131543
132029
  res.setHeader("Content-Disposition", `attachment; filename="${entry.filename}"`);
131544
132030
  if (entry.size > 0) res.setHeader("Content-Length", String(entry.size));
131545
- const stream = (0, import_node_fs9.createReadStream)(entry.path);
132031
+ const stream = (0, import_node_fs10.createReadStream)(entry.path);
131546
132032
  stream.on("error", () => {
131547
132033
  if (!res.headersSent) res.status(500).json({ error: `Failed to read artifact "${id}"` });
131548
132034
  else res.destroy();
@@ -131556,29 +132042,41 @@ function makeArtifactListRoute(registry2) {
131556
132042
  res.json({ artifacts });
131557
132043
  };
131558
132044
  }
131559
- function streamDirectoryAsTarGz(id, entry, res) {
131560
- res.setHeader("Content-Type", "application/gzip");
131561
- res.setHeader("Content-Disposition", `attachment; filename="${entry.filename}.tar.gz"`);
131562
- const child = (0, import_node_child_process23.spawn)("tar", createTarGzArgs(entry.path, "-"), {
132045
+ function streamDirectoryAsArchive(id, entry, req, res) {
132046
+ const format = pickArchiveFormat(archiveFormatsFromAccept(req.headers.accept));
132047
+ const ext = format === "zstd" ? "tar.zst" : "tar.gz";
132048
+ res.setHeader("Content-Type", ARCHIVE_CONTENT_TYPES[format]);
132049
+ res.setHeader("Vary", "Accept");
132050
+ res.setHeader("Content-Disposition", `attachment; filename="${entry.filename}.${ext}"`);
132051
+ const child = (0, import_node_child_process23.spawn)("tar", createTarArgs(entry.path), {
131563
132052
  stdio: ["ignore", "pipe", "ignore"]
131564
132053
  });
131565
132054
  child.on("error", (err) => {
131566
132055
  if (!res.headersSent) {
132056
+ res.removeHeader("Content-Disposition");
132057
+ res.type("json");
131567
132058
  res.status(500).json({ error: `Failed to archive artifact "${id}": ${err.message}` });
131568
132059
  } else {
131569
132060
  res.destroy();
131570
132061
  }
131571
132062
  });
132063
+ const compressor = createCompressor(format);
131572
132064
  res.on("close", () => {
131573
- if (!res.writableFinished && child.exitCode === null && child.signalCode === null) {
131574
- child.kill("SIGTERM");
131575
- }
132065
+ if (res.writableFinished) return;
132066
+ compressor.destroy();
132067
+ if (child.exitCode === null && child.signalCode === null) child.kill("SIGTERM");
131576
132068
  });
131577
- child.stdout.pipe(res);
132069
+ compressor.on("error", () => res.destroy());
132070
+ child.on("close", (code) => {
132071
+ if (code === 0) return void compressor.end();
132072
+ compressor.destroy();
132073
+ if (!res.writableEnded) res.destroy();
132074
+ });
132075
+ child.stdout.pipe(compressor, { end: false }).pipe(res);
131578
132076
  }
131579
132077
 
131580
132078
  // ../tool-server/src/file-inputs.ts
131581
- var import_promises9 = require("node:fs/promises");
132079
+ var import_promises10 = require("node:fs/promises");
131582
132080
  var import_node_os8 = require("node:os");
131583
132081
  var import_node_path13 = require("node:path");
131584
132082
  var import_bytes = __toESM(require_bytes());
@@ -131589,7 +132087,7 @@ var FileInputError = class extends Error {
131589
132087
  async function probeHostPath(wire, kind) {
131590
132088
  const miss = { present: false, statVerified: false };
131591
132089
  try {
131592
- const st = await (0, import_promises9.stat)(wire.path);
132090
+ const st = await (0, import_promises10.stat)(wire.path);
131593
132091
  if (kind === "directory") return { present: st.isDirectory(), statVerified: false };
131594
132092
  if (kind === "probe") return { present: true, statVerified: false };
131595
132093
  if (kind === "tar-upload" && st.isDirectory()) {
@@ -131636,9 +132134,9 @@ function decodeContent(wire) {
131636
132134
  }
131637
132135
  async function materializeUpload(wire) {
131638
132136
  const data = decodeContent(wire);
131639
- const dir = await (0, import_promises9.mkdtemp)((0, import_node_path13.join)((0, import_node_os8.tmpdir)(), "argent-file-input-"));
132137
+ const dir = await (0, import_promises10.mkdtemp)((0, import_node_path13.join)((0, import_node_os8.tmpdir)(), "argent-file-input-"));
131640
132138
  const filePath = (0, import_node_path13.join)(dir, sanitizeFilename((0, import_node_path13.basename)(wire.path)));
131641
- await (0, import_promises9.writeFile)(filePath, data);
132139
+ await (0, import_promises10.writeFile)(filePath, data);
131642
132140
  return { filePath, dir };
131643
132141
  }
131644
132142
  async function extractTarUpload(wire, uploadId, meta3, tempDirs, lookupUpload) {
@@ -131659,11 +132157,11 @@ async function extractTarUpload(wire, uploadId, meta3, tempDirs, lookupUpload) {
131659
132157
  `Upload content hash mismatch for "${wire.path}" \u2014 the tarball may have been corrupted in transit. Re-run the tool to upload again.`
131660
132158
  );
131661
132159
  }
131662
- const extractDir = await (0, import_promises9.mkdtemp)(
132160
+ const extractDir = await (0, import_promises10.mkdtemp)(
131663
132161
  (0, import_node_path13.join)((0, import_node_os8.tmpdir)(), `argent-tar-upload-${entry.sha256.slice(0, 16)}-`)
131664
132162
  );
131665
132163
  tempDirs.push(extractDir);
131666
- const uploaded = await safeExtractTarGz(entry.tarPath, extractDir, (0, import_node_path13.basename)(wire.path));
132164
+ const uploaded = await safeExtractArchive(entry.tarPath, extractDir, (0, import_node_path13.basename)(wire.path));
131667
132165
  return { value: uploaded, meta: { ...meta3, viaUpload: true } };
131668
132166
  } catch (err) {
131669
132167
  if (err instanceof FileInputError) throw err;
@@ -131671,7 +132169,7 @@ async function extractTarUpload(wire, uploadId, meta3, tempDirs, lookupUpload) {
131671
132169
  `Could not extract the uploaded archive for "${wire.path}": ${err instanceof Error ? err.message : String(err)}`
131672
132170
  );
131673
132171
  } finally {
131674
- await (0, import_promises9.rm)(entry.tarPath, { force: true }).catch(() => {
132172
+ await (0, import_promises10.rm)(entry.tarPath, { force: true }).catch(() => {
131675
132173
  });
131676
132174
  }
131677
132175
  }
@@ -131721,10 +132219,10 @@ async function memberText(member, tempDirs, lookupUpload, taken) {
131721
132219
  `Could not read the uploaded file "${member.path}": ${errorText(err)}`
131722
132220
  );
131723
132221
  };
131724
- const { size } = await (0, import_promises9.stat)(file2).catch(unreadable);
132222
+ const { size } = await (0, import_promises10.stat)(file2).catch(unreadable);
131725
132223
  checkUploadSize(member, size);
131726
132224
  countMemberBytes(member, taken, size);
131727
- return (0, import_promises9.readFile)(file2, "utf8").catch(unreadable);
132225
+ return (0, import_promises10.readFile)(file2, "utf8").catch(unreadable);
131728
132226
  }
131729
132227
  async function resolveMembers(members2, tempDirs, lookupUpload) {
131730
132228
  const out = {};
@@ -131835,7 +132333,7 @@ async function releaseUploads(specs, body, lookupUpload) {
131835
132333
  await Promise.all(
131836
132334
  ids.map(async (id) => {
131837
132335
  const entry = typeof id === "string" ? lookupUpload?.(id) : void 0;
131838
- if (entry) await (0, import_promises9.rm)(entry.tarPath, { force: true }).catch(() => {
132336
+ if (entry) await (0, import_promises10.rm)(entry.tarPath, { force: true }).catch(() => {
131839
132337
  });
131840
132338
  })
131841
132339
  );
@@ -131844,7 +132342,7 @@ async function resolveFileInputs(def, body, lookupUpload) {
131844
132342
  const tempDirs = [];
131845
132343
  const cleanup = async () => {
131846
132344
  await Promise.all(
131847
- tempDirs.map((dir) => (0, import_promises9.rm)(dir, { recursive: true, force: true }).catch(() => {
132345
+ tempDirs.map((dir) => (0, import_promises10.rm)(dir, { recursive: true, force: true }).catch(() => {
131848
132346
  }))
131849
132347
  );
131850
132348
  };
@@ -133088,7 +133586,7 @@ init_src2();
133088
133586
 
133089
133587
  // ../tool-server/src/utils/ios-device/runner-artifact.ts
133090
133588
  var import_node_child_process26 = require("node:child_process");
133091
- var import_node_util19 = require("node:util");
133589
+ var import_node_util18 = require("node:util");
133092
133590
  var import_node_crypto9 = require("node:crypto");
133093
133591
  var fs31 = __toESM(require("node:fs"));
133094
133592
  var fsp = __toESM(require("node:fs/promises"));
@@ -133114,11 +133612,11 @@ init_src2();
133114
133612
 
133115
133613
  // ../tool-server/src/utils/ios-device/provisioning-profiles.ts
133116
133614
  var import_node_child_process25 = require("node:child_process");
133117
- var import_node_fs10 = require("node:fs");
133615
+ var import_node_fs11 = require("node:fs");
133118
133616
  var import_node_os9 = require("node:os");
133119
133617
  var path26 = __toESM(require("node:path"));
133120
- var import_node_util18 = require("node:util");
133121
- var execFileAsync18 = (0, import_node_util18.promisify)(import_node_child_process25.execFile);
133618
+ var import_node_util17 = require("node:util");
133619
+ var execFileAsync17 = (0, import_node_util17.promisify)(import_node_child_process25.execFile);
133122
133620
  var PROFILE_DIRECTORIES = [
133123
133621
  path26.join("Library", "Developer", "Xcode", "UserData", "Provisioning Profiles"),
133124
133622
  path26.join("Library", "MobileDevice", "Provisioning Profiles")
@@ -133143,13 +133641,13 @@ async function readInstalledProfiles() {
133143
133641
  const files = (await Promise.all(
133144
133642
  PROFILE_DIRECTORIES.map(async (directory) => {
133145
133643
  const absolute = path26.join((0, import_node_os9.homedir)(), directory);
133146
- const names = await import_node_fs10.promises.readdir(absolute).catch(() => []);
133644
+ const names = await import_node_fs11.promises.readdir(absolute).catch(() => []);
133147
133645
  return names.filter((name) => name.endsWith(".mobileprovision")).map((name) => path26.join(absolute, name));
133148
133646
  })
133149
133647
  )).flat();
133150
133648
  const decoded2 = await Promise.all(
133151
133649
  files.map(
133152
- (file2) => execFileAsync18("security", ["cms", "-D", "-i", file2], {
133650
+ (file2) => execFileAsync17("security", ["cms", "-D", "-i", file2], {
133153
133651
  timeout: PROFILE_DECODE_TIMEOUT_MS,
133154
133652
  maxBuffer: PROFILE_MAX_BYTES
133155
133653
  }).then(
@@ -133227,7 +133725,7 @@ function resolveSigningHint(output2) {
133227
133725
  }
133228
133726
 
133229
133727
  // ../tool-server/src/utils/ios-device/runner-artifact.ts
133230
- var execFileAsync19 = (0, import_node_util19.promisify)(import_node_child_process26.execFile);
133728
+ var execFileAsync18 = (0, import_node_util18.promisify)(import_node_child_process26.execFile);
133231
133729
  var PROJECT_SUFFIX = "ios-device-runner/ArgentRunner/ArgentRunner.xcodeproj";
133232
133730
  function resolveRunnerProjectPath() {
133233
133731
  const override = process.env.ARGENT_IOS_RUNNER_PROJECT;
@@ -133278,7 +133776,7 @@ async function fingerprintRunnerSources(projectPath) {
133278
133776
  }
133279
133777
  async function xcodeVersionFingerprint() {
133280
133778
  try {
133281
- const { stdout } = await execFileAsync19("xcodebuild", ["-version"], { timeout: 2e4 });
133779
+ const { stdout } = await execFileAsync18("xcodebuild", ["-version"], { timeout: 2e4 });
133282
133780
  return stdout.trim().replace(/\n/g, " ");
133283
133781
  } catch {
133284
133782
  return "unknown-xcode";
@@ -133426,7 +133924,7 @@ async function buildRunnerArtifact(derivedDataPath, staticArgs, destinationUdid,
133426
133924
  derivedDataPath
133427
133925
  ];
133428
133926
  try {
133429
- await execFileAsync19("xcodebuild", args, {
133927
+ await execFileAsync18("xcodebuild", args, {
133430
133928
  timeout: BUILD_TIMEOUT_MS,
133431
133929
  killSignal: "SIGKILL",
133432
133930
  maxBuffer: BUILD_MAX_OUTPUT_BYTES
@@ -133481,13 +133979,38 @@ var fs32 = __toESM(require("node:fs"));
133481
133979
  var fsp2 = __toESM(require("node:fs/promises"));
133482
133980
  var os12 = __toESM(require("node:os"));
133483
133981
  var path28 = __toESM(require("node:path"));
133982
+ var import_node_util19 = require("node:util");
133484
133983
  init_src2();
133984
+ var execFileAsync19 = (0, import_node_util19.promisify)(import_node_child_process27.execFile);
133485
133985
  function logsRoot() {
133486
133986
  return path28.join(os12.homedir(), ".argent", "ios-device-runner", "logs");
133487
133987
  }
133488
133988
  function resultsRoot() {
133489
133989
  return path28.join(os12.homedir(), ".argent", "ios-device-runner", "results");
133490
133990
  }
133991
+ var RUNNER_ATTACHMENT_SETTINGS = [
133992
+ ["PreferredScreenCaptureFormat", "screenshots"],
133993
+ ["SystemAttachmentLifetime", "keepNever"],
133994
+ ["UserAttachmentLifetime", "keepNever"]
133995
+ ];
133996
+ var RUNNER_TEST_TARGET_KEY_PATHS = ["ArgentRunnerUITests", "TestConfigurations.0.TestTargets.0"];
133997
+ async function disableRunnerAttachments(xctestrunPath) {
133998
+ for (const target of RUNNER_TEST_TARGET_KEY_PATHS) {
133999
+ try {
134000
+ for (const [key2, value] of RUNNER_ATTACHMENT_SETTINGS) {
134001
+ await execFileAsync19(
134002
+ "plutil",
134003
+ ["-replace", `${target}.${key2}`, "-string", value, xctestrunPath],
134004
+ {
134005
+ timeout: 1e4
134006
+ }
134007
+ );
134008
+ }
134009
+ return;
134010
+ } catch {
134011
+ }
134012
+ }
134013
+ }
133491
134014
  async function launchRunner(opts) {
133492
134015
  const logDir = logsRoot();
133493
134016
  const resultsDir = resultsRoot();
@@ -133499,6 +134022,7 @@ async function launchRunner(opts) {
133499
134022
  const logPath = path28.join(logDir, `runner-${deviceTag}.log`);
133500
134023
  const resultBundlePath = path28.join(resultsDir, `argent-${deviceTag}.xcresult`);
133501
134024
  await fsp2.rm(resultBundlePath, { recursive: true, force: true });
134025
+ await disableRunnerAttachments(opts.xctestrunPath);
133502
134026
  const logFd = fs32.openSync(logPath, "w");
133503
134027
  const child = (0, import_node_child_process27.spawn)(
133504
134028
  "xcodebuild",
@@ -134338,6 +134862,7 @@ function iosDeviceRunnerRef(device) {
134338
134862
  };
134339
134863
  }
134340
134864
  var RUNNER_READY_TIMEOUT_MS = 12e4;
134865
+ var RUNNER_CLEAN_EXIT_TIMEOUT_MS = 1e4;
134341
134866
  async function startRunner(udid, artifact) {
134342
134867
  const launched = await launchRunner({
134343
134868
  udid,
@@ -134491,9 +135016,12 @@ var iosDeviceRunnerBlueprint = {
134491
135016
  disposed = true;
134492
135017
  try {
134493
135018
  await client2.run({ command: "shutdown" }, { timeoutMs: 3e3 });
135019
+ await settleExit(RUNNER_CLEAN_EXIT_TIMEOUT_MS);
134494
135020
  } catch {
134495
135021
  }
134496
- killRunnerProcess(launched.child);
135022
+ if (exitCode === void 0) {
135023
+ killRunnerProcess(launched.child);
135024
+ }
134497
135025
  }
134498
135026
  };
134499
135027
  },
@@ -137927,21 +138455,21 @@ var Matcher = class {
137927
138455
  * @returns {string}
137928
138456
  */
137929
138457
  toString(separator, includeNamespace = true) {
137930
- const sep10 = separator || this.separator;
137931
- const isDefault = sep10 === this.separator && includeNamespace === true;
138458
+ const sep11 = separator || this.separator;
138459
+ const isDefault = sep11 === this.separator && includeNamespace === true;
137932
138460
  if (isDefault) {
137933
138461
  if (this._pathStringCache !== null) {
137934
138462
  return this._pathStringCache;
137935
138463
  }
137936
138464
  const result = this.path.map(
137937
138465
  (n) => n.namespace ? `${n.namespace}:${n.tag}` : n.tag
137938
- ).join(sep10);
138466
+ ).join(sep11);
137939
138467
  this._pathStringCache = result;
137940
138468
  return result;
137941
138469
  }
137942
138470
  return this.path.map(
137943
138471
  (n) => includeNamespace && n.namespace ? `${n.namespace}:${n.tag}` : n.tag
137944
- ).join(sep10);
138472
+ ).join(sep11);
137945
138473
  }
137946
138474
  /**
137947
138475
  * Get path as array of tag names.
@@ -139811,10 +140339,10 @@ async function describeVega(_serial) {
139811
140339
  // ../tool-server/src/tools/describe/platforms/harmony/index.ts
139812
140340
  var import_node_os10 = require("node:os");
139813
140341
  var import_node_path14 = require("node:path");
139814
- var import_promises11 = require("node:fs/promises");
140342
+ var import_promises12 = require("node:fs/promises");
139815
140343
 
139816
140344
  // ../tool-server/src/utils/harmony-uitest.ts
139817
- var import_promises10 = require("node:fs/promises");
140345
+ var import_promises11 = require("node:fs/promises");
139818
140346
  init_src2();
139819
140347
  var REMOTE_TMP = "/data/local/tmp";
139820
140348
  var UITEST_TIMEOUT_MS = 2e4;
@@ -140063,7 +140591,7 @@ async function harmonyDumpLayout(connectKey, localPath, timeoutMs = UITEST_TIMEO
140063
140591
  },
140064
140592
  Date.now() + timeoutMs
140065
140593
  );
140066
- const raw = await (0, import_promises10.readFile)(localPath, "utf8");
140594
+ const raw = await (0, import_promises11.readFile)(localPath, "utf8");
140067
140595
  try {
140068
140596
  return JSON.parse(raw);
140069
140597
  } catch (err) {
@@ -140358,7 +140886,7 @@ async function describeHarmony(connectKey, timeoutMs = HARMONY_INTERACTION_TIMEO
140358
140886
  ...display.screenOn ? {} : { stale: true }
140359
140887
  };
140360
140888
  } finally {
140361
- await (0, import_promises11.rm)(localPath, { force: true }).catch(() => {
140889
+ await (0, import_promises12.rm)(localPath, { force: true }).catch(() => {
140362
140890
  });
140363
140891
  }
140364
140892
  }
@@ -140830,7 +141358,7 @@ function createMacosAppApi(bundleId) {
140830
141358
  };
140831
141359
  const terminate = async (app) => {
140832
141360
  let ch;
140833
- let open4 = /* @__PURE__ */ new Set();
141361
+ let open5 = /* @__PURE__ */ new Set();
140834
141362
  let unanswered;
140835
141363
  try {
140836
141364
  ch = await ensureChannel();
@@ -140839,7 +141367,7 @@ function createMacosAppApi(bundleId) {
140839
141367
  const held = heldQuits.get(bundleId);
140840
141368
  unanswered = held?.pid === app.pid ? shown.find((w) => !held.openBefore.has(w.number)) : void 0;
140841
141369
  if (!unanswered) {
140842
- open4 = new Set(shown.map((w) => w.number));
141370
+ open5 = new Set(shown.map((w) => w.number));
140843
141371
  await ch.request("Application.terminate", {}, 2e3);
140844
141372
  }
140845
141373
  } catch {
@@ -140853,9 +141381,9 @@ function createMacosAppApi(bundleId) {
140853
141381
  }) : [app.pid];
140854
141382
  if (ch && left.length > 0) {
140855
141383
  const after = await ch.request("Window.list", {}, 2e3).catch(() => null);
140856
- const prompt = shownPrompts(after).find((w) => !open4.has(w.number));
141384
+ const prompt = shownPrompts(after).find((w) => !open5.has(w.number));
140857
141385
  if (prompt) {
140858
- heldQuits.set(bundleId, { pid: app.pid, openBefore: open4 });
141386
+ heldQuits.set(bundleId, { pid: app.pid, openBefore: open5 });
140859
141387
  throw quitPromptRefusal(bundleId, prompt);
140860
141388
  }
140861
141389
  }
@@ -140870,9 +141398,9 @@ function createMacosAppApi(bundleId) {
140870
141398
  );
140871
141399
  }
140872
141400
  if (signalled.length === 0) {
140873
- return open4.size > 0 ? `argent quit ${bundleId} (pid ${app.pid}) while it showed a dialog. Unsaved changes in it may be lost.` : void 0;
141401
+ return open5.size > 0 ? `argent quit ${bundleId} (pid ${app.pid}) while it showed a dialog. Unsaved changes in it may be lost.` : void 0;
140874
141402
  }
140875
- const reason2 = open4.size > 0 ? "a dialog it showed kept it from quitting" : ch ? `it did not quit within ${TERMINATE_GRACE_MS / 1e3} s` : "argent could not ask it to quit";
141403
+ const reason2 = open5.size > 0 ? "a dialog it showed kept it from quitting" : ch ? `it did not quit within ${TERMINATE_GRACE_MS / 1e3} s` : "argent could not ask it to quit";
140876
141404
  return `argent force-quit ${bundleId} (pid ${app.pid}): ${reason2}. Unsaved changes in it may be lost.`;
140877
141405
  };
140878
141406
  const doLaunch = async (opts) => {
@@ -142389,11 +142917,11 @@ function nearestAfter(candidates, anchors, reading) {
142389
142917
  }
142390
142918
  function findAll(root, selector, orientation) {
142391
142919
  const all = [];
142392
- const collect = (node2) => {
142920
+ const collect2 = (node2) => {
142393
142921
  all.push(node2);
142394
- for (const child of node2.children) collect(child);
142922
+ for (const child of node2.children) collect2(child);
142395
142923
  };
142396
- for (const child of root.children) collect(child);
142924
+ for (const child of root.children) collect2(child);
142397
142925
  return resolveSelector(all, selector, readingFrames(orientation));
142398
142926
  }
142399
142927
  var SELECTOR_RELATIONS = ["within", "after", "next"];
@@ -143751,7 +144279,7 @@ function createHttpApp(registry2, options) {
143751
144279
  for (const [id, entry] of uploads) {
143752
144280
  if (entry.expireAt < now) {
143753
144281
  uploads.delete(id);
143754
- (0, import_promises12.rm)(entry.tarPath, { force: true }).catch(() => {
144282
+ (0, import_promises13.rm)(entry.tarPath, { force: true }).catch(() => {
143755
144283
  });
143756
144284
  }
143757
144285
  }
@@ -143858,7 +144386,7 @@ function createHttpApp(registry2, options) {
143858
144386
  }
143859
144387
  const id = (0, import_node_crypto11.randomUUID)();
143860
144388
  const tarPath = (0, import_node_path15.join)((0, import_node_os11.tmpdir)(), `argent-upload-${id}.tar.gz`);
143861
- const ws = (0, import_node_fs11.createWriteStream)(tarPath);
144389
+ const ws = (0, import_node_fs12.createWriteStream)(tarPath);
143862
144390
  let received = 0;
143863
144391
  let released = false;
143864
144392
  const releaseInFlight = () => {
@@ -143869,7 +144397,7 @@ function createHttpApp(registry2, options) {
143869
144397
  const abort = (status, message) => {
143870
144398
  releaseInFlight();
143871
144399
  ws.destroy();
143872
- (0, import_promises12.rm)(tarPath, { force: true }).catch(() => {
144400
+ (0, import_promises13.rm)(tarPath, { force: true }).catch(() => {
143873
144401
  });
143874
144402
  if (!res.headersSent) res.status(status).json({ error: message });
143875
144403
  };
@@ -143896,7 +144424,7 @@ function createHttpApp(registry2, options) {
143896
144424
  if (req.readableEnded) return;
143897
144425
  releaseInFlight();
143898
144426
  ws.destroy();
143899
- (0, import_promises12.rm)(tarPath, { force: true }).catch(() => {
144427
+ (0, import_promises13.rm)(tarPath, { force: true }).catch(() => {
143900
144428
  });
143901
144429
  });
143902
144430
  ws.on("finish", () => {
@@ -143941,7 +144469,7 @@ function createHttpApp(registry2, options) {
143941
144469
  }));
143942
144470
  return [entry, ...aliases];
143943
144471
  });
143944
- res.json({ tools });
144472
+ res.json({ tools, uploadFormats: ARCHIVE_FORMATS });
143945
144473
  });
143946
144474
  app.post(
143947
144475
  "/tools/:name",
@@ -144298,7 +144826,7 @@ function createHttpApp(registry2, options) {
144298
144826
  dispose: () => {
144299
144827
  idleTimer.dispose();
144300
144828
  clearInterval(uploadSweeper);
144301
- for (const entry of uploads.values()) (0, import_promises12.rm)(entry.tarPath, { force: true }).catch(() => {
144829
+ for (const entry of uploads.values()) (0, import_promises13.rm)(entry.tarPath, { force: true }).catch(() => {
144302
144830
  });
144303
144831
  uploads.clear();
144304
144832
  },
@@ -144329,15 +144857,15 @@ function createHttpApp(registry2, options) {
144329
144857
 
144330
144858
  // ../tool-server/src/event-log.ts
144331
144859
  var import_bunyan = __toESM(require_bunyan());
144332
- var import_node_fs12 = require("node:fs");
144860
+ var import_node_fs13 = require("node:fs");
144333
144861
  var import_node_path16 = require("node:path");
144334
144862
  init_src2();
144335
144863
  function createToolServerEventLog({
144336
144864
  filePath
144337
144865
  }) {
144338
- (0, import_node_fs12.mkdirSync)((0, import_node_path16.dirname)(filePath), { recursive: true });
144339
- (0, import_node_fs12.writeFileSync)(filePath, "");
144340
- const fileStream = (0, import_node_fs12.createWriteStream)(filePath, { flags: "a" });
144866
+ (0, import_node_fs13.mkdirSync)((0, import_node_path16.dirname)(filePath), { recursive: true });
144867
+ (0, import_node_fs13.writeFileSync)(filePath, "");
144868
+ const fileStream = (0, import_node_fs13.createWriteStream)(filePath, { flags: "a" });
144341
144869
  let disposed = false;
144342
144870
  let disposePromise = null;
144343
144871
  let streamError = null;
@@ -146167,7 +146695,7 @@ Returns { envSetup, appRunning, connected, requiresRestart, state, message, next
146167
146695
  - nextLaunchWillBeInjected: if you launch this bundle now, native devtools env setup is already in place (always false for a non-injectable app)
146168
146696
  - injectable: false for Apple system apps (bundle ids under com.apple.), which the native tools refuse to read.
146169
146697
 
146170
- If injectable is false: treat this as TERMINAL. The app is not a supported native-devtools target, and no relaunch changes that. Do NOT restart/retry. Use the standard \`describe\` tool (its accessibility path reads the screen without injection) or \`screenshot\` (then interact by coordinate). Do not fall back to the native-devtools feature tools (native-find-views, native-full-hierarchy, native-network-logs, native-view-at-point, native-user-interactable-view-at-point): they run the same injection precheck and fail with the same non-injectable error.
146698
+ If injectable is false: treat this as TERMINAL. The app is not a supported native-devtools target, and no relaunch changes that. Do NOT restart/retry. Use the standard \`describe\` tool (its accessibility path reads the screen without injection) or \`screenshot\` (then interact by coordinate). Do not fall back to the native-devtools feature tools (native-find-views, native-full-hierarchy, native-network-logs, native-view-at-point): they run the same injection precheck and fail with the same non-injectable error.
146171
146699
  If appRunning is false and nextLaunchWillBeInjected is true: use launch-app normally.
146172
146700
  If requiresRestart is true: call restart-app once, then proceed with the native feature. Read state before acting on a second such reading. Indeterminate reaches this rule too, and its line below bounds it at that one restart.
146173
146701
  If state is unregistered: do NOT restart the app again: it already launched under the terms a restart would recreate. Restart the tool-server (\`argent server stop && argent server start --detach\`), then retry. If it reads unregistered again after that restart, stop: the process loads argent's dylib but never dials, and no further restart on either side changes it. Treat native devtools as unavailable, then use \`describe\` or \`screenshot\` and drive by coordinate.
@@ -146548,7 +147076,7 @@ var nativeFindViewsTool = {
146548
147076
  id: "native-find-views",
146549
147077
  description: `Search for specific UIViews in the running app by class name, accessibility identifier, accessibility label, tag or React Native nativeID; at least one of these params is required.
146550
147078
  Use when you need to locate a specific view by its properties without dumping the entire native-full-hierarchy.
146551
- Returns { status: "ok", matches }: the matching views with their frames, properties, optional ancestors and optional children. Frames are in points. frame and center are relative to the superview, and windowFrame turns with the UI. To tap a view, divide the centre of its screenFrame by the screen size in points, which native-full-hierarchy returns as screen (maxDepth: 1 is enough), and pass the result to gesture-tap. Matches are not filtered for visibility. Before tapping, call native-user-interactable-view-at-point at that centre with skipClasses ["UITextEffectsWindow"]. If it does not return the match or a descendant, check a screenshot.
147079
+ Returns { status: "ok", matches }: the matching views with their frames, properties, optional ancestors and optional children. Frames are in points. frame and center are relative to the superview, and windowFrame turns with the UI. To tap a view, divide the centre of its screenFrame by the screen size in points, which native-full-hierarchy returns as screen (maxDepth: 1 is enough), and pass the result to gesture-tap. Matches are not filtered for visibility. Before tapping, call native-view-at-point with hitTest: true at that centre, with skipClasses ["UITextEffectsWindow"]. If it does not return the match or a descendant, check a screenshot.
146552
147080
  <flag:macos-apps>On a Mac app it searches the NSViews of every visible window: className is the NSView class, and identifier matches the accessibility identifier or the view identifier. SwiftUI sets a control's identifier and label on an accessibility element, not on an NSView, so an identifier or label search does not find SwiftUI controls: describe lists them with their identifiers and frames. The tap recipe above and the statuses below are iOS only.
146553
147081
  </flag:macos-apps>If status is restart_required: follow the message (usually restart-app), then retry. If status is service_stale: the app is already injected, so restarting it cannot help. Restart the tool-server (\`argent server stop && argent server start --detach\`) and retry. If the same status comes back after that restart, stop restarting: follow the message, which names the terminal fallback. If status is connect_pending: the app is injected and still connecting. Do not restart it, wait a few seconds and retry. If status is init_failed: follow the message (re-boot the simulator) rather than retrying.
146554
147082
  An Apple system app is rejected outright (terminal: never retry it).`,
@@ -146704,7 +147232,7 @@ An Apple system app is rejected outright (terminal: never retry it).`,
146704
147232
  // ../tool-server/src/tools/native-devtools/native-view-at-point.ts
146705
147233
  init_zod();
146706
147234
  init_src2();
146707
- var zodSchema8 = external_exports.object({
147235
+ var viewAtPointParams = {
146708
147236
  ...nativeAppTarget,
146709
147237
  x: external_exports.number().describe(
146710
147238
  "Raw X coordinate in points, on the portrait axes of the screen<flag:macos-apps>; on a Mac app, points from the top-left of the area describe reports</flag:macos-apps>. NOT normalized [0,1] tap space."
@@ -146718,21 +147246,39 @@ var zodSchema8 = external_exports.object({
146718
147246
  skipClasses: external_exports.array(external_exports.string()).optional().describe("Exact UIView class names whose entire subtree should be pruned"),
146719
147247
  skipClassPrefixes: external_exports.array(external_exports.string()).optional().describe("Class name prefixes to prune entire subtrees"),
146720
147248
  maxDepth: external_exports.number().int().positive().optional().describe("Maximum depth for returned child/ancestor serialization (default 150)")
147249
+ };
147250
+ var zodSchema8 = external_exports.object({
147251
+ ...viewAtPointParams,
147252
+ hitTest: external_exports.boolean().optional().describe(
147253
+ "true returns the view that would receive a touch at the point: it respects userInteractionEnabled, close to UIKit hit-testing. Default false: the deepest visible view."
147254
+ )
146721
147255
  });
147256
+ function queryViewAtPoint(services, params, toolId, hitTest) {
147257
+ return queryViewHierarchyFor(
147258
+ services,
147259
+ params,
147260
+ toolId,
147261
+ hitTest ? "ViewHierarchy.userInteractableViewAtPoint" : "ViewHierarchy.viewAtPoint",
147262
+ hitTest ? FAILURE_CODES.NATIVE_DEVTOOLS_USER_INTERACTABLE_VIEW_AT_POINT_ERROR : FAILURE_CODES.NATIVE_DEVTOOLS_VIEW_AT_POINT_ERROR,
147263
+ (result) => ({ status: "ok", view: result.view ?? null })
147264
+ );
147265
+ }
146722
147266
  var nativeViewAtPointTool = {
146723
147267
  id: "native-view-at-point",
146724
- description: `Inspect the deepest visible UIView at a raw native window point.
146725
-
146726
- Unlike native-user-interactable-view-at-point, this ignores userInteractionEnabled,
146727
- so it answers "what is visually here?" rather than "what would receive the touch?".
147268
+ description: `Inspect the deepest UIView at a raw native window point: the one drawn there, or with hitTest: true the one that would receive a touch.
146728
147269
 
147270
+ Without hitTest it ignores userInteractionEnabled and answers "what is visually here?".
146729
147271
  Use when a screenshot shows something the accessibility tree does not name (an
146730
147272
  unlabeled icon, a decorative overlay, a custom-drawn cell) and you need the class,
146731
147273
  identifier or nativeID of whatever draws it.
146732
147274
 
147275
+ With hitTest: true it answers "what would receive the touch?". Use when a tap lands
147276
+ somewhere unexpected or does nothing, to see which control UIKit would hand the
147277
+ touch to: a transparent overlay swallowing it, a parent recognizer, a disabled button.
147278
+
146733
147279
  Returns { status: "ok", view }: the matched view with its class name, frames,
146734
147280
  identifier, label and layer name, plus its ancestors and subviews as requested.
146735
- view is null when nothing is drawn at that point.
147281
+ view is null when nothing is drawn at that point, or with hitTest when no touchable view sits under it.
146736
147282
 
146737
147283
  To get x and y from a normalized describe frame, multiply its values by the
146738
147284
  screen size in points, also when the UI is landscape.
@@ -146744,9 +147290,9 @@ An Apple system app is rejected outright (terminal: never retry it).`,
146744
147290
  zodSchema: zodSchema8,
146745
147291
  readOnly: true,
146746
147292
  interaction: {
146747
- startedMsg: ({ params }) => `Inspecting native view at (${params.x}, ${params.y})`,
146748
- completedMsg: ({ params }) => `Inspected native view at (${params.x}, ${params.y})`,
146749
- failedMsg: ({ params, failureSignal: failureSignal2 }) => `Failed to inspect native view at (${params.x}, ${params.y}): ${failureSignal2.error_code}`
147293
+ startedMsg: ({ params }) => params.hitTest ? `Finding interactive view at (${params.x}, ${params.y})` : `Inspecting native view at (${params.x}, ${params.y})`,
147294
+ completedMsg: ({ params }) => params.hitTest ? `Found interactive view at (${params.x}, ${params.y})` : `Inspected native view at (${params.x}, ${params.y})`,
147295
+ failedMsg: ({ params, failureSignal: failureSignal2 }) => params.hitTest ? `Failed to find interactive view at (${params.x}, ${params.y}): ${failureSignal2.error_code}` : `Failed to inspect native view at (${params.x}, ${params.y}): ${failureSignal2.error_code}`
146750
147296
  },
146751
147297
  capability: {
146752
147298
  apple: { simulator: true },
@@ -146754,57 +147300,22 @@ An Apple system app is rejected outright (terminal: never retry it).`,
146754
147300
  macos: { app: true }
146755
147301
  },
146756
147302
  services: nativeAppServices,
146757
- execute: (services, params) => queryViewHierarchyFor(
146758
- services,
146759
- params,
146760
- "native-view-at-point",
146761
- "ViewHierarchy.viewAtPoint",
146762
- FAILURE_CODES.NATIVE_DEVTOOLS_VIEW_AT_POINT_ERROR,
146763
- (result) => ({ status: "ok", view: result.view ?? null })
146764
- )
147303
+ execute: (services, { hitTest, ...query }) => queryViewAtPoint(services, query, "native-view-at-point", hitTest === true)
146765
147304
  };
146766
147305
 
146767
147306
  // ../tool-server/src/tools/native-devtools/native-user-interactable-view-at-point.ts
146768
147307
  init_zod();
146769
- init_src2();
146770
- var zodSchema9 = external_exports.object({
146771
- ...nativeAppTarget,
146772
- x: external_exports.number().describe(
146773
- "Raw X coordinate in points, on the portrait axes of the screen<flag:macos-apps>; on a Mac app, points from the top-left of the area describe reports</flag:macos-apps>. NOT normalized [0,1] tap space."
146774
- ),
146775
- y: external_exports.number().describe("Raw Y coordinate in points, on the same axes as x. NOT normalized [0,1] tap space."),
146776
- includeAncestors: external_exports.boolean().optional().describe("Include ancestor chain for the matched view (default true)"),
146777
- includeChildren: external_exports.boolean().optional().describe("Include child views for the matched view (default false)"),
146778
- fields: external_exports.array(external_exports.string()).optional().describe(
146779
- "View fields to include. Defaults: pointer, className, tag, frame, windowFrame, screenFrame, bounds, hidden, alpha, opaque, clipsToBounds, userInteractionEnabled, depth, identifier, label, layerName, nativeID. Additional: center, transform, contentMode, backgroundColor, tintColor, value, firstResponder"
146780
- ),
146781
- skipClasses: external_exports.array(external_exports.string()).optional().describe("Exact UIView class names whose entire subtree should be pruned"),
146782
- skipClassPrefixes: external_exports.array(external_exports.string()).optional().describe("Class name prefixes to prune entire subtrees"),
146783
- maxDepth: external_exports.number().int().positive().optional().describe("Maximum depth for returned child/ancestor serialization (default 150)")
146784
- });
147308
+ var zodSchema9 = external_exports.object(viewAtPointParams);
146785
147309
  var nativeUserInteractableViewAtPointTool = {
146786
147310
  id: "native-user-interactable-view-at-point",
146787
147311
  description: `Inspect the deepest UIView at a raw native window point that would actually receive touch input.
146788
147312
 
146789
- Unlike native-view-at-point, this respects userInteractionEnabled and is closer to
146790
- UIKit hit-testing semantics.
146791
-
146792
- Use when a tap lands somewhere unexpected or does nothing, to see which control
146793
- UIKit would hand the touch to: a transparent overlay swallowing it, a parent
146794
- recognizer, a disabled button.
146795
-
146796
- Returns { status: "ok", view }: the hit-test winner with its class name, frames,
146797
- identifier, label and layer name, plus its ancestors and subviews as requested.
146798
- view is null when no touchable view sits under that point.
146799
-
146800
- To get x and y from a normalized describe frame, multiply its values by the
146801
- screen size in points, also when the UI is landscape.
146802
- native-full-hierarchy returns that size as screen (pass maxDepth: 1 and fields: ["className"] to keep it small).<flag:macos-apps> On a Mac app,
146803
- multiply them by the size of the area describe reports instead.</flag:macos-apps>
147313
+ It respects userInteractionEnabled and is close to UIKit hit-testing. The same query as native-view-at-point with hitTest: true, which documents the coordinates and the result.
146804
147314
 
146805
147315
  If status is restart_required: follow the message (usually restart-app), then retry. If status is service_stale: the app is already injected, so restarting it cannot help. Restart the tool-server (\`argent server stop && argent server start --detach\`) and retry. If the same status comes back after that restart, stop restarting: follow the message, which names the terminal fallback. If status is connect_pending: the app is injected and still connecting. Do not restart it, wait a few seconds and retry. If status is init_failed: follow the message (re-boot the simulator) rather than retrying.
146806
147316
  An Apple system app is rejected outright (terminal: never retry it).`,
146807
147317
  zodSchema: zodSchema9,
147318
+ hideFromMcp: true,
146808
147319
  readOnly: true,
146809
147320
  interaction: {
146810
147321
  startedMsg: ({ params }) => `Finding interactive view at (${params.x}, ${params.y})`,
@@ -146817,25 +147328,18 @@ An Apple system app is rejected outright (terminal: never retry it).`,
146817
147328
  macos: { app: true }
146818
147329
  },
146819
147330
  services: nativeAppServices,
146820
- execute: (services, params) => queryViewHierarchyFor(
146821
- services,
146822
- params,
146823
- "native-user-interactable-view-at-point",
146824
- "ViewHierarchy.userInteractableViewAtPoint",
146825
- FAILURE_CODES.NATIVE_DEVTOOLS_USER_INTERACTABLE_VIEW_AT_POINT_ERROR,
146826
- (result) => ({ status: "ok", view: result.view ?? null })
146827
- )
147331
+ execute: (services, params) => queryViewAtPoint(services, params, "native-user-interactable-view-at-point", true)
146828
147332
  };
146829
147333
 
146830
147334
  // ../tool-server/src/blueprints/js-runtime-debugger.ts
146831
147335
  init_src2();
146832
147336
 
146833
147337
  // ../tool-server/src/utils/debugger/discovery.ts
146834
- var import_node_fs13 = require("node:fs");
147338
+ var import_node_fs14 = require("node:fs");
146835
147339
  init_src2();
146836
147340
  var DECOY_VM = "don't use";
146837
147341
  function decodeProjectRoot(raw) {
146838
- if (!raw.includes("%") || (0, import_node_fs13.existsSync)(raw)) return raw;
147342
+ if (!raw.includes("%") || (0, import_node_fs14.existsSync)(raw)) return raw;
146839
147343
  try {
146840
147344
  return decodeURIComponent(raw);
146841
147345
  } catch {
@@ -149510,8 +150014,8 @@ function clearLostProfilerRun(port, deviceId) {
149510
150014
 
149511
150015
  // ../tool-server/src/tools/devices/boot-device.ts
149512
150016
  var import_node_child_process34 = require("node:child_process");
149513
- var import_node_fs15 = require("node:fs");
149514
- var import_promises13 = require("node:fs/promises");
150017
+ var import_node_fs16 = require("node:fs");
150018
+ var import_promises14 = require("node:fs/promises");
149515
150019
  var import_node_os14 = require("node:os");
149516
150020
  var import_node_path19 = require("node:path");
149517
150021
  var import_node_util24 = require("node:util");
@@ -149623,7 +150127,7 @@ function readMb(config2, key2) {
149623
150127
 
149624
150128
  // ../tool-server/src/utils/simulator-app-launch.ts
149625
150129
  var import_node_child_process32 = require("node:child_process");
149626
- var import_node_fs14 = __toESM(require("node:fs"));
150130
+ var import_node_fs15 = __toESM(require("node:fs"));
149627
150131
  var import_node_os13 = __toESM(require("node:os"));
149628
150132
  var import_node_path18 = __toESM(require("node:path"));
149629
150133
  var import_node_util23 = require("node:util");
@@ -149637,7 +150141,7 @@ function verdictFilePath() {
149637
150141
  }
149638
150142
  function loadVerdicts() {
149639
150143
  try {
149640
- const parsed = JSON.parse(import_node_fs14.default.readFileSync(verdictFilePath(), "utf8"));
150144
+ const parsed = JSON.parse(import_node_fs15.default.readFileSync(verdictFilePath(), "utf8"));
149641
150145
  return parsed && typeof parsed === "object" ? parsed : {};
149642
150146
  } catch {
149643
150147
  return {};
@@ -149645,13 +150149,13 @@ function loadVerdicts() {
149645
150149
  }
149646
150150
  function persistVerdict(key2, verdict) {
149647
150151
  const filePath = verdictFilePath();
149648
- import_node_fs14.default.mkdirSync(import_node_path18.default.dirname(filePath), { recursive: true });
150152
+ import_node_fs15.default.mkdirSync(import_node_path18.default.dirname(filePath), { recursive: true });
149649
150153
  const tmpPath = `${filePath}.${process.pid}.tmp`;
149650
150154
  try {
149651
- import_node_fs14.default.writeFileSync(tmpPath, JSON.stringify({ ...loadVerdicts(), [key2]: verdict }, null, 2));
149652
- import_node_fs14.default.renameSync(tmpPath, filePath);
150155
+ import_node_fs15.default.writeFileSync(tmpPath, JSON.stringify({ ...loadVerdicts(), [key2]: verdict }, null, 2));
150156
+ import_node_fs15.default.renameSync(tmpPath, filePath);
149653
150157
  } catch (err) {
149654
- import_node_fs14.default.rmSync(tmpPath, { force: true });
150158
+ import_node_fs15.default.rmSync(tmpPath, { force: true });
149655
150159
  throw err;
149656
150160
  }
149657
150161
  }
@@ -150433,9 +150937,9 @@ async function bootIos(udid, registry2, force, headless) {
150433
150937
  async function openSimulatorWindow(udid) {
150434
150938
  const timeout = 5e3;
150435
150939
  const { stdout } = await execFileAsync24("xcode-select", ["-p"], { timeout });
150436
- const developerDir2 = (0, import_node_fs15.realpathSync)(stdout.trim());
150940
+ const developerDir2 = (0, import_node_fs16.realpathSync)(stdout.trim());
150437
150941
  const simulatorApp = (0, import_node_path19.join)(developerDir2, "Applications", "Simulator.app");
150438
- if ((0, import_node_fs15.existsSync)(simulatorApp)) {
150942
+ if ((0, import_node_fs16.existsSync)(simulatorApp)) {
150439
150943
  const launched = await launchSimulatorApp(
150440
150944
  simulatorApp,
150441
150945
  () => execFileAsync24("open", ["-a", simulatorApp], { timeout })
@@ -150443,7 +150947,7 @@ async function openSimulatorWindow(udid) {
150443
150947
  return launched ? void 0 : `${simulatorApp} exits right after launch on this host, so Argent no longer opens it and the device runs without a window. Delete ~/.argent/simulator-app-launch.json to try opening it again.`;
150444
150948
  }
150445
150949
  const deviceHubApp = (0, import_node_path19.join)(developerDir2, "..", "Applications", "DeviceHub.app");
150446
- if ((0, import_node_fs15.existsSync)(deviceHubApp)) {
150950
+ if ((0, import_node_fs16.existsSync)(deviceHubApp)) {
150447
150951
  const url2 = `devices://device/open?id=${encodeURIComponent(udid)}`;
150448
150952
  await execFileAsync24("open", ["-a", deviceHubApp, url2], { timeout });
150449
150953
  }
@@ -150491,7 +150995,7 @@ async function attemptBoot(params) {
150491
150995
  if (process.platform === "win32") {
150492
150996
  const safeName = params.avdName.replace(/[^\w.-]/g, "_");
150493
150997
  const logPath = (0, import_node_path19.join)((0, import_node_os14.tmpdir)(), `argent-emulator-${safeName}.log`);
150494
- emulatorLogFd = (0, import_node_fs15.openSync)(logPath, "w");
150998
+ emulatorLogFd = (0, import_node_fs16.openSync)(logPath, "w");
150495
150999
  stdio = ["ignore", emulatorLogFd, emulatorLogFd];
150496
151000
  }
150497
151001
  const child = (0, import_node_child_process34.spawn)(params.emulatorBinary, params.emulatorArgs, {
@@ -150501,7 +151005,7 @@ async function attemptBoot(params) {
150501
151005
  child.unref();
150502
151006
  if (emulatorLogFd !== void 0) {
150503
151007
  try {
150504
- (0, import_node_fs15.closeSync)(emulatorLogFd);
151008
+ (0, import_node_fs16.closeSync)(emulatorLogFd);
150505
151009
  } catch {
150506
151010
  }
150507
151011
  }
@@ -151019,11 +151523,11 @@ async function startHarmonyEmulator(instanceName) {
151019
151523
  });
151020
151524
  }
151021
151525
  try {
151022
- for (const entry of (0, import_node_fs15.readdirSync)((0, import_node_os14.tmpdir)())) {
151526
+ for (const entry of (0, import_node_fs16.readdirSync)((0, import_node_os14.tmpdir)())) {
151023
151527
  if (!entry.startsWith("argent-harmony-") || !entry.endsWith(".log")) continue;
151024
151528
  try {
151025
- if (Date.now() - (0, import_node_fs15.statSync)((0, import_node_path19.join)((0, import_node_os14.tmpdir)(), entry)).mtimeMs > HARMONY_LOG_TTL_MS) {
151026
- (0, import_node_fs15.rmSync)((0, import_node_path19.join)((0, import_node_os14.tmpdir)(), entry), { force: true });
151529
+ if (Date.now() - (0, import_node_fs16.statSync)((0, import_node_path19.join)((0, import_node_os14.tmpdir)(), entry)).mtimeMs > HARMONY_LOG_TTL_MS) {
151530
+ (0, import_node_fs16.rmSync)((0, import_node_path19.join)((0, import_node_os14.tmpdir)(), entry), { force: true });
151027
151531
  }
151028
151532
  } catch {
151029
151533
  }
@@ -151034,7 +151538,7 @@ async function startHarmonyEmulator(instanceName) {
151034
151538
  const logPath = (0, import_node_path19.join)((0, import_node_os14.tmpdir)(), `argent-harmony-${safeName}-${process.hrtime.bigint()}.log`);
151035
151539
  let logFd;
151036
151540
  try {
151037
- logFd = (0, import_node_fs15.openSync)(logPath, "w");
151541
+ logFd = (0, import_node_fs16.openSync)(logPath, "w");
151038
151542
  } catch {
151039
151543
  logFd = null;
151040
151544
  }
@@ -151045,7 +151549,7 @@ async function startHarmonyEmulator(instanceName) {
151045
151549
  child.unref();
151046
151550
  if (logFd !== null) {
151047
151551
  try {
151048
- (0, import_node_fs15.closeSync)(logFd);
151552
+ (0, import_node_fs16.closeSync)(logFd);
151049
151553
  } catch {
151050
151554
  }
151051
151555
  }
@@ -151054,7 +151558,7 @@ async function startHarmonyEmulator(instanceName) {
151054
151558
  if (exit) return;
151055
151559
  let output2 = "";
151056
151560
  try {
151057
- output2 = (0, import_node_fs15.readFileSync)(logPath, "utf8");
151561
+ output2 = (0, import_node_fs16.readFileSync)(logPath, "utf8");
151058
151562
  } catch {
151059
151563
  }
151060
151564
  exit = { reason: reason2, output: output2 };
@@ -151165,7 +151669,7 @@ async function waitForHarmonyDrivable(connectKey, deadline, checkAlive) {
151165
151669
  await new Promise((r) => setTimeout(r, Math.min(HARMONY_TARGET_POLL_MS, remaining)));
151166
151670
  }
151167
151671
  } finally {
151168
- const remove = () => (0, import_promises13.rm)(probePath, { force: true }).catch(() => {
151672
+ const remove = () => (0, import_promises14.rm)(probePath, { force: true }).catch(() => {
151169
151673
  });
151170
151674
  if (inFlight3) void inFlight3.then(remove);
151171
151675
  else await remove();
@@ -151822,6 +152326,8 @@ function parseResolvedActivity(raw) {
151822
152326
  if (/^android\/.*(Resolver|Chooser)Activity$/.test(last)) return null;
151823
152327
  return last;
151824
152328
  }
152329
+ var LAUNCHER = "android.intent.category.LAUNCHER";
152330
+ var LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
151825
152331
  async function resolveLauncherActivity(udid, bundleId, isTv = false) {
151826
152332
  let lastRaw = "";
151827
152333
  const resolveFor = async (category) => {
@@ -151835,11 +152341,11 @@ async function resolveLauncherActivity(udid, bundleId, isTv = false) {
151835
152341
  return parseResolvedActivity(raw);
151836
152342
  };
151837
152343
  if (isTv) {
151838
- const leanback = await resolveFor("android.intent.category.LEANBACK_LAUNCHER");
151839
- if (leanback) return leanback;
152344
+ const leanback = await resolveFor(LEANBACK_LAUNCHER);
152345
+ if (leanback) return { component: leanback, category: LEANBACK_LAUNCHER };
151840
152346
  }
151841
152347
  const launcher = await resolveFor();
151842
- if (launcher) return launcher;
152348
+ if (launcher) return { component: launcher, category: LAUNCHER };
151843
152349
  const pmPath = await adbShell(udid, `pm path ${shellQuote2(bundleId)}; true`);
151844
152350
  throw new FailureError(
151845
152351
  `Could not resolve a ${isTv ? "LEANBACK_LAUNCHER or LAUNCHER" : "LAUNCHER"} activity for ${bundleId}. ` + (pmPath.includes("package:") ? `It is installed but declares no such activity: pass an explicit \`activity\`. ` : `It is not installed on ${udid}: install it with \`reinstall-app\`. `) + `(resolve-activity output: ${lastRaw.trim() || "empty"})`,
@@ -151863,17 +152369,22 @@ async function followNativeNetworkCapture(udid, bundleId) {
151863
152369
  return {};
151864
152370
  }
151865
152371
  }
152372
+ function launcherStartArgs(category) {
152373
+ return category ? ` -a android.intent.action.MAIN -c ${shellQuote2(category)}` : "";
152374
+ }
151866
152375
  var androidImpl = {
151867
152376
  requires: ["adb"],
151868
152377
  handler: async (_services, params) => {
151869
152378
  let component;
152379
+ let category = null;
151870
152380
  if (params.activity) {
151871
152381
  component = normalizeActivityComponent(params.bundleId, params.activity);
151872
152382
  } else {
151873
152383
  const isTv = await isAndroidTv(params.udid);
151874
- component = await resolveLauncherActivity(params.udid, params.bundleId, isTv);
152384
+ ({ component, category } = await resolveLauncherActivity(params.udid, params.bundleId, isTv));
151875
152385
  }
151876
- const out = await adbShell(params.udid, `am start -W -n ${shellQuote2(component)}`, {
152386
+ const start2 = `am start -W${launcherStartArgs(category)} -n ${shellQuote2(component)}`;
152387
+ const out = await adbShell(params.udid, start2, {
151877
152388
  timeoutMs: 3e4
151878
152389
  });
151879
152390
  assertAmStartOk(out);
@@ -152291,13 +152802,15 @@ var androidImpl2 = {
152291
152802
  const { udid, bundleId, activity } = params;
152292
152803
  await adbShell(udid, `am force-stop ${shellQuote2(bundleId)}`, { timeoutMs: 15e3 });
152293
152804
  let component;
152805
+ let category = null;
152294
152806
  if (activity) {
152295
152807
  component = normalizeActivityComponent(bundleId, activity);
152296
152808
  } else {
152297
152809
  const isTv = await isAndroidTv(udid);
152298
- component = await resolveLauncherActivity(udid, bundleId, isTv);
152810
+ ({ component, category } = await resolveLauncherActivity(udid, bundleId, isTv));
152299
152811
  }
152300
- const out = await adbShell(udid, `am start -W -n ${shellQuote2(component)}`, {
152812
+ const start2 = `am start -W${launcherStartArgs(category)} -n ${shellQuote2(component)}`;
152813
+ const out = await adbShell(udid, start2, {
152301
152814
  timeoutMs: 3e4
152302
152815
  });
152303
152816
  try {
@@ -152523,19 +153036,19 @@ init_src2();
152523
153036
 
152524
153037
  // ../tool-server/src/tools/reinstall-app/validate-app.ts
152525
153038
  var import_node_child_process38 = require("node:child_process");
152526
- var import_promises15 = require("node:fs/promises");
153039
+ var import_promises16 = require("node:fs/promises");
152527
153040
  var import_node_path20 = require("node:path");
152528
153041
  var import_node_util28 = require("node:util");
152529
153042
  init_capability();
152530
153043
 
152531
153044
  // ../tool-server/src/utils/apk-package.ts
152532
- var import_promises14 = require("node:fs/promises");
152533
- var import_node_zlib = require("node:zlib");
153045
+ var import_promises15 = require("node:fs/promises");
153046
+ var import_node_zlib2 = require("node:zlib");
152534
153047
  async function readApkPackageName(apkPath) {
152535
153048
  return parseManifestPackage(await readZipEntry(apkPath, "AndroidManifest.xml"));
152536
153049
  }
152537
153050
  async function readZipEntry(zipPath, entryName) {
152538
- const file2 = await (0, import_promises14.open)(zipPath, "r");
153051
+ const file2 = await (0, import_promises15.open)(zipPath, "r");
152539
153052
  try {
152540
153053
  const read = async (position, length) => {
152541
153054
  const buf = Buffer.alloc(length);
@@ -152561,7 +153074,7 @@ async function readZipEntry(zipPath, entryName) {
152561
153074
  const dataStart = localOffset + 30 + local.readUInt16LE(26) + local.readUInt16LE(28);
152562
153075
  const data = await read(dataStart, compressedSize);
152563
153076
  if (method === 0) return data;
152564
- if (method === 8) return (0, import_node_zlib.inflateRawSync)(data);
153077
+ if (method === 8) return (0, import_node_zlib2.inflateRawSync)(data);
152565
153078
  throw new Error(`unsupported zip compression method ${method}`);
152566
153079
  }
152567
153080
  p = nextEntry;
@@ -152626,7 +153139,7 @@ function readStringPool(xml, chunk) {
152626
153139
  // ../tool-server/src/tools/reinstall-app/validate-app.ts
152627
153140
  var execFileAsync28 = (0, import_node_util28.promisify)(import_node_child_process38.execFile);
152628
153141
  async function requirePath(absolute, kind, what) {
152629
- const info = await (0, import_promises15.stat)(absolute).catch(() => null);
153142
+ const info = await (0, import_promises16.stat)(absolute).catch(() => null);
152630
153143
  if (!info) {
152631
153144
  throw new InvalidToolInputError(`appPath ${absolute} does not exist. Nothing was uninstalled.`);
152632
153145
  }
@@ -152642,7 +153155,7 @@ function mismatch(bundleId, absolute, actual) {
152642
153155
  async function assertIosAppBundle(absolute, bundleId, { readBundleId = true } = {}) {
152643
153156
  await requirePath(absolute, "directory", "an .app bundle directory");
152644
153157
  const infoPlist = (0, import_node_path20.join)(absolute, "Info.plist");
152645
- if (!(await (0, import_promises15.stat)(infoPlist).catch(() => null))?.isFile()) {
153158
+ if (!(await (0, import_promises16.stat)(infoPlist).catch(() => null))?.isFile()) {
152646
153159
  throw new InvalidToolInputError(
152647
153160
  `appPath ${absolute} has no Info.plist, so it is not an iOS .app bundle. Nothing was uninstalled.`
152648
153161
  );
@@ -153610,7 +154123,7 @@ init_device_info();
153610
154123
  init_adb();
153611
154124
 
153612
154125
  // ../tool-server/src/utils/device-orientation.ts
153613
- var import_node_fs16 = require("node:fs");
154126
+ var import_node_fs17 = require("node:fs");
153614
154127
  init_adb();
153615
154128
  var SURFACE_ROTATION_TO_NAME = {
153616
154129
  0: "Portrait",
@@ -153655,7 +154168,7 @@ function captureRotationForSurface(rotation) {
153655
154168
  async function readPngSize2(path63) {
153656
154169
  let handle;
153657
154170
  try {
153658
- handle = await import_node_fs16.promises.open(path63, "r");
154171
+ handle = await import_node_fs17.promises.open(path63, "r");
153659
154172
  const buf = Buffer.alloc(24);
153660
154173
  const { bytesRead } = await handle.read(buf, 0, 24, 0);
153661
154174
  if (bytesRead < 24) return null;
@@ -153725,7 +154238,7 @@ function androidDevtoolsRotationPeek(registry2, device) {
153725
154238
  }
153726
154239
 
153727
154240
  // ../tool-server/src/utils/vega-screen.ts
153728
- var import_promises16 = require("node:fs/promises");
154241
+ var import_promises17 = require("node:fs/promises");
153729
154242
  var import_node_os15 = require("node:os");
153730
154243
  var import_node_path27 = require("node:path");
153731
154244
  var import_pngjs3 = __toESM(require_png());
@@ -153737,12 +154250,12 @@ async function captureVegaScreenshotPng(opts = {}) {
153737
154250
  async function captureViaEmulatorConsole(opts) {
153738
154251
  const port = await discoverVegaConsolePort();
153739
154252
  const serial = `emulator-${port}`;
153740
- const outDir = await (0, import_promises16.mkdtemp)((0, import_node_path27.join)((0, import_node_os15.tmpdir)(), "vega-shot-"));
154253
+ const outDir = await (0, import_promises17.mkdtemp)((0, import_node_path27.join)((0, import_node_os15.tmpdir)(), "vega-shot-"));
153741
154254
  try {
153742
154255
  await runAdb(["-s", serial, "emu", "screenrecord", "screenshot", outDir], {
153743
154256
  timeoutMs: 2e4
153744
154257
  });
153745
- const pngName = (await (0, import_promises16.readdir)(outDir)).find((f) => f.toLowerCase().endsWith(".png"));
154258
+ const pngName = (await (0, import_promises17.readdir)(outDir)).find((f) => f.toLowerCase().endsWith(".png"));
153746
154259
  if (!pngName) {
153747
154260
  throw new FailureError(`emulator console wrote no PNG to ${outDir} for ${serial}`, {
153748
154261
  error_code: FAILURE_CODES.VEGA_SCREENSHOT_FAILED,
@@ -153751,22 +154264,22 @@ async function captureViaEmulatorConsole(opts) {
153751
154264
  error_kind: "unknown"
153752
154265
  });
153753
154266
  }
153754
- const decoded2 = import_pngjs3.PNG.sync.read(await (0, import_promises16.readFile)((0, import_node_path27.join)(outDir, pngName)));
154267
+ const decoded2 = import_pngjs3.PNG.sync.read(await (0, import_promises17.readFile)((0, import_node_path27.join)(outDir, pngName)));
153755
154268
  const scaled = scaleDecodedPng(
153756
154269
  decoded2,
153757
154270
  opts.scale ?? getScreenshotScaleOverride() ?? tvDefaultScale(decoded2.width, decoded2.height)
153758
154271
  );
153759
154272
  const outPath = (0, import_node_path27.join)((0, import_node_os15.tmpdir)(), `vega-screenshot-${process.hrtime.bigint()}.png`);
153760
- await (0, import_promises16.writeFile)(outPath, import_pngjs3.PNG.sync.write(scaled));
154273
+ await (0, import_promises17.writeFile)(outPath, import_pngjs3.PNG.sync.write(scaled));
153761
154274
  return outPath;
153762
154275
  } finally {
153763
- await (0, import_promises16.rm)(outDir, { recursive: true, force: true }).catch(() => {
154276
+ await (0, import_promises17.rm)(outDir, { recursive: true, force: true }).catch(() => {
153764
154277
  });
153765
154278
  }
153766
154279
  }
153767
154280
 
153768
154281
  // ../tool-server/src/utils/harmony-screen.ts
153769
- var import_promises17 = require("node:fs/promises");
154282
+ var import_promises18 = require("node:fs/promises");
153770
154283
  var import_node_os16 = require("node:os");
153771
154284
  var import_node_path28 = require("node:path");
153772
154285
  var import_pngjs4 = __toESM(require_png());
@@ -153792,17 +154305,17 @@ async function captureHarmonyScreenshotPng(opts) {
153792
154305
  const rawPath = (0, import_node_path28.join)((0, import_node_os16.tmpdir)(), `argent-harmony-raw-${process.hrtime.bigint()}.png`);
153793
154306
  try {
153794
154307
  await harmonyScreenCap(opts.connectKey, rawPath);
153795
- const decoded2 = decodeCapture(await (0, import_promises17.readFile)(rawPath), opts.connectKey);
154308
+ const decoded2 = decodeCapture(await (0, import_promises18.readFile)(rawPath), opts.connectKey);
153796
154309
  const scaled = scaleDecodedPng(decoded2, opts.scale);
153797
154310
  const outPath = (0, import_node_path28.join)((0, import_node_os16.tmpdir)(), `harmony-screenshot-${process.hrtime.bigint()}.png`);
153798
154311
  if (scaled === decoded2) {
153799
- await (0, import_promises17.rename)(rawPath, outPath);
154312
+ await (0, import_promises18.rename)(rawPath, outPath);
153800
154313
  } else {
153801
- await (0, import_promises17.writeFile)(outPath, import_pngjs4.PNG.sync.write(scaled));
154314
+ await (0, import_promises18.writeFile)(outPath, import_pngjs4.PNG.sync.write(scaled));
153802
154315
  }
153803
154316
  return outPath;
153804
154317
  } finally {
153805
- await (0, import_promises17.rm)(rawPath, { force: true }).catch(() => {
154318
+ await (0, import_promises18.rm)(rawPath, { force: true }).catch(() => {
153806
154319
  });
153807
154320
  }
153808
154321
  }
@@ -159707,7 +160220,7 @@ ${lines.join("\n")}`;
159707
160220
  };
159708
160221
 
159709
160222
  // ../tool-server/src/tools/network/network-request.ts
159710
- var zlib2 = __toESM(require("node:zlib"));
160223
+ var zlib3 = __toESM(require("node:zlib"));
159711
160224
  init_zod();
159712
160225
  init_device_info();
159713
160226
  var SENSITIVE_HEADER_PATTERNS = [
@@ -160035,19 +160548,19 @@ function decodeOne(bytes, coding, truncated) {
160035
160548
  let out;
160036
160549
  switch (coding) {
160037
160550
  case "gzip":
160038
- out = zlib2.gunzipSync(bytes, { maxOutputLength, ...flush(zlib2.constants.Z_SYNC_FLUSH) });
160551
+ out = zlib3.gunzipSync(bytes, { maxOutputLength, ...flush(zlib3.constants.Z_SYNC_FLUSH) });
160039
160552
  break;
160040
160553
  case "br":
160041
- out = zlib2.brotliDecompressSync(bytes, {
160554
+ out = zlib3.brotliDecompressSync(bytes, {
160042
160555
  maxOutputLength,
160043
- ...flush(zlib2.constants.BROTLI_OPERATION_FLUSH)
160556
+ ...flush(zlib3.constants.BROTLI_OPERATION_FLUSH)
160044
160557
  });
160045
160558
  break;
160046
160559
  case "zstd":
160047
- if (typeof zlib2.zstdDecompressSync !== "function") return void 0;
160048
- out = zlib2.zstdDecompressSync(bytes, {
160560
+ if (typeof zlib3.zstdDecompressSync !== "function") return void 0;
160561
+ out = zlib3.zstdDecompressSync(bytes, {
160049
160562
  maxOutputLength,
160050
- ...flush(zlib2.constants.ZSTD_e_flush)
160563
+ ...flush(zlib3.constants.ZSTD_e_flush)
160051
160564
  });
160052
160565
  break;
160053
160566
  default:
@@ -160377,7 +160890,7 @@ function createDescribeTool(registry2) {
160377
160890
  // Android's device probes plus the tree dump can outlast the 30s MCP fetch timeout.
160378
160891
  longRunning: true,
160379
160892
  description: `Get the accessibility / DOM element tree for the current screen.
160380
- Use when you need element frames or labels and have no fresh tree: most interaction tools (not tv-remote or shake) already return one after each action.
160893
+ Use when you need element frames or labels and have no fresh tree: most interaction tools (not tv-remote or shake) already return one after each action, or name an identical earlier one by its tree id.
160381
160894
  On iOS it reads the AXRuntime accessibility service, so it sees whatever is visible, including system dialogs and permission prompts. While a system dialog is visible it returns the dialog's elements (buttons, text); otherwise the foreground app's. On a physical iOS device it covers only the app started with launch-app; to read system dialogs there, launch-app \`com.apple.springboard\` first.
160382
160895
  On Android it reads the tree through Argent's UiAutomation helper, falling back to \`uiautomator dump\`. On Chromium it walks the DOM over the Chrome DevTools Protocol: every visible element with its ARIA role, accessible name and bounding rect.
160383
160896
  On Vega (Fire TV) it reads the on-device automation toolkit; \`[focused]\`/\`[selected]\` mark the D-pad cursor, which you move with \`tv-remote\` (Vega has no touch).<flag:harmonyos>
@@ -165110,11 +165623,11 @@ function buildHotspots(nodes, samples, timeDeltas, topN2, reactOnly) {
165110
165623
  function renderMarkdownTable(entries) {
165111
165624
  if (entries.length === 0) return "_No hotspots found._";
165112
165625
  const header = "| Function | Location | Self (ms) | Total (ms) | Self % |";
165113
- const sep10 = "|---|---|---|---|---|";
165626
+ const sep11 = "|---|---|---|---|---|";
165114
165627
  const rows = entries.map(
165115
165628
  (e) => `| \`${e.function}\` | ${e.url || "\u2014"} | ${e.self_ms} | ${e.total_ms} | ${e.self_pct} |`
165116
165629
  );
165117
- return [header, sep10, ...rows].join("\n");
165630
+ return [header, sep11, ...rows].join("\n");
165118
165631
  }
165119
165632
  var zodSchema50 = external_exports.object({
165120
165633
  port: metroPortField,
@@ -165232,11 +165745,11 @@ function renderMarkdownTable2(entries) {
165232
165745
  if (entries.length === 0)
165233
165746
  return "_No render data found. Ensure React DevTools global hook is present._";
165234
165747
  const header = "| Component | Instances | Total (ms) | Self Base (ms) |";
165235
- const sep10 = "|---|---|---|---|";
165748
+ const sep11 = "|---|---|---|---|";
165236
165749
  const rows = entries.map(
165237
165750
  (e) => `| \`${e.component}\` | ${e.renderCount} | ${e.totalActualDuration_ms.toFixed(2)} | ${e.selfBaseDuration_ms.toFixed(2)} |`
165238
165751
  );
165239
- return [header, sep10, ...rows].join("\n");
165752
+ return [header, sep11, ...rows].join("\n");
165240
165753
  }
165241
165754
  var zodSchema51 = external_exports.object({
165242
165755
  port: metroPortField,
@@ -165716,7 +166229,7 @@ init_capability();
165716
166229
  var import_child_process4 = require("child_process");
165717
166230
  init_src2();
165718
166231
  var import_fs9 = require("fs");
165719
- var import_node_fs17 = require("node:fs");
166232
+ var import_node_fs18 = require("node:fs");
165720
166233
  var path40 = __toESM(require("path"));
165721
166234
  init_external_devices();
165722
166235
 
@@ -167403,7 +167916,7 @@ function resolveDefaultTemplatePath() {
167403
167916
  )
167404
167917
  ];
167405
167918
  for (const candidate of candidates) {
167406
- if ((0, import_node_fs17.existsSync)(candidate)) return candidate;
167919
+ if ((0, import_node_fs18.existsSync)(candidate)) return candidate;
167407
167920
  }
167408
167921
  throw new FailureError(
167409
167922
  `Argent.tracetemplate not found. Looked in:
@@ -171612,7 +172125,7 @@ function renderTopFunctions(index, topN2, startMs, endMs, reactOnly = false) {
171612
172125
  return `_No function sampled in ${windowStart.toFixed(1)}\u2013${windowEnd.toFixed(1)}ms has a PascalCase (React component) name. Query again without react_only to see the JS work._`;
171613
172126
  }
171614
172127
  const header = "| Function | Self (ms) | Self % | Total (ms) | Location |";
171615
- const sep10 = "|---|---|---|---|---|";
172128
+ const sep11 = "|---|---|---|---|---|";
171616
172129
  const rows = hotspots.map((hs) => {
171617
172130
  const loc = hs.url ? `${shortenUrl(hs.url)}${hs.lineNumber != null ? `:${hs.lineNumber}` : ""}` : "\u2014";
171618
172131
  const selfPct = res.coveredMs > 0 ? `${(hs.selfMs / res.coveredMs * 100).toFixed(1)}%` : "\u2014";
@@ -171623,7 +172136,7 @@ function renderTopFunctions(index, topN2, startMs, endMs, reactOnly = false) {
171623
172136
  ${coverageNote(res, windowStart, windowEnd, reactOnly)}
171624
172137
 
171625
172138
  ${header}
171626
- ${sep10}
172139
+ ${sep11}
171627
172140
  ${rows.join("\n")}`;
171628
172141
  }
171629
172142
  function renderCallTree(index, functionName, topN2, includeCallers) {
@@ -173305,7 +173818,7 @@ Fails if the input has an unknown key (e.g. \`udids\` instead of \`devices\`); o
173305
173818
  // ../tool-server/src/tools/simulator/stop-metro.ts
173306
173819
  init_zod();
173307
173820
  var import_node_child_process47 = require("node:child_process");
173308
- var import_node_fs18 = require("node:fs");
173821
+ var import_node_fs19 = require("node:fs");
173309
173822
  init_src2();
173310
173823
  function parseNetstatListeningPids(netstatOutput, port) {
173311
173824
  const pids = /* @__PURE__ */ new Set();
@@ -173325,7 +173838,7 @@ function procListeningPids(port, proc = "/proc") {
173325
173838
  for (const table of ["tcp", "tcp6"]) {
173326
173839
  let rows;
173327
173840
  try {
173328
- rows = (0, import_node_fs18.readFileSync)(`${proc}/net/${table}`, "utf-8");
173841
+ rows = (0, import_node_fs19.readFileSync)(`${proc}/net/${table}`, "utf-8");
173329
173842
  } catch (error63) {
173330
173843
  if (table === "tcp6" && error63.code === "ENOENT") continue;
173331
173844
  throw error63;
@@ -173340,11 +173853,11 @@ function procListeningPids(port, proc = "/proc") {
173340
173853
  if (inodes.size === 0) return [];
173341
173854
  const owned = /* @__PURE__ */ new Set();
173342
173855
  const pids = [];
173343
- for (const entry of (0, import_node_fs18.readdirSync)(proc)) {
173856
+ for (const entry of (0, import_node_fs19.readdirSync)(proc)) {
173344
173857
  if (!/^\d+$/.test(entry)) continue;
173345
173858
  let fds;
173346
173859
  try {
173347
- fds = (0, import_node_fs18.readdirSync)(`${proc}/${entry}/fd`);
173860
+ fds = (0, import_node_fs19.readdirSync)(`${proc}/${entry}/fd`);
173348
173861
  } catch {
173349
173862
  continue;
173350
173863
  }
@@ -173352,7 +173865,7 @@ function procListeningPids(port, proc = "/proc") {
173352
173865
  for (const fd of fds) {
173353
173866
  let target;
173354
173867
  try {
173355
- target = (0, import_node_fs18.readlinkSync)(`${proc}/${entry}/fd/${fd}`);
173868
+ target = (0, import_node_fs19.readlinkSync)(`${proc}/${entry}/fd/${fd}`);
173356
173869
  } catch {
173357
173870
  continue;
173358
173871
  }
@@ -173371,8 +173884,8 @@ function procListeningPids(port, proc = "/proc") {
173371
173884
  }
173372
173885
  return pids;
173373
173886
  }
173374
- var LSOF_BIN = ["/usr/sbin/lsof", "/usr/bin/lsof"].find((p) => (0, import_node_fs18.existsSync)(p)) ?? "lsof";
173375
- var DARWIN_NETSTAT_BIN = (0, import_node_fs18.existsSync)("/usr/sbin/netstat") ? "/usr/sbin/netstat" : "netstat";
173887
+ var LSOF_BIN = ["/usr/sbin/lsof", "/usr/bin/lsof"].find((p) => (0, import_node_fs19.existsSync)(p)) ?? "lsof";
173888
+ var DARWIN_NETSTAT_BIN = (0, import_node_fs19.existsSync)("/usr/sbin/netstat") ? "/usr/sbin/netstat" : "netstat";
173376
173889
  function parseDarwinNetstatHasListener(netstatOutput, port) {
173377
173890
  return netstatOutput.split("\n").some((line) => {
173378
173891
  const cols = line.trim().split(/\s+/);
@@ -173491,7 +174004,7 @@ init_zod();
173491
174004
  // ../tool-server/src/tools/flows/flow-utils.ts
173492
174005
  var path48 = __toESM(require("node:path"));
173493
174006
  var fs63 = __toESM(require("node:fs/promises"));
173494
- var import_node_fs19 = require("node:fs");
174007
+ var import_node_fs20 = require("node:fs");
173495
174008
  init_src();
173496
174009
  init_src2();
173497
174010
  var import_yaml = __toESM(require_dist8());
@@ -175116,7 +175629,7 @@ function parseScriptPath(raw, value) {
175116
175629
  if (typeof value !== "string" || value.length === 0) {
175117
175630
  badEntry(
175118
175631
  raw,
175119
- "a `script` step needs a `path` \u2014 a .mjs file path relative to this e2e test's file, e.g. `script: { path: scripts/seed.mjs }`"
175632
+ `a \`script\` step needs a \`path\` \u2014 a ${SCRIPT_EXTENSIONS_FOR_MESSAGE} file path relative to this e2e test's file, e.g. \`script: { path: scripts/seed.mjs }\``
175120
175633
  );
175121
175634
  }
175122
175635
  if (value.includes("\\")) {
@@ -175125,23 +175638,34 @@ function parseScriptPath(raw, value) {
175125
175638
  if (path48.posix.isAbsolute(value) || /^[A-Za-z]:/.test(value)) {
175126
175639
  badEntry(raw, "a `script` path must be relative to the e2e test file that references it");
175127
175640
  }
175128
- if (!value.endsWith(".mjs")) {
175129
- if (value.toLowerCase().endsWith(".mjs")) {
175130
- badEntry(raw, "a `script` path must use the lowercase .mjs extension");
175641
+ if (!SCRIPT_FILE_EXTENSIONS.some((extension2) => value.endsWith(extension2))) {
175642
+ const lower = value.toLowerCase();
175643
+ const miscased = SCRIPT_FILE_EXTENSIONS.find((extension2) => lower.endsWith(extension2));
175644
+ if (miscased) {
175645
+ badEntry(raw, `a \`script\` path must use the lowercase ${miscased} extension`);
175646
+ }
175647
+ const commonJsOnly = COMMONJS_ONLY_EXTENSIONS.find((extension2) => lower.endsWith(extension2));
175648
+ if (commonJsOnly) {
175649
+ badEntry(
175650
+ raw,
175651
+ `a \`script\` path must end in ${SCRIPT_EXTENSIONS_FOR_MESSAGE}, and ${commonJsOnly} is not accepted \u2014 where the project's package.json sets "type": "module", use \`import\` in the script in place of \`require\``
175652
+ );
175131
175653
  }
175132
175654
  badEntry(
175133
175655
  raw,
175134
- "a `script` path must end in .mjs \u2014 the extension pins the module type whatever the project's package.json says"
175656
+ `a \`script\` path must end in ${SCRIPT_EXTENSIONS_FOR_MESSAGE} \u2014 a JavaScript or TypeScript file`
175135
175657
  );
175136
175658
  }
175137
175659
  if (!SCRIPT_FILE_NAME_PATTERN.test(path48.posix.basename(value))) {
175138
175660
  badEntry(
175139
175661
  raw,
175140
- `a \`script\` path's filename must match ${SCRIPT_FILE_NAME_PATTERN} \u2014 letters, digits, underscore, hyphen before the .mjs`
175662
+ `a \`script\` path's filename must match ${SCRIPT_FILE_NAME_PATTERN} \u2014 letters, digits, underscore, hyphen before the extension`
175141
175663
  );
175142
175664
  }
175143
175665
  return value;
175144
175666
  }
175667
+ var COMMONJS_ONLY_EXTENSIONS = [".cjs", ".cts"];
175668
+ var SCRIPT_EXTENSIONS_FOR_MESSAGE = `${SCRIPT_FILE_EXTENSIONS.slice(0, -1).join(", ")} or ${SCRIPT_FILE_EXTENSIONS.slice(-1)[0]}`;
175145
175669
  function parseScriptTimeout(raw, value) {
175146
175670
  if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
175147
175671
  badEntry(raw, "script.timeout needs a positive number of milliseconds (e.g. `timeout: 30000`)");
@@ -175732,7 +176256,7 @@ async function followDanglingLink(linkPath) {
175732
176256
  return current;
175733
176257
  }
175734
176258
  async function isWritable(filePath) {
175735
- return fs63.access(filePath, import_node_fs19.constants.W_OK).then(
176259
+ return fs63.access(filePath, import_node_fs20.constants.W_OK).then(
175736
176260
  () => true,
175737
176261
  () => false
175738
176262
  );
@@ -175972,7 +176496,7 @@ standalone e2e test, record a restart-app of the app under test as the FIRST ste
175972
176496
  pass executionPrerequisite instead. Starting over an existing e2e test replaces the
175973
176497
  whole file, including its \`requires:\` block; pass \`requires\` to keep it.
175974
176498
  Use e2e-add-echo to add labels, and
175975
- e2e-add-script to run a local .mjs file and record it as a \`script:\` step.
176499
+ e2e-add-script to run a local .mjs, .mts, .js or .ts file and record it as a \`script:\` step.
175976
176500
  Call e2e-finish-recording when done.
175977
176501
 
175978
176502
  To remove or reorder steps, edit the .yaml file after e2e-finish-recording, not
@@ -179544,6 +180068,7 @@ var FORCE_GRACE_MS = 500;
179544
180068
  var QUEUE_DEPTH_LIMIT = 32;
179545
180069
  var QUEUE_WAIT_REPORT_MS = 5e3;
179546
180070
  var MAX_BUFFERED_LINE_CHARS = 8 * 1024;
180071
+ var TYPE_STRIPPING_PROBE_TIMEOUT_MS = 1e4;
179547
180072
  var V8_HEAP_FATAL_RE = /FATAL ERROR:[^\n]*(?:heap limit|heap out of memory|Allocation failed)/i;
179548
180073
  var HEAP_FATAL_WINDOW_CHARS = 256;
179549
180074
  var RUNNER_FILE = "flow-script-runner.mjs";
@@ -179662,6 +180187,7 @@ var FlowScriptExecutor = class {
179662
180187
  running = 0;
179663
180188
  waiting = [];
179664
180189
  concurrencyLimit;
180190
+ typeStripping;
179665
180191
  /**
179666
180192
  * Read again for every step, never memoized: both bounds below are
179667
180193
  * schema-driven configuration, and the reference page promises that editing
@@ -179701,6 +180227,24 @@ var FlowScriptExecutor = class {
179701
180227
  get activeCount() {
179702
180228
  return this.running;
179703
180229
  }
180230
+ /**
180231
+ * Whether a script process started here runs a TypeScript file: `true`,
180232
+ * `false`, or `undefined` when the question could not be asked.
180233
+ *
180234
+ * Asked of a child, because neither thing this process knows answers it. The
180235
+ * Node version does not: a build configured `--without-amaro` — the `nodejs`
180236
+ * package of Debian and Ubuntu — carries a version that strips types and
180237
+ * cannot. This process's own `process.features.typescript` does not either:
180238
+ * a script's process gets its own `execArgv` and no `NODE_OPTIONS`, so a flag
180239
+ * that turned stripping on or off here says nothing about it.
180240
+ *
180241
+ * Asked once: the binary and the way a script is started are fixed for the
180242
+ * life of the process.
180243
+ */
180244
+ stripsTypes() {
180245
+ this.typeStripping ??= probeTypeStripping(this.options.nodeOptions ?? []);
180246
+ return this.typeStripping;
180247
+ }
179704
180248
  async execute(request3) {
179705
180249
  const bounds = this.resolveBounds();
179706
180250
  const queueStarted = Date.now();
@@ -179847,11 +180391,18 @@ var FlowScriptExecutor = class {
179847
180391
  // The runner rides in as a preload, not as the entry module, so the
179848
180392
  // *script* is what `process.argv[1]`/`require.main` name and an "am I
179849
180393
  // the main module?" guard runs its body. Node awaits an `--import`
179850
- // module before the entry, which leaves room for the handshake.
180394
+ // module before the entry, which leaves room for the handshake. The
180395
+ // preload also sends a CommonJS entry through the ESM loader, which
180396
+ // leaves `module.id` and `module.parent` unlike a main module's; the
180397
+ // runner's `claimMainModuleIdentity` puts those back. A CommonJS `.ts`
180398
+ // entry also gets a reduced `require` there, so the runner loads that
180399
+ // one itself: see its `loadEntryAsPlainNodeDoes`.
179851
180400
  execArgv: [
179852
180401
  `--max-old-space-size=${bounds.heapLimitMb}`,
179853
180402
  "--import",
179854
- (0, import_node_url3.pathToFileURL)(runnerPath).href
180403
+ (0, import_node_url3.pathToFileURL)(runnerPath).href,
180404
+ TYPELESS_PACKAGE_WARNING_FLAG,
180405
+ ...this.options.nodeOptions ?? []
179855
180406
  ],
179856
180407
  // Index 3 is a sink, and the protocol channel sits above it. The
179857
180408
  // channel is inherited by the script, Node parses it inside its own
@@ -180233,6 +180784,7 @@ function realPathOrSelf(candidate) {
180233
180784
  return candidate;
180234
180785
  }
180235
180786
  }
180787
+ var TYPELESS_PACKAGE_WARNING_FLAG = "--disable-warning=MODULE_TYPELESS_PACKAGE_JSON";
180236
180788
  function resolveRunnerPath(runnerDir) {
180237
180789
  const dir = runnerDir ?? __dirname;
180238
180790
  const runner = path53.join(dir, RUNNER_FILE);
@@ -180244,6 +180796,33 @@ function resolveRunnerPath(runnerDir) {
180244
180796
  }
180245
180797
  return runner;
180246
180798
  }
180799
+ function probeTypeStripping(nodeOptions) {
180800
+ return new Promise((resolve19) => {
180801
+ let env;
180802
+ try {
180803
+ env = buildChildEnv(void 0);
180804
+ } catch {
180805
+ resolve19(void 0);
180806
+ return;
180807
+ }
180808
+ delete env[RUNNER_ACTIVATION_ENV];
180809
+ try {
180810
+ (0, import_node_child_process48.execFile)(
180811
+ process.execPath,
180812
+ [...nodeOptions, "-p", "process.features.typescript"],
180813
+ { env, timeout: TYPE_STRIPPING_PROBE_TIMEOUT_MS, windowsHide: true },
180814
+ (err, stdout) => {
180815
+ const answer = err ? "" : stdout.trim();
180816
+ if (answer === "strip" || answer === "transform") resolve19(true);
180817
+ else if (answer === "false" || answer === "undefined") resolve19(false);
180818
+ else resolve19(void 0);
180819
+ }
180820
+ );
180821
+ } catch {
180822
+ resolve19(void 0);
180823
+ }
180824
+ });
180825
+ }
180247
180826
  function buildChildEnv(overrides) {
180248
180827
  const caseInsensitive = process.platform === "win32";
180249
180828
  const allowed = new Set(
@@ -180487,9 +181066,9 @@ var ScriptLogCapture = class {
180487
181066
  };
180488
181067
  function withoutPartialMarker(buffer, taken) {
180489
181068
  const text = buffer.subarray(0, taken).toString("utf8");
180490
- const open4 = text.lastIndexOf(SECRET_PLACEHOLDER_MARKER);
180491
- if (open4 >= 0 && !text.includes("}}", open4 + SECRET_PLACEHOLDER_MARKER.length)) {
180492
- return Buffer.byteLength(text.slice(0, open4), "utf8");
181069
+ const open5 = text.lastIndexOf(SECRET_PLACEHOLDER_MARKER);
181070
+ if (open5 >= 0 && !text.includes("}}", open5 + SECRET_PLACEHOLDER_MARKER.length)) {
181071
+ return Buffer.byteLength(text.slice(0, open5), "utf8");
180493
181072
  }
180494
181073
  for (let n = Math.min(SECRET_PLACEHOLDER_MARKER.length - 1, text.length); n > 0; n--) {
180495
181074
  if (text.endsWith(SECRET_PLACEHOLDER_MARKER.slice(0, n))) return taken - n;
@@ -180643,6 +181222,10 @@ async function runFlowScriptStep(request3) {
180643
181222
  }
180644
181223
  };
180645
181224
  }
181225
+ const refusal = await typeScriptScriptRefusal(target);
181226
+ if (refusal !== void 0) {
181227
+ return { ran: "no", outcome: { status: "error", reason: refusal } };
181228
+ }
180646
181229
  const result = await flowScriptExecutor().execute({
180647
181230
  scriptPath: canonical,
180648
181231
  output: {},
@@ -180654,15 +181237,14 @@ async function runFlowScriptStep(request3) {
180654
181237
  ...request3.logBudget ? { logBudget: request3.logBudget } : {},
180655
181238
  ...request3.signal ? { signal: request3.signal } : {}
180656
181239
  });
180657
- const verdict = scriptVerdict(result);
180658
- const frames = result.ok ? "" : scriptFrames(result.failure?.stack, [
180659
- request3.projectRoot,
180660
- await canonicalFlowPath(request3.projectRoot)
180661
- ]);
181240
+ const roots = result.ok ? [] : [request3.projectRoot, await canonicalFlowPath(request3.projectRoot)];
181241
+ const hostLimit = await typeScriptLoadRefusal(target, result, roots);
181242
+ const verdict = hostLimit !== void 0 ? { status: "error", reason: [hostLimit, ...result.notes].join(" ") } : scriptVerdict(result);
181243
+ const tail = result.ok || hostLimit !== void 0 ? "" : cjsRenameNote(result.failure, canonical) + scriptFrames(result.failure?.stack, roots);
180662
181244
  return {
180663
181245
  outcome: {
180664
181246
  ...verdict,
180665
- ...frames && verdict.reason !== void 0 ? { reason: verdict.reason + frames } : {},
181247
+ ...tail && verdict.reason !== void 0 ? { reason: verdict.reason + tail } : {},
180666
181248
  ...result.log ? { scriptLog: result.log } : {},
180667
181249
  ...result.logTruncated ? { scriptLogTruncated: true } : {}
180668
181250
  },
@@ -180670,13 +181252,67 @@ async function runFlowScriptStep(request3) {
180670
181252
  ran: scriptRan(result)
180671
181253
  };
180672
181254
  }
181255
+ function isTypeScriptScript(base) {
181256
+ return base.endsWith(".ts") || base.endsWith(".mts");
181257
+ }
181258
+ function javaScriptSpelling(target) {
181259
+ return /\.m[jt]s$/.test(target) ? ".mjs" : ".js, or .mjs for an ES module";
181260
+ }
181261
+ function cjsRenameNote(failure2, canonical) {
181262
+ if (!failure2?.stack || !NODE_CJS_RENAME_ADVICE.test(failure2.message)) return "";
181263
+ const top = failure2.stack.split("\n").find((line) => line.trim().startsWith("at "));
181264
+ if (!top?.includes(`${(0, import_node_url4.pathToFileURL)(canonical).href}:`)) return "";
181265
+ return " A script step does not accept a .cjs file: use import in the script instead.";
181266
+ }
181267
+ var NODE_CJS_RENAME_ADVICE = /rename it to use the '\.cjs' file extension/;
181268
+ function cannotRunTypeScript(strips) {
181269
+ return strips === false;
181270
+ }
181271
+ function typeScriptRefusalReason(subject2, version3 = process.versions.node, javaScript = ".mjs") {
181272
+ return `${subject2}, and the tool-server runs on Node.js ${version3}, which cannot run it: this Node.js has no TypeScript support. A release older than Argent supports has none, and neither has the nodejs package of Debian and Ubuntu. Stop the tool-server with \`argent server stop\`, then run Argent on a current Node.js from nodejs.org, or use JavaScript (${javaScript}) for the script and for the files it imports.`;
181273
+ }
181274
+ async function typeScriptScriptRefusal(target) {
181275
+ if (!isTypeScriptScript(path54.posix.basename(target))) return void 0;
181276
+ if (!cannotRunTypeScript(await flowScriptExecutor().stripsTypes())) return void 0;
181277
+ return typeScriptRefusalReason(
181278
+ `Script "${target}" is TypeScript`,
181279
+ void 0,
181280
+ javaScriptSpelling(target)
181281
+ );
181282
+ }
181283
+ var UNKNOWN_TYPESCRIPT_FILE_RE = /^Unknown file extension "\.[mc]?ts" for (.+)$/;
181284
+ async function typeScriptLoadRefusal(target, result, roots) {
181285
+ if (result.ok || !result.failure) return void 0;
181286
+ const file2 = unloadedTypeScriptFile(result.failure);
181287
+ if (file2 === void 0) return void 0;
181288
+ if (!cannotRunTypeScript(await flowScriptExecutor().stripsTypes())) return void 0;
181289
+ return typeScriptRefusalReason(
181290
+ `Script "${target}" loads the TypeScript file "${readablePath(file2, roots)}"`,
181291
+ void 0,
181292
+ javaScriptSpelling(target)
181293
+ );
181294
+ }
181295
+ function unloadedTypeScriptFile(failure2) {
181296
+ if (failure2.kind === "load") {
181297
+ const named = UNKNOWN_TYPESCRIPT_FILE_RE.exec(failure2.message)?.[1];
181298
+ if (named !== void 0) return named;
181299
+ }
181300
+ const lines = failure2.stack?.split("\n") ?? [];
181301
+ const place = lines[0]?.trim() ?? "";
181302
+ if (!STACK_PLACE_RE.test(place) || place.startsWith("file:")) return void 0;
181303
+ const file2 = place.slice(0, place.lastIndexOf(":"));
181304
+ if (!TYPESCRIPT_FILE_RE.test(file2)) return void 0;
181305
+ return lines.some((line) => line.startsWith("SyntaxError")) ? file2 : void 0;
181306
+ }
181307
+ var TYPESCRIPT_FILE_RE = /\.[mc]?ts$/;
180673
181308
  var SCRIPT_REASON_MAX_FRAMES = 6;
180674
181309
  function isHostFrame(frame2) {
180675
- return frame2.includes("node:internal") || frame2.includes("flow-script-runner.mjs") || frame2.includes("flow-script-watchdog");
181310
+ return NODE_FRAME_RE.test(frame2) || frame2.includes("node:internal") || frame2.includes("flow-script-runner.mjs") || frame2.includes("flow-script-watchdog");
180676
181311
  }
181312
+ var NODE_FRAME_RE = /(?:^at (?:async )?|\()node:[^\s()]+\)?$/;
180677
181313
  function readableFrame(frame2, roots) {
180678
- return frame2.replace(/file:\/\/[^\s)]+/g, (match) => {
180679
- const split = /^(.*?)(:\d+:\d+)$/.exec(match);
181314
+ const withoutUrls = frame2.replace(/file:\/\/[^\s)]+/g, (match) => {
181315
+ const split = /^(.*?)(:\d+(?::\d+)?)$/.exec(match);
180680
181316
  const url2 = split ? split[1] : match;
180681
181317
  const position = split ? split[2] : "";
180682
181318
  let file2;
@@ -180685,20 +181321,34 @@ function readableFrame(frame2, roots) {
180685
181321
  } catch {
180686
181322
  return match;
180687
181323
  }
180688
- for (const root of roots) {
180689
- const relative9 = path54.relative(root, file2);
180690
- if (relative9 !== "" && !relative9.startsWith("..") && !path54.isAbsolute(relative9)) {
180691
- return `${relative9}${position}`;
180692
- }
180693
- }
180694
- return `${file2}${position}`;
181324
+ return `${readablePath(file2, roots)}${position}`;
180695
181325
  });
181326
+ return roots.reduce(withoutRoot, withoutUrls);
181327
+ }
181328
+ function withoutRoot(frame2, root) {
181329
+ const prefix = root.endsWith(path54.sep) ? root : root + path54.sep;
181330
+ const escaped = prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
181331
+ const flags = process.platform === "win32" ? "gi" : "g";
181332
+ return frame2.replace(new RegExp(`(^at (?:async )?|\\()${escaped}`, flags), "$1");
180696
181333
  }
181334
+ function readablePath(file2, roots) {
181335
+ for (const root of roots) {
181336
+ const relative9 = path54.relative(root, file2);
181337
+ if (relative9 !== "" && !relative9.startsWith("..") && !path54.isAbsolute(relative9)) {
181338
+ return relative9;
181339
+ }
181340
+ }
181341
+ return file2;
181342
+ }
181343
+ var STACK_PLACE_RE = /^(?:file:\/\/\S+|(?:\/|[A-Za-z]:[\\/]).*):\d+$/;
180697
181344
  function scriptFrames(stack, roots) {
180698
181345
  if (!stack) return "";
180699
181346
  const frames = [];
180700
181347
  let dropped = 0;
180701
- for (const line of stack.split("\n")) {
181348
+ const lines = stack.split("\n");
181349
+ const place = lines[0].trim();
181350
+ if (STACK_PLACE_RE.test(place)) frames.push(` ${readableFrame(`at ${place}`, roots)}`);
181351
+ for (const line of lines) {
180702
181352
  const frame2 = line.trim();
180703
181353
  if (!frame2.startsWith("at ") || isHostFrame(frame2)) continue;
180704
181354
  if (frames.length >= SCRIPT_REASON_MAX_FRAMES) {
@@ -180803,13 +181453,13 @@ var zodSchema69 = external_exports.object({
180803
181453
  name: external_exports.string().describe("E2E test name passed to e2e-start-recording."),
180804
181454
  project_root: external_exports.string().describe("Absolute project root passed to e2e-start-recording."),
180805
181455
  path: external_exports.string().describe(
180806
- 'Path to the .mjs file, relative to the e2e test YAML. For example: "../../scripts/seed-order.mjs".'
181456
+ 'Path to the script file (.mjs, .mts, .js or .ts), relative to the e2e test YAML. For example: "../../scripts/seed-order.mjs".'
180807
181457
  ),
180808
181458
  timeout: external_exports.number().optional().describe("Time limit in milliseconds. The default is 30000 and the minimum is 100.")
180809
181459
  });
180810
181460
  var flowAddScriptTool = {
180811
181461
  id: "e2e-add-script",
180812
- description: `Run a local .mjs file and record it as a \`script:\` step in an active e2e test. Use when the user requests a local script in the e2e test, and only then. Call it at the point in the recording where the script must run. Returns \`status\`, \`reason\` and \`stepCount\`. A failed script is not recorded. Check \`reason\` and the affected state before you retry. Over a link (argent link or ARGENT_TOOLS_URL), the tool refuses the call: record such an e2e test with no link.`,
181462
+ description: `Run a local JavaScript (.mjs, .js) or TypeScript (.mts, .ts) file and record it as a \`script:\` step in an active e2e test. Use when the user requests a local script in the e2e test, and only then. Call it at the point in the recording where the script must run. Returns \`status\`, \`reason\` and \`stepCount\`. A failed script is not recorded. Check \`reason\` and the affected state before you retry. Over a link (argent link or ARGENT_TOOLS_URL), the tool refuses the call: record such an e2e test with no link.`,
180813
181463
  zodSchema: zodSchema69,
180814
181464
  aliases: ["flow-add-script"],
180815
181465
  interaction: {
@@ -181034,7 +181684,7 @@ var import_pngjs7 = __toESM(require_png());
181034
181684
  init_src2();
181035
181685
 
181036
181686
  // ../tool-server/src/tools/screenshot-diff/screenshot-diff.ts
181037
- var import_promises18 = __toESM(require("fs/promises"));
181687
+ var import_promises19 = __toESM(require("fs/promises"));
181038
181688
  var import_path8 = __toESM(require("path"));
181039
181689
  var import_pngjs6 = __toESM(require_png());
181040
181690
  init_src2();
@@ -182779,7 +183429,7 @@ async function writeDiffArtifacts(params) {
182779
183429
  }
182780
183430
  async function decodePngFile(filePath) {
182781
183431
  try {
182782
- const buffer = await import_promises18.default.readFile(filePath);
183432
+ const buffer = await import_promises19.default.readFile(filePath);
182783
183433
  const png = import_pngjs6.PNG.sync.read(buffer);
182784
183434
  return {
182785
183435
  width: png.width,
@@ -182834,8 +183484,8 @@ function luminanceFromOffset(data, offset) {
182834
183484
  return 0.2126 * data[offset] + 0.7152 * data[offset + 1] + 0.0722 * data[offset + 2];
182835
183485
  }
182836
183486
  async function writePngFile(filePath, png) {
182837
- await import_promises18.default.mkdir(import_path8.default.dirname(filePath), { recursive: true });
182838
- await import_promises18.default.writeFile(filePath, import_pngjs6.PNG.sync.write(png));
183487
+ await import_promises19.default.mkdir(import_path8.default.dirname(filePath), { recursive: true });
183488
+ await import_promises19.default.writeFile(filePath, import_pngjs6.PNG.sync.write(png));
182839
183489
  }
182840
183490
  function downscalePng(source, scale) {
182841
183491
  const resized = resizeDecodedPng(
@@ -183854,9 +184504,19 @@ function findRetiredToolArg(registry2, steps) {
183854
184504
  function retiredArgReason(use) {
183855
184505
  return `${use.where} as written (echo included) passes ${use.tool}'s retired \`${use.key}\` key${use.guidance ? `: ${use.guidance}` : ""}`;
183856
184506
  }
183857
- function fragmentLoadRefusal(registry2, fragment, target) {
184507
+ async function findUnrunnableScript(steps) {
184508
+ for (const { step } of walkSteps(steps)) {
184509
+ if (step.kind !== "script") continue;
184510
+ const refusal = await typeScriptScriptRefusal(step.path);
184511
+ if (refusal !== void 0) return refusal;
184512
+ }
184513
+ return void 0;
184514
+ }
184515
+ async function fragmentLoadRefusal(registry2, fragment, target) {
183858
184516
  const retiredArg = findRetiredToolArg(registry2, fragment.steps);
183859
- return retiredArg ? `fragment "${target}" ${retiredArgReason(retiredArg)}` : void 0;
184517
+ if (retiredArg) return `fragment "${target}" ${retiredArgReason(retiredArg)}`;
184518
+ const unrunnableScript = await findUnrunnableScript(fragment.steps);
184519
+ return unrunnableScript ? `fragment "${target}" cannot run. ${unrunnableScript}` : void 0;
183860
184520
  }
183861
184521
  function assertUploadSelfContained(registry2, flow, closure, origin = {
183862
184522
  subject: "This e2e test",
@@ -184045,6 +184705,15 @@ Without a link, every step kind runs.`,
184045
184705
  error_kind: "validation"
184046
184706
  });
184047
184707
  }
184708
+ const unrunnableScript = await findUnrunnableScript(flow.steps);
184709
+ if (unrunnableScript) {
184710
+ throw new FailureError(`E2E test "${flowName}" was not run. ${unrunnableScript}`, {
184711
+ error_code: FAILURE_CODES.FLOW_SCRIPT_TYPESCRIPT_UNSUPPORTED,
184712
+ failure_stage: "flow_run_validate",
184713
+ failure_area: "tool_server",
184714
+ error_kind: "validation"
184715
+ });
184716
+ }
184048
184717
  const rootEntry = {
184049
184718
  canonical: clientProject && rootInput ? clientRootCanonical(rootInput, params.name, flow) : canonicalPath,
184050
184719
  display: flowName
@@ -184280,7 +184949,7 @@ async function scanLeadingLaunch(flow, stack, rootDisplay, env) {
184280
184949
  } catch {
184281
184950
  return null;
184282
184951
  }
184283
- if (fragmentLoadRefusal(env.registry, nested, step.flow) !== void 0) return null;
184952
+ if (await fragmentLoadRefusal(env.registry, nested, step.flow) !== void 0) return null;
184284
184953
  const inner = await scanLeadingLaunch(
184285
184954
  nested,
184286
184955
  [...stack, { canonical, display: runDisplayFor(step.flow, rootDisplay) }],
@@ -184642,7 +185311,7 @@ async function execRunStep(state3, step, scope) {
184642
185311
  } catch (err) {
184643
185312
  return fail(`could not load fragment "${target}": ${errMsg5(err)}`);
184644
185313
  }
184645
- const refusal = fragmentLoadRefusal(state3.registry, fragment, target);
185314
+ const refusal = await fragmentLoadRefusal(state3.registry, fragment, target);
184646
185315
  if (refusal !== void 0) return fail(refusal);
184647
185316
  if (state3.device) {
184648
185317
  try {
@@ -185122,13 +185791,13 @@ Address the e2e test exactly as you will address it in e2e-execute: name or e2e_
185122
185791
  init_zod();
185123
185792
 
185124
185793
  // ../tool-server/src/utils/workspace-reader.ts
185125
- var import_promises19 = require("node:fs/promises");
185794
+ var import_promises20 = require("node:fs/promises");
185126
185795
  var import_node_path30 = require("node:path");
185127
185796
  var import_node_child_process50 = require("node:child_process");
185128
185797
  var import_dotenv2 = __toESM(require_dist());
185129
185798
  async function exists2(path63) {
185130
185799
  try {
185131
- await (0, import_promises19.access)(path63);
185800
+ await (0, import_promises20.access)(path63);
185132
185801
  return true;
185133
185802
  } catch {
185134
185803
  return false;
@@ -185136,7 +185805,7 @@ async function exists2(path63) {
185136
185805
  }
185137
185806
  async function isDirectory2(path63) {
185138
185807
  try {
185139
- const s = await (0, import_promises19.stat)(path63);
185808
+ const s = await (0, import_promises20.stat)(path63);
185140
185809
  return s.isDirectory();
185141
185810
  } catch {
185142
185811
  return false;
@@ -185144,7 +185813,7 @@ async function isDirectory2(path63) {
185144
185813
  }
185145
185814
  async function readJsonFile(path63) {
185146
185815
  try {
185147
- const raw = await (0, import_promises19.readFile)(path63, "utf-8");
185816
+ const raw = await (0, import_promises20.readFile)(path63, "utf-8");
185148
185817
  return JSON.parse(raw);
185149
185818
  } catch {
185150
185819
  return null;
@@ -185152,14 +185821,14 @@ async function readJsonFile(path63) {
185152
185821
  }
185153
185822
  async function readTextFile(path63) {
185154
185823
  try {
185155
- return await (0, import_promises19.readFile)(path63, "utf-8");
185824
+ return await (0, import_promises20.readFile)(path63, "utf-8");
185156
185825
  } catch {
185157
185826
  return null;
185158
185827
  }
185159
185828
  }
185160
185829
  async function listDir(path63) {
185161
185830
  try {
185162
- const entries = await (0, import_promises19.readdir)(path63);
185831
+ const entries = await (0, import_promises20.readdir)(path63);
185163
185832
  return entries;
185164
185833
  } catch {
185165
185834
  return null;
@@ -185659,7 +186328,7 @@ var dismissUpdateTool = {
185659
186328
 
185660
186329
  // ../tool-server/src/tools/screenshot-diff/index.ts
185661
186330
  var import_node_crypto16 = __toESM(require("node:crypto"));
185662
- var import_promises20 = __toESM(require("fs/promises"));
186331
+ var import_promises21 = __toESM(require("fs/promises"));
185663
186332
  var import_node_os17 = __toESM(require("node:os"));
185664
186333
  var import_path9 = __toESM(require("path"));
185665
186334
  init_zod();
@@ -185804,7 +186473,7 @@ async function resolveOutputDir(params, options) {
185804
186473
  }
185805
186474
  if (params.outputDir) {
185806
186475
  try {
185807
- await import_promises20.default.mkdir(params.outputDir);
186476
+ await import_promises21.default.mkdir(params.outputDir);
185808
186477
  return params.outputDir;
185809
186478
  } catch (err) {
185810
186479
  if (err.code === "EEXIST") return params.outputDir;
@@ -185815,7 +186484,7 @@ async function resolveOutputDir(params, options) {
185815
186484
  "argent-screenshot-diff",
185816
186485
  import_node_crypto16.default.randomBytes(6).toString("hex")
185817
186486
  );
185818
- await import_promises20.default.mkdir(dir, { recursive: true });
186487
+ await import_promises21.default.mkdir(dir, { recursive: true });
185819
186488
  return dir;
185820
186489
  }
185821
186490
  async function resolveInputPaths(services, params, outputDir, options, captureScreenshot2, peekFor) {
@@ -185920,8 +186589,8 @@ async function captureIosDeviceLiveInput(params) {
185920
186589
  async function writeLivePng(outputDir, name, png) {
185921
186590
  const suffix = import_node_crypto16.default.randomBytes(4).toString("hex");
185922
186591
  const destination = import_path9.default.join(outputDir, `${name}-${suffix}.live.png`);
185923
- await import_promises20.default.mkdir(outputDir, { recursive: true });
185924
- await import_promises20.default.writeFile(destination, png);
186592
+ await import_promises21.default.mkdir(outputDir, { recursive: true });
186593
+ await import_promises21.default.writeFile(destination, png);
185925
186594
  return destination;
185926
186595
  }
185927
186596
  async function captureHarmonyLiveInput(params) {
@@ -185939,10 +186608,10 @@ async function captureHarmonyLiveInput(params) {
185939
186608
  const suffix = import_node_crypto16.default.randomBytes(4).toString("hex");
185940
186609
  const destination = import_path9.default.join(params.outputDir, `${params.name}-${suffix}.live.png`);
185941
186610
  try {
185942
- await import_promises20.default.mkdir(params.outputDir, { recursive: true });
185943
- await import_promises20.default.copyFile(captured, destination);
186611
+ await import_promises21.default.mkdir(params.outputDir, { recursive: true });
186612
+ await import_promises21.default.copyFile(captured, destination);
185944
186613
  } finally {
185945
- await import_promises20.default.rm(captured, { force: true }).catch(() => {
186614
+ await import_promises21.default.rm(captured, { force: true }).catch(() => {
185946
186615
  });
185947
186616
  }
185948
186617
  return destination;
@@ -185974,8 +186643,8 @@ async function captureLiveInput(params) {
185974
186643
  }
185975
186644
  const suffix = import_node_crypto16.default.randomBytes(4).toString("hex");
185976
186645
  const destination = import_path9.default.join(params.outputDir, `${params.name}-${suffix}.live.png`);
185977
- await import_promises20.default.mkdir(params.outputDir, { recursive: true });
185978
- await import_promises20.default.copyFile(capture.path, destination);
186646
+ await import_promises21.default.mkdir(params.outputDir, { recursive: true });
186647
+ await import_promises21.default.copyFile(capture.path, destination);
185979
186648
  return {
185980
186649
  path: destination,
185981
186650
  ...panel?.warning !== void 0 ? { warning: panel.warning } : {}
@@ -186659,9 +187328,9 @@ async function waitForPanel(app, params, signal) {
186659
187328
  }
186660
187329
  if (Date.now() >= deadline) {
186661
187330
  const which = params.panel !== void 0 ? `File panel ${params.panel} is not open` : "No file panel is open";
186662
- const open4 = panels.length > 0 ? ` (open: ${panels.map((p) => p.number).join(", ")})` : "";
187331
+ const open5 = panels.length > 0 ? ` (open: ${panels.map((p) => p.number).join(", ")})` : "";
186663
187332
  throw invalid(
186664
- `${which}${open4} in ${app.bundleId}. Open it in the app first (gesture-tap on the button that shows it), or arm an answer for the next one with action stub.`,
187333
+ `${which}${open5} in ${app.bundleId}. Open it in the app first (gesture-tap on the button that shows it), or arm an answer for the next one with action stub.`,
186665
187334
  "file_panel_not_open"
186666
187335
  );
186667
187336
  }