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,5 +1,5 @@
1
- import{C as e,w as t}from"./sdk-contracts.js";import{r as n}from"./sdk-batch-runner.js";import{S as r,c as i,h as a,l as o,u as s,w as c}from"./sdk-device.js";import{Gt as l,Xt as u,Zt as d}from"./sdk-batch.js";import{c as f,r as p}from"./diagnostics.js";import{n as m}from"./exec.js";import"./diagnostics2.js";import"./command.js";import{n as h}from"./scoped-provider.js";import{i as ee,n as te,r as ne}from"./ios-snapshot-planning.js";import{t as re}from"./request.js";import{n as ie,r as ae,t as oe}from"./application-lifecycle-runtime.js";import{i as se,t as ce}from"./touch-runtime.js";import{A as le,C as ue,D as de,G as fe,H as pe,I as me,L as he,N as ge,O as _e,P as ve,R as ye,T as be,U as xe,V as Se,a as Ce,b as we,d as Te,g as Ee,i as De,j as Oe,m as ke,s as Ae,t as je,v as Me,w as Ne,x as Pe,z as Fe}from"./alert-runtime.js";import{n as Ie}from"./audio-probe-runtime.js";import{n as Le}from"./perf-runtime.js";import{a as Re,n as ze}from"./durable-resource.js";import{n as Be,t as Ve}from"./async-lifecycle.js";import{a as He,c as Ue,d as We,f as Ge,l as Ke,n as qe,o as Je,s as Ye,t as Xe,u as Ze}from"./src7.js";import{n as Qe,t as $e}from"./screen-recording-completion.js";import{a as et,i as tt,n as nt,r as rt,t as it}from"./stop-sequence.js";import{n as g}from"./screen-recording-runtime.js";import{t as at}from"./ios-system-surface.js";import{i as ot,r as st}from"./gesture-admission.js";import{t as ct}from"./interactor-operation-catalog.js";import{a as lt,i as ut,n as dt,r as ft,t as pt}from"./perf-runtime-operation-builder.js";import{t as mt}from"./app-log-runtime.js";import{i as ht,r as gt}from"./managed-device-scope.js";import{a as _t,n as vt,o as yt}from"./application-lifecycle-interaction.js";import{a as bt}from"./tool-provider.js";import{n as xt}from"./apps-simctl.js";import{a as St}from"./simulator.js";import{t as Ct}from"./multitouch-support.js";import{n as _,t as wt}from"./simulator-state.js";import{n as Tt,r as Et,t as Dt}from"./snapshot-process.js";import Ot from"node:path";import{randomUUID as kt}from"node:crypto";function At(e){let t=ht();return Object.freeze(t?{...h({...e},e=>St(t,e))}:e)}function jt(e){return rt(e)?Object.freeze({available:!0}):s(e)||o(e)&&e.kind===`simulator`?Object.freeze({available:!1,reason:`unsupported-device-backend`,hint:`audio probe capture requires a macOS host.`}):Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`audio is supported for macOS sessions and iOS simulators on macOS hosts; physical iOS devices expose no host audio tap.`})}function Mt(e){let{resolveHost:t,device:n,owner:r}=e;return Object.freeze({...pt({platform:`Apple`,expectedProfileKind:`xctrace`,start:async e=>await t().start(n,r,e),reattach:async e=>await t().reattach(n,e),cleanup:async e=>await t().cleanup(n,e),writeProfileReport:async e=>await t().writeProfileReport(e)}),perfFrames:async({appId:e})=>({metric:e?await ut(t().sampleFrames(n,e)):dt(`Apple`,`bundle ID`),sampling:await t().frameSampling(n)}),perfMemorySample:async({appId:e})=>({metric:e?await ut(t().sampleMemory(n,e)):dt(`Apple`,`bundle ID`),sampling:await t().memorySampling(n)}),perfMemorySnapshot:async({appId:e,kind:r,outPath:i,artifactsDir:a})=>{let o=r??`memgraph`,s={...await t().memorySnapshotSupport(n),androidHprof:!1,heapprofd:!1};if(o!==`memgraph`)return lt(`Apple`,o,s,`Use perf memory snapshot --kind memgraph for supported Apple app sessions.`);if(!e)throw ft();let c=i??Ot.join(a,`memory-memgraph-${Nt()}.memgraph`);return{artifact:await t().captureMemorySnapshot(n,e,c),support:s,sampling:{method:`xcrun memgraph`,description:`Native Apple memory graph captured for offline inspection.`,defaultKind:`memgraph`,artifactOnly:!0}}}})}function Nt(){return new Date().toISOString().replaceAll(/[:.]/g,`-`)}const v=Object.freeze({available:!0}),y=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),b=Lt(`Gestures are supported only for Apple simulators and devices.`),Pt=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:st}),Ft=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:ot}),It=Lt(`scroll is supported only for Apple simulators and devices.`);function Lt(e){return Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:e})}function Rt(e){return{...ge({unsupported:zt(e),plan:Bt(e),directionalFling:Bt(e),multiTouch:Vt(e),targetAuthoredDrag:Ht(e),viewport:Ut(e)}),...le({scroll:Wt(e)})}}function zt(e){return e.appleOs===`watchos`||e.appleOs===`visionos`?y:b}function Bt(e){return e.appleOs===`watchos`||e.appleOs===`visionos`?y:x(e)?v:b}function Vt(e){if(e.appleOs===`watchos`)return y;if(!x(e))return b;let t=r(e);if(t!==`ios`&&t!==`ipados`){let e=Ct[t];return Object.freeze({available:!1,reason:`unsupported-platform-leaf`,...e===void 0?{}:{hint:e}})}return e.kind===`simulator`?v:Pt}function Ht(e){return x(e)?(e.appleOs===void 0?e.target!==`desktop`&&e.target!==`tv`:e.appleOs===`ios`||e.appleOs===`ipados`)?v:Ft:b}function Ut(e){return e.appleOs===`watchos`?y:x(e)?v:b}function Wt(e){return x(e)?v:It}function x(e){return e.kind===`simulator`||e.kind===`device`}const S=`This command requires a CoreDevice-backed physical iOS device. The selected XCTest backend supports open, close, interactions, snapshots, and screenshots.`;function C(e){return s(e)?`macos`:e.kind===`device`?`ios-device`:`ios-simulator`}const Gt=Object.freeze({resourceKind:mt,version:1,encode:e=>({...e}),decode:e=>!qt(e.transport)||!Jt(e.backend)||!Qt(e.outputPath)||!Xt(e.pidPath)||!Yt(e.transport,e.backend)?Kt():{status:`decoded`,descriptor:Object.freeze({transport:e.transport,backend:e.backend,outputPath:e.outputPath,...e.pidPath===void 0?{}:{pidPath:e.pidPath}})}});function Kt(){return{status:`invalid`,message:`Invalid Apple app-log descriptor`}}function qt(e){return e===`apple-log-stream`||e===`coredevice-console`}function Jt(e){return e===`ios-simulator`||e===`ios-device`||e===`macos`}function Yt(e,t){return e===`coredevice-console`?t===`ios-device`:t!==`ios-device`}function Xt(e){return e===void 0||Qt(e)}function Zt(e){if(!e.device.appleOs)throw TypeError(`Apple app-log persistence requires an explicit appleOs identity`);return ze({resourceKind:mt,sessionId:e.sessionId,device:{id:e.device.id,family:`apple`,appleOs:e.device.appleOs,kind:e.device.kind,...e.device.target===void 0?{}:{target:e.device.target},...e.device.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.device.iosPhysicalDeviceBackend}},owner:e.owner,fence:e.fence,lifecycle:`open`,descriptor:Re(Gt,e.descriptor)})}function Qt(e){return typeof e==`string`&&e.trim().length>0}const $t={message:`iOS physical-device app console capture is not supported by the installed devicectl.`,hint:`This devicectl does not expose process launch --console. Markers can still be written to app.log, but app output is not being captured. Use an iOS simulator for agent-device app logs or inspect physical-device logs in Console.app/Xcode until this Xcode toolchain exposes scriptable console capture.`},en={message:`Could not verify iOS physical-device app console capture support.`,hint:`Retry logs clear --restart. If the probe keeps failing, run logs doctor and inspect the request diagnostics for the devicectl help command.`};async function tn(e,t){try{let n=await e.appleTools.run({tool:`devicectl`,args:[`device`,`process`,`launch`,`--help`],allowFailure:!0,timeoutMs:5e3},t),r=n.stderr.trim()||void 0;if(n.exitCode!==0)return{supported:!1,reason:`probe-failed`,stderr:r};let i=`${n.stdout}\n${n.stderr}`;return/\bUSAGE:\s+devicectl device process launch\b/i.test(i)&&/--console\b/.test(i)&&/--terminate-existing\b/.test(i)?{supported:!0,...r?{stderr:r}:{}}:{supported:!1,reason:`unsupported`,...r?{stderr:r}:{}}}catch(e){if(t?.aborted)throw t.reason;return{supported:!1,reason:`probe-failed`,...e instanceof Error?{stderr:e.message}:{}}}}async function nn(e,t,n,r){let i={},a=n?[]:[`No app bundle is tracked in this session. Run open <app> first for app-scoped logs.`];if(s(t))i.logAvailable=!!await e.commands.which(`log`);else if(t.kind===`simulator`)i.simctlAvailable=await et(async()=>tt(await e.appleTools.run({tool:`simctl`,args:[`help`],allowFailure:!0},r)),r);else if(t.iosPhysicalDeviceBackend===`xctest`)i.devicectlAvailable=!1,i.devicectlConsoleCapture=!1,a.push(S);else{i.devicectlAvailable=await et(async()=>tt(await e.appleTools.run({tool:`devicectl`,args:[`--version`],allowFailure:!0},r)),r);let t=await tn(e,r);if(i.devicectlConsoleCapture=t.supported,!t.supported){let e=t.reason===`unsupported`?$t:en;a.push(`${e.message} ${e.hint}`)}}return{backend:C(t),checks:i,notes:a}}function rn(e,t){let n=sn(e),r=[`subsystem == "${n}"`,`subsystem CONTAINS "${n}"`,`processImagePath ENDSWITH[c] "/${n}"`,`senderImagePath ENDSWITH[c] "/${n}"`];if(t){let e=sn(t);r.push(`process == "${e}"`,`processImagePath ENDSWITH[c] "/${e}"`,`senderImagePath ENDSWITH[c] "/${e}"`,`processImagePath CONTAINS[c] "/${e}.app/"`,`senderImagePath CONTAINS[c] "/${e}.app/"`)}return r.join(` OR `)}function an(e){return[...e.simulatorSetPath?[`simctl`,`--set`,e.simulatorSetPath]:[`simctl`],`spawn`,e.deviceId,`log`,`stream`,`--style`,`compact`,`--level`,`info`,`--predicate`,rn(e.appBundleId,e.executableName)]}function on(e,t){return[`devicectl`,`device`,`process`,`launch`,`--device`,e,`--console`,`--terminate-existing`,t]}function sn(e){return e.replaceAll(`\\`,String.raw`\\`).replaceAll(`"`,String.raw`\"`)}async function cn(e,t,n,r,i){ln(t),Je(e,n);let a=C(t),o=await dn(e,t,n.appBundleId,i),s=new Ve,c=!1;try{let l=await e.outputs.openAppend(n.outputPath);s.defer(async()=>{c||await l[Symbol.asyncDispose]()}),i?.throwIfAborted();let u=await un(e,t,o,l,n.pidPath,i);s.defer(async()=>{c||await u[Symbol.asyncDispose]()});let d=pn(e,u,l,a,n.outputPath),f={transport:a===`ios-device`?`coredevice-console`:`apple-log-stream`,backend:a,outputPath:n.outputPath,...n.pidPath===void 0?{}:{pidPath:n.pidPath}},p=Ge(d,Zt({sessionId:n.sessionId,device:t,owner:r,fence:n.fence,descriptor:f}));return c=!0,p}finally{await s[Symbol.asyncDispose]()}}function ln(t){if(t.appleOs===`watchos`)throw new e(`UNSUPPORTED_PLATFORM`,`watchOS app logs are not supported`);if(o(t)&&t.kind===`device`&&t.iosPhysicalDeviceBackend===`xctest`)throw new e(`UNSUPPORTED_OPERATION`,S,{hint:S})}async function un(t,n,r,i,a,s){if(o(n)&&n.kind===`device`){let n=await tn(t,s);if(!n.supported){let t=n.reason===`unsupported`?$t:en;throw new e(n.reason===`unsupported`?`UNSUPPORTED_OPERATION`:`COMMAND_FAILED`,t.message,{backend:`ios-device`,hint:t.hint,stderr:n.stderr})}}return s?.throwIfAborted(),await t.processes.start({command:{kind:`host`,request:r},output:i,...a?{markerPath:a}:{}})}async function dn(e,t,n,r){if(s(t))return{executable:`log`,args:[`stream`,`--style`,`compact`,`--predicate`,rn(n)],allowFailure:!0};if(t.kind===`device`)return{executable:`xcrun`,args:on(t.id,n),allowFailure:!0};let i=await fn(e,t,n,r);return{executable:`xcrun`,args:an({deviceId:t.id,appBundleId:n,executableName:i,simulatorSetPath:t.simulatorSetPath}),allowFailure:!0}}async function fn(e,t,n,r){let i=t.simulatorSetPath?[`--set`,t.simulatorSetPath]:[],a=await e.appleTools.run({tool:`simctl`,args:[...i,`get_app_container`,t.id,n,`app`],allowFailure:!0,timeoutMs:4e3},r),o=a.exitCode===0?a.stdout.trim():``;if(!o)return;let s=await e.commands.run({executable:`plutil`,args:[`-extract`,`CFBundleExecutable`,`raw`,`-o`,`-`,Ot.join(o,`Info.plist`)],allowFailure:!0,timeoutMs:4e3},r);return s.exitCode===0&&s.stdout.trim()||void 0}function pn(e,t,n,r,i){let a=e.clock.now(),o=`active`;t.wait.then(e=>{o=e.exitCode===0?`ended`:`failed`},()=>{o=`failed`});let s;return Ze({inspect:()=>({backend:r,state:o,startedAt:a}),finish:async()=>s??=(async()=>(await mn([async()=>await t.terminate(),async()=>await t.wait.then(()=>void 0),async()=>await t[Symbol.asyncDispose](),async()=>await n[Symbol.asyncDispose]()])).length>0?(o=`failed`,{status:`cleanup-pending`,reason:`transport-failed`,message:`Apple app-log cleanup did not settle every owned resource`}):(o=`ended`,{status:`completed`,result:{backend:r,outputPath:i,completedAt:e.clock.now()}}))()})}async function mn(e){let t=[];for(let n of e)try{await n()}catch(e){t.push(e)}return t}const w=l(`apple`),T=Object.freeze({available:!0});function hn(t){return Object.freeze({owner:w,ownsDevice:e=>e.platform===`apple`,inspectFacts:async e=>_n(e),bind:async n=>{if(n.intent.kind===`exact-owner`&&!u(n.intent.owner,w))throw new e(`UNSUPPORTED_OPERATION`,`Apple app-log owner identity does not match`);return gn(t,n.device,n.scope.signal)},shutdown:async()=>void 0})}function gn(t,n,r){if(n.platform!==`apple`)throw new e(`UNSUPPORTED_PLATFORM`,`Apple app-log owner cannot bind ${n.platform}`);let i=We({codec:Gt,reattach:async(e,r)=>e.backend!==C(n)||!He(t,r.sessionId,e)?{status:`unreattachable`,reason:`descriptor-invalid`,message:`Apple app-log descriptor does not match the bound device or owning session`}:await Ue(t,e.pidPath),cleanup:async(e,r)=>e.backend===C(n)&&He(t,r.sessionId,e)?await Ye(t,e.pidPath):{status:`cleanup-pending`,reason:`ownership-fence-lost`,message:`Apple app-log descriptor does not match the bound device or owning session`}}),a=Object.freeze({appLogInspect:async()=>({backend:C(n)}),appLogDoctor:async({appBundleId:e})=>await nn(t,n,e,r),appLogStart:async e=>await cn(t,n,e,w,r),...i});return Object.freeze({device:n,owner:w,facts:_n(n),operations:a,[Symbol.asyncDispose]:async()=>void 0})}function _n(e){if(e.appleOs===`watchos`)return vn(e);let t=o(e)&&e.kind===`device`&&e.iosPhysicalDeviceBackend===`xctest`?{available:!1,reason:`unsupported-device-backend`,hint:S}:T;return Object.freeze({device:{family:`apple`,appleOs:e.appleOs,kind:e.kind,...e.target===void 0?{}:{target:e.target},...e.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.iosPhysicalDeviceBackend},providerMode:`local`},operations:{appLogInspect:t,appLogDoctor:t,appLogStart:t,appLogReattach:T,appLogCleanup:T}})}function vn(e){let t=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`watchOS app logs are not supported.`});return Object.freeze({device:{family:`apple`,appleOs:`watchos`,kind:e.kind,...e.target===void 0?{}:{target:e.target},providerMode:`local`},operations:{appLogInspect:t,appLogDoctor:t,appLogStart:t,appLogReattach:t,appLogCleanup:t}})}async function yn(e,t,n,r){let i=C(t),a=await e.appLogs.readRecent(n.sessionId,n.maxScanLines),o=qe(a.text,{...n,path:a.path,exists:a.exists,lineNumberOffset:a.skippedLines,backend:i}),s=[];if(xn(t,n,o.dump)){let i=await Sn(e,t,n,a.path,r);i&&(o=bn(s,o,i,n.maxEntries))}return Tn(s,t,n),wn(s,o.dump),o.dump.entries.length===0&&s.push(En(t)),Object.freeze({source:`app-log`,backend:i,dump:o.dump,notes:Object.freeze(s)})}function bn(e,t,n,r){let i=n.scan.dump.entries.length;return i===0&&(n.scan.dump.unnamedRequests??0)===0?(n.lineCount>0&&e.push(`Recovered ${n.lineCount} recent iOS simulator app log lines from simctl log show, but none looked like HTTP traffic. This app may not emit request URLs, status, or timing into Unified Logging for this repro window.`),t):(i>0&&e.push(`Recovered ${i} iOS simulator HTTP entr${i===1?`y`:`ies`} from simctl log show (${n.lineCount} app log lines scanned).`),Xe(n.scan,t,r))}function xn(e,t,n){return o(e)&&e.kind===`simulator`&&!!t.appBundleId&&n.entries.length===0}async function Sn(e,t,n,r,i){let a=[...t.simulatorSetPath?[`--set`,t.simulatorSetPath]:[],`spawn`,t.id,`log`,`show`,`--style`,`compact`,`--info`,`--predicate`,Cn(n.appBundleId)],o=n.appLogSnapshot?.startedAt;a.push(...typeof o==`number`&&Number.isFinite(o)&&o>0?[`--start`,`@${Math.floor(o/1e3)}`]:[`--last`,`5m`]);let s=await e.appleTools.run({tool:`simctl`,args:a,allowFailure:!0,timeoutMs:4e3},i);if(s.exitCode!==0||!s.stdout.trim())return;let c=s.stdout.split(`
2
- `).map(e=>e.trimEnd()).filter(e=>e.trim()&&!e.trim().startsWith(`Timestamp Ty Process[PID:TID]`));if(c.length!==0)return{scan:qe(`${c.join(`
3
- `)}\n`,{...n,path:`${r} (simctl log show recovery)`,exists:!0,backend:`ios-simulator`}),lineCount:c.length}}function Cn(e){let t=e.replaceAll(`\\`,String.raw`\\`).replaceAll(`"`,String.raw`\"`);return[`subsystem == "${t}"`,`subsystem CONTAINS "${t}"`,`processImagePath ENDSWITH[c] "/${t}"`,`senderImagePath ENDSWITH[c] "/${t}"`].join(` OR `)}function wn(e,t){let n=t.entries.filter(e=>e.pathUnavailable).length,r=t.unnamedRequests??0,i=n+r;if(i===0)return;let a=[`${i} request${i===1?``:`s`} reused a keep-alive connection, so CFNetwork logged no request URL.`];n>0&&a.push(`${n} listed against the origin the connection was opened for, without a path.`),r>0&&a.push(`${r} opened before this scan window and are missing from the entries entirely; scan more lines, or run logs clear --restart before the repro.`),a.push(`Absence of an endpoint in this dump does not prove it was not called.`),e.push(a.join(` `))}function Tn(e,t,n){n.appLogSnapshot?n.appLogSnapshot.state!==`active`&&e.length===0&&e.push(o(t)&&t.kind===`simulator`?`Session app log stream is inactive. The iOS simulator recovery path scanned recent simctl log history, but a fresh logs clear --restart window is still the most reliable repro loop.`:`Session app log stream is inactive. Run logs clear --restart, reproduce the request window again, then rerun network dump.`):e.push(`Capture uses the session app log file. For fresh traffic, run logs clear --restart before reproducing requests.`)}function En(e){return o(e)&&e.kind===`simulator`?`No HTTP(s) entries were found in recent iOS simulator app logs. If the app only emits non-HTTP diagnostics, inspect logs path or add app-side URLSession/network logging for per-request timing and payload details.`:o(e)?`No HTTP(s) entries were found in recent iOS device app logs. iOS network dump only sees what the app emits into Unified Logging for this process.`:`No HTTP(s) entries were found in recent session app logs.`}async function Dn(e){let{host:n,snapshot:r,targetLabel:i,recorderWarning:a,nativePathDisposition:o}=e,s=r.invalidatedReason?{recorder:`lost`,why:`owner-session-lost`}:e.stopObservation;if(r.invalidatedReason&&!r.showTouches)throw Error(`recording invalidated: ${r.invalidatedReason}`);let c;try{c=await n.screenRecording.finalize.complete({outputPath:r.outPath,showTouches:!r.invalidatedReason&&r.showTouches,gestureEvents:r.gestureEvents,exportQuality:r.exportQuality??`medium`,targetLabel:i})}catch(e){throw t(e,`COMMAND_FAILED`)}let l=[...c.warning?[c.warning]:[],...a?[a]:[]];return $e(r,{...c,...l.length>0?{warning:l.join(` `)}:{},...r.invalidatedReason?{overlayWarning:`overlay unavailable: ${r.invalidatedReason}`}:{}},{stopObservation:s,...o===void 0?{}:{nativePathDisposition:o}})}async function On(e){let{host:t,snapshot:n,targetLabel:r,collectedPath:i,exportPath:a,nativePath:o}=e;if(n.invalidatedReason&&!n.showTouches)throw Error(`recording invalidated: ${n.invalidatedReason}`);let s;try{await t.screenRecording.outputs.copy({from:i,to:a}),s=await kn(()=>t.screenRecording.finalize.complete({outputPath:a,showTouches:!n.invalidatedReason&&n.showTouches,gestureEvents:n.gestureEvents,exportQuality:n.exportQuality??`medium`,targetLabel:r}))}catch(e){throw await t.screenRecording.outputs.remove(a),e}return{...s,...n.invalidatedReason?{overlayWarning:`overlay unavailable: ${n.invalidatedReason}`}:{},nativePathDisposition:await t.screenRecording.outputs.remove(o)===`removed`?`retired`:`retirable`}}async function kn(e){try{return await e()}catch(e){throw t(e,`COMMAND_FAILED`)}}const E=Object.freeze({resourceKind:g,version:1,encode:e=>e.backend===`simctl`?{backend:e.backend,outputPath:e.outputPath,processes:e.processes.map(e=>({...e}))}:{backend:e.backend,outputPath:e.outputPath,appBundleId:e.appBundleId,runnerSessionId:e.runnerSessionId,runnerAuthority:e.runnerAuthority,...e.remotePath===void 0?{}:{remotePath:e.remotePath}},decode:e=>In(e)});function An(e){let{device:t,owner:n,input:r,descriptor:i}=e;return ze({resourceKind:g,sessionId:r.sessionId,device:c(t),owner:n,fence:r.fence,lifecycle:`open`,descriptor:Re(E,i)})}async function jn(e,t,n,r){let i=E.decode(n);return i.status!==`decoded`||!Un(t,i.descriptor)?{status:`cleanup-pending`,reason:`manual-recovery-required`}:i.descriptor.backend===`simctl`?await Mn(e,i.descriptor.processes,r):await Pn(e,t,i.descriptor)}async function Mn(e,t,n){let r=await Promise.all(t.map(async t=>await e.screenRecording.apple.inspectProcess(t)));if(r.includes(`ownership-lost`))return{status:`cleanup-pending`,reason:`ownership-fence-lost`};if(r.every(e=>e===`missing`))return n!==void 0&&e.screenRecording.ownedProcesses.clear(Nn(n)),{status:`already-missing`};let i=await Promise.all(t.flatMap((t,n)=>r[n]===`owned-alive`?[e.screenRecording.apple.terminateProcess(t)]:[]));return i.includes(`ownership-lost`)?{status:`cleanup-pending`,reason:`ownership-fence-lost`}:(n!==void 0&&e.screenRecording.ownedProcesses.clear(Nn(n)),i.every(e=>e===`already-missing`)?{status:`already-missing`}:{status:`cleaned`})}function Nn(e){return{kind:`session`,sessionId:e}}async function Pn(e,t,n){try{let r=await e.screenRecording.apple.inspectRunner(t,n.runnerSessionId,n.runnerAuthority);return r===`missing`?{status:`already-missing`}:r===`ownership-lost`?{status:`cleanup-pending`,reason:`ownership-fence-lost`}:(await e.screenRecording.apple.runRunner(t,{kind:`stop`,appBundleId:n.appBundleId,runnerSessionId:n.runnerSessionId,runnerAuthority:n.runnerAuthority}),{status:`cleaned`})}catch(e){return{status:`cleanup-pending`,reason:`transport-failed`,message:e instanceof Error?e.message:`Apple recording cleanup failed`}}}async function Fn(e,t,n){let r=E.decode(n);if(r.status!==`decoded`)return{status:`unreattachable`,reason:`descriptor-invalid`,message:r.message};if(!Un(t,r.descriptor))return{status:`unreattachable`,reason:`descriptor-invalid`,message:`Apple screen-recording descriptor does not match the bound device.`};let i=r.descriptor.backend===`simctl`?await Promise.all(r.descriptor.processes.map(async t=>await e.screenRecording.apple.inspectProcess(t))):[await e.screenRecording.apple.inspectRunner(t,r.descriptor.runnerSessionId,r.descriptor.runnerAuthority)];return i.every(e=>e===`missing`)?{status:`missing`}:{status:`unreattachable`,reason:`transport-not-reattachable`,message:i.includes(`ownership-lost`)?`Apple recording ownership no longer matches the durable descriptor.`:`Apple screen recordings require exact cleanup after daemon restart.`}}function In(e){return typeof e.outputPath!=`string`||e.outputPath.length===0?D():e.backend===`simctl`?Ln(e,e.outputPath):e.backend===`runner`?Rn(e,e.outputPath):D()}function Ln(e,t){let n=Wn(e.processes);return n?{status:`decoded`,descriptor:Object.freeze({backend:`simctl`,outputPath:t,processes:n})}:D()}function Rn(e,t){return!zn(e.appBundleId)||!zn(e.runnerSessionId)||!Bn(e.runnerAuthority)||!Vn(e.remotePath)?D():{status:`decoded`,descriptor:Object.freeze({backend:`runner`,outputPath:t,appBundleId:e.appBundleId,runnerSessionId:e.runnerSessionId,runnerAuthority:e.runnerAuthority,...e.remotePath===void 0?{}:{remotePath:e.remotePath}})}}function zn(e){return typeof e==`string`&&e.length>0}function Bn(e){return e===`local-lease`||e===`scoped-provider`}function Vn(e){return e===void 0||Hn(e)}function Hn(e){return typeof e==`string`&&/^tmp\/agent-device-recording-\d+\.mp4$/.test(e)}function Un(e,t){return e.kind===`simulator`?t.backend===`simctl`:t.backend===`runner`?e.appleOs===`macos`?t.remotePath===void 0:o(e)?t.remotePath!==void 0&&Hn(t.remotePath):t.remotePath===void 0:!1}function Wn(e){if(!Array.isArray(e)||e.length===0)return;let t=e.filter(e=>typeof e==`object`&&!!e&&Number.isInteger(e.pid)&&(e.pid??0)>0&&typeof e.startTime==`string`&&e.startTime.length>0&&typeof e.command==`string`&&e.command.length>0);return t.length===e.length?Object.freeze([...t]):void 0}function D(){return{status:`invalid`,message:`Invalid Apple screen-recording descriptor`}}async function Gn(e,t,n){if(e.kind!==`simulator`||t.scope!==`app`)return;let r=t.activeSessionApp?.bundleId;if(!r)throw TypeError(`App-scoped recording requires an active app session; open the app under test before recording.`);if(await n(r))throw TypeError(`App-scoped recording requires a real application session; open the app under test before recording.`)}function Kn(e){return e.appleOs===`watchos`?ir(`unsupported-platform-leaf`,`watchOS recording is not supported.`):o(e)&&e.kind===`device`&&e.iosPhysicalDeviceBackend===`xctest`?ir(`unsupported-device-backend`,`This command requires a CoreDevice-backed physical iOS device. The selected XCTest backend supports open, close, interactions, snapshots, and screenshots.`):Object.freeze({available:!0})}function qn(e){let{host:t,device:n,owner:r,signal:i}=e;return Object.freeze({screenRecordingStart:async e=>await Jn({host:t,device:n,owner:r,input:e,signal:i}),screenRecordingReattach:async e=>await Fn(t,n,e.envelope.descriptor.body),screenRecordingCleanup:async e=>await jn(t,n,e.envelope.descriptor.body,e.envelope.sessionId)})}async function Jn(e){return e.signal.throwIfAborted(),e.device.kind===`simulator`?await Yn(e):await Xn(e)}async function Yn(e){let{host:t,device:n,owner:r,input:i,signal:a}=e;await Gn(n,i,t.screenRecording.apple.isRunnerBundleId);let o=i.activeSessionApp?await t.screenRecording.apple.captureClockAnchor(n,i.activeSessionApp.bundleId,a):void 0,s=nt(i.outputPath);await t.screenRecording.outputs.prepare(s);let c=await t.screenRecording.apple.startSimulator(n,s,a),l=c.markers;if(!l||l.length===0)throw await O(c).catch(()=>{}),Error(`simctl recordVideo did not expose durable process identity`);try{a.throwIfAborted(),t.screenRecording.ownedProcesses.replace({kind:`session`,sessionId:i.sessionId},l.map(e=>({...e,purpose:`simctl-screen-recording`})))}catch(e){try{t.screenRecording.ownedProcesses.clear({kind:`session`,sessionId:i.sessionId})}catch{}throw await O(c).catch(()=>{}),e}let u,d,f=async()=>{await c.terminate();let e=await c.wait;return d=e,u=Qn(e),t.screenRecording.ownedProcesses.clear({kind:`session`,sessionId:i.sessionId}),{observation:{recorder:`confirmed`},...u===void 0?{}:{warning:`${u} before record stop; the video covers only what the recorder wrote before it stopped.`}}};return nr({device:n,owner:r,input:i,descriptor:{backend:`simctl`,outputPath:s,processes:l},snapshot:rr(i,`simctl recordVideo`,{},o),finish:(e,n)=>it({snapshot:e,progress:n,steps:{stop:f,collect:async e=>{try{await t.screenRecording.outputs.copy({from:s,to:e}),await t.screenRecording.finalize.sniff({outputPath:e})}catch(e){throw $n(e,u,d)}},finalize:async({collectedPath:n,exportPath:r})=>{try{return await On({host:t,snapshot:e,targetLabel:`iOS recording`,collectedPath:n,exportPath:r,nativePath:s})}catch(e){throw $n(e,u,d)}},discard:async e=>{await t.screenRecording.outputs.remove(e)}}}),cleanup:async()=>{let e=await tr(c);return(e.status===`cleaned`||e.status===`already-missing`)&&t.screenRecording.ownedProcesses.clear({kind:`session`,sessionId:i.sessionId}),e}})}async function Xn(e){let{host:t,device:n,owner:r,input:i,signal:a}=e,o=i.activeSessionApp?.bundleId;if(!o)throw TypeError(`Apple runner recording requires an active app session identity`);await t.screenRecording.outputs.prepare(i.outputPath);let s=await t.screenRecording.apple.runRunner(n,{kind:`start`,appBundleId:o,outputPath:i.outputPath,...i.fps===void 0?{}:{fps:i.fps}},a);if(!s.runnerSessionId||!s.runnerAuthority)throw Error(`Apple runner recording did not expose durable session ownership`);let c={runnerSessionId:s.runnerSessionId,runnerAuthority:s.runnerAuthority},l,u=()=>(l??=Zn(()=>t.screenRecording.apple.runRunner(n,{kind:`stop`,appBundleId:o,...c}).then(()=>void 0)).catch(e=>{throw l=void 0,e}),l);if(!er(n,s.remotePath))throw await u().catch(()=>{}),Error(`Apple runner recording did not expose coherent durable media ownership`);try{a.throwIfAborted()}catch(e){throw await u().catch(()=>{}),e}return nr({device:n,owner:r,input:i,descriptor:{backend:`runner`,outputPath:i.outputPath,appBundleId:o,...c,...s.remotePath===void 0?{}:{remotePath:s.remotePath}},snapshot:rr(i,`runner AVAssetWriter`,s),finish:async e=>(await u(),s.remotePath!==void 0&&await t.screenRecording.apple.retrieveRunnerRecording(n,s.remotePath,e.outPath),await Dn({host:t,snapshot:e,targetLabel:n.appleOs===`macos`?`macOS recording`:`iOS recording`,stopObservation:{recorder:`confirmed`},...s.remotePath===void 0?{}:{nativePathDisposition:`retirable`}})),cleanup:async()=>(await u(),{status:`cleaned`})})}async function Zn(e){try{return await e()}catch(e){throw t(e,`COMMAND_FAILED`)}}function Qn(e){if(e.exitCode!==0)return e.signal?`simctl recordVideo was killed by ${e.signal}`:`simctl recordVideo exited with code ${e.exitCode}`}function $n(n,r,i){let a=t(n,`COMMAND_FAILED`);return r===void 0||i===void 0||a.details?.reason!==`recording-output-unplayable`?n:new e(a.code,`${a.message}; ${r}`,m(i,{...a.details??{},...i.signal===void 0?{}:{signal:i.signal},retriable:!1,hint:`The recorder exited before record stop, so the next record stop reads the same file. Close this session to release the device, then record again.`}))}function er(e,t){return e.appleOs===`macos`||!o(e)?t===void 0:t!==void 0&&/^tmp\/agent-device-recording-\d+\.mp4$/.test(t)}async function O(e){return await e.terminate(),await e.wait}async function tr(e){try{return await O(e),{status:`cleaned`}}catch(e){return{status:`cleanup-pending`,reason:`transport-failed`,message:e instanceof Error?e.message:`Apple simulator cleanup failed`}}}function nr(e){let{device:t,owner:n,input:r,descriptor:i,snapshot:a,finish:o,cleanup:s}=e,c=Qe(a,{finish:o,forceCleanup:s});return Object.freeze({pendingHandle:new Be(c),envelope:An({device:t,owner:n,input:r,descriptor:i})})}function rr(e,t,n={},r){let i=Date.now();return Object.freeze({backend:t,outPath:e.outputPath,...e.clientOutputPath===void 0?{}:{clientOutPath:e.clientOutputPath},startedAt:i,scope:e.scope,showTouches:e.showTouches,recordOnlySession:e.recordOnlySession,...e.activeSessionApp===void 0?{}:{activeSessionApp:e.activeSessionApp},...e.exportQuality===void 0?{}:{exportQuality:e.exportQuality},gestureEvents:[],...r===void 0?{}:{gestureClockOriginAtMs:r.wallClockAtMs,gestureClockOriginUptimeMs:r.uptimeMs},...n.recorderStartUptimeMs===void 0?{}:{gestureClockOriginAtMs:i,gestureClockOriginUptimeMs:n.recorderStartUptimeMs,runnerStartedAtUptimeMs:n.recorderStartUptimeMs},...n.runnerSessionId===void 0?{}:{runnerSessionId:n.runnerSessionId}})}function ir(e,t){return Object.freeze({available:!1,reason:e,hint:t})}const ar=15e3;async function k(e,t,n,r={}){return n.throwIfAborted(),await gt(t)||s(t)?{...t,booted:!0}:t.kind===`device`?(await e.deviceReadiness.applePhysical.ensureConnected(t,n),{...t,booted:!0}):t.kind===`simulator`?((await or(e,t)?`Booted`:await ur(e,t,n))!==`Booted`&&(r.onColdBootStart?.(),e.deviceReadiness.appleAutomation.keepHot(t),await sr(e,t,n,r.deadlineAtMs),await dr(e,n)),e.deviceReadiness.appleAutomation.keepHot(t),e.deviceReadiness.appleAutomation.markBooted(t),{...t,booted:!0}):{...t,booted:!0}}async function or(e,t){try{return await e.deviceReadiness.appleAutomation.wasRecentlyObservedBooted(t)}catch{return!1}}async function sr(e,t,n,r=Date.now()+12e4){let i=!1;try{i=await cr(e,t,n,r),await lr(e,t,n,r)}catch(a){throw i&&n.aborted&&fr(e,t),n.throwIfAborted(),Date.now()>=r?j(t,a):a}}async function cr(t,n,r,i){let a=await t.appleTools.run({tool:`simctl`,args:_(n,[`boot`,n.id]),allowFailure:!0,timeoutMs:A(i,n)},r),o=`${a.stdout}\n${a.stderr}`.toLowerCase(),s=o.includes(`already booted`)||o.includes(`current state: booted`);if(a.exitCode!==0&&!s)throw new e(`COMMAND_FAILED`,`simctl boot failed`,{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode});return!s}async function lr(t,n,r,i){re({type:`command`,status:`progress`,message:`Waiting for the Simulator to finish booting...`});let a=await t.appleTools.run({tool:`simctl`,args:_(n,[`bootstatus`,n.id,`-b`]),allowFailure:!0,timeoutMs:A(i,n)},r);if(a.exitCode!==0)throw new e(`COMMAND_FAILED`,`simctl bootstatus failed`,{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode});if(await wt(t.appleTools,n,r,Math.min(ar,A(i,n)))!==`Booted`)throw new e(`COMMAND_FAILED`,`Simulator is still booting`,{deviceId:n.id});if(Date.now()>=i)throw j(n)}function A(e,t){let n=e-Date.now();if(n<=0)throw j(t);return n}function j(t,n){return new e(`COMMAND_FAILED`,`Simulator did not finish booting within the startup budget`,{reason:`boot_timeout`,deviceId:t.id,hint:`The Simulator keeps booting in the background; a first boot can take several minutes. Retry once it is up, or pass a larger --timeout.`},n instanceof Error?n:void 0)}async function ur(e,t,n){return await wt(e.appleTools,t,n,ar)}async function dr(e,t){await e.commands.run({executable:`open`,args:[`-a`,`Simulator`],allowFailure:!0,timeoutMs:1e4},t)}function fr(e,t){e.appleTools.run({tool:`simctl`,args:_(t,[`shutdown`,t.id]),allowFailure:!0}).catch(()=>{})}const pr=Object.freeze({resolveOpenTarget:`simulator`,prepareApplicationOpen:`simulator`,openApplication:`simulator`,applyRuntimeHints:`simulator`,clearRuntimeHints:`simulator`,closeApplication:`simulator`,finalizeApplicationClose:`simulator`,prepareAppleRunner:`runner`,configureProviderPortReverse:`simulator`,ensureReady:`simulator`,bootTarget:`simulator`,bootTargetHeadless:`simulator`,shutdownTarget:`simulator`,listApps:`simulator`,deployApp:`simulator`,materializeAppSource:`simulator`,deployMaterializedApp:`simulator`,sendPushNotification:`simulator`,appState:`simulator`,appLogStart:`simulator`,appLogInspect:`simulator`,appLogDoctor:`simulator`,appLogReattach:`simulator`,appLogCleanup:`simulator`,networkDump:`simulator`,audioProbeStart:`simulator`,audioProbeQuery:`simulator`,audioProbeReattach:`simulator`,audioProbeCleanup:`simulator`,readClipboard:`simulator`,writeClipboard:`simulator`,setSetting:`simulator`,captureSnapshot:`simulator`,captureSnapshotWithoutActiveApp:`simulator`,captureSnapshotWithCustomActions:`runner`,captureScreenshot:`simulator`,findText:`runner`,readTextAtPoint:`runner`,tapPoint:`runner`,tapRef:`runner`,tapElementSelector:`runner`,fillPoint:`runner`,fillRef:`runner`,longPressPoint:`runner`,hoverPoint:`runner`,hoverRef:`runner`,focusPoint:`runner`,typeText:`runner`,scrollDirection:`runner`,performGesturePlan:`runner`,performMultiTouchGesturePlan:`runner`,performTargetAuthoredDrag:`runner`,performDirectionalFlingPlan:`runner`,gestureViewport:`runner`,setViewport:`runner`,back:`runner`,home:`runner`,setOrientation:`runner`,appSwitcher:`runner`,tvRemote:`runner`,keyboardDismiss:`runner`,keyboardEnter:`runner`,keyboardStatus:`runner`,triggerAppEvent:`runner`,readAlert:`runner`,awaitAlert:`runner`,acceptAlert:`runner`,dismissAlert:`runner`,perfFrames:`runner`,perfMemorySample:`runner`,perfMemorySnapshot:`runner`,perfNativeCaptureStart:`runner`,perfNativeCaptureReattach:`runner`,perfNativeCaptureCleanup:`runner`,perfProfileReport:`runner`,screenRecordingStart:`runner`,screenRecordingReattach:`runner`,screenRecordingCleanup:`runner`});function mr(e){return e===void 0?`possible`:e.some(e=>pr[e]===`runner`)?`required`:`none`}const hr=new Map([[`application-element-missing`,5e3],[`application-server-unavailable`,5e3],[`foreground-owner-unverified`,1e3],[`foreground-owner-changed`,1e3]]);function M(e){return e.platform===`apple`&&e.appleOs===`ios`&&e.kind===`simulator`}function gr(e){let t=ee(ne({depth:1,interactiveOnly:!0}));return Object.freeze({awaitObservable:async(n,r,i)=>{if(!M(n))return`not-eligible`;let a;for(;;){let o=await e.resolveTarget(n,r,i).catch(()=>void 0);if(i.throwIfAborted(),!o)return`unobservable`;if(e.isBridgeDisabled(o))return p({level:`debug`,phase:`ios_launch_observation_skipped`,data:{reason:`circuit-disabled`,deviceId:n.id,generation:o.generation}}),`unobservable`;let s=await e.source.acquire({target:o,hint:t,signal:i});if(s.stage!==`failed`)return`observable`;i.throwIfAborted();let c=hr.get(s.failure.code);if(c===void 0)return`unobservable`;let l=e.clock.now();if(a=Math.min(a??1/0,l+c),l>=a)return`unobservable`;await e.clock.sleep(Math.min(150,a-l),i)}}})}function _r(e,t,n){let r=n&&M(e),i=r?mr(t.execution.plannedOperations):void 0,a=o(e)&&t.surface===`app`&&t.positionals.length>0&&!!t.appBundleId&&i!==`none`;return{...i?{runnerDemand:i}:{},shouldPrewarmRunner:a,awaitPrewarmAfterOpen:t.relaunch&&!r}}function vr(e,t,n,r){r.runnerDemand===`none`&&e.appleApplications.releaseSpeculativeRunner(t.device,n.execution).catch(()=>{})}async function yr(e,t,n,r,i,a){let o=Date.now();r&&M(t.device)&&i&&n.appBundleId&&(a.postOpenObservation=await i.awaitObservable(t.device,n.appBundleId,t.signal)),r&&a.postOpenObservation!==`observable`&&await e.clock.sleep(300,t.signal),a.postOpenSettleDurationMs=Math.max(0,Date.now()-o)}function br(e){let t=vt({device:e.device,signal:e.signal,resolveInteractor:e.host.localInteractors.resolve});return Object.freeze({resolveOpenTarget:async t=>await e.host.appleApplications.resolveOpenTarget(e.device,t),prepareApplicationOpen:async t=>{await k(e.host,e.device,e.signal,{deadlineAtMs:t.execution.startupDeadlineAtMs,onColdBootStart:t.prewarmRunnerOnColdBoot?()=>{e.host.appleApplications.prewarmRunnerCache(e.device,t.execution,e.signal).catch(()=>{})}:void 0})},openApplication:async n=>await xr(e.host,t,n,e.observation),applyRuntimeHints:async t=>await e.host.appleApplications.applyRuntimeHints(e.device,t),clearRuntimeHints:async t=>await e.host.appleApplications.clearRuntimeHints(e.device,t),closeApplication:async n=>await jr(e.host,t,n),finalizeApplicationClose:async t=>await Mr(e.host,e.device,e.signal,t),prepareAppleRunner:async t=>await Nr(e.host,e.device,e.signal,t),configureProviderPortReverse:Rr})}async function xr(e,t,n,r){let i={},a=N(t.device),o=Pr(e,t,n,i),s=_r(t.device,n,a);s.runnerDemand&&(i.runnerDemand=s.runnerDemand),vr(e,t,n,s);let{shouldPrewarmRunner:c}=s,l=Ar(t.device,n,a);a&&c&&!n.prewarmRunnerBeforeOpen&&o.schedule();try{await Sr(e,t,n,a,l,i),await Cr(n,i),await wr(o,c,n.prewarmRunnerBeforeOpen);let u=o.wasAwaited();return await Tr(t,n,a,i),await Dr(o,c,s.awaitPrewarmAfterOpen),await Or(e,t,n,a,u,l),await yr(e,t,n,a,r,i),{appBundleId:n.appBundleId,timing:i}}catch(n){throw l&&await e.appleApplications.stopRunnerSession(t.device.id).catch(()=>{}),n}}async function Sr(e,t,n,r,a,o){if(!kr(n,r)||!n.target)return;let s=Date.now();i(t.device.platform)&&!r&&!a&&await e.appleApplications.stopRunnerSession(t.device.id),await _t({device:t.device,interactor:await t.resolveInteractor(n.execution,n.appBundleId),positionals:[n.appBundleId??n.target]}),r&&await e.clock.sleep(300,t.signal),o.relaunchCloseDurationMs=P(s)}async function Cr(t,n){if(!ae(t.runtimeHints))return;if(!t.applyRuntimeHints)throw new e(`COMMAND_FAILED`,`Runtime hint operation was not admitted for this open.`,{reason:`runtime-hints-operation-missing`});let r=Date.now();await t.applyRuntimeHints({appId:t.appBundleId,values:t.runtimeHints}),n.runtimeHintsDurationMs=P(r)}async function wr(e,t,n){!t||!n||(e.schedule(!0),await e.wait())}async function Tr(e,t,n,r){let i=Ir(t,n),a=Date.now();await yt({device:e.device,interactor:await e.resolveInteractor(t.execution,t.appBundleId),positionals:i.positionals,appBundleId:t.appBundleId,execution:t.execution,...n&&t.relaunch&&!t.execution.clearAppState?{terminateRunningApp:!0}:{}}),r.openDispatchDurationMs=P(a),await Er(e,t,i.followUpUrl,r)}async function Er(e,t,n,r){if(!n){r.launchUrlDurationMs=0;return}let i={...t.execution,clearAppState:void 0,launchConsole:void 0,launchArgs:void 0},a=Date.now();await yt({device:e.device,interactor:await e.resolveInteractor(i,t.appBundleId),positionals:[n],appBundleId:t.appBundleId,execution:i}),r.launchUrlDurationMs=P(a)}async function Dr(e,t,n){t&&!e.wasScheduled()&&e.schedule(),n?await e.wait():e.recordUnawaited()}async function Or(e,t,n,r,i,a){!o(t.device)||!r&&!a||!n.relaunch&&!i||r&&!i&&!await e.appleApplications.hasLiveRunnerSession(t.device,n.execution)||await e.appleApplications.notifyRunnerAppRelaunched(t.device,n.execution,t.signal)}function kr(e,t){return!!(e.relaunch&&e.target)&&!(t&&!e.execution.clearAppState)}function Ar(e,t,n){return e.kind===`device`&&e.appleOs===`ios`&&kr(t,n)}async function jr(e,t,n){n.ensureReady&&await k(e,t.device,t.signal),i(t.device.platform)&&!N(t.device)&&await e.appleApplications.stopRunnerSession(t.device.id),await _t({device:t.device,interactor:await t.resolveInteractor(n.execution,n.appBundleId),positionals:n.positionals}),N(t.device)&&await e.clock.sleep(300,t.signal)}async function Mr(e,t,n,r){r.daemonShutdown||await e.appleApplications.releaseRunnerOnClose(t.id,{retain:r.retainRunner}),await e.appleApplications.dismissCloseAlerts(t,r).catch(()=>{});let i=r.shutdownTarget&&N(t)?await e.deviceShutdown.apple.shutdownTarget(t,n):void 0;return i===void 0?{}:{shutdown:i}}async function Nr(e,t,n,r){let i=Date.now()+r.timeoutMs;await k(e,t,n,{deadlineAtMs:i});let a=Math.max(1,i-Date.now());return await e.appleApplications.prepareRunner(t,{...r,timeoutMs:a},n)}function Pr(e,t,n,r){let i,a=!1,o=Fr(t.device,n)?{healthCheck:!1}:void 0;return{schedule:(a=!1)=>{i||=(r.runnerPrewarmKind=`session`,r.runnerPrewarmScheduled=!0,o?e.appleApplications.prewarmRunnerSession(t.device,n.execution,t.signal,a,o):e.appleApplications.prewarmRunnerSession(t.device,n.execution,t.signal,a))},wait:async()=>{if(!i||a)return;a=!0;let e=Date.now();await i,r.runnerPrewarmWaited=!0,r.runnerPrewarmDurationMs=P(e)},wasAwaited:()=>a,wasScheduled:()=>i!==void 0,recordUnawaited:()=>{i&&!a&&(r.runnerPrewarmWaited=!1)}}}function Fr(e,t){return e.kind===`device`&&e.appleOs===`ios`&&!t.hasExistingSession&&!t.relaunch&&!t.prewarmRunnerBeforeOpen}function Ir(e,t){let r=e.runtimeLaunchUrl?.trim(),i=e.positionals.length===1?e.positionals[0]?.trim():void 0;return!r||!i||n(i)?{positionals:e.positionals}:t&&!Lr(e)?{positionals:[i,r]}:{positionals:e.positionals,followUpUrl:r}}function Lr(e){return e.execution.clearAppState===!0||!!e.execution.launchConsole?.trim()||!!e.execution.launchArgs?.length}function N(e){return o(e)&&e.kind===`simulator`}function P(e){return Math.max(0,Date.now()-e)}async function Rr(){throw new e(`UNSUPPORTED_OPERATION`,`This lifecycle operation is unavailable for Apple.`)}const zr=Object.freeze({available:!0}),Br=Object.freeze({available:!1,reason:`unsupported-device-backend`,hint:`This command requires a CoreDevice-backed physical iOS device. The selected XCTest backend supports open, close, interactions, snapshots, and screenshots.`}),Vr=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`Push notifications are supported on Apple simulators only.`}),Hr=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),Ur=Object.freeze({available:!1,reason:`unsupported-device-kind`});function Wr(e){let t=Qr(e);return Object.freeze({deployApp:t,materializeAppSource:t,deployMaterializedApp:t,sendPushNotification:$r(e)})}function Gr(e){let{host:t,device:n,signal:r}=e,i=Wr(n);return Object.freeze({...i.deployApp.available?{deployApp:async e=>await Kr(t,n,e,r),materializeAppSource:async e=>await t.appleDeployment.prepareArtifact(e,{signal:r}),deployMaterializedApp:async e=>await qr(t,n,e,r)}:{},...i.sendPushNotification.available?{sendPushNotification:async e=>(await Xr(t,n,e,r),{})}:{}})}async function Kr(e,t,n,r){if(n.replaceExisting)return await e.appleDeployment.withInvalidatedAppResolutionCache(t,async()=>{let i=await e.appleDeployment.resolveAppBundleId(t,n.app);await Yr(e,t,i,r);let a=await e.appleDeployment.prepareArtifact({source:{kind:`path`,path:n.appPath}},{appIdentifierHint:n.app,signal:r});try{return await Jr(e,t,a.installablePath,r),{bundleId:i,launchTarget:i}}finally{await a.cleanup()}});let i=await e.appleDeployment.prepareArtifact({source:{kind:`path`,path:n.appPath}},{appIdentifierHint:n.app,signal:r});try{return await qr(e,t,{artifact:i},r)}finally{await i.cleanup()}}async function qr(e,t,n,r){return await Jr(e,t,n.artifact.installablePath,r),{...n.artifact.bundleId?{bundleId:n.artifact.bundleId}:{},...n.artifact.appName?{appName:n.artifact.appName}:{},...n.artifact.bundleId?{launchTarget:n.artifact.bundleId}:{}}}async function Jr(e,t,n,r){await k(e,t,r),F(await e.appleTools.run(t.kind===`simulator`?{tool:`simctl`,args:_(t,[`install`,t.id,n])}:{tool:`devicectl`,args:[`device`,`install`,`app`,`--device`,t.id,n],timeoutMs:12e4},r),`Apple app install failed`)}async function Yr(e,t,n,r){await k(e,t,r);let i=await e.appleTools.run(t.kind===`simulator`?{tool:`simctl`,args:_(t,[`uninstall`,t.id,n]),allowFailure:!0}:{tool:`devicectl`,args:[`device`,`uninstall`,`app`,`--device`,t.id,n],allowFailure:!0},r);i.exitCode===0||Zr(`${i.stdout}\n${i.stderr}`)||F(i,`Apple app uninstall failed for ${n}`)}async function Xr(t,n,r,i){if(n.kind!==`simulator`)throw new e(`UNSUPPORTED_OPERATION`,`Apple push notifications require a simulator`);await k(t,n,i);let a=await t.temporaryFiles.create({prefix:`agent-device-ios-push-`,suffix:`.apns`});try{await a.writeText(`${JSON.stringify(r.payload)}\n`),F(await t.appleTools.run({tool:`simctl`,args:_(n,[`push`,n.id,r.appId,a.path])},i),`Apple push notification failed`)}finally{await a[Symbol.asyncDispose]()}}function Zr(e){let t=e.toLowerCase();return t.includes(`not installed`)||t.includes(`not found`)||t.includes(`no such file`)}function F(t,n){if(t.exitCode!==0)throw new e(`COMMAND_FAILED`,n,{stdout:t.stdout,stderr:t.stderr,exitCode:t.exitCode})}function Qr(e){return ei(e)?e.kind!==`simulator`&&e.kind!==`device`?Ur:e.kind===`device`&&e.iosPhysicalDeviceBackend===`xctest`?Br:zr:Hr}function $r(e){return ei(e)?e.kind===`simulator`?zr:Vr:Hr}function ei(e){return o(e)&&e.appleOs!==`watchos`}const I=Object.freeze({available:!0}),ti=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`back is supported on Apple simulators and physical devices.`}),ni=Object.freeze({available:!1,reason:`unsupported-platform-leaf`});function ri(e){return e.kind!==`simulator`&&e.kind!==`device`?ti:r(e)===`watchos`?ni:I}const ii=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`home is supported on Apple simulators and physical devices.`}),ai=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),oi=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`app-switcher is supported on Apple simulators and physical devices.`});function si(e,t){if(e.kind!==`simulator`&&e.kind!==`device`)return t;let n=r(e);return n===`macos`||n===`watchos`?ai:I}function L(e){if(e.kind!==`simulator`&&e.kind!==`device`)return!1;let t=r(e);return t!==`tvos`&&t!==`macos`&&t!==`watchos`}const ci=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`orientation is supported on Apple simulators and physical devices.`}),li=Object.freeze({available:!1,reason:`unsupported-platform-leaf`});function ui(e){return e.kind!==`simulator`&&e.kind!==`device`?ci:L(e)?I:li}const di=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`tv-remote is supported only on tvOS devices.`});function fi(e){return(e.kind===`simulator`||e.kind===`device`)&&a(e)?I:di}const R=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),pi=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`keyboard status/get is currently supported only on Android; use keyboard dismiss or enter on iOS`});function mi(e){return L(e)?pi:R}function hi(e){return L(e)?I:R}function gi(e){return L(e)?I:R}function _i(e){return Object.freeze({...Pe({back:ri(e)}),...we({home:si(e,ii)}),...Ae({appSwitcher:si(e,oi)}),...Me({orientation:ui(e)}),...Ee({tvRemote:fi(e)}),...ke({unsupported:R,status:mi(e),dismiss:hi(e),enter:gi(e)})})}function vi(e){let{host:t,device:n,signal:r}=e;return ct({device:n,signal:r,resolveInteractor:t.localInteractors.resolve,facts:_i(n)})}const z=Object.freeze({available:!0}),yi=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`clipboard is supported on Apple simulators and the macOS host.`}),bi=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`settings is supported on Apple simulators and the macOS host.`}),xi=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`settings is supported on Apple simulators and the macOS host, not on physical devices of this OS.`}),Si=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`clipboard is supported on Apple simulators and the macOS host, not on physical devices of this OS.`}),B=Object.freeze({available:!1,reason:`unsupported-platform-leaf`});function Ci(e,t,n){if(e.kind!==`simulator`&&e.kind!==`device`)return t;let i=r(e);return i===`watchos`?B:e.kind===`simulator`||i===`macos`?z:n}function wi(e){return Ci(e,yi,Si)}const Ti=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`trigger-app-event is supported on Apple simulators and physical devices.`}),Ei=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`alert is supported on Apple simulators and physical devices.`}),Di=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`alert is supported on Apple simulators, the macOS host, and physical iOS devices.`});function Oi(e){if(e.kind!==`simulator`&&e.kind!==`device`)return Ei;let t=r(e);return t===`watchos`?B:e.kind===`simulator`||t===`ios`||t===`macos`?z:Di}function ki(e){return e.kind!==`simulator`&&e.kind!==`device`?Ti:r(e)===`watchos`?B:z}function Ai(e){let t=wi(e);return t.available?Si:t}function ji(e){let t=wi(e),n=Oi(e);return Object.freeze({...Te({unsupported:Ai(e),read:t,write:t}),...je({read:n,wait:n,accept:n,dismiss:n}),...Ce({triggerAppEvent:ki(e)}),...De({setSetting:Ci(e,bi,xi)})})}function Mi(e){let{host:t,device:n,signal:r}=e;return ct({device:n,signal:r,resolveInteractor:t.localInteractors.resolve,facts:ji(n)})}function Ni(e,t,n){let r=Fe({device:t.device,signal:t.signal,resolveInteractor:e.localInteractors.resolve}),i=async i=>{if(s(t.device)&&i.options?.surface!==void 0&&i.options.surface!==`app`)return await e.snapshot.captureSurface(t.device,i.options,Se(t.signal,i));if(!n)return await r.captureSnapshot(i);let a=Se(t.signal,i);return await n.capture(t.device,i,a,async e=>await r.captureSnapshot(e))};return Object.freeze({captureSnapshot:i,captureSnapshotWithCustomActions:i,captureSnapshotWithoutActiveApp:i})}function Pi(e,t){return Object.freeze({findText:async n=>{let r=await Fi(e,t,n);if(!r)return{found:!1};let i=await e.localInteractors.resolve(t.device,{...n.execution,...r});return i.findText?await i.findText(n.text,r):{found:!1}}})}async function Fi(e,t,n){let r=n.options?.appBundleId;if(r===void 0)return;let i=n.options?.surface;if(s(t.device)&&i!==void 0&&i!==`app`)return;let a=n.signal?AbortSignal.any([t.signal,n.signal]):t.signal;if(a.throwIfAborted(),await Ii(e,t.device,n.execution))return{appBundleId:r,signal:a}}async function Ii(e,t,n){return!M(t)||await e.appleApplications.hasLiveRunnerSession(t,n??{})}function Li(){let e,t=!1,n=async()=>(e??=import(`./adapter.js`).then(({createSimulatorSnapshotSource:e})=>e()),await e);return{acquire:async e=>t?{stage:`failed`,failure:{kind:`unsupported`,code:`source-closed`}}:await(await n()).acquire(e),close:async()=>{t=!0,e&&await(await e).close()}}}const Ri=3e3;function zi(){let e=new Map,t=new Map,n=Tt({waitMs:1500});return async(r,i,a,o)=>{a.throwIfAborted();let s=`${r.id}:${i}`,c=e.get(s);return c&&o!==`refresh`&&await Dt(c.pid,{signal:a,timeoutMs:Ri})===c.processStartTime?c:(e.delete(s),await n.value(s,{start:async()=>{let n=await Bi(r,i,t);return e.set(s,n),n},wait:(e,t)=>Et({waitMs:e,signal:a,stop:t,cancelled:()=>a.reason}),pending:()=>H(`simulator-target-discovery-pending`,r,i)}))}}async function Bi(e,t,n){let r=Date.now()+15e3,[i,a]=await Promise.allSettled([xt(e,[`spawn`,e.id,`launchctl`,`list`],{allowFailure:!0,timeoutMs:V(r)}),Vi(e,n,r)]);if(i.status===`rejected`)throw i.reason;if(a.status===`rejected`)throw a.reason;let o=i.value,s=a.value;if(o.exitCode!==0)throw H(`simulator-target-probe-failed`,e,t);let c=Hi(o.stdout,t);if(!c)throw H(`simulator-target-unavailable`,e,t);let l=await Dt(c.pid,{timeoutMs:Math.min(Ri,V(r))});if(!l)throw H(`simulator-target-identity-unavailable`,e,t);return Object.freeze({udid:e.id,runtime:s,pid:c.pid,generation:`${c.pid}:${c.label}:${l}`,targetId:`${e.id}:${t}`,processStartTime:l})}async function Vi(e,t,n){let r=t.get(e.id);if(r)return await r;let i=xt(e,[`list`,`devices`,`-j`],{allowFailure:!0,timeoutMs:V(n)}).then(t=>{if(t.exitCode!==0)throw H(`simulator-runtime-probe-failed`,e,``);let n=JSON.parse(t.stdout),r=Object.entries(n.devices??{}).find(([,t])=>t.some(t=>t.udid===e.id))?.[0];if(!r)throw H(`simulator-runtime-unavailable`,e,``);return r});t.set(e.id,i);try{return await i}catch(n){throw t.delete(e.id),n}}function Hi(e,t){for(let n of e.split(`
4
- `)){let[e,,r]=n.trim().split(/\s+/);if(!e||!r||!r.startsWith(`UIKitApplication:${t}[`))continue;let i=Number(e);if(Number.isSafeInteger(i)&&i>0)return{pid:i,label:r}}}function V(e){return Math.max(1,e-Date.now())}function H(t,n,r){return new e(`COMMAND_FAILED`,`Unable to resolve the running iOS Simulator app (${t}).`,{reason:t,deviceId:n.id,appBundleId:r})}function Ui(e=Date.now){let t=new Map;return async(n,r)=>{if(n.kind!==`simulator`)return`absent`;let i=t.get(n.id);if(i!==void 0&&e()-i.at<1e3)return{kind:`present`,host:i.host};t.delete(n.id);let a=await Wi(n,r);return a!==`absent`&&a!==`unknown`&&t.set(n.id,{at:e(),host:a.host}),a}}async function Wi(e,t){let n=!1;for(let r of at){let i=await Gi(r.processExecutable,t);if(i===`unknown`){n=!0;continue}for(let a of i){let i=await Ki(a,e.id,t);if(i===`unknown`)n=!0;else if(i)return{kind:`present`,host:r}}}return n?`unknown`:`absent`}async function Gi(e,t){let n=await qi(`pgrep`,[`-f`,e],t);return n===`unknown`?`unknown`:n.exitCode===1?[]:n.exitCode===0?n.stdout.split(`
5
- `).map(e=>Number.parseInt(e.trim(),10)).filter(e=>Number.isSafeInteger(e)&&e>0):`unknown`}async function Ki(e,t,n){let r=await qi(`ps`,[`eww`,`-p`,String(e),`-o`,`command=`],n);return r===`unknown`||r.exitCode!==0?`unknown`:r.stdout.includes(`SIMULATOR_UDID=${t}`)?!0:!r.stdout.includes(`SIMULATOR_UDID=`)&&`unknown`}async function qi(e,t,n){try{let r=await bt(e,t,{allowFailure:!0,timeoutMs:3e3,...n?{signal:n}:{}});return{exitCode:r.exitCode,stdout:r.stdout}}catch{return`unknown`}}const Ji=`system-surface-presented`,Yi=`system-surface-host-lingering`;function Xi(t,n={}){let r=n.source??Li(),i=n.resolveTarget??zi(),a=n.systemSurfacePresent??Ui(),o=new Set,s=new Map,c=e=>(sa(e,s,o),o.has(ca(e))),l=gr({source:r,resolveTarget:i,clock:t.clock,isBridgeDisabled:c});return Object.freeze({awaitObservable:l.awaitObservable,shutdown:async()=>await r.close(),capture:async(n,s,l,u)=>{if(!$i(n,s))return await na(n,s,u);let d=await a(n,l);if(d===`unknown`)return await U(n.id,s,u,W(n.id,s),q(s),`system-surface-probe-unavailable`,[K()]);if(d!==`absent`)return await ta(n,s,u,d.host.bundleId);let p;try{p=await Zi(t,i,n,s,l)}catch(e){return l.throwIfAborted(),J(`target-resolution-failed`,n,void 0,e),await U(n.id,s,u,W(n.id,s),q(s),`target-resolution-failed`,[K()])}if(c(p))return await U(n.id,s,u,p,q(s),`circuit-disabled`);let m=q(s),h=await r.acquire({target:p,hint:ee(m),signal:l});if(h.stage===`failed`){if(h.failure.kind===`cancelled`)throw l.throwIfAborted(),new e(`COMMAND_FAILED`,`Simulator AX snapshot acquisition was cancelled.`,{reason:h.failure.code,...h.failure.details});let t=await oa(h.failure,p,n,s.options.appBundleId,l,i);return await ea(s,u,p,t,m,h.failure,o)}try{return await f(`ios.snapshot-source.present`,async()=>await t.snapshot.presentIosAcquisition(h,s.options),{producer:`simulator-ax-bridge`})}catch(e){return await ea(s,u,p,{lineage:p,residue:[]},m,{kind:`malformed-tree`,code:`presentation-invariant`},o,e)}}})}async function Zi(e,t,n,r,i){let a=r.options.appBundleId;for(;;)try{return await t(n,a,i)}catch(t){if(!Qi(t))throw t;let i={requestId:r.execution?.requestId};if(await e.appleApplications.hasLiveRunnerSession(n,i))throw t}}function Qi(t){return t instanceof e&&t.details?.reason===`simulator-target-discovery-pending`}function $i(e,t){return e.platform===`apple`&&e.appleOs===`ios`&&e.kind===`simulator`&&!!t.options?.appBundleId&&t.options?.customActions!==!0&&t.options?.preferredBackend===void 0}async function ea(e,t,n,r,i,a,o,s){return a.kind!==`preparing`&&o.add(ca(n)),J(a.code,{id:n.udid},n.generation,s,a.details),await U(n.udid,e,t,r.lineage,i,a.code,r.residue)}async function U(e,t,n,r,i,a,o=[]){return ra(e,await n(t),r,i,a,o)}async function ta(e,t,n,r){let i=await n(t),a=i.systemSurface?Ji:Yi;return i.systemSurface||J(a,e,void 0,void 0,{detectedHost:r}),ra(e.id,i,W(e.id,t),q(t),a)}async function na(e,t,n){let r=await n(t),i=r.systemSurface;return i?{...r,comparisonIdentity:ia(G(e.id,i.bundleId),q(t),[])}:r}function ra(e,t,n,r,i,a=[]){let o=t.systemSurface;return{...t,comparisonIdentity:ia(o?G(e,o.bundleId):n,r,[...o?[]:a,{kind:`fallback-source`,producer:`apple-runner`}]),warnings:[...t.warnings??[],aa(i,n,o!==void 0)]}}function W(e,t){return{targetId:`${e}:${t.options.appBundleId}`}}function G(e,t){return{targetId:`${e}:${t}`}}function ia(e,t,n){return Object.freeze({producer:`apple-runner`,intent:t.acquisitionIntent,lineage:Object.freeze({...e.targetId?{targetId:e.targetId}:{},...e.generation?{generation:e.generation}:{}}),presentationKey:te(t),residue:Object.freeze([...n])})}function aa(e,t,n){return e===Ji?`Simulator AX snapshot inapplicable (${e}); used XCTest to read the system surface presented over the app.`:e===Yi?`Simulator AX snapshot inapplicable (${e}); used XCTest, which read app content: the system surface host process was still running but no longer presenting.`:n?`Simulator AX snapshot unavailable (${e}); used XCTest, which read the system surface presented over the app.`:e===`bridge-preparation-pending`?`Simulator AX snapshot unavailable (${e}); used XCTest for this capture while the bridge is still being prepared.`:`Simulator AX snapshot unavailable (${e}); used XCTest for ${t.generation?`this app generation`:`an unverified app generation`}.`}async function oa(e,t,n,r,i,a){if(e.kind!==`stale-target`)return{lineage:t,residue:[]};try{return{lineage:await a(n,r,i,`refresh`),residue:[]}}catch(e){return i.throwIfAborted(),J(`fallback-target-resolution-failed`,n,void 0,e),{lineage:{targetId:t.targetId},residue:[K()]}}}function K(){return{kind:`unknown-generation`,captureId:kt()}}function q(e){return ne({raw:e.options?.raw,interactiveOnly:e.options?.interactiveOnly,depth:e.options?.depth,scope:e.options?.scope,customActions:e.options?.customActions,acquisitionIntent:e.options?.acquisitionIntent})}function sa(e,t,n){let r=t.get(e.targetId);r&&r!==e.generation&&n.delete(`${e.targetId}:${r}`),t.set(e.targetId,e.generation)}function ca(e){return`${e.targetId}:${e.generation}`}function J(e,t,n,r,i){p({level:`debug`,phase:`ios_snapshot_route_fallback`,data:{reason:e,deviceId:t.id,...n?{generation:n}:{},...r?{error:r instanceof Error?r.message:String(r)}:{},...i?{details:i}:{}}})}const Y=l(`apple`),X=Object.freeze({available:!0}),Z=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),la=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`viewport resizes web targets only (--platform web). Apple screen geometry is fixed by the selected simulator or device type — open a different simulator to test another screen size.`}),ua=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`the stateless audio page probe is a web-session operation; Apple targets use the host capture.`}),da=Object.freeze({available:!1,reason:`unsupported-device-backend`,hint:`perf requires an Apple simulator, macOS device, or CoreDevice-backed physical Apple device.`}),fa=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`focus is supported on Apple simulators and physical devices.`}),pa=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`Apple appstate reads the active session state; a sessionless runtime foreground probe is unavailable.`}),ma=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Headless boot is supported only for local Android emulators.`}),ha=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`watchOS has no XCUITest-driveable UI, so element text comes from the captured tree only.`}),ga=Object.freeze({available:!1,reason:`unsupported-device-kind`}),_a=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`watchOS open is not supported because XCUITest cannot drive watchOS UI.`}),va=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`watchOS runner preparation is not supported because XCUITest cannot drive watchOS UI.`}),ya=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`watchOS close is not supported because XCUITest cannot drive watchOS UI.`}),ba=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`Runtime hints are supported only for local iOS-family simulators and Android devices.`}),xa=Q(`open is supported only for Apple simulators and devices.`),Sa=Q(`prepare is supported only for Apple simulators and devices.`),Ca=Q(`close is supported only for Apple simulators and devices.`),wa=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Port reverse is supported only by an owning provider runtime.`}),Ta=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`shutdown is supported only for Apple simulators and Android emulators.`}),Ea=Q(`snapshot is supported only for Apple simulators and devices.`),Da=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`Re-run without --actions, or target an iOS simulator.`}),Oa=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`screenshot is not supported on watchOS because XCUITest cannot drive watchOS UI.`}),ka=Q(`screenshot is supported only for Apple simulators and devices.`),Aa=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`Open the app under test before capturing its snapshot.`});function Q(e){return Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:e})}function ja(e){return!o(e)||e.appleOs===`watchos`?Z:e.kind===`simulator`?X:Ta}function Ma(e){let t=Na(e),n=Pa(e),r=Fa(e),i=Ia(e);return oe({resolveOpenTarget:t,prepareApplicationOpen:t,openApplication:t,applyRuntimeHints:i,clearRuntimeHints:i,closeApplication:r,finalizeApplicationClose:r,prepareAppleRunner:n,configureProviderPortReverse:wa})}function Na(e){return r(e)===`watchos`?_a:e.kind===`simulator`||e.kind===`device`?X:xa}function Pa(e){return r(e)===`watchos`?va:e.kind===`simulator`||e.kind===`device`?X:Sa}function Fa(e){return r(e)===`watchos`?ya:e.kind===`simulator`||e.kind===`device`?X:Ca}function Ia(e){return r(e)!==`watchos`&&o(e)&&e.kind===`simulator`?X:ba}function La(e){return e.appleOs===`watchos`?Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`watchOS app inventory is not supported.`}):e.kind===`device`&&e.iosPhysicalDeviceBackend===`xctest`?Object.freeze({available:!1,reason:`unsupported-device-backend`,hint:`App inventory is available only on CoreDevice-backed physical iOS devices.`}):X}function $(e){return e.kind===`simulator`||e.kind===`device`?X:fa}function Ra(e){let t=hn(e),n=Xi(e),r=async n=>{let r=await t.inspectFacts(n),i=Wr(n),a=Kn(n),c=a.available?await e.screenRecording.apple.availability(n):void 0,l=a.available&&c?.available===!1?Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:c.hint}):a,u=n.appleOs===`watchos`?Z:X,d=s(n)||n.appleOs===`watchos`?Z:X,f=La(n);return Object.freeze({device:r.device,operations:{...r.operations,...i,appState:pa,networkDump:X,screenRecordingStart:l,screenRecordingReattach:l,screenRecordingCleanup:l,...Ua(n),...fe({capture:Ha(n)}),...ye({findText:Va(n)}),...he({setViewport:la}),...me({focus:$(n)}),...Rt(n),...de({type:$(n)}),...se({unsupported:Z,tap:$(n),longPress:$(n),fill:$(n),...o(n)?{tapElementSelector:$(n)}:{}}),...Ne({readTextAtPoint:Ba(n)}),..._i(n),...ji(n),...Ie({capture:jt(n),query:ua}),...Le(za(n)),ensureReady:u,bootTarget:d,bootTargetHeadless:ma,listApps:f,...Ma(n),shutdownTarget:ja(n)}})};return Object.freeze({owner:Y,ownsDevice:e=>e.platform===`apple`,inspectFacts:r,bind:async i=>{let a=await t.bind(i),o=await r(i.device),s=o.operations.screenRecordingStart,c={...a.operations,...Gr({host:e,device:i.device,signal:i.scope.signal}),networkDump:async t=>await yn(e,i.device,t,i.scope.signal),...d(s,()=>qn({host:e,device:i.device,owner:Y,signal:i.scope.signal})),...d(o.operations.audioProbeStart,()=>Ke({host:e.audioProbe.hostCapture,device:i.device,owner:Y})),...d(o.operations.perfFrames,()=>Mt({resolveHost:()=>e.perf.apple,device:i.device,owner:Y})),...d(o.operations.captureSnapshot,()=>Ni(e,{device:i.device,signal:i.scope.signal},n)),...d(o.operations.captureScreenshot,()=>xe({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve})),...d(o.operations.focusPoint,()=>ve({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve})),...Oe({device:i.device,signal:i.scope.signal,facts:o.operations,resolveInteractor:e.localInteractors.resolve}),...d(o.operations.scrollDirection,()=>_e({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve})),...d(o.operations.typeText,()=>be({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve})),...d(o.operations.tapPoint,()=>ce({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve,facts:o.operations,pause:async t=>await e.clock.sleep(t,i.scope.signal)})),...d(o.operations.readTextAtPoint,()=>ue({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve})),...d(o.operations.findText,()=>Pi(e,{device:i.device,signal:i.scope.signal})),...vi({host:e,device:i.device,signal:i.scope.signal}),...Mi({host:e,device:i.device,signal:i.scope.signal}),...d(o.operations.ensureReady,()=>({ensureReady:async()=>await k(e,i.device,i.scope.signal)})),...d(o.operations.bootTarget,()=>({bootTarget:async()=>await k(e,i.device,i.scope.signal)})),...d(o.operations.listApps,()=>({listApps:async e=>{i.scope.signal.throwIfAborted();let{listIosApps:t}=await import(`./app-resolution.js`).then(e=>e.t);return(await t(e.device,e.filter)).map(e=>({id:e.bundleId,name:e.name}))}})),...ie(br({host:e,device:i.device,signal:i.scope.signal,observation:n}),o.operations),...d(o.operations.shutdownTarget,()=>({shutdownTarget:async()=>await e.deviceShutdown.apple.shutdownTarget(i.device,i.scope.signal)}))};return Object.freeze({device:a.device,owner:Y,facts:o,operations:At(c),[Symbol.asyncDispose]:async()=>await a[Symbol.asyncDispose]()})},shutdown:async()=>{await Promise.all([t.shutdown(),n.shutdown()])}})}function za(e){let t=e.iosPhysicalDeviceBackend!==`xctest`&&r(e)!==`watchos`?X:da;return{frames:t,memorySample:t,memorySnapshot:t,nativeCapture:t,profileReport:t}}function Ba(e){return r(e)===`watchos`?ha:e.kind===`simulator`||e.kind===`device`?X:ga}function Va(e){return r(e)===`watchos`?Ea:e.kind===`simulator`||e.kind===`device`?X:Ea}function Ha(e){return r(e)===`watchos`?Oa:e.kind===`simulator`||e.kind===`device`?X:ka}function Ua(e){let t=Va(e);return pe({capture:t,customActions:t.available&&o(e)&&e.kind===`simulator`?X:Da,withoutActiveApp:o(e)?Aa:t})}export{Ra as createApplePlatformRuntime};
1
+ import{D as e,O as t}from"./sdk-contracts.js";import{r as n}from"./sdk-batch-runner.js";import{C as r,T as i,d as a,g as o,l as s,o as c,u as l}from"./sdk-device.js";import{Kt as u,Qt as d,Zt as f}from"./sdk-batch.js";import{c as ee,r as p}from"./diagnostics.js";import{n as m}from"./exec.js";import"./diagnostics2.js";import"./command.js";import{n as te}from"./scoped-provider.js";import{i as ne,n as re,r as ie}from"./ios-snapshot-planning.js";import{t as ae}from"./request.js";import{n as oe,r as se,t as ce}from"./application-lifecycle-runtime.js";import{i as le,t as ue}from"./touch-runtime.js";import{A as de,C as fe,D as pe,G as me,H as he,I as ge,L as _e,N as ve,O as ye,P as be,R as xe,T as Se,U as Ce,V as we,a as Te,b as Ee,d as De,g as Oe,i as ke,j as Ae,m as je,s as Me,t as Ne,v as Pe,w as Fe,x as Ie,z as Le}from"./alert-runtime.js";import{n as Re}from"./audio-probe-runtime.js";import{n as ze}from"./perf-runtime.js";import{a as Be,n as Ve}from"./durable-resource.js";import{n as He,t as Ue}from"./async-lifecycle.js";import{a as We,c as Ge,d as Ke,f as qe,l as Je,n as Ye,o as Xe,s as Ze,t as Qe,u as $e}from"./src7.js";import{n as et,t as tt}from"./screen-recording-completion.js";import{a as nt,i as rt,n as it,r as at,t as ot}from"./stop-sequence.js";import{n as st}from"./screen-recording-runtime.js";import{t as ct}from"./ios-system-surface.js";import{i as lt,r as ut}from"./gesture-admission.js";import{t as dt}from"./interactor-operation-catalog.js";import{a as ft,i as pt,n as mt,r as ht,t as gt}from"./perf-runtime-operation-builder.js";import{t as h}from"./app-log-runtime.js";import{i as _t,r as vt}from"./managed-device-scope.js";import{a as yt,n as bt,o as xt}from"./application-lifecycle-interaction.js";import{a as St}from"./tool-provider.js";import{n as Ct}from"./apps-simctl.js";import{a as wt}from"./simulator.js";import{t as Tt}from"./multitouch-support.js";import{n as g,t as Et}from"./simulator-state.js";import{n as Dt,r as Ot,t as kt}from"./snapshot-process.js";import At from"node:path";import{randomUUID as jt}from"node:crypto";function Mt(e){let t=_t();return Object.freeze(t?{...te({...e},e=>wt(t,e))}:e)}function Nt(e){return at(e)?Object.freeze({available:!0}):a(e)||l(e)&&e.kind===`simulator`?Object.freeze({available:!1,reason:`unsupported-device-backend`,hint:`audio probe capture requires a macOS host.`}):Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`audio is supported for macOS sessions and iOS simulators on macOS hosts; physical iOS devices expose no host audio tap.`})}function Pt(e){let{resolveHost:t,device:n,owner:r}=e;return Object.freeze({...gt({platform:`Apple`,expectedProfileKind:`xctrace`,start:async e=>await t().start(n,r,e),reattach:async e=>await t().reattach(n,e),cleanup:async e=>await t().cleanup(n,e),writeProfileReport:async e=>await t().writeProfileReport(e)}),perfFrames:async({appId:e})=>({metric:e?await pt(t().sampleFrames(n,e)):mt(`Apple`,`bundle ID`),sampling:await t().frameSampling(n)}),perfMemorySample:async({appId:e})=>({metric:e?await pt(t().sampleMemory(n,e)):mt(`Apple`,`bundle ID`),sampling:await t().memorySampling(n)}),perfMemorySnapshot:async({appId:e,kind:r,outPath:i,artifactsDir:a})=>{let o=r??`memgraph`,s={...await t().memorySnapshotSupport(n),androidHprof:!1,heapprofd:!1};if(o!==`memgraph`)return ft(`Apple`,o,s,`Use perf memory snapshot --kind memgraph for supported Apple app sessions.`);if(!e)throw ht();let c=i??At.join(a,`memory-memgraph-${Ft()}.memgraph`);return{artifact:await t().captureMemorySnapshot(n,e,c),support:s,sampling:{method:`xcrun memgraph`,description:`Native Apple memory graph captured for offline inspection.`,defaultKind:`memgraph`,artifactOnly:!0}}}})}function Ft(){return new Date().toISOString().replaceAll(/[:.]/g,`-`)}const _=Object.freeze({available:!0}),v=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),y=zt(`Gestures are supported only for Apple simulators and devices.`),It=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:ut}),Lt=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:lt}),Rt=zt(`scroll is supported only for Apple simulators and devices.`);function zt(e){return Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:e})}function Bt(e){return{...ve({unsupported:Vt(e),plan:Ht(e),directionalFling:Ht(e),multiTouch:Ut(e),targetAuthoredDrag:Wt(e),viewport:Gt(e)}),...de({scroll:Kt(e)})}}function Vt(e){return e.appleOs===`watchos`||e.appleOs===`visionos`?v:y}function Ht(e){return e.appleOs===`watchos`||e.appleOs===`visionos`?v:b(e)?_:y}function Ut(e){if(e.appleOs===`watchos`)return v;if(!b(e))return y;let t=r(e);if(t!==`ios`&&t!==`ipados`){let e=Tt[t];return Object.freeze({available:!1,reason:`unsupported-platform-leaf`,...e===void 0?{}:{hint:e}})}return e.kind===`simulator`?_:It}function Wt(e){return b(e)?(e.appleOs===void 0?e.target!==`desktop`&&e.target!==`tv`:e.appleOs===`ios`||e.appleOs===`ipados`)?_:Lt:y}function Gt(e){return e.appleOs===`watchos`?v:b(e)?_:y}function Kt(e){return b(e)?_:Rt}function b(e){return e.kind===`simulator`||e.kind===`device`}const x=`This command requires a CoreDevice-backed physical iOS device. The selected XCTest backend supports open, close, interactions, snapshots, and screenshots.`;function S(e){return a(e)?`macos`:e.kind===`device`?`ios-device`:`ios-simulator`}const C=Object.freeze({resourceKind:h,version:1,encode:e=>({...e}),decode:e=>!Jt(e.transport)||!Yt(e.backend)||!$t(e.outputPath)||!Zt(e.pidPath)||!Xt(e.transport,e.backend)?qt():{status:`decoded`,descriptor:Object.freeze({transport:e.transport,backend:e.backend,outputPath:e.outputPath,...e.pidPath===void 0?{}:{pidPath:e.pidPath}})}});function qt(){return{status:`invalid`,message:`Invalid Apple app-log descriptor`}}function Jt(e){return e===`apple-log-stream`||e===`coredevice-console`}function Yt(e){return e===`ios-simulator`||e===`ios-device`||e===`macos`}function Xt(e,t){return e===`coredevice-console`?t===`ios-device`:t!==`ios-device`}function Zt(e){return e===void 0||$t(e)}function Qt(e){if(!e.device.appleOs)throw TypeError(`Apple app-log persistence requires an explicit appleOs identity`);return Ve({resourceKind:h,sessionId:e.sessionId,device:{id:e.device.id,family:`apple`,appleOs:e.device.appleOs,kind:e.device.kind,...e.device.target===void 0?{}:{target:e.device.target},...e.device.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.device.iosPhysicalDeviceBackend}},owner:e.owner,fence:e.fence,lifecycle:`open`,descriptor:Be(C,e.descriptor)})}function $t(e){return typeof e==`string`&&e.trim().length>0}const en={message:`iOS physical-device app console capture is not supported by the installed devicectl.`,hint:`This devicectl does not expose process launch --console. Markers can still be written to app.log, but app output is not being captured. Use an iOS simulator for agent-device app logs or inspect physical-device logs in Console.app/Xcode until this Xcode toolchain exposes scriptable console capture.`},tn={message:`Could not verify iOS physical-device app console capture support.`,hint:`Retry logs clear --restart. If the probe keeps failing, run logs doctor and inspect the request diagnostics for the devicectl help command.`};async function nn(e,t){try{let n=await e.appleTools.run({tool:`devicectl`,args:[`device`,`process`,`launch`,`--help`],allowFailure:!0,timeoutMs:5e3},t),r=n.stderr.trim()||void 0;if(n.exitCode!==0)return{supported:!1,reason:`probe-failed`,stderr:r};let i=`${n.stdout}\n${n.stderr}`;return/\bUSAGE:\s+devicectl device process launch\b/i.test(i)&&/--console\b/.test(i)&&/--terminate-existing\b/.test(i)?{supported:!0,...r?{stderr:r}:{}}:{supported:!1,reason:`unsupported`,...r?{stderr:r}:{}}}catch(e){if(t?.aborted)throw t.reason;return{supported:!1,reason:`probe-failed`,...e instanceof Error?{stderr:e.message}:{}}}}async function rn(e,t,n,r){let i={},o=n?[]:[`No app bundle is tracked in this session. Run open <app> first for app-scoped logs.`];if(a(t))i.logAvailable=!!await e.commands.which(`log`);else if(t.kind===`simulator`)i.simctlAvailable=await nt(async()=>rt(await e.appleTools.run({tool:`simctl`,args:[`help`],allowFailure:!0},r)),r);else if(t.iosPhysicalDeviceBackend===`xctest`)i.devicectlAvailable=!1,i.devicectlConsoleCapture=!1,o.push(x);else{i.devicectlAvailable=await nt(async()=>rt(await e.appleTools.run({tool:`devicectl`,args:[`--version`],allowFailure:!0},r)),r);let t=await nn(e,r);if(i.devicectlConsoleCapture=t.supported,!t.supported){let e=t.reason===`unsupported`?en:tn;o.push(`${e.message} ${e.hint}`)}}return{backend:S(t),checks:i,notes:o}}function an(e,t){let n=cn(e),r=[`subsystem == "${n}"`,`subsystem CONTAINS "${n}"`,`processImagePath ENDSWITH[c] "/${n}"`,`senderImagePath ENDSWITH[c] "/${n}"`];if(t){let e=cn(t);r.push(`process == "${e}"`,`processImagePath ENDSWITH[c] "/${e}"`,`senderImagePath ENDSWITH[c] "/${e}"`,`processImagePath CONTAINS[c] "/${e}.app/"`,`senderImagePath CONTAINS[c] "/${e}.app/"`)}return r.join(` OR `)}function on(e){return[...e.simulatorSetPath?[`simctl`,`--set`,e.simulatorSetPath]:[`simctl`],`spawn`,e.deviceId,`log`,`stream`,`--style`,`compact`,`--level`,`info`,`--predicate`,an(e.appBundleId,e.executableName)]}function sn(e,t){return[`devicectl`,`device`,`process`,`launch`,`--device`,e,`--console`,`--terminate-existing`,t]}function cn(e){return e.replaceAll(`\\`,String.raw`\\`).replaceAll(`"`,String.raw`\"`)}async function ln(e,t,n,r,i){un(t),Xe(e,n);let a=S(t),o=await fn(e,t,n.appBundleId,i),s=new Ue,c=!1;try{let l=await e.outputs.openAppend(n.outputPath);s.defer(async()=>{c||await l[Symbol.asyncDispose]()}),i?.throwIfAborted();let u=await dn(e,t,o,l,n.pidPath,i);s.defer(async()=>{c||await u[Symbol.asyncDispose]()});let d=mn(e,u,l,a,n.outputPath),f={transport:a===`ios-device`?`coredevice-console`:`apple-log-stream`,backend:a,outputPath:n.outputPath,...n.pidPath===void 0?{}:{pidPath:n.pidPath}},ee=qe(d,Qt({sessionId:n.sessionId,device:t,owner:r,fence:n.fence,descriptor:f}));return c=!0,ee}finally{await s[Symbol.asyncDispose]()}}function un(t){if(t.appleOs===`watchos`)throw new e(`UNSUPPORTED_PLATFORM`,`watchOS app logs are not supported`);if(l(t)&&t.kind===`device`&&t.iosPhysicalDeviceBackend===`xctest`)throw new e(`UNSUPPORTED_OPERATION`,x,{hint:x})}async function dn(t,n,r,i,a,o){if(l(n)&&n.kind===`device`){let n=await nn(t,o);if(!n.supported){let t=n.reason===`unsupported`?en:tn;throw new e(n.reason===`unsupported`?`UNSUPPORTED_OPERATION`:`COMMAND_FAILED`,t.message,{backend:`ios-device`,hint:t.hint,stderr:n.stderr})}}return o?.throwIfAborted(),await t.processes.start({command:{kind:`host`,request:r},output:i,...a?{markerPath:a}:{}})}async function fn(e,t,n,r){if(a(t))return{executable:`log`,args:[`stream`,`--style`,`compact`,`--predicate`,an(n)],allowFailure:!0};if(t.kind===`device`)return{executable:`xcrun`,args:sn(t.id,n),allowFailure:!0};let i=await pn(e,t,n,r);return{executable:`xcrun`,args:on({deviceId:t.id,appBundleId:n,executableName:i,simulatorSetPath:t.simulatorSetPath}),allowFailure:!0}}async function pn(e,t,n,r){let i=t.simulatorSetPath?[`--set`,t.simulatorSetPath]:[],a=await e.appleTools.run({tool:`simctl`,args:[...i,`get_app_container`,t.id,n,`app`],allowFailure:!0,timeoutMs:4e3},r),o=a.exitCode===0?a.stdout.trim():``;if(!o)return;let s=await e.commands.run({executable:`plutil`,args:[`-extract`,`CFBundleExecutable`,`raw`,`-o`,`-`,At.join(o,`Info.plist`)],allowFailure:!0,timeoutMs:4e3},r);return s.exitCode===0&&s.stdout.trim()||void 0}function mn(e,t,n,r,i){let a=e.clock.now(),o=`active`;t.wait.then(e=>{o=e.exitCode===0?`ended`:`failed`},()=>{o=`failed`});let s;return $e({inspect:()=>({backend:r,state:o,startedAt:a}),finish:async()=>s??=(async()=>(await hn([async()=>await t.terminate(),async()=>await t.wait.then(()=>void 0),async()=>await t[Symbol.asyncDispose](),async()=>await n[Symbol.asyncDispose]()])).length>0?(o=`failed`,{status:`cleanup-pending`,reason:`transport-failed`,message:`Apple app-log cleanup did not settle every owned resource`}):(o=`ended`,{status:`completed`,result:{backend:r,outputPath:i,completedAt:e.clock.now()}}))()})}async function hn(e){let t=[];for(let n of e)try{await n()}catch(e){t.push(e)}return t}const w=u(`apple`),T=Object.freeze({available:!0});function gn(t){return Object.freeze({owner:w,ownsDevice:e=>e.platform===`apple`,inspectFacts:async e=>E(e),bind:async n=>{if(n.intent.kind===`exact-owner`&&!f(n.intent.owner,w))throw new e(`UNSUPPORTED_OPERATION`,`Apple app-log owner identity does not match`);return _n(t,n.device,n.scope.signal)},shutdown:async()=>void 0})}function _n(t,n,r){if(n.platform!==`apple`)throw new e(`UNSUPPORTED_PLATFORM`,`Apple app-log owner cannot bind ${n.platform}`);let i=Ke({codec:C,reattach:async(e,r)=>e.backend!==S(n)||!We(t,r.sessionId,e)?{status:`unreattachable`,reason:`descriptor-invalid`,message:`Apple app-log descriptor does not match the bound device or owning session`}:await Ge(t,e.pidPath),cleanup:async(e,r)=>e.backend===S(n)&&We(t,r.sessionId,e)?await Ze(t,e.pidPath):{status:`cleanup-pending`,reason:`ownership-fence-lost`,message:`Apple app-log descriptor does not match the bound device or owning session`}}),a=Object.freeze({appLogInspect:async()=>({backend:S(n)}),appLogDoctor:async({appBundleId:e})=>await rn(t,n,e,r),appLogStart:async e=>await ln(t,n,e,w,r),...i});return Object.freeze({device:n,owner:w,facts:E(n),operations:a,[Symbol.asyncDispose]:async()=>void 0})}function E(e){if(e.appleOs===`watchos`)return vn(e);let t=l(e)&&e.kind===`device`&&e.iosPhysicalDeviceBackend===`xctest`?{available:!1,reason:`unsupported-device-backend`,hint:x}:T;return Object.freeze({device:{family:`apple`,appleOs:e.appleOs,kind:e.kind,...e.target===void 0?{}:{target:e.target},...e.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.iosPhysicalDeviceBackend},providerMode:`local`},operations:{appLogInspect:t,appLogDoctor:t,appLogStart:t,appLogReattach:T,appLogCleanup:T}})}function vn(e){let t=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`watchOS app logs are not supported.`});return Object.freeze({device:{family:`apple`,appleOs:`watchos`,kind:e.kind,...e.target===void 0?{}:{target:e.target},providerMode:`local`},operations:{appLogInspect:t,appLogDoctor:t,appLogStart:t,appLogReattach:t,appLogCleanup:t}})}async function yn(e,t,n,r){let i=S(t),a=await e.appLogs.readRecent(n.sessionId,n.maxScanLines),o=Ye(a.text,{...n,path:a.path,exists:a.exists,lineNumberOffset:a.skippedLines,backend:i}),s=[];if(xn(t,n,o.dump)){let i=await Sn(e,t,n,a.path,r);i&&(o=bn(s,o,i,n.maxEntries))}return Tn(s,t,n),wn(s,o.dump),o.dump.entries.length===0&&s.push(En(t)),Object.freeze({source:`app-log`,backend:i,dump:o.dump,notes:Object.freeze(s)})}function bn(e,t,n,r){let i=n.scan.dump.entries.length;return i===0&&(n.scan.dump.unnamedRequests??0)===0?(n.lineCount>0&&e.push(`Recovered ${n.lineCount} recent iOS simulator app log lines from simctl log show, but none looked like HTTP traffic. This app may not emit request URLs, status, or timing into Unified Logging for this repro window.`),t):(i>0&&e.push(`Recovered ${i} iOS simulator HTTP entr${i===1?`y`:`ies`} from simctl log show (${n.lineCount} app log lines scanned).`),Qe(n.scan,t,r))}function xn(e,t,n){return l(e)&&e.kind===`simulator`&&!!t.appBundleId&&n.entries.length===0}async function Sn(e,t,n,r,i){let a=[...t.simulatorSetPath?[`--set`,t.simulatorSetPath]:[],`spawn`,t.id,`log`,`show`,`--style`,`compact`,`--info`,`--predicate`,Cn(n.appBundleId)],o=n.appLogSnapshot?.startedAt;a.push(...typeof o==`number`&&Number.isFinite(o)&&o>0?[`--start`,`@${Math.floor(o/1e3)}`]:[`--last`,`5m`]);let s=await e.appleTools.run({tool:`simctl`,args:a,allowFailure:!0,timeoutMs:4e3},i);if(s.exitCode!==0||!s.stdout.trim())return;let c=s.stdout.split(`
2
+ `).map(e=>e.trimEnd()).filter(e=>e.trim()&&!e.trim().startsWith(`Timestamp Ty Process[PID:TID]`));if(c.length!==0)return{scan:Ye(`${c.join(`
3
+ `)}\n`,{...n,path:`${r} (simctl log show recovery)`,exists:!0,backend:`ios-simulator`}),lineCount:c.length}}function Cn(e){let t=e.replaceAll(`\\`,String.raw`\\`).replaceAll(`"`,String.raw`\"`);return[`subsystem == "${t}"`,`subsystem CONTAINS "${t}"`,`processImagePath ENDSWITH[c] "/${t}"`,`senderImagePath ENDSWITH[c] "/${t}"`].join(` OR `)}function wn(e,t){let n=t.entries.filter(e=>e.pathUnavailable).length,r=t.unnamedRequests??0,i=n+r;if(i===0)return;let a=[`${i} request${i===1?``:`s`} reused a keep-alive connection, so CFNetwork logged no request URL.`];n>0&&a.push(`${n} listed against the origin the connection was opened for, without a path.`),r>0&&a.push(`${r} opened before this scan window and are missing from the entries entirely; scan more lines, or run logs clear --restart before the repro.`),a.push(`Absence of an endpoint in this dump does not prove it was not called.`),e.push(a.join(` `))}function Tn(e,t,n){n.appLogSnapshot?n.appLogSnapshot.state!==`active`&&e.length===0&&e.push(l(t)&&t.kind===`simulator`?`Session app log stream is inactive. The iOS simulator recovery path scanned recent simctl log history, but a fresh logs clear --restart window is still the most reliable repro loop.`:`Session app log stream is inactive. Run logs clear --restart, reproduce the request window again, then rerun network dump.`):e.push(`Capture uses the session app log file. For fresh traffic, run logs clear --restart before reproducing requests.`)}function En(e){return l(e)&&e.kind===`simulator`?`No HTTP(s) entries were found in recent iOS simulator app logs. If the app only emits non-HTTP diagnostics, inspect logs path or add app-side URLSession/network logging for per-request timing and payload details.`:l(e)?`No HTTP(s) entries were found in recent iOS device app logs. iOS network dump only sees what the app emits into Unified Logging for this process.`:`No HTTP(s) entries were found in recent session app logs.`}async function Dn(e){let{host:n,snapshot:r,targetLabel:i,recorderWarning:a,nativePathDisposition:o}=e,s=r.invalidatedReason?{recorder:`lost`,why:`owner-session-lost`}:e.stopObservation;if(r.invalidatedReason&&!r.showTouches)throw Error(`recording invalidated: ${r.invalidatedReason}`);let c;try{c=await n.screenRecording.finalize.complete({outputPath:r.outPath,showTouches:!r.invalidatedReason&&r.showTouches,gestureEvents:r.gestureEvents,exportQuality:r.exportQuality??`medium`,targetLabel:i})}catch(e){throw t(e,`COMMAND_FAILED`)}let l=[...c.warning?[c.warning]:[],...a?[a]:[]];return tt(r,{...c,...l.length>0?{warning:l.join(` `)}:{},...r.invalidatedReason?{overlayWarning:`overlay unavailable: ${r.invalidatedReason}`}:{}},{stopObservation:s,...o===void 0?{}:{nativePathDisposition:o}})}async function On(e){let{host:t,snapshot:n,targetLabel:r,collectedPath:i,exportPath:a,nativePath:o}=e;if(n.invalidatedReason&&!n.showTouches)throw Error(`recording invalidated: ${n.invalidatedReason}`);let s;try{await t.screenRecording.outputs.copy({from:i,to:a}),s=await kn(()=>t.screenRecording.finalize.complete({outputPath:a,showTouches:!n.invalidatedReason&&n.showTouches,gestureEvents:n.gestureEvents,exportQuality:n.exportQuality??`medium`,targetLabel:r}))}catch(e){throw await t.screenRecording.outputs.remove(a),e}return{...s,...n.invalidatedReason?{overlayWarning:`overlay unavailable: ${n.invalidatedReason}`}:{},nativePathDisposition:await t.screenRecording.outputs.remove(o)===`removed`?`retired`:`retirable`}}async function kn(e){try{return await e()}catch(e){throw t(e,`COMMAND_FAILED`)}}const D=Object.freeze({resourceKind:st,version:1,encode:e=>e.backend===`simctl`?{backend:e.backend,outputPath:e.outputPath,processes:e.processes.map(e=>({...e}))}:{backend:e.backend,outputPath:e.outputPath,appBundleId:e.appBundleId,runnerSessionId:e.runnerSessionId,runnerAuthority:e.runnerAuthority,...e.remotePath===void 0?{}:{remotePath:e.remotePath}},decode:e=>In(e)});function An(e){let{device:t,owner:n,input:r,descriptor:a}=e;return Ve({resourceKind:st,sessionId:r.sessionId,device:i(t),owner:n,fence:r.fence,lifecycle:`open`,descriptor:Be(D,a)})}async function jn(e,t,n,r){let i=D.decode(n);return i.status!==`decoded`||!Un(t,i.descriptor)?{status:`cleanup-pending`,reason:`manual-recovery-required`}:i.descriptor.backend===`simctl`?await Mn(e,i.descriptor.processes,r):await Pn(e,t,i.descriptor)}async function Mn(e,t,n){let r=await Promise.all(t.map(async t=>await e.screenRecording.apple.inspectProcess(t)));if(r.includes(`ownership-lost`))return{status:`cleanup-pending`,reason:`ownership-fence-lost`};if(r.every(e=>e===`missing`))return n!==void 0&&e.screenRecording.ownedProcesses.clear(Nn(n)),{status:`already-missing`};let i=await Promise.all(t.flatMap((t,n)=>r[n]===`owned-alive`?[e.screenRecording.apple.terminateProcess(t)]:[]));return i.includes(`ownership-lost`)?{status:`cleanup-pending`,reason:`ownership-fence-lost`}:(n!==void 0&&e.screenRecording.ownedProcesses.clear(Nn(n)),i.every(e=>e===`already-missing`)?{status:`already-missing`}:{status:`cleaned`})}function Nn(e){return{kind:`session`,sessionId:e}}async function Pn(e,t,n){try{let r=await e.screenRecording.apple.inspectRunner(t,n.runnerSessionId,n.runnerAuthority);return r===`missing`?{status:`already-missing`}:r===`ownership-lost`?{status:`cleanup-pending`,reason:`ownership-fence-lost`}:(await e.screenRecording.apple.runRunner(t,{kind:`stop`,appBundleId:n.appBundleId,runnerSessionId:n.runnerSessionId,runnerAuthority:n.runnerAuthority}),{status:`cleaned`})}catch(e){return{status:`cleanup-pending`,reason:`transport-failed`,message:e instanceof Error?e.message:`Apple recording cleanup failed`}}}async function Fn(e,t,n){let r=D.decode(n);if(r.status!==`decoded`)return{status:`unreattachable`,reason:`descriptor-invalid`,message:r.message};if(!Un(t,r.descriptor))return{status:`unreattachable`,reason:`descriptor-invalid`,message:`Apple screen-recording descriptor does not match the bound device.`};let i=r.descriptor.backend===`simctl`?await Promise.all(r.descriptor.processes.map(async t=>await e.screenRecording.apple.inspectProcess(t))):[await e.screenRecording.apple.inspectRunner(t,r.descriptor.runnerSessionId,r.descriptor.runnerAuthority)];return i.every(e=>e===`missing`)?{status:`missing`}:{status:`unreattachable`,reason:`transport-not-reattachable`,message:i.includes(`ownership-lost`)?`Apple recording ownership no longer matches the durable descriptor.`:`Apple screen recordings require exact cleanup after daemon restart.`}}function In(e){return typeof e.outputPath!=`string`||e.outputPath.length===0?O():e.backend===`simctl`?Ln(e,e.outputPath):e.backend===`runner`?Rn(e,e.outputPath):O()}function Ln(e,t){let n=Wn(e.processes);return n?{status:`decoded`,descriptor:Object.freeze({backend:`simctl`,outputPath:t,processes:n})}:O()}function Rn(e,t){return!zn(e.appBundleId)||!zn(e.runnerSessionId)||!Bn(e.runnerAuthority)||!Vn(e.remotePath)?O():{status:`decoded`,descriptor:Object.freeze({backend:`runner`,outputPath:t,appBundleId:e.appBundleId,runnerSessionId:e.runnerSessionId,runnerAuthority:e.runnerAuthority,...e.remotePath===void 0?{}:{remotePath:e.remotePath}})}}function zn(e){return typeof e==`string`&&e.length>0}function Bn(e){return e===`local-lease`||e===`scoped-provider`}function Vn(e){return e===void 0||Hn(e)}function Hn(e){return typeof e==`string`&&/^tmp\/agent-device-recording-\d+\.mp4$/.test(e)}function Un(e,t){return e.kind===`simulator`?t.backend===`simctl`:t.backend===`runner`?e.appleOs===`macos`?t.remotePath===void 0:l(e)?t.remotePath!==void 0&&Hn(t.remotePath):t.remotePath===void 0:!1}function Wn(e){if(!Array.isArray(e)||e.length===0)return;let t=e.filter(e=>typeof e==`object`&&!!e&&Number.isInteger(e.pid)&&(e.pid??0)>0&&typeof e.startTime==`string`&&e.startTime.length>0&&typeof e.command==`string`&&e.command.length>0);return t.length===e.length?Object.freeze([...t]):void 0}function O(){return{status:`invalid`,message:`Invalid Apple screen-recording descriptor`}}async function Gn(e,t,n){if(e.kind!==`simulator`||t.scope!==`app`)return;let r=t.activeSessionApp?.bundleId;if(!r)throw TypeError(`App-scoped recording requires an active app session; open the app under test before recording.`);if(await n(r))throw TypeError(`App-scoped recording requires a real application session; open the app under test before recording.`)}function Kn(e){return e.appleOs===`watchos`?ir(`unsupported-platform-leaf`,`watchOS recording is not supported.`):l(e)&&e.kind===`device`&&e.iosPhysicalDeviceBackend===`xctest`?ir(`unsupported-device-backend`,`This command requires a CoreDevice-backed physical iOS device. The selected XCTest backend supports open, close, interactions, snapshots, and screenshots.`):Object.freeze({available:!0})}function qn(e){let{host:t,device:n,owner:r,signal:i}=e;return Object.freeze({screenRecordingStart:async e=>await Jn({host:t,device:n,owner:r,input:e,signal:i}),screenRecordingReattach:async e=>await Fn(t,n,e.envelope.descriptor.body),screenRecordingCleanup:async e=>await jn(t,n,e.envelope.descriptor.body,e.envelope.sessionId)})}async function Jn(e){return e.signal.throwIfAborted(),e.device.kind===`simulator`?await Yn(e):await Xn(e)}async function Yn(e){let{host:t,device:n,owner:r,input:i,signal:a}=e;await Gn(n,i,t.screenRecording.apple.isRunnerBundleId);let o=i.activeSessionApp?await t.screenRecording.apple.captureClockAnchor(n,i.activeSessionApp.bundleId,a):void 0,s=it(i.outputPath);await t.screenRecording.outputs.prepare(s);let c=await t.screenRecording.apple.startSimulator(n,s,a),l=c.markers;if(!l||l.length===0)throw await k(c).catch(()=>{}),Error(`simctl recordVideo did not expose durable process identity`);try{a.throwIfAborted(),t.screenRecording.ownedProcesses.replace({kind:`session`,sessionId:i.sessionId},l.map(e=>({...e,purpose:`simctl-screen-recording`})))}catch(e){try{t.screenRecording.ownedProcesses.clear({kind:`session`,sessionId:i.sessionId})}catch{}throw await k(c).catch(()=>{}),e}let u,d,f=async()=>{await c.terminate();let e=await c.wait;return d=e,u=Qn(e),t.screenRecording.ownedProcesses.clear({kind:`session`,sessionId:i.sessionId}),{observation:{recorder:`confirmed`},...u===void 0?{}:{warning:`${u} before record stop; the video covers only what the recorder wrote before it stopped.`}}};return nr({device:n,owner:r,input:i,descriptor:{backend:`simctl`,outputPath:s,processes:l},snapshot:rr(i,`simctl recordVideo`,{},o),finish:(e,n)=>ot({snapshot:e,progress:n,steps:{stop:f,collect:async e=>{try{await t.screenRecording.outputs.copy({from:s,to:e}),await t.screenRecording.finalize.sniff({outputPath:e})}catch(e){throw $n(e,u,d)}},finalize:async({collectedPath:n,exportPath:r})=>{try{return await On({host:t,snapshot:e,targetLabel:`iOS recording`,collectedPath:n,exportPath:r,nativePath:s})}catch(e){throw $n(e,u,d)}},discard:async e=>{await t.screenRecording.outputs.remove(e)}}}),cleanup:async()=>{let e=await tr(c);return(e.status===`cleaned`||e.status===`already-missing`)&&t.screenRecording.ownedProcesses.clear({kind:`session`,sessionId:i.sessionId}),e}})}async function Xn(e){let{host:t,device:n,owner:r,input:i,signal:a}=e,o=i.activeSessionApp?.bundleId;if(!o)throw TypeError(`Apple runner recording requires an active app session identity`);await t.screenRecording.outputs.prepare(i.outputPath);let s=await t.screenRecording.apple.runRunner(n,{kind:`start`,appBundleId:o,outputPath:i.outputPath,...i.fps===void 0?{}:{fps:i.fps}},a);if(!s.runnerSessionId||!s.runnerAuthority)throw Error(`Apple runner recording did not expose durable session ownership`);let c={runnerSessionId:s.runnerSessionId,runnerAuthority:s.runnerAuthority},l,u=()=>(l??=Zn(()=>t.screenRecording.apple.runRunner(n,{kind:`stop`,appBundleId:o,...c}).then(()=>void 0)).catch(e=>{throw l=void 0,e}),l);if(!er(n,s.remotePath))throw await u().catch(()=>{}),Error(`Apple runner recording did not expose coherent durable media ownership`);try{a.throwIfAborted()}catch(e){throw await u().catch(()=>{}),e}return nr({device:n,owner:r,input:i,descriptor:{backend:`runner`,outputPath:i.outputPath,appBundleId:o,...c,...s.remotePath===void 0?{}:{remotePath:s.remotePath}},snapshot:rr(i,`runner AVAssetWriter`,s),finish:async e=>(await u(),s.remotePath!==void 0&&await t.screenRecording.apple.retrieveRunnerRecording(n,s.remotePath,e.outPath),await Dn({host:t,snapshot:e,targetLabel:n.appleOs===`macos`?`macOS recording`:`iOS recording`,stopObservation:{recorder:`confirmed`},...s.remotePath===void 0?{}:{nativePathDisposition:`retirable`}})),cleanup:async()=>(await u(),{status:`cleaned`})})}async function Zn(e){try{return await e()}catch(e){throw t(e,`COMMAND_FAILED`)}}function Qn(e){if(e.exitCode!==0)return e.signal?`simctl recordVideo was killed by ${e.signal}`:`simctl recordVideo exited with code ${e.exitCode}`}function $n(n,r,i){let a=t(n,`COMMAND_FAILED`);return r===void 0||i===void 0||a.details?.reason!==`recording-output-unplayable`?n:new e(a.code,`${a.message}; ${r}`,m(i,{...a.details??{},...i.signal===void 0?{}:{signal:i.signal},retriable:!1,hint:`The recorder exited before record stop, so the next record stop reads the same file. Close this session to release the device, then record again.`}))}function er(e,t){return e.appleOs===`macos`||!l(e)?t===void 0:t!==void 0&&/^tmp\/agent-device-recording-\d+\.mp4$/.test(t)}async function k(e){return await e.terminate(),await e.wait}async function tr(e){try{return await k(e),{status:`cleaned`}}catch(e){return{status:`cleanup-pending`,reason:`transport-failed`,message:e instanceof Error?e.message:`Apple simulator cleanup failed`}}}function nr(e){let{device:t,owner:n,input:r,descriptor:i,snapshot:a,finish:o,cleanup:s}=e,c=et(a,{finish:o,forceCleanup:s});return Object.freeze({pendingHandle:new He(c),envelope:An({device:t,owner:n,input:r,descriptor:i})})}function rr(e,t,n={},r){let i=Date.now();return Object.freeze({backend:t,outPath:e.outputPath,...e.clientOutputPath===void 0?{}:{clientOutPath:e.clientOutputPath},startedAt:i,scope:e.scope,showTouches:e.showTouches,recordOnlySession:e.recordOnlySession,...e.activeSessionApp===void 0?{}:{activeSessionApp:e.activeSessionApp},...e.exportQuality===void 0?{}:{exportQuality:e.exportQuality},gestureEvents:[],...r===void 0?{}:{gestureClockOriginAtMs:r.wallClockAtMs,gestureClockOriginUptimeMs:r.uptimeMs},...n.recorderStartUptimeMs===void 0?{}:{gestureClockOriginAtMs:i,gestureClockOriginUptimeMs:n.recorderStartUptimeMs,runnerStartedAtUptimeMs:n.recorderStartUptimeMs},...n.runnerSessionId===void 0?{}:{runnerSessionId:n.runnerSessionId}})}function ir(e,t){return Object.freeze({available:!1,reason:e,hint:t})}const ar=15e3;async function A(e,t,n,r={}){return n.throwIfAborted(),await vt(t)||a(t)?{...t,booted:!0}:t.kind===`device`?(await e.deviceReadiness.applePhysical.ensureConnected(t,n),{...t,booted:!0}):t.kind===`simulator`?((await or(e,t)?`Booted`:await ur(e,t,n))!==`Booted`&&(r.onColdBootStart?.(),e.deviceReadiness.appleAutomation.keepHot(t),await sr(e,t,n,r.deadlineAtMs),await dr(e,n)),e.deviceReadiness.appleAutomation.keepHot(t),e.deviceReadiness.appleAutomation.markBooted(t),{...t,booted:!0}):{...t,booted:!0}}async function or(e,t){try{return await e.deviceReadiness.appleAutomation.wasRecentlyObservedBooted(t)}catch{return!1}}async function sr(e,t,n,r=Date.now()+12e4){let i=!1;try{i=await cr(e,t,n,r),await lr(e,t,n,r)}catch(a){throw i&&n.aborted&&fr(e,t),n.throwIfAborted(),Date.now()>=r?M(t,a):a}}async function cr(t,n,r,i){let a=await t.appleTools.run({tool:`simctl`,args:g(n,[`boot`,n.id]),allowFailure:!0,timeoutMs:j(i,n)},r),o=`${a.stdout}\n${a.stderr}`.toLowerCase(),s=o.includes(`already booted`)||o.includes(`current state: booted`);if(a.exitCode!==0&&!s)throw new e(`COMMAND_FAILED`,`simctl boot failed`,{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode});return!s}async function lr(t,n,r,i){ae({type:`command`,status:`progress`,message:`Waiting for the Simulator to finish booting...`});let a=await t.appleTools.run({tool:`simctl`,args:g(n,[`bootstatus`,n.id,`-b`]),allowFailure:!0,timeoutMs:j(i,n)},r);if(a.exitCode!==0)throw new e(`COMMAND_FAILED`,`simctl bootstatus failed`,{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode});if(await Et(t.appleTools,n,r,Math.min(ar,j(i,n)))!==`Booted`)throw new e(`COMMAND_FAILED`,`Simulator is still booting`,{deviceId:n.id});if(Date.now()>=i)throw M(n)}function j(e,t){let n=e-Date.now();if(n<=0)throw M(t);return n}function M(t,n){return new e(`COMMAND_FAILED`,`Simulator did not finish booting within the startup budget`,{reason:`boot_timeout`,deviceId:t.id,hint:`The Simulator keeps booting in the background; a first boot can take several minutes. Retry once it is up, or pass a larger --timeout.`},n instanceof Error?n:void 0)}async function ur(e,t,n){return await Et(e.appleTools,t,n,ar)}async function dr(e,t){await e.commands.run({executable:`open`,args:[`-a`,`Simulator`],allowFailure:!0,timeoutMs:1e4},t)}function fr(e,t){e.appleTools.run({tool:`simctl`,args:g(t,[`shutdown`,t.id]),allowFailure:!0}).catch(()=>{})}const pr=Object.freeze({resolveOpenTarget:`simulator`,prepareApplicationOpen:`simulator`,openApplication:`simulator`,applyRuntimeHints:`simulator`,clearRuntimeHints:`simulator`,closeApplication:`simulator`,finalizeApplicationClose:`simulator`,prepareAppleRunner:`runner`,configureProviderPortReverse:`simulator`,ensureReady:`simulator`,bootTarget:`simulator`,bootTargetHeadless:`simulator`,shutdownTarget:`simulator`,listApps:`simulator`,deployApp:`simulator`,materializeAppSource:`simulator`,deployMaterializedApp:`simulator`,sendPushNotification:`simulator`,appState:`simulator`,appLogStart:`simulator`,appLogInspect:`simulator`,appLogDoctor:`simulator`,appLogReattach:`simulator`,appLogCleanup:`simulator`,networkDump:`simulator`,audioProbeStart:`simulator`,audioProbeQuery:`simulator`,audioProbeReattach:`simulator`,audioProbeCleanup:`simulator`,readClipboard:`simulator`,writeClipboard:`simulator`,setSetting:`simulator`,captureSnapshot:`simulator`,captureSnapshotWithoutActiveApp:`simulator`,captureSnapshotWithCustomActions:`runner`,captureScreenshot:`simulator`,findText:`runner`,readTextAtPoint:`runner`,tapPoint:`runner`,tapRef:`runner`,tapElementSelector:`runner`,fillPoint:`runner`,fillRef:`runner`,longPressPoint:`runner`,hoverPoint:`runner`,hoverRef:`runner`,focusPoint:`runner`,typeText:`runner`,scrollDirection:`runner`,performGesturePlan:`runner`,performMultiTouchGesturePlan:`runner`,performTargetAuthoredDrag:`runner`,performDirectionalFlingPlan:`runner`,gestureViewport:`runner`,setViewport:`runner`,back:`runner`,home:`runner`,setOrientation:`runner`,appSwitcher:`runner`,actionButton:`runner`,tvRemote:`runner`,keyboardDismiss:`runner`,keyboardEnter:`runner`,keyboardStatus:`runner`,triggerAppEvent:`runner`,readAlert:`runner`,awaitAlert:`runner`,acceptAlert:`runner`,dismissAlert:`runner`,perfFrames:`runner`,perfMemorySample:`runner`,perfMemorySnapshot:`runner`,perfNativeCaptureStart:`runner`,perfNativeCaptureReattach:`runner`,perfNativeCaptureCleanup:`runner`,perfProfileReport:`runner`,screenRecordingStart:`runner`,screenRecordingReattach:`runner`,screenRecordingCleanup:`runner`});function mr(e){return e===void 0?`possible`:e.some(e=>pr[e]===`runner`)?`required`:`none`}const hr=new Map([[`application-element-missing`,5e3],[`application-server-unavailable`,5e3],[`foreground-owner-unverified`,1e3],[`foreground-owner-changed`,1e3]]);function N(e){return e.platform===`apple`&&e.appleOs===`ios`&&e.kind===`simulator`}function gr(e){let t=ne(ie({depth:1,interactiveOnly:!0}));return Object.freeze({awaitObservable:async(n,r,i)=>{if(!N(n))return`not-eligible`;let a;for(;;){let o=await e.resolveTarget(n,r,i).catch(()=>void 0);if(i.throwIfAborted(),!o)return`unobservable`;if(e.isBridgeDisabled(o))return p({level:`debug`,phase:`ios_launch_observation_skipped`,data:{reason:`circuit-disabled`,deviceId:n.id,generation:o.generation}}),`unobservable`;let s=await e.source.acquire({target:o,hint:t,signal:i});if(s.stage!==`failed`)return`observable`;i.throwIfAborted();let c=hr.get(s.failure.code);if(c===void 0)return`unobservable`;let l=e.clock.now();if(a=Math.min(a??1/0,l+c),l>=a)return`unobservable`;await e.clock.sleep(Math.min(150,a-l),i)}}})}function _r(e,t,n){let r=n&&N(e),i=r?mr(t.execution.plannedOperations):void 0,a=l(e)&&t.surface===`app`&&t.positionals.length>0&&!!t.appBundleId&&i!==`none`;return{...i?{runnerDemand:i}:{},shouldPrewarmRunner:a,awaitPrewarmAfterOpen:t.relaunch&&!r}}function vr(e,t,n,r){r.runnerDemand===`none`&&e.appleApplications.releaseSpeculativeRunner(t.device,n.execution).catch(()=>{})}async function yr(e,t,n,r,i,a){let o=Date.now();r&&N(t.device)&&i&&n.appBundleId&&(a.postOpenObservation=await i.awaitObservable(t.device,n.appBundleId,t.signal)),r&&a.postOpenObservation!==`observable`&&await e.clock.sleep(300,t.signal),a.postOpenSettleDurationMs=Math.max(0,Date.now()-o)}function br(e){let t=bt({device:e.device,signal:e.signal,resolveInteractor:e.host.localInteractors.resolve});return Object.freeze({resolveOpenTarget:async t=>await e.host.appleApplications.resolveOpenTarget(e.device,t),prepareApplicationOpen:async t=>{await A(e.host,e.device,e.signal,{deadlineAtMs:t.execution.startupDeadlineAtMs,onColdBootStart:t.prewarmRunnerOnColdBoot?()=>{e.host.appleApplications.prewarmRunnerCache(e.device,t.execution,e.signal).catch(()=>{})}:void 0})},openApplication:async n=>await xr(e.host,t,n,e.observation),applyRuntimeHints:async t=>await e.host.appleApplications.applyRuntimeHints(e.device,t),clearRuntimeHints:async t=>await e.host.appleApplications.clearRuntimeHints(e.device,t),closeApplication:async n=>await jr(e.host,t,n),finalizeApplicationClose:async t=>await Mr(e.host,e.device,e.signal,t),prepareAppleRunner:async t=>await Nr(e.host,e.device,e.signal,t),configureProviderPortReverse:Rr})}async function xr(e,t,n,r){let i={},a=P(t.device),o=Pr(e,t,n,i),s=_r(t.device,n,a);s.runnerDemand&&(i.runnerDemand=s.runnerDemand),vr(e,t,n,s);let{shouldPrewarmRunner:c}=s,l=Ar(t.device,n,a);a&&c&&!n.prewarmRunnerBeforeOpen&&o.schedule();try{await Sr(e,t,n,a,l,i),await Cr(n,i),await wr(o,c,n.prewarmRunnerBeforeOpen);let u=o.wasAwaited();return await Tr(t,n,a,i),await Dr(o,c,s.awaitPrewarmAfterOpen),await Or(e,t,n,a,u,l),await yr(e,t,n,a,r,i),{appBundleId:n.appBundleId,timing:i}}catch(n){throw l&&await e.appleApplications.stopRunnerSession(t.device.id).catch(()=>{}),n}}async function Sr(e,t,n,r,i,a){if(!kr(n,r)||!n.target)return;let o=Date.now();s(t.device.platform)&&!r&&!i&&await e.appleApplications.stopRunnerSession(t.device.id),await yt({device:t.device,interactor:await t.resolveInteractor(n.execution,n.appBundleId),positionals:[n.appBundleId??n.target]}),r&&await e.clock.sleep(300,t.signal),a.relaunchCloseDurationMs=F(o)}async function Cr(t,n){if(!se(t.runtimeHints))return;if(!t.applyRuntimeHints)throw new e(`COMMAND_FAILED`,`Runtime hint operation was not admitted for this open.`,{reason:`runtime-hints-operation-missing`});let r=Date.now();await t.applyRuntimeHints({appId:t.appBundleId,values:t.runtimeHints}),n.runtimeHintsDurationMs=F(r)}async function wr(e,t,n){!t||!n||(e.schedule(!0),await e.wait())}async function Tr(e,t,n,r){let i=Ir(t,n),a=Date.now();await xt({device:e.device,interactor:await e.resolveInteractor(t.execution,t.appBundleId),positionals:i.positionals,appBundleId:t.appBundleId,execution:t.execution,...n&&t.relaunch&&!t.execution.clearAppState?{terminateRunningApp:!0}:{}}),r.openDispatchDurationMs=F(a),await Er(e,t,i.followUpUrl,r)}async function Er(e,t,n,r){if(!n){r.launchUrlDurationMs=0;return}let i={...t.execution,clearAppState:void 0,launchConsole:void 0,launchArgs:void 0},a=Date.now();await xt({device:e.device,interactor:await e.resolveInteractor(i,t.appBundleId),positionals:[n],appBundleId:t.appBundleId,execution:i}),r.launchUrlDurationMs=F(a)}async function Dr(e,t,n){t&&!e.wasScheduled()&&e.schedule(),n?await e.wait():e.recordUnawaited()}async function Or(e,t,n,r,i,a){!l(t.device)||!r&&!a||!n.relaunch&&!i||r&&!i&&!await e.appleApplications.hasLiveRunnerSession(t.device,n.execution)||await e.appleApplications.notifyRunnerAppRelaunched(t.device,n.execution,t.signal)}function kr(e,t){return!!(e.relaunch&&e.target)&&!(t&&!e.execution.clearAppState)}function Ar(e,t,n){return e.kind===`device`&&e.appleOs===`ios`&&kr(t,n)}async function jr(e,t,n){n.ensureReady&&await A(e,t.device,t.signal),s(t.device.platform)&&!P(t.device)&&await e.appleApplications.stopRunnerSession(t.device.id),await yt({device:t.device,interactor:await t.resolveInteractor(n.execution,n.appBundleId),positionals:n.positionals}),P(t.device)&&await e.clock.sleep(300,t.signal)}async function Mr(e,t,n,r){r.daemonShutdown||await e.appleApplications.releaseRunnerOnClose(t.id,{retain:r.retainRunner}),await e.appleApplications.dismissCloseAlerts(t,r).catch(()=>{});let i=r.shutdownTarget&&P(t)?await e.deviceShutdown.apple.shutdownTarget(t,n):void 0;return i===void 0?{}:{shutdown:i}}async function Nr(e,t,n,r){let i=Date.now()+r.timeoutMs;await A(e,t,n,{deadlineAtMs:i});let a=Math.max(1,i-Date.now());return await e.appleApplications.prepareRunner(t,{...r,timeoutMs:a},n)}function Pr(e,t,n,r){let i,a=!1,o=Fr(t.device,n)?{healthCheck:!1}:void 0;return{schedule:(a=!1)=>{i||=(r.runnerPrewarmKind=`session`,r.runnerPrewarmScheduled=!0,o?e.appleApplications.prewarmRunnerSession(t.device,n.execution,t.signal,a,o):e.appleApplications.prewarmRunnerSession(t.device,n.execution,t.signal,a))},wait:async()=>{if(!i||a)return;a=!0;let e=Date.now();await i,r.runnerPrewarmWaited=!0,r.runnerPrewarmDurationMs=F(e)},wasAwaited:()=>a,wasScheduled:()=>i!==void 0,recordUnawaited:()=>{i&&!a&&(r.runnerPrewarmWaited=!1)}}}function Fr(e,t){return e.kind===`device`&&e.appleOs===`ios`&&!t.hasExistingSession&&!t.relaunch&&!t.prewarmRunnerBeforeOpen}function Ir(e,t){let r=e.runtimeLaunchUrl?.trim(),i=e.positionals.length===1?e.positionals[0]?.trim():void 0;return!r||!i||n(i)?{positionals:e.positionals}:t&&!Lr(e)?{positionals:[i,r]}:{positionals:e.positionals,followUpUrl:r}}function Lr(e){return e.execution.clearAppState===!0||!!e.execution.launchConsole?.trim()||!!e.execution.launchArgs?.length}function P(e){return l(e)&&e.kind===`simulator`}function F(e){return Math.max(0,Date.now()-e)}async function Rr(){throw new e(`UNSUPPORTED_OPERATION`,`This lifecycle operation is unavailable for Apple.`)}const zr=Object.freeze({available:!0}),Br=Object.freeze({available:!1,reason:`unsupported-device-backend`,hint:`This command requires a CoreDevice-backed physical iOS device. The selected XCTest backend supports open, close, interactions, snapshots, and screenshots.`}),Vr=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`Push notifications are supported on Apple simulators only.`}),Hr=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),Ur=Object.freeze({available:!1,reason:`unsupported-device-kind`});function Wr(e){let t=Qr(e);return Object.freeze({deployApp:t,materializeAppSource:t,deployMaterializedApp:t,sendPushNotification:$r(e)})}function Gr(e){let{host:t,device:n,signal:r}=e,i=Wr(n);return Object.freeze({...i.deployApp.available?{deployApp:async e=>await Kr(t,n,e,r),materializeAppSource:async e=>await t.appleDeployment.prepareArtifact(e,{signal:r}),deployMaterializedApp:async e=>await qr(t,n,e,r)}:{},...i.sendPushNotification.available?{sendPushNotification:async e=>(await Xr(t,n,e,r),{})}:{}})}async function Kr(e,t,n,r){if(n.replaceExisting)return await e.appleDeployment.withInvalidatedAppResolutionCache(t,async()=>{let i=await e.appleDeployment.resolveAppBundleId(t,n.app);await Yr(e,t,i,r);let a=await e.appleDeployment.prepareArtifact({source:{kind:`path`,path:n.appPath}},{appIdentifierHint:n.app,signal:r});try{return await Jr(e,t,a.installablePath,r),{bundleId:i,launchTarget:i}}finally{await a.cleanup()}});let i=await e.appleDeployment.prepareArtifact({source:{kind:`path`,path:n.appPath}},{appIdentifierHint:n.app,signal:r});try{return await qr(e,t,{artifact:i},r)}finally{await i.cleanup()}}async function qr(e,t,n,r){return await Jr(e,t,n.artifact.installablePath,r),{...n.artifact.bundleId?{bundleId:n.artifact.bundleId}:{},...n.artifact.appName?{appName:n.artifact.appName}:{},...n.artifact.bundleId?{launchTarget:n.artifact.bundleId}:{}}}async function Jr(e,t,n,r){await A(e,t,r),I(await e.appleTools.run(t.kind===`simulator`?{tool:`simctl`,args:g(t,[`install`,t.id,n])}:{tool:`devicectl`,args:[`device`,`install`,`app`,`--device`,t.id,n],timeoutMs:12e4},r),`Apple app install failed`)}async function Yr(e,t,n,r){await A(e,t,r);let i=await e.appleTools.run(t.kind===`simulator`?{tool:`simctl`,args:g(t,[`uninstall`,t.id,n]),allowFailure:!0}:{tool:`devicectl`,args:[`device`,`uninstall`,`app`,`--device`,t.id,n],allowFailure:!0},r);i.exitCode===0||Zr(`${i.stdout}\n${i.stderr}`)||I(i,`Apple app uninstall failed for ${n}`)}async function Xr(t,n,r,i){if(n.kind!==`simulator`)throw new e(`UNSUPPORTED_OPERATION`,`Apple push notifications require a simulator`);await A(t,n,i);let a=await t.temporaryFiles.create({prefix:`agent-device-ios-push-`,suffix:`.apns`});try{await a.writeText(`${JSON.stringify(r.payload)}\n`),I(await t.appleTools.run({tool:`simctl`,args:g(n,[`push`,n.id,r.appId,a.path])},i),`Apple push notification failed`)}finally{await a[Symbol.asyncDispose]()}}function Zr(e){let t=e.toLowerCase();return t.includes(`not installed`)||t.includes(`not found`)||t.includes(`no such file`)}function I(t,n){if(t.exitCode!==0)throw new e(`COMMAND_FAILED`,n,{stdout:t.stdout,stderr:t.stderr,exitCode:t.exitCode})}function Qr(e){return ei(e)?e.kind!==`simulator`&&e.kind!==`device`?Ur:e.kind===`device`&&e.iosPhysicalDeviceBackend===`xctest`?Br:zr:Hr}function $r(e){return ei(e)?e.kind===`simulator`?zr:Vr:Hr}function ei(e){return l(e)&&e.appleOs!==`watchos`}const L=Object.freeze({available:!0}),ti=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`back is supported on Apple simulators and physical devices.`}),ni=Object.freeze({available:!1,reason:`unsupported-platform-leaf`});function ri(e){return e.kind!==`simulator`&&e.kind!==`device`?ti:r(e)===`watchos`?ni:L}const ii=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`home is supported on Apple simulators and physical devices.`}),ai=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),oi=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`app-switcher is supported on Apple simulators and physical devices.`});function si(e,t){if(e.kind!==`simulator`&&e.kind!==`device`)return t;let n=r(e);return n===`macos`||n===`watchos`?ai:L}function R(e){if(e.kind!==`simulator`&&e.kind!==`device`)return!1;let t=r(e);return t!==`tvos`&&t!==`macos`&&t!==`watchos`}const ci=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`orientation is supported on Apple simulators and physical devices.`}),li=Object.freeze({available:!1,reason:`unsupported-platform-leaf`});function ui(e){return e.kind!==`simulator`&&e.kind!==`device`?ci:R(e)?L:li}const di=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`tv-remote is supported only on tvOS devices.`});function fi(e){return(e.kind===`simulator`||e.kind===`device`)&&o(e)?L:di}const z=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),pi=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`keyboard status/get is currently supported only on Android; use keyboard dismiss or enter on iOS`});function mi(e){return R(e)?pi:z}function hi(e){return R(e)?L:z}function gi(e){return R(e)?L:z}const _i=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`action-button is supported on iPhone and iPad simulators and physical devices.`}),vi=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`The Action Button is iPhone and iPad hardware; tvOS, macOS, watchOS and visionOS have no such control.`});function yi(e){return e.kind!==`simulator`&&e.kind!==`device`?_i:c(e)?L:vi}function bi(e){return Object.freeze({...Ie({back:ri(e)}),...Ee({home:si(e,ii)}),...Me({appSwitcher:si(e,oi)}),...Pe({orientation:ui(e)}),...Oe({tvRemote:fi(e)}),actionButton:yi(e),...je({unsupported:z,status:mi(e),dismiss:hi(e),enter:gi(e)})})}function xi(e){let{host:t,device:n,signal:r}=e;return dt({device:n,signal:r,resolveInteractor:t.localInteractors.resolve,facts:bi(n)})}const B=Object.freeze({available:!0}),Si=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`clipboard is supported on Apple simulators and the macOS host.`}),Ci=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`settings is supported on Apple simulators and the macOS host.`}),wi=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`settings is supported on Apple simulators and the macOS host, not on physical devices of this OS.`}),Ti=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`clipboard is supported on Apple simulators and the macOS host, not on physical devices of this OS.`}),V=Object.freeze({available:!1,reason:`unsupported-platform-leaf`});function Ei(e,t,n){if(e.kind!==`simulator`&&e.kind!==`device`)return t;let i=r(e);return i===`watchos`?V:e.kind===`simulator`||i===`macos`?B:n}function Di(e){return Ei(e,Si,Ti)}const Oi=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`trigger-app-event is supported on Apple simulators and physical devices.`}),ki=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`alert is supported on Apple simulators and physical devices.`}),Ai=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`alert is supported on Apple simulators, the macOS host, and physical iOS devices.`});function ji(e){if(e.kind!==`simulator`&&e.kind!==`device`)return ki;let t=r(e);return t===`watchos`?V:e.kind===`simulator`||t===`ios`||t===`macos`?B:Ai}function Mi(e){return e.kind!==`simulator`&&e.kind!==`device`?Oi:r(e)===`watchos`?V:B}function Ni(e){let t=Di(e);return t.available?Ti:t}function Pi(e){let t=Di(e),n=ji(e);return Object.freeze({...De({unsupported:Ni(e),read:t,write:t}),...Ne({read:n,wait:n,accept:n,dismiss:n}),...Te({triggerAppEvent:Mi(e)}),...ke({setSetting:Ei(e,Ci,wi)})})}function Fi(e){let{host:t,device:n,signal:r}=e;return dt({device:n,signal:r,resolveInteractor:t.localInteractors.resolve,facts:Pi(n)})}function Ii(e,t,n){let r=Le({device:t.device,signal:t.signal,resolveInteractor:e.localInteractors.resolve}),i=async i=>{if(a(t.device)&&i.options?.surface!==void 0&&i.options.surface!==`app`)return await e.snapshot.captureSurface(t.device,i.options,we(t.signal,i));if(!n)return await r.captureSnapshot(i);let o=we(t.signal,i);return await n.capture(t.device,i,o,async e=>await r.captureSnapshot(e))};return Object.freeze({captureSnapshot:i,captureSnapshotWithCustomActions:i,captureSnapshotWithoutActiveApp:i})}function Li(e,t){return Object.freeze({findText:async n=>{let r=await Ri(e,t,n);if(!r)return{found:!1};let i=await e.localInteractors.resolve(t.device,{...n.execution,...r});return i.findText?await i.findText(n.text,r):{found:!1}}})}async function Ri(e,t,n){let r=n.options?.appBundleId;if(r===void 0)return;let i=n.options?.surface;if(a(t.device)&&i!==void 0&&i!==`app`)return;let o=n.signal?AbortSignal.any([t.signal,n.signal]):t.signal;if(o.throwIfAborted(),await zi(e,t.device,n.execution))return{appBundleId:r,signal:o}}async function zi(e,t,n){return!N(t)||await e.appleApplications.hasLiveRunnerSession(t,n??{})}function Bi(){let e,t=!1,n=async()=>(e??=import(`./adapter.js`).then(({createSimulatorSnapshotSource:e})=>e()),await e);return{acquire:async e=>t?{stage:`failed`,failure:{kind:`unsupported`,code:`source-closed`}}:await(await n()).acquire(e),close:async()=>{t=!0,e&&await(await e).close()}}}const Vi=3e3;function Hi(){let e=new Map,t=new Map,n=Dt({waitMs:1500});return async(r,i,a,o)=>{a.throwIfAborted();let s=`${r.id}:${i}`,c=e.get(s);return c&&o!==`refresh`&&await kt(c.pid,{signal:a,timeoutMs:Vi})===c.processStartTime?c:(e.delete(s),await n.value(s,{start:async()=>{let n=await Ui(r,i,t);return e.set(s,n),n},wait:(e,t)=>Ot({waitMs:e,signal:a,stop:t,cancelled:()=>a.reason}),pending:()=>U(`simulator-target-discovery-pending`,r,i)}))}}async function Ui(e,t,n){let r=Date.now()+15e3,[i,a]=await Promise.allSettled([Ct(e,[`spawn`,e.id,`launchctl`,`list`],{allowFailure:!0,timeoutMs:H(r)}),Wi(e,n,r)]);if(i.status===`rejected`)throw i.reason;if(a.status===`rejected`)throw a.reason;let o=i.value,s=a.value;if(o.exitCode!==0)throw U(`simulator-target-probe-failed`,e,t);let c=Gi(o.stdout,t);if(!c)throw U(`simulator-target-unavailable`,e,t);let l=await kt(c.pid,{timeoutMs:Math.min(Vi,H(r))});if(!l)throw U(`simulator-target-identity-unavailable`,e,t);return Object.freeze({udid:e.id,runtime:s,pid:c.pid,generation:`${c.pid}:${c.label}:${l}`,targetId:`${e.id}:${t}`,processStartTime:l})}async function Wi(e,t,n){let r=t.get(e.id);if(r)return await r;let i=Ct(e,[`list`,`devices`,`-j`],{allowFailure:!0,timeoutMs:H(n)}).then(t=>{if(t.exitCode!==0)throw U(`simulator-runtime-probe-failed`,e,``);let n=JSON.parse(t.stdout),r=Object.entries(n.devices??{}).find(([,t])=>t.some(t=>t.udid===e.id))?.[0];if(!r)throw U(`simulator-runtime-unavailable`,e,``);return r});t.set(e.id,i);try{return await i}catch(n){throw t.delete(e.id),n}}function Gi(e,t){for(let n of e.split(`
4
+ `)){let[e,,r]=n.trim().split(/\s+/);if(!e||!r||!r.startsWith(`UIKitApplication:${t}[`))continue;let i=Number(e);if(Number.isSafeInteger(i)&&i>0)return{pid:i,label:r}}}function H(e){return Math.max(1,e-Date.now())}function U(t,n,r){return new e(`COMMAND_FAILED`,`Unable to resolve the running iOS Simulator app (${t}).`,{reason:t,deviceId:n.id,appBundleId:r})}function Ki(e=Date.now){let t=new Map;return async(n,r)=>{if(n.kind!==`simulator`)return`absent`;let i=t.get(n.id);if(i!==void 0&&e()-i.at<1e3)return{kind:`present`,host:i.host};t.delete(n.id);let a=await qi(n,r);return a!==`absent`&&a!==`unknown`&&t.set(n.id,{at:e(),host:a.host}),a}}async function qi(e,t){let n=!1;for(let r of ct){let i=await Ji(r.processExecutable,t);if(i===`unknown`){n=!0;continue}for(let a of i){let i=await Yi(a,e.id,t);if(i===`unknown`)n=!0;else if(i)return{kind:`present`,host:r}}}return n?`unknown`:`absent`}async function Ji(e,t){let n=await Xi(`pgrep`,[`-f`,e],t);return n===`unknown`?`unknown`:n.exitCode===1?[]:n.exitCode===0?n.stdout.split(`
5
+ `).map(e=>Number.parseInt(e.trim(),10)).filter(e=>Number.isSafeInteger(e)&&e>0):`unknown`}async function Yi(e,t,n){let r=await Xi(`ps`,[`eww`,`-p`,String(e),`-o`,`command=`],n);return r===`unknown`||r.exitCode!==0?`unknown`:r.stdout.includes(`SIMULATOR_UDID=${t}`)?!0:!r.stdout.includes(`SIMULATOR_UDID=`)&&`unknown`}async function Xi(e,t,n){try{let r=await St(e,t,{allowFailure:!0,timeoutMs:3e3,...n?{signal:n}:{}});return{exitCode:r.exitCode,stdout:r.stdout}}catch{return`unknown`}}const Zi=`system-surface-presented`,Qi=`system-surface-host-lingering`,$i=`window-coordinate-space-unresolved`;function ea(t,n={}){let r=n.source??Bi(),i=n.resolveTarget??Hi(),a=n.systemSurfacePresent??Ki(),o=new Set,s=new Map,c=e=>(pa(e,s,o),o.has(ma(e))),l=gr({source:r,resolveTarget:i,clock:t.clock,isBridgeDisabled:c});return Object.freeze({awaitObservable:l.awaitObservable,shutdown:async()=>await r.close(),capture:async(n,s,l,u)=>{if(!ra(n,s))return await sa(n,s,u);let d=await a(n,l);if(d===`unknown`)return await W(n.id,s,u,G(n.id,s),q(s),`system-surface-probe-unavailable`,[K()]);if(d!==`absent`)return await oa(n,s,u,d.host.bundleId);let f;try{f=await ta(t,i,n,s,l)}catch(e){return l.throwIfAborted(),J(`target-resolution-failed`,n,void 0,e),await W(n.id,s,u,G(n.id,s),q(s),`target-resolution-failed`,[K()])}if(c(f))return await W(n.id,s,u,f,q(s),`circuit-disabled`);let p=q(s),m=await r.acquire({target:f,hint:ne(p),signal:l});if(m.stage===`failed`){if(m.failure.kind===`cancelled`)throw l.throwIfAborted(),new e(`COMMAND_FAILED`,`Simulator AX snapshot acquisition was cancelled.`,{reason:m.failure.code,...m.failure.details});let t=await fa(m.failure,f,n,s.options.appBundleId,l,i);return await ia(s,u,f,t,p,m.failure,o)}try{return await ee(`ios.snapshot-source.present`,async()=>await t.snapshot.presentIosAcquisition(m,s.options),{producer:`simulator-ax-bridge`})}catch(e){return await ia(s,u,f,{lineage:f,residue:[]},p,{kind:`malformed-tree`,code:`presentation-invariant`},o,e)}}})}async function ta(e,t,n,r,i){let a=r.options.appBundleId;for(;;)try{return await t(n,a,i)}catch(t){if(!na(t))throw t;let i={requestId:r.execution?.requestId};if(await e.appleApplications.hasLiveRunnerSession(n,i))throw t}}function na(t){return t instanceof e&&t.details?.reason===`simulator-target-discovery-pending`}function ra(e,t){return e.platform===`apple`&&e.appleOs===`ios`&&e.kind===`simulator`&&!!t.options?.appBundleId&&t.options?.customActions!==!0&&t.options?.preferredBackend===void 0}async function ia(e,t,n,r,i,a,o,s){return aa(a)&&o.add(ma(n)),J(a.code,{id:n.udid},n.generation,s,a.details),await W(n.udid,e,t,r.lineage,i,a.code,r.residue)}function aa(e){return e.kind!==`preparing`&&e.code!==$i}async function W(e,t,n,r,i,a,o=[]){return ca(e,await n(t),r,i,a,o)}async function oa(e,t,n,r){let i=await n(t),a=i.systemSurface?Zi:Qi;return i.systemSurface||J(a,e,void 0,void 0,{detectedHost:r}),ca(e.id,i,G(e.id,t),q(t),a)}async function sa(e,t,n){let r=await n(t),i=r.systemSurface;return i?{...r,comparisonIdentity:ua(la(e.id,i.bundleId),q(t),[])}:r}function ca(e,t,n,r,i,a=[]){let o=t.systemSurface;return{...t,comparisonIdentity:ua(o?la(e,o.bundleId):n,r,[...o?[]:a,{kind:`fallback-source`,producer:`apple-runner`}]),warnings:[...t.warnings??[],da(i,n,o!==void 0)]}}function G(e,t){return{targetId:`${e}:${t.options.appBundleId}`}}function la(e,t){return{targetId:`${e}:${t}`}}function ua(e,t,n){return Object.freeze({producer:`apple-runner`,intent:t.acquisitionIntent,lineage:Object.freeze({...e.targetId?{targetId:e.targetId}:{},...e.generation?{generation:e.generation}:{}}),presentationKey:re(t),residue:Object.freeze([...n])})}function da(e,t,n){return e===Zi?`Simulator AX snapshot inapplicable (${e}); used XCTest to read the system surface presented over the app.`:e===Qi?`Simulator AX snapshot inapplicable (${e}); used XCTest, which read app content: the system surface host process was still running but no longer presenting.`:n?`Simulator AX snapshot unavailable (${e}); used XCTest, which read the system surface presented over the app.`:e===`bridge-preparation-pending`?`Simulator AX snapshot unavailable (${e}); used XCTest for this capture while the bridge is still being prepared.`:e===$i?`Simulator AX snapshot unavailable (${e}); used XCTest for this capture, which reports captured geometry in the app's own orientation space.`:`Simulator AX snapshot unavailable (${e}); used XCTest for ${t.generation?`this app generation`:`an unverified app generation`}.`}async function fa(e,t,n,r,i,a){if(e.kind!==`stale-target`)return{lineage:t,residue:[]};try{return{lineage:await a(n,r,i,`refresh`),residue:[]}}catch(e){return i.throwIfAborted(),J(`fallback-target-resolution-failed`,n,void 0,e),{lineage:{targetId:t.targetId},residue:[K()]}}}function K(){return{kind:`unknown-generation`,captureId:jt()}}function q(e){return ie({raw:e.options?.raw,interactiveOnly:e.options?.interactiveOnly,depth:e.options?.depth,scope:e.options?.scope,customActions:e.options?.customActions,acquisitionIntent:e.options?.acquisitionIntent})}function pa(e,t,n){let r=t.get(e.targetId);r&&r!==e.generation&&n.delete(`${e.targetId}:${r}`),t.set(e.targetId,e.generation)}function ma(e){return`${e.targetId}:${e.generation}`}function J(e,t,n,r,i){p({level:`debug`,phase:`ios_snapshot_route_fallback`,data:{reason:e,deviceId:t.id,...n?{generation:n}:{},...r?{error:r instanceof Error?r.message:String(r)}:{},...i?{details:i}:{}}})}const Y=u(`apple`),X=Object.freeze({available:!0}),Z=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),ha=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`viewport resizes web targets only (--platform web). Apple screen geometry is fixed by the selected simulator or device type — open a different simulator to test another screen size.`}),ga=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`the stateless audio page probe is a web-session operation; Apple targets use the host capture.`}),_a=Object.freeze({available:!1,reason:`unsupported-device-backend`,hint:`perf requires an Apple simulator, macOS device, or CoreDevice-backed physical Apple device.`}),va=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`focus is supported on Apple simulators and physical devices.`}),ya=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`Apple appstate is unavailable: the Apple target answers no sessionless foreground probe, and a session-scoped guess about the foreground is not a fact. The per-command answer is the targetActivation disclosure, which a capture carries when its command had to re-activate the session app (#2682).`}),ba=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Headless boot is supported only for local Android emulators.`}),xa=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`watchOS has no XCUITest-driveable UI, so element text comes from the captured tree only.`}),Sa=Object.freeze({available:!1,reason:`unsupported-device-kind`}),Ca=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`watchOS open is not supported because XCUITest cannot drive watchOS UI.`}),wa=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`watchOS runner preparation is not supported because XCUITest cannot drive watchOS UI.`}),Ta=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`watchOS close is not supported because XCUITest cannot drive watchOS UI.`}),Ea=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`Runtime hints are supported only for local iOS-family simulators and Android devices.`}),Da=Q(`open is supported only for Apple simulators and devices.`),Oa=Q(`prepare is supported only for Apple simulators and devices.`),ka=Q(`close is supported only for Apple simulators and devices.`),Aa=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Port reverse is supported only by an owning provider runtime.`}),ja=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`shutdown is supported only for Apple simulators and Android emulators.`}),Ma=Q(`snapshot is supported only for Apple simulators and devices.`),Na=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`Re-run without --actions, or target an iOS simulator.`}),Pa=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`screenshot is not supported on watchOS because XCUITest cannot drive watchOS UI.`}),Fa=Q(`screenshot is supported only for Apple simulators and devices.`),Ia=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`Open the app under test before capturing its snapshot.`});function Q(e){return Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:e})}function La(e){return!l(e)||e.appleOs===`watchos`?Z:e.kind===`simulator`?X:ja}function Ra(e){let t=za(e),n=Ba(e),r=Va(e),i=Ha(e);return ce({resolveOpenTarget:t,prepareApplicationOpen:t,openApplication:t,applyRuntimeHints:i,clearRuntimeHints:i,closeApplication:r,finalizeApplicationClose:r,prepareAppleRunner:n,configureProviderPortReverse:Aa})}function za(e){return r(e)===`watchos`?Ca:e.kind===`simulator`||e.kind===`device`?X:Da}function Ba(e){return r(e)===`watchos`?wa:e.kind===`simulator`||e.kind===`device`?X:Oa}function Va(e){return r(e)===`watchos`?Ta:e.kind===`simulator`||e.kind===`device`?X:ka}function Ha(e){return r(e)!==`watchos`&&l(e)&&e.kind===`simulator`?X:Ea}function Ua(e){return e.appleOs===`watchos`?Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`watchOS app inventory is not supported.`}):e.kind===`device`&&e.iosPhysicalDeviceBackend===`xctest`?Object.freeze({available:!1,reason:`unsupported-device-backend`,hint:`App inventory is available only on CoreDevice-backed physical iOS devices.`}):X}function $(e){return e.kind===`simulator`||e.kind===`device`?X:va}function Wa(e){let t=gn(e),n=ea(e),r=async n=>{let r=await t.inspectFacts(n),i=Wr(n),o=Kn(n),s=o.available?await e.screenRecording.apple.availability(n):void 0,c=o.available&&s?.available===!1?Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:s.hint}):o,u=n.appleOs===`watchos`?Z:X,d=a(n)||n.appleOs===`watchos`?Z:X,f=Ua(n);return Object.freeze({device:r.device,operations:{...r.operations,...i,appState:ya,networkDump:X,screenRecordingStart:c,screenRecordingReattach:c,screenRecordingCleanup:c,...Ya(n),...me({capture:Ja(n)}),...xe({findText:qa(n)}),..._e({setViewport:ha}),...ge({focus:$(n)}),...Bt(n),...pe({type:$(n)}),...le({unsupported:Z,tap:$(n),longPress:$(n),fill:$(n),...l(n)?{tapElementSelector:$(n)}:{}}),...Fe({readTextAtPoint:Ka(n)}),...bi(n),...Pi(n),...Re({capture:Nt(n),query:ga}),...ze(Ga(n)),ensureReady:u,bootTarget:d,bootTargetHeadless:ba,listApps:f,...Ra(n),shutdownTarget:La(n)}})};return Object.freeze({owner:Y,ownsDevice:e=>e.platform===`apple`,inspectFacts:r,bind:async i=>{let a=await t.bind(i),o=await r(i.device),s=o.operations.screenRecordingStart,c={...a.operations,...Gr({host:e,device:i.device,signal:i.scope.signal}),networkDump:async t=>await yn(e,i.device,t,i.scope.signal),...d(s,()=>qn({host:e,device:i.device,owner:Y,signal:i.scope.signal})),...d(o.operations.audioProbeStart,()=>Je({host:e.audioProbe.hostCapture,device:i.device,owner:Y})),...d(o.operations.perfFrames,()=>Pt({resolveHost:()=>e.perf.apple,device:i.device,owner:Y})),...d(o.operations.captureSnapshot,()=>Ii(e,{device:i.device,signal:i.scope.signal},n)),...d(o.operations.captureScreenshot,()=>Ce({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve})),...d(o.operations.focusPoint,()=>be({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve})),...Ae({device:i.device,signal:i.scope.signal,facts:o.operations,resolveInteractor:e.localInteractors.resolve}),...d(o.operations.scrollDirection,()=>ye({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve})),...d(o.operations.typeText,()=>Se({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve})),...d(o.operations.tapPoint,()=>ue({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve,facts:o.operations,pause:async t=>await e.clock.sleep(t,i.scope.signal)})),...d(o.operations.readTextAtPoint,()=>fe({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve})),...d(o.operations.findText,()=>Li(e,{device:i.device,signal:i.scope.signal})),...xi({host:e,device:i.device,signal:i.scope.signal}),...Fi({host:e,device:i.device,signal:i.scope.signal}),...d(o.operations.ensureReady,()=>({ensureReady:async()=>await A(e,i.device,i.scope.signal)})),...d(o.operations.bootTarget,()=>({bootTarget:async()=>await A(e,i.device,i.scope.signal)})),...d(o.operations.listApps,()=>({listApps:async e=>{i.scope.signal.throwIfAborted();let{listIosApps:t}=await import(`./app-resolution.js`).then(e=>e.t);return(await t(e.device,e.filter)).map(e=>({id:e.bundleId,name:e.name}))}})),...oe(br({host:e,device:i.device,signal:i.scope.signal,observation:n}),o.operations),...d(o.operations.shutdownTarget,()=>({shutdownTarget:async()=>await e.deviceShutdown.apple.shutdownTarget(i.device,i.scope.signal)}))};return Object.freeze({device:a.device,owner:Y,facts:o,operations:Mt(c),[Symbol.asyncDispose]:async()=>await a[Symbol.asyncDispose]()})},shutdown:async()=>{await Promise.all([t.shutdown(),n.shutdown()])}})}function Ga(e){let t=e.iosPhysicalDeviceBackend!==`xctest`&&r(e)!==`watchos`?X:_a;return{frames:t,memorySample:t,memorySnapshot:t,nativeCapture:t,profileReport:t}}function Ka(e){return r(e)===`watchos`?xa:e.kind===`simulator`||e.kind===`device`?X:Sa}function qa(e){return r(e)===`watchos`?Ma:e.kind===`simulator`||e.kind===`device`?X:Ma}function Ja(e){return r(e)===`watchos`?Pa:e.kind===`simulator`||e.kind===`device`?X:Fa}function Ya(e){let t=qa(e);return he({capture:t,customActions:t.available&&l(e)&&e.kind===`simulator`?X:Na,withoutActiveApp:l(e)?Ia:t})}export{Wa as createApplePlatformRuntime};
@@ -1 +1 @@
1
- import{N as e}from"./sdk-contracts.js";import{l as t}from"./sdk-device.js";import{n,t as r}from"./simulator-state.js";const i=15e3;function a(e){return Object.freeze({canShutdownTarget:o,shutdownTarget:async(t,n)=>await s(e.appleTools,t,n)})}function o(e){return t(e)&&e.appleOs!==`watchos`&&e.kind===`simulator`}async function s(t,r,a){a.throwIfAborted();try{let e=await t.run({tool:`simctl`,args:n(r,[`shutdown`,r.id]),allowFailure:!0,timeoutMs:i},a);a.throwIfAborted();let o=l(e);return o.success?o:await c(t,r,a)===`Shutdown`?{...o,success:!0,exitCode:0}:o}catch(t){a.throwIfAborted();let n=e(t);return{success:!1,exitCode:-1,stdout:``,stderr:n.message,error:n}}}async function c(e,t,n){try{return await r(e,t,n,i)}catch{return n.throwIfAborted(),null}}function l(e){let t=e.exitCode??-1;return{success:t===0,exitCode:t,stdout:e.stdout,stderr:e.stderr}}export{a as createAppleShutdownRuntime};
1
+ import{L as e}from"./sdk-contracts.js";import{u as t}from"./sdk-device.js";import{n,t as r}from"./simulator-state.js";const i=15e3;function a(e){return Object.freeze({canShutdownTarget:o,shutdownTarget:async(t,n)=>await s(e.appleTools,t,n)})}function o(e){return t(e)&&e.appleOs!==`watchos`&&e.kind===`simulator`}async function s(t,r,a){a.throwIfAborted();try{let e=await t.run({tool:`simctl`,args:n(r,[`shutdown`,r.id]),allowFailure:!0,timeoutMs:i},a);a.throwIfAborted();let o=l(e);return o.success?o:await c(t,r,a)===`Shutdown`?{...o,success:!0,exitCode:0}:o}catch(t){a.throwIfAborted();let n=e(t);return{success:!1,exitCode:-1,stdout:``,stderr:n.message,error:n}}}async function c(e,t,n){try{return await r(e,t,n,i)}catch{return n.throwIfAborted(),null}}function l(e){let t=e.exitCode??-1;return{success:t===0,exitCode:t,stdout:e.stdout,stderr:e.stderr}}export{a as createAppleShutdownRuntime};
@@ -1 +1 @@
1
- import{C as e}from"./sdk-contracts.js";import{w as t}from"./sdk-device.js";import{Gt as n,Zt as r}from"./sdk-batch.js";import{n as i,t as a}from"./application-lifecycle-runtime.js";import{i as o,t as s}from"./touch-runtime.js";import{A as c,D as l,G as u,H as d,I as f,L as p,N as ee,O as te,P as m,R as h,T as g,U as ne,a as re,b as ie,d as ae,g as oe,i as se,j as ce,m as le,s as ue,t as de,v as fe,w as pe,x as me,z as he}from"./alert-runtime.js";import{n as ge}from"./audio-probe-runtime.js";import{n as _e}from"./perf-runtime.js";import{a as _,n as v}from"./durable-resource.js";import{n as ve}from"./async-lifecycle.js";import{i as ye,r as be}from"./src7.js";import{n as xe,t as y}from"./screen-recording-completion.js";import{t as b}from"./screen-recording-options.js";import{n as x}from"./screen-recording-runtime.js";import{i as S}from"./gesture-admission.js";import{t as C}from"./interactor-operation-catalog.js";import{i as w,n as T}from"./perf-runtime-operation-builder.js";import{t as E}from"./app-log-runtime.js";import{n as D,t as O}from"./application-lifecycle-interaction.js";import{randomUUID as k}from"node:crypto";import{setTimeout as A}from"node:timers/promises";const j=Object.freeze({resourceKind:E,version:1,encode:e=>({...e}),decode:e=>e.transport!==`harmony-hilog`||!N(e.outputPath)||!N(e.pidPath)?{status:`invalid`,message:`Invalid HarmonyOS app-log descriptor`}:{status:`decoded`,descriptor:Object.freeze({transport:`harmony-hilog`,outputPath:e.outputPath,pidPath:e.pidPath})}});function M(e){return v({resourceKind:E,sessionId:e.sessionId,device:{id:e.device.id,family:`harmonyos`,kind:e.device.kind,...e.device.target===void 0?{}:{target:e.device.target}},owner:e.owner,fence:e.fence,lifecycle:`open`,descriptor:_(j,e.descriptor)})}function N(e){return typeof e==`string`&&e.trim().length>0}function Se(e){return be(e,{family:`harmonyos`,backend:`harmonyos`,label:`HarmonyOS`,codec:j,startUnavailableHint:`The selected HarmonyOS transport cannot start a background hilog stream.`,cleanupFailureMessage:`HarmonyOS app-log cleanup did not settle every owned resource`,doctor:async(e,t)=>({backend:`harmonyos`,checks:{},notes:t?[]:[`No app bundle is tracked in this session. Run open <app> first for app-scoped logs.`]}),process:async({host:e,device:t,input:n,signal:r})=>{let i=await Ce(e,r);return{resolvePid:async r=>await ye(e,{executable:i,args:[`-t`,t.id,`shell`,`pidof`,n.appBundleId],allowFailure:!0,timeoutMs:5e3},r),command:e=>({kind:`host`,request:{executable:i,args:[`-t`,t.id,`shell`,`hilog`,`-P`,e],allowFailure:!0}})}},descriptor:({artifacts:e})=>({transport:`harmony-hilog`,...e}),envelope:({input:e,device:t,owner:n,descriptor:r})=>M({sessionId:e.sessionId,device:t,owner:n,fence:e.fence,descriptor:r})})}async function Ce(t,n){n.throwIfAborted(),await P(async()=>await t.toolchains.prepare(`harmonyos`),n),n.throwIfAborted();let r=await P(async()=>await t.commands.which(`hdc`),n);if(n.throwIfAborted(),!r)throw new e(`TOOL_MISSING`,`hdc not found in PATH`,{hint:`Install HarmonyOS Command Line Tools, then add its sdk/default/openharmony/toolchains directory to PATH.`});return r}async function P(e,t){try{return await e()}catch(e){throw t.throwIfAborted(),e}}function we(e){let{resolveHost:t,device:n}=e,r={available:!1,reason:`Dropped-frame sampling is currently available only on Android app sessions and connected iOS device app sessions.`};return Object.freeze({perfFrames:async()=>({metric:r,sampling:r}),perfMemorySample:async({appId:e})=>({metric:e?await w(t().sampleMemory(n,e)):T(`HarmonyOS`,`bundle`),sampling:{method:`hdc-shell-proc-status`,description:`Resident memory snapshot from HarmonyOS /proc/<pid>/status. Values are reported in kilobytes.`,unit:`kB`,topConsumerLimit:1}}),perfMemorySnapshot:async({kind:e})=>({artifact:{available:!1,kind:e??`memgraph`,reason:`Memory snapshot artifacts are not supported on harmonyos.`,hint:`Use perf memory sample where supported, or run the snapshot against Android, iOS simulator, or macOS.`,support:{platform:`harmonyos`,defaultKind:`memgraph`,androidHprof:!1,memgraph:!1,heapprofd:!1}},sampling:{method:`unsupported`,description:`HarmonyOS memory snapshot capture is not available through HDC.`,artifactOnly:!0}})})}const F=Object.freeze({resourceKind:x,version:1,encode:e=>({...e}),decode:e=>e.backend===`harmony-screen-recorder`&&typeof e.fileName==`string`&&De(e.fileName)&&e.remotePath===`/data/local/tmp/${e.fileName}`?{status:`decoded`,descriptor:Object.freeze({backend:`harmony-screen-recorder`,fileName:e.fileName,remotePath:e.remotePath})}:{status:`invalid`,message:`Invalid HarmonyOS screen-recording descriptor`}});function Te(e){let{device:n,owner:r,input:i,descriptor:a}=e;return v({resourceKind:x,sessionId:i.sessionId,device:t(n),owner:r,fence:i.fence,lifecycle:`open`,descriptor:_(F,a)})}function Ee(e){return F.decode(e).status===`decoded`?{status:`cleanup-pending`,reason:`manual-recovery-required`,message:`HarmonyOS recorder ownership cannot be proven after daemon restart; no recorder was stopped.`}:{status:`cleanup-pending`,reason:`manual-recovery-required`}}function De(e){return/^agent-device-recording-[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.mp4$/i.test(e)}function Oe(e){return e.kind===`device`?Object.freeze({available:!0}):Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`HarmonyOS recording is supported on physical devices only.`})}function ke(e){let{host:t,device:n,owner:r,signal:i}=e;return Object.freeze({screenRecordingStart:async e=>await Ae({host:t,device:n,owner:r,input:e,signal:i}),screenRecordingReattach:async()=>({status:`unreattachable`,reason:`transport-not-reattachable`,message:`HarmonyOS recordings cannot be reattached after daemon restart.`}),screenRecordingCleanup:async e=>Ee(e.envelope.descriptor.body)})}async function Ae(t){let{host:n,device:r,owner:i,input:a,signal:o}=t;if(a.scope===`app`)throw new e(`INVALID_ARGS`,`HarmonyOS recording captures the whole physical-device screen; use --scope device or --scope system`);b(a,{scopes:[`device`,`system`],fps:!1,exportQuality:!1,hideTouches:!1},e=>`HarmonyOS recordings do not support ${e.join(`, `)}`),o.throwIfAborted(),await n.screenRecording.outputs.prepare(a.outputPath);let s=`agent-device-recording-${k()}.mp4`,c={backend:`harmony-screen-recorder`,fileName:s,remotePath:`/data/local/tmp/${s}`},l;try{l=await n.screenRecording.harmony.start(r,s,o),o.throwIfAborted()}catch(e){throw o.aborted?(await L(n,r,c).catch(()=>{}),o.reason):e}z(l,`start`);try{o.throwIfAborted()}catch(e){throw await L(n,r,c).catch(()=>{}),e}let u=je(a),d=!1,f=async()=>{d||=(z(await n.screenRecording.harmony.stop(r),`stop`),!0)},p=xe(u,{finish:async e=>await Me(n,r,e,c,f),forceCleanup:async()=>await L(n,r,c,f)});return Object.freeze({pendingHandle:new ve(p),envelope:Te({device:r,owner:i,input:a,descriptor:c})})}function je(e){return Object.freeze({backend:`HarmonyOS ScreenRecorder`,outPath:e.outputPath,...e.clientOutputPath===void 0?{}:{clientOutPath:e.clientOutputPath},startedAt:Date.now(),scope:e.scope,showTouches:!1,recordOnlySession:e.recordOnlySession,...e.activeSessionApp===void 0?{}:{activeSessionApp:e.activeSessionApp},gestureEvents:[]})}async function Me(e,t,n,r,i){await i();let a=await e.screenRecording.harmony.findMedia(t,r.fileName);if(!a)throw Error(`failed to find finalized HarmonyOS recording '${r.fileName}'`);if(!await Fe(e,t,r,a))throw Error(`failed to finalize HarmonyOS recording: ${r.fileName} did not produce a non-empty media file`);try{if((await e.screenRecording.harmony.pull(t,{remotePath:r.remotePath,outputPath:n.outPath})).exitCode!==0)throw Error(`failed to retrieve HarmonyOS recording`);let i=await e.screenRecording.finalize.complete({outputPath:n.outPath,showTouches:!1,gestureEvents:n.gestureEvents,targetLabel:`HarmonyOS recording`}),o=await Ne(e,t,r,a);return y(n,{...i,...Pe(i.warning,o)},{stopObservation:{recorder:`confirmed`},nativePathDisposition:o===void 0?`retired`:`retirable`,showTouches:!1})}catch(n){throw await e.screenRecording.harmony.remove(t,r.remotePath).catch(()=>{}),n}}async function Ne(e,t,n,r){let i=[];return await I(()=>e.screenRecording.harmony.remove(t,n.remotePath))||i.push(`staging artifact`),await I(()=>e.screenRecording.harmony.removeMedia(t,r))||i.push(`media-library artifact`),i.length===0?void 0:`HarmonyOS recording completed, but cleanup was not confirmed for the ${i.join(` and `)}.`}async function I(e){try{return await e()}catch{return!1}}function Pe(e,t){let n=[e,t].filter(e=>e!==void 0).join(` `);return n.length===0?{}:{warning:n}}async function Fe(e,t,n,r){let i;for(let a=0;a<40;a+=1){if(await e.screenRecording.harmony.remove(t,n.remotePath).catch(()=>{}),await e.screenRecording.harmony.stageMedia(t,{mediaUri:r,remotePath:n.remotePath})){let r=await e.screenRecording.harmony.stagedFileSize(t,n.remotePath);if(r!==void 0&&r>0&&r===i)return!0;i=r!==void 0&&r>0?r:void 0}else i=void 0;a<39&&await e.clock.sleep(250)}return!1}async function L(e,t,n,r=async()=>{z(await e.screenRecording.harmony.stop(t),`stop`)}){let i=[await R(r),await R(async()=>{if(!await e.screenRecording.harmony.remove(t,n.remotePath))throw Error(`HarmonyOS recording staging artifact removal was not confirmed`)}),await R(async()=>await Ie(e,t,n.fileName))].find(e=>e!==void 0);return i===void 0?{status:`cleaned`}:{status:`cleanup-pending`,reason:`transport-failed`,message:i instanceof Error?i.message:`HarmonyOS recording cleanup failed`}}async function Ie(e,t,n){let r=await e.screenRecording.harmony.findMedia(t,n);if(r&&!await e.screenRecording.harmony.removeMedia(t,r))throw Error(`HarmonyOS recording media removal was not confirmed`)}async function R(e){try{await e();return}catch(e){return e}}function z(e,t){if(e.exitCode===0&&e.stdout.includes(`start ability successfully`))return;let n=e.stdout.trim()||e.stderr.trim()||`hdc exit ${e.exitCode}`;throw Error(`failed to ${t} HarmonyOS screen recording: ${n}`)}async function Le(t,n){n.throwIfAborted();let{runHarmonyHdc:r}=await import(`./hdc.js`),i=await r(t,[`shell`,`aa`,`dump`,`-l`],{timeoutMs:15e3,signal:n});n.throwIfAborted();let a=Re(i.stdout);if(!a)throw new e(`COMMAND_FAILED`,`Could not determine the foreground HarmonyOS app`,{hint:`Open an app on the target, then retry appstate.`});return a}function Re(e){let t=e.split(/(?=^\s*Mission ID #)/m);for(let e of t){if(!/\bstate #FOREGROUND\b/.test(e))continue;let t=e.match(/mission name #\[#([^:]+):[^:]*:([^\]]+)]/);if(!t)continue;let[,n,r]=t;if(!(!n||!r))return{package:n,activity:r}}}function ze(e){return O({owner:`HarmonyOS`,openTargetIdentity:`bundle-id`,binding:D({device:e.device,signal:e.signal,resolveInteractor:e.host.resolve})})}const Be=Object.freeze({available:!0}),Ve=Object.freeze({available:!1,reason:`unsupported-device-kind`}),B=Object.freeze({available:!1,reason:`unsupported-platform-leaf`});function V(e){let t=e.kind===`emulator`||e.kind===`device`?Be:Ve;return Object.freeze({deployApp:t,materializeAppSource:B,deployMaterializedApp:B,sendPushNotification:B})}function He(e){return V(e.device).deployApp.available?Object.freeze({deployApp:async t=>await Ue(e.commands,e.device,t,e.signal)}):Object.freeze({})}async function Ue(t,n,r,i){let a=await We(t,r.appPath,i)??r.app.trim();if(!a)throw new e(`INVALID_ARGS`,`Could not determine the bundle name from the HAP archive`,{hint:`Pass the HarmonyOS bundle name before the HAP path, or provide a valid HAP containing module.json.`});return await H(t,n,[`install`,`-r`,r.appPath],i,18e4),r.replaceExisting&&(await A(1e3,void 0,{signal:i}),await Ge(t,n,a,i)),{packageName:a,launchTarget:a}}async function We(e,t,n){let r=await e.run({executable:`unzip`,args:[`-p`,t,`module.json`],allowFailure:!0,timeoutMs:15e3},n);if(r.exitCode===0&&r.stdout.trim().length!==0)try{return JSON.parse(r.stdout).app?.bundleName?.trim()||void 0}catch{return}}async function Ge(t,n,r,i){let a=Ke((await H(t,n,[`shell`,`bm`,`dump`,`-n`,r],i)).stdout);if(!a)throw new e(`COMMAND_FAILED`,`Could not determine a launchable ability for ${r}`,{hint:`Check that the HarmonyOS bundle exposes a main ability.`});await H(t,n,[`shell`,`aa`,`start`,`-b`,r,...a.module?[`-m`,a.module]:[],`-a`,a.ability],i)}function Ke(e){let t=e.indexOf(`{`);if(t!==-1)try{let n=JSON.parse(e.slice(t)).hapModuleInfos?.find(e=>e.mainElementName);return n?.mainElementName?{ability:n.mainElementName,...n.moduleName?{module:n.moduleName}:{}}:void 0}catch{return}}async function H(e,t,n,r,i=15e3){return await e.run({executable:`hdc`,args:[`-t`,t.id,...n],timeoutMs:i},r)}const U=n(`harmonyos`),qe=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`HarmonyOS reads element text from the captured tree only.`}),Je=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`focus is supported on HarmonyOS emulators and physical devices.`}),W=Object.freeze({available:!0}),G=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),Ye=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`HarmonyOS appstate is supported only for HarmonyOS emulators and devices.`}),Xe=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`Apple runner preparation is supported only for Apple targets.`}),K=Object.freeze({available:!0}),Ze=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`open is supported only for HarmonyOS emulators and devices.`}),Qe=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`close is supported only for HarmonyOS emulators and devices.`}),$e=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Port reverse is supported only by an owning provider runtime.`}),q=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`snapshot is supported only for HarmonyOS emulators and devices.`}),J=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`screenshot is supported only for HarmonyOS emulators and devices.`}),et=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`Re-run without --actions, or target an iOS simulator.`}),tt=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`viewport resizes web targets only (--platform web).`});function nt(e){let t=rt(e),n=it(e);return a({resolveOpenTarget:t,prepareApplicationOpen:t,openApplication:t,applyRuntimeHints:G,clearRuntimeHints:G,closeApplication:n,finalizeApplicationClose:n,prepareAppleRunner:Xe,configureProviderPortReverse:$e})}function rt(e){return e.kind===`emulator`||e.kind===`device`?K:Ze}function it(e){return e.kind===`emulator`||e.kind===`device`?K:Qe}const Y=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`Gestures are supported on HarmonyOS emulators and physical devices.`}),at=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),ot=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:S});function X(e){return e.kind===`emulator`||e.kind===`device`?W:Y}function Z(e){return e.kind===`emulator`||e.kind===`device`?W:Je}const Q=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),st=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`keyboard status/get is not available through the public HarmonyOS HDC API; use keyboard dismiss or enter`}),$=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`audio is supported for web browser sessions, macOS sessions, iOS simulators, and Android emulators on macOS hosts`});function ct(e){let t=Se(e),n=async e=>{let n=await t.inspectFacts(e),r=V(e),i=Oe(e);return Object.freeze({device:n.device,operations:{...n.operations,...r,appState:e.kind===`simulator`?Ye:W,networkDump:G,screenRecordingStart:i,screenRecordingReattach:i,screenRecordingCleanup:i,...d({capture:e.kind===`emulator`||e.kind===`device`?W:q,customActions:et,withoutActiveApp:e.kind===`emulator`||e.kind===`device`?W:q}),...u({capture:e.kind===`emulator`||e.kind===`device`?W:J}),...h({findText:q}),...p({setViewport:tt}),...f({focus:Z(e)}),...ee({unsupported:Y,plan:X(e),directionalFling:X(e),multiTouch:at,targetAuthoredDrag:ot,viewport:X(e)}),...c({scroll:X(e)}),...l({type:Z(e)}),...o({unsupported:G,tap:Z(e),longPress:Z(e),fill:Z(e)}),...pe({readTextAtPoint:qe}),...me({back:Z(e)}),...ie({home:Z(e)}),...ue({appSwitcher:Z(e)}),...re({triggerAppEvent:Q}),...se({setSetting:Z(e)}),...de({read:Q,wait:Q,accept:Q,dismiss:Q}),...fe({orientation:Q}),...oe({tvRemote:Q}),...le({unsupported:Q,status:st,dismiss:Z(e),enter:Z(e)}),...ae({unsupported:Q}),...ge({capture:$,query:$}),..._e({frames:Z(e),memorySample:Z(e),memorySnapshot:Z(e),nativeCapture:Q,profileReport:Q}),ensureReady:W,bootTarget:G,bootTargetHeadless:G,listApps:W,...nt(e),shutdownTarget:G}})};return Object.freeze({owner:U,ownsDevice:e=>e.platform===`harmonyos`,inspectFacts:n,bind:async a=>{let o=await t.bind(a),c=await n(a.device),l=c.operations.screenRecordingStart;return Object.freeze({device:o.device,owner:U,facts:c,operations:Object.freeze({...o.operations,...He({commands:e.commands,device:a.device,signal:a.scope.signal}),...c.operations.appState.available?{appState:async()=>await Le(a.device,a.scope.signal)}:{},ensureReady:async()=>({...a.device,booted:!0}),...l.available?ke({host:e,device:a.device,owner:U,signal:a.scope.signal}):{},...c.operations.captureSnapshot.available?he({device:a.device,signal:a.scope.signal,resolveInteractor:e.localInteractors.resolve}):{},...c.operations.captureScreenshot.available?ne({device:a.device,signal:a.scope.signal,resolveInteractor:e.localInteractors.resolve}):{},...c.operations.focusPoint.available?m({device:a.device,signal:a.scope.signal,resolveInteractor:e.localInteractors.resolve}):{},...c.operations.typeText.available?g({device:a.device,signal:a.scope.signal,resolveInteractor:e.localInteractors.resolve}):{},...ce({device:a.device,signal:a.scope.signal,facts:c.operations,resolveInteractor:e.localInteractors.resolve}),...c.operations.scrollDirection.available?te({device:a.device,signal:a.scope.signal,resolveInteractor:e.localInteractors.resolve}):{},...C({device:a.device,signal:a.scope.signal,resolveInteractor:e.localInteractors.resolve,facts:c.operations}),...r(c.operations.perfFrames,()=>we({resolveHost:()=>e.perf.harmony,device:a.device})),...r(c.operations.tapPoint,()=>s({device:a.device,signal:a.scope.signal,resolveInteractor:e.localInteractors.resolve,facts:c.operations,pause:async t=>await e.clock.sleep(t,a.scope.signal)})),listApps:async e=>{a.scope.signal.throwIfAborted();let{listHarmonyApps:t}=await import(`./app-lifecycle2.js`);return(await t(e.device,e.filter,{signal:a.scope.signal})).map(e=>({id:e.package,name:e.name}))},...i(ze({host:e.localInteractors,device:a.device,signal:a.scope.signal}),c.operations)}),[Symbol.asyncDispose]:async()=>await o[Symbol.asyncDispose]()})},shutdown:async()=>await t.shutdown()})}export{ct as createHarmonyPlatformRuntime};
1
+ import{D as e}from"./sdk-contracts.js";import{T as t}from"./sdk-device.js";import{Kt as n,Qt as r}from"./sdk-batch.js";import{n as i}from"./device-shell.js";import{n as a,t as o}from"./application-lifecycle-runtime.js";import{i as s,t as c}from"./touch-runtime.js";import{A as l,D as u,G as d,H as f,I as p,L as ee,N as te,O as m,P as h,R as g,T as ne,U as re,a as ie,b as ae,d as oe,g as se,i as ce,j as le,m as ue,s as de,t as fe,v as pe,w as me,x as he,z as ge}from"./alert-runtime.js";import{n as _e}from"./audio-probe-runtime.js";import{n as ve}from"./perf-runtime.js";import{a as _,n as v}from"./durable-resource.js";import{n as ye}from"./async-lifecycle.js";import{i as be,r as xe}from"./src7.js";import{n as y,t as b}from"./screen-recording-completion.js";import{t as x}from"./screen-recording-options.js";import{n as S}from"./screen-recording-runtime.js";import{i as C}from"./gesture-admission.js";import{t as w}from"./interactor-operation-catalog.js";import{i as T,n as E}from"./perf-runtime-operation-builder.js";import{t as D}from"./app-log-runtime.js";import{n as O,t as k}from"./application-lifecycle-interaction.js";import{randomUUID as A}from"node:crypto";import{setTimeout as j}from"node:timers/promises";const M=Object.freeze({resourceKind:D,version:1,encode:e=>({...e}),decode:e=>e.transport!==`harmony-hilog`||!N(e.outputPath)||!N(e.pidPath)?{status:`invalid`,message:`Invalid HarmonyOS app-log descriptor`}:{status:`decoded`,descriptor:Object.freeze({transport:`harmony-hilog`,outputPath:e.outputPath,pidPath:e.pidPath})}});function Se(e){return v({resourceKind:D,sessionId:e.sessionId,device:{id:e.device.id,family:`harmonyos`,kind:e.device.kind,...e.device.target===void 0?{}:{target:e.device.target}},owner:e.owner,fence:e.fence,lifecycle:`open`,descriptor:_(M,e.descriptor)})}function N(e){return typeof e==`string`&&e.trim().length>0}function Ce(e){return xe(e,{family:`harmonyos`,backend:`harmonyos`,label:`HarmonyOS`,codec:M,startUnavailableHint:`The selected HarmonyOS transport cannot start a background hilog stream.`,cleanupFailureMessage:`HarmonyOS app-log cleanup did not settle every owned resource`,doctor:async(e,t)=>({backend:`harmonyos`,checks:{},notes:t?[]:[`No app bundle is tracked in this session. Run open <app> first for app-scoped logs.`]}),process:async({host:e,device:t,input:n,signal:r})=>{let a=await we(e,r);return{resolvePid:async r=>await be(e,{executable:a,args:i(`hdc`,`shell`,[`pidof`,n.appBundleId],[`-t`,t.id]),allowFailure:!0,timeoutMs:5e3},r),command:e=>({kind:`host`,request:{executable:a,args:i(`hdc`,`shell`,[`hilog`,`-P`,e],[`-t`,t.id]),allowFailure:!0}})}},descriptor:({artifacts:e})=>({transport:`harmony-hilog`,...e}),envelope:({input:e,device:t,owner:n,descriptor:r})=>Se({sessionId:e.sessionId,device:t,owner:n,fence:e.fence,descriptor:r})})}async function we(t,n){n.throwIfAborted(),await P(async()=>await t.toolchains.prepare(`harmonyos`),n),n.throwIfAborted();let r=await P(async()=>await t.commands.which(`hdc`),n);if(n.throwIfAborted(),!r)throw new e(`TOOL_MISSING`,`hdc not found in PATH`,{hint:`Install HarmonyOS Command Line Tools, then add its sdk/default/openharmony/toolchains directory to PATH.`});return r}async function P(e,t){try{return await e()}catch(e){throw t.throwIfAborted(),e}}function Te(e){let{resolveHost:t,device:n}=e,r={available:!1,reason:`Dropped-frame sampling is currently available only on Android app sessions and connected iOS device app sessions.`};return Object.freeze({perfFrames:async()=>({metric:r,sampling:r}),perfMemorySample:async({appId:e})=>({metric:e?await T(t().sampleMemory(n,e)):E(`HarmonyOS`,`bundle`),sampling:{method:`hdc-shell-proc-status`,description:`Resident memory snapshot from HarmonyOS /proc/<pid>/status. Values are reported in kilobytes.`,unit:`kB`,topConsumerLimit:1}}),perfMemorySnapshot:async({kind:e})=>({artifact:{available:!1,kind:e??`memgraph`,reason:`Memory snapshot artifacts are not supported on harmonyos.`,hint:`Use perf memory sample where supported, or run the snapshot against Android, iOS simulator, or macOS.`,support:{platform:`harmonyos`,defaultKind:`memgraph`,androidHprof:!1,memgraph:!1,heapprofd:!1}},sampling:{method:`unsupported`,description:`HarmonyOS memory snapshot capture is not available through HDC.`,artifactOnly:!0}})})}const F=Object.freeze({resourceKind:S,version:1,encode:e=>({...e}),decode:e=>e.backend===`harmony-screen-recorder`&&typeof e.fileName==`string`&&Oe(e.fileName)&&e.remotePath===`/data/local/tmp/${e.fileName}`?{status:`decoded`,descriptor:Object.freeze({backend:`harmony-screen-recorder`,fileName:e.fileName,remotePath:e.remotePath})}:{status:`invalid`,message:`Invalid HarmonyOS screen-recording descriptor`}});function Ee(e){let{device:n,owner:r,input:i,descriptor:a}=e;return v({resourceKind:S,sessionId:i.sessionId,device:t(n),owner:r,fence:i.fence,lifecycle:`open`,descriptor:_(F,a)})}function De(e){return F.decode(e).status===`decoded`?{status:`cleanup-pending`,reason:`manual-recovery-required`,message:`HarmonyOS recorder ownership cannot be proven after daemon restart; no recorder was stopped.`}:{status:`cleanup-pending`,reason:`manual-recovery-required`}}function Oe(e){return/^agent-device-recording-[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.mp4$/i.test(e)}function ke(e){return e.kind===`device`?Object.freeze({available:!0}):Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`HarmonyOS recording is supported on physical devices only.`})}function Ae(e){let{host:t,device:n,owner:r,signal:i}=e;return Object.freeze({screenRecordingStart:async e=>await je({host:t,device:n,owner:r,input:e,signal:i}),screenRecordingReattach:async()=>({status:`unreattachable`,reason:`transport-not-reattachable`,message:`HarmonyOS recordings cannot be reattached after daemon restart.`}),screenRecordingCleanup:async e=>De(e.envelope.descriptor.body)})}async function je(t){let{host:n,device:r,owner:i,input:a,signal:o}=t;if(a.scope===`app`)throw new e(`INVALID_ARGS`,`HarmonyOS recording captures the whole physical-device screen; use --scope device or --scope system`);x(a,{scopes:[`device`,`system`],fps:!1,exportQuality:!1,hideTouches:!1},e=>`HarmonyOS recordings do not support ${e.join(`, `)}`),o.throwIfAborted(),await n.screenRecording.outputs.prepare(a.outputPath);let s=`agent-device-recording-${A()}.mp4`,c={backend:`harmony-screen-recorder`,fileName:s,remotePath:`/data/local/tmp/${s}`},l;try{l=await n.screenRecording.harmony.start(r,s,o),o.throwIfAborted()}catch(e){throw o.aborted?(await L(n,r,c).catch(()=>{}),o.reason):e}z(l,`start`);try{o.throwIfAborted()}catch(e){throw await L(n,r,c).catch(()=>{}),e}let u=Me(a),d=!1,f=async()=>{d||=(z(await n.screenRecording.harmony.stop(r),`stop`),!0)},p=y(u,{finish:async e=>await Ne(n,r,e,c,f),forceCleanup:async()=>await L(n,r,c,f)});return Object.freeze({pendingHandle:new ye(p),envelope:Ee({device:r,owner:i,input:a,descriptor:c})})}function Me(e){return Object.freeze({backend:`HarmonyOS ScreenRecorder`,outPath:e.outputPath,...e.clientOutputPath===void 0?{}:{clientOutPath:e.clientOutputPath},startedAt:Date.now(),scope:e.scope,showTouches:!1,recordOnlySession:e.recordOnlySession,...e.activeSessionApp===void 0?{}:{activeSessionApp:e.activeSessionApp},gestureEvents:[]})}async function Ne(e,t,n,r,i){await i();let a=await e.screenRecording.harmony.findMedia(t,r.fileName);if(!a)throw Error(`failed to find finalized HarmonyOS recording '${r.fileName}'`);if(!await Ie(e,t,r,a))throw Error(`failed to finalize HarmonyOS recording: ${r.fileName} did not produce a non-empty media file`);try{if((await e.screenRecording.harmony.pull(t,{remotePath:r.remotePath,outputPath:n.outPath})).exitCode!==0)throw Error(`failed to retrieve HarmonyOS recording`);let i=await e.screenRecording.finalize.complete({outputPath:n.outPath,showTouches:!1,gestureEvents:n.gestureEvents,targetLabel:`HarmonyOS recording`}),o=await Pe(e,t,r,a);return b(n,{...i,...Fe(i.warning,o)},{stopObservation:{recorder:`confirmed`},nativePathDisposition:o===void 0?`retired`:`retirable`,showTouches:!1})}catch(n){throw await e.screenRecording.harmony.remove(t,r.remotePath).catch(()=>{}),n}}async function Pe(e,t,n,r){let i=[];return await I(()=>e.screenRecording.harmony.remove(t,n.remotePath))||i.push(`staging artifact`),await I(()=>e.screenRecording.harmony.removeMedia(t,r))||i.push(`media-library artifact`),i.length===0?void 0:`HarmonyOS recording completed, but cleanup was not confirmed for the ${i.join(` and `)}.`}async function I(e){try{return await e()}catch{return!1}}function Fe(e,t){let n=[e,t].filter(e=>e!==void 0).join(` `);return n.length===0?{}:{warning:n}}async function Ie(e,t,n,r){let i;for(let a=0;a<40;a+=1){if(await e.screenRecording.harmony.remove(t,n.remotePath).catch(()=>{}),await e.screenRecording.harmony.stageMedia(t,{mediaUri:r,remotePath:n.remotePath})){let r=await e.screenRecording.harmony.stagedFileSize(t,n.remotePath);if(r!==void 0&&r>0&&r===i)return!0;i=r!==void 0&&r>0?r:void 0}else i=void 0;a<39&&await e.clock.sleep(250)}return!1}async function L(e,t,n,r=async()=>{z(await e.screenRecording.harmony.stop(t),`stop`)}){let i=[await R(r),await R(async()=>{if(!await e.screenRecording.harmony.remove(t,n.remotePath))throw Error(`HarmonyOS recording staging artifact removal was not confirmed`)}),await R(async()=>await Le(e,t,n.fileName))].find(e=>e!==void 0);return i===void 0?{status:`cleaned`}:{status:`cleanup-pending`,reason:`transport-failed`,message:i instanceof Error?i.message:`HarmonyOS recording cleanup failed`}}async function Le(e,t,n){let r=await e.screenRecording.harmony.findMedia(t,n);if(r&&!await e.screenRecording.harmony.removeMedia(t,r))throw Error(`HarmonyOS recording media removal was not confirmed`)}async function R(e){try{await e();return}catch(e){return e}}function z(e,t){if(e.exitCode===0&&e.stdout.includes(`start ability successfully`))return;let n=e.stdout.trim()||e.stderr.trim()||`hdc exit ${e.exitCode}`;throw Error(`failed to ${t} HarmonyOS screen recording: ${n}`)}async function Re(t,n){n.throwIfAborted();let{runHarmonyShell:r}=await import(`./hdc.js`),i=await r(t,[`aa`,`dump`,`-l`],{timeoutMs:15e3,signal:n});n.throwIfAborted();let a=ze(i.stdout);if(!a)throw new e(`COMMAND_FAILED`,`Could not determine the foreground HarmonyOS app`,{hint:`Open an app on the target, then retry appstate.`});return a}function ze(e){let t=e.split(/(?=^\s*Mission ID #)/m);for(let e of t){if(!/\bstate #FOREGROUND\b/.test(e))continue;let t=e.match(/mission name #\[#([^:]+):[^:]*:([^\]]+)]/);if(!t)continue;let[,n,r]=t;if(!(!n||!r))return{package:n,activity:r}}}function Be(e){return k({owner:`HarmonyOS`,openTargetIdentity:`bundle-id`,binding:O({device:e.device,signal:e.signal,resolveInteractor:e.host.resolve})})}const Ve=Object.freeze({available:!0}),He=Object.freeze({available:!1,reason:`unsupported-device-kind`}),B=Object.freeze({available:!1,reason:`unsupported-platform-leaf`});function V(e){let t=e.kind===`emulator`||e.kind===`device`?Ve:He;return Object.freeze({deployApp:t,materializeAppSource:B,deployMaterializedApp:B,sendPushNotification:B})}function Ue(e){return V(e.device).deployApp.available?Object.freeze({deployApp:async t=>await We(e.commands,e.device,t,e.signal)}):Object.freeze({})}async function We(t,n,r,i){let a=await Ge(t,r.appPath,i)??r.app.trim();if(!a)throw new e(`INVALID_ARGS`,`Could not determine the bundle name from the HAP archive`,{hint:`Pass the HarmonyOS bundle name before the HAP path, or provide a valid HAP containing module.json.`});return await Je(t,n,[`install`,`-r`,r.appPath],i,18e4),r.replaceExisting&&(await j(1e3,void 0,{signal:i}),await Ke(t,n,a,i)),{packageName:a,launchTarget:a}}async function Ge(e,t,n){let r=await e.run({executable:`unzip`,args:[`-p`,t,`module.json`],allowFailure:!0,timeoutMs:15e3},n);if(r.exitCode===0&&r.stdout.trim().length!==0)try{return JSON.parse(r.stdout).app?.bundleName?.trim()||void 0}catch{return}}async function Ke(t,n,r,i){let a=qe((await H(t,n,[`bm`,`dump`,`-n`,r],i)).stdout);if(!a)throw new e(`COMMAND_FAILED`,`Could not determine a launchable ability for ${r}`,{hint:`Check that the HarmonyOS bundle exposes a main ability.`});await H(t,n,[`aa`,`start`,`-b`,r,...a.module?[`-m`,a.module]:[],`-a`,a.ability],i)}function qe(e){let t=e.indexOf(`{`);if(t!==-1)try{let n=JSON.parse(e.slice(t)).hapModuleInfos?.find(e=>e.mainElementName);return n?.mainElementName?{ability:n.mainElementName,...n.moduleName?{module:n.moduleName}:{}}:void 0}catch{return}}async function Je(e,t,n,r,i=15e3){return await e.run({executable:`hdc`,args:[`-t`,t.id,...n],timeoutMs:i},r)}async function H(e,t,n,r,a=15e3){return await e.run({executable:`hdc`,args:i(`hdc`,`shell`,n,[`-t`,t.id]),timeoutMs:a},r)}const U=n(`harmonyos`),Ye=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`HarmonyOS reads element text from the captured tree only.`}),Xe=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`focus is supported on HarmonyOS emulators and physical devices.`}),W=Object.freeze({available:!0}),G=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),Ze=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`HarmonyOS appstate is supported only for HarmonyOS emulators and devices.`}),Qe=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`Apple runner preparation is supported only for Apple targets.`}),K=Object.freeze({available:!0}),$e=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`open is supported only for HarmonyOS emulators and devices.`}),et=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`close is supported only for HarmonyOS emulators and devices.`}),q=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Port reverse is supported only by an owning provider runtime.`}),J=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`snapshot is supported only for HarmonyOS emulators and devices.`}),tt=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`screenshot is supported only for HarmonyOS emulators and devices.`}),nt=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`Re-run without --actions, or target an iOS simulator.`}),rt=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`viewport resizes web targets only (--platform web).`});function it(e){let t=at(e),n=ot(e);return o({resolveOpenTarget:t,prepareApplicationOpen:t,openApplication:t,applyRuntimeHints:G,clearRuntimeHints:G,closeApplication:n,finalizeApplicationClose:n,prepareAppleRunner:Qe,configureProviderPortReverse:q})}function at(e){return e.kind===`emulator`||e.kind===`device`?K:$e}function ot(e){return e.kind===`emulator`||e.kind===`device`?K:et}const Y=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`Gestures are supported on HarmonyOS emulators and physical devices.`}),st=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),ct=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:C});function X(e){return e.kind===`emulator`||e.kind===`device`?W:Y}function Z(e){return e.kind===`emulator`||e.kind===`device`?W:Xe}const Q=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),lt=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`keyboard status/get is not available through the public HarmonyOS HDC API; use keyboard dismiss or enter`}),$=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`audio is supported for web browser sessions, macOS sessions, iOS simulators, and Android emulators on macOS hosts`});function ut(e){let t=Ce(e),n=async e=>{let n=await t.inspectFacts(e),r=V(e),i=ke(e);return Object.freeze({device:n.device,operations:{...n.operations,...r,appState:e.kind===`simulator`?Ze:W,networkDump:G,screenRecordingStart:i,screenRecordingReattach:i,screenRecordingCleanup:i,...f({capture:e.kind===`emulator`||e.kind===`device`?W:J,customActions:nt,withoutActiveApp:e.kind===`emulator`||e.kind===`device`?W:J}),...d({capture:e.kind===`emulator`||e.kind===`device`?W:tt}),...g({findText:J}),...ee({setViewport:rt}),...p({focus:Z(e)}),...te({unsupported:Y,plan:X(e),directionalFling:X(e),multiTouch:st,targetAuthoredDrag:ct,viewport:X(e)}),...l({scroll:X(e)}),...u({type:Z(e)}),...s({unsupported:G,tap:Z(e),longPress:Z(e),fill:Z(e)}),...me({readTextAtPoint:Ye}),...he({back:Z(e)}),...ae({home:Z(e)}),...de({appSwitcher:Z(e)}),actionButton:Q,...ie({triggerAppEvent:Q}),...ce({setSetting:Z(e)}),...fe({read:Q,wait:Q,accept:Q,dismiss:Q}),...pe({orientation:Q}),...se({tvRemote:Q}),...ue({unsupported:Q,status:lt,dismiss:Z(e),enter:Z(e)}),...oe({unsupported:Q}),..._e({capture:$,query:$}),...ve({frames:Z(e),memorySample:Z(e),memorySnapshot:Z(e),nativeCapture:Q,profileReport:Q}),ensureReady:W,bootTarget:G,bootTargetHeadless:G,listApps:W,...it(e),shutdownTarget:G}})};return Object.freeze({owner:U,ownsDevice:e=>e.platform===`harmonyos`,inspectFacts:n,bind:async i=>{let o=await t.bind(i),s=await n(i.device),l=s.operations.screenRecordingStart;return Object.freeze({device:o.device,owner:U,facts:s,operations:Object.freeze({...o.operations,...Ue({commands:e.commands,device:i.device,signal:i.scope.signal}),...s.operations.appState.available?{appState:async()=>await Re(i.device,i.scope.signal)}:{},ensureReady:async()=>({...i.device,booted:!0}),...l.available?Ae({host:e,device:i.device,owner:U,signal:i.scope.signal}):{},...s.operations.captureSnapshot.available?ge({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve}):{},...s.operations.captureScreenshot.available?re({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve}):{},...s.operations.focusPoint.available?h({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve}):{},...s.operations.typeText.available?ne({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve}):{},...le({device:i.device,signal:i.scope.signal,facts:s.operations,resolveInteractor:e.localInteractors.resolve}),...s.operations.scrollDirection.available?m({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve}):{},...w({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve,facts:s.operations}),...r(s.operations.perfFrames,()=>Te({resolveHost:()=>e.perf.harmony,device:i.device})),...r(s.operations.tapPoint,()=>c({device:i.device,signal:i.scope.signal,resolveInteractor:e.localInteractors.resolve,facts:s.operations,pause:async t=>await e.clock.sleep(t,i.scope.signal)})),listApps:async e=>{i.scope.signal.throwIfAborted();let{listHarmonyApps:t}=await import(`./app-lifecycle2.js`);return(await t(e.device,e.filter,{signal:i.scope.signal})).map(e=>({id:e.package,name:e.name}))},...a(Be({host:e.localInteractors,device:i.device,signal:i.scope.signal}),s.operations)}),[Symbol.asyncDispose]:async()=>await o[Symbol.asyncDispose]()})},shutdown:async()=>await t.shutdown()})}export{ut as createHarmonyPlatformRuntime};
@@ -1 +1 @@
1
- import{C as e}from"./sdk-contracts.js";import{Gt as t,Xt as n}from"./sdk-batch.js";import{n as r,t as i}from"./application-lifecycle-runtime.js";import{i as a}from"./touch-runtime.js";import{A as o,D as s,G as c,H as ee,I as l,N as u,V as d,b as f,d as p,w as m,x as h}from"./alert-runtime.js";import{r as g}from"./platform-runtime-unavailable.js";import{i as _}from"./gesture-admission.js";import{t as v}from"./local-interactor-operation-set.js";import{n as y,t as b}from"./application-lifecycle-interaction.js";function x(e){return b({owner:`Linux`,openTargetIdentity:`app-name`,binding:y({device:e.device,signal:e.signal,resolveInteractor:e.host.resolve})})}const S=Object.freeze({available:!0}),C=t(`linux`),w=$(`unsupported-platform-leaf`),T=$(`unsupported-device-kind`),E=$(`unsupported-device-kind`,`focus is supported only for the Linux desktop device.`),D=$(`unsupported-device-kind`,`type is supported only for the Linux desktop device.`),O=$(`unsupported-device-kind`,`Gestures are supported only for the Linux desktop device.`),k=$(`unsupported-device-kind`,`scroll is supported only for the Linux desktop device.`),A=$(`unsupported-platform-leaf`),j=$(`unsupported-platform-leaf`),M=$(`unsupported-platform-leaf`,_),N=$(`unsupported-platform-leaf`),P=$(`unsupported-platform-leaf`,`Runtime hints are supported only for local iOS-family simulators and Android devices.`),F=$(`unsupported-platform-leaf`,`Apple runner preparation is supported only for Apple targets.`),I=$(`unsupported-provider-mode`,`Port reverse is supported only by an owning provider runtime.`),L=$(`unsupported-device-kind`,`open is supported only for the Linux desktop device.`),R=$(`unsupported-device-kind`,`close is supported only for the Linux desktop device.`),z=$(`unsupported-device-kind`,`snapshot is supported only for the Linux desktop device.`),B=$(`unsupported-device-kind`,`screenshot is supported only for the Linux desktop device.`),V=$(`unsupported-platform-leaf`,`Re-run without --actions, or target an iOS simulator.`),H=$(`unsupported-device-kind`,`back is supported only for the Linux desktop device.`),U=$(`unsupported-device-kind`,`home is supported only for the Linux desktop device.`),W=$(`unsupported-device-kind`,`clipboard is supported only for the Linux desktop device.`),G=w,K=$(`unsupported-platform-leaf`,`audio is supported for web browser sessions, macOS sessions, iOS simulators, and Android emulators on macOS hosts`);function q(t){return Object.freeze({owner:C,ownsDevice:e=>e.platform===`linux`,inspectFacts:async e=>Y(e),bind:async i=>{if(i.intent.kind===`exact-owner`&&!n(i.intent.owner,C))throw new e(`UNSUPPORTED_OPERATION`,`Linux runtime owner identity does not match`);if(i.device.platform!==`linux`)throw new e(`UNSUPPORTED_PLATFORM`,`Linux runtime cannot bind this device`);let a=Y(i.device),o=x({host:t.localInteractors,device:i.device,signal:i.scope.signal});return Object.freeze({device:i.device,owner:C,facts:a,operations:Object.freeze({...r(o,a.operations),...a.operations.captureSnapshot.available?Q(t,i):{},...J(t,i,a)}),[Symbol.asyncDispose]:async()=>void 0})},shutdown:async()=>void 0})}function J(e,t,n){let r={device:t.device,signal:t.scope.signal,resolveInteractor:e.localInteractors.resolve};return v({...r,facts:n.operations,pause:async n=>await e.clock.sleep(n,t.scope.signal)})}function Y(e){let t=e.kind===`device`?S:L,n=e.kind===`device`?S:R,r=g(e,C,{appLog:w,network:w,screenshot:B,snapshot:z,viewport:w,focus:E,gesture:O,scroll:k,typeText:D,touch:E,elementText:T,back:H,home:U,orientation:G,tvRemote:G,clipboard:W,appSwitcher:G,triggerAppEvent:G,setSetting:G,readAlert:G,awaitAlert:G,acceptAlert:G,dismissAlert:G,keyboard:G,audioProbeCapture:K,audioProbeQuery:K,perf:G,readiness:w,lifecycle:i({resolveOpenTarget:t,prepareApplicationOpen:t,openApplication:t,applyRuntimeHints:P,clearRuntimeHints:P,closeApplication:n,finalizeApplicationClose:n,prepareAppleRunner:F,configureProviderPortReverse:I})});return Object.freeze({device:r.device,operations:{...r.operations,...ee({capture:X(e,z),customActions:V,withoutActiveApp:X(e,z)}),...c({capture:X(e,B)}),...l({focus:X(e,E)}),...u({unsupported:O,plan:X(e,O),directionalFling:A,multiTouch:j,targetAuthoredDrag:M,viewport:N}),...o({scroll:X(e,k)}),...s({type:X(e,D)}),...Z(e),...m({readTextAtPoint:X(e,T)}),...h({back:X(e,H)}),...f({home:X(e,U)}),...p({unsupported:W,read:X(e,W),write:X(e,W)})}})}function X(e,t){return e.kind===`device`?S:t}function Z(e){let t=e.kind===`device`?S:E;return a({unsupported:w,tap:t,longPress:t,fill:t})}function Q(e,t){let n=async n=>await e.snapshot.captureSurface(t.device,n.options,d(t.scope.signal,n));return Object.freeze({captureSnapshot:n,captureSnapshotWithCustomActions:n,captureSnapshotWithoutActiveApp:n})}function $(e,t){return Object.freeze(t===void 0?{available:!1,reason:e}:{available:!1,reason:e,hint:t})}export{q as createLinuxPlatformRuntime};
1
+ import{D as e}from"./sdk-contracts.js";import{Kt as t,Zt as n}from"./sdk-batch.js";import{n as r,t as i}from"./application-lifecycle-runtime.js";import{i as a}from"./touch-runtime.js";import{A as o,D as s,G as c,H as ee,I as l,N as u,V as d,b as f,d as p,w as m,x as h}from"./alert-runtime.js";import{r as g}from"./platform-runtime-unavailable.js";import{i as _}from"./gesture-admission.js";import{t as v}from"./local-interactor-operation-set.js";import{n as y,t as b}from"./application-lifecycle-interaction.js";function x(e){return b({owner:`Linux`,openTargetIdentity:`app-name`,binding:y({device:e.device,signal:e.signal,resolveInteractor:e.host.resolve})})}const S=Object.freeze({available:!0}),C=t(`linux`),w=$(`unsupported-platform-leaf`),T=$(`unsupported-device-kind`),E=$(`unsupported-device-kind`,`focus is supported only for the Linux desktop device.`),D=$(`unsupported-device-kind`,`type is supported only for the Linux desktop device.`),O=$(`unsupported-device-kind`,`Gestures are supported only for the Linux desktop device.`),k=$(`unsupported-device-kind`,`scroll is supported only for the Linux desktop device.`),A=$(`unsupported-platform-leaf`),j=$(`unsupported-platform-leaf`),M=$(`unsupported-platform-leaf`,_),N=$(`unsupported-platform-leaf`),P=$(`unsupported-platform-leaf`,`Runtime hints are supported only for local iOS-family simulators and Android devices.`),F=$(`unsupported-platform-leaf`,`Apple runner preparation is supported only for Apple targets.`),I=$(`unsupported-provider-mode`,`Port reverse is supported only by an owning provider runtime.`),L=$(`unsupported-device-kind`,`open is supported only for the Linux desktop device.`),R=$(`unsupported-device-kind`,`close is supported only for the Linux desktop device.`),z=$(`unsupported-device-kind`,`snapshot is supported only for the Linux desktop device.`),B=$(`unsupported-device-kind`,`screenshot is supported only for the Linux desktop device.`),V=$(`unsupported-platform-leaf`,`Re-run without --actions, or target an iOS simulator.`),H=$(`unsupported-device-kind`,`back is supported only for the Linux desktop device.`),U=$(`unsupported-device-kind`,`home is supported only for the Linux desktop device.`),W=$(`unsupported-device-kind`,`clipboard is supported only for the Linux desktop device.`),G=w,K=$(`unsupported-platform-leaf`,`audio is supported for web browser sessions, macOS sessions, iOS simulators, and Android emulators on macOS hosts`);function q(t){return Object.freeze({owner:C,ownsDevice:e=>e.platform===`linux`,inspectFacts:async e=>Y(e),bind:async i=>{if(i.intent.kind===`exact-owner`&&!n(i.intent.owner,C))throw new e(`UNSUPPORTED_OPERATION`,`Linux runtime owner identity does not match`);if(i.device.platform!==`linux`)throw new e(`UNSUPPORTED_PLATFORM`,`Linux runtime cannot bind this device`);let a=Y(i.device),o=x({host:t.localInteractors,device:i.device,signal:i.scope.signal});return Object.freeze({device:i.device,owner:C,facts:a,operations:Object.freeze({...r(o,a.operations),...a.operations.captureSnapshot.available?Q(t,i):{},...J(t,i,a)}),[Symbol.asyncDispose]:async()=>void 0})},shutdown:async()=>void 0})}function J(e,t,n){let r={device:t.device,signal:t.scope.signal,resolveInteractor:e.localInteractors.resolve};return v({...r,facts:n.operations,pause:async n=>await e.clock.sleep(n,t.scope.signal)})}function Y(e){let t=e.kind===`device`?S:L,n=e.kind===`device`?S:R,r=g(e,C,{appLog:w,network:w,screenshot:B,snapshot:z,viewport:w,focus:E,gesture:O,scroll:k,typeText:D,touch:E,elementText:T,back:H,home:U,orientation:G,tvRemote:G,clipboard:W,appSwitcher:G,actionButton:G,triggerAppEvent:G,setSetting:G,readAlert:G,awaitAlert:G,acceptAlert:G,dismissAlert:G,keyboard:G,audioProbeCapture:K,audioProbeQuery:K,perf:G,readiness:w,lifecycle:i({resolveOpenTarget:t,prepareApplicationOpen:t,openApplication:t,applyRuntimeHints:P,clearRuntimeHints:P,closeApplication:n,finalizeApplicationClose:n,prepareAppleRunner:F,configureProviderPortReverse:I})});return Object.freeze({device:r.device,operations:{...r.operations,...ee({capture:X(e,z),customActions:V,withoutActiveApp:X(e,z)}),...c({capture:X(e,B)}),...l({focus:X(e,E)}),...u({unsupported:O,plan:X(e,O),directionalFling:A,multiTouch:j,targetAuthoredDrag:M,viewport:N}),...o({scroll:X(e,k)}),...s({type:X(e,D)}),...Z(e),...m({readTextAtPoint:X(e,T)}),...h({back:X(e,H)}),...f({home:X(e,U)}),...p({unsupported:W,read:X(e,W),write:X(e,W)})}})}function X(e,t){return e.kind===`device`?S:t}function Z(e){let t=e.kind===`device`?S:E;return a({unsupported:w,tap:t,longPress:t,fill:t})}function Q(e,t){let n=async n=>await e.snapshot.captureSurface(t.device,n.options,d(t.scope.signal,n));return Object.freeze({captureSnapshot:n,captureSnapshotWithCustomActions:n,captureSnapshotWithoutActiveApp:n})}function $(e,t){return Object.freeze(t===void 0?{available:!1,reason:e}:{available:!1,reason:e,hint:t})}export{q as createLinuxPlatformRuntime};
@@ -1 +1 @@
1
- import{C as e}from"./sdk-contracts.js";import{Gt as t,Xt as n}from"./sdk-batch.js";import{n as r,t as i}from"./application-lifecycle-runtime.js";import{N as a,b as o,g as s,x as c}from"./alert-runtime.js";import{r as l}from"./platform-runtime-unavailable.js";import{i as u}from"./gesture-admission.js";import{t as d}from"./interactor-operation-catalog.js";import{n as f,t as p}from"./application-lifecycle-interaction.js";function m(e){return p({owner:`Vega`,openTargetIdentity:`app-name`,binding:f({device:e.device,signal:e.signal,resolveInteractor:e.host.resolve})})}const h=t(`vega`),g=Object.freeze({available:!0}),_=U(`unsupported-platform-leaf`),v=U(`unsupported-platform-leaf`,`Runtime hints are supported only for local iOS-family simulators and Android devices.`),y=U(`unsupported-platform-leaf`,`Apple runner preparation is supported only for Apple targets.`),b=U(`unsupported-provider-mode`,`Port reverse is supported only by an owning provider runtime.`),x=U(`unsupported-device-kind`,`open currently supports only Vega Virtual Devices.`),S=U(`unsupported-device-kind`,`close currently supports only Vega Virtual Devices.`);function C(t){return Object.freeze({owner:h,ownsDevice:e=>e.platform===`vega`,inspectFacts:async e=>H(e),bind:async i=>{if(i.intent.kind===`exact-owner`&&!n(i.intent.owner,h))throw new e(`UNSUPPORTED_OPERATION`,`Vega runtime owner identity does not match`);if(i.device.platform!==`vega`)throw new e(`UNSUPPORTED_PLATFORM`,`Vega runtime cannot bind this device`);let a=H(i.device),o=m({host:t.localInteractors,device:i.device,signal:i.scope.signal});return Object.freeze({device:i.device,owner:h,facts:a,operations:Object.freeze({...r(o,a.operations),...d({device:i.device,signal:i.scope.signal,resolveInteractor:t.localInteractors.resolve,facts:a.operations})}),[Symbol.asyncDispose]:async()=>void 0})},shutdown:async()=>void 0})}const w=U(`unsupported-platform-leaf`,`screenshot is not supported on Vega OS: the Vega runtime exposes remote navigation only.`),T=U(`unsupported-platform-leaf`,`focus is not supported on Vega OS: the Vega runtime exposes remote navigation only.`),E=U(`unsupported-platform-leaf`,`type is not supported on Vega OS: the Vega runtime exposes remote navigation only.`),D=U(`unsupported-platform-leaf`,`Gestures are not supported on Vega OS: the Vega runtime exposes remote navigation only.`),O=U(`unsupported-platform-leaf`,`scroll is not supported on Vega OS: the Vega runtime exposes remote navigation only.`),k=U(`unsupported-platform-leaf`),A=U(`unsupported-platform-leaf`,u),j=U(`unsupported-platform-leaf`,`orientation is not supported on Vega OS.`),M=U(`unsupported-platform-leaf`,`keyboard is not supported on Vega OS.`),N=U(`unsupported-platform-leaf`,`alert is not supported on Vega OS.`),P=U(`unsupported-platform-leaf`,`settings is not supported on Vega OS.`),F=U(`unsupported-platform-leaf`,`trigger-app-event is not supported on Vega OS.`),I=U(`unsupported-platform-leaf`,`app-switcher is not supported on Vega OS.`),L=U(`unsupported-platform-leaf`,`clipboard is not supported on Vega OS.`),R=U(`unsupported-device-kind`,`back currently supports only Vega Virtual Devices.`),z=U(`unsupported-device-kind`,`home currently supports only Vega Virtual Devices.`),B=U(`unsupported-device-kind`,`tv-remote currently supports only Vega Virtual Devices.`),V=U(`unsupported-platform-leaf`,`audio is supported for web browser sessions, macOS sessions, iOS simulators, and Android emulators on macOS hosts`);function H(e){let t=e.kind===`emulator`&&e.target===`tv`,n=t?g:x,r=t?g:S,u=l(e,h,{appLog:_,network:_,screenshot:w,snapshot:_,viewport:_,focus:T,gesture:D,scroll:O,typeText:E,touch:_,elementText:_,back:R,home:z,orientation:j,tvRemote:B,clipboard:L,appSwitcher:I,triggerAppEvent:F,setSetting:P,readAlert:N,awaitAlert:N,acceptAlert:N,dismissAlert:N,keyboard:M,audioProbeCapture:V,audioProbeQuery:V,perf:_,readiness:_,lifecycle:i({resolveOpenTarget:n,prepareApplicationOpen:n,openApplication:n,applyRuntimeHints:v,clearRuntimeHints:v,closeApplication:r,finalizeApplicationClose:r,prepareAppleRunner:y,configureProviderPortReverse:b})});return Object.freeze({device:u.device,operations:{...u.operations,...c({back:t?g:R}),...o({home:t?g:z}),...s({tvRemote:t?g:B}),...a({unsupported:D,multiTouch:k,targetAuthoredDrag:A})}})}function U(e,t){let n={available:!1,reason:e,...t===void 0?{}:{hint:t}};return Object.freeze(n)}export{C as createVegaPlatformRuntime};
1
+ import{D as e}from"./sdk-contracts.js";import{Kt as t,Zt as n}from"./sdk-batch.js";import{n as r,t as i}from"./application-lifecycle-runtime.js";import{N as a,b as o,g as s,x as c}from"./alert-runtime.js";import{r as l}from"./platform-runtime-unavailable.js";import{i as u}from"./gesture-admission.js";import{t as d}from"./interactor-operation-catalog.js";import{n as f,t as p}from"./application-lifecycle-interaction.js";function m(e){return p({owner:`Vega`,openTargetIdentity:`app-name`,binding:f({device:e.device,signal:e.signal,resolveInteractor:e.host.resolve})})}const h=t(`vega`),g=Object.freeze({available:!0}),_=W(`unsupported-platform-leaf`),v=W(`unsupported-platform-leaf`,`Runtime hints are supported only for local iOS-family simulators and Android devices.`),y=W(`unsupported-platform-leaf`,`Apple runner preparation is supported only for Apple targets.`),b=W(`unsupported-provider-mode`,`Port reverse is supported only by an owning provider runtime.`),x=W(`unsupported-device-kind`,`open currently supports only Vega Virtual Devices.`),S=W(`unsupported-device-kind`,`close currently supports only Vega Virtual Devices.`);function C(t){return Object.freeze({owner:h,ownsDevice:e=>e.platform===`vega`,inspectFacts:async e=>U(e),bind:async i=>{if(i.intent.kind===`exact-owner`&&!n(i.intent.owner,h))throw new e(`UNSUPPORTED_OPERATION`,`Vega runtime owner identity does not match`);if(i.device.platform!==`vega`)throw new e(`UNSUPPORTED_PLATFORM`,`Vega runtime cannot bind this device`);let a=U(i.device),o=m({host:t.localInteractors,device:i.device,signal:i.scope.signal});return Object.freeze({device:i.device,owner:h,facts:a,operations:Object.freeze({...r(o,a.operations),...d({device:i.device,signal:i.scope.signal,resolveInteractor:t.localInteractors.resolve,facts:a.operations})}),[Symbol.asyncDispose]:async()=>void 0})},shutdown:async()=>void 0})}const w=W(`unsupported-platform-leaf`,`screenshot is not supported on Vega OS: the Vega runtime exposes remote navigation only.`),T=W(`unsupported-platform-leaf`,`focus is not supported on Vega OS: the Vega runtime exposes remote navigation only.`),E=W(`unsupported-platform-leaf`,`type is not supported on Vega OS: the Vega runtime exposes remote navigation only.`),D=W(`unsupported-platform-leaf`,`Gestures are not supported on Vega OS: the Vega runtime exposes remote navigation only.`),O=W(`unsupported-platform-leaf`,`scroll is not supported on Vega OS: the Vega runtime exposes remote navigation only.`),k=W(`unsupported-platform-leaf`),A=W(`unsupported-platform-leaf`,u),j=W(`unsupported-platform-leaf`,`orientation is not supported on Vega OS.`),M=W(`unsupported-platform-leaf`,`keyboard is not supported on Vega OS.`),N=W(`unsupported-platform-leaf`,`alert is not supported on Vega OS.`),P=W(`unsupported-platform-leaf`,`settings is not supported on Vega OS.`),F=W(`unsupported-platform-leaf`,`trigger-app-event is not supported on Vega OS.`),I=W(`unsupported-platform-leaf`,`app-switcher is not supported on Vega OS.`),L=W(`unsupported-platform-leaf`,`action-button is not supported on Vega OS.`),R=W(`unsupported-platform-leaf`,`clipboard is not supported on Vega OS.`),z=W(`unsupported-device-kind`,`back currently supports only Vega Virtual Devices.`),B=W(`unsupported-device-kind`,`home currently supports only Vega Virtual Devices.`),V=W(`unsupported-device-kind`,`tv-remote currently supports only Vega Virtual Devices.`),H=W(`unsupported-platform-leaf`,`audio is supported for web browser sessions, macOS sessions, iOS simulators, and Android emulators on macOS hosts`);function U(e){let t=e.kind===`emulator`&&e.target===`tv`,n=t?g:x,r=t?g:S,u=l(e,h,{appLog:_,network:_,screenshot:w,snapshot:_,viewport:_,focus:T,gesture:D,scroll:O,typeText:E,touch:_,elementText:_,back:z,home:B,orientation:j,tvRemote:V,clipboard:R,appSwitcher:I,actionButton:L,triggerAppEvent:F,setSetting:P,readAlert:N,awaitAlert:N,acceptAlert:N,dismissAlert:N,keyboard:M,audioProbeCapture:H,audioProbeQuery:H,perf:_,readiness:_,lifecycle:i({resolveOpenTarget:n,prepareApplicationOpen:n,openApplication:n,applyRuntimeHints:v,clearRuntimeHints:v,closeApplication:r,finalizeApplicationClose:r,prepareAppleRunner:y,configureProviderPortReverse:b})});return Object.freeze({device:u.device,operations:{...u.operations,...c({back:t?g:z}),...o({home:t?g:B}),...s({tvRemote:t?g:V}),...a({unsupported:D,multiTouch:k,targetAuthoredDrag:A})}})}function W(e,t){let n={available:!1,reason:e,...t===void 0?{}:{hint:t}};return Object.freeze(n)}export{C as createVegaPlatformRuntime};
@@ -1 +1 @@
1
- import{C as e}from"./sdk-contracts.js";import{w as t}from"./sdk-device.js";import{Gt as n,Xt as r,Zt as i}from"./sdk-batch.js";import{n as a,t as o}from"./application-lifecycle-runtime.js";import{i as s,t as c}from"./touch-runtime.js";import{A as l,D as u,G as d,H as f,I as p,L as m,N as ee,O as te,P as ne,R as re,T as ie,U as h,a as g,b as _,d as v,g as ae,i as y,m as oe,s as b,t as x,v as S,w as C,x as w,z as T}from"./alert-runtime.js";import{n as E}from"./audio-probe-runtime.js";import{n as D}from"./perf-runtime.js";import{a as O,n as k}from"./durable-resource.js";import{n as A}from"./async-lifecycle.js";import"./src7.js";import{n as j,t as M}from"./screen-recording-completion.js";import{t as N}from"./screen-recording-options.js";import{n as P}from"./screen-recording-runtime.js";import{i as F}from"./gesture-admission.js";import{n as I,t as L}from"./application-lifecycle-interaction.js";const R=Object.freeze({resourceKind:P,version:1,encode:e=>({...e}),decode:e=>e.backend===`agent-browser`&&typeof e.outputPath==`string`?{status:`decoded`,descriptor:Object.freeze({backend:`agent-browser`,outputPath:e.outputPath})}:{status:`invalid`,message:`Invalid web screen-recording descriptor`}});async function z(e){let{host:t,device:n,owner:r,signal:i}=e,a=await t.screenRecording.web.resolve(n);return a?{available:!0,operations:{screenRecordingStart:async e=>await B({host:t,transport:a,device:n,owner:r,input:e,signal:i}),screenRecordingReattach:async()=>({status:`unreattachable`,reason:`transport-not-reattachable`,message:`Web recordings cannot be reattached after daemon restart.`}),screenRecordingCleanup:async()=>V()}}:{available:!1,operations:{}}}async function B(n){let{host:r,transport:i,device:a,owner:o,input:s,signal:c}=n;if(s.recordOnlySession)throw new e(`INVALID_ARGS`,`record on web requires an active browser session; run open <url> --platform web first`);if(!s.outputPath.toLowerCase().endsWith(`.webm`))throw new e(`INVALID_ARGS`,`web recordings require a .webm output path; agent-browser records WebM directly`);N(s,{scopes:[`app`],fps:!1,exportQuality:!1,hideTouches:!1},e=>`web recordings do not support ${e.join(`, `)}; agent-browser records WebM directly`),c.throwIfAborted(),await r.screenRecording.outputs.prepare(s.outputPath);let l=!1;try{await i.start(s.outputPath,c),l=!0,c.throwIfAborted()}catch(e){throw l&&await i.stop().catch(()=>{}),c.throwIfAborted(),e}let u=!1,d=async()=>{u||=(await i.stop(),!0)},f=j({backend:`agent-browser`,outPath:s.outputPath,...s.clientOutputPath===void 0?{}:{clientOutPath:s.clientOutputPath},startedAt:Date.now(),scope:s.scope,showTouches:!1,recordOnlySession:s.recordOnlySession,...s.activeSessionApp===void 0?{}:{activeSessionApp:s.activeSessionApp},gestureEvents:[]},{finish:async e=>{await d();let t=await r.screenRecording.finalize.complete({outputPath:e.outPath,showTouches:!1,gestureEvents:e.gestureEvents,targetLabel:`web recording`});return M(e,t,{stopObservation:{recorder:`confirmed`},showTouches:!1})},forceCleanup:async()=>{try{return await d(),{status:`cleaned`}}catch(e){return{status:`cleanup-pending`,reason:`transport-failed`,message:e instanceof Error?e.message:`Web recording cleanup failed`}}}});return Object.freeze({pendingHandle:new A(f),envelope:k({resourceKind:P,sessionId:s.sessionId,device:t(a),owner:o,fence:s.fence,lifecycle:`open`,descriptor:O(R,{backend:`agent-browser`,outputPath:s.outputPath})})})}function V(){return{status:`cleanup-pending`,reason:`manual-recovery-required`,message:`Web recordings cannot be cleaned after daemon restart.`}}function H(e){return L({owner:`web`,openTargetIdentity:`app-name`,binding:I({device:e.device,signal:e.signal,resolveInteractor:e.host.resolve})})}const U=n(`web`),W=Object.freeze({available:!0}),G=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`Web targets read element text from the captured tree only.`}),K=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),q=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`record is not supported by this web provider`}),se=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`Re-run without --actions, or target an iOS simulator.`}),J=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),ce=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`apps is not supported on web targets.`}),le=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),Y=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),ue=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`Apple runner preparation is supported only for Apple targets.`}),de=Object.freeze({available:!1,reason:`owner-capability-missing`}),fe=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`audio on web sessions is the stateless page probe; host capture is a macOS-host operation.`});function X(e,t){return typeof e==`function`?t:de}function Z(e,t){return e?W:t}const pe=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),me=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:F}),Q=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`open is supported only for web browser devices.`}),he=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`close is supported only for web browser devices.`}),ge=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Port reverse is supported only by an owning provider runtime.`});function _e(e){let t=ve(e),n=ye(e);return o({resolveOpenTarget:t,prepareApplicationOpen:t,openApplication:t,applyRuntimeHints:J,clearRuntimeHints:J,closeApplication:n,finalizeApplicationClose:n,prepareAppleRunner:ue,configureProviderPortReverse:ge})}function ve(e){return e.kind===`device`?W:Q}function ye(e){return e.kind===`device`?W:he}function be(t){return Object.freeze({owner:U,ownsDevice:e=>e.platform===`web`,inspectFacts:async e=>{let n=await t.networkTransports.resolve(e),r=await z({host:t,device:e,owner:U,signal:new AbortController().signal}),i=e.kind===`device`?await t.localInteractors.resolve(e,{}):void 0;return $(e,n,r.available,i)},bind:async n=>{if(n.intent.kind===`exact-owner`&&!r(n.intent.owner,U))throw new e(`UNSUPPORTED_OPERATION`,`Web runtime owner identity does not match`);if(n.device.platform!==`web`)throw new e(`UNSUPPORTED_PLATFORM`,`Web runtime owner cannot bind ${n.device.platform}`);let i=await t.networkTransports.resolve(n.device),a=await z({host:t,device:n.device,owner:U,signal:n.scope.signal}),o=n.device.kind===`device`?await t.localInteractors.resolve(n.device,{signal:n.scope.signal}):void 0;return xe(t,n.device,n.scope.signal,i,a,$(n.device,i,a.available,o))},shutdown:async()=>void 0})}function xe(t,n,r,o,s,l){let u=o.dump,d={...u?{networkDump:async e=>{let t=await u({maxEntries:e.maxEntries,include:e.include},r);return Object.freeze({source:`provider`,...t})}}:{},...s.operations,...l.operations.captureSnapshot.available?T({device:n,signal:r,resolveInteractor:t.localInteractors.resolve}):{},...l.operations.captureScreenshot.available?h({device:n,signal:r,resolveInteractor:t.localInteractors.resolve}):{},...l.operations.focusPoint.available?ne({device:n,signal:r,resolveInteractor:t.localInteractors.resolve}):{},...l.operations.typeText.available?ie({device:n,signal:r,resolveInteractor:t.localInteractors.resolve}):{},...i(l.operations.tapPoint,()=>c({device:n,signal:r,resolveInteractor:t.localInteractors.resolve,facts:l.operations,pause:async e=>await t.clock.sleep(e,r)})),...l.operations.scrollDirection.available?te({device:n,signal:r,resolveInteractor:t.localInteractors.resolve}):{},...l.operations.setViewport.available?{setViewport:async i=>{r.throwIfAborted();let a=await t.localInteractors.resolve(n,{signal:r});if(!a.setViewport)throw new e(`UNSUPPORTED_OPERATION`,`viewport is not supported by the bound web interactor`);await a.setViewport(i.width,i.height),r.throwIfAborted()}}:{},...i(l.operations.audioProbeQuery,()=>({audioProbeQuery:async r=>{let i=await t.audioProbe.web.resolve(n);if(i===void 0)throw new e(`UNSUPPORTED_OPERATION`,`audio is not supported by this web provider`);return await i.probe(r)}})),...a(H({host:t.localInteractors,device:n,signal:r}),l.operations)};return Object.freeze({device:n,owner:U,facts:l,operations:Object.freeze(d),[Symbol.asyncDispose]:async()=>void 0})}function $(e,t,n,r){let i=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`network is not supported by this web provider`}),a=Z(e.kind===`device`,Q);return Object.freeze({device:{family:`web`,kind:e.kind,...e.target===void 0?{}:{target:e.target},providerMode:t.mode},operations:{appLogInspect:K,appLogDoctor:K,appLogStart:K,appLogReattach:K,appLogCleanup:K,appState:le,networkDump:Z(!!t.dump,i),screenRecordingStart:Z(n,q),screenRecordingReattach:Z(n,q),screenRecordingCleanup:Z(n,q),...f({capture:a,customActions:se,withoutActiveApp:a}),...re({findText:Q}),...d({capture:a}),...p({focus:a}),...u({type:a}),...s({unsupported:J,tap:a,tapRef:X(r?.tapRef,a),longPress:J,hover:X(r?.hover,a),hoverRef:X(r?.hoverRef,a),fill:a,fillRef:X(r?.fillRef,a)}),...l({scroll:a}),...ee({unsupported:pe,targetAuthoredDrag:me}),...m({setViewport:a}),...C({readTextAtPoint:G}),...w({back:Y}),..._({home:Y}),...S({orientation:Y}),...ae({tvRemote:Y}),...oe({unsupported:Y}),...v({unsupported:Y}),...E({capture:fe,query:W}),...D({frames:Y,memorySample:Y,memorySnapshot:Y,nativeCapture:Y,profileReport:Y}),...b({appSwitcher:Y}),...g({triggerAppEvent:Y}),...y({setSetting:Y}),...x({read:Y,wait:Y,accept:Y,dismiss:Y}),ensureReady:J,bootTarget:J,bootTargetHeadless:J,listApps:ce,deployApp:J,materializeAppSource:J,deployMaterializedApp:J,sendPushNotification:J,shutdownTarget:J,..._e(e)}})}export{be as createWebPlatformRuntime};
1
+ import{D as e}from"./sdk-contracts.js";import{Kt as t,Qt as n,Zt as r}from"./sdk-batch.js";import{n as i,t as a}from"./application-lifecycle-runtime.js";import{i as o,t as ee}from"./touch-runtime.js";import{A as s,D as c,G as l,H as u,I as te,L as ne,N as re,O as d,P as f,R as p,T as m,U as h,a as g,b as _,d as v,g as ie,i as y,m as b,s as x,t as S,v as C,w,x as T,z as E}from"./alert-runtime.js";import{n as D}from"./audio-probe-runtime.js";import{n as O}from"./perf-runtime.js";import{i as k}from"./gesture-admission.js";import{n as A,t as j}from"./application-lifecycle-interaction.js";import{n as M,r as N,t as P}from"./screen-recording-transport.js";async function F(e){let{host:t,device:n,owner:r,signal:i}=e,a=await t.screenRecording.web.resolve(n);return a?{available:!0,operations:{screenRecordingStart:async e=>(I(e),await P({host:t,device:n,owner:r,input:e,signal:i,transport:{backend:`agent-browser`,targetLabel:`web recording`,start:async t=>await a.start(e.outputPath,t),stop:async()=>await a.stop()},support:{scopes:[`app`],fps:!1,exportQuality:!1,hideTouches:!1},unsupported:e=>`web recordings do not support ${e.join(`, `)}; agent-browser records WebM directly`})),screenRecordingReattach:async()=>N(`Web recordings cannot be reattached after daemon restart.`),screenRecordingCleanup:async()=>M(`Web recordings cannot be cleaned after daemon restart.`)}}:{available:!1,operations:{}}}function I(t){if(t.recordOnlySession)throw new e(`INVALID_ARGS`,`record on web requires an active browser session; run open <url> --platform web first`);if(!t.outputPath.toLowerCase().endsWith(`.webm`))throw new e(`INVALID_ARGS`,`web recordings require a .webm output path; agent-browser records WebM directly`)}function L(e){return j({owner:`web`,openTargetIdentity:`app-name`,binding:A({device:e.device,signal:e.signal,resolveInteractor:e.host.resolve})})}const R=t(`web`),z=Object.freeze({available:!0}),B=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`Web targets read element text from the captured tree only.`}),V=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),H=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`record is not supported by this web provider`}),U=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`Re-run without --actions, or target an iOS simulator.`}),W=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),G=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`apps is not supported on web targets.`}),K=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),q=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),J=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`Apple runner preparation is supported only for Apple targets.`}),Y=Object.freeze({available:!1,reason:`owner-capability-missing`}),ae=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`audio on web sessions is the stateless page probe; host capture is a macOS-host operation.`});function X(e,t){return typeof e==`function`?t:Y}function Z(e,t){return e?z:t}const oe=Object.freeze({available:!1,reason:`unsupported-platform-leaf`}),se=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:k}),Q=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`open is supported only for web browser devices.`}),ce=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`close is supported only for web browser devices.`}),le=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Port reverse is supported only by an owning provider runtime.`});function ue(e){let t=de(e),n=fe(e);return a({resolveOpenTarget:t,prepareApplicationOpen:t,openApplication:t,applyRuntimeHints:W,clearRuntimeHints:W,closeApplication:n,finalizeApplicationClose:n,prepareAppleRunner:J,configureProviderPortReverse:le})}function de(e){return e.kind===`device`?z:Q}function fe(e){return e.kind===`device`?z:ce}function pe(t){return Object.freeze({owner:R,ownsDevice:e=>e.platform===`web`,inspectFacts:async e=>{let n=await t.networkTransports.resolve(e),r=await F({host:t,device:e,owner:R,signal:new AbortController().signal}),i=e.kind===`device`?await t.localInteractors.resolve(e,{}):void 0;return $(e,n,r.available,i)},bind:async n=>{if(n.intent.kind===`exact-owner`&&!r(n.intent.owner,R))throw new e(`UNSUPPORTED_OPERATION`,`Web runtime owner identity does not match`);if(n.device.platform!==`web`)throw new e(`UNSUPPORTED_PLATFORM`,`Web runtime owner cannot bind ${n.device.platform}`);let i=await t.networkTransports.resolve(n.device),a=await F({host:t,device:n.device,owner:R,signal:n.scope.signal}),o=n.device.kind===`device`?await t.localInteractors.resolve(n.device,{signal:n.scope.signal}):void 0;return me(t,n.device,n.scope.signal,i,a,$(n.device,i,a.available,o))},shutdown:async()=>void 0})}function me(t,r,a,o,s,c){let l=o.dump,u={...l?{networkDump:async e=>{let t=await l({maxEntries:e.maxEntries,include:e.include},a);return Object.freeze({source:`provider`,...t})}}:{},...s.operations,...c.operations.captureSnapshot.available?E({device:r,signal:a,resolveInteractor:t.localInteractors.resolve}):{},...c.operations.captureScreenshot.available?h({device:r,signal:a,resolveInteractor:t.localInteractors.resolve}):{},...c.operations.focusPoint.available?f({device:r,signal:a,resolveInteractor:t.localInteractors.resolve}):{},...c.operations.typeText.available?m({device:r,signal:a,resolveInteractor:t.localInteractors.resolve}):{},...n(c.operations.tapPoint,()=>ee({device:r,signal:a,resolveInteractor:t.localInteractors.resolve,facts:c.operations,pause:async e=>await t.clock.sleep(e,a)})),...c.operations.scrollDirection.available?d({device:r,signal:a,resolveInteractor:t.localInteractors.resolve}):{},...c.operations.setViewport.available?{setViewport:async n=>{a.throwIfAborted();let i=await t.localInteractors.resolve(r,{signal:a});if(!i.setViewport)throw new e(`UNSUPPORTED_OPERATION`,`viewport is not supported by the bound web interactor`);await i.setViewport(n.width,n.height),a.throwIfAborted()}}:{},...n(c.operations.audioProbeQuery,()=>({audioProbeQuery:async n=>{let i=await t.audioProbe.web.resolve(r);if(i===void 0)throw new e(`UNSUPPORTED_OPERATION`,`audio is not supported by this web provider`);return await i.probe(n)}})),...i(L({host:t.localInteractors,device:r,signal:a}),c.operations)};return Object.freeze({device:r,owner:R,facts:c,operations:Object.freeze(u),[Symbol.asyncDispose]:async()=>void 0})}function $(e,t,n,r){let i=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`network is not supported by this web provider`}),a=Z(e.kind===`device`,Q);return Object.freeze({device:{family:`web`,kind:e.kind,...e.target===void 0?{}:{target:e.target},providerMode:t.mode},operations:{appLogInspect:V,appLogDoctor:V,appLogStart:V,appLogReattach:V,appLogCleanup:V,appState:K,networkDump:Z(!!t.dump,i),screenRecordingStart:Z(n,H),screenRecordingReattach:Z(n,H),screenRecordingCleanup:Z(n,H),...u({capture:a,customActions:U,withoutActiveApp:a}),...p({findText:Q}),...l({capture:a}),...te({focus:a}),...c({type:a}),...o({unsupported:W,tap:a,tapRef:X(r?.tapRef,a),longPress:W,hover:X(r?.hover,a),hoverRef:X(r?.hoverRef,a),fill:a,fillRef:X(r?.fillRef,a)}),...s({scroll:a}),...re({unsupported:oe,targetAuthoredDrag:se}),...ne({setViewport:a}),...w({readTextAtPoint:B}),...T({back:q}),..._({home:q}),...C({orientation:q}),...ie({tvRemote:q}),...b({unsupported:q}),...v({unsupported:q}),...D({capture:ae,query:z}),...O({frames:q,memorySample:q,memorySnapshot:q,nativeCapture:q,profileReport:q}),...x({appSwitcher:q}),actionButton:q,...g({triggerAppEvent:q}),...y({setSetting:q}),...S({read:q,wait:q,accept:q,dismiss:q}),ensureReady:W,bootTarget:W,bootTargetHeadless:W,listApps:G,deployApp:W,materializeAppSource:W,deployMaterializedApp:W,sendPushNotification:W,shutdownTarget:W,...ue(e)}})}export{pe as createWebPlatformRuntime};
@@ -0,0 +1 @@
1
+ import{D as e}from"./sdk-contracts.js";import{E as t,T as n}from"./sdk-device.js";function r(r){let i=r.now??Date.now,a=r.undurableCleanupTtlMs??3e5,o=new Map;return Object.freeze({blockUndurableCleanup(e,r){let s=n(e);o.set(t(s),{device:s,reason:r,expiresAt:i()+a})},clearUndurableCleanup(e){o.delete(t(n(e)))},assertStartAllowed(a){let s=t(n(a)),c=o.get(s);if(c){if(i()>c.expiresAt){o.delete(s),r.onUndurableCleanupExpired?.({device:c.device,reason:c.reason});return}throw new e(`COMMAND_FAILED`,`The existing ${r.displayName.toLowerCase()} resource has process-local unconfirmed ownership`,{reason:`cleanup-unconfirmed`,hint:`Do not start a replacement in this daemon process: ${c.reason}`})}}})}function i(){return r({displayName:`screen recording`})}export{r as n,i as t};
@@ -1 +1 @@
1
- import{C as e}from"./sdk-contracts.js";import{t}from"./durable-resource.js";function n(e,t){let n=r(e),a,o=!1,s,c,l=()=>o||s!==void 0,u=e=>(o=!0,a??=t.finish(n,e).catch(e=>{throw a=void 0,e}),a),d=()=>s??=a?a.then(async e=>e.status===`completed`?{status:`cleaned`}:await t.forceCleanup(n),async()=>await t.forceCleanup(n)):t.forceCleanup(n);return Object.freeze({inspect:()=>n,appendGestureEvents:e=>{e.length===0||l()||(n=r({...n,gestureEvents:[...n.gestureEvents,...e]}))},setTouchReferenceFrame:e=>{l()||(n=r({...n,...e?{touchReferenceFrame:e}:{}}))},setRunnerSessionId:e=>{l()||e.trim().length===0||(n=r({...n,runnerSessionId:e}))},invalidate:e=>{l()||n.invalidatedReason||(n=r({...n,invalidatedReason:e}))},finish:u,forceCleanup:d,[Symbol.asyncDispose]:async()=>{c??=d().then(i),await c}})}function r(e){return Object.freeze({...e,gestureEvents:Object.freeze([...e.gestureEvents])})}function i(n){if(!t(n))throw new e(`COMMAND_FAILED`,n.message??`Screen recording cleanup could not be confirmed`,{reason:n.reason,retriable:n.reason!==`ownership-fence-lost`,hint:n.reason===`ownership-fence-lost`?`Use the current recording owner or recovery record before retrying cleanup.`:`Keep the recovery record and retry cleanup through the exact runtime owner.`})}function a(e,t,n){let{stopObservation:r,nativePathDisposition:i,showTouches:a=e.showTouches}=n;return Object.freeze({status:`completed`,result:Object.freeze({backend:e.backend,outPath:e.outPath,...e.clientOutPath===void 0?{}:{clientOutPath:e.clientOutPath},startedAt:e.startedAt,completedAt:Date.now(),stopObservation:r,...i===void 0?{}:{nativePathDisposition:i},scope:e.scope,showTouches:a,recordOnlySession:e.recordOnlySession,...e.activeSessionApp===void 0?{}:{activeSessionApp:e.activeSessionApp},...t})})}export{n,a as t};
1
+ import{D as e}from"./sdk-contracts.js";import{t}from"./durable-resource.js";function n(e,t){let n=r(e),a,o=!1,s,c,l=()=>o||s!==void 0,u=e=>(o=!0,a??=t.finish(n,e).catch(e=>{throw a=void 0,e}),a),d=()=>s??=a?a.then(async e=>e.status===`completed`?{status:`cleaned`}:await t.forceCleanup(n),async()=>await t.forceCleanup(n)):t.forceCleanup(n);return Object.freeze({inspect:()=>n,appendGestureEvents:e=>{e.length===0||l()||(n=r({...n,gestureEvents:[...n.gestureEvents,...e]}))},setTouchReferenceFrame:e=>{l()||(n=r({...n,...e?{touchReferenceFrame:e}:{}}))},setRunnerSessionId:e=>{l()||e.trim().length===0||(n=r({...n,runnerSessionId:e}))},invalidate:e=>{l()||n.invalidatedReason||(n=r({...n,invalidatedReason:e}))},finish:u,forceCleanup:d,[Symbol.asyncDispose]:async()=>{c??=d().then(i),await c}})}function r(e){return Object.freeze({...e,gestureEvents:Object.freeze([...e.gestureEvents])})}function i(n){if(!t(n))throw new e(`COMMAND_FAILED`,n.message??`Screen recording cleanup could not be confirmed`,{reason:n.reason,retriable:n.reason!==`ownership-fence-lost`,hint:n.reason===`ownership-fence-lost`?`Use the current recording owner or recovery record before retrying cleanup.`:`Keep the recovery record and retry cleanup through the exact runtime owner.`})}function a(e,t,n){let{stopObservation:r,nativePathDisposition:i,showTouches:a=e.showTouches}=n;return Object.freeze({status:`completed`,result:Object.freeze({backend:e.backend,outPath:e.outPath,...e.clientOutPath===void 0?{}:{clientOutPath:e.clientOutPath},startedAt:e.startedAt,completedAt:Date.now(),stopObservation:r,...i===void 0?{}:{nativePathDisposition:i},scope:e.scope,showTouches:a,recordOnlySession:e.recordOnlySession,...e.activeSessionApp===void 0?{}:{activeSessionApp:e.activeSessionApp},...t})})}export{n,a as t};
@@ -1 +1 @@
1
- import{C as e}from"./sdk-contracts.js";function t(t,r,i){let a=n(t,r);if(a.length>0)throw new e(`INVALID_ARGS`,i(a))}function n(e,t){return Object.freeze([...t.scopes.includes(e.scope)?[]:[`--scope`],...t.fps||e.fps===void 0?[]:[`--fps`],...t.exportQuality||e.exportQuality===void 0?[]:[`--quality`],...t.hideTouches||!e.hideTouchesRequested?[]:[`--hide-touches`]])}export{t};
1
+ import{D as e}from"./sdk-contracts.js";function t(t,r,i){let a=n(t,r);if(a.length>0)throw new e(`INVALID_ARGS`,i(a))}function n(e,t){return Object.freeze([...t.scopes.includes(e.scope)?[]:[`--scope`],...t.fps||e.fps===void 0?[]:[`--fps`],...t.exportQuality||e.exportQuality===void 0?[]:[`--quality`],...t.hideTouches||!e.hideTouchesRequested?[]:[`--hide-touches`]])}export{t};