@swmansion/argent 0.22.2-next.1 → 0.22.2-next.11

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.
Files changed (35) hide show
  1. package/bin/darwin/simulator-server +0 -0
  2. package/bin/linux/simulator-server +0 -0
  3. package/bin/linux-arm64/simulator-server +0 -0
  4. package/bin/win32/simulator-server.exe +0 -0
  5. package/dist/cli-cmds.mjs +16 -1
  6. package/dist/installer.mjs +197 -7
  7. package/dist/mcp-server.mjs +92 -23
  8. package/dist/tool-server.cjs +345 -178
  9. package/package.json +1 -1
  10. package/rules/argent.md +7 -7
  11. package/skills/argent-device-interact/SKILL.md +1 -1
  12. package/bin/linux/resources/android/LICENSE.txt +0 -186
  13. package/bin/linux/resources/android/README.md +0 -11
  14. package/bin/linux/resources/android/arm64-v8a/libscreen-sharing-agent.so +0 -0
  15. package/bin/linux/resources/android/armeabi-v7a/libscreen-sharing-agent.so +0 -0
  16. package/bin/linux/resources/android/screen-sharing-agent.jar +0 -0
  17. package/bin/linux/resources/android/x86_64/libscreen-sharing-agent.so +0 -0
  18. package/bin/linux-arm64/resources/android/LICENSE.txt +0 -186
  19. package/bin/linux-arm64/resources/android/README.md +0 -11
  20. package/bin/linux-arm64/resources/android/arm64-v8a/libscreen-sharing-agent.so +0 -0
  21. package/bin/linux-arm64/resources/android/armeabi-v7a/libscreen-sharing-agent.so +0 -0
  22. package/bin/linux-arm64/resources/android/screen-sharing-agent.jar +0 -0
  23. package/bin/linux-arm64/resources/android/x86_64/libscreen-sharing-agent.so +0 -0
  24. package/bin/win32/resources/android/LICENSE.txt +0 -186
  25. package/bin/win32/resources/android/README.md +0 -11
  26. package/bin/win32/resources/android/arm64-v8a/libscreen-sharing-agent.so +0 -0
  27. package/bin/win32/resources/android/armeabi-v7a/libscreen-sharing-agent.so +0 -0
  28. package/bin/win32/resources/android/screen-sharing-agent.jar +0 -0
  29. package/bin/win32/resources/android/x86_64/libscreen-sharing-agent.so +0 -0
  30. /package/bin/{darwin/resources → resources}/android/LICENSE.txt +0 -0
  31. /package/bin/{darwin/resources → resources}/android/README.md +0 -0
  32. /package/bin/{darwin/resources → resources}/android/arm64-v8a/libscreen-sharing-agent.so +0 -0
  33. /package/bin/{darwin/resources → resources}/android/armeabi-v7a/libscreen-sharing-agent.so +0 -0
  34. /package/bin/{darwin/resources → resources}/android/screen-sharing-agent.jar +0 -0
  35. /package/bin/{darwin/resources → resources}/android/x86_64/libscreen-sharing-agent.so +0 -0
Binary file
Binary file
Binary file
Binary file
package/dist/cli-cmds.mjs CHANGED
@@ -2287,6 +2287,9 @@ var FAILURE_CODES = {
2287
2287
  SIMULATOR_SERVER_READY_TIMEOUT: "SIMULATOR_SERVER_READY_TIMEOUT",
2288
2288
  SIMULATOR_SERVER_PROCESS_ERROR: "SIMULATOR_SERVER_PROCESS_ERROR",
2289
2289
  SIMULATOR_SERVER_TERMINATED: "SIMULATOR_SERVER_TERMINATED",
2290
+ SIMULATOR_COMMAND_REJECTED: "SIMULATOR_COMMAND_REJECTED",
2291
+ SIMULATOR_COMMAND_ACK_TIMEOUT: "SIMULATOR_COMMAND_ACK_TIMEOUT",
2292
+ SIMULATOR_COMMAND_TRANSPORT_FAILED: "SIMULATOR_COMMAND_TRANSPORT_FAILED",
2290
2293
  AX_QUERY_TIMEOUT: "AX_QUERY_TIMEOUT",
2291
2294
  AX_DAEMON_READY_TIMEOUT: "AX_DAEMON_READY_TIMEOUT",
2292
2295
  AX_DAEMON_EXITED_BEFORE_READY: "AX_DAEMON_EXITED_BEFORE_READY",
@@ -2815,6 +2818,10 @@ var FLAG_REGISTRY = [
2815
2818
  name: "disable-auto-screenshot",
2816
2819
  description: "Disable the automatic screenshot captured after interaction tools."
2817
2820
  },
2821
+ {
2822
+ name: "disable-auto-describe",
2823
+ description: "Disable the accessibility element tree appended after interaction tools."
2824
+ },
2818
2825
  {
2819
2826
  name: "argent-lens",
2820
2827
  description: "Argent Lens \u2014 the propose_variant / await_user_selection tools and the Electron preview window for staging UI design variants and letting a human pick among them. Off by default while the feature is in development."
@@ -3285,6 +3292,14 @@ var CONFIG_SCHEMA = [
3285
3292
  // drained/reset, not just the file rewritten.
3286
3293
  manageCommand: "argent telemetry"
3287
3294
  },
3295
+ {
3296
+ key: "allowlist.enabled",
3297
+ description: "Whether `argent update` re-applies editor auto-approve allowlist rules. Unset (the default) keeps the current behavior: update refreshes the rules for editors that already have argent configured. Set to `false` to keep update from touching editor allowlists. `false` in either scope wins, so a committed project opt-out holds for every teammate.",
3298
+ scopes: ["project", "global"],
3299
+ parse: asBoolean,
3300
+ merge: "prioritize-restrictive",
3301
+ example: "false"
3302
+ },
3288
3303
  {
3289
3304
  key: "lens.agent",
3290
3305
  description: "Coding-agent id remembered by `argent lens` to skip the picker.",
@@ -7210,7 +7225,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
7210
7225
  var SESSION_ID2 = randomUUID5();
7211
7226
  function readCliVersion() {
7212
7227
  if (true) {
7213
- return "0.22.2-next.1";
7228
+ return "0.22.2-next.11";
7214
7229
  }
7215
7230
  return "0.0.0";
7216
7231
  }
@@ -15095,6 +15095,31 @@ function readConfigObject(scope = "global", options = {}) {
15095
15095
  }
15096
15096
  return {};
15097
15097
  }
15098
+ var FORBIDDEN_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
15099
+ function splitKey(dottedKey) {
15100
+ const parts = dottedKey.split(".");
15101
+ if (parts.length === 0 || parts.some((p) => p === "")) {
15102
+ throw new Error(`Invalid config key "${dottedKey}": empty path segment`);
15103
+ }
15104
+ for (const p of parts) {
15105
+ if (FORBIDDEN_SEGMENTS.has(p)) {
15106
+ throw new Error(`Invalid config key "${dottedKey}": forbidden segment "${p}"`);
15107
+ }
15108
+ }
15109
+ return parts;
15110
+ }
15111
+ function isPlainObject(value) {
15112
+ return !!value && typeof value === "object" && !Array.isArray(value);
15113
+ }
15114
+ function getAtPath(obj, dottedKey) {
15115
+ const parts = splitKey(dottedKey);
15116
+ let cur = obj;
15117
+ for (const part of parts) {
15118
+ if (!isPlainObject(cur)) return void 0;
15119
+ cur = cur[part];
15120
+ }
15121
+ return cur;
15122
+ }
15098
15123
  var LOCK_STALE_MS = 1e4;
15099
15124
  var LOCK_MAX_WAIT_MS = 2e3;
15100
15125
  var LOCK_RETRY_MS = 25;
@@ -15172,8 +15197,162 @@ var import_dotenv = __toESM(require_main(), 1);
15172
15197
  import * as fs4 from "node:fs";
15173
15198
  import * as path5 from "node:path";
15174
15199
 
15200
+ // ../configuration-core/src/merge.ts
15201
+ function mergeRestrictive(local, global2) {
15202
+ if (local === void 0) return global2;
15203
+ if (global2 === void 0) return local;
15204
+ if (typeof local === "boolean" && typeof global2 === "boolean") {
15205
+ return local && global2;
15206
+ }
15207
+ if (typeof local === "number" && typeof global2 === "number") {
15208
+ return Math.min(local, global2);
15209
+ }
15210
+ return local;
15211
+ }
15212
+ function toArray(value) {
15213
+ return Array.isArray(value) ? value : null;
15214
+ }
15215
+ function mergeUnion(local, global2) {
15216
+ const l2 = toArray(local);
15217
+ const g = toArray(global2);
15218
+ if (l2 === null && g === null) return local ?? global2;
15219
+ const merged = [...g ?? [], ...l2 ?? []];
15220
+ return Array.from(new Set(merged));
15221
+ }
15222
+ function mergeIntersection(local, global2) {
15223
+ const l2 = toArray(local);
15224
+ const g = toArray(global2);
15225
+ if (l2 === null && g === null) return local ?? global2;
15226
+ if (l2 === null) return global2;
15227
+ if (g === null) return local;
15228
+ const globalSet = new Set(g);
15229
+ return l2.filter((item) => globalSet.has(item));
15230
+ }
15231
+ function applyMergePolicy(policy, local, global2) {
15232
+ if (typeof policy === "function") return policy({ local, global: global2 });
15233
+ switch (policy) {
15234
+ case "prioritize-local":
15235
+ return local ?? global2;
15236
+ case "prioritize-global":
15237
+ return global2 ?? local;
15238
+ case "prioritize-restrictive":
15239
+ return mergeRestrictive(local, global2);
15240
+ case "union":
15241
+ return mergeUnion(local, global2);
15242
+ case "intersection":
15243
+ return mergeIntersection(local, global2);
15244
+ default: {
15245
+ const _exhaustive = policy;
15246
+ return _exhaustive;
15247
+ }
15248
+ }
15249
+ }
15250
+
15251
+ // ../configuration-core/src/config-schema.ts
15252
+ function asBoolean(raw) {
15253
+ return typeof raw === "boolean" ? raw : void 0;
15254
+ }
15255
+ function asString(raw) {
15256
+ if (typeof raw !== "string") return void 0;
15257
+ const trimmed = raw.trim();
15258
+ return trimmed === "" ? void 0 : trimmed;
15259
+ }
15260
+ function asStringArray(raw) {
15261
+ if (!Array.isArray(raw)) return void 0;
15262
+ const out = [];
15263
+ for (const item of raw) {
15264
+ if (typeof item === "string" && item.trim() !== "") out.push(item.trim());
15265
+ }
15266
+ return out;
15267
+ }
15268
+ var CONFIG_SCHEMA = [
15269
+ {
15270
+ key: "telemetry.enabled",
15271
+ description: "Whether anonymous opt-out telemetry is enabled (on by default; environment opt-outs like DO_NOT_TRACK are not reflected here \u2014 `argent telemetry status` shows effective consent). `false` in either scope wins, so a committed project opt-out holds for every teammate.",
15272
+ scopes: ["project", "global"],
15273
+ parse: asBoolean,
15274
+ merge: "prioritize-restrictive",
15275
+ // Opt-out: consent.ts reads an unstored value as enabled, so the config
15276
+ // surface must show the same rather than "(unset)".
15277
+ default: true,
15278
+ // Opt-in/out goes through the dedicated command so the live client is
15279
+ // drained/reset, not just the file rewritten.
15280
+ manageCommand: "argent telemetry"
15281
+ },
15282
+ {
15283
+ key: "allowlist.enabled",
15284
+ description: "Whether `argent update` re-applies editor auto-approve allowlist rules. Unset (the default) keeps the current behavior: update refreshes the rules for editors that already have argent configured. Set to `false` to keep update from touching editor allowlists. `false` in either scope wins, so a committed project opt-out holds for every teammate.",
15285
+ scopes: ["project", "global"],
15286
+ parse: asBoolean,
15287
+ merge: "prioritize-restrictive",
15288
+ example: "false"
15289
+ },
15290
+ {
15291
+ key: "lens.agent",
15292
+ description: "Coding-agent id remembered by `argent lens` to skip the picker.",
15293
+ scopes: ["project", "global"],
15294
+ parse: asString,
15295
+ merge: "prioritize-local",
15296
+ example: "claude"
15297
+ },
15298
+ {
15299
+ key: "ios.additionalDeviceSets",
15300
+ description: "Additional CoreSimulator device-set directories whose simulators argent should see alongside the default set. Absolute paths (or ~/\u2026); relative entries resolve against the project root (project scope) or home (global scope).",
15301
+ scopes: ["project", "global"],
15302
+ parse: asStringArray,
15303
+ // Additive rather than shadowing: global baseline first, project extras
15304
+ // after, deduplicated. `getAdditionalIosDeviceSets` re-implements this union
15305
+ // (path resolution must precede dedup) and guards on the preset staying "union".
15306
+ merge: "union",
15307
+ example: '["~/DeviceSets/ci"]'
15308
+ },
15309
+ {
15310
+ key: "recordings.directory",
15311
+ description: "Directory where finished screen recordings (mp4) are saved on the client host. Absolute, `~`-prefixed, or relative to the project root (home dir when not in a project). Unset \u21D2 `.argent/recordings` under the project root.",
15312
+ scopes: ["project", "global"],
15313
+ parse: asString,
15314
+ // Resolved on the client (the machine the mp4 is persisted to), so with a
15315
+ // remote `argent link` tool-server it is the *client's* config that decides.
15316
+ merge: "prioritize-local",
15317
+ example: "~/Movies/argent"
15318
+ }
15319
+ ];
15320
+ function getConfigDefinition(key, registry = CONFIG_SCHEMA) {
15321
+ return registry.find((def) => def.key === key);
15322
+ }
15323
+
15175
15324
  // ../configuration-core/src/config-access.ts
15176
15325
  import * as path6 from "node:path";
15326
+ function readScopeValue(def, scope, options) {
15327
+ if (!def.scopes.includes(scope)) return void 0;
15328
+ const raw = getAtPath(readConfigObject(scope, options), def.key);
15329
+ return raw === void 0 ? void 0 : def.parse(raw);
15330
+ }
15331
+ function getConfigValue(def, options = {}) {
15332
+ const local = readScopeValue(def, "project", options);
15333
+ const global2 = readScopeValue(def, "global", options);
15334
+ const merged = applyMergePolicy(def.merge, local, global2);
15335
+ return merged ?? def.default;
15336
+ }
15337
+ function getConfigValueByKey(key, options = {}, registry = CONFIG_SCHEMA) {
15338
+ const def = requireDefinition(key, registry);
15339
+ return getConfigValue(def, options);
15340
+ }
15341
+ function requireDefinition(key, registry = CONFIG_SCHEMA) {
15342
+ const def = getConfigDefinition(key, registry);
15343
+ if (!def) {
15344
+ throw new UnknownConfigKeyError(key);
15345
+ }
15346
+ return def;
15347
+ }
15348
+ var UnknownConfigKeyError = class extends Error {
15349
+ constructor(key) {
15350
+ super(`Unknown configuration key "${key}".`);
15351
+ this.key = key;
15352
+ this.name = "UnknownConfigKeyError";
15353
+ }
15354
+ key;
15355
+ };
15177
15356
 
15178
15357
  // ../telemetry/src/paths.ts
15179
15358
  function identityFilePath() {
@@ -15443,6 +15622,9 @@ var FAILURE_CODES = {
15443
15622
  SIMULATOR_SERVER_READY_TIMEOUT: "SIMULATOR_SERVER_READY_TIMEOUT",
15444
15623
  SIMULATOR_SERVER_PROCESS_ERROR: "SIMULATOR_SERVER_PROCESS_ERROR",
15445
15624
  SIMULATOR_SERVER_TERMINATED: "SIMULATOR_SERVER_TERMINATED",
15625
+ SIMULATOR_COMMAND_REJECTED: "SIMULATOR_COMMAND_REJECTED",
15626
+ SIMULATOR_COMMAND_ACK_TIMEOUT: "SIMULATOR_COMMAND_ACK_TIMEOUT",
15627
+ SIMULATOR_COMMAND_TRANSPORT_FAILED: "SIMULATOR_COMMAND_TRANSPORT_FAILED",
15446
15628
  AX_QUERY_TIMEOUT: "AX_QUERY_TIMEOUT",
15447
15629
  AX_DAEMON_READY_TIMEOUT: "AX_DAEMON_READY_TIMEOUT",
15448
15630
  AX_DAEMON_EXITED_BEFORE_READY: "AX_DAEMON_EXITED_BEFORE_READY",
@@ -16428,7 +16610,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
16428
16610
  var SESSION_ID = randomUUID4();
16429
16611
  function readCliVersion() {
16430
16612
  if (true) {
16431
- return "0.22.2-next.1";
16613
+ return "0.22.2-next.11";
16432
16614
  }
16433
16615
  return "0.0.0";
16434
16616
  }
@@ -23369,12 +23551,15 @@ async function update(args) {
23369
23551
  )
23370
23552
  );
23371
23553
  }
23372
- for (const [scope, adapters] of adaptersByScope) {
23373
- for (const adapter of adapters) {
23374
- if (!adapter.addAllowlist) continue;
23375
- try {
23376
- adapter.addAllowlist(projectRoot, scope);
23377
- } catch {
23554
+ const allowlistDisabled = getConfigValueByKey("allowlist.enabled", { cwd: projectRoot }) === false;
23555
+ if (!allowlistDisabled) {
23556
+ for (const [scope, adapters] of adaptersByScope) {
23557
+ for (const adapter of adapters) {
23558
+ if (!adapter.addAllowlist) continue;
23559
+ try {
23560
+ adapter.addAllowlist(projectRoot, scope);
23561
+ } catch {
23562
+ }
23378
23563
  }
23379
23564
  }
23380
23565
  }
@@ -23385,6 +23570,11 @@ async function update(args) {
23385
23570
  ...copyRulesAndAgents(localAdapters, projectRoot, "local", RULES_DIR, AGENTS_DIR)
23386
23571
  ];
23387
23572
  spinner2.stop("Configuration refreshed.");
23573
+ if (allowlistDisabled) {
23574
+ log.info(
23575
+ import_picocolors11.default.dim("Left editor auto-approve allowlists alone (allowlist.enabled is false).")
23576
+ );
23577
+ }
23388
23578
  if (results.length > 0) {
23389
23579
  note(results.join("\n"), "MCP Configs Updated");
23390
23580
  }
@@ -16471,6 +16471,9 @@ var FAILURE_CODES = {
16471
16471
  SIMULATOR_SERVER_READY_TIMEOUT: "SIMULATOR_SERVER_READY_TIMEOUT",
16472
16472
  SIMULATOR_SERVER_PROCESS_ERROR: "SIMULATOR_SERVER_PROCESS_ERROR",
16473
16473
  SIMULATOR_SERVER_TERMINATED: "SIMULATOR_SERVER_TERMINATED",
16474
+ SIMULATOR_COMMAND_REJECTED: "SIMULATOR_COMMAND_REJECTED",
16475
+ SIMULATOR_COMMAND_ACK_TIMEOUT: "SIMULATOR_COMMAND_ACK_TIMEOUT",
16476
+ SIMULATOR_COMMAND_TRANSPORT_FAILED: "SIMULATOR_COMMAND_TRANSPORT_FAILED",
16474
16477
  AX_QUERY_TIMEOUT: "AX_QUERY_TIMEOUT",
16475
16478
  AX_DAEMON_READY_TIMEOUT: "AX_DAEMON_READY_TIMEOUT",
16476
16479
  AX_DAEMON_EXITED_BEFORE_READY: "AX_DAEMON_EXITED_BEFORE_READY",
@@ -17153,6 +17156,14 @@ var CONFIG_SCHEMA = [
17153
17156
  // drained/reset, not just the file rewritten.
17154
17157
  manageCommand: "argent telemetry"
17155
17158
  },
17159
+ {
17160
+ key: "allowlist.enabled",
17161
+ description: "Whether `argent update` re-applies editor auto-approve allowlist rules. Unset (the default) keeps the current behavior: update refreshes the rules for editors that already have argent configured. Set to `false` to keep update from touching editor allowlists. `false` in either scope wins, so a committed project opt-out holds for every teammate.",
17162
+ scopes: ["project", "global"],
17163
+ parse: asBoolean,
17164
+ merge: "prioritize-restrictive",
17165
+ example: "false"
17166
+ },
17156
17167
  {
17157
17168
  key: "lens.agent",
17158
17169
  description: "Coding-agent id remembered by `argent lens` to skip the picker.",
@@ -18491,7 +18502,7 @@ async function stepArtifactBlocks(artifacts, status, ctx, depth) {
18491
18502
  return blocks;
18492
18503
  }
18493
18504
 
18494
- // ../argent-mcp/src/auto-screenshot.ts
18505
+ // ../argent-mcp/src/auto-capture.ts
18495
18506
  var AUTO_SCREENSHOT_TOOLS = /* @__PURE__ */ new Set([
18496
18507
  "gesture-tap",
18497
18508
  "gesture-swipe",
@@ -18532,6 +18543,30 @@ var DEFAULT_DELAY_MS = 1400;
18532
18543
  function autoScreenshotEnabled(options) {
18533
18544
  return !isFlagEnabled("disable-auto-screenshot", options);
18534
18545
  }
18546
+ var AUTO_DESCRIBE_TOOLS = /* @__PURE__ */ new Set([
18547
+ "gesture-tap",
18548
+ "gesture-swipe",
18549
+ "gesture-scroll",
18550
+ "gesture-drag",
18551
+ "gesture-custom",
18552
+ "gesture-pinch",
18553
+ "gesture-rotate",
18554
+ "button",
18555
+ "keyboard",
18556
+ "paste",
18557
+ "rotate",
18558
+ "launch-app",
18559
+ "restart-app",
18560
+ "open-url",
18561
+ "run-sequence"
18562
+ ]);
18563
+ function autoDescribeEnabled(options) {
18564
+ return !isFlagEnabled("disable-auto-describe", options);
18565
+ }
18566
+ var AUTO_DESCRIBE_HEADER = "--- Elements after action (describe) ---";
18567
+ function shouldAutoDescribe(toolName) {
18568
+ return AUTO_DESCRIBE_TOOLS.has(normalizeToolName(toolName));
18569
+ }
18535
18570
  var SECRET_PLACEHOLDER_MARKER = "{{secret:";
18536
18571
  function containsSecretPlaceholder(args) {
18537
18572
  try {
@@ -18628,6 +18663,7 @@ async function startMcpServer(options) {
18628
18663
  markFirstRunNoticeShown();
18629
18664
  }
18630
18665
  const autoScreenshotOn = autoScreenshotEnabled();
18666
+ const autoDescribeOn = autoDescribeEnabled();
18631
18667
  let TOOLS_URL;
18632
18668
  let AUTH_TOKEN;
18633
18669
  const resolved = await getResolvedToolsUrl();
@@ -18715,7 +18751,7 @@ async function startMcpServer(options) {
18715
18751
  { name: "argent", version: getInstalledVersion() },
18716
18752
  {
18717
18753
  capabilities: { tools: {} },
18718
- instructions: "Argent \u2014 iOS Simulator, Android Emulator, and Chromium app control for interacting, testing, profiling and debugging mobile and Chromium applications. Always use discovery tools (describe / debugger-component-tree / screenshot) before tapping \u2014 never guess coordinates. On session end: call stop-all-simulator-servers with devices: [...] naming the devices this session used, and perform any necessary cleanup. 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. Full guidance is in the argent rule loaded from .claude/rules/argent.md."
18754
+ 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 (or debugger-component-tree) only when no fresh tree is available \u2014 never guess coordinates from pixels. On session end: call stop-all-simulator-servers with devices: [...] naming the devices this session used, and perform any necessary cleanup. 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. Full guidance is in the argent rule loaded from .claude/rules/argent.md."
18719
18755
  }
18720
18756
  );
18721
18757
  server.setRequestHandler(ListToolsRequestSchema, async () => {
@@ -18767,15 +18803,17 @@ async function startMcpServer(options) {
18767
18803
  content = await toMcpContent(result, outputHint, ctx, params.arguments);
18768
18804
  }
18769
18805
  const udid = getUdidFromArgs(params.arguments);
18770
- if (autoScreenshotOn && udid && shouldAutoScreenshot(params.name) && containsSecretPlaceholder(params.arguments)) {
18806
+ const wantScreenshot = autoScreenshotOn && shouldAutoScreenshot(params.name);
18807
+ const wantTree = autoDescribeOn && shouldAutoDescribe(params.name);
18808
+ if (udid && (wantScreenshot || wantTree) && containsSecretPlaceholder(params.arguments)) {
18771
18809
  content = [
18772
18810
  ...content,
18773
18811
  {
18774
18812
  type: "text",
18775
- text: "Auto-screenshot skipped: the input contains a {{secret:\u2026}} placeholder, and a screenshot of this screen could reveal the typed secret. The secret is already typed \u2014 do not send the typing step again, or the field will hold two copies of it. Submit or navigate away, then verify the resulting screen as usual. Only this call is covered: the next call is screenshotted normally, and captures the secret if the field is still on screen. To cover the submit as well, put the typing and the submit in ONE `run-sequence` the next time you type a secret."
18813
+ text: "Auto-screenshot and element tree skipped: the input contains a {{secret:\u2026}} placeholder, and a capture of this screen could reveal the typed secret. The secret is already typed \u2014 do not send the typing step again, or the field will hold two copies of it. Submit or navigate away, then verify the resulting screen as usual. Only this call is covered: the next call is captured normally, and shows the secret if the field is still on screen. To cover the submit as well, put the typing and the submit in ONE `run-sequence` the next time you type a secret."
18776
18814
  }
18777
18815
  ];
18778
- } else if (autoScreenshotOn && udid && shouldAutoScreenshot(params.name)) {
18816
+ } else if (udid && (wantScreenshot || wantTree)) {
18779
18817
  const maxWaitMs = getAutoScreenshotDelayMs(params.name);
18780
18818
  if (maxWaitMs > 0) {
18781
18819
  try {
@@ -18791,25 +18829,56 @@ async function startMcpServer(options) {
18791
18829
  await new Promise((r) => setTimeout(r, maxWaitMs));
18792
18830
  }
18793
18831
  }
18794
- try {
18795
- const screenshotResult = await callTool("screenshot", { udid });
18796
- const screenshotContent = await toMcpContent(screenshotResult.result, "image", {
18797
- toolsUrl: TOOLS_URL,
18798
- authToken: AUTH_TOKEN,
18799
- deviceId: udid
18800
- });
18801
- const hasImage = screenshotContent.some((b) => b.type === "image");
18802
- if (hasImage) {
18803
- content = [
18804
- ...content,
18805
- {
18806
- type: "text",
18807
- text: "--- Screen after action ---"
18808
- },
18809
- ...screenshotContent
18810
- ];
18832
+ if (wantScreenshot) {
18833
+ try {
18834
+ const screenshotResult = await callTool("screenshot", { udid });
18835
+ const screenshotContent = await toMcpContent(screenshotResult.result, "image", {
18836
+ toolsUrl: TOOLS_URL,
18837
+ authToken: AUTH_TOKEN,
18838
+ deviceId: udid
18839
+ });
18840
+ const hasImage = screenshotContent.some((b) => b.type === "image");
18841
+ if (hasImage) {
18842
+ content = [
18843
+ ...content,
18844
+ {
18845
+ type: "text",
18846
+ text: "--- Screen after action ---"
18847
+ },
18848
+ ...screenshotContent
18849
+ ];
18850
+ }
18851
+ } catch {
18852
+ }
18853
+ }
18854
+ if (wantTree) {
18855
+ const t1 = Date.now();
18856
+ try {
18857
+ const d = await callTool("describe", { udid });
18858
+ const desc = d.result?.description;
18859
+ if (typeof desc === "string" && desc.length > 0) {
18860
+ content = [
18861
+ ...content,
18862
+ { type: "text", text: `${AUTO_DESCRIBE_HEADER}
18863
+ ${desc}` }
18864
+ ];
18865
+ }
18866
+ await spyLog({
18867
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
18868
+ event: "auto_describe",
18869
+ name: params.name,
18870
+ durationMs: Date.now() - t1,
18871
+ chars: typeof desc === "string" ? desc.length : 0
18872
+ });
18873
+ } catch (e) {
18874
+ await spyLog({
18875
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
18876
+ event: "auto_describe",
18877
+ name: params.name,
18878
+ durationMs: Date.now() - t1,
18879
+ error: String(e instanceof Error ? e.message : e)
18880
+ });
18811
18881
  }
18812
- } catch {
18813
18882
  }
18814
18883
  }
18815
18884
  if (note) {