@swmansion/argent 0.35.1-next.30 → 0.35.1-next.32

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
@@ -38595,7 +38595,7 @@ function isCi(env = process.env) {
38595
38595
  var SESSION_ID2 = randomUUID5();
38596
38596
  function readCliVersion() {
38597
38597
  if (true) {
38598
- return "0.35.1-next.30";
38598
+ return "0.35.1-next.32";
38599
38599
  }
38600
38600
  return "0.0.0";
38601
38601
  }
@@ -17117,7 +17117,7 @@ function isCi(env = process.env) {
17117
17117
  var SESSION_ID = randomUUID4();
17118
17118
  function readCliVersion() {
17119
17119
  if (true) {
17120
- return "0.35.1-next.30";
17120
+ return "0.35.1-next.32";
17121
17121
  }
17122
17122
  return "0.0.0";
17123
17123
  }
@@ -38154,7 +38154,7 @@ async function startMcpServer(options) {
38154
38154
  const autoDescribeOn = autoDescribeEnabled();
38155
38155
  const whatsNewOn = whatsNewEnabled();
38156
38156
  const installedVersion = getInstalledVersion();
38157
- const highlightsVersion = true ? "0.35.1-next.30" : installedVersion;
38157
+ const highlightsVersion = true ? "0.35.1-next.32" : installedVersion;
38158
38158
  const captureTimeoutMs = options.captureTimeoutMs ?? CAPTURE_TIMEOUT_MS;
38159
38159
  const trees = createTreeMemory();
38160
38160
  const screenshots = createScreenshotMemory();
@@ -51836,16 +51836,16 @@ var require_foldFlowLines = __commonJS({
51836
51836
  onFold();
51837
51837
  let res = text.slice(0, folds[0]);
51838
51838
  for (let i2 = 0; i2 < folds.length; ++i2) {
51839
- const fold2 = folds[i2];
51839
+ const fold3 = folds[i2];
51840
51840
  const end2 = folds[i2 + 1] || text.length;
51841
- if (fold2 === 0)
51841
+ if (fold3 === 0)
51842
51842
  res = `
51843
51843
  ${indent}${text.slice(0, end2)}`;
51844
51844
  else {
51845
- if (mode === FOLD_QUOTED && escapedFolds[fold2])
51846
- res += `${text[fold2]}\\`;
51845
+ if (mode === FOLD_QUOTED && escapedFolds[fold3])
51846
+ res += `${text[fold3]}\\`;
51847
51847
  res += `
51848
- ${indent}${text.slice(fold2 + 1, end2)}`;
51848
+ ${indent}${text.slice(fold3 + 1, end2)}`;
51849
51849
  }
51850
51850
  }
51851
51851
  return res;
@@ -55484,8 +55484,8 @@ var require_resolve_flow_scalar = __commonJS({
55484
55484
  if (ch === "\r" && source[i + 1] === "\n")
55485
55485
  continue;
55486
55486
  if (ch === "\n") {
55487
- const { fold: fold2, offset } = foldNewline(source, i);
55488
- res += fold2;
55487
+ const { fold: fold3, offset } = foldNewline(source, i);
55488
+ res += fold3;
55489
55489
  i = offset;
55490
55490
  } else if (ch === "\\") {
55491
55491
  let next = source[++i];
@@ -55525,19 +55525,19 @@ var require_resolve_flow_scalar = __commonJS({
55525
55525
  return res;
55526
55526
  }
55527
55527
  function foldNewline(source, offset) {
55528
- let fold2 = "";
55528
+ let fold3 = "";
55529
55529
  let ch = source[offset + 1];
55530
55530
  while (ch === " " || ch === " " || ch === "\n" || ch === "\r") {
55531
55531
  if (ch === "\r" && source[offset + 2] !== "\n")
55532
55532
  break;
55533
55533
  if (ch === "\n")
55534
- fold2 += "\n";
55534
+ fold3 += "\n";
55535
55535
  offset += 1;
55536
55536
  ch = source[offset + 1];
55537
55537
  }
55538
- if (!fold2)
55539
- fold2 = " ";
55540
- return { fold: fold2, offset };
55538
+ if (!fold3)
55539
+ fold3 = " ";
55540
+ return { fold: fold3, offset };
55541
55541
  }
55542
55542
  var escapeCodes = {
55543
55543
  "0": "\0",
@@ -72978,7 +72978,7 @@ function isCi(env = process.env) {
72978
72978
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
72979
72979
  function readCliVersion() {
72980
72980
  if (true) {
72981
- return "0.35.1-next.30";
72981
+ return "0.35.1-next.32";
72982
72982
  }
72983
72983
  return "0.0.0";
72984
72984
  }
@@ -79801,6 +79801,7 @@ function getCachedSimulatorRuntimeKind(udid) {
79801
79801
  }
79802
79802
  var deviceTypeFoldableCache = /* @__PURE__ */ new Map();
79803
79803
  var deviceTypeBundlePaths = null;
79804
+ var deviceTypeReread = null;
79804
79805
  var foldableCache = /* @__PURE__ */ new Map();
79805
79806
  async function listDeviceTypeBundlePaths() {
79806
79807
  try {
@@ -79823,11 +79824,17 @@ async function listDeviceTypeBundlePaths() {
79823
79824
  }
79824
79825
  async function deviceTypeBundlePath(identifier) {
79825
79826
  deviceTypeBundlePaths ??= listDeviceTypeBundlePaths();
79826
- let paths = await deviceTypeBundlePaths;
79827
+ const paths = await deviceTypeBundlePaths;
79827
79828
  if (paths.has(identifier)) return paths.get(identifier);
79828
- deviceTypeBundlePaths = listDeviceTypeBundlePaths();
79829
- paths = await deviceTypeBundlePaths;
79830
- return paths.get(identifier);
79829
+ if (!deviceTypeReread) {
79830
+ const reread = listDeviceTypeBundlePaths();
79831
+ deviceTypeReread = reread;
79832
+ deviceTypeBundlePaths = reread;
79833
+ void reread.finally(() => {
79834
+ if (deviceTypeReread === reread) deviceTypeReread = null;
79835
+ });
79836
+ }
79837
+ return (await deviceTypeReread).get(identifier);
79831
79838
  }
79832
79839
  async function countIntegratedDisplays(bundlePath) {
79833
79840
  const plist = path20.join(bundlePath, "Contents", "Resources", "capabilities.plist");
@@ -79845,14 +79852,22 @@ async function countIntegratedDisplays(bundlePath) {
79845
79852
  return 0;
79846
79853
  }
79847
79854
  }
79848
- async function isFoldableDeviceType(identifier) {
79849
- const cached3 = deviceTypeFoldableCache.get(identifier);
79850
- if (cached3 !== void 0) return cached3;
79851
- const bundlePath = await deviceTypeBundlePath(identifier);
79852
- const foldable = bundlePath ? await countIntegratedDisplays(bundlePath) > 1 : false;
79853
- deviceTypeFoldableCache.set(identifier, foldable);
79855
+ function isFoldableDeviceType(identifier) {
79856
+ let foldable = deviceTypeFoldableCache.get(identifier);
79857
+ if (!foldable) {
79858
+ foldable = deviceTypeBundlePath(identifier).then(
79859
+ async (bundlePath) => bundlePath ? await countIntegratedDisplays(bundlePath) > 1 : false
79860
+ );
79861
+ deviceTypeFoldableCache.set(identifier, foldable);
79862
+ }
79854
79863
  return foldable;
79855
79864
  }
79865
+ var KNOWN_FOLDABLE_DEVICE_TYPES = /* @__PURE__ */ new Set([
79866
+ "com.apple.CoreSimulator.SimDeviceType.iPhone-Duo"
79867
+ ]);
79868
+ async function isRemoteFoldableDeviceType(identifier) {
79869
+ return KNOWN_FOLDABLE_DEVICE_TYPES.has(identifier) || await isFoldableDeviceType(identifier);
79870
+ }
79856
79871
  async function isFoldableSimulator(udid) {
79857
79872
  const device = resolveDevice(udid);
79858
79873
  if (device.platform !== "ios" || device.kind !== "simulator") return false;
@@ -97901,6 +97916,7 @@ function installNodeWebTransport() {
97901
97916
  // ../tool-server/src/utils/sim-remote.ts
97902
97917
  var import_node_child_process14 = require("node:child_process");
97903
97918
  var import_node_util11 = require("node:util");
97919
+ init_zod();
97904
97920
  init_device_info();
97905
97921
  var execFileAsync10 = (0, import_node_util11.promisify)(import_node_child_process14.execFile);
97906
97922
  var SIM_REMOTE_TIMEOUT_MS = 3e4;
@@ -97913,7 +97929,8 @@ async function run(args, options) {
97913
97929
  timeout: options?.timeoutMs ?? SIM_REMOTE_TIMEOUT_MS,
97914
97930
  maxBuffer: 16 * 1024 * 1024,
97915
97931
  encoding: "utf8",
97916
- input: options?.stdin
97932
+ input: options?.stdin,
97933
+ signal: options?.signal
97917
97934
  });
97918
97935
  return { stdout: typeof stdout === "string" ? stdout : stdout.toString("utf8") };
97919
97936
  } catch (err) {
@@ -97999,7 +98016,7 @@ async function simctlSpawn(udid, opts) {
97999
98016
  cmd.push("--json");
98000
98017
  const args = opts.args ?? [];
98001
98018
  if (args.length > 0) cmd.push("--", ...args);
98002
- const { stdout } = await run(cmd, { timeoutMs: 6e4 });
98019
+ const { stdout } = await run(cmd, { timeoutMs: opts.timeoutMs ?? 6e4 });
98003
98020
  try {
98004
98021
  const parsed2 = JSON.parse(stdout);
98005
98022
  return {
@@ -98070,6 +98087,28 @@ async function screenRecordFetch(udid, recording, outputFile) {
98070
98087
  { timeoutMs: RECORDING_DOWNLOAD_TIMEOUT_MS }
98071
98088
  );
98072
98089
  }
98090
+ var remoteFoldSchema = external_exports.object({
98091
+ /** The angle the hinge was moved to, in degrees. */
98092
+ hinge_angle: external_exports.number(),
98093
+ /** Screen id of the panel the device renders to; null when the runner could not tell. */
98094
+ live_screen: external_exports.number().nullable(),
98095
+ warning: external_exports.string().optional()
98096
+ });
98097
+ var FOLD_TIMEOUT_MS = 6e4;
98098
+ async function fold(udid, target, signal) {
98099
+ const args = ["fold", stripRemotePrefix(udid), target, "--json"];
98100
+ const { stdout } = await run(args, { timeoutMs: FOLD_TIMEOUT_MS, signal });
98101
+ try {
98102
+ return remoteFoldSchema.parse(JSON.parse(stdout));
98103
+ } catch (err) {
98104
+ throw new Error(
98105
+ `sim-remote fold printed something other than a fold: ${err.message}`,
98106
+ {
98107
+ cause: err
98108
+ }
98109
+ );
98110
+ }
98111
+ }
98073
98112
  async function moqInfo(udid) {
98074
98113
  const { stdout } = await run(["moq-info", stripRemotePrefix(udid)]);
98075
98114
  try {
@@ -100072,11 +100111,11 @@ function appendDyldInsertLibrary(currentValue, dylibPath) {
100072
100111
  );
100073
100112
  return [...kept, dylibPath].join(":");
100074
100113
  }
100114
+ var APP_ACCESSIBILITY_FLAGS = ["AccessibilityEnabled", "ApplicationAccessibilityEnabled"];
100075
100115
  async function ensureAccessibilityEnabled(udid) {
100076
- const flags = ["AccessibilityEnabled", "ApplicationAccessibilityEnabled"];
100077
100116
  const { nativeId, prefix } = await simctlTargetForUdid(udid, { granted: "native-devtools" });
100078
100117
  await Promise.all(
100079
- flags.map(
100118
+ APP_ACCESSIBILITY_FLAGS.map(
100080
100119
  (flag) => execFileAsync12(
100081
100120
  "xcrun",
100082
100121
  [
@@ -100335,6 +100374,7 @@ var localIosHost = {
100335
100374
  withdrawNativeDevtoolsEnv: withdrawNativeDevtoolsEnvLocal,
100336
100375
  listRunningBundleIds: listRunningUIKitApplicationBundleIds,
100337
100376
  inspectRunningApp: inspectRunningAppLocal,
100377
+ enableAppAccessibility: ensureAccessibilityEnabled,
100338
100378
  async bootstrapAx(udid) {
100339
100379
  return { accessibilityPrefsEnabled: await prepareLocalAxPrefs(udid) };
100340
100380
  },
@@ -100344,11 +100384,27 @@ var localIosHost = {
100344
100384
  async stopProxy() {
100345
100385
  }
100346
100386
  };
100347
- var ACCESSIBILITY_DEFAULT_FLAGS = [
100348
- "AutomationEnabled",
100349
- "AccessibilityEnabled",
100350
- "ApplicationAccessibilityEnabled"
100351
- ];
100387
+ var ACCESSIBILITY_DEFAULT_FLAGS = ["AutomationEnabled", ...APP_ACCESSIBILITY_FLAGS];
100388
+ async function enableAppAccessibilityRemote(udid) {
100389
+ const writes = await Promise.allSettled(
100390
+ APP_ACCESSIBILITY_FLAGS.map(async (flag) => {
100391
+ const { exitCode, stderr } = await simctlSpawn(udid, {
100392
+ args: ["defaults", "write", "com.apple.Accessibility", flag, "-bool", "true"],
100393
+ // The launch waits no longer than this, so the write gets no longer either.
100394
+ timeoutMs: APP_ACCESSIBILITY_WAIT_MS
100395
+ });
100396
+ if (exitCode !== void 0 && exitCode !== 0) {
100397
+ throw new Error(`defaults exited with ${exitCode}: ${stderr.trim() || "no stderr"}`);
100398
+ }
100399
+ })
100400
+ );
100401
+ const failures = writes.flatMap(
100402
+ (write, index) => write.status === "rejected" ? [
100403
+ `${APP_ACCESSIBILITY_FLAGS[index]}: ${write.reason instanceof Error ? write.reason.message : String(write.reason)}`
100404
+ ] : []
100405
+ );
100406
+ if (failures.length > 0) throw new Error(failures.join("; "));
100407
+ }
100352
100408
  var remoteIosHost = {
100353
100409
  kind: "remote",
100354
100410
  requiresTcp: true,
@@ -100370,6 +100426,7 @@ var remoteIosHost = {
100370
100426
  const { stdout } = await simctlSpawn(udid, { args: ["launchctl", "list"] });
100371
100427
  return { running: parseUIKitApplicationJobs(stdout).has(bundleId), process: null };
100372
100428
  },
100429
+ enableAppAccessibility: enableAppAccessibilityRemote,
100373
100430
  // Accessibility `defaults write`s routed through the remote generic spawn.
100374
100431
  // The entitlement-bypass plist is assumed active on cloud sims.
100375
100432
  async bootstrapAx(udid) {
@@ -100387,6 +100444,19 @@ var remoteIosHost = {
100387
100444
  function pickIosHost(device) {
100388
100445
  return device.platform === "ios-remote" ? remoteIosHost : localIosHost;
100389
100446
  }
100447
+ var APP_ACCESSIBILITY_WAIT_MS = 1e4;
100448
+ async function enableAppAccessibilityBeforeLaunch(device) {
100449
+ const settled = await settleWithin(
100450
+ pickIosHost(device).enableAppAccessibility(device.id),
100451
+ APP_ACCESSIBILITY_WAIT_MS
100452
+ );
100453
+ if (settled.type === "value") return;
100454
+ const reason2 = settled.type === "error" ? settled.error : `no answer within ${APP_ACCESSIBILITY_WAIT_MS / 1e3}s, so the app starts without waiting and the write may still land after it has started`;
100455
+ process.stderr.write(
100456
+ `[ios-host] could not turn app accessibility on for ${device.id}: ${reason2}
100457
+ `
100458
+ );
100459
+ }
100390
100460
 
100391
100461
  // ../tool-server/src/blueprints/ios-network-records.ts
100392
100462
  var import_node_crypto7 = require("node:crypto");
@@ -106094,26 +106164,52 @@ function readinessRank(d) {
106094
106164
  if ("kind" in d && d.kind === "device") return d.state === "connected" ? 0 : 1;
106095
106165
  return d.state === "Booted" ? 0 : 1;
106096
106166
  }
106167
+ var REMOTE_FOLDABLE_LOOKUP_MS = 5e3;
106168
+ var REMOTE_LISTING_MARGIN_MS = 2e3;
106169
+ async function remoteFoldableTypes(deviceTypes, budgetMs) {
106170
+ const foldable = /* @__PURE__ */ new Set();
106171
+ const asked = [];
106172
+ for (const type of deviceTypes) {
106173
+ if (KNOWN_FOLDABLE_DEVICE_TYPES.has(type)) foldable.add(type);
106174
+ else asked.push(isFoldableDeviceType(type).then((is) => void (is && foldable.add(type))));
106175
+ }
106176
+ let timer;
106177
+ const gaveUp = new Promise((resolve24) => {
106178
+ timer = setTimeout(resolve24, budgetMs);
106179
+ });
106180
+ await Promise.race([Promise.allSettled(asked), gaveUp]);
106181
+ clearTimeout(timer);
106182
+ return new Set(foldable);
106183
+ }
106097
106184
  async function listRemoteIosSimulators() {
106098
106185
  try {
106186
+ const started = Date.now();
106099
106187
  const result = await simctlListDevices();
106100
- const out = [];
106101
- for (const [runtime, devices2] of Object.entries(result.devices)) {
106188
+ const listed = Object.entries(result.devices).flatMap(([runtime, devices2]) => {
106102
106189
  const runtimeKind = simulatorRuntimeKind(runtime);
106103
- if (!runtimeKind) continue;
106104
- for (const d of devices2) {
106105
- if (d.isAvailable === false) continue;
106106
- out.push({
106107
- platform: "ios-remote",
106108
- kind: "simulator",
106109
- udid: withRemotePrefix(d.udid),
106110
- name: d.name,
106111
- state: d.state,
106112
- runtime,
106113
- runtimeKind
106114
- });
106115
- }
106116
- }
106190
+ if (!runtimeKind) return [];
106191
+ return devices2.filter((d) => d.isAvailable !== false).map((d) => ({ runtime, runtimeKind, d }));
106192
+ });
106193
+ const mobileTypes = new Set(
106194
+ listed.flatMap(
106195
+ ({ runtimeKind, d }) => runtimeKind === "mobile" && d.deviceTypeIdentifier ? [d.deviceTypeIdentifier] : []
106196
+ )
106197
+ );
106198
+ const left = BRANCH_DEADLINE_MS - REMOTE_LISTING_MARGIN_MS - (Date.now() - started);
106199
+ const foldableTypes = await remoteFoldableTypes(
106200
+ mobileTypes,
106201
+ Math.max(0, Math.min(REMOTE_FOLDABLE_LOOKUP_MS, left))
106202
+ );
106203
+ const out = listed.map(({ runtime, runtimeKind, d }) => ({
106204
+ platform: "ios-remote",
106205
+ kind: "simulator",
106206
+ udid: withRemotePrefix(d.udid),
106207
+ name: d.name,
106208
+ state: d.state,
106209
+ runtime,
106210
+ runtimeKind,
106211
+ ...runtimeKind === "mobile" && foldableTypes.has(d.deviceTypeIdentifier ?? "") ? { foldable: true } : {}
106212
+ }));
106117
106213
  return { devices: out, cloud: "logged-in" };
106118
106214
  } catch (err) {
106119
106215
  if (simRemoteExecError(err).code === "ENOENT") {
@@ -127035,7 +127131,7 @@ function createInspector(serial, packageName, initialMetroPort) {
127035
127131
  if (!conn) return;
127036
127132
  if (msg.type === "CDP") {
127037
127133
  if (cdp.handleResponse(payload)) return;
127038
- if (typeof payload.method === "string") fold2(conn, payload.method, payload.params);
127134
+ if (typeof payload.method === "string") fold3(conn, payload.method, payload.params);
127039
127135
  return;
127040
127136
  }
127041
127137
  if (msg.type === "Status") onStatus(conn, payload);
@@ -127306,7 +127402,7 @@ function createInspector(serial, packageName, initialMetroPort) {
127306
127402
  }
127307
127403
  return foreground === appUser ? `the app restarted as pid ${next.pid}, and this tool-server did not attach capture to that process; call network-capture-start to attach it` : `Android user ${foreground} is in the foreground now, and its process of ${packageName} runs without capture; restart-app attaches capture to it, or call network-capture-start`;
127308
127404
  }
127309
- function fold2(conn, method, params) {
127405
+ function fold3(conn, method, params) {
127310
127406
  if (typeof params !== "object" || params === null) return;
127311
127407
  const p = params;
127312
127408
  const layerId = typeof p.requestId === "string" ? p.requestId : null;
@@ -135727,11 +135823,13 @@ function makeIosImpl(registry2) {
135727
135823
  requires: ["xcrun"],
135728
135824
  handler: async (_services, params, device, options) => {
135729
135825
  let nativeDevtools;
135826
+ let accessibility;
135730
135827
  if (!externalClaimForAnyId(device.id)) {
135731
135828
  const ndRef = nativeDevtoolsRef(device);
135732
135829
  nativeDevtools = await registry2.resolveService(ndRef.urn, ndRef.options);
135733
135830
  const blocked = await precheckNativeDevtools(nativeDevtools, params.udid);
135734
135831
  if (blocked) return blocked;
135832
+ accessibility = enableAppAccessibilityBeforeLaunch(device);
135735
135833
  }
135736
135834
  if (params.launchArgs?.length) {
135737
135835
  try {
@@ -135756,6 +135854,7 @@ function makeIosImpl(registry2) {
135756
135854
  }
135757
135855
  }
135758
135856
  }
135857
+ await accessibility;
135759
135858
  try {
135760
135859
  await execFileAsync27(
135761
135860
  "xcrun",
@@ -135861,9 +135960,10 @@ async function tolerateNothingToTerminate(terminate, nothingToTerminate) {
135861
135960
  // ../tool-server/src/tools/launch-app/platforms/shared.ts
135862
135961
  init_src2();
135863
135962
  function buildIosLaunchHandler(backend) {
135864
- return async (services, params) => {
135963
+ return async (services, params, device) => {
135865
135964
  const blocked = await precheckNativeDevtools(services.nativeDevtools, params.udid);
135866
135965
  if (blocked) return blocked;
135966
+ const accessibility = enableAppAccessibilityBeforeLaunch(device);
135867
135967
  if (params.launchArgs?.length) {
135868
135968
  try {
135869
135969
  await tolerateNothingToTerminate(
@@ -135886,6 +135986,7 @@ function buildIosLaunchHandler(backend) {
135886
135986
  );
135887
135987
  }
135888
135988
  }
135989
+ await accessibility;
135889
135990
  try {
135890
135991
  await backend.launch(params.udid, params.bundleId, params.launchArgs);
135891
135992
  } catch (err) {
@@ -136275,11 +136376,13 @@ function makeIosImpl2(registry2) {
136275
136376
  handler: async (_services, params, device, options) => {
136276
136377
  const { udid, bundleId } = params;
136277
136378
  let nativeDevtools;
136379
+ let accessibility;
136278
136380
  if (!externalClaimForAnyId(device.id)) {
136279
136381
  const ndRef = nativeDevtoolsRef(device);
136280
136382
  nativeDevtools = await registry2.resolveService(ndRef.urn, ndRef.options);
136281
136383
  const blocked = await precheckNativeDevtools(nativeDevtools, udid);
136282
136384
  if (blocked) return blocked;
136385
+ accessibility = enableAppAccessibilityBeforeLaunch(device);
136283
136386
  }
136284
136387
  try {
136285
136388
  await execFileAsync28("xcrun", await simctlArgsForUdid(udid, ["terminate", udid, bundleId]), {
@@ -136301,6 +136404,7 @@ function makeIosImpl2(registry2) {
136301
136404
  );
136302
136405
  }
136303
136406
  }
136407
+ await accessibility;
136304
136408
  try {
136305
136409
  await execFileAsync28(
136306
136410
  "xcrun",
@@ -136361,10 +136465,11 @@ var iosDeviceImpl2 = {
136361
136465
  // ../tool-server/src/tools/restart-app/platforms/shared.ts
136362
136466
  init_src2();
136363
136467
  function buildIosRestartHandler(backend) {
136364
- return async (services, params) => {
136468
+ return async (services, params, device) => {
136365
136469
  const { udid, bundleId } = params;
136366
136470
  const blocked = await precheckNativeDevtools(services.nativeDevtools, udid);
136367
136471
  if (blocked) return blocked;
136472
+ const accessibility = enableAppAccessibilityBeforeLaunch(device);
136368
136473
  try {
136369
136474
  await tolerateNothingToTerminate(
136370
136475
  backend.terminate(udid, bundleId),
@@ -136385,6 +136490,7 @@ function buildIosRestartHandler(backend) {
136385
136490
  { cause: err instanceof Error ? err : new Error(String(err)) }
136386
136491
  );
136387
136492
  }
136493
+ await accessibility;
136388
136494
  try {
136389
136495
  await backend.launch(udid, bundleId, params.launchArgs);
136390
136496
  } catch (err) {
@@ -142163,7 +142269,7 @@ async function readDeviceStates(serial) {
142163
142269
  return /* @__PURE__ */ new Map();
142164
142270
  }
142165
142271
  }
142166
- async function fold(serial, params, device, signal) {
142272
+ async function fold2(serial, params, device, signal) {
142167
142273
  signal?.throwIfAborted();
142168
142274
  const states = await readDeviceStates(serial);
142169
142275
  const byId = new Map([...states].map(([name, id]) => [id, name]));
@@ -142264,26 +142370,97 @@ var androidImpl8 = {
142264
142370
  "android_fold_not_emulator"
142265
142371
  );
142266
142372
  }
142267
- return withDeviceLock2(serial, () => fold(serial, params, device, signal));
142373
+ return withDeviceLock2(serial, () => fold2(serial, params, device, signal));
142268
142374
  }
142269
142375
  };
142270
142376
 
142271
- // ../tool-server/src/tools/fold/index.ts
142377
+ // ../tool-server/src/tools/fold/platforms/ios-remote.ts
142378
+ init_src2();
142379
+ init_device_info();
142272
142380
  var POSTURES2 = ["closed", "half-open", "open"];
142273
142381
  var POSTURE_ANGLE = { "closed": 0, "half-open": 120, "open": 180 };
142382
+ async function listedAsNotFoldable(udid, signal) {
142383
+ try {
142384
+ const bare = stripRemotePrefix(udid);
142385
+ const listed = Object.values((await simctlListDevices({ signal })).devices).flat().find((d) => d.udid === bare);
142386
+ const type = listed?.deviceTypeIdentifier;
142387
+ return type !== void 0 && !await isRemoteFoldableDeviceType(type);
142388
+ } catch {
142389
+ return false;
142390
+ }
142391
+ }
142392
+ async function foldFailure(err, udid, signal) {
142393
+ const message = err instanceof Error ? err.message : String(err);
142394
+ const cause = err instanceof Error ? { cause: err } : void 0;
142395
+ if (await listedAsNotFoldable(udid, signal)) {
142396
+ return new FailureError(
142397
+ message,
142398
+ {
142399
+ error_code: FAILURE_CODES.IOS_FOLD_UNSUPPORTED,
142400
+ failure_stage: "sim_remote_fold_not_foldable",
142401
+ failure_area: "tool_server",
142402
+ error_kind: "unsupported"
142403
+ },
142404
+ cause
142405
+ );
142406
+ }
142407
+ return new FailureError(
142408
+ message,
142409
+ {
142410
+ error_code: FAILURE_CODES.IOS_FOLD_FAILED,
142411
+ failure_stage: "sim_remote_fold",
142412
+ failure_area: "tool_server",
142413
+ error_kind: "subprocess",
142414
+ failure_command: "sim_remote"
142415
+ },
142416
+ cause
142417
+ );
142418
+ }
142419
+ var iosRemoteImpl7 = {
142420
+ requires: ["sim-remote"],
142421
+ async handler(_services, params, _device, ctx) {
142422
+ ctx?.signal?.throwIfAborted();
142423
+ const target = params.posture ?? String(params.angle);
142424
+ const folded = await fold(params.udid, target, ctx?.signal).catch(async (err) => {
142425
+ ctx?.signal?.throwIfAborted();
142426
+ const failure3 = await foldFailure(err, params.udid, ctx?.signal);
142427
+ ctx?.signal?.throwIfAborted();
142428
+ throw failure3;
142429
+ });
142430
+ const hingeAngle = folded.hinge_angle;
142431
+ const atStop2 = hingeAngle <= POSTURE_ANGLE.closed || hingeAngle >= POSTURE_ANGLE.open;
142432
+ await sleepOrAbort(atStop2 ? INPUT_READY_HOLD_MS : INPUT_READY_HOLD_MID_ANGLE_MS, ctx?.signal);
142433
+ ctx?.signal?.throwIfAborted();
142434
+ const activeScreen = folded.live_screen ?? MAIN_SCREEN_ID;
142435
+ const posture = params.posture ?? POSTURES2.find((p) => POSTURE_ANGLE[p] === hingeAngle);
142436
+ const warning = folded.warning ?? (folded.live_screen === null ? "The runner could not tell which panel the device renders to. argent takes it to be the cover panel; fold to closed or open to be sure." : void 0);
142437
+ return {
142438
+ activeScreen,
142439
+ screen: { id: activeScreen, panel: panelName(activeScreen) },
142440
+ ...posture ? { posture } : {},
142441
+ hingeAngle,
142442
+ ...warning ? { warning } : {}
142443
+ };
142444
+ }
142445
+ };
142446
+
142447
+ // ../tool-server/src/tools/fold/index.ts
142448
+ var POSTURES3 = ["closed", "half-open", "open"];
142449
+ var POSTURE_ANGLE2 = { "closed": 0, "half-open": 120, "open": 180 };
142274
142450
  var HINGE_REQUEST_TIMEOUT_MS = 3e4;
142275
142451
  var capability23 = {
142276
- // Local simulators only. A remote (MoQ) simulator is driven on its main
142277
- // screen and carries no hinge message; the server itself rejects a device
142278
- // that is not foldable, with its own reason.
142452
+ // The server itself rejects a device that is not foldable, with its own
142453
+ // reason.
142279
142454
  apple: { simulator: true },
142455
+ // Folded by the runner, through `sim-remote fold`.
142456
+ appleRemote: { simulator: true },
142280
142457
  // Emulators only: the hinge is moved through the emulator console. `unknown`
142281
142458
  // is let through and the handler rejects a serial with no console; it also
142282
142459
  // rejects a profile with no hinge, which the capability cannot see.
142283
142460
  android: { emulator: true, unknown: true }
142284
142461
  };
142285
142462
  function presetAtAngle(angle) {
142286
- return POSTURES2.find((p) => POSTURE_ANGLE[p] === angle);
142463
+ return POSTURES3.find((p) => POSTURE_ANGLE2[p] === angle);
142287
142464
  }
142288
142465
  function classifyHingeRefusal(err, known) {
142289
142466
  if (known?.foldable !== false) return err;
@@ -142309,19 +142486,19 @@ function targetLabel2(params) {
142309
142486
  return params.posture ?? `${params.angle}\xB0`;
142310
142487
  }
142311
142488
  function targetAngle(params) {
142312
- return params.angle ?? POSTURE_ANGLE[params.posture ?? "closed"];
142489
+ return params.angle ?? POSTURE_ANGLE2[params.posture ?? "closed"];
142313
142490
  }
142314
142491
  function atStop(angle) {
142315
- return angle <= POSTURE_ANGLE.closed || angle >= POSTURE_ANGLE.open;
142492
+ return angle <= POSTURE_ANGLE2.closed || angle >= POSTURE_ANGLE2.open;
142316
142493
  }
142317
142494
  function sweepStartFor(serverAngle, liveScreen, panels) {
142318
- const start2 = serverAngle ?? POSTURE_ANGLE.closed;
142495
+ const start2 = serverAngle ?? POSTURE_ANGLE2.closed;
142319
142496
  if (panelForHingeAngle(start2, panels) === liveScreen) return void 0;
142320
142497
  return liveScreen === MAIN_SCREEN_ID ? "closed" : "open";
142321
142498
  }
142322
142499
  function sweepStartAngle(start2, serverAngle) {
142323
- if (start2 !== void 0) return POSTURE_ANGLE[start2];
142324
- return serverAngle ?? POSTURE_ANGLE.closed;
142500
+ if (start2 !== void 0) return POSTURE_ANGLE2[start2];
142501
+ return serverAngle ?? POSTURE_ANGLE2.closed;
142325
142502
  }
142326
142503
  function screenResult(activeScreen, panels) {
142327
142504
  const panel = panels?.find((p) => p.screenId === activeScreen);
@@ -142394,7 +142571,7 @@ var zodSchema29 = external_exports.object({
142394
142571
  udid: external_exports.string().describe(
142395
142572
  "Foldable device id from `list-devices` (iOS simulator UDID or Android emulator serial)."
142396
142573
  ),
142397
- posture: external_exports.enum(POSTURES2).optional().describe("Target posture: `closed` (cover panel), `half-open`, or `open` (inner panel)."),
142574
+ posture: external_exports.enum(POSTURES3).optional().describe("Target posture: `closed` (cover panel), `half-open`, or `open` (inner panel)."),
142398
142575
  angle: external_exports.number().min(0).max(180).optional().describe("Hinge angle in degrees (0 = closed, 180 = open).")
142399
142576
  }).refine((p) => p.posture === void 0 !== (p.angle === void 0), {
142400
142577
  message: "Pass exactly one of `posture` and `angle`."
@@ -142403,8 +142580,8 @@ var foldTool = {
142403
142580
  id: "fold",
142404
142581
  description: `Move a foldable iOS simulator or Android emulator hinge to a \`posture\` or \`angle\` (pass exactly one) and wait until input is ready.
142405
142582
  Use when testing an app across folded/unfolded postures (\`list-devices\` marks \`foldable: true\`; use \`rotate\` for orientation). Coordinates change with the active panel, so read the returned tree or call \`describe\` before tapping.
142406
- iOS: fold to \`closed\`/\`open\` to guarantee a panel switch; returns \`{ activeScreen, screen, posture?, hingeAngle, warning? }\`. Android: returns \`{ posture?, deviceState, hingeAngle?, warning? }\` (use Pixel Fold AVD for accurate cover-panel coords).
142407
- Fails if the device is not foldable, is a remote simulator, or is a physical Android device.`,
142583
+ iOS: fold to \`closed\`/\`open\` to guarantee a panel switch; returns \`{ activeScreen, screen, posture?, hingeAngle, warning? }\`. A remote iOS simulator returns it without the panel size. Android: returns \`{ posture?, deviceState, hingeAngle?, warning? }\` (use Pixel Fold AVD for accurate cover-panel coords).
142584
+ Fails if the device is not foldable or is a physical Android device.`,
142408
142585
  zodSchema: zodSchema29,
142409
142586
  searchHint: "fold unfold hinge foldable duo posture open closed half-open panel screen split view",
142410
142587
  interaction: {
@@ -142412,17 +142589,23 @@ Fails if the device is not foldable, is a remote simulator, or is a physical And
142412
142589
  completedMsg: ({ params, result }) => "activeScreen" in result ? `Folded device to ${targetLabel2(params)}; it renders to screen ${result.activeScreen} (${result.screen.panel})` : `Folded device to ${targetLabel2(params)}; it is in device state ${result.deviceState}`,
142413
142590
  failedMsg: ({ params, failureSignal: failureSignal2 }) => `Failed to fold device to ${targetLabel2(params)}: ${failureSignal2.error_code}`
142414
142591
  },
142592
+ // A fold can outlast the MCP adapter's per-attempt timeout, which would
142593
+ // send it again while the first is still moving the hinge. Every wait in
142594
+ // it has a bound of its own.
142595
+ longRunning: true,
142415
142596
  capability: capability23,
142416
- // The Android hinge is moved through `adb`, so no simulator-server is
142417
- // spawned for it; the server follows the new panel on its own.
142597
+ // The Android hinge is moved through `adb` and a remote one by its runner,
142598
+ // so no simulator-server is spawned for either; the server follows the new
142599
+ // panel on its own.
142418
142600
  services: (params) => {
142419
142601
  const device = resolveDevice(params.udid);
142420
- return device.platform === "android" ? {} : { simulatorServer: simulatorServerRef(device) };
142602
+ return device.platform === "ios" ? { simulatorServer: simulatorServerRef(device) } : {};
142421
142603
  },
142422
142604
  execute: dispatchByPlatform({
142423
142605
  toolId: "fold",
142424
142606
  capability: capability23,
142425
142607
  ios: iosImpl6,
142608
+ iosRemote: iosRemoteImpl7,
142426
142609
  android: androidImpl8
142427
142610
  })
142428
142611
  };
Binary file
Binary file
Binary file
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.35.1-next.30",
3
+ "version": "0.35.1-next.32",
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",
@@ -98,5 +98,5 @@
98
98
  "vitest": "^5.0.5",
99
99
  "yaml": "^2.9.1"
100
100
  },
101
- "gitHead": "ce01bf65ed7b7b3033db462bfee5fb91ebbec222"
101
+ "gitHead": "4a8a259f63adb69c4463fe78f962cdd660d3c31b"
102
102
  }