agent-device 0.10.2 → 0.11.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 (203) hide show
  1. package/README.md +6 -0
  2. package/dist/src/36.js +3 -0
  3. package/dist/src/bin.js +82 -66
  4. package/dist/src/daemon.js +40 -39
  5. package/dist/src/index.d.ts +567 -5
  6. package/dist/src/index.js +3 -1
  7. package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +84 -16
  8. package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +140 -50
  9. package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +13 -2
  10. package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +22 -9
  11. package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +221 -0
  12. package/ios-runner/README.md +17 -2
  13. package/ios-runner/RUNNER_PROTOCOL.md +73 -0
  14. package/package.json +11 -6
  15. package/skills/agent-device/SKILL.md +38 -12
  16. package/skills/agent-device/references/bootstrap-install.md +55 -15
  17. package/skills/agent-device/references/exploration.md +65 -8
  18. package/skills/agent-device/references/macos-desktop.md +1 -2
  19. package/skills/agent-device/references/remote-tenancy.md +15 -2
  20. package/skills/agent-device/references/verification.md +7 -3
  21. package/dist/src/224.js +0 -2
  22. package/dist/src/331.js +0 -3
  23. package/dist/src/425.js +0 -1
  24. package/dist/src/bin.d.ts +0 -1
  25. package/dist/src/cli-client-commands.d.ts +0 -8
  26. package/dist/src/cli.d.ts +0 -6
  27. package/dist/src/client-metro.d.ts +0 -64
  28. package/dist/src/client-normalizers.d.ts +0 -20
  29. package/dist/src/client-shared.d.ts +0 -20
  30. package/dist/src/client-types.d.ts +0 -269
  31. package/dist/src/client.d.ts +0 -5
  32. package/dist/src/core/app-events.d.ts +0 -8
  33. package/dist/src/core/batch.d.ts +0 -17
  34. package/dist/src/core/capabilities.d.ts +0 -3
  35. package/dist/src/core/click-button.d.ts +0 -20
  36. package/dist/src/core/dispatch-payload.d.ts +0 -1
  37. package/dist/src/core/dispatch-resolve.d.ts +0 -29
  38. package/dist/src/core/dispatch-series.d.ts +0 -7
  39. package/dist/src/core/dispatch.d.ts +0 -37
  40. package/dist/src/core/open-target.d.ts +0 -4
  41. package/dist/src/core/session-surface.d.ts +0 -3
  42. package/dist/src/core/settings-contract.d.ts +0 -9
  43. package/dist/src/daemon/action-utils.d.ts +0 -3
  44. package/dist/src/daemon/android-system-dialog.d.ts +0 -11
  45. package/dist/src/daemon/app-log-android.d.ts +0 -4
  46. package/dist/src/daemon/app-log-ios.d.ts +0 -7
  47. package/dist/src/daemon/app-log-process.d.ts +0 -15
  48. package/dist/src/daemon/app-log-stream.d.ts +0 -19
  49. package/dist/src/daemon/app-log.d.ts +0 -28
  50. package/dist/src/daemon/artifact-archive.d.ts +0 -12
  51. package/dist/src/daemon/artifact-download.d.ts +0 -12
  52. package/dist/src/daemon/artifact-materialization.d.ts +0 -17
  53. package/dist/src/daemon/artifact-registry.d.ts +0 -12
  54. package/dist/src/daemon/config.d.ts +0 -16
  55. package/dist/src/daemon/context.d.ts +0 -25
  56. package/dist/src/daemon/device-ready.d.ts +0 -6
  57. package/dist/src/daemon/handlers/find.d.ts +0 -40
  58. package/dist/src/daemon/handlers/install-source.d.ts +0 -44
  59. package/dist/src/daemon/handlers/interaction-common.d.ts +0 -41
  60. package/dist/src/daemon/handlers/interaction-flags.d.ts +0 -4
  61. package/dist/src/daemon/handlers/interaction-get.d.ts +0 -3
  62. package/dist/src/daemon/handlers/interaction-is.d.ts +0 -3
  63. package/dist/src/daemon/handlers/interaction-read.d.ts +0 -14
  64. package/dist/src/daemon/handlers/interaction-scroll.d.ts +0 -3
  65. package/dist/src/daemon/handlers/interaction-selector.d.ts +0 -27
  66. package/dist/src/daemon/handlers/interaction-snapshot.d.ts +0 -8
  67. package/dist/src/daemon/handlers/interaction-targeting.d.ts +0 -28
  68. package/dist/src/daemon/handlers/interaction-touch.d.ts +0 -45
  69. package/dist/src/daemon/handlers/interaction.d.ts +0 -9
  70. package/dist/src/daemon/handlers/lease.d.ts +0 -8
  71. package/dist/src/daemon/handlers/parse-utils.d.ts +0 -3
  72. package/dist/src/daemon/handlers/record-trace-android.d.ts +0 -18
  73. package/dist/src/daemon/handlers/record-trace-ios.d.ts +0 -52
  74. package/dist/src/daemon/handlers/record-trace-recording.d.ts +0 -32
  75. package/dist/src/daemon/handlers/record-trace.d.ts +0 -10
  76. package/dist/src/daemon/handlers/session-batch.d.ts +0 -2
  77. package/dist/src/daemon/handlers/session-close.d.ts +0 -31
  78. package/dist/src/daemon/handlers/session-deploy.d.ts +0 -37
  79. package/dist/src/daemon/handlers/session-device-utils.d.ts +0 -26
  80. package/dist/src/daemon/handlers/session-open-target.d.ts +0 -3
  81. package/dist/src/daemon/handlers/session-open.d.ts +0 -22
  82. package/dist/src/daemon/handlers/session-perf.d.ts +0 -2
  83. package/dist/src/daemon/handlers/session-replay-heal.d.ts +0 -8
  84. package/dist/src/daemon/handlers/session-replay-script.d.ts +0 -3
  85. package/dist/src/daemon/handlers/session-runtime-command.d.ts +0 -9
  86. package/dist/src/daemon/handlers/session-runtime.d.ts +0 -36
  87. package/dist/src/daemon/handlers/session-startup-metrics.d.ts +0 -11
  88. package/dist/src/daemon/handlers/session.d.ts +0 -50
  89. package/dist/src/daemon/handlers/snapshot-alert.d.ts +0 -13
  90. package/dist/src/daemon/handlers/snapshot-capture.d.ts +0 -34
  91. package/dist/src/daemon/handlers/snapshot-session.d.ts +0 -15
  92. package/dist/src/daemon/handlers/snapshot-settings.d.ts +0 -24
  93. package/dist/src/daemon/handlers/snapshot-wait.d.ts +0 -37
  94. package/dist/src/daemon/handlers/snapshot.d.ts +0 -16
  95. package/dist/src/daemon/http-server.d.ts +0 -26
  96. package/dist/src/daemon/install-source-resolution.d.ts +0 -5
  97. package/dist/src/daemon/is-predicates.d.ts +0 -15
  98. package/dist/src/daemon/lease-context.d.ts +0 -9
  99. package/dist/src/daemon/lease-registry.d.ts +0 -63
  100. package/dist/src/daemon/materialized-path-registry.d.ts +0 -15
  101. package/dist/src/daemon/network-log.d.ts +0 -32
  102. package/dist/src/daemon/record-trace-errors.d.ts +0 -6
  103. package/dist/src/daemon/recording-gestures.d.ts +0 -3
  104. package/dist/src/daemon/recording-telemetry.d.ts +0 -20
  105. package/dist/src/daemon/recording-timing.d.ts +0 -24
  106. package/dist/src/daemon/request-cancel.d.ts +0 -9
  107. package/dist/src/daemon/request-lock-policy.d.ts +0 -2
  108. package/dist/src/daemon/request-router.d.ts +0 -23
  109. package/dist/src/daemon/runtime-hints.d.ts +0 -19
  110. package/dist/src/daemon/script-utils.d.ts +0 -28
  111. package/dist/src/daemon/scroll-planner.d.ts +0 -12
  112. package/dist/src/daemon/selectors-build.d.ts +0 -5
  113. package/dist/src/daemon/selectors-match.d.ts +0 -6
  114. package/dist/src/daemon/selectors-parse.d.ts +0 -29
  115. package/dist/src/daemon/selectors-resolve.d.ts +0 -33
  116. package/dist/src/daemon/selectors.d.ts +0 -5
  117. package/dist/src/daemon/server-lifecycle.d.ts +0 -23
  118. package/dist/src/daemon/session-open-script.d.ts +0 -7
  119. package/dist/src/daemon/session-routing.d.ts +0 -3
  120. package/dist/src/daemon/session-selector.d.ts +0 -10
  121. package/dist/src/daemon/session-store.d.ts +0 -33
  122. package/dist/src/daemon/snapshot-diff.d.ts +0 -20
  123. package/dist/src/daemon/snapshot-processing.d.ts +0 -10
  124. package/dist/src/daemon/touch-reference-frame.d.ts +0 -7
  125. package/dist/src/daemon/transport.d.ts +0 -6
  126. package/dist/src/daemon/types.d.ts +0 -173
  127. package/dist/src/daemon/upload-registry.d.ts +0 -7
  128. package/dist/src/daemon/upload.d.ts +0 -5
  129. package/dist/src/daemon-client.d.ts +0 -40
  130. package/dist/src/daemon.d.ts +0 -1
  131. package/dist/src/platforms/android/adb.d.ts +0 -5
  132. package/dist/src/platforms/android/app-lifecycle.d.ts +0 -31
  133. package/dist/src/platforms/android/device-input-state.d.ts +0 -19
  134. package/dist/src/platforms/android/devices.d.ts +0 -26
  135. package/dist/src/platforms/android/index.d.ts +0 -8
  136. package/dist/src/platforms/android/input-actions.d.ts +0 -17
  137. package/dist/src/platforms/android/install-artifact.d.ts +0 -11
  138. package/dist/src/platforms/android/manifest.d.ts +0 -1
  139. package/dist/src/platforms/android/notifications.d.ts +0 -11
  140. package/dist/src/platforms/android/open-target.d.ts +0 -4
  141. package/dist/src/platforms/android/screenshot.d.ts +0 -16
  142. package/dist/src/platforms/android/sdk.d.ts +0 -2
  143. package/dist/src/platforms/android/settings.d.ts +0 -3
  144. package/dist/src/platforms/android/snapshot.d.ts +0 -7
  145. package/dist/src/platforms/android/ui-hierarchy.d.ts +0 -21
  146. package/dist/src/platforms/appearance.d.ts +0 -2
  147. package/dist/src/platforms/boot-diagnostics.d.ts +0 -14
  148. package/dist/src/platforms/install-source.d.ts +0 -29
  149. package/dist/src/platforms/ios/app-filter.d.ts +0 -2
  150. package/dist/src/platforms/ios/apps.d.ts +0 -34
  151. package/dist/src/platforms/ios/config.d.ts +0 -10
  152. package/dist/src/platforms/ios/devicectl.d.ts +0 -13
  153. package/dist/src/platforms/ios/devices.d.ts +0 -40
  154. package/dist/src/platforms/ios/ensure-simulator.d.ts +0 -18
  155. package/dist/src/platforms/ios/index.d.ts +0 -3
  156. package/dist/src/platforms/ios/install-artifact.d.ts +0 -18
  157. package/dist/src/platforms/ios/launch-diagnostics.d.ts +0 -11
  158. package/dist/src/platforms/ios/macos-apps.d.ts +0 -12
  159. package/dist/src/platforms/ios/macos-helper.d.ts +0 -69
  160. package/dist/src/platforms/ios/plist.d.ts +0 -1
  161. package/dist/src/platforms/ios/runner-client.d.ts +0 -38
  162. package/dist/src/platforms/ios/runner-errors.d.ts +0 -20
  163. package/dist/src/platforms/ios/runner-macos-products.d.ts +0 -3
  164. package/dist/src/platforms/ios/runner-session.d.ts +0 -30
  165. package/dist/src/platforms/ios/runner-transport.d.ts +0 -10
  166. package/dist/src/platforms/ios/runner-xctestrun-products.d.ts +0 -2
  167. package/dist/src/platforms/ios/runner-xctestrun.d.ts +0 -38
  168. package/dist/src/platforms/ios/screenshot-status-bar.d.ts +0 -2
  169. package/dist/src/platforms/ios/screenshot.d.ts +0 -14
  170. package/dist/src/platforms/ios/simctl.d.ts +0 -7
  171. package/dist/src/platforms/ios/simulator.d.ts +0 -11
  172. package/dist/src/platforms/permission-utils.d.ts +0 -9
  173. package/dist/src/recording/overlay.d.ts +0 -10
  174. package/dist/src/upload-client.d.ts +0 -7
  175. package/dist/src/utils/args.d.ts +0 -27
  176. package/dist/src/utils/cli-config.d.ts +0 -10
  177. package/dist/src/utils/cli-option-schema.d.ts +0 -19
  178. package/dist/src/utils/cli-options.d.ts +0 -13
  179. package/dist/src/utils/command-schema.d.ts +0 -123
  180. package/dist/src/utils/device-isolation.d.ts +0 -3
  181. package/dist/src/utils/device.d.ts +0 -35
  182. package/dist/src/utils/diagnostics.d.ts +0 -30
  183. package/dist/src/utils/errors.d.ts +0 -26
  184. package/dist/src/utils/exec.d.ts +0 -32
  185. package/dist/src/utils/finders.d.ts +0 -12
  186. package/dist/src/utils/interactors.d.ts +0 -38
  187. package/dist/src/utils/json-input.d.ts +0 -1
  188. package/dist/src/utils/keyed-lock.d.ts +0 -1
  189. package/dist/src/utils/output.d.ts +0 -27
  190. package/dist/src/utils/path-resolution.d.ts +0 -8
  191. package/dist/src/utils/payload-input.d.ts +0 -12
  192. package/dist/src/utils/process-identity.d.ts +0 -11
  193. package/dist/src/utils/remote-config.d.ts +0 -15
  194. package/dist/src/utils/remote-open.d.ts +0 -9
  195. package/dist/src/utils/retry.d.ts +0 -54
  196. package/dist/src/utils/screenshot-diff.d.ts +0 -23
  197. package/dist/src/utils/session-binding.d.ts +0 -18
  198. package/dist/src/utils/snapshot-lines.d.ts +0 -15
  199. package/dist/src/utils/snapshot.d.ts +0 -49
  200. package/dist/src/utils/text-surface.d.ts +0 -19
  201. package/dist/src/utils/timeouts.d.ts +0 -3
  202. package/dist/src/utils/version.d.ts +0 -2
  203. package/dist/src/utils/video.d.ts +0 -9
@@ -4,22 +4,52 @@
4
4
 
5
5
  Open this file when the app or screen is already running and you need to discover the UI, choose targets, read state, wait for conditions, or perform normal interactions.
6
6
 
7
- ## Main commands to reach for first
7
+ ## Read-only first
8
+
9
+ - If the question is what text, labels, or structure is visible on screen, start with plain `snapshot`.
10
+ - Escalate to `snapshot -i` only when you need refs such as `@e3` for interactive exploration or a requested action.
11
+ - If you intend to `press`, `fill`, or otherwise interact, start with `snapshot -i` and fall back to plain `snapshot` only if interactive refs are unavailable.
12
+ - Prefer `get`, `is`, or `find` before mutating the UI when a read-only command can answer the question.
13
+ - You may take the smallest reversible UI action needed to unblock inspection, such as dismissing a popup, closing an alert, or backing out of an unintended surface.
14
+ - Do not type or fill text just to make hidden information easier to access unless the user asked for that interaction.
15
+ - Do not use external sources to infer missing UI state unless the user explicitly asked.
16
+ - If the answer is not visible or exposed in the UI, report that gap instead of compensating with search, navigation, or text entry.
17
+
18
+ ## Decision shortcut
19
+
20
+ - User asks what is visible on screen: `snapshot`
21
+ - User asks for exact text from a known target: `get text`
22
+ - User asks you to tap, type, or choose an element: `snapshot -i`, then act
23
+ - The on-screen keyboard is blocking the next step: `keyboard dismiss`; on iOS do this only while an app session is active, and use `keyboard status|get` only on Android
24
+ - UI does not expose the answer: say so plainly; do not browse or force the app into a new state unless asked
25
+
26
+ ## Read-only commands
8
27
 
9
28
  - `snapshot`
29
+ - `get`
30
+ - `is`
31
+ - `find`
32
+ - `keyboard status|get` on Android when keyboard visibility or input type matters
33
+
34
+ ## Interaction commands
35
+
10
36
  - `snapshot -i`
11
37
  - `press`
12
38
  - `fill`
13
- - `get`
14
- - `is`
39
+ - `type`
40
+ - `scrollintoview`
15
41
  - `wait`
16
- - `find`
42
+ - `keyboard dismiss` when the keyboard obscures the next target
17
43
 
18
44
  ## Most common mistake to avoid
19
45
 
20
46
  Do not treat `@ref` values as durable after navigation or dynamic updates. Re-snapshot after the UI changes, and switch to selectors when the flow must stay stable.
21
47
 
22
- ## Canonical loop
48
+ ## Common example loops
49
+
50
+ These are examples, not required exact sequences. Adapt them to the app, state, and task at hand.
51
+
52
+ ### Interactive exploration loop
23
53
 
24
54
  ```bash
25
55
  agent-device open Settings --platform ios
@@ -30,11 +60,21 @@ agent-device get text 'label="Privacy & Security"'
30
60
  agent-device close
31
61
  ```
32
62
 
63
+ ### Screen verification loop
64
+
65
+ ```bash
66
+ agent-device open MyApp --platform ios
67
+ # perform the necessary actions to reach the state you need to verify
68
+ agent-device snapshot
69
+ # verify whether the expected element or text is present
70
+ agent-device close
71
+ ```
72
+
33
73
  ## Snapshot choices
34
74
 
35
75
  - Use plain `snapshot` when you only need to verify whether visible text or structure is on screen.
36
- - Use `snapshot -i` when you need refs such as `@e3` for interactive exploration.
37
- - Treat large text-surface lines in `snapshot -i` as discovery output. If a node shows preview/truncation metadata, use `get text @ref` to expand the actual text after you choose the surface.
76
+ - Use `snapshot -i` when you need refs such as `@e3` for interactive exploration or for an intended interaction.
77
+ - Treat large text-surface lines in `snapshot -i` as discovery output. If a node shows preview or truncation metadata, use `get text @ref` only after you have already decided that `snapshot -i` is needed for that surface.
38
78
  - Use `snapshot -i -s "Camera"` or `snapshot -i -s @e3` when you want a smaller, scoped result.
39
79
 
40
80
  Example:
@@ -57,6 +97,8 @@ App: com.apple.Preferences
57
97
  ## Refs vs selectors
58
98
 
59
99
  - Use refs for discovery, debugging, and short local loops.
100
+ - Use `scrollintoview @ref` when the target is already known from the current snapshot and you want the command to re-snapshot after each swipe until the element reaches the viewport safe band.
101
+ - Cap long searches with `--max-scrolls <n>` when the list may be unbounded or the target may not exist.
60
102
  - Use selectors for deterministic scripts, assertions, and replay-friendly actions.
61
103
  - Prefer selector or `@ref` targeting over raw coordinates.
62
104
  - For tap interactions, `press` is canonical and `click` is an equivalent alias.
@@ -74,6 +116,9 @@ agent-device is visible 'id="camera_settings_anchor"'
74
116
 
75
117
  - Use `fill` to replace text in an editable field.
76
118
  - Use `type` to append text to the current insertion point.
119
+ - If the keyboard blocks the next control after text entry, prefer `keyboard dismiss` instead of backing out of the screen.
120
+ - On iOS, `keyboard dismiss` depends on the active app session to keep the target app foregrounded, so do not rely on selector-only dismiss calls after closing or without `open`.
121
+ - Do not use `fill` or `type` just to make the app reveal information that is not currently visible unless the user asked for that interaction.
77
122
 
78
123
  ## Query and sync rules
79
124
 
@@ -97,18 +142,28 @@ Use this loop when the task starts from acceptance criteria and you need to turn
97
142
 
98
143
  Preferred mapping:
99
144
 
100
- - visibility or presence claim: `is visible` or plain `snapshot`
145
+ - visibility claim for what is on-screen now: `is visible` or plain `snapshot`
146
+ - presence claim regardless of viewport visibility: `is exists`
101
147
  - exact text, label, or value claim: `get text`
102
148
  - post-action state change: act, then `wait`, then `is` or `get`
103
149
  - nearby structural UI change: `diff snapshot`
104
150
  - proof artifact for the final result: `screenshot` or `record`
105
151
 
152
+ Notes:
153
+
154
+ - `wait text` is useful for synchronizing on text presence, but it is not the same as `is visible`.
155
+
106
156
  Anti-hallucination rules:
107
157
 
108
158
  - Do not invent app names, device ids, session names, refs, selectors, or package names.
109
159
  - Discover them first with `devices`, `open`, `snapshot -i`, `find`, or `session list`.
110
160
  - If refs drift after navigation, re-snapshot or switch to selectors instead of guessing.
111
161
 
162
+ Avoid this escalation path for visible-text questions:
163
+
164
+ - Do not jump from `snapshot -i` to `get text @ref`, then to web search, then to typing into a search box just to force the app to reveal the answer.
165
+ - Start with `snapshot`. If the text is not visible or exposed, report that directly.
166
+
112
167
  Canonical QA loop:
113
168
 
114
169
  ```bash
@@ -168,12 +223,14 @@ Step payload contract:
168
223
 
169
224
  - `positionals` is optional and defaults to `[]`.
170
225
  - `flags` is optional and defaults to `{}`.
226
+ - Only `command`, `positionals`, `flags`, and `runtime` are accepted as top-level step keys.
171
227
  - Nested `batch` and `replay` are rejected.
172
228
  - Supported error mode is stop-on-first-error.
173
229
 
174
230
  Response handling:
175
231
 
176
232
  - Success returns fields such as `total`, `executed`, `totalDurationMs`, and `results[]`.
233
+ - Human-mode `batch` runs also print a short per-step success summary.
177
234
  - Failed runs include `details.step`, `details.command`, `details.executed`, and `details.partialResults`.
178
235
  - Replan from the first failing step instead of rerunning the whole flow blindly.
179
236
 
@@ -21,8 +21,7 @@ Do not treat every macOS surface the same. Use the normal `app` surface when you
21
21
 
22
22
  ```bash
23
23
  agent-device open TextEdit --platform macos
24
- agent-device snapshot -i
25
- agent-device fill @e3 "desktop smoke test"
24
+ agent-device snapshot
26
25
  agent-device close
27
26
  ```
28
27
 
@@ -2,10 +2,11 @@
2
2
 
3
3
  ## When to open this file
4
4
 
5
- Open this file only for remote daemon HTTP flows that require explicit daemon URL setup, authentication, lease allocation, or tenant-scoped command admission.
5
+ Open this file for remote daemon HTTP flows, including `--remote-config` launches, that let an agent running in a Linux sandbox talk to another `agent-device` instance on a remote macOS host in order to control devices that are not available locally. This file covers daemon URL setup, authentication, lease allocation, and tenant-scoped command admission.
6
6
 
7
7
  ## Main commands to reach for first
8
8
 
9
+ - `agent-device open <app> --remote-config <path> --relaunch`
9
10
  - `AGENT_DEVICE_DAEMON_BASE_URL=...`
10
11
  - `AGENT_DEVICE_DAEMON_AUTH_TOKEN=...`
11
12
  - `curl ... agent_device.lease.allocate`
@@ -17,7 +18,19 @@ Open this file only for remote daemon HTTP flows that require explicit daemon UR
17
18
 
18
19
  Do not run a tenant-isolated command without matching `tenant`, `run`, and `lease` scope. Admission checks require all three to line up.
19
20
 
20
- ## Canonical loop
21
+ ## Preferred remote launch path
22
+
23
+ Use this when the agent needs the simplest remote control flow: a Linux sandbox agent talks over HTTP to `agent-device` on a remote macOS host and launches the target app through a checked-in `--remote-config` profile.
24
+
25
+ ```bash
26
+ agent-device open com.example.myapp --remote-config ./agent-device.remote.json --relaunch
27
+ ```
28
+
29
+ - This is the preferred remote launch path for sandbox or cloud agents.
30
+ - For Android React Native relaunch flows, install or reinstall the APK first, then relaunch by installed package name.
31
+ - Do not use `open <apk|aab> --relaunch`; remote runtime hints are applied through the installed app sandbox.
32
+
33
+ ## Lease flow example
21
34
 
22
35
  ```bash
23
36
  export AGENT_DEVICE_DAEMON_BASE_URL=http://mac-host.example:4310
@@ -20,9 +20,8 @@ Do not use verification tools as the first exploration step. First get the app i
20
20
 
21
21
  ```bash
22
22
  agent-device open Settings --platform ios
23
- agent-device snapshot -i
24
- agent-device press @e5
25
- agent-device diff snapshot -i
23
+ # after using exploration to reach the state you want to verify
24
+ agent-device snapshot
26
25
  agent-device screenshot /tmp/settings-proof.png
27
26
  agent-device close
28
27
  ```
@@ -84,9 +83,14 @@ Use replay updates when selectors drift but the recorded scenario is still corre
84
83
 
85
84
  ```bash
86
85
  agent-device replay -u ./session.ad
86
+ agent-device test ./smoke --platform android
87
87
  ```
88
88
 
89
89
  - Prefer selector-based actions in recorded `.ad` replays.
90
+ - Use `test` when you already have multiple `.ad` flows and need a quick regression pass after updating or recording them.
91
+ - Keep the skill-level rule simple: use `replay -u` to maintain one script, use `test` to verify a folder or matcher of scripts.
92
+ - Treat `test` as a human and CI-facing suite runner that an agent can invoke for verification, not as the main source of product documentation.
93
+ - Failed runs keep suite artifacts under `.agent-device/test-artifacts` by default, which is usually enough for debugging without extra agent-side processing.
90
94
  - Use update mode for maintenance, not as a substitute for fixing a broken interaction strategy.
91
95
 
92
96
  ## Performance checks
package/dist/src/224.js DELETED
@@ -1,2 +0,0 @@
1
- import{createRequestId as e,node_path as t,isAgentDeviceDaemonProcess as r,runCmdDetached as a,readVersion as n,findProjectRoot as o,node_https as i,runCmdSync as s,withDiagnosticTimer as l,resolveDaemonTransportPreference as d,resolveUserPath as u,emitDiagnostic as c,spawn as p,AppError as m,node_fs as h,resolveDaemonPaths as f,node_net as I,resolveDaemonServerMode as g,stopProcessForTakeover as w,node_http as b}from"./331.js";async function y(e){let{localPath:r,baseUrl:a,token:n}=e,o=h.statSync(r).isDirectory(),s=t.basename(r),l=new URL("upload",a.endsWith("/")?a:`${a}/`),d="https:"===l.protocol?i:b,u={"x-artifact-type":o?"app-bundle":"file","x-artifact-filename":s,"transfer-encoding":"chunked"};return n&&(u.authorization=`Bearer ${n}`,u["x-agent-device-token"]=n),new Promise((e,a)=>{let n=d.request({protocol:l.protocol,host:l.hostname,port:l.port,method:"POST",path:l.pathname+l.search,headers:u},t=>{let r="";t.setEncoding("utf8"),t.on("data",e=>{r+=e}),t.on("end",()=>{clearTimeout(i);try{let t=JSON.parse(r);if(!t.ok||!t.uploadId)return void a(new m("COMMAND_FAILED",`Upload failed: ${r}`));e(t.uploadId)}catch{a(new m("COMMAND_FAILED",`Invalid upload response: ${r}`))}})}),i=setTimeout(()=>{n.destroy(),a(new m("COMMAND_FAILED","Artifact upload timed out",{timeoutMs:3e5,hint:"The upload to the remote daemon exceeded the 5-minute timeout."}))},3e5);if(n.on("error",e=>{clearTimeout(i),a(new m("COMMAND_FAILED","Failed to upload artifact to remote daemon",{hint:"Verify the remote daemon is reachable and supports artifact uploads."},e))}),o){let e=p("tar",["cf","-","-C",t.dirname(r),t.basename(r)],{stdio:["ignore","pipe","pipe"]});e.stdout.pipe(n),e.on("error",e=>{n.destroy(),a(new m("COMMAND_FAILED","Failed to create tar archive for app bundle",{},e))}),e.on("close",e=>{0!==e&&(n.destroy(),a(new m("COMMAND_FAILED",`tar failed with exit code ${e}`)))})}else{let e=h.createReadStream(r);e.pipe(n),e.on("error",e=>{n.destroy(),a(new m("COMMAND_FAILED","Failed to read local artifact",{},e))})}})}let v=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}(),A=function(e=process.env.AGENT_DEVICE_DAEMON_STARTUP_TIMEOUT_MS){if(!e)return 15e3;let t=Number(e);return Number.isFinite(t)?Math.max(1e3,Math.floor(t)):15e3}(),D=function(e=process.env.AGENT_DEVICE_DAEMON_STARTUP_ATTEMPTS){if(!e)return 2;let t=Number(e);return Number.isFinite(t)?Math.min(5,Math.max(1,Math.floor(t))):2}(),_=["xcodebuild .*AgentDeviceRunnerUITests/RunnerTests/testCommand","xcodebuild .*AgentDeviceRunner\\.env\\.session-","xcodebuild build-for-testing .*ios-runner/AgentDeviceRunner/AgentDeviceRunner\\.xcodeproj"];async function P(t){let r=t.meta?.requestId??e(),a=!!(t.meta?.debug||t.flags?.verbose),n=function(e){let t=e.flags?.stateDir??process.env.AGENT_DEVICE_STATE_DIR,r=function(e){let t;if(e){try{t=new URL(e)}catch(t){throw new m("INVALID_ARGS","Invalid daemon base URL",{daemonBaseUrl:e},t instanceof Error?t:void 0)}if("http:"!==t.protocol&&"https:"!==t.protocol)throw new m("INVALID_ARGS","Daemon base URL must use http or https",{daemonBaseUrl:e});return t.toString().replace(/\/+$/,"")}}(e.flags?.daemonBaseUrl??process.env.AGENT_DEVICE_DAEMON_BASE_URL),a=e.flags?.daemonAuthToken??process.env.AGENT_DEVICE_DAEMON_AUTH_TOKEN,n=e.flags?.daemonTransport??process.env.AGENT_DEVICE_DAEMON_TRANSPORT,o=d(n);if(r&&"socket"===o)throw new m("INVALID_ARGS","Remote daemon base URL only supports HTTP transport. Remove --daemon-transport socket.",{daemonBaseUrl:r});let i=g(e.flags?.daemonServerMode??process.env.AGENT_DEVICE_DAEMON_SERVER_MODE??("dual"===n?"dual":void 0));return{paths:f(t),transportPreference:o,serverMode:i,remoteBaseUrl:r,remoteAuthToken:a}}(t),o=await l("daemon_startup",async()=>await N(n),{requestId:r,session:t.session}),i=await E(t,o),s={...t,positionals:i.positionals,flags:i.flags,token:o.token,meta:{...t.meta??{},requestId:r,debug:a,cwd:t.meta?.cwd,tenantId:t.meta?.tenantId??t.flags?.tenant,runId:t.meta?.runId??t.flags?.runId,leaseId:t.meta?.leaseId??t.flags?.leaseId,sessionIsolation:t.meta?.sessionIsolation??t.flags?.sessionIsolation,lockPolicy:t.meta?.lockPolicy,lockPlatform:t.meta?.lockPlatform,...i.uploadedArtifactId?{uploadedArtifactId:i.uploadedArtifactId}:{},...i.clientArtifactPaths?{clientArtifactPaths:i.clientArtifactPaths}:{},...i.installSource?{installSource:i.installSource}:{}}};return c({level:"info",phase:"daemon_request_prepare",data:{requestId:r,command:t.command,session:t.session}}),await l("daemon_request",async()=>await j(o,s,n.transportPreference),{requestId:r,command:t.command})}async function E(e,r){let a,n=[...e.positionals??[]],o=e.flags?{...e.flags}:void 0,i=e.meta?.installSource,s={};if(X(r)){let l=function(e,r){if("screenshot"===e.command){let t=M(e,"path",".png");return r[0]?{field:"path",localPath:t,positionalIndex:0,positionalPath:k("screenshot",".png")}:{field:"path",localPath:t,positionalIndex:0,flagPath:k("screenshot",".png")}}if("record"===e.command&&"start"===(r[0]??"").toLowerCase()){let r=M(e,"outPath",".mp4",1);return{field:"outPath",localPath:r,positionalIndex:1,positionalPath:k("recording",t.extname(r)||".mp4")}}return null}(e,n);l&&(void 0!==l.positionalPath&&(n[l.positionalIndex]=l.positionalPath),void 0!==l.flagPath&&((o??={}).out=l.flagPath),s[l.field]=l.localPath);let d=await S(e,r);d&&(i=d.installSource,a=d.uploadedArtifactId??a)}if(!X(r)||"install"!==e.command&&"reinstall"!==e.command||n.length<2)return{positionals:n,flags:o,installSource:i,uploadedArtifactId:a,...Object.keys(s).length>0?{clientArtifactPaths:s}:{}};let l=n[1];if(l.startsWith("remote:"))return n[1]=l.slice(7),{positionals:n,flags:o,...Object.keys(s).length>0?{clientArtifactPaths:s}:{}};let d=t.isAbsolute(l)?l:t.resolve(e.meta?.cwd??process.cwd(),l);return h.existsSync(d)?{positionals:n,flags:o,installSource:i,uploadedArtifactId:a=await y({localPath:d,baseUrl:r.baseUrl,token:r.token}),...Object.keys(s).length>0?{clientArtifactPaths:s}:{}}:{positionals:n,flags:o,...Object.keys(s).length>0?{clientArtifactPaths:s}:{}}}async function S(e,r){let a=e.meta?.installSource;if("install_source"!==e.command||!a||"path"!==a.kind)return null;let n=a.path.trim();if(!n)return{installSource:a};if(n.startsWith("remote:"))return{installSource:{...a,path:n.slice(7)}};let o=t.isAbsolute(n)?n:t.resolve(e.meta?.cwd??process.cwd(),n);if(!h.existsSync(o))return{installSource:{...a,path:o}};let i=await y({localPath:o,baseUrl:r.baseUrl,token:r.token});return{installSource:{...a,path:o},uploadedArtifactId:i}}function M(e,r,a,n=0){let o=e.positionals?.[n]??e.flags?.out,i=`${"path"===r?"screenshot":"recording"}-${Date.now()}${a}`,s=o&&o.trim().length>0?o:i;return t.isAbsolute(s)?s:t.resolve(e.meta?.cwd??process.cwd(),s)}function k(e,r){let a=r.startsWith(".")?r:`.${r}`;return t.posix.join("/tmp",`agent-device-${e}-${Date.now()}-${Math.random().toString(36).slice(2,8)}${a}`)}async function N(e){let a;if(e.remoteBaseUrl){let t={transport:"http",token:e.remoteAuthToken??"",pid:0,baseUrl:e.remoteBaseUrl};if(await q(t,"http"))return t;throw new m("COMMAND_FAILED","Remote daemon is unavailable",{daemonBaseUrl:e.remoteBaseUrl,hint:"Verify AGENT_DEVICE_DAEMON_BASE_URL points to a reachable daemon with GET /health and POST /rpc."})}let i=x(e.paths.infoPath),s=n(),l=function(e,r=o()){try{let a=h.statSync(e),n=t.relative(r,e)||e;return`${n}:${a.size}:${Math.trunc(a.mtimeMs)}`}catch{return"unknown"}}((a=z()).useSrc?a.srcPath:a.distPath,a.root),d=!!i&&await q(i,e.transportPreference);if(i&&i.version===s&&i.codeSignature===l&&d)return i;i&&(i.version!==s||i.codeSignature!==l||!d)&&(await O(i),F(e.paths.infoPath)),function(e){let t=L(e);if(!t.hasLock||t.hasInfo)return;let a=C(e.lockPath);if(!a)return F(e.lockPath);r(a.pid,a.processStartTime)||F(e.lockPath)}(e.paths);let u=0;for(let t=1;t<=D;t+=1){await B(e);let r=await T(A,e);if(r)return r;if(await U(e.paths)){u+=1;continue}let a=L(e.paths);if(!(t<D))break;if(!a.hasInfo&&!a.hasLock){await R(150);continue}}let c=L(e.paths);throw new m("COMMAND_FAILED","Failed to start daemon",{kind:"daemon_startup_failed",infoPath:e.paths.infoPath,lockPath:e.paths.lockPath,startupTimeoutMs:A,startupAttempts:D,lockRecoveryCount:u,metadataState:c,hint:function(e,t=f(process.env.AGENT_DEVICE_STATE_DIR)){return e.hasLock&&!e.hasInfo?`Detected ${t.lockPath} without ${t.infoPath}. If no agent-device daemon process is running, delete ${t.lockPath} and retry.`:e.hasLock&&e.hasInfo?`Daemon metadata may be stale. If no agent-device daemon process is running, delete ${t.infoPath} and ${t.lockPath}, then retry.`:`Daemon metadata is missing or stale. Delete ${t.infoPath} if present and retry.`}(c,e.paths)})}async function T(e,t){let r=Date.now();for(;Date.now()-r<e;){let e=x(t.paths.infoPath);if(e&&await q(e,t.transportPreference))return e;await new Promise(e=>setTimeout(e,100))}return null}async function R(e){await new Promise(t=>setTimeout(t,e))}async function U(e){let t=L(e);if(!t.hasLock||t.hasInfo)return!1;let a=C(e.lockPath);return a&&r(a.pid,a.processStartTime)&&await w(a.pid,{termTimeoutMs:3e3,killTimeoutMs:1e3,expectedStartTime:a.processStartTime}),F(e.lockPath),!0}async function O(e){await w(e.pid,{termTimeoutMs:3e3,killTimeoutMs:1e3,expectedStartTime:e.processStartTime})}function x(e){let t=$(e);if(!t||"object"!=typeof t)return null;let r="string"==typeof t.token&&t.token.length>0?t.token:null;if(!r)return null;let a=Number.isInteger(t.port)&&Number(t.port)>0,n=Number.isInteger(t.httpPort)&&Number(t.httpPort)>0;if(!a&&!n)return null;let o=t.transport,i="string"==typeof t.version?t.version:void 0,s="string"==typeof t.codeSignature?t.codeSignature:void 0,l="string"==typeof t.processStartTime?t.processStartTime:void 0,d=Number.isInteger(t.pid)&&Number(t.pid)>0;return{token:r,port:a?Number(t.port):void 0,httpPort:n?Number(t.httpPort):void 0,transport:"socket"===o||"http"===o||"dual"===o?o:void 0,pid:d?Number(t.pid):0,version:i,codeSignature:s,processStartTime:l}}function C(e){let t=$(e);return t&&"object"==typeof t&&Number.isInteger(t.pid)&&Number(t.pid)>0?{pid:Number(t.pid),processStartTime:"string"==typeof t.processStartTime?t.processStartTime:void 0,startedAt:"number"==typeof t.startedAt?t.startedAt:void 0}:null}function L(e){return{hasInfo:h.existsSync(e.infoPath),hasLock:h.existsSync(e.lockPath)}}function $(e){if(!h.existsSync(e))return null;try{return JSON.parse(h.readFileSync(e,"utf8"))}catch{return null}}function F(e){try{h.existsSync(e)&&h.unlinkSync(e)}catch{}}async function q(e,t){var r;return"http"===G(e,t)?await function(e){let t=e.baseUrl?Y(e.baseUrl,"health"):e.httpPort?`http://127.0.0.1:${e.httpPort}/health`:null;if(!t)return Promise.resolve(!1);let r=new URL(t),a="https:"===r.protocol?i:b,n=e.baseUrl?3e3:500;return new Promise(e=>{let t=a.request({protocol:r.protocol,host:r.hostname,port:r.port,path:r.pathname+r.search,method:"GET",timeout:n},t=>{t.resume(),e((t.statusCode??500)<500)});t.on("timeout",()=>{t.destroy(),e(!1)}),t.on("error",()=>{e(!1)}),t.end()})}(e):await ((r=e.port)?new Promise(e=>{let t=I.createConnection({host:"127.0.0.1",port:r},()=>{t.destroy(),e(!0)});t.on("error",()=>{e(!1)})}):Promise.resolve(!1))}async function B(e){let t=z(),r=t.useSrc?["--experimental-strip-types",t.srcPath]:[t.distPath],n={...process.env,AGENT_DEVICE_STATE_DIR:e.paths.baseDir,AGENT_DEVICE_DAEMON_SERVER_MODE:e.serverMode};a(process.execPath,r,{env:n})}function z(){let e=o(),r=t.join(e,"dist","src","daemon.js"),a=t.join(e,"src","daemon.ts"),n=h.existsSync(r),i=h.existsSync(a);if(!n&&!i)throw new m("COMMAND_FAILED","Daemon entry not found",{distPath:r,srcPath:a});return{root:e,distPath:r,srcPath:a,useSrc:process.execArgv.includes("--experimental-strip-types")?i:!n&&i}}async function j(e,t,r){return"http"===G(e,r)?await J(e,t):await H(e,t)}function G(e,t){if(e.baseUrl){if("socket"===t)throw new m("COMMAND_FAILED","Remote daemon endpoint only supports HTTP transport",{daemonBaseUrl:e.baseUrl});return"http"}if("http"===t||"socket"===t){var r=e,a=t;if(V(r,a))return a;throw new m("COMMAND_FAILED","http"===a?"Daemon HTTP endpoint is unavailable":"Daemon socket endpoint is unavailable")}let n=("socket"===e.transport||"dual"===e.transport?["socket","http"]:["http","socket"]).find(t=>V(e,t));if(n)return n;throw new m("COMMAND_FAILED","Daemon metadata has no reachable transport")}function V(e,t){return"http"===t?!!e.httpPort:!!e.port}async function H(e,t){let r=e.port;if(!r)throw new m("COMMAND_FAILED","Daemon socket endpoint is unavailable");return new Promise((a,n)=>{let o=I.createConnection({host:"127.0.0.1",port:r},()=>{o.write(`${JSON.stringify(t)}
2
- `)}),i=setTimeout(()=>{o.destroy();let r=K(),a=W(e,f(t.flags?.stateDir??process.env.AGENT_DEVICE_STATE_DIR));c({level:"error",phase:"daemon_request_timeout",data:{timeoutMs:v,requestId:t.meta?.requestId,command:t.command,timedOutRunnerPidsTerminated:r.terminated,timedOutRunnerCleanupError:r.error,daemonPidReset:e.pid,daemonPidForceKilled:a.forcedKill}}),n(new m("COMMAND_FAILED","Daemon request timed out",{timeoutMs:v,requestId:t.meta?.requestId,hint:"Retry with --debug and check daemon diagnostics logs. Timed-out iOS runner xcodebuild processes were terminated when detected."}))},v),s="";o.setEncoding("utf8"),o.on("data",e=>{let r=(s+=e).indexOf("\n");if(-1===r)return;let l=s.slice(0,r).trim();if(l)try{let e=JSON.parse(l);o.end(),clearTimeout(i),a(e)}catch(e){clearTimeout(i),n(new m("COMMAND_FAILED","Invalid daemon response",{requestId:t.meta?.requestId,line:l},e instanceof Error?e:void 0))}}),o.on("error",e=>{clearTimeout(i),c({level:"error",phase:"daemon_request_socket_error",data:{requestId:t.meta?.requestId,message:e instanceof Error?e.message:String(e)}}),n(new m("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))})})}async function J(t,r){let a=t.baseUrl?new URL(Y(t.baseUrl,"rpc")):t.httpPort?new URL(`http://127.0.0.1:${t.httpPort}/rpc`):null;if(!a)throw new m("COMMAND_FAILED","Daemon HTTP endpoint is unavailable");let n=JSON.stringify({jsonrpc:"2.0",id:r.meta?.requestId??e(),method:"agent_device.command",params:r}),o={"content-type":"application/json","content-length":Buffer.byteLength(n)};return t.baseUrl&&t.token&&(o.authorization=`Bearer ${t.token}`,o["x-agent-device-token"]=t.token),await new Promise((e,s)=>{let l=f(r.flags?.stateDir??process.env.AGENT_DEVICE_STATE_DIR),d=("https:"===a.protocol?i:b).request({protocol:a.protocol,host:a.hostname,port:a.port,method:"POST",path:a.pathname+a.search,headers:o},a=>{let n="";a.setEncoding("utf8"),a.on("data",e=>{n+=e}),a.on("end",()=>{clearTimeout(u);try{let a=JSON.parse(n);if(a.error){let e=a.error.data??{};s(new m(String(e.code??"COMMAND_FAILED"),String(e.message??a.error.message??"Daemon RPC request failed"),{..."object"==typeof e.details&&e.details?e.details:{},hint:"string"==typeof e.hint?e.hint:void 0,diagnosticId:"string"==typeof e.diagnosticId?e.diagnosticId:void 0,logPath:"string"==typeof e.logPath?e.logPath:void 0,requestId:r.meta?.requestId}));return}if(!a.result||"object"!=typeof a.result)return void s(new m("COMMAND_FAILED","Invalid daemon RPC response",{requestId:r.meta?.requestId}));if(t.baseUrl&&a.result.ok)return void Q(t,r,a.result).then(e).catch(s);e(a.result)}catch(e){clearTimeout(u),s(new m("COMMAND_FAILED","Invalid daemon response",{requestId:r.meta?.requestId,line:n},e instanceof Error?e:void 0))}})}),u=setTimeout(()=>{d.destroy();let e=X(t)?{terminated:0}:K(),a=X(t)?{forcedKill:!1}:W(t,l);c({level:"error",phase:"daemon_request_timeout",data:{timeoutMs:v,requestId:r.meta?.requestId,command:r.command,timedOutRunnerPidsTerminated:e.terminated,timedOutRunnerCleanupError:e.error,daemonPidReset:X(t)?void 0:t.pid,daemonPidForceKilled:X(t)?void 0:a.forcedKill,daemonBaseUrl:t.baseUrl}}),s(new m("COMMAND_FAILED","Daemon request timed out",{timeoutMs:v,requestId:r.meta?.requestId,hint:X(t)?"Retry with --debug and verify the remote daemon URL, auth token, and remote host logs.":"Retry with --debug and check daemon diagnostics logs. Timed-out iOS runner xcodebuild processes were terminated when detected."}))},v);d.on("error",e=>{clearTimeout(u),c({level:"error",phase:"daemon_request_socket_error",data:{requestId:r.meta?.requestId,message:e instanceof Error?e.message:String(e)}}),s(new m("COMMAND_FAILED","Failed to communicate with daemon",{requestId:r.meta?.requestId,hint:X(t)?"Retry command. If this persists, verify the remote daemon URL, auth token, and remote host reachability.":"Retry command. If this persists, clean stale daemon metadata and start a fresh session."},e))}),d.write(n),d.end()})}function K(){let e=0;try{for(let t of _){let r=s("pkill",["-f",t],{allowFailure:!0});0===r.exitCode&&(e+=1)}return{terminated:e}}catch(t){return{terminated:e,error:t instanceof Error?t.message:String(t)}}}function W(e,t){let a=!1;try{r(e.pid,e.processStartTime)&&(process.kill(e.pid,"SIGKILL"),a=!0)}catch{w(e.pid,{termTimeoutMs:3e3,killTimeoutMs:1e3,expectedStartTime:e.processStartTime})}finally{F(t.infoPath),F(t.lockPath)}return{forcedKill:a}}function X(e){return"string"==typeof e.baseUrl&&e.baseUrl.length>0}function Y(e,t){return new URL(t,e.endsWith("/")?e:`${e}/`).toString()}async function Q(e,r,a){let n=Array.isArray(a.data?.artifacts)?a.data.artifacts:[];if(0===n.length||!e.baseUrl)return a;let o=a.data?{...a.data}:{},i=[];for(let a of n){if(!a||"object"!=typeof a||"string"!=typeof a.artifactId){i.push(a);continue}let n=function(e,r){if(e.localPath&&e.localPath.trim().length>0)return e.localPath;let a=e.fileName?.trim()||`${e.field}-${Date.now()}`;return t.resolve(r.meta?.cwd??process.cwd(),a)}(a,r);await Z({baseUrl:e.baseUrl,token:e.token,artifactId:a.artifactId,destinationPath:n,requestId:r.meta?.requestId}),o[a.field]=n,i.push({...a,localPath:n})}return o.artifacts=i,{ok:!0,data:o}}async function Z(e){var r,a;let n,o=new URL((r=e.baseUrl,a=e.artifactId,n=r.endsWith("/")?r:`${r}/`,new URL(`upload/${encodeURIComponent(a)}`,n).toString())),s="https:"===o.protocol?i:b;await h.promises.mkdir(t.dirname(e.destinationPath),{recursive:!0}),await new Promise((t,r)=>{let a=!1,n=e.timeoutMs??v,i=n=>{if(!a){if(a=!0,clearTimeout(d),n)return void h.promises.rm(e.destinationPath,{force:!0}).finally(()=>r(n));t()}},l=s.request({protocol:o.protocol,host:o.hostname,port:o.port,method:"GET",path:o.pathname+o.search,headers:e.token?{authorization:`Bearer ${e.token}`,"x-agent-device-token":e.token}:void 0},t=>{if((t.statusCode??500)>=400){let r="";t.setEncoding("utf8"),t.on("data",e=>{r+=e}),t.on("end",()=>{i(new m("COMMAND_FAILED","Failed to download remote artifact",{artifactId:e.artifactId,statusCode:t.statusCode,requestId:e.requestId,body:r}))});return}let r=h.createWriteStream(e.destinationPath);r.on("error",e=>{i(e instanceof Error?e:Error(String(e)))}),t.on("error",e=>{i(e instanceof Error?e:Error(String(e)))}),t.on("aborted",()=>{i(new m("COMMAND_FAILED","Remote artifact download was interrupted",{artifactId:e.artifactId,requestId:e.requestId}))}),r.on("finish",()=>{r.close(()=>i())}),t.pipe(r)}),d=setTimeout(()=>{l.destroy(new m("COMMAND_FAILED","Remote artifact download timed out",{artifactId:e.artifactId,requestId:e.requestId,timeoutMs:n}))},n);l.on("error",t=>{t instanceof m?i(t):i(new m("COMMAND_FAILED","Failed to download remote artifact",{artifactId:e.artifactId,requestId:e.requestId,timeoutMs:n},t instanceof Error?t:void 0))}),l.end()})}function ee(e){return e.replace(/\/+$/,"")}function et(e){return"string"==typeof e&&e.trim()?ee(e.trim()):""}function er(e){return"string"==typeof e&&e.trim()?e.trim():void 0}function ea(e,t,r){return u(e,{env:t,cwd:r})}function en(e){try{return h.accessSync(e,h.constants.F_OK),!0}catch{return!1}}function eo(e,t,r){if(null==e||""===e)return t;let a=Number.parseInt(String(e),10);return Number.isInteger(a)?Math.max(a,r):t}function ei(e,t){let r;return{platform:t,bundleUrl:((r=new URL(`${ee(e)}/index.bundle`)).searchParams.set("platform",t),r.searchParams.set("dev","true"),r.searchParams.set("minify","false"),r.toString())}}function es(e,t){return{platform:t,metroHost:er(e?.metro_host),metroPort:e?.metro_port,bundleUrl:er(e?.metro_bundle_url),launchUrl:er(e?.launch_url)}}function el(e){return`'${e.replace(/'/g,"'\"'\"'")}'`}async function ed(e){await new Promise(t=>setTimeout(t,e))}async function eu(e,t,r={}){try{let a=await fetch(e,{headers:r,signal:AbortSignal.timeout(t)});return{ok:a.ok,status:a.status,body:await a.text()}}catch(r){if(r instanceof Error&&"TimeoutError"===r.name)throw Error(`Timed out fetching ${e} after ${t}ms`);throw r}}async function ec(e,t){try{let r=await eu(e,t);return r.ok&&r.body.includes("packager-status:running")}catch{return!1}}async function ep(e){var t,r,a;let n;try{n=await fetch(`${e.baseUrl}/api/metro/bridge`,{method:"POST",headers:(t=e.baseUrl,r=e.bearerToken,{Authorization:`Bearer ${r}`,"Content-Type":"application/json",...t.includes("ngrok")?{"ngrok-skip-browser-warning":"1"}:{}}),body:JSON.stringify({ios_runtime:e.runtime,timeout_ms:e.timeoutMs}),signal:AbortSignal.timeout(e.timeoutMs)})}catch(t){if(t instanceof Error&&"TimeoutError"===t.name)throw Error(`/api/metro/bridge timed out after ${e.timeoutMs}ms calling ${e.baseUrl}/api/metro/bridge`);throw t}let o=await n.text(),i=o?JSON.parse(o):{};if(!n.ok)throw Error(`/api/metro/bridge failed (${n.status}): ${JSON.stringify(i)}`);return{enabled:(a=i.data??i).enabled,baseUrl:a.base_url,statusUrl:a.status_url,bundleUrl:a.bundle_url,iosRuntime:es(a.ios_runtime,"ios"),androidRuntime:es(a.android_runtime,"android"),upstream:{bundleUrl:a.upstream.bundle_url,host:a.upstream.host,port:a.upstream.port,statusUrl:a.upstream.status_url},probe:{reachable:a.probe.reachable,statusCode:a.probe.status_code,latencyMs:a.probe.latency_ms,detail:a.probe.detail}}}async function em(e,t,r){let a=Date.now()+t;for(;Date.now()<a;){let t=Math.min(r,Math.max(a-Date.now(),1));if(await ec(e,t))return!0;let n=Math.min(500,Math.max(a-Date.now(),0));n>0&&await ed(n)}return!1}async function eh(e={}){let r=e.env??process.env,a=process.cwd(),n=ea(e.projectRoot??a,r,a),o=function(e,r){if("auto"!==r)return r;let a=function(e){let r=t.join(e,"package.json");if(!en(r))throw new m("INVALID_ARGS",`package.json not found at ${r}`);return JSON.parse(h.readFileSync(r,"utf8"))}(e);return"string"==typeof({...a.dependencies??{},...a.devDependencies??{}}).expo?"expo":"react-native"}(n,e.kind??"auto"),i=function(e,t){if(null==e||""===e)return 8081;let r=Number.parseInt(String(e),10);if(!Number.isInteger(r)||r<1||r>65535)throw new m("INVALID_ARGS",`Invalid Metro port: ${String(e)}. Use 1-65535.`);return r}(e.metroPort??8081,0),l=er(e.listenHost)??"0.0.0.0",d=er(e.statusHost)??"127.0.0.1",u=et(e.publicBaseUrl),c=eo(e.startupTimeoutMs,18e4,3e4),p=eo(e.probeTimeoutMs,1e4,1e3),f=e.reuseExisting??!0,I=e.installDependenciesIfNeeded??!0,g=e.runtimeFilePath?ea(e.runtimeFilePath,r,a):null,w=ea(e.logPath??t.join(n,".agent-device","metro.log"),r,a);if(!u)throw new m("INVALID_ARGS","metro prepare requires --public-base-url <url>.");let{proxyEnabled:b,proxyBaseUrl:y,proxyBearerToken:v}=function(e,t){if(e&&!t)throw new m("INVALID_ARGS","metro prepare requires proxy auth when --proxy-base-url is provided. Pass --bearer-token or set AGENT_DEVICE_PROXY_TOKEN.");if(!e&&t)throw new m("INVALID_ARGS","metro prepare requires --proxy-base-url when proxy auth is provided.");return{proxyEnabled:!!(e&&t),proxyBaseUrl:e,proxyBearerToken:t}}(et(e.proxyBaseUrl),er(e.proxyBearerToken)??""),A=I?function(e,r){if(function(e){try{return h.statSync(e).isDirectory()}catch{return!1}}(t.join(e,"node_modules")))return{installed:!1};let a=en(t.join(e,"pnpm-lock.yaml"))?{command:"pnpm",installArgs:["install"]}:en(t.join(e,"yarn.lock"))?{command:"yarn",installArgs:["install"]}:{command:"npm",installArgs:["install"]};return s(a.command,a.installArgs,{cwd:e,env:r}),{installed:!0,packageManager:a.command}}(n,r):{installed:!1},D=`http://${d}:${i}/status`,_=!1,P=!1,E=0;if(f&&await ec(D,p))P=!0;else if(_=!0,E=function(e,r,a,n,o,i){let l="expo"===r?{command:"npx",installArgs:["expo","start","--host","lan","--port",String(a)]}:{command:"npx",installArgs:["react-native","start","--host",n,"--port",String(a)]};h.mkdirSync(t.dirname(o),{recursive:!0});let d=[el(l.command),...l.installArgs.map(el)].join(" "),u=s("/bin/sh",["-c",`nohup ${d} >> ${el(o)} 2>&1 < /dev/null & echo $!`],{cwd:e,env:i}),c=Number.parseInt(u.stdout.trim(),10);if(!Number.isInteger(c)||c<=0)throw Error(`Failed to start Metro. Expected a child PID in stdout, got "${u.stdout.trim()}".`);return{pid:c}}(n,o,i,l,w,r).pid,!await em(D,c,p))throw Error(`Metro did not become ready at ${D} within ${c}ms. Check ${w}.`);let S=ei(u,"ios"),M=ei(u,"android"),k=null,N=null;if(b)try{k=await ep({baseUrl:y,bearerToken:v,runtime:{metro_bundle_url:S.bundleUrl},timeoutMs:p})}catch(e){N=e instanceof Error?e.message:String(e)}if(b&&(!k||!1===k.probe.reachable)){var T,R;let e;throw Error((T=N,R=k,e=[`Metro bridge is required for this run but could not be configured via ${y}/api/metro/bridge.`],T&&e.push(`bridgeError=${T}`),R?.probe.reachable===!1&&e.push(`bridgeProbe=${R.probe.detail||`unreachable (status ${R.probe.statusCode||0})`}`),e.join(" ")))}let U=k?.iosRuntime??S,O=k?.androidRuntime??M,x={projectRoot:n,kind:o,dependenciesInstalled:A.installed,packageManager:A.packageManager??null,started:_,reused:P,pid:E,logPath:w,statusUrl:D,runtimeFilePath:g,iosRuntime:U,androidRuntime:O,bridge:k};return g&&(h.mkdirSync(t.dirname(g),{recursive:!0}),h.writeFileSync(g,JSON.stringify(x,null,2))),x}function ef(e){let t=e.appId??e.bundleId??e.packageName;return{session:e.session,appId:t,appBundleId:e.bundleId,package:e.packageName}}function eI(e,t,r){return{deviceId:t,deviceName:r,..."android"===e?{serial:t}:"ios"===e?{udid:t}:{}}}function eg(e,t={}){let r=t.includeAndroidSerial??!0;return{platform:e.platform,target:e.target,device:e.name,id:e.id,..."ios"===e.platform?{device_udid:e.ios?.udid??e.id,ios_simulator_device_set:e.ios?.simulatorSetPath??null}:{},..."android"===e.platform&&r?{serial:e.android?.serial??e.id}:{}}}function ew(e){return{name:e.name,...eg(e.device,{includeAndroidSerial:!1}),createdAt:e.createdAt}}function eb(e){return{platform:e.platform,id:e.id,name:e.name,kind:e.kind,target:e.target,..."boolean"==typeof e.booted?{booted:e.booted}:{}}}function ey(e){return{udid:e.udid,device:e.device,runtime:e.runtime,ios_simulator_device_set:e.iosSimulatorDeviceSet??null,created:e.created,booted:e.booted}}function ev(e){return{app:e.app,appPath:e.appPath,platform:e.platform,...e.appId?{appId:e.appId}:{},...e.bundleId?{bundleId:e.bundleId}:{},...e.package?{package:e.package}:{}}}function eA(e){return{launchTarget:e.launchTarget,...e.appName?{appName:e.appName}:{},...e.appId?{appId:e.appId}:{},...e.bundleId?{bundleId:e.bundleId}:{},...e.packageName?{package:e.packageName}:{},...e.installablePath?{installablePath:e.installablePath}:{},...e.archivePath?{archivePath:e.archivePath}:{},...e.materializationId?{materializationId:e.materializationId}:{},...e.materializationExpiresAt?{materializationExpiresAt:e.materializationExpiresAt}:{}}}function eD(e){return{session:e.session,...e.appName?{appName:e.appName}:{},...e.appBundleId?{appBundleId:e.appBundleId}:{},...e.startup?{startup:e.startup}:{},...e.runtime?{runtime:e.runtime}:{},...e.device?eg(e.device):{}}}function e_(e){return{session:e.session,...e.shutdown?{shutdown:e.shutdown}:{}}}function eP(e){return{nodes:e.nodes,truncated:e.truncated,...e.appName?{appName:e.appName}:{},...e.appBundleId?{appBundleId:e.appBundleId}:{}}}function eE(e,t){let r=eO(e,"bundleId"),a=eO(e,"package");return{app:eU(e,"app"),appPath:eU(e,"appPath"),platform:ex(e,"platform"),appId:r??a,bundleId:r,package:a,identifiers:ef({session:t,bundleId:r,packageName:a})}}function eS(e){var t;let r=eT(e),a=ex(r,"platform"),n=eU(r,"id"),o=eU(r,"name");return{platform:a,target:eC(r,"target"),kind:eL(r,t="kind",ez,`Daemon response has invalid "${t}".`),id:n,name:o,booted:"boolean"==typeof r.booted?r.booted:void 0,identifiers:eI(a,n,o),ios:"ios"===a?{udid:n}:void 0,android:"android"===a?{serial:n}:void 0}}function eM(e){var t;let r=eT(e),a=ex(r,"platform"),n=eU(r,"id"),o=eU(r,"name"),i=eC(r,"target"),s=eU(r,"device"),l={session:o,...eI(a,n,s)};return{name:o,createdAt:eL(r,t="createdAt",eq,`Daemon response is missing numeric "${t}".`),device:{platform:a,target:i,id:n,name:s,identifiers:l,ios:"ios"===a?{udid:n,simulatorSetPath:e$(r,"ios_simulator_device_set",eF)}:void 0,android:"android"===a?{serial:n}:void 0},identifiers:l}}function ek(e,t){return t??e??"default"}function eN(e){let t={};for(let[r,a]of Object.entries(e))void 0!==a&&(t[r]=a);return t}function eT(e){if(!eR(e))throw new m("COMMAND_FAILED","Daemon returned an unexpected response shape.",{value:e});return e}function eR(e){return"object"==typeof e&&null!==e}function eU(e,t){return eL(e,t,eF,`Daemon response is missing "${t}".`)}function eO(e,t){return eF(e[t])}function ex(e,t){return eL(e,t,eB,`Daemon response has invalid "${t}".`)}function eC(e,t){return ej(e[t])??"mobile"}function eL(e,t,r,a){let n=r(e[t]);if(void 0===n)throw new m("COMMAND_FAILED",a,{response:e});return n}function e$(e,t,r){let a=e[t];return null===a?null:r(a)}function eF(e){return"string"==typeof e&&e.length>0?e:void 0}function eq(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function eB(e){return"ios"===e||"macos"===e||"android"===e?e:void 0}function ez(e){return"simulator"===e||"emulator"===e||"device"===e?e:void 0}function ej(e){return"tv"===e||"mobile"===e||"desktop"===e?e:void 0}function eG(e={},t={}){let r=t.transport??P,a=async(t,a=[],n={})=>{let o={...e,...n},i=await r({session:ek(e.session,n.session),command:t,positionals:a,flags:eN({stateDir:o.stateDir,daemonBaseUrl:o.daemonBaseUrl,daemonAuthToken:o.daemonAuthToken,daemonTransport:o.daemonTransport,daemonServerMode:o.daemonServerMode,tenant:o.tenant,sessionIsolation:o.sessionIsolation,runId:o.runId,leaseId:o.leaseId,platform:o.platform,target:o.target,device:o.device,udid:o.udid,serial:o.serial,iosSimulatorDeviceSet:o.iosSimulatorDeviceSet,androidDeviceAllowlist:o.androidDeviceAllowlist,runtime:o.simulatorRuntimeId,boot:o.boot,reuseExisting:o.reuseExisting,activity:o.activity,relaunch:o.relaunch,shutdown:o.shutdown,saveScript:o.saveScript,noRecord:o.noRecord,metroHost:o.metroHost,metroPort:o.metroPort,bundleUrl:o.bundleUrl,launchUrl:o.launchUrl,snapshotInteractiveOnly:o.interactiveOnly,snapshotCompact:o.compact,snapshotDepth:o.depth,snapshotScope:o.scope,snapshotRaw:o.raw,verbose:o.debug}),runtime:o.runtime,meta:eN({requestId:o.requestId,cwd:o.cwd,debug:o.debug,lockPolicy:o.lockPolicy,lockPlatform:o.lockPlatform,tenantId:o.tenant,runId:o.runId,leaseId:o.leaseId,sessionIsolation:o.sessionIsolation,installSource:o.installSource,retainMaterializedPaths:o.retainMaterializedPaths,materializedPathRetentionMs:o.materializedPathRetentionMs,materializationId:o.materializationId})});if(!i.ok)throw new m(i.error.code,i.error.message,{...i.error.details??{},hint:i.error.hint,diagnosticId:i.error.diagnosticId,logPath:i.error.logPath});return i.data??{}},n=async(e={})=>{let t=await a("session_list",[],e);return(Array.isArray(t.sessions)?t.sessions:[]).map(eM)};return{devices:{list:async(e={})=>{let t=await a("devices",[],e);return(Array.isArray(t.devices)?t.devices:[]).map(eS)}},sessions:{list:async(e={})=>await n(e),close:async(t={})=>{let r=ek(e.session,t.session),n=(await a("close",[],t)).shutdown;return{session:r,shutdown:"object"==typeof n&&null!==n?n:void 0,identifiers:{session:r}}}},simulators:{ensure:async e=>{let{runtime:t,...r}=e,n=await a("ensure-simulator",[],{...r,simulatorRuntimeId:t}),o=eU(n,"udid"),i=eU(n,"device");return{udid:o,device:i,runtime:eU(n,"runtime"),created:!0===n.created,booted:!0===n.booted,iosSimulatorDeviceSet:e$(n,"ios_simulator_device_set",eF),identifiers:{deviceId:o,deviceName:i,udid:o}}}},apps:{install:async t=>eE(await a("install",[t.app,t.appPath],t),ek(e.session,t.session)),reinstall:async t=>eE(await a("reinstall",[t.app,t.appPath],t),ek(e.session,t.session)),installFromSource:async t=>(function(e,t){let r=eO(e,"bundleId"),a=eO(e,"packageName"),n=r??a??eO(e,"appId"),o=eO(e,"launchTarget")??a??r??n;if(!o)throw new m("COMMAND_FAILED",'Daemon response is missing "launchTarget".',{response:e});return{appName:eO(e,"appName"),appId:n,bundleId:r,packageName:a,launchTarget:o,installablePath:eO(e,"installablePath"),archivePath:eO(e,"archivePath"),materializationId:eO(e,"materializationId"),materializationExpiresAt:eO(e,"materializationExpiresAt"),identifiers:ef({session:t,bundleId:r,packageName:a,appId:n})}})(await a("install_source",[],{...t,installSource:t.source,retainMaterializedPaths:t.retainPaths,materializedPathRetentionMs:t.retentionMs}),ek(e.session,t.session)),open:async t=>{let r=ek(e.session,t.session),n=t.url?[t.app,t.url]:[t.app],o=await a("open",n,t),i=function(e){let t=e.platform,r=eO(e,"id"),a=eO(e,"device");if("ios"!==t&&"macos"!==t&&"android"!==t||!r||!a)return;let n=eC(e,"target"),o=eI(t,r,a);return{platform:t,target:n,id:r,name:a,identifiers:o,ios:"ios"===t?{udid:eO(e,"device_udid")??r,simulatorSetPath:e$(e,"ios_simulator_device_set",eF)}:void 0,android:"android"===t?{serial:eO(e,"serial")??r}:void 0}}(o),s=eO(o,"appBundleId");return{session:r,appName:eO(o,"appName"),appBundleId:s,appId:s,startup:function(e){if(eR(e)&&"number"==typeof e.durationMs&&"string"==typeof e.measuredAt&&"string"==typeof e.method)return{durationMs:e.durationMs,measuredAt:e.measuredAt,method:e.method,appTarget:eO(e,"appTarget"),appBundleId:eO(e,"appBundleId")}}(o.startup),runtime:function(e){if(!eR(e))return;let t=e.platform,r=eO(e,"metroHost"),a="number"==typeof e.metroPort?e.metroPort:void 0;return{platform:"ios"===t||"android"===t?t:void 0,metroHost:r,metroPort:a,bundleUrl:eO(e,"bundleUrl"),launchUrl:eO(e,"launchUrl")}}(o.runtime),device:i,identifiers:{session:r,deviceId:i?.id,deviceName:i?.name,udid:i?.ios?.udid,serial:i?.android?.serial,appId:s,appBundleId:s}}},close:async(t={})=>{let r=ek(e.session,t.session),n=(await a("close",t.app?[t.app]:[],t)).shutdown;return{session:r,closedApp:t.app,shutdown:"object"==typeof n&&null!==n?n:void 0,identifiers:{session:r}}}},materializations:{release:async e=>{var t;return{released:!0===(t=await a("release_materialized_paths",[],{...e,materializationId:e.materializationId})).released,materializationId:eU(t,"materializationId"),identifiers:{}}}},metro:{prepare:async t=>await eh({projectRoot:t.projectRoot??e.cwd,kind:t.kind,publicBaseUrl:t.publicBaseUrl,proxyBaseUrl:t.proxyBaseUrl,proxyBearerToken:t.bearerToken,metroPort:t.port,listenHost:t.listenHost,statusHost:t.statusHost,startupTimeoutMs:t.startupTimeoutMs,probeTimeoutMs:t.probeTimeoutMs,reuseExisting:t.reuseExisting,installDependenciesIfNeeded:t.installDependenciesIfNeeded,runtimeFilePath:t.runtimeFilePath,logPath:t.logPath})},capture:{snapshot:async(t={})=>{var r;let n=ek(e.session,t.session),o=await a("snapshot",[],t),i=eO(o,"appBundleId");return{nodes:Array.isArray(r=o.nodes)?r:[],truncated:!0===o.truncated,appName:eO(o,"appName"),appBundleId:i,identifiers:{session:n,appId:i,appBundleId:i}}},screenshot:async(t={})=>{let r=ek(e.session,t.session);return{path:eU(await a("screenshot",t.path?[t.path]:[],t),"path"),identifiers:{session:r}}}}}}export{eG as createAgentDeviceClient,P as sendToDaemon,e_ as serializeCloseResult,ev as serializeDeployResult,eb as serializeDevice,ey as serializeEnsureSimulatorResult,eA as serializeInstallFromSourceResult,eD as serializeOpenResult,ew as serializeSessionListEntry,eP as serializeSnapshotResult};
package/dist/src/331.js DELETED
@@ -1,3 +0,0 @@
1
- import{URL as e,fileURLToPath as t,pathToFileURL as r}from"node:url";import{spawn as n,spawnSync as o}from"node:child_process";import i from"node:os";import s,{existsSync as a,promises as d}from"node:fs";import u from"node:path";import{AsyncLocalStorage as c}from"node:async_hooks";import l,{createHash as f}from"node:crypto";let m=new c,p=/(token|secret|password|authorization|cookie|api[_-]?key|access[_-]?key|private[_-]?key)/i,h=/(bearer\s+[a-z0-9._-]+|(?:api[_-]?key|token|secret|password)\s*[=:]\s*\S+)/i;function g(){return l.randomBytes(8).toString("hex")}async function w(e,t){let r={...e,diagnosticId:`${Date.now().toString(36)}-${l.randomBytes(4).toString("hex")}`,events:[]};return await m.run(r,t)}function S(){let e=m.getStore();return e?{diagnosticId:e.diagnosticId,requestId:e.requestId,session:e.session,command:e.command,debug:e.debug}:{}}function E(e){let t=m.getStore();if(!t)return;let r={ts:new Date().toISOString(),level:e.level??"info",phase:e.phase,session:t.session,requestId:t.requestId,command:t.command,durationMs:e.durationMs,data:e.data?y(e.data):void 0};if(t.events.push(r),!t.debug)return;let n=`[agent-device][diag] ${JSON.stringify(r)}
2
- `;try{t.logPath&&s.appendFile(t.logPath,n,()=>{}),t.traceLogPath&&s.appendFile(t.traceLogPath,n,()=>{}),t.logPath||t.traceLogPath||process.stderr.write(n)}catch{}}async function D(e,t,r){let n=Date.now();try{let o=await t();return E({level:"info",phase:e,durationMs:Date.now()-n,data:r}),o}catch(t){throw E({level:"error",phase:e,durationMs:Date.now()-n,data:{...r??{},error:t instanceof Error?t.message:String(t)}}),t}}function v(e={}){let t=m.getStore();if(!t||!e.force&&!t.debug||0===t.events.length)return null;try{let e=(t.session??"default").replace(/[^a-zA-Z0-9._-]/g,"_"),r=new Date().toISOString().slice(0,10),n=u.join(i.homedir(),".agent-device","logs",e,r);s.mkdirSync(n,{recursive:!0});let o=new Date().toISOString().replace(/[:.]/g,"-"),a=u.join(n,`${o}-${t.diagnosticId}.ndjson`),d=t.events.map(e=>JSON.stringify(y(e)));return s.writeFileSync(a,`${d.join("\n")}
3
- `),t.events=[],a}catch{return null}}function y(e){return function e(t,r,n){if(null==t)return t;if("string"==typeof t){var o=t,i=n;let e=o.trim();if(!e)return o;if(i&&p.test(i)||h.test(e))return"[REDACTED]";let r=function(e){try{let t=new URL(e);return t.search&&(t.search="?REDACTED"),(t.username||t.password)&&(t.username="REDACTED",t.password="REDACTED"),t.toString()}catch{return null}}(e);return r||(e.length>400?`${e.slice(0,200)}...<truncated>`:e)}if("object"!=typeof t)return t;if(r.has(t))return"[Circular]";if(r.add(t),Array.isArray(t))return t.map(t=>e(t,r));let s={};for(let[n,o]of Object.entries(t)){if(p.test(n)){s[n]="[REDACTED]";continue}s[n]=e(o,r,n)}return s}(e,new WeakSet)}class I extends Error{code;details;cause;constructor(e,t,r,n){super(t),this.code=e,this.details=r,this.cause=n}}function M(e){return e instanceof I?e:e instanceof Error?new I("UNKNOWN",e.message,void 0,e):new I("UNKNOWN","Unknown error",{err:e})}function A(e,t={}){let r=M(e),n=r.details?y(r.details):void 0,o=n&&"string"==typeof n.hint?n.hint:void 0,i=(n&&"string"==typeof n.diagnosticId?n.diagnosticId:void 0)??t.diagnosticId,s=(n&&"string"==typeof n.logPath?n.logPath:void 0)??t.logPath,a=o??function(e){switch(e){case"INVALID_ARGS":return"Check command arguments and run --help for usage examples.";case"SESSION_NOT_FOUND":return"Run open first or pass an explicit device selector.";case"TOOL_MISSING":return"Install required platform tooling and ensure it is available in PATH.";case"DEVICE_NOT_FOUND":return"Verify the target device is booted/connected and selectors match.";case"UNSUPPORTED_OPERATION":return"This command is not available for the selected platform/device.";case"COMMAND_FAILED":default:return"Retry with --debug and inspect diagnostics log for details.";case"UNAUTHORIZED":return"Refresh daemon metadata and retry the command."}}(r.code),d=function(e){if(!e)return;let t={...e};return delete t.hint,delete t.diagnosticId,delete t.logPath,Object.keys(t).length>0?t:void 0}(n),u=function(e,t,r){if("COMMAND_FAILED"!==e||r?.processExitError!==!0)return t;let n=function(e){let t=[/^an error was encountered processing the command/i,/^underlying error\b/i,/^simulator device failed to complete the requested operation/i];for(let r of e.split("\n")){let e=r.trim();if(e&&!t.some(t=>t.test(e)))return e.length>200?`${e.slice(0,200)}...`:e}return null}("string"==typeof r?.stderr?r.stderr:"");return n||t}(r.code,r.message,n);return{code:r.code,message:u,hint:a,diagnosticId:i,logPath:s,details:d}}async function N(e,t,r={}){return new Promise((o,i)=>{let s=n(e,t,{cwd:r.cwd,env:r.env,stdio:["pipe","pipe","pipe"],detached:r.detached}),a="",d=r.binaryStdout?Buffer.alloc(0):void 0,u="",c=!1,l=L(r.timeoutMs),f=l?setTimeout(()=>{c=!0,s.kill("SIGKILL")},l):null;r.binaryStdout||s.stdout.setEncoding("utf8"),s.stderr.setEncoding("utf8"),void 0!==r.stdin&&s.stdin.write(r.stdin),s.stdin.end(),s.stdout.on("data",e=>{r.binaryStdout?d=Buffer.concat([d??Buffer.alloc(0),Buffer.isBuffer(e)?e:Buffer.from(e)]):a+=e}),s.stderr.on("data",e=>{u+=e}),s.on("error",r=>{(f&&clearTimeout(f),"ENOENT"===r.code)?i(new I("TOOL_MISSING",`${e} not found in PATH`,{cmd:e},r)):i(new I("COMMAND_FAILED",`Failed to run ${e}`,{cmd:e,args:t},r))}),s.on("close",n=>{f&&clearTimeout(f);let s=n??1;c&&l?i(new I("COMMAND_FAILED",`${e} timed out after ${l}ms`,{cmd:e,args:t,stdout:a,stderr:u,exitCode:s,timeoutMs:l})):0===s||r.allowFailure?o({stdout:a,stderr:u,exitCode:s,stdoutBuffer:d}):i(new I("COMMAND_FAILED",`${e} exited with code ${s}`,{cmd:e,args:t,stdout:a,stderr:u,exitCode:s,processExitError:!0}))})})}async function O(e){try{var t;let{shell:r,args:n}=(t=e,"win32"===process.platform?{shell:"cmd.exe",args:["/c","where",t]}:{shell:"bash",args:["-lc",`command -v ${t}`]}),o=await N(r,n,{allowFailure:!0});return 0===o.exitCode&&o.stdout.trim().length>0}catch{return!1}}function T(e,t,r={}){let n=o(e,t,{cwd:r.cwd,env:r.env,stdio:["pipe","pipe","pipe"],encoding:r.binaryStdout?void 0:"utf8",input:r.stdin,timeout:L(r.timeoutMs)});if(n.error){let o=n.error.code;if("ETIMEDOUT"===o)throw new I("COMMAND_FAILED",`${e} timed out after ${L(r.timeoutMs)}ms`,{cmd:e,args:t,timeoutMs:L(r.timeoutMs)},n.error);if("ENOENT"===o)throw new I("TOOL_MISSING",`${e} not found in PATH`,{cmd:e},n.error);throw new I("COMMAND_FAILED",`Failed to run ${e}`,{cmd:e,args:t},n.error)}let i=r.binaryStdout?Buffer.isBuffer(n.stdout)?n.stdout:Buffer.from(n.stdout??""):void 0,s=r.binaryStdout?"":"string"==typeof n.stdout?n.stdout:(n.stdout??"").toString(),a="string"==typeof n.stderr?n.stderr:(n.stderr??"").toString(),d=n.status??1;if(0!==d&&!r.allowFailure)throw new I("COMMAND_FAILED",`${e} exited with code ${d}`,{cmd:e,args:t,stdout:s,stderr:a,exitCode:d,processExitError:!0});return{stdout:s,stderr:a,exitCode:d,stdoutBuffer:i}}function _(e,t,r={}){n(e,t,{cwd:r.cwd,env:r.env,stdio:"ignore",detached:!0}).unref()}async function P(e,t,r={}){return new Promise((o,i)=>{let s=n(e,t,{cwd:r.cwd,env:r.env,stdio:["pipe","pipe","pipe"],detached:r.detached});r.onSpawn?.(s);let a="",d="",u=r.binaryStdout?Buffer.alloc(0):void 0;r.binaryStdout||s.stdout.setEncoding("utf8"),s.stderr.setEncoding("utf8"),void 0!==r.stdin&&s.stdin.write(r.stdin),s.stdin.end(),s.stdout.on("data",e=>{if(r.binaryStdout){u=Buffer.concat([u??Buffer.alloc(0),Buffer.isBuffer(e)?e:Buffer.from(e)]);return}let t=String(e);a+=t,r.onStdoutChunk?.(t)}),s.stderr.on("data",e=>{let t=String(e);d+=t,r.onStderrChunk?.(t)}),s.on("error",r=>{"ENOENT"===r.code?i(new I("TOOL_MISSING",`${e} not found in PATH`,{cmd:e},r)):i(new I("COMMAND_FAILED",`Failed to run ${e}`,{cmd:e,args:t},r))}),s.on("close",n=>{let s=n??1;0===s||r.allowFailure?o({stdout:a,stderr:d,exitCode:s,stdoutBuffer:u}):i(new I("COMMAND_FAILED",`${e} exited with code ${s}`,{cmd:e,args:t,stdout:a,stderr:d,exitCode:s,processExitError:!0}))})})}function C(e,t,r={}){let o=n(e,t,{cwd:r.cwd,env:r.env,stdio:["ignore","pipe","pipe"],detached:r.detached}),i="",s="";o.stdout.setEncoding("utf8"),o.stderr.setEncoding("utf8"),o.stdout.on("data",e=>{i+=e}),o.stderr.on("data",e=>{s+=e});let a=new Promise((n,a)=>{o.on("error",r=>{"ENOENT"===r.code?a(new I("TOOL_MISSING",`${e} not found in PATH`,{cmd:e},r)):a(new I("COMMAND_FAILED",`Failed to run ${e}`,{cmd:e,args:t},r))}),o.on("close",o=>{let d=o??1;0===d||r.allowFailure?n({stdout:i,stderr:s,exitCode:d}):a(new I("COMMAND_FAILED",`${e} exited with code ${d}`,{cmd:e,args:t,stdout:i,stderr:s,exitCode:d,processExitError:!0}))})});return{child:o,wait:a}}function L(e){if(!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t}function F(){try{let e=$();return JSON.parse(s.readFileSync(u.join(e,"package.json"),"utf8")).version??"0.0.0"}catch{return"0.0.0"}}function $(){let e=u.dirname(t(import.meta.url)),r=e;for(let e=0;e<6;e+=1){let e=u.join(r,"package.json");if(s.existsSync(e))return r;r=u.dirname(r)}return e}let b=[/(^|[\/\s"'=])dist\/src\/daemon\.js($|[\s"'])/,/(^|[\/\s"'=])src\/daemon\.ts($|[\s"'])/];function k(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(e){return"EPERM"===e.code}}function x(e){if(!Number.isInteger(e)||e<=0)return null;try{let t=T("ps",["-p",String(e),"-o","lstart="],{allowFailure:!0,timeoutMs:1e3});if(0!==t.exitCode)return null;let r=t.stdout.trim();return r.length>0?r:null}catch{return null}}function R(e){if(!Number.isInteger(e)||e<=0)return null;try{let t=T("ps",["-p",String(e),"-o","command="],{allowFailure:!0,timeoutMs:1e3});if(0!==t.exitCode)return null;let r=t.stdout.trim();return r.length>0?r:null}catch{return null}}function j(e,t){let r;if(!k(e))return!1;if(t){let r=x(e);if(!r||r!==t)return!1}let n=R(e);return!!n&&!!(r=n.toLowerCase().replaceAll("\\","/")).includes("agent-device")&&b.some(e=>e.test(r))}function B(e,t){try{return process.kill(e,t),!0}catch(t){let e=t.code;if("ESRCH"===e||"EPERM"===e)return!1;throw t}}async function U(e,t){if(!k(e))return!0;let r=Date.now();for(;Date.now()-r<t;)if(await new Promise(e=>setTimeout(e,50)),!k(e))return!0;return!k(e)}async function H(e,t){!j(e,t.expectedStartTime)||!B(e,"SIGTERM")||await U(e,t.termTimeoutMs)||B(e,"SIGKILL")&&await U(e,t.killTimeoutMs)}function G(e){return e?.HOME?.trim()||i.homedir()}function q(e,t={}){return"~"===e?G(t.env):e.startsWith("~/")?u.join(G(t.env),e.slice(2)):e}function z(e,t={}){let r=q(e,t);return u.isAbsolute(r)?r:u.resolve(t.cwd??process.cwd(),r)}function K(e){let t,r=(t=(e??"").trim())?z(t):u.join(q("~"),".agent-device");return{baseDir:r,infoPath:u.join(r,"daemon.json"),lockPath:u.join(r,"daemon.lock"),logPath:u.join(r,"daemon.log"),sessionsDir:u.join(r,"sessions")}}function V(e){let t=(e??"").trim().toLowerCase();return"http"===t?"http":"dual"===t?"dual":"socket"}function W(e){let t=(e??"").trim().toLowerCase();return"auto"===t?"auto":"socket"===t?"socket":"http"===t?"http":"auto"}function J(e){return"tenant"===(e??"").trim().toLowerCase()?"tenant":"none"}function Z(e){if(!e)return;let t=e.trim();if(t&&/^[a-zA-Z0-9._-]{1,128}$/.test(t))return t}export{default as node_net}from"node:net";export{default as node_http}from"node:http";export{default as node_https}from"node:https";export{I as AppError,M as asAppError,f as createHash,g as createRequestId,E as emitDiagnostic,a as existsSync,q as expandUserHomePath,e as external_node_url_URL,t as fileURLToPath,$ as findProjectRoot,v as flushDiagnosticsToSessionFile,S as getDiagnosticsMeta,j as isAgentDeviceDaemonProcess,k as isProcessAlive,l as node_crypto,s as node_fs,i as node_os,u as node_path,A as normalizeError,Z as normalizeTenantId,r as pathToFileURL,d as promises,R as readProcessCommand,x as readProcessStartTime,F as readVersion,K as resolveDaemonPaths,V as resolveDaemonServerMode,W as resolveDaemonTransportPreference,J as resolveSessionIsolationMode,z as resolveUserPath,N as runCmd,C as runCmdBackground,_ as runCmdDetached,P as runCmdStreaming,T as runCmdSync,n as spawn,H as stopProcessForTakeover,O as whichCmd,D as withDiagnosticTimer,w as withDiagnosticsScope};
package/dist/src/425.js DELETED
@@ -1 +0,0 @@
1
- import{AppError as e}from"./331.js";let t="<wifi|airplane|location> <on|off>",r="appearance <light|dark|toggle>",i="faceid <match|nonmatch|enroll|unenroll>",a="touchid <match|nonmatch|enroll|unenroll>",n="fingerprint <match|nonmatch>",s="permission <grant|deny|reset> <camera|microphone|photos|contacts|contacts-limited|notifications|calendar|location|location-always|media-library|motion|reminders|siri> [full|limited]",l="permission <grant|reset> <accessibility|screen-recording|input-monitoring>",o=`settings ${t} | settings ${r} | settings ${i} | settings ${a} | settings ${n} | settings ${s} | settings ${l}`,c=`settings requires ${t}, ${r}, ${i}, ${a}, ${n}, ${s}, or ${l}`,u=["app","frontmost-app","desktop","menubar"];function d(t){let r=t?.trim().toLowerCase();if("app"===r||"frontmost-app"===r||"desktop"===r||"menubar"===r)return r;throw new e("INVALID_ARGS",`Invalid surface: ${t}. Use ${u.join("|")}.`)}function p(e){var t;let r,i=f(e.label),a=f(e.value),n=f(e.identifier),s=(t=n)&&!/^[\w.]+:id\/[\w.-]+$/i.test(t)&&!/^_?NS:\d+$/i.test(t)?n:"";return(r=m(e.type??"")).includes("textfield")||r.includes("securetextfield")||r.includes("searchfield")||r.includes("edittext")||r.includes("textview")||r.includes("textarea")?a||i||s:i||a||s}function f(e){return"string"==typeof e?e.trim():""}function m(e){let t=e.trim().replace(/XCUIElementType/gi,"").replace(/^AX/,"").toLowerCase(),r=Math.max(t.lastIndexOf("."),t.lastIndexOf("/"));return -1!==r&&(t=t.slice(r+1)),t}function h(e,t={}){let r=[],i=[];for(let a of e){let e=a.depth??0;for(;r.length>0&&e<=r[r.length-1];)r.pop();let n=a.label?.trim()||a.value?.trim()||a.identifier?.trim()||"",s=x(a.type??"Element"),l="group"===s&&!n;l&&r.push(e);let o=l?e:Math.max(0,e-r.length);i.push({node:a,depth:o,type:s,text:w(a,o,l,s,t)})}return i}function w(e,t,r,i,a={}){var n,s,l,o,c;let u,d,h=i??x(e.type??"Element"),$=(u=p(e),{text:u,isLargeSurface:d=function(e,t){if("text-view"===t||"text-field"===t||"search"===t)return!0;let r=m(e.type??""),i=`${e.role??""} ${e.subrole??""}`.toLowerCase();return r.includes("textview")||r.includes("textarea")||r.includes("textfield")||r.includes("securetextfield")||r.includes("searchfield")||r.includes("edittext")||i.includes("text area")||i.includes("text field")}(e,h),shouldSummarize:d&&!!(n=u)&&(n.length>80||/[\r\n]/.test(n))}),A=(s=e,l=h,o=a,c=$,o.summarizeTextSurfaces&&c.shouldSummarize&&function(e,t,r){let i=f(e.label);if(i&&i!==r)return i;let a=f(e.identifier);if(a&&!S(a)&&a!==r)return a;switch(t){case"text":case"text-view":return"Text view";case"text-field":return"Text field";case"search":return"Search field";default:return""}}(s,l,c.text)||g(s,l)),y=" ".repeat(t),v=e.ref?`@${e.ref}`:"",I=(function(e,t,r,i){let a,n=[];if(!1===e.enabled&&n.push("disabled"),!r.summarizeTextSurfaces||(!0===e.selected&&n.push("selected"),b(t)&&n.push("editable"),function(e,t){if("scroll-area"===t)return!0;let r=(e.type??"").toLowerCase(),i=`${e.role??""} ${e.subrole??""}`.toLowerCase();return r.includes("scroll")||i.includes("scroll")}(e,t)&&n.push("scrollable"),!i.shouldSummarize))return n;return n.push(`preview:"${((a=i.text.replace(/\s+/g," ").trim()).length<=48?a:`${a.slice(0,45)}...`).replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`),n.push("truncated"),[...new Set(n)]})(e,h,a,$).map(e=>` [${e}]`).join(""),_=A?` "${A}"`:"";return r?`${y}${v} [${h}]${I}`.trimEnd():`${y}${v} [${h}]${_}${I}`.trimEnd()}function g(e,t){let r=e.label?.trim(),i=e.value?.trim();if(b(t)){if(i)return i;if(r)return r}else if(r)return r;if(i)return i;let a=e.identifier?.trim();return!a||S(a)&&("group"===t||"image"===t||"list"===t||"collection"===t)?"":a}function x(e){let t=e.replace(/XCUIElementType/gi,"").toLowerCase(),r=e.includes(".")&&(e.startsWith("android.")||e.startsWith("androidx.")||e.startsWith("com."));switch(t.includes(".")&&(t=t.replace(/^android\.widget\./,"").replace(/^android\.view\./,"").replace(/^android\.webkit\./,"").replace(/^androidx\./,"").replace(/^com\.google\.android\./,"").replace(/^com\.android\./,"")),t){case"application":return"application";case"navigationbar":return"navigation-bar";case"tabbar":return"tab-bar";case"button":case"imagebutton":return"button";case"link":return"link";case"cell":return"cell";case"statictext":case"checkedtextview":return"text";case"textfield":case"edittext":return"text-field";case"textview":return r?"text":"text-view";case"textarea":return"text-view";case"switch":return"switch";case"slider":return"slider";case"image":case"imageview":return"image";case"webview":return"webview";case"framelayout":case"linearlayout":case"relativelayout":case"constraintlayout":case"viewgroup":case"view":case"group":return"group";case"listview":case"recyclerview":return"list";case"collectionview":return"collection";case"searchfield":return"search";case"segmentedcontrol":return"segmented-control";case"window":return"window";case"checkbox":return"checkbox";case"radio":return"radio";case"menuitem":return"menu-item";case"toolbar":return"toolbar";case"scrollarea":case"scrollview":case"nestedscrollview":return"scroll-area";case"table":return"table";default:return t||"element"}}function b(e){return"text-field"===e||"text-view"===e||"search"===e}function S(e){return/^[\w.]+:id\/[\w.-]+$/i.test(e)}let $=100,A=new Set(["batch","replay"]);function y(t){let r;try{r=JSON.parse(t)}catch{throw new e("INVALID_ARGS","Batch steps must be valid JSON.")}if(!Array.isArray(r)||0===r.length)throw new e("INVALID_ARGS","Batch steps must be a non-empty JSON array.");return r}function v(t,r){if(!Array.isArray(t)||0===t.length)throw new e("INVALID_ARGS","batch requires a non-empty batchSteps array.");if(t.length>r)throw new e("INVALID_ARGS",`batch has ${t.length} steps; max allowed is ${r}.`);let i=[];for(let r=0;r<t.length;r+=1){let a=t[r];if(!a||"object"!=typeof a)throw new e("INVALID_ARGS",`Invalid batch step at index ${r}.`);let n="string"==typeof a.command?a.command.trim().toLowerCase():"";if(!n)throw new e("INVALID_ARGS",`Batch step ${r+1} requires command.`);if(A.has(n))throw new e("INVALID_ARGS",`Batch step ${r+1} cannot run ${n}.`);if(void 0!==a.positionals&&!Array.isArray(a.positionals))throw new e("INVALID_ARGS",`Batch step ${r+1} positionals must be an array.`);let s=a.positionals??[];if(s.some(e=>"string"!=typeof e))throw new e("INVALID_ARGS",`Batch step ${r+1} positionals must contain only strings.`);if(void 0!==a.flags&&("object"!=typeof a.flags||Array.isArray(a.flags)||!a.flags))throw new e("INVALID_ARGS",`Batch step ${r+1} flags must be an object.`);if(void 0!==a.runtime&&("object"!=typeof a.runtime||Array.isArray(a.runtime)||!a.runtime))throw new e("INVALID_ARGS",`Batch step ${r+1} runtime must be an object.`);i.push({command:n,positionals:s,flags:a.flags??{},runtime:a.runtime})}return i}export{TextDecoder,styleText}from"node:util";export{$ as DEFAULT_BATCH_MAX_STEPS,u as SESSION_SURFACES,c as SETTINGS_INVALID_ARGS_MESSAGE,o as SETTINGS_USAGE_OVERRIDE,h as buildSnapshotDisplayLines,g as displayLabel,p as extractReadableText,x as formatRole,w as formatSnapshotLine,y as parseBatchStepsJson,d as parseSessionSurface,v as validateAndNormalizeBatchSteps};
package/dist/src/bin.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import type { CliFlags } from './utils/command-schema.ts';
2
- import type { AgentDeviceClient } from './client.ts';
3
- export declare function tryRunClientBackedCommand(params: {
4
- command: string;
5
- positionals: string[];
6
- flags: CliFlags;
7
- client: AgentDeviceClient;
8
- }): Promise<boolean>;
package/dist/src/cli.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { sendToDaemon } from './daemon-client.ts';
2
- type CliDeps = {
3
- sendToDaemon: typeof sendToDaemon;
4
- };
5
- export declare function runCli(argv: string[], deps?: CliDeps): Promise<void>;
6
- export {};
@@ -1,64 +0,0 @@
1
- export type MetroPrepareKind = 'auto' | 'react-native' | 'expo';
2
- type ResolvedMetroKind = Exclude<MetroPrepareKind, 'auto'>;
3
- type EnvSource = NodeJS.ProcessEnv | Record<string, string | undefined>;
4
- export type MetroRuntimeHints = {
5
- platform?: 'ios' | 'android';
6
- metroHost?: string;
7
- metroPort?: number;
8
- bundleUrl?: string;
9
- launchUrl?: string;
10
- };
11
- export type MetroBridgeResult = {
12
- enabled: boolean;
13
- baseUrl: string;
14
- statusUrl: string;
15
- bundleUrl: string;
16
- iosRuntime: MetroRuntimeHints;
17
- androidRuntime: MetroRuntimeHints;
18
- upstream: {
19
- bundleUrl: string;
20
- host: string;
21
- port: number;
22
- statusUrl: string;
23
- };
24
- probe: {
25
- reachable: boolean;
26
- statusCode: number;
27
- latencyMs: number;
28
- detail: string;
29
- };
30
- };
31
- export type PrepareMetroRuntimeOptions = {
32
- projectRoot?: string;
33
- kind?: MetroPrepareKind;
34
- metroPort?: number | string;
35
- listenHost?: string;
36
- statusHost?: string;
37
- publicBaseUrl?: string;
38
- proxyBaseUrl?: string;
39
- proxyBearerToken?: string;
40
- startupTimeoutMs?: number | string;
41
- probeTimeoutMs?: number | string;
42
- reuseExisting?: boolean;
43
- installDependenciesIfNeeded?: boolean;
44
- runtimeFilePath?: string;
45
- logPath?: string;
46
- env?: EnvSource;
47
- };
48
- export type PrepareMetroRuntimeResult = {
49
- projectRoot: string;
50
- kind: ResolvedMetroKind;
51
- dependenciesInstalled: boolean;
52
- packageManager: string | null;
53
- started: boolean;
54
- reused: boolean;
55
- pid: number;
56
- logPath: string;
57
- statusUrl: string;
58
- runtimeFilePath: string | null;
59
- iosRuntime: MetroRuntimeHints;
60
- androidRuntime: MetroRuntimeHints;
61
- bridge: MetroBridgeResult | null;
62
- };
63
- export declare function prepareMetroRuntime(input?: PrepareMetroRuntimeOptions): Promise<PrepareMetroRuntimeResult>;
64
- export {};
@@ -1,20 +0,0 @@
1
- import type { CommandFlags } from './core/dispatch.ts';
2
- import type { DaemonRequest, SessionRuntimeHints } from './daemon/types.ts';
3
- import type { SnapshotNode } from './utils/snapshot.ts';
4
- import type { AgentDeviceDevice, AgentDeviceSession, AgentDeviceSessionDevice, AppDeployResult, AppInstallFromSourceResult, InternalRequestOptions, MaterializationReleaseResult, StartupPerfSample } from './client-types.ts';
5
- export declare const DEFAULT_SESSION_NAME = "default";
6
- export declare function normalizeDeployResult(data: Record<string, unknown>, session?: string): AppDeployResult;
7
- export declare function normalizeInstallFromSourceResult(data: Record<string, unknown>, session?: string): AppInstallFromSourceResult;
8
- export declare function normalizeMaterializationReleaseResult(data: Record<string, unknown>): MaterializationReleaseResult;
9
- export declare function normalizeDevice(value: unknown): AgentDeviceDevice;
10
- export declare function normalizeSession(value: unknown): AgentDeviceSession;
11
- export declare function normalizeRuntimeHints(value: unknown): SessionRuntimeHints | undefined;
12
- export declare function normalizeOpenDevice(value: Record<string, unknown>): AgentDeviceSessionDevice | undefined;
13
- export declare function normalizeStartupSample(value: unknown): StartupPerfSample | undefined;
14
- export declare function readSnapshotNodes(value: unknown): SnapshotNode[];
15
- export declare function buildFlags(options: InternalRequestOptions): CommandFlags;
16
- export declare function buildMeta(options: InternalRequestOptions): DaemonRequest['meta'];
17
- export declare function resolveSessionName(defaultSession: string | undefined, session: string | undefined): string;
18
- export declare function readRequiredString(record: Record<string, unknown>, key: string): string;
19
- export declare function readOptionalString(record: Record<string, unknown>, key: string): string | undefined;
20
- export declare function readNullableString(record: Record<string, unknown>, key: string): string | null | undefined;
@@ -1,20 +0,0 @@
1
- import type { AgentDeviceDevice, AgentDeviceIdentifiers, AgentDeviceSession, AgentDeviceSessionDevice, AppCloseResult, AppDeployResult, AppInstallFromSourceResult, AppOpenResult, CaptureSnapshotResult, EnsureSimulatorResult, SessionCloseResult } from './client-types.ts';
2
- import type { Platform } from './utils/device.ts';
3
- export declare function buildAppIdentifiers(params: {
4
- session?: string;
5
- bundleId?: string;
6
- packageName?: string;
7
- appId?: string;
8
- }): AgentDeviceIdentifiers;
9
- export declare function buildDeviceIdentifiers(platform: Platform, id: string, name: string): AgentDeviceIdentifiers;
10
- export declare function serializeSessionDevice(device: AgentDeviceSessionDevice, options?: {
11
- includeAndroidSerial?: boolean;
12
- }): Record<string, unknown>;
13
- export declare function serializeSessionListEntry(session: AgentDeviceSession): Record<string, unknown>;
14
- export declare function serializeDevice(device: AgentDeviceDevice): Record<string, unknown>;
15
- export declare function serializeEnsureSimulatorResult(result: EnsureSimulatorResult): Record<string, unknown>;
16
- export declare function serializeDeployResult(result: AppDeployResult): Record<string, unknown>;
17
- export declare function serializeInstallFromSourceResult(result: AppInstallFromSourceResult): Record<string, unknown>;
18
- export declare function serializeOpenResult(result: AppOpenResult): Record<string, unknown>;
19
- export declare function serializeCloseResult(result: SessionCloseResult | AppCloseResult): Record<string, unknown>;
20
- export declare function serializeSnapshotResult(result: CaptureSnapshotResult): Record<string, unknown>;