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

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.
@@ -97999,7 +97999,7 @@ async function simctlSpawn(udid, opts) {
97999
97999
  cmd.push("--json");
98000
98000
  const args = opts.args ?? [];
98001
98001
  if (args.length > 0) cmd.push("--", ...args);
98002
- const { stdout } = await run(cmd, { timeoutMs: 6e4 });
98002
+ const { stdout } = await run(cmd, { timeoutMs: opts.timeoutMs ?? 6e4 });
98003
98003
  try {
98004
98004
  const parsed2 = JSON.parse(stdout);
98005
98005
  return {
@@ -100072,11 +100072,11 @@ function appendDyldInsertLibrary(currentValue, dylibPath) {
100072
100072
  );
100073
100073
  return [...kept, dylibPath].join(":");
100074
100074
  }
100075
+ var APP_ACCESSIBILITY_FLAGS = ["AccessibilityEnabled", "ApplicationAccessibilityEnabled"];
100075
100076
  async function ensureAccessibilityEnabled(udid) {
100076
- const flags = ["AccessibilityEnabled", "ApplicationAccessibilityEnabled"];
100077
100077
  const { nativeId, prefix } = await simctlTargetForUdid(udid, { granted: "native-devtools" });
100078
100078
  await Promise.all(
100079
- flags.map(
100079
+ APP_ACCESSIBILITY_FLAGS.map(
100080
100080
  (flag) => execFileAsync12(
100081
100081
  "xcrun",
100082
100082
  [
@@ -100335,6 +100335,7 @@ var localIosHost = {
100335
100335
  withdrawNativeDevtoolsEnv: withdrawNativeDevtoolsEnvLocal,
100336
100336
  listRunningBundleIds: listRunningUIKitApplicationBundleIds,
100337
100337
  inspectRunningApp: inspectRunningAppLocal,
100338
+ enableAppAccessibility: ensureAccessibilityEnabled,
100338
100339
  async bootstrapAx(udid) {
100339
100340
  return { accessibilityPrefsEnabled: await prepareLocalAxPrefs(udid) };
100340
100341
  },
@@ -100344,11 +100345,27 @@ var localIosHost = {
100344
100345
  async stopProxy() {
100345
100346
  }
100346
100347
  };
100347
- var ACCESSIBILITY_DEFAULT_FLAGS = [
100348
- "AutomationEnabled",
100349
- "AccessibilityEnabled",
100350
- "ApplicationAccessibilityEnabled"
100351
- ];
100348
+ var ACCESSIBILITY_DEFAULT_FLAGS = ["AutomationEnabled", ...APP_ACCESSIBILITY_FLAGS];
100349
+ async function enableAppAccessibilityRemote(udid) {
100350
+ const writes = await Promise.allSettled(
100351
+ APP_ACCESSIBILITY_FLAGS.map(async (flag) => {
100352
+ const { exitCode, stderr } = await simctlSpawn(udid, {
100353
+ args: ["defaults", "write", "com.apple.Accessibility", flag, "-bool", "true"],
100354
+ // The launch waits no longer than this, so the write gets no longer either.
100355
+ timeoutMs: APP_ACCESSIBILITY_WAIT_MS
100356
+ });
100357
+ if (exitCode !== void 0 && exitCode !== 0) {
100358
+ throw new Error(`defaults exited with ${exitCode}: ${stderr.trim() || "no stderr"}`);
100359
+ }
100360
+ })
100361
+ );
100362
+ const failures = writes.flatMap(
100363
+ (write, index) => write.status === "rejected" ? [
100364
+ `${APP_ACCESSIBILITY_FLAGS[index]}: ${write.reason instanceof Error ? write.reason.message : String(write.reason)}`
100365
+ ] : []
100366
+ );
100367
+ if (failures.length > 0) throw new Error(failures.join("; "));
100368
+ }
100352
100369
  var remoteIosHost = {
100353
100370
  kind: "remote",
100354
100371
  requiresTcp: true,
@@ -100370,6 +100387,7 @@ var remoteIosHost = {
100370
100387
  const { stdout } = await simctlSpawn(udid, { args: ["launchctl", "list"] });
100371
100388
  return { running: parseUIKitApplicationJobs(stdout).has(bundleId), process: null };
100372
100389
  },
100390
+ enableAppAccessibility: enableAppAccessibilityRemote,
100373
100391
  // Accessibility `defaults write`s routed through the remote generic spawn.
100374
100392
  // The entitlement-bypass plist is assumed active on cloud sims.
100375
100393
  async bootstrapAx(udid) {
@@ -100387,6 +100405,19 @@ var remoteIosHost = {
100387
100405
  function pickIosHost(device) {
100388
100406
  return device.platform === "ios-remote" ? remoteIosHost : localIosHost;
100389
100407
  }
100408
+ var APP_ACCESSIBILITY_WAIT_MS = 1e4;
100409
+ async function enableAppAccessibilityBeforeLaunch(device) {
100410
+ const settled = await settleWithin(
100411
+ pickIosHost(device).enableAppAccessibility(device.id),
100412
+ APP_ACCESSIBILITY_WAIT_MS
100413
+ );
100414
+ if (settled.type === "value") return;
100415
+ 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`;
100416
+ process.stderr.write(
100417
+ `[ios-host] could not turn app accessibility on for ${device.id}: ${reason2}
100418
+ `
100419
+ );
100420
+ }
100390
100421
 
100391
100422
  // ../tool-server/src/blueprints/ios-network-records.ts
100392
100423
  var import_node_crypto7 = require("node:crypto");
@@ -135727,11 +135758,13 @@ function makeIosImpl(registry2) {
135727
135758
  requires: ["xcrun"],
135728
135759
  handler: async (_services, params, device, options) => {
135729
135760
  let nativeDevtools;
135761
+ let accessibility;
135730
135762
  if (!externalClaimForAnyId(device.id)) {
135731
135763
  const ndRef = nativeDevtoolsRef(device);
135732
135764
  nativeDevtools = await registry2.resolveService(ndRef.urn, ndRef.options);
135733
135765
  const blocked = await precheckNativeDevtools(nativeDevtools, params.udid);
135734
135766
  if (blocked) return blocked;
135767
+ accessibility = enableAppAccessibilityBeforeLaunch(device);
135735
135768
  }
135736
135769
  if (params.launchArgs?.length) {
135737
135770
  try {
@@ -135756,6 +135789,7 @@ function makeIosImpl(registry2) {
135756
135789
  }
135757
135790
  }
135758
135791
  }
135792
+ await accessibility;
135759
135793
  try {
135760
135794
  await execFileAsync27(
135761
135795
  "xcrun",
@@ -135861,9 +135895,10 @@ async function tolerateNothingToTerminate(terminate, nothingToTerminate) {
135861
135895
  // ../tool-server/src/tools/launch-app/platforms/shared.ts
135862
135896
  init_src2();
135863
135897
  function buildIosLaunchHandler(backend) {
135864
- return async (services, params) => {
135898
+ return async (services, params, device) => {
135865
135899
  const blocked = await precheckNativeDevtools(services.nativeDevtools, params.udid);
135866
135900
  if (blocked) return blocked;
135901
+ const accessibility = enableAppAccessibilityBeforeLaunch(device);
135867
135902
  if (params.launchArgs?.length) {
135868
135903
  try {
135869
135904
  await tolerateNothingToTerminate(
@@ -135886,6 +135921,7 @@ function buildIosLaunchHandler(backend) {
135886
135921
  );
135887
135922
  }
135888
135923
  }
135924
+ await accessibility;
135889
135925
  try {
135890
135926
  await backend.launch(params.udid, params.bundleId, params.launchArgs);
135891
135927
  } catch (err) {
@@ -136275,11 +136311,13 @@ function makeIosImpl2(registry2) {
136275
136311
  handler: async (_services, params, device, options) => {
136276
136312
  const { udid, bundleId } = params;
136277
136313
  let nativeDevtools;
136314
+ let accessibility;
136278
136315
  if (!externalClaimForAnyId(device.id)) {
136279
136316
  const ndRef = nativeDevtoolsRef(device);
136280
136317
  nativeDevtools = await registry2.resolveService(ndRef.urn, ndRef.options);
136281
136318
  const blocked = await precheckNativeDevtools(nativeDevtools, udid);
136282
136319
  if (blocked) return blocked;
136320
+ accessibility = enableAppAccessibilityBeforeLaunch(device);
136283
136321
  }
136284
136322
  try {
136285
136323
  await execFileAsync28("xcrun", await simctlArgsForUdid(udid, ["terminate", udid, bundleId]), {
@@ -136301,6 +136339,7 @@ function makeIosImpl2(registry2) {
136301
136339
  );
136302
136340
  }
136303
136341
  }
136342
+ await accessibility;
136304
136343
  try {
136305
136344
  await execFileAsync28(
136306
136345
  "xcrun",
@@ -136361,10 +136400,11 @@ var iosDeviceImpl2 = {
136361
136400
  // ../tool-server/src/tools/restart-app/platforms/shared.ts
136362
136401
  init_src2();
136363
136402
  function buildIosRestartHandler(backend) {
136364
- return async (services, params) => {
136403
+ return async (services, params, device) => {
136365
136404
  const { udid, bundleId } = params;
136366
136405
  const blocked = await precheckNativeDevtools(services.nativeDevtools, udid);
136367
136406
  if (blocked) return blocked;
136407
+ const accessibility = enableAppAccessibilityBeforeLaunch(device);
136368
136408
  try {
136369
136409
  await tolerateNothingToTerminate(
136370
136410
  backend.terminate(udid, bundleId),
@@ -136385,6 +136425,7 @@ function buildIosRestartHandler(backend) {
136385
136425
  { cause: err instanceof Error ? err : new Error(String(err)) }
136386
136426
  );
136387
136427
  }
136428
+ await accessibility;
136388
136429
  try {
136389
136430
  await backend.launch(udid, bundleId, params.launchArgs);
136390
136431
  } catch (err) {
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.31",
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": "c6cd14078b30ddf98be3cb622174d4b030bd0fb9"
102
102
  }