@swmansion/argent 0.35.1-next.82 → 0.35.1-next.84

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.
package/dist/cli-cmds.mjs CHANGED
@@ -38933,7 +38933,7 @@ function isCi(env = process.env) {
38933
38933
  var SESSION_ID2 = randomUUID5();
38934
38934
  function readCliVersion() {
38935
38935
  if (true) {
38936
- return "0.35.1-next.81";
38936
+ return "0.35.1-next.84";
38937
38937
  }
38938
38938
  return "0.0.0";
38939
38939
  }
@@ -17175,7 +17175,7 @@ function isCi(env = process.env) {
17175
17175
  var SESSION_ID = randomUUID4();
17176
17176
  function readCliVersion() {
17177
17177
  if (true) {
17178
- return "0.35.1-next.81";
17178
+ return "0.35.1-next.84";
17179
17179
  }
17180
17180
  return "0.0.0";
17181
17181
  }
@@ -38506,7 +38506,7 @@ async function startMcpServer(options) {
38506
38506
  const autoDescribeOn = autoDescribeEnabled();
38507
38507
  const whatsNewOn = whatsNewEnabled();
38508
38508
  const installedVersion = getInstalledVersion();
38509
- const highlightsVersion = true ? "0.35.1-next.81" : installedVersion;
38509
+ const highlightsVersion = true ? "0.35.1-next.84" : installedVersion;
38510
38510
  const captureTimeoutMs = options.captureTimeoutMs ?? CAPTURE_TIMEOUT_MS;
38511
38511
  const trees = createTreeMemory();
38512
38512
  const screenshots = createScreenshotMemory();
@@ -73410,7 +73410,7 @@ function isCi(env = process.env) {
73410
73410
  var SESSION_ID = (0, import_node_crypto4.randomUUID)();
73411
73411
  function readCliVersion() {
73412
73412
  if (true) {
73413
- return "0.35.1-next.81";
73413
+ return "0.35.1-next.84";
73414
73414
  }
73415
73415
  return "0.0.0";
73416
73416
  }
@@ -101018,6 +101018,7 @@ function nativeTreeToUi(node2, orientation) {
101018
101018
  return {
101019
101019
  ...node2,
101020
101020
  frame: nativeFrameToUi(node2.frame, orientation),
101021
+ ...node2.tapPoint ? { tapPoint: nativePointToUi(node2.tapPoint, orientation) } : {},
101021
101022
  children: node2.children.map((child) => nativeTreeToUi(child, orientation))
101022
101023
  };
101023
101024
  }
@@ -109525,6 +109526,7 @@ var describeNodeSchema = external_exports.lazy(
109525
109526
  () => external_exports.object({
109526
109527
  role: external_exports.string().min(1),
109527
109528
  frame: describeFrameSchema,
109529
+ tapPoint: describePointSchema.optional(),
109528
109530
  children: external_exports.array(describeNodeSchema),
109529
109531
  label: external_exports.string().optional(),
109530
109532
  hint: external_exports.string().optional(),
@@ -110023,8 +110025,8 @@ var axServiceBlueprint = {
110023
110025
  treeVersion: result.treeVersion
110024
110026
  };
110025
110027
  },
110026
- async foregroundApp() {
110027
- return await query("foreground_app");
110028
+ async foregroundApp(timeoutMs) {
110029
+ return await query("foreground_app", timeoutMs);
110028
110030
  },
110029
110031
  async orientation() {
110030
110032
  if (!lacksOrientationCommand) {
@@ -110347,7 +110349,42 @@ function clamp012(value) {
110347
110349
  function roundNormalized2(value) {
110348
110350
  return Math.round(value * 1e12) / 1e12;
110349
110351
  }
110350
- function adaptAXElement(el) {
110352
+ var SWITCH_WIDTH_PT = 63;
110353
+ var FLUSH_PT = 2;
110354
+ function containsFrame(outer, inner) {
110355
+ const eps = 1e-6;
110356
+ return inner.x >= outer.x - eps && inner.y >= outer.y - eps && inner.x + inner.width <= outer.x + outer.width + eps && inner.y + inner.height <= outer.y + outer.height + eps;
110357
+ }
110358
+ function onScreen(f) {
110359
+ return f.x >= 0 && f.y >= 0 && f.x + f.width <= 1 && f.y + f.height <= 1;
110360
+ }
110361
+ function switchRowTapPoint(el, elements, response) {
110362
+ const screen = response.screenFrame;
110363
+ const frame2 = el.frame;
110364
+ if (!screen || screen.width <= 0 || screen.height <= 0 || !frame2 || !el.label) return void 0;
110365
+ if (!el.traits?.includes("toggleButton") || el.value !== "0" && el.value !== "1") {
110366
+ return void 0;
110367
+ }
110368
+ if (!onScreen(frame2)) return void 0;
110369
+ const inside = elements.filter((o) => o !== el && o.frame && containsFrame(frame2, o.frame));
110370
+ const label = inside[0];
110371
+ if (inside.length !== 1 || label?.label?.trim() !== el.label.trim()) return void 0;
110372
+ const orientation = response.interfaceOrientation;
110373
+ const row = nativeFrameToUi(frame2, orientation);
110374
+ const text = nativeFrameToUi(label.frame, orientation);
110375
+ const pt = 1 / uiScreenSize(screen, orientation).width;
110376
+ const switchWidth = SWITCH_WIDTH_PT * pt;
110377
+ if (row.width <= switchWidth) return void 0;
110378
+ const flushLeading = Math.abs(text.x - row.x) <= FLUSH_PT * pt;
110379
+ const flushTrailing = Math.abs(text.x + text.width - (row.x + row.width)) <= FLUSH_PT * pt;
110380
+ if (flushLeading === flushTrailing) return void 0;
110381
+ const free = flushLeading ? row.x + row.width - (text.x + text.width) : text.x - row.x;
110382
+ if (free < switchWidth) return void 0;
110383
+ const x = flushLeading ? row.x + row.width - switchWidth / 2 : row.x + switchWidth / 2;
110384
+ const p = uiPointToNative({ x, y: row.y + row.height / 2 }, orientation);
110385
+ return { x: roundNormalized2(p.x), y: roundNormalized2(p.y) };
110386
+ }
110387
+ function adaptAXElement(el, response) {
110351
110388
  if (!el.frame) return null;
110352
110389
  const x1 = clamp012(el.frame.x);
110353
110390
  const y1 = clamp012(el.frame.y);
@@ -110357,6 +110394,7 @@ function adaptAXElement(el) {
110357
110394
  const height = y2 - y1;
110358
110395
  if (width <= 0 || height <= 0) return null;
110359
110396
  const traits = el.traits ?? [];
110397
+ const tapPoint = response && switchRowTapPoint(el, response.elements, response);
110360
110398
  return {
110361
110399
  role: mapNativeTraitsToDescribeRole(traits),
110362
110400
  frame: {
@@ -110365,6 +110403,7 @@ function adaptAXElement(el) {
110365
110403
  width: roundNormalized2(width),
110366
110404
  height: roundNormalized2(height)
110367
110405
  },
110406
+ ...tapPoint ? { tapPoint } : {},
110368
110407
  children: [],
110369
110408
  label: el.label,
110370
110409
  hint: el.hint,
@@ -110376,8 +110415,11 @@ function adaptAXElement(el) {
110376
110415
  ...traits.includes("selected") ? { selected: true } : {}
110377
110416
  };
110378
110417
  }
110379
- function adaptAXDescribeToDescribeResult(response) {
110380
- const children = response.elements.map(adaptAXElement).filter((n) => n !== null);
110418
+ function hasSwitchRow(response) {
110419
+ return response.elements.some((el) => switchRowTapPoint(el, response.elements, response));
110420
+ }
110421
+ function adaptAXDescribeToDescribeResult(response, options = {}) {
110422
+ const children = response.elements.map((el) => adaptAXElement(el, options.stockSwitches ? response : void 0)).filter((n) => n !== null);
110381
110423
  return parseDescribeResult({
110382
110424
  role: "AXGroup",
110383
110425
  frame: { x: 0, y: 0, width: 1, height: 1 },
@@ -110400,6 +110442,17 @@ function isStandingCaveat(hint) {
110400
110442
  function isBlindCaveat(hint) {
110401
110443
  return Boolean(hint?.endsWith(DEGRADED_BLIND_HINT) || hint?.endsWith(EXTERNAL_BLIND_BODY));
110402
110444
  }
110445
+ var FRONT_APP_TIMEOUT_MS = 1e3;
110446
+ var WEB_CONTENT_APPS = /* @__PURE__ */ new Set(["com.apple.mobilesafari", "com.apple.SafariViewService"]);
110447
+ async function appleAppInFront(ax) {
110448
+ try {
110449
+ const { bundleId } = await ax.foregroundApp(FRONT_APP_TIMEOUT_MS);
110450
+ return bundleId?.startsWith("com.apple.") === true && !WEB_CONTENT_APPS.has(bundleId);
110451
+ } catch (err) {
110452
+ if (axDaemonCrashSignal(err) !== void 0) throw err;
110453
+ return false;
110454
+ }
110455
+ }
110403
110456
  function startFailure(err) {
110404
110457
  return `The accessibility service failed to start (${errMsg(err)})`;
110405
110458
  }
@@ -110504,6 +110557,9 @@ async function readIos(registry2, device, params, options, facts) {
110504
110557
  facts.uiOrientation = response.interfaceOrientation;
110505
110558
  noteUiOrientation(device.id, response.interfaceOrientation, response.screenFrame);
110506
110559
  tree = adaptAXDescribeToDescribeResult(response);
110560
+ if (hasSwitchRow(response) && await appleAppInFront(axApi)) {
110561
+ tree = adaptAXDescribeToDescribeResult(response, { stockSwitches: true });
110562
+ }
110507
110563
  } catch (err) {
110508
110564
  crashSignal = axDaemonCrashSignal(err);
110509
110565
  if (crashSignal === void 0) {
@@ -116589,8 +116645,8 @@ function splitTvLabel(label) {
116589
116645
  function frameOf(element) {
116590
116646
  const f = element.frame;
116591
116647
  if (!f) return { x: 0, y: 0, width: 0, height: 0 };
116592
- const onScreen2 = f.x < 1 && f.y < 1 && f.x + f.width > 0 && f.y + f.height > 0;
116593
- return onScreen2 ? f : { x: f.x, y: f.y, width: 0, height: 0 };
116648
+ const onScreen3 = f.x < 1 && f.y < 1 && f.x + f.width > 0 && f.y + f.height > 0;
116649
+ return onScreen3 ? f : { x: f.x, y: f.y, width: 0, height: 0 };
116594
116650
  }
116595
116651
  var FOCUSED_TRAIT = "focused";
116596
116652
  function toNode(element) {
@@ -145921,12 +145977,12 @@ async function queryAndroidFullHierarchy(registry2, device, options = {}) {
145921
145977
 
145922
145978
  // ../tool-server/src/tools/flows/flow-chromium-tree.ts
145923
145979
  function projectChromiumNode(node2) {
145924
- const onScreen2 = node2.frame.width > 0 && node2.frame.height > 0;
145980
+ const onScreen3 = node2.frame.width > 0 && node2.frame.height > 0;
145925
145981
  const addressable = Boolean(
145926
145982
  node2.identifier || node2.label || node2.value || node2.clickable || node2.focused
145927
145983
  );
145928
145984
  let leaf = null;
145929
- if (onScreen2 && addressable) {
145985
+ if (onScreen3 && addressable) {
145930
145986
  leaf = { ...node2, children: [] };
145931
145987
  if (node2.password) {
145932
145988
  leaf.label = "[password]";
@@ -145939,7 +145995,7 @@ function projectChromiumNode(node2) {
145939
145995
  // Off-screen text must not hoist, or a text assert against an ancestor
145940
145996
  // would pass on content the screen doesn't show. A password's text never
145941
145997
  // bubbles up.
145942
- ownText: onScreen2 && !node2.password ? nodeText(node2) : "",
145998
+ ownText: onScreen3 && !node2.password ? nodeText(node2) : "",
145943
145999
  leaf,
145944
146000
  shield: Boolean(node2.identifier) || node2.password === true
145945
146001
  };
@@ -149686,6 +149742,9 @@ function fmtCoord(n) {
149686
149742
  function fmtFrame(f) {
149687
149743
  return `(${fmtCoord(f.x)},${fmtCoord(f.y)},${fmtCoord(f.width)},${fmtCoord(f.height)})`;
149688
149744
  }
149745
+ function fmtTapPoint(n) {
149746
+ return n.tapPoint ? ` tap=(${fmtCoord(n.tapPoint.x)},${fmtCoord(n.tapPoint.y)})` : "";
149747
+ }
149689
149748
  function escapeForLine(s) {
149690
149749
  return s.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
149691
149750
  }
@@ -149736,7 +149795,7 @@ function formatLine(n, indent, source) {
149736
149795
  const flagPart = formatFlags(n, source);
149737
149796
  const annotations = `${labelPart}${valuePart}${idPart}${hintPart}${flagPart}`.trim();
149738
149797
  const annotated = annotations ? ` ${annotations}` : "";
149739
- return `${pad}${n.role}${annotated} ${fmtFrame(n.frame)}`;
149798
+ return `${pad}${n.role}${annotated} ${fmtFrame(n.frame)}${fmtTapPoint(n)}`;
149740
149799
  }
149741
149800
  var CONTAIN_EPS = 5e-3;
149742
149801
  function frameContains2(outer, inner) {
@@ -150040,7 +150099,7 @@ function createDescribeTool(registry2) {
150040
150099
  longRunning: true,
150041
150100
  description: `Read the accessibility / DOM element tree for the current screen (or focused/focusable elements on TV targets). On a physical iPhone it covers only the app started with \`launch-app\`; call \`launch-app\` \`com.apple.springboard\` first to read system dialogs.<flag:harmonyos> On HarmonyOS (\`source: "harmony-uitest"\`), each top-level child is a window whose \`identifier\` is the owning bundle; a suspended display dumps its last frame with a \`hint\`.</flag:harmonyos><flag:macos-apps> On a Mac app, frames are fractions of the app window (expanded for sheets/menus).</flag:macos-apps>
150042
150101
  Use when you need tap coordinates or labels and have no fresh tree: interaction tools already attach one after each action (or reference an earlier \`Tree id\`).
150043
- Returns \`{ description, source, hint? }\`: one line per element with role, label/value/id/hint, flags, and normalized \`[0,1]\` frame \`(x,y,w,h)\`. Tap at \`(x+w/2, y+h/2)\`. No z-order/occlusion info; check a screenshot if a tap hits an overlay or a text field shows its placeholder as value. Fails if the tree backend is unreachable.
150102
+ Returns \`{ description, source, hint? }\`: one line per element with role, label/value/id/hint, flags, and normalized \`[0,1]\` frame \`(x,y,w,h)\`, and \`tap=(x,y)\` where the center misses the control. Tap at \`tap\` when present, else at \`(x+w/2, y+h/2)\`. No z-order/occlusion info; check a screenshot if a tap hits an overlay or a text field shows its placeholder as value. Fails if the tree backend is unreachable.
150044
150103
  For UIKit view properties (iOS sim) use \`native-find-views\`; for React Native components/testIDs use \`debugger-component-tree\`.`,
150045
150104
  zodSchema: zodSchema42,
150046
150105
  alwaysLoad: true,
@@ -150303,7 +150362,7 @@ function mapNode(xml, screenW, screenH, isRoot, v2) {
150303
150362
  }
150304
150363
  return node2;
150305
150364
  }
150306
- function onScreen(frame2) {
150365
+ function onScreen2(frame2) {
150307
150366
  if (!frame2) return false;
150308
150367
  const w = Math.min(frame2.x + frame2.width, 1) - Math.max(frame2.x, 0);
150309
150368
  const h = Math.min(frame2.y + frame2.height, 1) - Math.max(frame2.y, 0);
@@ -150343,7 +150402,7 @@ function adaptAndroidTree(capture, screen) {
150343
150402
  windows.forEach((w, i) => {
150344
150403
  const windowType = Number(w.attrs["window-type"]);
150345
150404
  const root = roots[i];
150346
- if (windowType === TYPE_INPUT_METHOD && onScreen(root.frame)) keyboard = true;
150405
+ if (windowType === TYPE_INPUT_METHOD && onScreen2(root.frame)) keyboard = true;
150347
150406
  if (foreground !== void 0 || !root.bundleId) return;
150348
150407
  if (windowType === TYPE_SYSTEM && root.bundleId === "android") alert = true;
150349
150408
  if (windowType !== TYPE_APPLICATION) return;
@@ -169637,12 +169696,12 @@ function wrapPreservingFailure(message, err) {
169637
169696
  return signal ? new FailureError(message, signal, { cause }) : new Error(message, { cause });
169638
169697
  }
169639
169698
  function projectIosDeviceNode(node2) {
169640
- const onScreen2 = node2.frame.width > 0 && node2.frame.height > 0;
169699
+ const onScreen3 = node2.frame.width > 0 && node2.frame.height > 0;
169641
169700
  return {
169642
169701
  skip: false,
169643
169702
  children: node2.children,
169644
169703
  // Off-screen text must not hoist.
169645
- ownText: onScreen2 ? nodeText(node2) : "",
169704
+ ownText: onScreen3 ? nodeText(node2) : "",
169646
169705
  leaf: { ...node2, children: [] },
169647
169706
  shield: Boolean(node2.identifier),
169648
169707
  // Scroll-clip inputs (see `flattenHoisting`), in the adapter's normalized
@@ -169677,13 +169736,13 @@ async function queryIosDeviceFlowTree(registry2, device) {
169677
169736
 
169678
169737
  // ../tool-server/src/tools/flows/flow-vega-tree.ts
169679
169738
  function projectVegaNode(node2) {
169680
- const onScreen2 = node2.frame.width > 0 && node2.frame.height > 0;
169739
+ const onScreen3 = node2.frame.width > 0 && node2.frame.height > 0;
169681
169740
  return {
169682
169741
  skip: false,
169683
169742
  children: node2.children,
169684
169743
  // Off-screen text must not hoist, or a text assert against an ancestor
169685
169744
  // would pass on content the screen doesn't show.
169686
- ownText: onScreen2 ? nodeText(node2) : "",
169745
+ ownText: onScreen3 ? nodeText(node2) : "",
169687
169746
  leaf: { ...node2, children: [] },
169688
169747
  shield: isAuthoredVegaTestId(node2.identifier)
169689
169748
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.35.1-next.82",
3
+ "version": "0.35.1-next.84",
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": "7d932dee9e464d81dce594948b685a445677342a"
101
+ "gitHead": "e75ceecfc2d93ffc0d01347aad987c4abf27928c"
102
102
  }
@@ -19,7 +19,7 @@ Each tool's description carries its parameters, defaults, and return shape. This
19
19
  ## Core Rules
20
20
 
21
21
  - **Open apps directly:** use `launch-app` or `open-url`, never tap home-screen icons. Use `restart-app` for clean in-memory state.
22
- - **Use the returned element tree:** interaction tools already attach a downscaled screenshot and `--- Elements after action (describe) ---` with normalized `[0,1]` tap frames. Call `describe` only when no fresh tree covers the current screen. Never derive routine tap coordinates from pixels.
22
+ - **Use the returned element tree:** interaction tools already attach a downscaled screenshot and `--- Elements after action (describe) ---` with normalized `[0,1]` tap frames. Tap at a line's `tap=(x,y)` when it has one, else at the frame center. Call `describe` only when no fresh tree covers the current screen. Never derive routine tap coordinates from pixels.
23
23
  - **Tree & screenshot IDs:** full trees/screenshots carry a `Tree id` / `Screenshot id`. When unchanged or slightly changed, a later result references that id (unchanged note or `-`/`+` diff); call `describe` or `screenshot` if that earlier result isn't in context. An identical tree does not mean the action did nothing.
24
24
  - **Batch known steps:** use `run-sequence` when multiple consecutive steps are known ahead of time (scroll sweeps, type + enter, form fill + submit).
25
25
  - **Text entry:** tap the field first (`keyboard` with no focus is a silent no-op). `keyboard` takes either `text` or `key`, not both. Keep `keyboard` as default; reserve `paste` for real paste flows (OTP, long tokens). Use `{{secret:<NAME>}}` placeholders for credentials and navigate/submit before capturing non-secure fields.