@swmansion/argent 0.34.1-next.16 → 0.34.1-next.18

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.
Binary file
Binary file
Binary file
Binary file
Binary file
package/dist/cli-cmds.mjs CHANGED
@@ -10782,6 +10782,8 @@ var FAILURE_CODES = {
10782
10782
  MACOS_APP_BUNDLE_ID_MISMATCH: "MACOS_APP_BUNDLE_ID_MISMATCH",
10783
10783
  MACOS_APP_OPEN_URL_FAILED: "MACOS_APP_OPEN_URL_FAILED",
10784
10784
  MACOS_APP_FILE_ACCESS_FAILED: "MACOS_APP_FILE_ACCESS_FAILED",
10785
+ /** The app's loaded Argent library lacks support for the requested operation. */
10786
+ MACOS_APP_LIBRARY_OUTDATED: "MACOS_APP_LIBRARY_OUTDATED",
10785
10787
  KEYBOARD_KEY_UNSUPPORTED: "KEYBOARD_KEY_UNSUPPORTED",
10786
10788
  KEYBOARD_CHARACTER_UNSUPPORTED: "KEYBOARD_CHARACTER_UNSUPPORTED",
10787
10789
  KEYBOARD_TEXT_AND_KEY_COMBINED: "KEYBOARD_TEXT_AND_KEY_COMBINED",
@@ -36080,7 +36082,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
36080
36082
  var SESSION_ID2 = randomUUID5();
36081
36083
  function readCliVersion() {
36082
36084
  if (true) {
36083
- return "0.34.1-next.15";
36085
+ return "0.34.1-next.18";
36084
36086
  }
36085
36087
  return "0.0.0";
36086
36088
  }
package/dist/client.js CHANGED
@@ -9355,6 +9355,8 @@ var FAILURE_CODES = {
9355
9355
  MACOS_APP_BUNDLE_ID_MISMATCH: "MACOS_APP_BUNDLE_ID_MISMATCH",
9356
9356
  MACOS_APP_OPEN_URL_FAILED: "MACOS_APP_OPEN_URL_FAILED",
9357
9357
  MACOS_APP_FILE_ACCESS_FAILED: "MACOS_APP_FILE_ACCESS_FAILED",
9358
+ /** The app's loaded Argent library lacks support for the requested operation. */
9359
+ MACOS_APP_LIBRARY_OUTDATED: "MACOS_APP_LIBRARY_OUTDATED",
9358
9360
  KEYBOARD_KEY_UNSUPPORTED: "KEYBOARD_KEY_UNSUPPORTED",
9359
9361
  KEYBOARD_CHARACTER_UNSUPPORTED: "KEYBOARD_CHARACTER_UNSUPPORTED",
9360
9362
  KEYBOARD_TEXT_AND_KEY_COMBINED: "KEYBOARD_TEXT_AND_KEY_COMBINED",
@@ -16005,6 +16005,8 @@ var FAILURE_CODES = {
16005
16005
  MACOS_APP_BUNDLE_ID_MISMATCH: "MACOS_APP_BUNDLE_ID_MISMATCH",
16006
16006
  MACOS_APP_OPEN_URL_FAILED: "MACOS_APP_OPEN_URL_FAILED",
16007
16007
  MACOS_APP_FILE_ACCESS_FAILED: "MACOS_APP_FILE_ACCESS_FAILED",
16008
+ /** The app's loaded Argent library lacks support for the requested operation. */
16009
+ MACOS_APP_LIBRARY_OUTDATED: "MACOS_APP_LIBRARY_OUTDATED",
16008
16010
  KEYBOARD_KEY_UNSUPPORTED: "KEYBOARD_KEY_UNSUPPORTED",
16009
16011
  KEYBOARD_CHARACTER_UNSUPPORTED: "KEYBOARD_CHARACTER_UNSUPPORTED",
16010
16012
  KEYBOARD_TEXT_AND_KEY_COMBINED: "KEYBOARD_TEXT_AND_KEY_COMBINED",
@@ -16879,7 +16881,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
16879
16881
  var SESSION_ID = randomUUID4();
16880
16882
  function readCliVersion() {
16881
16883
  if (true) {
16882
- return "0.34.1-next.15";
16884
+ return "0.34.1-next.18";
16883
16885
  }
16884
16886
  return "0.0.0";
16885
16887
  }
@@ -26065,6 +26065,8 @@ var FAILURE_CODES = {
26065
26065
  MACOS_APP_BUNDLE_ID_MISMATCH: "MACOS_APP_BUNDLE_ID_MISMATCH",
26066
26066
  MACOS_APP_OPEN_URL_FAILED: "MACOS_APP_OPEN_URL_FAILED",
26067
26067
  MACOS_APP_FILE_ACCESS_FAILED: "MACOS_APP_FILE_ACCESS_FAILED",
26068
+ /** The app's loaded Argent library lacks support for the requested operation. */
26069
+ MACOS_APP_LIBRARY_OUTDATED: "MACOS_APP_LIBRARY_OUTDATED",
26068
26070
  KEYBOARD_KEY_UNSUPPORTED: "KEYBOARD_KEY_UNSUPPORTED",
26069
26071
  KEYBOARD_CHARACTER_UNSUPPORTED: "KEYBOARD_CHARACTER_UNSUPPORTED",
26070
26072
  KEYBOARD_TEXT_AND_KEY_COMBINED: "KEYBOARD_TEXT_AND_KEY_COMBINED",
@@ -439,6 +439,8 @@ export interface ArgentToolArgs {
439
439
  clickCount?: number;
440
440
  /** Mouse button, Mac app only: "right" is a right-click, for example to open a context menu; any other device refuses it. Default "left". */
441
441
  button?: "left" | "right";
442
+ /** Keys held throughout a click or multi-click gesture. Mac apps only. An empty list leaves the click unmodified. */
443
+ modifiers?: Array<"control" | "option" | "shift" | "command">;
442
444
  };
443
445
  keyboard: {
444
446
  /** Target device id from `list-devices` (iOS UDID, Android serial, Vega serial, HarmonyOS id, Mac app id, or Chromium id). */
@@ -1825,6 +1825,8 @@ var init_failure_codes = __esm({
1825
1825
  MACOS_APP_BUNDLE_ID_MISMATCH: "MACOS_APP_BUNDLE_ID_MISMATCH",
1826
1826
  MACOS_APP_OPEN_URL_FAILED: "MACOS_APP_OPEN_URL_FAILED",
1827
1827
  MACOS_APP_FILE_ACCESS_FAILED: "MACOS_APP_FILE_ACCESS_FAILED",
1828
+ /** The app's loaded Argent library lacks support for the requested operation. */
1829
+ MACOS_APP_LIBRARY_OUTDATED: "MACOS_APP_LIBRARY_OUTDATED",
1828
1830
  KEYBOARD_KEY_UNSUPPORTED: "KEYBOARD_KEY_UNSUPPORTED",
1829
1831
  KEYBOARD_CHARACTER_UNSUPPORTED: "KEYBOARD_CHARACTER_UNSUPPORTED",
1830
1832
  KEYBOARD_TEXT_AND_KEY_COMBINED: "KEYBOARD_TEXT_AND_KEY_COMBINED",
@@ -101343,7 +101345,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
101343
101345
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
101344
101346
  function readCliVersion() {
101345
101347
  if (true) {
101346
- return "0.34.1-next.15";
101348
+ return "0.34.1-next.18";
101347
101349
  }
101348
101350
  return "0.0.0";
101349
101351
  }
@@ -125013,8 +125015,6 @@ function execSimctl(args, options = {}) {
125013
125015
  let stdout = "";
125014
125016
  let stderr = "";
125015
125017
  let settled = false;
125016
- child.stdout.setEncoding("utf8").on("data", (chunk) => stdout += chunk);
125017
- child.stderr.setEncoding("utf8").on("data", (chunk) => stderr += chunk);
125018
125018
  const settle3 = (err) => {
125019
125019
  if (settled) return;
125020
125020
  settled = true;
@@ -125036,6 +125036,8 @@ function execSimctl(args, options = {}) {
125036
125036
  }, timeoutMs);
125037
125037
  options.signal?.addEventListener("abort", onAbort, { once: true });
125038
125038
  child.on("error", (err) => settle3(err));
125039
+ child.stdout?.setEncoding("utf8").on("data", (chunk) => stdout += chunk);
125040
+ child.stderr?.setEncoding("utf8").on("data", (chunk) => stderr += chunk);
125039
125041
  child.on("close", (code, sig) => {
125040
125042
  if (code === 0) return settle3(null);
125041
125043
  settle3(
@@ -125394,22 +125396,39 @@ async function spawnSimulatorServerProcess(udid, subcommand) {
125394
125396
  let settled = false;
125395
125397
  const STREAM_GRACE_MS = 500;
125396
125398
  let apiReadyTimer = null;
125397
- const rl = readline.createInterface({ input: proc.stdout });
125398
125399
  const settle3 = (fn, cleanup) => {
125399
125400
  if (settled) return;
125400
125401
  settled = true;
125401
125402
  clearTimeout(timer);
125402
125403
  if (apiReadyTimer) clearTimeout(apiReadyTimer);
125403
- rl.close();
125404
+ rl?.close();
125404
125405
  cleanup?.();
125405
125406
  fn();
125406
125407
  };
125408
+ proc.on("error", (err) => {
125409
+ settle3(
125410
+ () => reject(
125411
+ new FailureError(
125412
+ err instanceof Error ? err.message : String(err),
125413
+ {
125414
+ error_code: FAILURE_CODES.SIMULATOR_SERVER_PROCESS_ERROR,
125415
+ failure_stage: "simulator_server_spawn_process",
125416
+ failure_area: "tool_server",
125417
+ error_kind: "subprocess",
125418
+ ...subprocessFailureMetadata(err, "simulator_server")
125419
+ },
125420
+ { cause: err instanceof Error ? err : new Error(String(err)) }
125421
+ )
125422
+ )
125423
+ );
125424
+ });
125425
+ const rl = proc.stdout ? readline.createInterface({ input: proc.stdout }) : null;
125407
125426
  let exited = false;
125408
125427
  const resolveWhenReady = () => {
125409
125428
  if (apiUrl == null || exited) return;
125410
125429
  settle3(() => resolve19({ proc, apiUrl, streamUrl }));
125411
125430
  };
125412
- rl.on("line", (rawLine) => {
125431
+ rl?.on("line", (rawLine) => {
125413
125432
  const line = rawLine.trim();
125414
125433
  if (line.startsWith("stream_ready ")) {
125415
125434
  const match = line.match(/(http:\/\/[^ ]+)/);
@@ -125470,23 +125489,6 @@ async function spawnSimulatorServerProcess(udid, subcommand) {
125470
125489
  fail();
125471
125490
  });
125472
125491
  });
125473
- proc.on("error", (err) => {
125474
- settle3(
125475
- () => reject(
125476
- new FailureError(
125477
- err instanceof Error ? err.message : String(err),
125478
- {
125479
- error_code: FAILURE_CODES.SIMULATOR_SERVER_PROCESS_ERROR,
125480
- failure_stage: "simulator_server_spawn_process",
125481
- failure_area: "tool_server",
125482
- error_kind: "subprocess",
125483
- ...subprocessFailureMetadata(err, "simulator_server")
125484
- },
125485
- { cause: err instanceof Error ? err : new Error(String(err)) }
125486
- )
125487
- )
125488
- );
125489
- });
125490
125492
  const timer = setTimeout(() => {
125491
125493
  settle3(
125492
125494
  () => reject(
@@ -131658,12 +131660,29 @@ async function spawnHelper(serial) {
131658
131660
  settled = true;
131659
131661
  clearTimeout(timer);
131660
131662
  clearTimeout(exitGrace);
131661
- rl.close();
131663
+ rl?.close();
131662
131664
  cleanup?.();
131663
131665
  fn();
131664
131666
  };
131665
- const rl = readline2.createInterface({ input: proc.stdout });
131666
- rl.on("line", async (rawLine) => {
131667
+ proc.on("error", (err) => {
131668
+ settle3(
131669
+ () => reject(
131670
+ new FailureError(
131671
+ "android-devtools helper process error.",
131672
+ {
131673
+ error_code: FAILURE_CODES.ANDROID_DEVTOOLS_HELPER_PROCESS_ERROR,
131674
+ failure_stage: "android_devtools_helper_process",
131675
+ failure_area: "tool_server",
131676
+ error_kind: "subprocess",
131677
+ ...subprocessFailureMetadata(err, "android_devtools")
131678
+ },
131679
+ { cause: err }
131680
+ )
131681
+ )
131682
+ );
131683
+ });
131684
+ const rl = proc.stdout ? readline2.createInterface({ input: proc.stdout }) : null;
131685
+ rl?.on("line", async (rawLine) => {
131667
131686
  const line = rawLine.trim();
131668
131687
  if (statusBuf.length < HELPER_STATUS_MAX_CHARS && HELPER_STATUS_MARKER.test(line)) {
131669
131688
  statusBuf = (statusBuf ? `${statusBuf} ${line}` : line).slice(0, HELPER_STATUS_MAX_CHARS);
@@ -131721,23 +131740,6 @@ async function spawnHelper(serial) {
131721
131740
  exitGrace = setTimeout(() => settle3(rejectExited), EXIT_GRACE_MS);
131722
131741
  });
131723
131742
  proc.on("close", () => settle3(rejectExited));
131724
- proc.on("error", (err) => {
131725
- settle3(
131726
- () => reject(
131727
- new FailureError(
131728
- "android-devtools helper process error.",
131729
- {
131730
- error_code: FAILURE_CODES.ANDROID_DEVTOOLS_HELPER_PROCESS_ERROR,
131731
- failure_stage: "android_devtools_helper_process",
131732
- failure_area: "tool_server",
131733
- error_kind: "subprocess",
131734
- ...subprocessFailureMetadata(err, "android_devtools")
131735
- },
131736
- { cause: err }
131737
- )
131738
- )
131739
- );
131740
- });
131741
131743
  const timer = setTimeout(() => {
131742
131744
  settle3(
131743
131745
  () => reject(
@@ -132675,6 +132677,7 @@ function streamDirectoryAsArchive(id, entry, req, res) {
132675
132677
  res.destroy();
132676
132678
  }
132677
132679
  });
132680
+ if (!child.stdout) return;
132678
132681
  const compressor = createCompressor(format);
132679
132682
  res.on("close", () => {
132680
132683
  if (res.writableFinished) return;
@@ -141706,9 +141709,6 @@ async function startSuspensionWatch(helperPath, pid) {
141706
141709
  let ended = false;
141707
141710
  let waiters = [];
141708
141711
  let stderr = "";
141709
- child.stderr.on("data", (d) => {
141710
- if (stderr.length < 2e3) stderr += d.toString("utf8");
141711
- });
141712
141712
  const close = (atMs) => {
141713
141713
  if (since !== null) windows.push({ startMs: since, endMs: Math.max(since, atMs) });
141714
141714
  since = null;
@@ -141718,7 +141718,15 @@ async function startSuspensionWatch(helperPath, pid) {
141718
141718
  };
141719
141719
  let reported;
141720
141720
  const firstState = new Promise((resolve19) => reported = resolve19);
141721
- readline3.createInterface({ input: child.stdout }).on("line", (line) => {
141721
+ child.on("error", (err) => {
141722
+ stderr ||= err.message;
141723
+ reported(false);
141724
+ });
141725
+ child.stderr?.on("data", (d) => {
141726
+ if (stderr.length < 2e3) stderr += d.toString("utf8");
141727
+ });
141728
+ const rl = child.stdout ? readline3.createInterface({ input: child.stdout }) : null;
141729
+ rl?.on("line", (line) => {
141722
141730
  let event2;
141723
141731
  try {
141724
141732
  event2 = JSON.parse(line);
@@ -141731,10 +141739,6 @@ async function startSuspensionWatch(helperPath, pid) {
141731
141739
  if (event2.suspended && since === null) since = event2.at;
141732
141740
  else if (!event2.suspended) close(event2.at);
141733
141741
  });
141734
- child.on("error", (err) => {
141735
- stderr ||= err.message;
141736
- reported(false);
141737
- });
141738
141742
  child.on("exit", () => {
141739
141743
  reported(false);
141740
141744
  if (!ended) close(Date.now());
@@ -142094,14 +142098,16 @@ function macosLaunchEnv(bundleId, listenSocketEnv, extra = {}) {
142094
142098
  if (listenSocketEnv) env.NATIVE_DEVTOOLS_LISTEN_SOCKET = listenSocketEnv;
142095
142099
  return env;
142096
142100
  }
142097
- async function helperPid(child, executable) {
142098
- const failed3 = (detail, cause) => macosFailure(
142101
+ function helperLaunchFailure(executable, detail, cause) {
142102
+ return macosFailure(
142099
142103
  `argent-macos-helper could not start ${executable}: ${detail}`,
142100
142104
  FAILURE_CODES.MACOS_APP_SPAWN_FAILED,
142101
142105
  "macos_app_helper_launch",
142102
142106
  "subprocess",
142103
142107
  cause
142104
142108
  );
142109
+ }
142110
+ async function helperPid(child, executable) {
142105
142111
  let stdout = "";
142106
142112
  let stderr = "";
142107
142113
  child.stdout.setEncoding("utf8").on("data", (chunk) => stdout += chunk);
@@ -142120,12 +142126,16 @@ async function helperPid(child, executable) {
142120
142126
  (0, import_node_events4.once)(child.stderr, "close")
142121
142127
  ]);
142122
142128
  } catch (err) {
142123
- throw failed3(errorMessage2(err), err);
142129
+ throw helperLaunchFailure(executable, errorMessage2(err), err);
142124
142130
  } finally {
142125
142131
  clearTimeout(timer);
142126
142132
  }
142127
- if (timedOut3) throw failed3(`no answer within ${HELPER_TIMEOUT_MS} ms`);
142128
- if (code !== 0) throw failed3(stderr.trim() || (signal ? `killed by ${signal}` : `exit ${code}`));
142133
+ if (timedOut3) throw helperLaunchFailure(executable, `no answer within ${HELPER_TIMEOUT_MS} ms`);
142134
+ if (code !== 0)
142135
+ throw helperLaunchFailure(
142136
+ executable,
142137
+ stderr.trim() || (signal ? `killed by ${signal}` : `exit ${code}`)
142138
+ );
142129
142139
  const line = stdout.split("\n").find((l) => l.trim().startsWith("{"));
142130
142140
  let pid;
142131
142141
  try {
@@ -142133,7 +142143,7 @@ async function helperPid(child, executable) {
142133
142143
  } catch {
142134
142144
  }
142135
142145
  if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0) {
142136
- throw failed3(`unexpected output ${JSON.stringify(stdout.trim())}`);
142146
+ throw helperLaunchFailure(executable, `unexpected output ${JSON.stringify(stdout.trim())}`);
142137
142147
  }
142138
142148
  return pid;
142139
142149
  }
@@ -142486,6 +142496,11 @@ function createMacosAppApi(bundleId) {
142486
142496
  cwd: "/"
142487
142497
  }
142488
142498
  );
142499
+ try {
142500
+ await (0, import_node_events4.once)(helper, "spawn");
142501
+ } catch (err) {
142502
+ throw helperLaunchFailure(info.executable, errorMessage2(err), err);
142503
+ }
142489
142504
  const ch = new LibraryChannel(
142490
142505
  helper.stdio[3],
142491
142506
  bundleId,
@@ -142890,9 +142905,21 @@ async function macosMouse(app, event2) {
142890
142905
  );
142891
142906
  }
142892
142907
  async function macosClick(app, x, y, opts = {}) {
142893
- await macosMouse(app, { type: "move", x, y });
142908
+ const modifiers = opts.modifiers?.length ? [...new Set(opts.modifiers)] : void 0;
142909
+ const moved = await app.call(
142910
+ "Input.mouse",
142911
+ insideMaxEdges({ type: "move", x, y, modifiers })
142912
+ );
142913
+ if (modifiers && !Array.isArray(moved?.modifiers)) {
142914
+ throw macosFailure(
142915
+ `The argent library running in ${app.bundleId} is older than this argent and cannot hold modifier keys, so nothing was clicked. Restart the app with restart-app to load the current library, then tap again.`,
142916
+ FAILURE_CODES.MACOS_APP_LIBRARY_OUTDATED,
142917
+ "macos_click_modifiers",
142918
+ "unsupported"
142919
+ );
142920
+ }
142894
142921
  for (let i = 1; i <= (opts.clickCount ?? 1); i++) {
142895
- const event2 = { x, y, button: opts.button, clickCount: i };
142922
+ const event2 = { x, y, button: opts.button, clickCount: i, modifiers };
142896
142923
  await macosMouse(app, { ...event2, type: "down" });
142897
142924
  await macosMouse(app, { ...event2, type: "up" });
142898
142925
  }
@@ -155598,12 +155625,18 @@ async function assertChromiumWindowVisible(chromium, action) {
155598
155625
  // ../tool-server/src/tools/gesture-tap/index.ts
155599
155626
  init_device_info();
155600
155627
  init_capability();
155628
+
155629
+ // ../tool-server/src/utils/macos-modifiers.ts
155630
+ var MACOS_MODIFIERS = ["control", "option", "shift", "command"];
155631
+
155632
+ // ../tool-server/src/tools/gesture-tap/index.ts
155601
155633
  var sleep4 = (ms) => new Promise((r) => setTimeout(r, ms));
155602
155634
  function tapDescription(params, tense) {
155603
155635
  const count2 = params.clickCount ?? 1;
155604
155636
  const action = count2 === 1 ? tense === "present" ? "Tapping" : "Tapped" : count2 === 2 ? tense === "present" ? "Double-tapping" : "Double-tapped" : `${tense === "present" ? "Tapping" : "Tapped"} ${count2} times`;
155605
155637
  const button = params.button === "right" ? " with the right button" : "";
155606
- return `${action} at (${Math.round(params.x * 100)}%, ${Math.round(params.y * 100)}%)${button}`;
155638
+ const modifiers = params.modifiers?.length ? ` holding ${[...new Set(params.modifiers)].join("+")}` : "";
155639
+ return `${action} at (${Math.round(params.x * 100)}%, ${Math.round(params.y * 100)}%)${button}${modifiers}`;
155607
155640
  }
155608
155641
  var capability10 = {
155609
155642
  apple: { simulator: true, device: true },
@@ -155667,11 +155700,15 @@ var zodSchema18 = external_exports.object({
155667
155700
  ),
155668
155701
  button: external_exports.enum(["left", "right"]).optional().describe(
155669
155702
  'Mouse button, Mac app only: "right" is a right-click, for example to open a context menu; any other device refuses it. Default "left".'
155703
+ ).meta({ [FLAG_META_KEY]: MACOS_APPS_FLAG }),
155704
+ modifiers: external_exports.array(external_exports.enum(MACOS_MODIFIERS)).max(MACOS_MODIFIERS.length).optional().describe(
155705
+ "Keys held throughout a click or multi-click gesture. Mac apps only. An empty list leaves the click unmodified."
155670
155706
  ).meta({ [FLAG_META_KEY]: MACOS_APPS_FLAG })
155671
155707
  });
155672
155708
  var gestureTapTool = {
155673
155709
  id: "gesture-tap",
155674
- description: `Press the device screen (iOS simulator or physical device, Android emulator, <flag:harmonyos>HarmonyOS device, </flag:harmonyos><flag:macos-apps>Mac app, </flag:macos-apps>or Chromium app) at a point given as fractions of the screen width and height (not pixels): a Down event followed by an Up event at the same spot.<flag:macos-apps> On a Mac app it is a click, and x/y are fractions of the area describe reports, not of the window.</flag:macos-apps>
155710
+ description: `Press the device screen (iOS simulator or physical device, Android emulator, <flag:harmonyos>HarmonyOS device, </flag:harmonyos><flag:macos-apps>Mac app, </flag:macos-apps>or Chromium app) at a point given as fractions of the screen width and height (not pixels): a Down event followed by an Up event at the same spot.<flag:macos-apps> On a Mac app it is a click, and x/y are fractions of the area describe reports, not of the window.
155711
+ If a modifier click returns \`MACOS_APP_LIBRARY_OUTDATED\`, the tool stopped before clicking. Run \`restart-app\` to reload the library, then retry. If the error persists, use an Argent build with modifier-click support.</flag:macos-apps>
155675
155712
  Use when tapping a button, link, or any tappable element on the screen.
155676
155713
  Returns { tapped: true, timestampMs }. On physical iOS, reactivated: true = app was re-fronted; re-describe. Fails if the device backend (simulator-server / emulator / Chromium CDP<flag:harmonyos> / \`hdc\`</flag:harmonyos>) is unreachable.
155677
155714
  Before tapping, take the coordinates from \`describe\` on every platform (on Chromium it walks the DOM<flag:harmonyos>, on HarmonyOS it reads the \`uitest\` layout dump</flag:harmonyos>). More information in \`argent-device-interact\` skill`,
@@ -155680,7 +155717,7 @@ Before tapping, take the coordinates from \`describe\` on every platform (on Chr
155680
155717
  // A physical iPhone's first call waits out the runner build, past the MCP fetch timeout,
155681
155718
  // whose abort replays the call: the gesture would land once per replay.
155682
155719
  longRunning: true,
155683
- searchHint: "tap press button element device simulator emulator chromium<flag:macos-apps> mac</flag:macos-apps> touch down up click<flag:macos-apps> right-click context menu</flag:macos-apps>",
155720
+ searchHint: "tap press button element device simulator emulator chromium<flag:macos-apps> mac</flag:macos-apps> touch down up click<flag:macos-apps> right-click context menu modifier command shift option control cmd-click shift-click multiple selection</flag:macos-apps>",
155684
155721
  interaction: {
155685
155722
  startedMsg: ({ params }) => tapDescription(params, "present"),
155686
155723
  completedMsg: ({ params }) => tapDescription(params, "past"),
@@ -155692,7 +155729,7 @@ Before tapping, take the coordinates from \`describe\` on every platform (on Chr
155692
155729
  if (device.platform === "macos") {
155693
155730
  return macosAppServices(device);
155694
155731
  }
155695
- if (params.button === "right") return {};
155732
+ if (params.button === "right" || params.modifiers?.length) return {};
155696
155733
  if (device.platform === "chromium") {
155697
155734
  return { chromium: chromiumCdpRef(device) };
155698
155735
  }
@@ -155708,7 +155745,11 @@ Before tapping, take the coordinates from \`describe\` on every platform (on Chr
155708
155745
  const clickCount = params.clickCount ?? 1;
155709
155746
  if (device.platform === "macos") {
155710
155747
  const app = requireMacosApp(services, "gesture-tap", device);
155711
- await macosClick(app, params.x, params.y, { clickCount, button: params.button });
155748
+ await macosClick(app, params.x, params.y, {
155749
+ clickCount,
155750
+ button: params.button,
155751
+ modifiers: params.modifiers
155752
+ });
155712
155753
  return { tapped: true, timestampMs };
155713
155754
  }
155714
155755
  if (params.button === "right") {
@@ -155720,6 +155761,15 @@ Before tapping, take the coordinates from \`describe\` on every platform (on Chr
155720
155761
  )
155721
155762
  );
155722
155763
  }
155764
+ if (params.modifiers?.length) {
155765
+ const refusal = device.platform === "chromium" ? `<flag:macos-apps>, which argent sends only to a Mac app</flag:macos-apps>: argent does not support modifier keys in a tap on a chromium app yet.` : `<flag:macos-apps>, which only a Mac app takes</flag:macos-apps>: ${device.platform} ${device.kind} takes no modifier keys in a tap.`;
155766
+ throw new InvalidToolInputError(
155767
+ renderFlagGated(
155768
+ `gesture-tap modifiers hold keyboard keys through a mouse click${refusal}`,
155769
+ isFlagOffered
155770
+ )
155771
+ );
155772
+ }
155723
155773
  if (device.platform === "chromium") {
155724
155774
  const chromium = services.chromium;
155725
155775
  await assertChromiumWindowVisible(chromium, "tap");
@@ -159010,7 +159060,7 @@ One screenshot and element tree are captured after the whole sequence, not per s
159010
159060
  On a TV target (Apple TV / Android TV / Vega) use tv-remote for remote presses and keyboard for text.
159011
159061
 
159012
159062
  Allowed tools, their args (? = optional) and targets. Positions and distances are 0\u20131 fractions of the screen (window on Chromium), not pixels; angles are in degrees, durations in ms.
159013
- gesture-tap: x, y, clickCount?<flag:macos-apps>, button? "left"|"right" (macos)</flag:macos-apps> [ios/android/chromium<flag:harmonyos>/harmony</flag:harmonyos><flag:macos-apps>/macos</flag:macos-apps>]
159063
+ gesture-tap: x, y, clickCount?<flag:macos-apps>, button? "left"|"right" (macos), modifiers? array of "control"|"option"|"shift"|"command" (macos)</flag:macos-apps> [ios/android/chromium<flag:harmonyos>/harmony</flag:harmonyos><flag:macos-apps>/macos</flag:macos-apps>]
159014
159064
  gesture-swipe: fromX, fromY, toX, toY, durationMs?, momentum? [ios/android<flag:harmonyos>/harmony</flag:harmonyos>]
159015
159065
  gesture-scroll: x, y, deltaX?, deltaY? (signed; positive scrolls down), durationMs? [chromium<flag:macos-apps>/macos</flag:macos-apps>]
159016
159066
  gesture-drag: fromX, fromY, toX, toY, durationMs?, momentum? [chromium<flag:macos-apps>/macos</flag:macos-apps>]
@@ -170246,12 +170296,6 @@ async function startPerfetto(opts) {
170246
170296
  const child = (0, import_child_process7.spawn)(adbPath, adbArgv(args), { stdio: ["pipe", "pipe", "pipe"] });
170247
170297
  let stdout = "";
170248
170298
  let stderr = "";
170249
- child.stdout.on("data", (chunk) => {
170250
- stdout += chunk.toString("utf8");
170251
- });
170252
- child.stderr.on("data", (chunk) => {
170253
- stderr += chunk.toString("utf8");
170254
- });
170255
170299
  const pid = await new Promise((resolve19, reject) => {
170256
170300
  let settled = false;
170257
170301
  const timer = setTimeout(() => {
@@ -170300,7 +170344,7 @@ async function startPerfetto(opts) {
170300
170344
  )
170301
170345
  )
170302
170346
  );
170303
- child.stdin.on(
170347
+ child.stdin?.on(
170304
170348
  "error",
170305
170349
  (err) => fail(
170306
170350
  new FailureError(
@@ -170326,7 +170370,13 @@ async function startPerfetto(opts) {
170326
170370
  if (!Number.isFinite(parsed2) || parsed2 <= 0) return;
170327
170371
  succeed(parsed2);
170328
170372
  };
170329
- child.stdout.on("data", () => tryResolve2());
170373
+ child.stdout?.on("data", (chunk) => {
170374
+ stdout += chunk.toString("utf8");
170375
+ tryResolve2();
170376
+ });
170377
+ child.stderr?.on("data", (chunk) => {
170378
+ stderr += chunk.toString("utf8");
170379
+ });
170330
170380
  child.once("exit", (code, signal) => {
170331
170381
  if (settled) return;
170332
170382
  const reason2 = signal ? `signal ${signal}` : `code ${code ?? "?"}`;
@@ -170360,8 +170410,8 @@ async function startPerfetto(opts) {
170360
170410
  );
170361
170411
  });
170362
170412
  try {
170363
- child.stdin.write(cfgText);
170364
- child.stdin.end();
170413
+ child.stdin?.write(cfgText);
170414
+ child.stdin?.end();
170365
170415
  } catch (err) {
170366
170416
  fail(
170367
170417
  new FailureError(
@@ -176276,12 +176326,15 @@ function toYamlStep(step) {
176276
176326
  }
176277
176327
  case "tap": {
176278
176328
  const target = targetToYaml(step);
176279
- if (step.times === void 0 && step.button === void 0) return { tap: target };
176329
+ if (step.times === void 0 && step.button === void 0 && step.modifiers === void 0) {
176330
+ return { tap: target };
176331
+ }
176280
176332
  return {
176281
176333
  tap: {
176282
176334
  on: target,
176283
176335
  ...step.times !== void 0 ? { times: step.times } : {},
176284
- ...step.button !== void 0 ? { button: step.button } : {}
176336
+ ...step.button !== void 0 ? { button: step.button } : {},
176337
+ ...step.modifiers !== void 0 ? { modifiers: [...step.modifiers] } : {}
176285
176338
  }
176286
176339
  };
176287
176340
  }
@@ -176912,6 +176965,15 @@ function parseTapButton(raw, entry) {
176912
176965
  if (raw !== "right") badEntry(entry, "tap.button must be left or right");
176913
176966
  return "right";
176914
176967
  }
176968
+ function parseTapModifiers(raw, entry) {
176969
+ if (raw === void 0) return void 0;
176970
+ const names = MACOS_MODIFIERS;
176971
+ if (!Array.isArray(raw) || !raw.every((m) => typeof m === "string" && names.includes(m))) {
176972
+ badEntry(entry, `tap.modifiers must be a list of ${MACOS_MODIFIERS.join(", ")}`);
176973
+ }
176974
+ const held = MACOS_MODIFIERS.filter((m) => raw.includes(m));
176975
+ return held.length > 0 ? held : void 0;
176976
+ }
176915
176977
  function hasSelectorField(obj) {
176916
176978
  return obj.text !== void 0 || obj.id !== void 0 || obj.identifier !== void 0 || obj.role !== void 0 || obj.any !== void 0 || SELECTOR_RELATIONS.some((relation) => obj[relation] !== void 0);
176917
176979
  }
@@ -176941,7 +177003,7 @@ function parseTarget(raw, where) {
176941
177003
  }
176942
177004
  function parseTap(body, entry) {
176943
177005
  const obj = body !== null && typeof body === "object" ? body : {};
176944
- if (obj.on !== void 0 || obj.times !== void 0 || obj.button !== void 0) {
177006
+ if (obj.on !== void 0 || obj.times !== void 0 || obj.button !== void 0 || obj.modifiers !== void 0) {
176945
177007
  if (hasSelectorField(obj)) {
176946
177008
  badEntry(
176947
177009
  entry,
@@ -176954,13 +177016,15 @@ function parseTap(body, entry) {
176954
177016
  "the tap options form takes a nested point \u2014 e.g. tap: { on: { x: 0.5, y: 0.5 }, times: 2 }"
176955
177017
  );
176956
177018
  }
176957
- if (!Object.keys(obj).every((k) => k === "on" || k === "times" || k === "button")) {
176958
- badEntry(entry, "the tap options form accepts only { on, times, button }");
177019
+ if (!Object.keys(obj).every(
177020
+ (k) => k === "on" || k === "times" || k === "button" || k === "modifiers"
177021
+ )) {
177022
+ badEntry(entry, "the tap options form accepts only { on, times, button, modifiers }");
176959
177023
  }
176960
177024
  if (obj.on === void 0) {
176961
177025
  badEntry(
176962
177026
  entry,
176963
- 'tap with times or button needs a target - e.g. tap: { on: "Photo", times: 2 }'
177027
+ 'tap with times, button or modifiers needs a target - e.g. tap: { on: "Photo", times: 2 }'
176964
177028
  );
176965
177029
  }
176966
177030
  const step = { kind: "tap", ...parseTarget(obj.on, "tap.on") };
@@ -176968,6 +177032,8 @@ function parseTap(body, entry) {
176968
177032
  if (times !== void 0) step.times = times;
176969
177033
  const button = parseTapButton(obj.button, entry);
176970
177034
  if (button !== void 0) step.button = button;
177035
+ const modifiers = parseTapModifiers(obj.modifiers, entry);
177036
+ if (modifiers !== void 0) step.modifiers = modifiers;
176971
177037
  return step;
176972
177038
  }
176973
177039
  return { kind: "tap", ...parseTarget(body, "tap") };
@@ -177321,7 +177387,7 @@ function* argFields(value, where, seen = /* @__PURE__ */ new Set()) {
177321
177387
  }
177322
177388
  function gestureTargetPath(step) {
177323
177389
  if (step.kind === "pinch" || step.kind === "rotate") return { path: `${step.kind}.on` };
177324
- const option = step.kind === "tap" ? step.times ?? step.button : step.duration;
177390
+ const option = step.kind === "tap" ? step.times ?? step.button ?? step.modifiers : step.duration;
177325
177391
  if (option !== void 0) return { path: `${step.kind}.on` };
177326
177392
  return { path: step.kind, alt: `${step.kind}.on` };
177327
177393
  }
@@ -179507,6 +179573,16 @@ async function runDirective(env, step) {
179507
179573
  )
179508
179574
  };
179509
179575
  }
179576
+ if (step.kind === "tap" && step.modifiers !== void 0 && env.device.platform !== "macos") {
179577
+ const platform = env.device.platform;
179578
+ return {
179579
+ ok: false,
179580
+ reason: renderFlagGated(
179581
+ platform === "chromium" ? `tap with modifiers holds keyboard keys through a mouse click<flag:macos-apps>, which argent sends only to a Mac app</flag:macos-apps>; argent does not support it on chromium yet` : `tap with modifiers holds keyboard keys through a mouse click<flag:macos-apps>, which only a Mac app takes</flag:macos-apps>; ${platform} takes none`,
179582
+ isFlagOffered
179583
+ )
179584
+ };
179585
+ }
179510
179586
  if (step.kind === "idle" && !supportsFlowTree(env.device.platform)) {
179511
179587
  return {
179512
179588
  ok: false,
@@ -179598,7 +179674,8 @@ async function runTap(env, target) {
179598
179674
  const sent = await invokeOnDevice(env, "gesture-tap", {
179599
179675
  ...resolved.point,
179600
179676
  ...target.times !== void 0 ? { clickCount: target.times } : {},
179601
- ...target.button !== void 0 ? { button: target.button } : {}
179677
+ ...target.button !== void 0 ? { button: target.button } : {},
179678
+ ...target.modifiers !== void 0 ? { modifiers: target.modifiers } : {}
179602
179679
  });
179603
179680
  return { ok: true, ...warnedBy(resolved.warning, toolWarning(sent)) };
179604
179681
  }
@@ -180692,8 +180769,9 @@ var POINT_GESTURE_STEP = {
180692
180769
  const target = step.selector ? yamlSelectorLabel(step.selector) : `(${step.x}, ${step.y})`;
180693
180770
  const times = step.kind === "tap" && step.times !== void 0 && step.times > 1 ? ` \xD7${step.times}` : "";
180694
180771
  const button = step.kind === "tap" && step.button === "right" ? " (right button)" : "";
180772
+ const keys = step.kind === "tap" && step.modifiers !== void 0 ? ` holding ${step.modifiers.join("+")}` : "";
180695
180773
  const held = step.kind === "long-press" && step.duration !== void 0 ? ` for ${step.duration}ms` : "";
180696
- return `${target}${times}${button}${held}`;
180774
+ return `${target}${times}${button}${keys}${held}`;
180697
180775
  },
180698
180776
  target: (step) => {
180699
180777
  if (step.selector) return selectorLabel(step.selector);
@@ -181522,10 +181600,18 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
181522
181600
  const cc = args.clickCount;
181523
181601
  const tapTimes = isTap && typeof cc === "number" && Number.isInteger(cc) && cc >= 2 && cc <= 10 ? { times: cc } : {};
181524
181602
  const tapButton = isTap && args.button === "right" ? { button: "right" } : {};
181603
+ const heldKeys = Array.isArray(args.modifiers) ? MACOS_MODIFIERS.filter((m) => args.modifiers.includes(m)) : [];
181604
+ const tapModifiers = isTap && heldKeys.length > 0 ? { modifiers: heldKeys } : {};
181525
181605
  let step;
181526
181606
  let warning;
181527
181607
  if (captured?.selector) {
181528
- step = { kind: "tap", selector: captured.selector, ...tapTimes, ...tapButton };
181608
+ step = {
181609
+ kind: "tap",
181610
+ selector: captured.selector,
181611
+ ...tapTimes,
181612
+ ...tapButton,
181613
+ ...tapModifiers
181614
+ };
181529
181615
  warning = captured.warning;
181530
181616
  } else if (isTap) {
181531
181617
  step = {
@@ -181533,7 +181619,8 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
181533
181619
  x: args.x,
181534
181620
  y: args.y,
181535
181621
  ...tapTimes,
181536
- ...tapButton
181622
+ ...tapButton,
181623
+ ...tapModifiers
181537
181624
  };
181538
181625
  warning = captured?.warning;
181539
181626
  } else if (isLaunch) {
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.34.1-next.16",
3
+ "version": "0.34.1-next.18",
4
4
  "mcpName": "io.github.software-mansion/argent",
5
5
  "description": "MCP server for iOS Simulator, Android Emulator, Chromium app and Mac app control",
6
6
  "license": "Apache-2.0",
@@ -23,6 +23,7 @@ description: Drive a native Mac app (AppKit, SwiftUI, react-native-macos, Mac Ca
23
23
  - Swipe or drag: `gesture-drag`. Long press: `gesture-drag` with the same start and end point. Scroll: `gesture-scroll`.
24
24
  - Zoom or rotate: `gesture-pinch` and `gesture-rotate` fail; use the app's own controls or shortcuts.
25
25
  - After a right-click (`gesture-tap` with `button: "right"`), the returned tree lists the menu items; a plain `gesture-tap` on one chooses it (the menu can stay in the tree for a moment while it closes). `keyboard` `escape` closes the menu; `enter` chooses nothing after a right-click, so tap the item.
26
+ - For a Command-click or Shift-click, pass `modifiers` in the `gesture-tap` call. Check the returned tree for the expected selection.
26
27
  - No hover: a tooltip is out of reach.
27
28
  - `open-url`: the URL goes to the running app. A custom scheme must be one the app declares; `http` and `https` go to the app, not the browser; a `file:` URL opens that document in the app.
28
29
  - A SwiftUI `DisclosureGroup` opens only at its chevron, near the left end of its frame: a tap at the centre passes and does nothing. Tap along the left end in steps of about 0.008 until its `value` changes.
@@ -2,5 +2,5 @@
2
2
 
3
3
  - Record the launch as a `restart-app` step, then write it as `launch: { macos: <bundle id> }` (keep `{ app, args }` if the recorder wrote args) so the runner picks the Mac app and starts it. Otherwise run with `--platform macos` or the device id: without them the runner never picks a Mac app.
4
4
  - A `swipe` is a mouse drag, a `long-press` a press and hold. `pinch` and `rotate` fail.
5
- - A right-click is `tap: { on: <selector>, button: right }`.
5
+ - A right-click is `tap: { on: <selector>, button: right }`. For a Command-click, write `tap: { on: <selector>, modifiers: [command] }`. The recorder preserves `modifiers` from `gesture-tap` so replay holds the same keys.
6
6
  - A file panel is a `tool: file-panel` step, a menu command a `tool: menu-bar` step (`args: { action: choose, path: [Edit, Select All] }`). Gate a branch with `when: { platform: macos }`.