@swmansion/argent 0.33.1-next.20 → 0.33.1-next.21

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
@@ -36069,7 +36069,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
36069
36069
  var SESSION_ID2 = randomUUID5();
36070
36070
  function readCliVersion() {
36071
36071
  if (true) {
36072
- return "0.33.1-next.20";
36072
+ return "0.33.1-next.21";
36073
36073
  }
36074
36074
  return "0.0.0";
36075
36075
  }
@@ -16986,7 +16986,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
16986
16986
  var SESSION_ID = randomUUID4();
16987
16987
  function readCliVersion() {
16988
16988
  if (true) {
16989
- return "0.33.1-next.20";
16989
+ return "0.33.1-next.21";
16990
16990
  }
16991
16991
  return "0.0.0";
16992
16992
  }
@@ -29203,6 +29203,53 @@ function getAutoScreenshotDelayMs(toolName) {
29203
29203
  return base;
29204
29204
  }
29205
29205
 
29206
+ // ../argent-mcp/src/unchanged-tree.ts
29207
+ import { randomInt } from "node:crypto";
29208
+ var MAX_UNCHANGED_IN_A_ROW = 3;
29209
+ var UNCHANGED_MAX_AGE_MS = 5 * 6e4;
29210
+ function treeIdLine(id) {
29211
+ return `Tree id: ${id}`;
29212
+ }
29213
+ function unchangedTreeNote(id, tool) {
29214
+ return `Identical to element tree \`${id}\`, which an earlier \`${tool}\` result returned, so it is not repeated here: take elements and frames from that tree. The action can still have had an effect that the tree does not show, such as text typed in a field. Call \`describe\` if you do not have tree \`${id}\`.`;
29215
+ }
29216
+ function randomTag() {
29217
+ return randomInt(36 ** 3).toString(36).padStart(3, "0");
29218
+ }
29219
+ function createTreeMemory(now = Date.now, tag = randomTag()) {
29220
+ const lastSent = /* @__PURE__ */ new Map();
29221
+ let count = 0;
29222
+ const sent = (udid, tree, toolName) => {
29223
+ const id = `${tag}-${++count}`;
29224
+ lastSent.set(udid, { id, tree, tool: normalizeToolName(toolName), sentAt: now(), notes: 0 });
29225
+ return id;
29226
+ };
29227
+ return {
29228
+ sent,
29229
+ afterAction(udid, tree, toolName) {
29230
+ const last = lastSent.get(udid);
29231
+ const identical = last !== void 0 && last.tree === tree;
29232
+ if (last !== void 0 && identical && last.notes < MAX_UNCHANGED_IN_A_ROW && now() - last.sentAt <= UNCHANGED_MAX_AGE_MS) {
29233
+ last.notes += 1;
29234
+ return { text: unchangedTreeNote(last.id, last.tool), identical, note: true };
29235
+ }
29236
+ const id = sent(udid, tree, toolName);
29237
+ return { text: `${treeIdLine(id)}
29238
+ ${tree}`, identical, note: false };
29239
+ },
29240
+ forget(udid) {
29241
+ lastSent.delete(udid);
29242
+ }
29243
+ };
29244
+ }
29245
+ function describedTree(result) {
29246
+ const { description, hint } = result ?? {};
29247
+ if (typeof description !== "string" || description.length === 0) return void 0;
29248
+ const hintLine = typeof hint === "string" && hint && !description.includes(hint) ? `Hint: ${hint}
29249
+ ` : "";
29250
+ return `${hintLine}${description}`;
29251
+ }
29252
+
29206
29253
  // ../argent-mcp/src/keyword-facts.ts
29207
29254
  var SHOWS_KEYWORDS = [
29208
29255
  /^claude-code\b/,
@@ -29441,7 +29488,7 @@ ${stopped.join("\n")}`;
29441
29488
  }
29442
29489
 
29443
29490
  // ../argent-mcp/src/instructions.ts
29444
- var SERVER_INSTRUCTIONS = "Argent \u2014 iOS Simulator, Android Emulator, and Chromium app control for interacting, testing, profiling and debugging mobile and Chromium applications. Interaction tools return the screen after the action: a screenshot plus the accessibility element tree with normalized tap frames. Take coordinates from that tree; call describe only when no fresh tree is available \u2014 never guess coordinates from pixels. Do not stop simulator servers when a task finishes: the next task reuses them. Call stop-all-simulator-servers when the user asks to clean up or ends the session, or when a skill tells you to recycle a device's services, always with devices: [...] naming the devices this session used. Never stop a Metro the user started unless they ask. One tool-server is shared by every agent using this argent install, so an unscoped call tears down their devices too \u2014 reserve it for a deliberate machine-wide cleanup.";
29491
+ var SERVER_INSTRUCTIONS = "Argent \u2014 iOS Simulator, Android Emulator, and Chromium app control for interacting, testing, profiling and debugging mobile and Chromium applications. Interaction tools return the screen after the action: a screenshot plus the accessibility element tree with normalized tap frames. Take coordinates from that tree; call describe only when no fresh tree is available \u2014 never guess coordinates from pixels. A result names an identical earlier tree by its tree id in place of repeating it. Do not stop simulator servers when a task finishes: the next task reuses them. Call stop-all-simulator-servers when the user asks to clean up or ends the session, or when a skill tells you to recycle a device's services, always with devices: [...] naming the devices this session used. Never stop a Metro the user started unless they ask. One tool-server is shared by every agent using this argent install, so an unscoped call tears down their devices too \u2014 reserve it for a deliberate machine-wide cleanup.";
29445
29492
 
29446
29493
  // ../argent-mcp/src/installed-version.ts
29447
29494
  import * as fs11 from "node:fs";
@@ -29576,6 +29623,7 @@ async function startMcpServer(options) {
29576
29623
  const autoScreenshotOn = autoScreenshotEnabled();
29577
29624
  const autoDescribeOn = autoDescribeEnabled();
29578
29625
  const captureTimeoutMs = options.captureTimeoutMs ?? CAPTURE_TIMEOUT_MS;
29626
+ const trees = createTreeMemory();
29579
29627
  let TOOLS_URL;
29580
29628
  let AUTH_TOKEN;
29581
29629
  const resolved = await getResolvedToolsUrl();
@@ -29677,19 +29725,21 @@ async function startMcpServer(options) {
29677
29725
  const t1 = Date.now();
29678
29726
  try {
29679
29727
  const d = await callTool("describe", { udid }, { signal });
29680
- const { description: desc, hint } = d.result ?? {};
29728
+ const tree = describedTree(d.result);
29729
+ const shown = tree === void 0 ? void 0 : trees.afterAction(udid, tree, toolName);
29681
29730
  await spyLog({
29682
29731
  ts: (/* @__PURE__ */ new Date()).toISOString(),
29683
29732
  event: "auto_describe",
29684
29733
  name: toolName,
29685
29734
  durationMs: Date.now() - t1,
29686
- chars: typeof desc === "string" ? desc.length : 0
29735
+ chars: tree?.length ?? 0,
29736
+ // `identical` is the repeat rate; `note` is what the agent was spared.
29737
+ identical: shown?.identical ?? false,
29738
+ note: shown?.note ?? false
29687
29739
  });
29688
- if (typeof desc !== "string" || desc.length === 0) return [];
29689
- const hintLine = typeof hint === "string" && hint && !desc.includes(hint) ? `Hint: ${hint}
29690
- ` : "";
29740
+ if (shown === void 0) return [];
29691
29741
  return [{ type: "text", text: `${AUTO_DESCRIBE_HEADER}
29692
- ${hintLine}${desc}` }];
29742
+ ${shown.text}` }];
29693
29743
  } catch (e) {
29694
29744
  await spyLog({
29695
29745
  ts: (/* @__PURE__ */ new Date()).toISOString(),
@@ -29727,8 +29777,9 @@ ${hintLine}${desc}` }];
29727
29777
  return { tools: [] };
29728
29778
  }
29729
29779
  });
29730
- server.setRequestHandler(CallToolRequestSchema, async ({ params }) => {
29780
+ server.setRequestHandler(CallToolRequestSchema, async ({ params }, { signal: cancelled }) => {
29731
29781
  const t0 = Date.now();
29782
+ let treeUdid;
29732
29783
  await spyLog({
29733
29784
  ts: (/* @__PURE__ */ new Date()).toISOString(),
29734
29785
  event: "tool_called",
@@ -29762,6 +29813,14 @@ ${hintLine}${desc}` }];
29762
29813
  content = await toMcpContent(result, outputHint, ctx, params.arguments);
29763
29814
  }
29764
29815
  const udid = getUdidFromArgs(params.arguments);
29816
+ if (udid && autoDescribeOn && canonicalToolId(params.name) === "describe") {
29817
+ const tree = describedTree(result);
29818
+ if (tree !== void 0) {
29819
+ treeUdid = udid;
29820
+ const id = trees.sent(udid, tree, "describe");
29821
+ content = [...content, { type: "text", text: treeIdLine(id) }];
29822
+ }
29823
+ }
29765
29824
  const wantScreenshot = autoScreenshotOn && shouldAutoScreenshot(params.name, params.arguments);
29766
29825
  const wantTree = autoDescribeOn && shouldAutoDescribe(params.name, params.arguments);
29767
29826
  if (udid && (wantScreenshot || wantTree) && containsSecretPlaceholder(params.arguments)) {
@@ -29782,14 +29841,17 @@ ${hintLine}${desc}` }];
29782
29841
  const signal = AbortSignal.timeout(captureTimeoutMs);
29783
29842
  const screenshot = wantScreenshot ? captureScreenshotBlocks(udid, signal) : Promise.resolve([]);
29784
29843
  if (!screenSettled) await screenshot;
29844
+ if (wantTree) treeUdid = udid;
29785
29845
  const tree = wantTree ? captureTreeBlocks(udid, params.name, signal) : Promise.resolve([]);
29786
29846
  content = [...content, ...await screenshot, ...await tree];
29787
29847
  }
29788
29848
  if (note) {
29789
29849
  content = [{ type: "text", text: note }, ...content];
29790
29850
  }
29851
+ if (treeUdid !== void 0 && cancelled.aborted) trees.forget(treeUdid);
29791
29852
  return { content };
29792
29853
  } catch (err) {
29854
+ if (treeUdid !== void 0) trees.forget(treeUdid);
29793
29855
  await spyLog({
29794
29856
  ts: (/* @__PURE__ */ new Date()).toISOString(),
29795
29857
  event: "tool_result",
@@ -101278,7 +101278,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
101278
101278
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
101279
101279
  function readCliVersion() {
101280
101280
  if (true) {
101281
- return "0.33.1-next.20";
101281
+ return "0.33.1-next.21";
101282
101282
  }
101283
101283
  return "0.0.0";
101284
101284
  }
@@ -160890,7 +160890,7 @@ function createDescribeTool(registry2) {
160890
160890
  // Android's device probes plus the tree dump can outlast the 30s MCP fetch timeout.
160891
160891
  longRunning: true,
160892
160892
  description: `Get the accessibility / DOM element tree for the current screen.
160893
- Use when you need element frames or labels and have no fresh tree: most interaction tools (not tv-remote or shake) already return one after each action.
160893
+ Use when you need element frames or labels and have no fresh tree: most interaction tools (not tv-remote or shake) already return one after each action, or name an identical earlier one by its tree id.
160894
160894
  On iOS it reads the AXRuntime accessibility service, so it sees whatever is visible, including system dialogs and permission prompts. While a system dialog is visible it returns the dialog's elements (buttons, text); otherwise the foreground app's. On a physical iOS device it covers only the app started with launch-app; to read system dialogs there, launch-app \`com.apple.springboard\` first.
160895
160895
  On Android it reads the tree through Argent's UiAutomation helper, falling back to \`uiautomator dump\`. On Chromium it walks the DOM over the Chrome DevTools Protocol: every visible element with its ARIA role, accessible name and bounding rect.
160896
160896
  On Vega (Fire TV) it reads the on-device automation toolkit; \`[focused]\`/\`[selected]\` mark the D-pad cursor, which you move with \`tv-remote\` (Vega has no touch).<flag:harmonyos>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.33.1-next.20",
3
+ "version": "0.33.1-next.21",
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",
package/rules/argent.md CHANGED
@@ -9,7 +9,7 @@ Argent - general rules:
9
9
  - use the platform the user named; otherwise prefer a device `list-devices` shows already running, and don't default to iOS; in a single-platform project boot that platform.
10
10
  - if tap fails twice, stop retrying and re-run a discovery tool
11
11
  - Prefer mcp-tool calls over raw commands like `xcrun` or `adb`; use them as fallback.
12
- - Interaction tools return screenshot and element tree automatically.
12
+ - Interaction tools return screenshot and element tree automatically; an identical earlier tree is named by its tree id, not repeated.
13
13
  - prefer `launch-app` or `open-url` than tapping icons on home screen.
14
14
  - If a task can require a saved e2e test, load `argent-create-e2e` (`argent-qa-e2e` for acceptance tests) before the first launch or in-app action; recording is not retroactive.
15
15
  - Load the matching `argent-*` skill before React Native build/debug, profiling, a physical phone, a Mac app or a TV.
@@ -40,7 +40,7 @@ Each tool's own description carries its parameters, defaults, return shape and e
40
40
 
41
41
  ## 3. Finding Tap Targets
42
42
 
43
- After an action moves you to a different screen, or whenever you don't know an element's coordinates, discover before tapping. Interaction results already carry the element tree (`--- Elements after action (describe) ---`): use it, and call a discovery tool only when no fresh tree covers the current screen.
43
+ After an action moves you to a different screen, or whenever you don't know an element's coordinates, discover before tapping. Interaction results already carry the element tree (`--- Elements after action (describe) ---`): use it, and call a discovery tool only when no fresh tree covers the current screen. Each tree has a `Tree id`. When the tree is identical to an earlier one, the result names that id in place of the tree: use that tree, and call `describe` if it is not in your context. An identical tree does not mean the action did nothing.
44
44
 
45
45
  | Need | Tool |
46
46
  | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
@@ -16,7 +16,7 @@ For implementation tasks that modify visible UI, this workflow also serves as a
16
16
  1. **Baseline screenshot**: call `screenshot` to see the current UI state. For visual regression comparison or UI change verification, capture the baseline at `scale: 1.0` with `includeImageInContext: false` and keep the returned `path` before editing whenever feasible.
17
17
  2. **Find target**: get element coordinates from a discovery tool before tapping:
18
18
  - **App screens (React Native included), in-app modals and system dialogs**: `describe`. Fall back to `screenshot` only if an overlay is not exposed reliably. When the app raises its own permission dialog, answer it here; that's the real flow under test. To take a prompt _out_ of the flow, use `argent-settings-permissions` during setup.
19
- 3. **Interact**: perform the action (`gesture-tap`, `gesture-swipe`, `keyboard`, `button`, ...); you receive a screenshot and element tree automatically.
19
+ 3. **Interact**: perform the action (`gesture-tap`, `gesture-swipe`, `keyboard`, `button`, ...); you receive a screenshot and element tree automatically (an identical earlier tree is named by its `Tree id`, not repeated).
20
20
  4. **Verify**: check the returned screenshot. If it shows a loading/transitional state, block with `await-ui-element` (expected element `visible`, or a spinner `hidden`) rather than a guessed delay (its result carries the new screenshot and element tree), but only with a selector you can trust (`text`/`identifier`/`role`) that the screen is known to have or that you saw in a prior `describe`; a guessed one just times out. Otherwise use a short fixed wait. Pick evidence by what's being asserted:
21
21
  - **Visual** (layout, spacing, color, typography, image/icon rendering, clipping, overflow, text rendering): prefer `screenshot-diff` against the step 1 baseline: it surfaces pixel-visible changes the auto-screenshot might miss. Fall back to inspecting the auto-screenshot only when a stable baseline isn't available.
22
22
  - **Structural** (navigation state, element existence, accessibility labels/values, selection, hierarchy, route): verify with `describe` or `debugger-component-tree`.