agent-device 0.21.6 → 0.21.7

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 (302) hide show
  1. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.6.apk → agent-device-android-ime-helper-0.21.7.apk} +0 -0
  2. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.7.apk.sha256 +1 -0
  3. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.6.manifest.json → agent-device-android-ime-helper-0.21.7.manifest.json} +4 -4
  4. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.6.apk → agent-device-android-snapshot-helper-0.21.7.apk} +0 -0
  5. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.7.apk.sha256 +1 -0
  6. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.6.manifest.json → agent-device-android-snapshot-helper-0.21.7.manifest.json} +6 -6
  7. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.h +4 -0
  8. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +20 -0
  9. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerScrollViewportPolicy.swift +1 -2
  10. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +25 -12
  11. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +56 -1
  12. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +1 -1
  13. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +36 -108
  14. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Keyboard.swift +241 -0
  15. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +29 -0
  16. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +46 -0
  17. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+PrivateAXPresentation.swift +85 -26
  18. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +134 -117
  19. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotBackendCapabilities.swift +1 -3
  20. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +25 -4
  21. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +1 -1
  22. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +3 -0
  23. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotCoordinateSpace.swift +197 -0
  24. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotModels.swift +30 -4
  25. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentation.swift +0 -81
  26. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationInvariant.swift +1 -9
  27. package/dist/src/absence-observation-errors.js +1 -1
  28. package/dist/src/adapter.js +1 -1
  29. package/dist/src/adb-executor.js +2 -2
  30. package/dist/src/adb-failure.js +1 -1
  31. package/dist/src/adb-transport.js +1 -1
  32. package/dist/src/adb.js +1 -1
  33. package/dist/src/agent-browser-lifecycle.js +1 -1
  34. package/dist/src/agent-browser-process-record.js +1 -1
  35. package/dist/src/agent-browser-provider.js +1 -1
  36. package/dist/src/agent-browser-tool.js +1 -1
  37. package/dist/src/agent-device-client.js +2 -2
  38. package/dist/src/ai-sdk.js +1 -1
  39. package/dist/src/alert-runtime.js +1 -1
  40. package/dist/src/android-adb.d.ts +29 -2
  41. package/dist/src/android-adb.js +1 -1
  42. package/dist/src/android-input-ownership.js +1 -1
  43. package/dist/src/android.js +1 -1
  44. package/dist/src/app-catalog.js +1 -1
  45. package/dist/src/app-deployment-resolution.js +1 -1
  46. package/dist/src/app-helpers.js +1 -1
  47. package/dist/src/app-inventory.js +1 -1
  48. package/dist/src/app-launch.js +2 -2
  49. package/dist/src/app-lifecycle.js +2 -2
  50. package/dist/src/app-lifecycle2.js +2 -2
  51. package/dist/src/app-log-files.js +1 -1
  52. package/dist/src/app-log-runtime2.js +3 -3
  53. package/dist/src/app-resolution.js +2 -2
  54. package/dist/src/app-state.js +1 -1
  55. package/dist/src/apple-runner-platform.js +1 -1
  56. package/dist/src/application-lifecycle-interaction.js +1 -1
  57. package/dist/src/archive.js +1 -1
  58. package/dist/src/artifact-download.js +1 -1
  59. package/dist/src/auth-session.js +1 -1
  60. package/dist/src/auth.js +1 -1
  61. package/dist/src/back-mode.js +1 -1
  62. package/dist/src/backend-snapshot-options.js +1 -1
  63. package/dist/src/boot-diagnostics.js +1 -1
  64. package/dist/src/capture-disclosure.js +1 -0
  65. package/dist/src/capture.js +1 -1
  66. package/dist/src/cli-config.js +1 -1
  67. package/dist/src/cli-help.js +15 -2
  68. package/dist/src/cli-output.js +1 -1
  69. package/dist/src/cli.js +4 -4
  70. package/dist/src/click-button.js +1 -1
  71. package/dist/src/client-metro.js +1 -1
  72. package/dist/src/client-types.d.ts +32 -2
  73. package/dist/src/clipboard-shell-response.js +1 -0
  74. package/dist/src/command-schema.js +1 -1
  75. package/dist/src/command-tools.js +4 -2
  76. package/dist/src/command.js +1 -1
  77. package/dist/src/config.js +1 -1
  78. package/dist/src/connection-runtime.js +1 -1
  79. package/dist/src/connection.js +1 -1
  80. package/dist/src/contracts.d.ts +1 -1
  81. package/dist/src/contracts.js +1 -1
  82. package/dist/src/daemon-client-lifecycle.js +1 -1
  83. package/dist/src/daemon.js +1 -1
  84. package/dist/src/debug-symbols-facade.js +1 -1
  85. package/dist/src/device-boot.js +1 -1
  86. package/dist/src/device-claim-inspection.js +1 -1
  87. package/dist/src/device-claim-rule.js +2 -1
  88. package/dist/src/device-input-state.d.ts +4 -4
  89. package/dist/src/device-inventory-context.js +1 -1
  90. package/dist/src/device-rotation.js +1 -1
  91. package/dist/src/device-selection-resolver.js +1 -1
  92. package/dist/src/device-session.js +1 -1
  93. package/dist/src/device-shell.js +1 -0
  94. package/dist/src/device.js +1 -1
  95. package/dist/src/device2.js +1 -1
  96. package/dist/src/devicectl.js +1 -0
  97. package/dist/src/diagnostics.js +1 -1
  98. package/dist/src/dispatch-resolve.js +1 -1
  99. package/dist/src/display-inventory.js +1 -0
  100. package/dist/src/doctor-facade.js +1 -1
  101. package/dist/src/doctor2.js +1 -1
  102. package/dist/src/durable-resource.js +1 -1
  103. package/dist/src/engine-eval-script.js +1 -1
  104. package/dist/src/error.js +1 -1
  105. package/dist/src/exec.js +1 -1
  106. package/dist/src/file.js +1 -1
  107. package/dist/src/find.js +1 -1
  108. package/dist/src/finders.js +1 -1
  109. package/dist/src/format.js +2 -1
  110. package/dist/src/generic.js +1 -1
  111. package/dist/src/gesture-admission.js +1 -1
  112. package/dist/src/gesture-plan.js +1 -1
  113. package/dist/src/gesture-runtime.js +1 -1
  114. package/dist/src/harmonyos.js +1 -1
  115. package/dist/src/hdc.js +1 -1
  116. package/dist/src/helper.js +1 -1
  117. package/dist/src/human-control-contract.js +1 -1
  118. package/dist/src/human-control.js +1 -1
  119. package/dist/src/index.d.ts +1 -1
  120. package/dist/src/index.js +1 -1
  121. package/dist/src/input-actions.js +1 -1
  122. package/dist/src/input-actions2.js +1 -1
  123. package/dist/src/install-artifact-facade.js +1 -1
  124. package/dist/src/install-source-network-transport.js +1 -1
  125. package/dist/src/install-source2.js +1 -1
  126. package/dist/src/interaction-positionals.js +1 -1
  127. package/dist/src/interaction-ref-policy.js +1 -1
  128. package/dist/src/interaction.js +1 -1
  129. package/dist/src/interaction2.js +1 -1
  130. package/dist/src/interactor-operation-catalog.js +1 -1
  131. package/dist/src/interactor.js +5 -5
  132. package/dist/src/interactor2.js +1 -1
  133. package/dist/src/interactors.js +1 -1
  134. package/dist/src/internal/bin.js +1 -1
  135. package/dist/src/internal/daemon.js +2 -2
  136. package/dist/src/internal/png-worker.d.ts +4 -1
  137. package/dist/src/internal/png-worker.js +1 -1
  138. package/dist/src/internal/run-script-http-child.js +1 -1
  139. package/dist/src/inventory.js +4 -4
  140. package/dist/src/inventory2.js +1 -1
  141. package/dist/src/inventory3.js +2 -2
  142. package/dist/src/inventory5.js +1 -1
  143. package/dist/src/ios-snapshot-acquisition.js +1 -1
  144. package/dist/src/ios-snapshot-runtime.js +1 -1
  145. package/dist/src/ios-target-activation.js +1 -0
  146. package/dist/src/lease-context.js +1 -1
  147. package/dist/src/lease-scope.js +1 -1
  148. package/dist/src/lease.js +1 -1
  149. package/dist/src/limrun-download-file.js +1 -0
  150. package/dist/src/limrun-runtime-dependencies.js +1 -1
  151. package/dist/src/limrun.d.ts +10 -4
  152. package/dist/src/linux.js +1 -1
  153. package/dist/src/local-interactor-operation-set.js +1 -1
  154. package/dist/src/location-coordinates.js +1 -1
  155. package/dist/src/managed-device-scope.js +1 -1
  156. package/dist/src/mechanics.js +16 -16
  157. package/dist/src/mobile-snapshot-semantics.js +1 -1
  158. package/dist/src/multitouch-support.js +1 -1
  159. package/dist/src/observation.js +2 -2
  160. package/dist/src/output-common.js +5 -2
  161. package/dist/src/parameterized-recorded-fill.js +1 -1
  162. package/dist/src/perf-facade.js +2 -2
  163. package/dist/src/perf-runtime-operation-builder.js +1 -1
  164. package/dist/src/perf-runtime-plan.js +1 -1
  165. package/dist/src/perf.js +1 -1
  166. package/dist/src/physical-device-control.js +1 -1
  167. package/dist/src/platform-request-scope.js +1 -1
  168. package/dist/src/platform-runtime-android-adb-host.js +1 -1
  169. package/dist/src/platform-runtime-host.js +1 -1
  170. package/dist/src/platform-runtime-managed-owner.js +1 -1
  171. package/dist/src/platform-runtime-open-target.js +1 -1
  172. package/dist/src/platform-runtime-operation-host.js +4 -4
  173. package/dist/src/platform-runtime-runtime-hints.js +2 -2
  174. package/dist/src/platform-runtime-screen-recording-android-host.js +1 -1
  175. package/dist/src/platform-runtime-screen-recording-apple-runner-transport.js +1 -1
  176. package/dist/src/platform-runtime-screen-recording-apple-simulator-host.js +1 -1
  177. package/dist/src/platform-runtime-screen-recording-apple-transport.js +1 -1
  178. package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
  179. package/dist/src/platform-runtime-screen-recording-harmony-host.js +1 -1
  180. package/dist/src/platform-runtime-screen-recording-process-host.js +1 -1
  181. package/dist/src/platform-runtime-unavailable.js +1 -1
  182. package/dist/src/platform-runtime.js +1 -1
  183. package/dist/src/platform-runtime2.js +1 -1
  184. package/dist/src/png-crop-bytes.js +1 -1
  185. package/dist/src/png-transcode.js +1 -0
  186. package/dist/src/png-worker-client.js +1 -0
  187. package/dist/src/png.js +1 -1
  188. package/dist/src/prepare-kind.js +1 -1
  189. package/dist/src/provider-session-ownership.js +1 -1
  190. package/dist/src/provider-webdriver.js +1 -1
  191. package/dist/src/proxy.js +1 -1
  192. package/dist/src/quality-warnings.js +1 -1
  193. package/dist/src/react-native.js +1 -1
  194. package/dist/src/record-runtime.js +1 -1
  195. package/dist/src/record-trace.js +1 -1
  196. package/dist/src/rect-center.js +1 -1
  197. package/dist/src/register-builtins.js +1 -1
  198. package/dist/src/registry.js +35 -35
  199. package/dist/src/remote-config2.js +1 -1
  200. package/dist/src/replay-divergence.js +1 -1
  201. package/dist/src/replay.js +2 -2
  202. package/dist/src/reporting.js +1 -1
  203. package/dist/src/request-admission.js +1 -1
  204. package/dist/src/request-cancel.js +1 -1
  205. package/dist/src/request-runtime-binding.js +1 -1
  206. package/dist/src/result-serialization.js +1 -1
  207. package/dist/src/retry.js +1 -1
  208. package/dist/src/runner-cache-metadata.js +2 -2
  209. package/dist/src/runner-client.js +1 -1
  210. package/dist/src/runner-disposal.js +1 -1
  211. package/dist/src/runner-operations-facade.js +1 -1
  212. package/dist/src/runner-presentation.js +1 -1
  213. package/dist/src/runner.js +1 -1
  214. package/dist/src/runtime-transport-hints.js +1 -1
  215. package/dist/src/runtime.js +3 -3
  216. package/dist/src/runtime10.js +1 -1
  217. package/dist/src/runtime2.js +4 -4
  218. package/dist/src/runtime3.js +1 -1
  219. package/dist/src/runtime4.js +5 -5
  220. package/dist/src/runtime5.js +1 -1
  221. package/dist/src/runtime6.js +1 -1
  222. package/dist/src/runtime7.js +1 -1
  223. package/dist/src/runtime8.js +1 -1
  224. package/dist/src/runtime9.js +1 -1
  225. package/dist/src/screen-recording-admission-ledger.js +1 -0
  226. package/dist/src/screen-recording-completion.js +1 -1
  227. package/dist/src/screen-recording-options.js +1 -1
  228. package/dist/src/screen-recording-resource-recovery.js +1 -1
  229. package/dist/src/screen-recording-transport.js +1 -0
  230. package/dist/src/screenshot-density.js +1 -1
  231. package/dist/src/screenshot-runtime.js +1 -1
  232. package/dist/src/screenshot.js +1 -1
  233. package/dist/src/screenshot3.js +1 -1
  234. package/dist/src/script.js +1 -1
  235. package/dist/src/scroll-command.js +1 -1
  236. package/dist/src/scroll-gesture.js +1 -1
  237. package/dist/src/sdk-batch-runner.js +2 -2
  238. package/dist/src/sdk-batch.js +2 -2
  239. package/dist/src/sdk-contracts.d.ts +76 -1
  240. package/dist/src/sdk-contracts.js +1 -1
  241. package/dist/src/sdk-device.js +1 -1
  242. package/dist/src/sdk-finders.d.ts +1 -1
  243. package/dist/src/sdk-finders.js +1 -1
  244. package/dist/src/sdk-io.js +1 -1
  245. package/dist/src/sdk-remote-config.js +1 -1
  246. package/dist/src/sdk-selectors.d.ts +18 -1
  247. package/dist/src/sdk-selectors.js +1 -1
  248. package/dist/src/selection.js +0 -0
  249. package/dist/src/selector-runtime.js +1 -1
  250. package/dist/src/selectors.js +1 -1
  251. package/dist/src/semantic-index.js +1 -1
  252. package/dist/src/server.js +1 -1
  253. package/dist/src/session-allocation.js +1 -1
  254. package/dist/src/session-observation.js +1 -1
  255. package/dist/src/session-routing.js +1 -1
  256. package/dist/src/session-runtime-admission.js +1 -1
  257. package/dist/src/session-snapshot.js +1 -1
  258. package/dist/src/session-store.js +3 -3
  259. package/dist/src/session2.js +4 -5
  260. package/dist/src/settings.js +1 -1
  261. package/dist/src/simctl-facade.js +1 -1
  262. package/dist/src/simctl.js +1 -1
  263. package/dist/src/simulator-boot.js +1 -1
  264. package/dist/src/simulator.js +1 -1
  265. package/dist/src/snapshot-capture-annotations.js +1 -1
  266. package/dist/src/snapshot-diagnostics.js +1 -1
  267. package/dist/src/snapshot-quality-backend-capabilities.js +1 -1
  268. package/dist/src/snapshot-runtime-binding.js +1 -1
  269. package/dist/src/snapshot-runtime.js +1 -1
  270. package/dist/src/snapshot-state.js +1 -1
  271. package/dist/src/snapshot.js +1 -1
  272. package/dist/src/snapshot2.js +1 -1
  273. package/dist/src/snapshot3.js +1 -1
  274. package/dist/src/snapshot4.js +1 -1
  275. package/dist/src/src.js +1 -1
  276. package/dist/src/src4.js +1 -1
  277. package/dist/src/src7.js +1 -1
  278. package/dist/src/src8.js +1 -1
  279. package/dist/src/stop-sequence.js +1 -1
  280. package/dist/src/string-enum.js +1 -1
  281. package/dist/src/takeover.js +1 -1
  282. package/dist/src/text-entry-focus.js +1 -1
  283. package/dist/src/tool-provider.js +1 -1
  284. package/dist/src/tool-provider2.js +1 -1
  285. package/dist/src/touch-runtime.js +1 -1
  286. package/dist/src/transport.js +1 -1
  287. package/dist/src/tree.js +1 -1
  288. package/dist/src/tv-remote.js +1 -1
  289. package/dist/src/type-text-runtime.js +1 -1
  290. package/dist/src/verified-file.js +1 -1
  291. package/dist/src/video.js +1 -1
  292. package/dist/src/viewport.js +1 -1
  293. package/dist/src/web.js +1 -1
  294. package/dist/src/web2.js +1 -1
  295. package/dist/src/webdriver-source.js +1 -1
  296. package/dist/src/window-state.js +1 -1
  297. package/package.json +2 -1
  298. package/server.json +2 -2
  299. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.6.apk.sha256 +0 -1
  300. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.6.apk.sha256 +0 -1
  301. package/dist/src/session-target-evidence.js +0 -1
  302. package/dist/src/vars.js +0 -2
@@ -1,2 +1,2 @@
1
- import{C as e,p 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(e,n,r,i){let a=t(n),o=e=>l(e,a.x,a.y);return(u(r.filter(o))??u(r))||(i?.(),u(e.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 _(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);let r=Oe(n);if(r.length===0)throw new e(`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(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector segment cannot be empty`);let r=ke(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Invalid selector segment: ${t}`);return{raw:n,terms:r.map(De)}}function De(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(!be.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(!g.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(be.has(i)){let t=Pe(a);if(t===null)throw new e(`INVALID_ARGS`,`Invalid boolean value for ${i}: ${a}`);return{key:i,value:t}}return{key:i,value:je(a)}}function Oe(t){let n=[],r=``,i=null;for(let a=0;a<t.length;a+=1){let o=t[a];if((o===`"`||o===`'`)&&!Fe(t,a)){i=Ae(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 ke(t){let n=[],r=``,i=null;for(let e=0;e<t.length;e+=1){let a=t.charAt(e);if((a===`"`||a===`'`)&&!Fe(t,e)){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 e(`INVALID_ARGS`,`Unclosed quote in selector: ${t}`);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,visibility: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,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(et(e))}function et(e){if(Array.isArray(e))return e.map(et);if(!e||typeof e!=`object`)return e;let t=e;return Object.fromEntries(Object.keys(t).sort().map(e=>[e,et(t[e])]))}function tt(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 nt=/^#\s*agent-device:target-v(\d+)(?:\s+(\S.*))?$/,rt=/^#\s*agent-device:targets-v(\d+)(?:\s+(\S.*))?$/,it=4096;function x(e){return e.normalize(`NFC`)}function at(e){if(e===void 0)return;let t=x(e);return t.length>0?t:void 0}function ot(e){return x(e)}function st(e){if(e===void 0)return;let t=x(e).trim().replaceAll(/\s+/g,` `);return t.length>0?t:void 0}function S(e){return Buffer.byteLength(e,`utf8`)}function C(e,t){if(S(e)<=t)return e;let n=e.length;for(;n>0&&S(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 ct(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(lt),t.sibling=e.sibling,t.viewportOrder=e.viewportOrder,e.scrollRegion&&(t.scrollRegion=ut(e.scrollRegion)),e.rect&&(t.rect=dt(e.rect)),t.verification=e.verification,t}function lt(e){let t={role:e.role};return e.label!==void 0&&(t.label=e.label),t}function ut(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 dt(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}function ft(e){return JSON.stringify(ct(e))}function pt(e){return`# agent-device:target-v1 ${ft(e)}`}function mt(e){return JSON.stringify({source:ct(e.source),destination:ct(e.destination)})}function ht(e){return`# agent-device:targets-v1 ${mt(e)}`}function gt(e){let t=e.trim(),n=rt.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:_t((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function _t(t){if(S(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:yt(JSON.stringify(r.source)),destination:yt(JSON.stringify(r.destination))}}function vt(e){let t=e.trim();if(!t.startsWith(`#`))return{kind:`none`};let n=nt.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:yt((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function yt(t){if(S(t)>4096)throw new e(`INVALID_ARGS`,`target-v1 annotation exceeds the ${it}-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=bt(r.role,`role`),a=xt(r.id,`id`),o=St(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 bt(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 w(ot(t),n)}function xt(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:w(r,n)}function St(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=st(t);return r===void 0?void 0:w(r,n)}function w(t,n){if(S(t)>256)throw new e(`INVALID_ARGS`,`target-v1 "${n}" exceeds the 256-byte field cap.`);return t}function Ct(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)=>wt(e,t))}function wt(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=bt(r.role,`ancestry[${n}].role`),a=St(r.label,`ancestry[${n}].label`);return{role:i,...a===void 0?{}:{label:a}}}function Tt(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 Et(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=bt(n.role,`scrollRegion.role`),i=xt(n.id,`id`),a=St(n.label,`scrollRegion.label`);return{role:r,...i===void 0?{}:{id:i},...a===void 0?{}:{label:a}}}function Dt(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: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(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 Ot(t){if(t===`verified`||t===`unverifiable`)return t;throw new e(`INVALID_ARGS`,`target-v1 "verification" must be "verified" or "unverifiable".`)}function kt(e){let t=ot(p(e.type??``)),n=at(e.identifier),r=st(e.label);return{...n===void 0?{}:{id:C(n,256)},role:C(t,256),...r===void 0?{}:{label:C(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=an([...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 an(t){let n=`any`,r=0;Kt.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=qt(a[0]);if(rn(o))return{locator:n,query:i,action:o};if(o===`get`)return{locator:n,query:i,action:on(a[1])};if(o===`wait`){let e=cn(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 e(`INVALID_ARGS`,`Unsupported find action: ${a[0]}`,{hint:en})}function on(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 sn(e,t){return e!==`any`||!t.includes(`=`)&&!t.includes(`||`)?null:v(t)?t:null}function cn(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function ln(e,t,n){return t.terms.every(t=>un(e,t,n))}function un(e,t,n){switch(t.key){case`id`:return A(e.identifier,String(t.value));case`role`:return A(p(e.type??``),String(t.value));case`label`:return A(e.label,String(t.value));case`value`:return A(e.value,String(t.value));case`text`:return A(m(e),String(t.value));case`appname`:return A(e.appName,String(t.value));case`windowtitle`:return A(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 A(e,t){return k(e??``)===k(t)}function dn(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=vn(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 fn(e,t,n){return dn(e,t,n).resolution}function pn(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:ln(e,a,n.platform));if(t.length>0)return{selector:a,selectorIndex:i,matchedNodes:t}}return null}function mn(e,t,n){let r=n.requireRect??!1,i=[];for(let[a,o]of t.selectors.entries()){let t=Sn(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 gn(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 _n(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 vn(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||ln(l,t,n)&&(i+=1,a??=l,o.push(l),yn(s,l,c));return{count:i,firstNode:a,disambiguated:s.tie?null:s.best,tiebreak:s.tie?null:bn(o,s.best,c),candidates:o}}function yn(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=Cn(t,e.best);i.result>0?(e.best=t,e.tie=!1):i.result===0&&(e.tie=!0)}function bn(e,t,n){if(!t)return null;let r=null;for(let i of e)i!==t&&(!r||xn(i,r,n).result>0)&&(r=i);return r?xn(t,r,n).criterion:null}function xn(e,t,n){let r=n(e);return r===n(t)?Cn(e,t):{result:r?1:-1,criterion:`visible`}}function Sn(e,t,n,r){let i=0;for(let a of e)r&&!a.rect||ln(a,t,n)&&(i+=1);return i}function Cn(e,t){let n=e.depth??0,r=t.depth??0;if(n!==r)return{result:n>r?1:-1,criterion:`deepest`};let i=wn(e),a=wn(t);return i===a?{result:0,criterion:null}:{result:i<a?1:-1,criterion:`smallest-area`}}function wn(e){return e.rect?e.rect.width*e.rect.height:1/0}const Tn={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 En(e){return e.ambiguity===`first-match`?{requireRect:e.requireRect,requireUnique:!1}:{requireRect:e.requireRect,requireUnique:!0,disambiguateAmbiguous:e.ambiguity===`disambiguate`}}function Dn(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 On(e){return{platform:e.platform,...En({ambiguity:e.allowDisambiguation?`disambiguate`:`fail-closed`,requireRect:e.requireRect})}}function kn(e,t,n){let r=v(e);if(!r)return{kind:`unresolved`,reason:`parse-invalid`,matchedNodes:[]};let{resolution:i,matchedNodes:a}=dn(t,r,On(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 An(e,t,n={}){return Ut(e,t,n)}function jn(e,t,n){let r=v(e);if(!r)return;let i=fn(t,r,On(n));if(i)return{node:i.node,basis:Nn(i.selector)}}function Mn(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 Nn(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 Pn(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?Fn(n.selectors,r,i):In(n.selectors[0],r,new Set(t.booleanKeys),i)}function Fn(e,t,n){let r=e.map(e=>{let r=e.terms.length===1?e.terms[0]:void 0;return r&&Ln(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 In(e,t,n,r){if(!e)return null;let i={},a=0;for(let o of e.terms){if(Ln(o.key,t,r)&&typeof o.value==`string`)a+=1;else if(!Rn(o,n,`boolean`))return null;i[r[o.key]??o.key]=o.value}return a<=1&&Object.keys(i).length>0?i:null}function Ln(e,t,n){return t.has(e)||n[e]!==void 0}function Rn(e,t,n){return t.has(e.key)&&typeof e.value===n}function zn(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 Bn(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 Vn(e,t){return v(e)?.selectors.some(e=>e.terms.some(e=>e.key===t))??!1}function Hn(e){return _(e).selectors.map(e=>e.raw)}function Un(e){return v(e)!==null}function Wn(e){_(e)}function j(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}const Gn=new Set([`exists`,`present`,`appears`,`gone`,`disappears`]);function Kn(e){let t=e[0];if(t===void 0)return null;let n=j(t);if(n!==null)return{kind:`sleep`,durationMs:n};let r=j(e.at(-1));return t===`text`?qn(e,r):t===`stable`?Jn(e):t===`absent`?Yn(e,r):t.startsWith(`@`)?{kind:`ref`,rawRef:t,timeoutMs:r}:Zn(e,r)}function qn(e,t){return{kind:`text`,text:(t===null?e.slice(1).join(` `):e.slice(1,-1).join(` `)).trim(),timeoutMs:t}}function Jn(e){let t=e.slice(1),n=t.length>1?j(t[1]):null;return{kind:`stable`,quietMs:t.length>0?j(t[0]):null,timeoutMs:n}}function Yn(e,t){let n=t===null?e.slice(1):e.slice(1,-1),r=b(n);return n.length>0&&r?.rest.length===0&&Un(r.selectorExpression)?{kind:`absent`,selectorExpression:r.selectorExpression,timeoutMs:t}:{kind:`invalid`,reason:`absent-selector-required`,message:Xn(n)}}function Xn(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 Zn(e,t){let n=t===null?e.slice():e.slice(0,-1),r=b(n);return r&&r.rest.length===0&&Un(r.selectorExpression)?{kind:`selector`,selectorExpression:r.selectorExpression,timeoutMs:t}:Qn(n,r)||{kind:`text`,text:(t===null?e.join(` `):e.slice(0,-1).join(` `)).trim(),timeoutMs:t}}function Qn(e,t){for(let t of e){let n=Te(t);if(n)return{kind:`invalid`,reason:`unknown-selector-key`,message:$n(n,e)}}return t&&t.rest.length>0?{kind:`invalid`,reason:`selector-shaped-text`,message:er(t,e)}:e.some(e=>y(e))?{kind:`invalid`,reason:`selector-shaped-text`,message:tr(e)}:null}function $n(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 er(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 tr(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=Gn.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 nr(e){let t=Kn(e);return t?t.kind===`sleep`?t.durationMs:t.kind===`invalid`?null:t.timeoutMs:null}const rr=24e4,ir=3e4,ar=3e5,M={budget:{source:`none`},envelopeMs:9e4,onTimeout:`reset-daemon`};function or(e,t){if(e.envelopeMs===`unbounded`)return;let n={...e,envelopeMs:e.envelopeMs};return sr(n,t.positionals??[])??cr(n,t.flags)??n.envelopeMs}function sr(e,t){if(e.budget.source!==`positional-parser`)return;let n=e.budget.parser(t);return n===null?void 0:ur(e,n)}function cr(e,t){if(e.budget.source===`flag`)return e.budget.envelope===`widen`?lr(e,e.budget,t):e.budget.envelope===`margin`?typeof t?.timeoutMs==`number`?ur(e,t.timeoutMs):e.envelopeMs:typeof t?.timeoutMs==`number`?t.timeoutMs:e.envelopeMs}function lr(e,t,n){if(n?.settle!==!0)return e.envelopeMs;let r=typeof n.timeoutMs==`number`?n.timeoutMs:t.defaultBudgetMs;return typeof r==`number`?dr(e,r):e.envelopeMs}function ur(e,t){return Math.max(e.envelopeMs,t+ir)}function dr(e,t){return Math.max(e.envelopeMs,e.envelopeMs+t+ir)}const fr={click:`settle-and-verify`,press:`settle-and-verify`,fill:`settle-and-verify`,longpress:`settle`,hover:`settle`,scroll:`settle`,back:`settle`};function pr(e){if(e!==void 0)return fr[e]}function N(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 mr(e){if(!n(e))throw TypeError(`Unknown local runtime family: ${String(e)}`);return Object.freeze({kind:`local-family`,family:e})}function hr(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 gr(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 P(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 _r(e,t){return P(e)===P(t)}function vr(e,t){return e.available?t():{}}function yr(e){if(!F(e.requesterId)||!F(e.identityIncarnationId)||!xr(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 br(e){let t=Sr(e.token);if(!t||t.length!==2)return null;let[n,r]=t;if(!F(n)||!F(r)||!xr(e.generation))return null;let i=Object.freeze({requesterId:n,requestGeneration:e.generation,identityIncarnationId:r});return yr(i).token===e.token?i:null}function xr(e){return Number.isInteger(e)&&e>=0}function F(e){return typeof e==`string`&&e.trim().length>0}function Sr(e){try{let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function Cr(e,t){let n={},r={};for(let i of t.required){let t=I(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=I(e.facts.operations,i);n[i]=t,t.available&&(r[i]=Er(e.operations,i))}for(let i of t.conditional??[]){let t=I(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 I(e,t){let n=e[t];if(!wr(n))throw N(`Runtime owner omitted the ${t} fact`);let r=Tr(n);if(r)return r;throw N(`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 N(`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(t,n){return new e(`UNSUPPORTED_OPERATION`,`Runtime operation ${t} 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`]}),z=L({required:[`fillPoint`]}),pi=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([z,pi]);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:pi}:{kind:`fill-point`,use:z};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.until===void 0?e.edge===void 0?Object.freeze({kind:`direction`,use:Ti}):Object.freeze({kind:`edge`,edge:e.edge,use:Ei}):Object.freeze({kind:`until`,until:e.until,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`]}),Ui=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`],conditional:[`findText`]}),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(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: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:t.marker??``,requiresAppSession:!1,use:U});case`clear`:return t.restart?Object.freeze({kind:`clear-restart`,requiresAppSession:!0,use:Fa}):Object.freeze({kind:`clear`,requiresAppSession:!1,use:U});default:throw new e(`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(t){let n=(t?.[0]??`probe`).toLowerCase();if(!Wa.includes(n))throw new e(`INVALID_ARGS`,`audio requires probe`);let r=(t?.[1]??`status`).toLowerCase();if(!Ga.includes(r))throw new e(`INVALID_ARGS`,`audio probe requires ${Ga.join(`, `)}`);if(r!==`start`&&t&&t.length>2)throw new e(`INVALID_ARGS`,`audio probe duration and bucket are only supported with audio probe start`);return Object.freeze({probeAction:r,durationMs:qa(t?.[2],{defaultValue:1e4,min:100,max:12e4,message:`audio probe duration must be an integer in range 100..120000 ms`}),bucketMs:qa(t?.[3],{defaultValue:1e3,min:100,max:1e4,message:`audio probe bucket must be an integer in range 100..10000 ms`})})}function qa(t,n){if(t===void 0)return n.defaultValue;let r=Number.parseInt(t,10);if(!Number.isInteger(r)||String(r)!==t||r<n.min||r>n.max)throw new e(`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(t){let n=(t.action??`dump`).toLowerCase(),r=(t.include??`summary`).toLowerCase();if(!$a(n))throw new e(`INVALID_ARGS`,`network requires dump or log`);if(!eo(r))throw new e(`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(t){switch((t.action??``).toLowerCase()){case`start`:if(!bo(t.scope??`app`))throw new e(`INVALID_ARGS`,`record scope must be app, device, or system`);return Object.freeze({kind:`start`,use:mo});case`stop`:return t.hasLiveHandle===!0?Object.freeze({kind:`stop-live`,use:go}):Object.freeze({kind:`stop-recovery`,use:ho});default:throw new e(`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(an(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:M,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={...M,onTimeout:`preserve-daemon`},Vo={...M,envelopeMs:18e4},Ho={...M,onTimeout:`preserve-daemon`},Uo={...Ho,envelopeMs:33e4},Wo={...M,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 pr(e)===void 0?t:Wo}function Z(e){let t=pr(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:M,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:M,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:M,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:M,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:M,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:M,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:M,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:M,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:M,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:M,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:M,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:M,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:M,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:M,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:M,batchable:!0},{name:`audio`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},timeoutPolicy:M,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:{...M,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:{...M,envelopeMs:`unbounded`},batchable:!0,platformExecution:q},{name:`runtime`,deviceClaimPolicy:`require-owner`,catalog:{group:`internal`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:M,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:M,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:M,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:M,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:M,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:M,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:{...M,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:rr,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:M,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:M,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:M,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:nr}},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:M,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:M,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:M,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:M,batchable:!0},{name:`trace`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`},timeoutPolicy:M,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`,M),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:M,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`,M),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:M,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:M,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:M,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:M,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:M,batchable:!0},{name:`debug`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`daemon`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:zo},{name:`device`,deviceClaimPolicy:`observe`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`metro`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`session`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`cdp`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`auth`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`connect`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`connection`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`disconnect`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`mcp`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`proxy`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`takeover`,deviceClaimPolicy:`observe`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:{kind:`inventory`,use:io}},{name:`react-devtools`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`,key:`reactDevtools`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`web`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,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?M:us.get(e)??M}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()}const ws={apps:{appsFilter:`user-installed`}};function Ts(e,t){if(!e||!as(e))return!1;let n=ws[e];if(!n)return!1;let r=!1;for(let e of Object.keys(n))t[e]===void 0&&(t[e]=n[e],r=!0);return r}function Es(e){let t=[];for(let n of e)n.daemon&&t.push({command:n.name,...n.daemon,replayScopedAction:n.recordsSessionAction});return t}function Ds(e){return e.filter(e=>e.batchable).map(e=>e.name)}const Os=Ds(Q),ks=new Set([`batch`,`replay`]),As=[`command`,`positionals`,`input`,`flags`,`runtime`],js=[`platform`,`target`,`device`,`udid`,`serial`,`verbose`,`out`],Ms=`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.`,Ns=new Set(Os);function Ps(e){return Ns.has(e)}function Fs(e){return typeof e==`string`?e.trim().toLowerCase():``}function Is(e){let t=Fs(e);return Ps(t)?t:void 0}function Ls(t,n,r=Ms){let i=Is(t);if(i!==void 0)return i;throw new e(`INVALID_ARGS`,`Batch step ${n} command is not available through command batch: ${String(t)}`,{hint:r})}function Rs(t,n){if(ks.has(t))throw new e(`INVALID_ARGS`,`Batch step ${n} cannot run ${t}.`)}export{Qr as $,C as $n,ar as $t,Ya as A,Jt as An,oe as Ar,oi as At,Ma as B,At as Bn,d as Br,R as Bt,vs as C,dn as Cn,ge as Cr,li as Ct,_o as D,en as Dn,fe as Dr,ri as Dt,yo as E,$t as En,ue as Er,ni as Et,Ia as F,D as Fn,re as Fr,ea as Ft,ba as G,Nt as Gn,mr as Gt,ka as H,Lt as Hn,c as Hr,Rr as Ht,Ra as I,It as In,te as Ir,ta as It,Ca as J,ht as Jn,hr as Jt,xa as K,Ft as Kn,gr as Kt,ja as L,Mt as Ln,ee as Lr,yi as Lt,Ba as M,an as Mn,p as Mr,Ni as Mt,Ka as N,sn as Nn,ne as Nr,aa as Nt,ho as O,tn as On,m as Or,ai as Ot,Ua as P,Ut as Pn,ie as Pr,Pi as Pt,Zr as Q,ft as Qn,N as Qt,Ta as R,Ht as Rn,l as Rr,Jr as Rt,ys as S,fn as Sn,le as Sr,Ur as St,xs as T,Gt as Tn,_e as Tr,ti as Tt,ya as U,kt as Un,s as Ur,Ir as Ut,Oa as V,Rt as Vn,u as Vr,Hr as Vt,Sa as W,Pt as Wn,a as Wr,br as Wt,_a as X,gt as Xn,_r as Xt,ga as Y,pt as Yn,P as Yt,va as Z,vt as Zn,vr as Zt,ns as _,En as _n,_ as _r,wi as _t,Rs as a,Pn as an,Ke as ar,Pr as at,bs as b,_n as bn,ve as br,Wr as bt,Is as c,Vn as cn,Je as cr,fi as ct,Q as d,An as dn,Ve as dr,$r as dt,rr as en,S as er,Yr as et,rs as f,Mn as fn,Be as fr,ei as ft,ts as g,Tn as gn,y as gr,Lr as gt,Cs as h,jn as hn,Ce as hr,$i as ht,Os as i,Un as in,qe as ir,Kr as it,Qa as j,qt as jn,se as jr,la as jt,to as k,Yt as kn,ae as kr,ii as kt,Es as l,Bn as ln,Ze as lr,ui as lt,hs as m,kn as mn,Te as mr,z as mt,As as n,Kn as nn,tt as nr,qr as nt,Fs as o,Hn as on,Xe as or,zr as ot,ms as p,Dn as pn,xe as pr,L as pt,Aa as q,it as qn,Cr as qt,js as r,j as rn,Qe as rr,ua as rt,Ls as s,zn as sn,Ye as sr,pi as st,Ms as t,or as tn,$e as tr,Xr as tt,Ts as u,Wn as un,Re as ur,ci as ut,is as v,hn as vn,b as vr,Br as vt,gs as w,gn as wn,he as wr,Vr as wt,Ss as x,pn as xn,h as xr,Gr as xt,_s as y,mn as yn,v as yr,di as yt,Ea as z,zt as zn,o as zr,fa as zt};
1
+ import{D as e,g as t}from"./sdk-contracts.js";import{n,p 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(e,n,r,i){let a=t(n),o=e=>l(e,a.x,a.y);return(u(r.filter(o))??u(r))||(i?.(),u(e.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 _(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);let r=Oe(n);if(r.length===0)throw new e(`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(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector segment cannot be empty`);let r=ke(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Invalid selector segment: ${t}`);return{raw:n,terms:r.map(De)}}function De(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(!be.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(!g.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(be.has(i)){let t=Pe(a);if(t===null)throw new e(`INVALID_ARGS`,`Invalid boolean value for ${i}: ${a}`);return{key:i,value:t}}return{key:i,value:je(a)}}function Oe(t){let n=[],r=``,i=null;for(let a=0;a<t.length;a+=1){let o=t[a];if((o===`"`||o===`'`)&&!Fe(t,a)){i=Ae(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 ke(t){let n=[],r=``,i=null;for(let e=0;e<t.length;e+=1){let a=t.charAt(e);if((a===`"`||a===`'`)&&!Fe(t,e)){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 e(`INVALID_ARGS`,`Unclosed quote in selector: ${t}`);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,visibility: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,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(et(e))}function et(e){if(Array.isArray(e))return e.map(et);if(!e||typeof e!=`object`)return e;let t=e;return Object.fromEntries(Object.keys(t).sort().map(e=>[e,et(t[e])]))}function tt(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 nt=/^#\s*agent-device:target-v(\d+)(?:\s+(\S.*))?$/,rt=/^#\s*agent-device:targets-v(\d+)(?:\s+(\S.*))?$/,it=4096;function at(e){return e.normalize(`NFC`)}function ot(e){if(e===void 0)return;let t=at(e);return t.length>0?t:void 0}function st(e){return at(e)}function ct(e){if(e===void 0)return;let t=at(e).trim().replaceAll(/\s+/g,` `);return t.length>0?t:void 0}function x(e){return Buffer.byteLength(e,`utf8`)}function S(e,t){if(x(e)<=t)return e;let n=e.length;for(;n>0&&x(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 lt(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(ut),t.sibling=e.sibling,t.viewportOrder=e.viewportOrder,e.scrollRegion&&(t.scrollRegion=dt(e.scrollRegion)),e.rect&&(t.rect=ft(e.rect)),t.verification=e.verification,t}function ut(e){let t={role:e.role};return e.label!==void 0&&(t.label=e.label),t}function dt(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 ft(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}function pt(e){return JSON.stringify(lt(e))}function mt(e){return`# agent-device:target-v1 ${pt(e)}`}function ht(e){return JSON.stringify({source:lt(e.source),destination:lt(e.destination)})}function gt(e){return`# agent-device:targets-v1 ${ht(e)}`}function _t(e){let t=e.trim(),n=rt.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:vt((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function vt(t){if(x(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:bt(JSON.stringify(r.source)),destination:bt(JSON.stringify(r.destination))}}function yt(e){let t=e.trim();if(!t.startsWith(`#`))return{kind:`none`};let n=nt.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:bt((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function bt(t){if(x(t)>4096)throw new e(`INVALID_ARGS`,`target-v1 annotation exceeds the ${it}-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=xt(r.role,`role`),a=St(r.id,`id`),o=Ct(r.label,`label`),s=Tt(r.ancestry),c=Dt(r.sibling,`sibling`,0),l=Dt(r.viewportOrder,`viewportOrder`,0),u=Ot(r.scrollRegion),d=kt(r.rect),f=At(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 xt(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 wt(st(t),n)}function St(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=ot(t);return r===void 0?void 0:wt(r,n)}function Ct(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=ct(t);return r===void 0?void 0:wt(r,n)}function wt(t,n){if(x(t)>256)throw new e(`INVALID_ARGS`,`target-v1 "${n}" exceeds the 256-byte field cap.`);return t}function Tt(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)=>Et(e,t))}function Et(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=xt(r.role,`ancestry[${n}].role`),a=Ct(r.label,`ancestry[${n}].label`);return{role:i,...a===void 0?{}:{label:a}}}function Dt(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 Ot(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=xt(n.role,`scrollRegion.role`),i=St(n.id,`id`),a=Ct(n.label,`scrollRegion.label`);return{role:r,...i===void 0?{}:{id:i},...a===void 0?{}:{label:a}}}function kt(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:C(n.x,`rect.x`),y:C(n.y,`rect.y`),width:C(n.width,`rect.width`),height:C(n.height,`rect.height`)}}function C(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 At(t){if(t===`verified`||t===`unverifiable`)return t;throw new e(`INVALID_ARGS`,`target-v1 "verification" must be "verified" or "unverifiable".`)}function jt(e){let t=st(p(e.type??``)),n=ot(e.identifier),r=ct(e.label);return{...n===void 0?{}:{id:S(n,256)},role:S(t,256),...r===void 0?{}:{label:S(r,256)}}}function Mt(e,t){return e.id===t.id&&e.role===t.role&&e.label===t.label}function Nt(e,t){let n=0;for(let r of e)jt(r).id===t&&(n+=1);return n}function Pt(e,t){if(e.id===void 0||Nt(t,e.id)<=1)return e;let{role:n,label:r}=e;return{role:n,...r===void 0?{}:{label:r}}}function Ft(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 It(e,t){return{documentOrder:e.index,sibling:Ft(t,e)}}function Lt(e,t){return e.documentOrder===t.documentOrder&&e.sibling===t.sibling}function Rt(e){return{...e.id===void 0?{}:{id:e.id},role:e.role,...e.label===void 0?{}:{label:e.label}}}function zt(e,t){return t.id===void 0?e.role===t.role&&e.label===t.label:e.id===t.id}function Bt(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 Vt(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 Ht(e){return e?`${e.role}${e.label?`/${e.label}`:``}`:`(missing)`}function Ut(e,t){return!t||t.role!==e.role||e.label!==void 0&&t.label!==e.label}function Wt(e,t){for(let[n,r]of e.entries()){let e=t[n];if(Ut(r,e))return[`ancestry[${n}]: recorded=${Ht(r)} observed=${Ht(e)}`]}return[]}function Gt(e,t,n={}){let r=[],i=p(e.type??``),a=Kt(e,n.nodes),o=T(e.label),s=T(e.value),c=T(m(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=Qe(r);return u.length===0&&i&&u.push(l?`role=${w(i)} editable=true`:`role=${w(i)}`),u.length===0&&h(e)&&u.push(`visible=true`),u}function Kt(e,t){let n=T(e.identifier);if(!n||!t)return n;let r=jt(e).id;return r===void 0?n:Nt(t,r)>1?null:n}function w(e){return JSON.stringify(e)}function T(e){return e&&e.trim()||null}const qt=[`any`,`text`,`label`,`value`,`role`,`id`],Jt=[`text`,`label`,`value`,`role`,`id`];function Yt(e){let t=e?.toLowerCase();return t===`press`||t===`tap`?`click`:t}function Xt(e){return e===`exists`||e===`wait`||e===`get_text`||e===`get_attrs`||e===`list`}function Zt(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=Qt(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 Qt(e,t,n){switch(t){case`role`:return $t(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 $t(e,t){let n=en(e??``);return n?n===t?2:+!!n.includes(t):0}function D(e){return e.trim().toLowerCase().replaceAll(/\s+/g,` `)}function en(e){let t=e.trim();return t?(t=(t.split(`.`).pop()??t).replaceAll(/XCUIElementType/gi,``).toLowerCase(),t):``}const tn=`find requires a value`,nn=`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 rn(e,t){if(e.length===0)return{ok:!1,code:`INVALID_ARGS`,message:`find requires a locator or text`};let n=O([...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:tn}}const an=[`exists`,`list`,`click`,`focus`];function on(e){return an.includes(e)}function O(t){let n=`any`,r=0;Jt.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=Yt(a[0]);if(on(o))return{locator:n,query:i,action:o};if(o===`get`)return{locator:n,query:i,action:sn(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`){let e=a.slice(1);return{locator:n,query:i,action:o,value:e.length===0?void 0:e.join(` `)}}throw new e(`INVALID_ARGS`,`Unsupported find action: ${a[0]}`,{hint:nn})}function sn(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 cn(e,t){return e!==`any`||!t.includes(`=`)&&!t.includes(`||`)?null:v(t)?t:null}function ln(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function k(e,t,n){return t.terms.every(t=>un(e,t,n))}function un(e,t,n){switch(t.key){case`id`:return A(e.identifier,String(t.value));case`role`:return A(p(e.type??``),String(t.value));case`label`:return A(e.label,String(t.value));case`value`:return A(e.value,String(t.value));case`text`:return A(m(e),String(t.value));case`appname`:return A(e.appName,String(t.value));case`windowtitle`:return A(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 A(e,t){return D(e??``)===D(t)}function dn(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=vn(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 fn(e,t,n){return dn(e,t,n).resolution}function pn(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:k(e,a,n.platform));if(t.length>0)return{selector:a,selectorIndex:i,matchedNodes:t}}return null}function mn(e,t,n){let r=n.requireRect??!1,i=[];for(let[a,o]of t.selectors.entries()){let t=Sn(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 gn(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 _n(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 vn(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||k(l,t,n)&&(i+=1,a??=l,o.push(l),yn(s,l,c));return{count:i,firstNode:a,disambiguated:s.tie?null:s.best,tiebreak:s.tie?null:bn(o,s.best,c),candidates:o}}function yn(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=Cn(t,e.best);i.result>0?(e.best=t,e.tie=!1):i.result===0&&(e.tie=!0)}function bn(e,t,n){if(!t)return null;let r=null;for(let i of e)i!==t&&(!r||xn(i,r,n).result>0)&&(r=i);return r?xn(t,r,n).criterion:null}function xn(e,t,n){let r=n(e);return r===n(t)?Cn(e,t):{result:r?1:-1,criterion:`visible`}}function Sn(e,t,n,r){let i=0;for(let a of e)r&&!a.rect||k(a,t,n)&&(i+=1);return i}function Cn(e,t){let n=e.depth??0,r=t.depth??0;if(n!==r)return{result:n>r?1:-1,criterion:`deepest`};let i=wn(e),a=wn(t);return i===a?{result:0,criterion:null}:{result:i<a?1:-1,criterion:`smallest-area`}}function wn(e){return e.rect?e.rect.width*e.rect.height:1/0}const Tn={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 En(e){return e.ambiguity===`first-match`?{requireRect:e.requireRect,requireUnique:!1}:{requireRect:e.requireRect,requireUnique:!0,disambiguateAmbiguous:e.ambiguity===`disambiguate`}}function Dn(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 On(e){return{platform:e.platform,...En({ambiguity:e.allowDisambiguation?`disambiguate`:`fail-closed`,requireRect:e.requireRect})}}function kn(e,t,n){let r=v(e);if(!r)return{kind:`unresolved`,reason:`parse-invalid`,matchedNodes:[]};let{resolution:i,matchedNodes:a}=dn(t,r,On(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 An(e,t,n={}){return Gt(e,t,n)}function jn(e,t,n){let r=v(e);if(!r)return;let i=fn(t,r,On(n));if(i)return{node:i.node,basis:Nn(i.selector)}}function Mn(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 Nn(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 Pn(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?Fn(n.selectors,r,i):In(n.selectors[0],r,new Set(t.booleanKeys),i)}function Fn(e,t,n){let r=e.map(e=>{let r=e.terms.length===1?e.terms[0]:void 0;return r&&Ln(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 In(e,t,n,r){if(!e)return null;let i={},a=0;for(let o of e.terms){if(Ln(o.key,t,r)&&typeof o.value==`string`)a+=1;else if(!Rn(o,n,`boolean`))return null;i[r[o.key]??o.key]=o.value}return a<=1&&Object.keys(i).length>0?i:null}function Ln(e,t,n){return t.has(e)||n[e]!==void 0}function Rn(e,t,n){return t.has(e.key)&&typeof e.value===n}function zn(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 Bn(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 Vn(e,t){return v(e)?.selectors.some(e=>e.terms.some(e=>e.key===t))??!1}function Hn(e){return _(e).selectors.map(e=>e.raw)}function Un(e){return v(e)!==null}function Wn(e){_(e)}function j(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}const Gn=new Set([`exists`,`present`,`appears`,`gone`,`disappears`]);function Kn(e){let t=e[0];if(t===void 0)return null;let n=j(t);if(n!==null)return{kind:`sleep`,durationMs:n};let r=j(e.at(-1));return t===`text`?qn(e,r):t===`stable`?Jn(e):t===`absent`?Yn(e,r):t.startsWith(`@`)?{kind:`ref`,rawRef:t,timeoutMs:r}:Zn(e,r)}function qn(e,t){return{kind:`text`,text:(t===null?e.slice(1).join(` `):e.slice(1,-1).join(` `)).trim(),timeoutMs:t}}function Jn(e){let t=e.slice(1),n=t.length>1?j(t[1]):null;return{kind:`stable`,quietMs:t.length>0?j(t[0]):null,timeoutMs:n}}function Yn(e,t){let n=t===null?e.slice(1):e.slice(1,-1),r=b(n);return n.length>0&&r?.rest.length===0&&Un(r.selectorExpression)?{kind:`absent`,selectorExpression:r.selectorExpression,timeoutMs:t}:{kind:`invalid`,reason:`absent-selector-required`,message:Xn(n)}}function Xn(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 Zn(e,t){let n=t===null?e.slice():e.slice(0,-1),r=b(n);return r&&r.rest.length===0&&Un(r.selectorExpression)?{kind:`selector`,selectorExpression:r.selectorExpression,timeoutMs:t}:Qn(n,r)||{kind:`text`,text:(t===null?e.join(` `):e.slice(0,-1).join(` `)).trim(),timeoutMs:t}}function Qn(e,t){for(let t of e){let n=Te(t);if(n)return{kind:`invalid`,reason:`unknown-selector-key`,message:$n(n,e)}}return t&&t.rest.length>0?{kind:`invalid`,reason:`selector-shaped-text`,message:er(t,e)}:e.some(e=>y(e))?{kind:`invalid`,reason:`selector-shaped-text`,message:tr(e)}:null}function $n(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 er(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 tr(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=Gn.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 nr(e){let t=Kn(e);return t?t.kind===`sleep`?t.durationMs:t.kind===`invalid`?null:t.timeoutMs:null}const rr=24e4,ir=3e4,ar=3e5,M={budget:{source:`none`},envelopeMs:9e4,onTimeout:`reset-daemon`};function or(e,t){if(e.envelopeMs===`unbounded`)return;let n={...e,envelopeMs:e.envelopeMs};return sr(n,t.positionals??[])??cr(n,t.flags)??n.envelopeMs}function sr(e,t){if(e.budget.source!==`positional-parser`)return;let n=e.budget.parser(t);return n===null?void 0:dr(e,n)}function cr(e,t){if(e.budget.source===`flag`)return e.budget.envelope===`widen`?ur(e,e.budget,t):e.budget.envelope===`margin`?lr(e,t):typeof t?.timeoutMs==`number`?t.timeoutMs:e.envelopeMs}function lr(e,t){let n=typeof t?.timeoutMs==`number`?dr(e,t.timeoutMs):e.envelopeMs;return typeof t?.waitMs==`number`?fr({...e,envelopeMs:n},t.waitMs):n}function ur(e,t,n){if(n?.settle!==!0)return e.envelopeMs;let r=typeof n.timeoutMs==`number`?n.timeoutMs:t.defaultBudgetMs;return typeof r==`number`?fr(e,r):e.envelopeMs}function dr(e,t){return Math.max(e.envelopeMs,t+ir)}function fr(e,t){return Math.max(e.envelopeMs,e.envelopeMs+t+ir)}const pr={click:`settle-and-verify`,press:`settle-and-verify`,fill:`settle-and-verify`,longpress:`settle`,hover:`settle`,scroll:`settle`,back:`settle`};function mr(e){if(e!==void 0)return pr[e]}function N(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 hr(e){if(!r(e))throw TypeError(`Unknown local runtime family: ${String(e)}`);return Object.freeze({kind:`local-family`,family:e})}function gr(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 _r(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 P(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 vr(e,t){return P(e)===P(t)}function yr(e,t){return e.available?t():{}}function br(e){if(!F(e.requesterId)||!F(e.identityIncarnationId)||!Sr(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 xr(e){let t=Cr(e.token);if(!t||t.length!==2)return null;let[n,r]=t;if(!F(n)||!F(r)||!Sr(e.generation))return null;let i=Object.freeze({requesterId:n,requestGeneration:e.generation,identityIncarnationId:r});return br(i).token===e.token?i:null}function Sr(e){return Number.isInteger(e)&&e>=0}function F(e){return typeof e==`string`&&e.trim().length>0}function Cr(e){try{let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function wr(e,t){let n={},r={};for(let i of t.required){let t=I(e.facts.operations,i);if(n[i]=t,!t.available)throw kr(i,t);r[i]=Dr(e.operations,i)}for(let i of t.preferred){let t=I(e.facts.operations,i);n[i]=t,t.available&&(r[i]=Dr(e.operations,i))}for(let i of t.conditional??[]){let t=I(e.facts.operations,i);n[i]=t,t.available&&(r[i]=Dr(e.operations,i))}return Object.freeze({device:e.device,owner:e.owner,facts:Object.freeze(n),operations:Object.freeze(r)})}function I(e,t){let n=e[t];if(!Tr(n))throw N(`Runtime owner omitted the ${t} fact`);let r=Er(n);if(r)return r;throw N(`Runtime owner returned an invalid ${t} fact`)}function Tr(e){return typeof e==`object`&&!!e&&`available`in e}function Er(e){if(e.available===!0)return Object.freeze({available:!0});if(e.available===!1&&Or(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 Dr(e,t){let n=e[t];if(typeof n!=`function`)throw N(`Runtime owner advertised ${t} without an implementation`);return n}function Or(e){return e===`unsupported-platform-leaf`||e===`unsupported-device-kind`||e===`unsupported-device-backend`||e===`unsupported-provider-mode`||e===`owner-capability-missing`}function kr(t,n){return new e(`UNSUPPORTED_OPERATION`,`Runtime operation ${t} is unavailable`,{reason:n.reason,hint:n.hint})}function Ar(e){return JSON.stringify({required:[...e.required].sort(),preferred:[...e.preferred].sort(),conditional:[...e.conditional??[]].sort()})}function jr(){return e=>{let t=Mr(e.required,`required`),n=Mr(e.preferred??[],`preferred`),r=Mr(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 Mr(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=jr(),Nr=L({required:[`bootTarget`]}),Pr=L({required:[`bootTargetHeadless`]}),Fr=L({required:[`ensureReady`,`listApps`]}),Ir=L({required:[`captureSnapshot`]}),Lr=L({required:[`setViewport`]}),Rr=L({required:[`focusPoint`]}),zr=L({required:[`typeText`]}),Br=L({required:[`back`]}),Vr=L({required:[`home`]}),Hr=L({required:[`setOrientation`]}),Ur=L({required:[`tvRemote`]}),Wr=L({required:[`keyboardStatus`]}),Gr=L({required:[`keyboardDismiss`]}),Kr=L({required:[`keyboardEnter`]}),qr=L({required:[`appSwitcher`]}),Jr=L({required:[`actionButton`]}),Yr=L({required:[`triggerAppEvent`]}),Xr=L({required:[`setSetting`]}),Zr=L({required:[`readAlert`]}),Qr=L({required:[`awaitAlert`]}),$r=L({required:[`acceptAlert`]}),ei=L({required:[`dismissAlert`]}),ti=L({required:[`readClipboard`]}),ni=L({required:[`writeClipboard`]}),ri=L({required:[`perfFrames`]}),ii=L({required:[`perfMemorySample`]}),ai=L({required:[`perfMemorySnapshot`]}),oi=L({required:[`perfNativeCaptureStart`]}),si=L({required:[`perfNativeCaptureReattach`,`perfNativeCaptureCleanup`]}),ci=L({required:[`perfProfileReport`]}),li=Object.freeze([ri,ii,ai,oi,si,ci]),R=L({required:[`tapPoint`]}),ui=L({required:[`captureSnapshot`,`tapPoint`],preferred:[`tapRef`],conditional:[`tapElementSelector`]}),di=L({required:[`longPressPoint`]}),fi=L({required:[`captureSnapshot`,`longPressPoint`]}),pi=L({required:[`hoverPoint`]}),mi=L({required:[`captureSnapshot`,`hoverPoint`],preferred:[`hoverRef`]}),hi=L({required:[`fillPoint`]}),z=L({required:[`captureSnapshot`,`fillPoint`],preferred:[`fillRef`]}),gi=Object.freeze([R,ui]),_i=gi,vi=Object.freeze([di,fi]),yi=Object.freeze([pi,mi]),bi=Object.freeze([hi,z]);function xi(e,t){switch(e){case`click`:case`press`:return t?{kind:`captured-tap`,use:ui}:{kind:`tap-point`,use:R};case`fill`:return t?{kind:`captured-fill`,use:z}:{kind:`fill-point`,use:hi};case`longpress`:return t?{kind:`captured-long-press`,use:fi}:{kind:`long-press-point`,use:di};case`hover`:return t?{kind:`captured-hover`,use:mi}:{kind:`hover-point`,use:pi}}}const Si=L({required:[`performGesturePlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Ci=L({required:[`performDirectionalFlingPlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),wi=L({required:[`performMultiTouchGesturePlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Ti=L({required:[`performTargetAuthoredDrag`,`captureSnapshot`],preferred:[`gestureViewport`]}),Ei=L({required:[`gestureViewport`]}),Di=L({required:[`scrollDirection`]}),Oi=L({required:[`scrollDirection`,`captureSnapshot`]}),ki=Object.freeze({plan:Si,"directional-fling":Ci,"multi-touch":wi,"target-authored-drag":Ti}),Ai=Object.freeze([Si,Ci,wi,Ti]),ji=Object.freeze([Si]),Mi=Object.freeze([Di,Oi]);function Ni(e){return e.intent===`pan`?(`pointerCount`in e?e.pointerCount:1)===2:e.intent===`pinch`||e.intent===`rotate`||e.intent===`transform`}function Pi(e){return e.intent===`drag`?`target-authored-drag`:Ni(e)?`multi-touch`:e.intent===`fling`&&`direction`in e?`directional-fling`:`plan`}function Fi(e){let t=Pi(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=ki[e];return Object.freeze({tier:e,operation:t.required[0],use:t})}function Ii(e){return e.until===void 0?e.edge===void 0?Object.freeze({kind:`direction`,use:Di}):Object.freeze({kind:`edge`,edge:e.edge,use:Oi}):Object.freeze({kind:`until`,until:e.until,use:Oi})}const Li=L({required:[`captureSnapshot`,`captureSnapshotWithCustomActions`]}),Ri=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`]}),zi=L({required:[`captureSnapshot`,`captureSnapshotWithCustomActions`,`captureSnapshotWithoutActiveApp`]}),Bi=L({required:[`captureSnapshot`]}),Vi=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`]}),Hi=L({required:[`captureSnapshot`],preferred:[`readTextAtPoint`]}),Ui=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`],preferred:[`readTextAtPoint`]}),Wi=L({required:[`captureSnapshot`],conditional:[`findText`]}),Gi=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`],conditional:[`findText`]}),Ki=Object.freeze([Bi,Vi]),qi=Object.freeze([Hi,Ui]),Ji=L({required:[`captureSnapshot`,`focusPoint`]}),Yi=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`,`focusPoint`]}),Xi=L({required:[`captureSnapshot`,`focusPoint`,`typeText`]}),Zi=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`,`focusPoint`,`typeText`]}),Qi=Object.freeze([Hi,Ui,Bi,Vi,Ji,Yi,Xi,Zi]),$i=Object.freeze([Wi,Gi]),ea=Object.freeze([Ir,Li,Ri,zi]),V=Object.freeze({"capture-only":Ki,"element-text":qi,"wait-observation":$i,"find-focus":Object.freeze([Ji,Yi]),"find-type":Object.freeze([Xi,Zi])});function ta(e){return e===`focus`?`find-focus`:e===`type`?`find-type`:`capture-only`}function na(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 ra(e){return e.customActions?e.hasActiveApp?Object.freeze({kind:`custom-actions-active-app`,operation:`captureSnapshotWithCustomActions`,use:Li}):Object.freeze({kind:`custom-actions-without-active-app`,operation:`captureSnapshotWithCustomActions`,use:zi}):e.hasActiveApp?Object.freeze({kind:`active-app`,operation:`captureSnapshot`,use:Ir}):Object.freeze({kind:`without-active-app`,operation:`captureSnapshotWithoutActiveApp`,use:Ri})}const ia=L({required:[`captureScreenshot`]}),aa=L({required:[`captureScreenshot`,`captureSnapshot`]}),oa=Object.freeze([ia,aa]);function sa(e){return e.cropOn?Object.freeze({kind:`capture-with-crop-on`,use:aa}):e.overlayRefs?Object.freeze({kind:`capture-with-overlay-refs`,use:aa}):Object.freeze({kind:`capture`,use:ia})}const ca=Object.freeze([Nr,Pr]),la=Object.freeze({kind:`boot-target`,operation:`bootTarget`,use:Nr}),ua=Object.freeze({kind:`boot-target-headless`,operation:`bootTargetHeadless`,use:Pr});function da(e){return e.headless?ua:la}const fa=L({required:[`ensureReady`,`appState`]}),pa=Object.freeze([fa]),ma=L({required:[`shutdownTarget`]}),ha=Object.freeze([ti,ni]),ga=Object.freeze([Zr,Qr,$r,ei]),_a=Object.freeze([Wr,Gr,Kr]),va=L({required:[`deployApp`]}),ya=L({required:[`ensureReady`,`materializeAppSource`,`deployMaterializedApp`]}),ba=L({required:[`ensureReady`,`sendPushNotification`]}),xa=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`]}),Sa=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`]}),Ca=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`clearRuntimeHints`]}),wa=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`,`clearRuntimeHints`]});function Ta(e){return e.applyRuntimeHints&&e.clearRemovedRuntimeHints?Object.freeze({kind:`open-apply-and-clear-runtime-hints`,use:wa}):e.applyRuntimeHints?Object.freeze({kind:`open-apply-runtime-hints`,use:Sa}):e.clearRemovedRuntimeHints?Object.freeze({kind:`open-clear-runtime-hints`,use:Ca}):Object.freeze({kind:`open`,use:xa})}const Ea=Object.freeze([xa,Sa,Ca,wa]),Da=L({required:[`closeApplication`,`finalizeApplicationClose`]}),Oa=L({required:[`closeApplication`,`finalizeApplicationClose`,`clearRuntimeHints`]}),ka=Object.freeze([Da,Oa]),Aa=L({required:[`finalizeApplicationClose`]}),ja=L({required:[`finalizeApplicationClose`,`clearRuntimeHints`]}),Ma=L({required:[`prepareAppleRunner`]}),Na=L({required:[`clearRuntimeHints`]}),Pa=L({required:[`configureProviderPortReverse`]}),Fa=Object.freeze([Na,Pa]),U=L({required:[`appLogInspect`]}),Ia=L({required:[`appLogInspect`,`appLogDoctor`]}),La=L({required:[`appLogInspect`,`appLogStart`]}),Ra=L({required:[],preferred:[`appLogInspect`]}),za=Object.freeze([U,Ia,La]);function Ba(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:U});case`start`:return Object.freeze({kind:`start`,requiresAppSession:!0,use:La});case`stop`:return Object.freeze({kind:`stop`,requiresAppSession:!1,use:U});case`doctor`:return Object.freeze({kind:`doctor`,requiresAppSession:!1,use:Ia});case`mark`:return Object.freeze({kind:`mark`,marker:t.marker??``,requiresAppSession:!1,use:U});case`clear`:return t.restart?Object.freeze({kind:`clear-restart`,requiresAppSession:!0,use:La}):Object.freeze({kind:`clear`,requiresAppSession:!1,use:U});default:throw new e(`INVALID_ARGS`,`logs requires path, start, stop, doctor, mark, or clear`)}}const Va=L({required:[`audioProbeStart`]}),Ha=L({required:[`audioProbeReattach`,`audioProbeCleanup`]}),Ua=L({required:[`audioProbeQuery`]}),Wa=Object.freeze([Va,Ha,Ua]);function Ga(e){if(e.mode===`query`)return Object.freeze({kind:`query`,action:e.probeAction,use:Ua});switch(e.probeAction){case`start`:return Object.freeze({kind:`capture-start`,use:Va});case`status`:return Object.freeze({kind:`capture-status`});case`stop`:return Object.freeze({kind:`capture-stop`})}}const Ka=[`probe`],qa=[`start`,`status`,`stop`];function Ja(t){let n=(t?.[0]??`probe`).toLowerCase();if(!Ka.includes(n))throw new e(`INVALID_ARGS`,`audio requires probe`);let r=(t?.[1]??`status`).toLowerCase();if(!qa.includes(r))throw new e(`INVALID_ARGS`,`audio probe requires ${qa.join(`, `)}`);if(r!==`start`&&t&&t.length>2)throw new e(`INVALID_ARGS`,`audio probe duration and bucket are only supported with audio probe start`);return Object.freeze({probeAction:r,durationMs:Ya(t?.[2],{defaultValue:1e4,min:100,max:12e4,message:`audio probe duration must be an integer in range 100..120000 ms`}),bucketMs:Ya(t?.[3],{defaultValue:1e3,min:100,max:1e4,message:`audio probe bucket must be an integer in range 100..10000 ms`})})}function Ya(t,n){if(t===void 0)return n.defaultValue;let r=Number.parseInt(t,10);if(!Number.isInteger(r)||String(r)!==t||r<n.min||r>n.max)throw new e(`INVALID_ARGS`,n.message);return r}const Xa=L({required:[`networkDump`]}),Za=L({required:[],preferred:[`networkDump`]}),Qa=[`dump`,`log`],$a=[`summary`,`headers`,`body`,`all`];function eo(t){let n=(t.action??`dump`).toLowerCase(),r=(t.include??`summary`).toLowerCase();if(!to(n))throw new e(`INVALID_ARGS`,`network requires dump or log`);if(!no(r))throw new e(`INVALID_ARGS`,`network --include must be summary, headers, body, or all`);return Object.freeze({action:n,include:r,use:Xa})}function to(e){return Qa.some(t=>t===e)}function no(e){return $a.some(t=>t===e)}function ro(e){let t=new Map;for(let n of e){if(!r(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,io(n))}let i=n.filter(e=>!t.has(e));if(i.length>0)throw TypeError(`Missing platform family registrations: ${i.join(`, `)}`);let a=Object.freeze([...n]),o=Object.freeze(a.map(e=>ao(t,e)));return Object.freeze({families:a,modules:o,get:e=>ao(t,e)})}function io(e){return Object.freeze({...e})}function ao(e,t){let n=e.get(t);if(!n)throw TypeError(`Missing platform family registration: ${t}`);return n}const oo=Object.freeze({kind:`device-inventory`});function so(e){if(typeof e!=`object`||!e)throw ho();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`])&&lo(t.use))&&!(t.kind===`device-runtime`&&W(n,[`kind`,`use`])&&uo(t.use))&&!(t.kind===`device-runtime`&&(W(n,[`kind`,`uses`])||W(n,[`kind`,`selectUses`,`uses`])&&typeof t.selectUses==`function`)&&co(t.uses)))throw ho()}function co(e){if(!Array.isArray(e)||e.length===0||!e.every(uo))return!1;let t=e.map(Ar);return new Set(t).size===t.length}function lo(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.kind===`device-inventory`&&W(Object.keys(t).sort(),[`kind`])}function uo(e){if(typeof e!=`object`||!e)return!1;let t=e,n=[po(t.required),po(t.preferred),po(t.conditional??[])];if(!fo(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 fo(e){return e.every(e=>e!==null&&mo(e))}function po(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)?e:null}function mo(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 ho(){return TypeError(`Command platform execution must declare exactly one of none, host, inventory, or device-runtime`)}const go=L({required:[`screenRecordingStart`]}),_o=L({required:[`screenRecordingReattach`,`screenRecordingCleanup`]}),vo=L({required:[]}),yo=L({required:[],preferred:[`screenRecordingStart`]}),bo=Object.freeze([go,_o]);function xo(t){switch((t.action??``).toLowerCase()){case`start`:if(!So(t.scope??`app`))throw new e(`INVALID_ARGS`,`record scope must be app, device, or system`);return Object.freeze({kind:`start`,use:go});case`stop`:return t.hasLiveHandle===!0?Object.freeze({kind:`stop-live`,use:vo}):Object.freeze({kind:`stop-recovery`,use:_o});default:throw new e(`INVALID_ARGS`,`record requires start or stop`)}}function So(e){return e===`app`||e===`device`||e===`system`}function Co(e){if(so(e),e.kind!==`device-runtime`||!(`uses`in e))throw wo();let t=e.uses.map(Ar),n=bo.map(Ar),r=new Set(t),i=new Set(n);if(t.length!==n.length||r.size!==t.length||[...r].some(e=>!i.has(e)))throw wo()}function wo(){return TypeError(`Record runtime execution must declare exactly the uses selected by its two runtime-bearing plans`)}function To(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 so(t),t}const G={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0},K={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0,selectorValidationExempt:!0},Eo=()=>!0,Do=e=>(e.positionals?.[0]??``).toLowerCase()===`start`,Oo=e=>e.command===`test`&&(typeof e.flags?.shardAll==`number`||typeof e.flags?.shardSplit==`number`),ko=e=>(e.positionals?.length??0)===0?{kind:`unconditional`}:void 0,Ao=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},jo=new Set([`status`,`get`]),Mo=e=>zo(e,jo,`status`),No=new Set([`get`,`wait`]),Po=e=>zo(e,No,`get`),Fo=e=>Bo(e,jo,`status`),Io=e=>Bo(e,No,`get`),Lo=e=>{try{return Xt(O(e.positionals??[]).action)?`observes-app`:`mutates-app`}catch{return`mutates-app`}},Ro=e=>Bo(e,new Set([`read`]),``);function zo(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`preserve`:`may-invalidate`}function Bo(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`observes-app`:`mutates-app`}const q={kind:`none`},Vo={kind:`host`},J={recordsSessionAction:!0,recordingEffect:`mutates-app`,deviceClaimPolicy:`require-owner`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:M,batchable:!0},Ho={targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,deviceClaimPolicy:`require-owner`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0}},Y={...M,onTimeout:`preserve-daemon`},Uo={...M,envelopeMs:18e4},Wo={...M,onTimeout:`preserve-daemon`},Go={...Wo,envelopeMs:33e4},Ko={...M,budget:{source:`flag`,envelope:`widen`,defaultBudgetMs:1e4},onTimeout:`preserve-daemon`},qo={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}}},Jo={fields:{delayMs:{defaultValue:0}}};function X(e,t){return mr(e)===void 0?t:Ko}function Z(e){let t=mr(e);if(t===void 0)throw Error(`Missing post-action observation descriptor support for ${e}`);return t}const Yo={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:Uo,batchable:!0},Xo=e=>{let t=e.flags?.snapshotCustomActions===!0||e.input?.customActions===!0;return[!0,!1].map(e=>ra({customActions:t,hasActiveApp:e}).use)},Zo=e=>{let t=$o(e);if(t===void 0||!Qo(t))return Qi;let n=ta(t);return[!0,!1].map(e=>na({hasActiveApp:e,intent:n}).use)};function Qo(e){return Xt(e)||e===`focus`||e===`type`}function $o(e){if(e.positionals===void 0)return;let t=rn(e.positionals,e.flags);return t.ok?t.parsed.action:void 0}const es=[{name:`human_control`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`humanControl`},recordsSessionAction:!1,daemon:{route:`humanControl`,refFrameEffect:`preserve`,selectorValidationExempt:!0,skipSessionlessProviderDevice:Eo},timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`lease_allocate`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseAllocate`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...G},timeoutPolicy:Go,batchable:!1,platformExecution:q},{name:`lease_heartbeat`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseHeartbeat`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...G},timeoutPolicy:Wo,batchable:!1,platformExecution:q},{name:`lease_release`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseRelease`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...G},timeoutPolicy:Wo,batchable:!1,platformExecution:q},{name:`artifacts`,deviceClaimPolicy:`none`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...G},timeoutPolicy:M,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:M,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:M,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:M,batchable:!0,platformExecution:{kind:`inventory`,use:oo}},{name:`capabilities`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,...K},timeoutPolicy:M,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:Eo,...K},timeoutPolicy:M,batchable:!0,platformExecution:Vo},{name:`apps`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,sessionlessLeaseAdmissionExemption:Ao},platformExecution:{kind:`device-runtime`,uses:[Fr]},timeoutPolicy:M,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:ca},timeoutPolicy:M,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:ma},timeoutPolicy:M,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:pa},timeoutPolicy:M,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:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:li}},{name:`logs`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,uses:za},timeoutPolicy:M,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:M,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:Xa},timeoutPolicy:M,batchable:!0},{name:`audio`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Wa}},{name:`replay`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:Oo,saveScriptFlagOwner:!0},timeoutPolicy:{...M,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:Oo},timeoutPolicy:{...M,envelopeMs:`unbounded`},batchable:!0,platformExecution:q},{name:`runtime`,deviceClaimPolicy:`require-owner`,catalog:{group:`internal`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:M,batchable:!1,platformExecution:{kind:`device-runtime`,uses:[...Fa,Ei]}},{name:`clipboard`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:Ro,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ha}},{name:`keyboard`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:Fo,daemon:{route:`session`,refFrameEffect:Mo,androidBlockingDialogGuard:!0},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:_a}},{name:`install`,...Yo},{name:`reinstall`,...Yo},{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:ya},timeoutPolicy:Uo,batchable:!1},{name:`release_materialized_paths`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`releaseMaterializedPaths`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,...K},timeoutPolicy:M,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:ba},timeoutPolicy:M,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:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[Yr]}},{name:`open`,deviceClaimPolicy:`acquire-session`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowSessionlessDefaultDevice:Eo,saveScriptFlagOwner:!0},timeoutPolicy:{...M,budget:{source:`flag`,envelope:`margin`}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ea}},{name:`prepare`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:{budget:{source:`flag`,envelope:`margin`},envelopeMs:rr,onTimeout:`reset-daemon`},batchable:!1,mcpExposed:!1,platformExecution:{kind:`device-runtime`,use:Ma}},{name:`batch`,deviceClaimPolicy:`none`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`},timeoutPolicy:M,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:ko},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ka}},{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:ea,selectUses:Xo}},{name:`diff`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ea,selectUses:Xo}},{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:nr}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:$i}},{name:`alert`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:Io,daemon:{route:`snapshot`,refFrameEffect:Po},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ga}},{name:`settings`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`snapshot`,refFrameEffect:`may-invalidate`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[Xr]}},{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:M,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:Do},platformExecution:{kind:`device-runtime`,uses:bo},timeoutPolicy:M,batchable:!0},{name:`trace`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`},timeoutPolicy:M,batchable:!0,platformExecution:q},{name:`find`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:Lo,daemon:{route:`find`,refFrameEffect:`may-invalidate`},timeoutPolicy:Y,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Qi,selectUses:Zo}},{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:qo,batchable:!0,platformExecution:{kind:`device-runtime`,uses:gi}},{name:`fill`,...Ho,frameworkTier:`core`,timeoutPolicy:X(`fill`,Y),postActionObservation:Z(`fill`),responseDataTransform:Jo,batchable:!0,platformExecution:{kind:`device-runtime`,uses:bi}},{name:`longpress`,...Ho,catalog:{group:`public`,key:`longPress`},frameworkTier:`extended`,timeoutPolicy:{...Ko,envelopeMs:21e4},postActionObservation:Z(`longpress`),batchable:!0,platformExecution:{kind:`device-runtime`,uses:vi}},{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:yi}},{name:`press`,...Ho,frameworkTier:`core`,timeoutPolicy:X(`press`,Y),postActionObservation:Z(`press`),responseDataTransform:qo,batchable:!0,platformExecution:{kind:`device-runtime`,uses:_i}},{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:[zr]}},{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:qi}},{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:Ki}},{name:`back`,catalog:{group:`public`},frameworkTier:`core`,...J,timeoutPolicy:X(`back`,M),postActionObservation:Z(`back`),platformExecution:{kind:`device-runtime`,uses:[Br]}},{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:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ai}},{name:`home`,catalog:{group:`public`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Vr]}},{name:`tv-remote`,catalog:{group:`public`,key:`tvRemote`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Ur]}},{name:`orientation`,catalog:{group:`public`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Hr]}},{name:`scroll`,catalog:{group:`public`},frameworkTier:`core`,...J,timeoutPolicy:X(`scroll`,M),postActionObservation:Z(`scroll`),platformExecution:{kind:`device-runtime`,uses:Mi}},{name:`swipe`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ji}},{name:`focus`,catalog:{group:`public`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Rr]}},{name:`screenshot`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`generic`,refFrameEffect:`preserve`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:oa}},{name:`viewport`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},timeoutPolicy:M,batchable:!1,platformExecution:{kind:`device-runtime`,uses:[Lr]}},{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:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[qr]}},{name:`action-button`,catalog:{group:`public`,key:`actionButton`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Jr]}},{name:`install-from-source`,deviceClaimPolicy:`none`,catalog:{group:`public`,key:`installFromSource`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,platformExecution:{kind:`device-runtime`,use:ya},timeoutPolicy:M,batchable:!0},{name:`debug`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`daemon`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:Vo},{name:`device`,deviceClaimPolicy:`observe`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`metro`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`session`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`cdp`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`auth`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`connect`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`connection`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`disconnect`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`mcp`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`proxy`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`takeover`,deviceClaimPolicy:`observe`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:{kind:`inventory`,use:oo}},{name:`react-devtools`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`,key:`reactDevtools`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`web`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:Vo}],ts=new Set([`public`,`local-cli`]),ns=new Set(es.filter(e=>ts.has(us(e))).map(e=>e.name)),Q=es.map(e=>{let t=To(e);return e.name===`record`&&Co(t),{...e,mcpExposed:cs(e),platformExecution:t}});function rs(e){return Q.filter(t=>us(t)===e).map(e=>[ds(e),e.name])}function is(){return Q.filter(e=>ls(e)).map(e=>e.name).sort()}function as(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 os(){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 ss(e){return ns.has(e)}function cs(e){return e.mcpExposed??ns.has(e.name)}function ls(e){return e.mcpExposed&&ss(e.name)}function us(e){return e.catalog.group}function ds(e){return e.catalog.key??e.name}const fs=new Map(Q.map(e=>[e.name,e.timeoutPolicy])),ps=new Map(Q.map(e=>[e.name,e.deviceClaimPolicy])),ms=new Map(Array.from($.values()).flatMap(e=>e.responseDataTransform?[[e.name,e.responseDataTransform]]:[]));function hs(e){if(e!==void 0)return $.get(e)?.postActionObservation}function gs(e){return hs(e)!==void 0}function _s(e){return hs(e)===`settle-and-verify`}function vs(e){return e===void 0?M:fs.get(e)??M}function ys(e){return e===void 0?`require-owner`:ps.get(e)??`require-owner`}function bs(e){if(e!==void 0)return ms.get(e)}function xs(e){return e===void 0?!1:$.get(e)?.recordsSessionAction??!1}function Ss(e){if(e!==void 0)return $.get(e)?.frameworkTier}function Cs(e){return $.get(e)?.targetIdentityVerification}function ws(e){let t=$.get(e.command);if(t?.recordsSessionAction)return typeof t.recordingEffect==`function`?t.recordingEffect(e):t.recordingEffect}function Ts(){return[...new Set(Array.from(ms.values()).flatMap(e=>Object.keys(e.fields)))].sort()}const Es={apps:{appsFilter:`user-installed`}};function Ds(e,t){if(!e||!ss(e))return!1;let n=Es[e];if(!n)return!1;let r=!1;for(let e of Object.keys(n))t[e]===void 0&&(t[e]=n[e],r=!0);return r}function Os(e){let t=[];for(let n of e)n.daemon&&t.push({command:n.name,...n.daemon,replayScopedAction:n.recordsSessionAction});return t}function ks(e){return e.filter(e=>e.batchable).map(e=>e.name)}const As=ks(Q),js=new Set([`batch`,`replay`]),Ms=[`command`,`positionals`,`input`,`flags`,`runtime`],Ns=[`platform`,`target`,`device`,`udid`,`serial`,`verbose`,`out`],Ps=`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.`,Fs=new Set(As);function Is(e){return Fs.has(e)}function Ls(e){return typeof e==`string`?e.trim().toLowerCase():``}function Rs(e){let t=Ls(e);return Is(t)?t:void 0}function zs(t,n,r=Ps){let i=Rs(t);if(i!==void 0)return i;throw new e(`INVALID_ARGS`,`Batch step ${n} command is not available through command batch: ${String(t)}`,{hint:r})}function Bs(t,n){if(js.has(t))throw new e(`INVALID_ARGS`,`Batch step ${n} cannot run ${t}.`)}export{$r as $,pt as $n,N as $t,Za as A,Zt as An,ae as Ar,oi as At,Pa as B,Vt as Bn,o as Br,ma as Bt,bs as C,fn as Cn,le as Cr,Wr as Ct,yo as D,tn as Dn,ue as Dr,ii as Dt,xo as E,qt as En,_e as Er,ri as Et,Ra as F,Gt as Fn,ie as Fr,Ii as Ft,Sa as G,It as Gn,a as Gr,xr as Gt,ja as H,Bt as Hn,u as Hr,Ur as Ht,Ba as I,T as In,re as Ir,na as It,Ta as J,it as Jn,wr as Jt,Ca as K,Ft as Kn,hr as Kt,Na as L,Rt as Ln,te as Lr,ra as Lt,Ha as M,Yt as Mn,se as Mr,da as Mt,Ja as N,O as Nn,p as Nr,Fi as Nt,_o as O,nn as On,fe as Or,ai as Ot,Ga as P,cn as Pn,ne as Pr,sa as Pt,Jr as Q,yt as Qn,yr as Qt,Da as R,Pt as Rn,ee as Rr,xi as Rt,xs as S,pn as Sn,h as Sr,Kr as St,Cs as T,gn as Tn,he as Tr,Hr as Tt,xa as U,zt as Un,c as Ur,zr as Ut,Aa as V,Mt as Vn,d as Vr,R as Vt,wa as W,jt as Wn,s as Wr,Lr as Wt,ya as X,mt as Xn,P as Xt,va as Y,gt as Yn,gr as Yt,ba as Z,_t as Zn,vr as Zt,is as _,Tn as _n,y as _r,Rr as _t,Bs as a,Un as an,qe as ar,qr as at,Ss as b,mn as bn,v as br,pi as bt,Rs as c,zn as cn,Ye as cr,z as ct,Q as d,Wn as dn,Re as dr,ui as dt,ar as en,S as er,ei as et,as as f,An as fn,Ve as fr,ti as ft,rs as g,jn as gn,Ce as gr,ta as gt,Ts as h,kn as hn,Te as hr,hi as ht,As as i,j as in,Qe as ir,fa as it,eo as j,Xt as jn,oe as jr,ci as jt,ro as k,rn as kn,m as kr,si as kt,Os as l,Vn as ln,Je as lr,mi as lt,_s as m,Dn as mn,xe as mr,L as mt,Ms as n,or as nn,$e as nr,Qr as nt,Ls as o,Pn as on,Ke as or,Fr as ot,gs as p,Mn as pn,Be as pr,ni as pt,Ma as q,Lt as qn,_r as qt,Ns as r,Kn as rn,tt as rr,Yr as rt,zs as s,Hn as sn,Xe as sr,Br as st,Ps as t,rr as tn,x as tr,Zr as tt,Ds as u,Bn as un,Ze as ur,fi as ut,os as v,En as vn,_ as vr,Ei as vt,vs as w,dn as wn,ge as wr,di as wt,ws as x,_n as xn,ve as xr,Gr as xt,ys as y,hn as yn,b as yr,Vr as yt,Oa as z,Wt as zn,l as zr,Xr as zt};
@@ -286,6 +286,42 @@ type RawSnapshotNode = {
286
286
  */
287
287
  actions?: string[];
288
288
  };
289
+ /**
290
+ * What a capture's producer can say about the software keyboard on screen, measured while the tree
291
+ * was captured rather than rebuilt from it afterwards.
292
+ *
293
+ * A keyboard is its own system surface, so it never reaches the tree as a covering sibling of app
294
+ * content, and a consumer that wants to refuse a tap behind it has to learn where it is from
295
+ * somewhere (#2589). A producer that can measure the band directly — the Apple runner, from its
296
+ * `app.keyboards` query — publishes one fact per capture and says nothing else about it. A consumer therefore gets three
297
+ * answers and no fourth: a band in the same space as every node rect, a proven absence, or a
298
+ * producer that could not look.
299
+ *
300
+ * A producer that publishes nothing has declared nothing, so absence from a result means the same
301
+ * thing as `unmeasurable` — which is why the field stays optional on every carrier, including the
302
+ * three client-side paths that rebuild a state from a bare backend result (#2199). Those consumers
303
+ * then derive the band from the tree they hold: the rule that stays for the producers that publish
304
+ * no fact (#2660).
305
+ */
306
+ type SnapshotKeyboardBandFact =
307
+ /** The band the keyboard occupies, in the same orientation space as this capture's node rects. */
308
+ {
309
+ kind: 'visible';
310
+ frame: Rect;
311
+ } |
312
+ /** The producer looked for the keyboard and found none. */
313
+ {
314
+ kind: 'absent';
315
+ } |
316
+ /**
317
+ * The producer cannot measure the band on this path, with a stable reason code. Typed rather than
318
+ * inferred from absence so a log says which path failed to measure without the consumer having to
319
+ * guess which producer it was talking to.
320
+ */
321
+ {
322
+ kind: 'unmeasurable';
323
+ reason: string;
324
+ };
289
325
  type SnapshotNode = RawSnapshotNode & {
290
326
  ref: string;
291
327
  /**
@@ -347,6 +383,32 @@ type SnapshotStateProvenance = OptionalProducerProvenance<SnapshotProvenance> |
347
383
  backend?: undefined;
348
384
  producer?: undefined;
349
385
  };
386
+ /**
387
+ * Reasons the Apple runner can stamp when serving a command required re-activating the session app
388
+ * (#2682). Mirrors its `activateTarget(bundleId:reason:)` call sites.
389
+ */
390
+ declare const IOS_TARGET_ACTIVATION_REASONS: readonly ['bundle_changed', 'stale_target', 'missing_after_wait', 'interaction_foreground_guard'];
391
+ type IosTargetActivationReason = (typeof IOS_TARGET_ACTIVATION_REASONS)[number];
392
+ /**
393
+ * States an activation could have been needed for, in `XCApplicationState` raw order.
394
+ * `runningForeground` is excluded because the runner skips `activate()` when the app is already
395
+ * foreground and never stamps a fact there.
396
+ */
397
+ declare const IOS_TARGET_ACTIVATION_PRIOR_STATES: readonly ['unknown', 'notRunning', 'runningBackground', 'runningBackgroundSuspended'];
398
+ type IosTargetActivationPriorState = (typeof IOS_TARGET_ACTIVATION_PRIOR_STATES)[number];
399
+ /**
400
+ * Foreground repair the Apple runner performed while serving one command (#2682). `priorState` is
401
+ * the session app's state BEFORE the runner activated it, so the fact describes what was repaired
402
+ * rather than what the repair produced. `otherActiveApplicationPid` is present only when exactly one
403
+ * application other than the session app held an active accessibility session at that moment: a
404
+ * liveness claim and nothing more, since the private AX client reports no ordering of
405
+ * `activeApplications`, resolves pids only, and answers no bundle id for an arbitrary app.
406
+ */
407
+ type IosTargetActivation = Readonly<{
408
+ reason: IosTargetActivationReason;
409
+ priorState: IosTargetActivationPriorState;
410
+ otherActiveApplicationPid?: number;
411
+ }>;
350
412
  type SnapshotState = {
351
413
  nodes: SnapshotNode[];
352
414
  createdAt: number;
@@ -368,6 +430,19 @@ type SnapshotState = {
368
430
  * must never be compared as the same presentation; consumers that surface the tree disclose it.
369
431
  */
370
432
  iosSystemSurfaceBundleId?: string;
433
+ /**
434
+ * iOS: the keyboard band this capture's producer measured, when it measured one. The tap-path
435
+ * keyboard guard prefers this over the band it would otherwise derive from `nodes`, because a
436
+ * producer that can query the keyboard directly answers in the app's own orientation space and
437
+ * needs no geometry to be plausible (#2660). Absent means the guard measures the tree as before.
438
+ */
439
+ keyboard?: SnapshotKeyboardBandFact;
440
+ /**
441
+ * iOS: this capture's own command found the session app out of foreground and the runner
442
+ * activated it before answering, so an earlier observation in the session described whatever held
443
+ * the foreground instead (#2682). Consumers that surface this tree disclose the repair.
444
+ */
445
+ targetActivation?: IosTargetActivation;
371
446
  } & SnapshotStateProvenance;
372
447
  type SnapshotUnchanged = {
373
448
  ageMs: number;
@@ -533,4 +608,4 @@ type JsonRpcRequestEnvelope<TParams = unknown> = {
533
608
  params?: TParams;
534
609
  };
535
610
  //#endregion
536
- export { SnapshotCommandOptionFields as A, DaemonError as B, Platform as C, RawSnapshotNode as D, Point as E, SnapshotState as F, normalizeError as G, defaultHintForCode as H, SnapshotUnchanged as I, SnapshotVisibility as L, SnapshotOptions as M, SnapshotProvenance as N, Rect as O, SnapshotQualityVerdict as P, centerOfRect as R, DeviceTarget as S, PublicPlatform as T, isAgentDeviceError as U, NormalizedError as V, normalizeAgentDeviceError as W, SessionIsolationMode as _, DaemonRequest as a, DeviceInfo as b, DaemonServerMode as c, JsonRpcRequestEnvelope as d, LeaseBackend as f, ResponseLevel as g, ResponseCost as h, DaemonLockPolicy as i, SnapshotNode as j, ScreenshotOverlayRef as k, DaemonTransportPreference as l, NetworkIncludeMode as m, DaemonArtifactType as n, DaemonResponse as o, LocalInstallSource as p, DaemonInstallSource as r, DaemonResponseData as s, DaemonArtifact as t, JsonRpcId as u, SessionRuntimeHints as v, PlatformSelector as w, DeviceKind as x, AppleOS as y, AppError as z };
611
+ export { ScreenshotOverlayRef as A, centerOfRect as B, Platform as C, Point as D, IosTargetActivation as E, SnapshotProvenance as F, isAgentDeviceError as G, DaemonError as H, SnapshotQualityVerdict as I, normalizeAgentDeviceError as K, SnapshotState as L, SnapshotKeyboardBandFact as M, SnapshotNode as N, RawSnapshotNode as O, SnapshotOptions as P, SnapshotUnchanged as R, DeviceTarget as S, PublicPlatform as T, NormalizedError as U, AppError as V, defaultHintForCode as W, SessionIsolationMode as _, DaemonRequest as a, DeviceInfo as b, DaemonServerMode as c, JsonRpcRequestEnvelope as d, LeaseBackend as f, ResponseLevel as g, ResponseCost as h, DaemonLockPolicy as i, SnapshotCommandOptionFields as j, Rect as k, DaemonTransportPreference as l, NetworkIncludeMode as m, DaemonArtifactType as n, DaemonResponse as o, LocalInstallSource as p, normalizeError as q, DaemonInstallSource as r, DaemonResponseData as s, DaemonArtifact as t, JsonRpcId as u, SessionRuntimeHints as v, PlatformSelector as w, DeviceKind as x, AppleOS as y, SnapshotVisibility as z };
@@ -1,2 +1,2 @@
1
1
  import{r as e}from"./rolldown-runtime.js";const t=/(token|secret|password|authorization|cookie|api[_-]?key|access[_-]?key|private[_-]?key|user[_-]?code|device[_-]?code|refresh[_-]?credential)/i,n=/\b(?:bearer\s+[a-z0-9._-]+|adc_(?:agent|live|refresh|cli)_[a-z0-9._-]+)\b/gi,r=/\b([a-z0-9_-]*(?:api[_-]?key|token|secret|password|user[_-]?code|device[_-]?code|refresh[_-]?credential)[a-z0-9_-]*)(\s*[=:]\s*)("[^"]*"|'[^']*'|\S+)/gi,i=/https?:\/\/[^\s"'<>]+/gi;function a(e){return s(e,new WeakSet)}function o(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.message==`string`&&t.message.length!==0)return a({message:t.message,...typeof t.code==`string`&&t.code.length>0?{code:t.code}:{}})}function s(e,n,r){if(e==null)return e;if(typeof e==`string`)return c(e,r);if(typeof e!=`object`)return e;if(n.has(e))return`[Circular]`;if(n.add(e),Array.isArray(e))return e.map(e=>s(e,n));let i={};for(let[r,a]of Object.entries(e)){if(t.test(r)){i[r]=`[REDACTED]`;continue}i[r]=s(a,n,r)}return i}function c(e,i){let a=e.trim();if(!a)return l(e);if(i&&t.test(i))return`[REDACTED]`;let o=u(a);return o=o.replace(n,`[REDACTED]`),o=o.replace(r,(e,t,n,r,i,a)=>f({key:t,separator:n,rawValue:r,offset:i,input:a})||d(r)?e:`${t}${n}[REDACTED]`),l(o)}function l(e){return e.length<=400?e:`${e.slice(0,386)}...<truncated>`}function u(e){return e.replace(i,e=>p(e)??e)}function d(e){return/^adc_(?:agent|live|refresh|cli)_\.\.\.$/i.test(e)}function f(e){if(e.key.toLowerCase()!==`token`||!e.separator.includes(`:`))return!1;try{return new URL(e.rawValue).pathname.replace(/\/+$/,``)===`/api-keys`&&/(?:^|\b)(?:service\/)?api\s+$/i.test(e.input.slice(0,e.offset))}catch{return!1}}function p(e){try{let t=new URL(e);return t.search&&=`?REDACTED`,(t.username||t.password)&&(t.username=`REDACTED`,t.password=`REDACTED`),t.toString()}catch{return null}}var m=e({AppError:()=>b,KNOWN_APP_ERROR_CODES:()=>h,asAppError:()=>O,createRequestCanceledError:()=>w,defaultHintForCode:()=>I,errorMessage:()=>D,isAgentDeviceError:()=>k,isRequestCanceledDetails:()=>T,isRequestCanceledError:()=>E,normalizeAgentDeviceError:()=>A,normalizeError:()=>j,readDiagnosticsRecordRef:()=>P,readElementMatchCandidateRefs:()=>v,readErrorCandidateViews:()=>_,retriableForErrorCode:()=>F,throwDaemonError:()=>x,toAppErrorCode:()=>g});const h=[`INVALID_ARGS`,`DEVICE_NOT_FOUND`,`DEVICE_IN_USE`,`TOOL_MISSING`,`APP_NOT_INSTALLED`,`UNSUPPORTED_PLATFORM`,`UNSUPPORTED_OPERATION`,`NOT_IMPLEMENTED`,`COMMAND_FAILED`,`SESSION_NOT_FOUND`,`UNAUTHORIZED`,`AMBIGUOUS_MATCH`,`REPLAY_DIVERGENCE`,`REPAIR_SESSION_EXPIRED`,`REPAIR_COMMIT_FAILED`,`UNKNOWN`];function g(e,t=`COMMAND_FAILED`){return typeof e==`string`&&e.length>0?e:t}function _(e){let t=y(e?.candidates),n=[];if(t.length>0){let r=typeof e?.matches==`number`?e.matches:t.length,i=typeof e?.refsGeneration==`number`?e.refsGeneration:void 0;n.push({kind:`element-match`,candidates:t,matches:r,...i===void 0?{}:{refsGeneration:i}})}let r=ee(e?.devices);return r.length>0&&n.push({kind:`device`,devices:r}),n}function v(e){return y(e?.candidates).flatMap(e=>{let t=/^@(e\d+)(?:~s\d+)?(?:\s|$)/.exec(e);return t?.[1]?[t[1]]:[]})}function y(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function ee(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&typeof e.name==`string`):[]}var b=class extends Error{code;details;cause;constructor(e,t,n,r){super(t),this.code=e,this.details=n,this.cause=r}};function x(e){throw new b(g(e.code),e.message,{...e.details??{},hint:e.hint,diagnosticId:e.diagnosticId,logPath:e.logPath,logPathUnavailable:e.logPathUnavailable,diagnosticsRecord:e.diagnosticsRecord,retriable:e.retriable,supportedOn:e.supportedOn},e.cause)}const S=`request_canceled`,C=`request canceled`;function w(e,t){return new b(`COMMAND_FAILED`,C,{hint:`The request was canceled intentionally (explicit cancel or client disconnect) — no retry is needed unless the cancellation was unintended.`,...e,reason:S},t)}function T(e){return e?.reason===S}function E(e){return!(e instanceof b)||e.code!==`COMMAND_FAILED`?!1:T(e.details)?!0:e.message===C}function D(e){return e instanceof Error?e.message:String(e)}function O(e,t=`UNKNOWN`){return e instanceof b?e:e instanceof Error?new b(t,e.message,void 0,e):new b(t,`Unknown error`,{err:e})}function k(e){return e instanceof b}function A(e,t={}){return j(e,t)}function j(e,t={}){let n=O(e),r=n.details?a(n.details):void 0,i=N(r,`diagnosticId`)??t.diagnosticId,s=N(r,`logPath`)??t.logPath,c=N(r,`logPathUnavailable`),l=P(r?.diagnosticsRecord)??t.diagnosticsRecord,u=N(r,`hint`)??I(n.code),d=ae(r,`retriable`)??F(n.code),f=N(r,`supportedOn`),p=oe(r),m=ne(n.code,n.message,r),h=o(n.cause);return{code:n.code,message:m,...h===void 0?{}:{cause:h},hint:u,diagnosticId:i,logPath:s,...c===void 0?{}:{logPathUnavailable:c},...l===void 0?{}:{diagnosticsRecord:l},...d===void 0?{}:{retriable:d},...f===void 0?{}:{supportedOn:f},details:p}}const te=/^\S+ exited with code -?\d+$/;function ne(e,t,n){if(e!==`COMMAND_FAILED`||n?.processExitError!==!0)return t;let r=M(typeof n?.stderr==`string`?n.stderr:``);return r?te.test(t)?r:t.includes(r)?t:`${t}: ${r}`:t}const re=[/^an error was encountered processing the command/i,/^underlying error\b/i,/^simulator device failed to complete the requested operation/i],ie=/^(?:(?:adb|xcrun|simctl):\s*)?(?:error:\s*)?/i;function M(e){for(let t of e.split(`
2
- `)){let e=t.trim();if(!e||re.some(t=>t.test(e)))continue;let n=e.replace(ie,``).trim();if(n)return n.length>200?`${n.slice(0,200)}...`:n}return null}function N(e,t){let n=e?.[t];return typeof n==`string`?n:void 0}function P(e){if(!e||typeof e!=`object`)return;let{session:t,requestId:n}=e;if(typeof t==`string`&&typeof n==`string`&&t.length!==0&&n.length!==0)return{session:t,requestId:n}}function ae(e,t){let n=e?.[t];return typeof n==`boolean`?n:void 0}function oe(e){if(!e)return;let t={...e};return delete t.hint,delete t.diagnosticId,delete t.logPath,delete t.logPathUnavailable,delete t.diagnosticsRecord,delete t.retriable,delete t.supportedOn,Object.keys(t).length>0?t:void 0}const se={DEVICE_IN_USE:!0};function ce(e){return h.includes(e)}function F(e){return ce(e)?se[e]:void 0}function I(e){switch(e){case`INVALID_ARGS`:return`Check command arguments and run --help for usage examples.`;case`SESSION_NOT_FOUND`:return`Run open first or pass an explicit device selector.`;case`TOOL_MISSING`:return`Install required platform tooling and ensure it is available in PATH.`;case`DEVICE_NOT_FOUND`:return`Verify the target device is booted/connected and selectors match.`;case`APP_NOT_INSTALLED`:return`Run apps to discover the exact installed package or bundle id, or install the app before open.`;case`UNSUPPORTED_OPERATION`:return`This command is not available for the selected platform/device.`;case`UNSUPPORTED_PLATFORM`:return`This platform is not supported for the requested operation; run devices to inspect available targets.`;case`AMBIGUOUS_MATCH`:return`Multiple candidates matched. Narrow the query or pass an exact identifier.`;case`DEVICE_IN_USE`:return`The device is busy with another agent-device request; retry once it frees up.`;case`REPLAY_DIVERGENCE`:return`Read details.divergence (screen/suggestions) for repair context, or rerun with --json for the full report.`;case`REPAIR_SESSION_EXPIRED`:return`The --save-script repair session was reaped before it was finalized; re-run replay <script> --save-script from the start.`;case`REPAIR_COMMIT_FAILED`:return`The repair transaction completed, but committing its healed script failed at teardown (no-clobber refusal or a filesystem error); inspect the target path/permissions, then re-run replay <script> --save-script to retry.`;case`NOT_IMPLEMENTED`:return`This command is part of the planned API but is not implemented yet.`;case`COMMAND_FAILED`:return`Retry with --debug and inspect diagnostics log for details.`;case`UNAUTHORIZED`:return`Refresh daemon metadata and retry the command.`;case`UNKNOWN`:return`Unexpected internal error. Retry with --debug and report the diagnostics log if it persists.`;default:return`Retry with --debug and inspect diagnostics log for details.`}}const L={interactiveOnly:`snapshotInteractiveOnly`,depth:`snapshotDepth`,scope:`snapshotScope`,raw:`snapshotRaw`,customActions:`snapshotCustomActions`,forceFull:`snapshotForceFull`,includeHiddenContentHints:`snapshotIncludeHiddenContentHints`,preferredBackend:`snapshotPreferredBackend`},le=[`interactiveOnly`,`depth`,`scope`,`raw`,`customActions`,`forceFull`],R=[`interactiveOnly`,`preferredBackend`,`depth`,`scope`,`raw`,`customActions`,`includeHiddenContentHints`],z=[`depth`,`interactiveOnly`,`raw`,`scope`,`customActions`];function B(e,t){return Object.fromEntries(t.map(t=>[t,e?.[L[t]]]))}function V(e,t){return Object.fromEntries(t.flatMap(t=>{let n=e?.[t];return n===void 0?[]:[[L[t],n]]}))}function H(e){if(e===void 0||e.backend===void 0)return{};switch(e.backend){case`xctest`:return{backend:e.backend,producer:e.producer};case`android`:return{backend:e.backend,producer:e.producer};case`harmonyos-arkui`:return{backend:e.backend,producer:e.producer};case`macos-helper`:return{backend:e.backend,producer:e.producer};case`linux-atspi`:return{backend:e.backend,producer:e.producer};case`web`:return{backend:e.backend,producer:e.producer}}}function U(e){return e===`xctest`||e===`android`||e===`harmonyos-arkui`||e===`macos-helper`||e===`linux-atspi`||e===`web`}function W(e){return e===void 0||e===`xctest`||e===`android`||e===`harmonyos-arkui`}function ue(e){return e.map((e,t)=>({...e,ref:e.ref??`e${t+1}`}))}const de=/^~s(\d+)$/,fe=`Refs look like @e12, optionally pinned to the snapshot generation that minted them: @e12~s3 (the ref, then "~s" and the refsGeneration reported by the issuing snapshot/find response).`;function G(e){let t=e.trim(),n=t.indexOf(`~`);if(n===-1)return{base:t};let r=de.exec(t.slice(n));return!r||n===0?null:{base:t.slice(0,n),generation:Number(r[1])}}function pe(e){let t=G(e);if(!t)return null;let n=t.base;return n.startsWith(`@`)?n.slice(1)||null:n.startsWith(`e`)?n:null}function me(e,t){return e.find(e=>e.ref===t)??null}function he(e){return JSON.stringify({interactiveOnly:e?.interactiveOnly===!0,depth:typeof e?.depth==`number`?e.depth:null,scope:e?.scope?.trim()||null,raw:e?.raw===!0,customActions:e?.customActions===!0})}function ge(e){if(e)return B(e,z)}function _e(e){return{x:Math.round(e.x+e.width/2),y:Math.round(e.y+e.height/2)}}const K=[`ios`,`android`,`harmonyos`];function ve(e){return K.some(t=>t===e)}const ye=[`summary`,`headers`,`body`,`all`],be=[`digest`,`default`,`full`];function xe(e){return e!==void 0&&e!=="default"}function q(e){return{parse(t){return e(t,`$`)}}}function J(e,t){throw Error(`${e}: ${t}`)}function Y(e,t){return(!e||typeof e!=`object`||Array.isArray(e))&&J(t,`Expected an object`),e}function X(e,t){return typeof e!=`string`&&J(t,`Expected a string`),e}function Se(e,t){return Number.isInteger(e)||J(t,`Expected an integer`),e}function Ce(e,t){return Array.isArray(e)||J(t,`Expected an array`),e}function Z(e,t,n){let r=e[t];return r===void 0?void 0:X(r,`${n}.${t}`)}function we(e,t,n){let r=e[t];if(r!==void 0)return Ce(r,`${n}.${t}`).map((e,r)=>X(e,`${n}.${t}[${String(r)}]`))}function Q(e,t,n){let r=e[t];return r===void 0?void 0:Se(r,`${n}.${t}`)}function $(e,t,n){let r=e[t];return r===void 0?void 0:Y(r,`${n}.${t}`)}function Te(e,t,n,r){let i=e[t];if(i!==void 0)return(typeof i!=`string`||!n.includes(i))&&J(`${r}.${t}`,`Expected one of: ${n.join(`, `)}`),i}const Ee=q((e,t)=>{let n=Y(e,t);return{platform:Te(n,`platform`,K,t),metroHost:Z(n,`metroHost`,t),metroPort:Q(n,`metroPort`,t),bundleUrl:Z(n,`bundleUrl`,t),launchUrl:Z(n,`launchUrl`,t)}});function De(e,t){let n=e.id;return n==null||typeof n!=`string`&&typeof n!=`number`&&J(`${t}.id`,`Expected a string, number, or null`),n}const Oe=q((e,t)=>{let n=Y(e,t);return{jsonrpc:Z(n,`jsonrpc`,t),id:De(n,t),method:Z(n,`method`,t),params:n.params}}),ke=q((e,t)=>{let n=Y(e,t);return{token:Z(n,`token`,t),session:Z(n,`session`,t),command:Z(n,`command`,t),positionals:we(n,`positionals`,t),input:$(n,`input`,t),flags:$(n,`flags`,t),runtime:$(n,`runtime`,t),meta:$(n,`meta`,t)}});export{T as A,a as B,b as C,D,I as E,v as F,_ as I,F as L,A as M,j as N,m as O,P,x as R,W as S,w as T,o as V,V as _,xe as a,H as b,fe as c,ue as d,he as f,pe as g,U as h,Ee as i,E as j,k,R as l,me as m,be as n,ve as o,_e as p,ke as r,Oe as s,ye as t,le as u,B as v,O as w,G as x,ge as y,g as z};
2
+ `)){let e=t.trim();if(!e||re.some(t=>t.test(e)))continue;let n=e.replace(ie,``).trim();if(n)return n.length>200?`${n.slice(0,200)}...`:n}return null}function N(e,t){let n=e?.[t];return typeof n==`string`?n:void 0}function P(e){if(!e||typeof e!=`object`)return;let{session:t,requestId:n}=e;if(typeof t==`string`&&typeof n==`string`&&t.length!==0&&n.length!==0)return{session:t,requestId:n}}function ae(e,t){let n=e?.[t];return typeof n==`boolean`?n:void 0}function oe(e){if(!e)return;let t={...e};return delete t.hint,delete t.diagnosticId,delete t.logPath,delete t.logPathUnavailable,delete t.diagnosticsRecord,delete t.retriable,delete t.supportedOn,Object.keys(t).length>0?t:void 0}const se={DEVICE_IN_USE:!0};function ce(e){return h.includes(e)}function F(e){return ce(e)?se[e]:void 0}function I(e){switch(e){case`INVALID_ARGS`:return`Check command arguments and run --help for usage examples.`;case`SESSION_NOT_FOUND`:return`Run open first or pass an explicit device selector.`;case`TOOL_MISSING`:return`Install required platform tooling and ensure it is available in PATH.`;case`DEVICE_NOT_FOUND`:return`Verify the target device is booted/connected and selectors match.`;case`APP_NOT_INSTALLED`:return`Run apps to discover the exact installed package or bundle id, or install the app before open.`;case`UNSUPPORTED_OPERATION`:return`This command is not available for the selected platform/device.`;case`UNSUPPORTED_PLATFORM`:return`This platform is not supported for the requested operation; run devices to inspect available targets.`;case`AMBIGUOUS_MATCH`:return`Multiple candidates matched. Narrow the query or pass an exact identifier.`;case`DEVICE_IN_USE`:return`The device is busy with another agent-device request; retry once it frees up.`;case`REPLAY_DIVERGENCE`:return`Read details.divergence (screen/suggestions) for repair context, or rerun with --json for the full report.`;case`REPAIR_SESSION_EXPIRED`:return`The --save-script repair session was reaped before it was finalized; re-run replay <script> --save-script from the start.`;case`REPAIR_COMMIT_FAILED`:return`The repair transaction completed, but committing its healed script failed at teardown (no-clobber refusal or a filesystem error); inspect the target path/permissions, then re-run replay <script> --save-script to retry.`;case`NOT_IMPLEMENTED`:return`This command is part of the planned API but is not implemented yet.`;case`COMMAND_FAILED`:return`Retry with --debug and inspect diagnostics log for details.`;case`UNAUTHORIZED`:return`Refresh daemon metadata and retry the command.`;case`UNKNOWN`:return`Unexpected internal error. Retry with --debug and report the diagnostics log if it persists.`;default:return`Retry with --debug and inspect diagnostics log for details.`}}const L={interactiveOnly:`snapshotInteractiveOnly`,depth:`snapshotDepth`,scope:`snapshotScope`,raw:`snapshotRaw`,customActions:`snapshotCustomActions`,forceFull:`snapshotForceFull`,includeHiddenContentHints:`snapshotIncludeHiddenContentHints`,preferredBackend:`snapshotPreferredBackend`},le=[`interactiveOnly`,`depth`,`scope`,`raw`,`customActions`,`forceFull`],ue=[`interactiveOnly`,`preferredBackend`,`depth`,`scope`,`raw`,`customActions`,`includeHiddenContentHints`],de=[`depth`,`interactiveOnly`,`raw`,`scope`,`customActions`];function R(e,t){return Object.fromEntries(t.map(t=>[t,e?.[L[t]]]))}function z(e,t){return Object.fromEntries(t.flatMap(t=>{let n=e?.[t];return n===void 0?[]:[[L[t],n]]}))}function B(e){if(e===void 0||e.backend===void 0)return{};switch(e.backend){case`xctest`:return{backend:e.backend,producer:e.producer};case`android`:return{backend:e.backend,producer:e.producer};case`harmonyos-arkui`:return{backend:e.backend,producer:e.producer};case`macos-helper`:return{backend:e.backend,producer:e.producer};case`linux-atspi`:return{backend:e.backend,producer:e.producer};case`web`:return{backend:e.backend,producer:e.producer}}}function V(e){return e===`xctest`||e===`android`||e===`harmonyos-arkui`||e===`macos-helper`||e===`linux-atspi`||e===`web`}function H(e){return e===void 0||e===`xctest`||e===`android`||e===`harmonyos-arkui`}const fe=[`bundle_changed`,`stale_target`,`missing_after_wait`,`interaction_foreground_guard`];function pe(e){return typeof e==`string`&&fe.includes(e)}function me(e){return e.map((e,t)=>({...e,ref:e.ref??`e${t+1}`}))}const he=/^~s(\d+)$/,ge=`Refs look like @e12, optionally pinned to the snapshot generation that minted them: @e12~s3 (the ref, then "~s" and the refsGeneration reported by the issuing snapshot/find response).`;function U(e){let t=e.trim(),n=t.indexOf(`~`);if(n===-1)return{base:t};let r=he.exec(t.slice(n));return!r||n===0?null:{base:t.slice(0,n),generation:Number(r[1])}}function _e(e){let t=U(e);if(!t)return null;let n=t.base;return n.startsWith(`@`)?n.slice(1)||null:n.startsWith(`e`)?n:null}function ve(e,t){return e.find(e=>e.ref===t)??null}function ye(e){return JSON.stringify({interactiveOnly:e?.interactiveOnly===!0,depth:typeof e?.depth==`number`?e.depth:null,scope:e?.scope?.trim()||null,raw:e?.raw===!0,customActions:e?.customActions===!0})}function be(e){if(e)return R(e,de)}function xe(e){return{x:Math.round(e.x+e.width/2),y:Math.round(e.y+e.height/2)}}const W=[`ios`,`android`,`harmonyos`];function Se(e){return W.some(t=>t===e)}const Ce=[`summary`,`headers`,`body`,`all`],we=[`digest`,`default`,`full`];function Te(e){return e!==void 0&&e!=="default"}function G(e,t,n,r){return{ok:!1,error:{code:e,message:t,...r?.hint?{hint:r.hint}:{},...r?.retriable===void 0?{}:{retriable:r.retriable},...n?{details:n}:{}}}}const K=`No active session. Run open first.`;function Ee(){return G(`SESSION_NOT_FOUND`,K)}function q(e){return{parse(t){return e(t,`$`)}}}function J(e,t){throw Error(`${e}: ${t}`)}function Y(e,t){return(!e||typeof e!=`object`||Array.isArray(e))&&J(t,`Expected an object`),e}function X(e,t){return typeof e!=`string`&&J(t,`Expected a string`),e}function De(e,t){return Number.isInteger(e)||J(t,`Expected an integer`),e}function Oe(e,t){return Array.isArray(e)||J(t,`Expected an array`),e}function Z(e,t,n){let r=e[t];return r===void 0?void 0:X(r,`${n}.${t}`)}function ke(e,t,n){let r=e[t];if(r!==void 0)return Oe(r,`${n}.${t}`).map((e,r)=>X(e,`${n}.${t}[${String(r)}]`))}function Ae(e,t,n){let r=e[t];return r===void 0?void 0:De(r,`${n}.${t}`)}function Q(e,t,n){let r=e[t];return r===void 0?void 0:Y(r,`${n}.${t}`)}function $(e,t,n,r){let i=e[t];if(i!==void 0)return(typeof i!=`string`||!n.includes(i))&&J(`${r}.${t}`,`Expected one of: ${n.join(`, `)}`),i}const je=q((e,t)=>{let n=Y(e,t);return{platform:$(n,`platform`,W,t),metroHost:Z(n,`metroHost`,t),metroPort:Ae(n,`metroPort`,t),bundleUrl:Z(n,`bundleUrl`,t),launchUrl:Z(n,`launchUrl`,t)}});function Me(e,t){let n=e.id;return n==null||typeof n!=`string`&&typeof n!=`number`&&J(`${t}.id`,`Expected a string, number, or null`),n}const Ne=q((e,t)=>{let n=Y(e,t);return{jsonrpc:Z(n,`jsonrpc`,t),id:Me(n,t),method:Z(n,`method`,t),params:n.params}}),Pe=q((e,t)=>{let n=Y(e,t);return{token:Z(n,`token`,t),session:Z(n,`session`,t),command:Z(n,`command`,t),positionals:ke(n,`positionals`,t),input:Q(n,`input`,t),flags:Q(n,`flags`,t),runtime:Q(n,`runtime`,t),meta:Q(n,`meta`,t)}});export{I as A,_ as B,be as C,b as D,H as E,E as F,o as G,x as H,A as I,j as L,m as M,k as N,O,T as P,P as R,R as S,U as T,g as U,F as V,a as W,ve as _,je as a,_e as b,Se as c,ge as d,ue as f,xe as g,ye as h,Pe as i,D as j,w as k,Ne as l,me as m,K as n,G as o,le as p,we as r,Te as s,Ce as t,Ee as u,pe as v,B as w,z as x,V as y,v as z};
@@ -1 +1 @@
1
- import{C as e}from"./sdk-contracts.js";function t(e){return Object.freeze({family:e.platform,...e.appleOs===void 0?{}:{appleOs:e.appleOs},kind:e.kind,...e.target===void 0?{}:{target:e.target},...e.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.iosPhysicalDeviceBackend}})}function n(e){return Object.freeze({id:e.id,...t(e)})}function r(e){return JSON.stringify([e.id,...o(e)])}function i(e,t){return r(e)===r(t)}function a(e,t){return JSON.stringify(o(e))===JSON.stringify(o(t))}function o(e){return[e.family,e.appleOs??null,e.kind,e.target??null,e.iosPhysicalDeviceBackend??null]}const s=[`ios`,`ipados`,`tvos`,`watchos`,`visionos`,`macos`],c=[`apple`,`android`,`harmonyos`,`vega`,`linux`,`web`],l=[`ios`,`macos`,`android`,`harmonyos`,`vega`,`linux`,`web`],u=[...c,`ios`,`macos`],d=[`mobile`,`tv`,`desktop`];function f(e){return[e.deviceName,e.udid,e.serial].some(e=>typeof e==`string`&&e.trim().length>0)}function p(e){return e===`apple`||e===`ios`||e===`macos`}function m(e){return e.appleOs===`macos`||e.platform===`macos`}function h(e){return p(e.platform)&&!m(e)}function g(e){return e.platform===`android`||e.platform===`harmonyos`||p(e.platform)&&!m(e)}function _(e){return p(e.platform)?m(e)?`macos`:`ios`:e.platform}function v(e){return e===`macos`?{platform:`apple`,appleOs:`macos`}:e===`ios`?{platform:`apple`}:{platform:e}}function y(e){return p(e.platform)&&e.target===`tv`}function b(e){return e.appleOs?e.appleOs:e.platform===`macos`?`macos`:y(e)?`tvos`:`ios`}function x(e){return c.includes(e)}function S(e){return l.includes(e)}function C(e){return s.includes(e)}function w(e,t){return t?t===`apple`?p(e.platform):t===`ios`?p(e.platform)&&!m(e):t===`macos`?p(e.platform)&&m(e):e.platform===t:!0}function T(e,t){return t?E(t):e===`macos`||e===`desktop`?`macOS`:e===`tv`?`tvOS`:`iOS`}function E(e){switch(e){case`tvos`:return`tvOS`;case`macos`:return`macOS`;case`visionos`:return`visionOS`;default:return`iOS`}}function D(e){let{simulatorSetPath:t,platform:n,target:r}=e;if(t&&n!==`macos`&&r!==`desktop`)return t}function O(e){return e.map((e,t)=>({device:e,index:t})).sort((e,t)=>Y(e,t)).map(({device:e})=>e)}function k(e){return!e||e===`apple`||e===`ios`}async function A(e,t,n={}){let r=e.filter(e=>U(e,t));return j(r,t)||F(r,t.deviceName)||(Q(r)&&(r=O(r)),ee(r,t,n))}function j(e,t){if(M(t),t.udid)return N(e,t.udid);if(t.serial)return P(e,t)}function M(t){let n=t.platform;if(n){if(t.udid&&G(n))throw new e(`INVALID_ARGS`,`--udid selects Apple devices, but this request selected --platform ${n}.`,{hint:`Use --serial ${t.udid} for ${n} devices.`});if(t.serial&&p(n))throw new e(`INVALID_ARGS`,`--serial selects Android and HarmonyOS devices, but this request selected --platform ${n}.`,{hint:`Use --udid ${t.serial} for Apple devices.`})}}function N(t,n){let r=t.find(e=>e.id===n&&p(e.platform));if(!r)throw new e(`DEVICE_NOT_FOUND`,`No Apple device with UDID ${n}`);return r}function P(t,n){let r=t.find(e=>e.id===n.serial&&G(e.platform));if(!r)throw new e(`DEVICE_NOT_FOUND`,K(n));return r}function F(t,n){if(!n)return;let r=J(n),i=t.find(e=>J(e.name)===r);if(!i){let r=I(t,n);throw new e(`DEVICE_NOT_FOUND`,`No device named ${n}`,r===void 0?void 0:{hint:r})}return i}function I(e,t){let n=e.find(e=>e.id===t);if(!n)return;let r=L(n.platform);if(r)return`${t} is the id of ${JSON.stringify(n.name)}, not its name. Did you mean ${r} ${t}?`}function L(e){if(p(e))return`--udid`;if(G(e))return`--serial`}function ee(e,t,n){let r=e[0];if(r!==void 0&&e.length===1)return r;e.length===0&&q(t,n);let i=B(e);i.length>1&&R(i);let a=i[0];return a||q(t,n),a}function R(t){let n=t.slice(0,10);throw new e(`AMBIGUOUS_MATCH`,`${t.length} devices match this request equally; select one explicitly.`,{devices:n.map(e=>({id:e.id,name:e.name})),matches:t.length,hint:z(n)})}function z(e){let t=e[0];return`Select the intended device explicitly, for example ${t&&G(t.platform)?`--serial ${t.id}`:`--udid ${t?.id??`<id>`}`} or --device ${JSON.stringify(t?.name??`<name>`)}. Run agent-device devices to list them.`}function B(e){let t=Q(e)?H(e):V(e),n=t.filter(e=>e.booted);return n.length>0?n:t}function V(e){let t=e.filter(e=>e.kind!==`device`);return t.length>0?t:e}function H(e){let t=Math.min(...e.map(e=>X(e)));return e.filter(e=>X(e)===t)}function U(e,t,n={}){return w(e,t.platform)&&(!t.target||(e.target??`mobile`)===t.target)&&(!n.includeExplicitSelectors||W(e,t))}function W(e,t){return!(t.udid&&!(e.id===t.udid&&p(e.platform))||t.serial&&!(e.id===t.serial&&G(e.platform))||t.deviceName&&J(e.name)!==J(t.deviceName))}function G(e){return e===`android`||e===`harmonyos`||e===`vega`}function K(e){return e.platform===`android`?`No Android device with serial ${e.serial}`:e.platform===`vega`?`No Vega VVD with serial ${e.serial}`:e.platform===`harmonyos`?`No HarmonyOS device with serial ${e.serial}`:`No Android, HarmonyOS device, or Vega VVD with serial ${e.serial}`}function q(t,n){let r=n.simulatorSetPath;throw r&&k(t.platform)?new e(`DEVICE_NOT_FOUND`,`No devices found in the scoped simulator set`,{simulatorSetPath:r,hint:`The simulator set at "${r}" appears to be empty. Create a compatible simulator first with xcrun simctl --set "${r}" create, or remove the scoped simulator set.`,selector:t}):new e(`DEVICE_NOT_FOUND`,`No devices found`,{selector:t})}function J(e){return e.toLowerCase().replaceAll(`_`,` `).replaceAll(/\s+/g,` `).trim()}function Y(e,t){return X(e.device)-X(t.device)||Number(t.device.booted===!0)-Number(e.device.booted===!0)||e.device.name.localeCompare(t.device.name)||e.index-t.index}function X(e){return e.kind===`simulator`?Z(e,0,1,2,3):e.kind===`device`&&p(e.platform)&&!m(e)?Z(e,10,11,12,13):14}function Z(e,t,n,r,i){return{mobile:$(e.name)?n:t,tv:r,desktop:i}[e.target??`mobile`]}function Q(e){return e.length>0&&e.every(e=>p(e.platform))}function $(e){return/\bipad\b/i.test(e)}export{O as C,i as D,t as E,a as O,b as S,r as T,w as _,v as a,D as b,p as c,g as d,x as f,U as g,y as h,l as i,h as l,G as m,c as n,f as o,S as p,u as r,C as s,d as t,m as u,_ as v,n as w,A as x,T as y};
1
+ import{D as e}from"./sdk-contracts.js";function t(e){return Object.freeze({family:e.platform,...e.appleOs===void 0?{}:{appleOs:e.appleOs},kind:e.kind,...e.target===void 0?{}:{target:e.target},...e.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.iosPhysicalDeviceBackend}})}function n(e){return Object.freeze({id:e.id,...t(e)})}function r(e){return JSON.stringify([e.id,...o(e)])}function i(e,t){return r(e)===r(t)}function a(e,t){return JSON.stringify(o(e))===JSON.stringify(o(t))}function o(e){return[e.family,e.appleOs??null,e.kind,e.target??null,e.iosPhysicalDeviceBackend??null]}const s=[`ios`,`ipados`,`tvos`,`watchos`,`visionos`,`macos`],c=[`apple`,`android`,`harmonyos`,`vega`,`linux`,`web`],l=[`ios`,`macos`,`android`,`harmonyos`,`vega`,`linux`,`web`],u=[...c,`ios`,`macos`],d=[`mobile`,`tv`,`desktop`];function f(e){return[e.deviceName,e.udid,e.serial].some(e=>typeof e==`string`&&e.trim().length>0)}function p(e){return e===`apple`||e===`ios`||e===`macos`}function m(e){return e.appleOs===`macos`||e.platform===`macos`}function h(e){return p(e.platform)&&!m(e)}function g(e){return e.platform===`android`||e.platform===`harmonyos`||p(e.platform)&&!m(e)}function _(e){return p(e.platform)?m(e)?`macos`:`ios`:e.platform}function v(e){return e===`macos`?{platform:`apple`,appleOs:`macos`}:e===`ios`?{platform:`apple`}:{platform:e}}function y(e){return p(e.platform)&&e.target===`tv`}function b(e){return e.appleOs?e.appleOs:e.platform===`macos`?`macos`:y(e)?`tvos`:`ios`}function x(e){let t=b(e);return t===`ios`||t===`ipados`}function S(e){return c.includes(e)}function C(e){return l.includes(e)}function w(e){return s.includes(e)}function T(e,t){return t?t===`apple`?p(e.platform):t===`ios`?p(e.platform)&&!m(e):t===`macos`?p(e.platform)&&m(e):e.platform===t:!0}function E(e,t){return t?D(t):e===`macos`||e===`desktop`?`macOS`:e===`tv`?`tvOS`:`iOS`}function D(e){switch(e){case`tvos`:return`tvOS`;case`macos`:return`macOS`;case`visionos`:return`visionOS`;default:return`iOS`}}function O(e){let{simulatorSetPath:t,platform:n,target:r}=e;if(t&&n!==`macos`&&r!==`desktop`)return t}function k(e){return e.map((e,t)=>({device:e,index:t})).sort((e,t)=>X(e,t)).map(({device:e})=>e)}function A(e){return!e||e===`apple`||e===`ios`}async function j(e,t,n={}){let r=e.filter(e=>W(e,t));return M(r,t)||I(r,t.deviceName)||($(r)&&(r=k(r)),ee(r,t,n))}function M(e,t){if(N(t),t.udid)return P(e,t.udid);if(t.serial)return F(e,t)}function N(t){let n=t.platform;if(n){if(t.udid&&K(n))throw new e(`INVALID_ARGS`,`--udid selects Apple devices, but this request selected --platform ${n}.`,{hint:`Use --serial ${t.udid} for ${n} devices.`});if(t.serial&&p(n))throw new e(`INVALID_ARGS`,`--serial selects Android and HarmonyOS devices, but this request selected --platform ${n}.`,{hint:`Use --udid ${t.serial} for Apple devices.`})}}function P(t,n){let r=t.find(e=>e.id===n&&p(e.platform));if(!r)throw new e(`DEVICE_NOT_FOUND`,`No Apple device with UDID ${n}`);return r}function F(t,n){let r=t.find(e=>e.id===n.serial&&K(e.platform));if(!r)throw new e(`DEVICE_NOT_FOUND`,q(n));return r}function I(t,n){if(!n)return;let r=Y(n),i=t.find(e=>Y(e.name)===r);if(!i){let r=L(t,n);throw new e(`DEVICE_NOT_FOUND`,`No device named ${n}`,r===void 0?void 0:{hint:r})}return i}function L(e,t){let n=e.find(e=>e.id===t);if(!n)return;let r=R(n.platform);if(r)return`${t} is the id of ${JSON.stringify(n.name)}, not its name. Did you mean ${r} ${t}?`}function R(e){if(p(e))return`--udid`;if(K(e))return`--serial`}function ee(e,t,n){let r=e[0];if(r!==void 0&&e.length===1)return r;e.length===0&&J(t,n);let i=V(e);i.length>1&&z(i);let a=i[0];return a||J(t,n),a}function z(t){let n=t.slice(0,10);throw new e(`AMBIGUOUS_MATCH`,`${t.length} devices match this request equally; select one explicitly.`,{devices:n.map(e=>({id:e.id,name:e.name})),matches:t.length,hint:B(n)})}function B(e){let t=e[0];return`Select the intended device explicitly, for example ${t&&K(t.platform)?`--serial ${t.id}`:`--udid ${t?.id??`<id>`}`} or --device ${JSON.stringify(t?.name??`<name>`)}. Run agent-device devices to list them.`}function V(e){let t=$(e)?U(e):H(e),n=t.filter(e=>e.booted);return n.length>0?n:t}function H(e){let t=e.filter(e=>e.kind!==`device`);return t.length>0?t:e}function U(e){let t=Math.min(...e.map(e=>Z(e)));return e.filter(e=>Z(e)===t)}function W(e,t,n={}){return T(e,t.platform)&&(!t.target||(e.target??`mobile`)===t.target)&&(!n.includeExplicitSelectors||G(e,t))}function G(e,t){return!(t.udid&&!(e.id===t.udid&&p(e.platform))||t.serial&&!(e.id===t.serial&&K(e.platform))||t.deviceName&&Y(e.name)!==Y(t.deviceName))}function K(e){return e===`android`||e===`harmonyos`||e===`vega`}function q(e){return e.platform===`android`?`No Android device with serial ${e.serial}`:e.platform===`vega`?`No Vega VVD with serial ${e.serial}`:e.platform===`harmonyos`?`No HarmonyOS device with serial ${e.serial}`:`No Android, HarmonyOS device, or Vega VVD with serial ${e.serial}`}function J(t,n){let r=n.simulatorSetPath;throw r&&A(t.platform)?new e(`DEVICE_NOT_FOUND`,`No devices found in the scoped simulator set`,{simulatorSetPath:r,hint:`The simulator set at "${r}" appears to be empty. Create a compatible simulator first with xcrun simctl --set "${r}" create, or remove the scoped simulator set.`,selector:t}):new e(`DEVICE_NOT_FOUND`,`No devices found`,{selector:t})}function Y(e){return e.toLowerCase().replaceAll(`_`,` `).replaceAll(/\s+/g,` `).trim()}function X(e,t){return Z(e.device)-Z(t.device)||Number(t.device.booted===!0)-Number(e.device.booted===!0)||e.device.name.localeCompare(t.device.name)||e.index-t.index}function Z(e){return e.kind===`simulator`?Q(e,0,1,2,3):e.kind===`device`&&p(e.platform)&&!m(e)?Q(e,10,11,12,13):14}function Q(e,t,n,r,i){return{mobile:te(e.name)?n:t,tv:r,desktop:i}[e.target??`mobile`]}function $(e){return e.length>0&&e.every(e=>p(e.platform))}function te(e){return/\bipad\b/i.test(e)}export{b as C,t as D,r as E,i as O,j as S,n as T,W as _,v as a,E as b,w as c,m as d,g as f,y as g,K as h,l as i,a as k,p as l,C as m,c as n,x as o,S as p,u as r,f as s,d as t,h as u,T as v,k as w,O as x,_ as y};
@@ -1,4 +1,4 @@
1
- import { j as SnapshotNode } from "./sdk-contracts.js";
1
+ import { N as SnapshotNode } from "./sdk-contracts.js";
2
2
  //#region packages/selectors/src/internal/find.d.ts
3
3
  declare const FIND_LOCATORS: readonly ['any', 'text', 'label', 'value', 'role', 'id'];
4
4
  type FindLocator = (typeof FIND_LOCATORS)[number];
@@ -1 +1 @@
1
- import{kn as e}from"./sdk-batch.js";function t(t,n,r,i){return e(t,n,r,typeof i==`boolean`?{requireRect:i}:i)}export{t};
1
+ import{An as e}from"./sdk-batch.js";function t(t,n,r,i){return e(t,n,r,typeof i==`boolean`?{requireRect:i}:i)}export{t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime.js";import{C as t}from"./sdk-contracts.js";import n from"node:path";import{promises as r}from"node:fs";import i from"node:os";var a=e({createLocalArtifactAdapter:()=>o});function o(e={}){let a=e.cwd??process.cwd(),o=e.tempDir??i.tmpdir(),c=e.rootDir?s(e.rootDir,a):void 0;return{resolveInput:async e=>{if(e.kind===`uploadedArtifact`)throw new t(`UNSUPPORTED_OPERATION`,`Uploaded artifact inputs require a custom artifact adapter`);return{path:s(e.path,a,c)}},reserveOutput:async(e,t)=>{let i,l=t.visibility??`client-visible`,u=e?.kind===`path`?s(e.path,a,c):n.join(i=await r.mkdtemp(n.join(o,`agent-device-${t.field}-`)),`${t.field}${t.ext}`);return await r.mkdir(n.dirname(u),{recursive:!0}),{path:u,visibility:l,...i?{cleanup:async()=>{await r.rm(i,{recursive:!0,force:!0})}}:{},publish:async()=>e?.kind===`downloadableArtifact`?{kind:`localPath`,field:t.field,artifactType:t.artifactType,path:u,fileName:e.fileName??n.basename(e.clientPath??u)}:void 0}},createTempFile:async e=>{let t=await r.mkdtemp(n.join(o,`${e.prefix}-`));return{path:n.join(t,`file${e.ext}`),visibility:`internal`,cleanup:async()=>{await r.rm(t,{recursive:!0,force:!0})}}}}}function s(e,r,i){let a=n.isAbsolute(e)?e:n.resolve(r,e);if(i&&!c(a,i))throw new t(`INVALID_ARGS`,`Local path is outside the artifact adapter root`,{path:a,rootDir:i});return a}function c(e,t){let r=n.relative(t,e);return r===``||!r.startsWith(`..`)&&!n.isAbsolute(r)}export{a as n,o as t};
1
+ import{r as e}from"./rolldown-runtime.js";import{D as t}from"./sdk-contracts.js";import n from"node:path";import{promises as r}from"node:fs";import i from"node:os";var a=e({createLocalArtifactAdapter:()=>o});function o(e={}){let a=e.cwd??process.cwd(),o=e.tempDir??i.tmpdir(),c=e.rootDir?s(e.rootDir,a):void 0;return{resolveInput:async e=>{if(e.kind===`uploadedArtifact`)throw new t(`UNSUPPORTED_OPERATION`,`Uploaded artifact inputs require a custom artifact adapter`);return{path:s(e.path,a,c)}},reserveOutput:async(e,t)=>{let i,l=t.visibility??`client-visible`,u=e?.kind===`path`?s(e.path,a,c):n.join(i=await r.mkdtemp(n.join(o,`agent-device-${t.field}-`)),`${t.field}${t.ext}`);return await r.mkdir(n.dirname(u),{recursive:!0}),{path:u,visibility:l,...i?{cleanup:async()=>{await r.rm(i,{recursive:!0,force:!0})}}:{},publish:async()=>e?.kind===`downloadableArtifact`?{kind:`localPath`,field:t.field,artifactType:t.artifactType,path:u,fileName:e.fileName??n.basename(e.clientPath??u)}:void 0}},createTempFile:async e=>{let t=await r.mkdtemp(n.join(o,`${e.prefix}-`));return{path:n.join(t,`file${e.ext}`),visibility:`internal`,cleanup:async()=>{await r.rm(t,{recursive:!0,force:!0})}}}}}function s(e,r,i){let a=n.isAbsolute(e)?e:n.resolve(r,e);if(i&&!c(a,i))throw new t(`INVALID_ARGS`,`Local path is outside the artifact adapter root`,{path:a,rootDir:i});return a}function c(e,t){let r=n.relative(t,e);return r===``||!r.startsWith(`..`)&&!n.isAbsolute(r)}export{a as n,o as t};