agent-device 0.21.0 → 0.21.2

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 (328) hide show
  1. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.0.apk → agent-device-android-ime-helper-0.21.2.apk} +0 -0
  2. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.2.apk.sha256 +1 -0
  3. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.0.manifest.json → agent-device-android-ime-helper-0.21.2.manifest.json} +4 -4
  4. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.2.apk +0 -0
  5. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.2.apk.sha256 +1 -0
  6. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.0.manifest.json → agent-device-android-snapshot-helper-0.21.2.manifest.json} +6 -6
  7. package/apple/snapshot-bridge/README.md +58 -1
  8. package/apple/snapshot-bridge/SnapshotBridge.m +6 -0
  9. package/apple/snapshot-bridge/SnapshotBridgeCapture.h +25 -0
  10. package/apple/snapshot-bridge/SnapshotBridgeCapture.m +138 -0
  11. package/apple/snapshot-bridge/SnapshotBridgeRuntime.h +1 -0
  12. package/apple/snapshot-bridge/SnapshotBridgeRuntime.m +32 -3
  13. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.h +12 -0
  14. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +20 -0
  15. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerScrollViewportPolicy.swift +413 -0
  16. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSelectorMatchPolicy.swift +15 -15
  17. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSystemSurfaceHostPolicy.swift +72 -0
  18. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTapPointPolicy.swift +63 -14
  19. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +668 -82
  20. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +48 -4
  21. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+BlockingSystemModalResolution.swift +39 -4
  22. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +1078 -211
  23. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +290 -0
  24. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Environment.swift +1 -1
  25. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Exceptions.swift +10 -10
  26. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +250 -74
  27. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Keyboard.swift +101 -42
  28. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +13 -13
  29. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +55 -43
  30. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +71 -4
  31. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+PrivateAXPresentation.swift +144 -7
  32. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScreenRecorder.swift +13 -1
  33. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollGesture.swift +216 -17
  34. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift +206 -22
  35. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +289 -42
  36. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotBackendCapabilities.swift +92 -22
  37. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +617 -122
  38. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotTiming.swift +79 -4
  39. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedCommitDeadline.swift +71 -71
  40. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +92 -6
  41. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedTextEntry.swift +67 -67
  42. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +4 -4
  43. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +17 -17
  44. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryFocus.swift +30 -30
  45. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryReadiness.swift +31 -31
  46. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextInputCandidatePolicy.swift +28 -0
  47. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextInputProbe.swift +101 -0
  48. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +19 -19
  49. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Transport.swift +55 -17
  50. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TvRemote.swift +26 -5
  51. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +126 -75
  52. package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/RecordingExportSupport.swift +8 -12
  53. package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-overlay.swift +9 -9
  54. package/dist/src/absence-observation-errors.js +1 -0
  55. package/dist/src/adapter.js +1 -1
  56. package/dist/src/adb-executor.js +1 -1
  57. package/dist/src/adb-failure.js +1 -1
  58. package/dist/src/agent-browser-lifecycle.js +1 -1
  59. package/dist/src/agent-browser-process-record.js +1 -1
  60. package/dist/src/agent-browser-provider.js +1 -1
  61. package/dist/src/agent-browser-tool.js +1 -1
  62. package/dist/src/agent-device-client.js +2 -2
  63. package/dist/src/ai-sdk.d.ts +1 -1
  64. package/dist/src/ai-sdk.js +1 -1
  65. package/dist/src/alert-runtime.js +1 -1
  66. package/dist/src/android-input-ownership.js +1 -1
  67. package/dist/src/app-catalog.js +1 -1
  68. package/dist/src/app-deployment-resolution.js +1 -1
  69. package/dist/src/app-helpers.js +1 -1
  70. package/dist/src/app-inventory-contract.js +1 -1
  71. package/dist/src/app-inventory.js +1 -1
  72. package/dist/src/app-launch.js +2 -2
  73. package/dist/src/app-lifecycle.js +3 -3
  74. package/dist/src/app-lifecycle2.js +1 -1
  75. package/dist/src/app-log-files.js +1 -1
  76. package/dist/src/app-log-runtime2.js +3 -3
  77. package/dist/src/app-resolution.js +1 -1
  78. package/dist/src/apple-runner-platform.js +1 -0
  79. package/dist/src/application-lifecycle-interaction.js +1 -1
  80. package/dist/src/archive.js +1 -1
  81. package/dist/src/artifact-download.js +1 -1
  82. package/dist/src/auth-session.js +1 -1
  83. package/dist/src/auth.js +1 -1
  84. package/dist/src/back-mode.js +1 -1
  85. package/dist/src/backend-snapshot-options.js +1 -1
  86. package/dist/src/boot-diagnostics.js +1 -1
  87. package/dist/src/browser-launch.js +1 -0
  88. package/dist/src/capture.js +1 -1
  89. package/dist/src/catalog.js +1 -1
  90. package/dist/src/cli-config.js +1 -1
  91. package/dist/src/cli-help.js +30 -26
  92. package/dist/src/cli.js +4 -4
  93. package/dist/src/click-button.js +1 -1
  94. package/dist/src/client-metro-companion.js +1 -1
  95. package/dist/src/client-metro.js +1 -1
  96. package/dist/src/client-types.d.ts +28 -13
  97. package/dist/src/code-signature-cache.js +1 -1
  98. package/dist/src/code-signature.js +1 -1
  99. package/dist/src/command-metadata.js +1 -1
  100. package/dist/src/command-schema.js +3 -3
  101. package/dist/src/command-tools.js +2 -2
  102. package/dist/src/command.js +1 -1
  103. package/dist/src/config.js +1 -1
  104. package/dist/src/connection-runtime.js +1 -1
  105. package/dist/src/connection.js +3 -3
  106. package/dist/src/contracts.d.ts +1 -1
  107. package/dist/src/contracts.js +1 -1
  108. package/dist/src/daemon-client-lifecycle.js +1 -1
  109. package/dist/src/daemon-process.js +1 -1
  110. package/dist/src/daemon-shutdown-report.js +1 -1
  111. package/dist/src/daemon.js +1 -1
  112. package/dist/src/debug-symbols-facade.js +1 -1
  113. package/dist/src/device-boot.js +1 -0
  114. package/dist/src/device-claim-inspection.js +1 -1
  115. package/dist/src/device-claim-rule.js +1 -1
  116. package/dist/src/device-input-state.d.ts +1 -1
  117. package/dist/src/device-inventory-context.js +1 -1
  118. package/dist/src/device-rotation.js +1 -1
  119. package/dist/src/device-selection-resolver.js +1 -1
  120. package/dist/src/device-session.js +1 -1
  121. package/dist/src/device2.js +1 -1
  122. package/dist/src/diagnostics.js +1 -1
  123. package/dist/src/dispatch-resolve.js +1 -1
  124. package/dist/src/doctor2.js +1 -1
  125. package/dist/src/durable-resource.js +1 -1
  126. package/dist/src/engine-eval-script.js +1 -0
  127. package/dist/src/error.js +1 -1
  128. package/dist/src/exec.js +1 -1
  129. package/dist/src/file.js +1 -1
  130. package/dist/src/find.js +1 -1
  131. package/dist/src/finders.js +1 -1
  132. package/dist/src/format.js +1 -2
  133. package/dist/src/generic-settle.js +1 -1
  134. package/dist/src/gesture-plan.js +1 -1
  135. package/dist/src/gesture-runtime.js +1 -1
  136. package/dist/src/harmonyos.js +1 -1
  137. package/dist/src/hdc.js +1 -1
  138. package/dist/src/helper.js +2 -2
  139. package/dist/src/human-control-contract.js +1 -1
  140. package/dist/src/human-control.js +1 -1
  141. package/dist/src/index.d.ts +1 -1
  142. package/dist/src/index.js +1 -1
  143. package/dist/src/input-actions.js +1 -1
  144. package/dist/src/input-actions2.js +2 -2
  145. package/dist/src/install-artifact-facade.js +1 -1
  146. package/dist/src/install-source-network-transport.js +1 -1
  147. package/dist/src/install-source2.js +1 -1
  148. package/dist/src/interaction-positionals.js +1 -1
  149. package/dist/src/interaction-ref-policy.js +1 -1
  150. package/dist/src/interaction.js +1 -1
  151. package/dist/src/interaction2.js +1 -1
  152. package/dist/src/interactor.js +5 -5
  153. package/dist/src/interactor2.js +1 -1
  154. package/dist/src/interactors.js +1 -1
  155. package/dist/src/internal/bin.js +1 -1
  156. package/dist/src/internal/daemon.js +2 -2
  157. package/dist/src/internal/png-worker.d.ts +3 -0
  158. package/dist/src/internal/png-worker.js +1 -1
  159. package/dist/src/internal/run-script-http-child.js +1 -1
  160. package/dist/src/inventory.js +2 -2
  161. package/dist/src/inventory2.js +1 -1
  162. package/dist/src/inventory3.js +1 -1
  163. package/dist/src/inventory5.js +1 -1
  164. package/dist/src/ios-snapshot-acquisition.js +1 -1
  165. package/dist/src/ios-snapshot-planning.js +1 -1
  166. package/dist/src/ios-snapshot-runtime.js +1 -1
  167. package/dist/src/ios-system-surface.js +1 -0
  168. package/dist/src/lease-scope.js +1 -1
  169. package/dist/src/lease.js +1 -1
  170. package/dist/src/limrun-runtime-dependencies.js +1 -1
  171. package/dist/src/limrun.d.ts +1 -1
  172. package/dist/src/linux.js +1 -1
  173. package/dist/src/local-interactor-operation-set.js +1 -1
  174. package/dist/src/location-coordinates.js +1 -1
  175. package/dist/src/managed-device-scope.js +1 -1
  176. package/dist/src/mechanics.js +16 -16
  177. package/dist/src/mobile-snapshot-semantics.js +1 -1
  178. package/dist/src/mp4-atoms.js +1 -0
  179. package/dist/src/multitouch-support.js +1 -1
  180. package/dist/src/observation.js +1 -1
  181. package/dist/src/open-target-resolution.js +1 -0
  182. package/dist/src/owner-identity.js +3 -3
  183. package/dist/src/parameterized-recorded-fill.js +1 -1
  184. package/dist/src/perf-facade.js +2 -2
  185. package/dist/src/perf-process-identity.js +1 -0
  186. package/dist/src/perf-runtime-operation-builder.js +1 -1
  187. package/dist/src/perf-runtime-plan.js +1 -1
  188. package/dist/src/perf.js +1 -1
  189. package/dist/src/physical-device-control.js +1 -1
  190. package/dist/src/platform-request-scope.js +1 -1
  191. package/dist/src/platform-runtime-android-adb-host.js +1 -1
  192. package/dist/src/platform-runtime-app-log-process.js +1 -1
  193. package/dist/src/platform-runtime-host.js +1 -1
  194. package/dist/src/platform-runtime-managed-owner.js +1 -1
  195. package/dist/src/platform-runtime-open-target.js +1 -1
  196. package/dist/src/platform-runtime-operation-host.js +2 -2
  197. package/dist/src/platform-runtime-runtime-hints.js +2 -2
  198. package/dist/src/platform-runtime-screen-recording-android-host.js +1 -1
  199. package/dist/src/platform-runtime-screen-recording-apple-runner-host.js +1 -1
  200. package/dist/src/platform-runtime-screen-recording-apple-runner-transport.js +1 -1
  201. package/dist/src/platform-runtime-screen-recording-apple-simulator-host.js +1 -1
  202. package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
  203. package/dist/src/platform-runtime-screen-recording-process-host.js +1 -1
  204. package/dist/src/platform-runtime-unavailable.js +1 -1
  205. package/dist/src/platform-runtime.js +1 -1
  206. package/dist/src/platform-runtime2.js +1 -1
  207. package/dist/src/png-crop-bytes.js +1 -0
  208. package/dist/src/png-worker-contract.js +1 -1
  209. package/dist/src/png.js +1 -0
  210. package/dist/src/prepare-kind.js +1 -1
  211. package/dist/src/process.js +1 -1
  212. package/dist/src/provider-device-runtime.js +1 -1
  213. package/dist/src/provider-session-ownership.js +1 -1
  214. package/dist/src/provider-webdriver.js +1 -1
  215. package/dist/src/proxy.js +1 -1
  216. package/dist/src/quality-warnings.js +1 -0
  217. package/dist/src/react-native.js +1 -1
  218. package/dist/src/record-runtime.js +1 -1
  219. package/dist/src/rect-center.js +1 -1
  220. package/dist/src/register-builtins.js +1 -1
  221. package/dist/src/registry.js +36 -36
  222. package/dist/src/remote-config2.js +1 -1
  223. package/dist/src/replay-divergence.js +1 -1
  224. package/dist/src/replay.js +2 -2
  225. package/dist/src/reporting.js +9 -8
  226. package/dist/src/request-admission.js +1 -1
  227. package/dist/src/request-cancel.js +1 -1
  228. package/dist/src/request-cancellation.js +1 -1
  229. package/dist/src/request-runtime-binding.js +1 -1
  230. package/dist/src/retry.js +1 -1
  231. package/dist/src/runner-cache-metadata.js +2 -2
  232. package/dist/src/runner-client.js +1 -1
  233. package/dist/src/runner-disposal.js +1 -1
  234. package/dist/src/runner-operations-facade.js +1 -1
  235. package/dist/src/runner-presentation.js +1 -1
  236. package/dist/src/runner.js +1 -1
  237. package/dist/src/runtime-transport-hints.js +1 -1
  238. package/dist/src/runtime.js +3 -3
  239. package/dist/src/runtime10.js +1 -0
  240. package/dist/src/runtime2.js +4 -4
  241. package/dist/src/runtime3.js +1 -1
  242. package/dist/src/runtime4.js +5 -4
  243. package/dist/src/runtime5.js +1 -1
  244. package/dist/src/runtime6.js +1 -1
  245. package/dist/src/runtime7.js +1 -1
  246. package/dist/src/runtime8.js +1 -1
  247. package/dist/src/runtime9.js +1 -1
  248. package/dist/src/screen-recording-live-handle.js +1 -1
  249. package/dist/src/screen-recording-options.js +1 -1
  250. package/dist/src/screen-recording-resource-recovery.js +1 -1
  251. package/dist/src/screenshot-density.js +1 -1
  252. package/dist/src/screenshot-runtime.js +1 -1
  253. package/dist/src/screenshot.js +1 -1
  254. package/dist/src/screenshot3.js +3 -3
  255. package/dist/src/script.js +1 -1
  256. package/dist/src/scroll-command.js +1 -1
  257. package/dist/src/scroll-gesture.js +1 -1
  258. package/dist/src/sdk-batch-runner.js +2 -2
  259. package/dist/src/sdk-batch.js +2 -2
  260. package/dist/src/sdk-contracts.d.ts +69 -26
  261. package/dist/src/sdk-contracts.js +2 -2
  262. package/dist/src/sdk-device.js +1 -1
  263. package/dist/src/sdk-finders.d.ts +1 -1
  264. package/dist/src/sdk-finders.js +1 -1
  265. package/dist/src/sdk-io.js +1 -1
  266. package/dist/src/sdk-remote-config.d.ts +1 -1
  267. package/dist/src/sdk-remote-config.js +1 -1
  268. package/dist/src/sdk-selectors.d.ts +80 -16
  269. package/dist/src/sdk-selectors.js +1 -1
  270. package/dist/src/selection.js +0 -0
  271. package/dist/src/selector-runtime.js +1 -1
  272. package/dist/src/selectors.js +1 -1
  273. package/dist/src/semantic-index.js +1 -1
  274. package/dist/src/server.js +3 -3
  275. package/dist/src/session-allocation.js +1 -1
  276. package/dist/src/session-observation.js +1 -0
  277. package/dist/src/session-routing.js +1 -1
  278. package/dist/src/session-runtime-admission.js +1 -1
  279. package/dist/src/session-snapshot.js +1 -1
  280. package/dist/src/session-store.js +3 -3
  281. package/dist/src/session-target-evidence.js +1 -1
  282. package/dist/src/session2.js +5 -5
  283. package/dist/src/settings.js +1 -1
  284. package/dist/src/simulator-boot.js +3 -0
  285. package/dist/src/simulator.js +1 -1
  286. package/dist/src/snapshot-quality-backend-capabilities.js +1 -1
  287. package/dist/src/snapshot-runtime-binding.js +1 -1
  288. package/dist/src/snapshot-runtime.js +1 -1
  289. package/dist/src/snapshot-state.js +1 -1
  290. package/dist/src/snapshot2.js +1 -1
  291. package/dist/src/snapshot3.js +1 -1
  292. package/dist/src/snapshot4.js +1 -1
  293. package/dist/src/src.js +1 -1
  294. package/dist/src/src7.js +2 -2
  295. package/dist/src/src8.js +2 -2
  296. package/dist/src/string-enum.js +1 -1
  297. package/dist/src/takeover.js +1 -1
  298. package/dist/src/telemetry.js +1 -1
  299. package/dist/src/tool-provider.js +2 -2
  300. package/dist/src/tool-provider2.js +1 -1
  301. package/dist/src/tool-provider3.js +1 -1
  302. package/dist/src/toolchain-probe.js +1 -1
  303. package/dist/src/touch-reference-frame.js +1 -0
  304. package/dist/src/touch-runtime.js +1 -1
  305. package/dist/src/transport.js +1 -1
  306. package/dist/src/tree.js +1 -1
  307. package/dist/src/tv-remote.js +1 -1
  308. package/dist/src/type-text-runtime.js +1 -1
  309. package/dist/src/update-check.js +1 -1
  310. package/dist/src/vars.js +2 -0
  311. package/dist/src/verified-file.js +1 -1
  312. package/dist/src/version.js +1 -1
  313. package/dist/src/video.js +2 -2
  314. package/dist/src/viewport.js +1 -0
  315. package/dist/src/web.js +1 -1
  316. package/dist/src/web2.js +1 -1
  317. package/dist/src/webdriver-ios-snapshot.js +1 -1
  318. package/dist/src/webdriver-source.js +1 -1
  319. package/dist/src/window-state.js +1 -0
  320. package/package.json +4 -2
  321. package/server.json +2 -2
  322. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.0.apk.sha256 +0 -1
  323. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.0.apk +0 -0
  324. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.0.apk.sha256 +0 -1
  325. package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-trim.swift +0 -93
  326. package/dist/src/platform-runtime-apple-resources.js +0 -1
  327. package/dist/src/runner-selector-query.js +0 -1
  328. package/dist/src/snapshot-quality-verdict.js +0 -1
@@ -1,4 +1,4 @@
1
- import{y as e}from"./sdk-contracts.js";import{l as t}from"./sdk-device.js";import{Yt as n,qt as r}from"./sdk-batch.js";import{n as i,o as a,r as o,s}from"./request-cancellation.js";import{n as c,t as l}from"./application-lifecycle-runtime.js";import{i as u,n as d}from"./touch-runtime.js";import{A as ee,B as te,D as ne,E as re,F as ie,G as f,H as p,I as ae,L as m,M as oe,N as h,R as g,W as se,a as ce,b as _,d as le,g as v,i as ue,k as de,m as fe,s as pe,t as me,v as y,w as he,x as b}from"./alert-runtime.js";import{n as ge}from"./audio-probe-runtime.js";import{n as _e}from"./perf-runtime.js";import{r as ve}from"./platform-runtime-unavailable.js";import{a as ye,n as be}from"./durable-resource.js";import{t as xe}from"./async-lifecycle.js";import{a as x,d as Se,f as Ce,n as we,o as Te,u as Ee}from"./src7.js";import{i as De,t as Oe}from"./gesture-admission.js";import{n as ke}from"./interactor-operation-catalog.js";import{t as S}from"./app-log-runtime.js";import{r as Ae,t as je}from"./application-lifecycle-interaction.js";import{setTimeout as Me}from"node:timers/promises";const C=Object.freeze({available:!0}),w=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose portable gesture execution yet.`}),Ne=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:Oe}),Pe=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:De});function T(e,t){if(t!==C)return h({plan:t,directionalFling:t,multiTouch:t,targetAuthoredDrag:t,viewport:t});if(e.platform!==`android`)return h({plan:w,directionalFling:w,multiTouch:w,targetAuthoredDrag:w,viewport:w});let n=e.target===`tv`;return h({plan:C,directionalFling:C,multiTouch:n?Ne:C,targetAuthoredDrag:n?Pe:C,viewport:C})}const Fe=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose home yet.`}),Ie=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose tv remote control.`}),Le=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`tv-remote is supported only on Android TV targets.`}),Re=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose keyboard actions.`}),ze=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose clipboard access yet.`}),Be=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose settings changes yet.`}),Ve=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose app switcher yet.`});function E(e,n){let r=n??C,i=Object.freeze({available:!1,reason:`unsupported-provider-mode`});return Object.freeze({...ae({focus:r}),...ne({type:r}),...u({tap:r,tapRef:i,longPress:n??(t(e)?i:r),hover:n??{available:!1,reason:`unsupported-provider-mode`,hint:`hover raises pointer hover state and is available on web targets only. On touch platforms use longpress for hold gestures.`},hoverRef:i,fill:r,fillRef:i,tapElementSelector:n??(t(e)?r:i)}),...T(e,r),...ee({scroll:r})})}function He(e){let{device:t,signal:n}=e,r=n=>e.getInteractor(t,n);return Object.freeze({...te({device:t,signal:n,resolveInteractor:r,presentIosAcquisition:e.presentIosAcquisition}),...ie({device:t,signal:n,resolveInteractor:r}),...re({device:t,signal:n,resolveInteractor:r}),...d({device:t,signal:n,resolveInteractor:r,facts:E(t),pause:async e=>await Me(e,void 0,{signal:n})}),...se({device:t,signal:n,resolveInteractor:r}),...oe({device:t,signal:n,facts:T(t,C),resolveInteractor:r}),...de({device:t,signal:n,resolveInteractor:r})})}function D(e,t){return t?Object.freeze({...b({back:t}),..._({home:t}),...y({orientation:t}),...v({tvRemote:t})}):e.platform===`android`?Object.freeze({...b({back:C}),..._({home:C}),...y({orientation:C}),...v({tvRemote:e.target===`tv`?C:Le})}):Object.freeze({...b({back:C}),..._({home:Fe}),...y({orientation:C}),...v({tvRemote:Ie})})}function O(e,t){let n=t??(e.platform===`android`?C:ze);return Object.freeze({...le({read:n,write:n})})}const Ue=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose alert inspection yet.`});function k(e,t){let n=t??(e.platform===`android`?C:Ue);return Object.freeze({...me({read:n,wait:n,accept:n,dismiss:n})})}function A(e,t){let n=t??(e.platform===`android`?C:Ve);return Object.freeze({...pe({appSwitcher:n})})}function j(e,t){return Object.freeze({...ce({triggerAppEvent:t??C})})}function M(e,t){let n=t??(e.platform===`android`?C:Be);return Object.freeze({...ue({setSetting:n})})}function N(e,t){let n=t??(e.platform===`android`?C:Re);return Object.freeze({...fe({status:n,dismiss:n,enter:n})})}const P=Object.freeze({resourceKind:S,version:1,encode:e=>({...e}),decode:e=>e.transport!==`limrun-log-poller`||e.platform!==`ios`&&e.platform!==`android`||!F(e.leaseId)||!F(e.instanceId)||!F(e.appBundleId)||!F(e.outputPath)?{status:`invalid`,message:`Invalid Limrun app-log descriptor`}:{status:`decoded`,descriptor:Object.freeze({transport:`limrun-log-poller`,platform:e.platform,leaseId:e.leaseId,instanceId:e.instanceId,appBundleId:e.appBundleId,outputPath:e.outputPath})}});function We(e){if(e.device.platform===`apple`&&!e.device.appleOs)throw TypeError(`Limrun Apple app-log persistence requires an explicit appleOs identity`);return be({resourceKind:S,sessionId:e.sessionId,device:{id:e.device.id,family:e.device.platform,...e.device.appleOs===void 0?{}:{appleOs:e.device.appleOs},kind:e.device.kind,...e.device.target===void 0?{}:{target:e.device.target},...e.device.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.device.iosPhysicalDeviceBackend}},owner:e.owner,fence:e.fence,lifecycle:`open`,descriptor:ye(P,e.descriptor)})}function F(e){return typeof e==`string`&&e.trim().length>0}async function I(e){let t=new xe,n=!1;t.defer(async()=>{n||await e.reader[Symbol.asyncDispose]()});try{let r=await e.host.outputs.readTail(e.outputPath,262144),i=await e.host.outputs.openAppend(e.outputPath);t.defer(async()=>{n||await i[Symbol.asyncDispose]()});let a=Ge(e,i,Xe(r));return n=!0,a}finally{await t[Symbol.asyncDispose]()}}function Ge(e,t,n){let r=Qe(e.reader),i=e.host.clock.now(),a=`active`,o=!1,s=n,c=(async()=>{for(;!o;){try{let n=await Ke(e);if(n.status===`timeout`){a=`failed`;return}if(o)return;let r=qe(s,n.text);s=n.text,r&&await t.write(r.endsWith(`
2
- `)?r:`${r}\n`),a=`active`}catch{if(o)return;a=`recovering`}await e.host.clock.sleep(1e3)}})(),l;return Ee({inspect:()=>({backend:r,state:a,startedAt:i}),finish:async()=>l??=(async()=>(o=!0,await c,(await Ze([e.reader,t])).length>0?(a=`failed`,{status:`cleanup-pending`,reason:`transport-failed`,message:`Limrun app-log cleanup did not settle every owned resource`}):(a=`ended`,{status:`completed`,result:{backend:r,outputPath:e.outputPath,completedAt:e.host.clock.now()}})))()})}async function Ke(e){let t=new AbortController,n=i(e.reader.readLogs(e.appBundleId,1e3),t.signal,`App-log provider read aborted`).then(e=>({status:`read`,text:e}));try{let r=await Promise.race([n,e.host.clock.sleep(5e3,t.signal).then(()=>({status:`timeout`}))]);return r.status===`timeout`&&(t.abort(),await n.catch(()=>void 0)),r}finally{t.abort()}}function qe(e,t){if(!e||!t)return t;let n=Je(t),r=Math.min(e.length,t.length),i=e.slice(e.length-r);return t.slice(Ye(i,t,n))}function Je(e){let t=new Uint32Array(e.length),n=0;for(let r=1;r<e.length;r+=1){for(;n>0&&e[r]!==e[n];)n=t[n-1];e[r]===e[n]&&(n+=1),t[r]=n}return t}function Ye(e,t,n){let r=0;for(let i=0;i<e.length;i+=1){for(;r>0&&e[i]!==t[r];)r=n[r-1];e[i]===t[r]&&(r+=1),r===t.length&&i<e.length-1&&(r=n[r-1])}return r}function Xe(e){return e.split(`
1
+ import{C as e}from"./sdk-contracts.js";import{l as t}from"./sdk-device.js";import{Jt as n,Xt as r}from"./sdk-batch.js";import{n as i,o as a,r as o,s}from"./request-cancellation.js";import{n as c,t as l}from"./application-lifecycle-runtime.js";import{i as u,n as d}from"./touch-runtime.js";import{A as ee,B as te,D as ne,E as re,F as ie,G as f,H as p,I as ae,L as m,M as oe,N as h,R as g,W as se,a as ce,b as _,d as v,g as y,i as le,k as ue,m as de,s as fe,t as pe,v as b,w as me,x}from"./alert-runtime.js";import{n as he}from"./audio-probe-runtime.js";import{n as ge}from"./perf-runtime.js";import{r as _e}from"./platform-runtime-unavailable.js";import{a as ve,n as ye}from"./durable-resource.js";import{t as be}from"./async-lifecycle.js";import{a as S,d as xe,f as Se,n as Ce,o as we,u as Te}from"./src7.js";import{i as Ee,t as De}from"./gesture-admission.js";import{n as Oe}from"./interactor-operation-catalog.js";import{t as C}from"./app-log-runtime.js";import{r as ke,t as Ae}from"./application-lifecycle-interaction.js";import{setTimeout as je}from"node:timers/promises";const w=Object.freeze({available:!0}),Me=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose portable gesture execution yet.`}),Ne=Object.freeze({available:!1,reason:`unsupported-provider-mode`}),Pe=Object.freeze({available:!1,reason:`unsupported-provider-mode`}),Fe=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:De}),Ie=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:Ee});function T(e,t){if(!t.available)return h({unsupported:t});if(e.platform!==`android`)return h({unsupported:Me});let n=e.target===`tv`;return h({unsupported:Ne,plan:w,directionalFling:w,multiTouch:n?Fe:w,targetAuthoredDrag:n?Ie:w,viewport:w})}const Le=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose home yet.`}),Re=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose tv remote control.`}),ze=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`tv-remote is supported only on Android TV targets.`}),Be=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose keyboard actions.`}),Ve=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose clipboard access yet.`}),He=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose settings changes yet.`}),Ue=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose app switcher yet.`});function E(e,n){let r=n??w,i=Object.freeze({available:!1,reason:`unsupported-provider-mode`});return Object.freeze({...ae({focus:r}),...ne({type:r}),...u({unsupported:i,tap:r,longPress:n??(t(e)?i:r),hover:n??i,fill:r,tapElementSelector:n??(t(e)?r:i)}),...T(e,r),...ee({scroll:r})})}function We(e){let{device:t,signal:n}=e,r=n=>e.getInteractor(t,n);return Object.freeze({...te({device:t,signal:n,resolveInteractor:r,presentIosAcquisition:e.presentIosAcquisition}),...ie({device:t,signal:n,resolveInteractor:r}),...re({device:t,signal:n,resolveInteractor:r}),...d({device:t,signal:n,resolveInteractor:r,facts:E(t),pause:async e=>await je(e,void 0,{signal:n})}),...se({device:t,signal:n,resolveInteractor:r}),...oe({device:t,signal:n,facts:T(t,w),resolveInteractor:r}),...ue({device:t,signal:n,resolveInteractor:r})})}function D(e,t){return t?Object.freeze({...x({back:t}),..._({home:t}),...b({orientation:t}),...y({tvRemote:t})}):e.platform===`android`?Object.freeze({...x({back:w}),..._({home:w}),...b({orientation:w}),...y({tvRemote:e.target===`tv`?w:ze})}):Object.freeze({...x({back:w}),..._({home:Le}),...b({orientation:w}),...y({tvRemote:Re})})}function O(e,t){return t?Object.freeze({...v({unsupported:t})}):e.platform===`android`?Object.freeze({...v({unsupported:Pe,read:w,write:w})}):Object.freeze({...v({unsupported:Ve})})}const Ge=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose alert inspection yet.`});function k(e,t){let n=t??(e.platform===`android`?w:Ge);return Object.freeze({...pe({read:n,wait:n,accept:n,dismiss:n})})}function A(e,t){let n=t??(e.platform===`android`?w:Ue);return Object.freeze({...fe({appSwitcher:n})})}function j(e,t){return Object.freeze({...ce({triggerAppEvent:t??w})})}function M(e,t){let n=t??(e.platform===`android`?w:He);return Object.freeze({...le({setSetting:n})})}function N(e,t){let n=t??Be,r=t===void 0&&e.platform===`android`;return Object.freeze({...de(r?{unsupported:n,status:w,dismiss:w,enter:w}:{unsupported:n})})}const P=Object.freeze({resourceKind:C,version:1,encode:e=>({...e}),decode:e=>e.transport!==`limrun-log-poller`||e.platform!==`ios`&&e.platform!==`android`||!F(e.leaseId)||!F(e.instanceId)||!F(e.appBundleId)||!F(e.outputPath)?{status:`invalid`,message:`Invalid Limrun app-log descriptor`}:{status:`decoded`,descriptor:Object.freeze({transport:`limrun-log-poller`,platform:e.platform,leaseId:e.leaseId,instanceId:e.instanceId,appBundleId:e.appBundleId,outputPath:e.outputPath})}});function Ke(e){if(e.device.platform===`apple`&&!e.device.appleOs)throw TypeError(`Limrun Apple app-log persistence requires an explicit appleOs identity`);return ye({resourceKind:C,sessionId:e.sessionId,device:{id:e.device.id,family:e.device.platform,...e.device.appleOs===void 0?{}:{appleOs:e.device.appleOs},kind:e.device.kind,...e.device.target===void 0?{}:{target:e.device.target},...e.device.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.device.iosPhysicalDeviceBackend}},owner:e.owner,fence:e.fence,lifecycle:`open`,descriptor:ve(P,e.descriptor)})}function F(e){return typeof e==`string`&&e.trim().length>0}async function I(e){let t=new be,n=!1;t.defer(async()=>{n||await e.reader[Symbol.asyncDispose]()});try{let r=await e.host.outputs.readTail(e.outputPath,262144),i=await e.host.outputs.openAppend(e.outputPath);t.defer(async()=>{n||await i[Symbol.asyncDispose]()});let a=qe(e,i,Qe(r));return n=!0,a}finally{await t[Symbol.asyncDispose]()}}function qe(e,t,n){let r=et(e.reader),i=e.host.clock.now(),a=`active`,o=!1,s=n,c=(async()=>{for(;!o;){try{let n=await Je(e);if(n.status===`timeout`){a=`failed`;return}if(o)return;let r=Ye(s,n.text);s=n.text,r&&await t.write(r.endsWith(`
2
+ `)?r:`${r}\n`),a=`active`}catch{if(o)return;a=`recovering`}await e.host.clock.sleep(1e3)}})(),l;return Te({inspect:()=>({backend:r,state:a,startedAt:i}),finish:async()=>l??=(async()=>(o=!0,await c,(await $e([e.reader,t])).length>0?(a=`failed`,{status:`cleanup-pending`,reason:`transport-failed`,message:`Limrun app-log cleanup did not settle every owned resource`}):(a=`ended`,{status:`completed`,result:{backend:r,outputPath:e.outputPath,completedAt:e.host.clock.now()}})))()})}async function Je(e){let t=new AbortController,n=i(e.reader.readLogs(e.appBundleId,1e3),t.signal,`App-log provider read aborted`).then(e=>({status:`read`,text:e}));try{let r=await Promise.race([n,e.host.clock.sleep(5e3,t.signal).then(()=>({status:`timeout`}))]);return r.status===`timeout`&&(t.abort(),await n.catch(()=>void 0)),r}finally{t.abort()}}function Ye(e,t){if(!e||!t)return t;let n=Xe(t),r=Math.min(e.length,t.length),i=e.slice(e.length-r);return t.slice(Ze(i,t,n))}function Xe(e){let t=new Uint32Array(e.length),n=0;for(let r=1;r<e.length;r+=1){for(;n>0&&e[r]!==e[n];)n=t[n-1];e[r]===e[n]&&(n+=1),t[r]=n}return t}function Ze(e,t,n){let r=0;for(let i=0;i<e.length;i+=1){for(;r>0&&e[i]!==t[r];)r=n[r-1];e[i]===t[r]&&(r+=1),r===t.length&&i<e.length-1&&(r=n[r-1])}return r}function Qe(e){return e.split(`
3
3
  `).filter(e=>!e.startsWith(`[agent-device][mark]`)).join(`
4
- `)}async function Ze(e){return(await Promise.allSettled(e.map(async e=>await e[Symbol.asyncDispose]()))).flatMap(e=>e.status===`rejected`?[e.reason]:[])}function Qe(e){return e.platform===`ios`?`ios-simulator`:`android`}function $e(e){let t=je({owner:`Limrun`,openTargetIdentity:`bundle-id`,closeBeforeRelaunch:!0,configureProviderPortReverse:async t=>await e.configurePortReverse(t),binding:Ae({device:e.device,signal:e.signal,resolveInteractor:t=>e.getInteractor(e.device,t)})}),n=e.resolveAppReference;return n?Object.freeze({...t,resolveOpenTarget:async e=>await t.resolveOpenTarget(et(e,n)),openApplication:async e=>await t.openApplication(tt(e,n)),closeApplication:async e=>await t.closeApplication(nt(e,n))}):t}function et(e,t){return e.target===void 0?e:{...e,target:t(e.target)}}function tt(e,t){return{...e,target:R(e.target,t),positionals:L(e.positionals,t),appBundleId:R(e.appBundleId,t)}}function nt(e,t){return{...e,positionals:L(e.positionals,t),appBundleId:R(e.appBundleId,t)}}function L(e,t){let n=e[0];return n===void 0?e:[t(n),...e.slice(1)]}function R(e,t){return e===void 0?void 0:t(e)}function rt(e){let t=s(e.id);return!t||e.target!==`mobile`?!1:t.platform===`ios`?e.platform===`apple`&&e.appleOs===`ios`&&e.kind===`simulator`&&e.iosPhysicalDeviceBackend===void 0:e.platform===`android`&&e.appleOs===void 0&&e.kind===`emulator`&&e.iosPhysicalDeviceBackend===void 0}const it=Object.freeze({available:!0}),z=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`The Limrun provider session is no longer active for this device.`}),at=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Push notifications are unavailable for Limrun provider-owned devices.`});function B(e,t){let n=st(e,t);return Object.freeze({deployApp:n,materializeAppSource:n,deployMaterializedApp:n,sendPushNotification:V(e,t)?at:z})}function ot(e,t,n,r){let i=e.deployApp,a=e.deployMaterializedApp;return!B(e,t).deployApp.available||!i||!a?Object.freeze({}):Object.freeze({deployApp:async e=>H(await i(t,e,n,r)),materializeAppSource:async r=>await ct(e.host,t,r,n),deployMaterializedApp:async e=>H(await a(t,e,n,r))})}function st(e,t){return rt(t)&&V(e,t)&&e.deployApp&&e.deployMaterializedApp?it:z}function V(e,t){return e.isSessionActive?.(t)??e.ownsDevice(t)}async function ct(e,t,n,r){return await(t.platform===`apple`?e.appleDeployment:e.androidDeployment).prepareArtifact(n,{signal:r})}function H(t){if(!t)throw new e(`UNSUPPORTED_OPERATION`,`The Limrun provider session is no longer active.`);return t}const U=Object.freeze({available:!0}),W=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Custom snapshot actions are available only for Limrun iOS simulator sessions.`}),lt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun does not expose viewport resizing.`}),G=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun-owned devices read element text from the captured tree only.`}),K=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun does not expose an exact-owner screen-recording runtime.`}),ut=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Headless boot is unavailable for provider-owned devices.`}),q=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`Limrun requires a matching live provider session for this device.`}),dt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Apple runner preparation is unavailable for Limrun-owned devices.`}),ft=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS appstate is session-owned; no sessionless provider foreground probe is exposed.`}),pt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun open requires a Limrun-owned iOS simulator or Android emulator.`}),mt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun close requires a Limrun-owned iOS simulator or Android emulator.`}),J=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Runtime hints are not applied to provider-owned devices.`}),ht=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun port reverse requires an active Android Limrun session.`}),gt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun does not expose the audio probe.`});function Y(e){return{...e,isSessionActive:e.hasLiveSession}}function X(e,t){let n=_t(e,t),r=vt(e,t),i=yt(e,t);return l({resolveOpenTarget:n,prepareApplicationOpen:n,openApplication:n,applyRuntimeHints:J,clearRuntimeHints:J,closeApplication:r,finalizeApplicationClose:r,prepareAppleRunner:dt,configureProviderPortReverse:i})}function _t(e,t){return a(e)?t?U:q:pt}function vt(e,t){return a(e)?t?U:q:mt}function yt(e,t){return t?e.platform===`android`?U:ht:q}function Z(e,n){let r=B(Y(e),n),i=n.platform===`android`,a=t(n)&&n.kind===`simulator`?U:W;return Object.freeze({device:{family:n.platform,...n.appleOs===void 0?{}:{appleOs:n.appleOs},kind:n.kind,...n.target===void 0?{}:{target:n.target},...n.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:n.iosPhysicalDeviceBackend},providerMode:`provider-runtime`},operations:{appLogInspect:U,appLogDoctor:U,appLogStart:U,appLogReattach:U,appLogCleanup:U,...r,appState:i?U:ft,networkDump:U,screenRecordingStart:K,screenRecordingReattach:K,screenRecordingCleanup:K,...p({capture:U,customActions:a,withoutActiveApp:U}),...f({capture:U}),...g({findText:W,findSelector:W}),...m({setViewport:lt}),...E(n),...he({readTextAtPoint:G}),...D(n),...N(n),...O(n),...A(n),...j(n),...M(n),...k(n),...ge({capture:gt,query:gt}),..._e({frames:G,memorySample:G,memorySnapshot:G,nativeCapture:G,profileReport:G}),ensureReady:U,bootTarget:U,bootTargetHeadless:ut,listApps:U,shutdownTarget:{available:!1,reason:`unsupported-provider-mode`,hint:`Limrun owns the target lifecycle for provider-owned devices.`},...X(n,!0)}})}function bt(e,t){let n=Z(e,t);return Object.freeze({device:n.device,operations:{...n.operations,appLogInspect:q,appLogDoctor:q,appLogStart:q,appLogReattach:U,appLogCleanup:U,appState:q,networkDump:q,screenRecordingStart:q,screenRecordingReattach:q,screenRecordingCleanup:q,...p({capture:q,customActions:q,withoutActiveApp:q}),...f({capture:q}),...g({findText:q,findSelector:q}),...m({setViewport:q}),...E(t,q),...D(t,q),...N(t,q),...O(t,q),...A(t,q),...j(t,q),...M(t,q),...k(t,q),ensureReady:q,bootTarget:q,bootTargetHeadless:q,listApps:q,deployApp:q,materializeAppSource:q,deployMaterializedApp:q,sendPushNotification:q,shutdownTarget:q,...X(t,!1)}})}function xt(t){let i=r(`limrun`,t.runtimeInstance),o=e=>a(e)&&t.ownsDevice(e),s=e=>o(e)&&t.hasLiveSession(e);return Object.freeze({owner:i,ownsDevice:o,inspectFacts:async e=>s(e)?Z(t,e):ve(e,i,{appLog:q,appState:q,appDeployment:q,network:q,screenshot:q,viewport:q,focus:q,gesture:q,scroll:q,typeText:q,touch:q,elementText:q,back:q,home:q,orientation:q,tvRemote:q,keyboardStatus:q,keyboardDismiss:q,keyboardEnter:q,readClipboard:q,writeClipboard:q,appSwitcher:q,triggerAppEvent:q,setSetting:q,readAlert:q,awaitAlert:q,acceptAlert:q,dismissAlert:q,audioProbeCapture:q,audioProbeQuery:q,perf:q,readiness:q,shutdown:q,lifecycle:X(e,!1)}),bind:async r=>{if(r.intent.kind===`exact-owner`&&!n(r.intent.owner,i))throw new e(`UNSUPPORTED_OPERATION`,`Limrun app-log owner identity does not match`);if(!a(r.device))throw new e(`UNSUPPORTED_PLATFORM`,`Limrun app logs require an iOS simulator or Android emulator device identity`);let o=s(r.device);if(r.intent.kind!==`exact-owner`&&!o)throw new e(`UNSUPPORTED_OPERATION`,`Limrun provider session is no longer live for the selected device`,{reason:`provider-session-unavailable`});return St(t,i,r.device,r.scope.signal,!o)},shutdown:async()=>void 0})}function St(t,n,r,i,a){let s=a?bt(t,r):Z(t,r),l=o(),u=Se({codec:P,reattach:async(e,n)=>{if(!$(e,r)||!x(t.host,n.sessionId,e))return{status:`unreattachable`,reason:`descriptor-invalid`,message:`Limrun app-log descriptor does not match the bound device or owning session`};let a=await t.reconnect(e,i);return a.status===`missing`?{status:`missing`}:a.status===`ownership-lost`?{status:`unreattachable`,reason:`ownership-fence-lost`}:{status:`active`,handle:await I({host:t.host,reader:a.reader,appBundleId:e.appBundleId,outputPath:e.outputPath})}},cleanup:async(e,n)=>$(e,r)&&x(t.host,n.sessionId,e)?{status:`cleaned`}:{status:`cleanup-pending`,reason:`ownership-fence-lost`,message:`Limrun app-log descriptor does not match the bound device or owning session`}}),d={appLogInspect:async()=>({backend:Q(r)}),appLogDoctor:async()=>({backend:Q(r),checks:{limrunSessionAvailable:await Ct(t,r,i)},notes:[]}),appLogStart:async a=>{Te(t.host,a),i.throwIfAborted();let o=await t.openCurrent(r);if(!o)throw new e(`UNSUPPORTED_OPERATION`,`Limrun app logs require an active instance`);let s={transport:`limrun-log-poller`,platform:o.platform,leaseId:o.leaseId,instanceId:o.instanceId,appBundleId:a.appBundleId,outputPath:a.outputPath},c=!1;try{i.throwIfAborted();let e=We({sessionId:a.sessionId,device:r,owner:n,fence:a.fence,descriptor:s});c=!0;let l=await I({host:t.host,reader:o,appBundleId:a.appBundleId,outputPath:a.outputPath});return Ce(l,e)}catch(e){throw c||await o[Symbol.asyncDispose](),e}},...u,networkDump:async e=>{let n=await t.host.appLogs.readRecent(e.sessionId,e.maxScanLines),i=Q(r),a=we(n.text,{...e,path:n.path,exists:n.exists,lineNumberOffset:n.skippedLines,backend:i}),o=a.entries.length===0?[`No HTTP(s) entries were found in recent session app logs.`]:[];return Object.freeze({source:`app-log`,backend:i,dump:a,notes:o})},ensureReady:async()=>({...r,booted:!0}),bootTarget:async()=>({...r,booted:!0}),listApps:async e=>await t.listApps(e.device,e.filter,i),...r.platform===`android`?{appState:async()=>await t.getAppState(r,i)}:{},...c($e({device:r,signal:i,getInteractor:t.getInteractor,resolveAppReference:e=>t.resolveAppReference?.(r,e)??e,configurePortReverse:t.configurePortReverse}),s.operations),...He({device:r,signal:i,getInteractor:t.getInteractor,presentIosAcquisition:t.host.snapshot.presentIosAcquisition}),...ke({device:r,signal:i,resolveInteractor:e=>t.getInteractor(r,e),facts:s.operations}),...ot(Y(t),r,i,l)};return Object.freeze({device:r,owner:n,facts:s,operations:Object.freeze(a?{appLogReattach:u.appLogReattach,appLogCleanup:u.appLogCleanup}:d),[Symbol.asyncDispose]:async()=>await l[Symbol.asyncDispose]()})}async function Ct(e,t,n){n.throwIfAborted();let r=await e.openCurrent(t);if(!r)return!1;try{n.throwIfAborted()}finally{await r[Symbol.asyncDispose]()}return!0}function Q(e){return e.platform===`apple`?`ios-simulator`:`android`}function $(e,t){if(!a(t))return!1;let n=s(t.id);return n!==void 0&&n.leaseId===e.leaseId&&n.platform===e.platform&&(t.platform===`apple`?e.platform===`ios`:e.platform===`android`)}export{xt as createLimrunPlatformRuntimeOwner};
4
+ `)}async function $e(e){return(await Promise.allSettled(e.map(async e=>await e[Symbol.asyncDispose]()))).flatMap(e=>e.status===`rejected`?[e.reason]:[])}function et(e){return e.platform===`ios`?`ios-simulator`:`android`}function tt(e){let t=Ae({owner:`Limrun`,openTargetIdentity:`bundle-id`,closeBeforeRelaunch:!0,configureProviderPortReverse:async t=>await e.configurePortReverse(t),binding:ke({device:e.device,signal:e.signal,resolveInteractor:t=>e.getInteractor(e.device,t)})}),n=e.resolveAppReference;return n?Object.freeze({...t,resolveOpenTarget:async e=>await t.resolveOpenTarget(nt(e,n)),openApplication:async e=>await t.openApplication(rt(e,n)),closeApplication:async e=>await t.closeApplication(it(e,n))}):t}function nt(e,t){return e.target===void 0?e:{...e,target:t(e.target)}}function rt(e,t){return{...e,target:R(e.target,t),positionals:L(e.positionals,t),appBundleId:R(e.appBundleId,t)}}function it(e,t){return{...e,positionals:L(e.positionals,t),appBundleId:R(e.appBundleId,t)}}function L(e,t){let n=e[0];return n===void 0?e:[t(n),...e.slice(1)]}function R(e,t){return e===void 0?void 0:t(e)}function at(e){let t=s(e.id);return!t||e.target!==`mobile`?!1:t.platform===`ios`?e.platform===`apple`&&e.appleOs===`ios`&&e.kind===`simulator`&&e.iosPhysicalDeviceBackend===void 0:e.platform===`android`&&e.appleOs===void 0&&e.kind===`emulator`&&e.iosPhysicalDeviceBackend===void 0}const ot=Object.freeze({available:!0}),z=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`The Limrun provider session is no longer active for this device.`}),st=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Push notifications are unavailable for Limrun provider-owned devices.`});function B(e,t){let n=lt(e,t);return Object.freeze({deployApp:n,materializeAppSource:n,deployMaterializedApp:n,sendPushNotification:V(e,t)?st:z})}function ct(e,t,n,r){let i=e.deployApp,a=e.deployMaterializedApp;return!B(e,t).deployApp.available||!i||!a?Object.freeze({}):Object.freeze({deployApp:async e=>H(await i(t,e,n,r)),materializeAppSource:async r=>await ut(e.host,t,r,n),deployMaterializedApp:async e=>H(await a(t,e,n,r))})}function lt(e,t){return at(t)&&V(e,t)&&e.deployApp&&e.deployMaterializedApp?ot:z}function V(e,t){return e.isSessionActive?.(t)??e.ownsDevice(t)}async function ut(e,t,n,r){return await(t.platform===`apple`?e.appleDeployment:e.androidDeployment).prepareArtifact(n,{signal:r})}function H(t){if(!t)throw new e(`UNSUPPORTED_OPERATION`,`The Limrun provider session is no longer active.`);return t}const U=Object.freeze({available:!0}),W=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Custom snapshot actions are available only for Limrun iOS simulator sessions.`}),dt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun does not expose viewport resizing.`}),G=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun-owned devices read element text from the captured tree only.`}),K=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun does not expose an exact-owner screen-recording runtime.`}),ft=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Headless boot is unavailable for provider-owned devices.`}),q=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`Limrun requires a matching live provider session for this device.`}),pt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Apple runner preparation is unavailable for Limrun-owned devices.`}),mt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS appstate is session-owned; no sessionless provider foreground probe is exposed.`}),ht=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun open requires a Limrun-owned iOS simulator or Android emulator.`}),gt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun close requires a Limrun-owned iOS simulator or Android emulator.`}),J=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Runtime hints are not applied to provider-owned devices.`}),_t=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun port reverse requires an active Android Limrun session.`}),Y=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun does not expose the audio probe.`});function vt(e){return{...e,isSessionActive:e.hasLiveSession}}function X(e,t){let n=yt(e,t),r=bt(e,t),i=xt(e,t);return l({resolveOpenTarget:n,prepareApplicationOpen:n,openApplication:n,applyRuntimeHints:J,clearRuntimeHints:J,closeApplication:r,finalizeApplicationClose:r,prepareAppleRunner:pt,configureProviderPortReverse:i})}function yt(e,t){return a(e)?t?U:q:ht}function bt(e,t){return a(e)?t?U:q:gt}function xt(e,t){return t?e.platform===`android`?U:_t:q}function Z(e,n){let r=B(vt(e),n),i=n.platform===`android`,a=t(n)&&n.kind===`simulator`?U:W;return Object.freeze({device:{family:n.platform,...n.appleOs===void 0?{}:{appleOs:n.appleOs},kind:n.kind,...n.target===void 0?{}:{target:n.target},...n.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:n.iosPhysicalDeviceBackend},providerMode:`provider-runtime`},operations:{appLogInspect:U,appLogDoctor:U,appLogStart:U,appLogReattach:U,appLogCleanup:U,...r,appState:i?U:mt,networkDump:U,screenRecordingStart:K,screenRecordingReattach:K,screenRecordingCleanup:K,...p({capture:U,customActions:a,withoutActiveApp:U}),...f({capture:U}),...g({findText:W}),...m({setViewport:dt}),...E(n),...me({readTextAtPoint:G}),...D(n),...N(n),...O(n),...A(n),...j(n),...M(n),...k(n),...he({capture:Y,query:Y}),...ge({frames:G,memorySample:G,memorySnapshot:G,nativeCapture:G,profileReport:G}),ensureReady:U,bootTarget:U,bootTargetHeadless:ft,listApps:U,shutdownTarget:{available:!1,reason:`unsupported-provider-mode`,hint:`Limrun owns the target lifecycle for provider-owned devices.`},...X(n,!0)}})}function St(e,t){let n=Z(e,t);return Object.freeze({device:n.device,operations:{...n.operations,appLogInspect:q,appLogDoctor:q,appLogStart:q,appLogReattach:U,appLogCleanup:U,appState:q,networkDump:q,screenRecordingStart:q,screenRecordingReattach:q,screenRecordingCleanup:q,...p({capture:q,customActions:q,withoutActiveApp:q}),...f({capture:q}),...g({findText:q}),...m({setViewport:q}),...E(t,q),...D(t,q),...N(t,q),...O(t,q),...A(t,q),...j(t,q),...M(t,q),...k(t,q),ensureReady:q,bootTarget:q,bootTargetHeadless:q,listApps:q,deployApp:q,materializeAppSource:q,deployMaterializedApp:q,sendPushNotification:q,shutdownTarget:q,...X(t,!1)}})}function Ct(t){let i=n(`limrun`,t.runtimeInstance),o=e=>a(e)&&t.ownsDevice(e),s=e=>o(e)&&t.hasLiveSession(e);return Object.freeze({owner:i,ownsDevice:o,inspectFacts:async e=>s(e)?Z(t,e):_e(e,i,{appLog:q,appState:q,appDeployment:q,network:q,screenshot:q,viewport:q,focus:q,gesture:q,scroll:q,typeText:q,touch:q,elementText:q,back:q,home:q,orientation:q,tvRemote:q,keyboard:q,clipboard:q,appSwitcher:q,triggerAppEvent:q,setSetting:q,readAlert:q,awaitAlert:q,acceptAlert:q,dismissAlert:q,audioProbeCapture:q,audioProbeQuery:q,perf:q,readiness:q,shutdown:q,lifecycle:X(e,!1)}),bind:async n=>{if(n.intent.kind===`exact-owner`&&!r(n.intent.owner,i))throw new e(`UNSUPPORTED_OPERATION`,`Limrun app-log owner identity does not match`);if(!a(n.device))throw new e(`UNSUPPORTED_PLATFORM`,`Limrun app logs require an iOS simulator or Android emulator device identity`);let o=s(n.device);if(n.intent.kind!==`exact-owner`&&!o)throw new e(`UNSUPPORTED_OPERATION`,`Limrun provider session is no longer live for the selected device`,{reason:`provider-session-unavailable`});return wt(t,i,n.device,n.scope.signal,!o)},shutdown:async()=>void 0})}function wt(t,n,r,i,a){let s=a?St(t,r):Z(t,r),l=o(),u=xe({codec:P,reattach:async(e,n)=>{if(!$(e,r)||!S(t.host,n.sessionId,e))return{status:`unreattachable`,reason:`descriptor-invalid`,message:`Limrun app-log descriptor does not match the bound device or owning session`};let a=await t.reconnect(e,i);return a.status===`missing`?{status:`missing`}:a.status===`ownership-lost`?{status:`unreattachable`,reason:`ownership-fence-lost`}:{status:`active`,handle:await I({host:t.host,reader:a.reader,appBundleId:e.appBundleId,outputPath:e.outputPath})}},cleanup:async(e,n)=>$(e,r)&&S(t.host,n.sessionId,e)?{status:`cleaned`}:{status:`cleanup-pending`,reason:`ownership-fence-lost`,message:`Limrun app-log descriptor does not match the bound device or owning session`}}),d={appLogInspect:async()=>({backend:Q(r)}),appLogDoctor:async()=>({backend:Q(r),checks:{limrunSessionAvailable:await Tt(t,r,i)},notes:[]}),appLogStart:async a=>{we(t.host,a),i.throwIfAborted();let o=await t.openCurrent(r);if(!o)throw new e(`UNSUPPORTED_OPERATION`,`Limrun app logs require an active instance`);let s={transport:`limrun-log-poller`,platform:o.platform,leaseId:o.leaseId,instanceId:o.instanceId,appBundleId:a.appBundleId,outputPath:a.outputPath},c=!1;try{i.throwIfAborted();let e=Ke({sessionId:a.sessionId,device:r,owner:n,fence:a.fence,descriptor:s});c=!0;let l=await I({host:t.host,reader:o,appBundleId:a.appBundleId,outputPath:a.outputPath});return Se(l,e)}catch(e){throw c||await o[Symbol.asyncDispose](),e}},...u,networkDump:async e=>{let n=await t.host.appLogs.readRecent(e.sessionId,e.maxScanLines),i=Q(r),{dump:a}=Ce(n.text,{...e,path:n.path,exists:n.exists,lineNumberOffset:n.skippedLines,backend:i}),o=a.entries.length===0?[`No HTTP(s) entries were found in recent session app logs.`]:[];return Object.freeze({source:`app-log`,backend:i,dump:a,notes:o})},ensureReady:async()=>({...r,booted:!0}),bootTarget:async()=>({...r,booted:!0}),listApps:async e=>await t.listApps(e.device,e.filter,i),...r.platform===`android`?{appState:async()=>await t.getAppState(r,i)}:{},...c(tt({device:r,signal:i,getInteractor:t.getInteractor,resolveAppReference:e=>t.resolveAppReference?.(r,e)??e,configurePortReverse:t.configurePortReverse}),s.operations),...We({device:r,signal:i,getInteractor:t.getInteractor,presentIosAcquisition:t.host.snapshot.presentIosAcquisition}),...Oe({device:r,signal:i,resolveInteractor:e=>t.getInteractor(r,e),facts:s.operations}),...ct(vt(t),r,i,l)};return Object.freeze({device:r,owner:n,facts:s,operations:Object.freeze(a?{appLogReattach:u.appLogReattach,appLogCleanup:u.appLogCleanup}:d),[Symbol.asyncDispose]:async()=>await l[Symbol.asyncDispose]()})}async function Tt(e,t,n){n.throwIfAborted();let r=await e.openCurrent(t);if(!r)return!1;try{n.throwIfAborted()}finally{await r[Symbol.asyncDispose]()}return!0}function Q(e){return e.platform===`apple`?`ios-simulator`:`android`}function $(e,t){if(!a(t))return!1;let n=s(t.id);return n!==void 0&&n.leaseId===e.leaseId&&n.platform===e.platform&&(t.platform===`apple`?e.platform===`ios`:e.platform===`android`)}export{Ct as createLimrunPlatformRuntimeOwner};
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime.js";import{y as t}from"./sdk-contracts.js";import{r as n}from"./sdk-batch-runner.js";import{l as r,u as i}from"./sdk-device.js";import{t as a}from"./ttl-memo.js";import{t as o}from"./app-resolution-cache.js";import{u as s}from"./host-file.js";import{a as c,c as l,i as u}from"./tool-provider.js";import{t as d}from"./physical-device-control.js";import{n as f}from"./apps-simctl.js";import{n as p}from"./helper.js";import m from"node:path";import{fileURLToPath as h}from"node:url";import{setTimeout as g}from"node:timers/promises";function _(e){let n=e.trim().toLowerCase();if(n===`light`)return`light`;if(n===`dark`)return`dark`;if(n===`toggle`)return`toggle`;throw new t(`INVALID_ARGS`,`Invalid appearance state: ${e}. Use light|dark|toggle.`)}function ee(e){let n=e.toLowerCase();if(n===`on`||n===`true`||n===`1`)return!0;if(n===`off`||n===`false`||n===`0`)return!1;throw new t(`INVALID_ARGS`,`Invalid setting state: ${e}`)}function v(e){return e.map(e=>({args:e.args.join(` `),exitCode:e.exitCode,stderr:e.stderr.slice(0,400)}))}const y={settings:`com.apple.systempreferences`},b=/^[a-z0-9-]+(?:\.[a-z0-9-]+)+$/,x={platform:`macos`,deviceId:`host`,variant:`all`},S=o();function C(e){return b.test(e)}async function w(e){let n=e.trim(),r=y[n.toLowerCase()];if(r)return r;if(C(n))return n;let i=S.get(x,n);if(i)return i;let a=(await j(`all`)).filter(e=>e.name.toLowerCase()===n.toLowerCase()),o=a[0];if(o!==void 0&&a.length===1)return S.set(x,n,o.bundleId);throw a.length>1?new t(`INVALID_ARGS`,`Multiple apps matched "${e}"`,{matches:a}):new t(`APP_NOT_INSTALLED`,`No app found matching "${e}"`)}async function T(e,r,i){let a=i?.url?.trim();if(a){if(!n(a))throw new t(`INVALID_ARGS`,`open <app> <url> requires a valid URL target`);let e=i?.appBundleId??await w(r);await M().openBundle(e,a);return}let o=r.trim();if(n(o)){await M().openTarget(o);return}let s=i?.appBundleId??await w(o);await M().openBundle(s)}async function E(e,n){let r=await w(n),i=await p(r);if(i.running){if(!i.terminated&&!i.forceTerminated)throw new t(`COMMAND_FAILED`,`Failed to close macOS app ${n}`,{bundleId:r,running:i.running,terminated:i.terminated,forceTerminated:i.forceTerminated});for(let e=1;e<20;e+=1)if(await g(100),!(await p(r)).running)return;throw new t(`COMMAND_FAILED`,`Timed out waiting for macOS app ${n} to close`,{reason:`MACOS_APP_TERMINATION_TIMEOUT`,bundleId:r,attempts:20})}}async function D(){return await M().readClipboard()}async function O(e){await M().writeClipboard(e)}async function k(){return await M().readDarkMode()}async function A(e){let t=_(e),n=t===`toggle`?!await k():t===`dark`;await M().setDarkMode(n)}async function j(e){return await M().listApps(e)}function M(){let e=u().macosHost;if(!e)throw new t(`UNSUPPORTED_OPERATION`,`macOS host provider is not available`);return e}function N(e){return new t(`APP_NOT_INSTALLED`,`No app found matching "${e}"`)}var P=e({buildAppNotInstalledError:()=>N,detectSoleRunningIosSimulatorApp:()=>W,findIosSimulatorInstalledApp:()=>B,invalidateIosAppResolutionCache:()=>R,listIosApps:()=>J,resolveIosApp:()=>z,resolveIosAppAlias:()=>V,resolveIosSimulatorDeepLinkBundleId:()=>K});const F={settings:`com.apple.Preferences`},I=o();function L(e){return{platform:`ios`,deviceId:e.id,variant:e.kind}}async function R(e,t){return await I.invalidateWhile(L(e),t)}async function z(e,n){if(i(e))return await w(n);let r=n.trim();if(r.includes(`.`))return r;let a=V(r);if(a!==r)return a;let o=L(e),s=I.get(o,r);if(s)return s;let c=(e.kind===`simulator`?await Y(e):await d(e).listApps(e,`all`)).filter(e=>e.name.toLowerCase()===r.toLowerCase()),l=c[0];if(l!==void 0&&c.length===1)return I.set(o,r,l.bundleId);throw c.length>1?new t(`INVALID_ARGS`,`Multiple apps matched "${n}"`,{matches:c}):N(n)}async function B(e,t){if(!r(e)||e.kind!==`simulator`||e.booted!==!0)return;let n=V(t.trim());if(!n)return;let i=await Y(e);if(n.includes(`.`))return i.find(e=>e.bundleId===n)?.bundleId;let a=i.filter(e=>e.name.toLowerCase()===n.toLowerCase());return a.length===1?a[0]?.bundleId:void 0}function V(e){let t=e.trim();return F[t.toLowerCase()]??e}const H=3e3,U=/UIKitApplication:([^[\s]+)\[/;async function W(e){if(!(!r(e)||e.kind!==`simulator`||e.booted!==!0))try{let[t,n]=await Promise.all([G(e),Y(e,{timeoutMs:H})]);if(t.length===0)return;let r=new Map(n.map(e=>[e.bundleId,e])),i=new Map;for(let e of t){let t=r.get(e);t&&i.set(t.bundleId,t)}return i.size===1?[...i.values()][0]:void 0}catch{return}}async function G(e){let t=await f(e,[`spawn`,e.id,`launchctl`,`list`],{allowFailure:!0,timeoutMs:H});if(t.exitCode!==0)return[];let n=[];for(let e of t.stdout.split(`
1
+ import{r as e}from"./rolldown-runtime.js";import{C as t}from"./sdk-contracts.js";import{r as n}from"./sdk-batch-runner.js";import{l as r,u as i}from"./sdk-device.js";import{t as a}from"./ttl-memo.js";import{t as o}from"./app-resolution-cache.js";import{u as s}from"./host-file.js";import{a as c,c as l,i as u}from"./tool-provider.js";import{t as d}from"./physical-device-control.js";import{n as f}from"./apps-simctl.js";import{n as p}from"./helper.js";import m from"node:path";import{fileURLToPath as h}from"node:url";import{setTimeout as g}from"node:timers/promises";function _(e){let n=e.trim().toLowerCase();if(n===`light`)return`light`;if(n===`dark`)return`dark`;if(n===`toggle`)return`toggle`;throw new t(`INVALID_ARGS`,`Invalid appearance state: ${e}. Use light|dark|toggle.`)}function ee(e){let n=e.toLowerCase();if(n===`on`||n===`true`||n===`1`)return!0;if(n===`off`||n===`false`||n===`0`)return!1;throw new t(`INVALID_ARGS`,`Invalid setting state: ${e}`)}function v(e){return e.map(e=>({args:e.args.join(` `),exitCode:e.exitCode,stderr:e.stderr.slice(0,400)}))}const y={settings:`com.apple.systempreferences`},b=/^[a-z0-9-]+(?:\.[a-z0-9-]+)+$/,x={platform:`macos`,deviceId:`host`,variant:`all`},S=o();function C(e){return b.test(e)}async function w(e){let n=e.trim(),r=y[n.toLowerCase()];if(r)return r;if(C(n))return n;let i=S.get(x,n);if(i)return i;let a=(await j(`all`)).filter(e=>e.name.toLowerCase()===n.toLowerCase()),o=a[0];if(o!==void 0&&a.length===1)return S.set(x,n,o.bundleId);throw a.length>1?new t(`INVALID_ARGS`,`Multiple apps matched "${e}"`,{matches:a}):new t(`APP_NOT_INSTALLED`,`No app found matching "${e}"`)}async function T(e,r,i){let a=i?.url?.trim();if(a){if(!n(a))throw new t(`INVALID_ARGS`,`open <app> <url> requires a valid URL target`);let e=i?.appBundleId??await w(r);await M().openBundle(e,a);return}let o=r.trim();if(n(o)){await M().openTarget(o);return}let s=i?.appBundleId??await w(o);await M().openBundle(s)}async function E(e,n){let r=await w(n),i=await p(r);if(i.running){if(!i.terminated&&!i.forceTerminated)throw new t(`COMMAND_FAILED`,`Failed to close macOS app ${n}`,{bundleId:r,running:i.running,terminated:i.terminated,forceTerminated:i.forceTerminated});for(let e=1;e<20;e+=1)if(await g(100),!(await p(r)).running)return;throw new t(`COMMAND_FAILED`,`Timed out waiting for macOS app ${n} to close`,{reason:`MACOS_APP_TERMINATION_TIMEOUT`,bundleId:r,attempts:20})}}async function D(){return await M().readClipboard()}async function O(e){await M().writeClipboard(e)}async function k(){return await M().readDarkMode()}async function A(e){let t=_(e),n=t===`toggle`?!await k():t===`dark`;await M().setDarkMode(n)}async function j(e){return await M().listApps(e)}function M(){let e=u().macosHost;if(!e)throw new t(`UNSUPPORTED_OPERATION`,`macOS host provider is not available`);return e}function N(e){return new t(`APP_NOT_INSTALLED`,`No app found matching "${e}"`)}var P=e({buildAppNotInstalledError:()=>N,detectSoleRunningIosSimulatorApp:()=>W,findIosSimulatorInstalledApp:()=>B,invalidateIosAppResolutionCache:()=>R,listIosApps:()=>J,resolveIosApp:()=>z,resolveIosAppAlias:()=>V,resolveIosSimulatorDeepLinkBundleId:()=>K});const F={settings:`com.apple.Preferences`},I=o();function L(e){return{platform:`ios`,deviceId:e.id,variant:e.kind}}async function R(e,t){return await I.invalidateWhile(L(e),t)}async function z(e,n){if(i(e))return await w(n);let r=n.trim();if(r.includes(`.`))return r;let a=V(r);if(a!==r)return a;let o=L(e),s=I.get(o,r);if(s)return s;let c=(e.kind===`simulator`?await Y(e):await d(e).listApps(e,`all`)).filter(e=>e.name.toLowerCase()===r.toLowerCase()),l=c[0];if(l!==void 0&&c.length===1)return I.set(o,r,l.bundleId);throw c.length>1?new t(`INVALID_ARGS`,`Multiple apps matched "${n}"`,{matches:c}):N(n)}async function B(e,t){if(!r(e)||e.kind!==`simulator`||e.booted!==!0)return;let n=V(t.trim());if(!n)return;let i=await Y(e);if(n.includes(`.`))return i.find(e=>e.bundleId===n)?.bundleId;let a=i.filter(e=>e.name.toLowerCase()===n.toLowerCase());return a.length===1?a[0]?.bundleId:void 0}function V(e){let t=e.trim();return F[t.toLowerCase()]??e}const H=3e3,U=/UIKitApplication:([^[\s]+)\[/;async function W(e){if(!(!r(e)||e.kind!==`simulator`||e.booted!==!0))try{let[t,n]=await Promise.all([G(e),Y(e,{timeoutMs:H})]);if(t.length===0)return;let r=new Map(n.map(e=>[e.bundleId,e])),i=new Map;for(let e of t){let t=r.get(e);t&&i.set(t.bundleId,t)}return i.size===1?[...i.values()][0]:void 0}catch{return}}async function G(e){let t=await f(e,[`spawn`,e.id,`launchctl`,`list`],{allowFailure:!0,timeoutMs:H});if(t.exitCode!==0)return[];let n=[];for(let e of t.stdout.split(`
2
2
  `)){let t=U.exec(e);t?.[1]&&n.push(t[1])}return n}async function K(e,t){if(!r(e)||e.kind!==`simulator`)return;let n=q(t);if(!n)return;let i=await X(e),a=[];for(let e of i)e.bundleId.startsWith(`com.callstack.agentdevice.runner`)||e.path&&(await te(m.join(e.path,`Info.plist`))).has(n)&&a.push(e);let o=a.filter(e=>e.applicationType===`User`);if(o.length===1)return o[0]?.bundleId;if(!(o.length>1))return a.length===1?a[0]?.bundleId:void 0}function q(e){return/^([A-Za-z][A-Za-z0-9+.-]*):/.exec(e.trim())?.[1]?.toLowerCase()}async function J(e,t){if(i(e))return await j(t);if(e.kind===`simulator`){let n=await Y(e);return l(n,t)}return await d(e).listApps(e,t)}async function Y(e,t){return(await X(e,t)).map(e=>({bundleId:e.bundleId,name:e.name}))}async function X(e,t){let n=(await f(e,[`listapps`,e.id],{allowFailure:!0,timeoutMs:t?.timeoutMs})).stdout.trim();if(!n)return[];let r=null;if(n.startsWith(`{`))try{r=JSON.parse(n)}catch{r=null}if(!r&&n.startsWith(`{`))try{let e=await c(`plutil`,[`-convert`,`json`,`-o`,`-`,`-`],{allowFailure:!0,stdin:n,timeoutMs:t?.timeoutMs});e.exitCode===0&&e.stdout.trim().startsWith(`{`)&&(r=JSON.parse(e.stdout))}catch{r=null}return r?Object.entries(r).map(([e,t])=>{let n=Z(t);return{bundleId:e,name:t.CFBundleDisplayName??t.CFBundleName??e,...n?{path:n}:{},...t.ApplicationType?{applicationType:t.ApplicationType}:{}}}):[]}function Z(e){if(e.Path)return e.Path;if(e.Bundle)try{return h(e.Bundle)}catch{return}}const Q=a({ttlMs:18e5,scheduleExpiry:!0});async function te(e){let t;try{t=`${e}:${(await s(e)).mtimeMs}`}catch{t=void 0}if(t===void 0)return await $(e)??new Set;let n=Q.get(t);if(n)return n;let r=await $(e);return r&&Q.set(t,r),r??new Set}async function $(e){let t=await c(`plutil`,[`-convert`,`json`,`-o`,`-`,e],{allowFailure:!0});if(t.exitCode===0)try{let e=JSON.parse(t.stdout),n=new Set;for(let t of e.CFBundleURLTypes??[])if(Array.isArray(t.CFBundleURLSchemes))for(let e of t.CFBundleURLSchemes)typeof e==`string`&&e.trim()&&n.add(e.trim().toLowerCase());return n}catch{return}}export{z as a,N as c,D as d,A as f,v as g,ee as h,R as i,E as l,_ as m,W as n,V as o,O as p,B as r,K as s,P as t,T as u};
@@ -0,0 +1 @@
1
+ import{C as e}from"./sdk-contracts.js";import{c as t,u as n,y as r}from"./sdk-device.js";const i=3e4,a={iOS:{sdkName:{simulator:`iphonesimulator`,device:`iphoneos`},derivedBaseName:{simulator:`ios-simulator`,device:`ios-device`},xctestrunHints:{simulator:{preferred:[`iphonesimulator`],disallowed:[`iphoneos`,`appletvos`,`appletvsimulator`,`macos`]},device:{preferred:[`iphoneos`],disallowed:[`iphonesimulator`,`appletvos`,`appletvsimulator`,`macos`]}}},tvOS:{sdkName:{simulator:`appletvsimulator`,device:`appletvos`},derivedBaseName:{simulator:`tvos-simulator`,device:`tvos-device`},xctestrunHints:{simulator:{preferred:[`appletvsimulator`],disallowed:[`appletvos`,`iphoneos`,`iphonesimulator`,`macos`]},device:{preferred:[`appletvos`],disallowed:[`appletvsimulator`,`iphoneos`,`iphonesimulator`,`macos`]}}},macOS:{sdkName:{simulator:`macosx`,device:`macosx`},derivedBaseName:{simulator:`macos`,device:`macos`},xctestrunHints:{simulator:{preferred:[`macos`],disallowed:[`iphoneos`,`iphonesimulator`,`appletvos`,`appletvsimulator`]},device:{preferred:[`macos`],disallowed:[`iphoneos`,`iphonesimulator`,`appletvos`,`appletvsimulator`]}}},visionOS:{sdkName:{simulator:`xrsimulator`,device:`xros`},derivedBaseName:{simulator:`visionos-simulator`,device:`visionos-device`},xctestrunHints:{simulator:{preferred:[`xrsimulator`],disallowed:[`xros`,`iphoneos`,`iphonesimulator`,`appletvos`,`appletvsimulator`,`macos`]},device:{preferred:[`xros`],disallowed:[`xrsimulator`,`iphoneos`,`iphonesimulator`,`appletvos`,`appletvsimulator`,`macos`]}}}};function o(i){if(!t(i.platform))throw new e(`UNSUPPORTED_PLATFORM`,`Unsupported platform for Apple runner: ${i.platform}`);return n(i)?`macOS`:r(i.target,i.appleOs)}function s(e,t){return a[e].sdkName[p(t)]}function c(e){return a[o(e)].derivedBaseName[p(e.kind)]}function l(e){return a[o(e)].xctestrunHints[p(e.kind)]}function u(e){let t=o(e);return t===`macOS`?`platform=macOS,arch=${m()}`:e.kind===`simulator`?`platform=${t} Simulator,id=${e.id}`:`platform=${t},id=${e.id}`}function d(e){let t=o(e);return t===`macOS`?`platform=macOS,arch=${m()}`:e.kind===`simulator`?`platform=${t} Simulator,id=${e.id}`:`generic/platform=${t}`}function f(e){let t=o(e);return t===`macOS`?`platform=macOS,arch=${m()}`:e.kind===`simulator`?`generic/platform=${t} Simulator`:`generic/platform=${t}`}function p(e){return e===`simulator`?`simulator`:`device`}function m(){return process.arch===`arm64`?`arm64`:`x86_64`}export{u as a,l as c,c as i,d as n,o,f as r,s,i as t};
@@ -1 +1 @@
1
- import{y as e}from"./sdk-contracts.js";import{r as t}from"./sdk-batch-runner.js";import{l as n}from"./sdk-device.js";import{n as r,t as i}from"./launch-console.js";function a(e,t,n){return{requestId:e.requestId,signal:n,appBundleId:t,verbose:e.verbose,logPath:e.logPath,traceLogPath:e.traceLogPath,iosXctestrunFile:e.iosXctestrunFile,iosXctestDerivedDataPath:e.iosXctestDerivedDataPath,iosXctestEnvDir:e.iosXctestEnvDir,runnerLeaseContext:e.runnerLeaseContext}}function o(t){let{device:n,signal:r,ownership:i}=t;return Object.freeze({device:n,signal:r,resolveInteractor:async(o,s)=>{let c=a(o,s,r);if(i===`local`)return await t.resolveLocalInteractor(n,c);let l=i.resolveInteractor(c);if(l)return l;throw new e(`UNSUPPORTED_OPERATION`,`Provider-owned application lifecycle operation has no bound provider interactor.`,{reason:`provider-runtime-interactor-missing`,deviceId:n.id})}})}function s(e){return o({device:e.device,signal:e.signal,resolveLocalInteractor:e.resolveInteractor,ownership:`local`})}function c(e){return o({device:e.device,signal:e.signal,ownership:{kind:`provider`,resolveInteractor:e.resolveInteractor}})}async function l(e){let{device:t,positionals:n,execution:r}=e;u(n);let i=n[0],a=n[1];if(!i){await d(e);return}if(f(t,r),a!==void 0){await p(e,i,a);return}await m(e,i)}function u(t){if(t.length>2)throw new e(`INVALID_ARGS`,`open accepts at most two arguments: <app|url> [url]`)}async function d(t){if(t.execution.launchConsole)throw new e(`INVALID_ARGS`,`--launch-console requires an app target`);if(t.execution.launchArgs&&t.execution.launchArgs.length>0)throw new e(`INVALID_ARGS`,`--launch-args requires an app target`);await t.interactor.openDevice()}function f(t,i){if(i.launchConsole&&(!n(t)||t.kind!==`simulator`))throw new e(`UNSUPPORTED_OPERATION`,r);if(t.platform===`linux`&&i.launchArgs&&i.launchArgs.length>0)throw new e(`UNSUPPORTED_OPERATION`,`--launch-args is not supported on Linux.`)}async function p(n,r,a){if(t(r))throw new e(`INVALID_ARGS`,`open <app> <url> requires an app target as the first argument`);if(!t(a))throw new e(`INVALID_ARGS`,`open <app> <url> requires a valid URL target`);if(n.execution.launchConsole)throw new e(`INVALID_ARGS`,i);await n.interactor.open(r,{activity:n.execution.activity,appBundleId:n.appBundleId,launchArgs:n.execution.launchArgs?[...n.execution.launchArgs]:void 0,terminateRunningApp:n.terminateRunningApp,url:a})}async function m(n,r){let{execution:a,interactor:o}=n;if(a.launchConsole&&t(r))throw new e(`INVALID_ARGS`,i);if(a.clearAppState){if(t(r))throw new e(`INVALID_ARGS`,`Clearing app state requires an app target, not a deep link.`);await o.setSetting(`clear-app-state`,`clear`,r)}await o.open(r,{activity:a.activity,appBundleId:n.appBundleId,launchConsole:a.launchConsole,launchArgs:a.launchArgs?[...a.launchArgs]:void 0,terminateRunningApp:n.terminateRunningApp})}function h(t){let{binding:n}=t,r=async()=>{throw new e(`UNSUPPORTED_OPERATION`,`This lifecycle operation is unavailable for ${t.owner}.`)};return Object.freeze({resolveOpenTarget:async e=>v(t.openTargetIdentity,e),prepareApplicationOpen:async()=>void 0,openApplication:async e=>await g(t,e),applyRuntimeHints:r,clearRuntimeHints:r,closeApplication:async e=>{await y({device:n.device,interactor:await n.resolveInteractor(e.execution,e.appBundleId),positionals:e.positionals})},finalizeApplicationClose:async()=>({}),prepareAppleRunner:r,configureProviderPortReverse:t.configureProviderPortReverse??r})}async function g(e,t){let{binding:n}=e,r=await n.resolveInteractor(t.execution,t.appBundleId);e.closeBeforeRelaunch&&t.relaunch&&t.target!==void 0&&await y({device:n.device,interactor:r,positionals:[t.appBundleId??t.target]}),await l({device:n.device,interactor:r,positionals:t.positionals,appBundleId:t.appBundleId,execution:t.execution});let i=_(t);return i&&await l({device:n.device,interactor:r,positionals:[i],appBundleId:t.appBundleId,execution:{...t.execution,clearAppState:void 0,launchConsole:void 0,launchArgs:void 0}}),{appBundleId:t.appBundleId,timing:{}}}function _(e){let n=e.runtimeLaunchUrl?.trim(),r=e.positionals.length===1?e.positionals[0]?.trim():void 0;if(!(!n||!r||t(r)))return n}function v(e,n){let r=n.target;if(e===`app-name`)return Object.freeze(r===void 0?{}:{appName:r});let i=r?.trim(),a=i&&i.includes(`.`)&&!t(i)?i:n.currentAppBundleId;return Object.freeze({...a===void 0?{}:{appBundleId:a},...r===void 0?{}:{appName:r}})}async function y(e){let{device:t,interactor:n,positionals:r}=e,i=r[0];if(!i){t.platform===`web`&&await n.close(``);return}await n.close(i)}export{y as a,_ as i,s as n,l as o,c as r,h as t};
1
+ import{C as e}from"./sdk-contracts.js";import{r as t}from"./sdk-batch-runner.js";import{l as n}from"./sdk-device.js";import{n as r,t as i}from"./launch-console.js";function a(e,t,n){return{requestId:e.requestId,signal:n,appBundleId:t,verbose:e.verbose,logPath:e.logPath,traceLogPath:e.traceLogPath,iosXctestrunFile:e.iosXctestrunFile,iosXctestDerivedDataPath:e.iosXctestDerivedDataPath,iosXctestEnvDir:e.iosXctestEnvDir,runnerLeaseContext:e.runnerLeaseContext}}function o(t){let{device:n,signal:r,ownership:i}=t;return Object.freeze({device:n,signal:r,resolveInteractor:async(o,s)=>{let c=a(o,s,r);if(i===`local`)return await t.resolveLocalInteractor(n,c);let l=i.resolveInteractor(c);if(l)return l;throw new e(`UNSUPPORTED_OPERATION`,`Provider-owned application lifecycle operation has no bound provider interactor.`,{reason:`provider-runtime-interactor-missing`,deviceId:n.id})}})}function s(e){return o({device:e.device,signal:e.signal,resolveLocalInteractor:e.resolveInteractor,ownership:`local`})}function c(e){return o({device:e.device,signal:e.signal,ownership:{kind:`provider`,resolveInteractor:e.resolveInteractor}})}async function l(e){let{device:t,positionals:n,execution:r}=e;u(n);let i=n[0],a=n[1];if(!i){await d(e);return}if(f(t,r),a!==void 0){await p(e,i,a);return}await m(e,i)}function u(t){if(t.length>2)throw new e(`INVALID_ARGS`,`open accepts at most two arguments: <app|url> [url]`)}async function d(t){if(t.execution.launchConsole)throw new e(`INVALID_ARGS`,`--launch-console requires an app target`);if(t.execution.launchArgs&&t.execution.launchArgs.length>0)throw new e(`INVALID_ARGS`,`--launch-args requires an app target`);await t.interactor.openDevice()}function f(t,i){if(i.launchConsole&&(!n(t)||t.kind!==`simulator`))throw new e(`UNSUPPORTED_OPERATION`,r);if(t.platform===`linux`&&i.launchArgs&&i.launchArgs.length>0)throw new e(`UNSUPPORTED_OPERATION`,`--launch-args is not supported on Linux.`)}async function p(n,r,a){if(t(r))throw new e(`INVALID_ARGS`,`open <app> <url> requires an app target as the first argument`);if(!t(a))throw new e(`INVALID_ARGS`,`open <app> <url> requires a valid URL target`);if(n.execution.launchConsole)throw new e(`INVALID_ARGS`,i);await n.interactor.open(r,{activity:n.execution.activity,appBundleId:n.appBundleId,launchArgs:n.execution.launchArgs?[...n.execution.launchArgs]:void 0,terminateRunningApp:n.terminateRunningApp,url:a})}async function m(n,r){let{execution:a,interactor:o}=n;if(a.launchConsole&&t(r))throw new e(`INVALID_ARGS`,i);if(a.clearAppState){if(t(r))throw new e(`INVALID_ARGS`,`Clearing app state requires an app target, not a deep link.`);await o.setSetting(`clear-app-state`,`clear`,r)}await o.open(r,{activity:a.activity,appBundleId:n.appBundleId,launchConsole:a.launchConsole,launchArgs:a.launchArgs?[...a.launchArgs]:void 0,terminateRunningApp:n.terminateRunningApp})}function h(t){let{binding:n}=t,r=async()=>{throw new e(`UNSUPPORTED_OPERATION`,`This lifecycle operation is unavailable for ${t.owner}.`)};return Object.freeze({resolveOpenTarget:async e=>v(t.openTargetIdentity,e),prepareApplicationOpen:async()=>void 0,openApplication:async e=>await g(t,e),applyRuntimeHints:r,clearRuntimeHints:r,closeApplication:async e=>{await y({device:n.device,interactor:await n.resolveInteractor(e.execution,e.appBundleId),positionals:e.positionals})},finalizeApplicationClose:async()=>({}),prepareAppleRunner:r,configureProviderPortReverse:t.configureProviderPortReverse??r})}async function g(e,t){let{binding:n}=e,r=await n.resolveInteractor(t.execution,t.appBundleId);e.closeBeforeRelaunch&&t.relaunch&&t.target!==void 0&&await y({device:n.device,interactor:r,positionals:[t.appBundleId??t.target]}),await l({device:n.device,interactor:r,positionals:t.positionals,appBundleId:t.appBundleId,execution:t.execution});let i=_(t);return i&&await l({device:n.device,interactor:r,positionals:[i],appBundleId:t.appBundleId,execution:{...t.execution,clearAppState:void 0,launchConsole:void 0,launchArgs:void 0}}),{appBundleId:t.appBundleId,timing:{}}}function _(e){let n=e.runtimeLaunchUrl?.trim(),r=e.positionals.length===1?e.positionals[0]?.trim():void 0;if(!(!n||!r||t(r)))return n}function v(e,n){let r=n.target;if(e===`app-name`)return Object.freeze(r===void 0?{}:{appName:r});let i=r?.trim(),a=i&&i.includes(`.`)&&!t(i)?i:n.currentAppBundleId;return Object.freeze({...a===void 0?{}:{appBundleId:a},...r===void 0?{}:{appName:r}})}async function y(e){let{device:t,interactor:n,positionals:r}=e,i=r[0];if(!i){t.platform===`web`&&await n.close(``);return}await n.close(i)}export{y as a,_ as i,s as n,l as o,c as r,h as t};
@@ -1,4 +1,4 @@
1
- import{a as e,i as t,r as n,t as r}from"./rolldown-runtime.js";import{y as i}from"./sdk-contracts.js";import a from"node:path";import{createReadStream as o,createWriteStream as s,promises as c}from"node:fs";import{pipeline as l}from"node:stream/promises";import{createGunzip as u}from"node:zlib";const d=2147483648;var f=class{maxBytes;maxEntries;maxDepth;#e=0;#t=0;constructor(e={}){this.maxBytes=y(e.maxBytes??4294967296,`maxBytes`),this.maxEntries=y(e.maxEntries??1e5,`maxEntries`),this.maxDepth=y(e.maxDepth??3,`maxDepth`)}get bytes(){return this.#e}get entries(){return this.#t}preflightArchive(e){let t=y(e.depth,`depth`),n=y(e.entryCount,`entryCount`),r=y(e.declaredBytes,`declaredBytes`);if(t<1||t>this.maxDepth)throw v(`ARCHIVE_NESTING_LIMIT`,`Archive nesting depth exceeds the limit`);if(n>this.maxEntries-this.#t)throw v(`ARCHIVE_ENTRY_LIMIT`,`Archive contains too many entries`);if(r>this.maxBytes-this.#e)throw v(`ARCHIVE_EXPANDED_BYTES_LIMIT`,`Archive expands beyond the byte limit`);return new p(e=>this.#n(e),()=>this.#r(),e.entryCount,e.declaredBytes)}#n(e){let t=y(e,`bytes`);if(t>this.maxBytes-this.#e)throw v(`ARCHIVE_EXPANDED_BYTES_LIMIT`,`Archive expands beyond the byte limit`);this.#e+=t}#r(){if(this.#t>=this.maxEntries)throw v(`ARCHIVE_ENTRY_LIMIT`,`Archive contains too many entries`);this.#t+=1}},p=class{#e;#t;#n;#r;#i=0;#a=0;constructor(e,t,n,r){this.#e=e,this.#t=t,this.#n=n,this.#r=r}chargeBytes(e){let t=y(e,`bytes`);if(t>this.#r-this.#a)throw v(`ARCHIVE_MANIFEST_MISMATCH`,`Archive contents changed after inspection`);this.#e(t),this.#a+=t}commitEntry(){if(this.#i>=this.#n)throw v(`ARCHIVE_MANIFEST_MISMATCH`,`Archive contents changed after inspection`);this.#t(),this.#i+=1}finish(){if(this.#i!==this.#n||this.#a!==this.#r)throw v(`ARCHIVE_MANIFEST_MISMATCH`,`Archive contents changed after inspection`)}};function m(e,t,n){return e.preflightArchive({depth:t,entryCount:n.length,declaredBytes:n.reduce((e,t)=>e+t.size,0)})}function h(e,t){return e.name===t.name&&e.kind===t.kind&&e.size===t.size&&e.mode===t.mode}function g(e){if(!e||e.includes(`\0`)||e.includes(`\\`)||a.posix.isAbsolute(e)||/^[a-zA-Z]:/.test(e)||e.startsWith(`//`))throw v(`ARCHIVE_UNSAFE_PATH`,`Archive contains an unsafe entry path`);let t=a.posix.normalize(e).replace(/^(\.\/)+/,``).replace(/\/$/,``);if(!t||t===`.`||t===`..`||t.startsWith(`../`))throw v(`ARCHIVE_UNSAFE_PATH`,`Archive contains an unsafe entry path`);return t}function _(e,t){let n=g(t),r=a.resolve(e),i=a.resolve(r,...n.split(`/`));if(!i.startsWith(`${r}${a.sep}`))throw v(`ARCHIVE_UNSAFE_PATH`,`Archive entry escapes the extraction root`);return i}function v(e,t,n){return new i(`INVALID_ARGS`,t,{reason:e},n)}function y(e,t){if(!Number.isSafeInteger(e)||e<0)throw RangeError(`${t} must be a non-negative safe integer`);return e}var b=r(((e,n)=>{n.exports=t(`events`)})),x=r(((e,t)=>{t.exports=class{constructor(e){if(!(e>0)||e-1&e)throw Error(`Max size for a FixedFIFO should be a power of two`);this.buffer=Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}clear(){this.top=this.btm=0,this.next=null,this.buffer.fill(void 0)}push(e){return this.buffer[this.top]===void 0&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}peek(){return this.buffer[this.btm]}isEmpty(){return this.buffer[this.btm]===void 0}}})),S=r(((e,t)=>{let n=x();t.exports=class{constructor(e){this.hwm=e||16,this.head=new n(this.hwm),this.tail=this.head,this.length=0}clear(){this.head=this.tail,this.head.clear(),this.length=0}push(e){if(this.length++,!this.head.push(e)){let t=this.head;this.head=t.next=new n(2*this.head.buffer.length),this.head.push(e)}}shift(){this.length!==0&&this.length--;let e=this.tail.shift();if(e===void 0&&this.tail.next){let e=this.tail.next;return this.tail.next=null,this.tail=e,this.tail.shift()}return e}peek(){let e=this.tail.peek();return e===void 0&&this.tail.next?this.tail.next.peek():e}isEmpty(){return this.length===0}}})),C=r(((e,t)=>{function n(e){return Buffer.isBuffer(e)||e instanceof Uint8Array}function r(e){return Buffer.isEncoding(e)}function i(e,t,n){return Buffer.alloc(e,t,n)}function a(e){return Buffer.allocUnsafe(e)}function o(e){return Buffer.allocUnsafeSlow(e)}function s(e,t){return Buffer.byteLength(e,t)}function c(e,t){return Buffer.compare(e,t)}function l(e,t){return Buffer.concat(e,t)}function u(e,t,n,r,i){return b(e).copy(t,n,r,i)}function d(e,t){return b(e).equals(t)}function f(e,t,n,r,i){return b(e).fill(t,n,r,i)}function p(e,t,n){return Buffer.from(e,t,n)}function m(e,t,n,r){return b(e).includes(t,n,r)}function h(e,t,n,r){return b(e).indexOf(t,n,r)}function g(e,t,n,r){return b(e).lastIndexOf(t,n,r)}function _(e){return b(e).swap16()}function v(e){return b(e).swap32()}function y(e){return b(e).swap64()}function b(e){return Buffer.isBuffer(e)?e:Buffer.from(e.buffer,e.byteOffset,e.byteLength)}function x(e,t,n,r){return b(e).toString(t,n,r)}function S(e,t,n,r,i){return b(e).write(t,n,r,i)}function C(e,t){return b(e).readDoubleBE(t)}function w(e,t){return b(e).readDoubleLE(t)}function T(e,t){return b(e).readFloatBE(t)}function E(e,t){return b(e).readFloatLE(t)}function D(e,t){return b(e).readInt32BE(t)}function O(e,t){return b(e).readInt32LE(t)}function k(e,t){return b(e).readUInt32BE(t)}function A(e,t){return b(e).readUInt32LE(t)}function j(e,t,n){return b(e).writeDoubleBE(t,n)}function M(e,t,n){return b(e).writeDoubleLE(t,n)}function N(e,t,n){return b(e).writeFloatBE(t,n)}function P(e,t,n){return b(e).writeFloatLE(t,n)}function F(e,t,n){return b(e).writeInt32BE(t,n)}function I(e,t,n){return b(e).writeInt32LE(t,n)}function L(e,t,n){return b(e).writeUInt32BE(t,n)}function R(e,t,n){return b(e).writeUInt32LE(t,n)}t.exports={isBuffer:n,isEncoding:r,alloc:i,allocUnsafe:a,allocUnsafeSlow:o,byteLength:s,compare:c,concat:l,copy:u,equals:d,fill:f,from:p,includes:m,indexOf:h,lastIndexOf:g,swap16:_,swap32:v,swap64:y,toBuffer:b,toString:x,write:S,readDoubleBE:C,readDoubleLE:w,readFloatBE:T,readFloatLE:E,readInt32BE:D,readInt32LE:O,readUInt32BE:k,readUInt32LE:A,writeDoubleBE:j,writeDoubleLE:M,writeFloatBE:N,writeFloatLE:P,writeInt32BE:F,writeInt32LE:I,writeUInt32BE:L,writeUInt32LE:R}})),w=r(((e,t)=>{let n=C();t.exports=class{constructor(e){this.encoding=e}get remaining(){return 0}decode(e){return n.toString(e,this.encoding)}flush(){return``}}})),T=r(((e,t)=>{let n=C();t.exports=class{constructor(){this._reset()}get remaining(){return this.bytesSeen}decode(e){if(e.byteLength===0)return``;if(this.bytesNeeded===0&&r(e,0)===0)return this.bytesSeen=i(e),n.toString(e,`utf8`);let t=``,a=0;if(this.bytesNeeded>0){for(;a<e.byteLength;){let n=e[a];if(n<this.lowerBoundary||n>this.upperBoundary){t+=`�`,this._reset();break}if(this.lowerBoundary=128,this.upperBoundary=191,this.codePoint=this.codePoint<<6|n&63,this.bytesSeen++,a++,this.bytesSeen===this.bytesNeeded){t+=String.fromCodePoint(this.codePoint),this._reset();break}}if(this.bytesNeeded>0)return t}let o=r(e,a),s=e.byteLength-o;s>a&&(t+=n.toString(e,`utf8`,a,s));for(let n=s;n<e.byteLength;n++){let r=e[n];if(this.bytesNeeded===0){r<=127?(this.bytesSeen=0,t+=String.fromCharCode(r)):r>=194&&r<=223?(this.bytesNeeded=2,this.bytesSeen=1,this.codePoint=r&31):r>=224&&r<=239?(r===224?this.lowerBoundary=160:r===237&&(this.upperBoundary=159),this.bytesNeeded=3,this.bytesSeen=1,this.codePoint=r&15):r>=240&&r<=244?(r===240?this.lowerBoundary=144:r===244&&(this.upperBoundary=143),this.bytesNeeded=4,this.bytesSeen=1,this.codePoint=r&7):(this.bytesSeen=1,t+=`�`);continue}if(r<this.lowerBoundary||r>this.upperBoundary){t+=`�`,n--,this._reset();continue}this.lowerBoundary=128,this.upperBoundary=191,this.codePoint=this.codePoint<<6|r&63,this.bytesSeen++,this.bytesSeen===this.bytesNeeded&&(t+=String.fromCodePoint(this.codePoint),this._reset())}return t}flush(){let e=this.bytesNeeded>0?`�`:``;return this._reset(),e}_reset(){this.codePoint=0,this.bytesNeeded=0,this.bytesSeen=0,this.lowerBoundary=128,this.upperBoundary=191}};function r(e,t){let n=e.byteLength;if(n<=t)return 0;let r=Math.max(t,n-4),i=n-1;for(;i>r&&(e[i]&192)==128;)i--;if(i<t)return 0;let a=e[i],o;if(a<=127)return 0;if(a>=194&&a<=223)o=2;else if(a>=224&&a<=239)o=3;else if(a>=240&&a<=244)o=4;else return 0;let s=n-i;return s<o?s:0}function i(e){let t=e.byteLength;if(t===0)return 0;let n=e[t-1];if(n<=127)return 0;if((n&192)!=128)return 1;let r=Math.max(0,t-4),i=t-2;for(;i>=r&&(e[i]&192)==128;)i--;if(i<0)return 1;let a=e[i],o;if(a>=194&&a<=223)o=2;else if(a>=224&&a<=239)o=3;else if(a>=240&&a<=244)o=4;else return 1;if(t-i!==o)return 1;if(o>=3){let t=e[i+1];if(a===224&&t<160||a===237&&t>159||a===240&&t<144||a===244&&t>143)return 1}return 0}})),E=r(((e,t)=>{let n=w(),r=T();t.exports=class{constructor(e=`utf8`){switch(this.encoding=i(e),this.encoding){case`utf8`:this.decoder=new r;break;case`utf16le`:case`base64`:throw Error(`Unsupported encoding: `+this.encoding);default:this.decoder=new n(this.encoding)}}get remaining(){return this.decoder.remaining}push(e){return typeof e==`string`?e:this.decoder.decode(e)}write(e){return this.push(e)}end(e){let t=``;return e&&(t=this.push(e)),t+=this.decoder.flush(),t}};function i(e){switch(e=e.toLowerCase(),e){case`utf8`:case`utf-8`:return`utf8`;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return`utf16le`;case`latin1`:case`binary`:return`latin1`;case`base64`:case`ascii`:case`hex`:return e;default:throw Error(`Unknown encoding: `+e)}}})),D=r(((e,t)=>{t.exports=class e extends Error{constructor(t,n,r=e){super(t),this.code=n,Error.captureStackTrace&&Error.captureStackTrace(this,r)}static isStreamDestroyed(e){return e&&e.code===`STREAM_DESTROYED`}static isPrematureClose(e){return e&&e.code===`PREMATURE_CLOSE`}static isAborted(e){return e&&e.code===`ABORTED`}static isBadArgument(e){return e&&e.code===`BAD_ARGUMENT`}get name(){return`StreamError`}static STREAM_DESTROYED(){return new e(`Stream was destroyed`,`STREAM_DESTROYED`,e.STREAM_DESTROYED)}static PREMATURE_CLOSE(t=`Premature close`){return new e(t,`PREMATURE_CLOSE`,e.PREMATURE_CLOSE)}static ABORTED(){return new e(`Stream aborted`,`ABORTED`,e.ABORTED)}static BAD_ARGUMENT(t=`Bad argument`){return new e(t,`BAD_ARGUMENT`,e.BAD_ARGUMENT)}}})),O=r(((e,t)=>{let{EventEmitter:n}=b(),r=S(),i=E(),a=D(),o=typeof queueMicrotask>`u`?e=>global.process.nextTick(e):queueMicrotask,s=536870910,c=1024,l=2048,u=16384,d=32768,f=131072,p=536805375,m=536870143,h=536838143,g=536739839,_=2<<18,v=4<<18,y=8<<18,x=32<<18,C=64<<18,w=128<<18,T=512<<18,O=1024<<18,k=503316479,A=268435455,j=262160,M=8404992,N=8405006,P=33587200,F=33587215,I=16527,L=270794767,R=Symbol.asyncIterator||Symbol(`asyncIterator`);var z=class{constructor(e,{highWaterMark:t=16384,map:n=null,mapWritable:i,byteLength:a,byteLengthWritable:o}={}){this.stream=e,this.queue=new r,this.highWaterMark=t,this.buffered=0,this.error=null,this.pipeline=null,this.drains=null,this.byteLength=o||a||xe,this.map=i||n,this.afterWrite=re.bind(this),this.afterUpdateNextTick=W.bind(this)}get ending(){return!!(this.stream._duplexState&T)}get ended(){return!!(this.stream._duplexState&x)}push(e){return this.stream._duplexState&142606350?!1:(this.map!==null&&(e=this.map(e)),this.buffered+=this.byteLength(e),this.queue.push(e),this.buffered<this.highWaterMark?(this.stream._duplexState|=y,!0):(this.stream._duplexState|=6291456,!1))}shift(){let e=this.queue.shift();return this.buffered-=this.byteLength(e),this.buffered===0&&(this.stream._duplexState&=534773759),e}end(e){typeof e==`function`?this.stream.once(`finish`,e):e!=null&&this.push(e),this.stream._duplexState=(this.stream._duplexState|T)&535822335}autoBatch(e,t){let n=[],r=this.stream;for(n.push(e);(r._duplexState&L)==2359296;)n.push(r._writableState.shift());if(r._duplexState&15)return t(null);r._writev(n,t)}update(){let e=this.stream;e._duplexState|=_;do{for(;(e._duplexState&L)==y;){let t=this.shift();e._duplexState|=67371008,e._write(t,this.afterWrite)}e._duplexState&1310720||this.updateNonPrimary()}while(this.continueUpdate()===!0);e._duplexState&=536346623}updateNonPrimary(){let e=this.stream;if((e._duplexState&144965647)==T){e._duplexState|=262144,e._final(ne.bind(this));return}if((e._duplexState&14)==4){e._duplexState&P||(e._duplexState|=j,e._destroy(H.bind(this)));return}(e._duplexState&F)==1&&(e._duplexState=(e._duplexState|j)&s,e._open(G.bind(this)))}continueUpdate(){return this.stream._duplexState&w?(this.stream._duplexState&=k,!0):!1}updateCallback(){(this.stream._duplexState&35127311)==v?this.update():this.updateNextTick()}updateNextTick(){this.stream._duplexState&w||(this.stream._duplexState|=w,this.stream._duplexState&_||o(this.afterUpdateNextTick))}},ee=class{constructor(e,{highWaterMark:t=16384,map:n=null,mapReadable:i,byteLength:a,byteLengthReadable:o}={}){this.stream=e,this.queue=new r,this.highWaterMark=t===0?1:t,this.buffered=0,this.readAhead=t>0,this.error=null,this.pipeline=null,this.byteLength=o||a||xe,this.map=i||n,this.pipeTo=null,this.afterRead=ie.bind(this),this.afterUpdateNextTick=U.bind(this)}get ending(){return!!(this.stream._duplexState&c)}get ended(){return!!(this.stream._duplexState&u)}pipe(e,t){if(this.pipeTo!==null)throw a.BAD_ARGUMENT(`Can only pipe to one destination`);if(typeof t!=`function`&&(t=null),this.stream._duplexState|=512,this.pipeTo=e,this.pipeline=new te(this.stream,e,t),t&&this.stream.on(`error`,$),Q(e))e._writableState.pipeline=this.pipeline,t&&e.on(`error`,$),e.on(`finish`,this.pipeline.finished.bind(this.pipeline));else{let t=this.pipeline.done.bind(this.pipeline,e),n=this.pipeline.done.bind(this.pipeline,e,null);e.on(`error`,t),e.on(`close`,n),e.on(`finish`,this.pipeline.finished.bind(this.pipeline))}e.on(`drain`,V.bind(this)),this.stream.emit(`piping`,e),e.emit(`pipe`,this.stream)}push(e){let t=this.stream;return e===null?(this.highWaterMark=0,t._duplexState=(t._duplexState|c)&536805311,!1):this.map!==null&&(e=this.map(e),e===null)?(t._duplexState&=p,this.buffered<this.highWaterMark):(this.buffered+=this.byteLength(e),this.queue.push(e),t._duplexState=(t._duplexState|128)&p,this.buffered<this.highWaterMark)}shift(){let e=this.queue.shift();return this.buffered-=this.byteLength(e),this.buffered===0&&(this.stream._duplexState&=536862591),e}unshift(e){let t=[this.map===null?e:this.map(e)];for(;this.buffered>0;)t.push(this.shift());for(let e=0;e<t.length-1;e++){let n=t[e];this.buffered+=this.byteLength(n),this.queue.push(n)}this.push(t[t.length-1])}read(){let e=this.stream;if((e._duplexState&I)==128){let t=this.shift();return this.pipeTo!==null&&this.pipeTo.write(t)===!1&&(e._duplexState&=m),e._duplexState&l&&e.emit(`data`,t),t}return this.readAhead===!1&&(e._duplexState|=f,this.updateNextTick()),null}drain(){let e=this.stream;for(;(e._duplexState&I)==128&&e._duplexState&768;){let t=this.shift();this.pipeTo!==null&&this.pipeTo.write(t)===!1&&(e._duplexState&=m),e._duplexState&l&&e.emit(`data`,t)}}update(){let e=this.stream;e._duplexState|=32;do{for(this.drain();this.buffered<this.highWaterMark&&(e._duplexState&214047)==f;)e._duplexState|=65552,e._read(this.afterRead),this.drain();(e._duplexState&12431)==4224&&(e._duplexState|=8192,e.emit(`readable`)),e._duplexState&80||this.updateNonPrimary()}while(this.continueUpdate()===!0);e._duplexState&=536870879}updateNonPrimary(){let e=this.stream;if((e._duplexState&1167)==c&&(e._duplexState=(e._duplexState|u)&536869887,e.emit(`end`),(e._duplexState&N)==M&&(e._duplexState|=4),this.pipeTo!==null&&this.pipeTo.end()),(e._duplexState&14)==4){e._duplexState&P||(e._duplexState|=j,e._destroy(H.bind(this)));return}(e._duplexState&F)==1&&(e._duplexState=(e._duplexState|j)&s,e._open(G.bind(this)))}continueUpdate(){return this.stream._duplexState&d?(this.stream._duplexState&=h,!0):!1}updateCallback(){(this.stream._duplexState&32879)==64?this.update():this.updateNextTick()}updateNextTickIfOpen(){this.stream._duplexState&32769||(this.stream._duplexState|=d,this.stream._duplexState&32||o(this.afterUpdateNextTick))}updateNextTick(){this.stream._duplexState&d||(this.stream._duplexState|=d,this.stream._duplexState&32||o(this.afterUpdateNextTick))}},B=class{constructor(e){this.data=null,this.afterTransform=oe.bind(e),this.afterFinal=null}},te=class{constructor(e,t,n){this.from=e,this.to=t,this.afterPipe=n,this.error=null,this.pipeToFinished=!1}finished(){this.pipeToFinished=!0}done(e,t){if(t&&(this.error=t),e===this.to&&(this.to=null,this.from!==null)){(!(this.from._duplexState&u)||!this.pipeToFinished)&&this.from.destroy(this.error||a.PREMATURE_CLOSE(`Writable stream closed`));return}if(e===this.from&&(this.from=null,this.to!==null)){e._duplexState&u||this.to.destroy(this.error||a.PREMATURE_CLOSE(`Readable stream closed`));return}this.afterPipe!==null&&this.afterPipe(this.error),this.to=this.from=this.afterPipe=null}};function V(){this.stream._duplexState|=512,this.updateCallback()}function ne(e){let t=this.stream;e&&t.destroy(e),t._duplexState&14||(t._duplexState|=x,t.emit(`finish`)),(t._duplexState&N)==M&&(t._duplexState|=4),t._duplexState&=402391039,t._duplexState&_?this.updateNextTick():this.update()}function H(e){let t=this.stream;!e&&!a.isStreamDestroyed(this.error)&&(e=this.error),e&&t.emit(`error`,e),t._duplexState|=8,t.emit(`close`);let n=t._readableState,r=t._writableState;if(n!==null&&n.pipeline!==null&&n.pipeline.done(t,e),r!==null){for(;r.drains!==null&&r.drains.length>0;)r.drains.shift().resolve(!1);r.pipeline!==null&&r.pipeline.done(t,e)}}function re(e){let t=this.stream;e&&t.destroy(e),t._duplexState&=469499903,this.drains!==null&&ae(this.drains),(t._duplexState&6553615)==4194304&&(t._duplexState&=532676607,(t._duplexState&C)==C&&t.emit(`drain`)),this.updateCallback()}function ie(e){e&&this.stream.destroy(e),this.stream._duplexState&=536870895,this.readAhead===!1&&!(this.stream._duplexState&256)&&(this.stream._duplexState&=g),this.updateCallback()}function U(){this.stream._duplexState&32||(this.stream._duplexState&=h,this.update())}function W(){this.stream._duplexState&_||(this.stream._duplexState&=k,this.update())}function ae(e){for(let t=0;t<e.length;t++)--e[t].writes===0&&(e.shift().resolve(!0),t--)}function G(e){let t=this.stream;e&&t.destroy(e),t._duplexState&4||(t._duplexState&17423||(t._duplexState|=64),t._duplexState&142606351||(t._duplexState|=v),t.emit(`open`)),t._duplexState&=536608751,t._writableState!==null&&t._writableState.updateCallback(),t._readableState!==null&&t._readableState.updateCallback()}function oe(e,t){t!=null&&this.push(t),this._writableState.afterWrite(e)}function K(e){this._readableState!==null&&(e===`data`&&(this._duplexState|=133376,this._readableState.updateNextTick()),e===`readable`&&(this._duplexState|=4096,this._readableState.updateNextTick())),this._writableState!==null&&e===`drain`&&(this._duplexState|=C,this._writableState.updateNextTick())}var q=class extends n{constructor(e){super(),this._duplexState=0,this._readableState=null,this._writableState=null,e&&(e.open&&(this._open=e.open),e.destroy&&(this._destroy=e.destroy),e.predestroy&&(this._predestroy=e.predestroy),e.signal&&e.signal.addEventListener(`abort`,Se.bind(this))),this.on(`newListener`,K)}_open(e){e(null)}_destroy(e){e(null)}_predestroy(){}get readable(){return this._readableState!==null||void 0}get writable(){return this._writableState!==null||void 0}get destroyed(){return!!(this._duplexState&8)}get destroying(){return!!(this._duplexState&14)}destroy(e){this._duplexState&14||(e||=a.STREAM_DESTROYED(),this._duplexState=(this._duplexState|4)&535822271,this._readableState!==null&&(this._readableState.highWaterMark=0,this._readableState.error=e),this._writableState!==null&&(this._writableState.highWaterMark=0,this._writableState.error=e),this._duplexState|=2,this._predestroy(),this._duplexState&=536870909,this._readableState!==null&&this._readableState.updateNextTick(),this._writableState!==null&&this._writableState.updateNextTick())}},J=class e extends q{constructor(e){super(e),this._duplexState|=8519681,this._readableState=new ee(this,e),e&&(this._readableState.readAhead===!1&&(this._duplexState&=g),e.read&&(this._read=e.read),e.eagerOpen&&this._readableState.updateNextTick(),e.encoding&&this.setEncoding(e.encoding))}static deferred(e,t){let n=new ce(t);return e().then(e=>{if(e===null)return n.end();n.destroying||Z(e,n,$)}).catch(e=>n.destroy(e)),n}setEncoding(e){let t=new i(e),n=this._readableState.map||de;return this._readableState.map=r,this;function r(e){let r=t.push(e);return r===``&&(e.byteLength!==0||t.remaining>0)?null:n(r)}}_read(e){e(null)}pipe(e,t){return this._readableState.updateNextTick(),this._readableState.pipe(e,t),e}read(){return this._readableState.updateNextTick(),this._readableState.read()}push(e){return this._readableState.updateNextTickIfOpen(),this._readableState.push(e)}unshift(e){return this._readableState.updateNextTickIfOpen(),this._readableState.unshift(e)}resume(){return this._duplexState|=131328,this._readableState.updateNextTick(),this}pause(){return this._duplexState&=this._readableState.readAhead===!1?536739583:536870655,this}static _fromAsyncIterator(t,n){let r,i=new e({...n,read(e){t.next().then(a).then(e.bind(null,null)).catch(e)},predestroy(){r=t.return()},destroy(e){if(!r)return e(null);r.then(e.bind(null,null)).catch(e)}});return i;function a(e){e.done?i.push(null):i.push(e.value)}}static from(t,n){if(ve(t))return t;if(t[R])return this._fromAsyncIterator(t[R](),n);Array.isArray(t)||(t=t===void 0?[]:[t]);let r=0;return new e({...n,read(e){this.push(r===t.length?null:t[r++]),e(null)}})}static isBackpressured(e){return!!(e._duplexState&17422)||e._readableState.buffered>=e._readableState.highWaterMark}static isPaused(e){return!(e._duplexState&256)}[R](){let e=this,t=null,n=null,r=null;return this.on(`error`,e=>{t=e}),this.on(`readable`,i),this.on(`close`,o),{[R](){return this},next(){return new Promise(function(t,i){n=t,r=i;let a=e.read();a===null?e._duplexState&8&&s(null):s(a)})},return(){return c(null)},throw(e){return c(e)}};function i(){n!==null&&s(e.read())}function o(){n!==null&&s(null)}function s(i){r!==null&&(t?r(t):i===null&&!(e._duplexState&u)?r(a.STREAM_DESTROYED()):n({value:i,done:i===null}),r=n=null)}function c(t){return e.destroy(t),new Promise((n,r)=>{if(e._duplexState&8)return n({value:void 0,done:!0});e.once(`close`,function(){t?r(t):n({value:void 0,done:!0})})})}}},Y=class extends q{constructor(e){super(e),this._duplexState|=16385,this._writableState=new z(this,e),e&&(e.writev&&(this._writev=e.writev),e.write&&(this._write=e.write),e.final&&(this._final=e.final),e.eagerOpen&&this._writableState.updateNextTick())}cork(){this._duplexState|=O}uncork(){this._duplexState&=A,this._writableState.updateNextTick()}_writev(e,t){t(null)}_write(e,t){this._writableState.autoBatch(e,t)}_final(e){e(null)}static isBackpressured(e){return!!(e._duplexState&146800654)}static drained(e){if(e.destroyed)return Promise.resolve(!1);let t=e._writableState,n=(Ce(e)?Math.min(1,t.queue.length):t.queue.length)+(e._duplexState&67108864?1:0);return n===0?Promise.resolve(!0):(t.drains===null&&(t.drains=[]),new Promise(e=>{t.drains.push({writes:n,resolve:e})}))}write(e){return this._writableState.updateNextTick(),this._writableState.push(e)}end(e){return this._writableState.updateNextTick(),this._writableState.end(e),this}},X=class extends J{constructor(e){super(e),this._duplexState=1|this._duplexState&f,this._writableState=new z(this,e),e&&(e.writev&&(this._writev=e.writev),e.write&&(this._write=e.write),e.final&&(this._final=e.final))}cork(){this._duplexState|=O}uncork(){this._duplexState&=A,this._writableState.updateNextTick()}_writev(e,t){t(null)}_write(e,t){this._writableState.autoBatch(e,t)}_final(e){e(null)}write(e){return this._writableState.updateNextTick(),this._writableState.push(e)}end(e){return this._writableState.updateNextTick(),this._writableState.end(e),this}},se=class extends X{constructor(e){super(e),this._transformState=new B(this),e&&(e.transform&&(this._transform=e.transform),e.flush&&(this._flush=e.flush))}_write(e,t){this._readableState.buffered>=this._readableState.highWaterMark?this._transformState.data=e:this._transform(e,this._transformState.afterTransform)}_read(e){if(this._transformState.data!==null){let t=this._transformState.data;this._transformState.data=null,e(null),this._transform(t,this._transformState.afterTransform)}else e(null)}destroy(e){super.destroy(e),this._transformState.data!==null&&(this._transformState.data=null,this._transformState.afterTransform())}_transform(e,t){t(null,e)}_flush(e){e(null)}_final(e){this._transformState.afterFinal=e,this._flush(le.bind(this))}},ce=class extends se{};function le(e,t){let n=this._transformState.afterFinal;if(e)return n(e);t!=null&&this.push(t),this.push(null),n(null)}function ue(...e){return new Promise((t,n)=>Z(...e,e=>{if(e)return n(e);t()}))}function Z(e,...t){let n=Array.isArray(e)?[...e,...t]:[e,...t],r=n.length&&typeof n[n.length-1]==`function`?n.pop():null;if(n.length<2)throw a.BAD_ARGUMENT(`Pipeline requires at least 2 streams`);let i=n[0],o=null,s=null;for(let e=1;e<n.length;e++)o=n[e],Q(i)?i.pipe(o,l):(c(i,!0,e>1,l),i.pipe(o)),i=o;if(r){let e=!1,t=Q(o)||!!(o._writableState&&o._writableState.autoDestroy);o.on(`error`,e=>{s===null&&(s=e)}),o.on(`finish`,()=>{e=!0,t||r(s)}),t&&o.on(`close`,()=>r(s||(e?null:a.PREMATURE_CLOSE())))}return o;function c(e,t,n,r){e.on(`error`,r),e.on(`close`,i);function i(){if(t&&e._readableState&&!e._readableState.ended||n&&e._writableState&&!e._writableState.ended)return r(a.PREMATURE_CLOSE())}}function l(e){if(!(!e||s)){s=e;for(let t of n)t.destroy(e)}}}function de(e){return e}function fe(e){return!!e._readableState||!!e._writableState}function Q(e){return typeof e._duplexState==`number`&&fe(e)}function pe(e){return!!e._readableState&&e._readableState.ending}function me(e){return!!e._readableState&&e._readableState.ended}function he(e){return!!e._writableState&&e._writableState.ending}function ge(e){return!!e._writableState&&e._writableState.ended}function _e(e,t={}){let n=e._readableState&&e._readableState.error||e._writableState&&e._writableState.error;return!t.all&&a.isStreamDestroyed(n)?null:n}function ve(e){return Q(e)&&e.readable}function ye(e){return(e._duplexState&1)!=1||(e._duplexState&4)==4||!!(e._duplexState&P)}function be(e){return typeof e==`object`&&!!e&&typeof e.byteLength==`number`}function xe(e){return be(e)?e.byteLength:1024}function $(){}function Se(){this.destroy(a.ABORTED())}function Ce(e){return e._writev!==Y.prototype._writev&&e._writev!==X.prototype._writev}t.exports={pipeline:Z,pipelinePromise:ue,isStream:fe,isStreamx:Q,isEnding:pe,isEnded:me,isFinishing:he,isFinished:ge,isDisturbed:ye,getStreamError:_e,Stream:q,Writable:Y,Readable:J,Duplex:X,Transform:se,PassThrough:ce}})),k=r((e=>{let t=C(),n=t.from([117,115,116,97,114,0]),r=t.from([48,48]),i=t.from([117,115,116,97,114,32]),a=t.from([32,0]);e.decodeLongPath=function(e,t){return v(e,0,e.length,t)},e.encodePax=function(e){let n=``;e.name&&(n+=y(` path=`+e.name+`
1
+ import{a as e,i as t,r as n,t as r}from"./rolldown-runtime.js";import{C as i}from"./sdk-contracts.js";import a from"node:path";import{createReadStream as o,createWriteStream as s,promises as c}from"node:fs";import{pipeline as l}from"node:stream/promises";import{createGunzip as u}from"node:zlib";const d=2147483648;var f=class{maxBytes;maxEntries;maxDepth;#e=0;#t=0;constructor(e={}){this.maxBytes=y(e.maxBytes??4294967296,`maxBytes`),this.maxEntries=y(e.maxEntries??1e5,`maxEntries`),this.maxDepth=y(e.maxDepth??3,`maxDepth`)}get bytes(){return this.#e}get entries(){return this.#t}preflightArchive(e){let t=y(e.depth,`depth`),n=y(e.entryCount,`entryCount`),r=y(e.declaredBytes,`declaredBytes`);if(t<1||t>this.maxDepth)throw v(`ARCHIVE_NESTING_LIMIT`,`Archive nesting depth exceeds the limit`);if(n>this.maxEntries-this.#t)throw v(`ARCHIVE_ENTRY_LIMIT`,`Archive contains too many entries`);if(r>this.maxBytes-this.#e)throw v(`ARCHIVE_EXPANDED_BYTES_LIMIT`,`Archive expands beyond the byte limit`);return new p(e=>this.#n(e),()=>this.#r(),e.entryCount,e.declaredBytes)}#n(e){let t=y(e,`bytes`);if(t>this.maxBytes-this.#e)throw v(`ARCHIVE_EXPANDED_BYTES_LIMIT`,`Archive expands beyond the byte limit`);this.#e+=t}#r(){if(this.#t>=this.maxEntries)throw v(`ARCHIVE_ENTRY_LIMIT`,`Archive contains too many entries`);this.#t+=1}},p=class{#e;#t;#n;#r;#i=0;#a=0;constructor(e,t,n,r){this.#e=e,this.#t=t,this.#n=n,this.#r=r}chargeBytes(e){let t=y(e,`bytes`);if(t>this.#r-this.#a)throw v(`ARCHIVE_MANIFEST_MISMATCH`,`Archive contents changed after inspection`);this.#e(t),this.#a+=t}commitEntry(){if(this.#i>=this.#n)throw v(`ARCHIVE_MANIFEST_MISMATCH`,`Archive contents changed after inspection`);this.#t(),this.#i+=1}finish(){if(this.#i!==this.#n||this.#a!==this.#r)throw v(`ARCHIVE_MANIFEST_MISMATCH`,`Archive contents changed after inspection`)}};function m(e,t,n){return e.preflightArchive({depth:t,entryCount:n.length,declaredBytes:n.reduce((e,t)=>e+t.size,0)})}function h(e,t){return e.name===t.name&&e.kind===t.kind&&e.size===t.size&&e.mode===t.mode}function g(e){if(!e||e.includes(`\0`)||e.includes(`\\`)||a.posix.isAbsolute(e)||/^[a-zA-Z]:/.test(e)||e.startsWith(`//`))throw v(`ARCHIVE_UNSAFE_PATH`,`Archive contains an unsafe entry path`);let t=a.posix.normalize(e).replace(/^(\.\/)+/,``).replace(/\/$/,``);if(!t||t===`.`||t===`..`||t.startsWith(`../`))throw v(`ARCHIVE_UNSAFE_PATH`,`Archive contains an unsafe entry path`);return t}function _(e,t){let n=g(t),r=a.resolve(e),i=a.resolve(r,...n.split(`/`));if(!i.startsWith(`${r}${a.sep}`))throw v(`ARCHIVE_UNSAFE_PATH`,`Archive entry escapes the extraction root`);return i}function v(e,t,n){return new i(`INVALID_ARGS`,t,{reason:e},n)}function y(e,t){if(!Number.isSafeInteger(e)||e<0)throw RangeError(`${t} must be a non-negative safe integer`);return e}var b=r(((e,n)=>{n.exports=t(`events`)})),x=r(((e,t)=>{t.exports=class{constructor(e){if(!(e>0)||e-1&e)throw Error(`Max size for a FixedFIFO should be a power of two`);this.buffer=Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}clear(){this.top=this.btm=0,this.next=null,this.buffer.fill(void 0)}push(e){return this.buffer[this.top]===void 0&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}peek(){return this.buffer[this.btm]}isEmpty(){return this.buffer[this.btm]===void 0}}})),S=r(((e,t)=>{let n=x();t.exports=class{constructor(e){this.hwm=e||16,this.head=new n(this.hwm),this.tail=this.head,this.length=0}clear(){this.head=this.tail,this.head.clear(),this.length=0}push(e){if(this.length++,!this.head.push(e)){let t=this.head;this.head=t.next=new n(2*this.head.buffer.length),this.head.push(e)}}shift(){this.length!==0&&this.length--;let e=this.tail.shift();if(e===void 0&&this.tail.next){let e=this.tail.next;return this.tail.next=null,this.tail=e,this.tail.shift()}return e}peek(){let e=this.tail.peek();return e===void 0&&this.tail.next?this.tail.next.peek():e}isEmpty(){return this.length===0}}})),C=r(((e,t)=>{function n(e){return Buffer.isBuffer(e)||e instanceof Uint8Array}function r(e){return Buffer.isEncoding(e)}function i(e,t,n){return Buffer.alloc(e,t,n)}function a(e){return Buffer.allocUnsafe(e)}function o(e){return Buffer.allocUnsafeSlow(e)}function s(e,t){return Buffer.byteLength(e,t)}function c(e,t){return Buffer.compare(e,t)}function l(e,t){return Buffer.concat(e,t)}function u(e,t,n,r,i){return b(e).copy(t,n,r,i)}function d(e,t){return b(e).equals(t)}function f(e,t,n,r,i){return b(e).fill(t,n,r,i)}function p(e,t,n){return Buffer.from(e,t,n)}function m(e,t,n,r){return b(e).includes(t,n,r)}function h(e,t,n,r){return b(e).indexOf(t,n,r)}function g(e,t,n,r){return b(e).lastIndexOf(t,n,r)}function _(e){return b(e).swap16()}function v(e){return b(e).swap32()}function y(e){return b(e).swap64()}function b(e){return Buffer.isBuffer(e)?e:Buffer.from(e.buffer,e.byteOffset,e.byteLength)}function x(e,t,n,r){return b(e).toString(t,n,r)}function S(e,t,n,r,i){return b(e).write(t,n,r,i)}function C(e,t){return b(e).readDoubleBE(t)}function w(e,t){return b(e).readDoubleLE(t)}function T(e,t){return b(e).readFloatBE(t)}function E(e,t){return b(e).readFloatLE(t)}function D(e,t){return b(e).readInt32BE(t)}function O(e,t){return b(e).readInt32LE(t)}function k(e,t){return b(e).readUInt32BE(t)}function A(e,t){return b(e).readUInt32LE(t)}function j(e,t,n){return b(e).writeDoubleBE(t,n)}function M(e,t,n){return b(e).writeDoubleLE(t,n)}function N(e,t,n){return b(e).writeFloatBE(t,n)}function P(e,t,n){return b(e).writeFloatLE(t,n)}function F(e,t,n){return b(e).writeInt32BE(t,n)}function I(e,t,n){return b(e).writeInt32LE(t,n)}function L(e,t,n){return b(e).writeUInt32BE(t,n)}function R(e,t,n){return b(e).writeUInt32LE(t,n)}t.exports={isBuffer:n,isEncoding:r,alloc:i,allocUnsafe:a,allocUnsafeSlow:o,byteLength:s,compare:c,concat:l,copy:u,equals:d,fill:f,from:p,includes:m,indexOf:h,lastIndexOf:g,swap16:_,swap32:v,swap64:y,toBuffer:b,toString:x,write:S,readDoubleBE:C,readDoubleLE:w,readFloatBE:T,readFloatLE:E,readInt32BE:D,readInt32LE:O,readUInt32BE:k,readUInt32LE:A,writeDoubleBE:j,writeDoubleLE:M,writeFloatBE:N,writeFloatLE:P,writeInt32BE:F,writeInt32LE:I,writeUInt32BE:L,writeUInt32LE:R}})),w=r(((e,t)=>{let n=C();t.exports=class{constructor(e){this.encoding=e}get remaining(){return 0}decode(e){return n.toString(e,this.encoding)}flush(){return``}}})),T=r(((e,t)=>{let n=C();t.exports=class{constructor(){this._reset()}get remaining(){return this.bytesSeen}decode(e){if(e.byteLength===0)return``;if(this.bytesNeeded===0&&r(e,0)===0)return this.bytesSeen=i(e),n.toString(e,`utf8`);let t=``,a=0;if(this.bytesNeeded>0){for(;a<e.byteLength;){let n=e[a];if(n<this.lowerBoundary||n>this.upperBoundary){t+=`�`,this._reset();break}if(this.lowerBoundary=128,this.upperBoundary=191,this.codePoint=this.codePoint<<6|n&63,this.bytesSeen++,a++,this.bytesSeen===this.bytesNeeded){t+=String.fromCodePoint(this.codePoint),this._reset();break}}if(this.bytesNeeded>0)return t}let o=r(e,a),s=e.byteLength-o;s>a&&(t+=n.toString(e,`utf8`,a,s));for(let n=s;n<e.byteLength;n++){let r=e[n];if(this.bytesNeeded===0){r<=127?(this.bytesSeen=0,t+=String.fromCharCode(r)):r>=194&&r<=223?(this.bytesNeeded=2,this.bytesSeen=1,this.codePoint=r&31):r>=224&&r<=239?(r===224?this.lowerBoundary=160:r===237&&(this.upperBoundary=159),this.bytesNeeded=3,this.bytesSeen=1,this.codePoint=r&15):r>=240&&r<=244?(r===240?this.lowerBoundary=144:r===244&&(this.upperBoundary=143),this.bytesNeeded=4,this.bytesSeen=1,this.codePoint=r&7):(this.bytesSeen=1,t+=`�`);continue}if(r<this.lowerBoundary||r>this.upperBoundary){t+=`�`,n--,this._reset();continue}this.lowerBoundary=128,this.upperBoundary=191,this.codePoint=this.codePoint<<6|r&63,this.bytesSeen++,this.bytesSeen===this.bytesNeeded&&(t+=String.fromCodePoint(this.codePoint),this._reset())}return t}flush(){let e=this.bytesNeeded>0?`�`:``;return this._reset(),e}_reset(){this.codePoint=0,this.bytesNeeded=0,this.bytesSeen=0,this.lowerBoundary=128,this.upperBoundary=191}};function r(e,t){let n=e.byteLength;if(n<=t)return 0;let r=Math.max(t,n-4),i=n-1;for(;i>r&&(e[i]&192)==128;)i--;if(i<t)return 0;let a=e[i],o;if(a<=127)return 0;if(a>=194&&a<=223)o=2;else if(a>=224&&a<=239)o=3;else if(a>=240&&a<=244)o=4;else return 0;let s=n-i;return s<o?s:0}function i(e){let t=e.byteLength;if(t===0)return 0;let n=e[t-1];if(n<=127)return 0;if((n&192)!=128)return 1;let r=Math.max(0,t-4),i=t-2;for(;i>=r&&(e[i]&192)==128;)i--;if(i<0)return 1;let a=e[i],o;if(a>=194&&a<=223)o=2;else if(a>=224&&a<=239)o=3;else if(a>=240&&a<=244)o=4;else return 1;if(t-i!==o)return 1;if(o>=3){let t=e[i+1];if(a===224&&t<160||a===237&&t>159||a===240&&t<144||a===244&&t>143)return 1}return 0}})),E=r(((e,t)=>{let n=w(),r=T();t.exports=class{constructor(e=`utf8`){switch(this.encoding=i(e),this.encoding){case`utf8`:this.decoder=new r;break;case`utf16le`:case`base64`:throw Error(`Unsupported encoding: `+this.encoding);default:this.decoder=new n(this.encoding)}}get remaining(){return this.decoder.remaining}push(e){return typeof e==`string`?e:this.decoder.decode(e)}write(e){return this.push(e)}end(e){let t=``;return e&&(t=this.push(e)),t+=this.decoder.flush(),t}};function i(e){switch(e=e.toLowerCase(),e){case`utf8`:case`utf-8`:return`utf8`;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return`utf16le`;case`latin1`:case`binary`:return`latin1`;case`base64`:case`ascii`:case`hex`:return e;default:throw Error(`Unknown encoding: `+e)}}})),D=r(((e,t)=>{t.exports=class e extends Error{constructor(t,n,r=e){super(t),this.code=n,Error.captureStackTrace&&Error.captureStackTrace(this,r)}static isStreamDestroyed(e){return e&&e.code===`STREAM_DESTROYED`}static isPrematureClose(e){return e&&e.code===`PREMATURE_CLOSE`}static isAborted(e){return e&&e.code===`ABORTED`}static isBadArgument(e){return e&&e.code===`BAD_ARGUMENT`}get name(){return`StreamError`}static STREAM_DESTROYED(){return new e(`Stream was destroyed`,`STREAM_DESTROYED`,e.STREAM_DESTROYED)}static PREMATURE_CLOSE(t=`Premature close`){return new e(t,`PREMATURE_CLOSE`,e.PREMATURE_CLOSE)}static ABORTED(){return new e(`Stream aborted`,`ABORTED`,e.ABORTED)}static BAD_ARGUMENT(t=`Bad argument`){return new e(t,`BAD_ARGUMENT`,e.BAD_ARGUMENT)}}})),O=r(((e,t)=>{let{EventEmitter:n}=b(),r=S(),i=E(),a=D(),o=typeof queueMicrotask>`u`?e=>global.process.nextTick(e):queueMicrotask,s=536870910,c=1024,l=2048,u=16384,d=32768,f=131072,p=536805375,m=536870143,h=536838143,g=536739839,_=2<<18,v=4<<18,y=8<<18,x=32<<18,C=64<<18,w=128<<18,T=512<<18,O=1024<<18,k=503316479,A=268435455,j=262160,M=8404992,N=8405006,P=33587200,F=33587215,I=16527,L=270794767,R=Symbol.asyncIterator||Symbol(`asyncIterator`);var z=class{constructor(e,{highWaterMark:t=16384,map:n=null,mapWritable:i,byteLength:a,byteLengthWritable:o}={}){this.stream=e,this.queue=new r,this.highWaterMark=t,this.buffered=0,this.error=null,this.pipeline=null,this.drains=null,this.byteLength=o||a||xe,this.map=i||n,this.afterWrite=re.bind(this),this.afterUpdateNextTick=W.bind(this)}get ending(){return!!(this.stream._duplexState&T)}get ended(){return!!(this.stream._duplexState&x)}push(e){return this.stream._duplexState&142606350?!1:(this.map!==null&&(e=this.map(e)),this.buffered+=this.byteLength(e),this.queue.push(e),this.buffered<this.highWaterMark?(this.stream._duplexState|=y,!0):(this.stream._duplexState|=6291456,!1))}shift(){let e=this.queue.shift();return this.buffered-=this.byteLength(e),this.buffered===0&&(this.stream._duplexState&=534773759),e}end(e){typeof e==`function`?this.stream.once(`finish`,e):e!=null&&this.push(e),this.stream._duplexState=(this.stream._duplexState|T)&535822335}autoBatch(e,t){let n=[],r=this.stream;for(n.push(e);(r._duplexState&L)==2359296;)n.push(r._writableState.shift());if(r._duplexState&15)return t(null);r._writev(n,t)}update(){let e=this.stream;e._duplexState|=_;do{for(;(e._duplexState&L)==y;){let t=this.shift();e._duplexState|=67371008,e._write(t,this.afterWrite)}e._duplexState&1310720||this.updateNonPrimary()}while(this.continueUpdate()===!0);e._duplexState&=536346623}updateNonPrimary(){let e=this.stream;if((e._duplexState&144965647)==T){e._duplexState|=262144,e._final(ne.bind(this));return}if((e._duplexState&14)==4){e._duplexState&P||(e._duplexState|=j,e._destroy(H.bind(this)));return}(e._duplexState&F)==1&&(e._duplexState=(e._duplexState|j)&s,e._open(G.bind(this)))}continueUpdate(){return this.stream._duplexState&w?(this.stream._duplexState&=k,!0):!1}updateCallback(){(this.stream._duplexState&35127311)==v?this.update():this.updateNextTick()}updateNextTick(){this.stream._duplexState&w||(this.stream._duplexState|=w,this.stream._duplexState&_||o(this.afterUpdateNextTick))}},ee=class{constructor(e,{highWaterMark:t=16384,map:n=null,mapReadable:i,byteLength:a,byteLengthReadable:o}={}){this.stream=e,this.queue=new r,this.highWaterMark=t===0?1:t,this.buffered=0,this.readAhead=t>0,this.error=null,this.pipeline=null,this.byteLength=o||a||xe,this.map=i||n,this.pipeTo=null,this.afterRead=ie.bind(this),this.afterUpdateNextTick=U.bind(this)}get ending(){return!!(this.stream._duplexState&c)}get ended(){return!!(this.stream._duplexState&u)}pipe(e,t){if(this.pipeTo!==null)throw a.BAD_ARGUMENT(`Can only pipe to one destination`);if(typeof t!=`function`&&(t=null),this.stream._duplexState|=512,this.pipeTo=e,this.pipeline=new te(this.stream,e,t),t&&this.stream.on(`error`,$),Q(e))e._writableState.pipeline=this.pipeline,t&&e.on(`error`,$),e.on(`finish`,this.pipeline.finished.bind(this.pipeline));else{let t=this.pipeline.done.bind(this.pipeline,e),n=this.pipeline.done.bind(this.pipeline,e,null);e.on(`error`,t),e.on(`close`,n),e.on(`finish`,this.pipeline.finished.bind(this.pipeline))}e.on(`drain`,V.bind(this)),this.stream.emit(`piping`,e),e.emit(`pipe`,this.stream)}push(e){let t=this.stream;return e===null?(this.highWaterMark=0,t._duplexState=(t._duplexState|c)&536805311,!1):this.map!==null&&(e=this.map(e),e===null)?(t._duplexState&=p,this.buffered<this.highWaterMark):(this.buffered+=this.byteLength(e),this.queue.push(e),t._duplexState=(t._duplexState|128)&p,this.buffered<this.highWaterMark)}shift(){let e=this.queue.shift();return this.buffered-=this.byteLength(e),this.buffered===0&&(this.stream._duplexState&=536862591),e}unshift(e){let t=[this.map===null?e:this.map(e)];for(;this.buffered>0;)t.push(this.shift());for(let e=0;e<t.length-1;e++){let n=t[e];this.buffered+=this.byteLength(n),this.queue.push(n)}this.push(t[t.length-1])}read(){let e=this.stream;if((e._duplexState&I)==128){let t=this.shift();return this.pipeTo!==null&&this.pipeTo.write(t)===!1&&(e._duplexState&=m),e._duplexState&l&&e.emit(`data`,t),t}return this.readAhead===!1&&(e._duplexState|=f,this.updateNextTick()),null}drain(){let e=this.stream;for(;(e._duplexState&I)==128&&e._duplexState&768;){let t=this.shift();this.pipeTo!==null&&this.pipeTo.write(t)===!1&&(e._duplexState&=m),e._duplexState&l&&e.emit(`data`,t)}}update(){let e=this.stream;e._duplexState|=32;do{for(this.drain();this.buffered<this.highWaterMark&&(e._duplexState&214047)==f;)e._duplexState|=65552,e._read(this.afterRead),this.drain();(e._duplexState&12431)==4224&&(e._duplexState|=8192,e.emit(`readable`)),e._duplexState&80||this.updateNonPrimary()}while(this.continueUpdate()===!0);e._duplexState&=536870879}updateNonPrimary(){let e=this.stream;if((e._duplexState&1167)==c&&(e._duplexState=(e._duplexState|u)&536869887,e.emit(`end`),(e._duplexState&N)==M&&(e._duplexState|=4),this.pipeTo!==null&&this.pipeTo.end()),(e._duplexState&14)==4){e._duplexState&P||(e._duplexState|=j,e._destroy(H.bind(this)));return}(e._duplexState&F)==1&&(e._duplexState=(e._duplexState|j)&s,e._open(G.bind(this)))}continueUpdate(){return this.stream._duplexState&d?(this.stream._duplexState&=h,!0):!1}updateCallback(){(this.stream._duplexState&32879)==64?this.update():this.updateNextTick()}updateNextTickIfOpen(){this.stream._duplexState&32769||(this.stream._duplexState|=d,this.stream._duplexState&32||o(this.afterUpdateNextTick))}updateNextTick(){this.stream._duplexState&d||(this.stream._duplexState|=d,this.stream._duplexState&32||o(this.afterUpdateNextTick))}},B=class{constructor(e){this.data=null,this.afterTransform=oe.bind(e),this.afterFinal=null}},te=class{constructor(e,t,n){this.from=e,this.to=t,this.afterPipe=n,this.error=null,this.pipeToFinished=!1}finished(){this.pipeToFinished=!0}done(e,t){if(t&&(this.error=t),e===this.to&&(this.to=null,this.from!==null)){(!(this.from._duplexState&u)||!this.pipeToFinished)&&this.from.destroy(this.error||a.PREMATURE_CLOSE(`Writable stream closed`));return}if(e===this.from&&(this.from=null,this.to!==null)){e._duplexState&u||this.to.destroy(this.error||a.PREMATURE_CLOSE(`Readable stream closed`));return}this.afterPipe!==null&&this.afterPipe(this.error),this.to=this.from=this.afterPipe=null}};function V(){this.stream._duplexState|=512,this.updateCallback()}function ne(e){let t=this.stream;e&&t.destroy(e),t._duplexState&14||(t._duplexState|=x,t.emit(`finish`)),(t._duplexState&N)==M&&(t._duplexState|=4),t._duplexState&=402391039,t._duplexState&_?this.updateNextTick():this.update()}function H(e){let t=this.stream;!e&&!a.isStreamDestroyed(this.error)&&(e=this.error),e&&t.emit(`error`,e),t._duplexState|=8,t.emit(`close`);let n=t._readableState,r=t._writableState;if(n!==null&&n.pipeline!==null&&n.pipeline.done(t,e),r!==null){for(;r.drains!==null&&r.drains.length>0;)r.drains.shift().resolve(!1);r.pipeline!==null&&r.pipeline.done(t,e)}}function re(e){let t=this.stream;e&&t.destroy(e),t._duplexState&=469499903,this.drains!==null&&ae(this.drains),(t._duplexState&6553615)==4194304&&(t._duplexState&=532676607,(t._duplexState&C)==C&&t.emit(`drain`)),this.updateCallback()}function ie(e){e&&this.stream.destroy(e),this.stream._duplexState&=536870895,this.readAhead===!1&&!(this.stream._duplexState&256)&&(this.stream._duplexState&=g),this.updateCallback()}function U(){this.stream._duplexState&32||(this.stream._duplexState&=h,this.update())}function W(){this.stream._duplexState&_||(this.stream._duplexState&=k,this.update())}function ae(e){for(let t=0;t<e.length;t++)--e[t].writes===0&&(e.shift().resolve(!0),t--)}function G(e){let t=this.stream;e&&t.destroy(e),t._duplexState&4||(t._duplexState&17423||(t._duplexState|=64),t._duplexState&142606351||(t._duplexState|=v),t.emit(`open`)),t._duplexState&=536608751,t._writableState!==null&&t._writableState.updateCallback(),t._readableState!==null&&t._readableState.updateCallback()}function oe(e,t){t!=null&&this.push(t),this._writableState.afterWrite(e)}function K(e){this._readableState!==null&&(e===`data`&&(this._duplexState|=133376,this._readableState.updateNextTick()),e===`readable`&&(this._duplexState|=4096,this._readableState.updateNextTick())),this._writableState!==null&&e===`drain`&&(this._duplexState|=C,this._writableState.updateNextTick())}var q=class extends n{constructor(e){super(),this._duplexState=0,this._readableState=null,this._writableState=null,e&&(e.open&&(this._open=e.open),e.destroy&&(this._destroy=e.destroy),e.predestroy&&(this._predestroy=e.predestroy),e.signal&&e.signal.addEventListener(`abort`,Se.bind(this))),this.on(`newListener`,K)}_open(e){e(null)}_destroy(e){e(null)}_predestroy(){}get readable(){return this._readableState!==null||void 0}get writable(){return this._writableState!==null||void 0}get destroyed(){return!!(this._duplexState&8)}get destroying(){return!!(this._duplexState&14)}destroy(e){this._duplexState&14||(e||=a.STREAM_DESTROYED(),this._duplexState=(this._duplexState|4)&535822271,this._readableState!==null&&(this._readableState.highWaterMark=0,this._readableState.error=e),this._writableState!==null&&(this._writableState.highWaterMark=0,this._writableState.error=e),this._duplexState|=2,this._predestroy(),this._duplexState&=536870909,this._readableState!==null&&this._readableState.updateNextTick(),this._writableState!==null&&this._writableState.updateNextTick())}},J=class e extends q{constructor(e){super(e),this._duplexState|=8519681,this._readableState=new ee(this,e),e&&(this._readableState.readAhead===!1&&(this._duplexState&=g),e.read&&(this._read=e.read),e.eagerOpen&&this._readableState.updateNextTick(),e.encoding&&this.setEncoding(e.encoding))}static deferred(e,t){let n=new ce(t);return e().then(e=>{if(e===null)return n.end();n.destroying||Z(e,n,$)}).catch(e=>n.destroy(e)),n}setEncoding(e){let t=new i(e),n=this._readableState.map||de;return this._readableState.map=r,this;function r(e){let r=t.push(e);return r===``&&(e.byteLength!==0||t.remaining>0)?null:n(r)}}_read(e){e(null)}pipe(e,t){return this._readableState.updateNextTick(),this._readableState.pipe(e,t),e}read(){return this._readableState.updateNextTick(),this._readableState.read()}push(e){return this._readableState.updateNextTickIfOpen(),this._readableState.push(e)}unshift(e){return this._readableState.updateNextTickIfOpen(),this._readableState.unshift(e)}resume(){return this._duplexState|=131328,this._readableState.updateNextTick(),this}pause(){return this._duplexState&=this._readableState.readAhead===!1?536739583:536870655,this}static _fromAsyncIterator(t,n){let r,i=new e({...n,read(e){t.next().then(a).then(e.bind(null,null)).catch(e)},predestroy(){r=t.return()},destroy(e){if(!r)return e(null);r.then(e.bind(null,null)).catch(e)}});return i;function a(e){e.done?i.push(null):i.push(e.value)}}static from(t,n){if(ve(t))return t;if(t[R])return this._fromAsyncIterator(t[R](),n);Array.isArray(t)||(t=t===void 0?[]:[t]);let r=0;return new e({...n,read(e){this.push(r===t.length?null:t[r++]),e(null)}})}static isBackpressured(e){return!!(e._duplexState&17422)||e._readableState.buffered>=e._readableState.highWaterMark}static isPaused(e){return!(e._duplexState&256)}[R](){let e=this,t=null,n=null,r=null;return this.on(`error`,e=>{t=e}),this.on(`readable`,i),this.on(`close`,o),{[R](){return this},next(){return new Promise(function(t,i){n=t,r=i;let a=e.read();a===null?e._duplexState&8&&s(null):s(a)})},return(){return c(null)},throw(e){return c(e)}};function i(){n!==null&&s(e.read())}function o(){n!==null&&s(null)}function s(i){r!==null&&(t?r(t):i===null&&!(e._duplexState&u)?r(a.STREAM_DESTROYED()):n({value:i,done:i===null}),r=n=null)}function c(t){return e.destroy(t),new Promise((n,r)=>{if(e._duplexState&8)return n({value:void 0,done:!0});e.once(`close`,function(){t?r(t):n({value:void 0,done:!0})})})}}},Y=class extends q{constructor(e){super(e),this._duplexState|=16385,this._writableState=new z(this,e),e&&(e.writev&&(this._writev=e.writev),e.write&&(this._write=e.write),e.final&&(this._final=e.final),e.eagerOpen&&this._writableState.updateNextTick())}cork(){this._duplexState|=O}uncork(){this._duplexState&=A,this._writableState.updateNextTick()}_writev(e,t){t(null)}_write(e,t){this._writableState.autoBatch(e,t)}_final(e){e(null)}static isBackpressured(e){return!!(e._duplexState&146800654)}static drained(e){if(e.destroyed)return Promise.resolve(!1);let t=e._writableState,n=(Ce(e)?Math.min(1,t.queue.length):t.queue.length)+(e._duplexState&67108864?1:0);return n===0?Promise.resolve(!0):(t.drains===null&&(t.drains=[]),new Promise(e=>{t.drains.push({writes:n,resolve:e})}))}write(e){return this._writableState.updateNextTick(),this._writableState.push(e)}end(e){return this._writableState.updateNextTick(),this._writableState.end(e),this}},X=class extends J{constructor(e){super(e),this._duplexState=1|this._duplexState&f,this._writableState=new z(this,e),e&&(e.writev&&(this._writev=e.writev),e.write&&(this._write=e.write),e.final&&(this._final=e.final))}cork(){this._duplexState|=O}uncork(){this._duplexState&=A,this._writableState.updateNextTick()}_writev(e,t){t(null)}_write(e,t){this._writableState.autoBatch(e,t)}_final(e){e(null)}write(e){return this._writableState.updateNextTick(),this._writableState.push(e)}end(e){return this._writableState.updateNextTick(),this._writableState.end(e),this}},se=class extends X{constructor(e){super(e),this._transformState=new B(this),e&&(e.transform&&(this._transform=e.transform),e.flush&&(this._flush=e.flush))}_write(e,t){this._readableState.buffered>=this._readableState.highWaterMark?this._transformState.data=e:this._transform(e,this._transformState.afterTransform)}_read(e){if(this._transformState.data!==null){let t=this._transformState.data;this._transformState.data=null,e(null),this._transform(t,this._transformState.afterTransform)}else e(null)}destroy(e){super.destroy(e),this._transformState.data!==null&&(this._transformState.data=null,this._transformState.afterTransform())}_transform(e,t){t(null,e)}_flush(e){e(null)}_final(e){this._transformState.afterFinal=e,this._flush(le.bind(this))}},ce=class extends se{};function le(e,t){let n=this._transformState.afterFinal;if(e)return n(e);t!=null&&this.push(t),this.push(null),n(null)}function ue(...e){return new Promise((t,n)=>Z(...e,e=>{if(e)return n(e);t()}))}function Z(e,...t){let n=Array.isArray(e)?[...e,...t]:[e,...t],r=n.length&&typeof n[n.length-1]==`function`?n.pop():null;if(n.length<2)throw a.BAD_ARGUMENT(`Pipeline requires at least 2 streams`);let i=n[0],o=null,s=null;for(let e=1;e<n.length;e++)o=n[e],Q(i)?i.pipe(o,l):(c(i,!0,e>1,l),i.pipe(o)),i=o;if(r){let e=!1,t=Q(o)||!!(o._writableState&&o._writableState.autoDestroy);o.on(`error`,e=>{s===null&&(s=e)}),o.on(`finish`,()=>{e=!0,t||r(s)}),t&&o.on(`close`,()=>r(s||(e?null:a.PREMATURE_CLOSE())))}return o;function c(e,t,n,r){e.on(`error`,r),e.on(`close`,i);function i(){if(t&&e._readableState&&!e._readableState.ended||n&&e._writableState&&!e._writableState.ended)return r(a.PREMATURE_CLOSE())}}function l(e){if(!(!e||s)){s=e;for(let t of n)t.destroy(e)}}}function de(e){return e}function fe(e){return!!e._readableState||!!e._writableState}function Q(e){return typeof e._duplexState==`number`&&fe(e)}function pe(e){return!!e._readableState&&e._readableState.ending}function me(e){return!!e._readableState&&e._readableState.ended}function he(e){return!!e._writableState&&e._writableState.ending}function ge(e){return!!e._writableState&&e._writableState.ended}function _e(e,t={}){let n=e._readableState&&e._readableState.error||e._writableState&&e._writableState.error;return!t.all&&a.isStreamDestroyed(n)?null:n}function ve(e){return Q(e)&&e.readable}function ye(e){return(e._duplexState&1)!=1||(e._duplexState&4)==4||!!(e._duplexState&P)}function be(e){return typeof e==`object`&&!!e&&typeof e.byteLength==`number`}function xe(e){return be(e)?e.byteLength:1024}function $(){}function Se(){this.destroy(a.ABORTED())}function Ce(e){return e._writev!==Y.prototype._writev&&e._writev!==X.prototype._writev}t.exports={pipeline:Z,pipelinePromise:ue,isStream:fe,isStreamx:Q,isEnding:pe,isEnded:me,isFinishing:he,isFinished:ge,isDisturbed:ye,getStreamError:_e,Stream:q,Writable:Y,Readable:J,Duplex:X,Transform:se,PassThrough:ce}})),k=r((e=>{let t=C(),n=t.from([117,115,116,97,114,0]),r=t.from([48,48]),i=t.from([117,115,116,97,114,32]),a=t.from([32,0]);e.decodeLongPath=function(e,t){return v(e,0,e.length,t)},e.encodePax=function(e){let n=``;e.name&&(n+=y(` path=`+e.name+`
2
2
  `)),e.linkname&&(n+=y(` linkpath=`+e.linkname+`
3
3
  `));let r=e.pax;if(r)for(let e in r)n+=y(` `+e+`=`+r[e]+`
4
4
  `);return t.from(n)},e.decodePax=function(e){let n={};for(;e.length;){let r=0;for(;r<e.length&&e[r]!==32;)r++;let i=parseInt(t.toString(e.subarray(0,r)),10);if(!i)return n;let a=t.toString(e.subarray(r+1,i-1)),o=a.indexOf(`=`);if(o===-1)return n;n[a.slice(0,o)]=a.slice(o+1),e=e.subarray(i)}return n},e.encode=function(e){let i=t.alloc(512),a=e.name,o=``;if(e.typeflag===5&&a[a.length-1]!==`/`&&(a+=`/`),t.byteLength(a)!==a.length)return null;for(;t.byteLength(a)>100;){let e=a.indexOf(`/`);if(e===-1)return null;o+=o?`/`+a.slice(0,e):a.slice(0,e),a=a.slice(e+1)}return t.byteLength(a)>100||t.byteLength(o)>155||e.linkname&&t.byteLength(e.linkname)>100?null:(t.write(i,a),t.write(i,p(e.mode&4095,6),100),t.write(i,p(e.uid,6),108),t.write(i,p(e.gid,6),116),h(e.size,i,124),t.write(i,p(e.mtime.getTime()/1e3|0,11),136),i[156]=48+u(e.type),e.linkname&&t.write(i,e.linkname,157),t.copy(n,i,257),t.copy(r,i,263),e.uname&&t.write(i,e.uname,265),e.gname&&t.write(i,e.gname,297),t.write(i,p(e.devmajor||0,6),329),t.write(i,p(e.devminor||0,6),337),o&&t.write(i,o,345),t.write(i,p(f(i),6),148),i)},e.decode=function(e,t,n){let r=e[156]===0?0:e[156]-48,i=v(e,0,100,t),a=_(e,100,8),c=_(e,108,8),u=_(e,116,8),d=_(e,124,12),p=_(e,136,12),m=l(r),h=e[157]===0?null:v(e,157,100,t),g=v(e,265,32),y=v(e,297,32),b=_(e,329,8),x=_(e,337,8),S=f(e);if(S===256)return null;if(S!==_(e,148,8))throw Error(`Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?`);if(o(e))e[345]&&(i=v(e,345,155,t)+`/`+i);else if(!s(e)&&!n)throw Error(`Invalid tar header: unknown format.`);return r===0&&i&&i[i.length-1]===`/`&&(r=5),{name:i,mode:a,uid:c,gid:u,size:d,byteOffset:0,mtime:new Date(1e3*p),type:m,linkname:h,uname:g,gname:y,devmajor:b,devminor:x,pax:null}};function o(e){return t.equals(n,e.subarray(257,263))}function s(e){return t.equals(i,e.subarray(257,263))&&t.equals(a,e.subarray(263,265))}function c(e,t,n){return typeof e==`number`?(e=~~e,e>=t?t:e>=0||(e+=t,e>=0)?e:0):n}function l(e){switch(e){case 0:return`file`;case 1:return`link`;case 2:return`symlink`;case 3:return`character-device`;case 4:return`block-device`;case 5:return`directory`;case 6:return`fifo`;case 7:return`contiguous-file`;case 72:return`pax-header`;case 55:return`pax-global-header`;case 27:return`gnu-long-link-path`;case 28:case 30:return`gnu-long-path`}return null}function u(e){switch(e){case`file`:return 0;case`link`:return 1;case`symlink`:return 2;case`character-device`:return 3;case`block-device`:return 4;case`directory`:return 5;case`fifo`:return 6;case`contiguous-file`:return 7;case`pax-header`:return 72}return 0}function d(e,t,n,r){for(;n<r;n++)if(e[n]===t)return n;return r}function f(e){let t=256;for(let n=0;n<148;n++)t+=e[n];for(let n=156;n<512;n++)t+=e[n];return t}function p(e,t){return e=e.toString(8),e.length>t?`7777777777777777777`.slice(0,t)+` `:`0000000000000000000`.slice(0,t-e.length)+e+` `}function m(e,t,n){t[n]=128;for(let r=11;r>0;r--)t[n+r]=e&255,e=Math.floor(e/256)}function h(e,n,r){e.toString(8).length>11?m(e,n,r):t.write(n,p(e,11),r)}function g(e){let t;if(e[0]===128)t=!0;else if(e[0]===255)t=!1;else return null;let n=[],r;for(r=e.length-1;r>0;r--){let i=e[r];t?n.push(i):n.push(255-i)}let i=0,a=n.length;for(r=0;r<a;r++)i+=n[r]*256**r;return t?i:-1*i}function _(e,n,r){if(e=e.subarray(n,n+r),n=0,e[n]&128)return g(e);{for(;n<e.length&&e[n]===32;)n++;let r=c(d(e,32,n,e.length),e.length,e.length);for(;n<r&&e[n]===0;)n++;return r===n?0:parseInt(t.toString(e.subarray(n,r)),8)}}function v(e,n,r,i){return t.toString(e.subarray(n,d(e,0,n,n+r)),i)}function y(e){let n=t.byteLength(e),r=Math.floor(Math.log(n)/Math.log(10))+1;return n+r>=10**r&&r++,n+r+e}})),A=r(((e,t)=>{let{Writable:n,Readable:r,getStreamError:i}=O(),a=S(),o=C(),s=k(),c=o.alloc(0);var l=class{constructor(){this.buffered=0,this.shifted=0,this.queue=new a,this._offset=0}push(e){this.buffered+=e.byteLength,this.queue.push(e)}shiftFirst(e){return this.buffered===0?null:this._next(e)}shift(e){if(e>this.buffered)return null;if(e===0)return c;let t=this._next(e);if(e===t.byteLength)return t;let n=[t];for(;(e-=t.byteLength)>0;)t=this._next(e),n.push(t);return o.concat(n)}_next(e){let t=this.queue.peek(),n=t.byteLength-this._offset;if(e>=n){let e=this._offset?t.subarray(this._offset,t.byteLength):t;return this.queue.shift(),this._offset=0,this.buffered-=n,this.shifted+=n,e}return this.buffered-=e,this.shifted+=e,t.subarray(this._offset,this._offset+=e)}},u=class extends r{constructor(e,t,n){super(),this.header=t,this.offset=n,this._parent=e}_read(e){this.header.size===0&&this.push(null),this._parent._stream===this&&this._parent._update(),e(null)}_predestroy(){this._parent.destroy(i(this))}_detach(){this._parent._stream===this&&(this._parent._stream=null,this._parent._missing=p(this.header.size),this._parent._update())}_destroy(e){this._detach(),e(null)}},d=class extends n{constructor(e){super(e),e||={},this._buffer=new l,this._offset=0,this._header=null,this._stream=null,this._missing=0,this._longHeader=!1,this._callback=f,this._locked=!1,this._finished=!1,this._pax=null,this._paxGlobal=null,this._gnuLongPath=null,this._gnuLongLinkPath=null,this._filenameEncoding=e.filenameEncoding||`utf-8`,this._allowUnknownFormat=!!e.allowUnknownFormat,this._unlockBound=this._unlock.bind(this)}_unlock(e){if(this._locked=!1,e){this.destroy(e),this._continueWrite(e);return}this._update()}_consumeHeader(){if(this._locked)return!1;this._offset=this._buffer.shifted;try{this._header=s.decode(this._buffer.shift(512),this._filenameEncoding,this._allowUnknownFormat)}catch(e){return this._continueWrite(e),!1}if(!this._header)return!0;switch(this._header.byteOffset=this._buffer.shifted,this._header.type){case`gnu-long-path`:case`gnu-long-link-path`:case`pax-global-header`:case`pax-header`:return this._longHeader=!0,this._missing=this._header.size,this._missing>4194304?(this._continueWrite(Error(`Header exceeds max size`)),!1):!0}return this._locked=!0,this._applyLongHeaders(),this._header.size>=0?this._header.size===0||this._header.type===`directory`?(this.emit(`entry`,this._header,this._createStream(),this._unlockBound),!0):(this._stream=this._createStream(),this._missing=this._header.size,this.emit(`entry`,this._header,this._stream,this._unlockBound),!0):(this._continueWrite(Error(`Invalid header`)),!1)}_applyLongHeaders(){this._gnuLongPath&&=(this._header.name=this._gnuLongPath,null),this._gnuLongLinkPath&&=(this._header.linkname=this._gnuLongLinkPath,null),this._pax&&=(this._pax.path&&(this._header.name=this._pax.path),this._pax.linkpath&&(this._header.linkname=this._pax.linkpath),this._pax.size&&(this._header.size=parseInt(this._pax.size,10)),this._header.pax=this._pax,null)}_decodeLongHeader(e){switch(this._header.type){case`gnu-long-path`:this._gnuLongPath=s.decodeLongPath(e,this._filenameEncoding);break;case`gnu-long-link-path`:this._gnuLongLinkPath=s.decodeLongPath(e,this._filenameEncoding);break;case`pax-global-header`:this._paxGlobal=s.decodePax(e);break;case`pax-header`:this._pax=this._paxGlobal===null?s.decodePax(e):Object.assign({},this._paxGlobal,s.decodePax(e))}}_consumeLongHeader(){this._longHeader=!1,this._missing=p(this._header.size);let e=this._buffer.shift(this._header.size);try{this._decodeLongHeader(e)}catch(e){return this._continueWrite(e),!1}return!0}_consumeStream(){let e=this._buffer.shiftFirst(this._missing);if(e===null)return!1;this._missing-=e.byteLength;let t=this._stream.push(e);return this._missing===0?(this._stream.push(null),t&&this._stream._detach(),t&&this._locked===!1):t}_createStream(){return new u(this,this._header,this._offset)}_update(){for(;this._buffer.buffered>0&&!this.destroying;){if(this._missing>0){if(this._stream!==null){if(this._consumeStream()===!1)return;continue}if(this._longHeader===!0){if(this._missing>this._buffer.buffered)break;if(this._consumeLongHeader()===!1)return!1;continue}let e=this._buffer.shiftFirst(this._missing);e!==null&&(this._missing-=e.byteLength);continue}if(this._buffer.buffered<512)break;if(this._stream!==null||this._consumeHeader()===!1)return}this._continueWrite(null)}_continueWrite(e){let t=this._callback;this._callback=f,t(e)}_write(e,t){this._callback=t,this._buffer.push(e),this._update()}_final(e){this._finished=this._missing===0&&this._buffer.buffered===0,e(this._finished?null:Error(`Unexpected end of data`))}_predestroy(){this._continueWrite(null)}_destroy(e){this._stream&&this._stream.destroy(i(this)),e(null)}[Symbol.asyncIterator](){let e=null,t=null,n=null,r=null,i=null,a=this;return this.on(`entry`,c),this.on(`error`,t=>{e=t}),this.on(`close`,l),{[Symbol.asyncIterator](){return this},next(){return new Promise(s)},return(){return u(null)},throw(e){return u(e)}};function o(e){if(!i)return;let t=i;i=null,t(e)}function s(i,s){if(e)return s(e);if(r){i({value:r,done:!1}),r=null;return}t=i,n=s,o(null),a._finished&&t&&(t({value:void 0,done:!0}),t=n=null)}function c(e,a,o){i=o,a.on(`error`,f),t?(t({value:a,done:!1}),t=n=null):r=a}function l(){o(e),t&&=(e?n(e):t({value:void 0,done:!0}),n=null)}function u(e){return a.destroy(e),o(e),new Promise((t,n)=>{if(a.destroyed)return t({value:void 0,done:!0});a.once(`close`,function(){e?n(e):t({value:void 0,done:!0})})})}}};t.exports=function(e){return new d(e)};function f(){}function p(e){return e&=511,e&&512-e}})),j=r(((e,n)=>{let r={S_IFMT:61440,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960};try{n.exports=t(`fs`).constants||r}catch{n.exports=r}})),M=r(((e,t)=>{let{Readable:n,Writable:r,getStreamError:i}=O(),a=C(),o=j(),s=k(),c=a.alloc(1024);var l=class extends r{constructor(e,t,n){super({mapWritable:m,eagerOpen:!0}),this.written=0,this.header=t,this._callback=n,this._linkname=null,this._isLinkname=t.type===`symlink`&&!t.linkname,this._isVoid=t.type!==`file`&&t.type!==`contiguous-file`,this._finished=!1,this._pack=e,this._openCallback=null,this._pack._stream===null?this._pack._stream=this:this._pack._pending.push(this)}_open(e){this._openCallback=e,this._pack._stream===this&&this._continueOpen()}_continuePack(e){if(this._callback===null)return;let t=this._callback;this._callback=null,t(e)}_continueOpen(){this._pack._stream===null&&(this._pack._stream=this);let e=this._openCallback;if(this._openCallback=null,e!==null){if(this._pack.destroying)return e(Error(`pack stream destroyed`));if(this._pack._finalized)return e(Error(`pack stream is already finalized`));this._pack._stream=this,this._isLinkname||this._pack._encode(this.header),this._isVoid&&(this._finish(),this._continuePack(null)),e(null)}}_write(e,t){if(this._isLinkname)return this._linkname=this._linkname?a.concat([this._linkname,e]):e,t(null);if(this._isVoid)return e.byteLength>0?t(Error(`No body allowed for this entry`)):t();if(this.written+=e.byteLength,this._pack.push(e))return t();this._pack._drain=t}_finish(){this._finished||(this._finished=!0,this._isLinkname&&(this.header.linkname=this._linkname?a.toString(this._linkname,`utf-8`):``,this._pack._encode(this.header)),p(this._pack,this.header.size),this._pack._done(this))}_final(e){if(this.written!==this.header.size)return e(Error(`Size mismatch`));this._finish(),e(null)}_getError(){return i(this)||Error(`tar entry destroyed`)}_predestroy(){this._pack.destroy(this._getError())}_destroy(e){this._pack._done(this),this._continuePack(this._finished?null:this._getError()),e()}},u=class extends n{constructor(e){super(e),this._drain=f,this._finalized=!1,this._finalizing=!1,this._pending=[],this._stream=null}entry(e,t,n){if(this._finalized||this.destroying)throw Error(`already finalized or destroyed`);typeof t==`function`&&(n=t,t=null),n||=f,(!e.size||e.type===`symlink`)&&(e.size=0),e.type||=d(e.mode),e.mode||=e.type===`directory`?493:420,e.uid||=0,e.gid||=0,e.mtime||=new Date,typeof t==`string`&&(t=a.from(t));let r=new l(this,e,n);return a.isBuffer(t)?(e.size=t.byteLength,r.write(t),r.end(),r):(r._isVoid,r)}finalize(){if(this._stream||this._pending.length>0){this._finalizing=!0;return}this._finalized||(this._finalized=!0,this.push(c),this.push(null))}_done(e){e===this._stream&&(this._stream=null,this._finalizing&&this.finalize(),this._pending.length&&this._pending.shift()._continueOpen())}_encode(e){if(!e.pax){let t=s.encode(e);if(t){this.push(t);return}}this._encodePax(e)}_encodePax(e){let t=s.encodePax({name:e.name,linkname:e.linkname,pax:e.pax}),n={name:`PaxHeader`,mode:e.mode,uid:e.uid,gid:e.gid,size:t.byteLength,mtime:e.mtime,type:`pax-header`,linkname:e.linkname&&`PaxHeader`,uname:e.uname,gname:e.gname,devmajor:e.devmajor,devminor:e.devminor};this.push(s.encode(n)),this.push(t),p(this,t.byteLength),n.size=e.size,n.type=e.type,this.push(s.encode(n))}_doDrain(){let e=this._drain;this._drain=f,e()}_predestroy(){let e=i(this);for(this._stream&&this._stream.destroy(e);this._pending.length;){let t=this._pending.shift();t.destroy(e),t._continueOpen()}this._doDrain()}_read(e){this._doDrain(),e()}};t.exports=function(e){return new u(e)};function d(e){switch(e&o.S_IFMT){case o.S_IFBLK:return`block-device`;case o.S_IFCHR:return`character-device`;case o.S_IFDIR:return`directory`;case o.S_IFIFO:return`fifo`;case o.S_IFLNK:return`symlink`}return`file`}function f(){}function p(e,t){t&=511,t&&e.push(c.subarray(0,512-t))}function m(e){return a.isBuffer(e)?e:a.from(e)}})),N=e(r((e=>{e.extract=A(),e.pack=M()}))(),1);async function P(e){e.signal?.throwIfAborted();let t=e.budget??new f,n=e.depth??1,r=await F(e,t,n);await e.validateManifest?.(r);let i=m(t,n,r),a=N.extract(),o=I(e.archivePath,e.gzip,a,e.signal);try{for await(let t of a){e.signal?.throwIfAborted();let n=z(t.header);if(!n){await B(t);continue}let a=r.shift();if(!a||!h(a,n))throw v(`ARCHIVE_MANIFEST_MISMATCH`,`Archive contents changed after inspection`);await ee(t,a,e.outputRoot,i),i.commitEntry()}await o}catch(e){throw a.destroy(),await o.catch(()=>{}),e}if(r.length!==0)throw v(`ARCHIVE_MANIFEST_MISMATCH`,`Archive contents changed after inspection`);i.finish()}async function F(e,t,n){let r=[],i=0,a=N.extract(),o=I(e.archivePath,e.gzip,a,e.signal);try{for await(let o of a){e.signal?.throwIfAborted();let a=z(o.header);if(!a){await B(o);continue}i+=a.size,t.preflightArchive({depth:n,entryCount:r.length+1,declaredBytes:i}),r.push(a),await B(o)}await o}catch(e){throw a.destroy(),await o.catch(()=>{}),e}return r}function I(e,t,n,r){return t?l(o(e),u(),n,{signal:r}):l(o(e),n,{signal:r})}function L(e){if(e===`directory`)return`directory`;if(e===`file`||e===`contiguous-file`||e==null)return`file`;throw e===`link`||e===`symlink`?v(`ARCHIVE_UNSAFE_ENTRY`,`Uploaded app bundle archive cannot contain symlinks or hard links`):v(`ARCHIVE_UNSAFE_ENTRY`,`Archive contains a link or special entry`)}function R(e,t){return(e??(t===`directory`?493:420))&511}function z(e){if(te(e.name,e.type))return;let t=g(e.name),n=L(e.type),r=n===`directory`?0:e.size??0;if(!Number.isSafeInteger(r)||r<0)throw v(`ARCHIVE_INVALID_ENTRY`,`Archive entry has an invalid size`);return{name:t,kind:n,size:r,mode:R(e.mode,n)}}async function ee(e,t,n,r){let i=_(n,t.name);if(t.kind===`directory`){await c.mkdir(i,{recursive:!0,mode:t.mode}),await B(e);return}await c.mkdir(a.dirname(i),{recursive:!0}),await l(e,async function*(e){for await(let t of e)r.chargeBytes(Buffer.byteLength(t)),yield t},s(i,{flags:`wx`,mode:t.mode}))}async function B(e){for await(let t of e);}function te(e,t){return t===`directory`&&(e===`.`||e===`./`||e===``)}var V=r(((e,t)=>{t.exports=n;function n(){this.pending=0,this.max=1/0,this.listeners=[],this.waiting=[],this.error=null}n.prototype.go=function(e){this.pending<this.max?i(this,e):this.waiting.push(e)},n.prototype.wait=function(e){this.pending===0?e(this.error):this.listeners.push(e)},n.prototype.hold=function(){return r(this)};function r(e){e.pending+=1;var t=!1;return n;function n(n){if(t)throw Error(`callback called twice`);if(t=!0,e.error=e.error||n,--e.pending,e.waiting.length>0&&e.pending<e.max)i(e,e.waiting.shift());else if(e.pending===0){var a=e.listeners;e.listeners=[],a.forEach(r)}}function r(t){t(e.error)}}function i(e,t){t(r(e))}})),ne=r((e=>{var n=t(`fs`),r=t(`util`),i=t(`stream`),a=i.Readable,o=i.PassThrough,s=V(),c=t(`events`).EventEmitter;e.BufferSlicer=d,e.FdSlicer=l,r.inherits(l,c);function l(e){c.call(this),this.fd=e,this.pend=new s,this.pend.max=1,this.refCount=0}l.prototype.read=function(e,t,r,i,a){var o=this;o.pend.go(function(s){n.read(o.fd,e,t,r,i,function(e,t,n){s(),a(e,t,n)})})},l.prototype.createReadStream=function(e){return new u(this,e)},l.prototype.ref=function(){this.refCount+=1},l.prototype.unref=function(){var e=this;if(--e.refCount,e.refCount<0)throw Error(`invalid unref`);if(e.refCount>0)return;n.close(e.fd,t);function t(t){t?e.emit(`error`,t):e.emit(`close`)}},r.inherits(u,a);function u(e,t){t||={},a.call(this,t),this.context=e,this.context.ref(),this.start=t.start||0,this.endOffset=t.end,this.pos=this.start}u.prototype._read=function(e){var t=this,r=Math.min(t._readableState.highWaterMark,e);if(t.endOffset!=null&&(r=Math.min(r,t.endOffset-t.pos)),r<=0){t.push(null),this._cleanup();return}t.context.pend.go(function(e){var i=Buffer.allocUnsafe(r);n.read(t.context.fd,i,0,r,t.pos,function(n,r){n?t.destroy(n):r===0?(t.push(null),t._cleanup()):(t.pos+=r,t.push(i.slice(0,r))),e()})})},u.prototype._destroy=function(e,t){this._cleanup(),t(e)},u.prototype._cleanup=function(){this.context!=null&&(this.context.unref(),this.context=null)},r.inherits(d,c);function d(e){c.call(this),this.refCount=0,this.buffer=e}d.prototype.read=function(e,t,n,r,i){if(!(0<=t&&t<=e.length))throw RangeError(`offset outside buffer: 0 <= `+t+` <= `+e.length);if(r<0)throw RangeError(`position is negative: `+r);if(t+n>e.length&&(n=e.length-t),r+n>this.buffer.length&&(n=this.buffer.length-r),n<=0){setImmediate(function(){i(null,0)});return}this.buffer.copy(e,t,r,r+n),setImmediate(function(){i(null,n)})},d.prototype.createReadStream=function(e){e||={};var t=new o(e);t.start=e.start||0,t.endOffset=e.end,t.pos=t.endOffset||this.buffer.length;for(var n=this.buffer.slice(t.start,t.pos),r=65536,i=0;;){var a=i+r;if(a>=n.length){i<n.length&&t.write(n.slice(i,n.length));break}t.write(n.slice(i,a)),i=a}return t.end(),t},d.prototype.ref=function(){this.refCount+=1},d.prototype.unref=function(){if(--this.refCount,this.refCount<0)throw Error(`invalid unref`)}})),H=r(((e,t)=>{let n=new Int32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);function r(e){let t=-1;for(let r of e)t=n[(t^r)&255]^t>>>8;return(t^-1)>>>0}t.exports=r})),re=e(r((e=>{var n=t(`fs`),r=t(`zlib`),i=ne(),a=t(`util`),o=t(`events`).EventEmitter,s=t(`stream`).Transform,c=t(`stream`).PassThrough,l=t(`stream`).Writable;let u=typeof r.crc32==`function`?r.crc32:H();e.open=d;function d(e,t,r){typeof t==`function`&&(r=t,t=null),t??={},t.autoClose??(t.autoClose=!0),t.lazyEntries??(t.lazyEntries=!1),t.decodeStrings??(t.decodeStrings=!0),t.validateEntrySizes??(t.validateEntrySizes=!0),t.strictFileNames??(t.strictFileNames=!1),r??=M,n.open(e,`r`,function(e,i){if(e)return r(e);f(i,t,function(e,t){e&&n.close(i,M),r(e,t)})})}function f(e,t,r){typeof t==`function`&&(r=t,t=null),t??={},t.autoClose??(t.autoClose=!1),t.lazyEntries??(t.lazyEntries=!1),t.decodeStrings??(t.decodeStrings=!0),t.validateEntrySizes??(t.validateEntrySizes=!0),t.strictFileNames??(t.strictFileNames=!1),r??=M,n.fstat(e,function(n,a){if(n)return r(n);p(new i.FdSlicer(e),a.size,t,r)})}function p(e,t,n,r){typeof n==`function`&&(r=n,n=null),n??={},n.autoClose??(n.autoClose=!0),n.lazyEntries??(n.lazyEntries=!1),n.decodeStrings??(n.decodeStrings=!0);var i=!!n.decodeStrings;if(n.validateEntrySizes??(n.validateEntrySizes=!0),n.strictFileNames??(n.strictFileNames=!1),r??=M,typeof t!=`number`)throw Error(`expected totalSize parameter to be a number`);if(t>2**53-1)throw Error(`zip file too large. only file sizes up to 2^52 are supported due to JavaScript's Number type being an IEEE 754 double.`);e.ref();var a=22,o=20,s=Math.min(o+a+65535,t),c=A(s);C(e,c,0,s,t-c.length,function(l){if(l)return r(l);for(var u=s-a;u>=0;--u)if(c.readUInt32LE(u)===101010256){var d=c.subarray(u),f=d.readUInt16LE(4),p=d.readUInt16LE(10),h=d.readUInt32LE(16),g=d.readUInt16LE(20),_=d.length-a;if(g!==_)return r(Error(`Invalid comment length. Expected: `+_+`. Found: `+g+". Are there extra bytes at the end of the file? Or is the end of central dir signature `PK☺☻` in the comment?"));var v=i?O(d.subarray(22),!1):d.subarray(22);if(u-o>=0&&c.readUInt32LE(u-o)===117853008){var y=k(c.subarray(u-o,u-o+o),8),b=A(56);return C(e,b,0,b.length,y,function(a){return a?r(a):b.readUInt32LE(0)===101075792?(f=b.readUInt32LE(16),f===0?(p=k(b,32),h=k(b,48),r(null,new m(e,h,t,p,v,n.autoClose,n.lazyEntries,i,n.validateEntrySizes,n.strictFileNames))):r(Error(`multi-disk zip files are not supported: found disk number: `+f))):r(Error(`invalid zip64 end of central directory record signature`))})}return f===0?r(null,new m(e,h,t,p,v,n.autoClose,n.lazyEntries,i,n.validateEntrySizes,n.strictFileNames)):r(Error(`multi-disk zip files are not supported: found disk number: `+f))}r(Error(`End of central directory record signature not found. Either not a zip file, or file is truncated.`))})}a.inherits(m,o);function m(e,t,n,r,i,a,s,c,l,u){var d=this;o.call(d),d.reader=e,d.reader.on(`error`,function(e){g(d,e)}),d.reader.once(`close`,function(){d.emit(`close`)}),d.readEntryCursor=t,d.fileSize=n,d.entryCount=r,d.comment=i,d.entriesRead=0,d.autoClose=!!a,d.lazyEntries=!!s,d.decodeStrings=!!c,d.validateEntrySizes=!!l,d.strictFileNames=!!u,d.isOpen=!0,d.emittedError=!1,d.hasEachEntryBeenCalled=!1,d.lazyEntries||d._readEntry()}m.prototype.close=function(){this.isOpen&&(this.isOpen=!1,this.reader.unref())};function h(e,t){e.autoClose&&e.close(),g(e,t)}function g(e,t){e.emittedError||(e.emittedError=!0,e.emit(`error`,t))}m.prototype.readEntry=function(){if(!this.lazyEntries)throw Error(`readEntry() called without lazyEntries:true`);this._readEntry()},m.prototype._readEntry=function(){var e=this;if(e.entryCount===e.entriesRead){setImmediate(function(){e.autoClose&&e.close(),!e.emittedError&&e.emit(`end`)});return}if(!e.emittedError){var t=A(46);C(e.reader,t,0,t.length,e.readEntryCursor,function(n){if(n)return h(e,n);if(!e.emittedError){var r=new _,i=t.readUInt32LE(0);if(i!==33639248)return h(e,Error(`invalid central directory file header signature: 0x`+i.toString(16)));if(r.versionMadeBy=t.readUInt16LE(4),r.versionNeededToExtract=t.readUInt16LE(6),r.generalPurposeBitFlag=t.readUInt16LE(8),r.compressionMethod=t.readUInt16LE(10),r.lastModFileTime=t.readUInt16LE(12),r.lastModFileDate=t.readUInt16LE(14),r.crc32=t.readUInt32LE(16),r.compressedSize=t.readUInt32LE(20),r.uncompressedSize=t.readUInt32LE(24),r.fileNameLength=t.readUInt16LE(28),r.extraFieldLength=t.readUInt16LE(30),r.fileCommentLength=t.readUInt16LE(32),r.internalFileAttributes=t.readUInt16LE(36),r.externalFileAttributes=t.readUInt32LE(38),r.relativeOffsetOfLocalHeader=t.readUInt32LE(42),r.generalPurposeBitFlag&64)return h(e,Error(`strong encryption is not supported`));e.readEntryCursor+=46,t=A(r.fileNameLength+r.extraFieldLength+r.fileCommentLength),C(e.reader,t,0,t.length,e.readEntryCursor,function(n){if(n)return h(e,n);if(!e.emittedError){r.fileNameRaw=t.subarray(0,r.fileNameLength);var i=r.fileNameLength+r.extraFieldLength;r.extraFieldRaw=t.subarray(r.fileNameLength,i),r.fileCommentRaw=t.subarray(i,i+r.fileCommentLength);try{r.extraFields=S(r.extraFieldRaw)}catch(t){return h(e,t)}if(e.decodeStrings){var a=!!(r.generalPurposeBitFlag&2048);r.fileComment=O(r.fileCommentRaw,a),r.fileName=b(r.generalPurposeBitFlag,r.fileNameRaw,r.extraFields,e.strictFileNames);var o=x(r.fileName);if(o!=null)return h(e,Error(o))}else r.fileComment=r.fileCommentRaw,r.fileName=r.fileNameRaw;r.comment=r.fileComment,e.readEntryCursor+=t.length,e.entriesRead+=1;for(var s=0;s<r.extraFields.length;s++){var c=r.extraFields[s];if(c.id===1){var l=c.data,u=0;if(r.uncompressedSize===4294967295){if(u+8>l.length)return h(e,Error(`zip64 extended information extra field does not include uncompressed size`));r.uncompressedSize=k(l,u),u+=8}if(r.compressedSize===4294967295){if(u+8>l.length)return h(e,Error(`zip64 extended information extra field does not include compressed size`));r.compressedSize=k(l,u),u+=8}if(r.relativeOffsetOfLocalHeader===4294967295){if(u+8>l.length)return h(e,Error(`zip64 extended information extra field does not include relative header offset`));r.relativeOffsetOfLocalHeader=k(l,u),u+=8}break}}if(e.validateEntrySizes&&r.compressionMethod===0){var d=r.uncompressedSize;if(r.isEncrypted()&&(d+=12),r.compressedSize!==d){var f=`compressed/uncompressed size mismatch for stored file: `+r.compressedSize+` != `+r.uncompressedSize;return h(e,Error(f))}}e.emit(`entry`,r),e.lazyEntries||e._readEntry()}})}})}},m.prototype.eachEntry=function(){let e=this;if(!e.lazyEntries)throw Error(`eachEntry() requires lazyEntries: true`);if(e.hasEachEntryBeenCalled)throw Error(`eachEntry() must only be called once per ZipFile`);e.hasEachEntryBeenCalled=!0;let t=null;e.on(`entry`,r),e.on(`end`,i),e.on(`error`,a);function n(){e.removeListener(`entry`,r),e.removeListener(`end`,i),e.removeListener(`error`,a),e.autoClose&&e.close()}function r(e){let{resolve:n}=t;t=null,n({value:e})}function i(){let{resolve:e}=t;t=null,n(),e({done:!0})}function a(e){let{reject:r}=t;t=null,n(),r(e)}return{[Symbol.asyncIterator](){return this},next(){let n=new Promise((e,n)=>{if(t!=null)throw Error(`next() called before previous Promise was resolved.`);t={resolve:e,reject:n}});return e.readEntry(),n},return(e){return n(),Promise.resolve({done:!0,value:e})},throw(e){return n(),Promise.reject(e)}}},m.prototype.openReadStream=function(e,t,n){var r=this,i=0,a=e.compressedSize;if(n??(n=t,t=null),t==null)t={};else{if(t.decodeFileData===!1){if(t.decrypt!=null)throw Error(`cannot use options.decrypt when options.decodeFileData === false`);if(t.decompress!=null)throw Error(`cannot use options.decompress when options.decodeFileData === false`)}else{if(t.decrypt!=null){if(!e.isEncrypted())throw Error(`options.decrypt can only be specified for encrypted entries. See also option decodeFileData.`);if(t.decrypt!==!1)throw Error(`invalid options.decrypt value: `+t.decrypt);if(e.isCompressed()&&t.decompress!==!1)throw Error(`entry is encrypted and compressed, and options.decompress !== false. See also option decodeFileData.`)}if(t.decompress!=null){if(!e.isCompressed())throw Error(`options.decompress can only be specified for compressed entries. See also option decodeFileData.`);if(t.decompress!==!1&&t.decompress!==!0)throw Error(`invalid options.decompress value: `+t.decompress);s=t.decompress}}if(t.start!=null){if(i=t.start,i<0)throw Error(`options.start < 0`);if(i>e.compressedSize)throw Error(`options.start > entry.compressedSize`)}if(t.end!=null){if(a=t.end,a<0)throw Error(`options.end < 0`);if(a>e.compressedSize)throw Error(`options.end > entry.compressedSize`);if(a<i)throw Error(`options.end < options.start`)}}var o=t.decodeFileData===!1||(e.compressionMethod===0||e.compressionMethod===8&&t.decompress===!1)&&(!e.isEncrypted()||t.decrypt===!1);if((t.start!=null||t.end!=null)&&!o)throw Error(`start/end range require options.decodeFileData === false for non-trivial encoded entries.`);if(!r.isOpen)return n(Error(`closed`));if(e.isEncrypted()&&!o&&t.decrypt!==!1)return n(Error(`entry is encrypted, and options.decodeFileData !== false`));var s;if(o)s=!1;else if(e.compressionMethod===8)s=t.decodeFileData!==!0;else return n(Error(`unsupported compression method: `+e.compressionMethod));r.readLocalFileHeader(e,{minimal:!0},function(t,o){if(t)return n(t);r.openReadStreamLowLevel(o.fileDataStart,e.compressedSize,i,a,s,e.uncompressedSize,n)})},m.prototype.openReadStreamLowLevel=function(e,t,n,i,a,o,s){var c=this;e+t;var l=c.reader.createReadStream({start:e+n,end:e+i}),u=l;if(a){var d=!1,f=r.createInflateRaw();l.on(`error`,function(e){setImmediate(function(){d||f.emit(`error`,e)})}),l.pipe(f),c.validateEntrySizes?(u=new w(o),f.on(`error`,function(e){setImmediate(function(){d||u.emit(`error`,e)})}),f.pipe(u)):u=f,j(u,function(){d=!0,f!==u&&f.unpipe(u),l.unpipe(f),l.destroy()})}s(null,u)},m.prototype.readLocalFileHeader=function(e,t,n){var r=this;n??(n=t,t=null),t??={},r.reader.ref();var i=A(30);C(r.reader,i,0,i.length,e.relativeOffsetOfLocalHeader,function(a){try{if(a)return n(a);var o=i.readUInt32LE(0);if(o!==67324752)return n(Error(`invalid local file header signature: 0x`+o.toString(16)));var s=i.readUInt16LE(26),c=i.readUInt16LE(28),l=e.relativeOffsetOfLocalHeader+30+s+c;if(l+e.compressedSize>r.fileSize)return n(Error(`file data overflows file bounds: `+l+` + `+e.compressedSize+` > `+r.fileSize));if(t.minimal)return n(null,{fileDataStart:l});var u=new v;u.fileDataStart=l,u.versionNeededToExtract=i.readUInt16LE(4),u.generalPurposeBitFlag=i.readUInt16LE(6),u.compressionMethod=i.readUInt16LE(8),u.lastModFileTime=i.readUInt16LE(10),u.lastModFileDate=i.readUInt16LE(12),u.crc32=i.readUInt32LE(14),u.compressedSize=i.readUInt32LE(18),u.uncompressedSize=i.readUInt32LE(22),u.fileNameLength=s,u.extraFieldLength=c,i=A(s+c),r.reader.ref(),C(r.reader,i,0,i.length,e.relativeOffsetOfLocalHeader+30,function(e){try{return e?n(e):(u.fileName=i.subarray(0,s),u.extraField=i.subarray(s),n(null,u))}finally{r.reader.unref()}})}finally{r.reader.unref()}})},m.prototype.openReadStreamPromise=function(e,t){return new Promise((n,r)=>{this.openReadStream(e,t,function(e,t){if(e)return r(e);n(t)})})},m.prototype.openReadStreamLowLevelPromise=function(e,t,n,r,i,a){return new Promise((o,s)=>{this.openReadStream(e,t,n,r,i,a,function(e,t){if(e)return s(e);o(t)})})},m.prototype.readLocalFileHeaderPromise=function(e,t){return new Promise((n,r)=>{this.readLocalFileHeader(e,t,function(e,t){if(e)return r(e);n(t)})})};function _(){}_.prototype.getLastModDate=function(e){if(e??={},!e.forceDosFormat)for(var t=0;t<this.extraFields.length;t++){var n=this.extraFields[t];if(n.id===21589){var r=n.data;if(r.length<5||!(r[0]&1))continue;var i=r.readInt32LE(1);return new Date(i*1e3)}if(n.id===10){var r=n.data;if(r.length!==32||r.readUInt16LE(4)!==1||r.readUInt16LE(6)!==24)continue;var a=(r.readUInt32LE(8)+4294967296*r.readInt32LE(12))/1e4-0xa9730b66800;return new Date(a)}}return y(this.lastModFileDate,this.lastModFileTime,e.timezone)},_.prototype.canDecodeFileData=function(){return!this.isEncrypted()&&(this.compressionMethod===0||this.compressionMethod===8)},_.prototype.isEncrypted=function(){return!!(this.generalPurposeBitFlag&1)},_.prototype.isCompressed=function(){return this.compressionMethod===8};function v(){}function y(e,t,n){var r=e&31,i=(e>>5&15)-1,a=(e>>9&127)+1980,o=0,s=(t&31)*2,c=t>>5&63,l=t>>11&31;if(n==null||n===`local`)return new Date(a,i,r,l,c,s,o);if(n===`UTC`)return new Date(Date.UTC(a,i,r,l,c,s,o));throw Error(`unrecognized options.timezone: `+options.timezone)}function b(e,t,n,r){for(var i=null,a=0;a<n.length;a++){var o=n[a];if(o.id===28789){if(o.data.length<6||o.data.readUInt8(0)!==1)continue;var s=o.data.readUInt32LE(1);if(u(t)!==s)continue;i=O(o.data.subarray(5),!0);break}}return i??=O(t,!!(e&2048)),r||(i=i.replace(/\\/g,`/`)),i}function x(e){return e.indexOf(`\\`)===-1?/^[a-zA-Z]:/.test(e)||/^\//.test(e)?`absolute path: `+e:e.split(`/`).indexOf(`..`)===-1?null:`invalid relative path: `+e:`invalid characters in fileName: `+e}function S(e){for(var t=[],n=0;n<e.length-3;){var r=e.readUInt16LE(n+0),i=e.readUInt16LE(n+2),a=n+4,o=a+i;if(o>e.length)throw Error(`extra field length exceeds extra field buffer size`);var s=e.subarray(a,o);t.push({id:r,data:s}),n=o}return t}function C(e,t,n,r,i,a){if(r===0)return setImmediate(function(){a(null,A(0))});e.read(t,n,r,i,function(e,t){if(e)return a(e);if(t<r)return a(Error(`unexpected EOF`));a()})}a.inherits(w,s);function w(e){s.call(this),this.actualByteCount=0,this.expectedByteCount=e}w.prototype._transform=function(e,t,n){if(this.actualByteCount+=e.length,this.actualByteCount>this.expectedByteCount){var r=`too many bytes in the stream. expected `+this.expectedByteCount+`. got at least `+this.actualByteCount;return n(Error(r))}n(null,e)},w.prototype._flush=function(e){if(this.actualByteCount<this.expectedByteCount){var t=`not enough bytes in the stream. expected `+this.expectedByteCount+`. got only `+this.actualByteCount;return e(Error(t))}e()},a.inherits(T,o);function T(){o.call(this),this.refCount=0}T.prototype.ref=function(){this.refCount+=1},T.prototype.unref=function(){var e=this;if(--e.refCount,e.refCount>0)return;if(e.refCount<0)throw Error(`invalid unref`);e.close(t);function t(t){if(t)return e.emit(`error`,t);e.emit(`close`)}},T.prototype.createReadStream=function(e){e??={};var t=e.start,n=e.end;if(t===n){var r=new c;return setImmediate(function(){r.end()}),r}var i=this._readStreamForRange(t,n),a=!1,o=new E(this);i.on(`error`,function(e){setImmediate(function(){a||o.emit(`error`,e)})}),j(o,function(){i.unpipe(o),o.unref(),i.destroy()});var s=new w(n-t);return o.on(`error`,function(e){setImmediate(function(){a||s.emit(`error`,e)})}),j(s,function(){a=!0,o.unpipe(s),o.destroy()}),i.pipe(o).pipe(s)},T.prototype._readStreamForRange=function(e,t){throw Error(`not implemented`)},T.prototype.read=function(e,t,n,r,i){var a=this.createReadStream({start:r,end:r+n}),o=new l,s=0;o._write=function(n,r,i){n.copy(e,t+s,0,n.length),s+=n.length,i()},o.on(`finish`,i),a.on(`error`,function(e){i(e)}),a.pipe(o)},T.prototype.close=function(e){setImmediate(e)},a.inherits(E,c);function E(e){c.call(this),this.context=e,this.context.ref(),this.unreffedYet=!1}E.prototype._flush=function(e){this.unref(),e()},E.prototype.unref=function(e){this.unreffedYet||(this.unreffedYet=!0,this.context.unref())};var D=`\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■\xA0`;function O(e,t){if(t)return e.toString(`utf8`);for(var n=``,r=0;r<e.length;r++)n+=D[e[r]];return n}function k(e,t){var n=e.readUInt32LE(t);return e.readUInt32LE(t+4)*4294967296+n}var A=typeof Buffer.allocUnsafe==`function`?function(e){return Buffer.allocUnsafe(e)}:function(e){return new Buffer(e)};function j(e,t){typeof e.destroy==`function`?e._destroy=function(e,n){t(),n?.(e)}:e.destroy=t}function M(e){if(e)throw e}}))(),1);async function ie(e){e.signal?.throwIfAborted();let t=e.budget??new f,n=e.depth??1,r=[],i=0;await U(e.archivePath,e.signal,e=>{t.preflightArchive({depth:n,entryCount:r.length+1,declaredBytes:i});let a=G(e);i+=a.size,t.preflightArchive({depth:n,entryCount:r.length+1,declaredBytes:i}),r.push(a)}),await e.validateManifest?.(r);let o=m(t,n,r),u=await U(e.archivePath,e.signal,(e,t)=>{t>=r.length&&q()});u.length!==r.length&&q();let d=await W(e.archivePath);try{for(let t=0;t<u.length;t+=1){e.signal?.throwIfAborted();let n=u[t],i=r[t];(!n||!i||!h(G(n),i))&&q();let f=_(e.outputRoot,i.name);if(i.kind===`directory`)await c.mkdir(f,{recursive:!0,mode:i.mode});else{await c.mkdir(a.dirname(f),{recursive:!0});let t=await ae(d,n);await l(t,async function*(e){for await(let t of e)o.chargeBytes(Buffer.byteLength(t)),yield t},s(f,{flags:`wx`,mode:i.mode}),{signal:e.signal})}o.commitEntry()}o.finish()}finally{d.close()}}async function U(e,t,n){let r=await W(e);return await new Promise((e,i)=>{let a=[],o=()=>{r.off(`entry`,s),r.off(`end`,c),r.off(`error`,l),t?.removeEventListener(`abort`,u)},s=e=>{try{n?.(e,a.length),a.push(e),r.readEntry()}catch(e){o(),i(e)}},c=()=>{o(),e(a)},l=e=>{o(),i(e)},u=()=>{o(),r.close(),i(t?.reason??new DOMException(`The operation was aborted`,`AbortError`))};if(r.on(`entry`,s),r.once(`end`,c),r.once(`error`,l),t?.addEventListener(`abort`,u,{once:!0}),t?.aborted)return u();r.readEntry()}).finally(()=>r.close())}function W(e){return new Promise((t,n)=>{re.open(e,{lazyEntries:!0,autoClose:!1,validateEntrySizes:!0,strictFileNames:!0},(e,r)=>e?n(e):t(r))})}function ae(e,t){return new Promise((n,r)=>{e.openReadStream(t,(e,t)=>e?r(e):n(t))})}function G(e){oe(e);let t=g(e.fileName),n=e.externalFileAttributes>>>16&65535,r=K(e.fileName,n),i=r?493:420;return{name:t,kind:r?`directory`:`file`,size:r?0:e.uncompressedSize,mode:n&511||i}}function oe(e){if(e.isEncrypted())throw v(`ARCHIVE_UNSAFE_ENTRY`,`Encrypted archive entries are not supported`);let t=e.externalFileAttributes>>>16&61440;if(t!==0&&t!==16384&&t!==32768)throw v(`ARCHIVE_UNSAFE_ENTRY`,`Archive contains a link or special entry`)}function K(e,t){return e.endsWith(`/`)||(t&61440)==16384}function q(){throw v(`ARCHIVE_MANIFEST_MISMATCH`,`Archive contents changed after inspection`)}async function J(e){e.signal?.throwIfAborted();let t=a.resolve(e.archivePath),n=a.resolve(e.outputRoot);if(t===n||t.startsWith(`${n}${a.sep}`))throw RangeError(`archivePath must be outside outputRoot`);await c.mkdir(n,{recursive:!1});try{e.type===`zip`?await ie({...e,archivePath:t,outputRoot:n}):await P({...e,archivePath:t,outputRoot:n,gzip:e.type===`tgz`})}catch(e){throw await c.rm(n,{recursive:!0,force:!0}),e}}function Y(e){let t=e.toLowerCase();if(t.endsWith(`.tar.gz`)||t.endsWith(`.tgz`))return`tgz`;if(t.endsWith(`.tar`))return`tar`;if(t.endsWith(`.zip`)||t.endsWith(`.ipa`))return`zip`}var X=n({MAX_ARTIFACT_COMPRESSED_BYTES:()=>d,extractArchiveSafely:()=>J});export{d as a,f as i,Y as n,J as r,X as t};
@@ -1 +1 @@
1
- import{y as e}from"./sdk-contracts.js";import{d as t,n,p as r}from"./transport.js";import i from"node:path";import a from"node:fs";import{pipeline as o}from"node:stream/promises";function s(e){let{destinationPath:t}=e;return e.isDirectory?{prepare:async()=>{await a.promises.mkdir(t,{recursive:!0})},cleanupOnError:async()=>{},materialize:(e,n)=>l(e,t,n)}:{prepare:async()=>{await a.promises.mkdir(i.dirname(t),{recursive:!0})},cleanupOnError:()=>a.promises.rm(t,{force:!0}),materialize:async(e,n)=>(await o(e,a.createWriteStream(t),{signal:n}),t)}}async function c(i){let a=await n(i.artifactUrl.protocol),o=s(i);return await o.prepare(),await new Promise((n,s)=>{let c=!1,l=!1,u,d=new AbortController,f=i.timeoutMs??9e4,p=(e,t)=>{if(!c){if(c=!0,clearTimeout(h),t){o.cleanupOnError().finally(()=>s(t));return}n(e??i.destinationPath)}},m=a.request({protocol:i.artifactUrl.protocol,host:i.artifactUrl.hostname,port:i.artifactUrl.port,method:`GET`,path:i.artifactUrl.pathname+i.artifactUrl.search,headers:{...t(i.token),...r(i.requestScope?.tenantId)}},t=>{if((t.statusCode??500)>=400){let n=``;t.setEncoding(`utf8`),t.on(`data`,e=>{n+=e}),t.on(`end`,()=>{p(void 0,new e(`COMMAND_FAILED`,`Failed to download remote artifact`,{artifactId:i.artifactId,statusCode:t.statusCode,requestId:i.requestScope?.requestId,body:n}))});return}l=!0,o.materialize(t,d.signal).then(e=>p(e),e=>p(void 0,u??(e instanceof Error?e:Error(String(e)))))}),h=setTimeout(()=>{u=new e(`COMMAND_FAILED`,`Remote artifact download timed out`,{artifactId:i.artifactId,requestId:i.requestScope?.requestId,timeoutMs:f}),d.abort(u),m.destroy(u),l||p(void 0,u)},f);m.on(`error`,t=>{if(!l){if(t instanceof e){p(void 0,u??t);return}p(void 0,new e(`COMMAND_FAILED`,`Failed to download remote artifact`,{artifactId:i.artifactId,requestId:i.requestScope?.requestId,timeoutMs:f},t instanceof Error?t:void 0))}}),m.end()})}async function l(t,n,r){let s=await a.promises.mkdtemp(i.join(n,`.agent-device-download-`)),c=i.join(s,`artifact.tar.gz`),l=i.join(s,`extracted`);try{await o(t,a.createWriteStream(c),{signal:r});let{extractArchiveSafely:s}=await import(`./archive.js`).then(e=>e.t);await s({archivePath:c,outputRoot:l,type:`tgz`,signal:r}),r.throwIfAborted();let[u,...d]=await a.promises.readdir(l);if(!u||d.length>0)throw new e(`COMMAND_FAILED`,`Downloaded directory artifact has an unexpected shape: expected exactly one top-level entry, found ${d.length+ +!!u}`);r.throwIfAborted();let f=i.join(n,u);return await a.promises.rename(i.join(l,u),f),f}finally{await a.promises.rm(s,{recursive:!0,force:!0})}}export{c as downloadRemoteArtifactFromUrl};
1
+ import{C as e}from"./sdk-contracts.js";import{d as t,n,p as r}from"./transport.js";import i from"node:path";import a from"node:fs";import{pipeline as o}from"node:stream/promises";function s(e){let{destinationPath:t}=e;return e.isDirectory?{prepare:async()=>{await a.promises.mkdir(t,{recursive:!0})},cleanupOnError:async()=>{},materialize:(e,n)=>l(e,t,n)}:{prepare:async()=>{await a.promises.mkdir(i.dirname(t),{recursive:!0})},cleanupOnError:()=>a.promises.rm(t,{force:!0}),materialize:async(e,n)=>(await o(e,a.createWriteStream(t),{signal:n}),t)}}async function c(i){let a=await n(i.artifactUrl.protocol),o=s(i);return await o.prepare(),await new Promise((n,s)=>{let c=!1,l=!1,u,d=new AbortController,f=i.timeoutMs??9e4,p=(e,t)=>{if(!c){if(c=!0,clearTimeout(h),t){o.cleanupOnError().finally(()=>s(t));return}n(e??i.destinationPath)}},m=a.request({protocol:i.artifactUrl.protocol,host:i.artifactUrl.hostname,port:i.artifactUrl.port,method:`GET`,path:i.artifactUrl.pathname+i.artifactUrl.search,headers:{...t(i.token),...r(i.requestScope?.tenantId)}},t=>{if((t.statusCode??500)>=400){let n=``;t.setEncoding(`utf8`),t.on(`data`,e=>{n+=e}),t.on(`end`,()=>{p(void 0,new e(`COMMAND_FAILED`,`Failed to download remote artifact`,{artifactId:i.artifactId,statusCode:t.statusCode,requestId:i.requestScope?.requestId,body:n}))});return}l=!0,o.materialize(t,d.signal).then(e=>p(e),e=>p(void 0,u??(e instanceof Error?e:Error(String(e)))))}),h=setTimeout(()=>{u=new e(`COMMAND_FAILED`,`Remote artifact download timed out`,{artifactId:i.artifactId,requestId:i.requestScope?.requestId,timeoutMs:f}),d.abort(u),m.destroy(u),l||p(void 0,u)},f);m.on(`error`,t=>{if(!l){if(t instanceof e){p(void 0,u??t);return}p(void 0,new e(`COMMAND_FAILED`,`Failed to download remote artifact`,{artifactId:i.artifactId,requestId:i.requestScope?.requestId,timeoutMs:f},t instanceof Error?t:void 0))}}),m.end()})}async function l(t,n,r){let s=await a.promises.mkdtemp(i.join(n,`.agent-device-download-`)),c=i.join(s,`artifact.tar.gz`),l=i.join(s,`extracted`);try{await o(t,a.createWriteStream(c),{signal:r});let{extractArchiveSafely:s}=await import(`./archive.js`).then(e=>e.t);await s({archivePath:c,outputRoot:l,type:`tgz`,signal:r}),r.throwIfAborted();let[u,...d]=await a.promises.readdir(l);if(!u||d.length>0)throw new e(`COMMAND_FAILED`,`Downloaded directory artifact has an unexpected shape: expected exactly one top-level entry, found ${d.length+ +!!u}`);r.throwIfAborted();let f=i.join(n,u);return await a.promises.rename(i.join(l,u),f),f}finally{await a.promises.rm(s,{recursive:!0,force:!0})}}export{c as downloadRemoteArtifactFromUrl};
@@ -1 +1 @@
1
- import{y as e}from"./sdk-contracts.js";import{s as t}from"./exec.js";import"./command.js";import n from"node:path";import r from"node:fs";async function i(t,n){let r=await t.text(),i={};if(r.trim().length>0)try{i=JSON.parse(r)}catch(r){throw new e(`COMMAND_FAILED`,n.invalidJsonMessage,{status:t.status},r instanceof Error?r:void 0)}if(!t.ok)throw new e(`UNAUTHORIZED`,n.rejectedMessage,{status:t.status,response:i});return i}const a=1e3;async function o(e){return await s({command:e.command,flags:e.flags,stateDir:e.stateDir,allowInteractiveLogin:e.command===`connect`&&!e.flags.noLogin,env:e.env})}async function s(t){let n=t.env??t.io?.env??process.env;if(!t.flags.daemonBaseUrl)return{flags:t.flags,source:`none`};if(A(t.flags.daemonAuthToken))return{flags:t.flags,source:`flag`};if(A(n.AGENT_DEVICE_DAEMON_AUTH_TOKEN))return{flags:t.flags,source:`env`};if(!T(t.flags.daemonBaseUrl,n))return{flags:t.flags,source:`none`};let r=await h({stateDir:t.stateDir,flags:t.flags,env:n,io:t.io});if(r)return{flags:{...t.flags,daemonAuthToken:r.accessToken},source:`cli-session`};if(!t.allowInteractiveLogin)throw t.flags.noLogin?new e(`UNAUTHORIZED`,`Remote daemon authentication is required.`,{hint:`Run agent-device auth login, unset --no-login, or set AGENT_DEVICE_DAEMON_AUTH_TOKEN.`}):C(t.command,n);let i=await l({stateDir:t.stateDir,flags:t.flags,env:n,io:t.io});return{flags:{...t.flags,daemonAuthToken:i.accessToken},source:`login`}}async function c(t){let n=t.env??t.io?.env??process.env;if(A(t.flags.daemonAuthToken))return{accessToken:t.flags.daemonAuthToken,cloudBaseUrl:w(n)};if(A(n.AGENT_DEVICE_DAEMON_AUTH_TOKEN))return{accessToken:n.AGENT_DEVICE_DAEMON_AUTH_TOKEN,cloudBaseUrl:w(n)};let r=await h({stateDir:t.stateDir,flags:t.flags,env:n,io:t.io});if(r)return{accessToken:r.accessToken,cloudBaseUrl:r.cloudBaseUrl};if(t.flags.noLogin)throw new e(`UNAUTHORIZED`,`Cloud connection profile authentication is required.`,{hint:`Run agent-device auth login, unset --no-login, or set AGENT_DEVICE_DAEMON_AUTH_TOKEN.`});let i=await l({stateDir:t.stateDir,flags:t.flags,env:n,io:t.io,commandLabel:`agent-device connect`});return{accessToken:i.accessToken,cloudBaseUrl:i.session.cloudBaseUrl}}async function l(t){let n=t.env??t.io?.env??process.env,r=b(n,t.io);if(r===`non-interactive`)throw C(t.commandLabel??`agent-device connect`,n);let i=w(n),a=await v({baseUrl:i,pathName:`/api/control-plane/device-auth/start`,body:{client:`agent-device`,tenant:t.flags.tenant,runId:t.flags.runId,daemonBaseUrl:t.flags.daemonBaseUrl,session:t.flags.session},fetchImpl:t.io?.fetch});y(a);let o=a.verificationUriComplete??a.verificationUri,s=r===`local-browser`?a.verificationUri:E(a.verificationUri,a.userCode);r===`local-browser`?(O(t.io,`Opening ${a.verificationUri}...\n`),await D(o,t.io)):O(t.io,`Open this URL on your machine:\n${s}\n\nWaiting for approval for 10 minutes...\n`);let c=await _({cloudBaseUrl:i,deviceCode:a.deviceCode,expiresIn:a.expiresIn,interval:a.interval,fetchImpl:t.io?.fetch,now:t.io?.now}),l=c.cliSession?.refreshCredential??c.cliSession?.refreshToken;if(!A(c.accessToken)||!A(l))throw new e(`UNAUTHORIZED`,`Device authorization did not return CLI credentials.`);let u=new Date(t.io?.now?.()??Date.now()).toISOString(),f={version:1,id:c.cliSession?.id??`cli-${Date.now().toString(36)}`,cloudBaseUrl:i,workspaceId:c.cliSession?.workspaceId,accountId:c.cliSession?.accountId,name:c.cliSession?.name,refreshCredential:l,createdAt:u,expiresAt:c.cliSession?.expiresAt};return d({stateDir:t.stateDir,session:f}),{accessToken:c.accessToken,expiresAt:c.expiresAt,session:f}}function u(e){let t=p(e.stateDir);if(!r.existsSync(t))return null;try{let e=JSON.parse(r.readFileSync(t,`utf8`));return e.version!==1||!A(e.id)||!A(e.cloudBaseUrl)||!A(e.refreshCredential)||!A(e.createdAt)?null:e}catch{return null}}function d(e){let t=p(e.stateDir);r.mkdirSync(n.dirname(t),{recursive:!0,mode:448}),r.writeFileSync(t,`${JSON.stringify(e.session,null,2)}\n`,{mode:384});try{r.chmodSync(t,384)}catch{}}function f(e){let t=p(e.stateDir);return r.existsSync(t)?(r.rmSync(t,{force:!0}),!0):!1}function p(e){return n.join(e,`auth`,`cli-session.json`)}function m(e){let t=u({stateDir:e.stateDir});return t?{authenticated:!0,source:`cli-session`,sessionId:t.id,cloudBaseUrl:t.cloudBaseUrl,workspaceId:t.workspaceId,accountId:t.accountId,name:t.name,createdAt:t.createdAt,expiresAt:t.expiresAt,expired:k(t.expiresAt,e.now)}:{authenticated:!1,source:`none`}}async function h(e){let t=u({stateDir:e.stateDir});return!t||k(t.expiresAt,e.io?.now)?null:{accessToken:(await g({session:t,flags:e.flags,env:e.env,io:e.io})).accessToken,cloudBaseUrl:w(e.env,t.cloudBaseUrl)}}async function g(t){let n=await v({baseUrl:w(t.env,t.session.cloudBaseUrl),pathName:`/api/control-plane/cli-session/refresh`,body:{refreshCredential:t.session.refreshCredential,tenant:t.flags.tenant,runId:t.flags.runId,daemonBaseUrl:t.flags.daemonBaseUrl,session:t.flags.session},fetchImpl:t.io?.fetch});if(A(n.accessToken))return{accessToken:n.accessToken,expiresAt:n.expiresAt};throw n.status===`revoked`||n.error===`revoked`?new e(`UNAUTHORIZED`,`Stored cloud CLI session was revoked.`,{hint:`Run agent-device auth login again, or set AGENT_DEVICE_DAEMON_AUTH_TOKEN.`,status:n.status,error:n.error}):new e(`UNAUTHORIZED`,`Failed to refresh CLI session.`,{hint:`Run agent-device auth login again, or set AGENT_DEVICE_DAEMON_AUTH_TOKEN.`,status:n.status,error:n.error})}async function _(t){let n=t.now??Date.now,r=Math.min((t.expiresIn??600)*1e3,6e5),i=n()+r,o=Math.max(a,(t.interval??5)*1e3);for(;n()<i;){let n=await v({baseUrl:t.cloudBaseUrl,pathName:`/api/control-plane/device-auth/poll`,body:{deviceCode:t.deviceCode},fetchImpl:t.fetchImpl});if(n.status===`approved`||A(n.accessToken))return n;if(n.status===`slow_down`||n.error===`slow_down`)o+=a;else if(n.status!==`authorization_pending`&&n.error!==`authorization_pending`)throw new e(`UNAUTHORIZED`,`Device authorization was not approved.`,{status:n.status,error:n.error});await j(o)}throw new e(`TIMEOUT`,`Device authorization expired before approval.`)}async function v(e){let t=await(e.fetchImpl??fetch)(new URL(e.pathName,e.baseUrl),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e.body),signal:AbortSignal.timeout(15e3)});return await i(t,{invalidJsonMessage:`Cloud auth endpoint returned invalid JSON (${t.status}).`,rejectedMessage:`Cloud auth endpoint rejected the request.`})}function y(t){if(!A(t.deviceCode)||!A(t.userCode)||!A(t.verificationUri))throw new e(`COMMAND_FAILED`,`Cloud auth start returned an unusable response.`)}function b(e,t){let n=t?.stdinIsTTY??process.stdin.isTTY,r=t?.stdoutIsTTY??process.stdout.isTTY;return x(e)||!n||!r?`non-interactive`:S(e)?`device-code`:`local-browser`}function x(e){return e.CI===`true`||e.GITHUB_ACTIONS===`true`||e.BUILDKITE===`true`}function S(e){return!!(e.SSH_TTY||e.SSH_CONNECTION||e.CODESPACES===`true`||e.GITPOD_WORKSPACE_ID||e.REMOTE_CONTAINERS===`true`)}function C(t,n){let r=w(n);return new e(`UNAUTHORIZED`,`${t} cannot perform interactive login in CI or a non-interactive shell.`,{hint:`Create a service/API token: ${new URL(`/api-keys`,r).toString()} Then set AGENT_DEVICE_DAEMON_AUTH_TOKEN=adc_live_...`})}function w(t,n){let r=t.AGENT_DEVICE_CLOUD_BASE_URL??n??`https://cloud.agent-device.dev`;try{return new URL(r).toString().replace(/\/+$/,``)}catch(t){throw new e(`INVALID_ARGS`,`Invalid AGENT_DEVICE_CLOUD_BASE_URL.`,{cloudBaseUrl:r},t instanceof Error?t:void 0)}}function T(e,t){if(t.AGENT_DEVICE_CLOUD_AUTH===`1`||t.AGENT_DEVICE_CLOUD_AUTH===`true`||A(t.AGENT_DEVICE_CLOUD_BASE_URL))return!0;try{let t=new URL(e).hostname.toLowerCase();return t===`agent-device.dev`||t.endsWith(`.agent-device.dev`)}catch{return!1}}function E(e,t){let n=new URL(e);return n.searchParams.set(`user_code`,t),n.toString()}async function D(e,n){if(n?.openBrowser){await n.openBrowser(e);return}let r=process.platform;try{r===`darwin`?await t(`open`,[e],{allowFailure:!0,timeoutMs:5e3}):r===`win32`?await t(`cmd`,[`/c`,`start`,``,e],{allowFailure:!0,timeoutMs:5e3}):await t(`xdg-open`,[e],{allowFailure:!0,timeoutMs:5e3})}catch{O(n,`Open this URL on your machine:\n${e}\n`)}}function O(e,t){(e?.stderr??process.stderr).write(t)}function k(e,t){if(!e)return!1;let n=Date.parse(e);return!Number.isFinite(n)||n<=(t?.()??Date.now())}function A(e){return typeof e==`string`&&e.trim().length>0}async function j(e){await new Promise(t=>setTimeout(t,e))}export{m as a,o as i,f as n,i as o,c as r,l as t};
1
+ import{C as e}from"./sdk-contracts.js";import t from"node:path";import n from"node:fs";async function r(t,n){let r=await t.text(),i={};if(r.trim().length>0)try{i=JSON.parse(r)}catch(r){throw new e(`COMMAND_FAILED`,n.invalidJsonMessage,{status:t.status},r instanceof Error?r:void 0)}if(!t.ok)throw new e(`UNAUTHORIZED`,n.rejectedMessage,{status:t.status,response:i});return i}const i=1e3;async function a(e){return await o({command:e.command,flags:e.flags,stateDir:e.stateDir,allowInteractiveLogin:e.command===`connect`&&!e.flags.noLogin,env:e.env})}async function o(t){let n=t.env??t.io?.env??process.env;if(!t.flags.daemonBaseUrl)return{flags:t.flags,source:`none`};if(A(t.flags.daemonAuthToken))return{flags:t.flags,source:`flag`};if(A(n.AGENT_DEVICE_DAEMON_AUTH_TOKEN))return{flags:t.flags,source:`env`};if(!T(t.flags.daemonBaseUrl,n))return{flags:t.flags,source:`none`};let r=await m({stateDir:t.stateDir,flags:t.flags,env:n,io:t.io});if(r)return{flags:{...t.flags,daemonAuthToken:r.accessToken},source:`cli-session`};if(!t.allowInteractiveLogin)throw t.flags.noLogin?new e(`UNAUTHORIZED`,`Remote daemon authentication is required.`,{hint:`Run agent-device auth login, unset --no-login, or set AGENT_DEVICE_DAEMON_AUTH_TOKEN.`}):C(t.command,n);let i=await c({stateDir:t.stateDir,flags:t.flags,env:n,io:t.io});return{flags:{...t.flags,daemonAuthToken:i.accessToken},source:`login`}}async function s(t){let n=t.env??t.io?.env??process.env;if(A(t.flags.daemonAuthToken))return{accessToken:t.flags.daemonAuthToken,cloudBaseUrl:w(n)};if(A(n.AGENT_DEVICE_DAEMON_AUTH_TOKEN))return{accessToken:n.AGENT_DEVICE_DAEMON_AUTH_TOKEN,cloudBaseUrl:w(n)};let r=await m({stateDir:t.stateDir,flags:t.flags,env:n,io:t.io});if(r)return{accessToken:r.accessToken,cloudBaseUrl:r.cloudBaseUrl};if(t.flags.noLogin)throw new e(`UNAUTHORIZED`,`Cloud connection profile authentication is required.`,{hint:`Run agent-device auth login, unset --no-login, or set AGENT_DEVICE_DAEMON_AUTH_TOKEN.`});let i=await c({stateDir:t.stateDir,flags:t.flags,env:n,io:t.io,commandLabel:`agent-device connect`});return{accessToken:i.accessToken,cloudBaseUrl:i.session.cloudBaseUrl}}async function c(t){let n=t.env??t.io?.env??process.env,r=b(n,t.io);if(r===`non-interactive`)throw C(t.commandLabel??`agent-device connect`,n);let i=w(n),a=await _({baseUrl:i,pathName:`/api/control-plane/device-auth/start`,body:{client:`agent-device`,tenant:t.flags.tenant,runId:t.flags.runId,daemonBaseUrl:t.flags.daemonBaseUrl,session:t.flags.session},fetchImpl:t.io?.fetch});await v(a);let o=A(a.verificationUriComplete)?a.verificationUriComplete:a.verificationUri;if(r===`local-browser`)O(t.io,`Opening ${a.verificationUri}...\n`),await D(o,t.io);else{let e=E(a.verificationUri,a.userCode);O(t.io,`Open this URL on your machine:\n${e}\n\nWaiting for approval for 10 minutes...\n`)}let s=await g({cloudBaseUrl:i,deviceCode:a.deviceCode,expiresIn:a.expiresIn,interval:a.interval,fetchImpl:t.io?.fetch,now:t.io?.now}),c=s.cliSession?.refreshCredential??s.cliSession?.refreshToken;if(!A(s.accessToken)||!A(c))throw new e(`UNAUTHORIZED`,`Device authorization did not return CLI credentials.`);let l=new Date(t.io?.now?.()??Date.now()).toISOString(),d={version:1,id:s.cliSession?.id??`cli-${Date.now().toString(36)}`,cloudBaseUrl:i,workspaceId:s.cliSession?.workspaceId,accountId:s.cliSession?.accountId,name:s.cliSession?.name,refreshCredential:c,createdAt:l,expiresAt:s.cliSession?.expiresAt};return u({stateDir:t.stateDir,session:d}),{accessToken:s.accessToken,expiresAt:s.expiresAt,session:d}}function l(e){let t=f(e.stateDir);if(!n.existsSync(t))return null;try{let e=JSON.parse(n.readFileSync(t,`utf8`));return e.version!==1||!A(e.id)||!A(e.cloudBaseUrl)||!A(e.refreshCredential)||!A(e.createdAt)?null:e}catch{return null}}function u(e){let r=f(e.stateDir);n.mkdirSync(t.dirname(r),{recursive:!0,mode:448}),n.writeFileSync(r,`${JSON.stringify(e.session,null,2)}\n`,{mode:384});try{n.chmodSync(r,384)}catch{}}function d(e){let t=f(e.stateDir);return n.existsSync(t)?(n.rmSync(t,{force:!0}),!0):!1}function f(e){return t.join(e,`auth`,`cli-session.json`)}function p(e){let t=l({stateDir:e.stateDir});return t?{authenticated:!0,source:`cli-session`,sessionId:t.id,cloudBaseUrl:t.cloudBaseUrl,workspaceId:t.workspaceId,accountId:t.accountId,name:t.name,createdAt:t.createdAt,expiresAt:t.expiresAt,expired:k(t.expiresAt,e.now)}:{authenticated:!1,source:`none`}}async function m(e){let t=l({stateDir:e.stateDir});return!t||k(t.expiresAt,e.io?.now)?null:{accessToken:(await h({session:t,flags:e.flags,env:e.env,io:e.io})).accessToken,cloudBaseUrl:w(e.env,t.cloudBaseUrl)}}async function h(t){let n=await _({baseUrl:w(t.env,t.session.cloudBaseUrl),pathName:`/api/control-plane/cli-session/refresh`,body:{refreshCredential:t.session.refreshCredential,tenant:t.flags.tenant,runId:t.flags.runId,daemonBaseUrl:t.flags.daemonBaseUrl,session:t.flags.session},fetchImpl:t.io?.fetch});if(A(n.accessToken))return{accessToken:n.accessToken,expiresAt:n.expiresAt};throw n.status===`revoked`||n.error===`revoked`?new e(`UNAUTHORIZED`,`Stored cloud CLI session was revoked.`,{hint:`Run agent-device auth login again, or set AGENT_DEVICE_DAEMON_AUTH_TOKEN.`,status:n.status,error:n.error}):new e(`UNAUTHORIZED`,`Failed to refresh CLI session.`,{hint:`Run agent-device auth login again, or set AGENT_DEVICE_DAEMON_AUTH_TOKEN.`,status:n.status,error:n.error})}async function g(t){let n=t.now??Date.now,r=Math.min((t.expiresIn??600)*1e3,6e5),a=n()+r,o=Math.max(i,(t.interval??5)*1e3);for(;n()<a;){let n=await _({baseUrl:t.cloudBaseUrl,pathName:`/api/control-plane/device-auth/poll`,body:{deviceCode:t.deviceCode},fetchImpl:t.fetchImpl});if(n.status===`approved`||A(n.accessToken))return n;if(n.status===`slow_down`||n.error===`slow_down`)o+=i;else if(n.status!==`authorization_pending`&&n.error!==`authorization_pending`)throw new e(`UNAUTHORIZED`,`Device authorization was not approved.`,{status:n.status,error:n.error});await j(o)}throw new e(`TIMEOUT`,`Device authorization expired before approval.`)}async function _(e){let t=await(e.fetchImpl??fetch)(new URL(e.pathName,e.baseUrl),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e.body),signal:AbortSignal.timeout(15e3)});return await r(t,{invalidJsonMessage:`Cloud auth endpoint returned invalid JSON (${t.status}).`,rejectedMessage:`Cloud auth endpoint rejected the request.`})}async function v(e){if(!A(e.deviceCode))throw y(`deviceCode`);if(!A(e.userCode))throw y(`userCode`);if(!A(e.verificationUri))throw y(`verificationUri`);let{isSafeBrowserUrl:t}=await import(`./browser-launch.js`);if(!t(e.verificationUri))throw y(`verificationUri`);if(A(e.verificationUriComplete)&&!t(e.verificationUriComplete))throw y(`verificationUriComplete`)}function y(t){return new e(`COMMAND_FAILED`,`Cloud auth start returned an unusable response.`,{field:t})}function b(e,t){let n=t?.stdinIsTTY??process.stdin.isTTY,r=t?.stdoutIsTTY??process.stdout.isTTY;return x(e)||!n||!r?`non-interactive`:S(e)?`device-code`:`local-browser`}function x(e){return e.CI===`true`||e.GITHUB_ACTIONS===`true`||e.BUILDKITE===`true`}function S(e){return!!(e.SSH_TTY||e.SSH_CONNECTION||e.CODESPACES===`true`||e.GITPOD_WORKSPACE_ID||e.REMOTE_CONTAINERS===`true`)}function C(t,n){let r=w(n);return new e(`UNAUTHORIZED`,`${t} cannot perform interactive login in CI or a non-interactive shell.`,{hint:`Create a service/API token: ${new URL(`/api-keys`,r).toString()} Then set AGENT_DEVICE_DAEMON_AUTH_TOKEN=adc_live_...`})}function w(t,n){let r=t.AGENT_DEVICE_CLOUD_BASE_URL??n??`https://cloud.agent-device.dev`;try{return new URL(r).toString().replace(/\/+$/,``)}catch(t){throw new e(`INVALID_ARGS`,`Invalid AGENT_DEVICE_CLOUD_BASE_URL.`,{cloudBaseUrl:r},t instanceof Error?t:void 0)}}function T(e,t){if(t.AGENT_DEVICE_CLOUD_AUTH===`1`||t.AGENT_DEVICE_CLOUD_AUTH===`true`||A(t.AGENT_DEVICE_CLOUD_BASE_URL))return!0;try{let t=new URL(e).hostname.toLowerCase();return t===`agent-device.dev`||t.endsWith(`.agent-device.dev`)}catch{return!1}}function E(e,t){let n=new URL(e);return n.searchParams.set(`user_code`,t),n.toString()}async function D(e,t){if(t?.openBrowser){await t.openBrowser(e);return}let{openUrlInBrowser:n}=await import(`./browser-launch.js`);await n(e)||O(t,`Open this URL on your machine:\n${e}\n`)}function O(e,t){(e?.stderr??process.stderr).write(t)}function k(e,t){if(!e)return!1;let n=Date.parse(e);return!Number.isFinite(n)||n<=(t?.()??Date.now())}function A(e){return typeof e==`string`&&e.trim().length>0}async function j(e){await new Promise(t=>setTimeout(t,e))}export{p as a,a as i,d as n,r as o,s as r,c as t};
package/dist/src/auth.js CHANGED
@@ -1,2 +1,2 @@
1
- import{y as e}from"./sdk-contracts.js";import{n as t}from"./config.js";import{a as n,n as r,t as i}from"./auth-session.js";import{t as a}from"./shared.js";const o=async({positionals:o,flags:c})=>{let l=o[0]??`status`,u=t(c.stateDir).baseDir;if(l===`status`){let e=n({stateDir:u});return await a(c,e,()=>s(e)),!0}if(l===`login`){let e=await i({stateDir:u,flags:c,commandLabel:`agent-device auth login`}),t={authenticated:!0,source:`cli-session`,sessionId:e.session.id,cloudBaseUrl:e.session.cloudBaseUrl,workspaceId:e.session.workspaceId,accountId:e.session.accountId,expiresAt:e.session.expiresAt,agentTokenExpiresAt:e.expiresAt};return await a(c,t,()=>`Authenticated with cloud CLI session.`),!0}if(l===`logout`){let e=r({stateDir:u});return await a(c,{authenticated:!1,removed:e},()=>e?`Removed stored cloud CLI session.`:`No stored cloud CLI session.`),!0}throw new e(`INVALID_ARGS`,`auth accepts only: status, login, logout`)};function s(e){return e.authenticated?[`Authenticated with cloud CLI session.`,`cloud=${e.cloudBaseUrl}`,`session=${e.sessionId}`,e.workspaceId?`workspace=${e.workspaceId}`:null,e.accountId?`account=${e.accountId}`:null,e.expiresAt?`expiresAt=${e.expiresAt}`:null,e.expired?`status=expired`:null].filter(e=>!!e).join(`
1
+ import{C as e}from"./sdk-contracts.js";import{n as t}from"./config.js";import{a as n,n as r,t as i}from"./auth-session.js";import{t as a}from"./shared.js";const o=async({positionals:o,flags:c})=>{let l=o[0]??`status`,u=t(c.stateDir).baseDir;if(l===`status`){let e=n({stateDir:u});return await a(c,e,()=>s(e)),!0}if(l===`login`){let e=await i({stateDir:u,flags:c,commandLabel:`agent-device auth login`}),t={authenticated:!0,source:`cli-session`,sessionId:e.session.id,cloudBaseUrl:e.session.cloudBaseUrl,workspaceId:e.session.workspaceId,accountId:e.session.accountId,expiresAt:e.session.expiresAt,agentTokenExpiresAt:e.expiresAt};return await a(c,t,()=>`Authenticated with cloud CLI session.`),!0}if(l===`logout`){let e=r({stateDir:u});return await a(c,{authenticated:!1,removed:e},()=>e?`Removed stored cloud CLI session.`:`No stored cloud CLI session.`),!0}throw new e(`INVALID_ARGS`,`auth accepts only: status, login, logout`)};function s(e){return e.authenticated?[`Authenticated with cloud CLI session.`,`cloud=${e.cloudBaseUrl}`,`session=${e.sessionId}`,e.workspaceId?`workspace=${e.workspaceId}`:null,e.accountId?`account=${e.accountId}`:null,e.expiresAt?`expiresAt=${e.expiresAt}`:null,e.expired?`status=expired`:null].filter(e=>!!e).join(`
2
2
  `):`Not authenticated.`}export{o as authCommand};
@@ -1 +1 @@
1
- const e=[`app`,`device`,`system`];function t(e){return e===`device`||e===`system`}const n=[`in-app`,`system`];export{e as n,t as r,n as t};
1
+ import{n as e}from"./sdk-contracts.js";import{a as t}from"./capture.js";import{r as n}from"./sdk-device.js";import{c as r}from"./sdk-remote-config.js";import{t as i}from"./session.js";import{c as a}from"./observability.js";const o=[`app`,`device`,`system`];function s(e){return o.some(t=>t===e)}function c(e){return e===`device`||e===`system`}const l=[{key:`count`,names:[`--count`],type:`int`,min:1,max:200,usageLabel:`--count <n>`,usageDescription:`Repeat count for press/swipe series`,projectConfig:!0,recorded:!0},{key:`pointerCount`,names:[`--pointer-count`],type:`int`,min:1,max:2,usageLabel:`--pointer-count <1|2>`,usageDescription:`Gesture pan: number of touch pointers (default 1)`,projectConfig:!0,recorded:!0},{key:`fps`,names:[`--fps`],type:`int`,min:1,max:120,usageLabel:`--fps <n>`,usageDescription:`Record: target frames per second (iOS physical device runner)`,projectConfig:!0,recorded:!0},{key:`quality`,names:[`--quality`],type:`string`,usageLabel:`--quality <medium|high>`,usageDescription:`Record: output quality preset; Android maps this to screenrecord bitrate, Apple targets use it for export/encoding. Legacy numeric values 5-7 map to medium; 8-10 map to high`,projectConfig:!0,recorded:!0},{key:`hideTouches`,names:[`--hide-touches`],type:`boolean`,usageLabel:`--hide-touches`,usageDescription:`Record: skip touch-overlay post-processing for faster raw benchmark videos`,projectConfig:!0,recorded:!0},{key:`recordingScope`,names:[`--scope`],type:`enum`,enumValues:o,usageLabel:`--scope <app|device|system>`,usageDescription:`Record: app requires an active app session; device/system records the whole screen`,projectConfig:!0,recorded:!1},{key:`intervalMs`,names:[`--interval-ms`],type:`int`,min:0,max:1e4,usageLabel:`--interval-ms <ms>`,usageDescription:`Delay between press iterations`,projectConfig:!0,recorded:!0},{key:`delayMs`,names:[`--delay-ms`],type:`int`,min:0,max:1e4,usageLabel:`--delay-ms <ms>`,usageDescription:`Delay between typed characters`,projectConfig:!0,recorded:!0},{key:`recordAs`,names:[`--record-as`],type:`string`,usageLabel:`--record-as <VAR>`,usageDescription:"Fill: send the live text but publish ${VAR} in an armed .ad recording",projectConfig:!0,recorded:!1},{key:`durationMs`,names:[`--duration-ms`],type:`int`,min:0,max:1e4,usageLabel:`--duration-ms <ms>`,usageDescription:`Scroll: pace the gesture over this duration when supported`,projectConfig:!0,recorded:!1},{key:`holdMs`,names:[`--hold-ms`],type:`int`,min:0,max:1e4,usageLabel:`--hold-ms <ms>`,usageDescription:`Press hold duration for each iteration`,projectConfig:!0,recorded:!0},{key:`jitterPx`,names:[`--jitter-px`],type:`int`,min:0,max:100,usageLabel:`--jitter-px <n>`,usageDescription:`Deterministic coordinate jitter radius for press`,projectConfig:!0,recorded:!0},{key:`pixels`,names:[`--pixels`],type:`int`,min:1,max:1e5,usageLabel:`--pixels <n>`,usageDescription:`Scroll: explicit gesture distance in pixels`,projectConfig:!0,recorded:!1},{key:`until`,names:[`--until`],type:`string`,usageLabel:`--until <selector>`,usageDescription:`Scroll: repeat passes until the selector is visible on screen`,projectConfig:!0,recorded:!1},{key:`doubleTap`,names:[`--double-tap`],type:`boolean`,usageLabel:`--double-tap`,usageDescription:`Use double-tap gesture per press iteration`,projectConfig:!0,recorded:!0},{key:`verify`,names:[`--verify`],type:`boolean`,usageLabel:`--verify`,usageDescription:`Capture cheap post-action evidence (AX digest, node counts, changedFromBefore) instead of a follow-up snapshot`,projectConfig:!0,recorded:!1},{key:`settle`,names:[`--settle`],type:`boolean`,usageLabel:`--settle`,usageDescription:`After the action, wait for the UI to go quiet and return the settled diff vs the pre-action tree in the same response (best-effort; never fails the action)`,projectConfig:!0,recorded:!1},{key:`settleQuietMs`,names:[`--settle-quiet`],type:`int`,min:0,usageLabel:`--settle-quiet <ms>`,usageDescription:`Settle: quiet window the UI must hold to count as settled (default 500ms)`,projectConfig:!0,recorded:!1},{key:`clickButton`,names:[`--button`],type:`enum`,enumValues:[`primary`,`secondary`,`middle`],usageLabel:`--button primary|secondary|middle`,usageDescription:`Click: choose mouse button (middle reserved for future macOS support)`,projectConfig:!0,recorded:!0},{key:`backMode`,names:[`--in-app`],type:`enum`,enumValues:[`in-app`,`system`],setValue:`in-app`,usageLabel:`--in-app`,usageDescription:`Back: use app-provided back UI when available`,projectConfig:!0,recorded:!1},{key:`backMode`,names:[`--system`],type:`enum`,enumValues:[`in-app`,`system`],setValue:`system`,usageLabel:`--system`,usageDescription:`Back: use system back input or gesture when available`,projectConfig:!0,recorded:!1},{key:`pauseMs`,names:[`--pause-ms`],type:`int`,min:0,max:1e4,usageLabel:`--pause-ms <ms>`,usageDescription:`Delay between swipe iterations`,projectConfig:!0,recorded:!0},{key:`pattern`,names:[`--pattern`],type:`enum`,enumValues:[`one-way`,`ping-pong`],usageLabel:`--pattern one-way|ping-pong`,usageDescription:`Swipe repeat pattern`,projectConfig:!0,recorded:!0},{key:`verbose`,names:[`--debug`,`--verbose`,`-v`],type:`boolean`,usageLabel:`--debug, --verbose, -v`,usageDescription:`Enable debug diagnostics; test --verbose prints per-test step timings without debug logs`,projectConfig:!0,recorded:!0},{key:`cost`,names:[`--cost`],type:`boolean`,usageLabel:`--cost`,usageDescription:`Include per-command wall-clock latency (cost.wallClockMs) in the response`,projectConfig:!0,recorded:!1},{key:`responseLevel`,names:[`--level`],type:`enum`,enumValues:e,usageLabel:`--level digest|default|full`,usageDescription:`Response detail level: digest (token-cheap), default (today), or full. Default keeps the wire shape unchanged.`,projectConfig:!0,recorded:!1},{key:`json`,names:[`--json`],type:`boolean`,usageLabel:`--json`,usageDescription:`JSON output`,projectConfig:!0,recorded:!1},{key:`help`,names:[`--help`,`-h`],type:`boolean`,usageLabel:`--help, -h`,usageDescription:`Print help and exit`,projectConfig:!1,recorded:!1},{key:`version`,names:[`--version`,`-V`],type:`boolean`,usageLabel:`--version, -V`,usageDescription:`Print version and exit`,projectConfig:!1,recorded:!1},{key:`snapshotDiff`,names:[`--diff`],type:`boolean`,usageLabel:`--diff`,usageDescription:`Snapshot: show structural diff against the previous session baseline`,projectConfig:!0,recorded:!1},{key:`saveScript`,names:[`--save-script`],type:`booleanOrString`,usageLabel:`--save-script [path]`,usageDescription:`Arm evidence capture on open, publish the armed recording on close; close --save-script alone (without an armed open) is rejected — start with open --save-script, or use session save-script mid-session. Optional custom output path.`,projectConfig:!1,recorded:!0},{key:`networkInclude`,names:[`--include`],type:`enum`,enumValues:[`summary`,`headers`,`body`,`all`],usageLabel:`--include summary|headers|body|all`,usageDescription:`Network: include headers, bodies, or both in output`,projectConfig:!0,recorded:!1},{key:`shutdown`,names:[`--shutdown`],type:`boolean`,usageLabel:`--shutdown`,usageDescription:`close: shutdown associated simulator/emulator after ending session`,projectConfig:!0,recorded:!1},{key:`relaunch`,names:[`--relaunch`],type:`boolean`,usageLabel:`--relaunch`,usageDescription:`open: terminate app process before launching it`,projectConfig:!0,recorded:!0},{key:`foreground`,names:[`--foreground`],type:`boolean`,usageLabel:`--foreground`,usageDescription:`open: keep normal app/device selection and return an initial snapshot; without an app, resolve the sole running app on the sole booted iOS simulator`,inputDescription:`Include an initial interactive snapshot in a fresh open response. With no app argument, discover the sole running app on the sole booted iOS simulator; ambiguous environments fail closed.`,projectConfig:!1,recorded:!1},{key:`restart`,names:[`--restart`],type:`boolean`,usageLabel:`--restart`,usageDescription:`logs clear: stop active stream, clear logs, then start streaming again`,projectConfig:!0,recorded:!1},{key:`retainPaths`,names:[`--retain-paths`],type:`boolean`,usageLabel:`--retain-paths`,usageDescription:`install-from-source: keep materialized artifact paths after install`,projectConfig:!0,recorded:!1},{key:`retentionMs`,names:[`--retention-ms`],type:`int`,min:1,usageLabel:`--retention-ms <ms>`,usageDescription:`install-from-source: retention TTL for materialized artifact paths`,projectConfig:!0,recorded:!1},{key:`noRecord`,names:[`--no-record`],type:`boolean`,usageLabel:`--no-record`,usageDescription:`Do not record this action`,projectConfig:!0,recorded:!0},{key:`record`,names:[`--record`],type:`boolean`,usageLabel:`--record`,usageHidden:!0,usageDescription:`Force-record this action even though its command is observation-only and would otherwise be excluded from a repair-armed heal by default (mutually exclusive with --no-record)`,projectConfig:!0,recorded:!0}],u=[{key:`config`,names:[`--config`],type:`string`,usageLabel:`--config <path>`,usageDescription:`Load CLI defaults from a specific config file (required for connection/provider defaults outside user config)`,projectConfig:!1,recorded:!1},{key:`remoteConfig`,names:[`--remote-config`],type:`string`,usageLabel:`--remote-config <path>`,usageDescription:`Load remote host + Metro workflow settings from a specific profile file`,projectConfig:!1,recorded:!1},{key:`stateDir`,names:[`--state-dir`],type:`string`,usageLabel:`--state-dir <path>`,usageDescription:`Daemon state directory (defaults to ~/.agent-device for packages, or a worktree-scoped dev dir from source)`,projectConfig:!1,recorded:!1},{key:`daemonBaseUrl`,names:[`--daemon-base-url`],type:`string`,usageLabel:`--daemon-base-url <url>`,usageDescription:`Explicit remote HTTP daemon base URL (skip local daemon discovery/startup)`,projectConfig:!1,recorded:!1},{key:`daemonAuthToken`,names:[`--daemon-auth-token`],type:`string`,usageLabel:`--daemon-auth-token <token>`,usageDescription:`Remote HTTP daemon or proxy auth token (sent as request token and bearer header)`,projectConfig:!1,recorded:!1},{key:`daemonTransport`,names:[`--daemon-transport`],type:`enum`,enumValues:[`auto`,`socket`,`http`],usageLabel:`--daemon-transport auto|socket|http`,usageDescription:`Daemon client transport preference`,projectConfig:!1,recorded:!1},{key:`daemonServerMode`,names:[`--daemon-server-mode`],type:`enum`,enumValues:[`socket`,`http`,`dual`],usageLabel:`--daemon-server-mode socket|http|dual`,usageDescription:`Daemon server mode used when spawning daemon`,projectConfig:!1,recorded:!1},{key:`proxyHost`,names:[`--host`],type:`string`,usageLabel:`--host <host>`,usageDescription:`Proxy: host interface to bind (default: 127.0.0.1)`,projectConfig:!1,recorded:!1},{key:`proxyPort`,names:[`--port`],type:`int`,min:1,max:65535,usageLabel:`--port <port>`,usageDescription:`Proxy: TCP port to bind (default: 0, choose a free port)`,projectConfig:!1,recorded:!1},{key:`tenant`,names:[`--tenant`],type:`string`,usageLabel:`--tenant <id>`,usageDescription:`Tenant scope identifier for isolated daemon sessions`,projectConfig:!1,recorded:!1},{key:`sessionIsolation`,names:[`--session-isolation`],type:`enum`,enumValues:[`none`,`tenant`],usageLabel:`--session-isolation none|tenant`,usageDescription:`Session isolation strategy (tenant prefixes session namespace)`,projectConfig:!1,recorded:!1},{key:`runId`,names:[`--run-id`],type:`string`,usageLabel:`--run-id <id>`,usageDescription:`Run identifier used for tenant lease admission checks`,projectConfig:!1,recorded:!1},{key:`leaseId`,names:[`--lease-id`],type:`string`,usageLabel:`--lease-id <id>`,usageDescription:`Lease identifier bound to tenant/run admission scope`,projectConfig:!1,recorded:!1},{key:`leaseBackend`,names:[`--lease-backend`],type:`enum`,enumValues:[`ios-simulator`,`ios-instance`,`android-instance`,`harmonyos-instance`],usageLabel:`--lease-backend ios-simulator|ios-instance|android-instance|harmonyos-instance`,usageDescription:`Lease backend for remote tenant connection admission`,projectConfig:!1,recorded:!1},{key:`provider`,names:[`--provider`],type:`string`,usageLabel:`--provider <name>`,usageDescription:`Cloud provider name for provider-scoped commands`,projectConfig:!1,recorded:!1},{key:`providerSessionId`,names:[`--provider-session`],type:`string`,usageLabel:`--provider-session <id>`,usageDescription:`Cloud provider session id or ARN`,projectConfig:!1,recorded:!1},{key:`providerApp`,names:[`--provider-app`],type:`string`,usageLabel:`--provider-app <ref-or-path>`,usageDescription:`Cloud provider app reference or local app path used when creating hosted WebDriver sessions`,projectConfig:!1,recorded:!1},{key:`providerOsVersion`,names:[`--provider-os-version`,`--os-version`],type:`string`,usageLabel:`--provider-os-version <version>`,usageDescription:`Hosted cloud provider OS version, for example 17 or 14.0`,projectConfig:!1,recorded:!1},{key:`providerProject`,names:[`--provider-project`],type:`string`,usageLabel:`--provider-project <name>`,usageDescription:`Hosted cloud provider project label`,projectConfig:!1,recorded:!1},{key:`providerBuild`,names:[`--provider-build`],type:`string`,usageLabel:`--provider-build <name>`,usageDescription:`Hosted cloud provider build label`,projectConfig:!1,recorded:!1},{key:`providerSessionName`,names:[`--provider-session-name`],type:`string`,usageLabel:`--provider-session-name <name>`,usageDescription:`Hosted cloud provider session label`,projectConfig:!1,recorded:!1},{key:`providerDeviceOrientation`,names:[`--provider-device-orientation`,`--device-orientation`],type:`enum`,enumValues:r,usageLabel:`--provider-device-orientation portrait|landscape`,usageDescription:`Screen orientation a hosted cloud provider session starts in. Set this rather than rotating after launch: a session that boots landscape renders login webviews landscape`,projectConfig:!1,recorded:!1},{key:`providerGeoLocation`,names:[`--provider-geo-location`,`--geo-location`],type:`string`,usageLabel:`--provider-geo-location <country>`,usageDescription:`Hosted cloud provider IP geolocation country code, for example US`,projectConfig:!1,recorded:!1},{key:`providerTimezone`,names:[`--provider-timezone`,`--timezone`],type:`string`,usageLabel:`--provider-timezone <zone>`,usageDescription:`Hosted cloud provider device time zone, for example New_York`,projectConfig:!1,recorded:!1},{key:`providerLanguage`,names:[`--provider-language`,`--language`],type:`string`,usageLabel:`--provider-language <language>`,usageDescription:`Hosted cloud provider app language, for example Fr`,projectConfig:!1,recorded:!1},{key:`providerLocale`,names:[`--provider-locale`,`--locale`],type:`string`,usageLabel:`--provider-locale <locale>`,usageDescription:`Hosted cloud provider device locale, for example Fr`,projectConfig:!1,recorded:!1},{key:`providerNetworkProfile`,names:[`--provider-network-profile`,`--network-profile`],type:`string`,usageLabel:`--provider-network-profile <profile>`,usageDescription:`Hosted cloud provider named network condition profile, for example 4g-lte-advanced-good. Mutually exclusive with --provider-custom-network`,projectConfig:!1,recorded:!1},{key:`providerCustomNetwork`,names:[`--provider-custom-network`,`--custom-network`],type:`string`,usageLabel:`--provider-custom-network <shape>`,usageDescription:`Hosted cloud provider custom network shape. Mutually exclusive with --provider-network-profile`,projectConfig:!1,recorded:!1},{key:`providerNoResignApp`,names:[`--provider-no-resign-app`],type:`boolean`,usageLabel:`--provider-no-resign-app`,usageDescription:`iOS only: keep an Enterprise-signed app as uploaded instead of letting the provider re-sign it, which strips entitlements such as push notifications`,projectConfig:!1,recorded:!1},{key:`awsProjectArn`,names:[`--aws-project-arn`],type:`string`,usageLabel:`--aws-project-arn <arn>`,usageDescription:`AWS Device Farm project ARN for hosted WebDriver sessions`,projectConfig:!1,recorded:!1},{key:`awsDeviceArn`,names:[`--aws-device-arn`],type:`string`,usageLabel:`--aws-device-arn <arn>`,usageDescription:`AWS Device Farm device ARN for hosted WebDriver sessions`,projectConfig:!1,recorded:!1},{key:`awsAppArn`,names:[`--aws-app-arn`],type:`string`,usageLabel:`--aws-app-arn <arn>`,usageDescription:`AWS Device Farm app ARN attached to hosted remote access sessions`,projectConfig:!1,recorded:!1},{key:`awsRegion`,names:[`--aws-region`],type:`string`,usageLabel:`--aws-region <region>`,usageDescription:`AWS region for Device Farm API calls`,projectConfig:!1,recorded:!1},{key:`awsInteractionMode`,names:[`--aws-interaction-mode`],type:`enum`,enumValues:[`INTERACTIVE`,`NO_VIDEO`,`VIDEO_ONLY`],usageLabel:`--aws-interaction-mode INTERACTIVE|NO_VIDEO|VIDEO_ONLY`,usageDescription:`AWS Device Farm remote access interaction mode`,projectConfig:!1,recorded:!1},{key:`force`,names:[`--force`,`--overwrite`],type:`boolean`,usageLabel:`--force, --overwrite`,usageDescription:`Force replacement of existing state (connect: replace an active connection; --save-script: overwrite an existing target instead of refusing)`,projectConfig:!0,recorded:!0},{key:`clean`,names:[`--clean`],type:`boolean`,usageLabel:`--clean`,usageDescription:`Daemon stop: remove retained runner processes and leases after stopping`,projectConfig:!0,recorded:!1},{key:`noLogin`,names:[`--no-login`],type:`boolean`,usageLabel:`--no-login`,usageDescription:`Connect: fail instead of starting implicit cloud login`,projectConfig:!0,recorded:!1},{key:`sessionLock`,names:[`--session-lock`],type:`enum`,enumValues:[`reject`,`strip`],usageLabel:`--session-lock reject|strip`,usageDescription:`Lock bound-session device routing for this CLI invocation and nested batch steps; strip drops conflicting platform/scope selectors only, and a selector naming a different device always fails`,projectConfig:!0,recorded:!1}],d=[{key:`platform`,names:[`--platform`],type:`enum`,enumValues:n,usageLabel:`--platform ${n.join(`|`)}`,usageDescription:"Platform to target (`apple` aliases the Apple automation backend)",projectConfig:!0,recorded:!0},{key:`target`,names:[`--target`],type:`enum`,enumValues:[`mobile`,`tv`,`desktop`],usageLabel:`--target mobile|tv|desktop`,usageDescription:`Device target class to match`,projectConfig:!0,recorded:!1},{key:`device`,names:[`--device`],type:`string`,usageLabel:`--device <name>`,usageDescription:`Device name to target (a UDID belongs in --udid, a serial in --serial)`,projectConfig:!0,recorded:!0},{key:`udid`,names:[`--udid`],type:`string`,usageLabel:`--udid <udid>`,usageDescription:`Apple device or simulator UDID; the only selector that pins one device when several share a --device name`,projectConfig:!0,recorded:!0},{key:`serial`,names:[`--serial`],type:`string`,usageLabel:`--serial <serial>`,usageDescription:`Android, HarmonyOS, or Vega VVD serial`,projectConfig:!0,recorded:!0},{key:`stale`,names:[`--stale`],type:`boolean`,usageLabel:`--stale`,usageDescription:`Device status: show only claims with a provably stale owner`,projectConfig:!0,recorded:!1},{key:`surface`,names:[`--surface`],type:`enum`,enumValues:i,usageLabel:`--surface app|frontmost-app|desktop|menubar`,usageDescription:`macOS session surface for open (defaults to app)`,projectConfig:!0,recorded:!1},{key:`headless`,names:[`--headless`],type:`boolean`,usageLabel:`--headless`,usageDescription:`Boot: launch Android emulator without a GUI window`,projectConfig:!0,recorded:!1},{key:`targetApp`,names:[`--app`,`--target-app`],type:`string`,usageLabel:`--app <id-or-name>`,usageDescription:`Doctor: verify an installed target app without opening a session`,projectConfig:!1,recorded:!1},{key:`metroHost`,names:[`--metro-host`],type:`string`,usageLabel:`--metro-host <host>`,usageDescription:`Session-scoped Metro/debug host hint`,projectConfig:!1,recorded:!0},{key:`metroPort`,names:[`--metro-port`],type:`int`,min:1,max:65535,usageLabel:`--metro-port <port>`,usageDescription:`Session-scoped Metro/debug port hint; on an emulator/simulator the host defaults to the loopback alias, physical devices still need --metro-host`,projectConfig:!1,recorded:!0},{key:`metroProjectRoot`,names:[`--project-root`],type:`string`,usageLabel:`--project-root <path>`,usageDescription:`metro prepare: React Native project root (default: cwd)`,projectConfig:!1,recorded:!1},{key:`kind`,names:[`--kind`],type:`enum`,enumValues:[`auto`,`react-native`,`expo`,`repack`,...a],usageLabel:`--kind <kind>`,usageDescription:`Kind selector for commands that support it, such as metro prepare or perf artifact collectors`,projectConfig:!0,recorded:!1},{key:`perfTemplate`,names:[`--template`],type:`string`,usageLabel:`--template <name>`,usageDescription:`Perf xctrace template name, for example Time Profiler`,projectConfig:!0,recorded:!1},{key:`metroKind`,names:[`--metro-kind`],type:`enum`,enumValues:[`auto`,`react-native`,`expo`,`repack`],usageLabel:`--metro-kind auto|react-native|expo|repack`,usageDescription:`metro prepare: detect or force the React Native dev-server launcher kind`,projectConfig:!1,recorded:!1},{key:`metroPublicBaseUrl`,names:[`--public-base-url`],type:`string`,usageLabel:`--public-base-url <url>`,usageDescription:`metro prepare: public base URL used for direct dev-server bundle hints`,projectConfig:!1,recorded:!1},{key:`metroProxyBaseUrl`,names:[`--proxy-base-url`],type:`string`,usageLabel:`--proxy-base-url <url>`,usageDescription:`metro prepare: optional bridge origin for remote dev-server access`,projectConfig:!1,recorded:!1},{key:`metroBearerToken`,names:[`--bearer-token`],type:`string`,usageLabel:`--bearer-token <token>`,usageDescription:`metro prepare: host bridge bearer token (or AGENT_DEVICE_METRO_BEARER_TOKEN; falls back to AGENT_DEVICE_DAEMON_AUTH_TOKEN)`,projectConfig:!1,recorded:!1},{key:`metroPreparePort`,names:[`--port`],type:`int`,min:1,max:65535,usageLabel:`--port <port>`,usageDescription:`metro prepare: local dev-server port (default: 8081)`,projectConfig:!1,recorded:!1},{key:`metroListenHost`,names:[`--listen-host`],type:`string`,usageLabel:`--listen-host <host>`,usageDescription:`metro prepare: host dev server listens on (default: 0.0.0.0)`,projectConfig:!1,recorded:!1},{key:`metroStatusHost`,names:[`--status-host`],type:`string`,usageLabel:`--status-host <host>`,usageDescription:`metro prepare: host used for local dev-server /status polling (default: 127.0.0.1)`,projectConfig:!1,recorded:!1},{key:`metroStartupTimeoutMs`,names:[`--startup-timeout-ms`],type:`int`,min:1,usageLabel:`--startup-timeout-ms <ms>`,usageDescription:`metro prepare: timeout while waiting for the dev server to become ready`,projectConfig:!1,recorded:!1},{key:`metroProbeTimeoutMs`,names:[`--probe-timeout-ms`],type:`int`,min:1,usageLabel:`--probe-timeout-ms <ms>`,usageDescription:`metro prepare: timeout for /status and proxy bridge calls`,projectConfig:!1,recorded:!1},{key:`metroRuntimeFile`,names:[`--runtime-file`],type:`string`,usageLabel:`--runtime-file <path>`,usageDescription:`metro prepare: optional file path to persist the JSON result`,projectConfig:!1,recorded:!1},{key:`metroNoReuseExisting`,names:[`--no-reuse-existing`],type:`boolean`,usageLabel:`--no-reuse-existing`,usageDescription:`metro prepare: always start a fresh Metro process`,projectConfig:!1,recorded:!1},{key:`metroNoInstallDeps`,names:[`--no-install-deps`],type:`boolean`,usageLabel:`--no-install-deps`,usageDescription:`metro prepare: skip package-manager install when node_modules is missing`,projectConfig:!1,recorded:!1},{key:`bundleUrl`,names:[`--bundle-url`],type:`string`,usageLabel:`--bundle-url <url>`,usageDescription:`Session-scoped bundle URL hint`,projectConfig:!1,recorded:!0},{key:`launchUrl`,names:[`--launch-url`],type:`string`,usageLabel:`--launch-url <url>`,usageDescription:`Session-scoped deep link / launch URL hint`,projectConfig:!0,recorded:!0},{key:`iosSimulatorDeviceSet`,names:[`--ios-simulator-device-set`],type:`string`,usageLabel:`--ios-simulator-device-set <path>`,usageDescription:`Scope iOS simulator discovery/commands to this simulator device set`,projectConfig:!1,recorded:!1},{key:`iosXctestrunFile`,names:[`--ios-xctestrun-file`],type:`string`,usageLabel:`--ios-xctestrun-file <path>`,usageDescription:`Use an externally built iOS XCTest runner .xctestrun artifact`,projectConfig:!1,recorded:!1},{key:`iosXctestDerivedDataPath`,names:[`--ios-xctest-derived-data-path`],type:`string`,usageLabel:`--ios-xctest-derived-data-path <path>`,usageDescription:`Derived data path for external iOS XCTest runner execution`,projectConfig:!1,recorded:!1},{key:`iosXctestEnvDir`,names:[`--ios-xctest-env-dir`],type:`string`,usageLabel:`--ios-xctest-env-dir <path>`,usageDescription:`Writable directory for per-session iOS XCTest runner env overlays`,projectConfig:!1,recorded:!1},{key:`deviceHub`,names:[`--device-hub`],type:`boolean`,usageLabel:`--device-hub`,usageDescription:`open: use Xcode Device Hub when surfacing Apple simulators`,projectConfig:!0,recorded:!1},{key:`testIme`,names:[`--test-ime`],type:`boolean`,usageLabel:`--test-ime`,usageDescription:`open: activate the headless Android test IME for deterministic Unicode text entry (default on for emulators; opt-in on real devices)`,projectConfig:!0,recorded:!1},{key:`testIme`,names:[`--no-test-ime`],type:`boolean`,setValue:!1,usageLabel:`--no-test-ime`,usageDescription:`open: keep the real Android keyboard even on emulators (opt out of the headless test IME)`,projectConfig:!0,recorded:!1},{key:`androidDeviceAllowlist`,names:[`--android-device-allowlist`],type:`string`,usageLabel:`--android-device-allowlist <serials>`,usageDescription:`Comma/space separated Android serial allowlist for discovery/selection`,projectConfig:!1,recorded:!1},{key:`remote`,names:[`--remote`],type:`boolean`,usageLabel:`--remote`,usageDescription:`Doctor: check remote connection setup instead of local device inventory`,projectConfig:!0,recorded:!1},{key:`activity`,names:[`--activity`],type:`string`,usageLabel:`--activity <component>`,usageDescription:`Android app launch activity (package/Activity); not for URL opens`,projectConfig:!0,recorded:!1},{key:`launchConsole`,names:[`--launch-console`],type:`string`,usageLabel:`--launch-console <path>`,usageDescription:`open: capture the initial iOS simulator launch console window to a file`,projectConfig:!1,recorded:!1},{key:`launchArgs`,names:[`--launch-args`],type:`string`,multiple:!0,usageLabel:`--launch-args <arg>`,usageDescription:`open: repeatable launch argument forwarded verbatim to the platform launch command (iOS app process args; Android adb shell am start args). Linux and macOS reject the flag.`,projectConfig:!0,recorded:!1},{key:`header`,names:[`--header`],type:`string`,multiple:!0,usageLabel:`--header <name:value>`,usageDescription:`install-from-source: repeatable HTTP header for URL downloads`,projectConfig:!1,recorded:!1},{key:`githubActionsArtifact`,names:[`--github-actions-artifact`],type:`string`,usageLabel:`--github-actions-artifact <owner/repo:artifact>`,usageDescription:`install-from-source: GitHub Actions artifact resolved by a remote daemon`,projectConfig:!1,recorded:!1},{key:`installSource`,names:[],type:`string`,projectConfig:!1,recorded:!1},{key:`session`,names:[`--session`],type:`string`,usageLabel:`--session <name>`,usageDescription:`Named session`,projectConfig:!0,recorded:!1}],f=[{key:`replayUpdate`,names:[`--update`,`-u`],type:`boolean`,usageLabel:`--update, -u`,usageDescription:`Replay: retired as a rewrite (ADR 0012) — never edits the .ad file; every divergence already carries ranked selector suggestions, --update or not`,projectConfig:!0,recorded:!1},{key:`replayFrom`,names:[`--from`],type:`int`,min:1,usageLabel:`--from <n>`,usageDescription:`Replay: resume at 1-based plan step n, skipping 1..n-1 without executing them (requires --plan-digest; see a divergence report's resume field). replay only, not test`,projectConfig:!0,recorded:!1},{key:`replayPlanDigest`,names:[`--plan-digest`],type:`string`,usageLabel:`--plan-digest <sha256>`,usageDescription:`Replay: the plan digest a --from resume must match (from a prior divergence report); mismatch, edits, or include/platform-expansion changes fail INVALID_ARGS before any action`,projectConfig:!0,recorded:!1},{key:`replayKeepSession`,names:[`--keep-session`],type:`boolean`,usageLabel:`--keep-session`,usageDescription:`Replay: leave the session active by suppressing exactly an authored terminal close in a native .ad script; replay only, not test or Maestro YAML`,projectConfig:!0,recorded:!1},{key:`replayMaestro`,names:[`--maestro`],type:`boolean`,usageLabel:`--maestro`,usageDescription:`Replay: treat input as a supported Maestro YAML subset; unsupported syntax fails loudly. See agent-device help maestro for commands and boundaries`,projectConfig:!0,recorded:!1},{key:`replayEnv`,names:[`-e`,`--env`],type:`string`,multiple:!0,usageLabel:`-e KEY=VALUE, --env KEY=VALUE`,usageDescription:"Replay/Test: inject or override a ${KEY} variable for the script (repeatable)",projectConfig:!1,recorded:!1},{key:`failFast`,names:[`--fail-fast`],type:`boolean`,usageLabel:`--fail-fast`,usageDescription:`Test: stop the suite after the first failing script; with sharding, each shard stops independently`,projectConfig:!0,recorded:!1},{key:`timeoutMs`,names:[`--timeout`],type:`int`,min:1,usageLabel:`--timeout <ms>`,usageDescription:`Open/Prepare: startup budget covering the Simulator boot (and runner preparation for prepare). Replay/Snapshot/Test: maximum wall-clock time for the command or attempt. With --settle: the settle-wait deadline (default 10s)`,projectConfig:!0,recorded:!1},{key:`retries`,names:[`--retries`],type:`int`,min:0,max:3,usageLabel:`--retries <n>`,usageDescription:`Test: retry each failed script up to n additional times`,projectConfig:!0,recorded:!1},{key:`recordVideo`,names:[`--record-video`],type:`boolean`,usageLabel:`--record-video`,usageDescription:`Test: record each replay attempt to recording.mp4 in its attempt artifacts`,projectConfig:!0,recorded:!1},{key:`artifactsDir`,names:[`--artifacts-dir`],type:`string`,usageLabel:`--artifacts-dir <path>`,usageDescription:`Test: root directory for suite artifacts`,projectConfig:!1,recorded:!1},{key:`reporter`,names:[`--reporter`],type:`string`,multiple:!0,usageLabel:`--reporter <name-or-path>`,usageDescription:`Test: add a replay suite reporter; use default, junit:<path>, or a custom reporter path (repeatable)`,projectConfig:!1,recorded:!1},{key:`reportJunit`,names:[`--report-junit`],type:`string`,usageLabel:`--report-junit <path>`,usageDescription:`Test: compatibility alias for --reporter junit:<path>`,projectConfig:!1,recorded:!1},{key:`shardAll`,names:[`--shard-all`],type:`int`,min:1,usageLabel:`--shard-all <n>`,usageDescription:`Test: run the full suite on each of n devices; combine with --device id1,id2 for explicit connected devices; AD_SHARD_INDEX is zero-based`,projectConfig:!0,recorded:!1},{key:`shardSplit`,names:[`--shard-split`],type:`int`,min:1,usageLabel:`--shard-split <n>`,usageDescription:`Test: split runnable suite entries across n devices; AD_SHARD_INDEX is zero-based`,projectConfig:!0,recorded:!1},{key:`steps`,names:[`--steps`],type:`string`,usageLabel:`--steps <json>`,usageDescription:`Batch: JSON array of {"command","input"} steps`,projectConfig:!1,recorded:!1},{key:`stepsFile`,names:[`--steps-file`],type:`string`,usageLabel:`--steps-file <path>`,usageDescription:`Batch: read steps JSON from file`,projectConfig:!1,recorded:!1},{key:`batchOnError`,names:[`--on-error`],type:`enum`,enumValues:[`stop`],usageLabel:`--on-error stop`,usageDescription:`Batch: stop when a step fails`,projectConfig:!0,recorded:!1},{key:`batchMaxSteps`,names:[`--max-steps`],type:`int`,min:1,max:1e3,usageLabel:`--max-steps <n>`,usageDescription:`Batch: maximum number of allowed steps`,projectConfig:!0,recorded:!1},{key:`appsFilter`,names:[`--all`],type:`enum`,enumValues:[`user-installed`,`all`],setValue:`all`,usageLabel:`--all`,usageDescription:`Apps: include system/OEM apps`,projectConfig:!0,recorded:!1},{key:`snapshotInteractiveOnly`,names:[`-i`],type:`boolean`,usageLabel:`-i`,usageDescription:`Snapshot: interactive elements only`,projectConfig:!0,recorded:!0},{key:`snapshotDepth`,names:[`--depth`,`-d`],type:`int`,min:0,usageLabel:`--depth, -d <depth>`,usageDescription:`Snapshot: limit snapshot depth`,projectConfig:!0,recorded:!0},{key:`snapshotScope`,names:[`--scope`,`-s`],type:`string`,usageLabel:`--scope, -s <scope>`,usageDescription:`Snapshot: scope snapshot to label/identifier`,projectConfig:!0,recorded:!0},{key:`snapshotRaw`,names:[`--raw`],type:`boolean`,usageLabel:`--raw`,usageDescription:`Snapshot: raw node output`,projectConfig:!0,recorded:!0},{key:`snapshotCustomActions`,names:[`--actions`],type:`boolean`,usageLabel:`--actions`,usageDescription:`Snapshot: name the affordances merged inside an element (iOS sim); not directly invokable — reach them via the detail screen, labeled children, or coordinates`,inputDescription:`Name the affordances an element merged away (iOS UIAccessibilityCustomAction, React Native accessibilityActions) — a card whose reply/options controls are not separate elements still lists them here. The names are for PLANNING, not invocation: there is no API to trigger them, so reach the affordance through the element detail screen, through the same control exposed as a labeled element elsewhere, or by coordinates from its rect. iOS simulator only; costs one accessibility round trip per merged element.`,projectConfig:!0,recorded:!0},{key:`snapshotForceFull`,names:[`--force-full`],type:`boolean`,usageLabel:`--force-full`,usageDescription:`Snapshot: re-emit the full tree even when unchanged`,projectConfig:!0,recorded:!1},{key:`findFirst`,names:[`--first`],type:`boolean`,usageLabel:`--first`,usageDescription:`Find: pick the first match when ambiguous`,projectConfig:!0,recorded:!1},{key:`findLast`,names:[`--last`],type:`boolean`,usageLabel:`--last`,usageDescription:`Find: pick the last match when ambiguous`,projectConfig:!0,recorded:!1},{key:`out`,names:[`--out`],type:`string`,usageLabel:`--out <path>`,usageDescription:`Output path`,projectConfig:!1,recorded:!0},{key:`artifact`,names:[`--artifact`],type:`string`,usageLabel:`--artifact <path>`,usageDescription:`Debug symbols: Apple crash artifact path (.ips, .crash, or .log)`,projectConfig:!1,recorded:!1},{key:`dsym`,names:[`--dsym`],type:`string`,usageLabel:`--dsym <path>`,usageDescription:`Debug symbols: matching .dSYM bundle path`,projectConfig:!1,recorded:!1},{key:`searchPath`,names:[`--search-path`],type:`string`,usageLabel:`--search-path <dir>`,usageDescription:`Debug symbols: directory to scan for matching .dSYM bundles`,projectConfig:!1,recorded:!1},{key:`overlayRefs`,names:[`--overlay-refs`],type:`boolean`,usageLabel:`--overlay-refs`,usageDescription:`Screenshot: draw current snapshot refs and target rectangles onto the saved PNG; diff screenshot: also write a separate current-screen overlay guide`,projectConfig:!0,recorded:!1},...t,{key:`baseline`,names:[`--baseline`,`-b`],type:`string`,usageLabel:`--baseline, -b <path>`,usageDescription:`Diff screenshot: path to baseline image file`,projectConfig:!0,recorded:!1},{key:`threshold`,names:[`--threshold`],type:`string`,usageLabel:`--threshold <0-1>`,usageDescription:`Diff screenshot: color distance threshold (default 0.1)`,projectConfig:!0,recorded:!1}],p=[...u,...d,...l,...f],m=new Map;for(let e of p)for(let t of e.names)m.set(t,e);function h(e){return m.get(e)}function g(){return p}function _(e){return p.filter(t=>t.key===e)}function v(){return new Set(p.filter(e=>e.projectConfig).map(e=>e.key))}function y(){return new Set(p.filter(e=>e.recorded).map(e=>e.key))}const b=[`in-app`,`system`];export{v as a,s as c,_ as i,c as l,h as n,y as o,g as r,o as s,b as t};
@@ -1 +1 @@
1
- const e={interactiveOnly:`snapshotInteractiveOnly`,scope:`snapshotScope`,depth:`snapshotDepth`,raw:`snapshotRaw`,customActions:`snapshotCustomActions`,includeHiddenContentHints:`snapshotIncludeHiddenContentHints`,preferredBackend:`snapshotPreferredBackend`};function t(t){return t?Object.fromEntries(Object.entries(e).flatMap(([e,n])=>{let r=t[e];return r===void 0?[]:[[n,r]]})):{}}export{t};
1
+ import{_ as e}from"./sdk-contracts.js";const t=Object.keys({interactiveOnly:!0,scope:!0,depth:!0,raw:!0,customActions:!0,includeHiddenContentHints:!0,preferredBackend:!0});function n(n){return e(n,t)}export{n as t};
@@ -1,2 +1,2 @@
1
- import{b as e}from"./sdk-contracts.js";function t(t){let n=t.error?e(t.error):null,r=t.context?.platform,i=t.context?.phase;if(n?.code===`TOOL_MISSING`)return r===`android`?`ADB_TRANSPORT_UNAVAILABLE`:`IOS_TOOL_MISSING`;let a=n?.details??{},o=typeof a.message==`string`?a.message:void 0,s=typeof a.stdout==`string`?a.stdout:void 0,c=typeof a.stderr==`string`?a.stderr:void 0,l=a.boot&&typeof a.boot==`object`?a.boot:null,u=a.bootstatus&&typeof a.bootstatus==`object`?a.bootstatus:null,d=[t.message,n?.message,t.stdout,t.stderr,o,s,c,typeof l?.stdout==`string`?l.stdout:void 0,typeof l?.stderr==`string`?l.stderr:void 0,typeof u?.stdout==`string`?u.stdout:void 0,typeof u?.stderr==`string`?u.stderr:void 0].filter(Boolean).join(`
1
+ import{w as e}from"./sdk-contracts.js";function t(t){let n=t.error?e(t.error):null,r=t.context?.platform,i=t.context?.phase;if(n?.code===`TOOL_MISSING`)return r===`android`?`ADB_TRANSPORT_UNAVAILABLE`:`IOS_TOOL_MISSING`;let a=n?.details??{},o=typeof a.message==`string`?a.message:void 0,s=typeof a.stdout==`string`?a.stdout:void 0,c=typeof a.stderr==`string`?a.stderr:void 0,l=a.boot&&typeof a.boot==`object`?a.boot:null,u=a.bootstatus&&typeof a.bootstatus==`object`?a.bootstatus:null,d=[t.message,n?.message,t.stdout,t.stderr,o,s,c,typeof l?.stdout==`string`?l.stdout:void 0,typeof l?.stderr==`string`?l.stderr:void 0,typeof u?.stdout==`string`?u.stdout:void 0,typeof u?.stderr==`string`?u.stderr:void 0].filter(Boolean).join(`
2
2
  `).toLowerCase();return r===`ios`&&d.includes(`0xe8008012`)?`IOS_RUNNER_DEVICE_NOT_PROVISIONED`:r===`ios`&&(d.includes(`provisioning profile`)||d.includes(`embedded profile`))?`BOOT_COMMAND_FAILED`:r===`ios`&&(d.includes(`runner did not accept connection`)||i===`connect`&&(d.includes(`timed out`)||d.includes(`timeout`)||d.includes(`econnrefused`)||d.includes(`connection refused`)||d.includes(`fetch failed`)||d.includes(`socket hang up`)))?`IOS_RUNNER_CONNECT_TIMEOUT`:r===`ios`&&i===`boot`&&(d.includes(`timed out`)||d.includes(`timeout`))?`IOS_BOOT_TIMEOUT`:r===`android`&&i===`boot`&&(d.includes(`timed out`)||d.includes(`timeout`))?`ANDROID_BOOT_TIMEOUT`:d.includes(`resource temporarily unavailable`)||d.includes(`killed: 9`)||d.includes(`cannot allocate memory`)||d.includes(`system is low on memory`)?`CI_RESOURCE_STARVATION_SUSPECTED`:r===`android`&&(d.includes(`device not found`)||d.includes(`no devices`)||d.includes(`device offline`)||d.includes(`offline`)||d.includes(`unauthorized`)||d.includes(`not authorized`)||d.includes(`unable to locate device`)||d.includes(`invalid device`))?`ADB_TRANSPORT_UNAVAILABLE`:n?.code===`COMMAND_FAILED`||d.length>0?`BOOT_COMMAND_FAILED`:`UNKNOWN`}function n(e){switch(e){case`IOS_BOOT_TIMEOUT`:return`Retry simulator boot and inspect simctl bootstatus logs; in CI reduce parallel jobs or use a larger runner.`;case`IOS_RUNNER_CONNECT_TIMEOUT`:return`Retry runner startup, inspect xcodebuild logs, and verify simulator responsiveness before command execution.`;case`IOS_RUNNER_OWNED_BY_OTHER_DAEMON`:return`Close the owning agent-device session or stop its daemon with retained-runner cleanup before retrying.`;case`IOS_RUNNER_DEVICE_NOT_PROVISIONED`:return`The XCTest runner cannot be installed on this device: its provisioning profile does not cover it. Register the device with the signing team (Xcode > Settings > Accounts, or add its UDID to the provisioning profile) and retry. Retrying without that will keep failing.`;case`ANDROID_BOOT_TIMEOUT`:return`Retry emulator startup and verify sys.boot_completed reaches 1; consider increasing startup budget in CI.`;case`ADB_TRANSPORT_UNAVAILABLE`:return`Check adb server/device transport (adb devices -l), restart adb, and ensure the target device is online and authorized.`;case`CI_RESOURCE_STARVATION_SUSPECTED`:return`CI machine may be resource constrained; reduce parallel jobs or use a larger runner.`;case`IOS_TOOL_MISSING`:return`Xcode command-line tools are missing or not in PATH; run xcode-select --install and verify xcrun works.`;case`BOOT_COMMAND_FAILED`:return`Inspect command stderr/stdout for the failing boot phase and retry after environment validation.`;default:return`Retry once and inspect verbose logs for the failing phase.`}}export{t as n,n as t};
@@ -0,0 +1 @@
1
+ import{c as e}from"./exec.js";import"./command.js";const t=/[\p{Cc}\p{Cf}]/u;function n(e){if(t.test(e))return!1;try{let{protocol:t}=new URL(e);return t===`http:`||t===`https:`}catch{return!1}}function r(e,t){return e===`darwin`?{command:`open`,args:[t],ignoresExitStatus:!1}:e===`win32`?{command:`rundll32.exe`,args:[`url.dll,FileProtocolHandler`,t],ignoresExitStatus:!0}:{command:`xdg-open`,args:[t],ignoresExitStatus:!1}}async function i(t){if(!n(t))return!1;let i=r(process.platform,t);try{let{exitCode:t}=await e(i.command,i.args,{allowFailure:!0,timeoutMs:5e3});return i.ignoresExitStatus||t===0}catch{return!1}}export{n as isSafeBrowserUrl,i as openUrlInBrowser};