agent-device 0.20.10 → 0.21.1

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 (510) hide show
  1. package/README.md +2 -2
  2. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.10.apk → agent-device-android-ime-helper-0.21.1.apk} +0 -0
  3. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.1.apk.sha256 +1 -0
  4. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.10.manifest.json → agent-device-android-ime-helper-0.21.1.manifest.json} +4 -4
  5. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.1.apk +0 -0
  6. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.1.apk.sha256 +1 -0
  7. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.10.manifest.json → agent-device-android-snapshot-helper-0.21.1.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 +106 -0
  12. package/apple/snapshot-bridge/SnapshotBridge.m +286 -0
  13. package/apple/snapshot-bridge/SnapshotBridgeCapture.h +25 -0
  14. package/apple/snapshot-bridge/SnapshotBridgeCapture.m +138 -0
  15. package/apple/snapshot-bridge/SnapshotBridgeRuntime.h +34 -0
  16. package/apple/snapshot-bridge/SnapshotBridgeRuntime.m +411 -0
  17. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +58 -0
  18. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/project.pbxproj +19 -0
  19. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.h +12 -0
  20. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +20 -0
  21. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAlertVerification.swift +36 -0
  22. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSelectorMatchPolicy.swift +15 -15
  23. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerStringNormalization.swift +8 -0
  24. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +12 -1
  25. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +100 -6
  26. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSystemSurfaceHostPolicy.swift +72 -0
  27. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTapPointPolicy.swift +63 -14
  28. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +677 -83
  29. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +35 -92
  30. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift +124 -0
  31. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+BlockingSystemModalResolution.swift +39 -4
  32. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +1058 -213
  33. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +296 -14
  34. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Environment.swift +1 -1
  35. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Exceptions.swift +10 -10
  36. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +309 -149
  37. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Keyboard.swift +101 -42
  38. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +24 -17
  39. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +124 -199
  40. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +71 -4
  41. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+PrivateAXElementTypes.swift +12 -0
  42. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+PrivateAXPresentation.swift +211 -78
  43. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScreenRecorder.swift +30 -10
  44. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollGesture.swift +254 -24
  45. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift +206 -22
  46. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +465 -494
  47. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotBackendCapabilities.swift +168 -0
  48. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +802 -247
  49. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotPresentationInvariant.swift +19 -0
  50. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotTiming.swift +185 -0
  51. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedCommitDeadline.swift +206 -0
  52. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +83 -5
  53. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedTextEntry.swift +156 -34
  54. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +5 -4
  55. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +35 -318
  56. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryFocus.swift +206 -0
  57. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryReadiness.swift +158 -0
  58. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextInputCandidatePolicy.swift +28 -0
  59. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextInputProbe.swift +101 -0
  60. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +56 -23
  61. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Transport.swift +56 -27
  62. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TvRemote.swift +30 -24
  63. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +126 -80
  64. package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/RecordingExportSupport.swift +111 -0
  65. package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-overlay.swift +47 -86
  66. package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-trim.swift +32 -79
  67. package/dist/apple/snapshot-presentation/Package.swift +21 -0
  68. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotGeometry.swift +56 -0
  69. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotModels.swift +259 -0
  70. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentation.swift +153 -0
  71. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationFailure.swift +27 -0
  72. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationInvariant.swift +91 -0
  73. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationProjection.swift +161 -0
  74. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotScopePolicy.swift +53 -0
  75. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFold.swift +242 -0
  76. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFoldProjection.swift +97 -0
  77. package/dist/src/adapter.js +1 -0
  78. package/dist/src/adb-executor.js +2 -0
  79. package/dist/src/adb-failure.js +1 -0
  80. package/dist/src/adb-host.js +1 -0
  81. package/dist/src/adb.js +1 -0
  82. package/dist/src/agent-browser-lifecycle.js +1 -0
  83. package/dist/src/agent-browser-process-record.js +1 -0
  84. package/dist/src/agent-browser-provider.js +1 -0
  85. package/dist/src/agent-browser-tool.js +1 -1
  86. package/dist/src/agent-device-client.js +2 -2
  87. package/dist/src/ai-sdk.d.ts +2 -2
  88. package/dist/src/ai-sdk.js +1 -1
  89. package/dist/src/alert-contract.js +1 -0
  90. package/dist/src/alert-runtime.js +1 -0
  91. package/dist/src/android-adb.d.ts +27 -19
  92. package/dist/src/android-adb.js +1 -1
  93. package/dist/src/android-input-ownership.js +1 -0
  94. package/dist/src/android-system-chrome.js +1 -0
  95. package/dist/src/android.js +1 -1
  96. package/dist/src/api.js +11 -0
  97. package/dist/src/app-catalog.js +1 -0
  98. package/dist/src/app-deployment-resolution.js +2 -0
  99. package/dist/src/app-helpers.js +1 -1
  100. package/dist/src/app-inventory-contract.js +1 -0
  101. package/dist/src/app-inventory.js +1 -0
  102. package/dist/src/app-launch.js +2 -0
  103. package/dist/src/app-lifecycle-facade.js +1 -0
  104. package/dist/src/app-lifecycle.js +3 -6
  105. package/dist/src/app-lifecycle2.js +2 -2
  106. package/dist/src/app-lifecycle3.js +1 -0
  107. package/dist/src/app-log-files.js +1 -1
  108. package/dist/src/app-log-reconnect.js +1 -1
  109. package/dist/src/app-log-runtime.js +1 -4
  110. package/dist/src/app-log-runtime2.js +4 -0
  111. package/dist/src/app-parsers.js +4 -0
  112. package/dist/src/app-resolution-cache.js +1 -0
  113. package/dist/src/app-resolution-facade.js +1 -0
  114. package/dist/src/app-resolution.js +2 -2
  115. package/dist/src/app-state.js +1 -2
  116. package/dist/src/apple-runner-platform.js +1 -0
  117. package/dist/src/application-lifecycle-interaction.js +1 -0
  118. package/dist/src/application-lifecycle-runtime.js +1 -0
  119. package/dist/src/apps-simctl.js +1 -0
  120. package/dist/src/archive.js +4 -0
  121. package/dist/src/artifact-download.js +1 -0
  122. package/dist/src/artifacts.d.ts +6 -2
  123. package/dist/src/artifacts.js +1 -1
  124. package/dist/src/async-lifecycle.js +1 -0
  125. package/dist/src/audio-probe-result.js +1 -0
  126. package/dist/src/audio-probe-runtime.js +1 -0
  127. package/dist/src/audio-probe-support.js +1 -0
  128. package/dist/src/auth-session.js +1 -1
  129. package/dist/src/auth.js +1 -1
  130. package/dist/src/backend-snapshot-options.js +1 -1
  131. package/dist/src/{url.js → base-url.js} +1 -1
  132. package/dist/src/boot-diagnostics.js +2 -2
  133. package/dist/src/byte-limit-stream.js +1 -1
  134. package/dist/src/capabilities.js +1 -0
  135. package/dist/src/capture.js +1 -0
  136. package/dist/src/catalog.js +1 -0
  137. package/dist/src/cli-command-aliases.js +1 -0
  138. package/dist/src/cli-config.js +1 -1
  139. package/dist/src/cli-help.js +74 -51
  140. package/dist/src/cli-output.js +1 -1
  141. package/dist/src/cli-runner.js +1 -1
  142. package/dist/src/cli.js +4 -6
  143. package/dist/src/click-button.js +1 -0
  144. package/dist/src/client-metro-companion.js +1 -0
  145. package/dist/src/client-metro.js +1 -1
  146. package/dist/src/client-types.d.ts +280 -242
  147. package/dist/src/clipboard.js +1 -0
  148. package/dist/src/code-signature-cache.js +1 -0
  149. package/dist/src/code-signature.js +1 -0
  150. package/dist/src/color.js +1 -0
  151. package/dist/src/command-metadata.js +1 -1
  152. package/dist/src/command-schema.js +3 -3
  153. package/dist/src/command-surface.js +1 -1
  154. package/dist/src/command-tools.js +2 -2
  155. package/dist/src/command.js +1 -0
  156. package/dist/src/compatibility-policy.js +1 -0
  157. package/dist/src/config.js +1 -1
  158. package/dist/src/config2.js +1 -0
  159. package/dist/src/connection-runtime.js +1 -1
  160. package/dist/src/connection.js +5 -5
  161. package/dist/src/contracts.d.ts +1 -1
  162. package/dist/src/contracts.js +1 -1
  163. package/dist/src/daemon-client-lifecycle.js +1 -0
  164. package/dist/src/daemon-process.js +1 -0
  165. package/dist/src/daemon-registration.js +1 -0
  166. package/dist/src/daemon-shutdown-report.js +1 -1
  167. package/dist/src/daemon.js +2 -2
  168. package/dist/src/debug-symbols-facade.js +5 -0
  169. package/dist/src/deploy-result-target.js +1 -0
  170. package/dist/src/device-claim-inspection.js +1 -1
  171. package/dist/src/device-claim-rule.js +1 -0
  172. package/dist/src/device-input-state.d.ts +190 -3
  173. package/dist/src/device-inventory-context.js +1 -0
  174. package/dist/src/device-isolation.js +1 -0
  175. package/dist/src/device-release.js +1 -0
  176. package/dist/src/device-rotation.js +1 -0
  177. package/dist/src/device-selection-resolver.js +1 -0
  178. package/dist/src/device-session.js +1 -0
  179. package/dist/src/device.js +1 -1
  180. package/dist/src/device2.js +3 -2
  181. package/dist/src/diagnostics.js +3 -0
  182. package/dist/src/diagnostics2.js +1 -0
  183. package/dist/src/dispatch-resolve.js +1 -0
  184. package/dist/src/doctor-facade.js +1 -0
  185. package/dist/src/doctor-output.js +1 -0
  186. package/dist/src/doctor.js +1 -0
  187. package/dist/src/doctor2.js +1 -0
  188. package/dist/src/doctor3.js +1 -0
  189. package/dist/src/durable-resource.js +1 -0
  190. package/dist/src/entities.js +1 -1
  191. package/dist/src/error.js +2 -0
  192. package/dist/src/exec.js +1 -0
  193. package/dist/src/file.js +1 -0
  194. package/dist/src/find.js +1 -1
  195. package/dist/src/finders.js +1 -1
  196. package/dist/src/generic-settle.js +1 -1
  197. package/dist/src/generic.js +1 -1
  198. package/dist/src/gesture-admission.js +1 -0
  199. package/dist/src/gesture-plan-types.js +1 -0
  200. package/dist/src/gesture-plan.js +1 -0
  201. package/dist/src/gesture-runtime.js +1 -0
  202. package/dist/src/harmonyos.js +1 -1
  203. package/dist/src/hdc.js +1 -1
  204. package/dist/src/helper.js +2 -2
  205. package/dist/src/host-file.js +1 -0
  206. package/dist/src/human-control-contract.js +1 -0
  207. package/dist/src/human-control.js +1 -0
  208. package/dist/src/index.d.ts +1 -1
  209. package/dist/src/index.js +1 -1
  210. package/dist/src/input-actions.js +1 -4
  211. package/dist/src/input-actions2.js +2 -1
  212. package/dist/src/install-artifact-facade.js +1 -0
  213. package/dist/src/install-source-network-transport.js +1 -0
  214. package/dist/src/install-source.d.ts +3 -10
  215. package/dist/src/install-source2.js +1 -1
  216. package/dist/src/interaction-positionals.js +1 -0
  217. package/dist/src/interaction-ref-policy.js +1 -0
  218. package/dist/src/interaction.js +1 -1
  219. package/dist/src/interaction2.js +1 -1
  220. package/dist/src/interactor-operation-catalog.js +1 -0
  221. package/dist/src/interactor-types.js +1 -0
  222. package/dist/src/interactor.js +6 -2
  223. package/dist/src/interactor2.js +1 -1
  224. package/dist/src/interactors.js +1 -1
  225. package/dist/src/internal/bin.d.ts +1 -1
  226. package/dist/src/internal/bin.js +1 -2
  227. package/dist/src/internal/companion-tunnel.d.ts +1 -1
  228. package/dist/src/internal/companion-tunnel.js +1 -1
  229. package/dist/src/internal/daemon.d.ts +1 -1
  230. package/dist/src/internal/daemon.js +2 -4
  231. package/dist/src/internal/png-worker.d.ts +4 -4
  232. package/dist/src/internal/png-worker.js +1 -1
  233. package/dist/src/internal/run-script-http-child.d.ts +4 -0
  234. package/dist/src/internal/run-script-http-child.js +1 -0
  235. package/dist/src/internal/update-check-entry.d.ts +1 -1
  236. package/dist/src/inventory.js +4 -4
  237. package/dist/src/inventory2.js +1 -1
  238. package/dist/src/inventory3.js +1 -1
  239. package/dist/src/inventory5.js +1 -1
  240. package/dist/src/inventory6.js +1 -1
  241. package/dist/src/ios-client.js +16 -0
  242. package/dist/src/ios-snapshot-acquisition.js +1 -0
  243. package/dist/src/ios-snapshot-adapter.js +1 -0
  244. package/dist/src/ios-snapshot-planning.js +1 -0
  245. package/dist/src/ios-snapshot-runtime.js +1 -0
  246. package/dist/src/ios-system-surface.js +1 -0
  247. package/dist/src/json.js +1 -0
  248. package/dist/src/keyboard-actions.js +1 -0
  249. package/dist/src/launch-console.js +1 -0
  250. package/dist/src/lease-context.js +1 -1
  251. package/dist/src/lease-scope.js +1 -0
  252. package/dist/src/lease.js +1 -1
  253. package/dist/src/limrun-runtime-dependencies.js +1 -1
  254. package/dist/src/limrun.d.ts +1610 -7
  255. package/dist/src/limrun.js +1 -1
  256. package/dist/src/linux.js +1 -1
  257. package/dist/src/local-interactor-operation-set.js +1 -0
  258. package/dist/src/location-coordinates.js +1 -1
  259. package/dist/src/logcat.js +1 -1
  260. package/dist/src/macos-facade.js +1 -0
  261. package/dist/src/managed-device-scope.js +1 -0
  262. package/dist/src/mechanics.js +19 -0
  263. package/dist/src/metro.d.ts +4 -2
  264. package/dist/src/metro.js +1 -1
  265. package/dist/src/metro2.js +1 -1
  266. package/dist/src/mobile-snapshot-semantics.js +1 -1
  267. package/dist/src/multitouch-support.js +1 -0
  268. package/dist/src/numeric.js +1 -0
  269. package/dist/src/observability.js +1 -1
  270. package/dist/src/observation.js +2 -0
  271. package/dist/src/open-target-resolution.js +1 -0
  272. package/dist/src/output-path.js +1 -1
  273. package/dist/src/owner-identity.js +3 -1
  274. package/dist/src/parameterized-recorded-fill.js +1 -0
  275. package/dist/src/parser.js +1 -1
  276. package/dist/src/perf-facade.js +2 -0
  277. package/dist/src/perf-process-identity.js +1 -0
  278. package/dist/src/perf-runtime-operation-builder.js +1 -0
  279. package/dist/src/perf-runtime-plan.js +1 -0
  280. package/dist/src/perf-runtime.js +1 -0
  281. package/dist/src/perf.js +1 -4
  282. package/dist/src/physical-device-control.js +1 -1
  283. package/dist/src/physical-device-facade.js +1 -0
  284. package/dist/src/platform-request-scope.js +1 -0
  285. package/dist/src/platform-runtime-android-adb-host.js +1 -0
  286. package/dist/src/platform-runtime-android-mechanics.js +1 -0
  287. package/dist/src/platform-runtime-app-log-android-transport.js +1 -1
  288. package/dist/src/platform-runtime-app-log-process.js +1 -1
  289. package/dist/src/platform-runtime-host.js +1 -1
  290. package/dist/src/platform-runtime-managed-owner.js +1 -0
  291. package/dist/src/platform-runtime-network-web-transport.js +1 -1
  292. package/dist/src/platform-runtime-open-target.js +1 -1
  293. package/dist/src/platform-runtime-operation-host.js +4 -4
  294. package/dist/src/platform-runtime-runtime-hints.js +2 -2
  295. package/dist/src/platform-runtime-screen-recording-android-host.js +1 -1
  296. package/dist/src/platform-runtime-screen-recording-apple-runner-host.js +1 -1
  297. package/dist/src/platform-runtime-screen-recording-apple-runner-transport.js +1 -1
  298. package/dist/src/platform-runtime-screen-recording-apple-simulator-host.js +1 -1
  299. package/dist/src/platform-runtime-screen-recording-apple-transport.js +1 -1
  300. package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
  301. package/dist/src/platform-runtime-screen-recording-harmony-host.js +1 -1
  302. package/dist/src/platform-runtime-screen-recording-process-host.js +1 -0
  303. package/dist/src/platform-runtime-screen-recording-web-host.js +1 -1
  304. package/dist/src/platform-runtime-unavailable.js +1 -0
  305. package/dist/src/platform-runtime.js +1 -1
  306. package/dist/src/platform-runtime2.js +1 -1
  307. package/dist/src/plist.js +1 -1
  308. package/dist/src/png-worker-contract.js +1 -1
  309. package/dist/src/prepare-kind.js +1 -0
  310. package/dist/src/process-exit.js +1 -1
  311. package/dist/src/process.js +1 -0
  312. package/dist/src/provider-device-runtime.js +1 -0
  313. package/dist/src/provider-session-ownership.js +2 -0
  314. package/dist/src/provider-webdriver.js +1 -1
  315. package/dist/src/provider.js +1 -1
  316. package/dist/src/providers.js +1 -0
  317. package/dist/src/proxy.js +2 -2
  318. package/dist/src/react-native-overlay.js +1 -0
  319. package/dist/src/react-native.js +1 -1
  320. package/dist/src/record-runtime.js +1 -1
  321. package/dist/src/record-trace.js +1 -1
  322. package/dist/src/rect-center.js +1 -0
  323. package/dist/src/register-builtins.js +1 -0
  324. package/dist/src/registry.js +40 -28
  325. package/dist/src/remote-config2.js +1 -1
  326. package/dist/src/replay-divergence.js +2 -0
  327. package/dist/src/replay.js +2 -2
  328. package/dist/src/reporting.js +8 -7
  329. package/dist/src/request-admission.js +1 -0
  330. package/dist/src/request-cancel.js +1 -0
  331. package/dist/src/request-cancellation.js +1 -0
  332. package/dist/src/request-progress-protocol.js +1 -0
  333. package/dist/src/request-providers.js +1 -0
  334. package/dist/src/request-runtime-binding.js +1 -0
  335. package/dist/src/request.js +1 -0
  336. package/dist/src/result-serialization.js +1 -0
  337. package/dist/src/retry.js +1 -0
  338. package/dist/src/rolldown-runtime.js +1 -1
  339. package/dist/src/runner-cache-metadata.js +2 -0
  340. package/dist/src/runner-client.js +1 -1
  341. package/dist/src/runner-disposal.js +1 -1
  342. package/dist/src/runner-operations-facade.js +1 -0
  343. package/dist/src/runner-owner-facade.js +1 -0
  344. package/dist/src/runner-owner-state.js +1 -0
  345. package/dist/src/runner-presentation.js +1 -0
  346. package/dist/src/runner.js +1 -0
  347. package/dist/src/{runtime-transport.js → runtime-transport-hints.js} +1 -1
  348. package/dist/src/runtime.js +3 -3
  349. package/dist/src/runtime2.js +4 -4
  350. package/dist/src/runtime3.js +1 -1
  351. package/dist/src/runtime4.js +5 -3
  352. package/dist/src/runtime5.js +1 -1
  353. package/dist/src/runtime6.js +1 -1
  354. package/dist/src/runtime7.js +1 -1
  355. package/dist/src/runtime8.js +1 -1
  356. package/dist/src/runtime9.js +1 -1
  357. package/dist/src/scoped-provider.js +1 -1
  358. package/dist/src/screen-recording-completion.js +1 -0
  359. package/dist/src/screen-recording-live-handle.js +1 -0
  360. package/dist/src/screen-recording-options.js +1 -0
  361. package/dist/src/screen-recording-resource-recovery.js +1 -0
  362. package/dist/src/screen-recording-runtime.js +1 -0
  363. package/dist/src/screenshot-density.js +1 -1
  364. package/dist/src/screenshot-result.js +1 -6
  365. package/dist/src/screenshot-runtime.js +1 -0
  366. package/dist/src/screenshot.js +1 -1
  367. package/dist/src/screenshot2.js +1 -0
  368. package/dist/src/screenshot3.js +5 -0
  369. package/dist/src/script.js +1 -0
  370. package/dist/src/scroll-command.js +1 -0
  371. package/dist/src/scroll-gesture.js +1 -0
  372. package/dist/src/scroll-indicator.js +1 -0
  373. package/dist/src/sdk-batch-runner.d.ts +23 -6
  374. package/dist/src/sdk-batch-runner.js +2 -3
  375. package/dist/src/sdk-batch.js +2 -0
  376. package/dist/src/sdk-contracts.d.ts +170 -41
  377. package/dist/src/sdk-contracts.js +2 -2
  378. package/dist/src/sdk-device.js +1 -1
  379. package/dist/src/sdk-finders.d.ts +1 -1
  380. package/dist/src/sdk-finders.js +1 -1
  381. package/dist/src/sdk-io.js +1 -1
  382. package/dist/src/sdk-remote-config.d.ts +1 -1
  383. package/dist/src/sdk-remote-config.js +1 -1
  384. package/dist/src/sdk-selectors.d.ts +524 -140
  385. package/dist/src/sdk-selectors.js +1 -1
  386. package/dist/src/selection.js +1 -0
  387. package/dist/src/selector-runtime.js +1 -1
  388. package/dist/src/selectors.js +1 -1
  389. package/dist/src/semantic-index.js +1 -0
  390. package/dist/src/server.js +4 -4
  391. package/dist/src/session-allocation.js +1 -0
  392. package/dist/src/session-artifact-paths.js +1 -0
  393. package/dist/src/session-observation.js +1 -0
  394. package/dist/src/session-paths.js +1 -0
  395. package/dist/src/session-repair-tombstone.js +1 -0
  396. package/dist/src/session-routing.js +1 -0
  397. package/dist/src/session-runtime-admission.js +1 -0
  398. package/dist/src/session-snapshot.js +1 -0
  399. package/dist/src/session-store.js +4 -0
  400. package/dist/src/session-target-evidence.js +1 -1
  401. package/dist/src/session2.js +5 -27
  402. package/dist/src/settings.js +1 -0
  403. package/dist/src/shared.js +2 -2
  404. package/dist/src/simctl-facade.js +1 -0
  405. package/dist/src/simctl.js +1 -1
  406. package/dist/src/simulator-facade.js +1 -0
  407. package/dist/src/simulator.js +1 -1
  408. package/dist/src/snapshot-capture-annotations.js +1 -0
  409. package/dist/src/snapshot-desktop-projection.js +1 -0
  410. package/dist/src/snapshot-diagnostics.js +1 -0
  411. package/dist/src/snapshot-process.js +1 -0
  412. package/dist/src/snapshot-quality-backend-capabilities.js +1 -0
  413. package/dist/src/snapshot-quality-verdict.js +1 -0
  414. package/dist/src/snapshot-runtime-binding.js +1 -0
  415. package/dist/src/snapshot-runtime.js +1 -1
  416. package/dist/src/snapshot-scope.js +1 -1
  417. package/dist/src/snapshot-state.js +1 -0
  418. package/dist/src/snapshot.js +1 -8
  419. package/dist/src/snapshot2.js +1 -1
  420. package/dist/src/snapshot3.js +1 -1
  421. package/dist/src/snapshot4.js +1 -0
  422. package/dist/src/src.js +1 -1
  423. package/dist/src/src2.js +1 -1
  424. package/dist/src/src3.js +1 -2
  425. package/dist/src/src4.js +1 -1
  426. package/dist/src/src5.js +1 -0
  427. package/dist/src/src6.js +1 -0
  428. package/dist/src/src7.js +2 -0
  429. package/dist/src/src8.js +115 -0
  430. package/dist/src/startup-recovery-fence.js +1 -0
  431. package/dist/src/status-markers.js +1 -0
  432. package/dist/src/string-enum.js +1 -1
  433. package/dist/src/success-text.js +1 -0
  434. package/dist/src/surface-snapshot.js +1 -0
  435. package/dist/src/surface-snapshot2.js +1 -0
  436. package/dist/src/takeover.js +5 -0
  437. package/dist/src/tool-provider-facade.js +1 -0
  438. package/dist/src/tool-provider.js +4 -3
  439. package/dist/src/tool-provider2.js +1 -1
  440. package/dist/src/tool-provider3.js +1 -1
  441. package/dist/src/toolchain-probe.js +2 -0
  442. package/dist/src/touch-reference-frame.js +1 -0
  443. package/dist/src/touch-runtime.js +1 -0
  444. package/dist/src/transport.js +3 -0
  445. package/dist/src/tree.js +1 -0
  446. package/dist/src/ttl-memo.js +1 -0
  447. package/dist/src/tv-remote.js +1 -0
  448. package/dist/src/type-text-runtime.js +1 -0
  449. package/dist/src/undici.js +99 -0
  450. package/dist/src/update-check.js +1 -1
  451. package/dist/src/verified-file.js +1 -1
  452. package/dist/src/version.js +1 -1
  453. package/dist/src/video.js +2 -2
  454. package/dist/src/web.js +2 -1
  455. package/dist/src/web2.js +1 -0
  456. package/dist/src/webdriver-ios-snapshot.js +1 -0
  457. package/dist/src/webdriver-source.js +1 -0
  458. package/dist/src/window-state.js +1 -0
  459. package/linux/atspi-dump.py +54 -9
  460. package/package.json +58 -35
  461. package/server.json +9 -3
  462. package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.10.apk.sha256 +0 -1
  463. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.10.apk +0 -0
  464. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.10.apk.sha256 +0 -1
  465. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CoordinateTextEntryTests.swift +0 -4
  466. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+FlatSnapshotFiltering.swift +0 -168
  467. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+LifecycleCacheTests.swift +0 -6
  468. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+RecordingTests.swift +0 -4
  469. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SelectorMatchPolicyTests.swift +0 -4
  470. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotPresentation.swift +0 -183
  471. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotPresentationTests.swift +0 -0
  472. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotTraversalIdentityTests.swift +0 -4
  473. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryPolicyTests.swift +0 -4
  474. package/dist/src/appearance.js +0 -1
  475. package/dist/src/apps.js +0 -5
  476. package/dist/src/audio-probe.js +0 -1
  477. package/dist/src/cli-grammar.js +0 -1
  478. package/dist/src/command-catalog.js +0 -1
  479. package/dist/src/debug-symbols.js +0 -5
  480. package/dist/src/device-input-state.js +0 -2
  481. package/dist/src/device-ready.js +0 -1
  482. package/dist/src/dispatch.js +0 -1
  483. package/dist/src/handler-utils.js +0 -1
  484. package/dist/src/helper-package-install.js +0 -1
  485. package/dist/src/host-process.js +0 -3
  486. package/dist/src/ime-lifecycle.js +0 -2
  487. package/dist/src/ime-recovery-marker.js +0 -1
  488. package/dist/src/input-actions3.js +0 -1
  489. package/dist/src/install-artifact.js +0 -1
  490. package/dist/src/install-artifact2.js +0 -1
  491. package/dist/src/interaction-common.js +0 -1
  492. package/dist/src/interaction-runtime.js +0 -1
  493. package/dist/src/interaction-snapshot.js +0 -1
  494. package/dist/src/manifest.js +0 -1
  495. package/dist/src/method-scope.js +0 -1
  496. package/dist/src/png-resize.js +0 -1
  497. package/dist/src/process-lock.js +0 -1
  498. package/dist/src/runner-lease.js +0 -1
  499. package/dist/src/runner-sequence.js +0 -1
  500. package/dist/src/script-source-bundle.js +0 -16
  501. package/dist/src/sdk-android-adb.d.ts +0 -245
  502. package/dist/src/sdk-android-adb.js +0 -4
  503. package/dist/src/sdk.js +0 -1
  504. package/dist/src/setting-state.js +0 -1
  505. package/dist/src/shell-quote.js +0 -1
  506. package/dist/src/snapshot-session.js +0 -1
  507. package/dist/src/timing-safe-equal.js +0 -1
  508. package/dist/src/unsupported-interactor.js +0 -1
  509. package/dist/src/verdict.js +0 -1
  510. /package/dist/src/{recording-telemetry.js → telemetry.js} +0 -0
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime.js";import{_ as t}from"./sdk-contracts.js";import{Jr as n,Pt as r}from"./sdk-batch-runner.js";import{A as i,_ as a,f as o}from"./sdk-android-adb.js";import{t as s}from"./timeouts.js";import{t as c}from"./scoped-provider.js";import{i as l,n as ee,o as te,r as ne}from"./agent-browser-tool.js";function u(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function d(e,t){return u(e)?e[t]:void 0}function f(e,t){let n=d(e,t);return typeof n==`string`?n:void 0}function re(e,t){let n=d(e,t);return typeof n==`boolean`?n:void 0}function p(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}const ie=[h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j];function ae(e){let t=ie.map(e=>`${e.toString()};`).join(``),n=se(e.action),r=m(e.durationMs),i=m(e.bucketMs);return`(()=>{${t}return ${j.name}({action:${n},durationMs:${r},bucketMs:${i}})})()`}function oe(e){let t=r(ce(e),{source:`media-elements`,backend:`agent-browser`,durationMs:0,elapsedMs:0,bucketMs:1e3,activeFallback:!1,mediaElementCount:0,sourceCount:0});return{...t,source:`media-elements`,mediaElementCount:t.mediaElementCount??0}}function se(e){switch(e){case`start`:return`'start'`;case`stop`:return`'stop'`;default:return`'status'`}}function m(e){return e===void 0||!Number.isFinite(e)?`undefined`:String(Math.trunc(e))}function h(e){return!Number.isFinite(e)||e<=0?-90:Math.max(-90,Math.min(0,Math.round(20*Math.log10(e))))}function g(e,t){e.notes.includes(t)||e.notes.push(t)}function _(){return Array.from(document.querySelectorAll(`audio,video`))}function v(e,t){if(!e||e.state===`stopped`)return e;clearInterval(e.timer),clearTimeout(e.timeout),e.timer=void 0,e.timeout=void 0,e.state=`stopped`,e.active=!1,e.reason=t,e.stoppedAt=Date.now();for(let t of e.analysers)try{t.analyser.disconnect(),t.source.disconnect(),t.audible&&t.source.connect(e.context.destination)}catch{}if(e.resumeOnGesture){for(let t of[`click`,`pointerdown`,`keydown`])window.removeEventListener(t,e.resumeOnGesture,!0);e.resumeOnGesture=void 0}return e}function y(e){let t=window.AudioContext||window.webkitAudioContext;if(!t)return;let n=window[e];if(n&&n.state!==`closed`)return n;let r=new t;return window[e]=r,r}function b(e,t,n){if(!(!t.currentSrc&&!t.src&&t.readyState===0))try{window[n]||(window[n]=new WeakMap);let r=window[n].get(t);return r||(r=e.context.createMediaElementSource(t),window[n].set(t,r)),r.disconnect(),{source:r,audible:!0}}catch{return}}function x(e,t){if(!(!t||typeof t.getAudioTracks!=`function`)&&t.getAudioTracks().length!==0)return{source:e.context.createMediaStreamSource(t),audible:!1}}function S(e,t){if(typeof t.captureStream==`function`)return x(e,t.captureStream())}function C(e,t){let n=e.context.createAnalyser();n.fftSize=2048,t.source.connect(n),n.connect(t.audible?e.context.destination:e.sink),e.analysers.push({...t,analyser:n,buffer:new Float32Array(n.fftSize)})}function w(e,t){let n=_();e.mediaElementCount=n.length;for(let r of n){if(e.seen.has(r))continue;let n=x(e,r.srcObject)??S(e,r)??b(e,r,t);if(!n){g(e,`Some media elements do not expose capturable audio to Web Audio.`);continue}e.seen.add(r),C(e,n)}e.sourceCount=e.analysers.length,e.sourceCount===0&&g(e,`No capturable page media audio sources were found yet.`)}function T(e){let t=0,n=0,r=0;for(let i of e.analysers){i.analyser.getFloatTimeDomainData(i.buffer);for(let e of i.buffer)t+=e*e,n+=1,r=Math.max(r,Math.abs(e))}return{rms:n>0?Math.sqrt(t/n):0,peak:r}}function E(e){let t=Math.ceil(e.durationMs/e.bucketMs)+2;e.rmsDbfs.length>t&&e.rmsDbfs.splice(0,e.rmsDbfs.length-t),e.peakDbfs.length>t&&e.peakDbfs.splice(0,e.peakDbfs.length-t)}function D(e,t){if(!e||e.state!==`running`)return;w(e,t);let n=T(e),r=h(n.rms),i=h(n.peak);e.rmsDbfs.push(r),e.peakDbfs.push(i),e.heard=e.heard||r>-90||i>-90,E(e),Date.now()-e.startedAt>=e.durationMs&&v(e,`duration`)}function O(e,t){return{audio:`probe`,state:`stopped`,active:!1,heard:!1,source:`media-elements`,backend:`agent-browser`,durationMs:Number(e.durationMs)||1e4,elapsedMs:0,bucketMs:Number(e.bucketMs)||1e3,sampleCount:0,mediaElementCount:_().length,sourceCount:0,rmsDbfs:[],peakDbfs:[],notes:t}}function k(e,t,n,r){return e?{audio:`probe`,state:e.state,active:e.state===`running`,heard:e.heard,source:`media-elements`,backend:`agent-browser`,durationMs:e.durationMs,elapsedMs:Math.max(0,Math.min((e.stoppedAt||Date.now())-e.startedAt,e.durationMs)),bucketMs:e.bucketMs,sampleCount:e.rmsDbfs.length,mediaElementCount:_().length,sourceCount:e.sourceCount,rmsDbfs:e.rmsDbfs.slice(),peakDbfs:e.peakDbfs.slice(),startedAt:new Date(e.startedAt).toISOString(),stoppedAt:e.stoppedAt?new Date(e.stoppedAt).toISOString():void 0,reason:e.reason,notes:[n,r,...e.notes]}:O(t,[n,r])}function A(e,t,n,r,i,a,o){t&&v(t,`restarted`);let s=y(r);if(!s)return O(e,[`Web Audio API is not available in this browser context.`]);let c=s.createGain();c.gain.value=0,c.connect(s.destination);let l={state:`running`,active:!0,context:s,sink:c,seen:new WeakSet,analysers:[],mediaElementCount:0,sourceCount:0,durationMs:Math.max(100,Number(e.durationMs)||1e4),bucketMs:Math.max(100,Number(e.bucketMs)||1e3),startedAt:Date.now(),stoppedAt:void 0,reason:void 0,heard:!1,rmsDbfs:[],peakDbfs:[],notes:[]};try{s.resume()}catch{g(l,`AudioContext could not be resumed by the probe.`)}l.resumeOnGesture=()=>{try{s.resume()}catch{g(l,`AudioContext could not be resumed from a user gesture.`)}};for(let e of[`click`,`pointerdown`,`keydown`])window.addEventListener(e,l.resumeOnGesture,{capture:!0,once:!0});return w(l,i),l.timer=setInterval(()=>D(l,i),l.bucketMs),l.timeout=setTimeout(()=>v(l,`duration`),l.durationMs),window[n]=l,k(l,e,a,o)}function j(e){let t=`__agentDeviceAudioProbe`,n=`__agentDeviceAudioProbeSources`,r=`Audio probe samples HTML media elements exposed to Web Audio; it is not whole-tab or system audio capture.`,i=`URL-backed media elements may be routed through the probe AudioContext while they are observed.`,a=window[t];return a&&a.state===`running`&&Date.now()-a.startedAt>=a.durationMs&&(D(a,n),v(a,`duration`)),e.action===`start`?A(e,a,t,`__agentDeviceAudioProbeContext`,n,r,i):e.action===`stop`?(a&&D(a,n),v(a,`manual`),k(a,e,r,i)):(a&&D(a,n),k(a,e,r,i))}function ce(e){return u(e)?u(e.result)?e.result:e:{}}function le(e,t={}){let n=ue(e),r=me(t.limit),i=t.include===`headers`||t.include===`all`,a=n.slice(-r).reverse().map(e=>fe(e,i)),o=t.include===`body`||t.include===`all`?[`agent-browser network requests does not expose request or response bodies.`]:void 0;return{entries:a,backend:`agent-browser`,redacted:!1,...o?{notes:o}:{}}}function ue(e){let t=u(e)&&Array.isArray(e.requests)?e.requests:e;return Array.isArray(t)?t.filter(de).map(e=>({headers:M(e.headers),method:f(e,`method`),mimeType:f(e,`mimeType`),requestId:f(e,`requestId`),resourceType:f(e,`resourceType`),responseHeaders:M(e.responseHeaders),status:p(e,`status`),timestamp:pe(e.timestamp),url:f(e,`url`)})):[]}function de(e){return u(e)}function fe(e,t){let r=e.timestamp===void 0?void 0:N(e.timestamp),i=n({requestId:e.requestId,resourceType:e.resourceType,mimeType:e.mimeType});return n({timestamp:r,method:e.method,url:e.url,status:e.status,requestHeaders:t?e.headers:void 0,responseHeaders:t?e.responseHeaders:void 0,metadata:Object.keys(i).length>0?i:void 0})}function M(e){if(!u(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&(t[n]=r);return Object.keys(t).length>0?t:void 0}function pe(e){if(typeof e==`number`||typeof e==`string`)return e}function N(e){if(typeof e==`string`){let t=Number(e);return Number.isFinite(t)?N(t):e}let t=e>1e10?e:e*1e3,n=new Date(t);return Number.isNaN(n.getTime())?String(e):n.toISOString()}function me(e){return typeof e!=`number`||!Number.isInteger(e)?25:Math.max(1,Math.min(e,200))}async function he(e,t){let n=_e(f(e,`snapshot`)??``,I(d(e,`refs`)));return t&&await ge(n,t),{nodes:n.map((e,t)=>({...e.node,index:t})),truncated:re(e,`truncated`)}}async function ge(e,t){for(let n=0;n<e.length;n+=8){let r=e.slice(n,n+8),i=await Promise.all(r.map(e=>t(e.ref)));for(let[e,t]of i.entries())t&&(r[e].node.rect=t)}}function _e(e,t){let n=new Map(t.map(e=>[e.ref,e])),r=[],i=new Set,a=new Map;for(let t of e.split(/\r?\n/)){let e=be(t);if(!e)continue;i.add(e);let o=n.get(e)?.data,s=ve(t),c=P(t,o,s),l=ye(a,s);l!==void 0&&(c.parentIndex=l),r.push({ref:e,node:{...c,index:r.length}}),a.set(s,r.length-1)}for(let e of t)i.has(e.ref)||r.push({ref:e.ref,node:{...F(e.data),index:r.length}});return r}function P(e,t,n){let r=xe(e)??R(t,[`role`,`type`]);return{index:0,type:r,role:r,label:Se(e)??R(t,[`label`,`name`,`text`]),value:Ce(e)??R(t,[`value`]),depth:n,enabled:z(t,[`enabled`]),focused:z(t,[`focused`])}}function F(e){let t=R(e,[`role`,`type`]);return{index:0,type:t,role:t,label:R(e,[`label`,`name`,`text`]),value:R(e,[`value`]),enabled:z(e,[`enabled`]),focused:z(e,[`focused`])}}function I(e){return Array.isArray(e)?e.flatMap(e=>{let t=u(e)?e:void 0,n=L(R(t,[`ref`,`id`])??String(e));return n?[{ref:n,data:t}]:[]}):u(e)?Object.entries(e).flatMap(([e,t])=>{let n=L(e);return n?[{ref:n,data:u(t)?t:void 0}]:[]}):[]}function ve(e){let t=e.match(/^\s*/)?.[0].length??0;return Math.floor(t/2)}function ye(e,t){for(let n=t-1;n>=0;--n){let t=e.get(n);if(t!==void 0)return t}}function be(e){return L(e.match(/\bref=['"]?(@?e\d+)['"]?/i)?.[1]??e.match(/@?(e\d+)\b/i)?.[1])}function L(e){let t=e?.trim().replace(/^@/,``);return t&&/^e\d+$/i.test(t)?t.toLowerCase():null}function xe(e){return e.replace(/\[[^\]]*ref[^\]]*\]/gi,``).replace(/@?e\d+\b/gi,``).replace(/^[\s|├└─>*-]+/g,``).trim().match(/^([A-Za-z][\w-]*)\b/)?.[1]}function Se(e){return e.match(/"([^"]+)"/)?.[1]??e.match(/'([^']+)'/)?.[1]}function Ce(e){return we(e)??e.match(/\bvalue=(?:"([^"]*)"|'([^']*)'|([^\s\]]+))/i)?.slice(1).find(B)??e.match(/\bvalue:\s*(?:"([^"]*)"|'([^']*)'|([^\s\]]+))/i)?.slice(1).find(B)}function we(e){return e.match(/\]\s*:\s*(.+)$/)?.[1]?.trim()||void 0}function R(e,t){if(e)for(let n of t){let t=e[n];if(typeof t==`string`&&t.length>0)return t}}function z(e,t){if(e)for(let n of t){let t=e[n];if(typeof t==`boolean`)return t}}function B(e){return typeof e==`string`}const V=`agent-browser`,H="Run `agent-device web setup` to install the managed web backend.";function U(e={}){let t=e.session?.trim(),n=async(n,r)=>await Pe(n,{session:t,options:e,signal:r});return{async open(e){await n([`open`,e])},async close(){await n([`close`])},async startRecording(e){await n([`record`,`start`,e])},async stopRecording(){await n([`record`,`stop`])},async snapshot(e){return await Ae(t=>n(t,e?.signal),e)},async screenshot(e,t){await n([`screenshot`,...t?.fullscreen?[`--full`]:[],e])},async setViewport(e,t){await n([`set`,`viewport`,String(e),String(t)])},async click(e,t){await W(n,e,t)},async hover(e,t){await G(n,e,t)},async hoverRef(e){await n([`hover`,J(e)])},async clickRef(e){await n([`click`,J(e)])},async fill(e,t,r){await W(n,e,t),await n([`press`,Ve()]),await n([`keyboard`,`type`,r])},async fillRef(e,t){await n([`fill`,J(e),t])},async typeText(e){await n([`keyboard`,`type`,e])},async scroll(e,t){return await Te(n,e,t),t?.durationMs===void 0?{}:{durationMs:t.durationMs}},async dumpNetwork(e){return le(await n([`network`,`requests`]),e)},async probeAudio(e){return oe(await n([`eval`,ae(e)]))}}}async function Te(e,t,n){let r=Ee(n);for(let n of r)await e(ke(t,n.distance)),n.delayAfterMs>0&&await s(n.delayAfterMs)}function Ee(e){let t=e?.pixels??e?.amount,n=e?.durationMs;if(n===void 0||n<=0)return[{distance:t,delayAfterMs:0}];let r=Math.max(1,Math.min(20,Math.ceil(n/50))),i=n/Math.max(1,r-1);return De(e,r).map((e,t)=>({distance:e,delayAfterMs:t<r-1?i:0}))}function De(e,t){let n=e?.pixels??e?.amount??300;return e?.amount!==void 0&&e.pixels===void 0?Array.from({length:t},()=>n/t):Oe(Math.round(n),t)}function Oe(e,t){let n=Math.floor(e/t),r=e-n*t;return Array.from({length:t},(e,t)=>t<r?n+1:n)}function ke(e,t){return[`scroll`,e,...t===void 0?[]:[String(t)]]}async function W(e,t,n){await G(e,t,n),await e([`mouse`,`down`]),await e([`mouse`,`up`])}async function G(e,t,n){await e([`mouse`,`move`,String(Math.round(t)),String(Math.round(n))])}async function Ae(e,t){return await he(await e(je(t)),t?.includeRects?async t=>await Me(e,t):void 0)}function je(e){return[`snapshot`,...e?.interactiveOnly?[`--interactive`]:[],...e?.raw?[]:[`--compact`],...typeof e?.depth==`number`?[`--depth`,String(e.depth)]:[],...e?.scope?[`--selector`,e.scope]:[]]}async function Me(e,t){try{return He(await e([`get`,`box`,J(t)]))}catch(e){if(Ne(e))return;throw e}}function Ne(e){let t=e instanceof Error?e.message:String(e);return!/\bstale\b/i.test(t)&&/\bbox\b|not visible|not found|no element/i.test(t)}async function Pe(e,t){let{session:n,options:r,signal:i}=t,a=[...e,`--json`,...n?[`--session`,n]:[]],o=await Fe(a,r,i);return Le(Re(o.stdout,o.stderr,a,o.exitCode),o,a)}async function Fe(e,t,n){let r=``,i=``,o=0;try{await Ie(t);let s=await l({stateDir:t.stateDir}),c=await a(s.command,e,{allowFailure:!0,env:s.env,timeoutMs:3e4,signal:n});r=c.stdout,i=c.stderr,o=c.exitCode}catch(t){throw ze(t,e)}return{stdout:r,stderr:i,exitCode:o}}async function Ie(e){if(!e.openWebSessionNames)return;let t=ee({stateDir:e.stateDir});if(t.installed)try{await te(t,{openWebSessionNames:e.openWebSessionNames()})}catch(e){i({level:`warn`,phase:`web_agent_browser_provider_orphan_cleanup_failed`,data:{error:e instanceof Error?e.message:String(e)}})}}function Le(e,n,r){if(!u(e))return e;if((e.success??e.ok)===!1)throw new t(q(e.code),Be(e),{cmd:V,args:r,hint:f(e,`hint`)??H,agentBrowserError:e.error});if(n.exitCode!==0)throw new t(`COMMAND_FAILED`,`agent-browser command failed`,o(n,{cmd:V,args:r,stdout:n.stdout.slice(0,500),stderr:n.stderr.slice(0,500),hint:f(e,`hint`)??H}));return Object.hasOwn(e,`data`)?e.data:e}function Re(e,n,r,i){try{return JSON.parse(e)}catch(a){let o=i!==0;throw new t(`COMMAND_FAILED`,o?`agent-browser command failed`:`agent-browser returned invalid JSON`,{cmd:V,args:r,...o?{exitCode:i}:{},stdout:e.slice(0,500),stderr:n.slice(0,500),hint:H},a instanceof Error?a:void 0)}}function ze(e,n){let r=ne(e);return r.code===`TOOL_MISSING`?new t(`TOOL_MISSING`,r.message,{...r.details??{},cmd:V,args:n,hint:K(r)},r):r.code===`COMMAND_FAILED`?new t(`COMMAND_FAILED`,r.message,{...r.details??{},cmd:V,args:n,hint:K(r)},r):r}function K(e){return typeof e.details?.hint==`string`?e.details.hint:H}function Be(e){let t=e.error;if(typeof t==`string`&&t.trim())return t.trim();if(u(t)){let e=f(t,`message`)??f(t,`error`);if(e)return e}return f(e,`message`)??`agent-browser command failed`}function q(e){return typeof e==`string`&&e.length>0?e:`COMMAND_FAILED`}function J(e){return e.startsWith(`@`)?e:`@${e}`}function Ve(){return process.platform===`darwin`?`Meta+a`:`Control+a`}function He(e){let t=u(e)&&u(e.box)?e.box:e;if(u(t))return Ue(t)??We(t)}function Ue(e){return Y(p(e,`x`),p(e,`y`),p(e,`width`),p(e,`height`))}function We(e){let t=p(e,`left`),n=p(e,`top`),r=p(e,`right`),i=p(e,`bottom`);return Y(t,n,X(r,t),X(i,n))}function Y(e,t,n,r){if(!(e===void 0||t===void 0||n===void 0||r===void 0))return{x:e,y:t,width:n,height:r}}function X(e,t){return e===void 0||t===void 0?void 0:e-t}var Ge=e({hasScopedWebProvider:()=>Ke,resolveWebProvider:()=>Q,withWebProvider:()=>$});const Z=c(U());function Q(e){return Z.resolve(e)}function Ke(){return Z.hasScope()}async function $(e,t){return await Z.run(e,t)}export{U as i,Q as n,$ as r,Ge as t};
1
+ import{t as e}from"./scoped-provider.js";import{createAgentBrowserWebProvider as t}from"./agent-browser-provider.js";const n=t(),r=e(n);function i(e){return r.resolve(e)}function a(){return r.hasScope()}async function o(e,t){return await r.run(e,t)}export{a as hasScopedWebProvider,i as resolveWebProvider,o as withWebProvider};
@@ -0,0 +1 @@
1
+ const e={browserStack:`browserstack`,awsDeviceFarm:`aws-device-farm`},t=new Set(Object.values(e));function n(e){return e!==void 0&&t.has(e)}export{n,e as t};
package/dist/src/proxy.js CHANGED
@@ -1,2 +1,2 @@
1
- import{E as e,_ as t}from"./sdk-contracts.js";import{Ct as n,_t as r}from"./script-source-bundle.js";import{a as i,i as a}from"./agent-device-client.js";import{dt as o,ft as s,gt as c,lt as l,mt as u,r as d,ut as f}from"./screenshot-result.js";import{t as p}from"./timing-safe-equal.js";import{t as m}from"./shared.js";import{randomBytes as h,randomUUID as g}from"node:crypto";import{pipeline as ee}from"node:stream/promises";import{Readable as _}from"node:stream";import v from"node:http";const y=`${l}/`,b=[`content-type`,`content-range`,`x-artifact-type`,`x-artifact-filename`,`x-artifact-hash`,`x-artifact-hash-algorithm`,f],x=[`content-type`,`content-disposition`,`x-request-id`];function S(e){let t=P(e);return v.createServer((e,n)=>{C(e,n,t).catch(e=>{X(n,e)})})}async function C(e,t,n){let r=te(e.url??`/`);if(e.method===`GET`&&r===`/health`){await w(t,n);return}if(!L(r,e.method)){t.statusCode=404,t.end(`Not found`);return}let i;if(r===`/rpc`&&(i=(await c(e,n.maxRpcBodyBytes,`Proxy request body is too large.`)).toString(`utf8`)),!U(e,n.clientToken,i)){Y(t,r,q(i));return}await E({req:e,res:t,route:r,options:n,rpcBody:i})}async function w(e,t){let n=await T(t);e.statusCode=200,e.setHeader(`content-type`,`application/json`),e.end(JSON.stringify(d(`agent-device-proxy`,{upstream:n})))}async function T(e){let t=new URL(u(e.upstreamBaseUrl,`health`)),n=await e.fetchImpl(t,{method:`GET`,headers:V({headers:{}},e.upstreamToken,`/health`),signal:AbortSignal.timeout(e.upstreamTimeoutMs)}),r=await n.text();try{return r?JSON.parse(r):{ok:n.ok,status:n.status}}catch{return{ok:n.ok,status:n.status}}}async function E(e){let{req:t,res:n,route:r,options:i,rpcBody:a}=e,o=B(i.upstreamBaseUrl,r,t.url??`/`),s=t.method??`GET`,c=V(t,i.upstreamToken,r),l=H(t,r,a,i.upstreamToken);await D({req:t,res:n,route:r,response:await i.fetchImpl(o,{method:s,headers:c,signal:AbortSignal.timeout(i.upstreamTimeoutMs),...l?{body:l,duplex:`half`}:{}}),clientToken:i.clientToken})}async function D(e){let{req:t,res:n,route:r,response:i,clientToken:a}=e;if(n.statusCode=i.status,O(i,n),k(t,n),z(r)){await A({req:t,res:n,response:i,clientToken:a});return}await N(i,n)}function O(e,t){for(let n of x){let r=e.headers.get(n);r&&t.setHeader(n,r)}}function k(e,t){t.hasHeader(`x-request-id`)||t.setHeader(`x-request-id`,J(e))}async function A(e){let{req:t,res:n,response:r,clientToken:i}=e,a=await r.text();n.setHeader(`content-type`,r.headers.get(`content-type`)??`application/json`),n.end(j(a,t,i))}function j(e,t,n){let r;try{r=JSON.parse(e)}catch{return e}if(!r||typeof r!=`object`)return e;let i=r;if(!i.upload||typeof i.upload.url!=`string`)return e;let a=M(i.upload.url,t);if(!a)return e;let s=i.upload.headers&&typeof i.upload.headers==`object`?{...i.upload.headers}:{};return Object.assign(s,o(n)),JSON.stringify({...r,upload:{...i.upload,url:a,headers:s}})}function M(e,t){let n;try{n=new URL(e)}catch{return null}if(!n.pathname.startsWith(`/upload/`))return null;let r=typeof t.headers.host==`string`?t.headers.host:``;if(!r)return null;let i=new URL(t.url??`/`,`http://127.0.0.1`).pathname,a=i.lastIndexOf(`/upload/preflight`),o=a>=0?i.slice(0,a):``,s=t.headers[`x-forwarded-proto`],c=Array.isArray(s)?s[0]:s,l=new URL(`${c||`http`}://${r}`);return l.pathname=`${o}${n.pathname}`,l.search=n.search,l.toString()}async function N(e,t){if(!e.body){t.end();return}await ee(_.fromWeb(e.body),t)}function P(e){return{upstreamBaseUrl:F(e.upstreamBaseUrl,`upstreamBaseUrl`),upstreamToken:I(e.upstreamToken,`upstreamToken`),clientToken:I(e.clientToken,`clientToken`),maxRpcBodyBytes:e.maxRpcBodyBytes??1048576,upstreamTimeoutMs:e.upstreamTimeoutMs??3e5,fetchImpl:e.fetchImpl??fetch}}function F(e,n){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`)throw Error(`unsupported protocol`);return t.toString().replace(/\/+$/,``)}catch(r){throw new t(`INVALID_ARGS`,`Invalid ${n}`,{[n]:e},r)}}function I(e,n){let r=e.trim();if(!r)throw new t(`INVALID_ARGS`,`Proxy ${n} is required.`);return r}function te(e){let t=new URL(e,`http://127.0.0.1`).pathname;return t===`/agent-device`?`/`:t.startsWith(y)?`/${t.slice(y.length)}`:t}function L(e,t){return e===`/rpc`?t===`POST`:R(e,t)?!0:e===`/artifacts`||e===`/artifacts/`||e.startsWith(`/artifacts/`)?t===`GET`:!1}function R(e,t){return e===`/upload`||z(e)||e===`/upload/finalize`?t===`POST`:e.startsWith(`/upload/direct/`)?t===`PUT`:!1}function z(e){return e===`/upload/preflight`}function B(e,t,n){let r=new URL(u(e,t)),i=n.indexOf(`?`);return i>=0&&(r.search=n.slice(i)),r}function V(e,t,n){let r=new Headers;for(let t of b){let n=e.headers[t];typeof n==`string`&&n.trim()&&r.set(t,n)}n===`/rpc`&&!r.has(`content-type`)&&r.set(`content-type`,`application/json`);for(let[e,n]of Object.entries(o(t)))r.set(e,n);return r}function H(e,t,n,r){if(!(e.method===`GET`||e.method===`HEAD`))return t===`/rpc`?G(n??``,r):e}function U(e,t,n){let r=W(e,n);return r.length>0&&p(r,t)}function W(e,t){let n=typeof e.headers.authorization==`string`?e.headers.authorization:``;if(n.toLowerCase().startsWith(`bearer `))return n.slice(7);let r=e.headers[`x-agent-device-token`];if(typeof r==`string`)return r;if(t){let e=K(t);if(e)return e}return``}function G(e,t){let n=JSON.parse(e);return n.params={...n.params??{},token:t},JSON.stringify(n)}function K(e){try{let t=JSON.parse(e);return typeof t.params?.token==`string`?t.params.token:``}catch{return``}}function q(e){if(!e)return null;try{return JSON.parse(e).id??null}catch{return null}}function J(e){let t=e.headers[`x-request-id`];return typeof t==`string`&&t.trim()?t.trim().slice(0,128):g()}function Y(n,r,i){if(n.statusCode=401,n.setHeader(`content-type`,`application/json`),r===`/rpc`){n.end(JSON.stringify({jsonrpc:`2.0`,id:i,error:{code:-32001,message:`Invalid proxy token`,data:e(new t(`UNAUTHORIZED`,`Invalid proxy token`))}}));return}n.end(JSON.stringify({ok:!1,error:`Invalid proxy token`,code:`UNAUTHORIZED`}))}function X(t,n){if(t.headersSent){t.destroy(n instanceof Error?n:void 0);return}let r=e(n);t.statusCode=r.code===`INVALID_ARGS`?400:500,t.setHeader(`content-type`,`application/json`),t.end(JSON.stringify({ok:!1,error:r.message,code:r.code}))}const Z=async({positionals:e,flags:n})=>{if(e.length>0)throw new t(`INVALID_ARGS`,`proxy does not accept positional arguments.`);let r=await Q(n);return m(n,r,()=>oe(r)),await se(),!0};async function Q(e){let n=i({session:`default`,command:`proxy`,positionals:[],flags:{stateDir:e.stateDir,daemonBaseUrl:``,daemonTransport:`http`,daemonServerMode:`http`}}),r=await a(n),o=ne(r.info.httpPort),c=re(e),l=S({upstreamBaseUrl:o,upstreamToken:r.info.token,clientToken:c});await ie(l,e.proxyHost?.trim()||`127.0.0.1`,e.proxyPort??0);let u=l.address();if(!u||typeof u==`string`)throw new t(`COMMAND_FAILED`,`Proxy did not bind to a TCP address.`);let d=`http://${ae(u.address)}:${u.port}`;return{proxyBaseUrl:d,agentDeviceBaseUrl:s(d),token:c,upstreamBaseUrl:o,stateDir:n.paths.baseDir}}function ne(e){if(!e)throw new t(`COMMAND_FAILED`,`Local daemon HTTP endpoint is unavailable.`,{hint:`Retry after cleaning daemon state, or run proxy with a fresh --state-dir.`});return`http://127.0.0.1:${e}`}function re(e){return e.daemonAuthToken?.trim()||h(32).toString(`hex`)}function ie(e,t,n){return new Promise((r,i)=>{e.once(`error`,i),e.listen(n,t,()=>{e.off(`error`,i),r()})})}function ae(e){return e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e}function oe(e,t={}){let r=t.useColor??n(),i=$(`✓`,`green`,r),a=$(e.proxyBaseUrl,`cyan`,r),o=$(`<tunnel URL>`,`cyan`,r),s=$(e.token,`yellow`,r);return[`${i} Proxy listening at ${a}`,``,`Provide this to the agent-device instance connecting:`,``,`Daemon base URL: ${o}`,`Daemon auth token: ${s}`].join(`
2
- `)}function $(e,t,n){return n?r(e,t,{validateStream:!1}):e}function se(){return new Promise(()=>{})}export{Z as proxyCommand};
1
+ import{C as e,M as t}from"./sdk-contracts.js";import{a as n,c as r,d as i,f as a,l as o,m as s,o as c,r as l,s as u,u as d}from"./transport.js";import{i as f,s as p}from"./daemon-client-lifecycle.js";import{r as m}from"./version.js";import{t as h}from"./shared.js";import{n as ee,t as te}from"./color.js";import{randomBytes as ne,randomUUID as g}from"node:crypto";import{Readable as _}from"node:stream";import{pipeline as v}from"node:stream/promises";import y from"node:http";function b(e){let t=S(e);if(!t)return!1;let n=T(t.meta);return C(n)?!1:w(t.source)||w(n?.installSource)}function x(n,r){let i=new e(`INVALID_ARGS`,`Invalid params: an install source of kind "path" names a file on the daemon host and is not accepted through the proxy`,{hint:`Upload the artifact, or use a "url" or "github-actions-artifact" source.`});n.statusCode=400,n.setHeader(`content-type`,`application/json`),n.end(JSON.stringify({jsonrpc:`2.0`,id:r,error:{code:-32602,message:i.message,data:t(i)}}))}function S(e){if(e)try{return T(T(JSON.parse(e))?.params)}catch{return}}function C(e){let t=e?.uploadedArtifactId;return typeof t==`string`&&t.trim().length>0}function w(e){return T(e)?.kind===`path`}function T(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}const E=`${c}/`,D=[`content-type`,`content-range`,`x-artifact-type`,`x-artifact-filename`,`x-artifact-hash`,`x-artifact-hash-algorithm`,o],O=[`content-type`,`content-disposition`,`x-request-id`];function k(e){let t=V(e);return y.createServer((e,n)=>{A(e,n,t).catch(e=>{de(n,e)})})}async function A(e,t,n){let r=W(e.url??`/`);if(e.method===`GET`&&r===`/health`){await j(t,n);return}if(!G(r,e.method)){t.statusCode=404,t.end(`Not found`);return}let i;if(r===`/rpc`&&(i=(await l(e,n.maxRpcBodyBytes,`Proxy request body is too large.`)).toString(`utf8`)),!ae(e,n.clientToken,i)){ue(t,r,Z(i));return}if(b(i)){x(t,Z(i));return}await N({req:e,res:t,route:r,options:n,rpcBody:i})}async function j(e,t){let n=await M(t);e.statusCode=200,e.setHeader(`content-type`,`application/json`),e.end(JSON.stringify(d(`agent-device-proxy`,m(),{upstream:n})))}async function M(e){let t=new URL(s(e.upstreamBaseUrl,`health`)),n=await e.fetchImpl(t,{method:`GET`,headers:X({headers:{}},e.upstreamToken,`/health`),signal:AbortSignal.timeout(e.upstreamTimeoutMs)}),r=await n.text();try{return r?JSON.parse(r):{ok:n.ok,status:n.status}}catch{return{ok:n.ok,status:n.status}}}async function N(e){let{req:t,res:n,route:r,options:i,rpcBody:a}=e,o=Y(i.upstreamBaseUrl,r,t.url??`/`),s=t.method??`GET`,c=X(t,i.upstreamToken,r),l=ie(t,r,a,i.upstreamToken);await F({req:t,res:n,route:r,response:await i.fetchImpl(o,{method:s,headers:c,signal:P(t,n,i.upstreamTimeoutMs),...l?{body:l,duplex:`half`}:{}}),clientToken:i.clientToken})}function P(t,n,r){let i=new AbortController,a=()=>{n.writableFinished||i.signal.aborted||i.abort(new e(`COMMAND_FAILED`,`Proxy client disconnected before the upstream response ended`))};return t.on(`aborted`,a),n.on(`close`,a),AbortSignal.any([i.signal,AbortSignal.timeout(r)])}async function F(e){let{req:t,res:n,route:r,response:i,clientToken:a}=e;if(n.statusCode=i.status,I(i,n),L(t,n),J(r)){await R({req:t,res:n,response:i,clientToken:a});return}await B(i,n)}function I(e,t){for(let n of O){let r=e.headers.get(n);r&&t.setHeader(n,r)}}function L(e,t){t.hasHeader(`x-request-id`)||t.setHeader(`x-request-id`,le(e))}async function R(e){let{req:t,res:n,response:r,clientToken:i}=e,a=await r.text();n.setHeader(`content-type`,r.headers.get(`content-type`)??`application/json`),n.end(z(a,t,i))}function z(e,t,n){let r;try{r=JSON.parse(e)}catch{return e}if(!r||typeof r!=`object`)return e;let a=r;if(!a.upload||typeof a.upload.url!=`string`)return e;let o=re(a.upload.url,t);if(!o)return e;let s=a.upload.headers&&typeof a.upload.headers==`object`?{...a.upload.headers}:{};return Object.assign(s,i(n)),JSON.stringify({...r,upload:{...a.upload,url:o,headers:s}})}function re(e,t){let n;try{n=new URL(e)}catch{return null}if(!n.pathname.startsWith(`/upload/`))return null;let r=typeof t.headers.host==`string`?t.headers.host:``;if(!r)return null;let i=new URL(t.url??`/`,`http://127.0.0.1`).pathname,a=i.lastIndexOf(`/upload/preflight`),o=a>=0?i.slice(0,a):``,s=t.headers[`x-forwarded-proto`],c=Array.isArray(s)?s[0]:s,l=new URL(`${c||`http`}://${r}`);return l.pathname=`${o}${n.pathname}`,l.search=n.search,l.toString()}async function B(e,t){if(!e.body){t.end();return}await v(_.fromWeb(e.body),t)}function V(e){return{upstreamBaseUrl:H(e.upstreamBaseUrl,`upstreamBaseUrl`),upstreamToken:U(e.upstreamToken,`upstreamToken`),clientToken:U(e.clientToken,`clientToken`),maxRpcBodyBytes:e.maxRpcBodyBytes??1048576,upstreamTimeoutMs:e.upstreamTimeoutMs??3e5,fetchImpl:e.fetchImpl??fetch}}function H(t,n){try{let e=new URL(t);if(e.protocol!==`http:`&&e.protocol!==`https:`)throw Error(`unsupported protocol`);return e.toString().replace(/\/+$/,``)}catch(r){throw new e(`INVALID_ARGS`,`Invalid ${n}`,{[n]:t},r)}}function U(t,n){let r=t.trim();if(!r)throw new e(`INVALID_ARGS`,`Proxy ${n} is required.`);return r}function W(e){let t=new URL(e,`http://127.0.0.1`).pathname;return t===`/agent-device`?`/`:t.startsWith(E)?`/${t.slice(E.length)}`:t}function G(e,t){return e===`/rpc`?t===`POST`:q(e,t)?!0:e===`/artifacts`||e===`/artifacts/`||e.startsWith(`/artifacts/`)||K(e)?t===`GET`:!1}function K(e){let t=e.split(`/`);return t.length===6&&t[1]===`sessions`&&t[3]===`requests`&&t[5]===`diagnostics`&&t[2]!==``&&t[4]!==``}function q(e,t){return e===`/upload`||J(e)||e===`/upload/finalize`?t===`POST`:e.startsWith(`/upload/direct/`)?t===`PUT`:!1}function J(e){return e===`/upload/preflight`}function Y(e,t,n){let r=new URL(s(e,t)),i=n.indexOf(`?`);return i>=0&&(r.search=n.slice(i)),r}function X(e,t,n){let a=new Headers;for(let t of D){let n=e.headers[t];typeof n==`string`&&n.trim()&&a.set(t,n)}n===`/rpc`&&!a.has(`content-type`)&&a.set(`content-type`,`application/json`),n===`/rpc`&&a.set(u,r);for(let[e,n]of Object.entries(i(t)))a.set(e,n);return a}function ie(e,t,n,r){if(e.method!==`GET`&&e.method!==`HEAD`)return t===`/rpc`?se(n??``,r):e}function ae(e,t,r){let i=oe(e,r);return i.length>0&&n(i,t)}function oe(e,t){let n=typeof e.headers.authorization==`string`?e.headers.authorization:``;if(n.toLowerCase().startsWith(`bearer `))return n.slice(7);let r=e.headers[`x-agent-device-token`];if(typeof r==`string`)return r;if(t){let e=ce(t);if(e)return e}return``}function se(e,t){let n=JSON.parse(e);return n.params={...n.params??{},token:t},JSON.stringify(n)}function ce(e){try{let t=JSON.parse(e);return typeof t.params?.token==`string`?t.params.token:``}catch{return``}}function Z(e){if(!e)return null;try{return JSON.parse(e).id??null}catch{return null}}function le(e){let t=e.headers[`x-request-id`];return typeof t==`string`&&t.trim()?t.trim().slice(0,128):g()}function ue(n,r,i){if(n.statusCode=401,n.setHeader(`content-type`,`application/json`),r===`/rpc`){n.end(JSON.stringify({jsonrpc:`2.0`,id:i,error:{code:-32001,message:`Invalid proxy token`,data:t(new e(`UNAUTHORIZED`,`Invalid proxy token`))}}));return}n.end(JSON.stringify({ok:!1,error:`Invalid proxy token`,code:`UNAUTHORIZED`}))}function de(e,n){if(e.destroyed)return;if(e.headersSent){e.destroy(n instanceof Error?n:void 0);return}let r=t(n);e.statusCode=r.code===`INVALID_ARGS`?400:500,e.setHeader(`content-type`,`application/json`),e.end(JSON.stringify({ok:!1,error:r.message,code:r.code}))}const fe=async({positionals:t,flags:n})=>{if(t.length>0)throw new e(`INVALID_ARGS`,`proxy does not accept positional arguments.`);let r=await pe(n);return await h(n,r,()=>_e(r)),await ve(),!0};async function pe(t){let n=p({session:`default`,command:`proxy`,positionals:[],flags:{stateDir:t.stateDir,daemonBaseUrl:``,daemonTransport:`http`,daemonServerMode:`http`}}),r=await f(n),i=me(r.info.httpPort),o=Q(t),s=k({upstreamBaseUrl:i,upstreamToken:r.info.token,clientToken:o});await he(s,t.proxyHost?.trim()||`127.0.0.1`,t.proxyPort??0);let c=s.address();if(!c||typeof c==`string`)throw new e(`COMMAND_FAILED`,`Proxy did not bind to a TCP address.`);let l=`http://${ge(c.address)}:${c.port}`;return{proxyBaseUrl:l,agentDeviceBaseUrl:a(l),token:o,upstreamBaseUrl:i,stateDir:n.paths.baseDir}}function me(t){if(!t)throw new e(`COMMAND_FAILED`,`Local daemon HTTP endpoint is unavailable.`,{hint:`Retry after cleaning daemon state, or run proxy with a fresh --state-dir.`});return`http://127.0.0.1:${t}`}function Q(e){return e.daemonAuthToken?.trim()||ne(32).toString(`hex`)}function he(e,t,n){return new Promise((r,i)=>{e.once(`error`,i),e.listen(n,t,()=>{e.off(`error`,i),r()})})}function ge(e){return e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e}function _e(e,t={}){let n=t.useColor??ee(),r=$(`✓`,`green`,n),i=$(e.proxyBaseUrl,`cyan`,n),a=$(`<tunnel URL>`,`cyan`,n),o=$(e.token,`yellow`,n);return[`${r} Proxy listening at ${i}`,``,`Provide this to the agent-device instance connecting:`,``,`Daemon base URL: ${a}`,`Daemon auth token: ${o}`].join(`
2
+ `)}function $(e,t,n){return n?te(e,t,{validateStream:!1}):e}function ve(){return new Promise(()=>{})}export{fe as proxyCommand};
@@ -0,0 +1 @@
1
+ const e=[/^!,\s+/,/^(warn|warning|error):\s+/,/\b(?:possible\s+)?unhandled (?:promise )?rejection\b/],t=[`open debugger to view warnings`,`getsnapshot should be cached to avoid an infinite loop`,`unique "key" prop`,`unique 'key' prop`,`virtualizedlists should never be nested`,`failed prop type`];function n(e){return i(e.label?.trim())&&c(e.rect)}function r(e,t){let r=e.label?.trim();return!r||!n(e)?!1:t.some(e=>e.label?.trim()===r&&s(e))}function i(n){let r=n?.trim().toLowerCase();return r?t.some(e=>r.includes(e))||e.some(e=>e.test(r)):!1}function a(e){return/^dismiss(?:\s*\([^)]*\))?$/i.test(e)}function o(e){return/^minimi[sz]e(?:\b|\s|\()/i.test(e)}function s(e){return e.rect?e.rect.width>=120&&e.rect.height>=36&&e.rect.height<=180:!1}function c(e){return e?e.x<=1&&e.y<=1&&e.width>=300&&e.height>=600:!1}export{a,r as i,i as n,o,n as r,s as t};
@@ -1 +1 @@
1
- import{E as e}from"./sdk-contracts.js";import{Jr as t}from"./sdk-batch-runner.js";import{yn as n}from"./script-source-bundle.js";import{n as r}from"./command-catalog.js";import{t as i}from"./verdict.js";import{c as a}from"./runtime.js";import{a as o,o as s,s as c,t as l}from"./dispatch.js";import{bt as u}from"./internal/daemon.js";import{t as d}from"./interaction-snapshot.js";import{n as f,t as p}from"./interaction-common.js";async function m(t){let{req:n,sessionName:o,sessionStore:l}=t;if(n.command!==r.reactNative)return null;let u=h(n.positionals??[]);if(!u.ok)return u.response;let f=l.get(o);if(!f)return s();let p=c(r.reactNative,f.device,{message:`react-native dismiss-overlay is not supported on this device`});if(p)return p;try{let e=await d(f,n.flags,l,t.contextFromFlags,{interactiveOnly:!0});if(i(e.snapshotQuality))return _(e.snapshotQuality);let r=a(e.nodes),o=r.primaryAction;return o?await v(t,f,e,o):g(r.detected)}catch(t){return{ok:!1,error:e(t)}}}function h(e){return e.length===1&&e[0]===`dismiss-overlay`?{ok:!0}:{ok:!1,response:o(`INVALID_ARGS`,`react-native supports only: dismiss-overlay`)}}function g(e){return e?o(`COMMAND_FAILED`,`React Native overlay detected, but no safe dismiss target was found`,{hint:`Use screenshot --overlay-refs for visual evidence and report the overlay instead of pressing the warning body.`}):{ok:!0,data:{action:`dismiss-overlay`,detected:!1,dismissed:!1,...n(`No React Native overlay detected`)}}}function _(e){return o(`COMMAND_FAILED`,`React Native overlay state could not be determined because the accessibility tree is unreadable`,{reason:e.reason,hint:`The snapshot quality verdict is sparse. Use screenshot as visual truth; if an overlay is visible, report it or navigate with coordinates, then retry snapshot or dismiss-overlay on a readable screen.`})}async function v(e,r,i,a){let{req:o,sessionStore:s}=e,c=Date.now();u(r);let d=await l(r.device,`press`,[String(a.point.x),String(a.point.y)],o.flags?.out,e.contextFromFlags(o.flags,r.appBundleId,r.trace?.outPath))??{},m=Date.now(),h=await y(e,r),g=t({...f(i.nodes),...d,action:`dismiss-overlay`,overlayAction:a.action,x:a.point.x,y:a.point.y,ref:a.ref,label:a.label,warning:a.warning,dismissed:!0,verified:h.verified,verificationRequired:!h.verified,verificationWarning:h.verificationWarning,nextCommand:h.nextCommand,...n(b(h))});return p({session:r,sessionStore:s,command:o.command,positionals:o.positionals??[],flags:o.flags,result:g,responseData:g,actionStartedAt:c,actionFinishedAt:m})}async function y(e,t){let{req:n,sessionStore:r}=e,o=await d(t,n.flags,r,e.contextFromFlags,{interactiveOnly:!0});return i(o.snapshotQuality)?{verified:!1,verificationWarning:`React Native overlay dismissal could not be verified because the post-dismiss accessibility tree is unreadable. Use screenshot as visual truth.`,nextCommand:`agent-device screenshot`}:a(o.nodes).detected?{verified:!1,verificationWarning:`React Native overlay is still detected after dismissal. Use screenshot --overlay-refs for visual evidence and report the overlay instead of pressing the warning body.`,nextCommand:`agent-device screenshot --overlay-refs`}:{verified:!0}}function b(e){return e.verified?`React Native overlay dismiss action sent and verified gone`:`React Native overlay dismiss action sent, but verification still detects an overlay`}export{m as handleReactNativeCommands};
1
+ import{M as e}from"./sdk-contracts.js";import{D as t}from"./sdk-batch-runner.js";import{C as n}from"./runtime.js";import{n as r}from"./catalog.js";import{n as i}from"./success-text.js";import{a,i as o}from"./request-runtime-binding.js";import{T as s,d as c,u as l}from"./session-snapshot.js";import{n as u}from"./touch-reference-frame.js";import{t as d}from"./snapshot-quality-verdict.js";import{o as f}from"./interaction-ref-policy.js";import{captureSnapshotForSession as p}from"./interaction.js";async function m(t){let{req:i,sessionName:s,sessionStore:l}=t;if(i.command!==r.reactNative)return null;let u=h(i.positionals??[]);if(!u.ok)return u.response;let f=l.get(s);if(!f)return a();let m=await c({device:f.device,command:`press`,requiresCapture:!1,inspectFacts:t.inspectFacts,bindDevice:t.bindDevice,unavailableResponse:e=>o(`UNSUPPORTED_OPERATION`,`react-native dismiss-overlay is not supported on this device`,void 0,e.hint?{hint:e.hint}:void 0)});if(!m.ok)return m.response;try{let e=await p(f,i.flags,l,t.contextFromFlags,{interactiveOnly:!0});if(d(e.snapshotQuality))return _(e.snapshotQuality);let r=n(e.nodes),a=r.primaryAction;return a?await v(t,f,e,a,m.runtime):g(r.detected)}catch(t){return{ok:!1,error:e(t)}}}function h(e){return e.length===1&&e[0]===`dismiss-overlay`?{ok:!0}:{ok:!1,response:o(`INVALID_ARGS`,`react-native supports only: dismiss-overlay`)}}function g(e){return e?o(`COMMAND_FAILED`,`React Native overlay detected, but no safe dismiss target was found`,{hint:`Use screenshot --overlay-refs for visual evidence and report the overlay instead of pressing the warning body.`}):{ok:!0,data:{action:`dismiss-overlay`,detected:!1,dismissed:!1,...i(`No React Native overlay detected`)}}}function _(e){return o(`COMMAND_FAILED`,`React Native overlay state could not be determined because the accessibility tree is unreadable`,{reason:e.reason,hint:`The snapshot quality verdict is sparse. Use screenshot as visual truth; if an overlay is visible, report it or navigate with coordinates, then retry snapshot or dismiss-overlay on a readable screen.`})}async function v(e,n,r,a,c){let{req:d,sessionStore:p}=e,m=e.contextFromFlags(d.flags,n.appBundleId,n.trace?.outPath),h=l(c,m).tapPoint;if(!h)return o(`UNSUPPORTED_OPERATION`,`react-native dismiss-overlay is not supported on this device`);let g=Date.now();s(n);let _=await h(a.point),v=Date.now(),x=await y(e,n),S=t({...u(r.nodes),..._,action:`dismiss-overlay`,overlayAction:a.action,x:a.point.x,y:a.point.y,ref:a.ref,label:a.label,warning:a.warning,dismissed:!0,verified:x.verified,verificationRequired:!x.verified,verificationWarning:x.verificationWarning,nextCommand:x.nextCommand,...i(b(x))});return f({session:n,sessionStore:p,command:d.command,positionals:d.positionals??[],flags:d.flags,result:S,responseData:S,actionStartedAt:g,actionFinishedAt:v})}async function y(e,t){let{req:r,sessionStore:i}=e,a=await p(t,r.flags,i,e.contextFromFlags,{interactiveOnly:!0});return d(a.snapshotQuality)?{verified:!1,verificationWarning:`React Native overlay dismissal could not be verified because the post-dismiss accessibility tree is unreadable. Use screenshot as visual truth.`,nextCommand:`agent-device screenshot`}:n(a.nodes).detected?{verified:!1,verificationWarning:`React Native overlay is still detected after dismissal. Use screenshot --overlay-refs for visual evidence and report the overlay instead of pressing the warning body.`,nextCommand:`agent-device screenshot --overlay-refs`}:{verified:!0}}function b(e){return e.verified?`React Native overlay dismiss action sent and verified gone`:`React Native overlay dismiss action sent, but verification still detects an overlay`}export{m as handleReactNativeCommands};
@@ -1 +1 @@
1
- import{E as e,_ as t}from"./sdk-contracts.js";import{w as n}from"./location-coordinates.js";import{$ as r,et as i,tt as a}from"./sdk-batch-runner.js";import{C as o,E as s}from"./sdk-device.js";import{on as c}from"./script-source-bundle.js";import{n as l,r as u}from"./recording-export-quality.js";import{i as d}from"./output-path.js";import{p as f}from"./dispatch.js";import{C as p,Q as m,S as h,et as g,t as _,w as v,x as y}from"./internal/daemon.js";import{t as b}from"./device-ready.js";import{t as x}from"./handler-utils.js";import{t as S}from"./recording-telemetry.js";import C from"node:path";function w(e){let r=n(`record`,e.flags);if(r)throw new t(`INVALID_ARGS`,r);let i=e.flags?.fps;if(i!==void 0&&(!Number.isInteger(i)||i<1||i>120))throw new t(`INVALID_ARGS`,`fps must be an integer between 1 and 120`);let a=u(e.flags?.quality);if(e.flags?.quality!==void 0&&a===void 0)throw new t(`INVALID_ARGS`,`quality must be one of: ${l.join(`, `)} (legacy numeric values 5-10 are accepted)`);return{scope:T(e.flags?.recordingScope),...i===void 0?{}:{fps:i},...a===void 0?{}:{exportQuality:a},showTouches:e.flags?.hideTouches!==!0,hideTouchesRequested:e.flags?.hideTouches===!0}}function T(e){if(e===void 0)return`app`;if(e===`app`||e===`device`||e===`system`)return e;throw new t(`INVALID_ARGS`,`record scope must be app, device, or system`)}function E(e){return{ok:!1,error:{code:`INVALID_ARGS`,message:m(e)?`record start with app scope and an explicit session requires an active app session; run open <app> first, or use --scope device to record the full screen`:`record start defaults to app scope and requires an active app session; run open <app> first, or use --scope device to record the full screen`}}}function D(e,t,n){return{ok:!0,data:{recording:`started`,outPath:e.clientOutPath??n,sessionStateDir:t,recordingBackend:e.backend,recordingScope:e.scope,recordOnlySession:e.recordOnlySession,activeSessionApp:e.activeSessionApp,showTouches:e.showTouches}}}function O(e){return{action:`start`,...e.clientOutPath?{requestedFileName:C.basename(e.clientOutPath)}:{},showTouches:e.showTouches}}function k(e){return{ok:!1,error:{code:`UNSUPPORTED_OPERATION`,message:`record is not supported on this device`,hint:e.hint??`Select an Apple, Android, physical HarmonyOS, or web target that supports screen recording.`,details:{reason:e.reason}}}}function A(e){let t=[j(e)];if(e.chunks&&e.chunks.length>1&&t.push(...e.chunks.slice(1).map(e=>({field:`chunkPath`,artifactType:`screen-recording-chunk`,path:e.path,localPath:e.clientOutPath,fileName:C.basename(e.clientOutPath??e.path)}))),e.telemetryPath){let n=e.clientOutPath?S(e.clientOutPath):void 0;t.push({field:`telemetryPath`,artifactType:`screen-recording-telemetry`,path:e.telemetryPath,localPath:n,fileName:C.basename(e.telemetryPath)})}return{ok:!0,data:{recording:`stopped`,outPath:e.outPath,telemetryPath:e.telemetryPath,artifacts:t,recordingBackend:e.backend,recordingScope:e.scope,recordOnlySession:e.recordOnlySession,activeSessionApp:e.activeSessionApp,durationMs:Math.max(0,e.completedAt-e.startedAt),showTouches:e.showTouches,warning:e.warning,overlayWarning:e.overlayWarning,chunks:e.chunks?.map(e=>({index:e.index,path:e.clientOutPath??e.path}))}}}function j(e){return{field:`outPath`,artifactType:`screen-recording`,path:e.outPath,localPath:e.clientOutPath,fileName:C.basename(e.clientOutPath??e.outPath)}}async function M(t){try{return await N(t)}catch(t){return{ok:!1,error:e(t)}}}async function N(e){let{req:t,sessionName:n,sessionStore:r}=e,i=r.get(n),{plan:a,scope:o}=P(t,i);if(a.kind===`start`&&!c(o)&&!i)return E(t);let s=await F(e,i);return a.kind===`start`?await I(e,s,w(t),a.use):await B(e,s,a.kind)}function P(e,t){let n=T(e.flags?.recordingScope);return{scope:n,plan:r({action:e.positionals?.[0],scope:n,hasLiveHandle:t?.screenRecording!==void 0})}}async function F(e,t){let n=t?.device??await f(e.req.flags??{});return await e.retainDeviceExecutionLock(n.id),t||(await b(n),U(e,n))}async function I(e,t,n,r){if(t.screenRecording)return{ok:!1,error:{code:`INVALID_ARGS`,message:`recording already in progress`}};let a=(await e.bindDevice(t.device,i)).facts.screenRecordingStart;if(!a.available)return k(a);let o=await e.bindDevice(t.device,r),{fence:s,outputPaths:c}=L(e,t),l=await o.operations.screenRecordingStart(R(e,t,n,s,c.outputPath));await y({admissionLedger:e.admissionLedger,session:t,sessionName:e.sessionName,sessionStore:e.sessionStore,device:t.device,owner:o.owner,fence:s,...l,throwIfCanceled:e.throwIfCanceled});let u=e.sessionStore.get(e.sessionName)?.screenRecording;if(!u)throw TypeError(`Screen recording adoption did not publish a live handle`);let d=u.handle.inspect();return x(e.sessionStore,t,e.req,e.req.command,O(d)),D(d,e.sessionStore.ensureSessionDir(e.sessionName),c.requestedPath)}function L(e,t){let n=v.store.resolvePath(e.sessionStore.resolveSessionDir(e.sessionName));return{fence:v.createNextFence({admissionLedger:e.admissionLedger,resourcePath:n,device:t.device}),outputPaths:d({requestedPath:e.req.positionals?.[1],platform:t.device.platform,cwd:e.req.meta?.cwd})}}function R(e,t,n,r,i){return{sessionId:e.sessionName,outputPath:i,clientOutputPath:e.req.meta?.clientArtifactPaths?.outPath,scope:n.scope,showTouches:n.showTouches,hideTouchesRequested:n.hideTouchesRequested,recordOnlySession:t.recordOnlySession===!0,activeSessionApp:z(t),exportQuality:n.exportQuality,fps:n.fps,fence:r}}function z(e){if(e.appBundleId)return{bundleId:e.appBundleId,...e.appName?{name:e.appName}:{}}}async function B(e,t,n){let r;try{r=n===`stop-live`?await h({session:t,sessionName:e.sessionName,sessionStore:e.sessionStore}):await H(e,t)}catch(n){throw V(e,t),n}let i=A(r);return x(e.sessionStore,t,e.req,e.req.command,{action:`stop`,outPath:r.outPath,...r.clientOutPath?{requestedFileName:C.basename(r.clientOutPath)}:{},showTouches:r.showTouches}),t.recordOnlySession&&e.sessionStore.delete(e.sessionName),i}function V(e,t){if(!t.recordOnlySession)return;let n=v.store.resolvePath(e.sessionStore.resolveSessionDir(e.sessionName)),r=v.store.read(n);r.status===`decoded`&&r.envelope.lifecycle===`completed`&&e.sessionStore.delete(e.sessionName)}async function H(e,n){let r=v.store.resolvePath(e.sessionStore.resolveSessionDir(e.sessionName)),i=v.store.read(r);if(i.status!==`decoded`||i.envelope.lifecycle!==`open`)throw new t(`INVALID_ARGS`,`no active recording`);if(i.envelope.sessionId!==e.sessionName)throw new t(`COMMAND_FAILED`,`Screen recording recovery record does not belong to the requested session`,{reason:`runtime-contract-invalid`});if(!s(i.envelope.device,o(n.device)))throw new t(`COMMAND_FAILED`,`Screen recording recovery device does not match the selected device`,{reason:`runtime-contract-invalid`});return await p({resourcePath:r,scope:e.requestScope,acquireControl:async(t,r)=>_({runtime:await e.bindExactDevice(n.device,t.owner,t.fence,a,r),dispose:async()=>{}})})}function U(e,t){return{name:e.sessionName,sessionScope:g(e.req),device:t,createdAt:Date.now(),recordOnlySession:!0,actions:[]}}export{M as t};
1
+ import{C as e,M as t}from"./sdk-contracts.js";import{c as n}from"./capture.js";import{H as r}from"./registry.js";import{D as i,w as a}from"./sdk-device.js";import{D as o,E as s,T as c}from"./sdk-batch.js";import{n as l,r as u}from"./recording-export-quality.js";import{c as d}from"./session-store.js";import{i as f}from"./output-path.js";import{n as p}from"./dispatch-resolve.js";import{n as m}from"./request-runtime-binding.js";import{a as h,t as g}from"./session-routing.js";import{a as _,i as v,o as y,s as b,t as x}from"./screen-recording-resource-recovery.js";import{t as S}from"./telemetry.js";import C from"node:path";function w(t){let r=n(`record`,t.flags);if(r)throw new e(`INVALID_ARGS`,r);let i=t.flags?.fps;if(i!==void 0&&(!Number.isInteger(i)||i<1||i>120))throw new e(`INVALID_ARGS`,`fps must be an integer between 1 and 120`);let a=u(t.flags?.quality);if(t.flags?.quality!==void 0&&a===void 0)throw new e(`INVALID_ARGS`,`quality must be one of: ${l.join(`, `)} (legacy numeric values 5-10 are accepted)`);return{scope:T(t.flags?.recordingScope),...i===void 0?{}:{fps:i},...a===void 0?{}:{exportQuality:a},showTouches:t.flags?.hideTouches!==!0,hideTouchesRequested:t.flags?.hideTouches===!0}}function T(t){if(t===void 0)return`app`;if(t===`app`||t===`device`||t===`system`)return t;throw new e(`INVALID_ARGS`,`record scope must be app, device, or system`)}function E(e){return{ok:!1,error:{code:`INVALID_ARGS`,message:g(e)?`record start with app scope and an explicit session requires an active app session; run open <app> first, or use --scope device to record the full screen`:`record start defaults to app scope and requires an active app session; run open <app> first, or use --scope device to record the full screen`}}}function D(e,t,n){return{ok:!0,data:{recording:`started`,outPath:e.clientOutPath??n,sessionStateDir:t,recordingBackend:e.backend,recordingScope:e.scope,recordOnlySession:e.recordOnlySession,activeSessionApp:e.activeSessionApp,showTouches:e.showTouches}}}function O(e){return{action:`start`,...e.clientOutPath?{requestedFileName:C.basename(e.clientOutPath)}:{},showTouches:e.showTouches}}function k(e){return{ok:!1,error:{code:`UNSUPPORTED_OPERATION`,message:`record is not supported on this device`,hint:e.hint??`Select an Apple, Android, physical HarmonyOS, or web target that supports screen recording.`,details:{reason:e.reason}}}}function A(e){let t=[j(e)];if(e.chunks&&e.chunks.length>1&&t.push(...e.chunks.slice(1).map(e=>({field:`chunkPath`,artifactType:`screen-recording-chunk`,path:e.path,localPath:e.clientOutPath,fileName:C.basename(e.clientOutPath??e.path)}))),e.telemetryPath){let n=e.clientOutPath?S(e.clientOutPath):void 0;t.push({field:`telemetryPath`,artifactType:`screen-recording-telemetry`,path:e.telemetryPath,localPath:n,fileName:C.basename(e.telemetryPath)})}return{ok:!0,data:{recording:`stopped`,outPath:e.outPath,telemetryPath:e.telemetryPath,artifacts:t,recordingBackend:e.backend,recordingScope:e.scope,recordOnlySession:e.recordOnlySession,activeSessionApp:e.activeSessionApp,durationMs:Math.max(0,e.completedAt-e.startedAt),showTouches:e.showTouches,warning:e.warning,overlayWarning:e.overlayWarning,chunks:e.chunks?.map(e=>({index:e.index,path:e.clientOutPath??e.path}))}}}function j(e){return{field:`outPath`,artifactType:`screen-recording`,path:e.outPath,localPath:e.clientOutPath,fileName:C.basename(e.clientOutPath??e.outPath)}}async function M(e){try{return await N(e)}catch(e){return{ok:!1,error:t(e)}}}async function N(e){let{req:t,sessionName:n,sessionStore:i}=e,a=i.get(n),{plan:o,scope:s}=P(t,a);if(o.kind===`start`&&!r(s)&&!a)return E(t);let c=await F(e,a),{session:l}=c;return o.kind===`start`?await I(e,l,w(t),o.use,c.needsReadiness):await B(e,l,o.kind,c.needsReadiness)}function P(e,t){let n=T(e.flags?.recordingScope);return{scope:n,plan:c({action:e.positionals?.[0],scope:n,hasLiveHandle:t?.screenRecording!==void 0})}}async function F(e,t){let n=t?.device??await p(e.req.flags??{});return await e.retainDeviceExecutionLock(n.id),t?{session:t,needsReadiness:!1}:{session:U(e,n),needsReadiness:!0}}async function I(e,t,n,r,i){if(t.screenRecording)return{ok:!1,error:{code:`INVALID_ARGS`,message:`recording already in progress`}};let a=await e.bindDevice(t.device,s);i&&await m(a);let o=a.facts.screenRecordingStart;if(!o.available)return k(o);let c=await e.bindDevice(t.device,r),{fence:l,outputPaths:u}=L(e,t),f=await c.operations.screenRecordingStart(R(e,t,n,l,u.outputPath));await v({admissionLedger:e.admissionLedger,session:t,sessionName:e.sessionName,sessionStore:e.sessionStore,device:t.device,owner:c.owner,fence:l,...f,throwIfCanceled:e.throwIfCanceled});let p=e.sessionStore.get(e.sessionName)?.screenRecording;if(!p)throw TypeError(`Screen recording adoption did not publish a live handle`);let h=p.handle.inspect();return d(e.sessionStore,t,e.req,e.req.command,O(h)),D(h,e.sessionStore.ensureSessionDir(e.sessionName),u.requestedPath)}function L(e,t){let n=b.store.resolvePath(e.sessionStore.resolveSessionDir(e.sessionName));return{fence:b.createNextFence({admissionLedger:e.admissionLedger,resourcePath:n,device:t.device}),outputPaths:f({requestedPath:e.req.positionals?.[1],platform:t.device.platform,cwd:e.req.meta?.cwd})}}function R(e,t,n,r,i){return{sessionId:e.sessionName,outputPath:i,clientOutputPath:e.req.meta?.clientArtifactPaths?.outPath,scope:n.scope,showTouches:n.showTouches,hideTouchesRequested:n.hideTouchesRequested,recordOnlySession:t.recordOnlySession===!0,activeSessionApp:z(t),exportQuality:n.exportQuality,fps:n.fps,fence:r}}function z(e){if(e.appBundleId)return{bundleId:e.appBundleId,...e.appName?{name:e.appName}:{}}}async function B(e,t,n,r){let i;try{i=n===`stop-live`?await _({session:t,sessionName:e.sessionName,sessionStore:e.sessionStore}):await H(e,t,r)}catch(n){throw V(e,t),n}let a=A(i);return d(e.sessionStore,t,e.req,e.req.command,{action:`stop`,outPath:i.outPath,...i.clientOutPath?{requestedFileName:C.basename(i.clientOutPath)}:{},showTouches:i.showTouches}),t.recordOnlySession&&e.sessionStore.delete(e.sessionName),a}function V(e,t){if(!t.recordOnlySession)return;let n=b.store.resolvePath(e.sessionStore.resolveSessionDir(e.sessionName)),r=b.store.read(n);r.status===`decoded`&&r.envelope.lifecycle===`completed`&&e.sessionStore.delete(e.sessionName)}async function H(t,n,r){let s=b.store.resolvePath(t.sessionStore.resolveSessionDir(t.sessionName)),c=b.store.read(s);if(c.status!==`decoded`||c.envelope.lifecycle!==`open`)throw new e(`INVALID_ARGS`,`no active recording`);if(c.envelope.sessionId!==t.sessionName)throw new e(`COMMAND_FAILED`,`Screen recording recovery record does not belong to the requested session`,{reason:`runtime-contract-invalid`});if(!i(c.envelope.device,a(n.device)))throw new e(`COMMAND_FAILED`,`Screen recording recovery device does not match the selected device`,{reason:`runtime-contract-invalid`});return await y({resourcePath:s,scope:t.requestScope,acquireControl:async(e,i)=>{let a=await t.bindExactDevice(n.device,e.owner,e.fence,o,i);return r&&await m(a),x({runtime:a,dispose:async()=>{}})}})}function U(e,t){return{name:e.sessionName,sessionScope:h(e.req),device:t,createdAt:Date.now(),recordOnlySession:!0,actions:[]}}export{M as t};
@@ -1 +1 @@
1
- import{x as e}from"./screenshot-result.js";import{a as t}from"./dispatch.js";import{t as n}from"./handler-utils.js";import{t as r}from"./record-runtime.js";import i from"node:path";import a from"node:fs";function o(e){let n=(e.req.positionals?.[0]??``).toLowerCase();if(n!==`start`&&n!==`stop`)return t(`INVALID_ARGS`,`trace requires start|stop`);let r=e.sessionStore.get(e.sessionName);return r?n===`start`?s(e.req,e.sessionStore,r):c(e.req,e.sessionStore,r):t(`SESSION_NOT_FOUND`,`No active session`)}function s(r,o,s){if(s.trace)return t(`INVALID_ARGS`,`trace already in progress`);let c=e.expandHome(r.positionals?.[1]??o.defaultTracePath(s));return a.mkdirSync(i.dirname(c),{recursive:!0}),a.appendFileSync(c,``),s.trace={outPath:c,startedAt:Date.now()},n(o,s,r,r.command,{action:`start`,outPath:c}),{ok:!0,data:{trace:`started`,outPath:c}}}function c(e,r,a){if(!a.trace)return t(`INVALID_ARGS`,`no active trace`);let o=l(a.trace.outPath,e.positionals?.[1]);a.trace=void 0,n(r,a,e,e.command,{action:`stop`,outPath:o});let s=e.meta?.clientArtifactPaths?.outPath??o;return{ok:!0,data:{trace:`stopped`,outPath:o,artifacts:[{field:`outPath`,artifactType:`trace-log`,path:o,localPath:s,fileName:i.basename(s)}]}}}function l(t,n){if(!n)return t;let r=e.expandHome(n);return a.mkdirSync(i.dirname(r),{recursive:!0}),a.existsSync(t)?a.renameSync(t,r):a.appendFileSync(r,``),r}async function u(e){let{req:t,sessionName:n,sessionStore:i}=e,a=t.command;return a===`record`?r({req:t,sessionName:n,sessionStore:i,bindDevice:e.bindDevice,bindExactDevice:e.bindExactDevice,admissionLedger:e.admissionLedger,requestScope:e.requestScope,retainDeviceExecutionLock:e.retainDeviceExecutionLock,throwIfCanceled:e.throwIfCanceled}):a===`trace`?o({req:t,sessionName:n,sessionStore:i}):null}export{u as handleRecordTraceCommands};
1
+ import{c as e,t}from"./session-store.js";import{i as n}from"./request-runtime-binding.js";import{t as r}from"./record-runtime.js";import i from"node:path";import a from"node:fs";function o(e){let t=(e.req.positionals?.[0]??``).toLowerCase();if(t!==`start`&&t!==`stop`)return n(`INVALID_ARGS`,`trace requires start|stop`);let r=e.sessionStore.get(e.sessionName);return r?t===`start`?s(e.req,e.sessionStore,r):c(e.req,e.sessionStore,r):n(`SESSION_NOT_FOUND`,`No active session`)}function s(r,o,s){if(s.trace)return n(`INVALID_ARGS`,`trace already in progress`);let c=t.expandHome(r.positionals?.[1]??o.defaultTracePath(s));return a.mkdirSync(i.dirname(c),{recursive:!0}),a.appendFileSync(c,``),s.trace={outPath:c,startedAt:Date.now()},e(o,s,r,r.command,{action:`start`,outPath:c}),{ok:!0,data:{trace:`started`,outPath:c}}}function c(t,r,a){if(!a.trace)return n(`INVALID_ARGS`,`no active trace`);let o=l(a.trace.outPath,t.positionals?.[1]);a.trace=void 0,e(r,a,t,t.command,{action:`stop`,outPath:o});let s=t.meta?.clientArtifactPaths?.outPath??o;return{ok:!0,data:{trace:`stopped`,outPath:o,artifacts:[{field:`outPath`,artifactType:`trace-log`,path:o,localPath:s,fileName:i.basename(s)}]}}}function l(e,n){if(!n)return e;let r=t.expandHome(n);return a.mkdirSync(i.dirname(r),{recursive:!0}),a.existsSync(e)?a.renameSync(e,r):a.appendFileSync(r,``),r}async function u(e){let{req:t,sessionName:n,sessionStore:i}=e,a=t.command;return a===`record`?r({req:t,sessionName:n,sessionStore:i,bindDevice:e.bindDevice,bindExactDevice:e.bindExactDevice,admissionLedger:e.admissionLedger,requestScope:e.requestScope,retainDeviceExecutionLock:e.retainDeviceExecutionLock,throwIfCanceled:e.throwIfCanceled}):a===`trace`?o({req:t,sessionName:n,sessionStore:i}):null}export{u as handleRecordTraceCommands};
@@ -0,0 +1 @@
1
+ import{p as e}from"./sdk-contracts.js";const t=[`x`,`y`,`width`,`height`];function n(t){let n=r(t);if(!n)return null;let i=e(n);return!Number.isFinite(i.x)||!Number.isFinite(i.y)?null:i}function r(e){if(!e)return null;let t=Number(e.x),n=Number(e.y),r=Number(e.width),i=Number(e.height);return!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i)||r<0||i<0?null:{x:t,y:n,width:r,height:i}}function i(e,n){return!e||!n?!1:t.every(t=>Math.abs(e[t]-n[t])<=.5)}function a(e){return{x:o(e.x,e.width),y:o(e.y,e.height)}}function o(e,t){if(t<=1)return Math.floor(e);let n=Math.ceil(e),r=Math.floor(e+t-1);return Math.round(Math.min(r,Math.max(n,e+t/2)))}export{n as i,r as n,a as r,i as t};
@@ -0,0 +1 @@
1
+ import{C as e}from"./sdk-contracts.js";import{t}from"./src2.js";import{i as n}from"./src4.js";const r=new Map;function i(e){for(let t of e.platforms){if(r.has(t))throw Error(`PlatformPlugin already registered for platform "${t}"`);r.set(t,e)}}function a(t){let n=r.get(t);if(!n)throw new e(`UNSUPPORTED_PLATFORM`,`Unsupported platform: ${t}`);return n}function o(e){return r.get(e)}const s=[t,{id:`android`,platforms:[`android`],providers:{platformGatedResolvers:[`androidAdbProvider`]},createInteractor:async(e,t)=>{let{createAndroidInteractor:n}=await import(`./android.js`).then(e=>e.t);return n(e,void 0,t)}},{id:`harmonyos`,platforms:[`harmonyos`],createInteractor:async(e,t)=>{let{createHarmonyInteractor:n}=await import(`./harmonyos.js`);return n(e,t)}},n,{id:`linux`,platforms:[`linux`],providers:{platformGatedResolvers:[`linuxToolProvider`]},createInteractor:async()=>{let{createLinuxInteractor:e}=await import(`./linux.js`);return e()}},{id:`web`,platforms:[`web`],providers:{platformGatedResolvers:[`webProvider`]},createInteractor:async()=>{let{createWebInteractor:e}=await import(`./web2.js`);return await e()}}];let c=!1;function l(){if(!c){for(let e of s)i(e);c=!0}}export{a as n,o as r,l as t};