agent-device 0.6.3 → 0.7.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.
- package/README.md +55 -7
- package/dist/src/bin.js +43 -34
- package/dist/src/daemon.js +29 -26
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/project.pbxproj +14 -6
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +104 -4
- package/package.json +4 -2
- package/skills/agent-device/SKILL.md +24 -2
- package/skills/agent-device/references/logs-and-debug.md +5 -0
- package/skills/agent-device/references/perf-metrics.md +53 -0
- package/skills/dogfood/SKILL.md +183 -0
- package/skills/dogfood/references/issue-taxonomy.md +83 -0
- package/skills/dogfood/templates/dogfood-report-template.md +52 -0
package/README.md
CHANGED
|
@@ -13,10 +13,12 @@ CLI to control iOS and Android devices for AI agents influenced by Vercel’s [a
|
|
|
13
13
|
The project is in early development and considered experimental. Pull requests are welcome!
|
|
14
14
|
|
|
15
15
|
## Features
|
|
16
|
-
- Platforms: iOS (simulator + physical device core automation) and Android (emulator + device).
|
|
16
|
+
- Platforms: iOS/tvOS (simulator + physical device core automation) and Android/AndroidTV (emulator + device).
|
|
17
17
|
- Core commands: `open`, `back`, `home`, `app-switcher`, `press`, `long-press`, `focus`, `type`, `fill`, `scroll`, `scrollintoview`, `wait`, `alert`, `screenshot`, `close`, `reinstall`, `push`.
|
|
18
18
|
- Inspection commands: `snapshot` (accessibility tree), `diff snapshot` (structural baseline diff), `appstate`, `apps`, `devices`.
|
|
19
|
-
-
|
|
19
|
+
- Clipboard commands: `clipboard read`, `clipboard write <text>`.
|
|
20
|
+
- Performance command: `perf` (alias: `metrics`) returns a metrics JSON blob for the active session; startup timing is currently sampled.
|
|
21
|
+
- App logs and traffic inspection: `logs path` returns session log metadata; `logs start` / `logs stop` stream app output; `logs clear` truncates session app logs; `logs clear --restart` resets and restarts stream in one step; `logs doctor` checks readiness; `logs mark` writes timeline markers; `network dump` parses recent HTTP(s) entries from session logs.
|
|
20
22
|
- Device tooling: `adb` (Android), `simctl`/`devicectl` (iOS via Xcode).
|
|
21
23
|
- Minimal dependencies; TypeScript executed directly on Node 22+ (no build step).
|
|
22
24
|
|
|
@@ -33,6 +35,7 @@ npx agent-device open SampleApp
|
|
|
33
35
|
```
|
|
34
36
|
|
|
35
37
|
The skill is also accessible on [ClawHub](https://clawhub.ai/okwasniewski/agent-device).
|
|
38
|
+
For structured exploratory QA workflows, use the dogfood skill at [skills/dogfood/SKILL.md](skills/dogfood/SKILL.md).
|
|
36
39
|
|
|
37
40
|
## Quick Start
|
|
38
41
|
|
|
@@ -147,11 +150,14 @@ agent-device scrollintoview @e42
|
|
|
147
150
|
- `alert`, `wait`, `screenshot`
|
|
148
151
|
- `trace start`, `trace stop`
|
|
149
152
|
- `logs path`, `logs start`, `logs stop`, `logs clear`, `logs clear --restart`, `logs doctor`, `logs mark` (session app log file for grep; iOS simulator + iOS device + Android)
|
|
153
|
+
- `clipboard read`, `clipboard write <text>` (iOS simulator + Android)
|
|
154
|
+
- `network dump [limit] [summary|headers|body|all]`, `network log ...` (best-effort HTTP(s) parsing from session app log)
|
|
150
155
|
- `settings wifi|airplane|location on|off`
|
|
151
156
|
- `settings appearance light|dark|toggle`
|
|
152
157
|
- `settings faceid match|nonmatch|enroll|unenroll` (iOS simulator only)
|
|
153
158
|
- `settings permission grant|deny|reset camera|microphone|photos|contacts|notifications [full|limited]`
|
|
154
159
|
- `appstate`, `apps`, `devices`, `session list`
|
|
160
|
+
- `perf` (alias: `metrics`)
|
|
155
161
|
|
|
156
162
|
Push notification simulation:
|
|
157
163
|
|
|
@@ -196,7 +202,8 @@ Efficient snapshot usage:
|
|
|
196
202
|
|
|
197
203
|
Flags:
|
|
198
204
|
- `--version, -V` print version and exit
|
|
199
|
-
- `--platform ios|android`
|
|
205
|
+
- `--platform ios|android|apple` (`apple` aliases the iOS/tvOS backend)
|
|
206
|
+
- `--target mobile|tv` select device class within platform (requires `--platform`; for example AndroidTV/tvOS)
|
|
200
207
|
- `--device <name>`
|
|
201
208
|
- `--udid <udid>` (iOS)
|
|
202
209
|
- `--serial <serial>` (Android)
|
|
@@ -216,8 +223,22 @@ Flags:
|
|
|
216
223
|
- `--on-error stop` batch: stop when a step fails
|
|
217
224
|
- `--max-steps <n>` batch: max allowed steps per request
|
|
218
225
|
|
|
226
|
+
TV targets:
|
|
227
|
+
- Use `--target tv` together with `--platform ios|android|apple`.
|
|
228
|
+
- TV target selection supports both simulator/emulator and connected physical devices (AppleTV + AndroidTV).
|
|
229
|
+
- AndroidTV app launch/app listing use TV launcher discovery (`LEANBACK_LAUNCHER`) and fallback component resolution when needed.
|
|
230
|
+
- tvOS uses the same runner-driven interaction/snapshot flow as iOS (`snapshot`, `wait`, `press`, `fill`, `get`, `scroll`, `back`, `home`, `app-switcher`, `record`, and related selector flows).
|
|
231
|
+
- tvOS back/home/app-switcher use Siri Remote semantics in the runner (`menu`, `home`, double-home).
|
|
232
|
+
- tvOS follows iOS simulator-only command semantics for helpers like `pinch`, `settings`, and `push`.
|
|
233
|
+
|
|
234
|
+
Examples:
|
|
235
|
+
- `agent-device open YouTube --platform android --target tv`
|
|
236
|
+
- `agent-device apps --platform android --target tv`
|
|
237
|
+
- `agent-device open Settings --platform ios --target tv`
|
|
238
|
+
- `agent-device screenshot ./apple-tv.png --platform ios --target tv`
|
|
239
|
+
|
|
219
240
|
Pinch:
|
|
220
|
-
- `pinch` is supported on iOS simulators.
|
|
241
|
+
- `pinch` is supported on iOS simulators (including tvOS simulator targets).
|
|
221
242
|
- On Android, `pinch` currently returns `UNSUPPORTED_OPERATION` in the adb backend.
|
|
222
243
|
|
|
223
244
|
Swipe timing:
|
|
@@ -246,7 +267,7 @@ Sessions:
|
|
|
246
267
|
- On iOS, `appstate` is session-scoped and requires an active session on the target device.
|
|
247
268
|
|
|
248
269
|
Navigation helpers:
|
|
249
|
-
- `boot --platform ios|android` ensures the target is ready without launching an app.
|
|
270
|
+
- `boot --platform ios|android|apple` ensures the target is ready without launching an app.
|
|
250
271
|
- Use `boot` mainly when starting a new session and `open` fails because no booted simulator/emulator is available.
|
|
251
272
|
- `open [app|url] [url]` already boots/activates the selected target when needed.
|
|
252
273
|
- `reinstall <app> <path>` uninstalls and installs the app binary in one command (Android + iOS simulator/device).
|
|
@@ -276,6 +297,25 @@ Assertions:
|
|
|
276
297
|
- `is` predicates: `visible`, `hidden`, `exists`, `editable`, `selected`, `text`.
|
|
277
298
|
- `is text` uses exact equality.
|
|
278
299
|
|
|
300
|
+
Performance metrics:
|
|
301
|
+
- `perf` (or `metrics`) requires an active session and returns a JSON metrics blob.
|
|
302
|
+
- Current metric: `startup` sampled from the elapsed wall-clock time around each session `open` command dispatch (`open-command-roundtrip`), unit `ms`.
|
|
303
|
+
- Startup samples are session-scoped and include sample history from recent `open` actions.
|
|
304
|
+
- Platform support for current sampling: iOS simulator, iOS physical device, Android emulator/device.
|
|
305
|
+
- `fps`, `memory`, and `cpu` are reported as not yet implemented in this release.
|
|
306
|
+
- Quick usage:
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
agent-device open Settings --platform ios
|
|
310
|
+
agent-device perf --json
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
- How to read it:
|
|
314
|
+
- `metrics.startup.lastDurationMs`: most recent startup sample in milliseconds.
|
|
315
|
+
- `metrics.startup.samples[]`: recent startup history for this session.
|
|
316
|
+
- `sampling.startup.method`: currently `open-command-roundtrip`.
|
|
317
|
+
- Caveat: startup here is command-to-launch round-trip timing, not true app TTI/first-interactive telemetry.
|
|
318
|
+
|
|
279
319
|
Replay update:
|
|
280
320
|
- `replay <path>` runs deterministic replay from `.ad` scripts.
|
|
281
321
|
- `replay -u <path>` attempts selector updates on failures and atomically rewrites the same file.
|
|
@@ -333,11 +373,18 @@ App state:
|
|
|
333
373
|
- On iOS, `appstate` returns the currently tracked session app (`source: session`) and requires an active session on the selected device.
|
|
334
374
|
- `apps` includes default/system apps by default (use `--user-installed` to filter).
|
|
335
375
|
|
|
376
|
+
Clipboard:
|
|
377
|
+
- `clipboard read` returns current clipboard text.
|
|
378
|
+
- `clipboard write <text>` sets clipboard text (`clipboard write ""` clears it).
|
|
379
|
+
- Supported on Android emulator/device and iOS simulator.
|
|
380
|
+
- iOS physical devices currently return `UNSUPPORTED_OPERATION` for clipboard commands.
|
|
381
|
+
|
|
336
382
|
## Debug
|
|
337
383
|
|
|
338
384
|
- **App logs (token-efficient):** Logging is off by default in normal flows. Enable it on demand when debugging. With an active session, run `logs path` to get path + state metadata (e.g. `~/.agent-device/sessions/<session>/app.log`). Run `logs start` to stream app output to that file; use `logs stop` to stop. Run `logs clear` to truncate `app.log` (and remove rotated `app.log.N` files) before a new repro window. Run `logs doctor` for tool/runtime checks and `logs mark "step"` to insert timeline markers. Grep the file when you need to inspect errors (e.g. `grep -n "Error\|Exception" <path>`) instead of pulling full logs into context. Supported on iOS simulator, iOS physical device, and Android.
|
|
339
385
|
- Use `logs clear --restart` when you want one command to stop an active stream, clear current logs, and immediately resume streaming.
|
|
340
386
|
- `logs start` appends to `app.log` and rotates to `app.log.1` when the file exceeds 5 MB.
|
|
387
|
+
- **Network dump (best-effort):** `network dump [limit] [summary|headers|body|all]` parses recent HTTP(s) lines from the same session app log file and returns method/url/status with optional headers/bodies. `network log ...` is an alias. Current limits: scans up to 4000 recent log lines, returns up to 200 entries, truncates payload/header fields at 2048 characters.
|
|
341
388
|
- Android log streaming automatically rebinds to the app PID after process restarts.
|
|
342
389
|
- Detailed playbook: `skills/agent-device/references/logs-and-debug.md`
|
|
343
390
|
- iOS log capture relies on Unified Logging signals (for example `os_log`); plain stdout/stderr output may be limited depending on app/runtime.
|
|
@@ -354,7 +401,7 @@ Boot diagnostics:
|
|
|
354
401
|
- Boot failures include normalized reason codes in `error.details.reason` (JSON mode) and verbose logs.
|
|
355
402
|
- Reason codes: `IOS_BOOT_TIMEOUT`, `IOS_RUNNER_CONNECT_TIMEOUT`, `ANDROID_BOOT_TIMEOUT`, `ADB_TRANSPORT_UNAVAILABLE`, `CI_RESOURCE_STARVATION_SUSPECTED`, `BOOT_COMMAND_FAILED`, `UNKNOWN`.
|
|
356
403
|
- Android boot waits fail fast for permission/tooling issues and do not always collapse into timeout errors.
|
|
357
|
-
- Use `agent-device boot --platform ios|android` when starting a new session only if `open` cannot find/connect to an available target.
|
|
404
|
+
- Use `agent-device boot --platform ios|android|apple` when starting a new session only if `open` cannot find/connect to an available target.
|
|
358
405
|
- `--debug` captures retry telemetry in diagnostics logs.
|
|
359
406
|
- Set `AGENT_DEVICE_RETRY_LOGS=1` to also print retry telemetry directly to stderr (ad-hoc troubleshooting).
|
|
360
407
|
|
|
@@ -371,6 +418,7 @@ Diagnostics files:
|
|
|
371
418
|
## iOS notes
|
|
372
419
|
- Core runner commands: `snapshot`, `wait`, `click`, `fill`, `get`, `is`, `find`, `press`, `longpress`, `focus`, `type`, `scroll`, `scrollintoview`, `back`, `home`, `app-switcher`.
|
|
373
420
|
- Simulator-only commands: `alert`, `pinch`, `settings`.
|
|
421
|
+
- tvOS targets are selectable (`--platform ios --target tv` or `--platform apple --target tv`) and support runner-driven interaction/snapshot commands.
|
|
374
422
|
- `record` supports iOS simulators and physical iOS devices.
|
|
375
423
|
- iOS simulator recording uses native `simctl io ... recordVideo`.
|
|
376
424
|
- Physical iOS device recording is runner-based and built from repeated `XCUIScreen.main.screenshot()` frames (no native video stream/audio capture).
|
|
@@ -409,7 +457,7 @@ Environment selectors:
|
|
|
409
457
|
- `AGENT_DEVICE_IOS_SIGNING_IDENTITY=<identity>` optional signing identity override.
|
|
410
458
|
- `AGENT_DEVICE_IOS_PROVISIONING_PROFILE=<profile>` optional provisioning profile specifier for iOS device runner signing.
|
|
411
459
|
- `AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH=<path>` optional override for iOS runner derived data root. By default, simulator uses `~/.agent-device/ios-runner/derived` and physical device uses `~/.agent-device/ios-runner/derived/device`. If you set this override, use separate paths per kind to avoid simulator/device artifact collisions.
|
|
412
|
-
- `AGENT_DEVICE_IOS_CLEAN_DERIVED=1` rebuild iOS runner artifacts from scratch for runtime daemon-triggered builds (`pnpm ad ...`) on the selected path. `pnpm build:xcuitest
|
|
460
|
+
- `AGENT_DEVICE_IOS_CLEAN_DERIVED=1` rebuild iOS runner artifacts from scratch for runtime daemon-triggered builds (`pnpm ad ...`) on the selected path. `pnpm build:xcuitest` (alias of `pnpm build:xcuitest:ios`), `pnpm build:xcuitest:tvos`, and `pnpm build:all` already clear their default derived paths and do not require this variable. When `AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH` is set, cleanup is blocked by default; set `AGENT_DEVICE_IOS_ALLOW_OVERRIDE_DERIVED_CLEAN=1` only for trusted custom paths.
|
|
413
461
|
|
|
414
462
|
Test screenshots are written to:
|
|
415
463
|
- `test/screenshots/android-settings.png`
|
package/dist/src/bin.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import{styleText as e}from"node:util";import{buildSnapshotDisplayLines as t,node_path as s,createRequestId as a,parseBatchStepsJson as r,normalizeError as i,isAgentDeviceDaemonProcess as o,runCmdDetached as n,readVersion as l,findProjectRoot as p,getDiagnosticsMeta as d,runCmdSync as c,withDiagnosticTimer as u,emitDiagnostic as g,SETTINGS_USAGE_OVERRIDE as m,asAppError as f,pathToFileURL as h,AppError as y,node_fs as w,node_os as v,node_net as b,withDiagnosticsScope as $,flushDiagnosticsToSessionFile as k,stopProcessForTakeover as S,formatSnapshotLine as A}from"./735.js";let x=["snapshotInteractiveOnly","snapshotCompact","snapshotDepth","snapshotScope","snapshotRaw"],D=["snapshotDepth","snapshotScope","snapshotRaw"],I=[{key:"platform",names:["--platform"],type:"enum",enumValues:["ios","android"],usageLabel:"--platform ios|android",usageDescription:"Platform to target"},{key:"device",names:["--device"],type:"string",usageLabel:"--device <name>",usageDescription:"Device name to target"},{key:"udid",names:["--udid"],type:"string",usageLabel:"--udid <udid>",usageDescription:"iOS device UDID"},{key:"serial",names:["--serial"],type:"string",usageLabel:"--serial <serial>",usageDescription:"Android device serial"},{key:"activity",names:["--activity"],type:"string",usageLabel:"--activity <component>",usageDescription:"Android app launch activity (package/Activity); not for URL opens"},{key:"session",names:["--session"],type:"string",usageLabel:"--session <name>",usageDescription:"Named session"},{key:"count",names:["--count"],type:"int",min:1,max:200,usageLabel:"--count <n>",usageDescription:"Repeat count for press/swipe series"},{key:"fps",names:["--fps"],type:"int",min:1,max:120,usageLabel:"--fps <n>",usageDescription:"Record: target frames per second (iOS physical device runner)"},{key:"intervalMs",names:["--interval-ms"],type:"int",min:0,max:1e4,usageLabel:"--interval-ms <ms>",usageDescription:"Delay between press iterations"},{key:"holdMs",names:["--hold-ms"],type:"int",min:0,max:1e4,usageLabel:"--hold-ms <ms>",usageDescription:"Press hold duration for each iteration"},{key:"jitterPx",names:["--jitter-px"],type:"int",min:0,max:100,usageLabel:"--jitter-px <n>",usageDescription:"Deterministic coordinate jitter radius for press"},{key:"doubleTap",names:["--double-tap"],type:"boolean",usageLabel:"--double-tap",usageDescription:"Use double-tap gesture per press iteration"},{key:"pauseMs",names:["--pause-ms"],type:"int",min:0,max:1e4,usageLabel:"--pause-ms <ms>",usageDescription:"Delay between swipe iterations"},{key:"pattern",names:["--pattern"],type:"enum",enumValues:["one-way","ping-pong"],usageLabel:"--pattern one-way|ping-pong",usageDescription:"Swipe repeat pattern"},{key:"verbose",names:["--debug","--verbose","-v"],type:"boolean",usageLabel:"--debug, --verbose, -v",usageDescription:"Enable debug diagnostics and stream daemon/runner logs"},{key:"json",names:["--json"],type:"boolean",usageLabel:"--json",usageDescription:"JSON output"},{key:"help",names:["--help","-h"],type:"boolean",usageLabel:"--help, -h",usageDescription:"Print help and exit"},{key:"version",names:["--version","-V"],type:"boolean",usageLabel:"--version, -V",usageDescription:"Print version and exit"},{key:"saveScript",names:["--save-script"],type:"booleanOrString",usageLabel:"--save-script [path]",usageDescription:"Save session script (.ad) on close; optional custom output path"},{key:"relaunch",names:["--relaunch"],type:"boolean",usageLabel:"--relaunch",usageDescription:"open: terminate app process before launching it"},{key:"restart",names:["--restart"],type:"boolean",usageLabel:"--restart",usageDescription:"logs clear: stop active stream, clear logs, then start streaming again"},{key:"noRecord",names:["--no-record"],type:"boolean",usageLabel:"--no-record",usageDescription:"Do not record this action"},{key:"replayUpdate",names:["--update","-u"],type:"boolean",usageLabel:"--update, -u",usageDescription:"Replay: update selectors and rewrite replay file in place"},{key:"steps",names:["--steps"],type:"string",usageLabel:"--steps <json>",usageDescription:"Batch: JSON array of steps"},{key:"stepsFile",names:["--steps-file"],type:"string",usageLabel:"--steps-file <path>",usageDescription:"Batch: read steps JSON from file"},{key:"batchOnError",names:["--on-error"],type:"enum",enumValues:["stop"],usageLabel:"--on-error stop",usageDescription:"Batch: stop when a step fails"},{key:"batchMaxSteps",names:["--max-steps"],type:"int",min:1,max:1e3,usageLabel:"--max-steps <n>",usageDescription:"Batch: maximum number of allowed steps"},{key:"appsFilter",names:["--user-installed"],type:"enum",setValue:"user-installed",usageLabel:"--user-installed",usageDescription:"Apps: list user-installed apps"},{key:"appsFilter",names:["--all"],type:"enum",setValue:"all",usageLabel:"--all",usageDescription:"Apps: list all apps (include system/default apps)"},{key:"snapshotInteractiveOnly",names:["-i"],type:"boolean",usageLabel:"-i",usageDescription:"Snapshot: interactive elements only"},{key:"snapshotCompact",names:["-c"],type:"boolean",usageLabel:"-c",usageDescription:"Snapshot: compact output (drop empty structure)"},{key:"snapshotDepth",names:["--depth","-d"],type:"int",min:0,usageLabel:"--depth, -d <depth>",usageDescription:"Snapshot: limit snapshot depth"},{key:"snapshotScope",names:["--scope","-s"],type:"string",usageLabel:"--scope, -s <scope>",usageDescription:"Snapshot: scope snapshot to label/identifier"},{key:"snapshotRaw",names:["--raw"],type:"boolean",usageLabel:"--raw",usageDescription:"Snapshot: raw node output"},{key:"out",names:["--out"],type:"string",usageLabel:"--out <path>",usageDescription:"Output path"}],F=new Set(["json","help","version","verbose","platform","device","udid","serial","session","noRecord"]),L={boot:{description:"Ensure target device/simulator is booted and ready",positionalArgs:[],allowedFlags:[]},open:{description:"Boot device/simulator; optionally launch app or deep link URL",positionalArgs:["appOrUrl?","url?"],allowedFlags:["activity","saveScript","relaunch"]},close:{description:"Close app or just end session",positionalArgs:["app?"],allowedFlags:["saveScript"]},reinstall:{description:"Uninstall + install app from binary path",positionalArgs:["app","path"],allowedFlags:[]},push:{description:"Simulate push notification payload delivery",positionalArgs:["bundleOrPackage","payloadOrJson"],allowedFlags:[]},snapshot:{description:"Capture accessibility tree",positionalArgs:[],allowedFlags:[...x]},diff:{usageOverride:"diff snapshot",description:"Diff current accessibility snapshot against previous baseline",positionalArgs:["kind"],allowedFlags:[...x]},devices:{description:"List available devices",positionalArgs:[],allowedFlags:[],skipCapabilityCheck:!0},apps:{description:"List installed apps (includes default/system apps by default)",positionalArgs:[],allowedFlags:["appsFilter"],defaults:{appsFilter:"all"}},appstate:{description:"Show foreground app/activity",positionalArgs:[],allowedFlags:[],skipCapabilityCheck:!0},back:{description:"Navigate back (where supported)",positionalArgs:[],allowedFlags:[]},home:{description:"Go to home screen (where supported)",positionalArgs:[],allowedFlags:[]},"app-switcher":{description:"Open app switcher (where supported)",positionalArgs:[],allowedFlags:[]},wait:{usageOverride:"wait <ms>|text <text>|@ref|<selector> [timeoutMs]",description:"Wait for duration, text, ref, or selector to appear",positionalArgs:["durationOrSelector","timeoutMs?"],allowsExtraPositionals:!0,allowedFlags:[...D]},alert:{usageOverride:"alert [get|accept|dismiss|wait] [timeout]",description:"Inspect or handle alert (iOS simulator)",positionalArgs:["action?","timeout?"],allowedFlags:[]},click:{usageOverride:"click <x y|@ref|selector>",description:"Tap/click by coordinates, snapshot ref, or selector",positionalArgs:["target"],allowsExtraPositionals:!0,allowedFlags:["count","intervalMs","holdMs","jitterPx","doubleTap",...D]},get:{usageOverride:"get text|attrs <@ref|selector>",description:"Return element text/attributes by ref or selector",positionalArgs:["subcommand","target"],allowedFlags:[...D]},replay:{description:"Replay a recorded session",positionalArgs:["path"],allowedFlags:["replayUpdate"],skipCapabilityCheck:!0},batch:{usageOverride:"batch [--steps <json> | --steps-file <path>]",description:"Execute multiple commands in one daemon request",positionalArgs:[],allowedFlags:["steps","stepsFile","batchOnError","batchMaxSteps","out"],skipCapabilityCheck:!0},press:{usageOverride:"press <x y|@ref|selector>",description:"Tap/press by coordinates, snapshot ref, or selector (supports repeated series)",positionalArgs:["targetOrX","y?"],allowsExtraPositionals:!0,allowedFlags:["count","intervalMs","holdMs","jitterPx","doubleTap",...D]},longpress:{description:"Long press by coordinates (iOS and Android)",positionalArgs:["x","y","durationMs?"],allowedFlags:[]},swipe:{description:"Swipe coordinates with optional repeat pattern",positionalArgs:["x1","y1","x2","y2","durationMs?"],allowedFlags:["count","pauseMs","pattern"]},focus:{description:"Focus input at coordinates",positionalArgs:["x","y"],allowedFlags:[]},type:{description:"Type text in focused field",positionalArgs:["text"],allowsExtraPositionals:!0,allowedFlags:[]},fill:{usageOverride:"fill <x> <y> <text> | fill <@ref|selector> <text>",description:"Tap then type",positionalArgs:["targetOrX","yOrText","text?"],allowsExtraPositionals:!0,allowedFlags:[...D]},scroll:{description:"Scroll in direction (0-1 amount)",positionalArgs:["direction","amount?"],allowedFlags:[]},scrollintoview:{usageOverride:"scrollintoview <text|@ref>",description:"Scroll until text appears or a snapshot ref is brought into view",positionalArgs:["target"],allowsExtraPositionals:!0,allowedFlags:[]},pinch:{description:"Pinch/zoom gesture (iOS simulator)",positionalArgs:["scale","x?","y?"],allowedFlags:[]},screenshot:{description:"Capture screenshot",positionalArgs:["path?"],allowedFlags:["out"]},record:{usageOverride:"record start [path] [--fps <n>] | record stop",description:"Start/stop screen recording",positionalArgs:["start|stop","path?"],allowedFlags:["fps"]},trace:{usageOverride:"trace start [path] | trace stop [path]",description:"Start/stop trace log capture",positionalArgs:["start|stop","path?"],allowedFlags:[],skipCapabilityCheck:!0},logs:{usageOverride:"logs path | logs start | logs stop | logs clear [--restart] | logs doctor | logs mark [message...]",description:"Session app log info, start/stop streaming, diagnostics, and markers",positionalArgs:["path|start|stop|clear|doctor|mark","message?"],allowsExtraPositionals:!0,allowedFlags:["restart"]},find:{usageOverride:"find <locator|text> <action> [value]",description:"Find by text/label/value/role/id and run action",positionalArgs:["query","action","value?"],allowsExtraPositionals:!0,allowedFlags:["snapshotDepth","snapshotRaw"]},is:{description:"Assert UI state (visible|hidden|exists|editable|selected|text)",positionalArgs:["predicate","selector","value?"],allowsExtraPositionals:!0,allowedFlags:[...D]},settings:{usageOverride:m,description:"Toggle OS settings, appearance, and app permissions (session app scope for permission actions)",positionalArgs:["setting","state","target?","mode?"],allowedFlags:[]},session:{usageOverride:"session list",description:"List active sessions",positionalArgs:["list?"],allowedFlags:[],skipCapabilityCheck:!0}},O=new Map,N=new Map;for(let e of I){for(let t of e.names)O.set(t,e);let t=N.get(e.key);t?t.push(e):N.set(e.key,[e])}function j(e){if(e)return L[e]}function _(e){let t=e.endsWith("?"),s=t?e.slice(0,-1):e;return t?`[${s}]`:`<${s}>`}function E(e,t){return t.usageOverride?t.usageOverride:[e,...t.positionalArgs.map(_),...t.allowedFlags.flatMap(e=>(N.get(e)??[]).map(e=>e.usageLabel??e.names[0])).map(e=>`[${e}]`)].join(" ")}let M=function(){let e=`agent-device <command> [args] [--json]
|
|
1
|
+
import{styleText as e}from"node:util";import{buildSnapshotDisplayLines as t,node_path as s,createRequestId as r,parseBatchStepsJson as a,normalizeError as i,isAgentDeviceDaemonProcess as o,runCmdDetached as n,readVersion as l,findProjectRoot as p,getDiagnosticsMeta as d,runCmdSync as c,withDiagnosticTimer as u,emitDiagnostic as g,SETTINGS_USAGE_OVERRIDE as m,asAppError as f,pathToFileURL as h,AppError as y,node_fs as w,node_os as v,node_net as b,withDiagnosticsScope as $,flushDiagnosticsToSessionFile as k,stopProcessForTakeover as A,formatSnapshotLine as S}from"./735.js";let x=["snapshotInteractiveOnly","snapshotCompact","snapshotDepth","snapshotScope","snapshotRaw"],D=["snapshotDepth","snapshotScope","snapshotRaw"],I=[{key:"platform",names:["--platform"],type:"enum",enumValues:["ios","android","apple"],usageLabel:"--platform ios|android|apple",usageDescription:"Platform to target (`apple` aliases the iOS/tvOS backend)"},{key:"target",names:["--target"],type:"enum",enumValues:["mobile","tv"],usageLabel:"--target mobile|tv",usageDescription:"Device target class to match"},{key:"device",names:["--device"],type:"string",usageLabel:"--device <name>",usageDescription:"Device name to target"},{key:"udid",names:["--udid"],type:"string",usageLabel:"--udid <udid>",usageDescription:"iOS device UDID"},{key:"serial",names:["--serial"],type:"string",usageLabel:"--serial <serial>",usageDescription:"Android device serial"},{key:"activity",names:["--activity"],type:"string",usageLabel:"--activity <component>",usageDescription:"Android app launch activity (package/Activity); not for URL opens"},{key:"session",names:["--session"],type:"string",usageLabel:"--session <name>",usageDescription:"Named session"},{key:"count",names:["--count"],type:"int",min:1,max:200,usageLabel:"--count <n>",usageDescription:"Repeat count for press/swipe series"},{key:"fps",names:["--fps"],type:"int",min:1,max:120,usageLabel:"--fps <n>",usageDescription:"Record: target frames per second (iOS physical device runner)"},{key:"intervalMs",names:["--interval-ms"],type:"int",min:0,max:1e4,usageLabel:"--interval-ms <ms>",usageDescription:"Delay between press iterations"},{key:"holdMs",names:["--hold-ms"],type:"int",min:0,max:1e4,usageLabel:"--hold-ms <ms>",usageDescription:"Press hold duration for each iteration"},{key:"jitterPx",names:["--jitter-px"],type:"int",min:0,max:100,usageLabel:"--jitter-px <n>",usageDescription:"Deterministic coordinate jitter radius for press"},{key:"doubleTap",names:["--double-tap"],type:"boolean",usageLabel:"--double-tap",usageDescription:"Use double-tap gesture per press iteration"},{key:"pauseMs",names:["--pause-ms"],type:"int",min:0,max:1e4,usageLabel:"--pause-ms <ms>",usageDescription:"Delay between swipe iterations"},{key:"pattern",names:["--pattern"],type:"enum",enumValues:["one-way","ping-pong"],usageLabel:"--pattern one-way|ping-pong",usageDescription:"Swipe repeat pattern"},{key:"verbose",names:["--debug","--verbose","-v"],type:"boolean",usageLabel:"--debug, --verbose, -v",usageDescription:"Enable debug diagnostics and stream daemon/runner logs"},{key:"json",names:["--json"],type:"boolean",usageLabel:"--json",usageDescription:"JSON output"},{key:"help",names:["--help","-h"],type:"boolean",usageLabel:"--help, -h",usageDescription:"Print help and exit"},{key:"version",names:["--version","-V"],type:"boolean",usageLabel:"--version, -V",usageDescription:"Print version and exit"},{key:"saveScript",names:["--save-script"],type:"booleanOrString",usageLabel:"--save-script [path]",usageDescription:"Save session script (.ad) on close; optional custom output path"},{key:"relaunch",names:["--relaunch"],type:"boolean",usageLabel:"--relaunch",usageDescription:"open: terminate app process before launching it"},{key:"restart",names:["--restart"],type:"boolean",usageLabel:"--restart",usageDescription:"logs clear: stop active stream, clear logs, then start streaming again"},{key:"noRecord",names:["--no-record"],type:"boolean",usageLabel:"--no-record",usageDescription:"Do not record this action"},{key:"replayUpdate",names:["--update","-u"],type:"boolean",usageLabel:"--update, -u",usageDescription:"Replay: update selectors and rewrite replay file in place"},{key:"steps",names:["--steps"],type:"string",usageLabel:"--steps <json>",usageDescription:"Batch: JSON array of steps"},{key:"stepsFile",names:["--steps-file"],type:"string",usageLabel:"--steps-file <path>",usageDescription:"Batch: read steps JSON from file"},{key:"batchOnError",names:["--on-error"],type:"enum",enumValues:["stop"],usageLabel:"--on-error stop",usageDescription:"Batch: stop when a step fails"},{key:"batchMaxSteps",names:["--max-steps"],type:"int",min:1,max:1e3,usageLabel:"--max-steps <n>",usageDescription:"Batch: maximum number of allowed steps"},{key:"appsFilter",names:["--user-installed"],type:"enum",setValue:"user-installed",usageLabel:"--user-installed",usageDescription:"Apps: list user-installed apps"},{key:"appsFilter",names:["--all"],type:"enum",setValue:"all",usageLabel:"--all",usageDescription:"Apps: list all apps (include system/default apps)"},{key:"snapshotInteractiveOnly",names:["-i"],type:"boolean",usageLabel:"-i",usageDescription:"Snapshot: interactive elements only"},{key:"snapshotCompact",names:["-c"],type:"boolean",usageLabel:"-c",usageDescription:"Snapshot: compact output (drop empty structure)"},{key:"snapshotDepth",names:["--depth","-d"],type:"int",min:0,usageLabel:"--depth, -d <depth>",usageDescription:"Snapshot: limit snapshot depth"},{key:"snapshotScope",names:["--scope","-s"],type:"string",usageLabel:"--scope, -s <scope>",usageDescription:"Snapshot: scope snapshot to label/identifier"},{key:"snapshotRaw",names:["--raw"],type:"boolean",usageLabel:"--raw",usageDescription:"Snapshot: raw node output"},{key:"out",names:["--out"],type:"string",usageLabel:"--out <path>",usageDescription:"Output path"}],F=new Set(["json","help","version","verbose","platform","target","device","udid","serial","session","noRecord"]),L={boot:{description:"Ensure target device/simulator is booted and ready",positionalArgs:[],allowedFlags:[]},open:{description:"Boot device/simulator; optionally launch app or deep link URL",positionalArgs:["appOrUrl?","url?"],allowedFlags:["activity","saveScript","relaunch"]},close:{description:"Close app or just end session",positionalArgs:["app?"],allowedFlags:["saveScript"]},reinstall:{description:"Uninstall + install app from binary path",positionalArgs:["app","path"],allowedFlags:[]},push:{description:"Simulate push notification payload delivery",positionalArgs:["bundleOrPackage","payloadOrJson"],allowedFlags:[]},snapshot:{description:"Capture accessibility tree",positionalArgs:[],allowedFlags:[...x]},diff:{usageOverride:"diff snapshot",description:"Diff current accessibility snapshot against previous baseline",positionalArgs:["kind"],allowedFlags:[...x]},devices:{description:"List available devices",positionalArgs:[],allowedFlags:[],skipCapabilityCheck:!0},apps:{description:"List installed apps (includes default/system apps by default)",positionalArgs:[],allowedFlags:["appsFilter"],defaults:{appsFilter:"all"}},appstate:{description:"Show foreground app/activity",positionalArgs:[],allowedFlags:[],skipCapabilityCheck:!0},clipboard:{usageOverride:"clipboard read | clipboard write <text>",description:"Read or write device clipboard text",positionalArgs:["read|write","text?"],allowsExtraPositionals:!0,allowedFlags:[]},perf:{description:"Show session performance metrics (startup timing)",positionalArgs:[],allowedFlags:[]},back:{description:"Navigate back (where supported)",positionalArgs:[],allowedFlags:[]},home:{description:"Go to home screen (where supported)",positionalArgs:[],allowedFlags:[]},"app-switcher":{description:"Open app switcher (where supported)",positionalArgs:[],allowedFlags:[]},wait:{usageOverride:"wait <ms>|text <text>|@ref|<selector> [timeoutMs]",description:"Wait for duration, text, ref, or selector to appear",positionalArgs:["durationOrSelector","timeoutMs?"],allowsExtraPositionals:!0,allowedFlags:[...D]},alert:{usageOverride:"alert [get|accept|dismiss|wait] [timeout]",description:"Inspect or handle alert (iOS simulator)",positionalArgs:["action?","timeout?"],allowedFlags:[]},click:{usageOverride:"click <x y|@ref|selector>",description:"Tap/click by coordinates, snapshot ref, or selector",positionalArgs:["target"],allowsExtraPositionals:!0,allowedFlags:["count","intervalMs","holdMs","jitterPx","doubleTap",...D]},get:{usageOverride:"get text|attrs <@ref|selector>",description:"Return element text/attributes by ref or selector",positionalArgs:["subcommand","target"],allowedFlags:[...D]},replay:{description:"Replay a recorded session",positionalArgs:["path"],allowedFlags:["replayUpdate"],skipCapabilityCheck:!0},batch:{usageOverride:"batch [--steps <json> | --steps-file <path>]",description:"Execute multiple commands in one daemon request",positionalArgs:[],allowedFlags:["steps","stepsFile","batchOnError","batchMaxSteps","out"],skipCapabilityCheck:!0},press:{usageOverride:"press <x y|@ref|selector>",description:"Tap/press by coordinates, snapshot ref, or selector (supports repeated series)",positionalArgs:["targetOrX","y?"],allowsExtraPositionals:!0,allowedFlags:["count","intervalMs","holdMs","jitterPx","doubleTap",...D]},longpress:{description:"Long press by coordinates (iOS and Android)",positionalArgs:["x","y","durationMs?"],allowedFlags:[]},swipe:{description:"Swipe coordinates with optional repeat pattern",positionalArgs:["x1","y1","x2","y2","durationMs?"],allowedFlags:["count","pauseMs","pattern"]},focus:{description:"Focus input at coordinates",positionalArgs:["x","y"],allowedFlags:[]},type:{description:"Type text in focused field",positionalArgs:["text"],allowsExtraPositionals:!0,allowedFlags:[]},fill:{usageOverride:"fill <x> <y> <text> | fill <@ref|selector> <text>",description:"Tap then type",positionalArgs:["targetOrX","yOrText","text?"],allowsExtraPositionals:!0,allowedFlags:[...D]},scroll:{description:"Scroll in direction (0-1 amount)",positionalArgs:["direction","amount?"],allowedFlags:[]},scrollintoview:{usageOverride:"scrollintoview <text|@ref>",description:"Scroll until text appears or a snapshot ref is brought into view",positionalArgs:["target"],allowsExtraPositionals:!0,allowedFlags:[]},pinch:{description:"Pinch/zoom gesture (iOS simulator)",positionalArgs:["scale","x?","y?"],allowedFlags:[]},screenshot:{description:"Capture screenshot",positionalArgs:["path?"],allowedFlags:["out"]},record:{usageOverride:"record start [path] [--fps <n>] | record stop",description:"Start/stop screen recording",positionalArgs:["start|stop","path?"],allowedFlags:["fps"]},trace:{usageOverride:"trace start [path] | trace stop [path]",description:"Start/stop trace log capture",positionalArgs:["start|stop","path?"],allowedFlags:[],skipCapabilityCheck:!0},logs:{usageOverride:"logs path | logs start | logs stop | logs clear [--restart] | logs doctor | logs mark [message...]",description:"Session app log info, start/stop streaming, diagnostics, and markers",positionalArgs:["path|start|stop|clear|doctor|mark","message?"],allowsExtraPositionals:!0,allowedFlags:["restart"]},network:{usageOverride:"network dump [limit] [summary|headers|body|all] | network log [limit] [summary|headers|body|all]",description:"Dump recent HTTP(s) traffic parsed from the session app log",positionalArgs:["dump|log","limit?","include?"],allowedFlags:[]},find:{usageOverride:"find <locator|text> <action> [value]",description:"Find by text/label/value/role/id and run action",positionalArgs:["query","action","value?"],allowsExtraPositionals:!0,allowedFlags:["snapshotDepth","snapshotRaw"]},is:{description:"Assert UI state (visible|hidden|exists|editable|selected|text)",positionalArgs:["predicate","selector","value?"],allowsExtraPositionals:!0,allowedFlags:[...D]},settings:{usageOverride:m,description:"Toggle OS settings, appearance, and app permissions (session app scope for permission actions)",positionalArgs:["setting","state","target?","mode?"],allowedFlags:[]},session:{usageOverride:"session list",description:"List active sessions",positionalArgs:["list?"],allowedFlags:[],skipCapabilityCheck:!0}},O=new Map,N=new Map;for(let e of I){for(let t of e.names)O.set(t,e);let t=N.get(e.key);t?t.push(e):N.set(e.key,[e])}function j(e){if(e)return L[e]}function _(e){let t=e.endsWith("?"),s=t?e.slice(0,-1):e;return t?`[${s}]`:`<${s}>`}function E(e,t){return t.usageOverride?t.usageOverride:[e,...t.positionalArgs.map(_),...t.allowedFlags.flatMap(e=>(N.get(e)??[]).map(e=>e.usageLabel??e.names[0])).map(e=>`[${e}]`)].join(" ")}let T=function(){let e=`agent-device <command> [args] [--json]
|
|
2
2
|
|
|
3
3
|
CLI to control iOS and Android devices for AI agents.
|
|
4
|
-
`,t=Object.keys(L).map(e=>{let t=L[e];if(!t)throw Error(`Missing command schema for ${e}`);return{name:e,schema:t,usage:E(e,t)}}),s=Math.max(...t.map(e=>e.usage.length))+2,
|
|
5
|
-
${
|
|
4
|
+
`,t=Object.keys(L).map(e=>{let t=L[e];if(!t)throw Error(`Missing command schema for ${e}`);return{name:e,schema:t,usage:E(e,t)}}),s=Math.max(...t.map(e=>e.usage.length))+2,r=["Commands:"];for(let e of t)r.push(` ${e.usage.padEnd(s)}${e.schema.description}`);let a=P("Flags:",I.filter(e=>e.usageLabel&&e.usageDescription));return`${e}
|
|
5
|
+
${r.join("\n")}
|
|
6
6
|
|
|
7
|
-
${
|
|
8
|
-
`}();function
|
|
9
|
-
(none)`;let s=Math.max(...t.map(e=>(e.usageLabel??"").length))+2,
|
|
7
|
+
${a}
|
|
8
|
+
`}();function M(e){return I.filter(t=>e.has(t.key)&&void 0!==t.usageLabel&&void 0!==t.usageDescription)}function P(e,t){if(0===t.length)return`${e}
|
|
9
|
+
(none)`;let s=Math.max(...t.map(e=>(e.usageLabel??"").length))+2,r=[e];for(let e of t)r.push(` ${(e.usageLabel??"").padEnd(s)}${e.usageDescription??""}`);return r.join("\n")}function R(e){let t=e.indexOf("=");return -1===t?[e,void 0]:[e.slice(0,t),e.slice(t+1)]}function C(e){return e.replace(/^-+/,"")}function V(e){if(!e.startsWith("-")||"-"===e)return!1;let[t]=e.startsWith("--")?R(e):[e,void 0];return void 0!==O.get(t)}function q(e){return"long-press"===e?"longpress":"metrics"===e?"perf":e}function G(e){process.stdout.write(`${JSON.stringify(e,null,2)}
|
|
10
10
|
`)}function B(e,t={}){let s=e instanceof y?i(e):e;process.stderr.write(`Error (${s.code}): ${s.message}
|
|
11
11
|
`),s.hint&&process.stderr.write(`Hint: ${s.hint}
|
|
12
12
|
`),s.diagnosticId&&process.stderr.write(`Diagnostic ID: ${s.diagnosticId}
|
|
13
13
|
`),s.logPath&&process.stderr.write(`Diagnostics Log: ${s.logPath}
|
|
14
14
|
`),t.showDetails&&s.details&&process.stderr.write(`${JSON.stringify(s.details,null,2)}
|
|
15
|
-
`)}function
|
|
16
|
-
`)}),i=setTimeout(()=>{
|
|
15
|
+
`)}function J(e){return"number"==typeof e&&Number.isFinite(e)?e:0}let U=s.join(v.homedir(),".agent-device"),W=s.join(U,"daemon.json"),z=s.join(U,"daemon.lock"),H=function(e=process.env.AGENT_DEVICE_DAEMON_TIMEOUT_MS){if(!e)return 9e4;let t=Number(e);return Number.isFinite(t)?Math.max(1e3,Math.floor(t)):9e4}(),K=["xcodebuild .*AgentDeviceRunnerUITests/RunnerTests/testCommand","xcodebuild .*AgentDeviceRunner\\.env\\.session-","xcodebuild build-for-testing .*ios-runner/AgentDeviceRunner/AgentDeviceRunner\\.xcodeproj"];async function X(e){let t=e.meta?.requestId??r(),s=!!(e.meta?.debug||e.flags?.verbose),a=await u("daemon_startup",async()=>await Z(),{requestId:t,session:e.session}),i={...e,token:a.token,meta:{requestId:t,debug:s,cwd:e.meta?.cwd}};return g({level:"info",phase:"daemon_request_prepare",data:{requestId:t,command:e.command,session:e.session}}),await u("daemon_request",async()=>await ep(a,i),{requestId:t,command:e.command})}async function Z(){var e;let t,r=et(),a=l(),i=function(e,t=p()){try{let r=w.statSync(e),a=s.relative(t,e)||e;return`${a}:${r.size}:${Math.trunc(r.mtimeMs)}`}catch{return"unknown"}}((t=el()).useSrc?t.srcPath:t.distPath,t.root),n=!!r&&await eo(r);if(r&&r.version===a&&r.codeSignature===i&&n)return r;r&&(r.version!==a||r.codeSignature!==i||!n)&&(await ee(r),ei(W)),function(){let e=er();if(!e.hasLock||e.hasInfo)return;let t=es();t&&o(t.pid,t.processStartTime)||ei(z)}(),await en();let d=await Y(5e3);if(d)return d;if(await Q()){await en();let e=await Y(5e3);if(e)return e}throw new y("COMMAND_FAILED","Failed to start daemon",{kind:"daemon_startup_failed",infoPath:W,lockPath:z,hint:(e=er()).hasLock&&!e.hasInfo?"Detected ~/.agent-device/daemon.lock without daemon.json. If no agent-device daemon process is running, delete ~/.agent-device/daemon.lock and retry.":e.hasLock&&e.hasInfo?"Daemon metadata may be stale. If no agent-device daemon process is running, delete ~/.agent-device/daemon.json and ~/.agent-device/daemon.lock, then retry.":"Daemon metadata is missing or stale. Delete ~/.agent-device/daemon.json if present and retry."})}async function Y(e){let t=Date.now();for(;Date.now()-t<e;){let e=et();if(e&&await eo(e))return e;await new Promise(e=>setTimeout(e,100))}return null}async function Q(){let e=er();if(!e.hasLock||e.hasInfo)return!1;let t=es();return t&&o(t.pid,t.processStartTime)&&await A(t.pid,{termTimeoutMs:3e3,killTimeoutMs:1e3,expectedStartTime:t.processStartTime}),ei(z),!0}async function ee(e){await A(e.pid,{termTimeoutMs:3e3,killTimeoutMs:1e3,expectedStartTime:e.processStartTime})}function et(){let e=ea(W);return e&&e.port&&e.token?{...e,pid:Number.isInteger(e.pid)&&e.pid>0?e.pid:0}:null}function es(){let e=ea(z);return e&&Number.isInteger(e.pid)&&!(e.pid<=0)?e:null}function er(){return{hasInfo:w.existsSync(W),hasLock:w.existsSync(z)}}function ea(e){if(!w.existsSync(e))return null;try{return JSON.parse(w.readFileSync(e,"utf8"))}catch{return null}}function ei(e){try{w.existsSync(e)&&w.unlinkSync(e)}catch{}}async function eo(e){return new Promise(t=>{let s=b.createConnection({host:"127.0.0.1",port:e.port},()=>{s.destroy(),t(!0)});s.on("error",()=>{t(!1)})})}async function en(){let e=el(),t=e.useSrc?["--experimental-strip-types",e.srcPath]:[e.distPath];n(process.execPath,t)}function el(){let e=p(),t=s.join(e,"dist","src","daemon.js"),r=s.join(e,"src","daemon.ts"),a=w.existsSync(t),i=w.existsSync(r);if(!a&&!i)throw new y("COMMAND_FAILED","Daemon entry not found",{distPath:t,srcPath:r});return{root:e,distPath:t,srcPath:r,useSrc:process.execArgv.includes("--experimental-strip-types")?i:!a&&i}}async function ep(e,t){return new Promise((s,r)=>{let a=b.createConnection({host:"127.0.0.1",port:e.port},()=>{a.write(`${JSON.stringify(t)}
|
|
16
|
+
`)}),i=setTimeout(()=>{a.destroy();let s=function(){let e=0;try{for(let t of K){let s=c("pkill",["-f",t],{allowFailure:!0});0===s.exitCode&&(e+=1)}return{terminated:e}}catch(t){return{terminated:e,error:t instanceof Error?t.message:String(t)}}}(),i=function(e){let t=!1;try{o(e.pid,e.processStartTime)&&(process.kill(e.pid,"SIGKILL"),t=!0)}catch{A(e.pid,{termTimeoutMs:3e3,killTimeoutMs:1e3,expectedStartTime:e.processStartTime})}finally{ei(W),ei(z)}return{forcedKill:t}}(e);g({level:"error",phase:"daemon_request_timeout",data:{timeoutMs:H,requestId:t.meta?.requestId,command:t.command,timedOutRunnerPidsTerminated:s.terminated,timedOutRunnerCleanupError:s.error,daemonPidReset:e.pid,daemonPidForceKilled:i.forcedKill}}),r(new y("COMMAND_FAILED","Daemon request timed out",{timeoutMs:H,requestId:t.meta?.requestId,hint:"Retry with --debug and check daemon diagnostics logs. Timed-out iOS runner xcodebuild processes were terminated when detected."}))},H),n="";a.setEncoding("utf8"),a.on("data",e=>{let o=(n+=e).indexOf("\n");if(-1===o)return;let l=n.slice(0,o).trim();if(l)try{let e=JSON.parse(l);a.end(),clearTimeout(i),s(e)}catch(e){clearTimeout(i),r(new y("COMMAND_FAILED","Invalid daemon response",{requestId:t.meta?.requestId,line:l},e instanceof Error?e:void 0))}}),a.on("error",e=>{clearTimeout(i),g({level:"error",phase:"daemon_request_socket_error",data:{requestId:t.meta?.requestId,message:e instanceof Error?e.message:String(e)}}),r(new y("COMMAND_FAILED","Failed to communicate with daemon",{requestId:t.meta?.requestId,hint:"Retry command. If this persists, clean stale daemon metadata and start a fresh session."},e))})})}let ed={sendToDaemon:X};async function ec(o,n=ed){let p=r(),c=o.includes("--debug")||o.includes("--verbose")||o.includes("-v"),u=o.includes("--json"),m=function(e){for(let t=0;t<e.length;t+=1){let s=e[t];if(s.startsWith("--session=")){let e=s.slice(10).trim();return e.length>0?e:null}if("--session"===s){let s=e[t+1]?.trim();if(s&&!s.startsWith("-"))return s;break}}return null}(o)??process.env.AGENT_DEVICE_SESSION??"default";await $({session:m,requestId:p,command:o[0],debug:c},async()=>{var r,m;let h;try{h=function(e,t){let s=(void 0)??function(e){if(!e)return!1;let t=e.trim().toLowerCase();return"1"===t||"true"===t||"yes"===t||"on"===t}(process.env.AGENT_DEVICE_STRICT_FLAGS),r={json:!1,help:!1,version:!1},a=null,i=[],o=[],n=[],l=!0;for(let t=0;t<e.length;t+=1){let s=e[t];if(l&&"--"===s){l=!1;continue}if(!l){a?i.push(s):a=q(s);continue}let o=s.startsWith("--"),p=s.startsWith("-")&&s.length>1;if(!o&&!p){a?i.push(s):a=q(s);continue}let[d,c]=o?R(s):[s,void 0],u=O.get(d);if(!u){if(function(e,t,s){var r;if(r=s,!/^-\d+(\.\d+)?$/.test(r)||!e)return!1;let a=j(e);return!a||!!a.allowsExtraPositionals||0!==a.positionalArgs.length&&(t.length<a.positionalArgs.length||a.positionalArgs.some(e=>e.includes("?")))}(a,i,s)){a?i.push(s):a=s;continue}throw new y("INVALID_ARGS",`Unknown flag: ${d}`)}let g=function(e,t,s,r){if(void 0!==e.setValue){if(void 0!==s)throw new y("INVALID_ARGS",`Flag ${t} does not take a value.`);return{value:e.setValue,consumeNext:!1}}if("boolean"===e.type){if(void 0!==s)throw new y("INVALID_ARGS",`Flag ${t} does not take a value.`);return{value:!0,consumeNext:!1}}if("booleanOrString"===e.type){if(void 0!==s){if(0===s.trim().length)throw new y("INVALID_ARGS",`Flag ${t} requires a non-empty value when provided.`);return{value:s,consumeNext:!1}}return void 0===r||V(r)||!function(e){let t=e.trim();return!(!t||/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(t))&&!!(t.startsWith("./")||t.startsWith("../")||t.startsWith("~/")||t.startsWith("/")||t.includes("/")||t.includes("\\"))}(r)?{value:!0,consumeNext:!1}:{value:r,consumeNext:!0}}let a=s??r;if(void 0===a||void 0===s&&V(a))throw new y("INVALID_ARGS",`Flag ${t} requires a value.`);if("string"===e.type)return{value:a,consumeNext:void 0===s};if("enum"===e.type){if(!e.enumValues?.includes(a))throw new y("INVALID_ARGS",`Invalid ${C(t)}: ${a}`);return{value:a,consumeNext:void 0===s}}let i=Number(a);if(!Number.isFinite(i)||"number"==typeof e.min&&i<e.min||"number"==typeof e.max&&i>e.max)throw new y("INVALID_ARGS",`Invalid ${C(t)}: ${a}`);return{value:Math.floor(i),consumeNext:void 0===s}}(u,d,c,e[t+1]);g.consumeNext&&(t+=1),r[u.key]=g.value,n.push({key:u.key,token:d})}let p=j(a),d=new Set([...F,...p?.allowedFlags??[]]),c=n.filter(e=>!d.has(e.key));if(c.length>0){var u,g;let e=(u=a,g=c.map(e=>e.token),u?1===g.length?`Flag ${g[0]} is not supported for command ${u}.`:`Flags ${g.join(", ")} are not supported for command ${u}.`:1===g.length?`Flag ${g[0]} requires a command that supports it.`:`Flags ${g.join(", ")} require a command that supports them.`);if(s)throw new y("INVALID_ARGS",e);for(let t of(o.push(`${e} Enable AGENT_DEVICE_STRICT_FLAGS=1 to fail fast.`),c))delete r[t.key]}if(p?.defaults)for(let[e,t]of Object.entries(p.defaults))void 0===r[e]&&(r[e]=t);if("batch"===a&&1!=+!!r.steps+ +!!r.stepsFile)throw new y("INVALID_ARGS","batch requires exactly one step source: --steps or --steps-file.");return{command:a,positionals:i,flags:r,warnings:o}}(o)}catch(t){g({level:"error",phase:"cli_parse_failed",data:{error:t instanceof Error?t.message:String(t)}});let e=i(t,{diagnosticId:d().diagnosticId,logPath:k({force:!0})??void 0});u?G({success:!1,error:e}):B(e,{showDetails:c}),process.exit(1);return}for(let e of h.warnings)process.stderr.write(`Warning: ${e}
|
|
17
17
|
`);h.flags.version&&(process.stdout.write(`${l()}
|
|
18
|
-
`),process.exit(0));let b="help"===h.command,$=h.flags.help;if(b||$){b&&h.positionals.length>1&&(B(new y("INVALID_ARGS","help accepts at most one command.")),process.exit(1));let e=b?h.positionals[0]:h.command;e||(process.stdout.write(`${
|
|
19
|
-
`),process.exit(0));let t=function(e){let t=j(e);if(!t)return null;let s=E(e,t),
|
|
18
|
+
`),process.exit(0));let b="help"===h.command,$=h.flags.help;if(b||$){b&&h.positionals.length>1&&(B(new y("INVALID_ARGS","help accepts at most one command.")),process.exit(1));let e=b?h.positionals[0]:h.command;e||(process.stdout.write(`${T}
|
|
19
|
+
`),process.exit(0));let t=function(e){let t=j(e);if(!t)return null;let s=E(e,t),r=M(new Set(t.allowedFlags)),a=M(F),i=[];return r.length>0&&i.push(P("Command flags:",r)),i.push(P("Global flags:",a)),`agent-device ${s}
|
|
20
20
|
|
|
21
21
|
${t.description}
|
|
22
22
|
|
|
@@ -24,43 +24,52 @@ Usage:
|
|
|
24
24
|
agent-device ${s}
|
|
25
25
|
|
|
26
26
|
${i.join("\n\n")}
|
|
27
|
-
`}(
|
|
28
|
-
`),process.exit(1)}h.command||(process.stdout.write(`${
|
|
29
|
-
`),process.exit(1));let{command:
|
|
30
|
-
`)),N&&N();return}if("session"===
|
|
31
|
-
`),N&&N();return}let s=await _({command:
|
|
32
|
-
`:"";if(0===
|
|
33
|
-
`;if(s.raw){let e=
|
|
27
|
+
`}(q(e));t&&(process.stdout.write(t),process.exit(0)),B(new y("INVALID_ARGS",`Unknown command: ${e}`)),process.stdout.write(`${T}
|
|
28
|
+
`),process.exit(1)}h.command||(process.stdout.write(`${T}
|
|
29
|
+
`),process.exit(1));let{command:A,positionals:x,flags:D}=h,I=function(e){let{json:t,help:s,version:r,...a}=e;return a}(D),L=D.session??process.env.AGENT_DEVICE_SESSION??"default",N=D.verbose&&!D.json?function(){try{let e=s.join(v.homedir(),".agent-device","daemon.log"),t=0,r=!1,a=setInterval(()=>{if(!r&&w.existsSync(e))try{let s=w.statSync(e);if(s.size<t&&(t=0),s.size<=t)return;let r=w.openSync(e,"r");try{let e=Buffer.alloc(s.size-t);w.readSync(r,e,0,e.length,t),t=s.size,e.length>0&&process.stdout.write(e.toString("utf8"))}finally{w.closeSync(r)}}catch{}},200);return()=>{r=!0,clearInterval(a)}}catch{return null}}():null,_=async e=>await n.sendToDaemon({session:L,command:e.command,positionals:e.positionals,flags:e.flags,meta:{requestId:p,debug:!!D.verbose,cwd:process.cwd()}});try{if("batch"===A){let e,t,s;if(x.length>0)throw new y("INVALID_ARGS","batch does not accept positional arguments.");let i=function(e){let t="";if(e.steps)t=e.steps;else if(e.stepsFile)try{t=w.readFileSync(e.stepsFile,"utf8")}catch(s){let t=s instanceof Error?s.message:String(s);throw new y("INVALID_ARGS",`Failed to read --steps-file ${e.stepsFile}: ${t}`)}return a(t)}(D),o={...I,batchSteps:i};delete o.steps,delete o.stepsFile;let n=await _({command:"batch",positionals:x,flags:o});if(!n.ok)throw new y(n.error.code,n.error.message,{...n.error.details??{},hint:n.error.hint,diagnosticId:n.error.diagnosticId,logPath:n.error.logPath});D.json?G({success:!0,data:n.data??{}}):(r=n.data??{},e="number"==typeof r.total?r.total:0,t="number"==typeof r.executed?r.executed:0,s="number"==typeof r.totalDurationMs?r.totalDurationMs:void 0,process.stdout.write(`Batch completed: ${t}/${e} steps${void 0!==s?` in ${s}ms`:""}
|
|
30
|
+
`)),N&&N();return}if("session"===A){let e=x[0]??"list";if("list"!==e)throw new y("INVALID_ARGS","session only supports list");let t=await _({command:"session_list",positionals:[],flags:I});if(!t.ok)throw new y(t.error.code,t.error.message,{...t.error.details??{},hint:t.error.hint,diagnosticId:t.error.diagnosticId,logPath:t.error.logPath});D.json?G({success:!0,data:t.data??{}}):process.stdout.write(`${JSON.stringify(t.data??{},null,2)}
|
|
31
|
+
`),N&&N();return}let s=await _({command:A,positionals:x,flags:I});if(s.ok){if(D.json){G({success:!0,data:s.data??{}}),N&&N();return}if("snapshot"===A){process.stdout.write(function(e,s={}){let r=e.nodes,a=Array.isArray(r)?r:[],i=!!e.truncated,o="string"==typeof e.appName?e.appName:void 0,n="string"==typeof e.appBundleId?e.appBundleId:void 0,l=[];o&&l.push(`Page: ${o}`),n&&l.push(`App: ${n}`);let p=`Snapshot: ${a.length} nodes${i?" (truncated)":""}`,d=l.length>0?`${l.join("\n")}
|
|
32
|
+
`:"";if(0===a.length)return`${d}${p}
|
|
33
|
+
`;if(s.raw){let e=a.map(e=>JSON.stringify(e));return`${d}${p}
|
|
34
34
|
${e.join("\n")}
|
|
35
|
-
`}if(s.flatten){let e=
|
|
35
|
+
`}if(s.flatten){let e=a.map(e=>S(e,0,!1));return`${d}${p}
|
|
36
36
|
${e.join("\n")}
|
|
37
|
-
`}let c=t(
|
|
37
|
+
`}let c=t(a).map(e=>e.text);return`${d}${p}
|
|
38
38
|
${c.join("\n")}
|
|
39
|
-
`}(s.data??{},{raw:D.snapshotRaw,flatten:D.snapshotInteractiveOnly})),N&&N();return}if("diff"===
|
|
40
|
-
`;let g=(function(e,t){if(0===e.length)return e;let s=e.map((e,t)=>({index:t,kind:e.kind})).filter(e=>"added"===e.kind||"removed"===e.kind).map(e=>e.index);if(0===s.length)return e;let
|
|
39
|
+
`}(s.data??{},{raw:D.snapshotRaw,flatten:D.snapshotInteractiveOnly})),N&&N();return}if("diff"===A&&"snapshot"===x[0]){process.stdout.write(function(t){var s,r,a,i;let o,n=!0===t.baselineInitialized,l=t.summary??{},p=J(l.additions),d=J(l.removals),c=J(l.unchanged),u=(o=process.env.FORCE_COLOR,"string"==typeof o?"0"!==o:"string"!=typeof process.env.NO_COLOR&&!!process.stdout.isTTY);if(n)return`Baseline initialized (${c} lines).
|
|
40
|
+
`;let g=(function(e,t){if(0===e.length)return e;let s=e.map((e,t)=>({index:t,kind:e.kind})).filter(e=>"added"===e.kind||"removed"===e.kind).map(e=>e.index);if(0===s.length)return e;let r=Array(e.length).fill(!1);for(let t of s){let s=Math.max(0,t-1),a=Math.min(e.length-1,t+1);for(let e=s;e<=a;e+=1)r[e]=!0}return e.filter((e,t)=>r[t])})(Array.isArray(t.lines)?t.lines:[],1).map(t=>{var s,r,a,i;let o="string"==typeof t.text?t.text:"";if("added"===t.kind){let t=o.startsWith(" ")?`+${o}`:`+ ${o}`;return u?(s=t,r="green",e(r,s)):t}if("removed"===t.kind){let t=o.startsWith(" ")?`-${o}`:`- ${o}`;return u?(a=t,e("red",a)):t}return u?(i=o,e("dim",i)):o}),m=g.length>0?`${g.join("\n")}
|
|
41
41
|
`:"";if(!u)return`${m}${p} additions, ${d} removals, ${c} unchanged
|
|
42
|
-
`;let f=`${(s=String(p),
|
|
43
|
-
`}(s.data??{})),N&&N();return}if("get"===
|
|
42
|
+
`;let f=`${(s=String(p),r="green",e(r,s))} additions, ${(a=String(d),e("red",a))} removals, ${(i=String(c),e("dim",i))} unchanged`;return`${m}${f}
|
|
43
|
+
`}(s.data??{})),N&&N();return}if("get"===A){let e=x[0];if("text"===e){let e=s.data?.text??"";process.stdout.write(`${e}
|
|
44
44
|
`),N&&N();return}if("attrs"===e){let e=s.data?.node??{};process.stdout.write(`${JSON.stringify(e,null,2)}
|
|
45
|
-
`),N&&N();return}}if("find"===
|
|
45
|
+
`),N&&N();return}}if("find"===A){let e=s.data;if("string"==typeof e?.text){process.stdout.write(`${e.text}
|
|
46
46
|
`),N&&N();return}if("boolean"==typeof e?.found){process.stdout.write(`Found: ${e.found}
|
|
47
47
|
`),N&&N();return}if(e?.node){process.stdout.write(`${JSON.stringify(e.node,null,2)}
|
|
48
|
-
`),N&&N();return}}if("is"===
|
|
49
|
-
`),N&&N();return}if("boot"===
|
|
50
|
-
`),N&&N();return}if("logs"===
|
|
51
|
-
`);let s="boolean"==typeof e?.active?e.active:void 0,
|
|
48
|
+
`),N&&N();return}}if("is"===A){let e=s.data?.predicate??"assertion";process.stdout.write(`Passed: is ${e}
|
|
49
|
+
`),N&&N();return}if("boot"===A){let e=s.data?.platform??"unknown",t=s.data?.device??s.data?.id??"unknown";process.stdout.write(`Boot ready: ${t} (${e})
|
|
50
|
+
`),N&&N();return}if("logs"===A){let e=s.data,t="string"==typeof e?.path?e.path:"";if(t){process.stdout.write(`${t}
|
|
51
|
+
`);let s="boolean"==typeof e?.active?e.active:void 0,r="string"==typeof e?.state?e.state:void 0,a="string"==typeof e?.backend?e.backend:void 0,i="number"==typeof e?.sizeBytes?e.sizeBytes:void 0,o=e?.started===!0,n=e?.stopped===!0,l=e?.marked===!0,p=e?.cleared===!0,d=e?.restarted===!0,c="number"==typeof e?.removedRotatedFiles?e.removedRotatedFiles:void 0;if(!D.json&&(void 0!==s||r||a||void 0!==i)){let e=[void 0!==s?`active=${s}`:"",r?`state=${r}`:"",a?`backend=${a}`:"",void 0!==i?`sizeBytes=${i}`:""].filter(Boolean).join(" ");e&&process.stderr.write(`${e}
|
|
52
52
|
`)}if(!D.json&&(o||n||l||p||d||void 0!==c)){let e=[o?"started=true":"",n?"stopped=true":"",l?"marked=true":"",p?"cleared=true":"",d?"restarted=true":"",void 0!==c?`removedRotatedFiles=${c}`:""].filter(Boolean).join(" ");e&&process.stderr.write(`${e}
|
|
53
53
|
`)}if(e?.hint&&!D.json&&process.stderr.write(`${e.hint}
|
|
54
54
|
`),Array.isArray(e?.notes)&&!D.json)for(let t of e.notes)"string"==typeof t&&t.length>0&&process.stderr.write(`${t}
|
|
55
|
-
`)}N&&N();return}if("
|
|
56
|
-
`),N&&N();return}if(
|
|
57
|
-
`)
|
|
58
|
-
`),
|
|
55
|
+
`)}N&&N();return}if("clipboard"===A){let e=s.data,t=(x[0]??("string"==typeof e?.action?e.action:"")).toLowerCase();if("read"===t){let t="string"==typeof e?.text?e.text:"";process.stdout.write(`${t}
|
|
56
|
+
`),N&&N();return}if("write"===t){process.stdout.write("Clipboard updated\n"),N&&N();return}}if("network"===A){let e=s.data,t="string"==typeof e?.path?e.path:"";t&&process.stdout.write(`${t}
|
|
57
|
+
`);let r=Array.isArray(e?.entries)?e.entries:[];if(0===r.length)process.stdout.write("No recent HTTP(s) entries found.\n");else for(let e of r){let t="string"==typeof e.method?e.method:"HTTP",s="string"==typeof e.url?e.url:"<unknown-url>",r="number"==typeof e.status?` status=${e.status}`:"",a="string"==typeof e.timestamp?`${e.timestamp} `:"";process.stdout.write(`${a}${t} ${s}${r}
|
|
58
|
+
`),"string"==typeof e.headers&&process.stdout.write(` headers: ${e.headers}
|
|
59
|
+
`),"string"==typeof e.requestBody&&process.stdout.write(` request: ${e.requestBody}
|
|
60
|
+
`),"string"==typeof e.responseBody&&process.stdout.write(` response: ${e.responseBody}
|
|
61
|
+
`)}let a="boolean"==typeof e?.active?e.active:void 0,i="string"==typeof e?.state?e.state:void 0,o="string"==typeof e?.backend?e.backend:void 0,n="number"==typeof e?.scannedLines?e.scannedLines:void 0,l="number"==typeof e?.matchedLines?e.matchedLines:void 0,p="string"==typeof e?.include?e.include:void 0,d=[void 0!==a?`active=${a}`:"",i?`state=${i}`:"",o?`backend=${o}`:"",p?`include=${p}`:"",void 0!==n?`scannedLines=${n}`:"",void 0!==l?`matchedLines=${l}`:""].filter(Boolean).join(" ");if(d&&process.stderr.write(`${d}
|
|
62
|
+
`),Array.isArray(e?.notes))for(let t of e.notes)"string"==typeof t&&t.length>0&&process.stderr.write(`${t}
|
|
63
|
+
`);N&&N();return}if("click"===A||"press"===A){let e=s.data?.ref??"",t=s.data?.x,r=s.data?.y;e&&"number"==typeof t&&"number"==typeof r&&process.stdout.write(`Tapped @${e} (${t}, ${r})
|
|
64
|
+
`),N&&N();return}if(s.data&&"object"==typeof s.data){let e=s.data;if("devices"===A){let t=(Array.isArray(e.devices)?e.devices:[]).map(e=>{let t=e?.name??e?.id??"unknown",s=e?.platform??"unknown",r=e?.kind?` ${e.kind}`:"",a=e?.target?` target=${e.target}`:"",i="boolean"==typeof e?.booted?` booted=${e.booted}`:"";return`${t} (${s}${r}${a})${i}`});process.stdout.write(`${t.join("\n")}
|
|
65
|
+
`),N&&N();return}if("apps"===A){let t=(Array.isArray(e.apps)?e.apps:[]).map(e=>{if("string"==typeof e)return e;if(e&&"object"==typeof e){let t=e.bundleId??e.package,s=e.name??e.label;return s&&t?`${s} (${t})`:t?String(t):JSON.stringify(e)}return String(e)});process.stdout.write(`${t.join("\n")}
|
|
66
|
+
`),N&&N();return}if("appstate"===A){let t=e?.platform,s=e?.appBundleId,r=e?.appName,a=e?.source,i=e?.package,o=e?.activity;if("ios"===t){process.stdout.write(`Foreground app: ${r??s??"unknown"}
|
|
59
67
|
`),s&&process.stdout.write(`Bundle: ${s}
|
|
60
|
-
`),
|
|
68
|
+
`),a&&process.stdout.write(`Source: ${a}
|
|
61
69
|
`),N&&N();return}if("android"===t){process.stdout.write(`Foreground app: ${i??"unknown"}
|
|
62
70
|
`),o&&process.stdout.write(`Activity: ${o}
|
|
63
|
-
`),N&&N();return}}
|
|
71
|
+
`),N&&N();return}}if("perf"===A){process.stdout.write(`${JSON.stringify(e,null,2)}
|
|
72
|
+
`),N&&N();return}}N&&N();return}throw new y(s.error.code,s.error.message,{...s.error.details??{},hint:s.error.hint,diagnosticId:s.error.diagnosticId,logPath:s.error.logPath})}catch(r){let e=f(r),t=i(e,{diagnosticId:d().diagnosticId,logPath:k({force:!0})??void 0});if("close"===A&&"COMMAND_FAILED"===(m=e).code&&(m.details?.kind==="daemon_startup_failed"||m.message.toLowerCase().includes("failed to start daemon")&&("string"==typeof m.details?.infoPath||"string"==typeof m.details?.lockPath))){D.json&&G({success:!0,data:{closed:"session",source:"no-daemon"}}),N&&N();return}if(D.json)G({success:!1,error:t});else if(B(t,{showDetails:D.verbose}),D.verbose)try{let e=s.join(v.homedir(),".agent-device","daemon.log");if(w.existsSync(e)){let t=w.readFileSync(e,"utf8").split("\n"),s=t.slice(Math.max(0,t.length-200)).join("\n");s.trim().length>0&&process.stderr.write(`
|
|
64
73
|
[daemon log]
|
|
65
74
|
${s}
|
|
66
75
|
`)}}catch{}N&&N(),process.exit(1)}})}h(process.argv[1]??"").href===import.meta.url&&ec(process.argv.slice(2)).catch(e=>{B(i(f(e)),{showDetails:!0}),process.exit(1)}),ec(process.argv.slice(2));
|