agent-device 0.20.9 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (492) hide show
  1. package/README.md +2 -2
  2. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.9.apk → agent-device-android-ime-helper-0.21.0.apk} +0 -0
  3. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.0.apk.sha256 +1 -0
  4. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.9.manifest.json → agent-device-android-ime-helper-0.21.0.manifest.json} +4 -4
  5. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.0.apk +0 -0
  6. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.0.apk.sha256 +1 -0
  7. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.9.manifest.json → agent-device-android-snapshot-helper-0.21.0.manifest.json} +6 -6
  8. package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/AudioProbe.swift +35 -33
  9. package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/main.swift +6 -1
  10. package/apple/snapshot-bridge/LICENSE.idb +23 -0
  11. package/apple/snapshot-bridge/README.md +49 -0
  12. package/apple/snapshot-bridge/SnapshotBridge.m +280 -0
  13. package/apple/snapshot-bridge/SnapshotBridgeRuntime.h +33 -0
  14. package/apple/snapshot-bridge/SnapshotBridgeRuntime.m +382 -0
  15. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +58 -0
  16. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/project.pbxproj +19 -0
  17. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAlertVerification.swift +36 -0
  18. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerStringNormalization.swift +8 -0
  19. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +12 -1
  20. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +100 -6
  21. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTapPointPolicy.swift +2 -2
  22. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +21 -12
  23. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +21 -88
  24. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift +124 -0
  25. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +110 -107
  26. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +6 -14
  27. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +85 -114
  28. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +13 -6
  29. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +72 -175
  30. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +10 -11
  31. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+PrivateAXElementTypes.swift +12 -0
  32. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+PrivateAXPresentation.swift +78 -64
  33. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScreenRecorder.swift +17 -9
  34. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollGesture.swift +47 -13
  35. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +232 -438
  36. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotBackendCapabilities.swift +98 -0
  37. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +229 -168
  38. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotPresentationInvariant.swift +19 -0
  39. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotTiming.swift +110 -0
  40. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedCommitDeadline.swift +206 -0
  41. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedTextEntry.swift +147 -25
  42. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +21 -18
  43. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +24 -307
  44. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryFocus.swift +206 -0
  45. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryReadiness.swift +158 -0
  46. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextInputCandidatePolicy.swift +19 -0
  47. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +49 -16
  48. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Transport.swift +2 -11
  49. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TvRemote.swift +4 -19
  50. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +16 -20
  51. package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/RecordingExportSupport.swift +111 -0
  52. package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-overlay.swift +42 -81
  53. package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-trim.swift +35 -82
  54. package/dist/apple/snapshot-presentation/Package.swift +21 -0
  55. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotGeometry.swift +56 -0
  56. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotModels.swift +259 -0
  57. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentation.swift +153 -0
  58. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationFailure.swift +27 -0
  59. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationInvariant.swift +91 -0
  60. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationProjection.swift +161 -0
  61. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotScopePolicy.swift +53 -0
  62. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFold.swift +242 -0
  63. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFoldProjection.swift +97 -0
  64. package/dist/src/adapter.js +1 -0
  65. package/dist/src/adb-executor.js +2 -0
  66. package/dist/src/adb-failure.js +1 -0
  67. package/dist/src/adb-host.js +1 -0
  68. package/dist/src/adb.js +1 -0
  69. package/dist/src/agent-browser-lifecycle.js +1 -0
  70. package/dist/src/agent-browser-process-record.js +1 -0
  71. package/dist/src/agent-browser-provider.js +1 -0
  72. package/dist/src/agent-browser-tool.js +1 -1
  73. package/dist/src/agent-device-client.js +2 -2
  74. package/dist/src/ai-sdk.d.ts +61 -0
  75. package/dist/src/ai-sdk.js +1 -0
  76. package/dist/src/alert-contract.js +1 -0
  77. package/dist/src/alert-runtime.js +1 -0
  78. package/dist/src/android-adb.d.ts +27 -19
  79. package/dist/src/android-adb.js +1 -1
  80. package/dist/src/android-input-ownership.js +1 -0
  81. package/dist/src/android-system-chrome.js +1 -0
  82. package/dist/src/android.js +1 -1
  83. package/dist/src/api.js +11 -0
  84. package/dist/src/app-catalog.js +1 -0
  85. package/dist/src/app-deployment-resolution.js +2 -0
  86. package/dist/src/app-helpers.js +1 -1
  87. package/dist/src/app-inventory-contract.js +1 -0
  88. package/dist/src/app-inventory.js +1 -0
  89. package/dist/src/app-launch.js +2 -0
  90. package/dist/src/app-lifecycle-facade.js +1 -0
  91. package/dist/src/app-lifecycle.js +3 -6
  92. package/dist/src/app-lifecycle2.js +2 -2
  93. package/dist/src/app-lifecycle3.js +1 -0
  94. package/dist/src/app-log-files.js +1 -1
  95. package/dist/src/app-log-reconnect.js +1 -1
  96. package/dist/src/app-log-runtime.js +1 -4
  97. package/dist/src/app-log-runtime2.js +4 -0
  98. package/dist/src/app-parsers.js +4 -0
  99. package/dist/src/app-resolution-cache.js +1 -0
  100. package/dist/src/app-resolution-facade.js +1 -0
  101. package/dist/src/app-resolution.js +2 -2
  102. package/dist/src/app-state.js +1 -2
  103. package/dist/src/application-lifecycle-interaction.js +1 -0
  104. package/dist/src/application-lifecycle-runtime.js +1 -0
  105. package/dist/src/apps-simctl.js +1 -0
  106. package/dist/src/archive.js +4 -0
  107. package/dist/src/artifact-download.js +1 -0
  108. package/dist/src/artifacts.d.ts +6 -2
  109. package/dist/src/artifacts.js +1 -1
  110. package/dist/src/async-lifecycle.js +1 -0
  111. package/dist/src/audio-probe-result.js +1 -0
  112. package/dist/src/audio-probe-runtime.js +1 -0
  113. package/dist/src/audio-probe-support.js +1 -0
  114. package/dist/src/auth-session.js +1 -1
  115. package/dist/src/auth.js +1 -1
  116. package/dist/src/back-mode.js +1 -0
  117. package/dist/src/{url.js → base-url.js} +1 -1
  118. package/dist/src/boot-diagnostics.js +2 -2
  119. package/dist/src/byte-limit-stream.js +1 -1
  120. package/dist/src/capabilities.js +1 -0
  121. package/dist/src/capture.js +1 -0
  122. package/dist/src/catalog.js +1 -0
  123. package/dist/src/cli-command-aliases.js +1 -0
  124. package/dist/src/cli-config.js +1 -1
  125. package/dist/src/cli-help.js +77 -51
  126. package/dist/src/cli-output.js +1 -1
  127. package/dist/src/cli-runner.js +1 -1
  128. package/dist/src/cli.js +5 -7
  129. package/dist/src/click-button.js +1 -0
  130. package/dist/src/client-metro-companion.js +1 -0
  131. package/dist/src/client-metro.js +1 -1
  132. package/dist/src/client-types.d.ts +1606 -0
  133. package/dist/src/clipboard.js +1 -0
  134. package/dist/src/code-signature-cache.js +1 -0
  135. package/dist/src/code-signature.js +1 -0
  136. package/dist/src/color.js +1 -0
  137. package/dist/src/command-metadata.js +1 -1
  138. package/dist/src/command-schema.js +3 -3
  139. package/dist/src/command-surface.js +1 -1
  140. package/dist/src/command-tools.js +2 -0
  141. package/dist/src/command.js +1 -0
  142. package/dist/src/{selector-vocabulary.js → compatibility-policy.js} +1 -1
  143. package/dist/src/config.js +1 -1
  144. package/dist/src/config2.js +1 -0
  145. package/dist/src/connection-runtime.js +1 -1
  146. package/dist/src/connection.js +5 -5
  147. package/dist/src/contracts.d.ts +1 -1
  148. package/dist/src/contracts.js +1 -1
  149. package/dist/src/daemon-client-lifecycle.js +1 -0
  150. package/dist/src/daemon-process.js +1 -0
  151. package/dist/src/daemon-registration.js +1 -0
  152. package/dist/src/daemon-shutdown-report.js +1 -1
  153. package/dist/src/daemon.js +2 -2
  154. package/dist/src/debug-symbols-facade.js +5 -0
  155. package/dist/src/deploy-result-target.js +1 -0
  156. package/dist/src/device-claim-inspection.js +1 -1
  157. package/dist/src/device-claim-rule.js +1 -0
  158. package/dist/src/device-input-state.d.ts +190 -3
  159. package/dist/src/device-inventory-context.js +1 -0
  160. package/dist/src/device-isolation.js +1 -0
  161. package/dist/src/device-release.js +1 -0
  162. package/dist/src/device-rotation.js +1 -0
  163. package/dist/src/device-selection-resolver.js +1 -0
  164. package/dist/src/device-session.js +1 -0
  165. package/dist/src/device.js +1 -1
  166. package/dist/src/device2.js +3 -2
  167. package/dist/src/diagnostics.js +3 -0
  168. package/dist/src/diagnostics2.js +1 -0
  169. package/dist/src/dispatch-resolve.js +1 -0
  170. package/dist/src/doctor-facade.js +1 -0
  171. package/dist/src/doctor-output.js +1 -0
  172. package/dist/src/doctor.js +1 -0
  173. package/dist/src/doctor2.js +1 -0
  174. package/dist/src/doctor3.js +1 -0
  175. package/dist/src/durable-resource.js +1 -0
  176. package/dist/src/entities.js +1 -1
  177. package/dist/src/error.js +2 -0
  178. package/dist/src/exec.js +1 -0
  179. package/dist/src/file.js +1 -0
  180. package/dist/src/find.js +1 -1
  181. package/dist/src/finders.js +1 -1
  182. package/dist/src/format.js +2 -0
  183. package/dist/src/generic-settle.js +1 -1
  184. package/dist/src/generic.js +1 -1
  185. package/dist/src/gesture-admission.js +1 -0
  186. package/dist/src/gesture-plan-types.js +1 -0
  187. package/dist/src/gesture-plan.js +1 -0
  188. package/dist/src/gesture-runtime.js +1 -0
  189. package/dist/src/harmonyos.js +1 -1
  190. package/dist/src/hdc.js +1 -1
  191. package/dist/src/helper.js +2 -2
  192. package/dist/src/host-file.js +1 -0
  193. package/dist/src/human-control-contract.js +1 -0
  194. package/dist/src/human-control.js +1 -0
  195. package/dist/src/index.d.ts +2 -1578
  196. package/dist/src/index.js +1 -1
  197. package/dist/src/input-actions.js +1 -4
  198. package/dist/src/input-actions2.js +2 -1
  199. package/dist/src/install-artifact-facade.js +1 -0
  200. package/dist/src/install-source-network-transport.js +1 -0
  201. package/dist/src/install-source.d.ts +3 -10
  202. package/dist/src/install-source2.js +1 -1
  203. package/dist/src/interaction-positionals.js +1 -0
  204. package/dist/src/interaction-ref-policy.js +1 -0
  205. package/dist/src/interaction.js +1 -1
  206. package/dist/src/interaction2.js +1 -1
  207. package/dist/src/interactor-operation-catalog.js +1 -0
  208. package/dist/src/interactor-types.js +1 -0
  209. package/dist/src/interactor.js +6 -2
  210. package/dist/src/interactor2.js +1 -1
  211. package/dist/src/interactors.js +1 -1
  212. package/dist/src/internal/bin.d.ts +1 -1
  213. package/dist/src/internal/bin.js +1 -2
  214. package/dist/src/internal/companion-tunnel.d.ts +1 -1
  215. package/dist/src/internal/companion-tunnel.js +1 -1
  216. package/dist/src/internal/daemon.d.ts +1 -1
  217. package/dist/src/internal/daemon.js +2 -4
  218. package/dist/src/internal/png-worker.d.ts +4 -4
  219. package/dist/src/internal/png-worker.js +1 -1
  220. package/dist/src/internal/run-script-http-child.d.ts +4 -0
  221. package/dist/src/internal/run-script-http-child.js +1 -0
  222. package/dist/src/internal/update-check-entry.d.ts +1 -1
  223. package/dist/src/inventory.js +4 -4
  224. package/dist/src/inventory2.js +1 -1
  225. package/dist/src/inventory3.js +1 -1
  226. package/dist/src/inventory5.js +1 -1
  227. package/dist/src/inventory6.js +1 -1
  228. package/dist/src/ios-client.js +16 -0
  229. package/dist/src/ios-snapshot-acquisition.js +1 -0
  230. package/dist/src/ios-snapshot-adapter.js +1 -0
  231. package/dist/src/ios-snapshot-planning.js +1 -0
  232. package/dist/src/ios-snapshot-runtime.js +1 -0
  233. package/dist/src/json.js +1 -0
  234. package/dist/src/keyboard-actions.js +1 -0
  235. package/dist/src/launch-console.js +1 -0
  236. package/dist/src/lease-context.js +1 -1
  237. package/dist/src/lease-scope.js +1 -0
  238. package/dist/src/lease.js +1 -1
  239. package/dist/src/limrun-runtime-dependencies.js +1 -1
  240. package/dist/src/limrun.d.ts +1618 -7
  241. package/dist/src/limrun.js +1 -1
  242. package/dist/src/linux.js +1 -1
  243. package/dist/src/local-interactor-operation-set.js +1 -0
  244. package/dist/src/location-coordinates.js +1 -1
  245. package/dist/src/logcat.js +1 -1
  246. package/dist/src/macos-facade.js +1 -0
  247. package/dist/src/managed-device-scope.js +1 -0
  248. package/dist/src/mechanics.js +19 -0
  249. package/dist/src/metro.d.ts +4 -2
  250. package/dist/src/metro.js +1 -1
  251. package/dist/src/metro2.js +1 -1
  252. package/dist/src/mobile-snapshot-semantics.js +1 -0
  253. package/dist/src/multitouch-support.js +1 -0
  254. package/dist/src/numeric.js +1 -0
  255. package/dist/src/observability.js +1 -1
  256. package/dist/src/observation.js +2 -0
  257. package/dist/src/output-path.js +1 -1
  258. package/dist/src/owner-identity.js +3 -1
  259. package/dist/src/parameterized-recorded-fill.js +1 -0
  260. package/dist/src/parser.js +1 -1
  261. package/dist/src/perf-facade.js +2 -0
  262. package/dist/src/perf-runtime-operation-builder.js +1 -0
  263. package/dist/src/perf-runtime-plan.js +1 -0
  264. package/dist/src/perf-runtime.js +1 -0
  265. package/dist/src/perf.js +1 -4
  266. package/dist/src/physical-device-control.js +1 -1
  267. package/dist/src/physical-device-facade.js +1 -0
  268. package/dist/src/platform-request-scope.js +1 -0
  269. package/dist/src/platform-runtime-android-adb-host.js +1 -0
  270. package/dist/src/platform-runtime-android-mechanics.js +1 -0
  271. package/dist/src/platform-runtime-app-log-android-transport.js +1 -1
  272. package/dist/src/platform-runtime-app-log-process.js +1 -1
  273. package/dist/src/platform-runtime-apple-resources.js +1 -0
  274. package/dist/src/platform-runtime-host.js +1 -1
  275. package/dist/src/platform-runtime-managed-owner.js +1 -0
  276. package/dist/src/platform-runtime-network-web-transport.js +1 -1
  277. package/dist/src/platform-runtime-open-target.js +1 -1
  278. package/dist/src/platform-runtime-operation-host.js +4 -4
  279. package/dist/src/platform-runtime-runtime-hints.js +2 -2
  280. package/dist/src/platform-runtime-screen-recording-android-host.js +1 -1
  281. package/dist/src/platform-runtime-screen-recording-apple-runner-host.js +1 -1
  282. package/dist/src/platform-runtime-screen-recording-apple-runner-transport.js +1 -1
  283. package/dist/src/platform-runtime-screen-recording-apple-simulator-host.js +1 -1
  284. package/dist/src/platform-runtime-screen-recording-apple-transport.js +1 -1
  285. package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
  286. package/dist/src/platform-runtime-screen-recording-harmony-host.js +1 -1
  287. package/dist/src/platform-runtime-screen-recording-process-host.js +1 -0
  288. package/dist/src/platform-runtime-screen-recording-web-host.js +1 -1
  289. package/dist/src/platform-runtime-unavailable.js +1 -0
  290. package/dist/src/platform-runtime.js +1 -1
  291. package/dist/src/platform-runtime2.js +1 -1
  292. package/dist/src/plist.js +1 -1
  293. package/dist/src/png-worker-contract.js +1 -1
  294. package/dist/src/prepare-kind.js +1 -15
  295. package/dist/src/process-exit.js +1 -1
  296. package/dist/src/process.js +1 -0
  297. package/dist/src/provider-device-runtime.js +1 -0
  298. package/dist/src/provider-session-ownership.js +2 -0
  299. package/dist/src/provider-webdriver.js +1 -1
  300. package/dist/src/provider.js +1 -1
  301. package/dist/src/providers.js +1 -0
  302. package/dist/src/proxy.js +2 -2
  303. package/dist/src/react-native-overlay.js +1 -0
  304. package/dist/src/react-native.js +1 -1
  305. package/dist/src/record-runtime.js +1 -1
  306. package/dist/src/record-trace.js +1 -1
  307. package/dist/src/rect-center.js +1 -0
  308. package/dist/src/register-builtins.js +1 -0
  309. package/dist/src/registry.js +39 -28
  310. package/dist/src/remote-config2.js +1 -1
  311. package/dist/src/replay-divergence.js +2 -0
  312. package/dist/src/replay.js +2 -2
  313. package/dist/src/reporting.js +8 -8
  314. package/dist/src/request-admission.js +1 -0
  315. package/dist/src/request-cancel.js +1 -0
  316. package/dist/src/request-cancellation.js +1 -0
  317. package/dist/src/request-progress-protocol.js +1 -0
  318. package/dist/src/request-providers.js +1 -0
  319. package/dist/src/request-runtime-binding.js +1 -0
  320. package/dist/src/request.js +1 -0
  321. package/dist/src/result-serialization.js +1 -0
  322. package/dist/src/retry.js +1 -0
  323. package/dist/src/rolldown-runtime.js +1 -1
  324. package/dist/src/runner-cache-metadata.js +2 -0
  325. package/dist/src/runner-client.js +1 -1
  326. package/dist/src/runner-disposal.js +1 -1
  327. package/dist/src/runner-operations-facade.js +1 -0
  328. package/dist/src/runner-owner-facade.js +1 -0
  329. package/dist/src/runner-owner-state.js +1 -0
  330. package/dist/src/runner-presentation.js +1 -0
  331. package/dist/src/runner-selector-query.js +1 -0
  332. package/dist/src/runner.js +1 -0
  333. package/dist/src/{runtime-transport.js → runtime-transport-hints.js} +1 -1
  334. package/dist/src/runtime.js +3 -3
  335. package/dist/src/runtime2.js +4 -4
  336. package/dist/src/runtime3.js +1 -1
  337. package/dist/src/runtime4.js +4 -3
  338. package/dist/src/runtime5.js +1 -1
  339. package/dist/src/runtime6.js +1 -1
  340. package/dist/src/runtime7.js +1 -1
  341. package/dist/src/runtime8.js +1 -1
  342. package/dist/src/runtime9.js +1 -1
  343. package/dist/src/scoped-provider.js +1 -1
  344. package/dist/src/screen-recording-completion.js +1 -0
  345. package/dist/src/screen-recording-live-handle.js +1 -0
  346. package/dist/src/screen-recording-options.js +1 -0
  347. package/dist/src/screen-recording-resource-recovery.js +1 -0
  348. package/dist/src/screen-recording-runtime.js +1 -0
  349. package/dist/src/screenshot-density.js +1 -1
  350. package/dist/src/screenshot-result.js +1 -6
  351. package/dist/src/screenshot-runtime.js +1 -0
  352. package/dist/src/screenshot.js +1 -1
  353. package/dist/src/screenshot2.js +1 -0
  354. package/dist/src/screenshot3.js +5 -0
  355. package/dist/src/script.js +1 -0
  356. package/dist/src/scroll-command.js +1 -0
  357. package/dist/src/scroll-gesture.js +1 -0
  358. package/dist/src/scroll-indicator.js +1 -0
  359. package/dist/src/sdk-batch-runner.d.ts +23 -6
  360. package/dist/src/sdk-batch-runner.js +2 -3
  361. package/dist/src/sdk-batch.js +2 -0
  362. package/dist/src/sdk-contracts.d.ts +222 -99
  363. package/dist/src/sdk-contracts.js +2 -2
  364. package/dist/src/sdk-device.js +1 -1
  365. package/dist/src/sdk-finders.d.ts +1 -1
  366. package/dist/src/sdk-finders.js +1 -1
  367. package/dist/src/sdk-io.js +1 -1
  368. package/dist/src/sdk-remote-config.d.ts +1 -1
  369. package/dist/src/sdk-remote-config.js +1 -1
  370. package/dist/src/sdk-selectors.d.ts +539 -199
  371. package/dist/src/sdk-selectors.js +1 -1
  372. package/dist/src/selection.js +1 -0
  373. package/dist/src/selector-runtime.js +1 -1
  374. package/dist/src/selectors.js +1 -1
  375. package/dist/src/semantic-index.js +1 -0
  376. package/dist/src/server.js +10 -3
  377. package/dist/src/session-allocation.js +1 -0
  378. package/dist/src/session-artifact-paths.js +1 -0
  379. package/dist/src/session-paths.js +1 -0
  380. package/dist/src/session-repair-tombstone.js +1 -0
  381. package/dist/src/session-routing.js +1 -0
  382. package/dist/src/session-runtime-admission.js +1 -0
  383. package/dist/src/session-snapshot.js +1 -0
  384. package/dist/src/session-store.js +4 -0
  385. package/dist/src/session-target-evidence.js +1 -1
  386. package/dist/src/session2.js +5 -28
  387. package/dist/src/settings.js +1 -0
  388. package/dist/src/shared.js +2 -2
  389. package/dist/src/simctl-facade.js +1 -0
  390. package/dist/src/simctl.js +1 -1
  391. package/dist/src/simulator-facade.js +1 -0
  392. package/dist/src/simulator.js +1 -1
  393. package/dist/src/snapshot-capture-annotations.js +1 -0
  394. package/dist/src/snapshot-desktop-projection.js +1 -0
  395. package/dist/src/snapshot-diagnostics.js +1 -0
  396. package/dist/src/snapshot-process.js +1 -0
  397. package/dist/src/snapshot-quality-backend-capabilities.js +1 -0
  398. package/dist/src/snapshot-quality-verdict.js +1 -0
  399. package/dist/src/snapshot-runtime-binding.js +1 -0
  400. package/dist/src/snapshot-runtime.js +1 -1
  401. package/dist/src/snapshot-scope.js +1 -0
  402. package/dist/src/snapshot-state.js +1 -0
  403. package/dist/src/snapshot.js +1 -8
  404. package/dist/src/snapshot2.js +1 -1
  405. package/dist/src/snapshot3.js +1 -1
  406. package/dist/src/snapshot4.js +1 -0
  407. package/dist/src/src.js +1 -1
  408. package/dist/src/src2.js +1 -1
  409. package/dist/src/src3.js +1 -2
  410. package/dist/src/src4.js +1 -0
  411. package/dist/src/src5.js +1 -0
  412. package/dist/src/src6.js +1 -0
  413. package/dist/src/src7.js +2 -0
  414. package/dist/src/src8.js +115 -0
  415. package/dist/src/startup-recovery-fence.js +1 -0
  416. package/dist/src/status-markers.js +1 -0
  417. package/dist/src/string-enum.js +1 -1
  418. package/dist/src/success-text.js +1 -0
  419. package/dist/src/surface-snapshot.js +1 -0
  420. package/dist/src/surface-snapshot2.js +1 -0
  421. package/dist/src/takeover.js +5 -0
  422. package/dist/src/tool-provider-facade.js +1 -0
  423. package/dist/src/tool-provider.js +4 -3
  424. package/dist/src/tool-provider2.js +1 -1
  425. package/dist/src/tool-provider3.js +1 -0
  426. package/dist/src/toolchain-probe.js +2 -0
  427. package/dist/src/touch-runtime.js +1 -0
  428. package/dist/src/transport.js +3 -0
  429. package/dist/src/tree.js +1 -0
  430. package/dist/src/ttl-memo.js +1 -0
  431. package/dist/src/tv-remote.js +1 -0
  432. package/dist/src/type-text-runtime.js +1 -0
  433. package/dist/src/undici.js +99 -0
  434. package/dist/src/update-check.js +1 -1
  435. package/dist/src/verified-file.js +1 -1
  436. package/dist/src/version.js +1 -1
  437. package/dist/src/video.js +2 -2
  438. package/dist/src/web.js +2 -1
  439. package/dist/src/web2.js +1 -0
  440. package/dist/src/webdriver-ios-snapshot.js +1 -0
  441. package/dist/src/webdriver-source.js +1 -0
  442. package/linux/atspi-dump.py +54 -9
  443. package/package.json +73 -38
  444. package/server.json +9 -3
  445. package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.9.apk.sha256 +0 -1
  446. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.9.apk +0 -0
  447. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.9.apk.sha256 +0 -1
  448. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CoordinateTextEntryTests.swift +0 -4
  449. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+FlatSnapshotFiltering.swift +0 -75
  450. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+LifecycleCacheTests.swift +0 -6
  451. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+RecordingTests.swift +0 -4
  452. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SelectorMatchPolicyTests.swift +0 -4
  453. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotTraversalIdentityTests.swift +0 -4
  454. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryPolicyTests.swift +0 -4
  455. package/dist/src/appearance.js +0 -1
  456. package/dist/src/apps.js +0 -5
  457. package/dist/src/audio-probe.js +0 -1
  458. package/dist/src/cancel.js +0 -1
  459. package/dist/src/cli-grammar.js +0 -1
  460. package/dist/src/command-catalog.js +0 -1
  461. package/dist/src/debug-symbols.js +0 -5
  462. package/dist/src/device-input-state.js +0 -2
  463. package/dist/src/device-ready.js +0 -1
  464. package/dist/src/dispatch.js +0 -1
  465. package/dist/src/handler-utils.js +0 -1
  466. package/dist/src/helper-package-install.js +0 -1
  467. package/dist/src/host-process.js +0 -3
  468. package/dist/src/ime-lifecycle.js +0 -2
  469. package/dist/src/ime-recovery-marker.js +0 -1
  470. package/dist/src/input-actions3.js +0 -1
  471. package/dist/src/install-artifact.js +0 -1
  472. package/dist/src/install-artifact2.js +0 -1
  473. package/dist/src/interaction-common.js +0 -1
  474. package/dist/src/interaction-runtime.js +0 -1
  475. package/dist/src/interaction-snapshot.js +0 -1
  476. package/dist/src/manifest.js +0 -1
  477. package/dist/src/method-scope.js +0 -1
  478. package/dist/src/png-resize.js +0 -1
  479. package/dist/src/process-lock.js +0 -1
  480. package/dist/src/runner-lease.js +0 -1
  481. package/dist/src/runner-sequence.js +0 -1
  482. package/dist/src/screenshot-geometry.js +0 -1
  483. package/dist/src/sdk-android-adb.d.ts +0 -245
  484. package/dist/src/sdk-android-adb.js +0 -4
  485. package/dist/src/sdk.js +0 -1
  486. package/dist/src/setting-state.js +0 -1
  487. package/dist/src/shell-quote.js +0 -1
  488. package/dist/src/snapshot-session.js +0 -1
  489. package/dist/src/timing-safe-equal.js +0 -1
  490. package/dist/src/unsupported-interactor.js +0 -1
  491. package/dist/src/verdict.js +0 -1
  492. /package/dist/src/{recording-telemetry.js → telemetry.js} +0 -0
@@ -0,0 +1 @@
1
+ import{x as e,y as t}from"./sdk-contracts.js";import{o as n}from"./sdk-remote-config.js";import{a as r,r as i,s as a}from"./diagnostics.js";import o from"node:path";import{constants as s}from"node:fs";import{AsyncLocalStorage as c}from"node:async_hooks";import{access as l,stat as u}from"node:fs/promises";import{spawn as d,spawnSync as f}from"node:child_process";import{Readable as p}from"node:stream";import{pipeline as m}from"node:stream/promises";const h=/^[A-Za-z0-9][A-Za-z0-9._+-]*$/,g=[`.com`,`.exe`,`.bat`,`.cmd`],_=new c;async function v(e,t){return e?await _.run(e,t):await t()}async function y(e){return await _.run(void 0,e)}async function b(e,t,n={}){let r=_.getStore()?.(e,t,n);return r?S(await r):await C(e,t,n)}async function x(e,t,n={}){let r=_.getStore()?.(e,t,n);return r?S(await r):await C(e,t,n)}function S(e){let t=typeof e.stdout==`string`?e.stdout:String(e.stdout??``),n=typeof e.stderr==`string`?e.stderr:String(e.stderr??``),r=typeof e.exitCode==`number`?e.exitCode:1;return t===e.stdout&&n===e.stderr&&r===e.exitCode?e:{...e,stdout:t,stderr:n,exitCode:r}}function C(e,t,n={}){let r=P(e),i=j();return new Promise((a,o)=>{let s=d(r,t,{cwd:n.cwd,env:n.env,stdio:[`pipe`,`pipe`,`pipe`],detached:n.detached,windowsHide:!0,shell:!1});n.onSpawn?.(s);let c=``,l=n.binaryStdout?[]:void 0,u=``,f=!1,p=Z(n.timeoutMs),m=p?setTimeout(()=>{f=!0,$(s,n.detached)},p):null,h=Q(s,n);n.binaryStdout||s.stdout.setEncoding(`utf8`),s.stderr.setEncoding(`utf8`),te(s,n.stdin).catch(i=>{h.didAbort||f||ne(i)||(o(ee(r,e,t,i)),$(s,n.detached))}),s.stdout.on(`data`,e=>{if(n.binaryStdout){l?.push(Buffer.isBuffer(e)?e:Buffer.from(e));return}let t=String(e);c+=t,n.onStdoutChunk?.(t)}),s.stderr.on(`data`,e=>{let t=String(e);u+=t,n.onStderrChunk?.(t)}),s.on(`error`,n=>{m&&clearTimeout(m),h.dispose(),i.emitForegroundCompletion(e,t),o(U(h,r,e,t,n))}),s.on(`close`,s=>{m&&clearTimeout(m),h.dispose(),i.emitForegroundCompletion(e,t);let d=s??1;if(!h.didAbort&&f&&p){o(z(r,e,t,p,d,c,u));return}let g=W(h,r,e,t,d,n.allowFailure,c,u);if(g){o(g);return}a({stdout:c,stderr:u,exitCode:d,stdoutBuffer:l?Buffer.concat(l):void 0})})})}async function w(e){let t=K(e);if(!t)return!1;if(o.isAbsolute(t))return Y(t);let n=process.env.PATH;if(!n)return!1;let r=q();for(let e of n.split(o.delimiter)){let n=e.trim();if(n){for(let e of J(t,r))if(await Y(o.join(n,e)))return!0}}return!1}async function T(e,n){let r=G(e,n,`executable`);if(r){if(!await Y(r))throw new t(`TOOL_MISSING`,`${n} points to a missing or non-executable file: ${r}`,{envName:n,path:r});return r}}async function E(e,n){let r=G(e,n,`file`);if(r){if(!await X(r))throw new t(`TOOL_MISSING`,`${n} points to a missing or non-file path: ${r}`,{envName:n,path:r});return r}}function D(e,n,r={}){let i=P(e),a=f(i,n,{cwd:r.cwd,env:r.env,stdio:[`pipe`,`pipe`,`pipe`],encoding:r.binaryStdout?void 0:`utf8`,input:r.stdin,timeout:Z(r.timeoutMs),windowsHide:!0,shell:!1,...r.maxBuffer===void 0?{}:{maxBuffer:r.maxBuffer}});if(a.error){let o=a.error.code;throw o===`ETIMEDOUT`?new t(`COMMAND_FAILED`,`${i} timed out after ${Z(r.timeoutMs)}ms`,{cmd:e,args:n,timeoutMs:Z(r.timeoutMs)},a.error):o===`ENOENT`?I(i,e,a.error):L(i,e,n,a.error)}let o=r.binaryStdout?Buffer.isBuffer(a.stdout)?a.stdout:Buffer.from(a.stdout??``):void 0,s=r.binaryStdout?``:typeof a.stdout==`string`?a.stdout:(a.stdout??``).toString(),c=typeof a.stderr==`string`?a.stderr:(a.stderr??``).toString(),l=a.status??1;if(l!==0&&!r.allowFailure)throw B(i,e,n,l,s,c);return{stdout:s,stderr:c,exitCode:l,stdoutBuffer:o}}function O(e,t,n={}){return k(e,t,n).pid}function k(e,t,n={}){let r=P(e),i=d(r,t,{cwd:n.cwd,env:n.env,stdio:n.stdio??`ignore`,detached:!0,windowsHide:!0,shell:!1}),a=i.pid??0,o=new Promise(e=>{i.once(`error`,t=>{e({pid:a,error:t.message})}),i.once(`exit`,(t,n)=>{e({pid:a,...typeof t==`number`?{exitCode:t}:{},...n?{signal:n}:{}})})});return i.unref(),{pid:a,exited:o}}function A(e,t,n={}){let r=P(e),i=j(),a=d(r,t,{cwd:n.cwd,env:n.env,stdio:n.stdio??[`ignore`,`pipe`,`pipe`],detached:n.detached,windowsHide:!0,shell:!1});i.emitBackgroundSpawn(e,t);let o=``,s=``,c=n.captureOutput??!0,l=Q(a,n);return c&&(a.stdout?.setEncoding(`utf8`),a.stderr?.setEncoding(`utf8`),a.stdout?.on(`data`,e=>{o+=e}),a.stderr?.on(`data`,e=>{s+=e})),{child:a,wait:new Promise((c,u)=>{a.on(`error`,n=>{l.dispose(),i.emitBackgroundCompletion(e,t,`error`),u(U(l,r,e,t,n))}),a.on(`close`,a=>{l.dispose(),i.emitBackgroundCompletion(e,t,`exit`);let d=a??1,f=W(l,r,e,t,d,n.allowFailure,o,s);if(f){u(f);return}c({stdout:o,stderr:s,exitCode:d})})})}}function j(){let e=r(),t=e.debug===!0,i=n(process.env.AGENT_DEVICE_EXEC_TRACE??``)===!0;if(!t&&!i)return M();i&&e.flushOnSuccess!==!0&&a({flushOnSuccess:!0});let o=Date.now(),s=!1;return{emitForegroundCompletion:(e,t)=>{s||(s=!0,N({cmd:e,args:t,startedAtMs:o}))},emitBackgroundSpawn:(e,t)=>{N({cmd:e,args:t,data:{event:`spawn`}})},emitBackgroundCompletion:(e,t,n)=>{s||(s=!0,N({cmd:e,args:t,startedAtMs:o,data:{event:n}}))}}}function M(){return{emitForegroundCompletion:()=>{},emitBackgroundSpawn:()=>{},emitBackgroundCompletion:()=>{}}}function N(e){let t=e.args.slice(0,6);i({level:`debug`,phase:`exec_command`,durationMs:e.startedAtMs===void 0?void 0:Math.max(0,Date.now()-e.startedAtMs),data:{command:e.cmd,argsPrefix:t,...e.args.length>t.length?{omittedArgCount:e.args.length-t.length}:{},...e.data??{}}})}function P(e){let n=K(e);if(!n)throw new t(`INVALID_ARGS`,`Invalid executable command: ${JSON.stringify(e)}`,{cmd:e,hint:`Use a bare command name from PATH or an absolute executable path.`});return n}function F(e,t,n,r){return r.code===`ENOENT`?I(e,t,r):L(e,t,n,r)}function I(e,n,r){return new t(`TOOL_MISSING`,`${e} not found in PATH`,{cmd:n},r)}function L(e,n,r,i){return new t(`COMMAND_FAILED`,`Failed to run ${e}`,{cmd:n,args:r},i)}function ee(e,n,r,i){return new t(`COMMAND_FAILED`,`Failed to write stdin for ${e}`,{cmd:n,args:r},i instanceof Error?i:void 0)}function R(t,n,r){return e({cmd:n,args:r,executable:t})}function z(e,n,r,i,a,o,s){return new t(`COMMAND_FAILED`,`${e} timed out after ${i}ms`,{cmd:n,args:r,stdout:o,stderr:s,exitCode:a,timeoutMs:i})}function B(e,n,r,i,a,o){return new t(`COMMAND_FAILED`,`${e} exited with code ${i}`,H({stdout:a,stderr:o,exitCode:i},{cmd:n,args:r}))}function V(e,n,r){if(e.exitCode===0)return e;throw new t(`COMMAND_FAILED`,n,H(e,typeof r==`function`?r(e):r))}function H(e,t){return{stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,processExitError:!0,...t}}function U(e,t,n,r,i){return e.didAbort?R(t,n,r):F(t,n,r,i)}function W(e,t,n,r,i,a,o,s){return e.didAbort?R(t,n,r):i!==0&&!a?B(t,n,r,i,o,s):null}function G(e,n,r){let i=e?.trim();if(i){if(!o.isAbsolute(i)||i.includes(`\0`))throw new t(`INVALID_ARGS`,`${n} must be an absolute ${r} path, not ${JSON.stringify(e)}`,{envName:n,path:e});return i}}function K(e){let t=e.trim();return!t||t.includes(`\0`)?null:o.isAbsolute(t)?t:t.includes(`/`)||t.includes(`\\`)?null:h.test(t)?t:null}function q(){if(process.platform!==`win32`)return[``];let e=process.env.PATHEXT;if(!e)return g;let t=e.split(`;`).map(e=>e.trim().toLowerCase()).filter(e=>e.length>0);return t.length>0?t:g}function J(e,t){if(process.platform!==`win32`)return[e];let n=e.toLowerCase();return t.some(e=>n.endsWith(e))?[e]:t.map(t=>`${e}${t}`)}async function Y(e){try{return await X(e)?(await l(e,process.platform===`win32`?s.F_OK:s.X_OK),!0):!1}catch{return!1}}async function X(e){try{return(await u(e)).isFile()}catch{return!1}}function Z(e){if(!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t}function Q(e,t){let n=!1,r=()=>{n=!0,$(e,t.detached)};return t.signal?.aborted?r():t.signal?.addEventListener(`abort`,r,{once:!0}),{get didAbort(){return n},dispose:()=>{t.signal?.removeEventListener(`abort`,r)}}}function $(e,t){if(t&&e.pid&&process.platform!==`win32`)try{process.kill(-e.pid,`SIGKILL`);return}catch{}e.kill(`SIGKILL`)}async function te(e,t){if(e.stdin){if(t===void 0){e.stdin?.end();return}await m(p.from([t]),e.stdin)}}function ne(e){return e instanceof Error&&`code`in e&&e.code===`EPIPE`}export{T as a,A as c,x as d,D as f,y as h,V as i,O as l,v as m,H as n,E as o,w as p,Y as r,b as s,S as t,k as u};
@@ -0,0 +1 @@
1
+ import{y as e}from"./sdk-contracts.js";import{D as t,t as n}from"./owner-identity.js";import{t as r}from"./timeouts.js";import i from"node:path";import a from"node:fs";async function o(t){let{lockDirPath:n,owner:o}=t,l=i.join(n,`owner.json`),d=Date.now()+(t.timeoutMs??3e4),f=t.pollMs??100,p=t.ownerGraceMs??5e3,m=t.description??`process lock`;for(a.mkdirSync(i.dirname(n),{recursive:!0});Date.now()<d;)try{a.mkdirSync(n),s(l,o);let e=!1;return async()=>{e||(e=!0,a.rmSync(n,{recursive:!0,force:!0}))}}catch(e){let t=e;if(t.code!==`EEXIST`)throw t;if(c(n,l,p))continue;await r(f)}throw new e(`COMMAND_FAILED`,`Timed out waiting for ${m}`,{lockDirPath:n,...u(n,l)})}function s(e,n){t({destination:e,contents:JSON.stringify(n)})}function c(e,t,n){let r=null;try{r=a.statSync(e)}catch{return!0}let i=l(t);return i?!d(i)&&(a.rmSync(e,{recursive:!0,force:!0}),!0):Date.now()-r.mtimeMs<n?!1:(a.rmSync(e,{recursive:!0,force:!0}),!0)}function l(e){try{return JSON.parse(a.readFileSync(e,`utf8`))}catch{return null}}function u(e,t){let r=Date.now(),i=l(t),o;try{o=Math.max(0,Math.round(r-a.statSync(e).mtimeMs))}catch{}return{...o===void 0?{}:{lockAgeMs:o},...i?{ownerPid:i.pid,ownerStartTime:i.startTime,ownerAgeMs:Math.max(0,Math.round(r-i.acquiredAtMs)),ownerLiveness:n({owner:i})}:{}}}function d(e){let t=n({owner:e});return t!==`owner-process-dead`&&t!==`owner-process-reused`}export{o as t};
package/dist/src/find.js CHANGED
@@ -1 +1 @@
1
- import{u as e}from"./sdk-contracts.js";import{_n as t,fn as n,mn as r,pn as i}from"./sdk-batch-runner.js";import{Bt as a,G as o,J as s,U as c,Vt as l,ct as u,q as d,vt as f}from"./prepare-kind.js";import"./screenshot-result.js";import{t as p}from"./verdict.js";import{a as m,o as h,t as g}from"./dispatch.js";import{Gt as _,Pt as v,Wt as y}from"./internal/daemon.js";import{o as b,s as x,t as S}from"./selector-runtime.js";import{t as C}from"./handler-utils.js";function w(e){if(e.ambiguity!==`reject-candidates`)throw Error(`find's resolution policy must reject candidates, got "${e.ambiguity}"`)}async function T(e){let{req:i,sessionName:a,logPath:s,sessionStore:c,invoke:l}=e,d=i.command;if(d!==`find`)return null;let f=n(i.positionals??[],i.flags);if(!f.ok)return m(f.code,f.message);let{locator:g,query:_,action:v,value:y}=f.parsed;if(i.flags?.record&&!r(v))return m(`INVALID_ARGS`,`find ${v} is a mutating action and is always recorded; --record only applies to a read-only find (exists, wait, list, get text, get attrs).`);let b=await S({req:i,sessionName:a,logPath:s,sessionStore:c});if(b)return b;let C=c.get(a);if(!C)return h();let w=C.device,T=t(g,_),A=D({device:w,session:C,req:i,logPath:s,locator:g,query:_,sessionStore:c,sessionName:a}),j={req:i,sessionName:a,logPath:s,sessionStore:c,invoke:l,session:C,device:w,command:d,locator:g,query:_,publicFlags:W(i.flags)},M=await A();if(p(M.snapshotQuality))return O(M.snapshotQuality);let{nodes:N}=M,P=k({nodes:N,locator:g,query:_,selectorExpression:T,flags:i.flags,platform:w.platform});if(!P.ok)return x(P.response,M);let F=P.node,I=await o(u.findAct,N,F),L=I.node,R=await E(j,{node:F,resolvedNode:L,ref:`@${L.ref}`,nodes:N,actionFlags:{...i.flags??{},noRecord:!0},...I.kind===`occluded`?{occludedNode:I.node}:{}},v,y);return R&&x(R,M)}async function E(e,t,n,r){let i={click:()=>L(e,t),fill:()=>R(e,t,r),focus:()=>z(e,t),type:()=>B(e,t,r)}[n];return i?await i():null}function D(e){let{device:t,session:n,req:r,logPath:i,locator:a,query:o}=e,{sessionStore:s,sessionName:c}=e,l=b({device:t,session:n,sessionStore:s,sessionName:c,req:r,logPath:i});return async()=>{let{snapshot:e}=await l.capture({flags:{...r.flags,snapshotInteractiveOnly:!0},recovery:{legacyIosSparse:{query:o,shouldScope:K(a)},sparseVerdictQueryScope:{query:o,shouldScope:K(a)}}});return{nodes:e.nodes,snapshotQuality:e.snapshotQuality,systemSurfaceOnly:e.systemSurfaceOnly}}}function O(e){return m(`COMMAND_FAILED`,`find could not read the current accessibility tree`,{reason:e.reason,hint:`The snapshot quality verdict is sparse. Use screenshot as visual truth, navigate with coordinates if needed, then retry find after reaching a readable screen.`})}function k(e){let{nodes:t,locator:n,query:r,selectorExpression:a,flags:o,platform:s}=e,l=u.findAct,f=t.filter(e=>!d(e,t[0])),p=l.resolution,h;if(h=a?c(l,f,a,{platform:s}).list?.matchedNodes??[]:i(f,n,r,{requireRect:p.requireRect}).matches,h=j(h,t),h.length>1){w(p);let e=A(h,o);if(!e)return{ok:!1,response:G(h,n,r)};h=e}let g=h[0]??null;return g?{ok:!0,node:g}:{ok:!1,response:m(`COMMAND_FAILED`,`find did not match any element`)}}function A(e,t){return t?.findFirst?[e[0]]:t?.findLast?[e[e.length-1]]:null}function j(t,n){let r=n[0]?.rect;if(!r)return t;let i=t.filter(t=>{if(!t.rect)return!1;let n=e(t.rect);return n.x>=r.x&&n.x<=r.x+r.width&&n.y>=r.y&&n.y<=r.y+r.height});return M(i.length>0?i:t,n)}function M(e,t){return e.length<2?e:e.map((e,n)=>({node:e,index:n,score:N(e,t)})).sort((e,t)=>t.score===e.score?F(e.node)-F(t.node)||e.index-t.index:t.score-e.score).map(e=>e.node)}function N(e,t){let n=s(t,e);if(n.reason===`covered`)return 0;let r=P(n,t[0]);return r>0?r:e.hittable&&e.rect&&!d(e,t[0])?3:+!!e.rect}function P(e,t){return e.node.rect?e.reason===`semantic-target`||e.reason===`same-rect-descendant`?4:e.reason===`hittable-ancestor`&&!d(e.node,t)?2:0:0}function F(e){return e.rect?e.rect.width*e.rect.height:1/0}function I(e){return{ref:e.ref,node:e.resolvedNode,nodes:e.nodes}}async function L(t,n){let{req:r,sessionName:i,sessionStore:o,session:s,invoke:c,command:u,locator:d,query:f,publicFlags:p}=t,m=await c({token:r.token,session:i,command:`click`,positionals:[n.ref],flags:n.actionFlags,internal:{findResolvedTarget:I(n)}});if(!m.ok)return m;let h=n.resolvedNode.rect?e(n.resolvedNode.rect):n.node.rect?e(n.node.rect):null,g={ref:n.ref,locator:d,query:f};h&&(g.x=h.x,g.y=h.y);let _=a(m.data)??`Tapped ${n.ref}${h?` (${h.x}, ${h.y})`:``}`;return Object.assign(g,l(_)),C(o,s,r,u,{ref:n.ref,action:`click`,locator:d,query:f},{flags:p}),{ok:!0,data:g}}async function R(e,t,n){let{req:r,sessionName:i,sessionStore:a,session:o,invoke:s,command:c,publicFlags:l}=e;if(!n)return m(`INVALID_ARGS`,`find fill requires text`);let u=await s({token:r.token,session:i,command:`fill`,positionals:[t.ref,n],flags:t.actionFlags,internal:{findResolvedTarget:I(t)}});return u.ok&&C(a,o,r,c,{ref:t.ref,action:`fill`},{flags:l}),u}async function z(e,t){let n=await V(e,t);return n.ok&&U(e,t,`focus`),n}async function B(e,t,n){let{req:r,device:i,logPath:a,session:o}=e;if(!n)return m(`INVALID_ARGS`,`find type requires text`);let s=await V(e,t);if(!s.ok)return s;v(o);let c=await g(i,`type`,[n],r.flags?.out,{..._(a,r.flags,o.appBundleId,o.trace?.outPath)});return U(e,t,`type`),{ok:!0,data:c??{ref:t.ref}}}async function V(t,n){let{req:r,device:i,logPath:a,session:o}=t,s=H(n,`be focused`);if(s)return s;let c=n.resolvedNode.rect?e(n.resolvedNode.rect):null;return c?(v(o),{ok:!0,data:await g(i,`focus`,[String(c.x),String(c.y)],r.flags?.out,{..._(a,r.flags,o.appBundleId,o.trace?.outPath)})??{ref:n.ref}}):m(`COMMAND_FAILED`,`matched element has no bounds`)}function H(e,t){let n=e.occludedNode;return n?m(`COMMAND_FAILED`,`Matched element ${e.ref} is covered by another visible element and cannot ${t} safely`,{ref:`@${n.ref}`,interactionBlocked:n.interactionBlocked,hint:`Use a different visible target, scroll it clear of the overlay, or inspect with snapshot/screenshot before retrying.`}):null}function U(e,t,n){let{req:r,sessionStore:i,session:a,command:o,publicFlags:s}=e;C(i,a,r,o,{ref:t.ref,action:n},{flags:s})}function W(e){return{...y(e)??{}}}function G(e,t,n){let r={matches:e.length,candidates:e.slice(0,5).map(e=>f(e,0,!1))};return m(`AMBIGUOUS_MATCH`,`find matched ${e.length} elements for ${t} "${n}". Use a more specific locator or selector.`,{locator:t,query:n,...r})}function K(e){return e!==`role`}export{G as buildAmbiguousMatchError,T as handleFindCommands};
1
+ import{d as e}from"./sdk-contracts.js";import{Dn as t,Mn as n,On as r,Pt as i,kn as a,mt as o}from"./sdk-batch.js";import{c as s}from"./session-store.js";import{f as c,g as l,h as u,m as d,y as f}from"./runtime.js";import{n as p,t as m}from"./success-text.js";import{d as h}from"./app-inventory-contract.js";import{a as g,i as _}from"./request-runtime-binding.js";import{C as v,b as y,y as b}from"./session-snapshot.js";import{t as x}from"./snapshot-quality-verdict.js";import{t as S}from"./internal/daemon.js";import{t as C}from"./snapshot-runtime-binding.js";import{l as w,n as T,u as E}from"./selector-runtime.js";import{t as D}from"./type-text-runtime.js";function O(t,n){let r=n[0]?.rect;if(!r)return t;let i=t.filter(t=>{if(!t.rect)return!1;let n=e(t.rect);return n.x>=r.x&&n.x<=r.x+r.width&&n.y>=r.y&&n.y<=r.y+r.height}),a=i.length>0?i:t;return a.length<2?a:k(a,n,u(n))}function k(e,t,n){return e.map((e,r)=>({node:e,index:r,score:A(e,t,n)})).sort((e,t)=>t.score===e.score?M(e.node)-M(t.node)||e.index-t.index:t.score-e.score).map(e=>e.node)}function A(e,t,n){let r=n(e);if(r.reason===`covered`)return 0;let i=j(r,t[0]);return i>0?i:e.hittable&&e.rect&&!l(e,t[0])?3:+!!e.rect}function j(e,t){return e.node.rect?e.reason===`semantic-target`||e.reason===`same-rect-descendant`?4:e.reason===`hittable-ancestor`&&!l(e.node,t)?2:0:0}function M(e){return e.rect?e.rect.width*e.rect.height:1/0}function N(e,t,n){let r={matches:e.length,candidates:e.slice(0,5).map(e=>h(e,0,!1))};return _(`AMBIGUOUS_MATCH`,`find matched ${e.length} elements for ${t} "${n}". Use a more specific locator or selector.`,{locator:t,query:n,...r})}function P(e){if(e.ambiguity!==`reject-candidates`)throw Error(`find's resolution policy must reject candidates, got "${e.ambiguity}"`)}function F(e){let{nodes:t,locator:n,query:i,selectorExpression:a,flags:o,platform:s}=e,u=f.findAct,d=t.filter(e=>!l(e,t[0])),p=u.resolution,m;if(m=a?c(u,d,a,{platform:s}).list?.matchedNodes??[]:r(d,n,i,{requireRect:p.requireRect}).matches,m=O(m,t),m.length>1){P(p);let e=I(m,o);if(!e)return{ok:!1,response:N(m,n,i)};m=e}let h=m[0]??null;return h?{ok:!0,node:h}:{ok:!1,response:_(`COMMAND_FAILED`,`find did not match any element`)}}function I(e,t){return t?.findFirst?[e[0]]:t?.findLast?[e.at(-1)]:null}function L(e){let{device:t,session:n,req:r,logPath:i,locator:a,query:o,sessionStore:s,sessionName:c}=e,l=w({device:t,session:n,sessionStore:s,sessionName:c,req:r,logPath:i,capture:e.capture});return async()=>{let{snapshot:e}=await l.capture({flags:{...r.flags,snapshotInteractiveOnly:!0},recovery:{legacyIosSparse:{query:o,shouldScope:z(a)},sparseVerdictQueryScope:{query:o,shouldScope:z(a)}}});return{nodes:e.nodes,snapshotQuality:e.snapshotQuality,systemSurfaceOnly:e.systemSurfaceOnly}}}function R(e){return _(`COMMAND_FAILED`,`find could not read the current accessibility tree`,{reason:e.reason,hint:`The snapshot quality verdict is sparse. Use screenshot as visual truth, navigate with coordinates if needed, then retry find after reaching a readable screen.`})}function z(e){return e!==`role`}async function B(e){let{req:r,sessionName:s,logPath:c,sessionStore:l,invoke:u}=e,p=r.command;if(p!==`find`)return null;let m=r.positionals??[],h=t(m,r.flags);if(!h.ok)return _(h.code,h.message);let{locator:v,query:y,action:b,value:S}=h.parsed;if(r.flags?.record&&!a(b))return _(`INVALID_ARGS`,`find ${b} is a mutating action and is always recorded; --record only applies to a read-only find (exists, wait, list, get text, get attrs).`);let w=await T({req:r,sessionName:s,logPath:c,sessionStore:l,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice});if(w)return w;let D=l.get(s);if(!D)return g();let O=D.device,k=await C({command:`find`,device:O,session:D,plan:i({hasActiveApp:D.appBundleId!==void 0,intent:o(b)}),inspectFacts:e.inspectFacts,bindDevice:e.bindDevice});if(!k.ok)return k.response;let A=n(v,y),j=L({device:O,session:D,req:r,logPath:c,locator:v,query:y,sessionStore:l,sessionName:s,capture:k.capture}),M={req:r,sessionName:s,logPath:c,sessionStore:l,invoke:u,session:D,device:O,command:p,locator:v,query:y,publicFlags:X(r.flags),boundFocusPoint:k.focusPoint,boundTypeText:k.typeText},N=await j();if(x(N.snapshotQuality))return R(N.snapshotQuality);let{nodes:P}=N,I=F({nodes:P,locator:v,query:y,selectorExpression:A,flags:r.flags,platform:O.platform});if(!I.ok)return E(I.response,N);let z=I.node,B=await d(f.findAct,P,z),H=B.node,U=await V(M,{node:z,resolvedNode:H,ref:`@${H.ref}`,nodes:P,actionFlags:{...r.flags??{},noRecord:!0},...B.kind===`occluded`?{occludedNode:B.node}:{}},b,S);return U&&E(U,N)}async function V(e,t,n,r){let i={click:()=>U(e,t),fill:()=>W(e,t,r),focus:()=>G(e,t),type:()=>K(e,t,r)}[n];return i?await i():null}function H(e){return{ref:e.ref,node:e.resolvedNode,nodes:e.nodes}}async function U(t,n){let{req:r,sessionName:i,sessionStore:a,session:o,invoke:c,command:l,locator:u,query:d,publicFlags:f}=t,h=await c({token:r.token,session:i,command:`click`,positionals:[n.ref],flags:n.actionFlags,internal:{findResolvedTarget:H(n)}});if(!h.ok)return h;let g=n.resolvedNode.rect?e(n.resolvedNode.rect):n.node.rect?e(n.node.rect):null,_={ref:n.ref,locator:u,query:d};g&&(_.x=g.x,_.y=g.y);let v=m(h.data)??`Tapped ${n.ref}${g?` (${g.x}, ${g.y})`:``}`;return Object.assign(_,p(v)),s(a,o,r,l,{ref:n.ref,action:`click`,locator:u,query:d},{flags:f}),{ok:!0,data:_}}async function W(e,t,n){let{req:r,sessionName:i,sessionStore:a,session:o,invoke:c,command:l,publicFlags:u}=e;if(n===void 0)return _(`INVALID_ARGS`,`find fill requires text (use "" to clear the field)`);let d=await c({token:r.token,session:i,command:`fill`,positionals:[t.ref,n],flags:t.actionFlags,internal:{findResolvedTarget:H(t)}});return d.ok&&s(a,o,r,l,{ref:t.ref,action:`fill`},{flags:u}),d}async function G(e,t){let n=await q(e,t);return n.ok&&Y(e,t,`focus`),n}async function K(e,t,n){let{req:r,logPath:i,session:a}=e;if(!n)return _(`INVALID_ARGS`,`find type requires text`);let o=await q(e,t);if(!o.ok)return o;v(a);let s=e.boundTypeText;if(!s)return _(`COMMAND_FAILED`,`find type was admitted without a text-entry operation`);let c=await D({operations:{typeText:s}},[n],y(i,r.flags,a.appBundleId,a.trace?.outPath));return Y(e,t,`type`),{ok:!0,data:c??{ref:t.ref}}}async function q(t,n){let{req:r,logPath:i,session:a}=t,o=J(n,`be focused`);if(o)return o;let s=n.resolvedNode.rect?e(n.resolvedNode.rect):null;if(!s)return _(`COMMAND_FAILED`,`matched element has no bounds`);v(a);let c=t.boundFocusPoint;return c?{ok:!0,data:await S({operations:{focusPoint:c}},s,y(i,r.flags,a.appBundleId,a.trace?.outPath))??{ref:n.ref}}:_(`COMMAND_FAILED`,`find focus was admitted without a focus operation`)}function J(e,t){let n=e.occludedNode;return n?_(`COMMAND_FAILED`,`Matched element ${e.ref} is covered by another visible element and cannot ${t} safely`,{ref:`@${n.ref}`,interactionBlocked:n.interactionBlocked,hint:`Use a different visible target, scroll it clear of the overlay, or inspect with snapshot/screenshot before retrying.`}):null}function Y(e,t,n){let{req:r,sessionStore:i,session:a,command:o,publicFlags:c}=e;s(i,a,r,o,{ref:t.ref,action:n},{flags:c})}function X(e){return{...b(e)??{}}}export{B as handleFindCommands};
@@ -1 +1 @@
1
- import{gn as e}from"./sdk-batch-runner.js";import{t}from"./sdk-finders.js";export{t as findBestMatchesByLocator,e as parseFindArgs};
1
+ import{jn as e}from"./sdk-batch.js";import{t}from"./sdk-finders.js";export{t as findBestMatchesByLocator,e as parseFindArgs};
@@ -0,0 +1,2 @@
1
+ import{y as e}from"./sdk-contracts.js";import{t}from"./script.js";import n from"node:path";function r(e){return e.startsWith(`AD_`)}function i(t){return new e(`INVALID_ARGS`,`The AD_* namespace is reserved for built-in variables. Rename ${t} to avoid the AD_ prefix.`)}function a(e){let t={};if(e.builtins)for(let[n,r]of Object.entries(e.builtins))t[n]=r;let n=[e.fileEnv,e.shellEnv,e.cliEnv];for(let e of n)if(e)for(let[n,a]of Object.entries(e)){if(r(n))throw i(n);t[n]=a}return{values:t,expandedBuiltinNames:new Set}}function o(e){let n={};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)&&(r(e)||(n[e]=a))}return n}function s(n){let a={};for(let o of n){let n=o.indexOf(`=`);if(n<=0)throw new e(`INVALID_ARGS`,`Invalid -e entry "${o}": expected KEY=VALUE.`);let s=o.slice(0,n);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(r(s))throw i(s);a[s]=o.slice(n+1)}return a}function c(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function l(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 u(e){return e>=`A`&&e<=`Z`||e>=`a`&&e<=`z`||e===`_`}function d(e){return u(e)||e>=`0`&&e<=`9`||e===`.`}function f(e){return e===`
2
+ `||e===`\r`||e===`\u2028`||e===`\u2029`}function p(e,t){let n=t+2;if(n>=e.length||!u(e[n]))return null;for(n+=1;n<e.length&&d(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(f(t))return{abortEnd:n+2};i+=t,n+=2;continue}i+=t,n+=1}return{abortEnd:e.length}}function m(t,n,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=p(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(n.values,t))r(t)&&(n.expandedBuiltinNames??=new Set).add(t),a+=String(n.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 h(e,t,n){return{...e,positionals:(e.positionals??[]).map(e=>m(e,t,n)),flags:g(e.flags,t,n)??{},runtime:g(e.runtime,t,n)}}function g(e,t,n){return e&&_(e,t,n)}function _(e,t,n){return typeof e==`string`?m(e,t,n):Array.isArray(e)?e.map(e=>_(e,t,n)):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).map(([e,r])=>[e,_(r,t,n)])):e}function v(e){return Object.entries(e.values).filter(([t,n])=>n.length>0&&(!r(t)||e.expandedBuiltinNames?.has(t))).map(([e,t])=>({name:e,value:t})).sort((e,t)=>t.value.length-e.value.length)}function y(e){let t=n.extname(e).toLowerCase();return t===`.yaml`||t===`.yml`}function b(e,t){return`Maestro YAML requires explicit --maestro routing: ${e} ${t} --maestro`}function x(e,t){return t===`maestro`&&y(e)?`maestro`:`ad`}export{v as a,c,a as i,l,b as n,o,x as r,s,y as t,h as u};
@@ -1 +1 @@
1
- import{p as e}from"./sdk-batch-runner.js";import{Dt as t}from"./internal/daemon.js";import{C as n,x as r}from"./selector-runtime.js";import{t as i}from"./interaction-runtime.js";import{t as a}from"./interaction-snapshot.js";function o(t){if(!e(t.command))return{};let i=n(t.command,t.flags);if(i)return{response:i};let a=r(t.flags);if(!a)return{};let o=t.session.snapshot?.nodes??[];return{observe:async()=>await s(t,a,o)}}async function s(e,n,r){let i=c(e);if(!i)return;let a=await i.interactions.settleObservation({...n,baselineNodes:r,session:e.sessionName,requestId:e.req.meta?.requestId}),o=t(e.session,a);return o===void 0?a:{...a,refsGeneration:o}}function c(e){try{return i({req:e.req,sessionName:e.sessionName,logPath:e.logPath,sessionStore:e.sessionStore,contextFromFlags:e.contextFromFlags,captureSnapshotForSession:a})}catch{return}}export{o as planGenericSettleObservation};
1
+ import{f as e}from"./sdk-batch.js";import{t}from"./session-snapshot.js";import{i as n,r}from"./interaction-ref-policy.js";import{captureSnapshotForSession as i,createInteractionRuntime as a}from"./interaction.js";function o(t){if(!e(t.command))return{};let i=n(t.command,t.flags);if(i)return{response:i};let a=r(t.flags);if(!a)return{};let o=t.session.snapshot?.nodes??[];return{observe:async()=>await s(t,a,o)}}async function s(e,n,r){let i=c(e);if(!i)return;let a=await i.interactions.settleObservation({...n,baselineNodes:r,session:e.sessionName,requestId:e.req.meta?.requestId}),o=t(e.session,a);return o===void 0?a:{...a,refsGeneration:o}}function c(e){try{return a({req:e.req,sessionName:e.sessionName,logPath:e.logPath,sessionStore:e.sessionStore,contextFromFlags:e.contextFromFlags,captureSnapshotForSession:i})}catch{return}}export{o as planGenericSettleObservation};
@@ -1 +1 @@
1
- import{a as e}from"./sdk-contracts.js";import{Bt as t}from"./prepare-kind.js";import{t as n}from"./shared.js";import{n as r}from"./cli-runner.js";async function i({command:t,positionals:i,flags:s,client:c,debug:l,replayTestReporterRuntime:u}){let{result:d,cliOutput:f}=await r({client:c,command:t,positionals:i,flags:s});if(e(s.responseLevel))return n(s,d,()=>JSON.stringify(d,null,2)),!0;if(f)o(s,f);else{let e=await a(t,s,d,{debug:l,replayTestReporterRuntime:u});e!==0&&process.exit(e)}return!0}function a(e,r,i,a={}){return e===`test`?import(`./reporting.js`).then(({renderReplayTestResponse:e})=>e({suite:i,debug:a.debug,verbose:r.verbose,json:r.json,reporter:r.reporter,reportJunit:r.reportJunit,reporterRuntime:a.replayTestReporterRuntime})):(n(r,i,()=>t(i)),0)}function o(e,t){!e.json&&t.stderr&&process.stderr.write(t.stderr),n(e,e.json?t.jsonData??t.data:t.data,()=>t.text)}export{i as runGenericClientBackedCommand};
1
+ import{a as e}from"./sdk-contracts.js";import{t}from"./success-text.js";import{t as n}from"./shared.js";import{n as r}from"./cli-runner.js";async function i({command:t,positionals:i,flags:s,client:c,debug:l,replayTestReporterRuntime:u,commandProgress:d}){let{result:f,cliOutput:p}=await r({client:c,command:t,positionals:i,flags:s,commandProgress:d});if(e(s.responseLevel))return await n(s,f,()=>JSON.stringify(f,null,2)),!0;if(p)await o(s,p);else{let e=await a(t,s,f,{debug:l,replayTestReporterRuntime:u});e!==0&&process.exit(e)}return!0}async function a(e,r,i,a={}){return e===`test`?import(`./reporting.js`).then(({renderReplayTestResponse:e})=>e({suite:i,debug:a.debug,verbose:r.verbose,json:r.json,reporter:r.reporter,reportJunit:r.reportJunit,reporterRuntime:a.replayTestReporterRuntime})):(await n(r,i,()=>t(i)),0)}async function o(e,t){!e.json&&t.stderr&&process.stderr.write(t.stderr),await n(e,e.json?t.jsonData??t.data:t.data,()=>t.text)}export{i as runGenericClientBackedCommand};
@@ -0,0 +1 @@
1
+ import{S as e,c as t}from"./sdk-device.js";const n={ios:`iOS`,ipados:`iPadOS`,tvos:`tvOS`,watchos:`watchOS`,visionos:`visionOS`,macos:`macOS`},r=`Target-authored drag requires an adapter that preserves source hold, timed movement, and destination hold; it is supported on Android touch devices and iOS/iPadOS.`,i=`Android TV has no touch input — this gesture is supported on Android phones, tablets, and the iOS simulator only.`,a=`Two-finger gesture synthesis is iOS-simulator only — not available on physical iOS devices.`;function o(e,t){return(t===`multi-touch`?s(e):t===`directional-fling`&&e.platform===`linux`?`Linux`:void 0)??e.appleOs??e.platform}function s(r){if(r.platform===`android`)return r.target===`tv`?`Android TV`:void 0;if(!t(r.platform))return;let i=e(r);if(i===`ios`||i===`ipados`)return`physical iOS devices`;if(i===`macos`||i===`tvos`||i===`visionos`)return n[i]}function c(e,t,n){return`gesture ${n} is not supported on ${o(e,t)}`}export{c as a,r as i,n,a as r,i as t};
@@ -0,0 +1 @@
1
+ const e=1e4;export{e as t};
@@ -0,0 +1 @@
1
+ import{y as e}from"./sdk-contracts.js";import{d as t,u as n}from"./scroll-gesture.js";import{t as r}from"./gesture-plan-types.js";const i={pinchAxisDegrees:-90,samplingProfile:`default`},a={ios:i,macos:i,android:{pinchAxisDegrees:0,samplingProfile:`android`},harmonyos:i,vega:i,linux:i,web:i};function o(e,t,n){let r=b(t),i=N(n);switch(e.intent){case`fling`:return u(e,r);case`pan`:return d(e,r,i);case`pinch`:return p({intent:`pinch`,origin:e.origin??k(r),delta:{x:0,y:0},scale:D(e.scale,`gesture pinch scale`),rotationDegrees:0,durationMs:300},r,i);case`rotate`:{let t=E(e.degrees,`gesture rotate degrees`);return p({intent:`rotate`,origin:e.origin??k(r),delta:{x:0,y:0},scale:1,rotationDegrees:t,durationMs:w(t)},r,i)}case`transform`:{let t=E(e.degrees,`gesture transform degrees`);return p({intent:`transform`,origin:e.origin,delta:e.delta,scale:D(e.scale,`gesture transform scale`),rotationDegrees:t,durationMs:x(e.durationMs,w(t),`gesture transform durationMs`)},r,i)}}}function s(e){let[{samples:t}]=e.pointers,n=t[0],r=t.at(-1);return{start:n.point,end:r.point}}function c(t,n){let i=b(n),a=S(t.sourceHoldMs,800,`gesture drag sourceHoldMs`),o=x(t.moveMs,500,`gesture drag moveMs`),s=C(t.destinationHoldMs,0,`gesture drag destinationHoldMs`);if(a+o+s>1e4)throw new e(`INVALID_ARGS`,`gesture drag total duration must be at most ${r}`);return l(f(`pan`,t.from,t.to,o,i,`timed-pan`),a,s)}function l(e,t,n){let r=e.pointers[0],[i,a]=r.samples,o=t+e.durationMs+n,s=[{offsetMs:0,point:i.point},{...i,offsetMs:i.offsetMs+t},{...a,offsetMs:a.offsetMs+t},...n>0?[{offsetMs:o,point:a.point}]:[]];return{...e,durationMs:o,pointers:[{...r,samples:s}]}}function u(e,n){if(`preset`in e){let{from:t,to:r}=M(e.preset,n);return f(`fling`,t,r,100,n,`endpoint-hold`)}if(`from`in e)return f(`fling`,e.from,e.to,100,n,`endpoint-hold`);let r=T(e.origin,`gesture fling origin`),i=O(e.distance??180,`gesture fling distance`);return f(`fling`,r,A(r,t(e.direction,i)),100,n,`endpoint-hold`)}function d(t,n,r){let i=x(t.durationMs,500,`gesture pan durationMs`);if((t.pointerCount??1)===1){let e=T(t.origin,`gesture pan origin`);return f(`pan`,e,A(e,T(t.delta,`gesture pan delta`)),i,n,t.executionProfile??`timed-pan`)}if(t.pointerCount!==2)throw new e(`INVALID_ARGS`,`gesture pan pointerCount must be 1 or 2`);return p({intent:`pan`,origin:t.origin,delta:t.delta,scale:1,rotationDegrees:0,durationMs:i},n,r)}function f(e,t,n,r,i,a){let o=T(t,`gesture ${e} start`),s=T(n,`gesture ${e} end`),c=[{offsetMs:0,point:o},{offsetMs:r,point:s}];return v(c,i,{intent:e,pointerId:0}),{topology:`single`,intent:e,executionProfile:a,durationMs:r,viewport:i,pointers:[{pointerId:0,samples:c}]}}function p(e,t,n){let r=T(e.origin,`gesture ${e.intent} origin`),i=A(r,T(e.delta,`gesture ${e.intent} delta`)),a=Math.min(t.width,t.height)*g(e.intent),o=e.scale>1?a/e.scale:a,s=o*e.scale;if(Math.min(o,s)<48)throw y({intent:e.intent,viewport:t,initialSpan:o,finalSpan:s,minimumReliableSpan:48});let c=o/2,l=_(e.durationMs,n.samplingProfile),u=(a,o)=>{let s=l.map(t=>({offsetMs:t,point:m({...e,start:r,end:i,initialRadius:c,offsetMs:t,side:o,profile:n})}));return v(s,t,{intent:e.intent,pointerId:a}),{pointerId:a,samples:s}};return{topology:`two`,intent:e.intent,durationMs:e.durationMs,viewport:t,pointers:[u(0,1),u(1,-1)]}}function m(e){let t=e.offsetMs/e.durationMs,n=j(e.start,e.end,t),r=e.initialRadius*(1+(e.scale-1)*t),i=P(h(e.intent,e.profile)+e.rotationDegrees*t);return{x:n.x+Math.cos(i)*r*e.side,y:n.y+Math.sin(i)*r*e.side}}function h(e,t){return e===`pinch`?t.pinchAxisDegrees:-90}function g(e){return e===`pinch`?.4:.25}function _(t,n){if(!Number.isFinite(t)||t<=0)throw new e(`INVALID_ARGS`,`gesture sample duration must be a positive finite number`);let r=t/16,i=Math.max(3,n===`android`?Math.round(r):Math.floor(r));return Array.from({length:i+1},(e,n)=>Math.round(t*n/i))}function v(t,n,r){let i=n.x+n.width-1,a=n.y+n.height-1;for(let o of t){let{x:t,y:s}=o.point;if(!Number.isFinite(t)||!Number.isFinite(s))throw new e(`INVALID_ARGS`,`Gesture motion produces non-finite pointer coordinates`,{...r,reason:`GESTURE_TRAJECTORY_NON_FINITE`,hint:`Reduce the requested rotation, translation, or scale.`});if(t<n.x+1||t>i||s<n.y+1||s>a)throw y({...r,viewport:n,sample:o})}}function y(t){return new e(`INVALID_ARGS`,`Gesture trajectory does not fit inside the viewport`,{...t,reason:`GESTURE_TRAJECTORY_OUT_OF_BOUNDS`,hint:`Move the gesture away from the edge or reduce its translation, scale, or rotation.`})}function b(t){let n={x:E(t.x,`gesture viewport x`),y:E(t.y,`gesture viewport y`),width:E(t.width,`gesture viewport width`),height:E(t.height,`gesture viewport height`)};if(n.width<=0||n.height<=0)throw new e(`INVALID_ARGS`,`gesture viewport width and height must be positive`);return n}function x(t,n,i){let a=t??n;if(!Number.isInteger(a)||a<16||a>1e4)throw new e(`INVALID_ARGS`,`${i} must be an integer between 16 and ${r}`);return a}function S(t,n,i){let a=t??n;if(!Number.isInteger(a)||a<1||a>1e4)throw new e(`INVALID_ARGS`,`${i} must be an integer between 1 and ${r}`);return a}function C(t,n,i){let a=t??n;if(!Number.isInteger(a)||a<0||a>1e4)throw new e(`INVALID_ARGS`,`${i} must be an integer between 0 and ${r}`);return a}function w(e){let t=Math.ceil(Math.abs(e)/3)*16;return Math.min(Math.max(300,t),2400)}function T(e,t){return{x:E(e.x,`${t} x`),y:E(e.y,`${t} y`)}}function E(t,n){if(!Number.isFinite(t))throw new e(`INVALID_ARGS`,`${n} must be a finite number`);return t}function D(t,n){let r=E(t,n);if(r<=0)throw new e(`INVALID_ARGS`,`${n} must be greater than 0`);return r}function O(t,n){let r=E(t,n);if(r<=0)throw new e(`INVALID_ARGS`,`${n} must be a positive number`);return r}function k(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function A(e,t){return{x:e.x+t.x,y:e.y+t.y}}function j(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function M(e,t){let r=n(e,{referenceWidth:t.width,referenceHeight:t.height});return{from:{x:t.x+r.x1,y:t.y+r.y1},to:{x:t.x+r.x2,y:t.y+r.y2}}}function N(e){return e===void 0?i:a[e]}function P(e){return e*Math.PI/180}export{s as a,_ as i,o as n,j as r,c as t};
@@ -0,0 +1 @@
1
+ import{O as e,y as t}from"./sdk-contracts.js";import{gt as n,jt as r}from"./sdk-batch.js";import{h as i,m as a,p as o}from"./session-snapshot.js";import{a as s}from"./gesture-admission.js";async function c(e){let t=await i({command:`runtime gesture-viewport`,device:e.device,use:n,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice});return t.type===`response`?{ok:!1,response:t.response}:{ok:!0,read:d(t.runtime).gestureViewport}}async function l(n){let i=r(n.input),o=await a({command:`gesture`,device:n.device,required:i.use.required,inspectFacts:n.inspectFacts,bindDevice:n.bindDevice,unavailableResponse:r=>({ok:!1,error:e(new t(`UNSUPPORTED_OPERATION`,s(n.device,i.tier,n.input.intent),{gesture:n.input.intent,...r.hint===void 0?{}:{hint:r.hint}}))})});return o.type===`response`?{ok:!1,response:o.response}:{ok:!0,gestures:await u(o.bind,n.device,i)}}async function u(e,t,n){switch(n.tier){case`plan`:{let r=await e(t,n.use);return{performPlan:async(e,t)=>await r.operations.performGesturePlan(f(e,t)),...d(r)}}case`directional-fling`:{let r=await e(t,n.use);return{performPlan:async(e,t)=>await r.operations.performDirectionalFlingPlan(f(e,t)),...d(r)}}case`multi-touch`:{let r=await e(t,n.use);return{performPlan:async(e,t)=>await r.operations.performMultiTouchGesturePlan(f(e,t)),...d(r)}}case`target-authored-drag`:{let r=await e(t,n.use);return{performPlan:async(e,t)=>await r.operations.performTargetAuthoredDrag(f(e,t)),...d(r)}}}}function d(e){let{gestureViewport:t}=e.operations,n=e.operations.captureSnapshot?{operations:{captureSnapshot:e.operations.captureSnapshot}}:void 0,r=t?{operations:{gestureViewport:t}}:void 0;return Object.freeze({...n?{captureSnapshot:async e=>await n.operations.captureSnapshot(e)}:{},...r?{gestureViewport:async e=>await r.operations.gestureViewport(p(e))}:{}})}function f(e,t){return{plan:e,...t.appBundleId===void 0?{}:{options:{appBundleId:t.appBundleId}},execution:o(t)}}function p(e){return{...e.appBundleId===void 0?{}:{options:{appBundleId:e.appBundleId}},execution:o(e)}}export{c as n,l as t};
@@ -1 +1 @@
1
- import{_ as e}from"./sdk-contracts.js";import{F as t}from"./sdk-android-adb.js";import{n}from"./hdc.js";import{closeHarmonyApp as r,openHarmonyApp as i}from"./app-lifecycle2.js";import{appSwitcherHarmony as a,backHarmony as o,doubleClickHarmony as s,fillHarmony as c,homeHarmony as l,longPressHarmony as u,n as d,performHarmonyGesture as f,pressHarmony as p,scrollHarmony as m,setHarmonyOrientation as h,t as g,typeHarmony as _}from"./input-actions2.js";import{randomUUID as v}from"node:crypto";import{promises as y}from"node:fs";async function b(t,r){let i=`/data/local/tmp/agent-device-screen-${v()}.jpeg`;try{await n(t,[`shell`,`snapshot_display`,`-f`,i],{timeoutMs:15e3}),await n(t,[`file`,`recv`,i,r],{timeoutMs:15e3});let a=await y.readFile(r);if(a.length<3||a[0]!==255||a[1]!==216||a[2]!==255)throw new e(`COMMAND_FAILED`,`HarmonyOS screenshot is not a JPEG file`)}finally{await n(t,[`shell`,`rm`,`-f`,i],{allowFailure:!0}).catch(()=>{})}}async function x(t,r,i,a){if(r!==`clear-app-state`)throw new e(`UNSUPPORTED_OPERATION`,`HarmonyOS setting "${r}" is not supported`,{hint:`HarmonyOS currently supports settings clear-app-state for an app bundle only.`});if(i!==`clear`)throw new e(`INVALID_ARGS`,`settings clear-app-state only supports clear.`);if(!a)throw new e(`INVALID_ARGS`,`settings clear-app-state requires an app id or an active app session.`);return await n(t,[`shell`,`aa`,`force-stop`,a],{timeoutMs:15e3}),await n(t,[`shell`,`bm`,`clean`,`-n`,a,`-d`,`-c`],{timeoutMs:15e3}),{bundleId:a,forceStopped:!0,clearedData:!0,clearedCache:!0}}function S(n,v){let y=t=>async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} is not supported on HarmonyOS`)};return{open:(e,t)=>i(n,e,{activity:t?.activity}),openDevice:()=>l(n),close:e=>r(n,e),tap:(e,t)=>p(n,e,t),doubleTap:(e,t)=>s(n,e,t),longPress:(e,t,r)=>u(n,e,t,r),focus:(e,t)=>p(n,e,t),type:(e,t)=>_(n,e,t),fill:(e,t,r,i)=>c(n,e,t,r,i),scroll:(e,t)=>m(n,e,t),performGesture:e=>f(n,e),gestureViewport:()=>g(n),screenshot:e=>b(n,e),snapshot:async e=>({...await t(`snapshot_capture`,async()=>await d(n,e),{backend:`harmonyos-arkui`}),backend:`harmonyos-arkui`}),back:()=>o(n),home:()=>l(n),setOrientation:e=>h(n,e),appSwitcher:()=>a(n),tvRemote:y(`tv-remote`),readClipboard:y(`clipboard`),writeClipboard:y(`clipboard`),setSetting:(e,t,r)=>x(n,e,t,r)}}export{S as createHarmonyInteractor};
1
+ import{y as e}from"./sdk-contracts.js";import{c as t}from"./diagnostics.js";import"./diagnostics2.js";import{_ as n,a as r,c as i,d as a,f as o,g as s,h as c,l,n as u,o as d,p as f,r as p,s as m,t as h,u as g,v as _,x as v,y}from"./src3.js";function b(b,x){let S=t=>async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} is not supported on HarmonyOS`)};return{open:(e,t)=>l(b,e,{activity:t?.activity}),openDevice:()=>m(b),close:e=>p(b,e),tap:(e,t)=>a(b,e,t),doubleTap:(e,t)=>r(b,e,t),longPress:(e,t,n)=>i(b,e,t,n),focus:(e,t)=>a(b,e,t),type:(e,t)=>v(b,e,t),fill:(e,t,n,r)=>d(b,e,t,n,r),scroll:(e,t)=>s(b,e,t),performGesture:e=>g(b,e),gestureViewport:()=>f(b),screenshot:e=>c(b,e),snapshot:async e=>({...await t(`snapshot_capture`,async()=>await y(b,e),{backend:`harmonyos-arkui`}),backend:`harmonyos-arkui`,producer:`harmonyos-uitest`}),back:()=>u(b),home:()=>m(b),setOrientation:e=>n(b,e),appSwitcher:()=>h(b),tvRemote:S(`tv-remote`),keyboardDismiss:async()=>(await o(b,`Back`),{kind:`acknowledged`}),keyboardEnter:async()=>(await o(b,`Enter`),{kind:`harmonyos-acknowledged`}),readClipboard:S(`clipboard`),writeClipboard:S(`clipboard`),setSetting:(e,t,n)=>_(b,e,t,n),readAlert:S(`alert`),awaitAlert:S(`alert`),acceptAlert:S(`alert`),dismissAlert:S(`alert`)}}export{b as createHarmonyInteractor};
package/dist/src/hdc.js CHANGED
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime.js";import{_ as t}from"./sdk-android-adb.js";import n from"node:path";import{promises as r}from"node:fs";var i=e({DEFAULT_HARMONY_HDC_TIMEOUT_MS:()=>a,ensureHarmonyToolchainPathConfigured:()=>s,runHarmonyHdc:()=>o});const a=15e3;async function o(e,n,r){return await t(`hdc`,[`-t`,e.id,...n],{timeoutMs:a,...r})}async function s(e=process.env){let t=[e.HDC_SDK_PATH,e.DEVECO_SDK_HOME?n.join(e.DEVECO_SDK_HOME,`default`,`openharmony`,`toolchains`):void 0,e.HARMONYOS_COMMAND_LINE_TOOLS?n.join(e.HARMONYOS_COMMAND_LINE_TOOLS,`sdk`,`default`,`openharmony`,`toolchains`):void 0].filter(e=>!!e?.trim()),i=[];for(let e of t)try{await r.access(n.join(e,`hdc`),r.constants.X_OK),i.push(e)}catch{}if(i.length===0)return;let a=(e.PATH??``).split(n.delimiter).filter(Boolean);e.PATH=[...new Set([...i,...a])].join(n.delimiter)}export{o as n,i as t};
1
+ import{c as e}from"./owner-identity.js";import{r as t,s as n}from"./exec.js";import"./command.js";import"./process.js";import r from"node:path";async function i(e,t,r){return await n(`hdc`,[`-t`,e.id,...t],{timeoutMs:15e3,...r})}async function a(n=e()){let i=[n.HDC_SDK_PATH,n.DEVECO_SDK_HOME?r.join(n.DEVECO_SDK_HOME,`default`,`openharmony`,`toolchains`):void 0,n.HARMONYOS_COMMAND_LINE_TOOLS?r.join(n.HARMONYOS_COMMAND_LINE_TOOLS,`sdk`,`default`,`openharmony`,`toolchains`):void 0].filter(e=>!!e?.trim()),a=[];for(let e of i)await t(r.join(e,`hdc`))&&a.push(e);if(a.length===0)return;let o=(n.PATH??``).split(r.delimiter).filter(Boolean);n.PATH=[...new Set([...a,...o])].join(r.delimiter)}export{a as ensureHarmonyToolchainPathConfigured,i as runHarmonyHdc};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./rolldown-runtime.js";import{_ as t}from"./sdk-contracts.js";import{g as n,v as r}from"./sdk-android-adb.js";import{i,r as a,t as o}from"./tool-provider.js";import s from"node:path";import{createHash as c}from"node:crypto";import{existsSync as l,promises as u}from"node:fs";import d from"node:os";import{fileURLToPath as f}from"node:url";var p=e({quitMacOsApp:()=>N,resolveFrontmostMacOsApp:()=>M,resolveMacOsHelperPackageRootFrom:()=>x,runMacOsAlertAction:()=>F,runMacOsPermissionAction:()=>P,runMacOsPressAction:()=>R,runMacOsReadTextAction:()=>L,runMacOsScreenshotAction:()=>z,runMacOsSnapshotAction:()=>I,startMacOsAudioProbeProcess:()=>A});const m=`agent-device-macos-helper`,h=`AGENT_DEVICE_MACOS_HELPER_BIN`,g=s.join(d.homedir(),`.agent-device`,`macos-helper`,`current`),_=s.join(g,`manifest.json`),v=/^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)+$/;function y(e){let n=e.trim();if(!v.test(n))throw new t(`INVALID_ARGS`,`macOS bundle id must use reverse-DNS form like com.example.App`,{bundleId:e});return n}function b(e,t){t.bundleId&&e.push(`--bundle-id`,y(t.bundleId)),t.surface&&e.push(`--surface`,t.surface)}function x(e){let n=s.dirname(e);for(;;){let e=s.join(n,`apple`,`macos-helper`);if(l(s.join(e,`Package.swift`)))return e;let t=s.dirname(n);if(t===n)break;n=t}throw new t(`COMMAND_FAILED`,`Unable to locate macOS helper package root`,{modulePath:e})}function S(){return x(f(import.meta.url))}function C(){return s.join(S(),`.build`,`release`,m)}function w(){return s.join(g,m)}async function T(e){let t=await u.readdir(e,{withFileTypes:!0});return(await Promise.all(t.map(async t=>{let n=s.join(e,t.name);return t.isDirectory()?t.name===`.build`?[]:await T(n):!t.isFile()||!t.name.endsWith(`.swift`)&&t.name!==`Package.swift`?[]:[n]}))).flat().sort()}async function E(e){let t=await T(e),n=c(`sha256`);for(let r of t)n.update(s.relative(e,r)),n.update(`\0`),n.update(await u.readFile(r)),n.update(`\0`);let r=await i(`swift`,[`--version`],{allowFailure:!0,cwd:e,timeoutMs:1e4});return n.update(`swift-version`),n.update(`\0`),n.update(r.stdout||r.stderr||`exit:${r.exitCode}`),n.update(`\0`),n.digest(`hex`)}async function D(){try{let e=JSON.parse(await u.readFile(_,`utf8`));return typeof e.fingerprint==`string`?e.fingerprint:null}catch{return null}}async function O(){let e=await n(process.env[h],h);if(e)return e;let t=S(),r=await E(t),a=w();try{if(await D()===r)return await u.access(a),a}catch{}let o=C();process.stderr.write(`agent-device: building macOS helper (first run or helper update)
2
- `),await i(`swift`,[`build`,`-c`,`release`,`--package-path`,t],{cwd:t,timeoutMs:12e4}),await u.mkdir(g,{recursive:!0});let s=`${a}.tmp`;return await u.copyFile(o,s),await u.rename(s,a),await u.chmod(a,493),await u.writeFile(_,`${JSON.stringify({fingerprint:r},null,2)}\n`,`utf8`),a}async function k(){let e=process.env[h]?.trim();if(e){let t=await n(e,h);if(t)return t}if(o())return m;if(process.platform!==`darwin`)throw new t(`UNSUPPORTED_PLATFORM`,`macOS helper is only available on macOS`);return await O()}async function A(e){return r(await k(),[`audio-probe`,`--duration-ms`,String(e.durationMs),`--bucket-ms`,String(e.bucketMs),`--out`,e.statusPath],{allowFailure:!0,captureOutput:!0})}async function j(e,n={}){let r={allowFailure:!0,timeoutMs:3e4,signal:n.signal},o=a().macosHelper,s=o?m:await k(),c=o?await o.run(e,r):await i(s,e,r),l=c.stdout.trim(),u=null;if(l)try{u=JSON.parse(l)}catch{u=null}if(c.exitCode===0&&u?.ok)return u.data;throw new t(`COMMAND_FAILED`,u&&!u.ok?u.error?.message??`macOS helper exited with code ${c.exitCode}`:l||c.stderr.trim()||`macOS helper exited with code ${c.exitCode}`,{helperPath:s,args:e,stdout:c.stdout,stderr:c.stderr,exitCode:c.exitCode,...u&&!u.ok?u.error?.details:{}})}async function M(){return await j([`app`,`frontmost`])}async function N(e){return await j([`app`,`quit`,`--bundle-id`,y(e)])}async function P(e,t){return await j([`permission`,e,t])}async function F(e,t={}){let n=[`alert`,e];return b(n,t),await j(n)}async function I(e,t={}){let n=[`snapshot`,`--surface`,e];return b(n,t),await j(n,{signal:t.signal})}async function L(e,t,n={}){let r=[`read`,`--x`,String(e),`--y`,String(t)];return b(r,n),await j(r)}async function R(e,t,n={}){let r=[`press`,`--x`,String(e),`--y`,String(t)];return b(r,n),await j(r)}async function z(e,t={}){let n=[`screenshot`,`--out`,e];return b(n,t),t.fullscreen&&n.push(`--fullscreen`),await j(n)}export{z as a,P as i,N as n,I as o,F as r,A as s,p as t};
1
+ import{r as e}from"./rolldown-runtime.js";import{y as t}from"./sdk-contracts.js";import{T as n,_ as r,d as i}from"./owner-identity.js";import{a,c as o}from"./exec.js";import"./command.js";import"./process.js";import{D as s,c,f as l,g as u,h as d,n as f,o as p,r as m,t as h,w as g,y as _}from"./host-file.js";import{a as v,i as y,n as b}from"./tool-provider.js";import x from"node:path";import{createHash as S}from"node:crypto";import{fileURLToPath as C}from"node:url";var w=e({quitMacOsApp:()=>W,resolveFrontmostMacOsApp:()=>U,resolveMacOsHelperPackageRootFrom:()=>M,runMacOsAlertAction:()=>K,runMacOsPermissionAction:()=>G,runMacOsPressAction:()=>Y,runMacOsReadTextAction:()=>J,runMacOsScreenshotAction:()=>X,runMacOsSnapshotAction:()=>q,startMacOsAudioProbeProcess:()=>V});const T=`agent-device-macos-helper`,E=`AGENT_DEVICE_MACOS_HELPER_BIN`,D=x.join(l(),`.agent-device`,`macos-helper`,`current`),O=x.join(D,`manifest.json`),k=/^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)+$/;function A(e){let n=e.trim();if(!k.test(n))throw new t(`INVALID_ARGS`,`macOS bundle id must use reverse-DNS form like com.example.App`,{bundleId:e});return n}function j(e,t){t.bundleId&&e.push(`--bundle-id`,A(t.bundleId)),t.surface&&e.push(`--surface`,t.surface)}function M(e){let n=x.dirname(e);for(;;){let e=x.join(n,`apple`,`macos-helper`);if(c(x.join(e,`Package.swift`)))return e;let t=x.dirname(n);if(t===n)break;n=t}throw new t(`COMMAND_FAILED`,`Unable to locate macOS helper package root`,{modulePath:e})}function N(){return M(C(import.meta.url))}function P(){return x.join(N(),`.build`,`release`,T)}function F(){return x.join(D,T)}async function I(e){let t=await u(e,{withFileTypes:!0});return(await Promise.all(t.map(async t=>{let n=x.join(e,t.name);return t.isDirectory()?t.name===`.build`?[]:await I(n):!t.isFile()||!t.name.endsWith(`.swift`)&&t.name!==`Package.swift`?[]:[n]}))).flat().sort()}async function L(e){let t=await I(e),n=S(`sha256`);for(let r of t)n.update(x.relative(e,r)),n.update(`\0`),n.update(await d(r)),n.update(`\0`);let r=await v(`swift`,[`--version`],{allowFailure:!0,cwd:e,timeoutMs:1e4});return n.update(`swift-version`),n.update(`\0`),n.update(r.stdout||r.stderr||`exit:${r.exitCode}`),n.update(`\0`),n.digest(`hex`)}async function R(){try{let e=JSON.parse(await _(O));return typeof e.fingerprint==`string`?e.fingerprint:null}catch{return null}}async function z(){let e=await a(r(E),E);if(e)return e;let t=N(),i=await L(t),o=F();try{if(await R()===i)return await h(o),o}catch{}let c=P();n(`agent-device: building macOS helper (first run or helper update)
2
+ `),await v(`swift`,[`build`,`-c`,`release`,`--package-path`,t],{cwd:t,timeoutMs:12e4}),await p(D);let l=`${o}.tmp`;return await m(c,l),await g(l,o),await f(o,493),await s(O,`${JSON.stringify({fingerprint:i},null,2)}\n`),o}async function B(){let e=r(E)?.trim();if(e){let t=await a(e,E);if(t)return t}if(b())return T;if(i()!==`darwin`)throw new t(`UNSUPPORTED_PLATFORM`,`macOS helper is only available on macOS`);return await z()}async function V(e){let t=await B();return o(t,[`audio-probe`,`--duration-ms`,String(e.durationMs),`--bucket-ms`,String(e.bucketMs),`--out`,e.statusPath],{allowFailure:!0,captureOutput:!0})}async function H(e,n={}){let r={allowFailure:!0,timeoutMs:3e4,signal:n.signal},i=y().macosHelper,a=i?T:await B(),o=i?await i.run(e,r):await v(a,e,r),s=o.stdout.trim(),c=null;if(s)try{c=JSON.parse(s)}catch{c=null}if(o.exitCode===0&&c?.ok)return c.data;let l=c&&!c.ok?c.error?.message??`macOS helper exited with code ${o.exitCode}`:s||o.stderr.trim()||`macOS helper exited with code ${o.exitCode}`;throw new t(`COMMAND_FAILED`,l,{helperPath:a,args:e,stdout:o.stdout,stderr:o.stderr,exitCode:o.exitCode,...c&&!c.ok?c.error?.details:{}})}async function U(){return await H([`app`,`frontmost`])}async function W(e){return await H([`app`,`quit`,`--bundle-id`,A(e)])}async function G(e,t){return await H([`permission`,e,t])}async function K(e,t={}){let n=[`alert`,e];return j(n,t),await H(n)}async function q(e,t={}){let n=[`snapshot`,`--surface`,e];return j(n,t),await H(n,{signal:t.signal})}async function J(e,t,n={}){let r=[`read`,`--x`,String(e),`--y`,String(t)];return j(r,n),await H(r)}async function Y(e,t,n={}){let r=[`press`,`--x`,String(e),`--y`,String(t)];return j(r,n),await H(r)}async function X(e,t={}){let n=[`screenshot`,`--out`,e];return j(n,t),t.fullscreen&&n.push(`--fullscreen`),await H(n)}export{G as a,K as i,W as n,X as o,U as r,V as s,w as t};
@@ -0,0 +1 @@
1
+ import e from"node:path";import t from"node:fs";import n from"node:os";import r from"node:fs/promises";function i(){return n.homedir()}function a(){return n.tmpdir()}async function o(t){return await r.mkdtemp(e.join(a(),t))}async function s(e){await r.mkdir(e,{recursive:!0})}async function c(e,t={}){return await r.readFile(e,{encoding:`utf8`,signal:t.signal})}async function l(e,t={}){return await r.readFile(e,{signal:t.signal})}async function u(e,t={}){return t.withFileTypes===!0?await r.readdir(e,{withFileTypes:!0}):await r.readdir(e)}async function d(e){return await r.stat(e)}async function f(e,t){await r.writeFile(e,t,`utf8`)}async function p(e,t){await r.writeFile(e,t)}async function m(e){await r.rm(e,{recursive:!0,force:!0})}async function h(e){await r.unlink(e)}async function g(e,t){await r.copyFile(e,t)}async function _(e,t){await r.cp(e,t,{recursive:!0})}async function v(e,t){await r.rename(e,t)}async function y(e,t){await r.chmod(e,t)}async function b(e){await r.access(e)}async function x(e){await m(e)}function S(e){t.mkdirSync(e,{recursive:!0})}function C(e){return t.readFileSync(e,`utf8`)}function w(e,n){t.writeFileSync(e,n,`utf8`)}function T(e){return t.existsSync(e)}function E(e){return t.statSync(e)}function D(e){return t.lstatSync(e)}function O(e){return t.readlinkSync(e)}function k(e){t.unlinkSync(e)}function A(e,n){t.symlinkSync(e,n,`dir`)}function j(e){return t.readdirSync(e)}export{m as C,f as D,p as E,w as O,k as S,h as T,j as _,A as a,C as b,T as c,E as d,i as f,u as g,l as h,_ as i,D as l,o as m,y as n,s as o,a as p,g as r,S as s,b as t,d as u,O as v,v as w,x,c as y};
@@ -0,0 +1 @@
1
+ import{y as e}from"./sdk-contracts.js";import{t}from"./config.js";import n from"node:crypto";const r=`default`;function i(t){let n=Number.isInteger(t.defaultLeaseTtlMs)?Math.max(1,Number(t.defaultLeaseTtlMs)):6e4,r=Number.isInteger(t.minLeaseTtlMs)?Math.max(1,Number(t.minLeaseTtlMs)):5e3,i=Number.isInteger(t.maxLeaseTtlMs)?Math.max(r,Number(t.maxLeaseTtlMs)):6e5;return t=>{if(!Number.isInteger(t))return n;let a=Number(t);if(a<r||a>i)throw new e(`INVALID_ARGS`,`Lease ttlMs must be between ${r} and ${i}.`);return a}}function a(e){if(!e)return;let t=e.trim();if(t&&/^[a-zA-Z0-9._-]{1,128}$/.test(t))return t}function o(e){if(!e)return;let t=e.trim();if(t&&/^[a-f0-9]{16,128}$/i.test(t))return t.toLowerCase()}function s(t){let n=o(t);if(!n)throw new e(`INVALID_ARGS`,`Invalid lease id.`);return n}function c(t){let n=(t??``).trim().toLowerCase();if(!n||n===`ios-simulator`)return`ios-simulator`;if(n===`ios-instance`||n===`android-instance`||n===`harmonyos-instance`)return n;throw new e(`INVALID_ARGS`,`Unsupported lease backend: ${t??``}`)}function l(t){if(t===void 0)return;let n=t.trim();if(!n||n.length>256||!/^[\u0020-\u007E]+$/.test(n))throw new e(`INVALID_ARGS`,`Invalid device key. Use 1-256 printable characters.`);return n}function u(e){return f(e,`client id`,128)}function d(e){return f(e,`lease provider`,64)}function f(t,n,r){if(t===void 0)return;let i=t.trim();if(!i||i.length>r||!/^[a-zA-Z0-9._-]+$/.test(i))throw new e(`INVALID_ARGS`,`Invalid ${n}. Use 1-${String(r)} chars: letters, numbers, dot, underscore, hyphen.`);return i}function p(n){let r=t(n);if(!r)throw new e(`INVALID_ARGS`,`Invalid tenant id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);return r}function m(t){let n=a(t);if(!n)throw new e(`INVALID_ARGS`,`Invalid run id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);return n}function h(e){return{backend:c(e.leaseBackend),leaseProvider:d(e.leaseProvider),deviceKey:l(e.deviceKey),clientId:u(e.clientId),tenantId:p(e.tenantId),runId:m(e.runId),ttlMs:e.ttlMs}}function g(e){return!!(e.leaseProvider??e.deviceKey??e.clientId)}function _(e,t){return!t.tenantId||!t.runId?!1:[[e.leaseProvider,t.leaseProvider],[e.deviceKey,t.deviceKey],[e.clientId,t.clientId]].every(([e,t])=>!e||!!t)}function v(t,n){let r=b(n);if(r.tenantId&&t.tenantId!==r.tenantId||r.runId&&t.runId!==r.runId||r.leaseBackend&&t.backend!==r.leaseBackend||r.leaseProvider&&t.leaseProvider!==r.leaseProvider||r.deviceKey&&t.deviceKey!==r.deviceKey||r.clientId&&t.clientId!==r.clientId)throw new e(`UNAUTHORIZED`,`Lease does not match tenant/run scope`,{reason:`LEASE_SCOPE_MISMATCH`})}function y(n){let r=c(n.leaseBackend),i=t(n.tenantId);if(!i)throw new e(`INVALID_ARGS`,`tenant isolation requires tenant id.`);let s=a(n.runId);if(!s)throw new e(`INVALID_ARGS`,`tenant isolation requires run id.`);let l=o(n.leaseId);if(!l)throw new e(`INVALID_ARGS`,`tenant isolation requires lease id.`);return{...n,tenantId:i,runId:s,leaseId:l,leaseBackend:r}}function b(n){let r=t(n.tenantId),i=a(n.runId);if(n.tenantId&&!r)throw new e(`INVALID_ARGS`,`Invalid tenant id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);if(n.runId&&!i)throw new e(`INVALID_ARGS`,`Invalid run id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);return{tenantId:r,runId:i,leaseBackend:n.leaseBackend?c(n.leaseBackend):void 0,leaseProvider:d(n.leaseProvider),deviceKey:l(n.deviceKey),clientId:u(n.clientId)}}function x(t,n){if(g(t)&&!_(t,n))throw new e(`UNAUTHORIZED`,`Lease owner scope is required`,{reason:`LEASE_SCOPE_REQUIRED`})}function S(e){if(e.deviceKey)return JSON.stringify([e.backend,e.leaseProvider??r,e.deviceKey])}function C(e){return JSON.stringify([e.tenantId,e.runId,e.backend,e.leaseProvider??r,e.deviceKey??`*`])}function w(e,t,r){return{leaseId:n.randomBytes(16).toString(`hex`),tenantId:e.tenantId,runId:e.runId,backend:e.backend,...e.leaseProvider?{leaseProvider:e.leaseProvider}:{},...e.deviceKey?{deviceKey:e.deviceKey}:{},...e.clientId?{clientId:e.clientId}:{},createdAt:r,heartbeatAt:r,expiresAt:r+t}}function T(t){return new e(`DEVICE_IN_USE`,`Device is already leased`,{reason:`DEVICE_LEASE_BUSY`,deviceKey:t.deviceKey,backend:t.backend,leaseProvider:t.leaseProvider,expiresAt:t.expiresAt,hint:`Retry after the lease expires or close the owning session.`})}const E=`/admin/human-control/holds`;function D(t){let n=k(t,`Human-control request body`),r=n.reason;if(r!==void 0&&(typeof r!=`string`||r.trim().length>512))throw new e(`INVALID_ARGS`,`Human-control reason must be at most 512 characters.`);let i=n.ttlMs;if(i!==void 0&&(typeof i!=`number`||!Number.isInteger(i)||i<1e3||i>864e5))throw new e(`INVALID_ARGS`,`Human-control ttlMs must be between 1000 and 86400000.`);return{...n.scope===void 0?{}:{scope:O(n.scope)},...typeof r==`string`&&r.trim()?{reason:r.trim()}:{},...typeof i==`number`?{ttlMs:i}:{}}}function O(t){let n=k(t,`Host human-control scope`);if(typeof n.backend!=`string`||!n.backend.trim()||typeof n.deviceKey!=`string`)throw new e(`INVALID_ARGS`,`Host human control requires scope.backend and scope.deviceKey.`);if(n.leaseProvider!==void 0&&typeof n.leaseProvider!=`string`)throw new e(`INVALID_ARGS`,`scope.leaseProvider must be a string.`);let r=d(n.leaseProvider);return{backend:c(n.backend),deviceKey:l(n.deviceKey),...r?{leaseProvider:r}:{}}}function k(t,n){if(!t||typeof t!=`object`||Array.isArray(t))throw new e(`INVALID_ARGS`,`${n} must be an object.`);return t}function A(t){let n=typeof t==`string`?t.trim():``;if(!/^[a-zA-Z0-9._-]{1,128}$/.test(n))throw new e(`INVALID_ARGS`,`Invalid human-control hold id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);return n}function j(e){return{...e,scope:{...e.scope}}}function M(t){return new e(`DEVICE_IN_USE`,`A human is interacting with this simulator or device; agent interactions are temporarily disabled.`,{reason:`human_control_active`,blockedBy:`human_control`,holdId:t.id,deviceKey:t.scope.deviceKey,pausedAt:new Date(t.createdAt).toISOString(),...t.expiresAt===void 0?{}:{expiresAt:new Date(t.expiresAt).toISOString()},...t.reason?{humanReason:t.reason}:{},hint:`Wait until the human-control hold is released before retrying.`})}export{D as a,w as c,S as d,C as f,s as g,o as h,A as i,i as l,y as m,j as n,x as o,h as p,M as r,v as s,E as t,T as u};
@@ -0,0 +1 @@
1
+ import{y as e}from"./sdk-contracts.js";import{r as t}from"./request-cancel.js";import"./request.js";import{a as n}from"./human-control-contract.js";async function r(n){let{req:r,registry:s}=n,c=r.internal?.admittedLease;if(!c)throw new e(`UNAUTHORIZED`,`Human control requires an admitted remote lease.`);let l={kind:`lease`,leaseId:c.leaseId},u=r.positionals??[],[d,f=``,p=``]=u;switch(d){case`list`:return a(u,1),{ok:!0,data:{holds:s.listHumanControlHolds(l)}};case`put`:return a(u,3),{ok:!0,data:{hold:await s.putHumanControlHold(l,f,i(p),t(r.meta?.requestId)),state:`active`}};case`remove`:{a(u,2);let e=s.removeHumanControlHold(l,f);return{ok:!0,data:{released:!!e,...e?{hold:e}:{}}}}default:throw o()}}function i(t){let r;try{r=JSON.parse(t)}catch(t){throw new e(`INVALID_ARGS`,`Human-control payload must be valid JSON.`,void 0,t)}return n(r)}function a(e,t){if(e.length!==t)throw o()}function o(){return new e(`INVALID_ARGS`,`human_control requires list, put <id> <payload>, or remove <id>.`)}export{r as handleHumanControlCommand};