@swmansion/argent 0.34.1-next.67 → 0.34.1-next.69

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.
@@ -101462,7 +101462,7 @@ function isCi(env = process.env) {
101462
101462
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
101463
101463
  function readCliVersion() {
101464
101464
  if (true) {
101465
- return "0.34.1-next.67";
101465
+ return "0.34.1-next.69";
101466
101466
  }
101467
101467
  return "0.0.0";
101468
101468
  }
@@ -132283,6 +132283,18 @@ function unexplainedHint(hint, detail, params) {
132283
132283
  // ../tool-server/src/tools/describe/platforms/android/index.ts
132284
132284
  init_src2();
132285
132285
  init_adb();
132286
+
132287
+ // ../tool-server/src/utils/uiautomator-lock.ts
132288
+ var uiautomatorDumpLocks = /* @__PURE__ */ new Map();
132289
+ function withUiautomatorLock(serial, fn) {
132290
+ return withKeyedLock(uiautomatorDumpLocks, serial, fn);
132291
+ }
132292
+ function uiautomatorKilledMessage(output2, serial) {
132293
+ if (!/\bKilled\b/.test(output2)) return void 0;
132294
+ return `uiautomator could not capture the screen: ${output2}. Another UiAutomation client (the argent devtools helper, or a test runner such as Espresso or Appium) holds the accessibility connection. Stop it, for the helper with \`${adbCommandPrefix(process.env)}adb -s ${serial} shell am force-stop com.argent.androiddevtools\`, and try again.`;
132295
+ }
132296
+
132297
+ // ../tool-server/src/tools/describe/platforms/android/index.ts
132286
132298
  init_device_info();
132287
132299
 
132288
132300
  // ../tool-server/src/utils/android-screen.ts
@@ -132485,7 +132497,9 @@ function attrIsTrue(attrs, key2) {
132485
132497
  }
132486
132498
  function isInteractive(attrs) {
132487
132499
  if (hasGestureFlag(attrs)) return true;
132488
- if (attrIsTrue(attrs, "focusable") && labelOf(attrs) !== "") return true;
132500
+ if (attrIsTrue(attrs, "focusable") && (labelOf(attrs) !== "" || attrIsTrue(attrs, "focused"))) {
132501
+ return true;
132502
+ }
132489
132503
  return false;
132490
132504
  }
132491
132505
  function labelOf(attrs) {
@@ -132550,6 +132564,8 @@ function makeUiNode(attrs, role, pixelBounds, label, children) {
132550
132564
  checked: attrIsTrue(attrs, "checked"),
132551
132565
  disabled: attrs.enabled === "false",
132552
132566
  password: attrIsTrue(attrs, "password"),
132567
+ focused: attrIsTrue(attrs, "focused"),
132568
+ selected: attrIsTrue(attrs, "selected"),
132553
132569
  scrollHidden: 0
132554
132570
  };
132555
132571
  if (label) out.label = label;
@@ -132631,6 +132647,7 @@ function computeNodeOutput(parsed2, scrollClip, inWebView, outputs, opts) {
132631
132647
  node3.clickable ||= inner.clickable;
132632
132648
  node3.longClickable ||= inner.longClickable;
132633
132649
  node3.scrollable ||= inner.scrollable;
132650
+ node3.focused ||= inner.focused;
132634
132651
  if (!node3.identifier && inner.identifier) node3.identifier = inner.identifier;
132635
132652
  }
132636
132653
  const hidden = hiddenInScroll + (inner?.scrollHidden ?? 0);
@@ -132642,10 +132659,11 @@ function computeNodeOutput(parsed2, scrollClip, inWebView, outputs, opts) {
132642
132659
  if (attrIsTrue(attrs, "password")) {
132643
132660
  label = "[password]";
132644
132661
  }
132645
- if (cls.endsWith(".ImageView") && !interactive && !label) {
132662
+ const selected = attrIsTrue(attrs, "selected");
132663
+ if (cls.endsWith(".ImageView") && !interactive && !label && !selected) {
132646
132664
  return keptChildren;
132647
132665
  }
132648
- if (LAYOUT_CONTAINERS.has(cls) && !interactive && !label) {
132666
+ if (LAYOUT_CONTAINERS.has(cls) && !interactive && !label && !selected) {
132649
132667
  return keptChildren;
132650
132668
  }
132651
132669
  if (!visible && keptChildren.length === 0) return [];
@@ -132657,6 +132675,8 @@ function computeNodeOutput(parsed2, scrollClip, inWebView, outputs, opts) {
132657
132675
  const c = keptChildren[0];
132658
132676
  if (c.clickable && c.pixelBounds && rectsEqual(c.pixelBounds, bounds)) {
132659
132677
  if (!c.label && label) c.label = label;
132678
+ c.focused ||= attrIsTrue(attrs, "focused");
132679
+ c.selected ||= attrIsTrue(attrs, "selected");
132660
132680
  const rid = attrs["resource-id"];
132661
132681
  if (!c.identifier && rid) c.identifier = rid;
132662
132682
  return [c];
@@ -132732,6 +132752,8 @@ function finalizeUiNode(n, children, sw, sh) {
132732
132752
  if (n.scrollable) out.scrollable = true;
132733
132753
  if (n.checkable) out.checkable = true;
132734
132754
  if (n.checked) out.checked = true;
132755
+ if (n.focused) out.focused = true;
132756
+ if (n.selected) out.selected = true;
132735
132757
  if (n.disabled) out.disabled = true;
132736
132758
  if (n.password) out.password = true;
132737
132759
  if (n.scrollHidden > 0) out.scrollHidden = n.scrollHidden;
@@ -134121,13 +134143,25 @@ async function awaitWebViewPublished(first, read) {
134121
134143
  async function uiautomatorDump(serial) {
134122
134144
  const randomSuffix = `${Date.now().toString(36)}-${Math.floor(Math.random() * 1e9).toString(36)}`;
134123
134145
  const dumpPath = `/data/local/tmp/argent-ui-dump-${randomSuffix}.xml`;
134124
- const rawBuf = await adbExecOutBinary(
134146
+ const rawBuf = await withUiautomatorLock(
134125
134147
  serial,
134126
- `uiautomator dump --compressed ${dumpPath} >/dev/null && cat ${dumpPath}; rm -f ${dumpPath}`,
134127
- { timeoutMs: 2e4 }
134148
+ () => adbExecOutBinary(
134149
+ serial,
134150
+ `uiautomator dump --compressed ${dumpPath} >/dev/null && cat ${dumpPath}; rm -f ${dumpPath}`,
134151
+ { timeoutMs: 2e4 }
134152
+ )
134128
134153
  );
134129
134154
  const raw = rawBuf.toString("utf-8");
134130
134155
  const trimmed = raw.trim();
134156
+ const killed = trimmed.includes("<hierarchy") ? void 0 : uiautomatorKilledMessage(trimmed.slice(0, 200), serial);
134157
+ if (killed) {
134158
+ throw new FailureError(killed, {
134159
+ error_code: FAILURE_CODES.ANDROID_UIAUTOMATOR_CAPTURE_FAILED,
134160
+ failure_stage: "android_uiautomator_capture",
134161
+ failure_area: "tool_server",
134162
+ error_kind: "subprocess"
134163
+ });
134164
+ }
134131
134165
  if (/^ERROR:/i.test(trimmed) || !trimmed.includes("<hierarchy") && /error/i.test(trimmed)) {
134132
134166
  throw new FailureError(
134133
134167
  `uiautomator could not capture the screen: ${trimmed}. Common causes: device locked / keyguard, DRM or secure overlay, Play Integrity screen. Unlock the device or take a screenshot as a fallback.`,
@@ -135430,10 +135464,10 @@ function tvControlRef(device) {
135430
135464
  };
135431
135465
  }
135432
135466
  function axSocketPath(udid) {
135433
- return `/tmp/argent-tv-ax-${udid.slice(0, 8)}.sock`;
135467
+ return `/tmp/argent-tv-ax-${udid.slice(0, 8)}-${process.pid}.sock`;
135434
135468
  }
135435
135469
  function hidSocketPath(udid) {
135436
- return `/tmp/argent-tv-hid-${udid.slice(0, 8)}.sock`;
135470
+ return `/tmp/argent-tv-hid-${udid.slice(0, 8)}-${process.pid}.sock`;
135437
135471
  }
135438
135472
  function sendLine(socketPath, line, timeoutMs = 1e4) {
135439
135473
  return new Promise((resolve21, reject) => {
@@ -135467,7 +135501,9 @@ function typeTimeoutMs(textLength) {
135467
135501
  return TYPE_BASE_MS + textLength * TYPE_MS_PER_CHAR;
135468
135502
  }
135469
135503
  async function sendJson(socketPath, command, timeoutMs) {
135470
- const raw = (await sendLine(socketPath, command, timeoutMs)).trim();
135504
+ return parseReply((await sendLine(socketPath, command, timeoutMs)).trim(), command);
135505
+ }
135506
+ function parseReply(raw, command) {
135471
135507
  if (!raw) return {};
135472
135508
  try {
135473
135509
  return JSON.parse(raw);
@@ -135494,6 +135530,10 @@ function spawnAxDaemon(udid, socketPath, axTarget) {
135494
135530
  proc.stderr?.on("data", (data) => process.stderr.write(`[tvos-ax ${tag3}] ${data}`));
135495
135531
  return proc;
135496
135532
  }
135533
+ function reapDaemons(socketPath) {
135534
+ const pattern = `tvos-.* --socket ${socketPath.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`;
135535
+ return new Promise((resolve21) => (0, import_node_child_process25.execFile)("pkill", ["-KILL", "-f", pattern], () => resolve21()));
135536
+ }
135497
135537
  function spawnHidDaemon(udid, socketPath) {
135498
135538
  const proc = (0, import_node_child_process25.execFile)(
135499
135539
  tvosHidDaemonBinaryPath(),
@@ -135585,6 +135625,7 @@ var tvControlBlueprint = {
135585
135625
  const hidSock = hidSocketPath(udid);
135586
135626
  let disposed = false;
135587
135627
  await Promise.all([ensureAutomationEnabled(udid), firstSimulatorPoll()]);
135628
+ await Promise.all([reapDaemons(axSock), reapDaemons(hidSock)]);
135588
135629
  const axTarget = () => simctlTargetForUdidSync(udid, { granted: "ax-service" });
135589
135630
  let axProc = spawnAxDaemon(udid, axSock, axTarget());
135590
135631
  const hidProc = spawnHidDaemon(udid, hidSock);
@@ -135622,6 +135663,7 @@ var tvControlBlueprint = {
135622
135663
  hidProc.removeListener("error", onHidError);
135623
135664
  if (!axProc.killed) axProc.kill("SIGKILL");
135624
135665
  if (!hidProc.killed) hidProc.kill("SIGTERM");
135666
+ await reapDaemons(axSock);
135625
135667
  for (const p of [axSock, hidSock]) {
135626
135668
  try {
135627
135669
  fs33.unlinkSync(p);
@@ -135643,6 +135685,7 @@ var tvControlBlueprint = {
135643
135685
  fs33.unlinkSync(axSock);
135644
135686
  } catch {
135645
135687
  }
135688
+ await reapDaemons(axSock);
135646
135689
  try {
135647
135690
  axProc = spawnAxDaemon(udid, axSock, target);
135648
135691
  axProc.on("exit", onAxExit);
@@ -135693,7 +135736,9 @@ var tvControlBlueprint = {
135693
135736
  for (let attempt = 0; ; attempt++) {
135694
135737
  await ensureAxAlive();
135695
135738
  try {
135696
- return await sendJson(axSock, command, timeoutMs);
135739
+ const raw = (await sendLine(axSock, command, timeoutMs)).trim();
135740
+ if (!raw && axRespawn) throw new Error(`tvOS AX reader was reaped during "${command}"`);
135741
+ return parseReply(raw, command);
135697
135742
  } catch (err) {
135698
135743
  if (axRespawn && attempt < 2) {
135699
135744
  await axRespawn.catch(() => {
@@ -135741,6 +135786,7 @@ var tvControlBlueprint = {
135741
135786
  }
135742
135787
  if (!axProc.killed) axProc.kill("SIGKILL");
135743
135788
  if (!hidProc.killed) hidProc.kill("SIGTERM");
135789
+ await reapDaemons(axSock);
135744
135790
  for (const p of [axSock, hidSock]) {
135745
135791
  try {
135746
135792
  fs33.unlinkSync(p);
@@ -136011,18 +136057,18 @@ var androidTvControlBlueprint = {
136011
136057
  async function dumpHierarchy() {
136012
136058
  const suffix = `${Date.now().toString(36)}-${Math.floor(Math.random() * 1e9).toString(36)}`;
136013
136059
  const dumpPath = `/data/local/tmp/argent-tv-dump-${suffix}.xml`;
136014
- const raw = (await adbExecOutBinary(
136060
+ const raw = (await withUiautomatorLock(
136015
136061
  serial,
136016
- `uiautomator dump --compressed ${dumpPath} >/dev/null && cat ${dumpPath}; rm -f ${dumpPath}`,
136017
- { timeoutMs: 2e4 }
136062
+ () => adbExecOutBinary(
136063
+ serial,
136064
+ `uiautomator dump --compressed ${dumpPath} >/dev/null && cat ${dumpPath}; rm -f ${dumpPath}`,
136065
+ { timeoutMs: 2e4 }
136066
+ )
136018
136067
  )).toString("utf-8");
136019
136068
  if (!raw.includes("<hierarchy")) {
136020
136069
  const output2 = raw.trim().slice(0, 200);
136021
- if (/\bKilled\b/.test(output2)) {
136022
- throw new Error(
136023
- `uiautomator could not capture the screen: ${output2}. Another UiAutomation client (the argent devtools helper, or a test runner such as Espresso or Appium) holds the accessibility connection. Stop it, for the helper with \`${adbCommandPrefix(process.env)}adb shell am force-stop com.argent.androiddevtools\`, and try again.`
136024
- );
136025
- }
136070
+ const killed = uiautomatorKilledMessage(output2, serial);
136071
+ if (killed) throw new Error(killed);
136026
136072
  throw new Error(
136027
136073
  `uiautomator could not capture the screen: ${output2}. The device may be locked or showing a secure overlay \u2014 take a screenshot to confirm.`
136028
136074
  );
@@ -136255,6 +136301,10 @@ function quotedText(data, deviceId, node2, read) {
136255
136301
 
136256
136302
  // ../tool-server/src/utils/poll-describe-tree.ts
136257
136303
  init_src2();
136304
+ var UNWAITABLE_FAILURES = /* @__PURE__ */ new Set([
136305
+ FAILURE_CODES.TOOL_XCODE_FIRST_LAUNCH_PENDING,
136306
+ FAILURE_CODES.VEGA_MULTIPLE_DEVICES
136307
+ ]);
136258
136308
  async function pollDescribeTree(args) {
136259
136309
  const { fetchTree, timeoutMs, pollIntervalMs, signal, onSample } = args;
136260
136310
  const start2 = Date.now();
@@ -136286,9 +136336,8 @@ async function pollDescribeTree(args) {
136286
136336
  break;
136287
136337
  }
136288
136338
  if (settled.type === "error") {
136289
- if (getFailureSignal(settled.cause)?.error_code === FAILURE_CODES.TOOL_XCODE_FIRST_LAUNCH_PENDING) {
136290
- throw settled.cause;
136291
- }
136339
+ const code = getFailureSignal(settled.cause)?.error_code;
136340
+ if (code && UNWAITABLE_FAILURES.has(code)) throw settled.cause;
136292
136341
  lastError = settled.error;
136293
136342
  } else {
136294
136343
  lastData = settled.value;
@@ -140762,9 +140811,16 @@ async function ensureAutomationToolkitEnabled(_serial) {
140762
140811
  // ../tool-server/src/utils/vega-inspect.ts
140763
140812
  var TOOLKIT_DEVICE_PORT = 8383;
140764
140813
  var HOST_PORT_OFFSET = 1e4;
140814
+ var pageSourceLocks = /* @__PURE__ */ new Map();
140765
140815
  async function fetchVegaPageSource(timeoutMs = 15e3) {
140766
140816
  const { serial, consolePort } = await emulatorSerial();
140767
- const hostPort = consolePort + HOST_PORT_OFFSET;
140817
+ return withKeyedLock(
140818
+ pageSourceLocks,
140819
+ serial,
140820
+ () => fetchPageSource(serial, consolePort + HOST_PORT_OFFSET, timeoutMs)
140821
+ );
140822
+ }
140823
+ async function fetchPageSource(serial, hostPort, timeoutMs) {
140768
140824
  await adbForward(serial, hostPort, TOOLKIT_DEVICE_PORT, { timeoutMs: 1e4 });
140769
140825
  try {
140770
140826
  const body = JSON.stringify({ jsonrpc: "2.0", id: 1, method: "getPageSource", params: {} });
@@ -140807,6 +140863,7 @@ function postJson(host, port, path71, body, timeoutMs) {
140807
140863
  let data = "";
140808
140864
  res.setEncoding("utf-8");
140809
140865
  res.on("data", (chunk) => data += chunk);
140866
+ res.on("error", reject);
140810
140867
  res.on("end", () => {
140811
140868
  const status = res.statusCode ?? 0;
140812
140869
  if (status < 200 || status >= 300) {
@@ -153167,7 +153224,6 @@ init_external_devices();
153167
153224
  var import_node_crypto15 = require("node:crypto");
153168
153225
  init_src2();
153169
153226
  init_device_info();
153170
- init_external_devices();
153171
153227
  init_macos_app_kind();
153172
153228
  function deviceKey2(target) {
153173
153229
  const logicalId = target.reactNative?.logicalDeviceId;
@@ -153207,25 +153263,6 @@ function metroDevices(pool) {
153207
153263
  }
153208
153264
  return devices2;
153209
153265
  }
153210
- function targetsOfOnlyDeviceNamed(pool, name) {
153211
- if (name === void 0) return void 0;
153212
- const named = pool.filter((t) => t.deviceName === name);
153213
- return new Set(named.map(deviceKey2)).size === 1 ? named : void 0;
153214
- }
153215
- function nameMetroLists(simulatorName) {
153216
- return simulatorName.split("&")[0].replaceAll("+", " ");
153217
- }
153218
- async function simulatorNameOnSharedMetro(deviceId, targets) {
153219
- if (isExternalId(deviceId)) return void 0;
153220
- const device = resolveDevice(deviceId);
153221
- if (device.platform !== "ios" || device.kind !== "simulator") return void 0;
153222
- if (metroDevices(targets).size < 2) return void 0;
153223
- const simulators = await listIosSimulators().catch(() => []);
153224
- const booted = simulators.filter((sim) => sim.state === "Booted");
153225
- const name = booted.find((sim) => sim.udid === deviceId)?.name;
153226
- if (name === void 0 || nameMetroLists(name) !== name) return void 0;
153227
- return booted.filter((sim) => nameMetroLists(sim.name) === name).length === 1 ? name : void 0;
153228
- }
153229
153266
  function macosAppTargets(pool, bundleId, port) {
153230
153267
  const own2 = pool.filter((t) => macosAppBundleIdOf(t)?.toLowerCase() === bundleId.toLowerCase());
153231
153268
  if (own2.length) return own2;
@@ -153242,6 +153279,12 @@ function macosAppTargets(pool, bundleId, port) {
153242
153279
  }
153243
153280
  );
153244
153281
  }
153282
+ function targetsNamedFor(pool, matches2) {
153283
+ if (typeof matches2 !== "function") return void 0;
153284
+ const named = pool.filter((t) => typeof t.deviceName === "string" && matches2(t.deviceName));
153285
+ const devices2 = new Set(named.map(deviceKey2));
153286
+ return devices2.size === 1 && !devices2.has(void 0) ? named : void 0;
153287
+ }
153245
153288
  var seenLogicalDeviceIds = /* @__PURE__ */ new Set();
153246
153289
  var LOGICAL_DEVICE_ID_SHAPE = /^[0-9a-f]{40}$/;
153247
153290
  function selectTarget(targets, port, options) {
@@ -153251,24 +153294,29 @@ function selectTarget(targets, port, options) {
153251
153294
  if (id) seenLogicalDeviceIds.add(id);
153252
153295
  }
153253
153296
  let candidates = pool;
153297
+ let matchedByName = false;
153254
153298
  const macosBundleId = typeof options?.deviceId === "string" && options.deviceId.startsWith(MACOS_APP_ID_PREFIX) ? options.deviceId.slice(MACOS_APP_ID_PREFIX.length) : null;
153255
153299
  if (macosBundleId !== null) {
153256
153300
  candidates = macosAppTargets(pool, macosBundleId, port);
153257
153301
  } else if (typeof options?.deviceId === "string" && options.deviceId) {
153258
153302
  const deviceId = options.deviceId;
153259
- const filtered = candidates.filter((t) => t.reactNative?.logicalDeviceId === deviceId);
153260
- const simulatorName = typeof options.simulatorName === "string" ? options.simulatorName : void 0;
153261
- const sameName = targetsOfOnlyDeviceNamed(pool, simulatorName);
153303
+ const pinned = typeof options.pinnedLogicalDeviceId === "string" ? options.pinnedLogicalDeviceId : void 0;
153304
+ const filtered = candidates.filter((t) => {
153305
+ const id = t.reactNative?.logicalDeviceId;
153306
+ return id === deviceId || pinned !== void 0 && id === pinned;
153307
+ });
153262
153308
  if (filtered.length) {
153263
153309
  candidates = filtered;
153264
- } else if (sameName) {
153265
- candidates = sameName;
153266
153310
  } else {
153267
153311
  const distinctDevices = metroDevices(pool);
153268
- if (distinctDevices.size > 1) {
153312
+ const named = distinctDevices.size > 1 || pinned !== void 0 ? targetsNamedFor(pool, options.deviceNameMatches) : void 0;
153313
+ if (named) {
153314
+ candidates = named;
153315
+ matchedByName = true;
153316
+ } else if (distinctDevices.size > 1) {
153269
153317
  const listed = [...distinctDevices.values()].join(", ");
153270
153318
  throw new FailureError(
153271
- `No debugger target matches device_id "${deviceId}". ${distinctDevices.size} devices are connected to Metro on port ${port}: ${listed}. Re-target with the logicalDeviceId in parentheses \u2014 that is what debugger-connect returns and what subsequent debugger-* calls must pass. A legacy-inspector device (RN 0.72 / Vega) reports none and cannot be singled out of a shared Metro: give it its own Metro port.`,
153319
+ `No debugger target matches device_id "${deviceId}". ${distinctDevices.size} devices are connected to Metro on port ${port}: ${listed}. ` + (typeof options.deviceNameMatches === "function" ? `More than one of them, or none, has this device's name, so it cannot be told apart by name. ` : "") + `Re-target with the logicalDeviceId in parentheses \u2014 debugger-connect returns it, and it is accepted by every debugger-* call. A legacy-inspector device (RN 0.72 / Vega) reports none and cannot be singled out of a shared Metro: give it its own Metro port.`,
153272
153320
  {
153273
153321
  error_code: FAILURE_CODES.DEBUGGER_TARGET_DEVICE_MISMATCH,
153274
153322
  failure_stage: "debugger_select_target",
@@ -153277,11 +153325,12 @@ function selectTarget(targets, port, options) {
153277
153325
  }
153278
153326
  );
153279
153327
  }
153280
- const seen = seenLogicalDeviceIds.has(deviceId);
153281
- if (seen || LOGICAL_DEVICE_ID_SHAPE.test(deviceId)) {
153328
+ const missingId = pinned ?? deviceId;
153329
+ const seen = seenLogicalDeviceIds.has(missingId);
153330
+ if (!named && (seen || LOGICAL_DEVICE_ID_SHAPE.test(missingId))) {
153282
153331
  const state3 = seen ? `is no longer attached to Metro on port ${port} \u2014 its app likely exited or reloaded onto another Metro. ` : `is not attached to Metro on port ${port} \u2014 its app is not running, is still starting, or uses another Metro. `;
153283
153332
  throw new FailureError(
153284
- `Device with logicalDeviceId "${deviceId}" ${state3}Not falling back to the remaining device: ${[...distinctDevices.values()].join(", ")}. If the app exited, relaunch it on the target device (launch-app / restart-app), then retry with the same id: a relaunched app keeps its logicalDeviceId. If it was reinstalled (reinstall-app), iOS can give it a new logicalDeviceId: when the device listed above is your target, retry with the id shown for it.`,
153333
+ `Device with logicalDeviceId "${missingId}"` + (pinned !== void 0 ? `, which device_id "${deviceId}" was matched to by name,` : "") + ` ${state3}Not falling back to the remaining device: ${[...distinctDevices.values()].join(", ")}. If the app exited, relaunch it on the target device (launch-app / restart-app), then retry with the same id: a relaunched app keeps its logicalDeviceId. If it was reinstalled (reinstall-app), iOS can give it a new logicalDeviceId: when the device listed above is your target, retry with the id shown for it.`,
153285
153334
  {
153286
153335
  error_code: FAILURE_CODES.DEBUGGER_METRO_NO_TARGETS,
153287
153336
  failure_stage: "debugger_select_target",
@@ -153299,29 +153348,30 @@ function selectTarget(targets, port, options) {
153299
153348
  const fusebox = candidates.find(
153300
153349
  (t) => t.reactNative?.capabilities?.prefersFuseboxFrontend === true
153301
153350
  );
153302
- if (fusebox) return makeResult(fusebox, port, true, false);
153351
+ if (fusebox) return makeResult(fusebox, port, true, false, matchedByName);
153303
153352
  const cppConn = candidates.find((t) => t.description?.endsWith("[C++ connection]"));
153304
- if (cppConn) return makeResult(cppConn, port, true, false);
153353
+ if (cppConn) return makeResult(cppConn, port, true, false, matchedByName);
153305
153354
  const bridge = candidates.find((t) => t.title?.startsWith("React Native Bridge"));
153306
- if (bridge) return makeResult(bridge, port, false, false);
153355
+ if (bridge) return makeResult(bridge, port, false, false, matchedByName);
153307
153356
  const hermes = candidates.find(
153308
153357
  (t) => LEGACY_APP_RUNTIME_TITLES.has(t.title?.replace(CXX_CONNECTION_SUFFIX, ""))
153309
153358
  );
153310
- if (hermes) return makeResult(hermes, port, false, true);
153311
- return makeResult(candidates[0], port, false, true);
153359
+ if (hermes) return makeResult(hermes, port, false, true, matchedByName);
153360
+ return makeResult(candidates[0], port, false, true, matchedByName);
153312
153361
  }
153313
153362
  var LEGACY_APP_RUNTIME_TITLES = /* @__PURE__ */ new Set([
153314
153363
  "Hermes React Native",
153315
153364
  "Hermes Bridgeless React Native"
153316
153365
  ]);
153317
153366
  var CXX_CONNECTION_SUFFIX = / \[C\+\+ connection\]$/;
153318
- function makeResult(target, port, isNewDebugger, legacyInspector) {
153367
+ function makeResult(target, port, isNewDebugger, legacyInspector, matchedByName) {
153319
153368
  return {
153320
153369
  target,
153321
153370
  webSocketUrl: normalizeWsUrl(target.webSocketDebuggerUrl, port),
153322
153371
  isNewDebugger,
153323
153372
  legacyInspector,
153324
- deviceName: target.deviceName ?? target.title ?? "unknown"
153373
+ deviceName: target.deviceName ?? target.title ?? "unknown",
153374
+ matchedByName
153325
153375
  };
153326
153376
  }
153327
153377
  function normalizeWsUrl(wsUrl, port) {
@@ -153331,6 +153381,232 @@ function normalizeWsUrl(wsUrl, port) {
153331
153381
  return url2.toString();
153332
153382
  }
153333
153383
 
153384
+ // ../tool-server/src/utils/debugger/device-name.ts
153385
+ init_adb();
153386
+ init_device_info();
153387
+ init_external_devices();
153388
+
153389
+ // ../tool-server/src/utils/debugger/runtime-device.ts
153390
+ var import_node_crypto16 = require("node:crypto");
153391
+ var import_node_child_process32 = require("node:child_process");
153392
+ var import_node_util23 = require("node:util");
153393
+ init_adb();
153394
+ var execFileAsync23 = (0, import_node_util23.promisify)(import_node_child_process32.execFile);
153395
+ var LOG_READ_TIMEOUT_MS = 5e3;
153396
+ var RETRY_DELAY_MS = 300;
153397
+ var OTHER_TRANSPORTS_GRACE_MS = 500;
153398
+ var NOT_FOUND = { found: [], unresolved: [] };
153399
+ async function findRuntimeDevices(cdp, {
153400
+ awaitSerials = [],
153401
+ waitSerials = []
153402
+ } = {}) {
153403
+ const marker = `argent-device-probe:${(0, import_node_crypto16.randomUUID)()}`;
153404
+ const logged = await cdp.evaluate(
153405
+ `(function () {
153406
+ if (typeof nativeLoggingHook !== "function") return false;
153407
+ nativeLoggingHook(${JSON.stringify(marker)}, 1);
153408
+ return true;
153409
+ })()`
153410
+ ).catch(() => false);
153411
+ if (logged !== true) return NOT_FOUND;
153412
+ const checks = [
153413
+ async () => androidDevices(await androidSerials(), marker, awaitSerials, waitSerials),
153414
+ async () => {
153415
+ const udids = await bootedSimulators();
153416
+ const udid = await firstFound(udids.map((udid2) => () => simulatorLogHolds(udid2, marker)));
153417
+ return udid === void 0 ? void 0 : { found: [udid], unresolved: [] };
153418
+ }
153419
+ ];
153420
+ for (let attempt = 0; attempt < 2; attempt++) {
153421
+ if (attempt > 0) await new Promise((r) => setTimeout(r, RETRY_DELAY_MS));
153422
+ const found = await firstFound(checks);
153423
+ if (found !== void 0) return found;
153424
+ }
153425
+ return NOT_FOUND;
153426
+ }
153427
+ function firstFound(checks) {
153428
+ return new Promise((resolve21) => {
153429
+ let left = checks.length;
153430
+ if (left === 0) resolve21(void 0);
153431
+ for (const check3 of checks) {
153432
+ void check3().then((value) => {
153433
+ if (value !== void 0) resolve21(value);
153434
+ else if (--left === 0) resolve21(void 0);
153435
+ });
153436
+ }
153437
+ });
153438
+ }
153439
+ async function androidDevices(serials, marker, awaitSerials, waitSerials) {
153440
+ const listed = [...new Set(serials)];
153441
+ const awaited = listed.filter(
153442
+ (serial) => awaitSerials.includes(serial) || waitSerials.includes(serial)
153443
+ );
153444
+ const answers = /* @__PURE__ */ new Map();
153445
+ await new Promise((resolve21) => {
153446
+ let graceOver = false;
153447
+ let grace;
153448
+ const settle3 = () => {
153449
+ const held = heldSerials(answers);
153450
+ const waitingOn = listed.filter(
153451
+ (serial) => !answers.has(serial) && (!graceOver || awaited.includes(serial)) && !held.some((found2) => anotherDevice(serial, found2))
153452
+ );
153453
+ if (waitingOn.length === 0) {
153454
+ clearTimeout(grace);
153455
+ resolve21();
153456
+ }
153457
+ };
153458
+ settle3();
153459
+ for (const serial of listed) {
153460
+ void logcatHolds(serial, marker).then((read) => {
153461
+ answers.set(serial, read);
153462
+ if (read === "held") {
153463
+ grace ??= setTimeout(() => {
153464
+ graceOver = true;
153465
+ settle3();
153466
+ }, OTHER_TRANSPORTS_GRACE_MS);
153467
+ }
153468
+ settle3();
153469
+ });
153470
+ }
153471
+ });
153472
+ const found = heldSerials(answers);
153473
+ if (found.length === 0) return void 0;
153474
+ const unresolved = [...new Set(awaitSerials)].filter(
153475
+ (serial) => (!listed.includes(serial) || answers.get(serial) === "failed") && !found.some((device) => anotherDevice(serial, device))
153476
+ );
153477
+ return { found, unresolved };
153478
+ }
153479
+ function heldSerials(answers) {
153480
+ return [...answers].filter(([, read]) => read === "held").map(([serial]) => serial);
153481
+ }
153482
+ function anotherDevice(a, b) {
153483
+ if (a === b) return false;
153484
+ const portA = consolePortFromAdbSerial(a);
153485
+ const portB = consolePortFromAdbSerial(b);
153486
+ if (portA !== null && portB !== null) return portA !== portB;
153487
+ if (isUsbSerial(a) && isUsbSerial(b)) return true;
153488
+ return portA !== null && isUsbSerial(b) || portB !== null && isUsbSerial(a);
153489
+ }
153490
+ function isUsbSerial(serial) {
153491
+ return !serial.startsWith("emulator-") && !serial.includes(":") && !serial.includes("._");
153492
+ }
153493
+ async function androidSerials() {
153494
+ try {
153495
+ const { stdout } = await runAdb(["devices"], { timeoutMs: ADB_DEVICES_TIMEOUT_MS });
153496
+ return parseAdbDevices(stdout).filter((d) => d.state === "device").map((d) => d.serial);
153497
+ } catch {
153498
+ return [];
153499
+ }
153500
+ }
153501
+ async function bootedSimulators() {
153502
+ const simulators = await listIosSimulators().catch(() => []);
153503
+ return simulators.filter((s) => s.state === "Booted").map((s) => s.udid);
153504
+ }
153505
+ async function logcatHolds(serial, marker) {
153506
+ try {
153507
+ const { stdout } = await runAdb(
153508
+ ["-s", serial, "logcat", "-d", "-s", "ReactNativeJS", "-e", marker],
153509
+ { timeoutMs: LOG_READ_TIMEOUT_MS }
153510
+ );
153511
+ return stdout.includes(marker) ? "held" : "absent";
153512
+ } catch {
153513
+ return "failed";
153514
+ }
153515
+ }
153516
+ async function simulatorLogHolds(udid, marker) {
153517
+ try {
153518
+ const args = await simctlArgsForUdid(udid, [
153519
+ "spawn",
153520
+ udid,
153521
+ "log",
153522
+ "show",
153523
+ "--info",
153524
+ "--last",
153525
+ "1m",
153526
+ "--style",
153527
+ "compact",
153528
+ "--predicate",
153529
+ `eventMessage CONTAINS ${JSON.stringify(marker)} AND process != "log"`
153530
+ ]);
153531
+ const { stdout } = await execFileAsync23("xcrun", args, {
153532
+ timeout: LOG_READ_TIMEOUT_MS,
153533
+ killSignal: SIMCTL_KILL_SIGNAL,
153534
+ encoding: "utf-8"
153535
+ });
153536
+ return stdout.includes(marker) ? udid : void 0;
153537
+ } catch {
153538
+ return void 0;
153539
+ }
153540
+ }
153541
+
153542
+ // ../tool-server/src/utils/debugger/device-name.ts
153543
+ async function deviceNameMatcher(deviceId) {
153544
+ const device = resolveDevice(deviceId);
153545
+ try {
153546
+ if (device.platform === "ios" && device.kind === "simulator") {
153547
+ return await iosSimulatorMatcher(externalNativeId(deviceId));
153548
+ }
153549
+ if (device.platform === "android") {
153550
+ return await androidMatcher(externalNativeId(deviceId));
153551
+ }
153552
+ } catch {
153553
+ return void 0;
153554
+ }
153555
+ return void 0;
153556
+ }
153557
+ function nameMetroLists(simulatorName) {
153558
+ return simulatorName.split("&")[0].replaceAll("+", " ");
153559
+ }
153560
+ async function iosSimulatorMatcher(udid) {
153561
+ const booted = (await listIosSimulators()).filter((s) => s.state === "Booted");
153562
+ const own2 = booted.find((s) => s.udid === udid);
153563
+ if (!own2) return void 0;
153564
+ if (nameMetroLists(own2.name) !== own2.name) return void 0;
153565
+ if (booted.some((s) => s.udid !== udid && nameMetroLists(s.name) === own2.name)) return void 0;
153566
+ return (reported) => reported === own2.name;
153567
+ }
153568
+ async function androidNames(serial) {
153569
+ const out = await adbShell(
153570
+ serial,
153571
+ 'echo "$(getprop ro.product.model)|$(getprop ro.build.version.release)|$(getprop ro.build.version.sdk)"',
153572
+ { timeoutMs: ENRICH_TIMEOUT_MS }
153573
+ );
153574
+ const [model = "", release2 = "", sdk = ""] = out.trim().split("|");
153575
+ if (!model) return void 0;
153576
+ return { full: `${model} - ${release2} - API ${sdk}`, model };
153577
+ }
153578
+ async function androidMatcher(serial) {
153579
+ const { stdout } = await runAdb(["devices"], { timeoutMs: ADB_DEVICES_TIMEOUT_MS });
153580
+ const others = parseAdbDevices(stdout).filter((d) => d.state === "device" && d.serial !== serial);
153581
+ const [own2, ...rest] = await Promise.all([
153582
+ androidNames(serial),
153583
+ ...others.map((d) => androidNames(d.serial).catch(() => null))
153584
+ ]);
153585
+ if (!own2) return void 0;
153586
+ if (rest.some((names) => names === null)) return void 0;
153587
+ const fullTaken = rest.some((names) => names?.full === own2.full);
153588
+ const modelTaken = rest.some((names) => names?.model === own2.model);
153589
+ if (fullTaken) return void 0;
153590
+ return (reported) => reported === own2.full || !modelTaken && reported === own2.model;
153591
+ }
153592
+ var nameMatchedLogicalIds = /* @__PURE__ */ new Map();
153593
+ var pinKey = (deviceId, port) => `${port}|${deviceId}`;
153594
+ function nameMatchedLogicalDeviceId(deviceId, port) {
153595
+ return nameMatchedLogicalIds.get(pinKey(deviceId, port));
153596
+ }
153597
+ function rememberNameMatch(deviceId, port, logicalDeviceId) {
153598
+ if (logicalDeviceId) nameMatchedLogicalIds.set(pinKey(deviceId, port), logicalDeviceId);
153599
+ }
153600
+ function forgetNameMatch(deviceId, port) {
153601
+ nameMatchedLogicalIds.delete(pinKey(deviceId, port));
153602
+ }
153603
+ async function runtimeRunsOn(cdp, deviceId) {
153604
+ const native = externalNativeId(deviceId);
153605
+ const { found } = await findRuntimeDevices(cdp, { waitSerials: [native] });
153606
+ if (found.includes(native)) return { verdict: "yes" };
153607
+ return found.length ? { verdict: "elsewhere", found } : { verdict: "unknown" };
153608
+ }
153609
+
153334
153610
  // ../tool-server/src/utils/debugger/source-resolver.ts
153335
153611
  var fs42 = __toESM(require("node:fs/promises"));
153336
153612
  var path36 = __toESM(require("node:path"));
@@ -153583,6 +153859,23 @@ var DISABLE_LOGBOX_SCRIPT = `(function() {
153583
153859
  init_wrapper();
153584
153860
  var http4 = __toESM(require("node:http"));
153585
153861
  var JS_RUNTIME_DEBUGGER_NAMESPACE = "JsRuntimeDebugger";
153862
+ function unconfirmedMatchError(deviceId, port, deviceName, where, targets) {
153863
+ const listed = [
153864
+ ...new Set(
153865
+ targets.filter((t) => t.reactNative?.logicalDeviceId).map((t) => `${t.deviceName ?? t.title ?? "unknown"} (${t.reactNative.logicalDeviceId})`)
153866
+ )
153867
+ ].join(", ");
153868
+ const state3 = where.verdict === "elsewhere" ? `runs on ${where.found.join(", ")}, not on this device` : `could not be confirmed to run on this device: no device log argent can read holds the probe it wrote`;
153869
+ return new FailureError(
153870
+ `No debugger target matches device_id "${deviceId}". The app Metro on port ${port} lists under this device's name, "${deviceName}", ${state3}. A device on another adb server, on the network or in another simulator device set can report the same name. Metro lists: ${listed}. If this device's app does not run, start it (launch-app) and retry. Otherwise re-target with the logicalDeviceId in parentheses \u2014 debugger-connect returns it, and it is accepted by every debugger-* call.`,
153871
+ {
153872
+ error_code: FAILURE_CODES.DEBUGGER_TARGET_DEVICE_MISMATCH,
153873
+ failure_stage: "debugger_select_target",
153874
+ failure_area: "tool_server",
153875
+ error_kind: "not_found"
153876
+ }
153877
+ );
153878
+ }
153586
153879
  function stringifyConsoleValue2(value) {
153587
153880
  if (typeof value === "object" && value !== null) {
153588
153881
  try {
@@ -153697,17 +153990,39 @@ var jsRuntimeDebuggerBlueprint = {
153697
153990
  }
153698
153991
  throw error63;
153699
153992
  });
153700
- const selected = selectTarget(metro.targets, port, {
153701
- ...options,
153702
- deviceId,
153703
- simulatorName: await simulatorNameOnSharedMetro(deviceId, metro.targets)
153704
- });
153705
153993
  const onPublishedBundler = publishedMetroPort(physicalDeviceId, port) === void 0;
153706
153994
  const proxied = onPublishedBundler ? externalJsDebuggerUrl(physicalDeviceId) : void 0;
153707
- const cdp = new CDPClient(proxied ?? selected.webSocketUrl, {
153708
- awaitPromisesInApp: !selected.legacyInspector
153709
- });
153710
- await cdp.connect();
153995
+ const logicalIds = new Set(metro.targets.map((t) => t.reactNative?.logicalDeviceId));
153996
+ let selected;
153997
+ let cdp;
153998
+ for (let attempt = 0; ; attempt++) {
153999
+ const pinnedLogicalDeviceId = nameMatchedLogicalDeviceId(deviceId, port);
154000
+ const needsName = !logicalIds.has(deviceId) && (pinnedLogicalDeviceId !== void 0 ? !logicalIds.has(pinnedLogicalDeviceId) : logicalIds.size > 1);
154001
+ const deviceNameMatches = needsName ? await deviceNameMatcher(deviceId) : void 0;
154002
+ selected = selectTarget(metro.targets, port, {
154003
+ ...options,
154004
+ deviceId,
154005
+ deviceNameMatches,
154006
+ pinnedLogicalDeviceId
154007
+ });
154008
+ const selectedId = selected.target.reactNative?.logicalDeviceId;
154009
+ const byPin = pinnedLogicalDeviceId !== void 0 && selectedId === pinnedLogicalDeviceId && selectedId !== deviceId;
154010
+ cdp = new CDPClient(proxied ?? selected.webSocketUrl, {
154011
+ awaitPromisesInApp: !selected.legacyInspector
154012
+ });
154013
+ await cdp.connect();
154014
+ if (!selected.matchedByName && !byPin) break;
154015
+ const client2 = cdp;
154016
+ const where = await client2.send("Runtime.enable").then(() => runtimeRunsOn(client2, deviceId)).catch(() => ({ verdict: "unknown" }));
154017
+ if (where.verdict === "yes") {
154018
+ rememberNameMatch(deviceId, port, selectedId);
154019
+ break;
154020
+ }
154021
+ forgetNameMatch(deviceId, port);
154022
+ await client2.disconnect();
154023
+ if (byPin && attempt === 0) continue;
154024
+ throw unconfirmedMatchError(deviceId, port, selected.deviceName, where, metro.targets);
154025
+ }
153711
154026
  const sourceMaps = new SourceMapsRegistry();
153712
154027
  cdp.events.on("scriptParsed", (script) => {
153713
154028
  sourceMaps.registerFromScriptParsed(script.url, script.scriptId, script.sourceMapURL);
@@ -153838,7 +154153,7 @@ var jsRuntimeDebuggerBlueprint = {
153838
154153
  init_src2();
153839
154154
 
153840
154155
  // ../tool-server/src/utils/debugger/scripts/network-interceptor.ts
153841
- var import_node_crypto16 = require("node:crypto");
154156
+ var import_node_crypto17 = require("node:crypto");
153842
154157
  var import_node_os12 = require("node:os");
153843
154158
  init_src3();
153844
154159
  var BINARY_BODY_TYPES = /^(image\/(?!svg)|audio\/|video\/|font\/|application\/(octet-stream|pdf|zip|gzip|wasm|x-protobuf)$)/;
@@ -154907,7 +155222,7 @@ var NETWORK_CAPTURE_MARK_SCRIPT = `(function() {
154907
155222
  var g = globalThis;
154908
155223
  return typeof g.__argent_network_mark === 'function' ? g.__argent_network_mark() : JSON.stringify({ install: null });
154909
155224
  })()`;
154910
- var HOLDER = JSON.stringify((0, import_node_crypto16.randomUUID)());
155225
+ var HOLDER = JSON.stringify((0, import_node_crypto17.randomUUID)());
154911
155226
  function holderRecord(capturing2) {
154912
155227
  return JSON.stringify({ capturing: capturing2, pid: process.pid, host: (0, import_node_os12.hostname)() });
154913
155228
  }
@@ -156106,21 +156421,21 @@ function clearLostProfilerRun(port, deviceId) {
156106
156421
  }
156107
156422
 
156108
156423
  // ../tool-server/src/tools/devices/boot-device.ts
156109
- var import_node_child_process35 = require("node:child_process");
156424
+ var import_node_child_process36 = require("node:child_process");
156110
156425
  var import_node_fs16 = require("node:fs");
156111
156426
  var import_promises14 = require("node:fs/promises");
156112
156427
  var import_node_os15 = require("node:os");
156113
156428
  var import_node_path19 = require("node:path");
156114
- var import_node_util25 = require("node:util");
156429
+ var import_node_util26 = require("node:util");
156115
156430
  init_zod();
156116
156431
  init_src();
156117
156432
  init_src2();
156118
156433
  init_adb();
156119
156434
 
156120
156435
  // ../tool-server/src/utils/emulator-process.ts
156121
- var import_node_child_process32 = require("node:child_process");
156122
- var import_node_util23 = require("node:util");
156123
- var execFileAsync23 = (0, import_node_util23.promisify)(import_node_child_process32.execFile);
156436
+ var import_node_child_process33 = require("node:child_process");
156437
+ var import_node_util24 = require("node:util");
156438
+ var execFileAsync24 = (0, import_node_util24.promisify)(import_node_child_process33.execFile);
156124
156439
  var EMULATOR_PROCESS_RE = /(?:^|\/)(?:qemu-system-[\w-]+|emulator|emulator64-[\w-]+)\s/;
156125
156440
  function escapeRegExp(value) {
156126
156441
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -156140,7 +156455,7 @@ function parseEmulatorPidsForAvd(psOutput, avdName) {
156140
156455
  async function listEmulatorPidsForAvd(avdName) {
156141
156456
  if (process.platform === "win32") return [];
156142
156457
  try {
156143
- const { stdout } = await execFileAsync23(PS_BIN, [...PS_ARGS_WITH_PID], {
156458
+ const { stdout } = await execFileAsync24(PS_BIN, [...PS_ARGS_WITH_PID], {
156144
156459
  timeout: 5e3,
156145
156460
  maxBuffer: 16 * 1024 * 1024
156146
156461
  });
@@ -156219,12 +156534,12 @@ function readMb(config2, key2) {
156219
156534
  }
156220
156535
 
156221
156536
  // ../tool-server/src/utils/simulator-app-launch.ts
156222
- var import_node_child_process33 = require("node:child_process");
156537
+ var import_node_child_process34 = require("node:child_process");
156223
156538
  var import_node_fs15 = __toESM(require("node:fs"));
156224
156539
  var import_node_os14 = __toESM(require("node:os"));
156225
156540
  var import_node_path18 = __toESM(require("node:path"));
156226
- var import_node_util24 = require("node:util");
156227
- var execFileAsync24 = (0, import_node_util24.promisify)(import_node_child_process33.execFile);
156541
+ var import_node_util25 = require("node:util");
156542
+ var execFileAsync25 = (0, import_node_util25.promisify)(import_node_child_process34.execFile);
156228
156543
  var CORE_SIMULATOR_INFO_PLIST = "/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/Resources/Info.plist";
156229
156544
  var LAUNCH_WATCH_MS = 1e4;
156230
156545
  var LAUNCH_POLL_MS = 250;
@@ -156253,7 +156568,7 @@ function persistVerdict(key2, verdict) {
156253
156568
  }
156254
156569
  }
156255
156570
  async function bundleVersion(infoPlist) {
156256
- const { stdout } = await execFileAsync24(
156571
+ const { stdout } = await execFileAsync25(
156257
156572
  "plutil",
156258
156573
  ["-extract", "CFBundleVersion", "raw", "-o", "-", infoPlist],
156259
156574
  { timeout: 5e3 }
@@ -156269,7 +156584,7 @@ async function launchKey(simulatorApp) {
156269
156584
  }
156270
156585
  var comparablePath = (p) => p.normalize("NFC").toLowerCase();
156271
156586
  async function runningExecutables() {
156272
- const { stdout } = await execFileAsync24(PS_BIN, ["-xo", "comm="], {
156587
+ const { stdout } = await execFileAsync25(PS_BIN, ["-xo", "comm="], {
156273
156588
  timeout: 5e3,
156274
156589
  env: { ...process.env, LC_ALL: "en_US.UTF-8" }
156275
156590
  });
@@ -156334,7 +156649,7 @@ init_capability();
156334
156649
  init_harmony_flag();
156335
156650
 
156336
156651
  // ../tool-server/src/tools/devices/boot-electron.ts
156337
- var import_node_child_process34 = require("node:child_process");
156652
+ var import_node_child_process35 = require("node:child_process");
156338
156653
  var fs45 = __toESM(require("node:fs"));
156339
156654
  var path38 = __toESM(require("node:path"));
156340
156655
  init_src2();
@@ -156530,7 +156845,7 @@ async function bootElectronApp(options) {
156530
156845
  ];
156531
156846
  let child;
156532
156847
  try {
156533
- child = (0, import_node_child_process34.spawn)(launcher.command, args, {
156848
+ child = (0, import_node_child_process35.spawn)(launcher.command, args, {
156534
156849
  detached: true,
156535
156850
  // stdout is discarded, not piped: nothing reads it, and an unread pipe
156536
156851
  // blocks the child's writes once the OS buffer fills. The
@@ -156693,7 +157008,7 @@ async function bootMacosApp(registry2, opts) {
156693
157008
  }
156694
157009
 
156695
157010
  // ../tool-server/src/tools/devices/boot-device.ts
156696
- var execFileAsync25 = (0, import_node_util25.promisify)(import_node_child_process35.execFile);
157011
+ var execFileAsync26 = (0, import_node_util26.promisify)(import_node_child_process36.execFile);
156697
157012
  function bootTarget(params) {
156698
157013
  return params.udid ?? params.avdName ?? params.vvdImage ?? params.harmonyInstance ?? params.electronAppPath ?? params.macosAppPath ?? "device";
156699
157014
  }
@@ -156915,7 +157230,7 @@ async function pickOwnSerial(avdName, newSerials) {
156915
157230
  }
156916
157231
  async function bootSimctl(prefix, [sub, udid, ...rest], timeoutMs) {
156917
157232
  try {
156918
- await execFileAsync25("xcrun", [...prefix, sub, udid, ...rest], {
157233
+ await execFileAsync26("xcrun", [...prefix, sub, udid, ...rest], {
156919
157234
  timeout: timeoutMs,
156920
157235
  killSignal: SIMCTL_KILL_SIGNAL
156921
157236
  });
@@ -157015,7 +157330,7 @@ async function bootIos(udid, registry2, force, headless) {
157015
157330
  return buildInitFailedResult(udid, initFailure);
157016
157331
  }
157017
157332
  if (!deviceSet) {
157018
- await execFileAsync25("defaults", [
157333
+ await execFileAsync26("defaults", [
157019
157334
  "write",
157020
157335
  "com.apple.iphonesimulator",
157021
157336
  "CurrentDeviceUDID",
@@ -157031,20 +157346,20 @@ async function bootIos(udid, registry2, force, headless) {
157031
157346
  }
157032
157347
  async function openSimulatorWindow(udid) {
157033
157348
  const timeout = 5e3;
157034
- const { stdout } = await execFileAsync25("xcode-select", ["-p"], { timeout });
157349
+ const { stdout } = await execFileAsync26("xcode-select", ["-p"], { timeout });
157035
157350
  const developerDir2 = (0, import_node_fs16.realpathSync)(stdout.trim());
157036
157351
  const simulatorApp = (0, import_node_path19.join)(developerDir2, "Applications", "Simulator.app");
157037
157352
  if ((0, import_node_fs16.existsSync)(simulatorApp)) {
157038
157353
  const launched = await launchSimulatorApp(
157039
157354
  simulatorApp,
157040
- () => execFileAsync25("open", ["-a", simulatorApp], { timeout })
157355
+ () => execFileAsync26("open", ["-a", simulatorApp], { timeout })
157041
157356
  );
157042
157357
  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.`;
157043
157358
  }
157044
157359
  const deviceHubApp = (0, import_node_path19.join)(developerDir2, "..", "Applications", "DeviceHub.app");
157045
157360
  if ((0, import_node_fs16.existsSync)(deviceHubApp)) {
157046
157361
  const url2 = `devices://device/open?id=${encodeURIComponent(udid)}`;
157047
- await execFileAsync25("open", ["-a", deviceHubApp, url2], { timeout });
157362
+ await execFileAsync26("open", ["-a", deviceHubApp, url2], { timeout });
157048
157363
  }
157049
157364
  }
157050
157365
  async function bootIosRemote(id, registry2, force) {
@@ -157093,7 +157408,7 @@ async function attemptBoot(params) {
157093
157408
  emulatorLogFd = (0, import_node_fs16.openSync)(logPath, "w");
157094
157409
  stdio = ["ignore", emulatorLogFd, emulatorLogFd];
157095
157410
  }
157096
- const child = (0, import_node_child_process35.spawn)(params.emulatorBinary, params.emulatorArgs, {
157411
+ const child = (0, import_node_child_process36.spawn)(params.emulatorBinary, params.emulatorArgs, {
157097
157412
  detached: true,
157098
157413
  stdio
157099
157414
  });
@@ -157637,7 +157952,7 @@ async function startHarmonyEmulator(instanceName) {
157637
157952
  } catch {
157638
157953
  logFd = null;
157639
157954
  }
157640
- const child = (0, import_node_child_process35.spawn)(bin, ["-start", instanceName], {
157955
+ const child = (0, import_node_child_process36.spawn)(bin, ["-start", instanceName], {
157641
157956
  detached: true,
157642
157957
  stdio: logFd === null ? "ignore" : ["ignore", logFd, logFd]
157643
157958
  });
@@ -158207,11 +158522,11 @@ function dispatchByPlatform(opts) {
158207
158522
  }
158208
158523
 
158209
158524
  // ../tool-server/src/tools/launch-app/platforms/ios.ts
158210
- var import_node_child_process36 = require("node:child_process");
158211
- var import_node_util26 = require("node:util");
158525
+ var import_node_child_process37 = require("node:child_process");
158526
+ var import_node_util27 = require("node:util");
158212
158527
  init_src2();
158213
158528
  init_external_devices();
158214
- var execFileAsync26 = (0, import_node_util26.promisify)(import_node_child_process36.execFile);
158529
+ var execFileAsync27 = (0, import_node_util27.promisify)(import_node_child_process37.execFile);
158215
158530
  function makeIosImpl(registry2) {
158216
158531
  return {
158217
158532
  requires: ["xcrun"],
@@ -158225,7 +158540,7 @@ function makeIosImpl(registry2) {
158225
158540
  }
158226
158541
  if (params.launchArgs?.length) {
158227
158542
  try {
158228
- await execFileAsync26(
158543
+ await execFileAsync27(
158229
158544
  "xcrun",
158230
158545
  await simctlArgsForUdid(params.udid, ["terminate", params.udid, params.bundleId]),
158231
158546
  { timeout: 15e3, killSignal: SIMCTL_KILL_SIGNAL }
@@ -158247,7 +158562,7 @@ function makeIosImpl(registry2) {
158247
158562
  }
158248
158563
  }
158249
158564
  try {
158250
- await execFileAsync26(
158565
+ await execFileAsync27(
158251
158566
  "xcrun",
158252
158567
  await simctlArgsForUdid(params.udid, [
158253
158568
  "launch",
@@ -158760,11 +159075,11 @@ init_zod();
158760
159075
  init_device_info();
158761
159076
 
158762
159077
  // ../tool-server/src/tools/restart-app/platforms/ios.ts
158763
- var import_node_child_process37 = require("node:child_process");
158764
- var import_node_util27 = require("node:util");
159078
+ var import_node_child_process38 = require("node:child_process");
159079
+ var import_node_util28 = require("node:util");
158765
159080
  init_src2();
158766
159081
  init_external_devices();
158767
- var execFileAsync27 = (0, import_node_util27.promisify)(import_node_child_process37.execFile);
159082
+ var execFileAsync28 = (0, import_node_util28.promisify)(import_node_child_process38.execFile);
158768
159083
  function makeIosImpl2(registry2) {
158769
159084
  return {
158770
159085
  requires: ["xcrun"],
@@ -158778,7 +159093,7 @@ function makeIosImpl2(registry2) {
158778
159093
  if (blocked) return blocked;
158779
159094
  }
158780
159095
  try {
158781
- await execFileAsync27("xcrun", await simctlArgsForUdid(udid, ["terminate", udid, bundleId]), {
159096
+ await execFileAsync28("xcrun", await simctlArgsForUdid(udid, ["terminate", udid, bundleId]), {
158782
159097
  timeout: 15e3,
158783
159098
  killSignal: SIMCTL_KILL_SIGNAL
158784
159099
  });
@@ -158798,7 +159113,7 @@ function makeIosImpl2(registry2) {
158798
159113
  }
158799
159114
  }
158800
159115
  try {
158801
- await execFileAsync27(
159116
+ await execFileAsync28(
158802
159117
  "xcrun",
158803
159118
  await simctlArgsForUdid(udid, ["launch", udid, bundleId, ...params.launchArgs ?? []]),
158804
159119
  { timeout: 3e4, killSignal: SIMCTL_KILL_SIGNAL }
@@ -159050,12 +159365,12 @@ For Mac apps, kind is 'catalyst' or 'app'. Check appPath and args to confirm the
159050
159365
  }
159051
159366
 
159052
159367
  // ../tool-server/src/tools/terminate-app/index.ts
159053
- var import_node_child_process38 = require("node:child_process");
159054
- var import_node_util28 = require("node:util");
159368
+ var import_node_child_process39 = require("node:child_process");
159369
+ var import_node_util29 = require("node:util");
159055
159370
  init_zod();
159056
159371
  init_src2();
159057
159372
  init_adb();
159058
- var execFileAsync28 = (0, import_node_util28.promisify)(import_node_child_process38.execFile);
159373
+ var execFileAsync29 = (0, import_node_util29.promisify)(import_node_child_process39.execFile);
159059
159374
  var capability5 = {
159060
159375
  apple: { simulator: true },
159061
159376
  appleRemote: { simulator: true },
@@ -159089,7 +159404,7 @@ Succeeds when the app is not running or not installed.`,
159089
159404
  requires: ["xcrun"],
159090
159405
  handler: async (_services, { udid, bundleId }) => {
159091
159406
  const args = await simctlArgsForUdid(udid, ["terminate", udid, bundleId]);
159092
- const terminate = execFileAsync28("xcrun", args, {
159407
+ const terminate = execFileAsync29("xcrun", args, {
159093
159408
  timeout: 15e3,
159094
159409
  killSignal: SIMCTL_KILL_SIGNAL
159095
159410
  }).catch((err) => {
@@ -159144,16 +159459,16 @@ Succeeds when the app is not running or not installed.`,
159144
159459
  init_zod();
159145
159460
 
159146
159461
  // ../tool-server/src/tools/reinstall-app/platforms/ios.ts
159147
- var import_node_child_process40 = require("node:child_process");
159148
- var import_node_util30 = require("node:util");
159462
+ var import_node_child_process41 = require("node:child_process");
159463
+ var import_node_util31 = require("node:util");
159149
159464
  var import_node_path21 = require("node:path");
159150
159465
  init_src2();
159151
159466
 
159152
159467
  // ../tool-server/src/tools/reinstall-app/validate-app.ts
159153
- var import_node_child_process39 = require("node:child_process");
159468
+ var import_node_child_process40 = require("node:child_process");
159154
159469
  var import_promises16 = require("node:fs/promises");
159155
159470
  var import_node_path20 = require("node:path");
159156
- var import_node_util29 = require("node:util");
159471
+ var import_node_util30 = require("node:util");
159157
159472
  init_capability();
159158
159473
 
159159
159474
  // ../tool-server/src/utils/apk-package.ts
@@ -159252,7 +159567,7 @@ function readStringPool(xml, chunk) {
159252
159567
  }
159253
159568
 
159254
159569
  // ../tool-server/src/tools/reinstall-app/validate-app.ts
159255
- var execFileAsync29 = (0, import_node_util29.promisify)(import_node_child_process39.execFile);
159570
+ var execFileAsync30 = (0, import_node_util30.promisify)(import_node_child_process40.execFile);
159256
159571
  async function requirePath(absolute, kind, what) {
159257
159572
  const info = await (0, import_promises16.stat)(absolute).catch(() => null);
159258
159573
  if (!info) {
@@ -159276,7 +159591,7 @@ async function assertIosAppBundle(absolute, bundleId, { readBundleId = true } =
159276
159591
  );
159277
159592
  }
159278
159593
  if (!readBundleId) return;
159279
- const actual = await execFileAsync29("plutil", [
159594
+ const actual = await execFileAsync30("plutil", [
159280
159595
  "-extract",
159281
159596
  "CFBundleIdentifier",
159282
159597
  "raw",
@@ -159329,7 +159644,7 @@ async function assertHap(absolute, bundleName) {
159329
159644
  }
159330
159645
 
159331
159646
  // ../tool-server/src/tools/reinstall-app/platforms/ios.ts
159332
- var execFileAsync30 = (0, import_node_util30.promisify)(import_node_child_process40.execFile);
159647
+ var execFileAsync31 = (0, import_node_util31.promisify)(import_node_child_process41.execFile);
159333
159648
  var iosImpl = {
159334
159649
  requires: ["xcrun"],
159335
159650
  handler: async (_services, params) => {
@@ -159338,7 +159653,7 @@ var iosImpl = {
159338
159653
  await assertIosAppBundle(absolute, bundleId);
159339
159654
  const { nativeId, prefix } = await simctlTargetForUdid(udid);
159340
159655
  try {
159341
- await execFileAsync30("xcrun", [...prefix, "uninstall", nativeId, bundleId], {
159656
+ await execFileAsync31("xcrun", [...prefix, "uninstall", nativeId, bundleId], {
159342
159657
  timeout: 3e4,
159343
159658
  killSignal: SIMCTL_KILL_SIGNAL
159344
159659
  });
@@ -159358,7 +159673,7 @@ var iosImpl = {
159358
159673
  }
159359
159674
  }
159360
159675
  try {
159361
- await execFileAsync30("xcrun", [...prefix, "install", nativeId, absolute], {
159676
+ await execFileAsync31("xcrun", [...prefix, "install", nativeId, absolute], {
159362
159677
  timeout: 18e4,
159363
159678
  killSignal: SIMCTL_KILL_SIGNAL
159364
159679
  });
@@ -159626,11 +159941,11 @@ var PERMISSION_NAMES = [
159626
159941
  ];
159627
159942
 
159628
159943
  // ../tool-server/src/tools/settings-permissions/platforms/ios.ts
159629
- var import_node_child_process41 = require("node:child_process");
159630
- var import_node_util31 = require("node:util");
159944
+ var import_node_child_process42 = require("node:child_process");
159945
+ var import_node_util32 = require("node:util");
159631
159946
  init_src2();
159632
159947
  init_capability();
159633
- var execFileAsync31 = (0, import_node_util31.promisify)(import_node_child_process41.execFile);
159948
+ var execFileAsync32 = (0, import_node_util32.promisify)(import_node_child_process42.execFile);
159634
159949
  var SIMCTL_ACTION = {
159635
159950
  grant: "grant",
159636
159951
  deny: "revoke",
@@ -159655,7 +159970,7 @@ var NON_TCC_GRANT_NEEDS_INSTALL = /* @__PURE__ */ new Set([
159655
159970
  ]);
159656
159971
  var localBackend = {
159657
159972
  async run(udid, simctlAction, service, bundleId) {
159658
- await execFileAsync31(
159973
+ await execFileAsync32(
159659
159974
  "xcrun",
159660
159975
  await simctlArgsForUdid(udid, ["privacy", udid, simctlAction, service, bundleId]),
159661
159976
  { timeout: 3e4 }
@@ -159663,7 +159978,7 @@ var localBackend = {
159663
159978
  },
159664
159979
  async isInstalled(udid, bundleId) {
159665
159980
  try {
159666
- await execFileAsync31(
159981
+ await execFileAsync32(
159667
159982
  "xcrun",
159668
159983
  await simctlArgsForUdid(udid, ["get_app_container", udid, bundleId]),
159669
159984
  { timeout: 15e3 }
@@ -159947,8 +160262,8 @@ init_zod();
159947
160262
  init_device_info();
159948
160263
 
159949
160264
  // ../tool-server/src/tools/open-url/platforms/ios.ts
159950
- var import_node_child_process42 = require("node:child_process");
159951
- var import_node_util32 = require("node:util");
160265
+ var import_node_child_process43 = require("node:child_process");
160266
+ var import_node_util33 = require("node:util");
159952
160267
  init_src2();
159953
160268
 
159954
160269
  // ../tool-server/src/tools/open-url/deep-link-note.ts
@@ -159958,13 +160273,13 @@ function httpDeepLinkNote(url2) {
159958
160273
  }
159959
160274
 
159960
160275
  // ../tool-server/src/tools/open-url/platforms/ios.ts
159961
- var execFileAsync32 = (0, import_node_util32.promisify)(import_node_child_process42.execFile);
160276
+ var execFileAsync33 = (0, import_node_util33.promisify)(import_node_child_process43.execFile);
159962
160277
  var iosImpl3 = {
159963
160278
  requires: ["xcrun"],
159964
160279
  handler: async (_services, params) => {
159965
160280
  await firstSimulatorPoll();
159966
160281
  try {
159967
- await execFileAsync32(
160282
+ await execFileAsync33(
159968
160283
  "xcrun",
159969
160284
  await simctlArgsForUdid(params.udid, ["openurl", params.udid, params.url]),
159970
160285
  { timeout: 3e4, killSignal: SIMCTL_KILL_SIGNAL }
@@ -160086,16 +160401,16 @@ var chromiumImpl2 = {
160086
160401
  };
160087
160402
 
160088
160403
  // ../tool-server/src/tools/open-url/platforms/macos.ts
160089
- var import_node_child_process43 = require("node:child_process");
160404
+ var import_node_child_process44 = require("node:child_process");
160090
160405
  var path39 = __toESM(require("node:path"));
160091
- var import_node_util33 = require("node:util");
160406
+ var import_node_util34 = require("node:util");
160092
160407
  init_src2();
160093
160408
  init_capability();
160094
- var execFileAsync33 = (0, import_node_util33.promisify)(import_node_child_process43.execFile);
160409
+ var execFileAsync34 = (0, import_node_util34.promisify)(import_node_child_process44.execFile);
160095
160410
  var WEB_URL_NOTE = "The URL went to the app of the device, not to the default browser. The app shows it only if it handles that URL.";
160096
160411
  async function declaredSchemes(appPath) {
160097
160412
  try {
160098
- const { stdout } = await execFileAsync33(
160413
+ const { stdout } = await execFileAsync34(
160099
160414
  "plutil",
160100
160415
  [
160101
160416
  "-extract",
@@ -160141,7 +160456,7 @@ var macosImpl3 = {
160141
160456
  );
160142
160457
  }
160143
160458
  try {
160144
- await execFileAsync33("open", ["-g", "-a", app.appPath, params.url], { timeout: 1e4 });
160459
+ await execFileAsync34("open", ["-g", "-a", app.appPath, params.url], { timeout: 1e4 });
160145
160460
  } catch (err) {
160146
160461
  const stderr = err.stderr?.trim();
160147
160462
  throw macosFailure(
@@ -160228,8 +160543,8 @@ Returns { opened, url, note? }. \`note\` explains the routing caveat when a web
160228
160543
  };
160229
160544
 
160230
160545
  // ../tool-server/src/tools/screenshot/index.ts
160231
- var import_node_child_process44 = require("node:child_process");
160232
- var import_node_util34 = require("node:util");
160546
+ var import_node_child_process45 = require("node:child_process");
160547
+ var import_node_util35 = require("node:util");
160233
160548
  var os18 = __toESM(require("node:os"));
160234
160549
  var path40 = __toESM(require("node:path"));
160235
160550
  init_zod();
@@ -160489,7 +160804,7 @@ async function captureHarmonyScreenshotPng(opts) {
160489
160804
  // ../tool-server/src/tools/screenshot/index.ts
160490
160805
  init_capability();
160491
160806
  var fs47 = __toESM(require("node:fs/promises"));
160492
- var execFileAsync34 = (0, import_node_util34.promisify)(import_node_child_process44.execFile);
160807
+ var execFileAsync35 = (0, import_node_util35.promisify)(import_node_child_process45.execFile);
160493
160808
  var capability9 = {
160494
160809
  apple: { simulator: true, device: true },
160495
160810
  appleRemote: { simulator: true },
@@ -160527,11 +160842,11 @@ async function tvScreenshot(udid, scale, signal) {
160527
160842
  os18.tmpdir(),
160528
160843
  `argent-tv-screenshot-${udid.slice(0, 8)}-${process.hrtime.bigint()}.png`
160529
160844
  );
160530
- await execFileAsync34("xcrun", await simctlArgsForUdid(udid, ["io", udid, "screenshot", file2]), {
160845
+ await execFileAsync35("xcrun", await simctlArgsForUdid(udid, ["io", udid, "screenshot", file2]), {
160531
160846
  signal
160532
160847
  });
160533
160848
  if (scale === void 0 || scale < 1) {
160534
- await execFileAsync34("sips", ["-Z", String(await tvTargetLongSide(file2, scale)), file2], {
160849
+ await execFileAsync35("sips", ["-Z", String(await tvTargetLongSide(file2, scale)), file2], {
160535
160850
  signal
160536
160851
  }).catch(() => {
160537
160852
  });
@@ -160541,7 +160856,7 @@ async function tvScreenshot(udid, scale, signal) {
160541
160856
  async function tvTargetLongSide(file2, scale) {
160542
160857
  let longSide = 3840;
160543
160858
  try {
160544
- const { stdout } = await execFileAsync34("sips", ["-g", "pixelWidth", "-g", "pixelHeight", file2]);
160859
+ const { stdout } = await execFileAsync35("sips", ["-g", "pixelWidth", "-g", "pixelHeight", file2]);
160545
160860
  const width = Number(/pixelWidth:\s*(\d+)/.exec(stdout)?.[1]);
160546
160861
  const height = Number(/pixelHeight:\s*(\d+)/.exec(stdout)?.[1]);
160547
160862
  if (Number.isFinite(width) && Number.isFinite(height) && width > 0 && height > 0) {
@@ -160576,7 +160891,7 @@ async function downscalePngInPlace(file2, scale, signal) {
160576
160891
  if (scale >= 1) {
160577
160892
  return;
160578
160893
  }
160579
- await execFileAsync34("sips", ["-Z", String(await tvTargetLongSide(file2, scale)), file2], {
160894
+ await execFileAsync35("sips", ["-Z", String(await tvTargetLongSide(file2, scale)), file2], {
160580
160895
  signal
160581
160896
  }).catch(() => {
160582
160897
  });
@@ -163090,13 +163405,13 @@ var shakeZodSchema = external_exports.object({
163090
163405
  });
163091
163406
 
163092
163407
  // ../tool-server/src/tools/shake/platforms/ios.ts
163093
- var import_node_child_process46 = require("node:child_process");
163094
- var import_node_util35 = require("node:util");
163408
+ var import_node_child_process47 = require("node:child_process");
163409
+ var import_node_util36 = require("node:util");
163095
163410
  init_src2();
163096
163411
  init_capability();
163097
163412
 
163098
163413
  // ../tool-server/src/utils/window-shake.ts
163099
- var import_node_child_process45 = require("node:child_process");
163414
+ var import_node_child_process46 = require("node:child_process");
163100
163415
  init_src();
163101
163416
  var MICROINTERACTIONS_FLAG = "microinteractions";
163102
163417
  var AMPLITUDE = 22;
@@ -163203,7 +163518,7 @@ end run
163203
163518
  }
163204
163519
  function runOsascript(script) {
163205
163520
  return new Promise((resolve21, reject) => {
163206
- const child = (0, import_node_child_process45.execFile)(
163521
+ const child = (0, import_node_child_process46.execFile)(
163207
163522
  "/usr/bin/osascript",
163208
163523
  ["-"],
163209
163524
  { timeout: OSASCRIPT_TIMEOUT_MS },
@@ -163296,7 +163611,7 @@ async function prepareHostWindowShake(target) {
163296
163611
  }
163297
163612
 
163298
163613
  // ../tool-server/src/tools/shake/platforms/ios.ts
163299
- var execFileAsync35 = (0, import_node_util35.promisify)(import_node_child_process46.execFile);
163614
+ var execFileAsync36 = (0, import_node_util36.promisify)(import_node_child_process47.execFile);
163300
163615
  var SHAKE_NOTIFICATION = "com.apple.UIKit.SimulatorShake";
163301
163616
  var SHAKE_INTERVAL_MS = 400;
163302
163617
  var sleep13 = (ms3) => new Promise((r) => setTimeout(r, ms3));
@@ -163338,7 +163653,7 @@ var iosImpl4 = {
163338
163653
  if (i > 0) await sleep13(SHAKE_INTERVAL_MS);
163339
163654
  shaker.begin();
163340
163655
  try {
163341
- await execFileAsync35("xcrun", args, { timeout: 15e3 });
163656
+ await execFileAsync36("xcrun", args, { timeout: 15e3 });
163342
163657
  } catch (err) {
163343
163658
  const error63 = err instanceof Error ? err : new Error(String(err));
163344
163659
  throw shakeFailure(udid, error63.message, error63);
@@ -164336,7 +164651,7 @@ function createTvRemoteTool(registry2) {
164336
164651
  id: "tv-remote",
164337
164652
  description: `Press a TV remote / D-pad button (or a whole path of them) on a TV device: Apple TV (tvOS), Android TV (leanback), or Vega (Fire TV).
164338
164653
  A TV is navigated with a directional remote, not touch. Use when you need to move focus or press a key on a TV, instead of gesture-tap/swipe (which do not apply on a TV).
164339
- Read the screen with \`describe\` before and after to see where focus landed.
164654
+ Call \`describe\` before the first press to find the cursor. Read where focus landed from the element tree in this result, or call \`describe\` again when it is missing.
164340
164655
  Returns { pressed, count }. Fails on a target that is not a TV, and on the Apple TV simulator for rewind, fastForward, next, previous, volumeUp, volumeDown and mute (its HID stack ignores them); every other button works on all three platforms.`,
164341
164656
  zodSchema: zodSchema29,
164342
164657
  searchHint: "tv remote dpad d-pad navigate focus up down left right select ok back home menu play pause rewind fast forward sequence path apple tv tvos android tv leanback vega fire tv",
@@ -164366,7 +164681,7 @@ init_device_info();
164366
164681
  init_capability();
164367
164682
 
164368
164683
  // ../tool-server/src/utils/sub-invoke.ts
164369
- var import_node_crypto17 = require("node:crypto");
164684
+ var import_node_crypto18 = require("node:crypto");
164370
164685
  init_src2();
164371
164686
  async function invokeSubTool(registry2, ctx, toolId, args, extra) {
164372
164687
  const signal = ctx?.signal;
@@ -164382,7 +164697,7 @@ async function invokeSubTool(registry2, ctx, toolId, args, extra) {
164382
164697
  if (!recordChildInvocation) {
164383
164698
  return signal || Object.keys(forwarded).length > 0 ? registry2.invokeTool(toolId, args, { ...signal ? { signal } : {}, ...forwarded }) : registry2.invokeTool(toolId, args);
164384
164699
  }
164385
- const toolInvocationId = (0, import_node_crypto17.randomUUID)();
164700
+ const toolInvocationId = (0, import_node_crypto18.randomUUID)();
164386
164701
  const release2 = recordChildInvocation(toolInvocationId, args);
164387
164702
  try {
164388
164703
  return await registry2.invokeTool(toolId, args, {
@@ -164565,7 +164880,7 @@ init_zod();
164565
164880
  var zodSchema31 = external_exports.object({
164566
164881
  port: metroPortField,
164567
164882
  device_id: external_exports.string().describe(
164568
- "Device id from list-devices: iOS simulator UDID, Android serial, Vega serial (amazon-...), <flag:macos-apps>Mac app id (macos-app-<bundle id>), </flag:macos-apps>or Chromium device id (chromium-cdp-<port>)."
164883
+ "Device id from list-devices: iOS simulator UDID, Android serial, Vega serial (amazon-...), <flag:macos-apps>Mac app id (macos-app-<bundle id>), </flag:macos-apps>or Chromium device id (chromium-cdp-<port>). Pass this SAME id as device_id to every subsequent debugger-* call to pin them to this device. The returned logicalDeviceId is informational (Metro's own per-connection handle, absent on Vega); you do not switch to it. Forwarding it still resolves here, but the list-devices id is the stable one. On a Metro shared by several devices, a simulator UDID or Android serial is matched by the device's name (a simulator's name; an Android model, release and API level); the app's device log must then confirm it runs there. When another booted simulator or attached device shares that name, or the log does not confirm it, the error asks for the logicalDeviceId instead."
164569
164884
  )
164570
164885
  });
164571
164886
  var debuggerConnectTool = {
@@ -167939,7 +168254,7 @@ function formatDescribeTree(root, opts) {
167939
168254
  var sleep16 = (ms3) => new Promise((r) => setTimeout(r, ms3));
167940
168255
  var EMPTY_RETRY_ATTEMPTS = 3;
167941
168256
  var EMPTY_RETRY_DELAY_MS = 600;
167942
- var EMPTY_HINT2 = "No focusable elements after retrying and recycling the read path. The app is most likely still launching (splash / loading screen) or mid-transition \u2014 this is normal right after launch-app / restart-app. Wait ~2-3s and call describe again; a React Native app only exposes focus once its JS bundle has loaded. If it stays empty, take a screenshot to confirm what's actually on screen.";
168257
+ var EMPTY_HINT2 = "No focusable elements after retrying and recycling the read path. Either the app is still loading or mid-transition (after launch-app / restart-app, or a press that opened an app), or the screen has nothing focusable (sleep, screensaver, video playback). Wait ~2-3s and call describe again; a React Native app only exposes focus once its JS bundle has loaded. If it stays empty, take a screenshot to confirm what's actually on screen.";
167943
168258
  var ANDROID_FOCUS_EMPTY_HINT = "The Android TV focus engine reported no focusable elements \u2014 common on react-native-tvos screens that drive focus with RN's own engine (invisible to the OS accessibility tree). Falling back to the full UI tree below. `tv-remote` (direction/select) still moves focus on these screens even though the labels aren't enumerable, so you can drive blind + screenshot to confirm.";
167944
168259
  function fmtElement(e) {
167945
168260
  const traits = e.traits?.length ? ` [${e.traits.join(",")}]` : "";
@@ -168092,13 +168407,13 @@ function createDescribeTool(registry2) {
168092
168407
  // Android's device probes plus the tree dump can outlast the 30s MCP fetch timeout.
168093
168408
  longRunning: true,
168094
168409
  description: `Get the accessibility / DOM element tree for the current screen.
168095
- 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.
168410
+ Use when you need element frames or labels and have no fresh tree: most interaction tools (not shake) already return one after each action, or name an identical earlier one by its tree id.
168096
168411
  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. On a local iOS simulator a text field shows its placeholder as its value, with no label, so an empty field reads like one holding that text. A text field with no accessibility label or identifier (e.g. the Settings search field) can also be missing from the tree, even with text typed in it. Check a screenshot in both cases.
168097
168412
  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 the visible part of its bounding rect; content scrolled or clipped out of view, or skipped by a closed \`<details>\` or \`content-visibility: hidden\`, has a zero-area frame.
168098
168413
  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>
168099
168414
  On HarmonyOS it runs the device's \`uitest dumpLayout\` (\`source: "harmony-uitest"\`); each top-level child is a window whose \`identifier\` (not its label) is the owning bundle, so an app plus the status bar reads as two windows. A suspended display still dumps its last frame, so the result then carries a \`hint\`, as it does for an empty dump.</flag:harmonyos><flag:macos-apps>
168100
168415
  On a Mac app it reads the app's accessibility tree with web view content and React Native testIDs merged in; frames are fractions of the app window, grown to include sheets and menus past it.</flag:macos-apps>
168101
- On a TV target (Apple TV / Android TV: a \`list-devices\` entry with runtimeKind 'tv') it returns the FOCUSED element and the FOCUSABLE elements instead, since a TV UI has no tap coordinates. Move the highlight with \`tv-remote\`, then call describe again to confirm where focus landed.
168416
+ On a TV target (Apple TV / Android TV: a \`list-devices\` entry with runtimeKind 'tv') it returns the FOCUSED element and the FOCUSABLE elements instead, since a TV UI has no tap coordinates. Move the highlight with \`tv-remote\`, then read where focus landed from the tree in its result, or call describe again when it is missing.
168102
168417
 
168103
168418
  Returns \`{ description, source }\`: \`description\` renders the tree one line per element, with its role, label/value/id, VoiceOver hint (iOS simulator), interactivity flags and frame. Frames are normalized [0,1] fractions of the screen / window width and height (not pixels); tap an element at the centre of its frame. The tree has no z-order or occlusion information: an element may be covered by an overlay (e.g. a toolbar over list rows), so check a screenshot when a tap lands unexpectedly.
168104
168419
  Fails if the tree cannot be read, e.g. on a physical iOS device before launch-app has started an app.
@@ -169243,6 +169558,7 @@ var capability30 = {
169243
169558
  appleRemote: { simulator: true },
169244
169559
  android: { emulator: true, device: true, unknown: true },
169245
169560
  chromium: { app: true },
169561
+ vega: { vvd: true },
169246
169562
  harmony: { device: true },
169247
169563
  macos: { app: true, catalyst: true }
169248
169564
  };
@@ -169252,7 +169568,7 @@ function treeSignature(root) {
169252
169568
  const walk = (node2) => {
169253
169569
  const f = node2.frame;
169254
169570
  parts2.push(
169255
- `${node2.role}|${node2.label ?? ""}|${node2.value ?? ""}|${round3(f.x)},${round3(f.y)},${round3(f.width)},${round3(f.height)}`
169571
+ `${node2.role}|${node2.label ?? ""}|${node2.value ?? ""}|${round3(f.x)},${round3(f.y)},${round3(f.width)},${round3(f.height)}|${node2.focused ? "F" : ""}${node2.selected ? "S" : ""}`
169256
169572
  );
169257
169573
  for (const child of node2.children) walk(child);
169258
169574
  };
@@ -169275,7 +169591,7 @@ function unsettledNote(lastData, lastError, darkTailMs) {
169275
169591
  }
169276
169592
  var zodSchema44 = external_exports.object({
169277
169593
  udid: external_exports.string().min(1).describe(
169278
- "Target device id from `list-devices` (iOS UDID, Android serial, <flag:harmonyos>HarmonyOS id, </flag:harmonyos><flag:macos-apps>Mac app id, </flag:macos-apps>or Chromium id)."
169594
+ "Target device id from `list-devices` (iOS UDID, Android serial, Vega serial, <flag:harmonyos>HarmonyOS id, </flag:harmonyos><flag:macos-apps>Mac app id, </flag:macos-apps>or Chromium id)."
169279
169595
  ),
169280
169596
  timeoutMs: external_exports.number().int().positive().max(12e4).optional().describe(
169281
169597
  `Max time to wait for the screen to settle before giving up (default ${DEFAULT_TIMEOUT_MS4}).`
@@ -169297,6 +169613,9 @@ function createAwaitScreenIdleTool(registry2) {
169297
169613
  if (device.platform === "android") {
169298
169614
  return describeAndroid(registry2, device.id, void 0, androidIsTv);
169299
169615
  }
169616
+ if (device.platform === "vega") {
169617
+ return describeVega(device.id);
169618
+ }
169300
169619
  if (device.platform === "harmony") {
169301
169620
  return pollHarmonyTree(harmonyConnectKey(device.id), budgetMs);
169302
169621
  }
@@ -169333,6 +169652,7 @@ Returns { settled, waitedMs, polls, note? }. If that is not seen before timeoutM
169333
169652
  if (device.platform === "ios") await ensureDeps(iosRequires);
169334
169653
  else if (device.platform === "ios-remote") await ensureDeps(["sim-remote"]);
169335
169654
  else if (device.platform === "android") await ensureDeps(androidRequires);
169655
+ else if (device.platform === "vega") await ensureDeps(vegaRequires);
169336
169656
  else if (device.platform === "harmony") await ensureDeps(harmonyRequires);
169337
169657
  const isTvOs = device.platform === "ios" && device.kind !== "device" && await isTvOsSimulator(device.id);
169338
169658
  const tvApi = isTvOs ? await resolveTvApi(registry2, device.id) : null;
@@ -169386,161 +169706,6 @@ Returns { settled, waitedMs, polls, note? }. If that is not seen before timeoutM
169386
169706
  var crypto6 = __toESM(require("node:crypto"));
169387
169707
  init_zod();
169388
169708
  init_src2();
169389
-
169390
- // ../tool-server/src/utils/debugger/runtime-device.ts
169391
- var import_node_crypto18 = require("node:crypto");
169392
- var import_node_child_process47 = require("node:child_process");
169393
- var import_node_util36 = require("node:util");
169394
- init_adb();
169395
- var execFileAsync36 = (0, import_node_util36.promisify)(import_node_child_process47.execFile);
169396
- var LOG_READ_TIMEOUT_MS = 5e3;
169397
- var RETRY_DELAY_MS = 300;
169398
- var OTHER_TRANSPORTS_GRACE_MS = 500;
169399
- var NOT_FOUND = { found: [], unresolved: [] };
169400
- async function findRuntimeDevices(cdp, {
169401
- awaitSerials = [],
169402
- waitSerials = []
169403
- } = {}) {
169404
- const marker = `argent-device-probe:${(0, import_node_crypto18.randomUUID)()}`;
169405
- const logged = await cdp.evaluate(
169406
- `(function () {
169407
- if (typeof nativeLoggingHook !== "function") return false;
169408
- nativeLoggingHook(${JSON.stringify(marker)}, 1);
169409
- return true;
169410
- })()`
169411
- ).catch(() => false);
169412
- if (logged !== true) return NOT_FOUND;
169413
- const checks = [
169414
- async () => androidDevices(await androidSerials(), marker, awaitSerials, waitSerials),
169415
- async () => {
169416
- const udids = await bootedSimulators();
169417
- const udid = await firstFound(udids.map((udid2) => () => simulatorLogHolds(udid2, marker)));
169418
- return udid === void 0 ? void 0 : { found: [udid], unresolved: [] };
169419
- }
169420
- ];
169421
- for (let attempt = 0; attempt < 2; attempt++) {
169422
- if (attempt > 0) await new Promise((r) => setTimeout(r, RETRY_DELAY_MS));
169423
- const found = await firstFound(checks);
169424
- if (found !== void 0) return found;
169425
- }
169426
- return NOT_FOUND;
169427
- }
169428
- function firstFound(checks) {
169429
- return new Promise((resolve21) => {
169430
- let left = checks.length;
169431
- if (left === 0) resolve21(void 0);
169432
- for (const check3 of checks) {
169433
- void check3().then((value) => {
169434
- if (value !== void 0) resolve21(value);
169435
- else if (--left === 0) resolve21(void 0);
169436
- });
169437
- }
169438
- });
169439
- }
169440
- async function androidDevices(serials, marker, awaitSerials, waitSerials) {
169441
- const listed = [...new Set(serials)];
169442
- const awaited = listed.filter(
169443
- (serial) => awaitSerials.includes(serial) || waitSerials.includes(serial)
169444
- );
169445
- const answers = /* @__PURE__ */ new Map();
169446
- await new Promise((resolve21) => {
169447
- let graceOver = false;
169448
- let grace;
169449
- const settle3 = () => {
169450
- const held = heldSerials(answers);
169451
- const waitingOn = listed.filter(
169452
- (serial) => !answers.has(serial) && (!graceOver || awaited.includes(serial)) && !held.some((found2) => anotherDevice(serial, found2))
169453
- );
169454
- if (waitingOn.length === 0) {
169455
- clearTimeout(grace);
169456
- resolve21();
169457
- }
169458
- };
169459
- settle3();
169460
- for (const serial of listed) {
169461
- void logcatHolds(serial, marker).then((read) => {
169462
- answers.set(serial, read);
169463
- if (read === "held") {
169464
- grace ??= setTimeout(() => {
169465
- graceOver = true;
169466
- settle3();
169467
- }, OTHER_TRANSPORTS_GRACE_MS);
169468
- }
169469
- settle3();
169470
- });
169471
- }
169472
- });
169473
- const found = heldSerials(answers);
169474
- if (found.length === 0) return void 0;
169475
- const unresolved = [...new Set(awaitSerials)].filter(
169476
- (serial) => (!listed.includes(serial) || answers.get(serial) === "failed") && !found.some((device) => anotherDevice(serial, device))
169477
- );
169478
- return { found, unresolved };
169479
- }
169480
- function heldSerials(answers) {
169481
- return [...answers].filter(([, read]) => read === "held").map(([serial]) => serial);
169482
- }
169483
- function anotherDevice(a, b) {
169484
- if (a === b) return false;
169485
- const portA = consolePortFromAdbSerial(a);
169486
- const portB = consolePortFromAdbSerial(b);
169487
- if (portA !== null && portB !== null) return portA !== portB;
169488
- if (isUsbSerial(a) && isUsbSerial(b)) return true;
169489
- return portA !== null && isUsbSerial(b) || portB !== null && isUsbSerial(a);
169490
- }
169491
- function isUsbSerial(serial) {
169492
- return !serial.startsWith("emulator-") && !serial.includes(":") && !serial.includes("._");
169493
- }
169494
- async function androidSerials() {
169495
- try {
169496
- const { stdout } = await runAdb(["devices"], { timeoutMs: ADB_DEVICES_TIMEOUT_MS });
169497
- return parseAdbDevices(stdout).filter((d) => d.state === "device").map((d) => d.serial);
169498
- } catch {
169499
- return [];
169500
- }
169501
- }
169502
- async function bootedSimulators() {
169503
- const simulators = await listIosSimulators().catch(() => []);
169504
- return simulators.filter((s) => s.state === "Booted").map((s) => s.udid);
169505
- }
169506
- async function logcatHolds(serial, marker) {
169507
- try {
169508
- const { stdout } = await runAdb(
169509
- ["-s", serial, "logcat", "-d", "-s", "ReactNativeJS", "-e", marker],
169510
- { timeoutMs: LOG_READ_TIMEOUT_MS }
169511
- );
169512
- return stdout.includes(marker) ? "held" : "absent";
169513
- } catch {
169514
- return "failed";
169515
- }
169516
- }
169517
- async function simulatorLogHolds(udid, marker) {
169518
- try {
169519
- const args = await simctlArgsForUdid(udid, [
169520
- "spawn",
169521
- udid,
169522
- "log",
169523
- "show",
169524
- "--info",
169525
- "--last",
169526
- "1m",
169527
- "--style",
169528
- "compact",
169529
- "--predicate",
169530
- `eventMessage CONTAINS ${JSON.stringify(marker)} AND process != "log"`
169531
- ]);
169532
- const { stdout } = await execFileAsync36("xcrun", args, {
169533
- timeout: LOG_READ_TIMEOUT_MS,
169534
- killSignal: SIMCTL_KILL_SIGNAL,
169535
- encoding: "utf-8"
169536
- });
169537
- return stdout.includes(marker) ? udid : void 0;
169538
- } catch {
169539
- return void 0;
169540
- }
169541
- }
169542
-
169543
- // ../tool-server/src/tools/profiler/react/react-profiler-start.ts
169544
169709
  init_external_devices();
169545
169710
 
169546
169711
  // ../tool-server/src/utils/react-profiler/devtools-bootstrap.ts
@@ -184318,7 +184483,7 @@ function createStopAllSimulatorServersTool(registry2) {
184318
184483
  id: "stop-all-simulator-servers",
184319
184484
  description: `Stop the services a device owns - simulator-server processes (iOS + Android), native devtools, the iOS accessibility service, TV-control daemons, Chromium CDP sessions, screen recordings, native profiler sessions, native network capture with the requests it recorded, and JS-runtime debugger sessions along with the network inspectors and React profiler sessions that ride on them - freeing their spawned processes, sockets and ports. Network capture started by network-capture-start ends here too, with the requests it recorded, except in a JS runtime this call does not reach, for example after Metro restarted: this call does not connect to it again, so its JS capture keeps recording and keeps its requests, and the result does not say so. A later network-capture-stop that reaches that runtime stops the recording. Call this when the user asks to clean up or ends the session, or when a skill tells you to recycle a device's services mid-flow - not just because a task finished, since the next task reuses these services and would start cold again. To stop the network capture of one app and keep its requests, call network-capture-stop instead.
184320
184485
  PASS \`devices\` with the device ids this session used: one tool-server serves every agent, subagent and CLI call using this argent install, and an unscoped call tears down THEIR devices too. Omit \`devices\` only when a machine-wide cleanup is what you actually want. An EMPTY array stops nothing; it does not ask for the machine-wide sweep.
184321
- A JS-runtime debugger session is keyed by the id you called \`debugger-connect\` with. On a Metro serving two or more devices that id can be a \`logicalDeviceId\`: connect refuses a serial, or a simulator udid it cannot match to one Metro device by name, and tells you to re-target with the \`logicalDeviceId\` it returns. A scope built from \`list-devices\` ids cannot reach that session. Pass any such \`logicalDeviceId\` in \`devices\` ALONGSIDE the device id.
184486
+ A JS-runtime debugger session is keyed by the id you called \`debugger-connect\` with. On a Metro serving two or more devices that id can be a \`logicalDeviceId\`: connect refuses a udid or serial it cannot match to one Metro device by name, and tells you to re-target with the \`logicalDeviceId\` it returns. A scope built from \`list-devices\` ids cannot reach that session. Pass any such \`logicalDeviceId\` in \`devices\` ALONGSIDE the device id.
184322
184487
  Returns { stopped }: the URNs of the live services that were shut down; empty means nothing was still running. { unmatched }, present only when a supplied id owns no service here, lists those ids, so a typo or a device NAME passed instead of an id does not read as a clean machine. It is NOT proof the id is wrong: a Vega device you only booted and drove with the remote registers no service and lands here, as does any device this session never started anything on. { left_running } lists the URNs of live debugger sessions (and the network inspectors / React profiler sessions riding on them) whose id no device scope can name; re-call with the id after each URN's \`<namespace>:<port>:\` prefix to reap them. { aborted: true } means the request was cancelled part-way: the rest was left untouched and \`unmatched\` / \`left_running\` were not computed.
184323
184488
  Fails if the input has an unknown key (e.g. \`udids\` instead of \`devices\`); otherwise it always succeeds, and reaping nothing is a result, not a failure.`,
184324
184489
  zodSchema: zodSchema66,