agent-device 0.20.9 → 0.21.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 (492) hide show
  1. package/README.md +2 -2
  2. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.9.apk → agent-device-android-ime-helper-0.21.0.apk} +0 -0
  3. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.0.apk.sha256 +1 -0
  4. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.9.manifest.json → agent-device-android-ime-helper-0.21.0.manifest.json} +4 -4
  5. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.0.apk +0 -0
  6. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.0.apk.sha256 +1 -0
  7. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.9.manifest.json → agent-device-android-snapshot-helper-0.21.0.manifest.json} +6 -6
  8. package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/AudioProbe.swift +35 -33
  9. package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/main.swift +6 -1
  10. package/apple/snapshot-bridge/LICENSE.idb +23 -0
  11. package/apple/snapshot-bridge/README.md +49 -0
  12. package/apple/snapshot-bridge/SnapshotBridge.m +280 -0
  13. package/apple/snapshot-bridge/SnapshotBridgeRuntime.h +33 -0
  14. package/apple/snapshot-bridge/SnapshotBridgeRuntime.m +382 -0
  15. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +58 -0
  16. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/project.pbxproj +19 -0
  17. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAlertVerification.swift +36 -0
  18. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerStringNormalization.swift +8 -0
  19. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +12 -1
  20. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +100 -6
  21. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTapPointPolicy.swift +2 -2
  22. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +21 -12
  23. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +21 -88
  24. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift +124 -0
  25. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +110 -107
  26. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +6 -14
  27. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +85 -114
  28. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +13 -6
  29. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +72 -175
  30. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +10 -11
  31. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+PrivateAXElementTypes.swift +12 -0
  32. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+PrivateAXPresentation.swift +78 -64
  33. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScreenRecorder.swift +17 -9
  34. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollGesture.swift +47 -13
  35. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +232 -438
  36. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotBackendCapabilities.swift +98 -0
  37. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +229 -168
  38. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotPresentationInvariant.swift +19 -0
  39. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotTiming.swift +110 -0
  40. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedCommitDeadline.swift +206 -0
  41. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedTextEntry.swift +147 -25
  42. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +21 -18
  43. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +24 -307
  44. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryFocus.swift +206 -0
  45. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryReadiness.swift +158 -0
  46. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextInputCandidatePolicy.swift +19 -0
  47. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +49 -16
  48. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Transport.swift +2 -11
  49. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TvRemote.swift +4 -19
  50. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +16 -20
  51. package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/RecordingExportSupport.swift +111 -0
  52. package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-overlay.swift +42 -81
  53. package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-trim.swift +35 -82
  54. package/dist/apple/snapshot-presentation/Package.swift +21 -0
  55. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotGeometry.swift +56 -0
  56. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotModels.swift +259 -0
  57. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentation.swift +153 -0
  58. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationFailure.swift +27 -0
  59. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationInvariant.swift +91 -0
  60. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationProjection.swift +161 -0
  61. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotScopePolicy.swift +53 -0
  62. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFold.swift +242 -0
  63. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFoldProjection.swift +97 -0
  64. package/dist/src/adapter.js +1 -0
  65. package/dist/src/adb-executor.js +2 -0
  66. package/dist/src/adb-failure.js +1 -0
  67. package/dist/src/adb-host.js +1 -0
  68. package/dist/src/adb.js +1 -0
  69. package/dist/src/agent-browser-lifecycle.js +1 -0
  70. package/dist/src/agent-browser-process-record.js +1 -0
  71. package/dist/src/agent-browser-provider.js +1 -0
  72. package/dist/src/agent-browser-tool.js +1 -1
  73. package/dist/src/agent-device-client.js +2 -2
  74. package/dist/src/ai-sdk.d.ts +61 -0
  75. package/dist/src/ai-sdk.js +1 -0
  76. package/dist/src/alert-contract.js +1 -0
  77. package/dist/src/alert-runtime.js +1 -0
  78. package/dist/src/android-adb.d.ts +27 -19
  79. package/dist/src/android-adb.js +1 -1
  80. package/dist/src/android-input-ownership.js +1 -0
  81. package/dist/src/android-system-chrome.js +1 -0
  82. package/dist/src/android.js +1 -1
  83. package/dist/src/api.js +11 -0
  84. package/dist/src/app-catalog.js +1 -0
  85. package/dist/src/app-deployment-resolution.js +2 -0
  86. package/dist/src/app-helpers.js +1 -1
  87. package/dist/src/app-inventory-contract.js +1 -0
  88. package/dist/src/app-inventory.js +1 -0
  89. package/dist/src/app-launch.js +2 -0
  90. package/dist/src/app-lifecycle-facade.js +1 -0
  91. package/dist/src/app-lifecycle.js +3 -6
  92. package/dist/src/app-lifecycle2.js +2 -2
  93. package/dist/src/app-lifecycle3.js +1 -0
  94. package/dist/src/app-log-files.js +1 -1
  95. package/dist/src/app-log-reconnect.js +1 -1
  96. package/dist/src/app-log-runtime.js +1 -4
  97. package/dist/src/app-log-runtime2.js +4 -0
  98. package/dist/src/app-parsers.js +4 -0
  99. package/dist/src/app-resolution-cache.js +1 -0
  100. package/dist/src/app-resolution-facade.js +1 -0
  101. package/dist/src/app-resolution.js +2 -2
  102. package/dist/src/app-state.js +1 -2
  103. package/dist/src/application-lifecycle-interaction.js +1 -0
  104. package/dist/src/application-lifecycle-runtime.js +1 -0
  105. package/dist/src/apps-simctl.js +1 -0
  106. package/dist/src/archive.js +4 -0
  107. package/dist/src/artifact-download.js +1 -0
  108. package/dist/src/artifacts.d.ts +6 -2
  109. package/dist/src/artifacts.js +1 -1
  110. package/dist/src/async-lifecycle.js +1 -0
  111. package/dist/src/audio-probe-result.js +1 -0
  112. package/dist/src/audio-probe-runtime.js +1 -0
  113. package/dist/src/audio-probe-support.js +1 -0
  114. package/dist/src/auth-session.js +1 -1
  115. package/dist/src/auth.js +1 -1
  116. package/dist/src/back-mode.js +1 -0
  117. package/dist/src/{url.js → base-url.js} +1 -1
  118. package/dist/src/boot-diagnostics.js +2 -2
  119. package/dist/src/byte-limit-stream.js +1 -1
  120. package/dist/src/capabilities.js +1 -0
  121. package/dist/src/capture.js +1 -0
  122. package/dist/src/catalog.js +1 -0
  123. package/dist/src/cli-command-aliases.js +1 -0
  124. package/dist/src/cli-config.js +1 -1
  125. package/dist/src/cli-help.js +77 -51
  126. package/dist/src/cli-output.js +1 -1
  127. package/dist/src/cli-runner.js +1 -1
  128. package/dist/src/cli.js +5 -7
  129. package/dist/src/click-button.js +1 -0
  130. package/dist/src/client-metro-companion.js +1 -0
  131. package/dist/src/client-metro.js +1 -1
  132. package/dist/src/client-types.d.ts +1606 -0
  133. package/dist/src/clipboard.js +1 -0
  134. package/dist/src/code-signature-cache.js +1 -0
  135. package/dist/src/code-signature.js +1 -0
  136. package/dist/src/color.js +1 -0
  137. package/dist/src/command-metadata.js +1 -1
  138. package/dist/src/command-schema.js +3 -3
  139. package/dist/src/command-surface.js +1 -1
  140. package/dist/src/command-tools.js +2 -0
  141. package/dist/src/command.js +1 -0
  142. package/dist/src/{selector-vocabulary.js → compatibility-policy.js} +1 -1
  143. package/dist/src/config.js +1 -1
  144. package/dist/src/config2.js +1 -0
  145. package/dist/src/connection-runtime.js +1 -1
  146. package/dist/src/connection.js +5 -5
  147. package/dist/src/contracts.d.ts +1 -1
  148. package/dist/src/contracts.js +1 -1
  149. package/dist/src/daemon-client-lifecycle.js +1 -0
  150. package/dist/src/daemon-process.js +1 -0
  151. package/dist/src/daemon-registration.js +1 -0
  152. package/dist/src/daemon-shutdown-report.js +1 -1
  153. package/dist/src/daemon.js +2 -2
  154. package/dist/src/debug-symbols-facade.js +5 -0
  155. package/dist/src/deploy-result-target.js +1 -0
  156. package/dist/src/device-claim-inspection.js +1 -1
  157. package/dist/src/device-claim-rule.js +1 -0
  158. package/dist/src/device-input-state.d.ts +190 -3
  159. package/dist/src/device-inventory-context.js +1 -0
  160. package/dist/src/device-isolation.js +1 -0
  161. package/dist/src/device-release.js +1 -0
  162. package/dist/src/device-rotation.js +1 -0
  163. package/dist/src/device-selection-resolver.js +1 -0
  164. package/dist/src/device-session.js +1 -0
  165. package/dist/src/device.js +1 -1
  166. package/dist/src/device2.js +3 -2
  167. package/dist/src/diagnostics.js +3 -0
  168. package/dist/src/diagnostics2.js +1 -0
  169. package/dist/src/dispatch-resolve.js +1 -0
  170. package/dist/src/doctor-facade.js +1 -0
  171. package/dist/src/doctor-output.js +1 -0
  172. package/dist/src/doctor.js +1 -0
  173. package/dist/src/doctor2.js +1 -0
  174. package/dist/src/doctor3.js +1 -0
  175. package/dist/src/durable-resource.js +1 -0
  176. package/dist/src/entities.js +1 -1
  177. package/dist/src/error.js +2 -0
  178. package/dist/src/exec.js +1 -0
  179. package/dist/src/file.js +1 -0
  180. package/dist/src/find.js +1 -1
  181. package/dist/src/finders.js +1 -1
  182. package/dist/src/format.js +2 -0
  183. package/dist/src/generic-settle.js +1 -1
  184. package/dist/src/generic.js +1 -1
  185. package/dist/src/gesture-admission.js +1 -0
  186. package/dist/src/gesture-plan-types.js +1 -0
  187. package/dist/src/gesture-plan.js +1 -0
  188. package/dist/src/gesture-runtime.js +1 -0
  189. package/dist/src/harmonyos.js +1 -1
  190. package/dist/src/hdc.js +1 -1
  191. package/dist/src/helper.js +2 -2
  192. package/dist/src/host-file.js +1 -0
  193. package/dist/src/human-control-contract.js +1 -0
  194. package/dist/src/human-control.js +1 -0
  195. package/dist/src/index.d.ts +2 -1578
  196. package/dist/src/index.js +1 -1
  197. package/dist/src/input-actions.js +1 -4
  198. package/dist/src/input-actions2.js +2 -1
  199. package/dist/src/install-artifact-facade.js +1 -0
  200. package/dist/src/install-source-network-transport.js +1 -0
  201. package/dist/src/install-source.d.ts +3 -10
  202. package/dist/src/install-source2.js +1 -1
  203. package/dist/src/interaction-positionals.js +1 -0
  204. package/dist/src/interaction-ref-policy.js +1 -0
  205. package/dist/src/interaction.js +1 -1
  206. package/dist/src/interaction2.js +1 -1
  207. package/dist/src/interactor-operation-catalog.js +1 -0
  208. package/dist/src/interactor-types.js +1 -0
  209. package/dist/src/interactor.js +6 -2
  210. package/dist/src/interactor2.js +1 -1
  211. package/dist/src/interactors.js +1 -1
  212. package/dist/src/internal/bin.d.ts +1 -1
  213. package/dist/src/internal/bin.js +1 -2
  214. package/dist/src/internal/companion-tunnel.d.ts +1 -1
  215. package/dist/src/internal/companion-tunnel.js +1 -1
  216. package/dist/src/internal/daemon.d.ts +1 -1
  217. package/dist/src/internal/daemon.js +2 -4
  218. package/dist/src/internal/png-worker.d.ts +4 -4
  219. package/dist/src/internal/png-worker.js +1 -1
  220. package/dist/src/internal/run-script-http-child.d.ts +4 -0
  221. package/dist/src/internal/run-script-http-child.js +1 -0
  222. package/dist/src/internal/update-check-entry.d.ts +1 -1
  223. package/dist/src/inventory.js +4 -4
  224. package/dist/src/inventory2.js +1 -1
  225. package/dist/src/inventory3.js +1 -1
  226. package/dist/src/inventory5.js +1 -1
  227. package/dist/src/inventory6.js +1 -1
  228. package/dist/src/ios-client.js +16 -0
  229. package/dist/src/ios-snapshot-acquisition.js +1 -0
  230. package/dist/src/ios-snapshot-adapter.js +1 -0
  231. package/dist/src/ios-snapshot-planning.js +1 -0
  232. package/dist/src/ios-snapshot-runtime.js +1 -0
  233. package/dist/src/json.js +1 -0
  234. package/dist/src/keyboard-actions.js +1 -0
  235. package/dist/src/launch-console.js +1 -0
  236. package/dist/src/lease-context.js +1 -1
  237. package/dist/src/lease-scope.js +1 -0
  238. package/dist/src/lease.js +1 -1
  239. package/dist/src/limrun-runtime-dependencies.js +1 -1
  240. package/dist/src/limrun.d.ts +1618 -7
  241. package/dist/src/limrun.js +1 -1
  242. package/dist/src/linux.js +1 -1
  243. package/dist/src/local-interactor-operation-set.js +1 -0
  244. package/dist/src/location-coordinates.js +1 -1
  245. package/dist/src/logcat.js +1 -1
  246. package/dist/src/macos-facade.js +1 -0
  247. package/dist/src/managed-device-scope.js +1 -0
  248. package/dist/src/mechanics.js +19 -0
  249. package/dist/src/metro.d.ts +4 -2
  250. package/dist/src/metro.js +1 -1
  251. package/dist/src/metro2.js +1 -1
  252. package/dist/src/mobile-snapshot-semantics.js +1 -0
  253. package/dist/src/multitouch-support.js +1 -0
  254. package/dist/src/numeric.js +1 -0
  255. package/dist/src/observability.js +1 -1
  256. package/dist/src/observation.js +2 -0
  257. package/dist/src/output-path.js +1 -1
  258. package/dist/src/owner-identity.js +3 -1
  259. package/dist/src/parameterized-recorded-fill.js +1 -0
  260. package/dist/src/parser.js +1 -1
  261. package/dist/src/perf-facade.js +2 -0
  262. package/dist/src/perf-runtime-operation-builder.js +1 -0
  263. package/dist/src/perf-runtime-plan.js +1 -0
  264. package/dist/src/perf-runtime.js +1 -0
  265. package/dist/src/perf.js +1 -4
  266. package/dist/src/physical-device-control.js +1 -1
  267. package/dist/src/physical-device-facade.js +1 -0
  268. package/dist/src/platform-request-scope.js +1 -0
  269. package/dist/src/platform-runtime-android-adb-host.js +1 -0
  270. package/dist/src/platform-runtime-android-mechanics.js +1 -0
  271. package/dist/src/platform-runtime-app-log-android-transport.js +1 -1
  272. package/dist/src/platform-runtime-app-log-process.js +1 -1
  273. package/dist/src/platform-runtime-apple-resources.js +1 -0
  274. package/dist/src/platform-runtime-host.js +1 -1
  275. package/dist/src/platform-runtime-managed-owner.js +1 -0
  276. package/dist/src/platform-runtime-network-web-transport.js +1 -1
  277. package/dist/src/platform-runtime-open-target.js +1 -1
  278. package/dist/src/platform-runtime-operation-host.js +4 -4
  279. package/dist/src/platform-runtime-runtime-hints.js +2 -2
  280. package/dist/src/platform-runtime-screen-recording-android-host.js +1 -1
  281. package/dist/src/platform-runtime-screen-recording-apple-runner-host.js +1 -1
  282. package/dist/src/platform-runtime-screen-recording-apple-runner-transport.js +1 -1
  283. package/dist/src/platform-runtime-screen-recording-apple-simulator-host.js +1 -1
  284. package/dist/src/platform-runtime-screen-recording-apple-transport.js +1 -1
  285. package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
  286. package/dist/src/platform-runtime-screen-recording-harmony-host.js +1 -1
  287. package/dist/src/platform-runtime-screen-recording-process-host.js +1 -0
  288. package/dist/src/platform-runtime-screen-recording-web-host.js +1 -1
  289. package/dist/src/platform-runtime-unavailable.js +1 -0
  290. package/dist/src/platform-runtime.js +1 -1
  291. package/dist/src/platform-runtime2.js +1 -1
  292. package/dist/src/plist.js +1 -1
  293. package/dist/src/png-worker-contract.js +1 -1
  294. package/dist/src/prepare-kind.js +1 -15
  295. package/dist/src/process-exit.js +1 -1
  296. package/dist/src/process.js +1 -0
  297. package/dist/src/provider-device-runtime.js +1 -0
  298. package/dist/src/provider-session-ownership.js +2 -0
  299. package/dist/src/provider-webdriver.js +1 -1
  300. package/dist/src/provider.js +1 -1
  301. package/dist/src/providers.js +1 -0
  302. package/dist/src/proxy.js +2 -2
  303. package/dist/src/react-native-overlay.js +1 -0
  304. package/dist/src/react-native.js +1 -1
  305. package/dist/src/record-runtime.js +1 -1
  306. package/dist/src/record-trace.js +1 -1
  307. package/dist/src/rect-center.js +1 -0
  308. package/dist/src/register-builtins.js +1 -0
  309. package/dist/src/registry.js +39 -28
  310. package/dist/src/remote-config2.js +1 -1
  311. package/dist/src/replay-divergence.js +2 -0
  312. package/dist/src/replay.js +2 -2
  313. package/dist/src/reporting.js +8 -8
  314. package/dist/src/request-admission.js +1 -0
  315. package/dist/src/request-cancel.js +1 -0
  316. package/dist/src/request-cancellation.js +1 -0
  317. package/dist/src/request-progress-protocol.js +1 -0
  318. package/dist/src/request-providers.js +1 -0
  319. package/dist/src/request-runtime-binding.js +1 -0
  320. package/dist/src/request.js +1 -0
  321. package/dist/src/result-serialization.js +1 -0
  322. package/dist/src/retry.js +1 -0
  323. package/dist/src/rolldown-runtime.js +1 -1
  324. package/dist/src/runner-cache-metadata.js +2 -0
  325. package/dist/src/runner-client.js +1 -1
  326. package/dist/src/runner-disposal.js +1 -1
  327. package/dist/src/runner-operations-facade.js +1 -0
  328. package/dist/src/runner-owner-facade.js +1 -0
  329. package/dist/src/runner-owner-state.js +1 -0
  330. package/dist/src/runner-presentation.js +1 -0
  331. package/dist/src/runner-selector-query.js +1 -0
  332. package/dist/src/runner.js +1 -0
  333. package/dist/src/{runtime-transport.js → runtime-transport-hints.js} +1 -1
  334. package/dist/src/runtime.js +3 -3
  335. package/dist/src/runtime2.js +4 -4
  336. package/dist/src/runtime3.js +1 -1
  337. package/dist/src/runtime4.js +4 -3
  338. package/dist/src/runtime5.js +1 -1
  339. package/dist/src/runtime6.js +1 -1
  340. package/dist/src/runtime7.js +1 -1
  341. package/dist/src/runtime8.js +1 -1
  342. package/dist/src/runtime9.js +1 -1
  343. package/dist/src/scoped-provider.js +1 -1
  344. package/dist/src/screen-recording-completion.js +1 -0
  345. package/dist/src/screen-recording-live-handle.js +1 -0
  346. package/dist/src/screen-recording-options.js +1 -0
  347. package/dist/src/screen-recording-resource-recovery.js +1 -0
  348. package/dist/src/screen-recording-runtime.js +1 -0
  349. package/dist/src/screenshot-density.js +1 -1
  350. package/dist/src/screenshot-result.js +1 -6
  351. package/dist/src/screenshot-runtime.js +1 -0
  352. package/dist/src/screenshot.js +1 -1
  353. package/dist/src/screenshot2.js +1 -0
  354. package/dist/src/screenshot3.js +5 -0
  355. package/dist/src/script.js +1 -0
  356. package/dist/src/scroll-command.js +1 -0
  357. package/dist/src/scroll-gesture.js +1 -0
  358. package/dist/src/scroll-indicator.js +1 -0
  359. package/dist/src/sdk-batch-runner.d.ts +23 -6
  360. package/dist/src/sdk-batch-runner.js +2 -3
  361. package/dist/src/sdk-batch.js +2 -0
  362. package/dist/src/sdk-contracts.d.ts +222 -99
  363. package/dist/src/sdk-contracts.js +2 -2
  364. package/dist/src/sdk-device.js +1 -1
  365. package/dist/src/sdk-finders.d.ts +1 -1
  366. package/dist/src/sdk-finders.js +1 -1
  367. package/dist/src/sdk-io.js +1 -1
  368. package/dist/src/sdk-remote-config.d.ts +1 -1
  369. package/dist/src/sdk-remote-config.js +1 -1
  370. package/dist/src/sdk-selectors.d.ts +539 -199
  371. package/dist/src/sdk-selectors.js +1 -1
  372. package/dist/src/selection.js +1 -0
  373. package/dist/src/selector-runtime.js +1 -1
  374. package/dist/src/selectors.js +1 -1
  375. package/dist/src/semantic-index.js +1 -0
  376. package/dist/src/server.js +10 -3
  377. package/dist/src/session-allocation.js +1 -0
  378. package/dist/src/session-artifact-paths.js +1 -0
  379. package/dist/src/session-paths.js +1 -0
  380. package/dist/src/session-repair-tombstone.js +1 -0
  381. package/dist/src/session-routing.js +1 -0
  382. package/dist/src/session-runtime-admission.js +1 -0
  383. package/dist/src/session-snapshot.js +1 -0
  384. package/dist/src/session-store.js +4 -0
  385. package/dist/src/session-target-evidence.js +1 -1
  386. package/dist/src/session2.js +5 -28
  387. package/dist/src/settings.js +1 -0
  388. package/dist/src/shared.js +2 -2
  389. package/dist/src/simctl-facade.js +1 -0
  390. package/dist/src/simctl.js +1 -1
  391. package/dist/src/simulator-facade.js +1 -0
  392. package/dist/src/simulator.js +1 -1
  393. package/dist/src/snapshot-capture-annotations.js +1 -0
  394. package/dist/src/snapshot-desktop-projection.js +1 -0
  395. package/dist/src/snapshot-diagnostics.js +1 -0
  396. package/dist/src/snapshot-process.js +1 -0
  397. package/dist/src/snapshot-quality-backend-capabilities.js +1 -0
  398. package/dist/src/snapshot-quality-verdict.js +1 -0
  399. package/dist/src/snapshot-runtime-binding.js +1 -0
  400. package/dist/src/snapshot-runtime.js +1 -1
  401. package/dist/src/snapshot-scope.js +1 -0
  402. package/dist/src/snapshot-state.js +1 -0
  403. package/dist/src/snapshot.js +1 -8
  404. package/dist/src/snapshot2.js +1 -1
  405. package/dist/src/snapshot3.js +1 -1
  406. package/dist/src/snapshot4.js +1 -0
  407. package/dist/src/src.js +1 -1
  408. package/dist/src/src2.js +1 -1
  409. package/dist/src/src3.js +1 -2
  410. package/dist/src/src4.js +1 -0
  411. package/dist/src/src5.js +1 -0
  412. package/dist/src/src6.js +1 -0
  413. package/dist/src/src7.js +2 -0
  414. package/dist/src/src8.js +115 -0
  415. package/dist/src/startup-recovery-fence.js +1 -0
  416. package/dist/src/status-markers.js +1 -0
  417. package/dist/src/string-enum.js +1 -1
  418. package/dist/src/success-text.js +1 -0
  419. package/dist/src/surface-snapshot.js +1 -0
  420. package/dist/src/surface-snapshot2.js +1 -0
  421. package/dist/src/takeover.js +5 -0
  422. package/dist/src/tool-provider-facade.js +1 -0
  423. package/dist/src/tool-provider.js +4 -3
  424. package/dist/src/tool-provider2.js +1 -1
  425. package/dist/src/tool-provider3.js +1 -0
  426. package/dist/src/toolchain-probe.js +2 -0
  427. package/dist/src/touch-runtime.js +1 -0
  428. package/dist/src/transport.js +3 -0
  429. package/dist/src/tree.js +1 -0
  430. package/dist/src/ttl-memo.js +1 -0
  431. package/dist/src/tv-remote.js +1 -0
  432. package/dist/src/type-text-runtime.js +1 -0
  433. package/dist/src/undici.js +99 -0
  434. package/dist/src/update-check.js +1 -1
  435. package/dist/src/verified-file.js +1 -1
  436. package/dist/src/version.js +1 -1
  437. package/dist/src/video.js +2 -2
  438. package/dist/src/web.js +2 -1
  439. package/dist/src/web2.js +1 -0
  440. package/dist/src/webdriver-ios-snapshot.js +1 -0
  441. package/dist/src/webdriver-source.js +1 -0
  442. package/linux/atspi-dump.py +54 -9
  443. package/package.json +73 -38
  444. package/server.json +9 -3
  445. package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.9.apk.sha256 +0 -1
  446. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.9.apk +0 -0
  447. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.9.apk.sha256 +0 -1
  448. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CoordinateTextEntryTests.swift +0 -4
  449. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+FlatSnapshotFiltering.swift +0 -75
  450. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+LifecycleCacheTests.swift +0 -6
  451. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+RecordingTests.swift +0 -4
  452. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SelectorMatchPolicyTests.swift +0 -4
  453. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotTraversalIdentityTests.swift +0 -4
  454. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryPolicyTests.swift +0 -4
  455. package/dist/src/appearance.js +0 -1
  456. package/dist/src/apps.js +0 -5
  457. package/dist/src/audio-probe.js +0 -1
  458. package/dist/src/cancel.js +0 -1
  459. package/dist/src/cli-grammar.js +0 -1
  460. package/dist/src/command-catalog.js +0 -1
  461. package/dist/src/debug-symbols.js +0 -5
  462. package/dist/src/device-input-state.js +0 -2
  463. package/dist/src/device-ready.js +0 -1
  464. package/dist/src/dispatch.js +0 -1
  465. package/dist/src/handler-utils.js +0 -1
  466. package/dist/src/helper-package-install.js +0 -1
  467. package/dist/src/host-process.js +0 -3
  468. package/dist/src/ime-lifecycle.js +0 -2
  469. package/dist/src/ime-recovery-marker.js +0 -1
  470. package/dist/src/input-actions3.js +0 -1
  471. package/dist/src/install-artifact.js +0 -1
  472. package/dist/src/install-artifact2.js +0 -1
  473. package/dist/src/interaction-common.js +0 -1
  474. package/dist/src/interaction-runtime.js +0 -1
  475. package/dist/src/interaction-snapshot.js +0 -1
  476. package/dist/src/manifest.js +0 -1
  477. package/dist/src/method-scope.js +0 -1
  478. package/dist/src/png-resize.js +0 -1
  479. package/dist/src/process-lock.js +0 -1
  480. package/dist/src/runner-lease.js +0 -1
  481. package/dist/src/runner-sequence.js +0 -1
  482. package/dist/src/screenshot-geometry.js +0 -1
  483. package/dist/src/sdk-android-adb.d.ts +0 -245
  484. package/dist/src/sdk-android-adb.js +0 -4
  485. package/dist/src/sdk.js +0 -1
  486. package/dist/src/setting-state.js +0 -1
  487. package/dist/src/shell-quote.js +0 -1
  488. package/dist/src/snapshot-session.js +0 -1
  489. package/dist/src/timing-safe-equal.js +0 -1
  490. package/dist/src/unsupported-interactor.js +0 -1
  491. package/dist/src/verdict.js +0 -1
  492. /package/dist/src/{recording-telemetry.js → telemetry.js} +0 -0
@@ -1,3 +1,2 @@
1
- import{_ as e,a as t,i as n,u as r,v as i}from"./sdk-contracts.js";import{T as a,c as o,d as s,l as c,n as l,s as u,x as d}from"./sdk-device.js";function f(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ee(t,n,r,i){let a=r(t[n]);if(a===void 0)throw new e(`COMMAND_FAILED`,i,{response:t});return a}function te(e,t,n){return n(e[t])}function ne(e,t,n){let r=e[t];return r===null?null:n(r)}function re(e,t){return ee(e,t,fe,`Daemon response is missing "${t}".`)}function ie(e,t){return te(e,t,fe)}function ae(e,t){return ne(e,t,fe)}function oe(e,t){return ee(e,t,pe,`Daemon response is missing numeric "${t}".`)}function se(e,t){return ee(e,t,me,`Daemon response has invalid "${t}".`)}function ce(e,t){return ee(e,t,he,`Daemon response has invalid "${t}".`)}function le(e,t){return te(e,t,ge)??`mobile`}function ue(e){if(!m(e))return;let t=p(e,`x`),n=p(e,`y`),r=p(e,`width`),i=p(e,`height`);if(!(t===void 0||n===void 0||r===void 0||i===void 0))return{x:t,y:n,width:r,height:i}}function de(e){if(!m(e))return;let t=p(e,`x`),n=p(e,`y`);if(!(t===void 0||n===void 0))return{x:t,y:n}}function p(e,t){let n=e[t];return typeof n==`number`?n:void 0}function fe(e){return typeof e==`string`&&e.length>0?e:void 0}function pe(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function me(e){return e===`apple`?`ios`:e===`ios`||e===`macos`||e===`android`||e===`harmonyos`||e===`vega`||e===`linux`||e===`web`?e:void 0}function he(e){return e===`simulator`||e===`emulator`||e===`device`?e:void 0}function ge(e){return e===`tv`||e===`mobile`||e===`desktop`?e:void 0}function _e(t){if(!m(t))throw new e(`COMMAND_FAILED`,`Daemon returned an unexpected response shape.`,{value:t});return t}function m(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ve(e){return m(e)?e:void 0}function ye(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}function be(e){return e.split(`
2
- `).map(e=>e.trim()).filter(e=>e.length>0)}function h(e,t){return{ok:!1,code:`INVALID_ARGS`,message:e,...t?{hint:t}:{}}}function g(e){return!!(e&&[e.x,e.y,e.width,e.height].every(Number.isFinite)&&e.width>0&&e.height>0)}function xe(e,t){return t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height}function Se(e){return e.width*e.height}function Ce(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function _(e){let t=null,n=-1;for(let r of e){let e=r.width*r.height;e>n&&(t=r,n=e)}return t}function we(e,t){return Te(e.x,e.x+e.width,t.x,t.x+t.width)&&Te(e.y,e.y+e.height,t.y,t.y+t.height)}function Te(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function Ee(e){let t=`${e??``}`.toLowerCase();return t.includes(`scroll`)||t.includes(`recyclerview`)||t.includes(`listview`)||t.includes(`gridview`)||t.includes(`collectionview`)||t===`table`}function De(e){return Ee(e.type)?!0:`${e.role??``} ${e.subrole??``}`.toLowerCase().includes(`scroll`)}function v(e){return new Map(e.map(e=>[e.index,e]))}function Oe(e,t,n,r){let i=t,a=new Set;for(;typeof i.parentIndex==`number`&&!a.has(i.index);){if(a.add(i.index),i=n.get(i.parentIndex)??e[i.parentIndex],!i)return null;let t=r(i);if(t!==null)return t}return null}function ke(e,t,n){return Oe(e,t,v(e),e=>n(e)?e:null)}function y(e){let t=e.trim().replace(/XCUIElementType/gi,``).replace(/^AX/,``).toLowerCase(),n=Math.max(t.lastIndexOf(`.`),t.lastIndexOf(`/`));return n!==-1&&(t=t.slice(n+1)),t}function Ae(e,t){let n=y(e);return n?t===`android`?n.includes(`edittext`)||n.includes(`autocompletetextview`):n.includes(`textfield`)||n.includes(`securetextfield`)||n.includes(`searchfield`)||n.includes(`textview`)||n.includes(`textarea`)||n===`search`:!0}function je(e){let t=e.trim();return!(!t||/^(true|false)$/i.test(t)||/^\d+$/.test(t))}function Me(e){return[e.label,e.value,e.identifier].map(e=>typeof e==`string`?e.trim():``).filter(e=>e.length>0)[0]??``}function Ne(e){let t=[e.type,e.role,e.subrole].map(e=>y(e??``)).join(` `);return t.includes(`application`)||t.includes(`window`)}function Pe(e,t){let n=r(t),i=e.flatMap(e=>Fe(e.rect)?[{node:e,rect:e.rect}]:[]),a=i.filter(e=>Ne(e.node)).map(e=>e.rect),o=e=>Ce(e,n.x,n.y);return _(a.filter(o))??_(a)??_(i.map(e=>e.rect).filter(o))}function Fe(e){return e?Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.width)&&Number.isFinite(e.height):!1}function Ie(e,t,n=v(t)){if(!e.rect)return!0;let r=ze(e,t,n);return r?we(e.rect,r):!0}function Le(e,t,n=v(t)){if(!e.rect)return!0;if(!Ie(e,t,n))return!1;let r=Pe(t,e.rect);return Re(e.rect,r)}function Re(e,t){return!t||t.width<=0||t.height<=0?!0:Ce(t,e.x+e.width/2,e.y+e.height/2)}function ze(e,t,n=v(t)){return Be(e,n,e=>!!e.rect)?.rect||Pe(t,e.rect??{x:0,y:0,width:0,height:0})}function Be(e,t,n=()=>!0){let r=typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0,i=new Set;for(;r&&!i.has(r.index);){if(i.add(r.index),n(r)&&De(r))return r;r=typeof r.parentIndex==`number`?t.get(r.parentIndex):void 0}return null}function Ve(e,t){if(t===`android`&&e.visibleToUser===!1)return!1;let n=y(e.type??``);return n.includes(`application`)||n.includes(`window`)||n.includes(`scrollview`)||n.includes(`tableview`)||n.includes(`collectionview`)||n===`table`||n===`list`||n===`listview`?!1:t===`android`?e.hittable===!0&&g(e.rect):e.hittable===!0||g(e.rect)}function b(e){return e.hittable===!0?!0:e.rect?e.rect.width>0&&e.rect.height>0:!1}function He(e,t){return Ae(e.type??``,t)&&e.enabled!==!1}const Ue=new Set([`id`,`role`,`text`,`label`,`value`,`appname`,`windowtitle`]),We=new Set([`visible`,`hidden`,`editable`,`selected`,`focused`,`enabled`,`hittable`]),x=new Set([...Ue,...We]),Ge=[...x],Ke=new Set(`button.imagebutton.link.cell.statictext.checkedtextview.textfield.textbox.edittext.textarea.switch.slider.image.imageview.webview.framelayout.linearlayout.relativelayout.constraintlayout.viewgroup.view.listview.recyclerview.collectionview.list.searchfield.segmentedcontrol.group.window.checkbox.radio.menuitem.toolbar.scrollarea.scrollview.nestedscrollview.table.application.navigationbar.tabbar.tab.alert.dialog.header`.split(`.`));function qe(e){return Ke.has(e.trim().toLowerCase())}const Je=new Map([[`"`,`"`],[`'`,`'`],[`\\`,`\\`],[`/`,`/`],[`b`,`\b`],[`f`,`\f`],[`n`,`
3
- `],[`r`,`\r`],[`t`,` `]]);function Ye(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);let r=tt(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);return{raw:n,selectors:r.map(e=>$e(e))}}function S(e){try{return Ye(e)}catch{return null}}function Xe(e){let t=e.trim();if(!t)return!1;if(t===`||`)return!0;let n=t.indexOf(`=`);if(n!==-1){let e=t.slice(0,n).trim().toLowerCase();return x.has(e)}return x.has(t.toLowerCase())}function Ze(e){let t=e.trim(),n=t.indexOf(`=`);if(n===-1)return null;let r=t.slice(0,n).trim().toLowerCase();if(!r||x.has(r))return null;let i=t.slice(n+1).trim();if(!i)return null;let a=it(i).trim();return a?{key:r,value:a}:null}function Qe(e,t={}){if(e.length===0)return null;let n=t.preferTrailingValue??!1,r=0,i=[];for(;r<e.length;){let t=e[r];if(t===void 0||!Xe(t))break;r+=1;let n=e.slice(0,r).join(` `).trim();n&&S(n)&&i.push(r)}if(i.length===0)return null;let a=i.at(-1);if(a===void 0)return null;let o=a;if(n)for(let t=i.length-1;t>=0;--t){let n=i[t];if(n!==void 0&&n<e.length){o=n;break}}let s=e.slice(0,o).join(` `).trim();return s?{selectorExpression:s,rest:e.slice(o)}:null}function $e(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector segment cannot be empty`);let r=nt(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Invalid selector segment: ${t}`);return{raw:n,terms:r.map(et)}}function et(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Empty selector term`);let r=n.indexOf(`=`);if(r===-1){let r=n.toLowerCase();if(!We.has(r))throw new e(`INVALID_ARGS`,`Invalid selector term "${t}", expected key=value`);return{key:r,value:!0}}let i=n.slice(0,r).trim().toLowerCase(),a=n.slice(r+1).trim();if(!x.has(i))throw new e(`INVALID_ARGS`,`Unknown selector key: ${i}`);if(!a)throw new e(`INVALID_ARGS`,`Missing selector value for key: ${i}`);if(We.has(i)){let t=st(a);if(t===null)throw new e(`INVALID_ARGS`,`Invalid boolean value for ${i}: ${a}`);return{key:i,value:t}}return{key:i,value:it(a)}}function tt(t){let n=[],r=``,i=null;for(let a=0;a<t.length;a+=1){let o=t[a];if((o===`"`||o===`'`)&&!ct(t,a)){i=rt(i,o),r+=o;continue}if(!i&&o===`|`&&t[a+1]===`|`){let i=r.trim();if(!i)throw new e(`INVALID_ARGS`,`Invalid selector fallback expression: ${t}`);n.push(i),r=``,a+=1;continue}r+=o}let a=r.trim();if(!a)throw new e(`INVALID_ARGS`,`Invalid selector fallback expression: ${t}`);return n.push(a),n}function nt(t){let n=[],r=``,i=null;for(let e=0;e<t.length;e+=1){let a=t.charAt(e);if((a===`"`||a===`'`)&&!ct(t,e)){i=rt(i,a),r+=a;continue}if(!i&&/\s/.test(a)){r.trim()&&n.push(r.trim()),r=``;continue}r+=a}if(i)throw new e(`INVALID_ARGS`,`Unclosed quote in selector: ${t}`);return r.trim()&&n.push(r.trim()),n}function rt(e,t){return e?e===t?null:e:t}function it(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?at(t.slice(1,-1)):t}function at(e){let t=``,n=0;for(;n<e.length;){let r=e.charAt(n);if(r!==`\\`){t+=r,n+=1;continue}let i=e.charAt(n+1);if(!i){t+=r,n+=1;continue}let a=ot(i);if(a!==null){t+=a,n+=2;continue}if(i===`u`){let r=e.slice(n+2,n+6);if(/^[0-9a-fA-F]{4}$/.test(r)){t+=String.fromCharCode(Number.parseInt(r,16)),n+=6;continue}}t+=r,n+=1}return t}function ot(e){return Je.get(e)??null}function st(e){let t=it(e).toLowerCase();return t===`true`?!0:t===`false`?!1:null}function ct(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function lt(e){return[`visible`,`hidden`,`exists`,`editable`,`selected`,`focused`,`text`].includes(e)}function ut(e){let t=e.toLowerCase();return lt(t)?{ok:!0,predicate:t}:h(`is requires predicate: visible|hidden|exists|editable|selected|focused|text`,dt)}const dt=`Use "is <predicate> <selector>" or "is <selector> <predicate>". visible|hidden|editable|selected|focused double as selector keys: a bare predicate token after the selector is read as the predicate, so write key=true (e.g. visible=true) inside the selector to use it as a filter instead.`;function ft(e){if(lt((e[0]??``).toLowerCase()))return e;for(let t=1;t<e.length;t+=1){let n=(e[t]??``).toLowerCase();if(lt(n)&&S(e.slice(0,t).join(` `)))return[n,...e.slice(0,t),...e.slice(t+1)]}return e}function pt(e){let{predicate:t,node:n,nodes:r,expectedText:i,platform:a}=e,o=Me(n),s=He(n,a),c=n.selected===!0,l=n.focused===!0,u=t===`text`?b(n):mt(n,r,a),d=!1;switch(t){case`visible`:d=u;break;case`hidden`:d=!u;break;case`editable`:d=s;break;case`selected`:d=c;break;case`focused`:d=l;break;case`text`:d=o===(i??``);break}let f=t===`text`?`expected="${i??``}" actual="${o}"`:`actual=${JSON.stringify({visible:u,editable:s,selected:c,focused:l})}`;return{pass:d,actualText:o,details:f}}function mt(e,t,n){if(n===`android`&&e.visibleToUser===!1)return!1;if(g(e.rect))return ht(e,t);if(e.rect)return!1;if(n!==`android`&&e.hittable===!0)return!0;let r=gt(e,t,n);return r?g(r.rect)?ht(r,t):n!==`android`&&r.hittable===!0:!1}function ht(e,t){return Ie(e,t)}function gt(e,t,n){return Oe(t,e,v(t),e=>Ve(e,n)?e:null)}function _t(e){let t=ft(e),n=t[0]??``;return{predicate:n,split:Qe(t.slice(1),{preferTrailingValue:n===`text`})}}const vt=`is requires a selector expression`,yt=`is text requires expected text value`;function bt(e){let{predicate:t,split:n}=_t([...e]),r=ut(t);if(!r.ok)return r;if(!n)return h(vt);let i=n.rest.join(` `).trim();return r.predicate===`text`&&!i?h(yt):r.predicate!==`text`&&n.rest.length>0?h(`is ${r.predicate} does not accept trailing values`):{ok:!0,predicate:r.predicate,selectorExpression:n.selectorExpression,expectedText:i}}function xt(e){return e===`text`||e===`attrs`?{ok:!0,format:e}:h(`get only supports text or attrs`)}function St(e){let t=e[0];if(t?.startsWith(`@`)){let n=e.slice(1).join(` `).trim();return{ok:!0,ref:t,...n?{label:n}:{}}}let n=e.join(` `).trim();return n?{ok:!0,selector:n}:h(`get requires @ref or selector expression`)}function Ct(e){return e?{ok:!0,text:e}:h(`wait requires text`)}function wt(t,n,r={}){let i=t[n];if(i===void 0)return;if(!Number.isInteger(i))throw new e(`INVALID_ARGS`,`Expected ${n} to be an integer.`);let a=i;if(r.min!==void 0&&a<r.min)throw new e(`INVALID_ARGS`,`Expected ${n} to be at least ${r.min}.`);if(r.max!==void 0&&a>r.max)throw new e(`INVALID_ARGS`,`Expected ${n} to be at most ${r.max}.`);return a}function Tt(t,n,r={}){let i=t[n];if(i!==void 0){if(typeof i!=`number`||!Number.isFinite(i))throw new e(`INVALID_ARGS`,`Expected ${n} to be a finite number.`);if(r.min!==void 0&&i<r.min)throw new e(`INVALID_ARGS`,`Expected ${n} to be at least ${r.min}.`);if(r.max!==void 0&&i>r.max)throw new e(`INVALID_ARGS`,`Expected ${n} to be at most ${r.max}.`);return i}}const Et=/^#\s*agent-device:target-v(\d+)(?:\s+(\S.*))?$/,Dt=/^#\s*agent-device:targets-v(\d+)(?:\s+(\S.*))?$/,Ot=4096;function kt(e){return e.normalize(`NFC`)}function At(e){if(e===void 0)return;let t=kt(e);return t.length>0?t:void 0}function jt(e){return kt(e)}function Mt(e){if(e===void 0)return;let t=kt(e).trim().replace(/\s+/g,` `);return t.length>0?t:void 0}function C(e){return Buffer.byteLength(e,`utf8`)}function Nt(e,t){if(C(e)<=t)return e;let n=e.length;for(;n>0&&C(e.slice(0,n))>t;)--n;if(n>0){let t=e.charCodeAt(n-1);t>=55296&&t<=56319&&--n}return e.slice(0,n)}function Pt(e){let t={};return e.id!==void 0&&(t.id=e.id),t.role=e.role,e.label!==void 0&&(t.label=e.label),t.ancestry=e.ancestry.map(Ft),t.sibling=e.sibling,t.viewportOrder=e.viewportOrder,e.scrollRegion&&(t.scrollRegion=It(e.scrollRegion)),e.rect&&(t.rect=Lt(e.rect)),t.verification=e.verification,t}function Ft(e){let t={role:e.role};return e.label!==void 0&&(t.label=e.label),t}function It(e){let t={role:e.role};return e.id!==void 0&&(t.id=e.id),e.label!==void 0&&(t.label=e.label),t}function Lt(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}function Rt(e){return JSON.stringify(Pt(e))}function zt(e){return`# agent-device:target-v1 ${Rt(e)}`}function Bt(e){return JSON.stringify({source:Pt(e.source),destination:Pt(e.destination)})}function Vt(e){return`# agent-device:targets-v1 ${Bt(e)}`}function Ht(e){let t=e.trim(),n=Dt.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:Ut((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function Ut(t){if(C(t)>8320)throw new e(`INVALID_ARGS`,`targets-v1 annotation exceeds the 8320-byte payload cap.`);let n;try{n=JSON.parse(t)}catch{throw new e(`INVALID_ARGS`,`targets-v1 annotation is not valid JSON.`)}if(typeof n!=`object`||!n||Array.isArray(n))throw new e(`INVALID_ARGS`,`targets-v1 annotation must be a JSON object.`);let r=n;if(r.source===void 0||r.destination===void 0)throw new e(`INVALID_ARGS`,`targets-v1 annotation requires source and destination evidence.`);return{source:Gt(JSON.stringify(r.source)),destination:Gt(JSON.stringify(r.destination))}}function Wt(e){let t=e.trim();if(!t.startsWith(`#`))return{kind:`none`};let n=Et.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:Gt((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function Gt(t){if(C(t)>4096)throw new e(`INVALID_ARGS`,`target-v1 annotation exceeds the ${Ot}-byte payload cap.`);let n;try{n=JSON.parse(t)}catch{throw new e(`INVALID_ARGS`,`target-v1 annotation is not valid JSON.`)}if(typeof n!=`object`||!n||Array.isArray(n))throw new e(`INVALID_ARGS`,`target-v1 annotation must be a JSON object.`);let r=n,i=Kt(r.role,`role`),a=qt(r.id,`id`),o=Jt(r.label,`label`),s=Xt(r.ancestry),c=Qt(r.sibling,`sibling`,0),l=Qt(r.viewportOrder,`viewportOrder`,0),u=$t(r.scrollRegion),d=en(r.rect),f=nn(r.verification);return{...a===void 0?{}:{id:a},role:i,...o===void 0?{}:{label:o},ancestry:s,sibling:c,viewportOrder:l,...u?{scrollRegion:u}:{},...d?{rect:d}:{},verification:f}}function Kt(t,n){if(t===void 0)throw new e(`INVALID_ARGS`,`target-v1 "${n}" is required.`);if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);return Yt(jt(t),n)}function qt(t,n){if(t===void 0)return;if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);let r=At(t);return r===void 0?void 0:Yt(r,n)}function Jt(t,n){if(t===void 0)return;if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);let r=Mt(t);return r===void 0?void 0:Yt(r,n)}function Yt(t,n){if(C(t)>256)throw new e(`INVALID_ARGS`,`target-v1 "${n}" exceeds the 256-byte field cap.`);return t}function Xt(t){if(t===void 0)return[];if(!Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "ancestry" must be an array.`);if(t.length>8)throw new e(`INVALID_ARGS`,`target-v1 "ancestry" exceeds the 8-entry cap.`);return t.map((e,t)=>Zt(e,t))}function Zt(t,n){if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "ancestry[${n}]" must be an object.`);let r=t,i=Kt(r.role,`ancestry[${n}].role`),a=Jt(r.label,`ancestry[${n}].label`);return{role:i,...a===void 0?{}:{label:a}}}function Qt(t,n,r){if(t===void 0)return r;if(typeof t!=`number`||!Number.isSafeInteger(t)||t<0)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a non-negative integer.`);return t}function $t(t){if(t===void 0)return;if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "scrollRegion" must be an object.`);let n=t,r=Kt(n.role,`scrollRegion.role`),i=qt(n.id,`id`),a=Jt(n.label,`scrollRegion.label`);return{role:r,...i===void 0?{}:{id:i},...a===void 0?{}:{label:a}}}function en(t){if(t===void 0)return;if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "rect" must be an object.`);let n=t;return{x:tn(n.x,`rect.x`),y:tn(n.y,`rect.y`),width:tn(n.width,`rect.width`),height:tn(n.height,`rect.height`)}}function tn(t,n){if(typeof t!=`number`||!Number.isFinite(t))throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a finite number.`);return t}function nn(t){if(t===`verified`||t===`unverifiable`)return t;throw new e(`INVALID_ARGS`,`target-v1 "verification" must be "verified" or "unverifiable".`)}function rn(e){let t=jt(y(e.type??``)),n=At(e.identifier),r=Mt(e.label);return{...n===void 0?{}:{id:Nt(n,256)},role:Nt(t,256),...r===void 0?{}:{label:Nt(r,256)}}}function an(e,t){return e.id===t.id&&e.role===t.role&&e.label===t.label}function on(e,t){let n=0;for(let r of e)rn(r).id===t&&(n+=1);return n}function sn(e,t){if(e.id===void 0||on(t,e.id)<=1)return e;let{role:n,label:r}=e;return{role:n,...r===void 0?{}:{label:r}}}function cn(e,t){let n=0;for(let r of e)if(r.parentIndex===t.parentIndex){if(r.index===t.index)return n;n+=1}return 0}function ln(e,t){return{documentOrder:e.index,sibling:cn(t,e)}}function un(e,t){return e.documentOrder===t.documentOrder&&e.sibling===t.sibling}function dn(e){return{...e.id===void 0?{}:{id:e.id},role:e.role,...e.label===void 0?{}:{label:e.label}}}function fn(e,t){return t.id===void 0?e.role===t.role&&e.label===t.label:e.id===t.id}function pn(e,t){if(e.length<t.length)return!1;for(let[n,r]of t.entries()){let t=e[n];if(!t||t.role!==r.role||r.label!==void 0&&t.label!==r.label)return!1}return!0}function mn(e,t){let n=[];return e.id!==t.id&&n.push(`id: recorded=${e.id??`(none)`} observed=${t.id??`(none)`}`),e.role!==t.role&&n.push(`role: recorded=${e.role} observed=${t.role}`),e.label!==t.label&&n.push(`label: recorded=${e.label??`(none)`} observed=${t.label??`(none)`}`),n}function hn(e){return e?`${e.role}${e.label?`/${e.label}`:``}`:`(missing)`}function gn(e,t){return!t||t.role!==e.role?!0:e.label!==void 0&&t.label!==e.label}function _n(e,t){for(let[n,r]of e.entries()){let e=t[n];if(gn(r,e))return[`ancestry[${n}]: recorded=${hn(r)} observed=${hn(e)}`]}return[]}function vn(e,t,n={}){let r=[],i=y(e.type??``),a=yn(e,n.nodes),o=T(e.label),s=T(e.value),c=T(Me(e)),l=n.action===`fill`;a&&r.push(`id=${w(a)}`),i&&o&&r.push(l?`role=${w(i)} label=${w(o)} editable=true`:`role=${w(i)} label=${w(o)}`),o&&r.push(l?`label=${w(o)} editable=true`:`label=${w(o)}`),s&&r.push(l?`value=${w(s)} editable=true`:`value=${w(s)}`),c&&c!==o&&c!==s&&r.push(l?`text=${w(c)} editable=true`:`text=${w(c)}`),i&&l&&!r.some(e=>e.includes(`editable=true`))&&r.push(`role=${w(i)} editable=true`);let u=bn(r);return u.length===0&&i&&u.push(l?`role=${w(i)} editable=true`:`role=${w(i)}`),u.length===0&&b(e)&&u.push(`visible=true`),u}function yn(e,t){let n=T(e.identifier);if(!n||!t)return n;let r=rn(e).id;return r===void 0?n:on(t,r)>1?null:n}function bn(e){return Array.from(new Set(e))}function w(e){return JSON.stringify(e)}function T(e){return e&&e.trim()||null}const xn=[`any`,`text`,`label`,`value`,`role`,`id`],Sn=[`text`,`label`,`value`,`role`,`id`];function Cn(e){let t=e?.toLowerCase();return t===`press`||t===`tap`?`click`:t}function wn(e){return e===`exists`||e===`wait`||e===`get_text`||e===`get_attrs`||e===`list`}function Tn(e,t,n,r={}){let i=D(n);if(!i)return{matches:[],score:0};let a=0,o=[];for(let n of e){if(r.requireRect&&!n.rect)continue;let e=En(n,t,i);if(!(e<=0)){if(e>a){a=e,o.length=0,o.push(n);continue}e===a&&o.push(n)}}return{matches:o,score:a}}function En(e,t,n){switch(t){case`role`:return Dn(e.type,n);case`label`:return E(e.label,n);case`value`:return E(e.value,n);case`id`:return E(e.identifier,n);default:return Math.max(E(e.label,n),E(e.value,n),E(e.identifier,n))}}function E(e,t){let n=D(e??``);return n?n===t?2:+!!n.includes(t):0}function Dn(e,t){let n=On(e??``);return n?n===t?2:+!!n.includes(t):0}function D(e){return e.trim().toLowerCase().replace(/\s+/g,` `)}function On(e){let t=e.trim();return t?(t=(t.split(`.`).pop()??t).replace(/XCUIElementType/gi,``).toLowerCase(),t):``}const kn=`find requires a value`,An=`find actions: click (default; press/tap are aliases), list, focus, fill, type, exists, wait, get text, get attrs — there is no longpress/swipe find action. Run find "<text>" list to inspect every match with its @ref without acting, then dispatch the gesture on the chosen ref, e.g. longpress @eNN.`;function jn(e,t){if(e.length===0)return{ok:!1,code:`INVALID_ARGS`,message:`find requires a locator or text`};let n=Pn([...e]);return n.query?t?.findFirst&&t?.findLast?{ok:!1,code:`INVALID_ARGS`,message:`find accepts only one of --first or --last`}:{ok:!0,parsed:n}:{ok:!1,code:`INVALID_ARGS`,message:kn}}const Mn=[`exists`,`list`,`click`,`focus`];function Nn(e){return Mn.includes(e)}function Pn(t){let n=`any`,r=0;Sn.includes(t[0])&&(n=t[0],r=1);let i=t[r]??``,a=t.slice(r+1);if(a.length===0)return{locator:n,query:i,action:`click`};let o=Cn(a[0]);if(Nn(o))return{locator:n,query:i,action:o};if(o===`get`)return{locator:n,query:i,action:Fn(a[1])};if(o===`wait`){let e=Ln(a[1]);return{locator:n,query:i,action:`wait`,timeoutMs:e??void 0}}if(o===`fill`||o===`type`)return{locator:n,query:i,action:o,value:a.slice(1).join(` `)};throw new e(`INVALID_ARGS`,`Unsupported find action: ${a[0]}`,{hint:An})}function Fn(t){let n=t?.toLowerCase();if(n===`text`)return`get_text`;if(n===`attrs`)return`get_attrs`;throw new e(`INVALID_ARGS`,`find get only supports text or attrs`)}function In(e,t){return e!==`any`||!t.includes(`=`)&&!t.includes(`||`)?null:S(t)?t:null}function Ln(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function O(e,t,n){return t.terms.every(t=>Rn(e,t,n))}function Rn(e,t,n){switch(t.key){case`id`:return k(e.identifier,String(t.value));case`role`:return k(y(e.type??``),String(t.value));case`label`:return k(e.label,String(t.value));case`value`:return k(e.value,String(t.value));case`text`:return k(Me(e),String(t.value));case`appname`:return k(e.appName,String(t.value));case`windowtitle`:return k(e.windowTitle,String(t.value));case`visible`:return b(e)===!!t.value;case`hidden`:return!b(e)==!!t.value;case`editable`:return He(e,n)===!!t.value;case`selected`:return e.selected===!0==!!t.value;case`focused`:return e.focused===!0==!!t.value;case`enabled`:return e.enabled!==!1==!!t.value;case`hittable`:return e.hittable===!0==!!t.value;default:return!1}}function k(e,t){return D(e??``)===D(t)}function zn(e,t,n){let r=n.requireRect??!1,i=n.requireUnique??!0,a=[];for(let[o,s]of t.selectors.entries()){let t=Gn(e,s,n.platform,r);if(a.push({selector:s.raw,matches:t.count}),!(t.count===0||!t.firstNode)){if(i&&t.count!==1){if(!n.disambiguateAmbiguous||!t.disambiguated||!t.tiebreak)continue;return{node:t.disambiguated,selector:s,selectorIndex:o,matches:t.count,diagnostics:a,disambiguation:{matchCount:t.count,tiebreak:t.tiebreak,alternatives:t.candidates.filter(e=>e!==t.disambiguated)}}}return{node:t.firstNode,selector:s,selectorIndex:o,matches:t.count,diagnostics:a}}}return null}function Bn(e,t,n){let r=n.requireRect??!1;for(let[i,a]of t.selectors.entries()){let t=e.filter(e=>r&&!e.rect?!1:O(e,a,n.platform));if(t.length>0)return{selector:a,selectorIndex:i,matchedNodes:t}}return null}function Vn(e,t,n){let r=n.requireRect??!1,i=[];for(let[a,o]of t.selectors.entries()){let t=Yn(e,o,n.platform,r);if(i.push({selector:o.raw,matches:t}),t>0)return{selectorIndex:a,selector:o,matches:t,diagnostics:i}}return null}const Hn=`Snapshot refs expire when the UI changes. Run snapshot -i and retry with a fresh @ref.`;function Un(e){return e.some(e=>e.matches>1)?`Add more terms to disambiguate (e.g. role=button text="Sign in"), use an @ref from snapshot -i, or use find <text> --first/--last.`:`Selector text/label values match exactly (quote multi-word values: text="Sign in"). Run snapshot -i to see current elements and refs, or use find <text> for contains matching.`}function Wn(e,t,n){if(t.length===0)return`Selector did not match: ${e}`;let r=t.map(e=>`${e.selector} -> ${e.matches}`).join(`, `);return n.unique??!0?`Selector did not resolve uniquely (${r})`:`Selector did not match (${r})`}function Gn(e,t,n,r){let i=0,a=null,o=[],s={best:null,bestVisible:!1,tie:!1},c,l=t=>(c??=v(e),Le(t,e,c));for(let c of e)r&&!c.rect||O(c,t,n)&&(i+=1,a??=c,o.push(c),Kn(s,c,l));return{count:i,firstNode:a,disambiguated:s.tie?null:s.best,tiebreak:s.tie?null:qn(o,s.best,l),candidates:o}}function Kn(e,t,n){if(!e.best){e.best=t;return}e.bestVisible||=n(e.best);let r=n(t);if(r!==e.bestVisible){r&&(e.best=t,e.bestVisible=!0,e.tie=!1);return}let i=Xn(t,e.best);i.result>0?(e.best=t,e.tie=!1):i.result===0&&(e.tie=!0)}function qn(e,t,n){if(!t)return null;let r=null;for(let i of e)i!==t&&(!r||Jn(i,r,n).result>0)&&(r=i);return r?Jn(t,r,n).criterion:null}function Jn(e,t,n){let r=n(e);return r===n(t)?Xn(e,t):{result:r?1:-1,criterion:`visible`}}function Yn(e,t,n,r){let i=0;for(let a of e)r&&!a.rect||O(a,t,n)&&(i+=1);return i}function Xn(e,t){let n=e.depth??0,r=t.depth??0;if(n!==r)return{result:n>r?1:-1,criterion:`deepest`};let i=Zn(e),a=Zn(t);return i===a?{result:0,criterion:null}:{result:i<a?1:-1,criterion:`smallest-area`}}function Zn(e){return e.rect?e.rect.width*e.rect.height:1/0}const Qn={act:{ambiguity:`reject-candidates`,requireRect:!0},actCoveredDiagnosis:{ambiguity:`first-match`,requireRect:!0},readText:{ambiguity:`disambiguate`,requireRect:!1},readUnique:{ambiguity:`fail-closed`,requireRect:!1},readAny:{ambiguity:`first-match`,requireRect:!1},wait:{ambiguity:`first-match`,requireRect:!1},findAct:{ambiguity:`reject-candidates`,requireRect:!0},readList:{ambiguity:`reject-candidates`,requireRect:!1}};function $n(e){return e.ambiguity===`first-match`?{requireRect:e.requireRect,requireUnique:!1}:{requireRect:e.requireRect,requireUnique:!0,disambiguateAmbiguous:e.ambiguity===`disambiguate`}}function er(e,t){let n=e===`is`?_t([...t]).split:Qe([...t]);return n?S(n.selectorExpression)?{kind:`expression`,expression:n.selectorExpression,rest:n.rest}:{kind:`invalid`}:{kind:`not-applicable`}}function tr(e){return{platform:e.platform,...$n({ambiguity:e.allowDisambiguation?`disambiguate`:`fail-closed`,requireRect:e.requireRect})}}function nr(e,t,n){let r=S(e);if(!r)return{kind:`unresolved`,reason:`parse-invalid`,matchedNodes:[]};let i=zn(t,r,tr(n));if(i){let e=t.filter(e=>n.requireRect&&!e.rect?!1:O(e,i.selector,n.platform));return{kind:`resolved`,winner:i.node,matchedNodes:e,matchCount:e.length,...i.disambiguation?{disambiguation:{tiebreak:i.disambiguation.tiebreak,matchCount:i.disambiguation.matchCount,alternatives:i.disambiguation.alternatives}}:{}}}let a=Bn(t,r,{platform:n.platform,requireRect:n.requireRect})?.matchedNodes??[];return{kind:`unresolved`,reason:a.length>0?`ambiguous`:`no-match`,matchedNodes:a}}function rr(e,t,n={}){return vn(e,t,n)}function ir(e,t,n){let r=S(e);if(!r)return;let i=zn(t,r,tr(n));if(i)return{node:i.node,basis:or(i.selector)}}function ar(e){if(!e)return;let t=S(e);if(!t)return;let n=t.selectors.flatMap(e=>e.terms.flatMap(e=>(e.key===`label`||e.key===`text`||e.key===`id`)&&typeof e.value==`string`?[e.value]:[]));if(n.length===0)return;let r=n[0];return r&&n.every(e=>e===r)?r:void 0}function or(e){let t=new Set(e.terms.map(e=>e.key));if(t.has(`id`))return`id`;let n=t.has(`role`),r=t.has(`label`)||t.has(`text`);return n&&r?`role-label`:r||t.has(`value`)?`label`:`other`}function sr(e,t){let n=S(e);if(!n)return e.includes(`=`)||e.includes(`||`)?null:e;let r=new Set(t.textKeys);return n.selectors.length>1?cr(n.selectors,r):lr(n.selectors[0],r,new Set(t.booleanKeys))}function cr(e,t){let n=e.map(e=>{let n=e.terms.length===1?e.terms[0]:void 0;return n&&t.has(n.key)&&typeof n.value==`string`?n.value:void 0}),r=n[0];return r!==void 0&&n.every(e=>e===r)?r:null}function lr(e,t,n){if(!e)return null;let r={},i=0;for(let a of e.terms){if(ur(a,t,`string`))i+=1;else if(!ur(a,n,`boolean`))return null;r[a.key]=a.value}return i<=1&&Object.keys(r).length>0?r:null}function ur(e,t,n){return t.has(e.key)&&typeof e.value===n}function dr(e){let t=S(e);if(!t||t.selectors.length!==1)return null;let n=t.selectors[0];if(!n||n.terms.length!==1)return null;let r=n.terms[0];return!r||typeof r.value!=`string`||r.key!==`id`&&r.key!==`label`&&r.key!==`text`&&r.key!==`value`?null:{key:r.key,value:r.value,raw:n.raw}}function fr(e,t){if(!t)return!1;let n=S(e);return n?n.selectors.some(e=>e.terms.some(e=>(e.key===`text`||e.key===`label`||e.key===`value`)&&typeof e.value==`string`&&e.value.includes(t))):!1}function pr(e){return Ye(e).selectors.map(e=>e.raw)}function mr(e){return S(e)!==null}function A(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function hr(e){let t=e[0];if(t===void 0)return null;let n=A(t);if(n!==null)return{kind:`sleep`,durationMs:n};let r=A(e[e.length-1]);if(t===`text`)return{kind:`text`,text:(r===null?e.slice(1).join(` `):e.slice(1,-1).join(` `)).trim(),timeoutMs:r};if(t===`stable`){let t=e.slice(1),n=t.length>1?A(t[1]):null;return{kind:`stable`,quietMs:t.length>0?A(t[0]):null,timeoutMs:n}}if(t.startsWith(`@`))return{kind:`ref`,rawRef:t,timeoutMs:r};let i=Qe(r===null?e.slice():e.slice(0,-1));return i&&i.rest.length===0&&mr(i.selectorExpression)?{kind:`selector`,selectorExpression:i.selectorExpression,timeoutMs:r}:{kind:`text`,text:(r===null?e.join(` `):e.slice(0,-1).join(` `)).trim(),timeoutMs:r}}function gr(e){let t=hr(e);return t?t.kind===`sleep`?t.durationMs:t.timeoutMs:null}const _r=24e4,j={budget:{source:`none`},envelopeMs:9e4,onTimeout:`reset-daemon`},vr={click:`settle-and-verify`,press:`settle-and-verify`,fill:`settle-and-verify`,longpress:`settle`,scroll:`settle`,back:`settle`};function yr(e){if(e!==void 0)return vr[e]}const br=new Set([`com.google.android.inputmethod.latin`,`com.samsung.android.honeyboard`,`com.touchtype.swiftkey`,`com.microsoft.swiftkey`]);function xr(e){let t=M(e.packageName),n=(e.resourceId??``).toLowerCase(),r=M(e.activeInputMethodPackage);if(t&&r&&t===r)return{inputMethodOwned:!0,source:`active-input-method`};if(r&&n.startsWith(`${r}:id/`))return{inputMethodOwned:!0,source:`active-input-method-resource`};if(t&&br.has(t))return{inputMethodOwned:!0,source:`known-ime-package`};for(let e of br)if(n.startsWith(`${e}:id/`))return{inputMethodOwned:!0,source:`known-ime-resource`};return{inputMethodOwned:!1,source:`app`}}function Sr(e,t,n){return xr({packageName:e,resourceId:t,activeInputMethodPackage:n}).inputMethodOwned}function Cr(e){return xr(e).inputMethodOwned}function wr(e){return Cr({packageName:e.bundleId,resourceId:e.identifier})}function Tr(e){let t=M(e);return!!(t&&br.has(t))}function Er(e){let t=(e??``).toLowerCase();for(let e of br)if(t.startsWith(`${e}:id/`))return!0;return!1}function Dr(e,t,n){return!e&&!t?`unknown`:Sr(e,t,n)?`ime`:`app`}function Or(e){for(let t of[/\bmCurMethodId=([^\s]+)/i,/\bmCurId=([^\s]+)/i,/\bmCurrentInputMethodId=([^\s]+)/i,/\bcurMethodId=([^\s]+)/i]){let n=kr(e.match(t)?.[1]);if(n)return n}}function kr(e){let t=(e??``).trim();if(t)return M((t.split(`/`)[0]??``).match(/[a-zA-Z0-9_.]+/)?.[0])}function M(e){return(e??``).trim().toLowerCase()||void 0}const Ar=new Set([`empty-helper-output`,`system-window-only`,`content-poor-app-window`]);function jr(e){return typeof e==`string`&&Ar.has(e)}function Mr(e){if(!e||typeof e!=`object`)return!1;let t=e.details?.androidSnapshotHelperFailureReason;return jr(t)}const Nr=`com.android.systemui`;function Pr(e){let t=e??``;if(!t.startsWith(`com.android.systemui:id/`))return!1;let n=t.slice(`${Nr}:id/`.length);return/(^|_)(status_bar|navigation_bar)(_|$)/.test(n)}function Fr(e){return`systemChrome`in e&&e.systemChrome===!0}function Ir(e){if(!Fr(e))return e;let{systemChrome:t,...n}=e;return n}function Lr(e){return e.some(Fr)?e.map(Ir):e}const Rr={ios:`iOS`,ipados:`iPadOS`,tvos:`tvOS`,watchos:`watchOS`,visionos:`visionOS`,macos:`macOS`},zr={visionos:`visionOS uses spatial input and does not support two-finger touch synthesis.`,tvos:`tvOS has no touch input — this gesture is supported on Android and the iOS simulator only.`,macos:`macOS automation has no multi-touch input — this gesture is supported on Android and the iOS simulator only.`};function Br(t,n){if(!u(t.platform))throw Vr(n,t.platform);let r=d(t);if(!((r===`ios`||r===`ipados`)&&t.kind===`simulator`))throw r===`ios`||r===`ipados`?new e(`UNSUPPORTED_OPERATION`,`gesture ${n} is not supported on physical iOS devices`,{hint:`Two-finger gesture synthesis is iOS-simulator only — not available on physical iOS devices.`}):Vr(n,Rr[r],zr[r])}function Vr(t,n,r){return new e(`UNSUPPORTED_OPERATION`,`gesture ${t} is not supported on ${n}`,r===void 0?void 0:{hint:r})}function Hr(e){let t=e.state??`stopped`;return{audio:`probe`,state:t,active:t===`running`,heard:!1,source:e.source,backend:e.backend,durationMs:e.durationMs,elapsedMs:e.elapsedMs??0,bucketMs:e.bucketMs,sampleCount:0,mediaElementCount:e.mediaElementCount,sourceCount:e.sourceCount??0,rmsDbfs:[],peakDbfs:[],reason:e.reason,notes:e.notes}}function Ur(e,t){let n=qr(e),r=Wr(n),i=Gr(n.rmsDbfs),a=Gr(n.peakDbfs),o=[...Kr(n.notes)??[],...t.notes??[]];return{audio:`probe`,state:r,active:r===`running`&&Jr(n.active,t.activeFallback??!0),heard:n.heard===!0,source:t.source,backend:P(n.backend)??t.backend,durationMs:N(n.durationMs,t.durationMs),elapsedMs:N(n.elapsedMs,t.elapsedMs),bucketMs:N(n.bucketMs,t.bucketMs),sampleCount:N(n.sampleCount,i.length),mediaElementCount:t.mediaElementCount===void 0?Yr(n.mediaElementCount):N(n.mediaElementCount,t.mediaElementCount),sourceCount:N(n.sourceCount,t.sourceCount??0),rmsDbfs:i,peakDbfs:a,startedAt:P(n.startedAt),stoppedAt:P(n.stoppedAt),reason:P(n.reason),notes:o.length>0?o:void 0}}function Wr(e){return e.state===`running`?`running`:`stopped`}function N(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function Gr(e){if(!Array.isArray(e))return[];let t=[];for(let n of e)typeof n==`number`&&Number.isFinite(n)&&t.push(n);return t}function Kr(e){if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}function qr(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Jr(e,t){return typeof e==`boolean`?e:t}function P(e){return typeof e==`string`?e:void 0}function Yr(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function Xr(e){return process.platform===`darwin`&&(c(e)||o(e)&&e.kind===`simulator`||e.platform===`android`&&e.kind===`emulator`)}function Zr(e){return e.platform===`web`||Xr(e)}function Qr(e){if(!s(e))throw TypeError(`Unknown local runtime family: ${String(e)}`);return Object.freeze({kind:`local-family`,family:e})}function $r(e,t){let n=e.trim(),r=t.trim();if(n.length===0||r.length===0)throw TypeError(`Provider runtime owner requires non-empty provider and instance identities`);return Object.freeze({kind:`provider-runtime`,provider:n,instance:r})}function ei(e){return e.kind===`local-family`?`local:${e.family}`:`provider:${JSON.stringify([e.provider,e.instance])}`}function ti(e,t){return ei(e)===ei(t)}function ni(e,t){let n={},r={};for(let i of t.required){let t=ri(e.facts.operations,i);if(n[i]=t,!t.available)throw ci(i,t);r[i]=oi(e.operations,i)}for(let i of t.preferred){let t=ri(e.facts.operations,i);n[i]=t,t.available&&(r[i]=oi(e.operations,i))}return Object.freeze({device:e.device,owner:e.owner,facts:Object.freeze(n),operations:Object.freeze(r)})}function ri(e,t){let n=e[t];if(!ii(n))throw li(`Runtime owner omitted the ${t} fact`);let r=ai(n);if(r)return r;throw li(`Runtime owner returned an invalid ${t} fact`)}function ii(e){return typeof e==`object`&&!!e&&`available`in e}function ai(e){if(e.available===!0)return Object.freeze({available:!0});if(e.available===!1&&si(e.reason)&&!(e.hint!==void 0&&typeof e.hint!=`string`))return Object.freeze({available:!1,reason:e.reason,...e.hint===void 0?{}:{hint:e.hint}})}function oi(e,t){let n=e[t];if(typeof n!=`function`)throw li(`Runtime owner advertised ${t} without an implementation`);return n}function si(e){return e===`unsupported-platform-leaf`||e===`unsupported-device-kind`||e===`unsupported-device-backend`||e===`unsupported-provider-mode`||e===`owner-capability-missing`}function ci(t,n){return new e(`UNSUPPORTED_OPERATION`,`Runtime operation ${t} is unavailable`,{reason:n.reason,hint:n.hint})}function li(t){return new e(`COMMAND_FAILED`,t,{reason:`runtime-contract-invalid`,hint:`This is an agent-device runtime contract bug; report the selected device and command.`})}function ui(){return e=>{let t=di(e.required,`required`),n=di(e.preferred??[],`preferred`),r=n.find(e=>t.includes(e));if(r!==void 0)throw TypeError(`Runtime operation cannot be both required and preferred: ${r}`);return Object.freeze({required:t,preferred:n})}}function di(e,t){let n=[...e];if(new Set(n).size!==n.length)throw TypeError(`Runtime use contains duplicate ${t} operations`);return Object.freeze(n)}const F=ui(),fi=F({required:[`bootTarget`]}),pi=F({required:[`bootTargetHeadless`]}),mi=F({required:[`ensureReady`,`listApps`]}),hi=Object.freeze([fi,pi]),gi=Object.freeze({kind:`boot-target`,operation:`bootTarget`,use:fi}),_i=Object.freeze({kind:`boot-target-headless`,operation:`bootTargetHeadless`,use:pi});function vi(e){return e.headless?_i:gi}const yi=F({required:[`ensureReady`,`appState`]}),bi=Object.freeze([yi]),xi=F({required:[`shutdownTarget`]}),Si=F({required:[`deployApp`]}),Ci=F({required:[`ensureReady`,`materializeAppSource`,`deployMaterializedApp`]}),wi=F({required:[`ensureReady`,`sendPushNotification`]});function Ti(e){if(typeof e!=`object`||!e)throw Ni();let t=e,n=Object.keys(t).sort();if(!(t.kind===`none`&&I(n,[`kind`]))&&!(t.kind===`legacy`&&I(n,[`kind`]))&&!(t.kind===`inventory`&&I(n,[`kind`,`use`])&&Oi(t.use))&&!(t.kind===`device-runtime`&&I(n,[`kind`,`use`])&&ki(t.use))&&!(t.kind===`device-runtime`&&I(n,[`kind`,`uses`])&&Ei(t.uses)))throw Ni()}function Ei(e){if(!Array.isArray(e)||e.length===0||!e.every(ki))return!1;let t=e.map(Di);return new Set(t).size===t.length}function Di(e){return JSON.stringify({required:[...e.required].sort(),preferred:[...e.preferred].sort()})}function Oi(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.kind===`device-inventory`&&I(Object.keys(t).sort(),[`kind`])}function ki(e){if(typeof e!=`object`||!e)return!1;let t=e,n=Ai(t.required),r=Ai(t.preferred);return!n||!r||!ji(n)||!ji(r)||!Mi(n,r)?!1:I(Object.keys(t).sort(),[`preferred`,`required`])}function Ai(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)?e:null}function ji(e){return new Set(e).size===e.length}function Mi(e,t){let n=new Set(e);return t.every(e=>!n.has(e))}function I(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Ni(){return TypeError(`Command platform execution must declare exactly one of none, legacy, inventory, or device-runtime`)}var Pi=class{#e=[];#t=`open`;get disposed(){return this.#t===`disposed`}defer(e){this.#n(),this.#e.push(e)}use(e){return this.defer(async()=>await e[Symbol.asyncDispose]()),e}async[Symbol.asyncDispose](){if(this.#t===`disposed`)return;if(this.#t===`disposing`)throw TypeError(`Async cleanup stack disposal is already in progress`);this.#t=`disposing`;let e=[];for(;this.#e.length>0;){let t=this.#e.pop();if(t)try{await t()}catch(t){e.push(t)}}if(this.#t=`disposed`,e.length===1)throw e[0];if(e.length>1)throw AggregateError(e,`Multiple asynchronous cleanups failed`)}#n(){if(this.#t!==`open`)throw TypeError(`Cannot register cleanup after disposal has begun`)}},Fi=class{#e;#t=`pending`;constructor(e){this.#e=e}get pending(){return this.#t===`pending`}transfer(){if(this.#t!==`pending`)throw TypeError(`Cannot transfer handle in ${this.#t} state`);return this.#t=`transferred`,this.#e}async[Symbol.asyncDispose](){this.#t===`pending`&&(this.#t=`disposed`,await this.#e[Symbol.asyncDispose]())}};const L=new Map;async function Ii(e,t){let n=L.get(e);if(n){await n;return}let r,i=new Promise(e=>{r=e});L.set(e,i);try{await t()}finally{L.get(e)===i&&L.delete(e),r()}}async function Li(e){await L.get(e)}const Ri=[`metroHost`,`metroPort`,`bundleUrl`];function zi(e){return Ri.some(t=>e[t]!==void 0)}const Bi=[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`,`clearRuntimeHints`,`closeApplication`,`finalizeApplicationClose`,`prepareAppleRunner`,`configureProviderPortReverse`];function Vi(e){return Object.freeze({resolveOpenTarget:e.resolveOpenTarget,prepareApplicationOpen:e.prepareApplicationOpen,openApplication:e.openApplication,applyRuntimeHints:e.applyRuntimeHints,clearRuntimeHints:e.clearRuntimeHints,closeApplication:e.closeApplication,finalizeApplicationClose:e.finalizeApplicationClose,prepareAppleRunner:e.prepareAppleRunner,configureProviderPortReverse:e.configureProviderPortReverse})}function Hi(e,t){return Object.freeze(Object.fromEntries(Bi.flatMap(n=>t[n].available?[[n,e[n]]]:[])))}function Ui(e,t,n){return Object.freeze({device:e,owner:t,facts:Wi(e,t,n),operations:Object.freeze({}),[Symbol.asyncDispose]:async()=>void 0})}function Wi(e,t,n){let{appLog:r,apps:i,appDeployment:o,appState:s,network:c,screenRecording:l,readiness:u,shutdown:d,lifecycle:f}=Gi(n);return Object.freeze({device:{...a(e),providerMode:t.kind===`local-family`?`local`:`provider-runtime`},operations:{appLogInspect:r,appLogDoctor:r,appLogStart:r,appLogReattach:r,appLogCleanup:r,listApps:i,deployApp:o,materializeAppSource:o,deployMaterializedApp:o,sendPushNotification:o,appState:s,networkDump:c,screenRecordingStart:l,screenRecordingReattach:l,screenRecordingCleanup:l,ensureReady:u,bootTarget:u,bootTargetHeadless:u,shutdownTarget:d,...f}})}function Gi(e){return Object.freeze({appLog:Object.freeze({...e.appLog}),apps:Object.freeze({...e.apps??e.network}),appDeployment:Object.freeze({...e.appDeployment??e.network}),appState:Object.freeze({...e.appState??e.network}),network:Object.freeze({...e.network}),screenRecording:Object.freeze({...e.screenRecording??e.network}),readiness:Object.freeze({...e.readiness??e.network}),shutdown:Object.freeze({...e.shutdown??e.network}),lifecycle:Vi(e.lifecycle)})}function Ki(e){return e.status===`cleaned`||e.status===`already-missing`}const qi=`app-log`,Ji=`screen-recording`,Yi=F({required:[`screenRecordingStart`]}),Xi=F({required:[`screenRecordingReattach`,`screenRecordingCleanup`]}),Zi=F({required:[]}),Qi=F({required:[],preferred:[`screenRecordingStart`]}),$i=Object.freeze([Yi,Xi]);function ea(t){switch((t.action??``).toLowerCase()){case`start`:if(!ta(t.scope??`app`))throw new e(`INVALID_ARGS`,`record scope must be app, device, or system`);return Object.freeze({kind:`start`,use:Yi});case`stop`:return t.hasLiveHandle===!0?Object.freeze({kind:`stop-live`,use:Zi}):Object.freeze({kind:`stop-recovery`,use:Xi});default:throw new e(`INVALID_ARGS`,`record requires start or stop`)}}function ta(e){return e===`app`||e===`device`||e===`system`}function na(e){if(Ti(e),e.kind!==`device-runtime`||!(`uses`in e))throw ia();let t=e.uses.map(ra),n=$i.map(ra),r=new Set(t),i=new Set(n);if(t.length!==n.length||r.size!==t.length||[...r].some(e=>!i.has(e)))throw ia()}function ra(e){return JSON.stringify({required:[...e.required].sort(),preferred:[...e.preferred].sort()})}function ia(){return TypeError(`Record runtime execution must declare exactly the uses selected by its two runtime-bearing plans`)}const aa=F({required:[`networkDump`]}),oa=F({required:[],preferred:[`networkDump`]}),sa=[`dump`,`log`],ca=[`summary`,`headers`,`body`,`all`];function la(t){let n=(t.action??`dump`).toLowerCase(),r=(t.include??`summary`).toLowerCase();if(!ua(n))throw new e(`INVALID_ARGS`,`network requires dump or log`);if(!da(r))throw new e(`INVALID_ARGS`,`network --include must be summary, headers, body, or all`);return Object.freeze({action:n,include:r,use:aa})}function ua(e){return sa.some(t=>t===e)}function da(e){return ca.some(t=>t===e)}function R(e){let t=e.trim();if(!t||/\s/.test(t))return!1;let n=/^([A-Za-z][A-Za-z0-9+.-]*):(.+)$/.exec(t);if(!n)return!1;let r=n[1]?.toLowerCase(),i=n[2]??``;return r===`http`||r===`https`||r===`ws`||r===`wss`||r===`ftp`||r===`ftps`?i.startsWith(`//`):!0}function fa(e){let t=e.trim().split(`:`)[0]?.toLowerCase();return t===`http`||t===`https`}function pa(e,t){let n=e?.trim();if(n)return n;if(fa(t))return`com.apple.mobilesafari`}const ma=`--launch-console is supported only for iOS simulator app launches`,ha=`--launch-console requires a direct app launch and cannot be used with URL opens`;function ga(e,t,n){return{requestId:e.requestId,signal:n,appBundleId:t,verbose:e.verbose,logPath:e.logPath,traceLogPath:e.traceLogPath,iosXctestrunFile:e.iosXctestrunFile,iosXctestDerivedDataPath:e.iosXctestDerivedDataPath,iosXctestEnvDir:e.iosXctestEnvDir,runnerLeaseContext:e.runnerLeaseContext}}function _a(t){let{device:n,signal:r,ownership:i}=t;return Object.freeze({device:n,signal:r,resolveInteractor:async(a,o)=>{let s=ga(a,o,r);if(i===`local`)return await t.resolveLocalInteractor(n,s);let c=i.resolveInteractor(s);if(c)return c;throw new e(`UNSUPPORTED_OPERATION`,`Provider-owned application lifecycle operation has no bound provider interactor.`,{reason:`provider-runtime-interactor-missing`,deviceId:n.id})}})}function va(e){return _a({device:e.device,signal:e.signal,resolveLocalInteractor:e.resolveInteractor,ownership:`local`})}function ya(e){return _a({device:e.device,signal:e.signal,ownership:{kind:`provider`,resolveInteractor:e.resolveInteractor}})}async function ba(e){let{device:t,positionals:n,execution:r}=e;xa(n);let i=n[0],a=n[1];if(!i){await Sa(e);return}if(Ca(t,r),a!==void 0){await wa(e,i,a);return}await Ta(e,i)}function xa(t){if(t.length>2)throw new e(`INVALID_ARGS`,`open accepts at most two arguments: <app|url> [url]`)}async function Sa(t){if(t.execution.launchConsole)throw new e(`INVALID_ARGS`,`--launch-console requires an app target`);if(t.execution.launchArgs&&t.execution.launchArgs.length>0)throw new e(`INVALID_ARGS`,`--launch-args requires an app target`);await t.interactor.openDevice()}function Ca(t,n){if(n.launchConsole&&(!o(t)||t.kind!==`simulator`))throw new e(`UNSUPPORTED_OPERATION`,ma);if(t.platform===`linux`&&n.launchArgs&&n.launchArgs.length>0)throw new e(`UNSUPPORTED_OPERATION`,`--launch-args is not supported on Linux.`)}async function wa(t,n,r){if(R(n))throw new e(`INVALID_ARGS`,`open <app> <url> requires an app target as the first argument`);if(!R(r))throw new e(`INVALID_ARGS`,`open <app> <url> requires a valid URL target`);if(t.execution.launchConsole)throw new e(`INVALID_ARGS`,ha);await t.interactor.open(n,{activity:t.execution.activity,appBundleId:t.appBundleId,launchArgs:t.execution.launchArgs?[...t.execution.launchArgs]:void 0,terminateRunningApp:t.terminateRunningApp,url:r})}async function Ta(t,n){let{execution:r,interactor:i}=t;if(r.launchConsole&&R(n))throw new e(`INVALID_ARGS`,ha);if(r.clearAppState){if(R(n))throw new e(`INVALID_ARGS`,`Clearing app state requires an app target, not a deep link.`);await i.setSetting(`clear-app-state`,`clear`,n)}await i.open(n,{activity:r.activity,appBundleId:t.appBundleId,launchConsole:r.launchConsole,launchArgs:r.launchArgs?[...r.launchArgs]:void 0,terminateRunningApp:t.terminateRunningApp})}function Ea(t){let{binding:n}=t,r=async()=>{throw new e(`UNSUPPORTED_OPERATION`,`This lifecycle operation is unavailable for ${t.owner}.`)};return Object.freeze({resolveOpenTarget:async e=>ka(t.openTargetIdentity,e),prepareApplicationOpen:async()=>void 0,openApplication:async e=>await Da(t,e),applyRuntimeHints:r,clearRuntimeHints:r,closeApplication:async e=>{await Aa({device:n.device,interactor:await n.resolveInteractor(e.execution,e.appBundleId),positionals:e.positionals})},finalizeApplicationClose:async()=>({}),prepareAppleRunner:r,configureProviderPortReverse:t.configureProviderPortReverse??r})}async function Da(e,t){let{binding:n}=e,r=await n.resolveInteractor(t.execution,t.appBundleId);e.closeBeforeRelaunch&&t.relaunch&&t.target!==void 0&&await Aa({device:n.device,interactor:r,positionals:[t.appBundleId??t.target]}),await ba({device:n.device,interactor:r,positionals:t.positionals,appBundleId:t.appBundleId,execution:t.execution});let i=Oa(t);return i&&await ba({device:n.device,interactor:r,positionals:[i],appBundleId:t.appBundleId,execution:{...t.execution,clearAppState:void 0,launchConsole:void 0,launchArgs:void 0}}),{appBundleId:t.appBundleId,timing:{}}}function Oa(e){let t=e.runtimeLaunchUrl?.trim(),n=e.positionals.length===1?e.positionals[0]?.trim():void 0;if(!(!t||!n||R(n)))return t}function ka(e,t){let n=t.target;if(e===`app-name`)return Object.freeze(n===void 0?{}:{appName:n});let r=n?.trim(),i=r&&r.includes(`.`)&&!R(r)?r:t.currentAppBundleId;return Object.freeze({...i===void 0?{}:{appBundleId:i},...n===void 0?{}:{appName:n}})}async function Aa(e){let{device:t,interactor:n,positionals:r}=e,i=r[0];if(!i){t.platform===`web`&&await n.close(``);return}await n.close(i)}const ja=F({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`]}),Ma=F({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`]}),Na=F({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`clearRuntimeHints`]}),Pa=F({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`,`clearRuntimeHints`]});function Fa(e){return e.applyRuntimeHints&&e.clearRemovedRuntimeHints?Object.freeze({kind:`open-apply-and-clear-runtime-hints`,use:Pa}):e.applyRuntimeHints?Object.freeze({kind:`open-apply-runtime-hints`,use:Ma}):e.clearRemovedRuntimeHints?Object.freeze({kind:`open-clear-runtime-hints`,use:Na}):Object.freeze({kind:`open`,use:ja})}const Ia=Object.freeze([ja,Ma,Na,Pa]),La=F({required:[`closeApplication`,`finalizeApplicationClose`]}),Ra=F({required:[`closeApplication`,`finalizeApplicationClose`,`clearRuntimeHints`]}),za=Object.freeze([La,Ra]),Ba=F({required:[`finalizeApplicationClose`]}),Va=F({required:[`finalizeApplicationClose`,`clearRuntimeHints`]}),Ha=F({required:[`prepareAppleRunner`]}),Ua=F({required:[`clearRuntimeHints`]}),Wa=F({required:[`configureProviderPortReverse`]}),Ga=Object.freeze([Ua,Wa]),z=F({required:[`appLogInspect`]}),Ka=F({required:[`appLogInspect`,`appLogDoctor`]}),qa=F({required:[`appLogInspect`,`appLogStart`]}),Ja=F({required:[],preferred:[`appLogInspect`]}),Ya=Object.freeze([z,Ka,qa]);function Xa(t){let n=(t.action??`path`).toLowerCase();if(t.restart&&n!==`clear`)throw new e(`INVALID_ARGS`,`logs --restart is only supported with logs clear`);switch(n){case`path`:return Object.freeze({kind:`path`,requiresAppSession:!1,use:z});case`start`:return Object.freeze({kind:`start`,requiresAppSession:!0,use:qa});case`stop`:return Object.freeze({kind:`stop`,requiresAppSession:!1,use:z});case`doctor`:return Object.freeze({kind:`doctor`,requiresAppSession:!1,use:Ka});case`mark`:return Object.freeze({kind:`mark`,marker:t.marker??``,requiresAppSession:!1,use:z});case`clear`:return t.restart?Object.freeze({kind:`clear-restart`,requiresAppSession:!0,use:qa}):Object.freeze({kind:`clear`,requiresAppSession:!1,use:z});default:throw new e(`INVALID_ARGS`,`logs requires path, start, stop, doctor, mark, or clear`)}}function Za(e){let t=new Map;for(let n of e){if(!s(n.family))throw TypeError(`Unknown platform family registration: ${String(n.family)}`);if(t.has(n.family))throw TypeError(`Duplicate platform family registration: ${n.family}`);t.set(n.family,Qa(n))}let n=l.filter(e=>!t.has(e));if(n.length>0)throw TypeError(`Missing platform family registrations: ${n.join(`, `)}`);let r=Object.freeze([...l]),i=Object.freeze(r.map(e=>$a(t,e)));return Object.freeze({families:r,modules:i,get:e=>$a(t,e)})}function Qa(e){return Object.freeze({...e})}function $a(e,t){let n=e.get(t);if(!n)throw TypeError(`Missing platform family registration: ${t}`);return n}const eo=Object.freeze({kind:`device-inventory`});function to(e){let t=e.platformExecution;if(t===void 0)throw TypeError(`Command descriptor "${e.name}" must declare platformExecution (none, legacy, inventory, or device-runtime); there is no registry-entry default`);if(Ti(t),t.kind===`none`&&e.capability!==void 0)throw TypeError(`Command descriptor "${e.name}" declares platformExecution none but keeps a capability bucket; a command with platform admission is not platform-free`);return t}const no={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0},B={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0,selectorValidationExempt:!0},ro=()=>!0,io=e=>(e.positionals?.[0]??``).toLowerCase()===`start`,ao=e=>e.command===`test`&&(typeof e.flags?.shardAll==`number`||typeof e.flags?.shardSplit==`number`),oo=new Set([`status`,`get`]),so=e=>mo(e,oo,`status`),co=new Set([`get`,`wait`]),lo=e=>mo(e,co,`get`),uo=e=>ho(e,oo,`status`),fo=e=>ho(e,co,`get`),po=e=>{try{return wn(Pn(e.positionals??[]).action)?`observes-app`:`mutates-app`}catch{return`mutates-app`}};function mo(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`preserve`:`may-invalidate`}function ho(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`observes-app`:`mutates-app`}const V={simulator:!0,device:!0},H={emulator:!0,device:!0,unknown:!0},go={emulator:!0},U={device:!0},W={},G={apple:V,android:H,linux:U},K={kind:`none`},q={kind:`legacy`},J={recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,linux:U},timeoutPolicy:j,batchable:!0},Y={...j,onTimeout:`preserve-daemon`},_o={...j,envelopeMs:18e4},vo={...j,budget:{source:`flag`,envelope:`widen`,defaultBudgetMs:1e4},onTimeout:`preserve-daemon`},yo={fields:{count:{defaultValue:1,omitDefault:!0},intervalMs:{defaultValue:0,omitDefault:!0},holdMs:{defaultValue:0,omitDefault:!0},jitterPx:{defaultValue:0,omitDefault:!0},doubleTap:{defaultValue:!1,omitDefault:!0}}},bo={fields:{delayMs:{defaultValue:0}}};function X(e,t){return yr(e)===void 0?t:vo}function Z(e){let t=yr(e);if(t===void 0)throw Error(`Missing post-action observation descriptor support for ${e}`);return t}const xo=[{name:`lease_allocate`,catalog:{group:`internal`,key:`leaseAllocate`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...no},timeoutPolicy:j,batchable:!1,platformExecution:K},{name:`lease_heartbeat`,catalog:{group:`internal`,key:`leaseHeartbeat`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...no},timeoutPolicy:j,batchable:!1,platformExecution:K},{name:`lease_release`,catalog:{group:`internal`,key:`leaseRelease`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...no},timeoutPolicy:j,batchable:!1,platformExecution:K},{name:`artifacts`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...no},timeoutPolicy:j,batchable:!1,platformExecution:K},{name:`session_list`,catalog:{group:`internal`,key:`sessionList`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,...B},timeoutPolicy:j,batchable:!1,platformExecution:K},{name:`session_save_script`,catalog:{group:`internal`,key:`sessionSaveScript`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`publication`},timeoutPolicy:j,batchable:!1,platformExecution:K},{name:`devices`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,...B},timeoutPolicy:j,batchable:!0,platformExecution:{kind:`inventory`,use:eo}},{name:`capabilities`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,...B},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`doctor`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,allowSessionlessDefaultDevice:ro,...B},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`apps`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0},platformExecution:{kind:`device-runtime`,uses:[mi]},timeoutPolicy:j,batchable:!0},{name:`boot`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,uses:hi},timeoutPolicy:j,batchable:!0},{name:`shutdown`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,use:xi},timeoutPolicy:j,batchable:!0},{name:`appstate`,catalog:{group:`public`,key:`appState`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,uses:bi},timeoutPolicy:j,batchable:!0},{name:`perf`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},capability:{apple:V,android:H,linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`logs`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,uses:Ya},timeoutPolicy:j,batchable:!0},{name:`events`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`,allowInvalidRecording:!0,...B},timeoutPolicy:j,batchable:!1,platformExecution:q},{name:`network`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,use:aa},timeoutPolicy:j,batchable:!0},{name:`audio`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},capability:{apple:V,android:{emulator:!0},linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`replay`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:ao,saveScriptFlagOwner:!0},timeoutPolicy:{...j,budget:{source:`flag`}},batchable:!1,platformExecution:q},{name:`test`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:ao},timeoutPolicy:{...j,envelopeMs:`unbounded`},batchable:!0,platformExecution:q},{name:`runtime`,catalog:{group:`internal`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:j,batchable:!1,platformExecution:{kind:`device-runtime`,uses:Ga}},{name:`clipboard`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`session`,refFrameEffect:`preserve`},dispatch:{},capability:{apple:V,android:H,linux:U},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`keyboard`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:uo,daemon:{route:`session`,refFrameEffect:so,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`install`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Si},timeoutPolicy:_o,batchable:!0},{name:`reinstall`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Si},timeoutPolicy:_o,batchable:!0},{name:`install_source`,catalog:{group:`internal`,key:`installSource`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Ci},timeoutPolicy:_o,batchable:!1},{name:`release_materialized_paths`,catalog:{group:`internal`,key:`releaseMaterializedPaths`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,...B},timeoutPolicy:j,batchable:!1,platformExecution:K},{name:`push`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:wi},timeoutPolicy:j,batchable:!0},{name:`trigger-app-event`,catalog:{group:`public`,key:`triggerAppEvent`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:V,android:H,linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`open`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowSessionlessDefaultDevice:ro,saveScriptFlagOwner:!0},timeoutPolicy:j,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ia}},{name:`prepare`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:{budget:{source:`flag`},envelopeMs:_r,onTimeout:`reset-daemon`},batchable:!1,mcpExposed:!1,platformExecution:{kind:`device-runtime`,use:Ha}},{name:`batch`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`},timeoutPolicy:j,batchable:!1,platformExecution:q},{name:`close`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowInvalidRecording:!0,saveScriptFlagOwner:!0},timeoutPolicy:j,batchable:!0,platformExecution:{kind:`device-runtime`,uses:za}},{name:`snapshot`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},dispatch:{},capability:G,timeoutPolicy:{...Y,budget:{source:`flag`}},batchable:!0,platformExecution:q},{name:`diff`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},capability:G,timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`wait`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,targetIdentityVerification:`post-resolution`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},capability:G,timeoutPolicy:{...Y,budget:{source:`positional-parser`,parser:gr}},batchable:!0,platformExecution:q},{name:`alert`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:fo,daemon:{route:`snapshot`,refFrameEffect:lo},capability:{apple:V,android:H,linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`settings`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`snapshot`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:V,android:H,linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`react-native`,catalog:{group:`public`,key:`reactNative`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`reactNative`,refFrameEffect:`may-invalidate`},capability:{apple:V,android:H,linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`record`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`,allowInvalidRecording:!0,allowSessionlessDefaultDevice:io},platformExecution:{kind:`device-runtime`,uses:$i},timeoutPolicy:j,batchable:!0},{name:`trace`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`find`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:po,daemon:{route:`find`,refFrameEffect:`may-invalidate`},capability:G,timeoutPolicy:Y,batchable:!0,platformExecution:q},{name:`click`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},capability:{apple:V,android:H,linux:U},timeoutPolicy:X(`click`,Y),postActionObservation:Z(`click`),responseDataTransform:yo,batchable:!0,platformExecution:q},{name:`fill`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,linux:U},timeoutPolicy:X(`fill`,Y),postActionObservation:Z(`fill`),responseDataTransform:bo,batchable:!0,platformExecution:q},{name:`longpress`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`,key:`longPress`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,linux:U},timeoutPolicy:{...vo,envelopeMs:21e4},postActionObservation:Z(`longpress`),batchable:!0,platformExecution:q},{name:`press`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,linux:U},timeoutPolicy:X(`press`,Y),postActionObservation:Z(`press`),responseDataTransform:yo,batchable:!0,platformExecution:q},{name:`type`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:G,timeoutPolicy:X(`type`,Y),batchable:!0,platformExecution:q},{name:`get`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`},capability:G,timeoutPolicy:X(`get`,Y),batchable:!0,platformExecution:q},{name:`read`,catalog:{group:`dispatch-alias`},recordsSessionAction:!1,dispatch:{},timeoutPolicy:j,batchable:!1,platformExecution:q},{name:`is`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`},capability:G,timeoutPolicy:X(`is`,Y),batchable:!0,platformExecution:q},{name:`back`,catalog:{group:`public`},...J,capability:{...J.capability,vega:go},timeoutPolicy:X(`back`,j),postActionObservation:Z(`back`),platformExecution:q},{name:`gesture`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,targetIdentityVerification:`pre-dispatch`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},capability:G,timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`home`,catalog:{group:`public`},...J,capability:{...J.capability,vega:go},platformExecution:q},{name:`tv-remote`,catalog:{group:`public`,key:`tvRemote`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,vega:go,linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`orientation`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`scroll`,catalog:{group:`public`},...J,timeoutPolicy:X(`scroll`,j),postActionObservation:Z(`scroll`),platformExecution:q},{name:`swipe`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},capability:{apple:V,android:H,linux:U},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`focus`,catalog:{group:`public`},...J,platformExecution:q},{name:`screenshot`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`generic`,refFrameEffect:`preserve`},dispatch:{},capability:G,timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`viewport`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:{},android:{},linux:W},timeoutPolicy:j,batchable:!1,platformExecution:q},{name:`app-switcher`,catalog:{group:`public`,key:`appSwitcher`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:V,android:H,linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`install-from-source`,catalog:{group:`public`,key:`installFromSource`},recordsSessionAction:!0,recordingEffect:`mutates-app`,platformExecution:{kind:`device-runtime`,use:Ci},timeoutPolicy:j,batchable:!0},{name:`debug`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,platformExecution:q},{name:`daemon`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`device`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`metro`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,platformExecution:K},{name:`session`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,platformExecution:K},{name:`cdp`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`auth`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`connect`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`connection`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`disconnect`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`mcp`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`proxy`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`react-devtools`,catalog:{group:`local-cli`,key:`reactDevtools`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`web`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:q}],So=new Set([`public`,`local-cli`]),Co=new Set(xo.filter(e=>So.has(ko(e))).map(e=>e.name)),Q=xo.map(e=>{let t=to(e);return e.name===`record`&&na(t),{...e,mcpExposed:Do(e),platformExecution:t}});function wo(e){return Q.filter(t=>ko(t)===e).map(e=>[Ao(e),e.name])}function To(){return Q.filter(e=>Oo(e)).map(e=>e.name).sort()}const $=new Map(Q.map(e=>[e.name,e]));function Eo(e){return Co.has(e)}function Do(e){return e.mcpExposed??Co.has(e.name)}function Oo(e){return e.mcpExposed&&Eo(e.name)}function ko(e){return e.catalog.group}function Ao(e){return e.catalog.key??e.name}const jo=new Map(Q.map(e=>[e.name,e.timeoutPolicy])),Mo=new Map(Array.from($.values()).flatMap(e=>e.responseDataTransform?[[e.name,e.responseDataTransform]]:[]));function No(e){if(e!==void 0)return $.get(e)?.postActionObservation}function Po(e){return No(e)!==void 0}function Fo(e){return No(e)===`settle-and-verify`}function Io(e){return e===void 0?j:jo.get(e)??j}function Lo(e){if(e!==void 0)return Mo.get(e)}function Ro(e){return e===void 0?!1:$.get(e)?.recordsSessionAction??!1}function zo(e){return $.get(e)?.targetIdentityVerification}function Bo(e){let t=$.get(e.command);if(t?.recordsSessionAction)return typeof t.recordingEffect==`function`?t.recordingEffect(e):t.recordingEffect}function Vo(){return[...new Set(Array.from(Mo.values()).flatMap(e=>Object.keys(e.fields)))].sort()}function Ho(e){return Number.isInteger(e)&&e>=1&&e<=1e3}function Uo(t,n){if(t>n)throw new e(`INVALID_ARGS`,`batch has ${t} steps; max allowed is ${n}.`)}function Wo(t,n){if(!f(t))throw new e(`INVALID_ARGS`,`Invalid batch step ${n}.`);return t}function Go(t,n){let r=t.input;if(!f(r))throw new e(`INVALID_ARGS`,`Batch step ${n} input must be an object.`);return r}function Ko(t,r){if(t!==void 0)try{return n.parse(t)}catch(t){throw new e(`INVALID_ARGS`,`Batch step ${r} runtime is invalid: ${t instanceof Error?t.message:String(t)}`)}}function qo(e){let t=[];for(let n of e)n.daemon&&t.push({command:n.name,...n.daemon,replayScopedAction:n.recordsSessionAction});return t}function Jo(e){let t={};for(let n of e)n.capability&&(t[n.name]=n.capability);return t}function Yo(e){return e.filter(e=>e.batchable).map(e=>e.name)}const Xo=Yo(Q),Zo=new Set([`batch`,`replay`]),Qo=[`command`,`positionals`,`input`,`flags`,`runtime`],$o=[`platform`,`target`,`device`,`udid`,`serial`,`verbose`,`out`],es=new Set(Xo);function ts(e){return es.has(e)}function ns(e){return typeof e==`string`?e.trim().toLowerCase():``}function rs(t,n){let r=ns(t);if(ts(r))return r;throw new e(`INVALID_ARGS`,`Batch step ${n} command is not available through command batch: ${String(t)}`)}function is(t,n){if(Zo.has(t))throw new e(`INVALID_ARGS`,`Batch step ${n} cannot run ${t}.`)}const as=new Set(Qo);async function os(e,t,n){let r=ps(e.flags),a=r?.batchOnError??`stop`;if(a!==`stop`)return ms(`INVALID_ARGS`,`Unsupported batch on-error mode: ${a}.`);let o=r?.batchMaxSteps??100;if(!Ho(o))return ms(`INVALID_ARGS`,`Invalid batch max-steps: ${String(r?.batchMaxSteps)}`);try{let i=ss(r?.batchSteps,o),a=Date.now(),s=[];for(let[r,a]of i.entries()){let o=await fs(e,t,a,n,r+1,r===i.length-1);if(!o.ok)return{ok:!1,error:{code:o.error.code,message:`Batch failed at step ${o.step} (${a.command}): ${o.error.message}`,hint:o.error.hint,diagnosticId:o.error.diagnosticId,logPath:o.error.logPath,...o.error.retriable===void 0?{}:{retriable:o.error.retriable},...o.error.supportedOn===void 0?{}:{supportedOn:o.error.supportedOn},details:{...o.error.details??{},step:o.step,command:a.command,positionals:a.positionals,executed:r,total:i.length,partialResults:s}}};s.push(o.result)}return{ok:!0,data:{total:i.length,executed:i.length,totalDurationMs:Date.now()-a,results:s}}}catch(e){let t=i(e);return ms(t.code,t.message,t.details)}}function ss(t,n){if(!Array.isArray(t)||t.length===0)throw new e(`INVALID_ARGS`,`batch requires a non-empty batchSteps array.`);Uo(t.length,n);let r=[];for(let n=0;n<t.length;n+=1){let i=t[n];if(!m(i))throw new e(`INVALID_ARGS`,`Invalid batch step at index ${n}.`);let a=Object.keys(i).filter(e=>!as.has(e));if(a.length>0){let t=a.map(e=>`"${e}"`).join(`, `);throw new e(`INVALID_ARGS`,`Batch step ${n+1} has unknown field(s): ${t}. Allowed fields: command, positionals, input, flags, runtime.`)}let o=ns(i.command);if(!o)throw new e(`INVALID_ARGS`,`Batch step ${n+1} requires command.`);if(is(o,n+1),i.positionals!==void 0&&!Array.isArray(i.positionals))throw new e(`INVALID_ARGS`,`Batch step ${n+1} positionals must be an array.`);let s=i.positionals??[];if(s.some(e=>typeof e!=`string`))throw new e(`INVALID_ARGS`,`Batch step ${n+1} positionals must contain only strings.`);if(i.flags!==void 0&&!m(i.flags))throw new e(`INVALID_ARGS`,`Batch step ${n+1} flags must be an object.`);if(i.input!==void 0&&!m(i.input))throw new e(`INVALID_ARGS`,`Batch step ${n+1} input must be an object.`);r.push({command:o,positionals:s,input:i.input,flags:i.flags??{},runtime:Ko(i.runtime,n+1)})}return r}function cs(e,t){let{batchSteps:n,batchOnError:r,batchMaxSteps:i,...a}=t??{};return ls(ps(e),a)}function ls(e,t){let n=ps(e)??{},r=t;for(let e of $o)r[e]===void 0&&n[e]!==void 0&&(r[e]=n[e]);return t}function us(e,n){return t(e)?n?e:`digest`:e}function ds(e,t){let n=e?.responseLevel,r=us(n,t);return r===n?e:{...e,responseLevel:r}}async function fs(e,t,n,r,i,a){let o=Date.now(),s=cs(e.flags,n.flags);s.session===void 0&&(s.session=t);let c=await r({token:e.token,session:t,command:n.command,positionals:n.positionals,input:n.input,flags:s,runtime:n.runtime===void 0?e.runtime:n.runtime,meta:ds(e.meta,a)}),l=Date.now()-o;return c.ok?{ok:!0,step:i,result:{step:i,command:n.command,ok:!0,data:c.data??{},durationMs:l}}:{ok:!1,step:i,error:c.error}}function ps(e){return e}function ms(e,t,n){return{ok:!1,error:{code:e,message:t,...n?{details:n}:{}}}}export{Xi as $,Ye as $n,nr as $t,Ba as A,un as An,de as Ar,Nr as At,ya as B,yt as Bn,ye as Br,Er as Bt,Za as C,mn as Cn,we as Cr,ei as Ct,La as D,rn as Dn,ve as Dr,Hr as Dt,Ua as E,fn as En,xe as Er,Xr as Et,Na as F,Wt as Fn,ce as Fr,Mr as Ft,ma as G,Ct as Gn,mr as Gt,Aa as H,St as Hn,_r as Ht,Ha as I,Rt as In,oe as Ir,Dr as It,pa as J,ft as Jn,dr as Jt,R as K,ut as Kn,sr as Kt,Fa as L,C as Ln,se as Lr,wr as Lt,ja as M,Vt as Mn,le as Mr,Pr as Mt,Pa as N,zt as Nn,ae as Nr,Lr as Nt,Ra as O,ln as On,_e as Or,Ur as Ot,Ma as P,Ht as Pn,ie as Pr,Ir as Pt,Qi as Q,Xe as Qn,er as Qt,Ea as R,wt as Rn,re as Rr,Cr as Rt,zo as S,_n as Sn,g as Sr,$r as St,Xa as T,pn as Tn,Se as Tr,Zr as Tt,ba as U,xt as Un,hr as Ut,Oa as V,vt as Vn,f as Vr,Or as Vt,ha as W,bt as Wn,A as Wt,la as X,Ze as Xn,rr as Xt,oa as Y,Ge as Yn,fr as Yt,ea as Z,qe as Zn,ar as Zt,To as _,In as _n,ke as _r,F as _t,Jo as a,Wn as an,Ie as ar,Vi as at,Lo as b,dn as bn,Ee as br,Qr as bt,Ho as c,Un as cn,Ve as cr,Ii as ct,Wo as d,An as dn,Pe as dr,Fi as dt,ir as en,Qe as er,Ji as et,Q as f,jn as fn,Me as fr,Si as ft,wo as g,Pn as gn,v as gr,mi as gt,Vo as h,Cn as hn,y as hr,yi as ht,rs as i,Vn as in,Be as ir,Wi as it,Va as j,Ot as jn,ue as jr,Fr as jt,Wa as k,cn as kn,m as kr,Br as kt,Ko as l,xn as ln,Ne as lr,Li as lt,Fo as m,wn as mn,je as mr,wi as mt,os as n,$n as nn,He as nr,Ki as nt,qo as o,Bn as on,Le as or,Hi as ot,Po as p,Tn as pn,Ae as pr,Ci as pt,fa as q,pt as qn,pr as qt,Xo as r,Hn as rn,b as rr,Ui as rt,Uo as s,zn as sn,Re as sr,zi as st,ls as t,Qn as tn,S as tr,qi as tt,Go as u,kn as un,ze as ur,Pi as ut,Bo as v,vn,Oe as vr,vi as vt,Ja as w,an as wn,_ as wr,ti as wt,Io as x,sn as xn,Ce as xr,ni as xt,Ro as y,T as yn,De as yr,xi as yt,va as z,Tt as zn,be as zr,Tr as zt};
1
+ import{a as e,b as t,i as n,y as r}from"./sdk-contracts.js";import{a as i,n as a,o,r as s}from"./sdk-batch.js";function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function l(e,t,n,i){let a=n(e[t]);if(a===void 0)throw new r(`COMMAND_FAILED`,i,{response:e});return a}function u(e,t,n){return n(e[t])}function d(e,t,n){let r=e[t];return r===null?null:n(r)}function f(e,t){return l(e,t,S,`Daemon response is missing "${t}".`)}function p(e,t){return u(e,t,S)}function m(e,t){return d(e,t,S)}function h(e,t){return l(e,t,C,`Daemon response is missing numeric "${t}".`)}function g(e,t){return l(e,t,w,`Daemon response has invalid "${t}".`)}function _(e,t){return l(e,t,T,`Daemon response has invalid "${t}".`)}function v(e,t){return u(e,t,E)??`mobile`}function y(e){if(!O(e))return;let t=x(e,`x`),n=x(e,`y`),r=x(e,`width`),i=x(e,`height`);if(t!==void 0&&n!==void 0&&r!==void 0&&i!==void 0)return{x:t,y:n,width:r,height:i}}function b(e){if(!O(e))return;let t=x(e,`x`),n=x(e,`y`);if(t!==void 0&&n!==void 0)return{x:t,y:n}}function x(e,t){let n=e[t];return typeof n==`number`?n:void 0}function S(e){return typeof e==`string`&&e.length>0?e:void 0}function C(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function w(e){return e===`apple`?`ios`:e===`ios`||e===`macos`||e===`android`||e===`harmonyos`||e===`vega`||e===`linux`||e===`web`?e:void 0}function T(e){return e===`simulator`||e===`emulator`||e===`device`?e:void 0}function E(e){return e===`tv`||e===`mobile`||e===`desktop`?e:void 0}function D(e){if(!O(e))throw new r(`COMMAND_FAILED`,`Daemon returned an unexpected response shape.`,{value:e});return e}function O(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function k(e){return O(e)?e:void 0}function A(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}function j(e){return e.split(`
2
+ `).map(e=>e.trim()).filter(e=>e.length>0)}function M(e,t,n={}){let i=e[t];if(i===void 0)return;if(!Number.isInteger(i))throw new r(`INVALID_ARGS`,`Expected ${t} to be an integer.`);let a=i;if(n.min!==void 0&&a<n.min)throw new r(`INVALID_ARGS`,`Expected ${t} to be at least ${n.min}.`);if(n.max!==void 0&&a>n.max)throw new r(`INVALID_ARGS`,`Expected ${t} to be at most ${n.max}.`);return a}function N(e,t,n={}){let i=e[t];if(i!==void 0){if(typeof i!=`number`||!Number.isFinite(i))throw new r(`INVALID_ARGS`,`Expected ${t} to be a finite number.`);if(n.min!==void 0&&i<n.min)throw new r(`INVALID_ARGS`,`Expected ${t} to be at least ${n.min}.`);if(n.max!==void 0&&i>n.max)throw new r(`INVALID_ARGS`,`Expected ${t} to be at most ${n.max}.`);return i}}function P(e){return Number.isInteger(e)&&e>=1&&e<=1e3}function F(e,t){if(e>t)throw new r(`INVALID_ARGS`,`batch has ${e} steps; max allowed is ${t}.`)}const I=`Each batch step is {"command":"<name>","input":{...}}, where input is that command's own structured input object, keyed by field name. There is no positional step form: args, argv, positionals, and flags are not step fields.`;function L(e,t,n=I){if(!c(e))throw new r(`INVALID_ARGS`,`Invalid batch step ${t}.`,{hint:n});return e}function R(e,t,n=I){let i=e.input;if(!c(i))throw new r(`INVALID_ARGS`,`Batch step ${t} input must be an object.`,{hint:n});return i}function z(e,t){if(e!==void 0)try{return n.parse(e)}catch(e){throw new r(`INVALID_ARGS`,`Batch step ${t} runtime is invalid: ${e instanceof Error?e.message:String(e)}`)}}function B(e){let t=e.trim();if(!t||/\s/.test(t))return!1;let n=/^([A-Za-z][A-Za-z0-9+.-]*):(.+)$/.exec(t);if(!n)return!1;let r=n[1]?.toLowerCase(),i=n[2]??``;return r===`http`||r===`https`||r===`ws`||r===`wss`||r===`ftp`||r===`ftps`?i.startsWith(`//`):!0}function V(e){let t=e.trim().split(`:`)[0]?.toLowerCase();return t===`http`||t===`https`}function H(e,t){let n=e?.trim();if(n)return n;if(V(t))return`com.apple.mobilesafari`}const U=new Set(a);async function W(e,n,r){let i=Z(e.flags),a=i?.batchOnError??`stop`;if(a!==`stop`)return Q(`INVALID_ARGS`,`Unsupported batch on-error mode: ${a}.`);let o=i?.batchMaxSteps??100;if(!P(o))return Q(`INVALID_ARGS`,`Invalid batch max-steps: ${String(i?.batchMaxSteps)}`);try{let t=G(i?.batchSteps,o),a=Date.now(),s=[];for(let[i,a]of t.entries()){let o=await X(e,n,a,r,{stepNumber:i+1,totalSteps:t.length,remainingSteps:t.slice(i+1).map(e=>({command:e.command,positionals:e.positionals,flags:e.flags,...e.input===void 0?{}:{input:e.input}}))});if(!o.ok)return{ok:!1,error:{code:o.error.code,message:`Batch failed at step ${o.step} (${a.command}): ${o.error.message}`,hint:o.error.hint,diagnosticId:o.error.diagnosticId,logPath:o.error.logPath,...o.error.retriable===void 0?{}:{retriable:o.error.retriable},...o.error.supportedOn===void 0?{}:{supportedOn:o.error.supportedOn},details:{...o.error.details??{},step:o.step,command:a.command,positionals:a.positionals,executed:i,total:t.length,partialResults:s}}};s.push(o.result)}return{ok:!0,data:{total:t.length,executed:t.length,totalDurationMs:Date.now()-a,results:s}}}catch(e){let n=t(e);return Q(n.code,n.message,n.details)}}function G(e,t){if(!Array.isArray(e)||e.length===0)throw new r(`INVALID_ARGS`,`batch requires a non-empty batchSteps array.`);F(e.length,t);let n=[];for(let t=0;t<e.length;t+=1){let a=e[t];if(!O(a))throw new r(`INVALID_ARGS`,`Invalid batch step at index ${t}.`);let s=Object.keys(a).filter(e=>!U.has(e));if(s.length>0){let e=s.map(e=>`"${e}"`).join(`, `);throw new r(`INVALID_ARGS`,`Batch step ${t+1} has unknown field(s): ${e}. Allowed fields: command, positionals, input, flags, runtime.`)}let c=o(a.command);if(!c)throw new r(`INVALID_ARGS`,`Batch step ${t+1} requires command.`);if(i(c,t+1),a.positionals!==void 0&&!Array.isArray(a.positionals))throw new r(`INVALID_ARGS`,`Batch step ${t+1} positionals must be an array.`);let l=a.positionals??[];if(l.some(e=>typeof e!=`string`))throw new r(`INVALID_ARGS`,`Batch step ${t+1} positionals must contain only strings.`);if(a.flags!==void 0&&!O(a.flags))throw new r(`INVALID_ARGS`,`Batch step ${t+1} flags must be an object.`);if(a.input!==void 0&&!O(a.input))throw new r(`INVALID_ARGS`,`Batch step ${t+1} input must be an object.`);n.push({command:c,positionals:l,input:a.input,flags:a.flags??{},runtime:z(a.runtime,t+1)})}return n}function K(e,t){let{batchSteps:n,batchOnError:r,batchMaxSteps:i,...a}=t??{};return q(Z(e),a)}function q(e,t){let n=Z(e)??{},r=t;for(let e of s)r[e]===void 0&&n[e]!==void 0&&(r[e]=n[e]);return t}function J(t,n){return e(t)?n?t:`digest`:t}function Y(e,t){let n=e?.responseLevel,r=J(n,t);return r===n?e:{...e,responseLevel:r}}async function X(e,t,n,r,i){let{stepNumber:a,totalSteps:o}=i,s=a===o,c=Date.now(),l=K(e.flags,n.flags);l.session===void 0&&(l.session=t);let u=await r({token:e.token,session:t,command:n.command,positionals:n.positionals,input:n.input,flags:l,runtime:n.runtime===void 0?e.runtime:n.runtime,meta:Y(e.meta,s)},i),d=Date.now()-c;return u.ok?{ok:!0,step:a,result:{step:a,command:n.command,ok:!0,data:u.data??{},durationMs:d}}:{ok:!1,step:a,error:u.error}}function Z(e){return e}function Q(e,t,n){return{ok:!1,error:{code:e,message:t,...n?{details:n}:{}}}}export{h as C,A as D,j as E,c as O,_ as S,f as T,b as _,H as a,m as b,P as c,L as d,M as f,O as g,D as h,V as i,z as l,k as m,W as n,I as o,N as p,B as r,F as s,q as t,R as u,y as v,g as w,p as x,v as y};
@@ -0,0 +1,2 @@
1
+ import{d as e,y as t}from"./sdk-contracts.js";import{f as n,n as r}from"./sdk-device.js";function i(e,t){return{ok:!1,code:`INVALID_ARGS`,message:e,...t?{hint:t}:{}}}const a=[`visible`,`hidden`,`exists`,`absent`,`editable`,`selected`,`focused`,`text`];function o(e){return!!(e&&[e.x,e.y,e.width,e.height].every(Number.isFinite)&&e.width>0&&e.height>0)}function s(e,t){return t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height}function c(e){return e.width*e.height}function l(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function u(e){let t=null,n=-1;for(let r of e){let e=r.width*r.height;e>n&&(t=r,n=e)}return t}function d(e,t){return f(e.x,e.x+e.width,t.x,t.x+t.width)&&f(e.y,e.y+e.height,t.y,t.y+t.height)}function f(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function ee(e){let t=`${e??``}`.toLowerCase();return t.includes(`scroll`)||t.includes(`recyclerview`)||t.includes(`listview`)||t.includes(`gridview`)||t.includes(`collectionview`)||t===`table`}function te(e){return ee(e.type)?!0:`${e.role??``} ${e.subrole??``}`.toLowerCase().includes(`scroll`)}function ne(e){return new Map(e.map(e=>[e.index,e]))}function re(e,t,n,r){let i=t,a=new Set;for(;typeof i.parentIndex==`number`&&!a.has(i.index);){if(a.add(i.index),i=n.get(i.parentIndex)??e[i.parentIndex],!i)return null;let t=r(i);if(t!==null)return t}return null}function ie(e,t,n){return re(e,t,ne(e),e=>n(e)?e:null)}function p(e){let t=e.trim().replaceAll(/XCUIElementType/gi,``).replace(/^AX/,``).toLowerCase(),n=Math.max(t.lastIndexOf(`.`),t.lastIndexOf(`/`));return n!==-1&&(t=t.slice(n+1)),t}function ae(e,t){let n=p(e);return n?t===`android`?n.includes(`edittext`)||n.includes(`autocompletetextview`):n.includes(`textfield`)||n.includes(`securetextfield`)||n.includes(`searchfield`)||n.includes(`textview`)||n.includes(`textarea`)||n===`search`:!0}function oe(e){let t=e.trim();return!(!t||/^(true|false)$/i.test(t)||/^\d+$/.test(t))}function se(e){if(typeof e!=`string`)return!1;let t=e.trim();return t?!/^(true|false)$/i.test(t):!1}function m(e){return[e.label,e.value,e.identifier].map(e=>typeof e==`string`?e.trim():``).filter(e=>e.length>0)[0]??``}const ce=Symbol(`SnapshotVisibility`);function le(e,t={}){let n,r,i=()=>(n||(n=ne(e),t.onNodeMapBuilt?.()),n),a=()=>(r||(r=de(e),t.onViewportRectsCollected?.()),r),o=n=>pe(e,n,a(),t.onContainingRectFallback),s=n=>{let r=ge(n,i(),e=>!!e.rect)?.rect;if(r)return r;let o=a();return o.length===0?null:pe(e,n.rect??{x:0,y:0,width:0,height:0},o,t.onContainingRectFallback)},c=e=>{if(!e.rect)return!0;let t=s(e);return!t||d(e.rect,t)},l=e=>e.rect?c(e)?he(e.rect,o(e.rect)):!1:!0;return{[ce]:!0,get nodeByIndex(){return i()},get viewportRects(){return a()},findAncestor(t,n){return re(e,t,i(),n)},isVisibleInEffectiveViewport:c,isVisibleOnScreen:l,resolveEffectiveViewport:s,resolveViewport:o}}function ue(e){let t=[e.type,e.role,e.subrole].map(e=>p(e??``)).join(` `);return t.includes(`application`)||t.includes(`window`)}function de(e){return e.flatMap(e=>ue(e)&&o(e.rect)?[e.rect]:[])}function fe(e,t,n){return pe(e,t,n??de(e))}function pe(t,n,r,i){let a=e(n),o=e=>l(e,a.x,a.y);return(u(r.filter(o))??u(r))||(i?.(),u(t.flatMap(e=>me(e.rect)&&o(e.rect)?[e.rect]:[])))}function me(e){return e?Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.width)&&Number.isFinite(e.height):!1}function he(e,t){return!t||t.width<=0||t.height<=0||l(t,e.x+e.width/2,e.y+e.height/2)}function ge(e,t,n=()=>!0){let r=typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0,i=new Set;for(;r&&!i.has(r.index);){if(i.add(r.index),n(r)&&te(r))return r;r=typeof r.parentIndex==`number`?t.get(r.parentIndex):void 0}return null}function _e(e,t){if(t===`android`&&e.visibleToUser===!1)return!1;let n=p(e.type??``);return n.includes(`application`)||n.includes(`window`)||n.includes(`scrollview`)||n.includes(`tableview`)||n.includes(`collectionview`)||n===`table`||n===`list`||n===`listview`?!1:t===`android`?e.hittable===!0&&o(e.rect):e.hittable===!0||o(e.rect)}function h(e){return e.hittable===!0?!0:e.rect?e.rect.width>0&&e.rect.height>0:!1}function ve(e,t){return ae(e.type??``,t)&&e.enabled!==!1}const ye=new Set([`id`,`role`,`text`,`label`,`value`,`appname`,`windowtitle`]),be=new Set([`visible`,`hidden`,`editable`,`selected`,`focused`,`enabled`,`hittable`]),g=new Set([...ye,...be]),xe=[...g],Se=new Set(`button.imagebutton.link.cell.statictext.checkedtextview.textfield.textbox.edittext.textarea.switch.slider.image.imageview.webview.framelayout.linearlayout.relativelayout.constraintlayout.viewgroup.view.listview.recyclerview.collectionview.list.searchfield.segmentedcontrol.group.window.checkbox.radio.menuitem.toolbar.scrollarea.scrollview.nestedscrollview.table.application.navigationbar.tabbar.tab.alert.dialog.header`.split(`.`));function Ce(e){return Se.has(e.trim().toLowerCase())}const we=new Map([[`"`,`"`],[`'`,`'`],[`\\`,`\\`],[`/`,`/`],[`b`,`\b`],[`f`,`\f`],[`n`,`
2
+ `],[`r`,`\r`],[`t`,` `]]);function _(e){let n=e.trim();if(!n)throw new t(`INVALID_ARGS`,`Selector expression cannot be empty`);let r=Oe(n);if(r.length===0)throw new t(`INVALID_ARGS`,`Selector expression cannot be empty`);return{raw:n,selectors:r.map(e=>Ee(e))}}function v(e){try{return _(e)}catch{return null}}function y(e){let t=e.trim();if(!t)return!1;if(t===`||`)return!0;let n=t.indexOf(`=`);if(n!==-1){let e=t.slice(0,n).trim().toLowerCase();return g.has(e)}return g.has(t.toLowerCase())}function Te(e){let t=e.trim(),n=t.indexOf(`=`);if(n===-1)return null;let r=t.slice(0,n).trim().toLowerCase();if(!r||g.has(r))return null;let i=t.slice(n+1).trim();if(!i)return null;let a=je(i).trim();return a?{key:r,value:a}:null}function b(e,t={}){if(e.length===0)return null;let n=t.preferTrailingValue??!1,r=0,i=[];for(;r<e.length;){let t=e[r];if(t===void 0||!y(t))break;r+=1;let n=e.slice(0,r).join(` `).trim();n&&v(n)&&i.push(r)}if(i.length===0)return null;let a=i.at(-1);if(a===void 0)return null;let o=a;if(n)for(let t=i.length-1;t>=0;--t){let n=i[t];if(n!==void 0&&n<e.length){o=n;break}}let s=e.slice(0,o).join(` `).trim();return s?{selectorExpression:s,rest:e.slice(o)}:null}function Ee(e){let n=e.trim();if(!n)throw new t(`INVALID_ARGS`,`Selector segment cannot be empty`);let r=ke(n);if(r.length===0)throw new t(`INVALID_ARGS`,`Invalid selector segment: ${e}`);return{raw:n,terms:r.map(De)}}function De(e){let n=e.trim();if(!n)throw new t(`INVALID_ARGS`,`Empty selector term`);let r=n.indexOf(`=`);if(r===-1){let r=n.toLowerCase();if(!be.has(r))throw new t(`INVALID_ARGS`,`Invalid selector term "${e}", expected key=value`);return{key:r,value:!0}}let i=n.slice(0,r).trim().toLowerCase(),a=n.slice(r+1).trim();if(!g.has(i))throw new t(`INVALID_ARGS`,`Unknown selector key: ${i}`);if(!a)throw new t(`INVALID_ARGS`,`Missing selector value for key: ${i}`);if(be.has(i)){let e=Pe(a);if(e===null)throw new t(`INVALID_ARGS`,`Invalid boolean value for ${i}: ${a}`);return{key:i,value:e}}return{key:i,value:je(a)}}function Oe(e){let n=[],r=``,i=null;for(let a=0;a<e.length;a+=1){let o=e[a];if((o===`"`||o===`'`)&&!Fe(e,a)){i=Ae(i,o),r+=o;continue}if(!i&&o===`|`&&e[a+1]===`|`){let i=r.trim();if(!i)throw new t(`INVALID_ARGS`,`Invalid selector fallback expression: ${e}`);n.push(i),r=``,a+=1;continue}r+=o}let a=r.trim();if(!a)throw new t(`INVALID_ARGS`,`Invalid selector fallback expression: ${e}`);return n.push(a),n}function ke(e){let n=[],r=``,i=null;for(let t=0;t<e.length;t+=1){let a=e.charAt(t);if((a===`"`||a===`'`)&&!Fe(e,t)){i=Ae(i,a),r+=a;continue}if(!i&&/\s/.test(a)){r.trim()&&n.push(r.trim()),r=``;continue}r+=a}if(i)throw new t(`INVALID_ARGS`,`Unclosed quote in selector: ${e}`);return r.trim()&&n.push(r.trim()),n}function Ae(e,t){return e?e===t?null:e:t}function je(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?Me(t.slice(1,-1)):t}function Me(e){let t=``,n=0;for(;n<e.length;){let r=e.charAt(n);if(r!==`\\`){t+=r,n+=1;continue}let i=e.charAt(n+1);if(!i){t+=r,n+=1;continue}let a=Ne(i);if(a!==null){t+=a,n+=2;continue}if(i===`u`){let r=e.slice(n+2,n+6);if(/^[0-9a-fA-F]{4}$/.test(r)){t+=String.fromCharCode(Number.parseInt(r,16)),n+=6;continue}}t+=r,n+=1}return t}function Ne(e){return we.get(e)??null}function Pe(e){let t=je(e).toLowerCase();return t===`true`||t!==`false`&&null}function Fe(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function Ie(e){return a.includes(e)}const Le=`is requires predicate: ${a.join(`|`)}`;function Re(e){let t=e.toLowerCase();return Ie(t)?{ok:!0,predicate:t}:i(Le,ze)}const ze=`Use "is <predicate> <selector>" or "is <selector> <predicate>". visible|hidden|editable|selected|focused double as selector keys: a bare predicate token after the selector is read as the predicate, so write key=true (e.g. visible=true) inside the selector to use it as a filter instead.`;function Be(e){if(Ie((e[0]??``).toLowerCase()))return e;for(let t=1;t<e.length;t+=1){let n=(e[t]??``).toLowerCase();if(Ie(n)&&v(e.slice(0,t).join(` `)))return[n,...e.slice(0,t),...e.slice(t+1)]}return e}function Ve(e){let{predicate:t,node:n,nodes:r,expectedText:i,platform:a}=e,o=m(n),s=ve(n,a),c=n.selected===!0,l=n.focused===!0,u=t===`text`?h(n):Ue(n,le(r),a),d=!1;switch(t){case`visible`:d=u;break;case`hidden`:d=!u;break;case`editable`:d=s;break;case`selected`:d=c;break;case`focused`:d=l;break;case`text`:d=o===(i??``);break;default:return He(t)}let f=t===`text`?`expected="${i??``}" actual="${o}"`:`actual=${JSON.stringify({visible:u,editable:s,selected:c,focused:l})}`;return{pass:d,actualText:o,details:f}}function He(e){throw Error(`Unhandled is predicate: ${String(e)}`)}function Ue(e,t,n){if(n===`android`&&e.visibleToUser===!1)return!1;if(o(e.rect))return t.isVisibleInEffectiveViewport(e);if(e.rect)return!1;if(n!==`android`&&e.hittable===!0)return!0;let r=We(e,t,n);return r?o(r.rect)?t.isVisibleInEffectiveViewport(r):n!==`android`&&r.hittable===!0:!1}function We(e,t,n){return t.findAncestor(e,e=>_e(e,n)?e:null)}function Ge(e){let t=Be(e),n=t[0]??``;return{predicate:n,split:b(t.slice(1),{preferTrailingValue:n===`text`})}}const Ke=`is requires a selector expression`,qe=`is text requires expected text value`;function Je(e){let{predicate:t,split:n}=Ge([...e]),r=Re(t);if(!r.ok)return r;if(!n)return i(Ke);let a=n.rest.join(` `).trim();return r.predicate===`text`&&!a?i(qe):r.predicate!==`text`&&n.rest.length>0?i(`is ${r.predicate} does not accept trailing values`):{ok:!0,predicate:r.predicate,selectorExpression:n.selectorExpression,expectedText:a}}function Ye(e){return e===`text`||e===`attrs`?{ok:!0,format:e}:i(`get only supports text or attrs`)}function Xe(e){let t=e[0];if(t?.startsWith(`@`)){let n=e.slice(1).join(` `).trim();return{ok:!0,ref:t,...n?{label:n}:{}}}let n=e.join(` `).trim();return n?{ok:!0,selector:n}:i(`get requires @ref or selector expression`)}function Ze(e){return e?{ok:!0,text:e}:i(`wait requires text`)}function Qe(e){return Array.from(new Set(e))}function $e(e){return JSON.stringify(x(e))}function x(e){if(Array.isArray(e))return e.map(x);if(!e||typeof e!=`object`)return e;let t=e;return Object.fromEntries(Object.keys(t).sort().map(e=>[e,x(t[e])]))}function et(e){let t=0,n=e.length;for(;t<n&&e[t]===`-`;)t+=1;for(;n>t&&e[n-1]===`-`;)--n;return e.slice(t,n)}const tt=/^#\s*agent-device:target-v(\d+)(?:\s+(\S.*))?$/,nt=/^#\s*agent-device:targets-v(\d+)(?:\s+(\S.*))?$/,rt=4096;function S(e){return e.normalize(`NFC`)}function it(e){if(e===void 0)return;let t=S(e);return t.length>0?t:void 0}function at(e){return S(e)}function ot(e){if(e===void 0)return;let t=S(e).trim().replaceAll(/\s+/g,` `);return t.length>0?t:void 0}function C(e){return Buffer.byteLength(e,`utf8`)}function w(e,t){if(C(e)<=t)return e;let n=e.length;for(;n>0&&C(e.slice(0,n))>t;)--n;if(n>0){let t=e.charCodeAt(n-1);t>=55296&&t<=56319&&--n}return e.slice(0,n)}function st(e){let t={};return e.id!==void 0&&(t.id=e.id),t.role=e.role,e.label!==void 0&&(t.label=e.label),t.ancestry=e.ancestry.map(ct),t.sibling=e.sibling,t.viewportOrder=e.viewportOrder,e.scrollRegion&&(t.scrollRegion=lt(e.scrollRegion)),e.rect&&(t.rect=ut(e.rect)),t.verification=e.verification,t}function ct(e){let t={role:e.role};return e.label!==void 0&&(t.label=e.label),t}function lt(e){let t={role:e.role};return e.id!==void 0&&(t.id=e.id),e.label!==void 0&&(t.label=e.label),t}function ut(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}function dt(e){return JSON.stringify(st(e))}function ft(e){return`# agent-device:target-v1 ${dt(e)}`}function pt(e){return JSON.stringify({source:st(e.source),destination:st(e.destination)})}function mt(e){return`# agent-device:targets-v1 ${pt(e)}`}function ht(e){let t=e.trim(),n=nt.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:gt((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function gt(e){if(C(e)>8320)throw new t(`INVALID_ARGS`,`targets-v1 annotation exceeds the 8320-byte payload cap.`);let n;try{n=JSON.parse(e)}catch{throw new t(`INVALID_ARGS`,`targets-v1 annotation is not valid JSON.`)}if(typeof n!=`object`||!n||Array.isArray(n))throw new t(`INVALID_ARGS`,`targets-v1 annotation must be a JSON object.`);let r=n;if(r.source===void 0||r.destination===void 0)throw new t(`INVALID_ARGS`,`targets-v1 annotation requires source and destination evidence.`);return{source:vt(JSON.stringify(r.source)),destination:vt(JSON.stringify(r.destination))}}function _t(e){let t=e.trim();if(!t.startsWith(`#`))return{kind:`none`};let n=tt.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:vt((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function vt(e){if(C(e)>4096)throw new t(`INVALID_ARGS`,`target-v1 annotation exceeds the ${rt}-byte payload cap.`);let n;try{n=JSON.parse(e)}catch{throw new t(`INVALID_ARGS`,`target-v1 annotation is not valid JSON.`)}if(typeof n!=`object`||!n||Array.isArray(n))throw new t(`INVALID_ARGS`,`target-v1 annotation must be a JSON object.`);let r=n,i=yt(r.role,`role`),a=bt(r.id,`id`),o=xt(r.label,`label`),s=Ct(r.ancestry),c=Tt(r.sibling,`sibling`,0),l=Tt(r.viewportOrder,`viewportOrder`,0),u=Et(r.scrollRegion),d=Dt(r.rect),f=Ot(r.verification);return{...a===void 0?{}:{id:a},role:i,...o===void 0?{}:{label:o},ancestry:s,sibling:c,viewportOrder:l,...u?{scrollRegion:u}:{},...d?{rect:d}:{},verification:f}}function yt(e,n){if(e===void 0)throw new t(`INVALID_ARGS`,`target-v1 "${n}" is required.`);if(typeof e!=`string`)throw new t(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);return St(at(e),n)}function bt(e,n){if(e===void 0)return;if(typeof e!=`string`)throw new t(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);let r=it(e);return r===void 0?void 0:St(r,n)}function xt(e,n){if(e===void 0)return;if(typeof e!=`string`)throw new t(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);let r=ot(e);return r===void 0?void 0:St(r,n)}function St(e,n){if(C(e)>256)throw new t(`INVALID_ARGS`,`target-v1 "${n}" exceeds the 256-byte field cap.`);return e}function Ct(e){if(e===void 0)return[];if(!Array.isArray(e))throw new t(`INVALID_ARGS`,`target-v1 "ancestry" must be an array.`);if(e.length>8)throw new t(`INVALID_ARGS`,`target-v1 "ancestry" exceeds the 8-entry cap.`);return e.map((e,t)=>wt(e,t))}function wt(e,n){if(typeof e!=`object`||!e||Array.isArray(e))throw new t(`INVALID_ARGS`,`target-v1 "ancestry[${n}]" must be an object.`);let r=e,i=yt(r.role,`ancestry[${n}].role`),a=xt(r.label,`ancestry[${n}].label`);return{role:i,...a===void 0?{}:{label:a}}}function Tt(e,n,r){if(e===void 0)return r;if(typeof e!=`number`||!Number.isSafeInteger(e)||e<0)throw new t(`INVALID_ARGS`,`target-v1 "${n}" must be a non-negative integer.`);return e}function Et(e){if(e===void 0)return;if(typeof e!=`object`||!e||Array.isArray(e))throw new t(`INVALID_ARGS`,`target-v1 "scrollRegion" must be an object.`);let n=e,r=yt(n.role,`scrollRegion.role`),i=bt(n.id,`id`),a=xt(n.label,`scrollRegion.label`);return{role:r,...i===void 0?{}:{id:i},...a===void 0?{}:{label:a}}}function Dt(e){if(e===void 0)return;if(typeof e!=`object`||!e||Array.isArray(e))throw new t(`INVALID_ARGS`,`target-v1 "rect" must be an object.`);let n=e;return{x:T(n.x,`rect.x`),y:T(n.y,`rect.y`),width:T(n.width,`rect.width`),height:T(n.height,`rect.height`)}}function T(e,n){if(typeof e!=`number`||!Number.isFinite(e))throw new t(`INVALID_ARGS`,`target-v1 "${n}" must be a finite number.`);return e}function Ot(e){if(e===`verified`||e===`unverifiable`)return e;throw new t(`INVALID_ARGS`,`target-v1 "verification" must be "verified" or "unverifiable".`)}function kt(e){let t=at(p(e.type??``)),n=it(e.identifier),r=ot(e.label);return{...n===void 0?{}:{id:w(n,256)},role:w(t,256),...r===void 0?{}:{label:w(r,256)}}}function At(e,t){return e.id===t.id&&e.role===t.role&&e.label===t.label}function jt(e,t){let n=0;for(let r of e)kt(r).id===t&&(n+=1);return n}function Mt(e,t){if(e.id===void 0||jt(t,e.id)<=1)return e;let{role:n,label:r}=e;return{role:n,...r===void 0?{}:{label:r}}}function Nt(e,t){let n=0;for(let r of e)if(r.parentIndex===t.parentIndex){if(r.index===t.index)return n;n+=1}return 0}function Pt(e,t){return{documentOrder:e.index,sibling:Nt(t,e)}}function Ft(e,t){return e.documentOrder===t.documentOrder&&e.sibling===t.sibling}function It(e){return{...e.id===void 0?{}:{id:e.id},role:e.role,...e.label===void 0?{}:{label:e.label}}}function Lt(e,t){return t.id===void 0?e.role===t.role&&e.label===t.label:e.id===t.id}function Rt(e,t){if(e.length<t.length)return!1;for(let[n,r]of t.entries()){let t=e[n];if(!t||t.role!==r.role||r.label!==void 0&&t.label!==r.label)return!1}return!0}function zt(e,t){let n=[];return e.id!==t.id&&n.push(`id: recorded=${e.id??`(none)`} observed=${t.id??`(none)`}`),e.role!==t.role&&n.push(`role: recorded=${e.role} observed=${t.role}`),e.label!==t.label&&n.push(`label: recorded=${e.label??`(none)`} observed=${t.label??`(none)`}`),n}function Bt(e){return e?`${e.role}${e.label?`/${e.label}`:``}`:`(missing)`}function Vt(e,t){return!t||t.role!==e.role||e.label!==void 0&&t.label!==e.label}function Ht(e,t){for(let[n,r]of e.entries()){let e=t[n];if(Vt(r,e))return[`ancestry[${n}]: recorded=${Bt(r)} observed=${Bt(e)}`]}return[]}function Ut(e,t,n={}){let r=[],i=p(e.type??``),a=Wt(e,n.nodes),o=D(e.label),s=D(e.value),c=D(m(e)),l=n.action===`fill`;a&&r.push(`id=${E(a)}`),i&&o&&r.push(l?`role=${E(i)} label=${E(o)} editable=true`:`role=${E(i)} label=${E(o)}`),o&&r.push(l?`label=${E(o)} editable=true`:`label=${E(o)}`),s&&r.push(l?`value=${E(s)} editable=true`:`value=${E(s)}`),c&&c!==o&&c!==s&&r.push(l?`text=${E(c)} editable=true`:`text=${E(c)}`),i&&l&&!r.some(e=>e.includes(`editable=true`))&&r.push(`role=${E(i)} editable=true`);let u=Qe(r);return u.length===0&&i&&u.push(l?`role=${E(i)} editable=true`:`role=${E(i)}`),u.length===0&&h(e)&&u.push(`visible=true`),u}function Wt(e,t){let n=D(e.identifier);if(!n||!t)return n;let r=kt(e).id;return r===void 0?n:jt(t,r)>1?null:n}function E(e){return JSON.stringify(e)}function D(e){return e&&e.trim()||null}const Gt=[`any`,`text`,`label`,`value`,`role`,`id`],Kt=[`text`,`label`,`value`,`role`,`id`];function qt(e){let t=e?.toLowerCase();return t===`press`||t===`tap`?`click`:t}function Jt(e){return e===`exists`||e===`wait`||e===`get_text`||e===`get_attrs`||e===`list`}function Yt(e,t,n,r={}){let i=k(n);if(!i)return{matches:[],score:0};let a=0,o=[];for(let n of e){if(r.requireRect&&!n.rect)continue;let e=Xt(n,t,i);if(!(e<=0)){if(e>a){a=e,o.length=0,o.push(n);continue}e===a&&o.push(n)}}return{matches:o,score:a}}function Xt(e,t,n){switch(t){case`role`:return Zt(e.type,n);case`label`:return O(e.label,n);case`value`:return O(e.value,n);case`id`:return O(e.identifier,n);default:return Math.max(O(e.label,n),O(e.value,n),O(e.identifier,n))}}function O(e,t){let n=k(e??``);return n?n===t?2:+!!n.includes(t):0}function Zt(e,t){let n=Qt(e??``);return n?n===t?2:+!!n.includes(t):0}function k(e){return e.trim().toLowerCase().replaceAll(/\s+/g,` `)}function Qt(e){let t=e.trim();return t?(t=(t.split(`.`).pop()??t).replaceAll(/XCUIElementType/gi,``).toLowerCase(),t):``}const $t=`find requires a value`,en=`find actions: click (default; press/tap are aliases), list, focus, fill, type, exists, wait, get text, get attrs — there is no longpress/swipe find action. Run find "<text>" list to inspect every match with its @ref without acting, then dispatch the gesture on the chosen ref, e.g. longpress @eNN.`;function tn(e,t){if(e.length===0)return{ok:!1,code:`INVALID_ARGS`,message:`find requires a locator or text`};let n=A([...e]);return n.query?t?.findFirst&&t?.findLast?{ok:!1,code:`INVALID_ARGS`,message:`find accepts only one of --first or --last`}:{ok:!0,parsed:n}:{ok:!1,code:`INVALID_ARGS`,message:$t}}const nn=[`exists`,`list`,`click`,`focus`];function rn(e){return nn.includes(e)}function A(e){let n=`any`,r=0;Kt.includes(e[0])&&(n=e[0],r=1);let i=e[r]??``,a=e.slice(r+1);if(a.length===0)return{locator:n,query:i,action:`click`};let o=qt(a[0]);if(rn(o))return{locator:n,query:i,action:o};if(o===`get`)return{locator:n,query:i,action:an(a[1])};if(o===`wait`){let e=sn(a[1]);return{locator:n,query:i,action:`wait`,timeoutMs:e??void 0}}if(o===`fill`||o===`type`){let e=a.slice(1);return{locator:n,query:i,action:o,value:e.length===0?void 0:e.join(` `)}}throw new t(`INVALID_ARGS`,`Unsupported find action: ${a[0]}`,{hint:en})}function an(e){let n=e?.toLowerCase();if(n===`text`)return`get_text`;if(n===`attrs`)return`get_attrs`;throw new t(`INVALID_ARGS`,`find get only supports text or attrs`)}function on(e,t){return e!==`any`||!t.includes(`=`)&&!t.includes(`||`)?null:v(t)?t:null}function sn(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function cn(e,t,n){return t.terms.every(t=>ln(e,t,n))}function ln(e,t,n){switch(t.key){case`id`:return j(e.identifier,String(t.value));case`role`:return j(p(e.type??``),String(t.value));case`label`:return j(e.label,String(t.value));case`value`:return j(e.value,String(t.value));case`text`:return j(m(e),String(t.value));case`appname`:return j(e.appName,String(t.value));case`windowtitle`:return j(e.windowTitle,String(t.value));case`visible`:return h(e)===!!t.value;case`hidden`:return!h(e)==!!t.value;case`editable`:return ve(e,n)===!!t.value;case`selected`:return e.selected===!0==!!t.value;case`focused`:return e.focused===!0==!!t.value;case`enabled`:return e.enabled!==!1==!!t.value;case`hittable`:return e.hittable===!0==!!t.value;default:return!1}}function j(e,t){return k(e??``)===k(t)}function un(e,t,n){let r=n.requireRect??!1,i=n.requireUnique??!0,a=[],o=null;for(let[s,c]of t.selectors.entries()){let t=_n(e,c,n.platform,r);if(a.push({selector:c.raw,matches:t.count}),!(t.count===0||!t.firstNode)){if(o??={selector:c,selectorIndex:s,matchedNodes:t.candidates},i&&t.count!==1){if(!n.disambiguateAmbiguous||!t.disambiguated||!t.tiebreak)continue;return{matchedNodes:t.candidates,firstMatch:o,resolution:{node:t.disambiguated,selector:c,selectorIndex:s,matches:t.count,diagnostics:a,disambiguation:{matchCount:t.count,tiebreak:t.tiebreak,alternatives:t.candidates.filter(e=>e!==t.disambiguated)}}}}return{matchedNodes:t.candidates,firstMatch:o,resolution:{node:t.firstNode,selector:c,selectorIndex:s,matches:t.count,diagnostics:a}}}}return{resolution:null,matchedNodes:o?.matchedNodes??[],firstMatch:o}}function dn(e,t,n){return un(e,t,n).resolution}function fn(e,t,n){let r=n.requireRect??!1;for(let[i,a]of t.selectors.entries()){let t=e.filter(e=>r&&!e.rect?!1:cn(e,a,n.platform));if(t.length>0)return{selector:a,selectorIndex:i,matchedNodes:t}}return null}function pn(e,t,n){let r=n.requireRect??!1,i=[];for(let[a,o]of t.selectors.entries()){let t=xn(e,o,n.platform,r);if(i.push({selector:o.raw,matches:t}),t>0)return{selectorIndex:a,selector:o,matches:t,diagnostics:i}}return null}const mn=`Snapshot refs expire when the UI changes. Run snapshot -i and retry with a fresh @ref.`;function hn(e){return e.some(e=>e.matches>1)?`Add more terms to disambiguate (e.g. role=button text="Sign in"), use an @ref from snapshot -i, or use find <text> --first/--last.`:`Selector text/label values match exactly (quote multi-word values: text="Sign in"). Run snapshot -i to see current elements and refs, or use find <text> for contains matching.`}function gn(e,t,n){if(t.length===0)return`Selector did not match: ${e}`;let r=t.map(e=>`${e.selector} -> ${e.matches}`).join(`, `);return n.unique??!0?`Selector did not resolve uniquely (${r})`:`Selector did not match (${r})`}function _n(e,t,n,r){let i=0,a=null,o=[],s={best:null,bestVisible:!1,tie:!1},c=le(e).isVisibleOnScreen;for(let l of e)r&&!l.rect||cn(l,t,n)&&(i+=1,a??=l,o.push(l),vn(s,l,c));return{count:i,firstNode:a,disambiguated:s.tie?null:s.best,tiebreak:s.tie?null:yn(o,s.best,c),candidates:o}}function vn(e,t,n){if(!e.best){e.best=t;return}e.bestVisible||=n(e.best);let r=n(t);if(r!==e.bestVisible){r&&(e.best=t,e.bestVisible=!0,e.tie=!1);return}let i=Sn(t,e.best);i.result>0?(e.best=t,e.tie=!1):i.result===0&&(e.tie=!0)}function yn(e,t,n){if(!t)return null;let r=null;for(let i of e)i!==t&&(!r||bn(i,r,n).result>0)&&(r=i);return r?bn(t,r,n).criterion:null}function bn(e,t,n){let r=n(e);return r===n(t)?Sn(e,t):{result:r?1:-1,criterion:`visible`}}function xn(e,t,n,r){let i=0;for(let a of e)r&&!a.rect||cn(a,t,n)&&(i+=1);return i}function Sn(e,t){let n=e.depth??0,r=t.depth??0;if(n!==r)return{result:n>r?1:-1,criterion:`deepest`};let i=Cn(e),a=Cn(t);return i===a?{result:0,criterion:null}:{result:i<a?1:-1,criterion:`smallest-area`}}function Cn(e){return e.rect?e.rect.width*e.rect.height:1/0}const wn={act:{ambiguity:`reject-candidates`,requireRect:!0},actCoveredDiagnosis:{ambiguity:`first-match`,requireRect:!0},readText:{ambiguity:`disambiguate`,requireRect:!1},readUnique:{ambiguity:`fail-closed`,requireRect:!1},readAny:{ambiguity:`first-match`,requireRect:!1},wait:{ambiguity:`first-match`,requireRect:!1},findAct:{ambiguity:`reject-candidates`,requireRect:!0},readList:{ambiguity:`reject-candidates`,requireRect:!1},cropTarget:{ambiguity:`fail-closed`,requireRect:!0}};function Tn(e){return e.ambiguity===`first-match`?{requireRect:e.requireRect,requireUnique:!1}:{requireRect:e.requireRect,requireUnique:!0,disambiguateAmbiguous:e.ambiguity===`disambiguate`}}function En(e,t){let n=e===`is`?Ge([...t]).split:b([...t]);return n?v(n.selectorExpression)?{kind:`expression`,expression:n.selectorExpression,rest:n.rest}:{kind:`invalid`}:{kind:`not-applicable`}}function Dn(e){return{platform:e.platform,...Tn({ambiguity:e.allowDisambiguation?`disambiguate`:`fail-closed`,requireRect:e.requireRect})}}function On(e,t,n){let r=v(e);if(!r)return{kind:`unresolved`,reason:`parse-invalid`,matchedNodes:[]};let{resolution:i,matchedNodes:a}=un(t,r,Dn(n));return i?{kind:`resolved`,winner:i.node,matchedNodes:a,matchCount:a.length,...i.disambiguation?{disambiguation:{tiebreak:i.disambiguation.tiebreak,matchCount:i.disambiguation.matchCount,alternatives:i.disambiguation.alternatives}}:{}}:{kind:`unresolved`,reason:a.length>0?`ambiguous`:`no-match`,matchedNodes:a}}function kn(e,t,n={}){return Ut(e,t,n)}function An(e,t,n){let r=v(e);if(!r)return;let i=dn(t,r,Dn(n));if(i)return{node:i.node,basis:Mn(i.selector)}}function jn(e){if(!e)return;let t=v(e);if(!t)return;let n=t.selectors.flatMap(e=>e.terms.flatMap(e=>(e.key===`label`||e.key===`text`||e.key===`id`)&&typeof e.value==`string`?[e.value]:[]));if(n.length===0)return;let r=n[0];return r&&n.every(e=>e===r)?r:void 0}function Mn(e){let t=new Set(e.terms.map(e=>e.key));if(t.has(`id`))return`id`;let n=t.has(`role`),r=t.has(`label`)||t.has(`text`);return n&&r?`role-label`:r||t.has(`value`)?`label`:`other`}function Nn(e,t){let n=v(e);if(!n)return e.includes(`=`)||e.includes(`||`)?null:e;let r=new Set(t.textKeys),i=t.textAliases??{};return n.selectors.length>1?Pn(n.selectors,r,i):Fn(n.selectors[0],r,new Set(t.booleanKeys),i)}function Pn(e,t,n){let r=e.map(e=>{let r=e.terms.length===1?e.terms[0]:void 0;return r&&In(r.key,t,n)&&typeof r.value==`string`?r.value:void 0}),i=r[0];return i!==void 0&&r.every(e=>e===i)?i:null}function Fn(e,t,n,r){if(!e)return null;let i={},a=0;for(let o of e.terms){if(In(o.key,t,r)&&typeof o.value==`string`)a+=1;else if(!Ln(o,n,`boolean`))return null;i[r[o.key]??o.key]=o.value}return a<=1&&Object.keys(i).length>0?i:null}function In(e,t,n){return t.has(e)||n[e]!==void 0}function Ln(e,t,n){return t.has(e.key)&&typeof e.value===n}function Rn(e){let t=v(e);if(!t||t.selectors.length!==1)return null;let n=t.selectors[0];if(!n||n.terms.length!==1)return null;let r=n.terms[0];return!r||typeof r.value!=`string`||r.key!==`id`&&r.key!==`label`&&r.key!==`text`&&r.key!==`value`?null:{key:r.key,value:r.value,raw:n.raw}}function zn(e,t){if(!t)return!1;let n=v(e);return n?n.selectors.some(e=>e.terms.some(e=>(e.key===`text`||e.key===`label`||e.key===`value`)&&typeof e.value==`string`&&e.value.includes(t))):!1}function Bn(e,t){return v(e)?.selectors.some(e=>e.terms.some(e=>e.key===t))??!1}function Vn(e){return _(e).selectors.map(e=>e.raw)}function Hn(e){return v(e)!==null}function Un(e){_(e)}function M(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}const Wn=new Set([`exists`,`present`,`appears`,`gone`,`disappears`]);function Gn(e){let t=e[0];if(t===void 0)return null;let n=M(t);if(n!==null)return{kind:`sleep`,durationMs:n};let r=M(e.at(-1));return t===`text`?Kn(e,r):t===`stable`?qn(e):t===`absent`?Jn(e,r):t.startsWith(`@`)?{kind:`ref`,rawRef:t,timeoutMs:r}:Xn(e,r)}function Kn(e,t){return{kind:`text`,text:(t===null?e.slice(1).join(` `):e.slice(1,-1).join(` `)).trim(),timeoutMs:t}}function qn(e){let t=e.slice(1),n=t.length>1?M(t[1]):null;return{kind:`stable`,quietMs:t.length>0?M(t[0]):null,timeoutMs:n}}function Jn(e,t){let n=t===null?e.slice(1):e.slice(1,-1),r=b(n);return n.length>0&&r?.rest.length===0&&Hn(r.selectorExpression)?{kind:`absent`,selectorExpression:r.selectorExpression,timeoutMs:t}:{kind:`invalid`,reason:`absent-selector-required`,message:Yn(n)}}function Yn(e){let t=e.join(` `);return t.length>0?`wait absent requires one valid selector; received "${t}". Use wait absent '<selector>' [timeoutMs].`:`wait absent requires <selector> [timeoutMs].`}function Xn(e,t){let n=t===null?e.slice():e.slice(0,-1),r=b(n);return r&&r.rest.length===0&&Hn(r.selectorExpression)?{kind:`selector`,selectorExpression:r.selectorExpression,timeoutMs:t}:Zn(n,r)||{kind:`text`,text:(t===null?e.join(` `):e.slice(0,-1).join(` `)).trim(),timeoutMs:t}}function Zn(e,t){for(let t of e){let n=Te(t);if(n)return{kind:`invalid`,reason:`unknown-selector-key`,message:Qn(n,e)}}return t&&t.rest.length>0?{kind:`invalid`,reason:`selector-shaped-text`,message:$n(t,e)}:e.some(e=>y(e))?{kind:`invalid`,reason:`selector-shaped-text`,message:er(e)}:null}function Qn(e,t){let n=t.join(` `),r=Ce(e.key)?`role=${e.key} label="${e.value}"`:`label="${e.value}"`;return`Unknown selector key "${e.key}" in "${n}". Supported: ${xe.join(`, `)}. Use wait '${r}' [timeoutMs] to wait for the selector, or wait text '${n}' [timeoutMs] to wait for the literal text "${n}".`}function $n(e,t){let n=t.join(` `);return`Selector ${e.selectorExpression} is followed by unexpected extra arguments: "${e.rest.join(` `)}". Selector values with spaces need quotes, e.g. label="Sign in". Use wait '<selector>' [timeoutMs], or wait text '${n}' [timeoutMs] to wait for the literal text "${n}".`}function er(e){let t=e.join(` `),n=e.filter(e=>!y(e)),r=e.filter(e=>y(e));if(n.length>0){let e=n[0],i=Wn.has(e.toLowerCase())?` "${e}" describes a condition, not a selector key. Use the selector form: `+(e.toLowerCase()===`gone`||e.toLowerCase()===`disappears`?`wait absent '${r.join(` `)}' [timeoutMs] to wait for zero matches.`:`wait '${r.join(` `)}' [timeoutMs] to wait for it to appear.`):` "${e}" is not a recognized selector key (${xe.join(`, `)}).`;return`"${t}" mixes plain word "${e}" with selector-shaped "${r.join(` `)}", so it is neither a valid selector nor safe as literal text.${i} Use wait '<selector>' [timeoutMs] for a selector, or wait text '${t}' [timeoutMs] to wait for the literal text "${t}".`}return`"${t}" looks like a selector key but is not a valid selector expression. Use wait '<selector>' [timeoutMs], e.g. wait '${e[0]}="value"' [timeoutMs], or wait text '${t}' [timeoutMs] to wait for the literal text "${t}".`}function tr(e){let t=Gn(e);return t?t.kind===`sleep`?t.durationMs:t.kind===`invalid`?null:t.timeoutMs:null}const nr=24e4,rr=3e4,ir=3e5,N={budget:{source:`none`},envelopeMs:9e4,onTimeout:`reset-daemon`};function ar(e,t){if(e.envelopeMs===`unbounded`)return;let n={...e,envelopeMs:e.envelopeMs};return or(n,t.positionals??[])??sr(n,t.flags)??n.envelopeMs}function or(e,t){if(e.budget.source!==`positional-parser`)return;let n=e.budget.parser(t);return n===null?void 0:lr(e,n)}function sr(e,t){if(e.budget.source===`flag`)return e.budget.envelope===`widen`?cr(e,e.budget,t):e.budget.envelope===`margin`?typeof t?.timeoutMs==`number`?lr(e,t.timeoutMs):e.envelopeMs:typeof t?.timeoutMs==`number`?t.timeoutMs:e.envelopeMs}function cr(e,t,n){if(n?.settle!==!0)return e.envelopeMs;let r=typeof n.timeoutMs==`number`?n.timeoutMs:t.defaultBudgetMs;return typeof r==`number`?ur(e,r):e.envelopeMs}function lr(e,t){return Math.max(e.envelopeMs,t+rr)}function ur(e,t){return Math.max(e.envelopeMs,e.envelopeMs+t+rr)}const dr={click:`settle-and-verify`,press:`settle-and-verify`,fill:`settle-and-verify`,longpress:`settle`,hover:`settle`,scroll:`settle`,back:`settle`};function fr(e){if(e!==void 0)return dr[e]}function P(e){return new t(`COMMAND_FAILED`,e,{reason:`runtime-contract-invalid`,hint:`This is an agent-device runtime contract bug; report the selected device and command.`})}function pr(e){if(!n(e))throw TypeError(`Unknown local runtime family: ${String(e)}`);return Object.freeze({kind:`local-family`,family:e})}function mr(e,t){let n=e.trim(),r=t.trim();if(n.length===0||r.length===0)throw TypeError(`Provider runtime owner requires non-empty provider and instance identities`);return Object.freeze({kind:`provider-runtime`,provider:n,instance:r})}function hr(e){let t=e.trim();if(t.length===0)throw TypeError(`Managed local runtime owner requires a non-empty allocator instance identity`);return Object.freeze({kind:`managed-local`,instance:t})}function F(e){switch(e.kind){case`local-family`:return`local:${e.family}`;case`managed-local`:return`managed:${JSON.stringify([e.instance])}`;case`provider-runtime`:return`provider:${JSON.stringify([e.provider,e.instance])}`}}function gr(e,t){return F(e)===F(t)}function _r(e,t){return e.available?t():{}}function vr(e){if(!I(e.requesterId)||!I(e.identityIncarnationId)||!br(e.requestGeneration))throw TypeError(`Managed binding fence requires non-empty requester and identity incarnation ids and a non-negative integer request generation`);return Object.freeze({token:JSON.stringify([e.requesterId,e.identityIncarnationId]),generation:e.requestGeneration})}function yr(e){let t=xr(e.token);if(!t||t.length!==2)return null;let[n,r]=t;if(!I(n)||!I(r)||!br(e.generation))return null;let i=Object.freeze({requesterId:n,requestGeneration:e.generation,identityIncarnationId:r});return vr(i).token===e.token?i:null}function br(e){return Number.isInteger(e)&&e>=0}function I(e){return typeof e==`string`&&e.trim().length>0}function xr(e){try{let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function Sr(e,t){let n={},r={};for(let i of t.required){let t=Cr(e.facts.operations,i);if(n[i]=t,!t.available)throw Or(i,t);r[i]=Er(e.operations,i)}for(let i of t.preferred){let t=Cr(e.facts.operations,i);n[i]=t,t.available&&(r[i]=Er(e.operations,i))}for(let i of t.conditional??[]){let t=Cr(e.facts.operations,i);n[i]=t,t.available&&(r[i]=Er(e.operations,i))}return Object.freeze({device:e.device,owner:e.owner,facts:Object.freeze(n),operations:Object.freeze(r)})}function Cr(e,t){let n=e[t];if(!wr(n))throw P(`Runtime owner omitted the ${t} fact`);let r=Tr(n);if(r)return r;throw P(`Runtime owner returned an invalid ${t} fact`)}function wr(e){return typeof e==`object`&&!!e&&`available`in e}function Tr(e){if(e.available===!0)return Object.freeze({available:!0});if(e.available===!1&&Dr(e.reason)&&(e.hint===void 0||typeof e.hint==`string`))return Object.freeze({available:!1,reason:e.reason,...e.hint===void 0?{}:{hint:e.hint}})}function Er(e,t){let n=e[t];if(typeof n!=`function`)throw P(`Runtime owner advertised ${t} without an implementation`);return n}function Dr(e){return e===`unsupported-platform-leaf`||e===`unsupported-device-kind`||e===`unsupported-device-backend`||e===`unsupported-provider-mode`||e===`owner-capability-missing`}function Or(e,n){return new t(`UNSUPPORTED_OPERATION`,`Runtime operation ${e} is unavailable`,{reason:n.reason,hint:n.hint})}function kr(e){return JSON.stringify({required:[...e.required].sort(),preferred:[...e.preferred].sort(),conditional:[...e.conditional??[]].sort()})}function Ar(){return e=>{let t=jr(e.required,`required`),n=jr(e.preferred??[],`preferred`),r=jr(e.conditional??[],`conditional`),i=[[`required`,t],[`preferred`,n],[`conditional`,r]];for(let e=0;e<i.length;e+=1){let t=i[e];if(t)for(let n of i.slice(e+1)){let e=n[1].find(e=>t[1].includes(e));if(e!==void 0)throw TypeError(`Runtime operation cannot be both ${t[0]} and ${n[0]}: ${e}`)}}return Object.freeze(r.length===0?{required:t,preferred:n}:{required:t,preferred:n,conditional:r})}}function jr(e,t){let n=[...e];if(new Set(n).size!==n.length)throw TypeError(`Runtime use contains duplicate ${t} operations`);return Object.freeze(n)}const L=Ar(),Mr=L({required:[`bootTarget`]}),Nr=L({required:[`bootTargetHeadless`]}),Pr=L({required:[`ensureReady`,`listApps`]}),Fr=L({required:[`captureSnapshot`]}),Ir=L({required:[`setViewport`]}),Lr=L({required:[`focusPoint`]}),Rr=L({required:[`typeText`]}),zr=L({required:[`back`]}),Br=L({required:[`home`]}),Vr=L({required:[`setOrientation`]}),Hr=L({required:[`tvRemote`]}),Ur=L({required:[`keyboardStatus`]}),Wr=L({required:[`keyboardDismiss`]}),Gr=L({required:[`keyboardEnter`]}),Kr=L({required:[`appSwitcher`]}),qr=L({required:[`triggerAppEvent`]}),Jr=L({required:[`setSetting`]}),Yr=L({required:[`readAlert`]}),Xr=L({required:[`awaitAlert`]}),Zr=L({required:[`acceptAlert`]}),Qr=L({required:[`dismissAlert`]}),$r=L({required:[`readClipboard`]}),ei=L({required:[`writeClipboard`]}),ti=L({required:[`perfFrames`]}),ni=L({required:[`perfMemorySample`]}),ri=L({required:[`perfMemorySnapshot`]}),ii=L({required:[`perfNativeCaptureStart`]}),ai=L({required:[`perfNativeCaptureReattach`,`perfNativeCaptureCleanup`]}),oi=L({required:[`perfProfileReport`]}),si=Object.freeze([ti,ni,ri,ii,ai,oi]),R=L({required:[`tapPoint`]}),ci=L({required:[`captureSnapshot`,`tapPoint`],preferred:[`tapRef`],conditional:[`tapElementSelector`]}),li=L({required:[`longPressPoint`]}),ui=L({required:[`captureSnapshot`,`longPressPoint`]}),di=L({required:[`hoverPoint`]}),fi=L({required:[`captureSnapshot`,`hoverPoint`],preferred:[`hoverRef`]}),pi=L({required:[`fillPoint`]}),z=L({required:[`captureSnapshot`,`fillPoint`],preferred:[`fillRef`]}),mi=Object.freeze([R,ci]),hi=mi,gi=Object.freeze([li,ui]),_i=Object.freeze([di,fi]),vi=Object.freeze([pi,z]);function yi(e,t){switch(e){case`click`:case`press`:return t?{kind:`captured-tap`,use:ci}:{kind:`tap-point`,use:R};case`fill`:return t?{kind:`captured-fill`,use:z}:{kind:`fill-point`,use:pi};case`longpress`:return t?{kind:`captured-long-press`,use:ui}:{kind:`long-press-point`,use:li};case`hover`:return t?{kind:`captured-hover`,use:fi}:{kind:`hover-point`,use:di}}}const bi=L({required:[`performGesturePlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),xi=L({required:[`performDirectionalFlingPlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Si=L({required:[`performMultiTouchGesturePlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Ci=L({required:[`performTargetAuthoredDrag`,`captureSnapshot`],preferred:[`gestureViewport`]}),wi=L({required:[`gestureViewport`]}),Ti=L({required:[`scrollDirection`]}),Ei=L({required:[`scrollDirection`,`captureSnapshot`]}),Di=Object.freeze({plan:bi,"directional-fling":xi,"multi-touch":Si,"target-authored-drag":Ci}),Oi=Object.freeze([bi,xi,Si,Ci]),ki=Object.freeze([bi]),Ai=Object.freeze([Ti,Ei]);function ji(e){return e.intent===`pan`?(`pointerCount`in e?e.pointerCount:1)===2:e.intent===`pinch`||e.intent===`rotate`||e.intent===`transform`}function Mi(e){return e.intent===`drag`?`target-authored-drag`:ji(e)?`multi-touch`:e.intent===`fling`&&`direction`in e?`directional-fling`:`plan`}function Ni(e){let t=Mi(e);switch(t){case`plan`:return B(t);case`directional-fling`:return B(t);case`multi-touch`:return B(t);case`target-authored-drag`:return B(t)}}function B(e){let t=Di[e];return Object.freeze({tier:e,operation:t.required[0],use:t})}function Pi(e){return e.edge===void 0?Object.freeze({kind:`direction`,use:Ti}):Object.freeze({kind:`edge`,edge:e.edge,use:Ei})}const Fi=L({required:[`captureSnapshot`,`captureSnapshotWithCustomActions`]}),Ii=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`]}),Li=L({required:[`captureSnapshot`,`captureSnapshotWithCustomActions`,`captureSnapshotWithoutActiveApp`]}),Ri=L({required:[`captureSnapshot`]}),zi=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`]}),Bi=L({required:[`captureSnapshot`],preferred:[`readTextAtPoint`]}),Vi=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`],preferred:[`readTextAtPoint`]}),Hi=L({required:[`captureSnapshot`],conditional:[`findText`,`findSelector`]}),Ui=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`],conditional:[`findText`,`findSelector`]}),Wi=Object.freeze([Ri,zi]),Gi=Object.freeze([Bi,Vi]),Ki=L({required:[`captureSnapshot`,`focusPoint`]}),qi=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`,`focusPoint`]}),Ji=L({required:[`captureSnapshot`,`focusPoint`,`typeText`]}),Yi=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`,`focusPoint`,`typeText`]}),Xi=Object.freeze([Bi,Vi,Ri,zi,Ki,qi,Ji,Yi]),Zi=Object.freeze([Hi,Ui]),Qi=Object.freeze([Fr,Fi,Ii,Li]),V=Object.freeze({"capture-only":Wi,"element-text":Gi,"wait-observation":Zi,"find-focus":Object.freeze([Ki,qi]),"find-type":Object.freeze([Ji,Yi])});function $i(e){return e===`focus`?`find-focus`:e===`type`?`find-type`:`capture-only`}function ea(e){switch(e.intent){case`capture-only`:return H(e.hasActiveApp,e.intent,V[e.intent]);case`element-text`:return H(e.hasActiveApp,e.intent,V[e.intent]);case`wait-observation`:return H(e.hasActiveApp,e.intent,V[e.intent]);case`find-focus`:return H(e.hasActiveApp,e.intent,V[e.intent]);case`find-type`:return H(e.hasActiveApp,e.intent,V[e.intent])}}function H(e,t,n){return Object.freeze(e?{kind:`selector-active-app`,intent:t,operation:`captureSnapshot`,use:n[0]}:{kind:`selector-without-active-app`,intent:t,operation:`captureSnapshotWithoutActiveApp`,use:n[1]})}function ta(e){return e.customActions?e.hasActiveApp?Object.freeze({kind:`custom-actions-active-app`,operation:`captureSnapshotWithCustomActions`,use:Fi}):Object.freeze({kind:`custom-actions-without-active-app`,operation:`captureSnapshotWithCustomActions`,use:Li}):e.hasActiveApp?Object.freeze({kind:`active-app`,operation:`captureSnapshot`,use:Fr}):Object.freeze({kind:`without-active-app`,operation:`captureSnapshotWithoutActiveApp`,use:Ii})}const na=L({required:[`captureScreenshot`]}),ra=L({required:[`captureScreenshot`,`captureSnapshot`]}),ia=Object.freeze([na,ra]);function aa(e){return e.cropOn?Object.freeze({kind:`capture-with-crop-on`,use:ra}):e.overlayRefs?Object.freeze({kind:`capture-with-overlay-refs`,use:ra}):Object.freeze({kind:`capture`,use:na})}const oa=Object.freeze([Mr,Nr]),sa=Object.freeze({kind:`boot-target`,operation:`bootTarget`,use:Mr}),ca=Object.freeze({kind:`boot-target-headless`,operation:`bootTargetHeadless`,use:Nr});function la(e){return e.headless?ca:sa}const ua=L({required:[`ensureReady`,`appState`]}),da=Object.freeze([ua]),fa=L({required:[`shutdownTarget`]}),pa=Object.freeze([$r,ei]),ma=Object.freeze([Yr,Xr,Zr,Qr]),ha=Object.freeze([Ur,Wr,Gr]),ga=L({required:[`deployApp`]}),_a=L({required:[`ensureReady`,`materializeAppSource`,`deployMaterializedApp`]}),va=L({required:[`ensureReady`,`sendPushNotification`]}),ya=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`]}),ba=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`]}),xa=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`clearRuntimeHints`]}),Sa=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`,`clearRuntimeHints`]});function Ca(e){return e.applyRuntimeHints&&e.clearRemovedRuntimeHints?Object.freeze({kind:`open-apply-and-clear-runtime-hints`,use:Sa}):e.applyRuntimeHints?Object.freeze({kind:`open-apply-runtime-hints`,use:ba}):e.clearRemovedRuntimeHints?Object.freeze({kind:`open-clear-runtime-hints`,use:xa}):Object.freeze({kind:`open`,use:ya})}const wa=Object.freeze([ya,ba,xa,Sa]),Ta=L({required:[`closeApplication`,`finalizeApplicationClose`]}),Ea=L({required:[`closeApplication`,`finalizeApplicationClose`,`clearRuntimeHints`]}),Da=Object.freeze([Ta,Ea]),Oa=L({required:[`finalizeApplicationClose`]}),ka=L({required:[`finalizeApplicationClose`,`clearRuntimeHints`]}),Aa=L({required:[`prepareAppleRunner`]}),ja=L({required:[`clearRuntimeHints`]}),Ma=L({required:[`configureProviderPortReverse`]}),Na=Object.freeze([ja,Ma]),U=L({required:[`appLogInspect`]}),Pa=L({required:[`appLogInspect`,`appLogDoctor`]}),Fa=L({required:[`appLogInspect`,`appLogStart`]}),Ia=L({required:[],preferred:[`appLogInspect`]}),La=Object.freeze([U,Pa,Fa]);function Ra(e){let n=(e.action??`path`).toLowerCase();if(e.restart&&n!==`clear`)throw new t(`INVALID_ARGS`,`logs --restart is only supported with logs clear`);switch(n){case`path`:return Object.freeze({kind:`path`,requiresAppSession:!1,use:U});case`start`:return Object.freeze({kind:`start`,requiresAppSession:!0,use:Fa});case`stop`:return Object.freeze({kind:`stop`,requiresAppSession:!1,use:U});case`doctor`:return Object.freeze({kind:`doctor`,requiresAppSession:!1,use:Pa});case`mark`:return Object.freeze({kind:`mark`,marker:e.marker??``,requiresAppSession:!1,use:U});case`clear`:return e.restart?Object.freeze({kind:`clear-restart`,requiresAppSession:!0,use:Fa}):Object.freeze({kind:`clear`,requiresAppSession:!1,use:U});default:throw new t(`INVALID_ARGS`,`logs requires path, start, stop, doctor, mark, or clear`)}}const za=L({required:[`audioProbeStart`]}),Ba=L({required:[`audioProbeReattach`,`audioProbeCleanup`]}),Va=L({required:[`audioProbeQuery`]}),Ha=Object.freeze([za,Ba,Va]);function Ua(e){if(e.mode===`query`)return Object.freeze({kind:`query`,action:e.probeAction,use:Va});switch(e.probeAction){case`start`:return Object.freeze({kind:`capture-start`,use:za});case`status`:return Object.freeze({kind:`capture-status`});case`stop`:return Object.freeze({kind:`capture-stop`})}}const Wa=[`probe`],Ga=[`start`,`status`,`stop`];function Ka(e){let n=(e?.[0]??`probe`).toLowerCase();if(!Wa.includes(n))throw new t(`INVALID_ARGS`,`audio requires probe`);let r=(e?.[1]??`status`).toLowerCase();if(!Ga.includes(r))throw new t(`INVALID_ARGS`,`audio probe requires ${Ga.join(`, `)}`);if(r!==`start`&&e&&e.length>2)throw new t(`INVALID_ARGS`,`audio probe duration and bucket are only supported with audio probe start`);return Object.freeze({probeAction:r,durationMs:qa(e?.[2],{defaultValue:1e4,min:100,max:12e4,message:`audio probe duration must be an integer in range 100..120000 ms`}),bucketMs:qa(e?.[3],{defaultValue:1e3,min:100,max:1e4,message:`audio probe bucket must be an integer in range 100..10000 ms`})})}function qa(e,n){if(e===void 0)return n.defaultValue;let r=Number.parseInt(e,10);if(!Number.isInteger(r)||String(r)!==e||r<n.min||r>n.max)throw new t(`INVALID_ARGS`,n.message);return r}const Ja=L({required:[`networkDump`]}),Ya=L({required:[],preferred:[`networkDump`]}),Xa=[`dump`,`log`],Za=[`summary`,`headers`,`body`,`all`];function Qa(e){let n=(e.action??`dump`).toLowerCase(),r=(e.include??`summary`).toLowerCase();if(!$a(n))throw new t(`INVALID_ARGS`,`network requires dump or log`);if(!eo(r))throw new t(`INVALID_ARGS`,`network --include must be summary, headers, body, or all`);return Object.freeze({action:n,include:r,use:Ja})}function $a(e){return Xa.some(t=>t===e)}function eo(e){return Za.some(t=>t===e)}function to(e){let t=new Map;for(let r of e){if(!n(r.family))throw TypeError(`Unknown platform family registration: ${String(r.family)}`);if(t.has(r.family))throw TypeError(`Duplicate platform family registration: ${r.family}`);t.set(r.family,no(r))}let i=r.filter(e=>!t.has(e));if(i.length>0)throw TypeError(`Missing platform family registrations: ${i.join(`, `)}`);let a=Object.freeze([...r]),o=Object.freeze(a.map(e=>ro(t,e)));return Object.freeze({families:a,modules:o,get:e=>ro(t,e)})}function no(e){return Object.freeze({...e})}function ro(e,t){let n=e.get(t);if(!n)throw TypeError(`Missing platform family registration: ${t}`);return n}const io=Object.freeze({kind:`device-inventory`});function ao(e){if(typeof e!=`object`||!e)throw po();let t=e,n=Object.keys(t).sort();if(!(t.kind===`none`&&W(n,[`kind`]))&&!(t.kind===`host`&&W(n,[`kind`]))&&!(t.kind===`inventory`&&W(n,[`kind`,`use`])&&so(t.use))&&!(t.kind===`device-runtime`&&W(n,[`kind`,`use`])&&co(t.use))&&!(t.kind===`device-runtime`&&(W(n,[`kind`,`uses`])||W(n,[`kind`,`selectUses`,`uses`])&&typeof t.selectUses==`function`)&&oo(t.uses)))throw po()}function oo(e){if(!Array.isArray(e)||e.length===0||!e.every(co))return!1;let t=e.map(kr);return new Set(t).size===t.length}function so(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.kind===`device-inventory`&&W(Object.keys(t).sort(),[`kind`])}function co(e){if(typeof e!=`object`||!e)return!1;let t=e,n=[uo(t.required),uo(t.preferred),uo(t.conditional??[])];if(!lo(n))return!1;let r=n.flat();return new Set(r).size===r.length&&W(Object.keys(t).sort(),t.conditional===void 0?[`preferred`,`required`]:[`conditional`,`preferred`,`required`])}function lo(e){return e.every(e=>e!==null&&fo(e))}function uo(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)?e:null}function fo(e){return new Set(e).size===e.length}function W(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function po(){return TypeError(`Command platform execution must declare exactly one of none, host, inventory, or device-runtime`)}const mo=L({required:[`screenRecordingStart`]}),ho=L({required:[`screenRecordingReattach`,`screenRecordingCleanup`]}),go=L({required:[]}),_o=L({required:[],preferred:[`screenRecordingStart`]}),vo=Object.freeze([mo,ho]);function yo(e){switch((e.action??``).toLowerCase()){case`start`:if(!bo(e.scope??`app`))throw new t(`INVALID_ARGS`,`record scope must be app, device, or system`);return Object.freeze({kind:`start`,use:mo});case`stop`:return e.hasLiveHandle===!0?Object.freeze({kind:`stop-live`,use:go}):Object.freeze({kind:`stop-recovery`,use:ho});default:throw new t(`INVALID_ARGS`,`record requires start or stop`)}}function bo(e){return e===`app`||e===`device`||e===`system`}function xo(e){if(ao(e),e.kind!==`device-runtime`||!(`uses`in e))throw So();let t=e.uses.map(kr),n=vo.map(kr),r=new Set(t),i=new Set(n);if(t.length!==n.length||r.size!==t.length||[...r].some(e=>!i.has(e)))throw So()}function So(){return TypeError(`Record runtime execution must declare exactly the uses selected by its two runtime-bearing plans`)}function Co(e){let t=e.platformExecution;if(t===void 0)throw TypeError(`Command descriptor "${e.name}" must declare platformExecution (none, host, inventory, or device-runtime); there is no registry-entry default`);return ao(t),t}const G={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0},K={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0,selectorValidationExempt:!0},wo=()=>!0,To=e=>(e.positionals?.[0]??``).toLowerCase()===`start`,Eo=e=>e.command===`test`&&(typeof e.flags?.shardAll==`number`||typeof e.flags?.shardSplit==`number`),Do=e=>(e.positionals?.length??0)===0?{kind:`unconditional`}:void 0,Oo=e=>{let t=e.flags?.leaseProvider;return e.flags?.leaseId===void 0&&typeof t==`string`&&(e.flags?.platform===`android`||e.flags?.platform===`ios`)?{kind:`provider-app-catalog`,provider:t}:void 0},ko=new Set([`status`,`get`]),Ao=e=>Lo(e,ko,`status`),jo=new Set([`get`,`wait`]),Mo=e=>Lo(e,jo,`get`),No=e=>Ro(e,ko,`status`),Po=e=>Ro(e,jo,`get`),Fo=e=>{try{return Jt(A(e.positionals??[]).action)?`observes-app`:`mutates-app`}catch{return`mutates-app`}},Io=e=>Ro(e,new Set([`read`]),``);function Lo(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`preserve`:`may-invalidate`}function Ro(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`observes-app`:`mutates-app`}const q={kind:`none`},zo={kind:`host`},J={recordsSessionAction:!0,recordingEffect:`mutates-app`,deviceClaimPolicy:`require-owner`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:N,batchable:!0},Bo={targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,deviceClaimPolicy:`require-owner`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0}},Y={...N,onTimeout:`preserve-daemon`},Vo={...N,envelopeMs:18e4},Ho={...N,onTimeout:`preserve-daemon`},Uo={...Ho,envelopeMs:33e4},Wo={...N,budget:{source:`flag`,envelope:`widen`,defaultBudgetMs:1e4},onTimeout:`preserve-daemon`},Go={fields:{count:{defaultValue:1,omitDefault:!0},intervalMs:{defaultValue:0,omitDefault:!0},holdMs:{defaultValue:0,omitDefault:!0},jitterPx:{defaultValue:0,omitDefault:!0},doubleTap:{defaultValue:!1,omitDefault:!0}}},Ko={fields:{delayMs:{defaultValue:0}}};function X(e,t){return fr(e)===void 0?t:Wo}function Z(e){let t=fr(e);if(t===void 0)throw Error(`Missing post-action observation descriptor support for ${e}`);return t}const qo={deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:ga},timeoutPolicy:Vo,batchable:!0},Jo=e=>{let t=e.flags?.snapshotCustomActions===!0||e.input?.customActions===!0;return[!0,!1].map(e=>ta({customActions:t,hasActiveApp:e}).use)},Yo=e=>{let t=Zo(e);if(t===void 0||!Xo(t))return Xi;let n=$i(t);return[!0,!1].map(e=>ea({hasActiveApp:e,intent:n}).use)};function Xo(e){return Jt(e)||e===`focus`||e===`type`}function Zo(e){if(e.positionals===void 0)return;let t=tn(e.positionals,e.flags);return t.ok?t.parsed.action:void 0}const Qo=[{name:`human_control`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`humanControl`},recordsSessionAction:!1,daemon:{route:`humanControl`,refFrameEffect:`preserve`,selectorValidationExempt:!0,skipSessionlessProviderDevice:wo},timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`lease_allocate`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseAllocate`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...G},timeoutPolicy:Uo,batchable:!1,platformExecution:q},{name:`lease_heartbeat`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseHeartbeat`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...G},timeoutPolicy:Ho,batchable:!1,platformExecution:q},{name:`lease_release`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseRelease`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...G},timeoutPolicy:Ho,batchable:!1,platformExecution:q},{name:`artifacts`,deviceClaimPolicy:`none`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...G},timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`session_list`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`sessionList`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,...K},timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`session_save_script`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`sessionSaveScript`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`publication`},timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`devices`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,...K},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`inventory`,use:io}},{name:`capabilities`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,...K},timeoutPolicy:N,batchable:!0,platformExecution:q},{name:`doctor`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,allowSessionlessDefaultDevice:wo,...K},timeoutPolicy:N,batchable:!0,platformExecution:zo},{name:`apps`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,sessionlessLeaseAdmissionExemption:Oo},platformExecution:{kind:`device-runtime`,uses:[Pr]},timeoutPolicy:N,batchable:!0},{name:`boot`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,uses:oa},timeoutPolicy:N,batchable:!0},{name:`shutdown`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,use:fa},timeoutPolicy:N,batchable:!0},{name:`appstate`,deviceClaimPolicy:`observe`,catalog:{group:`public`,key:`appState`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,uses:da},timeoutPolicy:N,batchable:!0},{name:`perf`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:si}},{name:`logs`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,uses:La},timeoutPolicy:N,batchable:!0},{name:`events`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`,allowInvalidRecording:!0,...K},timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`network`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,use:Ja},timeoutPolicy:N,batchable:!0},{name:`audio`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ha}},{name:`replay`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:Eo,saveScriptFlagOwner:!0},timeoutPolicy:{...N,budget:{source:`flag`}},batchable:!1,platformExecution:q},{name:`test`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:Eo},timeoutPolicy:{...N,envelopeMs:`unbounded`},batchable:!0,platformExecution:q},{name:`runtime`,deviceClaimPolicy:`require-owner`,catalog:{group:`internal`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!1,platformExecution:{kind:`device-runtime`,uses:[...Na,wi]}},{name:`clipboard`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:Io,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:pa}},{name:`keyboard`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:No,daemon:{route:`session`,refFrameEffect:Ao,androidBlockingDialogGuard:!0},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ha}},{name:`install`,...qo},{name:`reinstall`,...qo},{name:`install_source`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`internal`,key:`installSource`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:_a},timeoutPolicy:Vo,batchable:!1},{name:`release_materialized_paths`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`releaseMaterializedPaths`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,...K},timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`push`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:va},timeoutPolicy:N,batchable:!0},{name:`trigger-app-event`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`,key:`triggerAppEvent`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[qr]}},{name:`open`,deviceClaimPolicy:`acquire-session`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowSessionlessDefaultDevice:wo,saveScriptFlagOwner:!0},timeoutPolicy:{...N,budget:{source:`flag`,envelope:`margin`}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:wa}},{name:`prepare`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:{budget:{source:`flag`,envelope:`margin`},envelopeMs:nr,onTimeout:`reset-daemon`},batchable:!1,mcpExposed:!1,platformExecution:{kind:`device-runtime`,use:Aa}},{name:`batch`,deviceClaimPolicy:`none`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`},timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`close`,deviceClaimPolicy:`release-session`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowInvalidRecording:!0,saveScriptFlagOwner:!0,sessionlessLeaseAdmissionExemption:Do},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Da}},{name:`snapshot`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},timeoutPolicy:{...Y,budget:{source:`flag`}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:Qi,selectUses:Jo}},{name:`diff`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Qi,selectUses:Jo}},{name:`wait`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,targetIdentityVerification:`post-resolution`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},timeoutPolicy:{...Y,budget:{source:`positional-parser`,parser:tr}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:Zi}},{name:`alert`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:Po,daemon:{route:`snapshot`,refFrameEffect:Mo},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ma}},{name:`settings`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`snapshot`,refFrameEffect:`may-invalidate`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[Jr]}},{name:`react-native`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`,key:`reactNative`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`reactNative`,refFrameEffect:`may-invalidate`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[R]}},{name:`record`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`,allowInvalidRecording:!0,allowSessionlessDefaultDevice:To},platformExecution:{kind:`device-runtime`,uses:vo},timeoutPolicy:N,batchable:!0},{name:`trace`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!0,platformExecution:q},{name:`find`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:Fo,daemon:{route:`find`,refFrameEffect:`may-invalidate`},timeoutPolicy:Y,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Xi,selectUses:Yo}},{name:`click`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:X(`click`,Y),postActionObservation:Z(`click`),responseDataTransform:Go,batchable:!0,platformExecution:{kind:`device-runtime`,uses:mi}},{name:`fill`,...Bo,frameworkTier:`core`,timeoutPolicy:X(`fill`,Y),postActionObservation:Z(`fill`),responseDataTransform:Ko,batchable:!0,platformExecution:{kind:`device-runtime`,uses:vi}},{name:`longpress`,...Bo,catalog:{group:`public`,key:`longPress`},frameworkTier:`extended`,timeoutPolicy:{...Wo,envelopeMs:21e4},postActionObservation:Z(`longpress`),batchable:!0,platformExecution:{kind:`device-runtime`,uses:gi}},{name:`hover`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`},timeoutPolicy:X(`hover`,Y),postActionObservation:Z(`hover`),batchable:!0,platformExecution:{kind:`device-runtime`,uses:_i}},{name:`press`,...Bo,frameworkTier:`core`,timeoutPolicy:X(`press`,Y),postActionObservation:Z(`press`),responseDataTransform:Go,batchable:!0,platformExecution:{kind:`device-runtime`,uses:hi}},{name:`type`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:X(`type`,Y),batchable:!0,platformExecution:{kind:`device-runtime`,uses:[Rr]}},{name:`get`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`},timeoutPolicy:X(`get`,Y),batchable:!0,platformExecution:{kind:`device-runtime`,uses:Gi}},{name:`is`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`},timeoutPolicy:X(`is`,Y),batchable:!0,platformExecution:{kind:`device-runtime`,uses:Wi}},{name:`back`,catalog:{group:`public`},frameworkTier:`core`,...J,timeoutPolicy:X(`back`,N),postActionObservation:Z(`back`),platformExecution:{kind:`device-runtime`,uses:[zr]}},{name:`gesture`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,targetIdentityVerification:`pre-dispatch`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Oi}},{name:`home`,catalog:{group:`public`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Br]}},{name:`tv-remote`,catalog:{group:`public`,key:`tvRemote`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Hr]}},{name:`orientation`,catalog:{group:`public`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Vr]}},{name:`scroll`,catalog:{group:`public`},frameworkTier:`core`,...J,timeoutPolicy:X(`scroll`,N),postActionObservation:Z(`scroll`),platformExecution:{kind:`device-runtime`,uses:Ai}},{name:`swipe`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ki}},{name:`focus`,catalog:{group:`public`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Lr]}},{name:`screenshot`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`generic`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ia}},{name:`viewport`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},timeoutPolicy:N,batchable:!1,platformExecution:{kind:`device-runtime`,uses:[Ir]}},{name:`app-switcher`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`,key:`appSwitcher`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[Kr]}},{name:`install-from-source`,deviceClaimPolicy:`none`,catalog:{group:`public`,key:`installFromSource`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,platformExecution:{kind:`device-runtime`,use:_a},timeoutPolicy:N,batchable:!0},{name:`debug`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`daemon`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:zo},{name:`device`,deviceClaimPolicy:`observe`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`metro`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`session`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`cdp`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`auth`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`connect`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`connection`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`disconnect`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`mcp`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`proxy`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`takeover`,deviceClaimPolicy:`observe`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:{kind:`inventory`,use:io}},{name:`react-devtools`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`,key:`reactDevtools`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`web`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:zo}],$o=new Set([`public`,`local-cli`]),es=new Set(Qo.filter(e=>$o.has(cs(e))).map(e=>e.name)),Q=Qo.map(e=>{let t=Co(e);return e.name===`record`&&xo(t),{...e,mcpExposed:os(e),platformExecution:t}});function ts(e){return Q.filter(t=>cs(t)===e).map(e=>[ls(e),e.name])}function ns(){return Q.filter(e=>ss(e)).map(e=>e.name).sort()}function rs(e){let t=Q.find(t=>t.name===e)?.platformExecution;if(t?.kind===`device-runtime`)return(`uses`in t?t.uses:[t.use]).map(e=>e.required)}function is(){return Q.filter(e=>e.catalog.group===`public`&&e.platformExecution.kind===`device-runtime`).map(e=>e.name).sort()}const $=new Map(Q.map(e=>[e.name,e]));function as(e){return es.has(e)}function os(e){return e.mcpExposed??es.has(e.name)}function ss(e){return e.mcpExposed&&as(e.name)}function cs(e){return e.catalog.group}function ls(e){return e.catalog.key??e.name}const us=new Map(Q.map(e=>[e.name,e.timeoutPolicy])),ds=new Map(Q.map(e=>[e.name,e.deviceClaimPolicy])),fs=new Map(Array.from($.values()).flatMap(e=>e.responseDataTransform?[[e.name,e.responseDataTransform]]:[]));function ps(e){if(e!==void 0)return $.get(e)?.postActionObservation}function ms(e){return ps(e)!==void 0}function hs(e){return ps(e)===`settle-and-verify`}function gs(e){return e===void 0?N:us.get(e)??N}function _s(e){return e===void 0?`require-owner`:ds.get(e)??`require-owner`}function vs(e){if(e!==void 0)return fs.get(e)}function ys(e){return e===void 0?!1:$.get(e)?.recordsSessionAction??!1}function bs(e){if(e!==void 0)return $.get(e)?.frameworkTier}function xs(e){return $.get(e)?.targetIdentityVerification}function Ss(e){let t=$.get(e.command);if(t?.recordsSessionAction)return typeof t.recordingEffect==`function`?t.recordingEffect(e):t.recordingEffect}function Cs(){return[...new Set(Array.from(fs.values()).flatMap(e=>Object.keys(e.fields)))].sort()}function ws(e){let t=[];for(let n of e)n.daemon&&t.push({command:n.name,...n.daemon,replayScopedAction:n.recordsSessionAction});return t}function Ts(e){return e.filter(e=>e.batchable).map(e=>e.name)}const Es=Ts(Q),Ds=new Set([`batch`,`replay`]),Os=[`command`,`positionals`,`input`,`flags`,`runtime`],ks=[`platform`,`target`,`device`,`udid`,`serial`,`verbose`,`out`],As=`Session, daemon, connection, and host tooling commands are excluded from batch — they own lifecycle a batch cannot carry — and batch and replay never nest. Run an excluded command on its own; every other device command is available as a step.`,js=new Set(Es);function Ms(e){return js.has(e)}function Ns(e){return typeof e==`string`?e.trim().toLowerCase():``}function Ps(e){let t=Ns(e);return Ms(t)?t:void 0}function Fs(e,n,r=As){let i=Ps(e);if(i!==void 0)return i;throw new t(`INVALID_ARGS`,`Batch step ${n} command is not available through command batch: ${String(e)}`,{hint:r})}function Is(e,n){if(Ds.has(e))throw new t(`INVALID_ARGS`,`Batch step ${n} cannot run ${e}.`)}export{Yr as $,C as $n,nr as $t,Qa as A,qt as An,se as Ar,la as At,Oa as B,Rt as Bn,u as Br,Hr as Bt,gs as C,hn as Cn,he as Cr,Vr as Ct,ho as D,tn as Dn,m as Dr,ai as Dt,_o as E,en as En,fe as Er,ri as Et,Ra as F,It as Fn,te as Fr,ta as Ft,xa as G,Ft as Gn,hr as Gt,ya as H,kt as Hn,s as Hr,Ir as Ht,ja as I,Mt as In,ee as Ir,yi as It,ga as J,ft as Jn,F as Jt,Aa as K,rt as Kn,Sr as Kt,Ta as L,Ht as Ln,l as Lr,Jr as Lt,Ka as M,on as Mn,ne as Mr,aa as Mt,Ua as N,Ut as Nn,ie as Nr,Pi as Nt,to as O,Yt as On,ae as Or,ii as Ot,Ia as P,D as Pn,re as Pr,ea as Pt,Qr as Q,w as Qn,ir as Qt,Ea as R,zt as Rn,o as Rr,fa as Rt,vs as S,un as Sn,ge as Sr,li as St,yo as T,$t as Tn,ue as Tr,ni as Tt,Sa as U,Pt as Un,a as Ur,yr as Ut,ka as V,Lt as Vn,c as Vr,Rr as Vt,ba as W,Nt as Wn,pr as Wt,va as X,_t as Xn,_r as Xt,_a as Y,ht as Yn,gr as Yt,Zr as Z,dt as Zn,P as Zt,is as _,mn as _n,b as _r,Br as _t,Is as a,Vn as an,Xe as ar,zr as at,Ss as b,fn as bn,h as br,Gr as bt,Ps as c,zn as cn,Ze as cr,ui as ct,rs as d,jn as dn,Be as dr,ei as dt,ar as en,$e as er,Xr as et,ms as f,En as fn,xe as fr,L as ft,ns as g,Tn as gn,_ as gr,wi as gt,ts as h,wn as hn,y as hr,Lr as ht,Es as i,Nn as in,Ke as ir,Pr as it,Ba as j,A as jn,p as jr,Ni as jt,Ya as k,Jt as kn,oe as kr,oi as kt,ws as l,Un as ln,Re as lr,ci as lt,Cs as m,An as mn,Ce as mr,$i as mt,Os as n,M as nn,Qe as nr,ua as nt,Ns as o,Rn as on,Ye as or,z as ot,hs as p,On as pn,Te as pr,pi as pt,Ca as q,mt as qn,mr as qt,ks as r,Hn as rn,qe as rr,Kr as rt,Fs as s,Bn as sn,Je as sr,fi as st,As as t,Gn as tn,et as tr,qr as tt,Q as u,kn as un,Ve as ur,$r as ut,_s as v,pn as vn,v as vr,di as vt,xs as w,Gt as wn,_e as wr,ti as wt,ys as x,dn as xn,le as xr,Ur as xt,bs as y,gn as yn,ve as yr,Wr as yt,Ma as z,At as zn,d as zr,R as zt};