@swmansion/argent 0.33.1-next.9 → 0.34.1-next.0

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 (39) hide show
  1. package/assets/Argent.tracetemplate +0 -0
  2. package/bin/argent-android-devtools-0.4.0.apk +0 -0
  3. package/bin/darwin/argent-macos-helper +0 -0
  4. package/bin/darwin/ax-service +0 -0
  5. package/bin/darwin/tvos-ax-service +0 -0
  6. package/bin/darwin/tvos-hid-daemon +0 -0
  7. package/bin/network-inspector/network-inspector.jar +0 -0
  8. package/bin/tcp/ax-service +0 -0
  9. package/dist/cli-cmds.mjs +380 -123
  10. package/dist/client.js +256 -56
  11. package/dist/flow-script-runner.mjs +148 -5
  12. package/dist/installer.mjs +40 -24
  13. package/dist/ios-device-runner/ArgentRunner/ArgentRunnerUITests/ArgentRunnerSession+Snapshot.swift +110 -4
  14. package/dist/mcp-server.mjs +330 -68
  15. package/dist/tool-args.generated.d.ts +22 -20
  16. package/dist/tool-server.cjs +3763 -2146
  17. package/dylibs/libArgentInjectionBootstrap.dylib +0 -0
  18. package/dylibs/libKeyboardPatch.dylib +0 -0
  19. package/dylibs/libNativeDevtoolsIos.dylib +0 -0
  20. package/dylibs/macos/libArgentInjectionBootstrap.dylib +0 -0
  21. package/dylibs/macos/libNativeDevtoolsMacos.dylib +0 -0
  22. package/dylibs/tcp/libArgentInjectionBootstrap.dylib +0 -0
  23. package/dylibs/tcp/libKeyboardPatch.dylib +0 -0
  24. package/dylibs/tcp/libNativeDevtoolsIos.dylib +0 -0
  25. package/dylibs/tvos/libArgentInjectionBootstrap.dylib +0 -0
  26. package/dylibs/tvos/libKeyboardPatch.dylib +0 -0
  27. package/dylibs/tvos/libNativeDevtoolsIos.dylib +0 -0
  28. package/package.json +2 -3
  29. package/rules/argent.md +1 -1
  30. package/skills/argent-create-e2e/references/e2e-yaml.md +11 -1
  31. package/skills/argent-create-e2e/references/reliability-and-recovery.md +1 -1
  32. package/skills/argent-device-interact/SKILL.md +2 -2
  33. package/skills/argent-device-interact/references/harmonyos.md +1 -1
  34. package/skills/argent-macos-app-interact/SKILL.md +5 -1
  35. package/skills/argent-native-profiler/SKILL.md +14 -5
  36. package/skills/argent-react-native-profiler/SKILL.md +7 -0
  37. package/skills/argent-test-ui-flow/SKILL.md +1 -1
  38. package/assets/trace-processor/SHA256SUMS +0 -4
  39. package/assets/trace-processor/engine.mjs +0 -42423
@@ -106,9 +106,9 @@ var require_picocolors = __commonJS({
106
106
  var argv = p.argv || [];
107
107
  var env = p.env || {};
108
108
  var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
109
- var formatter = (open, close, replace = open) => (input) => {
110
- let string = "" + input, index = string.indexOf(close, open.length);
111
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
109
+ var formatter = (open2, close, replace = open2) => (input) => {
110
+ let string = "" + input, index = string.indexOf(close, open2.length);
111
+ return ~index ? open2 + replaceClose(string, close, replace, index) + close : open2 + string + close;
112
112
  };
113
113
  var replaceClose = (string, close, replace, index) => {
114
114
  let result = "", cursor3 = 0;
@@ -15735,7 +15735,10 @@ import { basename, extname } from "node:path";
15735
15735
  var FLOW_NAME_CHARSET = "[A-Za-z0-9_-]+";
15736
15736
  var FLOW_NAME_PATTERN = new RegExp(`^${FLOW_NAME_CHARSET}$`);
15737
15737
  var FLOW_FILE_NAME_PATTERN = new RegExp(`^${FLOW_NAME_CHARSET}\\.yaml$`);
15738
- var SCRIPT_FILE_NAME_PATTERN = new RegExp(`^${FLOW_NAME_CHARSET}\\.mjs$`);
15738
+ var SCRIPT_FILE_EXTENSIONS = [".mjs", ".mts", ".js", ".ts"];
15739
+ var SCRIPT_FILE_NAME_PATTERN = new RegExp(
15740
+ `^${FLOW_NAME_CHARSET}(?:${SCRIPT_FILE_EXTENSIONS.map((ext) => `\\${ext}`).join("|")})$`
15741
+ );
15739
15742
 
15740
15743
  // ../registry/src/flow-file-refs.ts
15741
15744
  import * as fs7 from "node:fs/promises";
@@ -16030,6 +16033,9 @@ var FAILURE_CODES = {
16030
16033
  NATIVE_PROFILER_SESSION_TORN_DOWN: "NATIVE_PROFILER_SESSION_TORN_DOWN",
16031
16034
  NATIVE_PROFILER_APP_PROCESS_NOT_FOUND: "NATIVE_PROFILER_APP_PROCESS_NOT_FOUND",
16032
16035
  NATIVE_PROFILER_NO_EXPORTED_TRACE: "NATIVE_PROFILER_NO_EXPORTED_TRACE",
16036
+ NATIVE_PROFILER_APP_NOT_DEBUGGABLE: "NATIVE_PROFILER_APP_NOT_DEBUGGABLE",
16037
+ NATIVE_PROFILER_APP_HAS_WEBKIT_HEAP: "NATIVE_PROFILER_APP_HAS_WEBKIT_HEAP",
16038
+ NATIVE_PROFILER_APP_HEAP_CHECK_FAILED: "NATIVE_PROFILER_APP_HEAP_CHECK_FAILED",
16033
16039
  // Android perfetto start failures, mirroring the iOS xctrace set above.
16034
16040
  NATIVE_PROFILER_PERFETTO_PROCESS_ERROR: "NATIVE_PROFILER_PERFETTO_PROCESS_ERROR",
16035
16041
  NATIVE_PROFILER_PERFETTO_READY_TIMEOUT: "NATIVE_PROFILER_PERFETTO_READY_TIMEOUT",
@@ -16059,6 +16065,8 @@ var FAILURE_CODES = {
16059
16065
  FLOW_DEVICE_RESOLUTION: "FLOW_DEVICE_RESOLUTION",
16060
16066
  // The target does not satisfy the test's `requires:` block; a directory run skips it.
16061
16067
  FLOW_REQUIREMENTS_UNMET: "FLOW_REQUIREMENTS_UNMET",
16068
+ // The tool-server's Node.js cannot run a TypeScript `script:` step the test holds.
16069
+ FLOW_SCRIPT_TYPESCRIPT_UNSUPPORTED: "FLOW_SCRIPT_TYPESCRIPT_UNSUPPORTED",
16062
16070
  PROFILER_QUERY_MODE_INVALID: "PROFILER_QUERY_MODE_INVALID",
16063
16071
  PROFILER_QUERY_REQUIRED_PARAM_MISSING: "PROFILER_QUERY_REQUIRED_PARAM_MISSING",
16064
16072
  PROFILER_DATA_NOT_LOADED: "PROFILER_DATA_NOT_LOADED",
@@ -16981,7 +16989,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
16981
16989
  var SESSION_ID = randomUUID4();
16982
16990
  function readCliVersion() {
16983
16991
  if (true) {
16984
- return "0.33.1-next.9";
16992
+ return "0.34.1-next.0";
16985
16993
  }
16986
16994
  return "0.0.0";
16987
16995
  }
@@ -20495,6 +20503,13 @@ function getAtJsoncPath(value, jsonPath) {
20495
20503
  function isEmptyPlainObject(value) {
20496
20504
  return value !== null && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0;
20497
20505
  }
20506
+ function removePath(targetPath) {
20507
+ const entry = fs16.lstatSync(targetPath, { throwIfNoEntry: false });
20508
+ if (!entry) return false;
20509
+ if (entry.isSymbolicLink()) fs16.unlinkSync(targetPath);
20510
+ else fs16.rmSync(targetPath, { recursive: entry.isDirectory(), force: true });
20511
+ return true;
20512
+ }
20498
20513
  function rmEmptyDir(dirPath) {
20499
20514
  try {
20500
20515
  if (!fs16.existsSync(dirPath)) return false;
@@ -20612,7 +20627,7 @@ function removeRetiredFiles(targetDir, files) {
20612
20627
  const file = resolveLinkedDestination(entryPath);
20613
20628
  try {
20614
20629
  fs16.rmSync(file);
20615
- if (file !== entryPath) fs16.rmSync(entryPath, { force: true });
20630
+ if (file !== entryPath) removePath(entryPath);
20616
20631
  removedPaths.push(relativePath);
20617
20632
  } catch {
20618
20633
  continue;
@@ -22612,9 +22627,7 @@ function pruneLegacySkillDirs(projectRoot, scope, bundled = new Set(listBundledS
22612
22627
  for (const name of legacy) {
22613
22628
  const dir = path21.join(targetPath, name);
22614
22629
  try {
22615
- if (!fs19.lstatSync(dir, { throwIfNoEntry: false })) continue;
22616
- fs19.rmSync(dir, { recursive: true, force: true });
22617
- removed.add(name);
22630
+ if (removePath(dir)) removed.add(name);
22618
22631
  } catch {
22619
22632
  }
22620
22633
  }
@@ -24160,7 +24173,7 @@ var LINK_FILE = path24.join(LINK_DIR, "link.json");
24160
24173
 
24161
24174
  // ../argent-tools-client/src/file-inputs.ts
24162
24175
  import { createHash as createHash4, randomUUID as randomUUID6 } from "node:crypto";
24163
- import { createReadStream, rmSync as rmSync7 } from "node:fs";
24176
+ import { createReadStream as createReadStream2, rmSync as rmSync6 } from "node:fs";
24164
24177
  import {
24165
24178
  chmod as chmod3,
24166
24179
  lstat,
@@ -24176,11 +24189,21 @@ import { constants, tmpdir } from "node:os";
24176
24189
  import * as path25 from "node:path";
24177
24190
 
24178
24191
  // ../archive/src/index.ts
24179
- import { execFile } from "node:child_process";
24180
- import { rm, readdir as readdir3 } from "node:fs/promises";
24181
- import { basename as basename4, dirname as dirname13, join as join24, posix as posix2, resolve as resolve13, sep as sep4 } from "node:path";
24182
- import { promisify } from "node:util";
24183
- var execFileAsync = promisify(execFile);
24192
+ import { spawn as spawn5 } from "node:child_process";
24193
+ import { once } from "node:events";
24194
+ import { createReadStream, createWriteStream } from "node:fs";
24195
+ import { open, rm, readdir as readdir3 } from "node:fs/promises";
24196
+ import { basename as basename4, dirname as dirname13, join as join24, resolve as resolve13, sep as sep4 } from "node:path";
24197
+ import { Writable } from "node:stream";
24198
+ import { pipeline } from "node:stream/promises";
24199
+ import zlib2 from "node:zlib";
24200
+ var ARCHIVE_FORMATS = typeof zlib2.createZstdCompress === "function" ? ["zstd", "gzip"] : ["gzip"];
24201
+ var CHUNK_BYTES = 1 << 20;
24202
+ var MAX_LISTING_BYTES = 32 << 20;
24203
+ var MAX_LISTING_LINES = 1 << 18;
24204
+ var MAX_STDERR_BYTES = 16 << 10;
24205
+ var MAX_UNREAD_BYTES = 16 << 20;
24206
+ var TAR_LOCALE = process.platform === "darwin" ? "en_US.UTF-8" : "C.UTF-8";
24184
24207
 
24185
24208
  // ../argent-tools-client/src/file-inputs.ts
24186
24209
  var MAX_CONTENT_BYTES = 32 * 1024 * 1024;
@@ -24809,7 +24832,7 @@ function removeBundledContent(sourceDir, targetDir) {
24809
24832
  try {
24810
24833
  if (!fs21.existsSync(targetPath)) continue;
24811
24834
  if (fs21.lstatSync(targetPath).isDirectory()) continue;
24812
- fs21.rmSync(targetPath, { force: true });
24835
+ removePath(targetPath);
24813
24836
  removedPaths.push(relativePath);
24814
24837
  } catch {
24815
24838
  }
@@ -24873,14 +24896,7 @@ function removeBundledSkillInstalls(skillNames, targetDir) {
24873
24896
  for (const skillName of skillNames) {
24874
24897
  const targetPath = path29.join(targetDir, skillName);
24875
24898
  try {
24876
- const stats = fs21.lstatSync(targetPath, { throwIfNoEntry: false });
24877
- if (!stats) continue;
24878
- if (stats.isDirectory() && !stats.isSymbolicLink()) {
24879
- fs21.rmSync(targetPath, { recursive: true, force: true });
24880
- } else {
24881
- fs21.rmSync(targetPath, { force: true });
24882
- }
24883
- removedPaths.push(skillName);
24899
+ if (removePath(targetPath)) removedPaths.push(skillName);
24884
24900
  } catch {
24885
24901
  }
24886
24902
  }
@@ -26,6 +26,16 @@ extension ArgentRunnerSession {
26
26
  /// Ceiling on emitted node depth.
27
27
  private static let emittedDepthLimit = 60
28
28
 
29
+ /// View services that present UI over the registered app from their own
30
+ /// process. On iOS 26 the host app's tree no longer bridges into them, so
31
+ /// an ASWebAuthenticationSession or SFSafariViewController sheet is missing
32
+ /// from the app's snapshot even though it covers the screen.
33
+ private static let hostedViewServiceBundleIds = ["com.apple.SafariViewService"]
34
+
35
+ /// Share of the node budget a hosted service may use. A heavy web page
36
+ /// must not crowd out the app's own nodes and the keyboard.
37
+ private static let hostedNodeBudget = 1000
38
+
29
39
  /// Captures the app's accessibility tree and flattens it into a snapshot
30
40
  /// payload. The capture is retried once after a short pause: this is the
31
41
  /// one runner-side retry, kept here because the capture can read its own
@@ -70,7 +80,7 @@ extension ArgentRunnerSession {
70
80
  )
71
81
  }
72
82
 
73
- let nodes = Self.flatten(root)
83
+ let nodes = Self.flatten(root, hosted: hostedServiceRoots(over: root))
74
84
  let capped = nodes.count >= Self.snapshotNodeBudget
75
85
 
76
86
  return .success(
@@ -88,28 +98,122 @@ extension ArgentRunnerSession {
88
98
  )
89
99
  }
90
100
 
101
+ /// Trees of the hosted view services presenting over `root` right now.
102
+ /// The service is read through a proxy and never activated: activating it
103
+ /// would front it as a standalone app and black out the screen.
104
+ ///
105
+ /// Only a foreground service is read. A suspended one, where the service
106
+ /// stays after its sheet closes, blocks `snapshot()` past the command
107
+ /// watchdog and leaves the runner busy. A background one returns stale
108
+ /// pieces of the closed sheet. A tree whose size differs from the app's
109
+ /// belongs to a sheet still animating in or out, and its frames would
110
+ /// mislead taps, so it is dropped too. A failure here never fails the
111
+ /// app's own snapshot.
112
+ private func hostedServiceRoots(over root: XCUIElementSnapshot)
113
+ -> [XCUIElementSnapshot]
114
+ {
115
+ // Before iOS 26 the app's tree already carries the hosted browser.
116
+ if Self.containsHostedBrowser(root) { return [] }
117
+
118
+ var roots: [XCUIElementSnapshot] = []
119
+
120
+ for bundleId in Self.hostedViewServiceBundleIds {
121
+ let service = XCUIApplication(bundleIdentifier: bundleId)
122
+ guard service.state == .runningForeground else { continue }
123
+
124
+ var hosted: XCUIElementSnapshot?
125
+ var failure: String?
126
+ let started = Date()
127
+ let exceptionDescription = ArgentExceptionGuard.runCatching {
128
+ do {
129
+ hosted = try service.snapshot()
130
+ } catch {
131
+ failure = String(describing: error)
132
+ }
133
+ }
134
+ let elapsedMs = Int(Date().timeIntervalSince(started) * 1000)
135
+
136
+ guard let hosted, service.state == .runningForeground,
137
+ Self.sameSize(hosted.frame, root.frame)
138
+ else {
139
+ NSLog(
140
+ "ARGENT_HOSTED_SKIPPED bundle=%@ ms=%d reason=%@",
141
+ bundleId, elapsedMs,
142
+ exceptionDescription ?? failure ?? "not settled on screen"
143
+ )
144
+ continue
145
+ }
146
+
147
+ NSLog("ARGENT_HOSTED bundle=%@ ms=%d", bundleId, elapsedMs)
148
+ roots.append(hosted)
149
+ }
150
+
151
+ return roots
152
+ }
153
+
154
+ /// Whether the tree holds SafariViewService's browser container, whose
155
+ /// identifier starts with "BrowserView". An app's own web view does not
156
+ /// count. Bounded by the raw depth limit.
157
+ private static func containsHostedBrowser(_ root: XCUIElementSnapshot)
158
+ -> Bool
159
+ {
160
+ var stack: [(XCUIElementSnapshot, Int)] = [(root, 0)]
161
+
162
+ while let (snapshot, depth) = stack.popLast() {
163
+ if snapshot.identifier.hasPrefix("BrowserView") { return true }
164
+ if depth >= rawDepthLimit { continue }
165
+ stack.append(contentsOf: snapshot.children.map { ($0, depth + 1) })
166
+ }
167
+
168
+ return false
169
+ }
170
+
171
+ /// Whether two frames have the same size within a point.
172
+ private static func sameSize(_ a: CGRect, _ b: CGRect) -> Bool {
173
+ abs(a.width - b.width) < 1 && abs(a.height - b.height) < 1
174
+ }
175
+
91
176
  /// Flattens the snapshot tree into an ordered node list. Keeps elements an
92
177
  /// agent can name or act on, assigns indices and parent links in emission
93
- /// order, and dedupes mirror elements.
94
- static func flatten(_ root: XCUIElementSnapshot) -> [SnapshotNodePayload] {
178
+ /// order, and dedupes mirror elements. `hosted` trees of view services
179
+ /// presenting over the app are emitted first under the root, within
180
+ /// their own share of the node budget.
181
+ static func flatten(
182
+ _ root: XCUIElementSnapshot,
183
+ hosted: [XCUIElementSnapshot] = []
184
+ ) -> [SnapshotNodePayload] {
95
185
  struct WorkItem {
96
186
  let snapshot: XCUIElementSnapshot
97
187
  let rawDepth: Int
98
188
  let emittedDepth: Int
99
189
  let parentIndex: Int
190
+ var hosted = false
100
191
  }
101
192
 
102
193
  let viewport = root.frame
103
194
  var nodes = [makeNode(root, index: 0, depth: 0, parentIndex: nil)]
104
195
  var seen: Set<String> = [identity(root)]
196
+ var hostedEmitted = 0
105
197
 
106
198
  var stack = root.children.reversed().map {
107
199
  WorkItem(snapshot: $0, rawDepth: 1, emittedDepth: 1, parentIndex: 0)
108
200
  }
109
201
 
202
+ // Pushed last so they are walked first: they cover the screen, and the
203
+ // app's keyboard keys must not use up the budget before them.
204
+ stack.append(
205
+ contentsOf: hosted.reversed().map {
206
+ WorkItem(
207
+ snapshot: $0, rawDepth: 1, emittedDepth: 1, parentIndex: 0,
208
+ hosted: true
209
+ )
210
+ }
211
+ )
212
+
110
213
  while let item = stack.popLast() {
111
214
  if nodes.count >= snapshotNodeBudget { break }
112
215
  if item.rawDepth > rawDepthLimit { continue }
216
+ if item.hosted && hostedEmitted >= hostedNodeBudget { continue }
113
217
 
114
218
  let snapshot = item.snapshot
115
219
  let frame = snapshot.frame
@@ -141,6 +245,7 @@ extension ArgentRunnerSession {
141
245
 
142
246
  childParentIndex = index
143
247
  childEmittedDepth += 1
248
+ if item.hosted { hostedEmitted += 1 }
144
249
  }
145
250
 
146
251
  for child in snapshot.children.reversed() {
@@ -149,7 +254,8 @@ extension ArgentRunnerSession {
149
254
  snapshot: child,
150
255
  rawDepth: item.rawDepth + 1,
151
256
  emittedDepth: childEmittedDepth,
152
- parentIndex: childParentIndex
257
+ parentIndex: childParentIndex,
258
+ hosted: item.hosted
153
259
  )
154
260
  )
155
261
  }