@swmansion/argent 0.34.1-next.6 → 0.34.1-next.8

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
@@ -36085,7 +36085,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
36085
36085
  var SESSION_ID2 = randomUUID5();
36086
36086
  function readCliVersion() {
36087
36087
  if (true) {
36088
- return "0.34.1-next.5";
36088
+ return "0.34.1-next.8";
36089
36089
  }
36090
36090
  return "0.0.0";
36091
36091
  }
@@ -16993,7 +16993,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
16993
16993
  var SESSION_ID = randomUUID4();
16994
16994
  function readCliVersion() {
16995
16995
  if (true) {
16996
- return "0.34.1-next.5";
16996
+ return "0.34.1-next.8";
16997
16997
  }
16998
16998
  return "0.0.0";
16999
16999
  }
@@ -20395,6 +20395,64 @@ var RETIRED_BUNDLED_PATHS = {
20395
20395
  ],
20396
20396
  rules: []
20397
20397
  };
20398
+ var RETIRED_GLOBAL_RULES = [
20399
+ {
20400
+ path: "argent.md",
20401
+ shipped: [
20402
+ "bfb07b5ad949f63ab9b41919f2c24c937b163c7644d6760fa8afda4f68c809f7",
20403
+ "90f6b24882ae077c8d5129652e7630c1b2a5651f5e800474d3b6e223222049f1",
20404
+ "cbf6cb5d898c14cd3460c85a15fd9ceeb7b3fed669df7e0932e61cad93a5a6fe",
20405
+ "ac8d19e2ece55ff6b7c554fd6a4a3eebc5a09af1eb95f6625f96781bb45505e2",
20406
+ "30bbef749f18d4fde7a5501941d58decf1e8abb2ca8c4e51f63e72bab3d863e2",
20407
+ "81663dc2f70aa2111388092e6027d27eddd89e9b5bdfb16043bdc96088d6850d",
20408
+ "5e3143dea13d15a9c80c7e24a1a3e4e1fb3ed34c8a077eccb74cb6e2a8a1c4a3",
20409
+ "51f8360f997c6bfcfb51c4c99d5f8b3a3b632ca4ca43a7f4ba5e7d8e8881798d",
20410
+ "5e27f0ed6dbdb4def30163387485b3c783c702bbc6594bc210d236454b6c5780",
20411
+ "06391305389e958b127a832de9977dc75a2164355a924bddb312b824656a8f72",
20412
+ "09ac21fd92efa4fc877e951475a0488a78ba4dbdfba63d6f1efd761c9f625866",
20413
+ "45fc6a4bf294af60e73ec9ab3c02219627767b5622467f7a57bb5b6976fd4126",
20414
+ "2f4eb998af8b5106b5fb49f19efd282d38366316c4a78f7123bc3d005c5848a4",
20415
+ "e425ebaafba2eeeb02f714d3e0b1ce19e0844fc4d661dbbd25bf6086ffc714b0",
20416
+ "d6cc846c1d3444bf8eaee6aa313a207e8c7a94391041df9d2a2908088c0191a7",
20417
+ "ad0f23a946e9bbc721a16b17a9516bf2570e7529094da0677f33ed63d43e0caa",
20418
+ "b1ce95af4c0e57cb478a148b6b8744ad4f8f15522441e566c0c6f7210c78fc79",
20419
+ "e3dc376ba736cef94de401bd5457c3df0192128164cbb44ac3e2ece57ad1af66",
20420
+ "aa43aeb338a5d0f50c425d8163dc697b9ffd7042539be05a67ed3ed85e8ba60f",
20421
+ "983f29ab70a565367bda4fbed705eb41fbe7b6767c70eb0569d2501f298e72c4",
20422
+ "251487afb2fda1707a27701be7fcc33b481e0176d43a4c946287a35595d26585",
20423
+ "933e657ec8789e57db8164fc2f58a692e9dc889bebd131eaa0f2017ef055add8",
20424
+ "35ea33df169b390d331733ab325dbf23b3804bc25927908e6050977563d7b10c",
20425
+ "7a89d0406784242b03ca187a2740898d4f69ccb7b76508ec373ad2aba5fb0a2c",
20426
+ "fa69c9e943572ab603b1318bc9a5c07f9d0e7c8f2cc208f6e29a6795991dab73",
20427
+ "192013fdee1954ba013985c022d91f37bbc34bf36ae4bcd76ab2cdf2f2b3f341",
20428
+ "4476fd58e33ede9cc938da7e954781fa8d5805f18cd71701cdaa4ec3bcabb085",
20429
+ "db80ca8efbe5dd775153ab39c63d4c387d1b5d864a1e7eae21fbd158f05d9e54",
20430
+ "32f3d3915f04fb43c4e835e076ec26ed7d88232f66963538308233c19055c951",
20431
+ "7aee698f1b8e5ed0399f45a72435961847b96097322e5f3391fd31adf03b8180",
20432
+ "1829b14538d913852bacb82a50d79cade45ea56c78fb2bc85e6e46f0f9ac6439",
20433
+ "c012bec1b6a225a0f03b7fc9133746d2130ce8f45cd1c2c86559bc31cafd81f7",
20434
+ "11f62b29badb21f0489e835975e5fa62b996188ed7194d01590b5eb6f020615b",
20435
+ "b83879ae5540a9e46140c5a1d0f93599e9aa48fbe752aba12db7a93cd8940834",
20436
+ "ec38c5e586782f376daec565302b3548fd22ea3236c384f9bb37b1d16bde3f39",
20437
+ "c40437e8afb99cc4cd6005ae3710d861b6f0af0da0f1de35499f4cb9ac790999",
20438
+ "4d62da692bc8735f3979f54e6c7e2c3b2e9d530e5898958aa41a869b5e9e6f11",
20439
+ "bec052b7cf7668da7f1cdddb5bae4c50b6db87ece0ec6930f1229e6e0bb8f96e",
20440
+ "0fffc00cc3d6fe32c93d857c8b4f8ad9754f7daf76c51cda6acc86aa5487e1e6",
20441
+ "1cb7d1f65d5014954a6d25bde4c9a271910ffed240899178b8dbf9e138ce83f3",
20442
+ "e3bc44c749ba6cecd50d1e4dc45c1dd3d896414982b339f07d62351c396e975d",
20443
+ "db0435ad74da7ba0e3ec362aab60c011ac24caa8aa9630dc77393058710c0deb",
20444
+ "aec395f5fdccc42c13ff39263ab101c5bebe68ed4181ee126a819c3a0a45aa94",
20445
+ "4867ae2b7f8bb207bad663759487b729be8bf58f9523d4589b885e5857966cc1",
20446
+ "5f9efed48536447a7ffc8d68b8a43eb20bceeb2adab884352f20cbbe5be37ac5",
20447
+ "51d5d412d5ff4edbc2dc837c33978d85678b5ff6461c987944469f535dbcc295",
20448
+ "d28de55c47c64bd9f7a7493825e1913f9fbf317976d6981f71ae24fb21631dea",
20449
+ "cb9a8c33b1dc6c1188674a1a846e97d1b3a58b2c386021b63139cfd33c1abe6c",
20450
+ "33bae8d5c6e38a730e15ceab19335145ed06988d475696690302daa1bf1221f3",
20451
+ "5f9b146efdac28c3d67a8b1fcdca3ab5950b69e7c74defa7dca5cbf4e44cc98a",
20452
+ "af428399983712d11e4cfc9999bd600ba5121f17acb1ce97f70e695ef68772b2"
20453
+ ]
20454
+ }
20455
+ ];
20398
20456
  function hashBundledContent(content) {
20399
20457
  return createHash2("sha256").update(content.replace(/\r\n/g, "\n")).digest("hex");
20400
20458
  }
@@ -20612,7 +20670,8 @@ function readRetiredFile(targetDir, relativePath) {
20612
20670
  function findRetiredFiles(retired, bundleDir, targetDir) {
20613
20671
  const found = [];
20614
20672
  for (const { path: relativePath, shipped } of retired) {
20615
- if (fs16.existsSync(path17.join(bundleDir, ...relativePath.split("/")))) continue;
20673
+ if (bundleDir !== null && fs16.existsSync(path17.join(bundleDir, ...relativePath.split("/"))))
20674
+ continue;
20616
20675
  const content = readRetiredFile(targetDir, relativePath);
20617
20676
  if (content === null) continue;
20618
20677
  const sha256 = hashBundledContent(content);
@@ -22055,18 +22114,29 @@ function removeCodexRules(configPath) {
22055
22114
  function findRetiredRulesAndAgents(scans, root, rulesDir, agentsDir) {
22056
22115
  const targets = scans.flatMap(({ adapters, scope }) => {
22057
22116
  const { ruleTargets, agentTargets } = getManagedContentTargets(adapters, root, scope);
22117
+ const globalRules = scope === "global";
22058
22118
  return [
22059
- ...ruleTargets.map((target) => ({ kind: "rules", target, bundleDir: rulesDir })),
22060
- ...agentTargets.map((target) => ({ kind: "agents", target, bundleDir: agentsDir }))
22119
+ ...ruleTargets.map((target) => ({
22120
+ kind: "rules",
22121
+ target,
22122
+ bundleDir: globalRules ? null : rulesDir,
22123
+ retired: globalRules ? [...RETIRED_BUNDLED_PATHS.rules, ...RETIRED_GLOBAL_RULES] : RETIRED_BUNDLED_PATHS.rules
22124
+ })),
22125
+ ...agentTargets.map((target) => ({
22126
+ kind: "agents",
22127
+ target,
22128
+ bundleDir: agentsDir,
22129
+ retired: RETIRED_BUNDLED_PATHS.agents
22130
+ }))
22061
22131
  ];
22062
22132
  });
22063
22133
  const found = [];
22064
22134
  const seen = /* @__PURE__ */ new Set();
22065
- for (const { kind, target, bundleDir } of targets) {
22135
+ for (const { kind, target, bundleDir, retired } of targets) {
22066
22136
  const dir = resolveLinkedDestination(target.targetPath);
22067
22137
  if (seen.has(`${kind}:${realpathOrSelf(dir)}`)) continue;
22068
22138
  seen.add(`${kind}:${realpathOrSelf(dir)}`);
22069
- const files = findRetiredFiles(RETIRED_BUNDLED_PATHS[kind], bundleDir, target.targetPath);
22139
+ const files = findRetiredFiles(retired, bundleDir, target.targetPath);
22070
22140
  if (files.length === 0) continue;
22071
22141
  found.push({ kind, target, location: formatCopyDestination(target, dir, root), files });
22072
22142
  }
@@ -22075,7 +22145,8 @@ function findRetiredRulesAndAgents(scans, root, rulesDir, agentsDir) {
22075
22145
  function copyRulesAndAgents(adapters, root, scope, rulesDir, agentsDir) {
22076
22146
  const results = [];
22077
22147
  const managedTargets = getManagedContentTargets(adapters, root, scope);
22078
- for (const target of managedTargets.ruleTargets) {
22148
+ const globalScope = scope === "global";
22149
+ for (const target of globalScope ? [] : managedTargets.ruleTargets) {
22079
22150
  try {
22080
22151
  const written = copyDir(rulesDir, target.targetPath);
22081
22152
  if (written) {
@@ -22096,6 +22167,16 @@ function copyRulesAndAgents(adapters, root, scope, rulesDir, agentsDir) {
22096
22167
  }
22097
22168
  }
22098
22169
  for (const target of managedTargets.codexConfigTargets) {
22170
+ if (globalScope) {
22171
+ try {
22172
+ if (removeCodexRules(target.targetPath)) {
22173
+ results.push(` Removed argent rules from ${target.targetPath} (developer_instructions)`);
22174
+ }
22175
+ } catch (err) {
22176
+ results.push(` Could not remove argent rules from ${target.targetPath}: ${err}`);
22177
+ }
22178
+ continue;
22179
+ }
22099
22180
  try {
22100
22181
  const injected = injectCodexRules(target.targetPath, rulesDir);
22101
22182
  if (injected) {
@@ -23807,7 +23888,8 @@ async function init2(args) {
23807
23888
  scope,
23808
23889
  allowlistEnabled: allowlist.enabled,
23809
23890
  skills,
23810
- copiedRules: copyResults.length > 0,
23891
+ // A global install writes no rule, only removes old ones.
23892
+ copiedRules: normalizedScope === "local" && copyResults.length > 0,
23811
23893
  wroteProjectTelemetryOptOut
23812
23894
  });
23813
23895
  const skillsMissing = skillsAreMissing(skills);
@@ -29504,7 +29504,7 @@ ${stopped.join("\n")}`;
29504
29504
  }
29505
29505
 
29506
29506
  // ../argent-mcp/src/instructions.ts
29507
- 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.";
29507
+ var SERVER_INSTRUCTIONS = "Argent \u2014 iOS Simulator, Android Emulator, and Chromium app control for interacting, testing, profiling and debugging mobile and Chromium applications. Use the platform the user named; otherwise prefer a device list-devices shows already running, and do not default to iOS. In a single-platform project, boot that platform. Prefer these tools over raw xcrun or adb commands, which are a fallback. Prefer launch-app or open-url over tapping home-screen icons. If the task may need a saved e2e test, load the argent-create-e2e skill (argent-qa-e2e for acceptance tests) before the first launch or in-app action: recording is not retroactive. Load the matching argent-* skill before React Native build or debug work, profiling, a physical phone, a Mac app or a TV. 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. If a tap fails twice, stop retrying and call a discovery tool again. Use await-ui-element to wait for the UI instead of polling with screenshots. 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. The argent CLI manages the toolkit: argent --help lists its commands.";
29508
29508
 
29509
29509
  // ../argent-mcp/src/installed-version.ts
29510
29510
  import * as fs11 from "node:fs";
@@ -79847,10 +79847,10 @@ async function probeAlive(device) {
79847
79847
  async function listExternalDevices(options = {}) {
79848
79848
  const providers = discoverProviders();
79849
79849
  if (providers.length === 0) return [];
79850
- const devices = providers.flatMap((record2) => readProviderDevices2(record2));
79851
- if (options.probe === false) return devices;
79852
- const alive = await Promise.all(devices.map((device) => probeAlive(device).catch(() => false)));
79853
- return devices.filter((_, index) => alive[index]);
79850
+ const devices2 = providers.flatMap((record2) => readProviderDevices2(record2));
79851
+ if (options.probe === false) return devices2;
79852
+ const alive = await Promise.all(devices2.map((device) => probeAlive(device).catch(() => false)));
79853
+ return devices2.filter((_, index) => alive[index]);
79854
79854
  }
79855
79855
  function findExternalDevice(id) {
79856
79856
  const parsed = parseExternalId(id);
@@ -84120,7 +84120,7 @@ async function removeAdbReverse(serial, devicePort) {
84120
84120
  }
84121
84121
  }
84122
84122
  function parseAdbDevices(stdout) {
84123
- const devices = [];
84123
+ const devices2 = [];
84124
84124
  const lines = stdout.split("\n");
84125
84125
  for (const raw of lines) {
84126
84126
  const line = raw.trim();
@@ -84129,9 +84129,9 @@ function parseAdbDevices(stdout) {
84129
84129
  if (!match) continue;
84130
84130
  const state3 = match[2];
84131
84131
  if (!ADB_DEVICE_STATES.has(state3)) continue;
84132
- devices.push({ serial: match[1], state: state3 });
84132
+ devices2.push({ serial: match[1], state: state3 });
84133
84133
  }
84134
- return devices;
84134
+ return devices2;
84135
84135
  }
84136
84136
  function consolePortFromAdbSerial(serial) {
84137
84137
  const emu = serial.match(/^emulator-(\d+)$/);
@@ -101285,7 +101285,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
101285
101285
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
101286
101286
  function readCliVersion() {
101287
101287
  if (true) {
101288
- return "0.34.1-next.5";
101288
+ return "0.34.1-next.8";
101289
101289
  }
101290
101290
  return "0.0.0";
101291
101291
  }
@@ -103831,7 +103831,7 @@ async function setContainsUdid(deviceSet, udid) {
103831
103831
  );
103832
103832
  const data = JSON.parse(stdout);
103833
103833
  return Object.values(data.devices ?? {}).some(
103834
- (devices) => devices.some((d) => d.udid === udid)
103834
+ (devices2) => devices2.some((d) => d.udid === udid)
103835
103835
  );
103836
103836
  } catch {
103837
103837
  return false;
@@ -103930,10 +103930,10 @@ async function listDeviceSetSimulators(deviceSet) {
103930
103930
  const data = JSON.parse(stdout);
103931
103931
  const out = [];
103932
103932
  const deviceTypes = [];
103933
- for (const [runtimeId, devices] of Object.entries(data.devices)) {
103933
+ for (const [runtimeId, devices2] of Object.entries(data.devices)) {
103934
103934
  const runtimeKind = simulatorRuntimeKind(runtimeId);
103935
103935
  if (!runtimeKind) continue;
103936
- for (const d of devices) {
103936
+ for (const d of devices2) {
103937
103937
  if (!d.isAvailable) continue;
103938
103938
  out.push({
103939
103939
  udid: d.udid,
@@ -104184,8 +104184,8 @@ async function getRemoteSimulatorRuntimeKind(udid, options) {
104184
104184
  const cached3 = remoteRuntimeKindCache.get(id);
104185
104185
  if (cached3) return cached3;
104186
104186
  try {
104187
- const { devices } = await simctlListDevices(options);
104188
- for (const [runtime, entries] of Object.entries(devices)) {
104187
+ const { devices: devices2 } = await simctlListDevices(options);
104188
+ for (const [runtime, entries] of Object.entries(devices2)) {
104189
104189
  if (!entries.some((d) => d.udid === id)) continue;
104190
104190
  const kind = simulatorRuntimeKind(runtime);
104191
104191
  if (kind) remoteRuntimeKindCache.set(id, kind);
@@ -124806,8 +124806,8 @@ async function getBootedUdidsInSet(deviceSet, signal) {
124806
124806
  });
124807
124807
  const data = JSON.parse(stdout);
124808
124808
  const udids = /* @__PURE__ */ new Set();
124809
- for (const devices of Object.values(data.devices)) {
124810
- for (const device of devices) {
124809
+ for (const devices2 of Object.values(data.devices)) {
124810
+ for (const device of devices2) {
124811
124811
  if (device.state === "Booted") {
124812
124812
  udids.add(device.udid);
124813
124813
  rememberDeviceSet(device.udid, deviceSet);
@@ -125907,9 +125907,9 @@ async function listIosPhysicalDevices() {
125907
125907
  return [];
125908
125908
  }
125909
125909
  const payload = json2;
125910
- const devices = payload?.result?.devices ?? [];
125910
+ const devices2 = payload?.result?.devices ?? [];
125911
125911
  const out = [];
125912
- for (const d of devices) {
125912
+ for (const d of devices2) {
125913
125913
  const hardwareProperties = d.hardwareProperties ?? {};
125914
125914
  const udid = hardwareProperties.udid ?? d.identifier;
125915
125915
  if (!udid) {
@@ -128541,7 +128541,7 @@ async function listVvdImages() {
128541
128541
  var VEGA_DISCOVERY_LIST_TIMEOUT_MS = 6e3;
128542
128542
  var VEGA_DISCOVERY_INFO_TIMEOUT_MS = 4e3;
128543
128543
  function parseVegaDeviceList(stdout) {
128544
- const devices = [];
128544
+ const devices2 = [];
128545
128545
  for (const raw of stdout.split("\n")) {
128546
128546
  const line = raw.trim();
128547
128547
  const sep11 = line.indexOf(" : ");
@@ -128552,9 +128552,9 @@ function parseVegaDeviceList(stdout) {
128552
128552
  const parts2 = rhs.split(/\s+-\s+/);
128553
128553
  const serial = parts2[parts2.length - 1]?.trim();
128554
128554
  if (!serial) continue;
128555
- devices.push({ serial, type });
128555
+ devices2.push({ serial, type });
128556
128556
  }
128557
- return devices;
128557
+ return devices2;
128558
128558
  }
128559
128559
  function filterVvdShadowsFromAndroid(androidDevices2, vvdAdbSerials) {
128560
128560
  return androidDevices2.filter((d) => !vvdAdbSerials.has(d.serial));
@@ -128692,10 +128692,10 @@ async function listRemoteIosSimulators() {
128692
128692
  try {
128693
128693
  const result = await simctlListDevices();
128694
128694
  const out = [];
128695
- for (const [runtime, devices] of Object.entries(result.devices)) {
128695
+ for (const [runtime, devices2] of Object.entries(result.devices)) {
128696
128696
  const runtimeKind = simulatorRuntimeKind(runtime);
128697
128697
  if (!runtimeKind) continue;
128698
- for (const d of devices) {
128698
+ for (const d of devices2) {
128699
128699
  if (d.isAvailable === false) continue;
128700
128700
  out.push({
128701
128701
  platform: "ios-remote",
@@ -128939,7 +128939,7 @@ Chromium apps are discovered by probing CDP debugging ports (default 9222; exten
128939
128939
  osVersion: h.osVersion
128940
128940
  }))
128941
128941
  ];
128942
- const devices = [
128942
+ const devices2 = [
128943
128943
  ...iosTagged,
128944
128944
  ...iosPhysicalTagged,
128945
128945
  ...iosRemote,
@@ -128950,7 +128950,7 @@ Chromium apps are discovered by probing CDP debugging ports (default 9222; exten
128950
128950
  ...harmonyTagged,
128951
128951
  ...external.map(toListedExternal)
128952
128952
  ];
128953
- devices.sort((a, b) => readinessRank(a) - readinessRank(b));
128953
+ devices2.sort((a, b) => readinessRank(a) - readinessRank(b));
128954
128954
  const avdsTagged = avds.map(
128955
128955
  (a) => foldableAvds.has(a.name) ? { ...a, foldable: true } : a
128956
128956
  );
@@ -128962,7 +128962,7 @@ Chromium apps are discovered by probing CDP debugging ports (default 9222; exten
128962
128962
  ...adbPrefix ? [adbServerHint(adbPrefix)] : []
128963
128963
  ];
128964
128964
  return {
128965
- devices,
128965
+ devices: devices2,
128966
128966
  avds: avdsTagged,
128967
128967
  ...hints.length > 0 ? { hint: hints.join("\n\n") } : {}
128968
128968
  };
@@ -131812,16 +131812,16 @@ function createPreviewRouter(registry2) {
131812
131812
  const KNOWN_DEVICES_TTL_MS = 5e3;
131813
131813
  let knownDevices = null;
131814
131814
  let knownDevicesInFlight = null;
131815
- function deviceIdSet(devices) {
131815
+ function deviceIdSet(devices2) {
131816
131816
  const ids = /* @__PURE__ */ new Set();
131817
- for (const d of devices) {
131817
+ for (const d of devices2) {
131818
131818
  const id = d.platform === "ios" ? d.udid : d.serial;
131819
131819
  if (typeof id === "string") ids.add(id);
131820
131820
  }
131821
131821
  return ids;
131822
131822
  }
131823
- function rememberDevices(devices) {
131824
- knownDevices = { ids: deviceIdSet(devices), at: Date.now() };
131823
+ function rememberDevices(devices2) {
131824
+ knownDevices = { ids: deviceIdSet(devices2), at: Date.now() };
131825
131825
  }
131826
131826
  async function knownDeviceIds() {
131827
131827
  if (knownDevices && Date.now() - knownDevices.at < KNOWN_DEVICES_TTL_MS) {
@@ -133730,6 +133730,159 @@ async function resolveTvApi(registry2, udid) {
133730
133730
  init_adb();
133731
133731
  init_capability();
133732
133732
 
133733
+ // ../tool-server/src/utils/secrets.ts
133734
+ init_src2();
133735
+ init_capability();
133736
+ init_src();
133737
+ var SECRET_PLACEHOLDER_MARKER = "{{secret:";
133738
+ function resolveSecretPlaceholders(text, options = {}) {
133739
+ const secrets = [];
133740
+ let sources;
133741
+ const resolved = text.replace(SECRET_PLACEHOLDER_RE, (_placeholder, rawName) => {
133742
+ sources ??= [
133743
+ ...options.clientSecrets ? [clientSecretSource(options.clientSecrets)] : [],
133744
+ ...secretSources(options)
133745
+ ];
133746
+ const { name, value } = lookupPlaceholderSecret(rawName, sources);
133747
+ if (value === void 0) {
133748
+ const names = secretNames(sources);
133749
+ const where = options.clientSecrets ? `the required secret ${name} was not provided: the argent client forwards its secrets to this tool-server and has no value for it, and no source on the machine running the tool-server defines it either` : `no source on the machine running the tool-server defines ${name}`;
133750
+ throw new InvalidToolInputError(
133751
+ `Unknown secret "${rawName}" \u2014 ${where}. Available secrets: ${names.length ? names.join(", ") : "(none)"}.
133752
+ Sources consulted, first match wins:
133753
+ ${describeSecretSources(sources)}
133754
+ ` + (options.clientSecrets ? clientSecretPlacementAdvice(name) : secretPlacementAdvice(name, options)),
133755
+ {
133756
+ error_code: FAILURE_CODES.SECRET_PLACEHOLDER_UNKNOWN,
133757
+ failure_stage: "secret_placeholder_resolution",
133758
+ error_kind: "validation"
133759
+ }
133760
+ );
133761
+ }
133762
+ if (!secrets.some((s) => s.name === name)) secrets.push({ name, value });
133763
+ return value;
133764
+ });
133765
+ return { text: resolved, secrets };
133766
+ }
133767
+ function scrubSecretValues(text, secrets) {
133768
+ return scrubSecretChunk(text, secrets, true).emit;
133769
+ }
133770
+ function scrubSecretChunk(text, secrets, final) {
133771
+ const ordered = orderedSecrets(secrets);
133772
+ if (ordered.length === 0) return { emit: text, held: 0 };
133773
+ const longestValue = ordered[0].value.length;
133774
+ const names = new Set(ordered.map((secret) => secret.name));
133775
+ const longestName = Math.max(...ordered.map((secret) => secret.name.length));
133776
+ let out = "";
133777
+ let copied = 0;
133778
+ let at = 0;
133779
+ while (at < text.length) {
133780
+ const marker = markerLengthAt(text, at, names, longestName);
133781
+ if (marker > 0 && !valueLeavesMarker(text, at, at + marker, ordered)) {
133782
+ at += marker;
133783
+ continue;
133784
+ }
133785
+ if (!final && text.length - at < longestValue && beginsAValue(text, at, ordered)) break;
133786
+ const hit = ordered.find((secret) => text.startsWith(secret.value, at));
133787
+ if (hit) {
133788
+ out += `${text.slice(copied, at)}${SECRET_PLACEHOLDER_MARKER}${hit.name}}}`;
133789
+ at += hit.value.length;
133790
+ copied = at;
133791
+ continue;
133792
+ }
133793
+ at += 1;
133794
+ }
133795
+ return {
133796
+ emit: copied === 0 ? text.slice(0, at) : out + text.slice(copied, at),
133797
+ held: text.length - at
133798
+ };
133799
+ }
133800
+ function valueLeavesMarker(text, from2, end, ordered) {
133801
+ for (let at = from2; at < end; at++) {
133802
+ for (const { value } of ordered) {
133803
+ if (at + value.length >= end && text.startsWith(value, at)) return true;
133804
+ }
133805
+ }
133806
+ return false;
133807
+ }
133808
+ function beginsAValue(text, at, ordered) {
133809
+ const rest = text.slice(at);
133810
+ return ordered.some(({ value }) => value.length > rest.length && value.startsWith(rest));
133811
+ }
133812
+ function orderedSecrets(secrets) {
133813
+ return secrets.filter(({ value }) => value.length > 0).sort((a, b) => b.value.length - a.value.length);
133814
+ }
133815
+ function markerLengthAt(text, at, names, longestName) {
133816
+ if (!text.startsWith(SECRET_PLACEHOLDER_MARKER, at)) return 0;
133817
+ const from2 = at + SECRET_PLACEHOLDER_MARKER.length;
133818
+ const window2 = text.slice(from2, from2 + longestName + 2);
133819
+ const end = window2.indexOf("}}");
133820
+ return end >= 0 && names.has(window2.slice(0, end)) ? SECRET_PLACEHOLDER_MARKER.length + end + 2 : 0;
133821
+ }
133822
+ function redactSecretsFromError(err, secrets) {
133823
+ const forms = secrets.flatMap((secret) => {
133824
+ const quoted = secret.value.replaceAll("'", "'\\''");
133825
+ return quoted === secret.value ? [secret] : [secret, { name: secret.name, value: quoted }];
133826
+ });
133827
+ const scrub = (s) => scrubSecretValues(s, forms);
133828
+ if (err instanceof Error) {
133829
+ err.message = scrub(err.message);
133830
+ if (err.stack) err.stack = scrub(err.stack);
133831
+ return err;
133832
+ }
133833
+ if (typeof err === "string") return scrub(err);
133834
+ return err;
133835
+ }
133836
+
133837
+ // ../tool-server/src/utils/typed-secrets.ts
133838
+ var MAX_VALUES = 256;
133839
+ var devices = /* @__PURE__ */ new Map();
133840
+ function deviceKey(deviceId) {
133841
+ return deviceId.toLowerCase();
133842
+ }
133843
+ function noteTypedSecrets(deviceId, secrets) {
133844
+ if (secrets.length === 0) return;
133845
+ const key2 = deviceKey(deviceId);
133846
+ const values = devices.get(key2) ?? /* @__PURE__ */ new Map();
133847
+ devices.set(key2, values);
133848
+ for (const { name, value } of secrets) {
133849
+ if (value.length === 0) continue;
133850
+ values.delete(value);
133851
+ values.set(value, `${SECRET_PLACEHOLDER_MARKER}${name}}}`);
133852
+ if (values.size > MAX_VALUES) values.delete(values.keys().next().value);
133853
+ }
133854
+ }
133855
+ function secretTypedOn(deviceId) {
133856
+ return devices.has(deviceKey(deviceId));
133857
+ }
133858
+ var WITHHELD_INPUT_TEXT = "[text withheld: a secret was typed on this device]";
133859
+ function redactTypedSecrets(deviceId, text) {
133860
+ const values = devices.get(deviceKey(deviceId));
133861
+ if (!values || values.size === 0) return text;
133862
+ const longestFirst = [...values].sort((a, b) => b[0].length - a[0].length);
133863
+ let out = "";
133864
+ for (let at = 0; at < text.length; ) {
133865
+ const hit = longestFirst.find(([value]) => text.startsWith(value, at));
133866
+ out += hit ? hit[1] : text[at];
133867
+ at += hit ? hit[0].length : 1;
133868
+ }
133869
+ return out;
133870
+ }
133871
+ function twinOf(tree, quotable, node2) {
133872
+ if (tree === node2) return quotable;
133873
+ for (let i = 0; i < tree.children.length; i++) {
133874
+ const twin = quotable.children[i];
133875
+ const found = twin && twinOf(tree.children[i], twin, node2);
133876
+ if (found) return found;
133877
+ }
133878
+ return void 0;
133879
+ }
133880
+ function quotedText(data, deviceId, node2, read) {
133881
+ if (!data.quotableTree) return redactTypedSecrets(deviceId, read(node2));
133882
+ const twin = twinOf(data.tree, data.quotableTree, node2);
133883
+ return twin ? read(twin) : WITHHELD_INPUT_TEXT;
133884
+ }
133885
+
133733
133886
  // ../tool-server/src/utils/poll-describe-tree.ts
133734
133887
  init_src2();
133735
133888
  async function pollDescribeTree(args) {
@@ -142976,7 +143129,11 @@ function flattenHoisting(node2, project, out, scrollClip = null) {
142976
143129
  if (t) childText.push(t);
142977
143130
  }
142978
143131
  const descendantText2 = childText.join(" ");
142979
- const subtree = view.ownText && !includesWordsCI(descendantText2, view.ownText) ? [view.ownText, descendantText2].filter(Boolean).join(" ") : descendantText2 || view.ownText;
143132
+ const ownParts = view.ownTextParts ?? [view.ownText];
143133
+ const subtree = [
143134
+ ...ownParts.filter((part) => part && !includesWordsCI(descendantText2, part)),
143135
+ descendantText2
143136
+ ].filter(Boolean).join(" ");
142980
143137
  if (view.leaf) {
142981
143138
  if (subtree && subtree !== view.ownText) view.leaf.subtreeText = subtree;
142982
143139
  out.push(view.leaf);
@@ -143561,7 +143718,8 @@ function timeoutNote(params, lastTree, fetchError, lastData) {
143561
143718
  case "text": {
143562
143719
  const first = textCheckTarget(matches2, void 0, isMacos(params));
143563
143720
  const wanted = params.textMatch === "equals" ? "equal" : "contain";
143564
- base = first ? `element matched but its text was "${macFieldText(first, isMacos(params)) ?? assertText(first)}" (wanted to ${wanted} "${params.expectedText}")` : "no element matched the selector before timeout";
143721
+ const shown = first ? redactTypedSecrets(params.udid, macFieldText(first, isMacos(params)) ?? assertText(first)) : void 0;
143722
+ base = shown !== void 0 ? `element matched but its text was "${shown}" (wanted to ${wanted} "${params.expectedText}")` : "no element matched the selector before timeout";
143565
143723
  break;
143566
143724
  }
143567
143725
  case "hidden":
@@ -147796,7 +147954,7 @@ init_external_devices();
147796
147954
  var import_node_crypto13 = require("node:crypto");
147797
147955
  init_src2();
147798
147956
  init_device_info();
147799
- function deviceKey(target) {
147957
+ function deviceKey2(target) {
147800
147958
  const logicalId = target.reactNative?.logicalDeviceId;
147801
147959
  if (logicalId) return logicalId;
147802
147960
  try {
@@ -147825,13 +147983,13 @@ function describeDevice(target) {
147825
147983
  function macosAppTargets(pool, bundleId, port) {
147826
147984
  const own2 = pool.filter((t) => macosAppBundleIdOf(t)?.toLowerCase() === bundleId.toLowerCase());
147827
147985
  if (own2.length) return own2;
147828
- const devices = /* @__PURE__ */ new Map();
147986
+ const devices2 = /* @__PURE__ */ new Map();
147829
147987
  for (const t of pool) {
147830
- const key2 = deviceKey(t);
147831
- if (key2 && !devices.has(key2)) devices.set(key2, describeDevice(t));
147988
+ const key2 = deviceKey2(t);
147989
+ if (key2 && !devices2.has(key2)) devices2.set(key2, describeDevice(t));
147832
147990
  }
147833
147991
  throw new FailureError(
147834
- `No JS runtime of the Mac app ${bundleId} is connected to Metro on port ${port}. Metro lists: ${[...devices.values()].join(", ")}. If the app does not run, start it (launch-app), wait a few seconds for the bundle to load, then retry. Otherwise the app must be a Debug build of react-native-macos 0.76 or later that loads its bundle from this Metro; a Release build has no JS debugger. If the app uses another Metro, pass that port.`,
147992
+ `No JS runtime of the Mac app ${bundleId} is connected to Metro on port ${port}. Metro lists: ${[...devices2.values()].join(", ")}. If the app does not run, start it (launch-app), wait a few seconds for the bundle to load, then retry. Otherwise the app must be a Debug build of react-native-macos 0.76 or later that loads its bundle from this Metro; a Release build has no JS debugger. If the app uses another Metro, pass that port.`,
147835
147993
  {
147836
147994
  error_code: FAILURE_CODES.DEBUGGER_TARGET_DEVICE_MISMATCH,
147837
147995
  failure_stage: "debugger_select_target",
@@ -147859,7 +148017,7 @@ function selectTarget(targets, port, options) {
147859
148017
  } else {
147860
148018
  const distinctDevices = /* @__PURE__ */ new Map();
147861
148019
  for (const t of pool) {
147862
- const key2 = deviceKey(t);
148020
+ const key2 = deviceKey2(t);
147863
148021
  if (key2 && !distinctDevices.has(key2)) distinctDevices.set(key2, describeDevice(t));
147864
148022
  }
147865
148023
  if (distinctDevices.size > 1) {
@@ -151152,8 +151310,8 @@ async function awaitFirstRealFrame(serial, timeoutMs) {
151152
151310
  }
151153
151311
  async function findSerialByAvdName(avdName, deadline) {
151154
151312
  while (Date.now() < deadline) {
151155
- const devices = await listAndroidDevices().catch(() => []);
151156
- const match = devices.find((d) => d.isEmulator && d.avdName === avdName);
151313
+ const devices2 = await listAndroidDevices().catch(() => []);
151314
+ const match = devices2.find((d) => d.isEmulator && d.avdName === avdName);
151157
151315
  if (match) return match.serial;
151158
151316
  await new Promise((r) => setTimeout(r, BOOT_POLL_INTERVALS_MS.serialByAvd));
151159
151317
  }
@@ -151191,8 +151349,8 @@ async function awaitOwnEmulatorSettled(avdName, deadline) {
151191
151349
  while (Date.now() < deadline) {
151192
151350
  if (healthy) return healthy;
151193
151351
  if ((await listEmulatorPidsForAvd(avdName)).length === 0) return null;
151194
- listing ??= listAndroidDevices().then((devices) => {
151195
- if (devices.some((d) => isRunningAvd(d, avdName))) healthy = devices;
151352
+ listing ??= listAndroidDevices().then((devices2) => {
151353
+ if (devices2.some((d) => isRunningAvd(d, avdName))) healthy = devices2;
151196
151354
  }).catch(() => {
151197
151355
  }).finally(() => {
151198
151356
  listing = null;
@@ -151203,9 +151361,9 @@ async function awaitOwnEmulatorSettled(avdName, deadline) {
151203
151361
  }
151204
151362
  return healthy;
151205
151363
  }
151206
- async function dropUnreachableSerials(devices, serialsBefore) {
151364
+ async function dropUnreachableSerials(devices2, serialsBefore) {
151207
151365
  await Promise.all(
151208
- devices.filter((d) => d.isEmulator && !(d.state === "device" && d.avdName !== null)).map(async (d) => {
151366
+ devices2.filter((d) => d.isEmulator && !(d.state === "device" && d.avdName !== null)).map(async (d) => {
151209
151367
  if ((await readEmulatorConsoleAvdName(d.serial)).status === "unreachable") {
151210
151368
  serialsBefore.delete(d.serial);
151211
151369
  }
@@ -151363,8 +151521,8 @@ async function bootIosRemote(id, registry2, force) {
151363
151521
  let simState;
151364
151522
  try {
151365
151523
  const list = await simctlListDevices();
151366
- outer: for (const devices of Object.values(list.devices)) {
151367
- for (const d of devices) {
151524
+ outer: for (const devices2 of Object.values(list.devices)) {
151525
+ for (const d of devices2) {
151368
151526
  if (d.udid === udid) {
151369
151527
  simState = d.state;
151370
151528
  break outer;
@@ -156267,110 +156425,6 @@ init_zod();
156267
156425
  init_src2();
156268
156426
  init_capability();
156269
156427
 
156270
- // ../tool-server/src/utils/secrets.ts
156271
- init_src2();
156272
- init_capability();
156273
- init_src();
156274
- var SECRET_PLACEHOLDER_MARKER = "{{secret:";
156275
- function resolveSecretPlaceholders(text, options = {}) {
156276
- const secrets = [];
156277
- let sources;
156278
- const resolved = text.replace(SECRET_PLACEHOLDER_RE, (_placeholder, rawName) => {
156279
- sources ??= [
156280
- ...options.clientSecrets ? [clientSecretSource(options.clientSecrets)] : [],
156281
- ...secretSources(options)
156282
- ];
156283
- const { name, value } = lookupPlaceholderSecret(rawName, sources);
156284
- if (value === void 0) {
156285
- const names = secretNames(sources);
156286
- const where = options.clientSecrets ? `the required secret ${name} was not provided: the argent client forwards its secrets to this tool-server and has no value for it, and no source on the machine running the tool-server defines it either` : `no source on the machine running the tool-server defines ${name}`;
156287
- throw new InvalidToolInputError(
156288
- `Unknown secret "${rawName}" \u2014 ${where}. Available secrets: ${names.length ? names.join(", ") : "(none)"}.
156289
- Sources consulted, first match wins:
156290
- ${describeSecretSources(sources)}
156291
- ` + (options.clientSecrets ? clientSecretPlacementAdvice(name) : secretPlacementAdvice(name, options)),
156292
- {
156293
- error_code: FAILURE_CODES.SECRET_PLACEHOLDER_UNKNOWN,
156294
- failure_stage: "secret_placeholder_resolution",
156295
- error_kind: "validation"
156296
- }
156297
- );
156298
- }
156299
- if (!secrets.some((s) => s.name === name)) secrets.push({ name, value });
156300
- return value;
156301
- });
156302
- return { text: resolved, secrets };
156303
- }
156304
- function scrubSecretValues(text, secrets) {
156305
- return scrubSecretChunk(text, secrets, true).emit;
156306
- }
156307
- function scrubSecretChunk(text, secrets, final) {
156308
- const ordered = orderedSecrets(secrets);
156309
- if (ordered.length === 0) return { emit: text, held: 0 };
156310
- const longestValue = ordered[0].value.length;
156311
- const names = new Set(ordered.map((secret) => secret.name));
156312
- const longestName = Math.max(...ordered.map((secret) => secret.name.length));
156313
- let out = "";
156314
- let copied = 0;
156315
- let at = 0;
156316
- while (at < text.length) {
156317
- const marker = markerLengthAt(text, at, names, longestName);
156318
- if (marker > 0 && !valueLeavesMarker(text, at, at + marker, ordered)) {
156319
- at += marker;
156320
- continue;
156321
- }
156322
- if (!final && text.length - at < longestValue && beginsAValue(text, at, ordered)) break;
156323
- const hit = ordered.find((secret) => text.startsWith(secret.value, at));
156324
- if (hit) {
156325
- out += `${text.slice(copied, at)}${SECRET_PLACEHOLDER_MARKER}${hit.name}}}`;
156326
- at += hit.value.length;
156327
- copied = at;
156328
- continue;
156329
- }
156330
- at += 1;
156331
- }
156332
- return {
156333
- emit: copied === 0 ? text.slice(0, at) : out + text.slice(copied, at),
156334
- held: text.length - at
156335
- };
156336
- }
156337
- function valueLeavesMarker(text, from2, end, ordered) {
156338
- for (let at = from2; at < end; at++) {
156339
- for (const { value } of ordered) {
156340
- if (at + value.length >= end && text.startsWith(value, at)) return true;
156341
- }
156342
- }
156343
- return false;
156344
- }
156345
- function beginsAValue(text, at, ordered) {
156346
- const rest = text.slice(at);
156347
- return ordered.some(({ value }) => value.length > rest.length && value.startsWith(rest));
156348
- }
156349
- function orderedSecrets(secrets) {
156350
- return secrets.filter(({ value }) => value.length > 0).sort((a, b) => b.value.length - a.value.length);
156351
- }
156352
- function markerLengthAt(text, at, names, longestName) {
156353
- if (!text.startsWith(SECRET_PLACEHOLDER_MARKER, at)) return 0;
156354
- const from2 = at + SECRET_PLACEHOLDER_MARKER.length;
156355
- const window2 = text.slice(from2, from2 + longestName + 2);
156356
- const end = window2.indexOf("}}");
156357
- return end >= 0 && names.has(window2.slice(0, end)) ? SECRET_PLACEHOLDER_MARKER.length + end + 2 : 0;
156358
- }
156359
- function redactSecretsFromError(err, secrets) {
156360
- const forms = secrets.flatMap((secret) => {
156361
- const quoted = secret.value.replaceAll("'", "'\\''");
156362
- return quoted === secret.value ? [secret] : [secret, { name: secret.name, value: quoted }];
156363
- });
156364
- const scrub = (s) => scrubSecretValues(s, forms);
156365
- if (err instanceof Error) {
156366
- err.message = scrub(err.message);
156367
- if (err.stack) err.stack = scrub(err.stack);
156368
- return err;
156369
- }
156370
- if (typeof err === "string") return scrub(err);
156371
- return err;
156372
- }
156373
-
156374
156428
  // ../tool-server/src/tools/keyboard/simulator-server-keys.ts
156375
156429
  init_src2();
156376
156430
 
@@ -157114,6 +157168,7 @@ React Native: after typing, the next tap outside the field may only close the ke
157114
157168
  clientSecrets: options?.clientSecrets
157115
157169
  });
157116
157170
  if (secrets.length === 0) return dispatch(services, params, options);
157171
+ noteTypedSecrets(params.udid, secrets);
157117
157172
  try {
157118
157173
  const result = await dispatch(services, { ...params, text }, options);
157119
157174
  return { ...result, typed: params.text };
@@ -157306,6 +157361,7 @@ Tap the field first so it has focus. Returns { pasted: true }, plus via: "keyboa
157306
157361
  });
157307
157362
  return serializedPerDevice(params.udid, async () => {
157308
157363
  if (secrets.length === 0) return dispatch(services, params, options);
157364
+ noteTypedSecrets(params.udid, secrets);
157309
157365
  try {
157310
157366
  return await dispatch(services, { ...params, text, hasSecrets: true }, options);
157311
157367
  } catch (err) {
@@ -162255,6 +162311,7 @@ Fails with FILL_NO_FOCUSED_FIELD when nothing editable has focus, FILL_NOT_VERIF
162255
162311
  const { text, secrets } = resolveSecretPlaceholders(params.text, {
162256
162312
  clientSecrets: options?.clientSecrets
162257
162313
  });
162314
+ noteTypedSecrets(params.udid, secrets);
162258
162315
  try {
162259
162316
  return await dispatch(services, { udid: params.udid, text }, options);
162260
162317
  } catch (err) {
@@ -175045,8 +175102,8 @@ Fails if the input has an unknown key (e.g. \`udids\` instead of \`devices\`); o
175045
175102
  // "all" only holds for the unscoped sweep; a scoped call touches just the
175046
175103
  // ids it was given.
175047
175104
  startedMsg: ({ params }) => {
175048
- const devices = params?.devices;
175049
- return devices ? `Stopping simulator servers for ${devices.length} ${devices.length === 1 ? "device" : "devices"}` : "Stopping all simulator servers";
175105
+ const devices2 = params?.devices;
175106
+ return devices2 ? `Stopping simulator servers for ${devices2.length} ${devices2.length === 1 ? "device" : "devices"}` : "Stopping all simulator servers";
175050
175107
  },
175051
175108
  completedMsg: ({ result }) => {
175052
175109
  const n = result.stopped.length;
@@ -175070,8 +175127,8 @@ Fails if the input has an unknown key (e.g. \`udids\` instead of \`devices\`); o
175070
175127
  },
175071
175128
  services: () => ({}),
175072
175129
  async execute(_services, params, ctx) {
175073
- const devices = params.devices;
175074
- const scoped = devices !== void 0;
175130
+ const devices2 = params.devices;
175131
+ const scoped = devices2 !== void 0;
175075
175132
  const snapshot = registry2.getSnapshot();
175076
175133
  const stopped = [];
175077
175134
  const matchedIds = /* @__PURE__ */ new Set();
@@ -175082,7 +175139,7 @@ Fails if the input has an unknown key (e.g. \`udids\` instead of \`devices\`); o
175082
175139
  aborted2 = true;
175083
175140
  break;
175084
175141
  }
175085
- const matchedId = scoped ? deviceIdOwningUrn(urn, DEVICE_OWNED_NAMESPACES, devices) : void 0;
175142
+ const matchedId = scoped ? deviceIdOwningUrn(urn, DEVICE_OWNED_NAMESPACES, devices2) : void 0;
175086
175143
  const matches2 = scoped ? matchedId !== void 0 : isDeviceServiceUrn(urn, DEVICE_OWNED_NAMESPACES);
175087
175144
  if (matchedId !== void 0) matchedIds.add(matchedId.toLowerCase());
175088
175145
  if (matches2 && entry.state !== "IDLE" /* IDLE */) {
@@ -175096,7 +175153,7 @@ Fails if the input has an unknown key (e.g. \`udids\` instead of \`devices\`); o
175096
175153
  if (aborted2) return { stopped, aborted: true };
175097
175154
  if (!scoped) return { stopped };
175098
175155
  const seen = /* @__PURE__ */ new Set();
175099
- const unmatched = devices.filter((id) => {
175156
+ const unmatched = devices2.filter((id) => {
175100
175157
  const key2 = id.toLowerCase();
175101
175158
  if (matchedIds.has(key2) || seen.has(key2)) return false;
175102
175159
  seen.add(key2);
@@ -177915,14 +177972,14 @@ function isBooted(d, platform) {
177915
177972
  return false;
177916
177973
  }
177917
177974
  }
177918
- function connectedIosDeviceHint(devices, platform) {
177975
+ function connectedIosDeviceHint(devices2, platform) {
177919
177976
  if (platform && platform !== "ios") return "";
177920
- const ids = devices.filter((d) => d.platform === "ios" && d.kind === "device" && d.state === "connected").map((d) => d.udid).filter((id) => Boolean(id));
177977
+ const ids = devices2.filter((d) => d.platform === "ios" && d.kind === "device" && d.state === "connected").map((d) => d.udid).filter((id) => Boolean(id));
177921
177978
  if (ids.length === 0) return "";
177922
177979
  return ` A physical iPhone is connected (${ids.join(", ")}); hardware is never picked automatically, pass device <udid> (--device on the CLI) to run on it.`;
177923
177980
  }
177924
- function macosAppHint(devices, platform) {
177925
- if (platform || !devices.some((d) => d.platform === "macos")) return "";
177981
+ function macosAppHint(devices2, platform) {
177982
+ if (platform || !devices2.some((d) => d.platform === "macos")) return "";
177926
177983
  return " A Mac app is picked only with --platform macos or --device.";
177927
177984
  }
177928
177985
  function macosFlagHint(platform) {
@@ -178009,9 +178066,9 @@ async function assertDeviceMeetsRequires(device, requires, subject2 = "This e2e
178009
178066
  );
178010
178067
  }
178011
178068
  }
178012
- function unknownRuntimeKindError(requires, devices, subject2 = "This e2e test", remedy = "") {
178069
+ function unknownRuntimeKindError(requires, devices2, subject2 = "This e2e test", remedy = "") {
178013
178070
  return requirementsError(
178014
- `${subject2} declares ${describeRequires(requires)}, but the runtime kind of ${devices.join(", ")} could not be determined.${remedy}`,
178071
+ `${subject2} declares ${describeRequires(requires)}, but the runtime kind of ${devices2.join(", ")} could not be determined.${remedy}`,
178015
178072
  FAILURE_CODES.FLOW_DEVICE_RESOLUTION
178016
178073
  );
178017
178074
  }
@@ -178029,8 +178086,8 @@ async function resolveFlowDevice(registry2, ctx, opts) {
178029
178086
  if (macosRefusal) throw deviceResolutionError(`Cannot run on ${device.id}: ${macosRefusal}`);
178030
178087
  return device;
178031
178088
  }
178032
- const { devices } = await invokeSubTool(registry2, ctx, "list-devices", {});
178033
- const booted = devices.filter((d) => isBooted(d, opts.platform));
178089
+ const { devices: devices2 } = await invokeSubTool(registry2, ctx, "list-devices", {});
178090
+ const booted = devices2.filter((d) => isBooted(d, opts.platform));
178034
178091
  const scoped = opts.platform ? booted.filter((d) => d.platform === opts.platform) : booted;
178035
178092
  const requires = opts.requires;
178036
178093
  const candidates = requires ? scoped.filter((d) => platformMeets(d.platform, requires)) : scoped;
@@ -178072,8 +178129,8 @@ async function resolveFlowDevice(registry2, ctx, opts) {
178072
178129
  if (eligible.length === 0) {
178073
178130
  const what = opts.platform ? `No booted ${opts.platform} device found.` : "No booted device found.";
178074
178131
  throw deviceResolutionError(
178075
- `${what} Pass a device id or platform explicitly.${connectedIosDeviceHint(devices, opts.platform)}${macosAppHint(devices, opts.platform)}${macosFlagHint(opts.platform)}`,
178076
- devices
178132
+ `${what} Pass a device id or platform explicitly.${connectedIosDeviceHint(devices2, opts.platform)}${macosAppHint(devices2, opts.platform)}${macosFlagHint(opts.platform)}`,
178133
+ devices2
178077
178134
  );
178078
178135
  }
178079
178136
  throw deviceResolutionError(
@@ -178194,6 +178251,7 @@ function asViewNode(v) {
178194
178251
  className: nonEmptyString(r.className),
178195
178252
  identifier: nonEmptyString(r.identifier),
178196
178253
  label: nonEmptyString(r.label),
178254
+ value: nonEmptyString(r.value),
178197
178255
  frame: asRect2(r.frame),
178198
178256
  windowFrame: asRect2(r.windowFrame),
178199
178257
  screenFrame: asRect2(r.screenFrame),
@@ -178203,10 +178261,11 @@ function asViewNode(v) {
178203
178261
  children
178204
178262
  };
178205
178263
  }
178264
+ var IOS_TEXT_INPUT_ROLE = "AXTextField";
178206
178265
  function roleFromClassName(cn) {
178207
178266
  if (!cn) return "AXGroup";
178208
178267
  if (/Button/i.test(cn)) return "AXButton";
178209
- if (/(TextField|TextView|SearchField)/i.test(cn)) return "AXTextField";
178268
+ if (/(TextField|TextView|SearchField)/i.test(cn)) return IOS_TEXT_INPUT_ROLE;
178210
178269
  if (/(Label|Text)/i.test(cn)) return "AXStaticText";
178211
178270
  if (/Image/i.test(cn)) return "AXImage";
178212
178271
  if (/(Slider|Stepper|Switch|ProgressView)/i.test(cn)) return "AXAdjustable";
@@ -178229,9 +178288,12 @@ function normalizeFrame4(rect, screenW, screenH) {
178229
178288
  height: roundNormalized3(height)
178230
178289
  };
178231
178290
  }
178232
- function projectIosNode(node2, screenW, screenH) {
178291
+ function projectIosNode(node2, screenW, screenH, quotedLabel) {
178233
178292
  const skip = node2.hidden === true || node2.alpha !== void 0 && node2.alpha < 0.01;
178234
178293
  const role = roleFromClassName(node2.className);
178294
+ const held = role === IOS_TEXT_INPUT_ROLE && node2.value !== node2.label ? node2.value : void 0;
178295
+ const value = quotedLabel && held !== void 0 ? WITHHELD_INPUT_TEXT : held;
178296
+ const label = quotedLabel && node2.label !== void 0 ? quotedLabel(node2.label) : node2.label;
178235
178297
  const win = node2.screenFrame ?? node2.windowFrame;
178236
178298
  const rect = win ? { x: win.x, y: win.y, w: win.width, h: win.height } : null;
178237
178299
  let leaf = null;
@@ -178244,27 +178306,34 @@ function projectIosNode(node2, screenW, screenH) {
178244
178306
  role,
178245
178307
  frame: frame2,
178246
178308
  children: [],
178247
- label: node2.label,
178309
+ label,
178310
+ value,
178248
178311
  identifier: node2.identifier,
178249
178312
  focused: node2.firstResponder || void 0
178250
178313
  };
178251
178314
  }
178252
178315
  }
178316
+ const ownTextParts = frame2 ? [label, value].filter((text) => Boolean(text)) : [];
178253
178317
  return {
178254
178318
  skip,
178255
178319
  children: node2.children ?? [],
178256
178320
  // Text hoists only from on-screen nodes (frame is null when the view is
178257
178321
  // scrolled off or zero-area) — otherwise a text assert against an ancestor
178258
178322
  // would pass on content the screen doesn't show. A label makes a node
178259
- // leaf-eligible, so `frame` was computed for any node with text.
178260
- ownText: frame2 ? node2.label ?? "" : "",
178323
+ // leaf-eligible, and so does the text input role a value needs, so `frame`
178324
+ // was computed for any node with text. Mirrors what `nodeText` reads off
178325
+ // the leaf: the label plus a distinct value.
178326
+ ownText: ownTextParts.join(" "),
178327
+ // Apart as well: the view under an empty field that draws its placeholder
178328
+ // repeats the value and not the label, and a floating label the reverse.
178329
+ ownTextParts,
178261
178330
  leaf,
178262
178331
  shield: Boolean(node2.identifier),
178263
178332
  rect,
178264
178333
  scrolls: role === "AXScrollArea"
178265
178334
  };
178266
178335
  }
178267
- function adaptFullHierarchy(raw) {
178336
+ function adaptFullHierarchy(raw, quotedLabel) {
178268
178337
  const payload = typeof raw === "object" && raw !== null ? raw : {};
178269
178338
  const reportedScreen = typeof payload.screen === "object" && payload.screen !== null ? payload.screen : void 0;
178270
178339
  const windows = Array.isArray(payload.windows) ? payload.windows.map(asViewNode).filter((n) => n !== null) : [];
@@ -178286,7 +178355,7 @@ function adaptFullHierarchy(raw) {
178286
178355
  const children = [];
178287
178356
  if (screenW > 0 && screenH > 0) {
178288
178357
  for (const win of windows) {
178289
- flattenHoisting(win, (n) => projectIosNode(n, screenW, screenH), children);
178358
+ flattenHoisting(win, (n) => projectIosNode(n, screenW, screenH, quotedLabel), children);
178290
178359
  }
178291
178360
  }
178292
178361
  const tree = parseDescribeResult({
@@ -178307,6 +178376,9 @@ var FULL_HIERARCHY_FIELDS = [
178307
178376
  "className",
178308
178377
  "identifier",
178309
178378
  "label",
178379
+ // A text input's text; an injected framework that omits it leaves a filled
178380
+ // field reading as empty.
178381
+ "value",
178310
178382
  "frame",
178311
178383
  "windowFrame",
178312
178384
  "screenFrame",
@@ -178469,8 +178541,10 @@ async function queryFullHierarchyTree(registry2, device, target) {
178469
178541
  );
178470
178542
  }
178471
178543
  const { tree, screen, uiOrientation } = adaptFullHierarchy(rawResult);
178544
+ const quotableTree = secretTypedOn(device.id) ? adaptFullHierarchy(rawResult, (label) => redactTypedSecrets(device.id, label)).tree : void 0;
178472
178545
  return {
178473
178546
  tree,
178547
+ ...quotableTree ? { quotableTree } : {},
178474
178548
  source: "native-devtools",
178475
178549
  ...screen ? { screen } : {},
178476
178550
  ...uiOrientation ? { uiOrientation } : {}
@@ -179579,6 +179653,7 @@ async function runType(env, step) {
179579
179653
  async function waitForCondition(env, step, timeoutMs) {
179580
179654
  const deadline = Date.now() + timeoutMs;
179581
179655
  let lastMatches = [];
179656
+ let lastData;
179582
179657
  let fetchError;
179583
179658
  let everMatched = false;
179584
179659
  let lastTrustedReadAt;
@@ -179590,6 +179665,7 @@ async function waitForCondition(env, step, timeoutMs) {
179590
179665
  try {
179591
179666
  const data = await readFlowTree(env);
179592
179667
  lastMatches = flowFindAll(data.tree, step.selector, data.uiOrientation);
179668
+ lastData = data;
179593
179669
  fetchError = void 0;
179594
179670
  everMatched ||= lastMatches.length > 0;
179595
179671
  const blind = isBlindRead(data, everMatched, step.condition);
@@ -179657,7 +179733,10 @@ async function waitForCondition(env, step, timeoutMs) {
179657
179733
  // The read `lastMatches` came from is the last one that answered, and
179658
179734
  // only a read that answers writes the orientation.
179659
179735
  readingOrientation(env),
179660
- env.device.platform === "macos"
179736
+ env.device.platform === "macos",
179737
+ // The text of an element is the only part of a reason that comes off
179738
+ // the screen, where a field shows a typed secret.
179739
+ (node2, read) => lastData ? quotedText(lastData, env.device.id, node2, read) : read(node2)
179661
179740
  ) + blipNote
179662
179741
  };
179663
179742
  }
@@ -179877,7 +179956,7 @@ async function waitForIdle(env, step) {
179877
179956
  warning: `the screen never held still for ${MIN_STILL_INTERVALS} consecutive ${IDLE_POLL_MS}ms intervals${stableFor > 0 ? ` spanning ${stableFor}ms` : ""} within ${timeoutMs}ms, and was moving again on the last one, so this step went ahead without waiting it out. Either something on it never stops (a video, a looping animation, a carousel, live-updating text) or the screen never finished loading. Look at what is moving, and make sure the next action is gated on a stable element rather than on stillness.` + blipNote
179878
179957
  };
179879
179958
  }
179880
- function assertReason(condition, selector, expectedText, textMatch, matches2, orientation, macos) {
179959
+ function assertReason(condition, selector, expectedText, textMatch, matches2, orientation, macos, quoted) {
179881
179960
  const sel = describeSelector(selector);
179882
179961
  switch (condition) {
179883
179962
  case "exists":
@@ -179890,9 +179969,8 @@ function assertReason(condition, selector, expectedText, textMatch, matches2, or
179890
179969
  const first = textCheckTarget(matches2, orientation, macos);
179891
179970
  if (!first) return `no element matched selector ${sel}`;
179892
179971
  const wanted = describeTextExpectation(expectedText, textMatch, "infinitive");
179893
- const field = macFieldText(first, macos);
179894
- const shown = field ?? assertText(first);
179895
- const own2 = field ?? nodeText(first);
179972
+ const shown = quoted(first, (node2) => macFieldText(node2, macos) ?? assertText(node2));
179973
+ const own2 = quoted(first, (node2) => macFieldText(node2, macos) ?? nodeText(node2));
179896
179974
  const ownNote = own2 && own2 !== shown ? ` (own text "${own2}")` : "";
179897
179975
  return `element matched ${sel} but its text was "${shown}"${ownNote} (wanted to ${wanted})`;
179898
179976
  }
@@ -180718,6 +180796,9 @@ function innermostTreeReason(message) {
180718
180796
  const unwrapped = /helper is unavailable:\s*(.+)/s.exec(message)?.[1] ?? message;
180719
180797
  return unwrapped.replace(/^\[[^\]]+\]\s*/, "").trim();
180720
180798
  }
180799
+ function withoutTypedText(node2, { source }) {
180800
+ return source === "native-devtools" && node2.role === IOS_TEXT_INPUT_ROLE ? { ...node2, value: void 0 } : node2;
180801
+ }
180721
180802
  async function captureTapSelector(registry2, session, udid, point) {
180722
180803
  try {
180723
180804
  const device = resolveDevice(udid);
@@ -180730,7 +180811,7 @@ async function captureTapSelector(registry2, session, udid, point) {
180730
180811
  const { tree, uiOrientation } = data;
180731
180812
  const node2 = nodeAtPoint(tree, point);
180732
180813
  if (!node2) return { warning: "no element found under the tap; kept coordinates (brittle)" };
180733
- const selector = deriveSelector(node2);
180814
+ const selector = deriveSelector(withoutTypedText(node2, data));
180734
180815
  if (!selector)
180735
180816
  return { warning: "tapped element has no stable text/id; kept coordinates (brittle)" };
180736
180817
  const resolved = selectorToFrame(tree, selector, uiOrientation);
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.34.1-next.6",
3
+ "version": "0.34.1-next.8",
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
@@ -1,34 +1,17 @@
1
1
  ---
2
- description: Always-on Argent rules for driving, testing and profiling apps on simulators, emulators, phones, TVs and Chromium
2
+ description: What to do when this project uses Argent but Argent is not available in this environment
3
3
  alwaysApply: true
4
4
  ---
5
5
 
6
- Argent - general rules:
6
+ This project uses Argent, through its `argent` MCP server, to drive, test and profile apps on simulators, emulators, phones, TVs and Chromium. The server's own instructions carry the usage guidance.
7
7
 
8
- - do not derive tap coordinates from screenshot pixels; use inspection tools that give coordinates
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
- - if tap fails twice, stop retrying and re-run a discovery tool
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; an identical earlier tree is named by its tree id, not repeated.
13
- - prefer `launch-app` or `open-url` than tapping icons on home screen.
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
- - Load the matching `argent-*` skill before React Native build/debug, profiling, a physical phone, a Mac app or a TV.
16
- - 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, with devices this session used. One tool-server is shared by every other agent, so unscoped call tears down their devices too. Never stop a Metro the user started unless they ask.
17
- - Use the `await-ui-element` tool to block until the UI settles instead of polling using screenshot.
18
- - The `argent` CLI manages the toolkit: `argent --help` lists commands, `argent --version` shows the installed version.
8
+ Check once per session whether argent is available; do not re-probe before later calls:
19
9
 
20
- <availability_check>
21
- Run this check once per session. Do not re-probe before later calls.
22
- Confirm argent is available:
23
-
24
- 1. Are `mcp__argent__*` tools in your tool list? If none, argent is not available.
10
+ 1. Are argent tools (such as `mcp__argent__*`) in your tool list? If none, argent is not available.
25
11
  2. If unsure, run `command -v argent`. Non-zero exit = the CLI is not on PATH.
26
12
 
27
- If argent IS available, ignore the rest of this block and follow this rule normally.
13
+ If argent is available, ignore this rule.
28
14
 
29
- If argent is ABSENT, treat it as an expected state, not an error to retry. Do not call `mcp__argent__*` tools, do not run `argent` commands, do not attempt any argent workflow.
30
- Tell the user once, and ask if you should continue without argent:
15
+ If argent is absent, treat it as an expected state, not an error to retry. Do not call argent tools, run `argent` commands or attempt any argent workflow. Tell the user once, and ask if you should continue without argent:
31
16
 
32
17
  > Argent isn't installed in this environment. To enable the mobile/Chromium tooling this repo is configured for, run `npx @swmansion/argent@latest init -y` (or `npm i -g @swmansion/argent@latest && argent init -y`).
33
-
34
- </availability_check>