agent-device 0.21.20 → 0.21.21

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 (357) hide show
  1. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.20.apk → agent-device-android-ime-helper-0.21.21.apk} +0 -0
  2. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.21.apk.sha256 +1 -0
  3. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.20.manifest.json → agent-device-android-ime-helper-0.21.21.manifest.json} +4 -4
  4. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.21.apk +0 -0
  5. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.21.apk.sha256 +1 -0
  6. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.20.manifest.json → agent-device-android-snapshot-helper-0.21.21.manifest.json} +6 -6
  7. package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/AppWindowScreenshot.swift +73 -0
  8. package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/BackgroundInteraction.swift +557 -0
  9. package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/GhostCursor.swift +141 -0
  10. package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/SnapshotTraversal.swift +107 -3
  11. package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/main.swift +136 -22
  12. package/apple/macos-helper/Tests/AgentDeviceMacOSHelperTests/BackgroundInteractionTests.swift +88 -0
  13. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +121 -4
  14. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +10 -2
  15. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +36 -9
  16. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +28 -0
  17. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +27 -0
  18. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedCommitDeadline.swift +6 -1
  19. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +7 -2
  20. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift +21 -7
  21. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedTextEntry.swift +121 -17
  22. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +179 -6
  23. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryConfirmation.swift +119 -0
  24. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryFocus.swift +8 -1
  25. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryReadiness.swift +23 -11
  26. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextInputProbe.swift +59 -6
  27. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +112 -23
  28. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TypeExecution.swift +25 -12
  29. package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/RecordingExportSupport.swift +6 -1
  30. package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-overlay.swift +43 -13
  31. package/dist/src/adapter.js +1 -1
  32. package/dist/src/adb-executor.js +2 -2
  33. package/dist/src/adb-failure.js +1 -1
  34. package/dist/src/adb-transport.js +1 -1
  35. package/dist/src/agent-browser-lifecycle.js +1 -1
  36. package/dist/src/agent-browser-process-record.js +1 -1
  37. package/dist/src/agent-browser-provider.js +1 -1
  38. package/dist/src/agent-browser-tool.js +1 -1
  39. package/dist/src/agent-device-client.js +2 -2
  40. package/dist/src/ai-sdk.js +1 -1
  41. package/dist/src/alert-runtime.js +1 -1
  42. package/dist/src/alert.js +1 -1
  43. package/dist/src/android-adb.d.ts +12 -0
  44. package/dist/src/android-input-ownership.js +1 -1
  45. package/dist/src/app-backend.js +1 -0
  46. package/dist/src/app-catalog.js +1 -1
  47. package/dist/src/app-deployment-resolution.js +1 -1
  48. package/dist/src/app-inventory.js +1 -1
  49. package/dist/src/app-launch.js +1 -1
  50. package/dist/src/app-lifecycle.js +2 -2
  51. package/dist/src/app-lifecycle2.js +1 -1
  52. package/dist/src/app-log-files.js +1 -1
  53. package/dist/src/app-log-reconnect.js +1 -1
  54. package/dist/src/app-log-runtime2.js +3 -3
  55. package/dist/src/app-log-session-resource.js +1 -0
  56. package/dist/src/app-resolution.js +2 -2
  57. package/dist/src/apple-runner-platform.js +1 -1
  58. package/dist/src/application-lifecycle-interaction.js +1 -1
  59. package/dist/src/archive.js +2 -2
  60. package/dist/src/artifact-download.js +1 -1
  61. package/dist/src/auth-session.js +1 -1
  62. package/dist/src/auth.js +1 -1
  63. package/dist/src/back-mode.js +1 -1
  64. package/dist/src/backend-snapshot-options.js +1 -1
  65. package/dist/src/boot-diagnostics.js +1 -1
  66. package/dist/src/cache.js +1 -1
  67. package/dist/src/capabilities.js +1 -1
  68. package/dist/src/capture.js +1 -1
  69. package/dist/src/cli-config.js +1 -1
  70. package/dist/src/cli-help.js +13 -5
  71. package/dist/src/cli.js +4 -4
  72. package/dist/src/click-button.js +1 -1
  73. package/dist/src/client-metro-companion.js +1 -1
  74. package/dist/src/client-metro.js +1 -1
  75. package/dist/src/client-options.js +3 -0
  76. package/dist/src/client-types.d.ts +88 -5
  77. package/dist/src/clipboard-shell-response.js +1 -1
  78. package/dist/src/cloud-artifacts.d.ts +7 -2
  79. package/dist/src/code-signature-cache.js +1 -1
  80. package/dist/src/code-signature.js +1 -1
  81. package/dist/src/command-schema.js +1 -1
  82. package/dist/src/command-tools.js +2 -2
  83. package/dist/src/connection-runtime.js +1 -1
  84. package/dist/src/connection.js +5 -5
  85. package/dist/src/contracts.d.ts +1 -1
  86. package/dist/src/contracts.js +1 -1
  87. package/dist/src/daemon-artifacts.js +1 -0
  88. package/dist/src/daemon-client-lease-beat.js +1 -1
  89. package/dist/src/daemon-client-lifecycle.js +1 -1
  90. package/dist/src/daemon-client-liveness-probe.js +1 -0
  91. package/dist/src/daemon-client-transport.js +1 -1
  92. package/dist/src/daemon-http.js +1 -0
  93. package/dist/src/daemon-policy-file.js +1 -1
  94. package/dist/src/daemon-registration-owner.js +1 -0
  95. package/dist/src/daemon-registration.js +1 -1
  96. package/dist/src/daemon-resolution.js +1 -1
  97. package/dist/src/daemon-shutdown-report.js +1 -1
  98. package/dist/src/daemon.js +2 -2
  99. package/dist/src/debug-symbols-facade.js +1 -1
  100. package/dist/src/device-claim-inspection.js +1 -1
  101. package/dist/src/device-claim-rule.js +1 -1
  102. package/dist/src/device-inventory-context.js +1 -1
  103. package/dist/src/device-readiness-runtime.js +1 -1
  104. package/dist/src/device-release.js +1 -1
  105. package/dist/src/device-rotation.js +1 -1
  106. package/dist/src/device-selection-resolver.js +1 -1
  107. package/dist/src/device-session.js +1 -1
  108. package/dist/src/device-shell.js +1 -1
  109. package/dist/src/device.js +1 -1
  110. package/dist/src/device2.js +1 -3
  111. package/dist/src/device3.js +3 -0
  112. package/dist/src/devicectl.js +1 -1
  113. package/dist/src/diagnostics.js +3 -3
  114. package/dist/src/dispatch-resolve.js +4 -1
  115. package/dist/src/display-inventory.js +1 -1
  116. package/dist/src/doctor-facade.js +1 -1
  117. package/dist/src/doctor2.js +1 -1
  118. package/dist/src/durable-capture-resource.js +1 -0
  119. package/dist/src/engine-eval-script.js +1 -1
  120. package/dist/src/error.js +1 -1
  121. package/dist/src/exec.js +1 -1
  122. package/dist/src/file.js +1 -1
  123. package/dist/src/find.js +1 -1
  124. package/dist/src/generic-settle.js +1 -1
  125. package/dist/src/generic.js +1 -1
  126. package/dist/src/gesture-admission.js +1 -1
  127. package/dist/src/gesture-plan.js +1 -1
  128. package/dist/src/gesture-runtime.js +1 -1
  129. package/dist/src/harmonyos.js +1 -1
  130. package/dist/src/hdc.js +1 -1
  131. package/dist/src/helper.js +2 -2
  132. package/dist/src/host-file.js +1 -1
  133. package/dist/src/host.js +1 -1
  134. package/dist/src/human-control-contract.js +1 -1
  135. package/dist/src/human-control.js +1 -1
  136. package/dist/src/index.d.ts +1 -1
  137. package/dist/src/index.js +1 -1
  138. package/dist/src/input-actions.js +1 -1
  139. package/dist/src/input-actions2.js +2 -2
  140. package/dist/src/install-artifact-facade.js +1 -1
  141. package/dist/src/install-source-network-transport.js +1 -1
  142. package/dist/src/install-source.d.ts +5 -0
  143. package/dist/src/install-source2.js +1 -1
  144. package/dist/src/instance-client.js +1 -0
  145. package/dist/src/interaction-positionals.js +1 -1
  146. package/dist/src/interaction-ref-policy.js +1 -1
  147. package/dist/src/interaction.js +1 -1
  148. package/dist/src/interaction2.js +1 -1
  149. package/dist/src/interactor-operation-binding.js +1 -1
  150. package/dist/src/interactor.js +5 -5
  151. package/dist/src/interactor2.js +1 -1
  152. package/dist/src/interactors.js +1 -1
  153. package/dist/src/internal/bin.js +1 -1
  154. package/dist/src/internal/daemon.js +1 -2
  155. package/dist/src/internal/png-worker.js +1 -1
  156. package/dist/src/internal/run-script-http-child.js +1 -1
  157. package/dist/src/inventory.js +4 -4
  158. package/dist/src/inventory2.js +1 -1
  159. package/dist/src/inventory3.js +1 -1
  160. package/dist/src/inventory5.js +1 -1
  161. package/dist/src/ios-client.js +4 -30
  162. package/dist/src/ios-settings.js +1 -0
  163. package/dist/src/ios-snapshot-engine.js +1 -1
  164. package/dist/src/ios-snapshot-runtime.js +1 -1
  165. package/dist/src/launch-confirmation.js +1 -1
  166. package/dist/src/lease-context.js +1 -1
  167. package/dist/src/lease-registry-scope.js +1 -0
  168. package/dist/src/lease-scope.js +1 -1
  169. package/dist/src/lease.js +1 -1
  170. package/dist/src/legacy-xctest-device-set.js +1 -1
  171. package/dist/src/limrun-download-file.js +1 -1
  172. package/dist/src/limrun-runtime-dependencies.js +1 -1
  173. package/dist/src/limrun.d.ts +28 -2
  174. package/dist/src/limrun.js +1 -1
  175. package/dist/src/linux.js +1 -1
  176. package/dist/src/load.js +1 -0
  177. package/dist/src/location-coordinates.js +1 -1
  178. package/dist/src/macos-facade.js +1 -1
  179. package/dist/src/managed-device-scope.js +1 -1
  180. package/dist/src/mechanics.js +16 -16
  181. package/dist/src/observation.js +1 -1
  182. package/dist/src/observe-until.js +1 -1
  183. package/dist/src/overlay.js +2 -2
  184. package/dist/src/owner-identity.js +3 -3
  185. package/dist/src/path-resolution.js +1 -1
  186. package/dist/src/perf-facade.js +1 -1
  187. package/dist/src/perf-runtime-operation-builder.js +1 -1
  188. package/dist/src/perf-runtime-plan.js +1 -1
  189. package/dist/src/perf-target.js +1 -1
  190. package/dist/src/perf.js +1 -1
  191. package/dist/src/physical-device-control.js +1 -1
  192. package/dist/src/platform-request-scope.js +1 -1
  193. package/dist/src/platform-runtime-android-adb-host.js +1 -1
  194. package/dist/src/platform-runtime-app-log-process.js +1 -1
  195. package/dist/src/platform-runtime-host.js +1 -1
  196. package/dist/src/platform-runtime-managed-owner.js +1 -1
  197. package/dist/src/platform-runtime-open-target.js +1 -1
  198. package/dist/src/platform-runtime-operation-host.js +2 -2
  199. package/dist/src/platform-runtime-runtime-hints.js +2 -2
  200. package/dist/src/platform-runtime-screen-recording-android-host.js +1 -1
  201. package/dist/src/platform-runtime-screen-recording-apple-runner-transport.js +1 -1
  202. package/dist/src/platform-runtime-screen-recording-apple-simulator-host.js +1 -1
  203. package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
  204. package/dist/src/platform-runtime-screen-recording-output-host.js +1 -1
  205. package/dist/src/platform-runtime-screen-recording-process-host.js +1 -1
  206. package/dist/src/platform-runtime-unavailable.js +1 -1
  207. package/dist/src/platform-runtime.js +1 -1
  208. package/dist/src/platform-runtime2.js +1 -1
  209. package/dist/src/plugins.d.ts +9 -0
  210. package/dist/src/plugins.js +1 -0
  211. package/dist/src/plugins2.js +2 -0
  212. package/dist/src/png-crop-bytes.js +1 -1
  213. package/dist/src/png-size.js +1 -1
  214. package/dist/src/png-worker-client.js +1 -1
  215. package/dist/src/png.js +1 -1
  216. package/dist/src/prepare-kind.js +1 -1
  217. package/dist/src/process.js +1 -1
  218. package/dist/src/project-runtime.js +1 -1
  219. package/dist/src/provider-credential-fingerprint.js +1 -0
  220. package/dist/src/provider-device-admission.js +1 -1
  221. package/dist/src/provider-device-runtimes.js +1 -0
  222. package/dist/src/provider-limrun-credentials.js +1 -0
  223. package/dist/src/provider-profile-fields.js +1 -0
  224. package/dist/src/provider-session-ownership.js +2 -2
  225. package/dist/src/provider-webdriver.js +2 -1
  226. package/dist/src/providers.js +1 -1
  227. package/dist/src/proxy.js +1 -1
  228. package/dist/src/quality-warnings.js +1 -1
  229. package/dist/src/react-native.js +1 -1
  230. package/dist/src/record-runtime.js +1 -1
  231. package/dist/src/record-trace.js +1 -1
  232. package/dist/src/recording.js +1 -1
  233. package/dist/src/rect-center.js +1 -1
  234. package/dist/src/register-builtins.js +1 -1
  235. package/dist/src/registry.js +39 -39
  236. package/dist/src/remote-config2.js +1 -1
  237. package/dist/src/replay-divergence.js +1 -1
  238. package/dist/src/replay.js +2 -2
  239. package/dist/src/reporting.js +5 -5
  240. package/dist/src/request-admission.js +1 -1
  241. package/dist/src/request-cancel.js +1 -1
  242. package/dist/src/request-cancellation.js +1 -1
  243. package/dist/src/request-runtime-binding.js +1 -1
  244. package/dist/src/result-serialization.js +1 -1
  245. package/dist/src/retry.js +1 -1
  246. package/dist/src/runner-artifact-manifest.js +1 -1
  247. package/dist/src/runner-cache-metadata.js +3 -3
  248. package/dist/src/runner-client.js +1 -1
  249. package/dist/src/runner-dev-tools-security.js +1 -1
  250. package/dist/src/runner-device-readiness.js +1 -1
  251. package/dist/src/runner-disposal.js +1 -1
  252. package/dist/src/runner-error-classification.js +2 -2
  253. package/dist/src/runner-exchange.js +1 -1
  254. package/dist/src/runner-operations-facade.js +1 -1
  255. package/dist/src/runner-session-types.js +1 -1
  256. package/dist/src/runner-start-budget.js +1 -1
  257. package/dist/src/runner.js +1 -1
  258. package/dist/src/runtime-admission.js +1 -1
  259. package/dist/src/runtime-transport-hints.js +1 -1
  260. package/dist/src/runtime.js +1 -1
  261. package/dist/src/runtime10.js +2 -2
  262. package/dist/src/runtime2.js +3 -3
  263. package/dist/src/runtime3.js +1 -1
  264. package/dist/src/runtime4.js +5 -5
  265. package/dist/src/runtime5.js +1 -1
  266. package/dist/src/runtime6.js +1 -1
  267. package/dist/src/runtime7.js +1 -1
  268. package/dist/src/runtime8.js +1 -1
  269. package/dist/src/runtime9.js +1 -1
  270. package/dist/src/screen-recording-admission-ledger.js +1 -1
  271. package/dist/src/screen-recording-completion.js +1 -1
  272. package/dist/src/screen-recording-options.js +1 -1
  273. package/dist/src/screen-recording-resource-recovery.js +1 -1
  274. package/dist/src/screen-recording-transport.js +1 -1
  275. package/dist/src/screenshot-density.js +1 -1
  276. package/dist/src/screenshot-image.js +1 -1
  277. package/dist/src/screenshot-result.js +1 -1
  278. package/dist/src/screenshot-runtime.js +1 -1
  279. package/dist/src/screenshot.js +1 -1
  280. package/dist/src/screenshot3.js +1 -1
  281. package/dist/src/script.js +1 -1
  282. package/dist/src/scroll-command.js +1 -1
  283. package/dist/src/scroll-gesture.js +1 -1
  284. package/dist/src/sdk-batch-runner.js +2 -2
  285. package/dist/src/sdk-batch.js +2 -2
  286. package/dist/src/sdk-contracts.d.ts +45 -2
  287. package/dist/src/sdk-contracts.js +2 -2
  288. package/dist/src/sdk-device.js +1 -1
  289. package/dist/src/sdk-io.js +1 -1
  290. package/dist/src/sdk-remote-config.js +1 -1
  291. package/dist/src/sdk-selectors.d.ts +33 -4
  292. package/dist/src/selection.js +0 -0
  293. package/dist/src/selector-runtime.js +1 -1
  294. package/dist/src/selectors.d.ts +2 -2
  295. package/dist/src/selectors.js +1 -1
  296. package/dist/src/server.js +1 -1
  297. package/dist/src/session-allocation.js +1 -1
  298. package/dist/src/session-artifact-paths.js +1 -1
  299. package/dist/src/session-repair-tombstone.js +1 -1
  300. package/dist/src/session-routing.js +1 -1
  301. package/dist/src/session-runtime-admission.js +1 -1
  302. package/dist/src/session-snapshot.js +1 -1
  303. package/dist/src/session-stream.js +27 -0
  304. package/dist/src/session.js +1 -1
  305. package/dist/src/session2.js +5 -5
  306. package/dist/src/settings.js +1 -1
  307. package/dist/src/settings2.js +1 -1
  308. package/dist/src/simctl-settings-facade.js +1 -0
  309. package/dist/src/simctl-settings.js +1 -0
  310. package/dist/src/simctl.js +1 -1
  311. package/dist/src/simulator.js +1 -1
  312. package/dist/src/snapshot-diagnostics.js +1 -1
  313. package/dist/src/snapshot-runtime-binding.js +1 -1
  314. package/dist/src/snapshot-runtime.js +1 -1
  315. package/dist/src/snapshot-state.js +1 -1
  316. package/dist/src/snapshot2.js +1 -1
  317. package/dist/src/snapshot3.js +1 -1
  318. package/dist/src/snapshot4.js +1 -1
  319. package/dist/src/src.js +1 -1
  320. package/dist/src/src7.js +1 -1
  321. package/dist/src/src8.js +2 -2
  322. package/dist/src/store.js +1 -0
  323. package/dist/src/string-enum.js +1 -1
  324. package/dist/src/surface-snapshot.js +1 -1
  325. package/dist/src/takeover.js +1 -1
  326. package/dist/src/target-evidence.js +1 -1
  327. package/dist/src/telemetry.js +1 -1
  328. package/dist/src/text-entry-focus.js +1 -1
  329. package/dist/src/tool-provider.js +1 -1
  330. package/dist/src/tool-provider2.js +1 -1
  331. package/dist/src/toolchain-probe.js +2 -2
  332. package/dist/src/touch-runtime.js +1 -1
  333. package/dist/src/touch-runtime2.js +1 -1
  334. package/dist/src/transport.js +2 -2
  335. package/dist/src/tv-remote.js +1 -1
  336. package/dist/src/type-text-runtime.js +1 -1
  337. package/dist/src/update-check.js +1 -1
  338. package/dist/src/vars.js +1 -1
  339. package/dist/src/verified-file.js +1 -1
  340. package/dist/src/version.js +1 -1
  341. package/dist/src/video.js +1 -1
  342. package/dist/src/viewport.js +1 -1
  343. package/dist/src/web.js +1 -1
  344. package/dist/src/web2.js +1 -1
  345. package/dist/src/webdriver-source.js +1 -1
  346. package/package.json +5 -1
  347. package/server.json +2 -2
  348. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.20.apk.sha256 +0 -1
  349. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.20.apk +0 -0
  350. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.20.apk.sha256 +0 -1
  351. package/dist/src/api.js +0 -3
  352. package/dist/src/daemon-process.js +0 -1
  353. package/dist/src/multitouch-support.js +0 -1
  354. package/dist/src/parameterized-recorded-fill.js +0 -1
  355. package/dist/src/runner-startup-transport.js +0 -1
  356. package/dist/src/runner-xctestrun.js +0 -1
  357. package/dist/src/session-store.js +0 -4
package/dist/src/src8.js CHANGED
@@ -1,4 +1,4 @@
1
- import{i as e,r as t,t as n}from"./rolldown-runtime.js";import{F as r,N as i}from"./sdk-contracts.js";import"./rect-center.js";import a from"node:path";function o(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}function s(e){return e.trim().toLowerCase().replaceAll(/\s+/g,` `)}function c(e){return[e.label,e.value,e.identifier].find(e=>typeof e==`string`&&e.length>0)?.trim()??``}function l(e={},t={}){let n={...t},r=u(e),a=[],o,s=0,c;return{get values(){return l()},get generation(){return s},get observation(){return c?.generation===s?c:void 0},enter(e={}){let t=f(e);return a.push(t),o=void 0,()=>{if(a.pop()!==t)throw new i(`COMMAND_FAILED`,`Maestro environment scopes were left out of order.`);o=void 0}},merge(e){r={...r,...e},o=void 0},replaceOutput(e){let t={};for(let[e,n]of Object.entries(r))e===`output`||e.startsWith(`output.`)||(t[e]=n);Object.assign(t,e),r=t,o=void 0},recordObservation(e){if(e.generation!==s)throw new i(`COMMAND_FAILED`,`Maestro observation generation ${e.generation} does not match ${s}.`);c=e},invalidateObservation(){s+=1,c=void 0},resolve(e){return d(e,l())},resolveDeferred(e){return d(e,l(),new Set,!1)}};function l(){return o||(o={...a.reduce((e,t)=>({...e,...t}),{...r}),...n},o)}function f(e){let t=u(e),r={};for(let[e,i]of Object.entries(t))r[e]=d(i,{...l(),...t,...r,...n},new Set,!1);return r}}function u(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,String(t)]))}function d(e,t,n=new Set,r=!0){let a=e.replaceAll(/\$\{([A-Za-z_][A-Za-z0-9_.]*)\}/g,(e,a)=>{if(!Object.hasOwn(t,a)){if(!r)return e;throw new i(`INVALID_ARGS`,`Maestro variable "${a}" is not defined.`)}if(n.has(a)){if(!r)return e;throw new i(`INVALID_ARGS`,`Maestro variable "${a}" has a cyclic reference.`)}return d(t[a],t,new Set([...n,a]),r)});return r&&f(a),a}function f(e){for(let t of e.matchAll(/\$\{[^{}]*\}/g))if(!p(t[0]))throw new i(`INVALID_ARGS`,`Maestro interpolation "${t[0]}" is unresolved or unsupported.`)}function p(e){return/^\$\{\s*maestro\.platform\s*(?:==|!=)\s*(['"]).*\1(?:\s*(?:&&|\|\|).*)?\s*\}$/.test(e)}var m=n((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),c=e=>!!e&&typeof e==`object`&&e[s]===t,l=e=>!!e&&typeof e==`object`&&e[s]===n,u=e=>!!e&&typeof e==`object`&&e[s]===r,d=e=>!!e&&typeof e==`object`&&e[s]===i,f=e=>!!e&&typeof e==`object`&&e[s]===a,p=e=>!!e&&typeof e==`object`&&e[s]===o;function m(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function h(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=e=>(f(e)||m(e))&&!!e.anchor,e.isAlias=c,e.isCollection=m,e.isDocument=l,e.isMap=u,e.isNode=h,e.isPair=d,e.isScalar=f,e.isSeq=p})),h=n((e=>{var t=m();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function a(e,n){let r=l(n);t.isDocument(e)?o(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):o(null,e,r,Object.freeze([]))}a.BREAK=n,a.SKIP=r,a.REMOVE=i;function o(e,r,a,s){let c=u(e,r,a,s);if(t.isNode(c)||t.isPair(c))return d(e,s,c),o(e,c,a,s);if(typeof c!=`symbol`){if(t.isCollection(r)){s=Object.freeze(s.concat(r));for(let e=0;e<r.items.length;++e){let t=o(e,r.items[e],a,s);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){s=Object.freeze(s.concat(r));let e=o(`key`,r.key,a,s);if(e===n)return n;e===i&&(r.key=null);let t=o(`value`,r.value,a,s);if(t===n)return n;t===i&&(r.value=null)}}return c}async function s(e,n){let r=l(n);t.isDocument(e)?await c(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await c(null,e,r,Object.freeze([]))}s.BREAK=n,s.SKIP=r,s.REMOVE=i;async function c(e,r,a,o){let s=await u(e,r,a,o);if(t.isNode(s)||t.isPair(s))return d(e,o,s),c(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await c(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await c(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await c(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function l(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function u(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function d(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=a,e.visitAsync=s})),g=n((e=>{var t=m(),n=h();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},i=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var a=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags)}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+i(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)(t!==`!!`||n!==`tag:yaml.org,2002:`)&&(!e||a.some(e=>e.startsWith(n)))&&r.push(`%TAG ${t} ${n}`);return r.join(`
1
+ import{i as e,r as t,t as n}from"./rolldown-runtime.js";import{I as r,P as i}from"./sdk-contracts.js";import"./rect-center.js";import a from"node:path";function o(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}function s(e){return e.trim().toLowerCase().replaceAll(/\s+/g,` `)}function c(e){return[e.label,e.value,e.identifier].find(e=>typeof e==`string`&&e.length>0)?.trim()??``}function l(e={},t={}){let n={...t},r=u(e),a=[],o,s=0,c;return{get values(){return l()},get generation(){return s},get observation(){return c?.generation===s?c:void 0},enter(e={}){let t=f(e);return a.push(t),o=void 0,()=>{if(a.pop()!==t)throw new i(`COMMAND_FAILED`,`Maestro environment scopes were left out of order.`);o=void 0}},merge(e){r={...r,...e},o=void 0},replaceOutput(e){let t={};for(let[e,n]of Object.entries(r))e===`output`||e.startsWith(`output.`)||(t[e]=n);Object.assign(t,e),r=t,o=void 0},recordObservation(e){if(e.generation!==s)throw new i(`COMMAND_FAILED`,`Maestro observation generation ${e.generation} does not match ${s}.`);c=e},invalidateObservation(){s+=1,c=void 0},resolve(e){return d(e,l())},resolveDeferred(e){return d(e,l(),new Set,!1)}};function l(){return o||(o={...a.reduce((e,t)=>({...e,...t}),{...r}),...n},o)}function f(e){let t=u(e),r={};for(let[e,i]of Object.entries(t))r[e]=d(i,{...l(),...t,...r,...n},new Set,!1);return r}}function u(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,String(t)]))}function d(e,t,n=new Set,r=!0){let a=e.replaceAll(/\$\{([A-Za-z_][A-Za-z0-9_.]*)\}/g,(e,a)=>{if(!Object.hasOwn(t,a)){if(!r)return e;throw new i(`INVALID_ARGS`,`Maestro variable "${a}" is not defined.`)}if(n.has(a)){if(!r)return e;throw new i(`INVALID_ARGS`,`Maestro variable "${a}" has a cyclic reference.`)}return d(t[a],t,new Set([...n,a]),r)});return r&&f(a),a}function f(e){for(let t of e.matchAll(/\$\{[^{}]*\}/g))if(!p(t[0]))throw new i(`INVALID_ARGS`,`Maestro interpolation "${t[0]}" is unresolved or unsupported.`)}function p(e){return/^\$\{\s*maestro\.platform\s*(?:==|!=)\s*(['"]).*\1(?:\s*(?:&&|\|\|).*)?\s*\}$/.test(e)}var m=n((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),c=e=>!!e&&typeof e==`object`&&e[s]===t,l=e=>!!e&&typeof e==`object`&&e[s]===n,u=e=>!!e&&typeof e==`object`&&e[s]===r,d=e=>!!e&&typeof e==`object`&&e[s]===i,f=e=>!!e&&typeof e==`object`&&e[s]===a,p=e=>!!e&&typeof e==`object`&&e[s]===o;function m(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function h(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=e=>(f(e)||m(e))&&!!e.anchor,e.isAlias=c,e.isCollection=m,e.isDocument=l,e.isMap=u,e.isNode=h,e.isPair=d,e.isScalar=f,e.isSeq=p})),h=n((e=>{var t=m();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function a(e,n){let r=l(n);t.isDocument(e)?o(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):o(null,e,r,Object.freeze([]))}a.BREAK=n,a.SKIP=r,a.REMOVE=i;function o(e,r,a,s){let c=u(e,r,a,s);if(t.isNode(c)||t.isPair(c))return d(e,s,c),o(e,c,a,s);if(typeof c!=`symbol`){if(t.isCollection(r)){s=Object.freeze(s.concat(r));for(let e=0;e<r.items.length;++e){let t=o(e,r.items[e],a,s);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){s=Object.freeze(s.concat(r));let e=o(`key`,r.key,a,s);if(e===n)return n;e===i&&(r.key=null);let t=o(`value`,r.value,a,s);if(t===n)return n;t===i&&(r.value=null)}}return c}async function s(e,n){let r=l(n);t.isDocument(e)?await c(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await c(null,e,r,Object.freeze([]))}s.BREAK=n,s.SKIP=r,s.REMOVE=i;async function c(e,r,a,o){let s=await u(e,r,a,o);if(t.isNode(s)||t.isPair(s))return d(e,o,s),c(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await c(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await c(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await c(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function l(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function u(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function d(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=a,e.visitAsync=s})),g=n((e=>{var t=m(),n=h();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},i=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var a=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags)}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+i(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)(t!==`!!`||n!==`tag:yaml.org,2002:`)&&(!e||a.some(e=>e.startsWith(n)))&&r.push(`%TAG ${t} ${n}`);return r.join(`
2
2
  `)}};a.defaultYaml={explicit:!1,version:`1.2`},a.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=a})),_=n((e=>{var t=m(),n=h();function r(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function i(e){let t=new Set;return n.visit(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function a(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function o(e,n){let r=[],o=new Map,s=null;return{onAnchor:t=>{r.push(t),s??=i(e);let o=a(n,s);return s.add(o),o},setAnchors:()=>{for(let e of r){let n=o.get(e);if(typeof n==`object`&&n.anchor&&(t.isScalar(n.node)||t.isCollection(n.node)))n.node.anchor=n.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:o}}e.anchorIsValid=r,e.anchorNames=i,e.createNodeAnchors=o,e.findNewAnchor=a})),v=n((e=>{function t(e,n,r,i){if(i&&typeof i==`object`){if(Array.isArray(i))for(let n=0,r=i.length;n<r;++n){let r=i[n],a=t(e,i,String(n),r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let r=i.get(n),a=t(e,i,n,r);a===void 0?i.delete(n):a!==r&&i.set(n,a)}else if(i instanceof Set)for(let n of Array.from(i)){let r=t(e,i,n,n);r===void 0?i.delete(n):r!==n&&(i.delete(n),i.add(r))}else for(let[n,r]of Object.entries(i)){let a=t(e,i,n,r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}}return e.call(n,r,i)}e.applyReviver=t})),y=n((e=>{var t=m();function n(e,r,i){if(Array.isArray(e))return e.map((e,t)=>n(e,String(t),i));if(e&&typeof e.toJSON==`function`){if(!i||!t.hasAnchor(e))return e.toJSON(r,i);let n={aliasCount:0,count:1,res:void 0};i.anchors.set(e,n),i.onCreate=e=>{n.res=e,delete i.onCreate};let a=e.toJSON(r,i);return i.onCreate&&i.onCreate(a),a}return typeof e==`bigint`&&!i?.keep?Number(e):e}e.toJS=n})),b=n((e=>{var t=v(),n=m(),r=y();e.NodeBase=class{constructor(e){Object.defineProperty(this,n.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:i,maxAliasCount:a,onAnchor:o,reviver:s}={}){if(!n.isDocument(e))throw TypeError(`A document argument is required`);let c={anchors:new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof a==`number`?a:100},l=r.toJS(this,``,c);if(typeof o==`function`)for(let{count:e,res:t}of c.anchors.values())o(t,e);return typeof s==`function`?t.applyReviver(s,{"":l},``,l):l}}})),x=n((e=>{var t=_(),n=h(),r=m(),i=b(),a=y(),o=class extends i.NodeBase{constructor(e){super(r.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let i;t?.aliasResolveCache?i=t.aliasResolveCache:(i=[],n.visit(e,{Node:(e,t)=>{(r.isAlias(t)||r.hasAnchor(t))&&i.push(t)}}),t&&(t.aliasResolveCache=i));let a;for(let e of i){if(e===this)break;e.anchor===this.source&&(a=e)}return a}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,o=this.resolve(r,t);if(!o){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let c=n.get(o);if(c||=(a.toJS(o,null,t),n.get(o)),c?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(c.count+=1,c.aliasCount===0&&(c.aliasCount=s(r,o,n)),c.count*c.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return c.res}toString(e,n,r){let i=`*${this.source}`;if(e){if(t.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${i} `}return i}};function s(e,t,n){if(r.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(r.isCollection(t)){let r=0;for(let i of t.items){let t=s(e,i,n);t>r&&(r=t)}return r}if(r.isPair(t)){let r=s(e,t.key,n),i=s(e,t.value,n);return Math.max(r,i)}return 1}e.Alias=o})),S=n((e=>{var t=m(),n=b(),r=y();let i=e=>!e||typeof e!=`function`&&typeof e!=`object`;var a=class extends n.NodeBase{constructor(e){super(t.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:r.toJS(this.value,e,t)}toString(){return String(this.value)}};a.BLOCK_FOLDED=`BLOCK_FOLDED`,a.BLOCK_LITERAL=`BLOCK_LITERAL`,a.PLAIN=`PLAIN`,a.QUOTE_DOUBLE=`QUOTE_DOUBLE`,a.QUOTE_SINGLE=`QUOTE_SINGLE`,e.Scalar=a,e.isScalarValue=i})),C=n((e=>{var t=x(),n=m(),r=S();function i(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function a(e,a,o){if(n.isDocument(e)&&(e=e.contents),n.isNode(e))return e;if(n.isPair(e)){let t=o.schema[n.MAP].createNode?.(o.schema,null,o);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:s,onAnchor:c,onTagObj:l,schema:u,sourceObjects:d}=o,f;if(s&&e&&typeof e==`object`){if(f=d.get(e),f)return f.anchor??(f.anchor=c(e)),new t.Alias(f.anchor);f={anchor:null,node:null},d.set(e,f)}a?.startsWith(`!!`)&&(a=`tag:yaml.org,2002:`+a.slice(2));let p=i(e,a,u.tags);if(!p){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new r.Scalar(e);return f&&(f.node=t),t}p=e instanceof Map?u[n.MAP]:Symbol.iterator in Object(e)?u[n.SEQ]:u[n.MAP]}l&&(l(p),delete o.onTagObj);let m=p?.createNode?p.createNode(o.schema,e,o):typeof p?.nodeClass?.from==`function`?p.nodeClass.from(o.schema,e,o):new r.Scalar(e);return a?m.tag=a:p.default||(m.tag=p.tag),f&&(f.node=m),m}e.createNode=a})),w=n((e=>{var t=C(),n=m(),r=b();function i(e,n,r){let i=r;for(let e=n.length-1;e>=0;--e){let t=n[e];if(typeof t==`number`&&Number.isInteger(t)&&t>=0){let e=[];e[t]=i,i=e}else i=new Map([[t,i]])}return t.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}let a=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;e.Collection=class extends r.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>n.isNode(t)||n.isPair(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(a(e))this.add(t);else{let[r,...a]=e,o=this.get(r,!0);if(n.isCollection(o))o.addIn(a,t);else if(o===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let i=this.get(t,!0);if(n.isCollection(i))return i.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...i]=e,a=this.get(r,!0);return i.length===0?!t&&n.isScalar(a)?a.value:a:n.isCollection(a)?a.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!n.isPair(t))return!1;let r=t.value;return r==null||e&&n.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let i=this.get(t,!0);return n.isCollection(i)?i.hasIn(r):!1}setIn(e,t){let[r,...a]=e;if(a.length===0)this.set(r,t);else{let e=this.get(r,!0);if(n.isCollection(e))e.setIn(a,t);else if(e===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}},e.collectionFromPath=i,e.isEmptyPath=a})),T=n((e=>{let t=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function n(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}e.indentComment=n,e.lineComment=(e,t,r)=>e.endsWith(`
3
3
  `)?n(r,t):r.includes(`
4
4
  `)?`
@@ -112,4 +112,4 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
112
112
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
113
113
  `,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){u(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey){if(!t.sep){if(a(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=l(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(a(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(s(t.key)&&!a(t.sep,`newline`)){let e=l(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken)}else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):a(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!a(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){u(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||a(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=l(c(t));d(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
114
114
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
115
- `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=l(c(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=l(c(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),Xe=n((e=>{var t=He(),n=Ee(),r=De(),i=re(),a=m(),o=Je(),s=Ye();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),Ze=n((e=>{var t=He(),n=Ee(),r=we(),i=De(),a=x(),o=m(),s=D(),c=S(),l=O(),u=A();Ke();var d=qe(),f=Je(),p=Ye(),g=Xe(),_=h();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.Lexer=d.Lexer,e.LineCounter=f.LineCounter,e.Parser=p.Parser,e.parse=g.parse,e.parseAllDocuments=g.parseAllDocuments,e.parseDocument=g.parseDocument,e.stringify=g.stringify,e.visit=_.visit,e.visitAsync=_.visitAsync})),P=Ze();function F(e,t){return Qe(e?.range?.[0],t)}function Qe(e,t){let n=t.lineCounter.linePos(e!==void 0&&e>=0?e:0).line;return t.sourcePath===void 0?{line:n}:{path:t.sourcePath,line:n}}function $e(e){return`${e.path===void 0?``:`${e.path}:`}line ${e.line}`}function I(e,t,n){throw new i(`INVALID_ARGS`,`${e} (${$e(F(t,n))})`)}function L(e,t,n){(0,P.isMap)(e)||I(`Maestro ${t} expects a map.`,e,n);let r=[];for(let i of e.items){let e=i.key;(0,P.isScalar)(e)||I(`Maestro ${t} map keys must be strings.`,void 0,n);let a=e.value;typeof a!=`string`&&typeof a!=`number`&&typeof a!=`boolean`&&I(`Maestro ${t} map keys must be strings.`,e,n),i.value!==null&&!(0,P.isNode)(i.value)&&I(`Maestro ${t} values must be YAML nodes.`,e,n),r.push({key:String(a),keyNode:e,value:i.value})}return r}function R(e,t,n){return(0,P.isSeq)(e)||I(`Maestro ${t} expects a list.`,e,n),e.items}function et(e,t,n){return R(e,t,n).map((e,r)=>K(e,`${t}[${r}]`,n))}function z(e,t,n,r){let i=new Set(n),a=new Set;for(let n of e)a.has(n.key)&&I(`Maestro ${t} contains duplicate field "${n.key}".`,n.keyNode,r),a.add(n.key),i.has(n.key)||I(`Maestro ${t} field "${n.key}" is not supported.`,n.keyNode,r)}function B(e,t){return e.some(e=>e.key===t)}function V(e,t){return e.find(e=>e.key===t)?.value}function H(e,t,n){return B(e,t)?n(V(e,t)):void 0}function U(e,t,n){return o({optional:H(e,`optional`,e=>J(e,`${t}.optional`,n))})}function W(e){return e===null||(0,P.isScalar)(e)&&e.value===null}function G(e,t,n){if(e==null)return null;(0,P.isScalar)(e)||I(`Maestro ${t} expects a scalar value.`,e,n);let r=e.value;if(r===null||typeof r==`string`||typeof r==`number`||typeof r==`boolean`)return r;I(`Maestro ${t} contains an unsupported scalar value.`,e,n)}function K(e,t,n){let r=G(e,t,n);return typeof r!=`string`&&I(`Maestro ${t} expects a string.`,e,n),r}function q(e,t,n){let r=G(e,t,n);if(r!==null)return typeof r!=`string`&&I(`Maestro ${t} expects a string.`,e,n),r}function J(e,t,n){let r=G(e,t,n);if(r!==null)return typeof r!=`boolean`&&I(`Maestro ${t} expects a boolean.`,e,n),r}const tt=/^\$\{[A-Za-z_][A-Za-z0-9_.]*\}$/,nt=new Set([`allow`,`deny`,`unset`,`always`,`inuse`,`never`,`limited`]),rt=/^-?\d+(\.\d+)?$/,it=/^-?\d+$/,at={"tapOn.index":{integer:!0,nonNegative:!0},"tapOn.repeat":{integer:!0,positive:!0},"tapOn.delay":{integer:!0,nonNegative:!0},"doubleTapOn.delay":{integer:!0,nonNegative:!0},eraseText:{integer:!0,positive:!0},"eraseText.charactersToErase":{integer:!0,positive:!0},"extendedWaitUntil.timeout":{nonNegative:!0},"scrollUntilVisible.timeout":{nonNegative:!0},waitForAnimationToEnd:{nonNegative:!0},"waitForAnimationToEnd.timeout":{nonNegative:!0},"swipe.duration":{nonNegative:!0},"repeat.times":{integer:!0,nonNegative:!0},"retry.maxRetries":{integer:!0,nonNegative:!0}};function ot(e){return e.positive&&e.integer?`a positive integer`:e.positive?`a positive number`:e.nonNegative&&e.integer?`a non-negative integer`:e.nonNegative?`a non-negative finite number`:e.integer?`an integer`:`a finite number`}function st(e,t,n,r,i){let a=`Maestro ${t} expects ${ot(i)} or a variable expression.`;Number.isFinite(e)||I(a,n,r),Math.abs(e)>2**53-1&&I(a,n,r),i.integer&&!Number.isSafeInteger(e)&&I(a,n,r),i.nonNegative&&e<0&&I(a,n,r),i.positive&&e<=0&&I(a,n,r)}function ct(e,t,n,r,i){if(typeof e==`number`)return st(e,t,n,r,i),e;if(typeof e==`string`){if(tt.test(e))return e;if((i.integer?it:rt).test(e)){let a=Number(e);return st(a,t,n,r,i),a}}I(`Maestro ${t} expects ${ot(i)} or a variable expression.`,n,r)}function Y(e,t,n,r=at[t]??{}){let i=G(e,t,n);if(i!==null)return ct(i,t,e,n,r)}function lt(e,t,n){let r=at[t]??{},i=G(e,t,n);return i===null&&I(`Maestro ${t} expects ${ot(r)} or a variable expression.`,e,n),ct(i,t,e,n,r)}function ut(e,t,n){let r=G(e,t,n);return r===null&&I(`Maestro ${t} requires a condition.`,e,n),typeof r==`string`&&r.includes("${")&&!tt.test(r)&&I(`Maestro ${t} only supports a literal value or a bare \${VAR} lookup; JavaScript expressions are not supported — compute it in a runScript and reference \${output.x}.`,e,n),r}function dt(e,t,n){let r=L(e,t,n),i={};for(let e of r){let r=G(e.value,`${t}.${e.key}`,n);r===null&&I(`Maestro ${t}.${e.key} expects a string, number, or boolean.`,e.value,n),i[e.key]=r}return i}function X(e,t,n){return H(e,`label`,e=>q(e,`${t}.label`,n))}const Z=[`id`,`text`,`enabled`,`selected`,`index`,`childOf`,`below`,`above`,`leftOf`,`rightOf`,`containsChild`,`containsDescendants`],ft={textKeys:[`id`,`text`],booleanKeys:[`enabled`,`selected`],textAliases:{label:`text`}},pt={id:(e,t,n,r)=>vt(e,`id`,t,n,r),text:(e,t,n,r)=>vt(e,`text`,t,n,r),enabled:(e,t,n,r)=>yt(e,`enabled`,t,n,r),selected:(e,t,n,r)=>yt(e,`selected`,t,n,r),index:(e,t,n,r)=>{e.index=Y(t.value,`${n}.index`,r,{integer:!0,nonNegative:!0})},childOf:(e,t,n,r)=>{e.childOf=Q(t.value,`${n}.childOf`,r)},below:(e,t,n,r)=>{e.below=Q(t.value,`${n}.below`,r)},above:(e,t,n,r)=>{e.above=Q(t.value,`${n}.above`,r)},leftOf:(e,t,n,r)=>{e.leftOf=Q(t.value,`${n}.leftOf`,r)},rightOf:(e,t,n,r)=>{e.rightOf=Q(t.value,`${n}.rightOf`,r)},containsChild:(e,t,n,r)=>{e.containsChild=Q(t.value,`${n}.containsChild`,r)},containsDescendants:(e,t,n,r)=>{e.containsDescendants=R(t.value,`${n}.containsDescendants`,r).map(e=>Q(e,`${n}.containsDescendants`,r))},optional:(e,t,n,r)=>yt(e,`optional`,t,n,r)};function Q(e,t,n,r=Z){if((0,P.isScalar)(e))return{text:K(e,t,n)};let i=L(e,t,n);return z(i,t,r,n),mt(i,t,n)}function mt(e,t,n){e.length===0&&I(`Maestro ${t} selector is empty.`,void 0,n);let r={};for(let i of e){let e=pt[i.key];e||I(`Maestro ${t} selector field "${i.key}" is not supported.`,i.keyNode,n),e(r,i,t,n)}return Object.keys(r).filter(e=>e!==`optional`).length===0&&I(`Maestro ${t} selector must contain a selector value.`,e[0]?.keyNode,n),r}function ht(e,t,n,r){let i=F(t,n);if((0,P.isScalar)(e))return{source:i,entries:[],target:xt(Q(e,r.name,n,r.selectorKeys))};let a=L(e,r.name,n),o=B(a,`point`);if(z(a,r.name,o?r.pointAllowedKeys:r.selectorAllowedKeys,n),o){let e=r.pointConflictingSelectorKeys??r.selectorKeys;return a.some(t=>bt(t.key,e))&&I(`Maestro ${r.name}.point cannot be combined with a selector.`,t,n),{source:i,entries:a,target:r.parsePoint(V(a,`point`),`${r.name}.point`,n)}}return{source:i,entries:a,target:xt(mt(a.filter(e=>bt(e.key,r.selectorKeys)),r.name,n))}}function gt(e,t,n){let r=K(e,t,n),i=/^\s*(\d+)\s*,\s*(\d+)\s*$/.exec(r);if(i)return{space:`absolute`,x:Number(i[1]),y:Number(i[2])};let a=/^\s*(\d+)%\s*,\s*(\d+)%\s*$/.exec(r);if(a){let r=Number(a[1]),i=Number(a[2]);return(r>100||i>100)&&I(`Maestro ${t} percentage coordinates must be between 0% and 100%.`,e,n),{space:`percent`,x:r,y:i}}/^\s*\d+(?:\.\d+)?%\s*,\s*\d+(?:\.\d+)?%\s*$/.test(r)&&I(`Maestro ${t} percentage coordinates must be whole numbers.`,e,n),I(`Maestro ${t} expects absolute or percentage coordinates.`,e,n)}function _t(e,t,n){let r=gt(e,t,n);return r.space!==`absolute`&&I(`Maestro ${t} only supports absolute coordinates.`,e,n),r}function vt(e,t,n,r,i){let a=q(n.value,`${r}.${t}`,i);a!==void 0&&(e[t]=a)}function yt(e,t,n,r,i){let a=J(n.value,`${r}.${t}`,i);a!==void 0&&(e[t]=a)}function bt(e,t){return t.includes(e)}function xt(e){return{space:`target`,selector:e}}function St(e,t,n){let r=ht(e,t,n,{name:`tapOn`,selectorKeys:Z,pointConflictingSelectorKeys:Z,pointAllowedKeys:[`point`,`retryTapIfNoChange`,`repeat`,`delay`,`optional`,`label`],selectorAllowedKeys:[...Z,`retryTapIfNoChange`,`repeat`,`delay`,`optional`,`label`],parsePoint:gt});if(r.entries.length===0)return{kind:`tapOn`,source:r.source,target:r.target};if(r.target.space!==`target`)return{kind:`tapOn`,source:r.source,target:r.target,...kt(r.entries,n)};let i=kt(r.entries,n);return o({kind:`tapOn`,source:r.source,target:r.target,...i})}function Ct(e,t,n){let r=ht(e,t,n,{name:`doubleTapOn`,selectorKeys:Z,pointAllowedKeys:[`point`,`delay`,`optional`,`label`],selectorAllowedKeys:[...Z,`delay`,`optional`,`label`],parsePoint:_t}),i=U(r.entries,`doubleTapOn`,n),a=B(r.entries,`delay`)?Y(V(r.entries,`delay`),`doubleTapOn.delay`,n):void 0,s=X(r.entries,`doubleTapOn`,n);return o({kind:`doubleTapOn`,source:r.source,target:r.target,...i,delay:a,label:s})}function wt(e,t,n){let r=ht(e,t,n,{name:`longPressOn`,selectorKeys:Z,pointAllowedKeys:[`point`,`optional`,`label`],selectorAllowedKeys:[...Z,`optional`,`label`],parsePoint:_t});return o({kind:`longPressOn`,source:r.source,target:r.target,...U(r.entries,`longPressOn`,n),label:X(r.entries,`longPressOn`,n)})}function Tt(e,t,n){let r=F(t,n),i=L(e,`swipe`,n);z(i,`swipe`,[`start`,`end`,`direction`,`duration`,`from`,`label`,`optional`],n);let a=U(i,`swipe`,n),o=X(i,`swipe`,n),s=B(i,`duration`)?Y(V(i,`duration`),`swipe.duration`,n):void 0;if(B(i,`start`)||B(i,`end`))return{...Et(i,r,s,t,n),...a,label:o};let c=B(i,`direction`)?At(V(i,`direction`),`swipe.direction`,n):void 0;return B(i,`from`)?{...Dt(i,r,c,s,t,n),...a,label:o}:{...Ot(r,c,s,t,n),...a,label:o}}function Et(e,t,n,r,i){B(e,`direction`)&&I(`Maestro swipe cannot combine direction with start/end coordinates.`,r,i),(!B(e,`start`)||!B(e,`end`))&&I(`Maestro swipe requires both start and end coordinates.`,r,i);let a=gt(V(e,`start`),`swipe.start`,i),s=gt(V(e,`end`),`swipe.end`,i);return a.space!==s.space&&I(`Maestro swipe start/end must use the same coordinate space.`,r,i),{kind:`swipe`,source:t,gesture:o({kind:`coordinates`,start:a,end:s,duration:n})}}function Dt(e,t,n,r,i,a){return n===void 0&&I(`Maestro target swipe requires direction.`,i,a),{kind:`swipe`,source:t,gesture:o({kind:`target`,from:Q(V(e,`from`),`swipe.from`,a),direction:n,duration:r})}}function Ot(e,t,n,r,i){return t===void 0&&I(`Maestro swipe requires direction, target, or start/end coordinates.`,r,i),{kind:`swipe`,source:e,gesture:o({kind:`screen`,direction:t,duration:n})}}function kt(e,t){let n=H(e,`retryTapIfNoChange`,e=>J(e,`tapOn.retryTapIfNoChange`,t)),r=H(e,`repeat`,e=>lt(e,`tapOn.repeat`,t)),i=H(e,`delay`,e=>Y(e,`tapOn.delay`,t)),a=U(e,`tapOn`,t).optional;return o({retryTapIfNoChange:n,repeat:r,delay:i,optional:a,label:X(e,`tapOn`,t)})}function At(e,t,n){let r=K(e,t,n).toLowerCase();if(r===`up`||r===`down`||r===`left`||r===`right`)return r;I(`Maestro ${t} must be UP, DOWN, LEFT, or RIGHT.`,e,n)}function jt(e,t,n,r){let i=F(n,r);if((0,P.isScalar)(t))return{kind:e,source:i,target:Q(t,e,r)};let a=L(t,e,r);z(a,e,[...Z,`optional`,`label`],r);let s=U(a,e,r),c=X(a,e,r);return o({kind:e,source:i,target:mt(a.filter(e=>e.key!==`optional`&&e.key!==`label`),e,r),...s,label:c})}const Mt=[...Z,`optional`];function Nt(e,t,n,r){if(!B(e,t))return;let{optional:i,...a}=Q(V(e,t),n,r,Mt);return{selector:a,optional:i}}function Pt(e,t,n){let r=Nt(e,`visible`,`extendedWaitUntil.visible`,n),i=Nt(e,`notVisible`,`extendedWaitUntil.notVisible`,n);return r&&i&&I(`Maestro extendedWaitUntil cannot specify both visible and notVisible.`,t,n),!r&&!i&&I(`Maestro extendedWaitUntil requires visible or notVisible.`,t,n),r?{key:`visible`,selector:r.selector,optional:r.optional}:{key:`notVisible`,selector:i.selector,optional:i.optional}}function Ft(e,t,n){let r=F(t,n);if((0,P.isScalar)(e))return{kind:`runScript`,source:r,file:K(e,`runScript`,n)};let i=L(e,`runScript`,n);return z(i,`runScript`,[`file`,`env`],n),B(i,`file`)||I(`Maestro runScript requires a file.`,t,n),o({kind:`runScript`,source:r,file:K(V(i,`file`),`runScript.file`,n),env:B(i,`env`)?dt(V(i,`env`),`runScript.env`,n):void 0})}function It(e,t,n,r){let i=F(t,n);if((0,P.isScalar)(e))return{kind:`runFlow`,source:i,include:{kind:`file`,path:K(e,`runFlow`,n)}};let a=L(e,`runFlow`,n);z(a,`runFlow`,[`file`,`commands`,`env`,`when`,`label`],n);let s=B(a,`file`);return s===B(a,`commands`)&&I(`Maestro runFlow requires exactly one of file or commands.`,t,n),o({kind:`runFlow`,source:i,include:s?{kind:`file`,path:K(V(a,`file`),`runFlow.file`,n)}:{kind:`commands`,commands:r(V(a,`commands`),`runFlow.commands`,n)},env:B(a,`env`)?dt(V(a,`env`),`runFlow.env`,n):void 0,when:B(a,`when`)?zt(V(a,`when`),n):void 0,label:X(a,`runFlow`,n)})}function Lt(e,t,n,r){let i=F(t,n),a=L(e,`repeat`,n);return z(a,`repeat`,[`times`,`commands`,`while`],n),B(a,`while`)&&I(`Maestro repeat.while is not supported; use repeat.times.`,V(a,`while`),n),B(a,`times`)||I(`Maestro repeat requires times.`,t,n),B(a,`commands`)||I(`Maestro repeat requires commands.`,t,n),{kind:`repeat`,source:i,times:lt(V(a,`times`),`repeat.times`,n),commands:r(V(a,`commands`),`repeat.commands`,n)}}function Rt(e,t,n,r){let i=F(t,n),a=L(e,`retry`,n);z(a,`retry`,[`maxRetries`,`commands`],n),B(a,`commands`)||I(`Maestro retry requires commands.`,t,n);let s=B(a,`maxRetries`)?lt(V(a,`maxRetries`),`retry.maxRetries`,n):void 0;return o({kind:`retry`,source:i,commands:r(V(a,`commands`),`retry.commands`,n),maxRetries:s})}function zt(e,t){let n=L(e,`runFlow.when`,t);return z(n,`runFlow.when`,[`platform`,`visible`,`notVisible`,`true`],t),n.length===0&&I(`Maestro runFlow.when cannot be empty.`,e,t),o({platform:H(n,`platform`,e=>Vt(e,t)),visible:H(n,`visible`,e=>Q(e,`runFlow.when.visible`,t)),notVisible:H(n,`notVisible`,e=>Q(e,`runFlow.when.notVisible`,t)),true:H(n,`true`,e=>Bt(e,t))})}function Bt(e,t){let n=G(e,`runFlow.when.true`,t);if(typeof n==`boolean`||typeof n==`string`)return n;I(`Maestro runFlow.when.true expects a boolean or expression string.`,e,t)}function Vt(e,t){let n=K(e,`runFlow.when.platform`,t).toLowerCase();if(n===`android`||n===`ios`||n===`web`)return n;I(`Maestro runFlow.when.platform expects Android, iOS, or Web.`,e,t)}function $(e,t,n){return R(e,t,n).map(e=>Ht(e,n))}function Ht(e,t){if((0,P.isScalar)(e))return typeof e.value!=`string`&&I(`Maestro command names must be strings.`,e,t),Ut(e.value,e,t);(0,P.isMap)(e)||I(`Maestro commands must be a scalar or one-key map.`,e,t);let n=L(e,`command`,t);n.length!==1&&I(`Maestro command maps must contain exactly one command.`,e,t);let r=n[0];return Gt(r.key,r.value,e,t)}function Ut(e,t,n){return Gt(e,null,t,n)}const Wt={launchApp:Kt,tapOn:St,doubleTapOn:Ct,longPressOn:wt,inputText:qt,eraseText:Jt,openLink:Yt,assertVisible:(e,t,n)=>jt(`assertVisible`,e,t,n),assertNotVisible:(e,t,n)=>jt(`assertNotVisible`,e,t,n),assertTrue:Xt,extendedWaitUntil:Zt,takeScreenshot:Qt,scroll:$t,scrollUntilVisible:en,swipe:Tt,hideKeyboard:tn,pressKey:nn,back:rn,waitForAnimationToEnd:an,stopApp:on,setPermissions:sn,clearState:un,runScript:Ft,evalScript:dn,runFlow:(e,t,n)=>It(e,t,n,$),repeat:(e,t,n)=>Lt(e,t,n,$),retry:(e,t,n)=>Rt(e,t,n,$)};Object.keys(Wt);function Gt(e,t,n,r){let i=Wt[e];return i||I(`Maestro command "${e}" is not supported.`,n,r),i(t,n,r)}function Kt(e,t,n){let r=F(t,n);if(W(e))return{kind:`launchApp`,source:r};if((0,P.isScalar)(e))return{kind:`launchApp`,source:r,appId:K(e,`launchApp`,n)};let i=L(e,`launchApp`,n);return z(i,`launchApp`,[`appId`,`stopApp`,`clearState`,`permissions`,`arguments`,`launchArguments`],n),o({kind:`launchApp`,source:r,appId:H(i,`appId`,e=>q(e,`launchApp.appId`,n)),stopApp:H(i,`stopApp`,e=>J(e,`launchApp.stopApp`,n)),clearState:H(i,`clearState`,e=>J(e,`launchApp.clearState`,n)),permissions:H(i,`permissions`,e=>cn(e,n,`launchApp`)),arguments:H(i,`arguments`,e=>fn(e,`launchApp.arguments`,n)),launchArguments:H(i,`launchArguments`,e=>fn(e,`launchApp.launchArguments`,n))})}function qt(e,t,n){let r=F(t,n);if((0,P.isScalar)(e))return{kind:`inputText`,source:r,text:K(e,`inputText`,n)};let i=L(e,`inputText`,n);return z(i,`inputText`,[`text`,`label`],n),B(i,`text`)||I(`Maestro inputText requires text.`,t,n),o({kind:`inputText`,source:r,text:K(V(i,`text`),`inputText.text`,n),label:X(i,`inputText`,n)})}function Jt(e,t,n){let r=F(t,n);if(W(e))return{kind:`eraseText`,source:r};if((0,P.isScalar)(e))return{kind:`eraseText`,source:r,charactersToErase:lt(e,`eraseText`,n)};let i=L(e,`eraseText`,n);return z(i,`eraseText`,[`charactersToErase`],n),o({kind:`eraseText`,source:r,charactersToErase:B(i,`charactersToErase`)?Y(V(i,`charactersToErase`),`eraseText.charactersToErase`,n):void 0})}function Yt(e,t,n){let r=F(t,n);if((0,P.isScalar)(e))return{kind:`openLink`,source:r,link:K(e,`openLink`,n)};let i=L(e,`openLink`,n);return z(i,`openLink`,[`link`],n),{kind:`openLink`,source:r,link:K(V(i,`link`),`openLink.link`,n)}}function Xt(e,t,n){let r=F(t,n);if(W(e)&&I(`Maestro assertTrue requires condition.`,t,n),(0,P.isScalar)(e))return{kind:`assertTrue`,source:r,condition:ut(e,`assertTrue`,n)};let i=L(e,`assertTrue`,n);z(i,`assertTrue`,[`condition`,`optional`,`label`],n),B(i,`condition`)||I(`Maestro assertTrue requires condition.`,t,n);let a=ut(V(i,`condition`),`assertTrue.condition`,n),s=U(i,`assertTrue`,n),c=X(i,`assertTrue`,n);return o({kind:`assertTrue`,source:r,condition:a,...s,label:c})}function Zt(e,t,n){let r=L(e,`extendedWaitUntil`,n);z(r,`extendedWaitUntil`,[`visible`,`notVisible`,`timeout`,`optional`,`label`],n);let i=U(r,`extendedWaitUntil`,n),a=X(r,`extendedWaitUntil`,n),s=Pt(r,t,n),c=B(r,`timeout`)?Y(V(r,`timeout`),`extendedWaitUntil.timeout`,n):void 0,l=i.optional===!0||s.optional===!0||void 0,u={kind:`extendedWaitUntil`,source:F(t,n),timeout:c,optional:l,label:a};return u[s.key]=s.selector,o(u)}function Qt(e,t,n){return{kind:`takeScreenshot`,source:F(t,n),path:K(e,`takeScreenshot`,n)}}function $t(e,t,n){return W(e)||I(`Maestro scroll does not accept options yet.`,t,n),{kind:`scroll`,source:F(t,n)}}function en(e,t,n){let r=F(t,n);if((0,P.isScalar)(e))return{kind:`scrollUntilVisible`,source:r,element:Q(e,`scrollUntilVisible.element`,n)};let i=L(e,`scrollUntilVisible`,n);z(i,`scrollUntilVisible`,[`element`,`direction`,`timeout`,`optional`,`label`],n);let a=U(i,`scrollUntilVisible`,n),s=X(i,`scrollUntilVisible`,n),c=Nt(i,`element`,`scrollUntilVisible.element`,n);c||I(`Maestro scrollUntilVisible requires element.`,t,n);let l=B(i,`direction`)?At(V(i,`direction`),`scrollUntilVisible.direction`,n):void 0,u=B(i,`timeout`)?Y(V(i,`timeout`),`scrollUntilVisible.timeout`,n):void 0,d=a.optional===!0||c.optional===!0||void 0;return o({kind:`scrollUntilVisible`,source:r,element:c.selector,direction:l,timeout:u,optional:d,label:s})}function tn(e,t,n){return W(e)||I(`Maestro hideKeyboard does not accept options.`,t,n),{kind:`hideKeyboard`,source:F(t,n)}}function nn(e,t,n){let r=K(e,`pressKey`,n).toLowerCase();return r!==`back`&&r!==`enter`&&r!==`return`&&r!==`home`&&I(`Maestro pressKey "${r}" is not supported.`,e,n),{kind:`pressKey`,source:F(t,n),key:r}}function rn(e,t,n){return W(e)||I(`Maestro back does not accept options.`,t,n),{kind:`back`,source:F(t,n)}}function an(e,t,n){let r=F(t,n);if(W(e))return{kind:`waitForAnimationToEnd`,source:r};if((0,P.isScalar)(e))return o({kind:`waitForAnimationToEnd`,source:r,timeout:Y(e,`waitForAnimationToEnd`,n)});let i=L(e,`waitForAnimationToEnd`,n);return z(i,`waitForAnimationToEnd`,[`timeout`],n),o({kind:`waitForAnimationToEnd`,source:r,timeout:B(i,`timeout`)?Y(V(i,`timeout`),`waitForAnimationToEnd.timeout`,n):void 0})}function on(e,t,n){let r=F(t,n);return W(e)?{kind:`stopApp`,source:r}:{kind:`stopApp`,source:r,appId:K(e,`stopApp`,n)}}function sn(e,t,n){let r=F(t,n),i=L(e,`setPermissions`,n);z(i,`setPermissions`,[`appId`,`permissions`,`optional`,`label`],n),B(i,`permissions`)||I(`Maestro setPermissions requires permissions.`,t,n);let a=H(i,`appId`,e=>q(e,`setPermissions.appId`,n)),s=cn(V(i,`permissions`),n),c=U(i,`setPermissions`,n),l=X(i,`setPermissions`,n);return o({kind:`setPermissions`,source:r,appId:a,permissions:s,...c,label:l})}function cn(e,t,n=`setPermissions`){let r=L(e,`${n}.permissions`,t);r.length===0&&I(`Maestro ${n}.permissions requires at least one permission.`,e,t);let i={};for(let e of r)i[e.key]=ln(e,t,n);return i}function ln(e,t,n=`setPermissions`){let r=`${n}.permissions.${e.key}`,i=G(e.value,r,t);typeof i!=`string`&&I(`Maestro ${r} expects a string.`,e.value,t);let a=i.toLowerCase();if(nt.has(a))return a;if(tt.test(i))return i;i.includes("${")&&I(`Maestro ${r} only supports allow|deny|unset (plus always|inuse|never|limited for location/photos) or a bare \${VAR} lookup; JavaScript expressions are not supported.`,e.value,t),I(`Maestro ${r} expects allow|deny|unset (plus always|inuse|never|limited for location/photos) or a bare \${VAR} lookup.`,e.value,t)}function un(e,t,n){let r=F(t,n);return W(e)?{kind:`clearState`,source:r}:{kind:`clearState`,source:r,appId:K(e,`clearState`,n)}}function dn(e,t,n){return{kind:`evalScript`,source:F(t,n),script:K(e,`evalScript`,n)}}function fn(e,t,n){if((0,P.isSeq)(e))return{kind:`list`,values:R(e,t,n).map((e,r)=>{let i=G(e,`${t}[${r}]`,n);return i===null&&I(`${t}[${r}] expects a scalar value.`,e,n),i})};if((0,P.isMap)(e))return{kind:`map`,values:dt(e,t,n)};let r=G(e,t,n);return r===null&&I(`${t} expects a scalar, list, or map.`,e,n),{kind:`scalar`,value:r}}function pn(e,t={}){let n=new P.LineCounter,r=o({lineCounter:n,sourcePath:t.sourcePath}),a=(0,P.parseAllDocuments)(e,{lineCounter:n});for(let e of a)if(e.errors.length>0){let t=e.errors[0],n=t?.message??`Invalid Maestro YAML flow.`,a=Qe(t?.pos[0],r);throw new i(`INVALID_ARGS`,`Invalid Maestro YAML flow: ${n} (${$e(a)})`)}let s=a.map(e=>e.contents).filter(e=>e!==null);s.length===0&&I(`Maestro flow is empty.`,void 0,r);let c,l;s.length===1&&(0,P.isSeq)(s[0])?l=s[0]:s.length===2&&(0,P.isMap)(s[0])&&(0,P.isSeq)(s[1])?(c=s[0],l=s[1]):I(`Maestro flow must contain a command list, optionally preceded by one config document.`,s[0],r);let u=c?mn(c,r):{};return{kind:`program`,source:F(c??l,r),config:u,commands:$(l,`commands`,r)}}function mn(e,t){let n=L(e,`flow config`,t);return z(n,`flow config`,[`name`,`appId`,`tags`,`env`,`onFlowStart`,`onFlowComplete`],t),o({name:H(n,`name`,e=>q(e,`name`,t)),appId:H(n,`appId`,e=>q(e,`appId`,t)),tags:H(n,`tags`,e=>et(e,`tags`,t)),env:H(n,`env`,e=>dt(e,`env`,t)),onFlowStart:H(n,`onFlowStart`,e=>$(e,`onFlowStart`,t)),onFlowComplete:H(n,`onFlowComplete`,e=>$(e,`onFlowComplete`,t))})}function hn(e,t){let n=new Map;return async(i,a,o)=>{if(o?.aborted)throw r();let s=gn(i,a,e),c=n.get(s);if(c)return c;let l=pn(t(s),{sourcePath:s});return n.set(s,l),l}}function gn(e,t,n){let r=t?a.dirname(t):n;return a.resolve(r,e)}function _n(e){let t={[e.entryPath]:e.entrySource},n=vn(e.entrySource,e.entryPath);return n&&yn({program:n,sourcePath:e.entryPath,context:l({},{...e.env}),files:t,readSource:e.readSource}),t}function vn(e,t){try{return pn(e,{sourcePath:t})}catch{return}}function yn(e){let t=e.context.enter(e.program.config.env??{});try{bn([...e.program.config.onFlowStart??[],...e.program.commands,...e.program.config.onFlowComplete??[]],e)}finally{t()}}function bn(e,t){for(let n of e){if(n.kind===`repeat`||n.kind===`retry`){bn(n.commands,t);continue}if(n.kind!==`runFlow`)continue;let e=t.context.enter(n.env??{});try{if(n.include.kind===`commands`){bn(n.include.commands,t);continue}xn(n.include.path,t)}finally{e()}}}function xn(e,t){let n=t.context.resolveDeferred(e);if(n.includes("${"))return;let r=gn(n,t.sourcePath,t.sourcePath);if(t.files[r]!==void 0)return;let i=t.readSource(r);if(i===void 0)return;t.files[r]=i;let a=vn(i,r);a&&yn({...t,program:a,sourcePath:r})}var Sn=t({MAESTRO_COMPATIBILITY_ADR_URL:()=>MAESTRO_COMPATIBILITY_ADR_URL,MAESTRO_COMPATIBILITY_ISSUE_URL:()=>MAESTRO_COMPATIBILITY_ISSUE_URL,collectMaestroFlowSources:()=>_n});export{at as a,l as c,o as d,ft as i,c as l,hn as n,ot as o,pn as r,Ze as s,Sn as t,s as u};
115
+ `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=l(c(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=l(c(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),Xe=n((e=>{var t=He(),n=Ee(),r=De(),i=re(),a=m(),o=Je(),s=Ye();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),Ze=n((e=>{var t=He(),n=Ee(),r=we(),i=De(),a=x(),o=m(),s=D(),c=S(),l=O(),u=A();Ke();var d=qe(),f=Je(),p=Ye(),g=Xe(),_=h();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.Lexer=d.Lexer,e.LineCounter=f.LineCounter,e.Parser=p.Parser,e.parse=g.parse,e.parseAllDocuments=g.parseAllDocuments,e.parseDocument=g.parseDocument,e.stringify=g.stringify,e.visit=_.visit,e.visitAsync=_.visitAsync})),P=Ze();function F(e,t){return Qe(e?.range?.[0],t)}function Qe(e,t){let n=t.lineCounter.linePos(e!==void 0&&e>=0?e:0).line;return t.sourcePath===void 0?{line:n}:{path:t.sourcePath,line:n}}function $e(e){return`${e.path===void 0?``:`${e.path}:`}line ${e.line}`}function I(e,t,n){throw new i(`INVALID_ARGS`,`${e} (${$e(F(t,n))})`)}function L(e,t,n){(0,P.isMap)(e)||I(`Maestro ${t} expects a map.`,e,n);let r=[];for(let i of e.items){let e=i.key;(0,P.isScalar)(e)||I(`Maestro ${t} map keys must be strings.`,void 0,n);let a=e.value;typeof a!=`string`&&typeof a!=`number`&&typeof a!=`boolean`&&I(`Maestro ${t} map keys must be strings.`,e,n),i.value!==null&&!(0,P.isNode)(i.value)&&I(`Maestro ${t} values must be YAML nodes.`,e,n),r.push({key:String(a),keyNode:e,value:i.value})}return r}function R(e,t,n){return(0,P.isSeq)(e)||I(`Maestro ${t} expects a list.`,e,n),e.items}function et(e,t,n){return R(e,t,n).map((e,r)=>K(e,`${t}[${r}]`,n))}function z(e,t,n,r){let i=new Set(n),a=new Set;for(let n of e)a.has(n.key)&&I(`Maestro ${t} contains duplicate field "${n.key}".`,n.keyNode,r),a.add(n.key),i.has(n.key)||I(`Maestro ${t} field "${n.key}" is not supported.`,n.keyNode,r)}function B(e,t){return e.some(e=>e.key===t)}function V(e,t){return e.find(e=>e.key===t)?.value}function H(e,t,n){return B(e,t)?n(V(e,t)):void 0}function U(e,t,n){return o({optional:H(e,`optional`,e=>J(e,`${t}.optional`,n))})}function W(e){return e===null||(0,P.isScalar)(e)&&e.value===null}function G(e,t,n){if(e==null)return null;(0,P.isScalar)(e)||I(`Maestro ${t} expects a scalar value.`,e,n);let r=e.value;if(r===null||typeof r==`string`||typeof r==`number`||typeof r==`boolean`)return r;I(`Maestro ${t} contains an unsupported scalar value.`,e,n)}function K(e,t,n){let r=G(e,t,n);return typeof r!=`string`&&I(`Maestro ${t} expects a string.`,e,n),r}function q(e,t,n){let r=G(e,t,n);if(r!==null)return typeof r!=`string`&&I(`Maestro ${t} expects a string.`,e,n),r}function J(e,t,n){let r=G(e,t,n);if(r!==null)return typeof r!=`boolean`&&I(`Maestro ${t} expects a boolean.`,e,n),r}const tt=/^\$\{[A-Za-z_][A-Za-z0-9_.]*\}$/,nt=new Set([`allow`,`deny`,`unset`,`always`,`inuse`,`never`,`limited`]),rt=/^-?\d+(\.\d+)?$/,it=/^-?\d+$/,at={"tapOn.index":{integer:!0,nonNegative:!0},"tapOn.repeat":{integer:!0,positive:!0},"tapOn.delay":{integer:!0,nonNegative:!0},"doubleTapOn.delay":{integer:!0,nonNegative:!0},eraseText:{integer:!0,positive:!0},"eraseText.charactersToErase":{integer:!0,positive:!0},"extendedWaitUntil.timeout":{nonNegative:!0},"scrollUntilVisible.timeout":{nonNegative:!0},waitForAnimationToEnd:{nonNegative:!0},"waitForAnimationToEnd.timeout":{nonNegative:!0},"swipe.duration":{nonNegative:!0},"repeat.times":{integer:!0,nonNegative:!0},"retry.maxRetries":{integer:!0,nonNegative:!0}};function ot(e){return e.positive&&e.integer?`a positive integer`:e.positive?`a positive number`:e.nonNegative&&e.integer?`a non-negative integer`:e.nonNegative?`a non-negative finite number`:e.integer?`an integer`:`a finite number`}function st(e,t,n,r,i){let a=`Maestro ${t} expects ${ot(i)} or a variable expression.`;Number.isFinite(e)||I(a,n,r),Math.abs(e)>2**53-1&&I(a,n,r),i.integer&&!Number.isSafeInteger(e)&&I(a,n,r),i.nonNegative&&e<0&&I(a,n,r),i.positive&&e<=0&&I(a,n,r)}function ct(e,t,n,r,i){if(typeof e==`number`)return st(e,t,n,r,i),e;if(typeof e==`string`){if(tt.test(e))return e;if((i.integer?it:rt).test(e)){let a=Number(e);return st(a,t,n,r,i),a}}I(`Maestro ${t} expects ${ot(i)} or a variable expression.`,n,r)}function Y(e,t,n,r=at[t]??{}){let i=G(e,t,n);if(i!==null)return ct(i,t,e,n,r)}function lt(e,t,n){let r=at[t]??{},i=G(e,t,n);return i===null&&I(`Maestro ${t} expects ${ot(r)} or a variable expression.`,e,n),ct(i,t,e,n,r)}function ut(e,t,n){let r=G(e,t,n);return r===null&&I(`Maestro ${t} requires a condition.`,e,n),typeof r==`string`&&r.includes("${")&&!tt.test(r)&&I(`Maestro ${t} only supports a literal value or a bare \${VAR} lookup; JavaScript expressions are not supported — compute it in a runScript and reference \${output.x}.`,e,n),r}function dt(e,t,n){let r=L(e,t,n),i={};for(let e of r){let r=G(e.value,`${t}.${e.key}`,n);r===null&&I(`Maestro ${t}.${e.key} expects a string, number, or boolean.`,e.value,n),i[e.key]=r}return i}function X(e,t,n){return H(e,`label`,e=>q(e,`${t}.label`,n))}const Z=[`id`,`text`,`enabled`,`selected`,`index`,`childOf`,`below`,`above`,`leftOf`,`rightOf`,`containsChild`,`containsDescendants`],ft={textKeys:[`id`,`text`],booleanKeys:[`enabled`,`selected`],textAliases:{label:`text`}},pt={id:(e,t,n,r)=>vt(e,`id`,t,n,r),text:(e,t,n,r)=>vt(e,`text`,t,n,r),enabled:(e,t,n,r)=>yt(e,`enabled`,t,n,r),selected:(e,t,n,r)=>yt(e,`selected`,t,n,r),index:(e,t,n,r)=>{e.index=Y(t.value,`${n}.index`,r,{integer:!0,nonNegative:!0})},childOf:(e,t,n,r)=>{e.childOf=Q(t.value,`${n}.childOf`,r)},below:(e,t,n,r)=>{e.below=Q(t.value,`${n}.below`,r)},above:(e,t,n,r)=>{e.above=Q(t.value,`${n}.above`,r)},leftOf:(e,t,n,r)=>{e.leftOf=Q(t.value,`${n}.leftOf`,r)},rightOf:(e,t,n,r)=>{e.rightOf=Q(t.value,`${n}.rightOf`,r)},containsChild:(e,t,n,r)=>{e.containsChild=Q(t.value,`${n}.containsChild`,r)},containsDescendants:(e,t,n,r)=>{e.containsDescendants=R(t.value,`${n}.containsDescendants`,r).map(e=>Q(e,`${n}.containsDescendants`,r))},optional:(e,t,n,r)=>yt(e,`optional`,t,n,r)};function Q(e,t,n,r=Z){if((0,P.isScalar)(e))return{text:K(e,t,n)};let i=L(e,t,n);return z(i,t,r,n),mt(i,t,n)}function mt(e,t,n){e.length===0&&I(`Maestro ${t} selector is empty.`,void 0,n);let r={};for(let i of e){let e=pt[i.key];e||I(`Maestro ${t} selector field "${i.key}" is not supported.`,i.keyNode,n),e(r,i,t,n)}return Object.keys(r).filter(e=>e!==`optional`).length===0&&I(`Maestro ${t} selector must contain a selector value.`,e[0]?.keyNode,n),r}function ht(e,t,n,r){let i=F(t,n);if((0,P.isScalar)(e))return{source:i,entries:[],target:xt(Q(e,r.name,n,r.selectorKeys))};let a=L(e,r.name,n),o=B(a,`point`);if(z(a,r.name,o?r.pointAllowedKeys:r.selectorAllowedKeys,n),o){let e=r.pointConflictingSelectorKeys??r.selectorKeys;return a.some(t=>bt(t.key,e))&&I(`Maestro ${r.name}.point cannot be combined with a selector.`,t,n),{source:i,entries:a,target:r.parsePoint(V(a,`point`),`${r.name}.point`,n)}}return{source:i,entries:a,target:xt(mt(a.filter(e=>bt(e.key,r.selectorKeys)),r.name,n))}}function gt(e,t,n){let r=K(e,t,n),i=/^\s*(\d+)\s*,\s*(\d+)\s*$/.exec(r);if(i)return{space:`absolute`,x:Number(i[1]),y:Number(i[2])};let a=/^\s*(\d+)%\s*,\s*(\d+)%\s*$/.exec(r);if(a){let r=Number(a[1]),i=Number(a[2]);return(r>100||i>100)&&I(`Maestro ${t} percentage coordinates must be between 0% and 100%.`,e,n),{space:`percent`,x:r,y:i}}/^\s*\d+(?:\.\d+)?%\s*,\s*\d+(?:\.\d+)?%\s*$/.test(r)&&I(`Maestro ${t} percentage coordinates must be whole numbers.`,e,n),I(`Maestro ${t} expects absolute or percentage coordinates.`,e,n)}function _t(e,t,n){let r=gt(e,t,n);return r.space!==`absolute`&&I(`Maestro ${t} only supports absolute coordinates.`,e,n),r}function vt(e,t,n,r,i){let a=q(n.value,`${r}.${t}`,i);a!==void 0&&(e[t]=a)}function yt(e,t,n,r,i){let a=J(n.value,`${r}.${t}`,i);a!==void 0&&(e[t]=a)}function bt(e,t){return t.includes(e)}function xt(e){return{space:`target`,selector:e}}function St(e,t,n){let r=ht(e,t,n,{name:`tapOn`,selectorKeys:Z,pointConflictingSelectorKeys:Z,pointAllowedKeys:[`point`,`retryTapIfNoChange`,`repeat`,`delay`,`optional`,`label`],selectorAllowedKeys:[...Z,`retryTapIfNoChange`,`repeat`,`delay`,`optional`,`label`],parsePoint:gt});if(r.entries.length===0)return{kind:`tapOn`,source:r.source,target:r.target};if(r.target.space!==`target`)return{kind:`tapOn`,source:r.source,target:r.target,...kt(r.entries,n)};let i=kt(r.entries,n);return o({kind:`tapOn`,source:r.source,target:r.target,...i})}function Ct(e,t,n){let r=ht(e,t,n,{name:`doubleTapOn`,selectorKeys:Z,pointAllowedKeys:[`point`,`delay`,`optional`,`label`],selectorAllowedKeys:[...Z,`delay`,`optional`,`label`],parsePoint:_t}),i=U(r.entries,`doubleTapOn`,n),a=B(r.entries,`delay`)?Y(V(r.entries,`delay`),`doubleTapOn.delay`,n):void 0,s=X(r.entries,`doubleTapOn`,n);return o({kind:`doubleTapOn`,source:r.source,target:r.target,...i,delay:a,label:s})}function wt(e,t,n){let r=ht(e,t,n,{name:`longPressOn`,selectorKeys:Z,pointAllowedKeys:[`point`,`optional`,`label`],selectorAllowedKeys:[...Z,`optional`,`label`],parsePoint:_t});return o({kind:`longPressOn`,source:r.source,target:r.target,...U(r.entries,`longPressOn`,n),label:X(r.entries,`longPressOn`,n)})}function Tt(e,t,n){let r=F(t,n),i=L(e,`swipe`,n);z(i,`swipe`,[`start`,`end`,`direction`,`duration`,`from`,`label`,`optional`],n);let a=U(i,`swipe`,n),o=X(i,`swipe`,n),s=B(i,`duration`)?Y(V(i,`duration`),`swipe.duration`,n):void 0;if(B(i,`start`)||B(i,`end`))return{...Et(i,r,s,t,n),...a,label:o};let c=B(i,`direction`)?At(V(i,`direction`),`swipe.direction`,n):void 0;return B(i,`from`)?{...Dt(i,r,c,s,t,n),...a,label:o}:{...Ot(r,c,s,t,n),...a,label:o}}function Et(e,t,n,r,i){B(e,`direction`)&&I(`Maestro swipe cannot combine direction with start/end coordinates.`,r,i),(!B(e,`start`)||!B(e,`end`))&&I(`Maestro swipe requires both start and end coordinates.`,r,i);let a=gt(V(e,`start`),`swipe.start`,i),s=gt(V(e,`end`),`swipe.end`,i);return a.space!==s.space&&I(`Maestro swipe start/end must use the same coordinate space.`,r,i),{kind:`swipe`,source:t,gesture:o({kind:`coordinates`,start:a,end:s,duration:n})}}function Dt(e,t,n,r,i,a){return n===void 0&&I(`Maestro target swipe requires direction.`,i,a),{kind:`swipe`,source:t,gesture:o({kind:`target`,from:Q(V(e,`from`),`swipe.from`,a),direction:n,duration:r})}}function Ot(e,t,n,r,i){return t===void 0&&I(`Maestro swipe requires direction, target, or start/end coordinates.`,r,i),{kind:`swipe`,source:e,gesture:o({kind:`screen`,direction:t,duration:n})}}function kt(e,t){let n=H(e,`retryTapIfNoChange`,e=>J(e,`tapOn.retryTapIfNoChange`,t)),r=H(e,`repeat`,e=>lt(e,`tapOn.repeat`,t)),i=H(e,`delay`,e=>Y(e,`tapOn.delay`,t)),a=U(e,`tapOn`,t).optional;return o({retryTapIfNoChange:n,repeat:r,delay:i,optional:a,label:X(e,`tapOn`,t)})}function At(e,t,n){let r=K(e,t,n).toLowerCase();if(r===`up`||r===`down`||r===`left`||r===`right`)return r;I(`Maestro ${t} must be UP, DOWN, LEFT, or RIGHT.`,e,n)}function jt(e,t,n,r){let i=F(n,r);if((0,P.isScalar)(t))return{kind:e,source:i,target:Q(t,e,r)};let a=L(t,e,r);z(a,e,[...Z,`optional`,`label`],r);let s=U(a,e,r),c=X(a,e,r);return o({kind:e,source:i,target:mt(a.filter(e=>e.key!==`optional`&&e.key!==`label`),e,r),...s,label:c})}const Mt=[...Z,`optional`];function Nt(e,t,n,r){if(!B(e,t))return;let{optional:i,...a}=Q(V(e,t),n,r,Mt);return{selector:a,optional:i}}function Pt(e,t,n){let r=Nt(e,`visible`,`extendedWaitUntil.visible`,n),i=Nt(e,`notVisible`,`extendedWaitUntil.notVisible`,n);return r&&i&&I(`Maestro extendedWaitUntil cannot specify both visible and notVisible.`,t,n),!r&&!i&&I(`Maestro extendedWaitUntil requires visible or notVisible.`,t,n),r?{key:`visible`,selector:r.selector,optional:r.optional}:{key:`notVisible`,selector:i.selector,optional:i.optional}}function Ft(e,t,n){let r=F(t,n);if((0,P.isScalar)(e))return{kind:`runScript`,source:r,file:K(e,`runScript`,n)};let i=L(e,`runScript`,n);return z(i,`runScript`,[`file`,`env`],n),B(i,`file`)||I(`Maestro runScript requires a file.`,t,n),o({kind:`runScript`,source:r,file:K(V(i,`file`),`runScript.file`,n),env:B(i,`env`)?dt(V(i,`env`),`runScript.env`,n):void 0})}function It(e,t,n,r){let i=F(t,n);if((0,P.isScalar)(e))return{kind:`runFlow`,source:i,include:{kind:`file`,path:K(e,`runFlow`,n)}};let a=L(e,`runFlow`,n);z(a,`runFlow`,[`file`,`commands`,`env`,`when`,`label`],n);let s=B(a,`file`);return s===B(a,`commands`)&&I(`Maestro runFlow requires exactly one of file or commands.`,t,n),o({kind:`runFlow`,source:i,include:s?{kind:`file`,path:K(V(a,`file`),`runFlow.file`,n)}:{kind:`commands`,commands:r(V(a,`commands`),`runFlow.commands`,n)},env:B(a,`env`)?dt(V(a,`env`),`runFlow.env`,n):void 0,when:B(a,`when`)?zt(V(a,`when`),`runFlow.when`,n):void 0,label:X(a,`runFlow`,n)})}function Lt(e,t,n,r){let i=F(t,n),a=L(e,`repeat`,n);z(a,`repeat`,[`times`,`commands`,`while`],n);let s=B(a,`while`)?zt(V(a,`while`),`repeat.while`,n):void 0;return!B(a,`times`)&&!s&&I(`Maestro repeat requires times or while.`,t,n),B(a,`commands`)||I(`Maestro repeat requires commands.`,t,n),o({kind:`repeat`,source:i,times:B(a,`times`)?lt(V(a,`times`),`repeat.times`,n):void 0,while:s,commands:r(V(a,`commands`),`repeat.commands`,n)})}function Rt(e,t,n,r){let i=F(t,n),a=L(e,`retry`,n);z(a,`retry`,[`maxRetries`,`commands`],n),B(a,`commands`)||I(`Maestro retry requires commands.`,t,n);let s=B(a,`maxRetries`)?lt(V(a,`maxRetries`),`retry.maxRetries`,n):void 0;return o({kind:`retry`,source:i,commands:r(V(a,`commands`),`retry.commands`,n),maxRetries:s})}function zt(e,t,n){let r=L(e,t,n);return z(r,t,[`platform`,`visible`,`notVisible`,`true`],n),r.length===0&&I(`Maestro ${t} cannot be empty.`,e,n),o({platform:H(r,`platform`,e=>Vt(e,n,`${t}.platform`)),visible:H(r,`visible`,e=>Q(e,`${t}.visible`,n)),notVisible:H(r,`notVisible`,e=>Q(e,`${t}.notVisible`,n)),true:H(r,`true`,e=>Bt(e,n,`${t}.true`))})}function Bt(e,t,n){let r=G(e,n,t);if(typeof r==`boolean`||typeof r==`string`)return r;I(`Maestro ${n} expects a boolean or expression string.`,e,t)}function Vt(e,t,n){let r=K(e,n,t).toLowerCase();if(r===`android`||r===`ios`||r===`web`)return r;I(`Maestro ${n} expects Android, iOS, or Web.`,e,t)}function $(e,t,n){return R(e,t,n).map(e=>Ht(e,n))}function Ht(e,t){if((0,P.isScalar)(e))return typeof e.value!=`string`&&I(`Maestro command names must be strings.`,e,t),Ut(e.value,e,t);(0,P.isMap)(e)||I(`Maestro commands must be a scalar or one-key map.`,e,t);let n=L(e,`command`,t);n.length!==1&&I(`Maestro command maps must contain exactly one command.`,e,t);let r=n[0];return Gt(r.key,r.value,e,t)}function Ut(e,t,n){return Gt(e,null,t,n)}const Wt={launchApp:Kt,tapOn:St,doubleTapOn:Ct,longPressOn:wt,inputText:qt,eraseText:Jt,openLink:Yt,assertVisible:(e,t,n)=>jt(`assertVisible`,e,t,n),assertNotVisible:(e,t,n)=>jt(`assertNotVisible`,e,t,n),assertTrue:Xt,extendedWaitUntil:Zt,takeScreenshot:Qt,scroll:$t,scrollUntilVisible:en,swipe:Tt,hideKeyboard:tn,pressKey:nn,back:rn,waitForAnimationToEnd:an,stopApp:on,setPermissions:sn,clearState:un,runScript:Ft,evalScript:dn,runFlow:(e,t,n)=>It(e,t,n,$),repeat:(e,t,n)=>Lt(e,t,n,$),retry:(e,t,n)=>Rt(e,t,n,$)};Object.keys(Wt);function Gt(e,t,n,r){let i=Wt[e];return i||I(`Maestro command "${e}" is not supported.`,n,r),i(t,n,r)}function Kt(e,t,n){let r=F(t,n);if(W(e))return{kind:`launchApp`,source:r};if((0,P.isScalar)(e))return{kind:`launchApp`,source:r,appId:K(e,`launchApp`,n)};let i=L(e,`launchApp`,n);return z(i,`launchApp`,[`appId`,`stopApp`,`clearState`,`permissions`,`arguments`,`launchArguments`],n),o({kind:`launchApp`,source:r,appId:H(i,`appId`,e=>q(e,`launchApp.appId`,n)),stopApp:H(i,`stopApp`,e=>J(e,`launchApp.stopApp`,n)),clearState:H(i,`clearState`,e=>J(e,`launchApp.clearState`,n)),permissions:H(i,`permissions`,e=>cn(e,n,`launchApp`)),arguments:H(i,`arguments`,e=>fn(e,`launchApp.arguments`,n)),launchArguments:H(i,`launchArguments`,e=>fn(e,`launchApp.launchArguments`,n))})}function qt(e,t,n){let r=F(t,n);if((0,P.isScalar)(e))return{kind:`inputText`,source:r,text:K(e,`inputText`,n)};let i=L(e,`inputText`,n);return z(i,`inputText`,[`text`,`label`],n),B(i,`text`)||I(`Maestro inputText requires text.`,t,n),o({kind:`inputText`,source:r,text:K(V(i,`text`),`inputText.text`,n),label:X(i,`inputText`,n)})}function Jt(e,t,n){let r=F(t,n);if(W(e))return{kind:`eraseText`,source:r};if((0,P.isScalar)(e))return{kind:`eraseText`,source:r,charactersToErase:lt(e,`eraseText`,n)};let i=L(e,`eraseText`,n);return z(i,`eraseText`,[`charactersToErase`],n),o({kind:`eraseText`,source:r,charactersToErase:B(i,`charactersToErase`)?Y(V(i,`charactersToErase`),`eraseText.charactersToErase`,n):void 0})}function Yt(e,t,n){let r=F(t,n);if((0,P.isScalar)(e))return{kind:`openLink`,source:r,link:K(e,`openLink`,n)};let i=L(e,`openLink`,n);return z(i,`openLink`,[`link`],n),{kind:`openLink`,source:r,link:K(V(i,`link`),`openLink.link`,n)}}function Xt(e,t,n){let r=F(t,n);if(W(e)&&I(`Maestro assertTrue requires condition.`,t,n),(0,P.isScalar)(e))return{kind:`assertTrue`,source:r,condition:ut(e,`assertTrue`,n)};let i=L(e,`assertTrue`,n);z(i,`assertTrue`,[`condition`,`optional`,`label`],n),B(i,`condition`)||I(`Maestro assertTrue requires condition.`,t,n);let a=ut(V(i,`condition`),`assertTrue.condition`,n),s=U(i,`assertTrue`,n),c=X(i,`assertTrue`,n);return o({kind:`assertTrue`,source:r,condition:a,...s,label:c})}function Zt(e,t,n){let r=L(e,`extendedWaitUntil`,n);z(r,`extendedWaitUntil`,[`visible`,`notVisible`,`timeout`,`optional`,`label`],n);let i=U(r,`extendedWaitUntil`,n),a=X(r,`extendedWaitUntil`,n),s=Pt(r,t,n),c=B(r,`timeout`)?Y(V(r,`timeout`),`extendedWaitUntil.timeout`,n):void 0,l=i.optional===!0||s.optional===!0||void 0,u={kind:`extendedWaitUntil`,source:F(t,n),timeout:c,optional:l,label:a};return u[s.key]=s.selector,o(u)}function Qt(e,t,n){return{kind:`takeScreenshot`,source:F(t,n),path:K(e,`takeScreenshot`,n)}}function $t(e,t,n){return W(e)||I(`Maestro scroll does not accept options yet.`,t,n),{kind:`scroll`,source:F(t,n)}}function en(e,t,n){let r=F(t,n);if((0,P.isScalar)(e))return{kind:`scrollUntilVisible`,source:r,element:Q(e,`scrollUntilVisible.element`,n)};let i=L(e,`scrollUntilVisible`,n);z(i,`scrollUntilVisible`,[`element`,`direction`,`timeout`,`optional`,`label`],n);let a=U(i,`scrollUntilVisible`,n),s=X(i,`scrollUntilVisible`,n),c=Nt(i,`element`,`scrollUntilVisible.element`,n);c||I(`Maestro scrollUntilVisible requires element.`,t,n);let l=B(i,`direction`)?At(V(i,`direction`),`scrollUntilVisible.direction`,n):void 0,u=B(i,`timeout`)?Y(V(i,`timeout`),`scrollUntilVisible.timeout`,n):void 0,d=a.optional===!0||c.optional===!0||void 0;return o({kind:`scrollUntilVisible`,source:r,element:c.selector,direction:l,timeout:u,optional:d,label:s})}function tn(e,t,n){return W(e)||I(`Maestro hideKeyboard does not accept options.`,t,n),{kind:`hideKeyboard`,source:F(t,n)}}function nn(e,t,n){let r=K(e,`pressKey`,n).toLowerCase();return r!==`back`&&r!==`enter`&&r!==`return`&&r!==`home`&&I(`Maestro pressKey "${r}" is not supported.`,e,n),{kind:`pressKey`,source:F(t,n),key:r}}function rn(e,t,n){return W(e)||I(`Maestro back does not accept options.`,t,n),{kind:`back`,source:F(t,n)}}function an(e,t,n){let r=F(t,n);if(W(e))return{kind:`waitForAnimationToEnd`,source:r};if((0,P.isScalar)(e))return o({kind:`waitForAnimationToEnd`,source:r,timeout:Y(e,`waitForAnimationToEnd`,n)});let i=L(e,`waitForAnimationToEnd`,n);return z(i,`waitForAnimationToEnd`,[`timeout`],n),o({kind:`waitForAnimationToEnd`,source:r,timeout:B(i,`timeout`)?Y(V(i,`timeout`),`waitForAnimationToEnd.timeout`,n):void 0})}function on(e,t,n){let r=F(t,n);return W(e)?{kind:`stopApp`,source:r}:{kind:`stopApp`,source:r,appId:K(e,`stopApp`,n)}}function sn(e,t,n){let r=F(t,n),i=L(e,`setPermissions`,n);z(i,`setPermissions`,[`appId`,`permissions`,`optional`,`label`],n),B(i,`permissions`)||I(`Maestro setPermissions requires permissions.`,t,n);let a=H(i,`appId`,e=>q(e,`setPermissions.appId`,n)),s=cn(V(i,`permissions`),n),c=U(i,`setPermissions`,n),l=X(i,`setPermissions`,n);return o({kind:`setPermissions`,source:r,appId:a,permissions:s,...c,label:l})}function cn(e,t,n=`setPermissions`){let r=L(e,`${n}.permissions`,t);r.length===0&&I(`Maestro ${n}.permissions requires at least one permission.`,e,t);let i={};for(let e of r)i[e.key]=ln(e,t,n);return i}function ln(e,t,n=`setPermissions`){let r=`${n}.permissions.${e.key}`,i=G(e.value,r,t);typeof i!=`string`&&I(`Maestro ${r} expects a string.`,e.value,t);let a=i.toLowerCase();if(nt.has(a))return a;if(tt.test(i))return i;i.includes("${")&&I(`Maestro ${r} only supports allow|deny|unset (plus always|inuse|never|limited for location/photos) or a bare \${VAR} lookup; JavaScript expressions are not supported.`,e.value,t),I(`Maestro ${r} expects allow|deny|unset (plus always|inuse|never|limited for location/photos) or a bare \${VAR} lookup.`,e.value,t)}function un(e,t,n){let r=F(t,n);return W(e)?{kind:`clearState`,source:r}:{kind:`clearState`,source:r,appId:K(e,`clearState`,n)}}function dn(e,t,n){return{kind:`evalScript`,source:F(t,n),script:K(e,`evalScript`,n)}}function fn(e,t,n){if((0,P.isSeq)(e))return{kind:`list`,values:R(e,t,n).map((e,r)=>{let i=G(e,`${t}[${r}]`,n);return i===null&&I(`${t}[${r}] expects a scalar value.`,e,n),i})};if((0,P.isMap)(e))return{kind:`map`,values:dt(e,t,n)};let r=G(e,t,n);return r===null&&I(`${t} expects a scalar, list, or map.`,e,n),{kind:`scalar`,value:r}}function pn(e,t={}){let n=new P.LineCounter,r=o({lineCounter:n,sourcePath:t.sourcePath}),a=(0,P.parseAllDocuments)(e,{lineCounter:n});for(let e of a)if(e.errors.length>0){let t=e.errors[0],n=t?.message??`Invalid Maestro YAML flow.`,a=Qe(t?.pos[0],r);throw new i(`INVALID_ARGS`,`Invalid Maestro YAML flow: ${n} (${$e(a)})`)}let s=a.map(e=>e.contents).filter(e=>e!==null);s.length===0&&I(`Maestro flow is empty.`,void 0,r);let c,l;s.length===1&&(0,P.isSeq)(s[0])?l=s[0]:s.length===2&&(0,P.isMap)(s[0])&&(0,P.isSeq)(s[1])?(c=s[0],l=s[1]):I(`Maestro flow must contain a command list, optionally preceded by one config document.`,s[0],r);let u=c?mn(c,r):{};return{kind:`program`,source:F(c??l,r),config:u,commands:$(l,`commands`,r)}}function mn(e,t){let n=L(e,`flow config`,t);return z(n,`flow config`,[`name`,`appId`,`tags`,`env`,`onFlowStart`,`onFlowComplete`],t),o({name:H(n,`name`,e=>q(e,`name`,t)),appId:H(n,`appId`,e=>q(e,`appId`,t)),tags:H(n,`tags`,e=>et(e,`tags`,t)),env:H(n,`env`,e=>dt(e,`env`,t)),onFlowStart:H(n,`onFlowStart`,e=>$(e,`onFlowStart`,t)),onFlowComplete:H(n,`onFlowComplete`,e=>$(e,`onFlowComplete`,t))})}function hn(e,t){let n=new Map;return async(i,a,o)=>{if(o?.aborted)throw r();let s=gn(i,a,e),c=n.get(s);if(c)return c;let l=pn(t(s),{sourcePath:s});return n.set(s,l),l}}function gn(e,t,n){let r=t?a.dirname(t):n;return a.resolve(r,e)}function _n(e){let t={[e.entryPath]:e.entrySource},n=vn(e.entrySource,e.entryPath);return n&&yn({program:n,sourcePath:e.entryPath,context:l({},{...e.env}),files:t,readSource:e.readSource}),t}function vn(e,t){try{return pn(e,{sourcePath:t})}catch{return}}function yn(e){let t=e.context.enter(e.program.config.env??{});try{bn([...e.program.config.onFlowStart??[],...e.program.commands,...e.program.config.onFlowComplete??[]],e)}finally{t()}}function bn(e,t){for(let n of e){if(n.kind===`repeat`||n.kind===`retry`){bn(n.commands,t);continue}if(n.kind!==`runFlow`)continue;let e=t.context.enter(n.env??{});try{if(n.include.kind===`commands`){bn(n.include.commands,t);continue}xn(n.include.path,t)}finally{e()}}}function xn(e,t){let n=t.context.resolveDeferred(e);if(n.includes("${"))return;let r=gn(n,t.sourcePath,t.sourcePath);if(t.files[r]!==void 0)return;let i=t.readSource(r);if(i===void 0)return;t.files[r]=i;let a=vn(i,r);a&&yn({...t,program:a,sourcePath:r})}var Sn=t({MAESTRO_COMPATIBILITY_ADR_URL:()=>MAESTRO_COMPATIBILITY_ADR_URL,MAESTRO_COMPATIBILITY_ISSUE_URL:()=>MAESTRO_COMPATIBILITY_ISSUE_URL,collectMaestroFlowSources:()=>_n});export{at as a,l as c,o as d,ft as i,c as l,hn as n,ot as o,pn as r,Ze as s,Sn as t,s as u};
@@ -0,0 +1 @@
1
+ import{J as e,P as t}from"./sdk-contracts.js";import{v as n}from"./sdk-batch-runner.js";import{A as r,o as i}from"./owner-identity.js";import{l as a}from"./exec.js";import{t as o}from"./file.js";import"./command.js";import"./process.js";import{n as s}from"./cli-config.js";import c from"node:crypto";import l from"node:fs";import u from"node:path";function d(e,n){let r=new Set(n);for(let n of e){let e=n.agentDevicePlugin.provider;if(r.has(e))throw new t(`INVALID_ARGS`,`Duplicate provider plugin: ${e}`);r.add(e)}}function f(e){let n;try{let t=u.join(e,`package.json`);n=JSON.parse(l.readFileSync(t,`utf8`))}catch(n){throw new t(`INVALID_ARGS`,`Cannot read plugin manifest: ${e}`,{},n)}let r=n?.agentDevicePlugin;if(typeof n?.name!=`string`||typeof n?.version!=`string`||!r||r.apiVersion!==1||typeof r.provider!=`string`||!/^[a-z][a-z0-9-]*$/.test(r.provider)||typeof r.entry!=`string`||!r.entry.startsWith(`./`))throw new t(`INVALID_ARGS`,`Package does not declare a compatible provider plugin`,{reason:`incompatible_plugin`,apiVersion:1,hint:`Install a plugin release supporting agentDevicePlugin.apiVersion 1.`});return p(e,r.entry),n}function p(e,n){try{let t=l.realpathSync(e),r=l.realpathSync(u.resolve(e,n));if(r.startsWith(`${t}${u.sep}`)&&l.statSync(r).isFile())return r}catch{}throw new t(`INVALID_ARGS`,`Plugin entry must be a readable file inside its package`,{directory:e,entry:n})}function m(e){let r=s(e);try{let e=JSON.parse(l.readFileSync(r,`utf8`));if(!n(e)||e.plugins!==void 0&&!n(e.plugins))throw new t(`INVALID_ARGS`,`Plugin config must contain an object`);return e}catch(e){if(e.code===`ENOENT`)return{};throw e instanceof SyntaxError?new t(`INVALID_ARGS`,`Invalid plugin JSON: ${r}`,{},e):e}}function h(e,r){if(!S(e)||!n(r)||typeof r.installation!=`string`||!/^[a-f0-9-]{36}$/.test(r.installation)||r.version!==void 0&&!C(r.version)||r.options!==void 0&&!n(r.options))throw new t(`INVALID_ARGS`,`Invalid plugin selection: ${e}`)}function g(e){let t=u.dirname(s(e));return Object.entries(m(e).plugins??{}).map(([e,n])=>_(t,e,n))}function _(e,n,r){h(n,r);let i=u.join(e,`plugins`,r.installation,`node_modules`,n),a=f(i);if(a.name!==n)throw new t(`INVALID_ARGS`,`Plugin package identity mismatch: ${n}`);return{...a,directory:i,selection:r}}function v(t){let n=u.dirname(s(t));return Object.entries(m(t).plugins??{}).map(([t,r])=>{try{let e=_(n,t,r);return{name:t,version:e.version,provider:e.agentDevicePlugin.provider,compatible:!0}}catch(n){return{name:t,compatible:!1,error:e(n)}}})}function y(e,n){if(e===`remove`)return{name:n,version:void 0};let r=/^(@[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._-]*|[a-z0-9][a-z0-9._-]*)(?:@(.+))?$/.exec(n);if(!r||!r[1]||r[2]!==void 0&&!C(r[2]))throw new t(`INVALID_ARGS`,`Expected an npm package name, optionally followed by @version or @tag`);if(e===`update`&&r[2]!==void 0)throw new t(`INVALID_ARGS`,`update accepts a package name without a version`);return{name:r[1],version:r[2]}}async function b(e,n,r,i){let o=c.randomUUID(),s=u.join(e,`plugins`,o);l.mkdirSync(s,{recursive:!0,mode:448});try{l.writeFileSync(u.join(s,`package.json`),JSON.stringify({private:!0,dependencies:{[n]:r??`latest`}})),await a(`npm`,[`install`,`--ignore-scripts`,`--no-audit`,`--no-fund`,`--global=false`,`--prefix`,s,`--workspaces=false`,`--package-lock=true`],{cwd:s,env:i,timeoutMs:12e4});let e=f(u.join(s,`node_modules`,n));if(e.name!==n)throw new t(`INVALID_ARGS`,`Plugin package identity mismatch: ${n}`);return{installation:o,project:s,manifest:e}}catch(e){throw l.rmSync(s,{recursive:!0,force:!0}),e}}async function x(e,a,c=process.env,f=[]){let{name:p,version:h}=y(e,a),g=s(c),v=u.dirname(g);l.mkdirSync(v,{recursive:!0,mode:448});let x=await o({lockDirPath:u.join(v,`plugins.lock`),owner:{...i(),acquiredAtMs:Date.now()},description:`plugin installation`}),S;try{let i=m(c),a={...i.plugins},o=Object.hasOwn(a,p)?a[p]:void 0;if(e!==`add`&&!Object.hasOwn(a,p))throw new t(`INVALID_ARGS`,`Plugin is not installed: ${p}`);if(e===`remove`)delete a[p];else{let t=e===`update`&&C(o?.version)?o.version:h;S=await b(v,p,t,c),d([...Object.entries(a).filter(([e])=>e!==p).flatMap(([e,t])=>{try{return[_(v,e,t)]}catch{return[]}}),S.manifest],f),a[p]={installation:S.installation,version:t,...n(o?.options)?{options:o.options}:{}}}r({destination:g,contents:`${JSON.stringify({...i,plugins:a},null,2)}\n`,mode:384})}catch(e){throw S&&l.rmSync(S.project,{recursive:!0,force:!0}),e}finally{await x()}}function S(e){return/^(@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/.test(e)}function C(e){return typeof e==`string`&&/^[a-zA-Z0-9*^~<>=| .+-]+$/.test(e)&&e.trim().length>0}export{p as a,d as i,g as n,v as r,x as t};
@@ -1 +1 @@
1
- import{N as e}from"./sdk-contracts.js";function t(t,n={message:e=>`Invalid value: ${e}`}){let r=new Set(t),i=n.normalize??(e=>e);return{is:e=>typeof e==`string`&&r.has(e),parse:t=>{let a=i(t??``);if(r.has(a))return a;throw new e(`INVALID_ARGS`,n.message(t??``))}}}export{t};
1
+ import{P as e}from"./sdk-contracts.js";function t(t,n={message:e=>`Invalid value: ${e}`}){let r=new Set(t),i=n.normalize??(e=>e);return{is:e=>typeof e==`string`&&r.has(e),parse:t=>{let a=i(t??``);if(r.has(a))return a;throw new e(`INVALID_ARGS`,n.message(t??``))}}}export{t};
@@ -1 +1 @@
1
- import{n as e}from"./snapshot-desktop-projection.js";async function t(t,n){let r=t.surface,{runMacOsSnapshotAction:i}=await import(`./helper.js`).then(e=>e.t),a=await i(r,{bundleId:r===`menubar`?t.appBundleId:void 0,signal:n});return e({...a,producer:`macos-helper`},t)}export{t};
1
+ import{n as e}from"./snapshot-desktop-projection.js";async function t(t,n){let r=t.surface,{runMacOsSnapshotAction:i}=await import(`./helper.js`).then(e=>e.n),a=await i(r,{bundleId:r===`menubar`||r===`app`?t.appBundleId:void 0,signal:n});return e({...a,producer:`macos-helper`},t)}export{t};
@@ -1,4 +1,4 @@
1
- import{N as e}from"./sdk-contracts.js";import{t}from"./shared.js";import{randomUUID as n}from"node:crypto";const r=async({positionals:t,flags:n,client:r})=>{let s=t[0]?.toLowerCase();if(s===`status`){if(t.length!==1)throw new e(`INVALID_ARGS`,`takeover status does not accept additional arguments.`);return await a(n,r),!0}if(s===`release`){if(t.length!==2||!t[1])throw new e(`INVALID_ARGS`,`takeover release requires a hold id.`);return await o(n,r,t[1]),!0}if(t.length>0)throw new e(`INVALID_ARGS`,`takeover accepts only: status or release <hold-id>.`);return await i(n,r),!0};async function i(e,r){let i=`takeover-${n()}`,a={reason:`Human is interacting with the simulator or device.`,ttlMs:15e3},o=r.leases.humanControl,c=await o.put(i,a);await t(e,{hold:c,state:`active`},()=>s(c));let l,u,d=!1,f,p=new Promise(e=>{f=e}),m=()=>f?.();process.once(`SIGINT`,m),process.once(`SIGTERM`,m);let h=setInterval(()=>{u||=o.put(i,a).then(()=>void 0).catch(e=>{l=e,f?.()}).finally(()=>{u=void 0})},5e3);try{await p}finally{clearInterval(h),process.off(`SIGINT`,m),process.off(`SIGTERM`,m),await u,d=await o.remove(i).catch(()=>!1)}if(l)throw l;e.json||process.stdout.write(d?`Human control released. Agent interactions are enabled.
1
+ import{P as e}from"./sdk-contracts.js";import{t}from"./shared.js";import{randomUUID as n}from"node:crypto";const r=async({positionals:t,flags:n,client:r})=>{let s=t[0]?.toLowerCase();if(s===`status`){if(t.length!==1)throw new e(`INVALID_ARGS`,`takeover status does not accept additional arguments.`);return await a(n,r),!0}if(s===`release`){if(t.length!==2||!t[1])throw new e(`INVALID_ARGS`,`takeover release requires a hold id.`);return await o(n,r,t[1]),!0}if(t.length>0)throw new e(`INVALID_ARGS`,`takeover accepts only: status or release <hold-id>.`);return await i(n,r),!0};async function i(e,r){let i=`takeover-${n()}`,a={reason:`Human is interacting with the simulator or device.`,ttlMs:15e3},o=r.leases.humanControl,c=await o.put(i,a);await t(e,{hold:c,state:`active`},()=>s(c));let l,u,d=!1,f,p=new Promise(e=>{f=e}),m=()=>f?.();process.once(`SIGINT`,m),process.once(`SIGTERM`,m);let h=setInterval(()=>{u||=o.put(i,a).then(()=>void 0).catch(e=>{l=e,f?.()}).finally(()=>{u=void 0})},5e3);try{await p}finally{clearInterval(h),process.off(`SIGINT`,m),process.off(`SIGTERM`,m),await u,d=await o.remove(i).catch(()=>!1)}if(l)throw l;e.json||process.stdout.write(d?`Human control released. Agent interactions are enabled.
2
2
  `:`Release could not be confirmed. The safety TTL will re-enable agent interactions automatically.
3
3
  `)}async function a(e,n){let r=await n.leases.humanControl.list();await t(e,{holds:r},()=>c(r))}async function o(e,n,r){let i=await n.leases.humanControl.remove(r);await t(e,{holdId:r,released:i},()=>i?`Released human-control hold ${r}.`:`No active hold found for ${r}.`)}function s(e){return[`Human control active for ${e.scope.deviceKey}.`,`Agent interactions are paused. Press Ctrl+C to return control.`,`Hold: ${e.id}`].join(`
4
4
  `)}function c(e){return e.length===0?`No active human-control holds.`:[`Active human-control holds:`,...e.map(e=>{let t=e.scope.deviceKey;return` ${e.id}: ${t}`})].join(`
@@ -1 +1 @@
1
- import{N as e}from"./sdk-contracts.js";import{Hn as t,Jn as n,Qn as r,Xn as i,ar as a,qn as o,rr as s}from"./sdk-batch.js";import{F as c,N as l,P as u,T as d,k as f,n as p}from"./runtime.js";import{i as m}from"./rect-center.js";import{n as h}from"./ios-system-surface.js";import{s as g}from"./tree.js";import{t as _}from"./ios-target-activation.js";function v(e){return e.matchedRefs.length===0?{path:2,outcome:`unverifiable`,reason:`selector-miss`}:e.identitySetRefs.length===0?{path:3,outcome:`unverifiable`,reason:`identity-set-empty`}:e.identitySetRefs.length===1?e.identitySetRefs[0]===e.winnerRef?{path:4,outcome:`verified`}:{path:5,outcome:`unverifiable`,reason:`unique-but-wrong`}:e.siblingMatchRefs.length===1?e.siblingMatchRefs[0]===e.winnerRef?{path:6,outcome:`verified`}:{path:6,outcome:`unverifiable`,reason:`signal-isolated-wrong`}:e.regionMemberRefs!==void 0&&e.regionMemberRefs.length>0&&e.viewportCandidateRef!==void 0?e.viewportCandidateRef===e.winnerRef?{path:6,outcome:`verified`}:{path:6,outcome:`unverifiable`,reason:`signal-isolated-wrong`}:{path:6,outcome:`unverifiable`,reason:`no-signal-isolation`}}function y(t,n={}){let r=n.plural===!0?`do`:`does`;return{resolveInput:async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} ${r} not resolve input artifacts`)},reserveOutput:async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} ${r} not reserve output artifacts`)},createTempFile:async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} ${r} not create temporary files`)}}}function b(e,t={}){return{artifacts:y(e,t),policy:d()}}function x(e,t){return e===void 0?t:(e.targetActivation??=t.targetActivation,e.postGestureOutcome??=t.postGestureOutcome,t)}function S(e,t){let n=t?.iosSystemSurfaceBundleId?h(t.iosSystemSurfaceBundleId):p(t);return n?E(e,n,`warning`):e}function C(e,t,n,r){if(!n)return e;let i=E(e,r(n),`warnings`);return i.ok?{...i,data:{...i.data,[t]:n}}:{...i,error:{...i.error,details:{...i.error.details,[t]:n}}}}function w(e,t){return C(e,`targetActivation`,t?.targetActivation,_)}function T(e){let{response:t,consumedTree:n,captureProof:r}=e;return w(C(S(t,n),`postGestureOutcome`,n?.postGestureOutcome,f),r)}function E(e,t,n){if(D(e,t))return e;if(!e.ok){let n=e.error.hint??e.error.details?.hint;return{...e,error:{...e.error,hint:O(n,t)}}}return n===`warnings`?{...e,data:{...e.data,warnings:[...k(e.data?.warnings),t]}}:{...e,data:{...e.data,warning:O(e.data?.warning,t)}}}function D(e,t){return(e.ok?[e.data?.warning,...k(e.data?.warnings)]:[e.error.hint]).some(e=>typeof e==`string`&&e.includes(t))}function O(e,t){return typeof e==`string`&&e.trim()!==``?`${e}\n${t}`:t}function k(e){return Array.isArray(e)?e.filter(e=>e!==void 0):[]}function A(e,n={}){let r=n.mode??`action`,{node:i,preActionNodes:a}=e;if(typeof i.index!=`number`)return;let o=u(a),s=t(P(i),a);if(r===`landmark`&&s.id===void 0&&s.label===void 0)return;let c=l(i,o,8),d=c.chain,f=F(a,i),p=I(i,o),m=R(i),h=+(d.length>0),g=e=>{let t=d.slice(0,e),n=z({nodes:a,byIndex:o,node:i,identity:s,ancestry:t,sibling:f,scrollRegion:p});return{candidate:{...s,ancestry:t,sibling:f,viewportOrder:n.viewportOrder,...p?{scrollRegion:p}:{},...m?{rect:m}:{},verification:`verified`},domain:n}};for(let e=d.length;e>=h;--e){let{candidate:t,domain:n}=g(e);if(M(t))return t.verification=j({node:i,domain:n,mode:r,brokenWalk:c.broken}),t;if(e===h)return N(t)}}function j(e){return e.brokenWalk?`unverifiable`:e.mode===`landmark`?`verified`:V({node:e.node,domain:e.domain})}function M(e){return a(s({...e,verification:`unverifiable`}))<=r}function N(e){return e.verification=`unverifiable`,a(s(e))>4096&&delete e.rect,e}const P=n;function F(e,t){return i(e,t)}function I(e,t){let n=g(e,t);if(!n)return;let r=P(n);return{role:r.role,...r.id===void 0?r.label===void 0?{}:{label:r.label}:{id:r.id}}}function L(e,t){return!e&&!t?!0:!e||!t?!1:o(e,t)}function R(e){let t=e.rect;if(t)return{x:t.x,y:t.y,width:t.width,height:t.height}}function z(e){let{nodes:t,byIndex:n,node:r,identity:i,ancestry:a,sibling:o,scrollRegion:s}=e,l=c(t,n,i,a),u=l.filter(e=>F(t,e)===o),d=l.length>0?l.filter(e=>L(I(e,n),s)):void 0,f=d?B(d):[];return{identitySet:l,siblingMatches:u,regionMembers:d,orderedRegion:f,viewportOrder:Math.max(f.findIndex(e=>e.index===r.index),0)}}function B(e){return e.map((e,t)=>({node:e,documentOrder:t,center:m(e.rect)})).sort((e,t)=>!e.center&&!t.center?e.documentOrder-t.documentOrder:e.center?t.center?e.center.y===t.center.y?e.center.x===t.center.x?e.documentOrder-t.documentOrder:e.center.x-t.center.x:e.center.y-t.center.y:-1:1).map(e=>e.node)}function V(e){let{node:t,domain:n}=e,r=t.ref,i=n.identitySet.map(e=>e.ref);return v({winnerRef:r,matchedRefs:i,identitySetRefs:i,siblingMatchRefs:n.siblingMatches.map(e=>e.ref),regionMemberRefs:n.regionMembers?.map(e=>e.ref),viewportCandidateRef:n.orderedRegion[n.viewportOrder]?.ref}).outcome}export{B as a,T as c,v as d,A as i,w as l,I as n,L as o,F as r,x as s,P as t,b as u};
1
+ import{P as e}from"./sdk-contracts.js";import{Hn as t,Jn as n,Qn as r,Xn as i,ar as a,qn as o,rr as s}from"./sdk-batch.js";import{F as c,N as l,P as u,T as d,k as f,n as p}from"./runtime.js";import{i as m}from"./rect-center.js";import{n as h}from"./ios-system-surface.js";import{s as g}from"./tree.js";import{t as _}from"./ios-target-activation.js";function v(e){return e.matchedRefs.length===0?{path:2,outcome:`unverifiable`,reason:`selector-miss`}:e.identitySetRefs.length===0?{path:3,outcome:`unverifiable`,reason:`identity-set-empty`}:e.identitySetRefs.length===1?e.identitySetRefs[0]===e.winnerRef?{path:4,outcome:`verified`}:{path:5,outcome:`unverifiable`,reason:`unique-but-wrong`}:e.siblingMatchRefs.length===1?e.siblingMatchRefs[0]===e.winnerRef?{path:6,outcome:`verified`}:{path:6,outcome:`unverifiable`,reason:`signal-isolated-wrong`}:e.regionMemberRefs!==void 0&&e.regionMemberRefs.length>0&&e.viewportCandidateRef!==void 0?e.viewportCandidateRef===e.winnerRef?{path:6,outcome:`verified`}:{path:6,outcome:`unverifiable`,reason:`signal-isolated-wrong`}:{path:6,outcome:`unverifiable`,reason:`no-signal-isolation`}}function y(t,n={}){let r=n.plural===!0?`do`:`does`;return{resolveInput:async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} ${r} not resolve input artifacts`)},reserveOutput:async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} ${r} not reserve output artifacts`)},createTempFile:async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} ${r} not create temporary files`)}}}function b(e,t={}){return{artifacts:y(e,t),policy:d()}}function x(e,t){return e===void 0?t:(e.targetActivation??=t.targetActivation,e.postGestureOutcome??=t.postGestureOutcome,t)}function S(e,t){let n=t?.iosSystemSurfaceBundleId?h(t.iosSystemSurfaceBundleId):p(t);return n?E(e,n,`warning`):e}function C(e,t,n,r){if(!n)return e;let i=E(e,r(n),`warnings`);return i.ok?{...i,data:{...i.data,[t]:n}}:{...i,error:{...i.error,details:{...i.error.details,[t]:n}}}}function w(e,t){return C(e,`targetActivation`,t?.targetActivation,_)}function T(e){let{response:t,consumedTree:n,captureProof:r}=e;return w(C(S(t,n),`postGestureOutcome`,n?.postGestureOutcome,f),r)}function E(e,t,n){if(D(e,t))return e;if(!e.ok){let n=e.error.hint??e.error.details?.hint;return{...e,error:{...e.error,hint:O(n,t)}}}return n===`warnings`?{...e,data:{...e.data,warnings:[...k(e.data?.warnings),t]}}:{...e,data:{...e.data,warning:O(e.data?.warning,t)}}}function D(e,t){return(e.ok?[e.data?.warning,...k(e.data?.warnings)]:[e.error.hint]).some(e=>typeof e==`string`&&e.includes(t))}function O(e,t){return typeof e==`string`&&e.trim()!==``?`${e}\n${t}`:t}function k(e){return Array.isArray(e)?e.filter(e=>e!==void 0):[]}function A(e,n={}){let r=n.mode??`action`,{node:i,preActionNodes:a}=e;if(typeof i.index!=`number`)return;let o=u(a),s=t(P(i),a);if(r===`landmark`&&s.id===void 0&&s.label===void 0)return;let c=l(i,o,8),d=c.chain,f=F(a,i),p=I(i,o),m=R(i),h=+(d.length>0),g=e=>{let t=d.slice(0,e),n=z({nodes:a,byIndex:o,node:i,identity:s,ancestry:t,sibling:f,scrollRegion:p});return{candidate:{...s,ancestry:t,sibling:f,viewportOrder:n.viewportOrder,...p?{scrollRegion:p}:{},...m?{rect:m}:{},verification:`verified`},domain:n}};for(let e=d.length;e>=h;--e){let{candidate:t,domain:n}=g(e);if(M(t))return t.verification=j({node:i,domain:n,mode:r,brokenWalk:c.broken}),t;if(e===h)return N(t)}}function j(e){return e.brokenWalk?`unverifiable`:e.mode===`landmark`?`verified`:V({node:e.node,domain:e.domain})}function M(e){return a(s({...e,verification:`unverifiable`}))<=r}function N(e){return e.verification=`unverifiable`,a(s(e))>4096&&delete e.rect,e}const P=n;function F(e,t){return i(e,t)}function I(e,t){let n=g(e,t);if(!n)return;let r=P(n);return{role:r.role,...r.id===void 0?r.label===void 0?{}:{label:r.label}:{id:r.id}}}function L(e,t){return!e&&!t?!0:!e||!t?!1:o(e,t)}function R(e){let t=e.rect;if(t)return{x:t.x,y:t.y,width:t.width,height:t.height}}function z(e){let{nodes:t,byIndex:n,node:r,identity:i,ancestry:a,sibling:o,scrollRegion:s}=e,l=c(t,n,i,a),u=l.filter(e=>F(t,e)===o),d=l.length>0?l.filter(e=>L(I(e,n),s)):void 0,f=d?B(d):[];return{identitySet:l,siblingMatches:u,regionMembers:d,orderedRegion:f,viewportOrder:Math.max(f.findIndex(e=>e.index===r.index),0)}}function B(e){return e.map((e,t)=>({node:e,documentOrder:t,center:m(e.rect)})).sort((e,t)=>!e.center&&!t.center?e.documentOrder-t.documentOrder:e.center?t.center?e.center.y===t.center.y?e.center.x===t.center.x?e.documentOrder-t.documentOrder:e.center.x-t.center.x:e.center.y-t.center.y:-1:1).map(e=>e.node)}function V(e){let{node:t,domain:n}=e,r=t.ref,i=n.identitySet.map(e=>e.ref);return v({winnerRef:r,matchedRefs:i,identitySetRefs:i,siblingMatchRefs:n.siblingMatches.map(e=>e.ref),regionMemberRefs:n.regionMembers?.map(e=>e.ref),viewportCandidateRef:n.orderedRegion[n.viewportOrder]?.ref}).outcome}export{B as a,T as c,v as d,A as i,w as l,I as n,L as o,F as r,x as s,P as t,b as u};
@@ -1 +1 @@
1
- import e from"node:path";import t from"node:fs";function n(t){let n=e.parse(t);return e.join(n.dir,`${n.name}.gesture-telemetry.json`)}function r(e){return[...e].sort((e,t)=>e.tMs-t.tMs)}function i(e){let i=n(e.videoPath),a={version:1,generatedAt:new Date().toISOString(),events:r(e.events)};return t.writeFileSync(i,JSON.stringify(a,null,2)),i}function a(e){let{recording:t}=e,n=i({videoPath:t.outPath,events:t.gestureEvents});return t.telemetryPath=n,n}export{a as n,n as t};
1
+ import e from"node:fs";import t from"node:path";function n(e){let n=t.parse(e);return t.join(n.dir,`${n.name}.gesture-telemetry.json`)}function r(e){return[...e].sort((e,t)=>e.tMs-t.tMs)}function i(t){let i=n(t.videoPath),a={version:1,generatedAt:new Date().toISOString(),events:r(t.events)};return e.writeFileSync(i,JSON.stringify(a,null,2)),i}function a(e){let{recording:t}=e,n=i({videoPath:t.outPath,events:t.gestureEvents});return t.telemetryPath=n,n}export{a as n,n as t};
@@ -1 +1 @@
1
- import{N as e}from"./sdk-contracts.js";import{Qr as t,Yr as n,qr as r}from"./sdk-batch.js";import{n as i,r as a}from"./snapshot.js";function o(t,n,r,i){return new e(`COMMAND_FAILED`,`fill tapped (${t}, ${n}) but ${r}`,{reason:`text_entry_focus_not_observed`,x:t,y:n,...i,hint:`The tap most likely missed the field. Re-check the target with snapshot -i and fill the element it reports, rather than retrying the same coordinates.`})}function s(e){let t=[];for(let r of p(e)){let e=a(r);n(e)&&t.push({node:r,identity:m(r),rect:e})}return t}function c(e){let t=new Map;for(let n of e)t.set(n.identity,(t.get(n.identity)??0)+1);return t}function l(e){let n=s(e),r=c(n),i=null,a=1/0;for(let e of n){if(!e.node.traits?.includes(`IsEditing`))continue;let n=t(e.rect);n>=a||(i=r.get(e.identity)===1?{identity:e.identity,rect:e.rect}:{rect:e.rect},a=n)}return i}function u(e,t,n){let i=s(e),a=c(i),o=new Set;for(let e of i)a.get(e.identity)===1&&r(e.rect,t,n)&&o.add(e.identity);return o}async function d(e){let t=Date.now()+(e.timeoutMs??3e3),n=0,r=!1;for(;;){let i=await e.readFocus();if(n+=1,i&&(r=!0,f(i,e.targetsAtPoint,e.x,e.y)))return`focused-element`;if(Date.now()>=t)break;await e.sleep(150)}throw o(e.x,e.y,`nothing there took text-entry focus, so the text was not sent`,{samples:n,editingElementObserved:r})}function f(e,t,n,i){return r(e.rect,n,i)?!0:e.identity!==void 0&&t.has(e.identity)}function p(e){let t=[],n=e=>{t.push(e);for(let t of i(e))n(t)};for(let t of Array.isArray(e)?e:[e])n(t);return t}function m(e){return[e.pid??``,e.type??e.elementType??``,e.AXUniqueId??e.identifier??``,e.AXLabel??e.label??``].join(`\0`)}export{d as awaitLimrunTextEntryFocus,l as readLimrunTextEntryFocus,u as readLimrunUnambiguousTapTargets};
1
+ import{P as e}from"./sdk-contracts.js";import{$r as t,Yr as n,qr as r}from"./sdk-batch.js";import{n as i,r as a}from"./snapshot.js";function o(t,n,r,i){return new e(`COMMAND_FAILED`,`fill tapped (${t}, ${n}) but ${r}`,{reason:`text_entry_focus_not_observed`,x:t,y:n,...i,hint:`The tap most likely missed the field. Re-check the target with snapshot -i and fill the element it reports, rather than retrying the same coordinates.`})}function s(e){let t=[];for(let r of p(e)){let e=a(r);n(e)&&t.push({node:r,identity:m(r),rect:e})}return t}function c(e){let t=new Map;for(let n of e)t.set(n.identity,(t.get(n.identity)??0)+1);return t}function l(e){let n=s(e),r=c(n),i=null,a=1/0;for(let e of n){if(!e.node.traits?.includes(`IsEditing`))continue;let n=t(e.rect);n>=a||(i=r.get(e.identity)===1?{identity:e.identity,rect:e.rect}:{rect:e.rect},a=n)}return i}function u(e,t,n){let i=s(e),a=c(i),o=new Set;for(let e of i)a.get(e.identity)===1&&r(e.rect,t,n)&&o.add(e.identity);return o}async function d(e){let t=Date.now()+(e.timeoutMs??3e3),n=0,r=!1;for(;;){let i=await e.readFocus();if(n+=1,i&&(r=!0,f(i,e.targetsAtPoint,e.x,e.y)))return`focused-element`;if(Date.now()>=t)break;await e.sleep(150)}throw o(e.x,e.y,`nothing there took text-entry focus, so the text was not sent`,{samples:n,editingElementObserved:r})}function f(e,t,n,i){return r(e.rect,n,i)?!0:e.identity!==void 0&&t.has(e.identity)}function p(e){let t=[],n=e=>{t.push(e);for(let t of i(e))n(t)};for(let t of Array.isArray(e)?e:[e])n(t);return t}function m(e){return[e.pid??``,e.type??e.elementType??``,e.AXUniqueId??e.identifier??``,e.AXLabel??e.label??``].join(`\0`)}export{d as awaitLimrunTextEntryFocus,l as readLimrunTextEntryFocus,u as readLimrunUnambiguousTapTargets};
@@ -1,4 +1,4 @@
1
- import{N as e}from"./sdk-contracts.js";import{g as t,l as n,o as r,t as i}from"./exec.js";import"./command.js";import{t as a}from"./scoped-provider.js";import{f as o,u as s}from"./host-file.js";import c from"node:path";function l(e,t){return t===`user-installed`?e.filter(e=>!e.bundleId.startsWith(`com.apple.`)):e}function u(t,n){return{openBundle:async(e,n)=>{await t(`open`,d(e,n))},openTarget:async e=>{await t(`open`,[e])},readClipboard:async()=>r(await t(`pbpaste`,[],{allowFailure:!0}),`Failed to read macOS clipboard`).stdout.replaceAll(`\r
1
+ import{P as e}from"./sdk-contracts.js";import{g as t,l as n,o as r,t as i}from"./exec.js";import"./command.js";import{t as a}from"./scoped-provider.js";import{f as o,u as s}from"./host-file.js";import c from"node:path";function l(e,t){return t===`user-installed`?e.filter(e=>!e.bundleId.startsWith(`com.apple.`)):e}function u(t,n){return{openBundle:async(e,n)=>{await t(`open`,d(e,n))},openTarget:async e=>{await t(`open`,[e])},readClipboard:async()=>r(await t(`pbpaste`,[],{allowFailure:!0}),`Failed to read macOS clipboard`).stdout.replaceAll(`\r
2
2
  `,`
3
3
  `).replace(/\n$/,``),writeClipboard:async e=>{r(await t(`pbcopy`,[],{allowFailure:!0,stdin:e}),`Failed to write macOS clipboard`)},readDarkMode:async()=>{let n=r(await t(`osascript`,[`-e`,`tell application "System Events" to tell appearance preferences to get dark mode`],{allowFailure:!0}),`Failed to read macOS appearance`),i=n.stdout.trim().toLowerCase();if(i===`true`)return!0;if(i===`false`)return!1;throw new e(`COMMAND_FAILED`,`Unable to determine current macOS appearance from osascript output: ${n.stdout.trim()}`)},setDarkMode:async e=>{r(await t(`osascript`,[`-e`,`tell application "System Events" to tell appearance preferences to set dark mode to ${e?`true`:`false`}`],{allowFailure:!0}),`Failed to set macOS appearance`)},listApps:async e=>await f(t,n,e)}}function d(e,t){let n=[`-b`,e];return t&&n.push(t),n}async function f(e,t,n){let r=[`/Applications`,`/System/Applications`,c.join(o(),`Applications`)],i=new Set;for(let t of r){if(!(await s(t).catch(()=>null))?.isDirectory())continue;let n=await e(`find`,[t,`-maxdepth`,`4`,`-type`,`d`,`-name`,`*.app`],{allowFailure:!0});if(n.exitCode===0)for(let e of n.stdout.split(`
4
4
  `)){let t=e.trim();t&&i.add(t)}}return l((await Promise.all(Array.from(i).map(async e=>{let n=await p(e,t).catch(()=>({})),r=n.bundleId;return r?{bundleId:r,name:n.appName??c.basename(e,`.app`)}:null}))).filter(e=>e!==null).sort((e,t)=>e.name.localeCompare(t.name)),n)}async function p(e,t){for(let n of[c.join(e,`Contents`,`Info.plist`),c.join(e,`Info.plist`)]){let e=await t(n),r=m(e,`CFBundleIdentifier`),i=m(e,`CFBundleDisplayName`),a=m(e,`CFBundleName`);if(r||i||a)return{bundleId:r,appName:i??a}}return{}}function m(e,t){let n=e?.[t];return typeof n==`string`&&n.trim()?n.trim():void 0}function h(e){return Object.freeze([`simctl`,...e])}async function g(e,t,n){return await e(`xcrun`,[...h(t)],n)}function _(e){return Object.freeze(e.slice(1))}const v={runCommand:n,simctl:{run:async(e,t)=>await g(n,e,t)},devicectl:{run:async(e,t)=>await n(`xcrun`,[`devicectl`,...e],t)},plist:{readJson:async(e,t)=>await A(n,e,t)},macosHost:u(n,async e=>await A(n,e)),whichCommand:t},y=a(v,D);function b(e={}){let t={...v,...e},n=e.plist??{readJson:async(e,n)=>await A(t.runCommand,e,n)};return{...t,simctl:e.simctl??{run:async(e,n)=>await g(t.runCommand,e,n)},devicectl:e.devicectl??{run:async(e,n)=>await t.runCommand(`xcrun`,[`devicectl`,...e],n)},plist:n,macosHost:e.macosHost??u(t.runCommand,async e=>await n.readJson(e))}}function x(e){return y.resolve(e)}async function S(e,t){return await y.run(e,t)}function C(){return y.hasScope()}async function w(e,t,n){return await x().runCommand(e,t,n)}async function T(e,t){let n=x();if(e[0]===`simctl`)return await n.simctl.run(_(e),t);let[r,...i]=e;return r===`devicectl`?await n.devicectl.run(i,t):await w(`xcrun`,[...e],t)}async function E(e,t){return await x().plist?.readJson(e,t)??null}function D(e){return b({...e,runCommand:O(e.runCommand),simctl:{run:k(e.simctl.run)},devicectl:{run:k(e.devicectl.run)},...e.macosHelper?{macosHelper:{run:k(e.macosHelper.run)}}:{}})}function O(e){return async(t,n,r)=>i(await e(t,n,r))}function k(e){return async(t,n)=>i(await e(t,n))}async function A(e,t,n){try{let r=await e(`plutil`,[`-convert`,`json`,`-o`,`-`,t],{allowFailure:!0,signal:n});return r.exitCode!==0||!r.stdout.trim()?null:JSON.parse(r.stdout)}catch{return n?.throwIfAborted(),null}}export{w as a,S as c,x as i,l,C as n,T as o,E as r,h as s,b as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime.js";import{N as t}from"./sdk-contracts.js";import{r as n}from"./diagnostics.js";import{c as r}from"./owner-identity.js";import{g as i,l as a}from"./exec.js";import{t as o}from"./timeouts.js";import"./diagnostics2.js";import"./command.js";import"./process.js";import"./retry.js";import{t as s}from"./scoped-provider.js";var c=e({createLocalLinuxToolProvider:()=>d,resolveLinuxToolProvider:()=>f,runLinuxToolCommand:()=>m,withLinuxToolProvider:()=>p});const l={runCommand:a,whichCommand:i,desktop:h(a,i),clipboard:g(a,i),screenshot:_(a,i)},u=s(l,d);function d(e={}){let t={...l,...e};return{...t,desktop:e.desktop??h(t.runCommand,t.whichCommand),clipboard:e.clipboard??g(t.runCommand,t.whichCommand),screenshot:e.screenshot??_(t.runCommand,t.whichCommand)}}function f(e){return u.resolve(e)}async function p(e,t){return await u.run(e,t)}async function m(e,t,n){return await f().runCommand(e,t,n)}function h(e,t){return{async openTarget(r){if(r.includes(`://`)||r.startsWith(`/`)){await e(`xdg-open`,[r]);return}if(await t(r)){e(r,[],{allowFailure:!0}).catch(e=>{n({level:`warn`,phase:`linux_app_launch`,data:{app:r,error:String(e)}})}),await o(500);return}await e(`xdg-open`,[r],{allowFailure:!0})},async closeApp(n){if(await t(`wmctrl`)){await e(`wmctrl`,[`-c`,n],{allowFailure:!0});return}await e(`pkill`,[`-x`,n],{allowFailure:!0})}}}function g(e,t){return{async readText(){let n=await w(t,y),r=x[n];return(await e(r.cmd,r.args,r.options)).stdout},async writeText(n){let r=await w(t,y),i=S[r](n);await e(i.cmd,i.args,i.options)}}}function _(e,t){return{async capture(n){let r=await w(t,b),i=C[r](n);await e(i.cmd,i.args,i.options)}}}const v=5e3,y={wayland:[{tool:`wl-clipboard`,command:`wl-paste`}],x11:[{tool:`xclip`,command:`xclip`},{tool:`xsel`,command:`xsel`}],waylandError:`wl-paste (wl-clipboard) is required for clipboard access on Wayland. Install via your package manager.`,x11Error:`xclip or xsel is required for clipboard access on X11. Install via your package manager.`},b={wayland:[{tool:`grim`,command:`grim`},{tool:`gnome-screenshot`,command:`gnome-screenshot`}],x11:[{tool:`scrot`,command:`scrot`},{tool:`import`,command:`import`},{tool:`gnome-screenshot`,command:`gnome-screenshot`}],waylandError:`grim or gnome-screenshot is required for screenshots on Wayland. Install via your package manager.`,x11Error:`scrot, import (ImageMagick), or gnome-screenshot is required for screenshots on X11. Install via your package manager.`},x={"wl-clipboard":{cmd:`wl-paste`,args:[`--no-newline`],options:{allowFailure:!0,timeoutMs:v}},xclip:{cmd:`xclip`,args:[`-selection`,`clipboard`,`-o`],options:{allowFailure:!0,timeoutMs:v}},xsel:{cmd:`xsel`,args:[`--clipboard`,`--output`],options:{allowFailure:!0,timeoutMs:v}}},S={"wl-clipboard":e=>({cmd:`wl-copy`,args:[`--`,e],options:{allowFailure:!1,timeoutMs:v}}),xclip:e=>({cmd:`xclip`,args:[`-selection`,`clipboard`],options:{allowFailure:!1,timeoutMs:v,stdin:e}}),xsel:e=>({cmd:`xsel`,args:[`--clipboard`,`--input`],options:{allowFailure:!1,timeoutMs:v,stdin:e}})},C={grim:e=>({cmd:`grim`,args:[e]}),scrot:e=>({cmd:`scrot`,args:[e]}),import:e=>({cmd:`import`,args:[`-window`,`root`,e]}),"gnome-screenshot":e=>({cmd:`gnome-screenshot`,args:[`-f`,e]})};async function w(e,n){let r=T()?`wayland`:`x11`;for(let t of n[r])if(await e(t.command))return t.tool;throw new t(`TOOL_MISSING`,r===`wayland`?n.waylandError:n.x11Error)}function T(){let e=r();return!!e.WAYLAND_DISPLAY||e.XDG_SESSION_TYPE===`wayland`}export{m as n,c as r,f as t};
1
+ import{r as e}from"./rolldown-runtime.js";import{P as t}from"./sdk-contracts.js";import{r as n}from"./diagnostics.js";import"./diagnostics2.js";import{l as r}from"./owner-identity.js";import{g as i,l as a}from"./exec.js";import{t as o}from"./timeouts.js";import"./command.js";import"./process.js";import"./retry.js";import{t as s}from"./scoped-provider.js";var c=e({createLocalLinuxToolProvider:()=>d,resolveLinuxToolProvider:()=>f,runLinuxToolCommand:()=>m,withLinuxToolProvider:()=>p});const l={runCommand:a,whichCommand:i,desktop:h(a,i),clipboard:g(a,i),screenshot:_(a,i)},u=s(l,d);function d(e={}){let t={...l,...e};return{...t,desktop:e.desktop??h(t.runCommand,t.whichCommand),clipboard:e.clipboard??g(t.runCommand,t.whichCommand),screenshot:e.screenshot??_(t.runCommand,t.whichCommand)}}function f(e){return u.resolve(e)}async function p(e,t){return await u.run(e,t)}async function m(e,t,n){return await f().runCommand(e,t,n)}function h(e,t){return{async openTarget(r){if(r.includes(`://`)||r.startsWith(`/`)){await e(`xdg-open`,[r]);return}if(await t(r)){e(r,[],{allowFailure:!0}).catch(e=>{n({level:`warn`,phase:`linux_app_launch`,data:{app:r,error:String(e)}})}),await o(500);return}await e(`xdg-open`,[r],{allowFailure:!0})},async closeApp(n){if(await t(`wmctrl`)){await e(`wmctrl`,[`-c`,n],{allowFailure:!0});return}await e(`pkill`,[`-x`,n],{allowFailure:!0})}}}function g(e,t){return{async readText(){let n=await w(t,y),r=x[n];return(await e(r.cmd,r.args,r.options)).stdout},async writeText(n){let r=await w(t,y),i=S[r](n);await e(i.cmd,i.args,i.options)}}}function _(e,t){return{async capture(n){let r=await w(t,b),i=C[r](n);await e(i.cmd,i.args,i.options)}}}const v=5e3,y={wayland:[{tool:`wl-clipboard`,command:`wl-paste`}],x11:[{tool:`xclip`,command:`xclip`},{tool:`xsel`,command:`xsel`}],waylandError:`wl-paste (wl-clipboard) is required for clipboard access on Wayland. Install via your package manager.`,x11Error:`xclip or xsel is required for clipboard access on X11. Install via your package manager.`},b={wayland:[{tool:`grim`,command:`grim`},{tool:`gnome-screenshot`,command:`gnome-screenshot`}],x11:[{tool:`scrot`,command:`scrot`},{tool:`import`,command:`import`},{tool:`gnome-screenshot`,command:`gnome-screenshot`}],waylandError:`grim or gnome-screenshot is required for screenshots on Wayland. Install via your package manager.`,x11Error:`scrot, import (ImageMagick), or gnome-screenshot is required for screenshots on X11. Install via your package manager.`},x={"wl-clipboard":{cmd:`wl-paste`,args:[`--no-newline`],options:{allowFailure:!0,timeoutMs:v}},xclip:{cmd:`xclip`,args:[`-selection`,`clipboard`,`-o`],options:{allowFailure:!0,timeoutMs:v}},xsel:{cmd:`xsel`,args:[`--clipboard`,`--output`],options:{allowFailure:!0,timeoutMs:v}}},S={"wl-clipboard":e=>({cmd:`wl-copy`,args:[`--`,e],options:{allowFailure:!1,timeoutMs:v}}),xclip:e=>({cmd:`xclip`,args:[`-selection`,`clipboard`],options:{allowFailure:!1,timeoutMs:v,stdin:e}}),xsel:e=>({cmd:`xsel`,args:[`--clipboard`,`--input`],options:{allowFailure:!1,timeoutMs:v,stdin:e}})},C={grim:e=>({cmd:`grim`,args:[e]}),scrot:e=>({cmd:`scrot`,args:[e]}),import:e=>({cmd:`import`,args:[`-window`,`root`,e]}),"gnome-screenshot":e=>({cmd:`gnome-screenshot`,args:[`-f`,e]})};async function w(e,n){let r=T()?`wayland`:`x11`;for(let t of n[r])if(await e(t.command))return t.tool;throw new t(`TOOL_MISSING`,r===`wayland`?n.waylandError:n.x11Error)}function T(){let e=r();return!!e.WAYLAND_DISPLAY||e.XDG_SESSION_TYPE===`wayland`}export{m as n,c as r,f as t};
@@ -1,2 +1,2 @@
1
- import{l as e}from"./exec.js";import"./command.js";const t=3e3;async function n(n,i){try{let a=await e(n,i,{allowFailure:!0,timeoutMs:t});return a.exitCode===0?r(a.stdout):void 0}catch{return}}function r(e){return e.split(`
2
- `).map(e=>e.trim()).find(Boolean)}export{n,r,t};
1
+ import{l as e}from"./exec.js";import"./command.js";const t=3e3;async function n(e,t){let n=await r(e,t);return n===void 0?void 0:i(n)}async function r(n,r){try{let i=await e(n,r,{allowFailure:!0,timeoutMs:t});return i.exitCode===0?i.stdout:void 0}catch{return}}function i(e){return e.split(`
2
+ `).map(e=>e.trim()).find(Boolean)}export{i,n,r,t};
@@ -1 +1 @@
1
- import{N as e,z as t}from"./sdk-contracts.js";import{n,r}from"./interactor-operation-binding.js";function i(e){let t=t=>t??e.unsupported;return Object.freeze({tapPoint:e.tap,tapRef:t(e.tapRef),longPressPoint:e.longPress,hoverPoint:a(t(e.hover)),hoverRef:a(t(e.hoverRef)),fillPoint:e.fill,fillRef:t(e.fillRef),tapElementSelector:t(e.tapElementSelector)})}function a(e){return e.available?e:Object.freeze({...e,hint:e.hint??`hover raises pointer hover state and is available on web targets only. On touch platforms use longpress for hold gestures.`})}function o(e,t){return{...e.execution,appBundleId:e.appBundleId,signal:t}}function s(t,n,r,i){let a=async e=>(t.throwIfAborted(),await n(o(e,t))),s=async e=>{t.throwIfAborted(),l(e.options,r.longPressPoint);let n=await a(e);return e.options.button!==`primary`&&n.alternateClick?await n.alternateClick(e.point,e.options.button):n.pressPoint?await n.pressPoint(e.point,e.options):await d(n,e.point,e.options,i)},u=async t=>{let n=await a(t);if(!n.hover)throw new e(`UNSUPPORTED_OPERATION`,`Bound runtime advertised hover without an interactor.`);return await n.hover(t.point.x,t.point.y)},f=async e=>await(await a(e)).fill(e.point.x,e.point.y,e.text,e.delayMs,{allowNonHittableCoordinateFallback:e.allowNonHittableCoordinateFallback});return Object.freeze({...r.tapPoint.available?{tapPoint:s}:{},...r.tapRef.available?{tapRef:async e=>{let t=await a(e);return t.tapRef?await t.tapRef(e.ref):c(`tapRef`)}}:{},...r.longPressPoint.available?{longPressPoint:async e=>await(await a(e)).longPress(e.point.x,e.point.y,e.durationMs)}:{},...r.hoverPoint.available?{hoverPoint:u}:{},...r.hoverRef.available?{hoverRef:async e=>{let t=await a(e);return t.hoverRef?await t.hoverRef(e.ref):c(`hoverRef`)}}:{},...r.fillPoint.available?{fillPoint:f}:{},...r.fillRef.available?{fillRef:async e=>{let t=await a(e);return t.fillRef?await t.fillRef(e.ref,e.text,e.delayMs):c(`fillRef`)}}:{},...r.tapElementSelector.available?{tapElementSelector:async e=>{let t=await a(e);return t.tapElementSelector?await t.tapElementSelector(e.selector):c(`tapElementSelector`)}}:{}})}function c(t){throw new e(`UNSUPPORTED_OPERATION`,`Bound runtime advertised ${t} without an interactor.`)}function l(t,n){if(!(t.holdMs<=0||n.available))throw new e(`UNSUPPORTED_OPERATION`,`press-and-hold is not supported by this runtime.`,{reason:n.reason,...n.hint===void 0?{}:{hint:n.hint}})}function u(t){if(t.doubleTap)return t.doubleTap;throw new e(`UNSUPPORTED_OPERATION`,`double-tap is not supported by this runtime.`,{reason:`owner-capability-missing`,hint:`This runtime drives single presses; use --count to repeat them.`})}async function d(n,r,i,a){if(i.button!==`primary`)throw new e(`UNSUPPORTED_OPERATION`,`Bound runtime does not implement ${i.button} click.`);let o=i.doubleTap?u(n):void 0,s,c=0;try{for(let e=0;e<i.count;e+=1){let[t,l]=m(e,i.jitterPx),u=await f(n,o,r.x+t,r.y+l,i);c+=1,s??=u,e<i.count-1&&i.intervalMs>0&&await a(i.intervalMs)}}catch(e){throw t(e,c)}return s}async function f(e,t,n,r,i){return t?await t.call(e,n,r):i.holdMs>0?await e.longPress(n,r,i.holdMs):await e.tap(n,r)}const p=[[0,0],[1,0],[0,1],[-1,0],[0,-1],[1,1],[-1,1],[1,-1],[-1,-1]];function m(e,t){if(t<=0)return[0,0];let[n,r]=p[e%p.length];return[n*t,r*t]}function h(e){return s(e.signal,n(e),e.facts,e.pause)}function g(e){return s(e.signal,r({...e,operation:`touch`}),e.facts,e.pause)}export{i,g as n,m as r,h as t};
1
+ import{B as e,P as t}from"./sdk-contracts.js";import{n,r}from"./interactor-operation-binding.js";function i(e){let t=t=>t??e.unsupported;return Object.freeze({tapPoint:e.tap,tapRef:t(e.tapRef),longPressPoint:e.longPress,hoverPoint:a(t(e.hover)),hoverRef:a(t(e.hoverRef)),fillPoint:e.fill,fillRef:t(e.fillRef),tapElementSelector:t(e.tapElementSelector)})}function a(e){return e.available?e:Object.freeze({...e,hint:e.hint??`hover raises pointer hover state and is available on web targets only. On touch platforms use longpress for hold gestures.`})}function o(e,t){return{...e.execution,appBundleId:e.appBundleId,signal:t}}function s(e,n,r,i){let a=async t=>(e.throwIfAborted(),await n(o(t,e))),s=async t=>{e.throwIfAborted(),l(t.options,r.longPressPoint);let n=await a(t);return t.options.button!==`primary`&&n.alternateClick?await n.alternateClick(t.point,t.options.button):n.pressPoint?await n.pressPoint(t.point,t.options):await d(n,t.point,t.options,i)},u=async e=>{let n=await a(e);if(!n.hover)throw new t(`UNSUPPORTED_OPERATION`,`Bound runtime advertised hover without an interactor.`);return await n.hover(e.point.x,e.point.y)},f=async e=>await(await a(e)).fill(e.point.x,e.point.y,e.text,e.delayMs,{allowNonHittableCoordinateFallback:e.allowNonHittableCoordinateFallback});return Object.freeze({...r.tapPoint.available?{tapPoint:s}:{},...r.tapRef.available?{tapRef:async e=>{let t=await a(e);return t.tapRef?await t.tapRef(e.ref):c(`tapRef`)}}:{},...r.longPressPoint.available?{longPressPoint:async e=>await(await a(e)).longPress(e.point.x,e.point.y,e.durationMs)}:{},...r.hoverPoint.available?{hoverPoint:u}:{},...r.hoverRef.available?{hoverRef:async e=>{let t=await a(e);return t.hoverRef?await t.hoverRef(e.ref):c(`hoverRef`)}}:{},...r.fillPoint.available?{fillPoint:f}:{},...r.fillRef.available?{fillRef:async e=>{let t=await a(e);return t.fillRef?await t.fillRef(e.ref,e.text,e.delayMs):c(`fillRef`)}}:{},...r.tapElementSelector.available?{tapElementSelector:async e=>{let t=await a(e);return t.tapElementSelector?await t.tapElementSelector(e.selector):c(`tapElementSelector`)}}:{}})}function c(e){throw new t(`UNSUPPORTED_OPERATION`,`Bound runtime advertised ${e} without an interactor.`)}function l(e,n){if(!(e.holdMs<=0||n.available))throw new t(`UNSUPPORTED_OPERATION`,`press-and-hold is not supported by this runtime.`,{reason:n.reason,...n.hint===void 0?{}:{hint:n.hint}})}function u(e){if(e.doubleTap)return e.doubleTap;throw new t(`UNSUPPORTED_OPERATION`,`double-tap is not supported by this runtime.`,{reason:`owner-capability-missing`,hint:`This runtime drives single presses; use --count to repeat them.`})}async function d(n,r,i,a){if(i.button!==`primary`)throw new t(`UNSUPPORTED_OPERATION`,`Bound runtime does not implement ${i.button} click.`);let o=i.doubleTap?u(n):void 0,s,c=0;try{for(let e=0;e<i.count;e+=1){let[t,l]=m(e,i.jitterPx),u=await f(n,o,r.x+t,r.y+l,i);c+=1,s??=u,e<i.count-1&&i.intervalMs>0&&await a(i.intervalMs)}}catch(t){throw e(t,c)}return s}async function f(e,t,n,r,i){return t?await t.call(e,n,r):i.holdMs>0?await e.longPress(n,r,i.holdMs):await e.tap(n,r)}const p=[[0,0],[1,0],[0,1],[-1,0],[0,-1],[1,1],[-1,1],[1,-1],[-1,-1]];function m(e,t){if(t<=0)return[0,0];let[n,r]=p[e%p.length];return[n*t,r*t]}function h(e){return s(e.signal,n(e),e.facts,e.pause)}function g(e){return s(e.signal,r({...e,operation:`touch`}),e.facts,e.pause)}export{i,g as n,m as r,h as t};
@@ -1 +1 @@
1
- import{N as e}from"./sdk-contracts.js";import{Et as t,Gt as n,St as r,Vt as i,dt as a,ft as o,gt as s,lt as c,ut as l}from"./sdk-batch.js";import{O as u}from"./runtime.js";import{r as d}from"./success-text.js";import{i as f}from"./click-button.js";import{f as p}from"./session-snapshot.js";import{t as m}from"./runtime-admission.js";import{t as h}from"./interactor-types.js";function g(e){let t=e?e.textEntryReadiness:void 0,n=x(t)?{textEntryReadiness:t}:{},r=_(e);return r?{...n,...r}:n}function _(e){if(!v(e))return null;let t=y(e.target);return t?{verification:`unconfirmed`,requested:e.requested,before:e.before,after:e.after,target:t}:null}function v(e){return!!(e&&e.verification===`unconfirmed`&&typeof e.requested==`string`&&S(e.before)&&S(e.after))}function y(e){if(!w(e)||!b(e))return null;let t=C(e.rect);return t?{resourceId:e.resourceId,className:e.className,packageName:e.packageName,rect:t}:null}function b(e){return S(e.resourceId)&&S(e.className)&&S(e.packageName)}function x(e){return typeof e==`string`&&h.includes(e)}function S(e){return e===null||typeof e==`string`}function C(e){return!w(e)||![e.x,e.y,e.width,e.height].every(e=>typeof e==`number`)?null:e}function w(e){return!!e&&typeof e==`object`}async function T(e){let u={device:e.device,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice},d=i(e.command,e.requiresCapture),f=await m({command:e.command,required:d.use.required,...e.unavailableResponse?{unavailableResponse:e.unavailableResponse}:{},...u});if(f.type===`response`)return{ok:!1,response:f.response};let p=f.bind;switch(d.kind){case`tap-point`:return{ok:!0,runtime:{kind:`tap`,captured:!1,runtime:await p(e.device,n)}};case`captured-tap`:return{ok:!0,runtime:{kind:`tap`,captured:!0,runtime:await p(e.device,o)}};case`long-press-point`:return{ok:!0,runtime:{kind:`long-press`,captured:!1,runtime:await p(e.device,t)}};case`captured-long-press`:return{ok:!0,runtime:{kind:`long-press`,captured:!0,runtime:await p(e.device,a)}};case`hover-point`:return{ok:!0,runtime:{kind:`hover`,captured:!1,runtime:await p(e.device,r)}};case`captured-hover`:return{ok:!0,runtime:{kind:`hover`,captured:!0,runtime:await p(e.device,l)}};case`fill-point`:return{ok:!0,runtime:{kind:`fill`,captured:!1,runtime:await p(e.device,s)}};case`captured-fill`:return{ok:!0,runtime:{kind:`fill`,captured:!0,runtime:await p(e.device,c)}}}}function E(e,t){let n={execution:p(t),appBundleId:t.appBundleId},r=e.captured?M(e.runtime):void 0;switch(e.kind){case`tap`:return D(e,t,n,r);case`long-press`:return O(e,n,r);case`hover`:return k(e,n,r);case`fill`:return A(e,t,n,r)}}function D(e,t,n,r){let i=e.captured?e.runtime.operations.tapRef:void 0,a=e.captured?e.runtime.operations.tapElementSelector:void 0;return Object.freeze({captureSnapshot:r,tapPoint:async(r,i={})=>{let a=N(i,t),o=await e.runtime.operations.tapPoint({point:r,options:a,...n});return{x:r.x,y:r.y,count:a.count,intervalMs:a.intervalMs,holdMs:a.holdMs,jitterPx:a.jitterPx,doubleTap:a.doubleTap,...a.button===`primary`?{}:{button:a.button},...o??{},...d(L(r,a.button))}},tapRef:i?async e=>await i({ref:e,...n}):void 0,tapElementSelector:e.captured&&a?async t=>{let r=await e.runtime.operations.tapElementSelector?.({selector:t,...n}),i=r?.maestroNonHittableCoordinateFallbackUsed===!0;return{selector:t.raw,...r??{},...d(i?`tapped via non-hittable coordinate fallback`:`Tapped ${t.raw}`)}}:void 0})}function O(e,t,n){return Object.freeze({captureSnapshot:n,longPressPoint:async(n,r)=>{let i=await e.runtime.operations.longPressPoint({point:n,durationMs:r,...t});return{x:n.x,y:n.y,durationMs:r,...i??{},...d(`Long pressed (${n.x}, ${n.y})`)}}})}function k(e,t,n){let r=e.captured?e.runtime.operations.hoverRef:void 0;return Object.freeze({captureSnapshot:n,hoverPoint:async n=>{let r=await e.runtime.operations.hoverPoint({point:n,...t});return{x:n.x,y:n.y,...r??{},...d(`Hovered (${n.x}, ${n.y})`)}},hoverRef:r?async e=>await r({ref:e,...t}):void 0})}function A(e,t,n,r){let i=e.captured?e.runtime.operations.fillRef:void 0,a=e=>u(e??t.delayMs??0,`delay-ms`,0,1e4);return Object.freeze({captureSnapshot:r,fillPoint:async(t,r,i={})=>{let o=a(i.delayMs),s=await e.runtime.operations.fillPoint({point:t,text:r,delayMs:o,allowNonHittableCoordinateFallback:i.allowNonHittableCoordinateFallback===!0,...n});return{x:t.x,y:t.y,text:r,delayMs:o,...j(s)?{maestroNonHittableCoordinateFallbackUsed:!0}:{},...g(s),...d(`Filled ${Array.from(r).length} chars`)}},fillRef:i?async(e,t,r={})=>await i({ref:e,text:t,delayMs:a(r.delayMs),...n}):void 0})}function j(e){return typeof e==`object`&&!!e&&`maestroNonHittableCoordinateFallbackUsed`in e&&e.maestroNonHittableCoordinateFallbackUsed===!0}function M(e){return async t=>await e.operations.captureSnapshot(t)}function N(e,t){let n=P(e,t);return I(n),{button:e.button??f(t),...n,surface:e.surface??t.surface}}function P(e,t){return{count:F(e.count,t.count,1,`count`,1,200),intervalMs:F(e.intervalMs,t.intervalMs,0,`interval-ms`,0,1e4),holdMs:F(e.holdMs,t.holdMs,0,`hold-ms`,0,1e4),jitterPx:F(e.jitterPx,t.jitterPx,0,`jitter-px`,0,100),doubleTap:e.doubleTap??t.doubleTap??!1}}function F(e,t,n,r,i,a){return u(e??t??n,r,i,a)}function I(t){if(t.doubleTap&&t.holdMs>0)throw new e(`INVALID_ARGS`,`double-tap cannot be combined with hold-ms`);if(t.doubleTap&&t.jitterPx>0)throw new e(`INVALID_ARGS`,`double-tap cannot be combined with jitter-px`)}function L(e,t){return t===`primary`?`Pressed (${e.x}, ${e.y})`:`${t===`secondary`?`Right`:`Middle`} clicked (${e.x}, ${e.y})`}export{T as n,E as t};
1
+ import{P as e}from"./sdk-contracts.js";import{Et as t,Gt as n,St as r,Vt as i,dt as a,ft as o,gt as s,lt as c,ut as l}from"./sdk-batch.js";import{O as u}from"./runtime.js";import{r as d}from"./success-text.js";import{i as f}from"./click-button.js";import{m as p}from"./session-snapshot.js";import{t as m}from"./runtime-admission.js";import{t as h}from"./interactor-types.js";function g(e){let t=e?e.textEntryReadiness:void 0,n=x(t)?{textEntryReadiness:t}:{},r=_(e);return r?{...n,...r}:n}function _(e){if(!v(e))return null;let t=y(e.target);return t?{verification:`unconfirmed`,requested:e.requested,before:e.before,after:e.after,target:t}:null}function v(e){return!!(e&&e.verification===`unconfirmed`&&typeof e.requested==`string`&&S(e.before)&&S(e.after))}function y(e){if(!w(e)||!b(e))return null;let t=C(e.rect);return t?{resourceId:e.resourceId,className:e.className,packageName:e.packageName,rect:t}:null}function b(e){return S(e.resourceId)&&S(e.className)&&S(e.packageName)}function x(e){return typeof e==`string`&&h.includes(e)}function S(e){return e===null||typeof e==`string`}function C(e){return!w(e)||![e.x,e.y,e.width,e.height].every(e=>typeof e==`number`)?null:e}function w(e){return!!e&&typeof e==`object`}async function T(e){let u={device:e.device,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice},d=i(e.command,e.requiresCapture),f=await m({command:e.command,required:d.use.required,...e.unavailableResponse?{unavailableResponse:e.unavailableResponse}:{},...u});if(f.type===`response`)return{ok:!1,response:f.response};let p=f.bind;switch(d.kind){case`tap-point`:return{ok:!0,runtime:{kind:`tap`,captured:!1,runtime:await p(e.device,n)}};case`captured-tap`:return{ok:!0,runtime:{kind:`tap`,captured:!0,runtime:await p(e.device,o)}};case`long-press-point`:return{ok:!0,runtime:{kind:`long-press`,captured:!1,runtime:await p(e.device,t)}};case`captured-long-press`:return{ok:!0,runtime:{kind:`long-press`,captured:!0,runtime:await p(e.device,a)}};case`hover-point`:return{ok:!0,runtime:{kind:`hover`,captured:!1,runtime:await p(e.device,r)}};case`captured-hover`:return{ok:!0,runtime:{kind:`hover`,captured:!0,runtime:await p(e.device,l)}};case`fill-point`:return{ok:!0,runtime:{kind:`fill`,captured:!1,runtime:await p(e.device,s)}};case`captured-fill`:return{ok:!0,runtime:{kind:`fill`,captured:!0,runtime:await p(e.device,c)}}}}function E(e,t){let n={execution:p(t),appBundleId:t.appBundleId},r=e.captured?M(e.runtime):void 0;switch(e.kind){case`tap`:return D(e,t,n,r);case`long-press`:return O(e,n,r);case`hover`:return k(e,n,r);case`fill`:return A(e,t,n,r)}}function D(e,t,n,r){let i=e.captured?e.runtime.operations.tapRef:void 0,a=e.captured?e.runtime.operations.tapElementSelector:void 0;return Object.freeze({captureSnapshot:r,tapPoint:async(r,i={})=>{let a=N(i,t),o=await e.runtime.operations.tapPoint({point:r,options:a,...n});return{x:r.x,y:r.y,count:a.count,intervalMs:a.intervalMs,holdMs:a.holdMs,jitterPx:a.jitterPx,doubleTap:a.doubleTap,...a.button===`primary`?{}:{button:a.button},...o??{},...d(L(r,a.button))}},tapRef:i?async e=>await i({ref:e,...n}):void 0,tapElementSelector:e.captured&&a?async t=>{let r=await e.runtime.operations.tapElementSelector?.({selector:t,...n}),i=r?.maestroNonHittableCoordinateFallbackUsed===!0;return{selector:t.raw,...r??{},...d(i?`tapped via non-hittable coordinate fallback`:`Tapped ${t.raw}`)}}:void 0})}function O(e,t,n){return Object.freeze({captureSnapshot:n,longPressPoint:async(n,r)=>{let i=await e.runtime.operations.longPressPoint({point:n,durationMs:r,...t});return{x:n.x,y:n.y,durationMs:r,...i??{},...d(`Long pressed (${n.x}, ${n.y})`)}}})}function k(e,t,n){let r=e.captured?e.runtime.operations.hoverRef:void 0;return Object.freeze({captureSnapshot:n,hoverPoint:async n=>{let r=await e.runtime.operations.hoverPoint({point:n,...t});return{x:n.x,y:n.y,...r??{},...d(`Hovered (${n.x}, ${n.y})`)}},hoverRef:r?async e=>await r({ref:e,...t}):void 0})}function A(e,t,n,r){let i=e.captured?e.runtime.operations.fillRef:void 0,a=e=>u(e??t.delayMs??0,`delay-ms`,0,1e4);return Object.freeze({captureSnapshot:r,fillPoint:async(t,r,i={})=>{let o=a(i.delayMs),s=await e.runtime.operations.fillPoint({point:t,text:r,delayMs:o,allowNonHittableCoordinateFallback:i.allowNonHittableCoordinateFallback===!0,...n});return{x:t.x,y:t.y,text:r,delayMs:o,...j(s)?{maestroNonHittableCoordinateFallbackUsed:!0}:{},...g(s),...d(`Filled ${Array.from(r).length} chars`)}},fillRef:i?async(e,t,r={})=>await i({ref:e,text:t,delayMs:a(r.delayMs),...n}):void 0})}function j(e){return typeof e==`object`&&!!e&&`maestroNonHittableCoordinateFallbackUsed`in e&&e.maestroNonHittableCoordinateFallbackUsed===!0}function M(e){return async t=>await e.operations.captureSnapshot(t)}function N(e,t){let n=P(e,t);return I(n),{button:e.button??f(t),...n,surface:e.surface??t.surface}}function P(e,t){return{count:F(e.count,t.count,1,`count`,1,200),intervalMs:F(e.intervalMs,t.intervalMs,0,`interval-ms`,0,1e4),holdMs:F(e.holdMs,t.holdMs,0,`hold-ms`,0,1e4),jitterPx:F(e.jitterPx,t.jitterPx,0,`jitter-px`,0,100),doubleTap:e.doubleTap??t.doubleTap??!1}}function F(e,t,n,r,i,a){return u(e??t??n,r,i,a)}function I(t){if(t.doubleTap&&t.holdMs>0)throw new e(`INVALID_ARGS`,`double-tap cannot be combined with hold-ms`);if(t.doubleTap&&t.jitterPx>0)throw new e(`INVALID_ARGS`,`double-tap cannot be combined with jitter-px`)}function L(e,t){return t===`primary`?`Pressed (${e.x}, ${e.y})`:`${t===`secondary`?`Right`:`Middle`} clicked (${e.x}, ${e.y})`}export{T as n,E as t};
@@ -1,3 +1,3 @@
1
- import{N as e}from"./sdk-contracts.js";import t from"node:crypto";const n=`/agent-device`,r=`x-agent-device-tenant`,i=`x-agent-device-network-access`,a=`public-only`;function o(e){return s(e,n)}function s(e,t){let n=e.endsWith(`/`)?e:`${e}/`;return new URL(t.replace(/^\/+/,``),n).toString()}function c(e){let t=e?.trim();return t?{authorization:`Bearer ${t}`,"x-agent-device-token":t}:{}}function l(e){let t=e?.trim();return t?{[r]:t}:{}}const u=`x-agent-device-instance`,d=`x-agent-device-upstream-instance`,f=`x-agent-device-instance-mismatch`;function p(e,t,n){return{jsonrpc:`2.0`,id:e,error:{code:-32001,message:t,data:n}}}function m(e,t,n={}){return{ok:!0,service:e,version:t,rpcProtocolVersion:2,...n.instanceId===void 0?{}:{instanceId:n.instanceId},...n.hostArch===void 0?{}:{hostArch:n.hostArch},...n.upstream===void 0?{}:{upstream:n.upstream}}}function h(e,t){let n=[],r=e+t.toString(),i=r.indexOf(`
1
+ import{P as e}from"./sdk-contracts.js";import t from"node:crypto";function n(e,t){let n=[],r=e+t.toString(),i=r.indexOf(`
2
2
  `);for(;i!==-1;){let e=r.slice(0,i).trim();r=r.slice(i+1),e&&n.push(e),i=r.indexOf(`
3
- `)}return{lines:n,buffer:r}}async function g(e){return e===`https:`?(await import(`node:https`)).default:(await import(`node:http`)).default}function _(e){return new Promise((t,n)=>{let r=``;e.setEncoding(`utf8`),e.on(`data`,e=>{r+=e}),e.on(`end`,()=>t(r)),e.on(`error`,n)})}async function v(t,n,r){let i=[],a=0;for await(let o of t){let t=Buffer.isBuffer(o)?o:Buffer.from(o);if(a+=t.length,a>n)throw new e(`INVALID_ARGS`,r);i.push(t)}return Buffer.concat(i)}function y(e,n){let r=t.createHash(`sha256`).update(e).digest(),i=t.createHash(`sha256`).update(n).digest();return t.timingSafeEqual(r,i)}export{s as _,y as a,f as c,r as d,d as f,l as g,o as h,_ as i,i as l,c as m,g as n,n as o,m as p,v as r,u as s,h as t,a as u,p as v};
3
+ `)}return{lines:n,buffer:r}}async function r(e){return e===`https:`?(await import(`node:https`)).default:(await import(`node:http`)).default}function i(e){return new Promise((t,n)=>{let r=``;e.setEncoding(`utf8`),e.on(`data`,e=>{r+=e}),e.on(`end`,()=>t(r)),e.on(`error`,n)})}async function a(t,n,r){let i=[],a=0;for await(let o of t){let t=Buffer.isBuffer(o)?o:Buffer.from(o);if(a+=t.length,a>n)throw new e(`INVALID_ARGS`,r);i.push(t)}return Buffer.concat(i)}function o(e,n){let r=t.createHash(`sha256`).update(e).digest(),i=t.createHash(`sha256`).update(n).digest();return t.timingSafeEqual(r,i)}export{o as a,i,r as n,a as r,n as t};
@@ -1 +1 @@
1
- import{N as e}from"./sdk-contracts.js";const t={android:`longpress`,apple:`exact`,vega:`exact`},n={up:{aliases:[],androidKeyevent:`KEYCODE_DPAD_UP`,appleRemoteButton:`up`,vegaKey:`KEY_UP`},down:{aliases:[],androidKeyevent:`KEYCODE_DPAD_DOWN`,appleRemoteButton:`down`,vegaKey:`KEY_DOWN`},left:{aliases:[],androidKeyevent:`KEYCODE_DPAD_LEFT`,appleRemoteButton:`left`,vegaKey:`KEY_LEFT`},right:{aliases:[],androidKeyevent:`KEYCODE_DPAD_RIGHT`,appleRemoteButton:`right`,vegaKey:`KEY_RIGHT`},select:{aliases:[`ok`,`center`,`enter`],androidKeyevent:`KEYCODE_DPAD_CENTER`,appleRemoteButton:`select`,vegaKey:`KEY_ENTER`},menu:{aliases:[],androidKeyevent:`KEYCODE_MENU`,appleRemoteButton:`menu`,vegaKey:`KEY_MENU`},home:{aliases:[],androidKeyevent:`KEYCODE_HOME`,appleRemoteButton:`home`,vegaKey:`KEY_HOMEPAGE`},back:{aliases:[],androidKeyevent:`KEYCODE_BACK`,appleRemoteButton:`menu`,vegaKey:`KEY_BACK`}},r=Object.keys(n),i=`<${r.join(`|`)}>`;function a(t){let n=t?.toLowerCase();if(o(n))return n;let i=n?d.get(n):void 0;if(i)return i;throw new e(`INVALID_ARGS`,`tv-remote button must be one of: ${r.join(`, `)}.`)}function o(e){return typeof e==`string`&&r.includes(e)}function s(e){return n[e].appleRemoteButton}function c(e){return n[e].androidKeyevent}function l(e){return n[e].vegaKey}function u(e){return t[e]}const d=new Map(r.flatMap(e=>n[e].aliases.map(t=>[t,e])));export{s as a,c as i,i as n,l as o,a as r,u as s,r as t};
1
+ import{P as e}from"./sdk-contracts.js";const t={android:`longpress`,apple:`exact`,vega:`exact`},n={up:{aliases:[],androidKeyevent:`KEYCODE_DPAD_UP`,appleRemoteButton:`up`,vegaKey:`KEY_UP`},down:{aliases:[],androidKeyevent:`KEYCODE_DPAD_DOWN`,appleRemoteButton:`down`,vegaKey:`KEY_DOWN`},left:{aliases:[],androidKeyevent:`KEYCODE_DPAD_LEFT`,appleRemoteButton:`left`,vegaKey:`KEY_LEFT`},right:{aliases:[],androidKeyevent:`KEYCODE_DPAD_RIGHT`,appleRemoteButton:`right`,vegaKey:`KEY_RIGHT`},select:{aliases:[`ok`,`center`,`enter`],androidKeyevent:`KEYCODE_DPAD_CENTER`,appleRemoteButton:`select`,vegaKey:`KEY_ENTER`},menu:{aliases:[],androidKeyevent:`KEYCODE_MENU`,appleRemoteButton:`menu`,vegaKey:`KEY_MENU`},home:{aliases:[],androidKeyevent:`KEYCODE_HOME`,appleRemoteButton:`home`,vegaKey:`KEY_HOMEPAGE`},back:{aliases:[],androidKeyevent:`KEYCODE_BACK`,appleRemoteButton:`menu`,vegaKey:`KEY_BACK`}},r=Object.keys(n),i=`<${r.join(`|`)}>`;function a(t){let n=t?.toLowerCase();if(o(n))return n;let i=n?d.get(n):void 0;if(i)return i;throw new e(`INVALID_ARGS`,`tv-remote button must be one of: ${r.join(`, `)}.`)}function o(e){return typeof e==`string`&&r.includes(e)}function s(e){return n[e].appleRemoteButton}function c(e){return n[e].androidKeyevent}function l(e){return n[e].vegaKey}function u(e){return t[e]}const d=new Map(r.flatMap(e=>n[e].aliases.map(t=>[t,e])));export{s as a,c as i,i as n,l as o,a as r,u as s,r as t};
@@ -1 +1 @@
1
- import{N as e}from"./sdk-contracts.js";import{qt as t}from"./sdk-batch.js";import{O as n}from"./runtime.js";import{r}from"./success-text.js";import{f as i}from"./session-snapshot.js";import{n as a}from"./runtime-admission.js";function o(e){let t=e?.trim().split(/\s+/,1)[0];if(!t||!t.startsWith(`@`)||t.length<3)return null;let n=t.slice(1);return/^[A-Za-z_-]*\d[\w-]*$/i.test(n)||/^(?:ref|node|element|el)[\w-]*$/i.test(n)?t:null}async function s(e){let n=await a({command:`type`,device:e.device,use:t,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice});if(n.type===`response`)return{ok:!1,response:n.response};let r=n.runtime;return{ok:!0,typeText:async(e,t)=>await c(r,e,t)}}async function c(t,i,a){let s=o(i[0]);if(s)throw new e(`INVALID_ARGS`,`type does not accept a target ref like "${s}"`,{hint:`Use fill ${s} "text" to target that field, or press ${s} then type "text" to append.`});let c=i.join(` `);if(!c)throw new e(`INVALID_ARGS`,`type requires text`);let u=n(a.delayMs??0,`delay-ms`,0,1e4),d=(await t.operations.typeText(l(c,u,a)))?.textEntryRoute;return{...d===void 0?{}:{textEntryRoute:d},text:c,delayMs:u,...r(`Typed ${Array.from(c).length} chars`)}}function l(e,t,n){return{text:e,delayMs:t,...n.appBundleId===void 0?{}:{options:{appBundleId:n.appBundleId}},execution:i(n)}}export{s as n,c as t};
1
+ import{P as e}from"./sdk-contracts.js";import{qt as t}from"./sdk-batch.js";import{O as n}from"./runtime.js";import{r}from"./success-text.js";import{m as i}from"./session-snapshot.js";import{n as a}from"./runtime-admission.js";function o(e){let t=e?.trim().split(/\s+/,1)[0];if(!t||!t.startsWith(`@`)||t.length<3)return null;let n=t.slice(1);return/^[A-Za-z_-]*\d[\w-]*$/i.test(n)||/^(?:ref|node|element|el)[\w-]*$/i.test(n)?t:null}async function s(e){let n=await a({command:`type`,device:e.device,use:t,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice});if(n.type===`response`)return{ok:!1,response:n.response};let r=n.runtime;return{ok:!0,typeText:async(e,t)=>await c(r,e,t)}}async function c(t,i,a){let s=o(i[0]);if(s)throw new e(`INVALID_ARGS`,`type does not accept a target ref like "${s}"`,{hint:`Use fill ${s} "text" to target that field, or press ${s} then type "text" to append.`});let c=i.join(` `);if(!c)throw new e(`INVALID_ARGS`,`type requires text`);let u=n(a.delayMs??0,`delay-ms`,0,1e4),d=(await t.operations.typeText(l(c,u,a)))?.textEntryRoute;return{...d===void 0?{}:{textEntryRoute:d},text:c,delayMs:u,...r(`Typed ${Array.from(c).length} chars`)}}function l(e,t,n){return{text:e,delayMs:t,...n.appBundleId===void 0?{}:{options:{appBundleId:n.appBundleId}},execution:i(n)}}export{s as n,c as t};
@@ -1 +1 @@
1
- import{d as e}from"./exec.js";import"./command.js";import{n as t}from"./version.js";import n from"node:path";import r from"node:fs";import{fileURLToPath as i}from"node:url";const a=`agent-device`,o=`--agent-device-run-update-check`;function s(e){if(!l(e))return;let t=Date.now(),r=n.join(e.stateDir,`update-check.json`),i=f(r);u(i,e.currentVersion)&&(process.stderr.write(`Update available: ${a} ${e.currentVersion} -> ${i.latestVersion}. Run \`npm install -g ${a}@latest\` to upgrade the CLI.\n`),p(r,{...i,prompted:!0})),d(i,t)&&h(r,e.currentVersion)}async function c(e){let n=Date.now(),r=f(e.cachePath);try{let i=await g()??void 0;if(!i||t(i,e.currentVersion)<=0){p(e.cachePath,{checkedAt:new Date(n).toISOString()});return}p(e.cachePath,{checkedAt:new Date(n).toISOString(),latestVersion:i,prompted:r.latestVersion===i&&r.prompted===!0})}catch{p(e.cachePath,{...r,checkedAt:new Date(n).toISOString()})}}function l(e){return!e.command||e.command===`help`||e.command===`test`||e.flags.help||e.flags.version||e.flags.json||process.env.CI?.trim()||process.env.NODE_ENV===`test`||process.env.AGENT_DEVICE_NO_UPDATE_NOTIFIER?.trim()?!1:!!process.stderr.isTTY}function u(e,n){return!e.latestVersion||t(e.latestVersion,n)<=0?!1:e.prompted!==!0}function d(e,t){let n=_(e.checkedAt);return n===void 0||t-n>=12096e5}function f(e){try{let t=JSON.parse(r.readFileSync(e,`utf8`));return{checkedAt:typeof t.checkedAt==`string`?t.checkedAt:void 0,latestVersion:typeof t.latestVersion==`string`?t.latestVersion:void 0,prompted:t.prompted===!0}}catch{return{}}}function p(e,t){try{r.mkdirSync(n.dirname(e),{recursive:!0}),r.writeFileSync(e,`${JSON.stringify(t,null,2)}\n`,`utf8`)}catch{}}function m(){let e=i(import.meta.url),t=n.extname(e)||`.js`,a=[n.join(n.dirname(e),`update-check-entry${t}`),n.join(n.dirname(e),`internal`,`update-check-entry${t}`)].find(e=>r.existsSync(e));if(!a)throw Error(`Update check entrypoint not found. Rebuild the package to include the update-check worker entry.`);return a}function h(t,n){let r=m(),i=r.endsWith(`.ts`)?[`--experimental-strip-types`]:[];e(process.execPath,[...i,r,o,t,n])}async function g(){let e=await fetch(`https://registry.npmjs.org/${a}/latest`,{signal:AbortSignal.timeout(3500),headers:{accept:`application/json`}});if(!e.ok)return;let t=await e.json();return typeof t.version==`string`&&t.version.trim().length>0?t.version.trim():void 0}function _(e){if(!e)return;let t=Date.parse(e);return Number.isNaN(t)?void 0:t}function v(e){if(e[0]!==o)return null;let t=e[1]?.trim(),n=e[2]?.trim();return!t||!n?null:{cachePath:t,currentVersion:n}}export{v as n,c as r,s as t};
1
+ import{d as e}from"./exec.js";import"./command.js";import{n as t}from"./version.js";import n from"node:fs";import r from"node:path";import{fileURLToPath as i}from"node:url";const a=`agent-device`,o=`--agent-device-run-update-check`;function s(e){if(!l(e))return;let t=Date.now(),n=r.join(e.stateDir,`update-check.json`),i=f(n);u(i,e.currentVersion)&&(process.stderr.write(`Update available: ${a} ${e.currentVersion} -> ${i.latestVersion}. Run \`npm install -g ${a}@latest\` to upgrade the CLI.\n`),p(n,{...i,prompted:!0})),d(i,t)&&h(n,e.currentVersion)}async function c(e){let n=Date.now(),r=f(e.cachePath);try{let i=await g()??void 0;if(!i||t(i,e.currentVersion)<=0){p(e.cachePath,{checkedAt:new Date(n).toISOString()});return}p(e.cachePath,{checkedAt:new Date(n).toISOString(),latestVersion:i,prompted:r.latestVersion===i&&r.prompted===!0})}catch{p(e.cachePath,{...r,checkedAt:new Date(n).toISOString()})}}function l(e){return!e.command||e.command===`help`||e.command===`test`||e.flags.help||e.flags.version||e.flags.json||process.env.CI?.trim()||process.env.NODE_ENV===`test`||process.env.AGENT_DEVICE_NO_UPDATE_NOTIFIER?.trim()?!1:!!process.stderr.isTTY}function u(e,n){return!e.latestVersion||t(e.latestVersion,n)<=0?!1:e.prompted!==!0}function d(e,t){let n=_(e.checkedAt);return n===void 0||t-n>=12096e5}function f(e){try{let t=JSON.parse(n.readFileSync(e,`utf8`));return{checkedAt:typeof t.checkedAt==`string`?t.checkedAt:void 0,latestVersion:typeof t.latestVersion==`string`?t.latestVersion:void 0,prompted:t.prompted===!0}}catch{return{}}}function p(e,t){try{n.mkdirSync(r.dirname(e),{recursive:!0}),n.writeFileSync(e,`${JSON.stringify(t,null,2)}\n`,`utf8`)}catch{}}function m(){let e=i(import.meta.url),t=r.extname(e)||`.js`,a=[r.join(r.dirname(e),`update-check-entry${t}`),r.join(r.dirname(e),`internal`,`update-check-entry${t}`)].find(e=>n.existsSync(e));if(!a)throw Error(`Update check entrypoint not found. Rebuild the package to include the update-check worker entry.`);return a}function h(t,n){let r=m(),i=r.endsWith(`.ts`)?[`--experimental-strip-types`]:[];e(process.execPath,[...i,r,o,t,n])}async function g(){let e=await fetch(`https://registry.npmjs.org/${a}/latest`,{signal:AbortSignal.timeout(3500),headers:{accept:`application/json`}});if(!e.ok)return;let t=await e.json();return typeof t.version==`string`&&t.version.trim().length>0?t.version.trim():void 0}function _(e){if(!e)return;let t=Date.parse(e);return Number.isNaN(t)?void 0:t}function v(e){if(e[0]!==o)return null;let t=e[1]?.trim(),n=e[2]?.trim();return!t||!n?null:{cachePath:t,currentVersion:n}}export{v as n,c as r,s as t};
package/dist/src/vars.js CHANGED
@@ -1,2 +1,2 @@
1
- import{N as e}from"./sdk-contracts.js";import{t}from"./script.js";function n(e){return e.startsWith(`AD_`)}function r(t){return new e(`INVALID_ARGS`,`The AD_* namespace is reserved for built-in variables. Rename ${t} to avoid the AD_ prefix.`)}function i(e){let t={};if(e.builtins)for(let[n,r]of Object.entries(e.builtins))t[n]=r;let i=[e.fileEnv,e.shellEnv,e.cliEnv];for(let e of i)if(e)for(let[i,a]of Object.entries(e)){if(n(i))throw r(i);t[i]=a}return{values:t,expandedBuiltinNames:new Set}}function a(e){let r={};for(let[i,a]of Object.entries(e)){if(typeof a!=`string`||!i.startsWith(`AD_VAR_`))continue;let e=i.slice(7);e.length!==0&&t.test(e)&&(n(e)||(r[e]=a))}return r}function o(i){let a={};for(let o of i){let i=o.indexOf(`=`);if(i<=0)throw new e(`INVALID_ARGS`,`Invalid -e entry "${o}": expected KEY=VALUE.`);let s=o.slice(0,i);if(!t.test(s))throw new e(`INVALID_ARGS`,`Invalid -e key "${s}": keys must be uppercase letters, digits, and underscores (e.g. APP_ID).`);if(n(s))throw r(s);a[s]=o.slice(i+1)}return a}function s(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function c(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&(t[n]=r);return t}return process.env}function l(e){return e>=`A`&&e<=`Z`||e>=`a`&&e<=`z`||e===`_`}function u(e){return l(e)||e>=`0`&&e<=`9`||e===`.`}function d(e){return e===`
1
+ import{P as e}from"./sdk-contracts.js";import{t}from"./script.js";function n(e){return e.startsWith(`AD_`)}function r(t){return new e(`INVALID_ARGS`,`The AD_* namespace is reserved for built-in variables. Rename ${t} to avoid the AD_ prefix.`)}function i(e){let t={};if(e.builtins)for(let[n,r]of Object.entries(e.builtins))t[n]=r;let i=[e.fileEnv,e.shellEnv,e.cliEnv];for(let e of i)if(e)for(let[i,a]of Object.entries(e)){if(n(i))throw r(i);t[i]=a}return{values:t,expandedBuiltinNames:new Set}}function a(e){let r={};for(let[i,a]of Object.entries(e)){if(typeof a!=`string`||!i.startsWith(`AD_VAR_`))continue;let e=i.slice(7);e.length!==0&&t.test(e)&&(n(e)||(r[e]=a))}return r}function o(i){let a={};for(let o of i){let i=o.indexOf(`=`);if(i<=0)throw new e(`INVALID_ARGS`,`Invalid -e entry "${o}": expected KEY=VALUE.`);let s=o.slice(0,i);if(!t.test(s))throw new e(`INVALID_ARGS`,`Invalid -e key "${s}": keys must be uppercase letters, digits, and underscores (e.g. APP_ID).`);if(n(s))throw r(s);a[s]=o.slice(i+1)}return a}function s(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function c(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&(t[n]=r);return t}return process.env}function l(e){return e>=`A`&&e<=`Z`||e>=`a`&&e<=`z`||e===`_`}function u(e){return l(e)||e>=`0`&&e<=`9`||e===`.`}function d(e){return e===`
2
2
  `||e===`\r`||e===`\u2028`||e===`\u2029`}function f(e,t){let n=t+2;if(n>=e.length||!l(e[n]))return null;for(n+=1;n<e.length&&u(e[n]);)n+=1;let r=e.slice(t+2,n);if(e[n]===`}`)return{key:r,fallback:void 0,end:n+1};if(e[n]!==`:`||e[n+1]!==`-`)return null;n+=2;let i=``;for(;n<e.length;){let t=e[n];if(t===`}`)return{key:r,fallback:i,end:n+1};if(t===`\\`){let t=e[n+1];if(t===void 0)return{abortEnd:e.length};if(d(t))return{abortEnd:n+2};i+=t,n+=2;continue}i+=t,n+=1}return{abortEnd:e.length}}function p(t,r,i){let a=``,o=0;for(;o<t.length;){let s=t[o];if(s===`\\`&&t.startsWith("${",o+1)){a+="${",o+=3;continue}if(s===`$`&&t[o+1]===`{`){let s=f(t,o);if(s!==null&&`abortEnd`in s){a+=t.slice(o,s.abortEnd),o=s.abortEnd;continue}if(s!==null){let{key:t,fallback:c}=s;if(Object.prototype.hasOwnProperty.call(r.values,t))n(t)&&(r.expandedBuiltinNames??=new Set).add(t),a+=String(r.values[t]);else if(c!==void 0)a+=c;else throw new e(`INVALID_ARGS`,`Unresolved variable \${${t}} at ${i.file}:${i.line}.`);o=s.end;continue}}a+=s,o+=1}return a}function m(e,t,n){return{...e,positionals:(e.positionals??[]).map(e=>p(e,t,n)),flags:h(e.flags,t,n)??{},runtime:h(e.runtime,t,n)}}function h(e,t,n){return e&&g(e,t,n)}function g(e,t,n){return typeof e==`string`?p(e,t,n):Array.isArray(e)?e.map(e=>g(e,t,n)):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).map(([e,r])=>[e,g(r,t,n)])):e}function _(e){return Object.entries(e.values).filter(([t,r])=>r.length>0&&(!n(t)||e.expandedBuiltinNames?.has(t))).map(([e,t])=>({name:e,value:t})).sort((e,t)=>t.value.length-e.value.length)}export{s as a,o as i,_ as n,c as o,a as r,m as s,i as t};
@@ -1 +1 @@
1
- import{N as e}from"./sdk-contracts.js";import t from"node:fs";const n=`agent-device only reads and writes regular files at this path. Remove the symbolic link or special file there and retry.`,r=`Another process replaced the file at this path while it was being opened. Stop the concurrent writer, then retry.`;function i(e){return s(e,t.constants.O_RDONLY,!1)}function a(e){return s(e,t.constants.O_WRONLY|t.constants.O_APPEND,!0)}function o(e){let n=s(e,t.constants.O_RDWR,!0);try{return t.ftruncateSync(n,0),n}catch(e){throw t.closeSync(n),e}}function s(t,n,i){for(let e=0;e<2;e+=1){let e=c(t,n,i);if(e.status!==`retry`)return e.status===`missing`?void 0:e.descriptor}throw new e(`COMMAND_FAILED`,`Final file could not be opened without an identity race: ${t}`,{hint:r})}function c(e,n,r){let i=p(e);if(!i&&!r)return{status:`missing`};let a=l(e,n,i===void 0,r);if(typeof a!=`number`)return a;try{return d(e,a,i),{status:`opened`,descriptor:a}}catch(e){throw t.closeSync(a),e}}function l(e,n,r,i){try{return t.openSync(e,n|g()|(r?t.constants.O_CREAT|t.constants.O_EXCL:0),384)}catch(e){let t=e.code,n=u(t,r,i);if(n)return n;throw e}}function u(e,t,n){if(e===`EEXIST`)return t?{status:`retry`}:void 0;if(e===`ENOENT`&&!t)return{status:n?`retry`:`missing`}}function d(e,n,r){let i=t.fstatSync(n),a=p(e);if(!i.isFile()||!a||!h(i,a)||r&&!h(r,i))throw f(e)}function f(t){return new e(`COMMAND_FAILED`,`Final file identity changed while it was opened: ${t}`,{hint:r})}function p(t){let r=m(t);if(r&&!r.isFile())throw new e(`COMMAND_FAILED`,`Final path must be a regular file: ${t}`,{hint:n});return r}function m(e){try{return t.lstatSync(e)}catch(e){if(e.code===`ENOENT`)return;throw e}}function h(e,t){return e.dev===t.dev&&e.ino===t.ino}function g(){let e=t.constants.O_NOFOLLOW;return Number.isInteger(e)&&e>0?e:0}export{o as a,i,m as n,a as r,n as t};
1
+ import{P as e}from"./sdk-contracts.js";import t from"node:fs";const n=`agent-device only reads and writes regular files at this path. Remove the symbolic link or special file there and retry.`,r=`Another process replaced the file at this path while it was being opened. Stop the concurrent writer, then retry.`;function i(e){return s(e,t.constants.O_RDONLY,!1)}function a(e){return s(e,t.constants.O_WRONLY|t.constants.O_APPEND,!0)}function o(e){let n=s(e,t.constants.O_RDWR,!0);try{return t.ftruncateSync(n,0),n}catch(e){throw t.closeSync(n),e}}function s(t,n,i){for(let e=0;e<2;e+=1){let e=c(t,n,i);if(e.status!==`retry`)return e.status===`missing`?void 0:e.descriptor}throw new e(`COMMAND_FAILED`,`Final file could not be opened without an identity race: ${t}`,{hint:r})}function c(e,n,r){let i=p(e);if(!i&&!r)return{status:`missing`};let a=l(e,n,i===void 0,r);if(typeof a!=`number`)return a;try{return d(e,a,i),{status:`opened`,descriptor:a}}catch(e){throw t.closeSync(a),e}}function l(e,n,r,i){try{return t.openSync(e,n|g()|(r?t.constants.O_CREAT|t.constants.O_EXCL:0),384)}catch(e){let t=e.code,n=u(t,r,i);if(n)return n;throw e}}function u(e,t,n){if(e===`EEXIST`)return t?{status:`retry`}:void 0;if(e===`ENOENT`&&!t)return{status:n?`retry`:`missing`}}function d(e,n,r){let i=t.fstatSync(n),a=p(e);if(!i.isFile()||!a||!h(i,a)||r&&!h(r,i))throw f(e)}function f(t){return new e(`COMMAND_FAILED`,`Final file identity changed while it was opened: ${t}`,{hint:r})}function p(t){let r=m(t);if(r&&!r.isFile())throw new e(`COMMAND_FAILED`,`Final path must be a regular file: ${t}`,{hint:n});return r}function m(e){try{return t.lstatSync(e)}catch(e){if(e.code===`ENOENT`)return;throw e}}function h(e,t){return e.dev===t.dev&&e.ino===t.ino}function g(){let e=t.constants.O_NOFOLLOW;return Number.isInteger(e)&&e>0?e:0}export{o as a,i,m as n,a as r,n as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime.js";import{t}from"./ttl-memo.js";import n from"node:path";import r from"node:fs";import{fileURLToPath as i}from"node:url";function a(e){let t=e,i=null;for(let e=0;e<8;e+=1){let e=n.join(t,`package.json`);if(r.existsSync(e)){i??=t;try{if(JSON.parse(r.readFileSync(e,`utf8`)).name===`agent-device`)return t}catch{}}t=n.dirname(t)}return i??e}const o=`src/daemon.ts`;function s(e){return r.existsSync(n.join(e,`package.json`))&&r.existsSync(n.join(e,`src/daemon.ts`))}const c=t(),l=t();function u(e=d()){let t=c.get(e);if(t!==void 0)return t;let i;try{i=JSON.parse(r.readFileSync(n.join(e,`package.json`),`utf8`))}catch{return`0.0.0`}let a=typeof i.version==`string`?i.version:`0.0.0`;return c.set(e,a),a}function d(){let e=l.get(`self`);if(e!==void 0)return e;let t=a(n.dirname(i(import.meta.url)));return l.set(`self`,t),t}function f(e,t){return p(e,t)>0}function p(e,t){let n=h(e),r=h(t);return g(n.release,r.release)||_(n.prerelease,r.prerelease)}const m=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;function h(e){let t=m.exec(e.trim());return t?{release:[Number(t[1]),Number(t[2]),Number(t[3])],prerelease:t[4]?.split(`.`)??[]}:{release:[0,0,0],prerelease:[]}}function g(e,t){for(let n=0;n<3;n+=1)if(e[n]!==t[n])return e[n]>t[n]?1:-1;return 0}function _(e,t){if(e.length===0)return t.length===0?0:1;if(t.length===0)return-1;let n=Math.max(e.length,t.length);for(let r=0;r<n;r+=1){let n=e[r],i=t[r];if(n===void 0)return-1;if(i===void 0)return 1;let a=v(n,i);if(a!==0)return a}return 0}function v(e,t){if(e===t)return 0;let n=/^\d+$/.test(e),r=/^\d+$/.test(t);return n&&r?Number(e)>Number(t)?1:-1:n===r?e>t?1:-1:n?-1:1}var y=e({DAEMON_SOURCE_ENTRY:()=>o,compareVersions:()=>p,findProjectRoot:()=>d,isNewerVersion:()=>f,isSourceCheckoutProjectRoot:()=>s,readVersion:()=>u});export{u as a,f as i,p as n,o,d as r,s,y as t};
1
+ import{r as e}from"./rolldown-runtime.js";import{t}from"./ttl-memo.js";import n from"node:fs";import r from"node:path";import{fileURLToPath as i}from"node:url";function a(e){let t=e,i=null;for(let e=0;e<8;e+=1){let e=r.join(t,`package.json`);if(n.existsSync(e)){i??=t;try{if(JSON.parse(n.readFileSync(e,`utf8`)).name===`agent-device`)return t}catch{}}t=r.dirname(t)}return i??e}const o=`src/daemon.ts`;function s(e){return n.existsSync(r.join(e,`package.json`))&&n.existsSync(r.join(e,`src/daemon.ts`))}const c=t(),l=t();function u(e=d()){let t=c.get(e);if(t!==void 0)return t;let i;try{i=JSON.parse(n.readFileSync(r.join(e,`package.json`),`utf8`))}catch{return`0.0.0`}let a=typeof i.version==`string`?i.version:`0.0.0`;return c.set(e,a),a}function d(){let e=l.get(`self`);if(e!==void 0)return e;let t=a(r.dirname(i(import.meta.url)));return l.set(`self`,t),t}function f(e,t){return p(e,t)>0}function p(e,t){let n=h(e),r=h(t);return g(n.release,r.release)||_(n.prerelease,r.prerelease)}const m=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;function h(e){let t=m.exec(e.trim());return t?{release:[Number(t[1]),Number(t[2]),Number(t[3])],prerelease:t[4]?.split(`.`)??[]}:{release:[0,0,0],prerelease:[]}}function g(e,t){for(let n=0;n<3;n+=1)if(e[n]!==t[n])return e[n]>t[n]?1:-1;return 0}function _(e,t){if(e.length===0)return t.length===0?0:1;if(t.length===0)return-1;let n=Math.max(e.length,t.length);for(let r=0;r<n;r+=1){let n=e[r],i=t[r];if(n===void 0)return-1;if(i===void 0)return 1;let a=v(n,i);if(a!==0)return a}return 0}function v(e,t){if(e===t)return 0;let n=/^\d+$/.test(e),r=/^\d+$/.test(t);return n&&r?Number(e)>Number(t)?1:-1:n===r?e>t?1:-1:n?-1:1}var y=e({DAEMON_SOURCE_ENTRY:()=>o,compareVersions:()=>p,findProjectRoot:()=>d,isNewerVersion:()=>f,isSourceCheckoutProjectRoot:()=>s,readVersion:()=>u});export{u as a,f as i,p as n,o,d as r,s,y as t};
package/dist/src/video.js CHANGED
@@ -1,4 +1,4 @@
1
- import{N as e}from"./sdk-contracts.js";import{sr as t}from"./sdk-batch.js";import{C as n}from"./owner-identity.js";import{l as r}from"./exec.js";import{t as i}from"./timeouts.js";import{n as a,t as o}from"./file.js";import"./command.js";import"./process.js";import"./retry.js";import s from"node:path";import c from"node:fs";import{createHash as l}from"node:crypto";import u from"node:os";import{fileURLToPath as d}from"node:url";const f=`apple/runner/AgentDeviceRunner/RecordingScripts`;function p(e,t,n,r){let i=`${f}/${e}`,a=`dist/${i}`;return[s.resolve(t,e),s.resolve(n,i),s.resolve(t,`../${i}`),s.resolve(t,`../../${i}`),s.resolve(t,`../../../${i}`),s.resolve(n,a),s.resolve(r,i)]}function m(t,n,r=s.dirname(d(import.meta.url)),i=process.cwd()){let a=p(t,r,n,i);for(let e of a)if(c.existsSync(e))return e;throw new e(`COMMAND_FAILED`,`Missing recording helper script: ${t}`,{hint:`Ensure ${f} is present in this checkout or bundled under dist/${f} in the package.`,scriptName:t,searchedPaths:a})}function h(e=process.env){let t=v(),n=s.join(t,`home`),r=s.join(t,`module-cache`);return c.mkdirSync(n,{recursive:!0}),c.mkdirSync(r,{recursive:!0}),{...e,HOME:n,CLANG_MODULE_CACHE_PATH:r}}async function g(e){let t=[e.sourcePath,...e.extraSourcePaths??[]],n=t.map(e=>({sourcePath:e,stat:c.statSync(e),source:c.readFileSync(e)})),r=S(e.cacheName??s.basename(e.sourcePath,s.extname(e.sourcePath))),i=C([`2`,process.platform,process.arch,...n.flatMap(({sourcePath:e,stat:t,source:n})=>[s.resolve(e),t.size,n])]),a=s.join(v(),`bin`,`${r}-${i}`);return await y({sourcePaths:t,executablePath:a,timeoutMs:e.timeoutMs}),a}async function _(e){let t=S(e.cacheName),n=C([`2`,process.platform,process.arch,e.source]),r=s.join(v(),`sources`,`${t}-${n}.swift`),i=s.join(v(),`bin`,`${t}-${n}`);return await y({sourcePaths:[r],executablePath:i,sourceText:e.source,timeoutMs:e.timeoutMs}),i}function v(){let e=process.env.AGENT_DEVICE_SWIFT_CACHE_DIR?.trim();return e?s.resolve(e):s.join(u.tmpdir(),`agent-device-swift-cache`)}async function y(e){if(x(e.executablePath))return;let t=s.dirname(e.executablePath);c.mkdirSync(t,{recursive:!0});let n=e.timeoutMs??12e4;await a({acquire:()=>b(`${e.executablePath}.lock`,n),task:async()=>{if(x(e.executablePath))return;let i=c.mkdtempSync(s.join(t,`.${s.basename(e.executablePath)}.${process.pid}.`)),a=s.join(i,s.basename(e.executablePath));try{let[t]=e.sourcePaths;e.sourceText!==void 0&&t&&!c.existsSync(t)&&(c.mkdirSync(s.dirname(t),{recursive:!0}),c.writeFileSync(t,e.sourceText)),await r(`xcrun`,[`swiftc`,...e.sourcePaths,`-o`,a],{timeoutMs:n,env:h()}),c.renameSync(a,e.executablePath)}finally{c.rmSync(i,{recursive:!0,force:!0})}}})}async function b(t,r){try{return await o({lockDirPath:t,owner:{pid:process.pid,startTime:n(process.pid),acquiredAtMs:Date.now()},timeoutMs:r,pollMs:25,ownerGraceMs:r,description:`Swift cache lock: ${t} (${r}ms)`})}catch(n){throw n instanceof e&&n.message.startsWith(`Timed out waiting for Swift cache lock:`)?new e(`COMMAND_FAILED`,n.message,{...n.details,lockDir:t,timeoutMs:r,hint:`Another agent-device process may still be compiling this Swift helper. Retry shortly; if no agent-device process is active, remove "${t}" and retry.`}):n}}function x(e){try{return c.accessSync(e,c.constants.X_OK),c.statSync(e).isFile()}catch{return!1}}function S(e){return t(e.replaceAll(/[^A-Za-z0-9._-]/g,`-`))||`swift-helper`}function C(e){let t=l(`sha256`);for(let n of e)t.update(Buffer.isBuffer(n)?n:String(n)),t.update(`\0`);return t.digest(`hex`).slice(0,16)}const w={block:161,blockGroup:160,cluster:524531317,codecId:134,documentType:17026,ebml:440786851,segment:408125543,simpleBlock:163,trackEntry:174,trackNumber:215,tracks:374648427,trackType:131};function T(e){let t=E(e);if(!t)return!1;let{bytes:n,fileSize:r}=t,i=L(n,0,n.length,r);if(!i||i.id!==w.ebml||!i.complete||i.unknownSize||!D(n,i))return!1;let a=L(n,i.nextOffset,n.length,r);return!a||a.id!==w.segment||!V(a,r)?!1:O(n,a,r)}function E(e){try{let t=c.openSync(e,`r`);try{let e=c.fstatSync(t).size;if(e<=0)return;let n=Buffer.alloc(Math.min(e,1048576));return c.readSync(t,n,0,n.length,0)===n.length?{bytes:n,fileSize:e}:void 0}finally{c.closeSync(t)}}catch{return}}function D(e,t){let n=I(e,t)?.find(e=>e.id===w.documentType);return n!==void 0&&e.toString(`ascii`,n.dataStart,n.dataEnd)===`webm`}function O(e,t,n){let r=new Set,i=new Set;for(let a=t.dataStart;a<t.dataEnd;){let o=L(e,a,t.dataEnd,n);if(!o||!V(o,n))return!1;if(o.id===w.tracks&&k(e,o,r),o.id===w.cluster&&j(e,o,n,i),H(r,i))return!0;if(!o.complete||o.unknownSize)return!1;a=o.nextOffset}return!1}function k(e,t,n){let r=I(e,t);if(r){for(let t of r)if(t.id===w.trackEntry){let r=A(e,t);r!==void 0&&n.add(r)}}}function A(e,t){let n=I(e,t),r=F(e,n,w.trackNumber),i=F(e,n,w.trackType),a=n?.find(e=>e.id===w.codecId),o=a?e.toString(`ascii`,a.dataStart,a.dataEnd):void 0;return i===1&&o?.startsWith(`V_`)?r:void 0}function j(e,t,n,r){for(let i=t.dataStart;i<t.dataEnd;){let a=L(e,i,t.dataEnd,n);if(!a||!V(a,n)||(a.id===w.simpleBlock&&N(e,a,r),a.id===w.blockGroup&&M(e,a,r),!a.complete||a.unknownSize))return;i=a.nextOffset}}function M(e,t,n){let r=I(e,t)?.find(e=>e.id===w.block);r&&N(e,r,n)}function N(e,t,n){if(!t.complete||t.unknownSize)return;let r=z(e,t.dataStart);!r||r.unknown||t.dataEnd-t.dataStart<r.length+4||n.add(r.value)}function P(e,t){let n=t.dataEnd-t.dataStart;if(n<1||n>6)return;let r=0;for(let n=t.dataStart;n<t.dataEnd;n+=1)r=r*256+e[n];return Number.isSafeInteger(r)?r:void 0}function F(e,t,n){let r=t?.find(e=>e.id===n);return r?P(e,r):void 0}function I(e,t){if(!t.complete||t.unknownSize)return;let n=[];for(let r=t.dataStart;r<t.dataEnd;){let i=L(e,r,t.dataEnd,e.length);if(!i||!i.complete||i.unknownSize)return;n.push(i),r=i.nextOffset}return n}function L(e,t,n,r){let i=R(e,t);if(!i)return;let a=z(e,t+i.length);if(!a)return;let o=t+i.length+a.length;if(o>n)return;let s=a.unknown?r:o+a.value;if(!(!Number.isSafeInteger(s)||s<o))return{id:i.value,dataStart:o,dataEnd:Math.min(s,n),nextOffset:s,complete:s<=n,unknownSize:a.unknown}}function R(e,t){let n=B(e,t,4);if(!n)return;let r=0;for(let i=0;i<n;i+=1)r=r*256+e[t+i];return{length:n,value:r}}function z(e,t){let n=B(e,t,8);if(!n)return;let r=e[t],i=128>>n-1;if((r&i-1)==i-1&&e.subarray(t+1,t+n).every(e=>e===255))return{length:n,value:0,unknown:!0};let a=r&i-1;for(let r=1;r<n;r+=1)a=a*256+e[t+r];return Number.isSafeInteger(a)?{length:n,value:a,unknown:!1}:void 0}function B(e,t,n){let r=e[t];if(r===void 0||r===0)return;let i=128,a=1;for(;(r&i)===0;)i>>=1,a+=1;return a<=n&&t+a<=e.length?a:void 0}function V(e,t){return e.unknownSize||e.nextOffset<=t}function H(e,t){for(let n of e)if(t.has(n))return!0;return!1}let U;async function W(e,t={}){let n=t.pollMs??150,r=t.attempts??12,a,o=0;for(let t=0;t<r;t+=1){let t=0;try{t=c.statSync(e).size}catch{t=0}if(t>0&&t===a){if(o+=1,o>=2)return}else o=0;a=t,await i(n)}}async function G(e){let t=await Z(e);if(!t)return!1;if(t===`webm`)return!0;try{let t=await K(),n=await r(t,[e],{allowFailure:!0,timeoutMs:1e4,env:h()});return n.exitCode===0||Y(n.stderr,n.stdout)}catch(e){if(q(e))return!0;throw e}}async function K(){U??=_({source:`import Foundation
1
+ import{P as e}from"./sdk-contracts.js";import{sr as t}from"./sdk-batch.js";import{w as n}from"./owner-identity.js";import{l as r}from"./exec.js";import{t as i}from"./timeouts.js";import{a,t as o}from"./file.js";import"./command.js";import"./process.js";import"./retry.js";import{createHash as s}from"node:crypto";import c from"node:fs";import l from"node:os";import u from"node:path";import{fileURLToPath as d}from"node:url";const f=`apple/runner/AgentDeviceRunner/RecordingScripts`;function p(e,t,n,r){let i=`${f}/${e}`,a=`dist/${i}`;return[u.resolve(t,e),u.resolve(n,i),u.resolve(t,`../${i}`),u.resolve(t,`../../${i}`),u.resolve(t,`../../../${i}`),u.resolve(n,a),u.resolve(r,i)]}function m(t,n,r=u.dirname(d(import.meta.url)),i=process.cwd()){let a=p(t,r,n,i);for(let e of a)if(c.existsSync(e))return e;throw new e(`COMMAND_FAILED`,`Missing recording helper script: ${t}`,{hint:`Ensure ${f} is present in this checkout or bundled under dist/${f} in the package.`,scriptName:t,searchedPaths:a})}function h(e=process.env){let t=v(),n=u.join(t,`home`),r=u.join(t,`module-cache`);return c.mkdirSync(n,{recursive:!0}),c.mkdirSync(r,{recursive:!0}),{...e,HOME:n,CLANG_MODULE_CACHE_PATH:r}}async function g(e){let t=[e.sourcePath,...e.extraSourcePaths??[]],n=t.map(e=>({sourcePath:e,stat:c.statSync(e),source:c.readFileSync(e)})),r=S(e.cacheName??u.basename(e.sourcePath,u.extname(e.sourcePath))),i=C([`2`,process.platform,process.arch,...n.flatMap(({sourcePath:e,stat:t,source:n})=>[u.resolve(e),t.size,n])]),a=u.join(v(),`bin`,`${r}-${i}`);return await y({sourcePaths:t,executablePath:a,timeoutMs:e.timeoutMs}),a}async function _(e){let t=S(e.cacheName),n=C([`2`,process.platform,process.arch,e.source]),r=u.join(v(),`sources`,`${t}-${n}.swift`),i=u.join(v(),`bin`,`${t}-${n}`);return await y({sourcePaths:[r],executablePath:i,sourceText:e.source,timeoutMs:e.timeoutMs}),i}function v(){let e=process.env.AGENT_DEVICE_SWIFT_CACHE_DIR?.trim();return e?u.resolve(e):u.join(l.tmpdir(),`agent-device-swift-cache`)}async function y(e){if(x(e.executablePath))return;let t=u.dirname(e.executablePath);c.mkdirSync(t,{recursive:!0});let n=e.timeoutMs??12e4;await a({acquire:()=>b(`${e.executablePath}.lock`,n),task:async()=>{if(x(e.executablePath))return;let i=c.mkdtempSync(u.join(t,`.${u.basename(e.executablePath)}.${process.pid}.`)),a=u.join(i,u.basename(e.executablePath));try{let[t]=e.sourcePaths;e.sourceText!==void 0&&t&&!c.existsSync(t)&&(c.mkdirSync(u.dirname(t),{recursive:!0}),c.writeFileSync(t,e.sourceText)),await r(`xcrun`,[`swiftc`,...e.sourcePaths,`-o`,a],{timeoutMs:n,env:h()}),c.renameSync(a,e.executablePath)}finally{c.rmSync(i,{recursive:!0,force:!0})}}})}async function b(t,r){try{return await o({lockDirPath:t,owner:{pid:process.pid,startTime:n(process.pid),acquiredAtMs:Date.now()},timeoutMs:r,pollMs:25,description:`Swift cache lock: ${t} (${r}ms)`})}catch(n){throw n instanceof e&&n.details?.reason===`process_lock_timeout`?new e(`COMMAND_FAILED`,n.message,{...n.details,lockDir:t,timeoutMs:r}):n}}function x(e){try{return c.accessSync(e,c.constants.X_OK),c.statSync(e).isFile()}catch{return!1}}function S(e){return t(e.replaceAll(/[^A-Za-z0-9._-]/g,`-`))||`swift-helper`}function C(e){let t=s(`sha256`);for(let n of e)t.update(Buffer.isBuffer(n)?n:String(n)),t.update(`\0`);return t.digest(`hex`).slice(0,16)}const w={block:161,blockGroup:160,cluster:524531317,codecId:134,documentType:17026,ebml:440786851,segment:408125543,simpleBlock:163,trackEntry:174,trackNumber:215,tracks:374648427,trackType:131};function T(e){let t=E(e);if(!t)return!1;let{bytes:n,fileSize:r}=t,i=L(n,0,n.length,r);if(!i||i.id!==w.ebml||!i.complete||i.unknownSize||!D(n,i))return!1;let a=L(n,i.nextOffset,n.length,r);return!a||a.id!==w.segment||!V(a,r)?!1:O(n,a,r)}function E(e){try{let t=c.openSync(e,`r`);try{let e=c.fstatSync(t).size;if(e<=0)return;let n=Buffer.alloc(Math.min(e,1048576));return c.readSync(t,n,0,n.length,0)===n.length?{bytes:n,fileSize:e}:void 0}finally{c.closeSync(t)}}catch{return}}function D(e,t){let n=I(e,t)?.find(e=>e.id===w.documentType);return n!==void 0&&e.toString(`ascii`,n.dataStart,n.dataEnd)===`webm`}function O(e,t,n){let r=new Set,i=new Set;for(let a=t.dataStart;a<t.dataEnd;){let o=L(e,a,t.dataEnd,n);if(!o||!V(o,n))return!1;if(o.id===w.tracks&&k(e,o,r),o.id===w.cluster&&j(e,o,n,i),H(r,i))return!0;if(!o.complete||o.unknownSize)return!1;a=o.nextOffset}return!1}function k(e,t,n){let r=I(e,t);if(r){for(let t of r)if(t.id===w.trackEntry){let r=A(e,t);r!==void 0&&n.add(r)}}}function A(e,t){let n=I(e,t),r=F(e,n,w.trackNumber),i=F(e,n,w.trackType),a=n?.find(e=>e.id===w.codecId),o=a?e.toString(`ascii`,a.dataStart,a.dataEnd):void 0;return i===1&&o?.startsWith(`V_`)?r:void 0}function j(e,t,n,r){for(let i=t.dataStart;i<t.dataEnd;){let a=L(e,i,t.dataEnd,n);if(!a||!V(a,n)||(a.id===w.simpleBlock&&N(e,a,r),a.id===w.blockGroup&&M(e,a,r),!a.complete||a.unknownSize))return;i=a.nextOffset}}function M(e,t,n){let r=I(e,t)?.find(e=>e.id===w.block);r&&N(e,r,n)}function N(e,t,n){if(!t.complete||t.unknownSize)return;let r=z(e,t.dataStart);!r||r.unknown||t.dataEnd-t.dataStart<r.length+4||n.add(r.value)}function P(e,t){let n=t.dataEnd-t.dataStart;if(n<1||n>6)return;let r=0;for(let n=t.dataStart;n<t.dataEnd;n+=1)r=r*256+e[n];return Number.isSafeInteger(r)?r:void 0}function F(e,t,n){let r=t?.find(e=>e.id===n);return r?P(e,r):void 0}function I(e,t){if(!t.complete||t.unknownSize)return;let n=[];for(let r=t.dataStart;r<t.dataEnd;){let i=L(e,r,t.dataEnd,e.length);if(!i||!i.complete||i.unknownSize)return;n.push(i),r=i.nextOffset}return n}function L(e,t,n,r){let i=R(e,t);if(!i)return;let a=z(e,t+i.length);if(!a)return;let o=t+i.length+a.length;if(o>n)return;let s=a.unknown?r:o+a.value;if(!(!Number.isSafeInteger(s)||s<o))return{id:i.value,dataStart:o,dataEnd:Math.min(s,n),nextOffset:s,complete:s<=n,unknownSize:a.unknown}}function R(e,t){let n=B(e,t,4);if(!n)return;let r=0;for(let i=0;i<n;i+=1)r=r*256+e[t+i];return{length:n,value:r}}function z(e,t){let n=B(e,t,8);if(!n)return;let r=e[t],i=128>>n-1;if((r&i-1)==i-1&&e.subarray(t+1,t+n).every(e=>e===255))return{length:n,value:0,unknown:!0};let a=r&i-1;for(let r=1;r<n;r+=1)a=a*256+e[t+r];return Number.isSafeInteger(a)?{length:n,value:a,unknown:!1}:void 0}function B(e,t,n){let r=e[t];if(r===void 0||r===0)return;let i=128,a=1;for(;(r&i)===0;)i>>=1,a+=1;return a<=n&&t+a<=e.length?a:void 0}function V(e,t){return e.unknownSize||e.nextOffset<=t}function H(e,t){for(let n of e)if(t.has(n))return!0;return!1}let U;async function W(e,t={}){let n=t.pollMs??150,r=t.attempts??12,a,o=0;for(let t=0;t<r;t+=1){let t=0;try{t=c.statSync(e).size}catch{t=0}if(t>0&&t===a){if(o+=1,o>=2)return}else o=0;a=t,await i(n)}}async function G(e){let t=await Z(e);if(!t)return!1;if(t===`webm`)return!0;try{let t=await K(),n=await r(t,[e],{allowFailure:!0,timeoutMs:1e4,env:h()});return n.exitCode===0||Y(n.stderr,n.stdout)}catch(e){if(q(e))return!0;throw e}}async function K(){U??=_({source:`import Foundation
2
2
  import AVFoundation
3
3
 
4
4
  let url = URL(fileURLWithPath: CommandLine.arguments[1])
@@ -1 +1 @@
1
- import{N as e}from"./sdk-contracts.js";function t(t,n){let r=t===void 0?NaN:Number(t);if(!Number.isInteger(r)||r<1)throw new e(`INVALID_ARGS`,`viewport ${n} must be a positive integer`);return r}function n(n){if(n.length!==2)throw new e(`INVALID_ARGS`,`viewport requires exactly two arguments: <width> <height>`);return{width:t(n[0],`width`),height:t(n[1],`height`)}}export{n as t};
1
+ import{P as e}from"./sdk-contracts.js";function t(t,n){let r=t===void 0?NaN:Number(t);if(!Number.isInteger(r)||r<1)throw new e(`INVALID_ARGS`,`viewport ${n} must be a positive integer`);return r}function n(n){if(n.length!==2)throw new e(`INVALID_ARGS`,`viewport requires exactly two arguments: <width> <height>`);return{width:t(n[0],`width`),height:t(n[1],`height`)}}export{n as t};
package/dist/src/web.js CHANGED
@@ -1,2 +1,2 @@
1
- import{N as e}from"./sdk-contracts.js";import{printJson as t}from"./json.js";function n(){return Object.freeze({setup:async e=>{let{setupManagedAgentBrowser:t}=await import(`./src6.js`).then(e=>e.i);return await t(e)},doctor:async e=>{let{doctorManagedAgentBrowser:t}=await import(`./src6.js`).then(e=>e.i);return await t(e)}})}const r=n();async function i(t,n){switch(t[0]){case`setup`:{a(n.flags.json);let e=await r.setup({stateDir:n.stateDir});return o(n.flags.json,e),0}case`doctor`:{let e=await r.doctor({stateDir:n.stateDir});return s(n.flags.json,e.exitCode===0?`Web backend is healthy.`:`Web backend doctor reported issues.`,e),e.exitCode}default:throw new e(`INVALID_ARGS`,`web requires setup or doctor`)}}function a(e){e||process.stdout.write(`Setting up managed agent-browser backend (downloads if needed)...
1
+ import{P as e}from"./sdk-contracts.js";import{printJson as t}from"./json.js";function n(){return Object.freeze({setup:async e=>{let{setupManagedAgentBrowser:t}=await import(`./src6.js`).then(e=>e.i);return await t(e)},doctor:async e=>{let{doctorManagedAgentBrowser:t}=await import(`./src6.js`).then(e=>e.i);return await t(e)}})}const r=n();async function i(t,n){switch(t[0]){case`setup`:{a(n.flags.json);let e=await r.setup({stateDir:n.stateDir});return o(n.flags.json,e),0}case`doctor`:{let e=await r.doctor({stateDir:n.stateDir});return s(n.flags.json,e.exitCode===0?`Web backend is healthy.`:`Web backend doctor reported issues.`,e),e.exitCode}default:throw new e(`INVALID_ARGS`,`web requires setup or doctor`)}}function a(e){e||process.stdout.write(`Setting up managed agent-browser backend (downloads if needed)...
2
2
  `)}function o(e,n){if(e){t({success:!0,data:{status:c(n)}});return}process.stdout.write(`Managed web backend installed.\nagent-browser available at: ${n.binaryPath}\n`)}function s(e,n,r){if(e){t({success:!0,data:l(r)});return}process.stdout.write(`${n}\n`)}function c(e){let{socketDir:t,...n}=e;return n}function l(e){let t=e.status;return u(t)?{...e,status:c(t)}:e}function u(e){return typeof e==`object`&&!!e&&`socketDir`in e&&`installDir`in e&&`binaryPath`in e}export{i as runWebCommand};
package/dist/src/web2.js CHANGED
@@ -1 +1 @@
1
- import{N as e}from"./sdk-contracts.js";import{r as t}from"./interaction-positionals.js";import{c as n}from"./diagnostics.js";import"./diagnostics2.js";import{n as r}from"./src6.js";function i(t){let n=async n=>{throw new e(`UNSUPPORTED_OPERATION`,`${n} is not supported on ${t}`)};return{open:()=>n(`open`),openDevice:()=>n(`openDevice`),close:()=>n(`close`),tap:()=>n(`tap`),longPress:()=>n(`longPress`),focus:()=>n(`focus`),type:()=>n(`type`),fill:()=>n(`fill`),scroll:()=>n(`scroll`),screenshot:()=>n(`screenshot`),snapshot:()=>n(`snapshot`),back:()=>n(`back`),setOrientation:()=>n(`setOrientation`),setSetting:()=>n(`setSetting`)}}async function a(a){let o=a??await r(),s=o.clickRef,c=o.hover,l=o.hoverRef,u=o.fillRef;return{...i(`web`),open:(e,t)=>o.open(t?.url??e,{url:t?.url}),openDevice:()=>o.open(`about:blank`),close:e=>o.close(e),tap:(e,t)=>o.click(e,t),...s?{tapRef:async e=>(await s(e),{ref:t(e)})}:{},...c?{hover:async(e,t)=>await c(e,t)}:{},...l?{hoverRef:async e=>(await l(e),{ref:t(e)})}:{},focus:(e,t)=>o.click(e,t),type:(e,t)=>o.typeText(e,{delayMs:t}),fill:(e,t,n,r)=>o.fill(e,t,n,{delayMs:r}),...u?{fillRef:async(e,n,r)=>(await u(e,n,{delayMs:r}),{ref:t(e),text:n,delayMs:r??0})}:{},scroll:(e,t)=>o.scroll(e,t),screenshot:(e,t)=>o.screenshot(e,t),setViewport:(e,t)=>o.setViewport(e,t),snapshot:async e=>{let t=await n(`snapshot_capture`,async()=>await o.snapshot(e),{backend:`web`});return{nodes:t.nodes,truncated:t.truncated??!1,backend:`web`,producer:`agent-browser`}},setOrientation:async()=>{throw new e(`UNSUPPORTED_OPERATION`,`orientation is not supported on web`)}}}export{a as createWebInteractor};
1
+ import{P as e}from"./sdk-contracts.js";import{c as t}from"./diagnostics.js";import"./diagnostics2.js";import{r as n}from"./interaction-positionals.js";import{n as r}from"./src6.js";function i(t){let n=async n=>{throw new e(`UNSUPPORTED_OPERATION`,`${n} is not supported on ${t}`)};return{open:()=>n(`open`),openDevice:()=>n(`openDevice`),close:()=>n(`close`),tap:()=>n(`tap`),longPress:()=>n(`longPress`),focus:()=>n(`focus`),type:()=>n(`type`),fill:()=>n(`fill`),scroll:()=>n(`scroll`),screenshot:()=>n(`screenshot`),snapshot:()=>n(`snapshot`),back:()=>n(`back`),setOrientation:()=>n(`setOrientation`),setSetting:()=>n(`setSetting`)}}async function a(a){let o=a??await r(),s=o.clickRef,c=o.hover,l=o.hoverRef,u=o.fillRef;return{...i(`web`),open:(e,t)=>o.open(t?.url??e,{url:t?.url}),openDevice:()=>o.open(`about:blank`),close:e=>o.close(e),tap:(e,t)=>o.click(e,t),...s?{tapRef:async e=>(await s(e),{ref:n(e)})}:{},...c?{hover:async(e,t)=>await c(e,t)}:{},...l?{hoverRef:async e=>(await l(e),{ref:n(e)})}:{},focus:(e,t)=>o.click(e,t),type:(e,t)=>o.typeText(e,{delayMs:t}),fill:(e,t,n,r)=>o.fill(e,t,n,{delayMs:r}),...u?{fillRef:async(e,t,r)=>(await u(e,t,{delayMs:r}),{ref:n(e),text:t,delayMs:r??0})}:{},scroll:(e,t)=>o.scroll(e,t),screenshot:(e,t)=>o.screenshot(e,t),setViewport:(e,t)=>o.setViewport(e,t),snapshot:async e=>{let n=await t(`snapshot_capture`,async()=>await o.snapshot(e),{backend:`web`});return{nodes:n.nodes,truncated:n.truncated??!1,backend:`web`,producer:`agent-browser`}},setOrientation:async()=>{throw new e(`UNSUPPORTED_OPERATION`,`orientation is not supported on web`)}}}export{a as createWebInteractor};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime.js";import{N as t}from"./sdk-contracts.js";import{t as n}from"./bounds.js";import{t as r}from"./parser.js";var i=e({parseWebDriverSourceFacts:()=>p});function a(e){try{return r(e)}catch(e){throw new t(`COMMAND_FAILED`,`Failed to parse WebDriver page source XML: ${e instanceof Error?e.message:String(e)}`,void 0,e)}}function o(e){let t=n(e.bounds??null);if(t)return t;let r=d(e.x),i=d(e.y),a=d(e.width),o=d(e.height);if(r!==void 0&&i!==void 0&&a!==void 0&&o!==void 0)return{x:r,y:i,width:a,height:o}}function s(e,t){for(let n of t){let t=c(e[n]);if(t!==void 0)return t}}function c(e){return e||void 0}function l(e,t){return e===void 0?t:e===`true`||e===`1`?!0:e===`false`||e===`0`?!1:t===void 0&&void 0}function u(e){return!!(e&&e.width>0&&e.height>0)}function d(e){if(e===void 0||e===``)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function f(e,t){return c(t.class)??c(e.replace(/^XCUIElementType/,``).toLowerCase())}function p(e,t=`ios`){let n=a(e),r=[],i=[];for(let e of n)m(r,e,void 0,0,i,t);return{nodes:r,roots:i}}function m(e,t,n,r,i,a){let o=h(t,a)?n:g(e,t,n,r,i,a),s=o===n?r:r+1;for(let n of t.children)m(e,n,o,s,i,a)}function h(e,t){if(Object.keys(e.attributes).length===0)return!0;let n=e.name.toLowerCase();return t===`ios`&&(n===`hierarchy`||n===`appiumaut`)}function g(e,t,n,r,i,a){let s=e.length,c=o(t.attributes);return e.push(_(s,t.name,t.attributes,n,r,c,a)),n===void 0&&i.push({type:t.name,...c?{rect:c}:{},rectStatus:x(t.attributes,c)}),s}function _(e,t,n,r,i,a,o){return{index:e,type:t,role:f(t,n),label:s(n,[`content-desc`,`label`,`text`,`name`]),value:c(n.value),identifier:s(n,[`resource-id`,`id`,`accessibility-id`,`name`]),rect:a,...v(n,a,o),depth:i,parentIndex:r}}function v(e,t,n){let r=n===`android`||void 0,i=l(e.enabled,r),a=l(e.displayed??e.visible,r);return n===`android`?{enabled:i,selected:l(e.selected,!1),focused:l(e.focused,!1),visibleToUser:a,hittable:a===!0&&i===!0&&u(t)}:{...y(`enabled`,i),...y(`selected`,l(e.selected)),...y(`focused`,l(e.focused)),...y(`visibleToUser`,a),...b(e.hittable)}}function y(e,t){return t===void 0?{}:{[e]:t}}function b(e){let t=l(e);return t===void 0?{}:{hittable:t}}function x(e,t){let n=e.bounds!==void 0,r=[`x`,`y`,`width`,`height`].every(t=>e[t]!==void 0);return!n&&!r?`not-provided`:u(t)?`reported`:`invalid`}export{i as n,p as t};
1
+ import{r as e}from"./rolldown-runtime.js";import{P as t}from"./sdk-contracts.js";import{t as n}from"./bounds.js";import{t as r}from"./parser.js";var i=e({parseWebDriverSourceFacts:()=>p});function a(e){try{return r(e)}catch(e){throw new t(`COMMAND_FAILED`,`Failed to parse WebDriver page source XML: ${e instanceof Error?e.message:String(e)}`,void 0,e)}}function o(e){let t=n(e.bounds??null);if(t)return t;let r=d(e.x),i=d(e.y),a=d(e.width),o=d(e.height);if(r!==void 0&&i!==void 0&&a!==void 0&&o!==void 0)return{x:r,y:i,width:a,height:o}}function s(e,t){for(let n of t){let t=c(e[n]);if(t!==void 0)return t}}function c(e){return e||void 0}function l(e,t){return e===void 0?t:e===`true`||e===`1`?!0:e===`false`||e===`0`?!1:t===void 0&&void 0}function u(e){return!!(e&&e.width>0&&e.height>0)}function d(e){if(e===void 0||e===``)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function f(e,t){return c(t.class)??c(e.replace(/^XCUIElementType/,``).toLowerCase())}function p(e,t=`ios`){let n=a(e),r=[],i=[];for(let e of n)m(r,e,void 0,0,i,t);return{nodes:r,roots:i}}function m(e,t,n,r,i,a){let o=h(t,a)?n:g(e,t,n,r,i,a),s=o===n?r:r+1;for(let n of t.children)m(e,n,o,s,i,a)}function h(e,t){if(Object.keys(e.attributes).length===0)return!0;let n=e.name.toLowerCase();return t===`ios`&&(n===`hierarchy`||n===`appiumaut`)}function g(e,t,n,r,i,a){let s=e.length,c=o(t.attributes);return e.push(_(s,t.name,t.attributes,n,r,c,a)),n===void 0&&i.push({type:t.name,...c?{rect:c}:{},rectStatus:k(t.attributes,c)}),s}function _(e,t,n,r,i,a,o){let l=x(t,n,o);return{index:e,type:t,role:f(t,n),...b(n,o),value:l===void 0?c(n.value):l.value,identifier:s(n,[`resource-id`,`id`,`accessibility-id`,`name`]),rect:a,...E(n,a,o),...l===void 0?{}:l.facts,...T(t,n,o),depth:i,parentIndex:r}}const v=/edittext|autocompletetextview/;function y(e){return e.slice(Math.max(e.lastIndexOf(`.`),e.lastIndexOf(`/`))+1).toLowerCase()}function b(e,t){if(t===`ios`)return{label:s(e,[`label`,`text`,`name`])};let n=c(e[`content-desc`]),r=c(e.text)??n;return{label:r,...n!==void 0&&n!==r?{contentDescription:n}:{}}}function x(e,t,n){return n===`android`?S(e,t):void 0}function S(e,t){let n=l(t.password);if(!v.test(y(t.class??e))&&n!==!0)return;let r=c(t.hint),i=c(t.text),a=r!==void 0&&i===r;return{value:a?void 0:i,facts:{editable:l(t.enabled,!0)===!0,...C(`password`,n),...r===void 0?{}:{placeholder:r,hintShowing:a}}}}function C(e,t){return t===void 0?{}:{[e]:t}}const w=/(CheckBox|RadioButton|Switch|ToggleButton|CheckedTextView)$/;function T(e,t,n){if(n!==`android`)return{};let r=l(t.checkable)??w.test(t.class??e),i=l(t.checked);return r&&i!==void 0?{checked:i}:{}}function E(e,t,n){let r=n===`android`||void 0,i=l(e.enabled,r),a=l(e.displayed??e.visible,r);return n===`android`?{enabled:i,selected:l(e.selected,!1),focused:l(e.focused,!1),visibleToUser:a,hittable:a===!0&&i===!0&&u(t)}:{...D(`enabled`,i),...D(`selected`,l(e.selected)),...D(`focused`,l(e.focused)),...D(`visibleToUser`,a),...O(e.hittable)}}function D(e,t){return t===void 0?{}:{[e]:t}}function O(e){let t=l(e);return t===void 0?{}:{hittable:t}}function k(e,t){let n=e.bounds!==void 0,r=[`x`,`y`,`width`,`height`].every(t=>e[t]!==void 0);return!n&&!r?`not-provided`:u(t)?`reported`:`invalid`}export{i as n,p as t};