agent-device 0.21.13 → 0.21.15

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 (298) hide show
  1. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.13.apk → agent-device-android-ime-helper-0.21.15.apk} +0 -0
  2. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.15.apk.sha256 +1 -0
  3. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.13.manifest.json → agent-device-android-ime-helper-0.21.15.manifest.json} +4 -4
  4. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.15.apk +0 -0
  5. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.15.apk.sha256 +1 -0
  6. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.13.manifest.json → agent-device-android-snapshot-helper-0.21.15.manifest.json} +6 -6
  7. package/apple/snapshot-bridge/SnapshotBridgeRuntime.m +11 -1
  8. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +110 -2
  9. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +4 -2
  10. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerMainOwnedState.swift +27 -0
  11. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedTextEntry.h +8 -2
  12. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedTextEntry.m +26 -1
  13. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +12 -19
  14. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +59 -20
  15. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift +2 -3
  16. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandDispatch.swift +179 -91
  17. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +21 -24
  18. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +1 -1
  19. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+GestureExecution.swift +9 -13
  20. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +36 -49
  21. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+MainThreadWork.swift +11 -15
  22. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +136 -29
  23. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +20 -21
  24. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+PrivateAXPresentation.swift +3 -0
  25. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScreenRecorder.swift +6 -5
  26. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollDragExecution.swift +12 -24
  27. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift +22 -42
  28. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +15 -18
  29. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotAcquisition.swift +73 -31
  30. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +20 -11
  31. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCaptureTarget.swift +9 -7
  32. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotExecution.swift +5 -4
  33. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotTiming.swift +2 -2
  34. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +51 -19
  35. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift +5 -2
  36. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedTextEntry.swift +78 -10
  37. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +32 -2
  38. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryFocus.swift +7 -4
  39. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +23 -0
  40. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Transport.swift +17 -10
  41. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TvRemote.swift +8 -9
  42. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TypeExecution.swift +9 -15
  43. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +12 -11
  44. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotCoordinateSpace.swift +16 -19
  45. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotGeometry.swift +24 -9
  46. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotModels.swift +66 -10
  47. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationInvariant.swift +12 -10
  48. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationProjection.swift +1 -0
  49. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFold.swift +27 -5
  50. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFoldProjection.swift +1 -0
  51. package/dist/src/adapter.js +1 -1
  52. package/dist/src/adb-executor.js +1 -1
  53. package/dist/src/adb-failure.js +1 -1
  54. package/dist/src/adb-transport.js +1 -1
  55. package/dist/src/agent-browser-provider.js +1 -1
  56. package/dist/src/agent-browser-tool.js +1 -1
  57. package/dist/src/agent-device-client.js +2 -2
  58. package/dist/src/ai-sdk.js +1 -1
  59. package/dist/src/alert-runtime.js +1 -1
  60. package/dist/src/android-adb.d.ts +1 -8
  61. package/dist/src/android-input-ownership.js +1 -1
  62. package/dist/src/android-snapshot-quality.js +1 -0
  63. package/dist/src/android-system-chrome.js +1 -1
  64. package/dist/src/android.js +1 -1
  65. package/dist/src/app-catalog.js +1 -1
  66. package/dist/src/app-deployment-resolution.js +1 -1
  67. package/dist/src/app-inventory.js +1 -1
  68. package/dist/src/app-launch.js +1 -1
  69. package/dist/src/app-lifecycle.js +1 -1
  70. package/dist/src/app-lifecycle2.js +1 -1
  71. package/dist/src/app-log-files.js +1 -1
  72. package/dist/src/app-log-runtime2.js +1 -1
  73. package/dist/src/app-resolution.js +2 -2
  74. package/dist/src/apple-runner-platform.js +1 -1
  75. package/dist/src/application-lifecycle-interaction.js +1 -1
  76. package/dist/src/archive.js +1 -1
  77. package/dist/src/artifact-download.js +1 -1
  78. package/dist/src/auth-session.js +1 -1
  79. package/dist/src/auth.js +1 -1
  80. package/dist/src/backend-snapshot-options.js +1 -1
  81. package/dist/src/boot-diagnostics.js +1 -1
  82. package/dist/src/capture-disclosure.js +1 -1
  83. package/dist/src/capture.js +1 -1
  84. package/dist/src/cli-config.js +1 -1
  85. package/dist/src/cli-help.js +2 -2
  86. package/dist/src/cli.js +4 -4
  87. package/dist/src/click-button.js +1 -1
  88. package/dist/src/client-metro.js +1 -1
  89. package/dist/src/client-types.d.ts +102 -95
  90. package/dist/src/clipboard-shell-response.js +1 -1
  91. package/dist/src/command-schema.js +1 -1
  92. package/dist/src/command-tools.js +3 -3
  93. package/dist/src/connection-runtime.js +1 -1
  94. package/dist/src/connection.js +1 -1
  95. package/dist/src/contracts.d.ts +1 -1
  96. package/dist/src/contracts.js +1 -1
  97. package/dist/src/daemon-client-lifecycle.js +1 -1
  98. package/dist/src/daemon.js +1 -1
  99. package/dist/src/debug-symbols-facade.js +1 -1
  100. package/dist/src/device-claim-rule.js +2 -2
  101. package/dist/src/device-input-state.d.ts +15 -2
  102. package/dist/src/device-inventory-context.js +1 -1
  103. package/dist/src/device-rotation.js +1 -1
  104. package/dist/src/device-selection-resolver.js +1 -1
  105. package/dist/src/device-session.js +1 -1
  106. package/dist/src/device-shell.js +1 -1
  107. package/dist/src/device2.js +1 -1
  108. package/dist/src/devicectl.js +1 -1
  109. package/dist/src/diagnostics.js +1 -1
  110. package/dist/src/dispatch-resolve.js +1 -1
  111. package/dist/src/doctor2.js +1 -1
  112. package/dist/src/engine-eval-script.js +1 -1
  113. package/dist/src/error.js +1 -1
  114. package/dist/src/exec.js +1 -1
  115. package/dist/src/file.js +1 -1
  116. package/dist/src/find.js +1 -1
  117. package/dist/src/format.js +1 -1
  118. package/dist/src/gesture-plan-types.d.ts +1 -1
  119. package/dist/src/gesture-plan.js +1 -1
  120. package/dist/src/gesture-runtime.js +1 -1
  121. package/dist/src/harmonyos.js +1 -1
  122. package/dist/src/helper.js +2 -2
  123. package/dist/src/human-control-contract.js +1 -1
  124. package/dist/src/human-control.js +1 -1
  125. package/dist/src/index.d.ts +7 -3
  126. package/dist/src/index.js +1 -1
  127. package/dist/src/input-actions.js +1 -1
  128. package/dist/src/input-actions2.js +1 -1
  129. package/dist/src/install-artifact-facade.js +1 -1
  130. package/dist/src/install-source-network-transport.js +1 -1
  131. package/dist/src/install-source2.js +1 -1
  132. package/dist/src/interaction-positionals.js +1 -1
  133. package/dist/src/interaction-ref-policy.js +1 -1
  134. package/dist/src/interaction2.js +1 -1
  135. package/dist/src/interactor-operation-binding.js +1 -1
  136. package/dist/src/interactor.js +4 -4
  137. package/dist/src/interactor2.js +1 -1
  138. package/dist/src/interactors.js +1 -1
  139. package/dist/src/internal/bin.js +1 -1
  140. package/dist/src/internal/daemon.js +2 -2
  141. package/dist/src/internal/png-worker.js +1 -1
  142. package/dist/src/internal/run-script-http-child.js +1 -1
  143. package/dist/src/inventory.js +1 -1
  144. package/dist/src/inventory2.js +1 -1
  145. package/dist/src/inventory3.js +1 -1
  146. package/dist/src/inventory5.js +1 -1
  147. package/dist/src/ios-snapshot-acquisition.js +1 -1
  148. package/dist/src/ios-snapshot-engine.js +1 -0
  149. package/dist/src/ios-snapshot-runtime.js +1 -1
  150. package/dist/src/lease.js +1 -1
  151. package/dist/src/limrun-download-file.js +1 -1
  152. package/dist/src/limrun-runtime-dependencies.js +1 -1
  153. package/dist/src/limrun.d.ts +16 -3
  154. package/dist/src/linux.js +1 -1
  155. package/dist/src/location-coordinates.js +1 -1
  156. package/dist/src/managed-device-scope.js +1 -1
  157. package/dist/src/mechanics.js +17 -17
  158. package/dist/src/mobile-snapshot-semantics.js +1 -1
  159. package/dist/src/multitouch-support.js +1 -1
  160. package/dist/src/native-build-cache.js +1 -0
  161. package/dist/src/observation.js +1 -1
  162. package/dist/src/overlay.js +3 -0
  163. package/dist/src/parameterized-recorded-fill.js +1 -1
  164. package/dist/src/perf-facade.js +1 -1
  165. package/dist/src/perf-runtime-operation-builder.js +1 -1
  166. package/dist/src/perf-runtime-plan.js +1 -1
  167. package/dist/src/perf-target.js +2 -2
  168. package/dist/src/perf.js +1 -1
  169. package/dist/src/physical-device-control.js +1 -1
  170. package/dist/src/platform-runtime-host.js +1 -1
  171. package/dist/src/platform-runtime-managed-owner.js +1 -1
  172. package/dist/src/platform-runtime-open-target.js +1 -1
  173. package/dist/src/platform-runtime-operation-host.js +4 -4
  174. package/dist/src/platform-runtime-runtime-hints.js +1 -1
  175. package/dist/src/platform-runtime-screen-recording-apple-simulator-host.js +1 -1
  176. package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
  177. package/dist/src/platform-runtime-screen-recording-process-host.js +1 -1
  178. package/dist/src/platform-runtime.js +1 -1
  179. package/dist/src/platform-runtime2.js +1 -1
  180. package/dist/src/png-crop-bytes.js +1 -1
  181. package/dist/src/png-size.js +1 -1
  182. package/dist/src/png-worker-client.js +1 -1
  183. package/dist/src/png.js +1 -1
  184. package/dist/src/prepare-kind.js +1 -1
  185. package/dist/src/provider-session-ownership.js +1 -1
  186. package/dist/src/provider-webdriver.js +1 -1
  187. package/dist/src/proxy.js +1 -1
  188. package/dist/src/quality-warnings.js +1 -1
  189. package/dist/src/react-native.js +1 -1
  190. package/dist/src/record-runtime.js +1 -1
  191. package/dist/src/recording.js +1 -1
  192. package/dist/src/rect-center.js +1 -1
  193. package/dist/src/register-builtins.js +1 -1
  194. package/dist/src/registry.js +36 -36
  195. package/dist/src/remote-config2.js +1 -1
  196. package/dist/src/replay-divergence.js +1 -1
  197. package/dist/src/replay.js +1 -1
  198. package/dist/src/reporting.js +1 -1
  199. package/dist/src/request-admission.js +1 -1
  200. package/dist/src/request-cancel.js +1 -1
  201. package/dist/src/request-runtime-binding.js +1 -1
  202. package/dist/src/retry.js +1 -1
  203. package/dist/src/runner-cache-metadata.js +1 -1
  204. package/dist/src/runner-client.js +1 -1
  205. package/dist/src/runner-dev-tools-security.js +1 -1
  206. package/dist/src/runner-device-readiness.js +1 -1
  207. package/dist/src/runner-disposal.js +1 -1
  208. package/dist/src/runner-error-classification.js +1 -1
  209. package/dist/src/runner.js +1 -1
  210. package/dist/src/runtime-transport-hints.js +1 -1
  211. package/dist/src/runtime.js +1 -3
  212. package/dist/src/runtime10.js +2 -2
  213. package/dist/src/runtime2.js +4 -4
  214. package/dist/src/runtime3.js +1 -1
  215. package/dist/src/runtime4.js +5 -5
  216. package/dist/src/runtime5.js +1 -1
  217. package/dist/src/runtime6.js +1 -1
  218. package/dist/src/runtime7.js +1 -1
  219. package/dist/src/runtime8.js +1 -1
  220. package/dist/src/runtime9.js +1 -1
  221. package/dist/src/screen-recording-admission-ledger.js +1 -1
  222. package/dist/src/screen-recording-completion.js +1 -1
  223. package/dist/src/screen-recording-options.js +1 -1
  224. package/dist/src/screen-recording-resource-recovery.js +1 -1
  225. package/dist/src/screenshot-density.js +1 -1
  226. package/dist/src/screenshot-image.js +1 -1
  227. package/dist/src/screenshot-overlay-draw.js +1 -1
  228. package/dist/src/screenshot-runtime.js +1 -1
  229. package/dist/src/screenshot.js +1 -1
  230. package/dist/src/screenshot3.js +1 -1
  231. package/dist/src/script.js +1 -1
  232. package/dist/src/scroll-command.d.ts +13 -6
  233. package/dist/src/scroll-command.js +1 -1
  234. package/dist/src/scroll-gesture.js +1 -1
  235. package/dist/src/sdk-batch-runner.js +2 -2
  236. package/dist/src/sdk-batch.js +2 -2
  237. package/dist/src/sdk-contracts.d.ts +59 -12
  238. package/dist/src/sdk-contracts.js +2 -2
  239. package/dist/src/sdk-device.js +1 -1
  240. package/dist/src/sdk-finders.d.ts +1 -1
  241. package/dist/src/sdk-io.js +1 -1
  242. package/dist/src/sdk-remote-config.js +1 -1
  243. package/dist/src/sdk-selectors.d.ts +1 -1
  244. package/dist/src/selection.js +0 -0
  245. package/dist/src/selector-runtime.js +1 -1
  246. package/dist/src/server.js +1 -1
  247. package/dist/src/session-allocation.js +1 -1
  248. package/dist/src/session-routing.js +1 -1
  249. package/dist/src/session-runtime-admission.js +1 -1
  250. package/dist/src/session-snapshot.js +1 -1
  251. package/dist/src/session-store.js +1 -1
  252. package/dist/src/session.js +1 -1
  253. package/dist/src/session2.js +4 -4
  254. package/dist/src/settings.js +1 -1
  255. package/dist/src/settings2.js +1 -0
  256. package/dist/src/simctl.js +1 -1
  257. package/dist/src/simulator-state.js +1 -1
  258. package/dist/src/simulator.js +1 -1
  259. package/dist/src/snapshot-capture-annotations.js +1 -1
  260. package/dist/src/snapshot-desktop-projection.js +1 -1
  261. package/dist/src/snapshot-runtime-binding.js +1 -1
  262. package/dist/src/snapshot-runtime.js +1 -1
  263. package/dist/src/snapshot-state.js +1 -1
  264. package/dist/src/snapshot2.js +1 -1
  265. package/dist/src/snapshot3.js +1 -1
  266. package/dist/src/snapshot4.js +1 -1
  267. package/dist/src/src.js +1 -1
  268. package/dist/src/src4.js +1 -1
  269. package/dist/src/src7.js +1 -1
  270. package/dist/src/src8.js +1 -1
  271. package/dist/src/string-enum.js +1 -1
  272. package/dist/src/surface-snapshot.js +1 -1
  273. package/dist/src/takeover.js +1 -1
  274. package/dist/src/text-entry-focus.js +1 -1
  275. package/dist/src/tool-provider-facade.js +1 -1
  276. package/dist/src/tool-provider.js +2 -2
  277. package/dist/src/tool-provider2.js +1 -1
  278. package/dist/src/touch-runtime.js +1 -1
  279. package/dist/src/transport.js +1 -1
  280. package/dist/src/tree.js +1 -1
  281. package/dist/src/tv-remote.js +1 -1
  282. package/dist/src/type-text-runtime.js +1 -1
  283. package/dist/src/verified-file.js +1 -1
  284. package/dist/src/video.js +1 -1
  285. package/dist/src/viewport.js +1 -1
  286. package/dist/src/web.js +1 -1
  287. package/dist/src/web2.js +1 -1
  288. package/dist/src/webdriver-source.js +1 -1
  289. package/package.json +1 -1
  290. package/server.json +2 -2
  291. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.13.apk.sha256 +0 -1
  292. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.13.apk +0 -0
  293. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.13.apk.sha256 +0 -1
  294. package/dist/src/absence-observation-errors.js +0 -1
  295. package/dist/src/runner-presentation.js +0 -1
  296. package/dist/src/semantic-index.js +0 -1
  297. package/dist/src/snapshot-process.js +0 -1
  298. package/dist/src/snapshot-scope.js +0 -1
@@ -1,4 +1,4 @@
1
- import{D as e}from"./sdk-contracts.js";import{d as t}from"./sdk-device.js";import{Qt as n,en 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{A as u,B as d,C as f,D as ee,F as te,G as p,I as m,J as h,M as ne,N as re,R as ie,U as ae,V as g,d as _,h as v,k as oe,n as se,o as ce,q as le,s as ue,v as de,w as y,x as b,z as fe}from"./alert-runtime.js";import{n as pe}from"./audio-probe-runtime.js";import{n as me}from"./perf-runtime.js";import{i as he,n as ge}from"./touch-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 x,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 S}from"./app-log-runtime.js";import{r as ke,t as Ae}from"./application-lifecycle-interaction.js";import{n as je,r as Me,t as Ne}from"./screen-recording-transport.js";import{setTimeout as Pe}from"node:timers/promises";const C=Object.freeze({available:!0}),Fe=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose portable gesture execution yet.`}),Ie=Object.freeze({available:!1,reason:`unsupported-provider-mode`}),Le=Object.freeze({available:!1,reason:`unsupported-provider-mode`}),Re=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:De}),ze=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:Ee});function w(e,t){if(!t.available)return m({unsupported:t});if(e.platform!==`android`)return m({unsupported:Fe});let n=e.target===`tv`;return m({unsupported:Ie,plan:C,directionalFling:C,multiTouch:n?Re:C,targetAuthoredDrag:n?ze:C,viewport:C})}const Be=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose home yet.`}),Ve=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose tv remote control.`}),He=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`tv-remote is supported only on Android TV targets.`}),Ue=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose keyboard actions.`}),We=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose clipboard access yet.`}),Ge=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose settings changes yet.`}),Ke=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose app switcher yet.`}),T=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`No Limrun session exposes this system button.`});function E(e,n){let r=n??C,i=Object.freeze({available:!1,reason:`unsupported-provider-mode`});return Object.freeze({...fe({focus:r}),...u({type:r}),...he({unsupported:i,tap:r,longPress:r,hover:n??i,fill:r,tapElementSelector:n??(t(e)?r:i)}),...w(e,r),...re({scroll:r})})}function qe(e){let{device:t,signal:n}=e,r=n=>e.getInteractor(t,n);return Object.freeze({...ae({device:t,signal:n,resolveInteractor:r,presentIosAcquisition:e.presentIosAcquisition}),...ie({device:t,signal:n,resolveInteractor:r}),...oe({device:t,signal:n,resolveInteractor:r}),...ge({device:t,signal:n,resolveInteractor:r,facts:E(t),pause:async e=>await Pe(e,void 0,{signal:n})}),...le({device:t,signal:n,resolveInteractor:r}),...te({device:t,signal:n,facts:w(t,C),resolveInteractor:r}),...ne({device:t,signal:n,resolveInteractor:r})})}function D(e,t){return t?Object.freeze({...y({back:t}),...f({orientation:t}),...b({tvRemote:t})}):e.platform===`android`?Object.freeze({...y({back:C}),...f({orientation:C}),...b({tvRemote:e.target===`tv`?C:He})}):Object.freeze({...y({back:C}),...f({orientation:C}),...b({tvRemote:Ve})})}function O(e,t){return t?Object.freeze({...v({unsupported:t})}):e.platform===`android`?Object.freeze({...v({unsupported:Le,read:C,write:C})}):Object.freeze({...v({unsupported:We})})}const Je=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:Je);return Object.freeze({...se({read:n,wait:n,accept:n,dismiss:n})})}function A(e,t){return t?_({unsupported:t}):e.platform===`android`?_({unsupported:T,home:C,appSwitcher:C}):_({unsupported:T,home:Be,appSwitcher:Ke})}const j=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`fold runs a HID helper through simctl spawn inside a foldable iPhone simulator on the daemon host; a Limrun session has no such simulator.`});function M(){return Object.freeze({setFoldPose:j})}function N(e,t){return Object.freeze({...ue({triggerAppEvent:t??C})})}function P(e,t){let n=t??(e.platform===`android`?C:Ge);return Object.freeze({...ce({setSetting:n,readSetting:n})})}function F(e,t){let n=t??Ue,r=t===void 0&&e.platform===`android`;return Object.freeze({...de(r?{unsupported:n,status:C,dismiss:C,enter:C}:{unsupported:n})})}const I=Object.freeze({resourceKind:S,version:1,encode:e=>({...e}),decode:e=>e.transport!==`limrun-log-poller`||e.platform!==`ios`&&e.platform!==`android`||!L(e.leaseId)||!L(e.instanceId)||!L(e.appBundleId)||!L(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 Ye(e){if(e.device.platform===`apple`&&!e.device.appleOs)throw TypeError(`Limrun Apple app-log persistence requires an explicit appleOs identity`);return ye({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:ve(I,e.descriptor)})}function L(e){return typeof e==`string`&&e.trim().length>0}async function R(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=Xe(e,i,tt(r));return n=!0,a}finally{await t[Symbol.asyncDispose]()}}function Xe(e,t,n){let r=rt(e.reader),i=e.host.clock.now(),a=`active`,o=!1,s=n,c=(async()=>{for(;!o;){try{let n=await Ze(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(`
1
+ import{A as e}from"./sdk-contracts.js";import{d as t}from"./sdk-device.js";import{Qt as n,en 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{A as u,B as d,C as f,D as ee,F as te,G as p,I as m,J as h,M as ne,N as re,R as ie,U as ae,V as g,d as _,h as v,k as oe,n as se,o as ce,q as le,s as ue,v as de,w as y,x as b,z as fe}from"./alert-runtime.js";import{n as pe}from"./audio-probe-runtime.js";import{n as me}from"./perf-runtime.js";import{i as he,n as ge}from"./touch-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 x,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 S}from"./app-log-runtime.js";import{r as ke,t as Ae}from"./application-lifecycle-interaction.js";import{n as je,r as Me,t as Ne}from"./screen-recording-transport.js";import{setTimeout as Pe}from"node:timers/promises";const C=Object.freeze({available:!0}),Fe=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose portable gesture execution yet.`}),Ie=Object.freeze({available:!1,reason:`unsupported-provider-mode`}),Le=Object.freeze({available:!1,reason:`unsupported-provider-mode`}),Re=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:De}),ze=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:Ee});function w(e,t){if(!t.available)return m({unsupported:t});if(e.platform!==`android`)return m({unsupported:Fe});let n=e.target===`tv`;return m({unsupported:Ie,plan:C,directionalFling:C,multiTouch:n?Re:C,targetAuthoredDrag:n?ze:C,viewport:C})}const Be=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose home yet.`}),Ve=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose tv remote control.`}),He=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`tv-remote is supported only on Android TV targets.`}),Ue=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose keyboard actions.`}),We=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose clipboard access yet.`}),Ge=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose settings changes yet.`}),Ke=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose app switcher yet.`}),T=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`No Limrun session exposes this system button.`});function E(e,n){let r=n??C,i=Object.freeze({available:!1,reason:`unsupported-provider-mode`});return Object.freeze({...fe({focus:r}),...u({type:r}),...he({unsupported:i,tap:r,longPress:r,hover:n??i,fill:r,tapElementSelector:n??(t(e)?r:i)}),...w(e,r),...re({scroll:r})})}function qe(e){let{device:t,signal:n}=e,r=n=>e.getInteractor(t,n);return Object.freeze({...ae({device:t,signal:n,resolveInteractor:r,presentIosAcquisition:e.presentIosAcquisition}),...ie({device:t,signal:n,resolveInteractor:r}),...oe({device:t,signal:n,resolveInteractor:r}),...ge({device:t,signal:n,resolveInteractor:r,facts:E(t),pause:async e=>await Pe(e,void 0,{signal:n})}),...le({device:t,signal:n,resolveInteractor:r}),...te({device:t,signal:n,facts:w(t,C),resolveInteractor:r}),...ne({device:t,signal:n,resolveInteractor:r})})}function D(e,t){return t?Object.freeze({...y({back:t}),...f({orientation:t}),...b({tvRemote:t})}):e.platform===`android`?Object.freeze({...y({back:C}),...f({orientation:C}),...b({tvRemote:e.target===`tv`?C:He})}):Object.freeze({...y({back:C}),...f({orientation:C}),...b({tvRemote:Ve})})}function O(e,t){return t?Object.freeze({...v({unsupported:t})}):e.platform===`android`?Object.freeze({...v({unsupported:Le,read:C,write:C})}):Object.freeze({...v({unsupported:We})})}const Je=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:Je);return Object.freeze({...se({read:n,wait:n,accept:n,dismiss:n})})}function A(e,t){return t?_({unsupported:t}):e.platform===`android`?_({unsupported:T,home:C,appSwitcher:C}):_({unsupported:T,home:Be,appSwitcher:Ke})}const j=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`fold runs a HID helper through simctl spawn inside a foldable iPhone simulator on the daemon host; a Limrun session has no such simulator.`});function M(){return Object.freeze({setFoldPose:j})}function N(e,t){return Object.freeze({...ue({triggerAppEvent:t??C})})}function P(e,t){let n=t??(e.platform===`android`?C:Ge);return Object.freeze({...ce({setSetting:n,readSetting:n})})}function F(e,t){let n=t??Ue,r=t===void 0&&e.platform===`android`;return Object.freeze({...de(r?{unsupported:n,status:C,dismiss:C,enter:C}:{unsupported:n})})}const I=Object.freeze({resourceKind:S,version:1,encode:e=>({...e}),decode:e=>e.transport!==`limrun-log-poller`||e.platform!==`ios`&&e.platform!==`android`||!L(e.leaseId)||!L(e.instanceId)||!L(e.appBundleId)||!L(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 Ye(e){if(e.device.platform===`apple`&&!e.device.appleOs)throw TypeError(`Limrun Apple app-log persistence requires an explicit appleOs identity`);return ye({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:ve(I,e.descriptor)})}function L(e){return typeof e==`string`&&e.trim().length>0}async function R(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=Xe(e,i,tt(r));return n=!0,a}finally{await t[Symbol.asyncDispose]()}}function Xe(e,t,n){let r=rt(e.reader),i=e.host.clock.now(),a=`active`,o=!1,s=n,c=(async()=>{for(;!o;){try{let n=await Ze(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
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 nt([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 Ze(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=$e(t),r=Math.min(e.length,t.length),i=e.slice(e.length-r);return t.slice(et(i,t,n))}function $e(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 et(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 tt(e){return e.split(`
3
3
  `).filter(e=>!e.startsWith(`[agent-device][mark]`)).join(`
4
4
  `)}async function nt(e){return(await Promise.allSettled(e.map(async e=>await e[Symbol.asyncDispose]()))).flatMap(e=>e.status===`rejected`?[e.reason]:[])}function rt(e){return e.platform===`ios`?`ios-simulator`:`android`}function it(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(at(e,n)),openApplication:async e=>await t.openApplication(ot(e,n)),closeApplication:async e=>await t.closeApplication(st(e,n))}):t}function at(e,t){return e.target===void 0?e:{...e,target:t(e.target)}}function ot(e,t){return{...e,target:B(e.target,t),positionals:z(e.positionals,t),appBundleId:B(e.appBundleId,t)}}function st(e,t){return{...e,positionals:z(e.positionals,t),appBundleId:B(e.appBundleId,t)}}function z(e,t){let n=e[0];return n===void 0?e:[t(n),...e.slice(1)]}function B(e,t){return e===void 0?void 0:t(e)}function ct(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 lt=Object.freeze({available:!0}),V=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`The Limrun provider session is no longer active for this device.`}),ut=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Push notifications are unavailable for Limrun provider-owned devices.`});function H(e,t){let n=ft(e,t);return Object.freeze({deployApp:n,materializeAppSource:n,deployMaterializedApp:n,sendPushNotification:U(e,t)?ut:V})}function dt(e,t,n,r){let i=e.deployApp,a=e.deployMaterializedApp;return!H(e,t).deployApp.available||!i||!a?Object.freeze({}):Object.freeze({deployApp:async e=>W(await i(t,e,n,r)),materializeAppSource:async r=>await pt(e.host,t,r,n),deployMaterializedApp:async e=>W(await a(t,e,n,r))})}function ft(e,t){return ct(t)&&U(e,t)&&e.deployApp&&e.deployMaterializedApp?lt:V}function U(e,t){return e.isSessionActive?.(t)??e.ownsDevice(t)}async function pt(e,t,n,r){return await(t.platform===`apple`?e.appleDeployment:e.androidDeployment).prepareArtifact(n,{signal:r})}function W(t){if(!t)throw new e(`UNSUPPORTED_OPERATION`,`The Limrun provider session is no longer active.`);return t}const mt=Object.freeze({medium:5,high:8});function ht(e){return Object.freeze({screenRecordingStart:async t=>await gt(e,t),screenRecordingReattach:async()=>Me(`Limrun recordings cannot be reattached after daemon restart.`),screenRecordingCleanup:async()=>je(`Limrun recordings cannot be cleaned after daemon restart; the instance disposes them when it terminates.`)})}async function gt(t,n){let r=t.getDeviceSession(t.device);if(!r)throw new e(`UNSUPPORTED_OPERATION`,`Limrun recording requires a live provider session for this device.`,{deviceId:t.device.id});return await Ne({host:t.host,device:t.device,owner:t.owner,input:n,signal:t.signal,transport:{backend:`limrun-recorder`,targetLabel:`Limrun recording`,start:async()=>{await r.startRecording({quality:mt[n.exportQuality??`medium`]})},stop:async()=>(await r.stopRecording()).downloadUrl,collect:async(e,t)=>{await r.downloadRecording({downloadUrl:e,outPath:t})}},support:{scopes:[`app`,`device`,`system`],fps:!1,exportQuality:!0,hideTouches:!1},unsupported:e=>`Limrun recordings do not support ${e.join(`, `)}`})}const G=Object.freeze({available:!0}),K=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Custom snapshot actions are available only for Limrun iOS simulator sessions.`}),_t=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun does not expose viewport resizing.`}),q=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun-owned devices read element text from the captured tree only.`}),vt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Headless boot is unavailable for provider-owned devices.`}),J=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`Limrun requires a matching live provider session for this device.`}),yt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Apple runner preparation is unavailable for Limrun-owned devices.`}),bt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS appstate is session-owned; no sessionless provider foreground probe is exposed.`}),xt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun open requires a Limrun-owned iOS simulator or Android emulator.`}),St=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun close requires a Limrun-owned iOS simulator or Android emulator.`}),Y=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Runtime hints are not applied to provider-owned devices.`}),Ct=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun port reverse requires an active Android Limrun session.`}),wt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun does not expose the audio probe.`});function Tt(e){return{...e,isSessionActive:e.hasLiveSession}}function X(e,t){let n=Et(e,t),r=Dt(e,t),i=Ot(e,t);return l({resolveOpenTarget:n,prepareApplicationOpen:n,openApplication:n,applyRuntimeHints:Y,clearRuntimeHints:Y,closeApplication:r,finalizeApplicationClose:r,prepareAppleRunner:yt,configureProviderPortReverse:i})}function Et(e,t){return a(e)?t?G:J:xt}function Dt(e,t){return a(e)?t?G:J:St}function Ot(e,t){return t?e.platform===`android`?G:Ct:J}function Z(e,n){let r=H(Tt(e),n),i=n.platform===`android`,a=t(n)&&n.kind===`simulator`?G:K;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:G,appLogDoctor:G,appLogStart:G,appLogReattach:G,appLogCleanup:G,...r,appState:i?G:bt,networkDump:G,screenRecordingStart:G,screenRecordingReattach:G,screenRecordingCleanup:G,...p({capture:G,customActions:a,withoutActiveApp:G}),...h({capture:G}),...g({findText:K}),...d({setViewport:_t}),...E(n),...ee({readTextAtPoint:q}),...D(n),...F(n),...O(n),...A(n),...M(),...N(n),...P(n),...k(n),...pe({capture:wt,query:wt}),...me({frames:q,memorySample:q,memorySnapshot:q,nativeCapture:q,profileReport:q}),ensureReady:G,bootTarget:G,bootTargetHeadless:vt,listApps:G,shutdownTarget:{available:!1,reason:`unsupported-provider-mode`,hint:`Limrun owns the target lifecycle for provider-owned devices.`},...X(n,!0)}})}function kt(e,t){let n=Z(e,t);return Object.freeze({device:n.device,operations:{...n.operations,appLogInspect:J,appLogDoctor:J,appLogStart:J,appLogReattach:G,appLogCleanup:G,appState:J,networkDump:J,screenRecordingStart:J,screenRecordingReattach:J,screenRecordingCleanup:J,...p({capture:J,customActions:J,withoutActiveApp:J}),...h({capture:J}),...g({findText:J}),...d({setViewport:J}),...E(t,J),...D(t,J),...F(t,J),...O(t,J),...A(t,J),...M(),...N(t,J),...P(t,J),...k(t,J),ensureReady:J,bootTarget:J,bootTargetHeadless:J,listApps:J,deployApp:J,materializeAppSource:J,deployMaterializedApp:J,sendPushNotification:J,shutdownTarget:J,...X(t,!1)}})}function At(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:J,appState:J,appDeployment:J,network:J,screenshot:J,viewport:J,focus:J,gesture:J,scroll:J,typeText:J,touch:J,elementText:J,back:J,orientation:J,tvRemote:J,keyboard:J,clipboard:J,systemButton:J,fold:j,triggerAppEvent:J,settings:J,readAlert:J,awaitAlert:J,acceptAlert:J,dismissAlert:J,audioProbeCapture:J,audioProbeQuery:J,perf:J,readiness:J,shutdown:J,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 jt(t,i,n.device,n.scope.signal,!o)},shutdown:async()=>void 0})}function jt(t,n,r,i,a){let s=a?kt(t,r):Z(t,r),l=o(),u=xe({codec:I,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 R({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 Mt(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=Ye({sessionId:a.sessionId,device:r,owner:n,fence:a.fence,descriptor:s});c=!0;let l=await R({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(it({device:r,signal:i,getInteractor:t.getInteractor,resolveAppReference:e=>t.resolveAppReference?.(r,e)??e,configurePortReverse:t.configurePortReverse}),s.operations),...qe({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}),...dt(Tt(t),r,i,l),...ht({host:t.host,device:r,owner:n,signal:i,getDeviceSession:t.getDeviceSession})};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 Mt(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{At as createLimrunPlatformRuntimeOwner};
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime.js";import{D as t}from"./sdk-contracts.js";import{i as n}from"./sdk-batch-runner.js";import{d as r,f 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{a as f}from"./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
- `)){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};
1
+ import{r as e}from"./rolldown-runtime.js";import{A as t}from"./sdk-contracts.js";import{i as n}from"./sdk-batch-runner.js";import{d as r,f as i}from"./sdk-device.js";import{g as a}from"./settings.js";import{t as o}from"./ttl-memo.js";import{t as s}from"./app-resolution-cache.js";import{u as c}from"./host-file.js";import{a as l,i as u,l as d}from"./tool-provider.js";import{t as f}from"./physical-device-control.js";import{a as p}from"./simctl.js";import{n as m}from"./helper.js";import h from"node:path";import{fileURLToPath as g}from"node:url";import{setTimeout as _}from"node:timers/promises";const v={settings:`com.apple.systempreferences`},y=/^[a-z0-9-]+(?:\.[a-z0-9-]+)+$/,b={platform:`macos`,deviceId:`host`,variant:`all`},x=s();function S(e){return y.test(e)}async function C(e){let n=e.trim(),r=v[n.toLowerCase()];if(r)return r;if(S(n))return n;let i=x.get(b,n);if(i)return i;let a=(await A(`all`)).filter(e=>e.name.toLowerCase()===n.toLowerCase()),o=a[0];if(o!==void 0&&a.length===1)return x.set(b,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 w(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 C(r);await j().openBundle(e,a);return}let o=r.trim();if(n(o)){await j().openTarget(o);return}let s=i?.appBundleId??await C(o);await j().openBundle(s)}async function T(e,n){let r=await C(n),i=await m(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 _(100),!(await m(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 E(){return await j().readClipboard()}async function D(e){await j().writeClipboard(e)}async function O(){return await j().readDarkMode()}async function k(e){let t=a(e),n=t===`toggle`?!await O():t===`dark`;await j().setDarkMode(n)}async function A(e){return await j().listApps(e)}function j(){let e=u().macosHost;if(!e)throw new t(`UNSUPPORTED_OPERATION`,`macOS host provider is not available`);return e}function M(e){return new t(`APP_NOT_INSTALLED`,`No app found matching "${e}"`)}var N=e({buildAppNotInstalledError:()=>M,detectSoleRunningIosSimulatorApp:()=>U,findIosSimulatorInstalledApp:()=>z,invalidateIosAppResolutionCache:()=>L,listIosApps:()=>q,resolveIosApp:()=>R,resolveIosAppAlias:()=>B,resolveIosSimulatorDeepLinkBundleId:()=>G});const P={settings:`com.apple.Preferences`},F=s();function I(e){return{platform:`ios`,deviceId:e.id,variant:e.kind}}async function L(e,t){return await F.invalidateWhile(I(e),t)}async function R(e,n){if(i(e))return await C(n);let r=n.trim();if(r.includes(`.`))return r;let a=B(r);if(a!==r)return a;let o=I(e),s=F.get(o,r);if(s)return s;let c=(e.kind===`simulator`?await J(e):await f(e).listApps(e,`all`)).filter(e=>e.name.toLowerCase()===r.toLowerCase()),l=c[0];if(l!==void 0&&c.length===1)return F.set(o,r,l.bundleId);throw c.length>1?new t(`INVALID_ARGS`,`Multiple apps matched "${n}"`,{matches:c}):M(n)}async function z(e,t){if(!r(e)||e.kind!==`simulator`||e.booted!==!0)return;let n=B(t.trim());if(!n)return;let i=await J(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 B(e){let t=e.trim();return P[t.toLowerCase()]??e}const V=3e3,H=/UIKitApplication:([^[\s]+)\[/;async function U(e){if(!(!r(e)||e.kind!==`simulator`||e.booted!==!0))try{let[t,n]=await Promise.all([W(e),J(e,{timeoutMs:V})]);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 W(e){let t=await p(e,[`spawn`,e.id,`launchctl`,`list`],{allowFailure:!0,timeoutMs:V});if(t.exitCode!==0)return[];let n=[];for(let e of t.stdout.split(`
2
+ `)){let t=H.exec(e);t?.[1]&&n.push(t[1])}return n}async function G(e,t){if(!r(e)||e.kind!==`simulator`)return;let n=K(t);if(!n)return;let i=await Y(e),a=[];for(let e of i)e.bundleId.startsWith(`com.callstack.agentdevice.runner`)||e.path&&(await Q(h.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 K(e){return/^([A-Za-z][A-Za-z0-9+.-]*):/.exec(e.trim())?.[1]?.toLowerCase()}async function q(e,t){if(i(e))return await A(t);if(e.kind===`simulator`){let n=await J(e);return d(n,t)}return await f(e).listApps(e,t)}async function J(e,t){return(await Y(e,t)).map(e=>({bundleId:e.bundleId,name:e.name}))}async function Y(e,t){let n=(await p(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 l(`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=X(t);return{bundleId:e,name:t.CFBundleDisplayName??t.CFBundleName??e,...n?{path:n}:{},...t.ApplicationType?{applicationType:t.ApplicationType}:{}}}):[]}function X(e){if(e.Path)return e.Path;if(e.Bundle)try{return g(e.Bundle)}catch{return}}const Z=o({ttlMs:18e5,scheduleExpiry:!0});async function Q(e){let t;try{t=`${e}:${(await c(e)).mtimeMs}`}catch{t=void 0}if(t===void 0)return await $(e)??new Set;let n=Z.get(t);if(n)return n;let r=await $(e);return r&&Z.set(t,r),r??new Set}async function $(e){let t=await l(`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{R as a,M as c,E as d,k as f,L as i,T as l,U as n,B as o,D as p,z as r,G as s,N as t,w as u};
@@ -1 +1 @@
1
- import{D as e}from"./sdk-contracts.js";import{f as t,l as n,w as r,x as i}from"./sdk-device.js";const a=3e4,o={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 s(r){if(!n(r.platform))throw new e(`UNSUPPORTED_PLATFORM`,`Unsupported platform for Apple runner: ${r.platform}`);return t(r)?`macOS`:i(r.target,r.appleOs)}function c(e){if(!n(e.platform))return{handoff:!1,reason:`non_apple_target`};if(e.kind===`simulator`)return{handoff:!0,lane:`simulator`};if(t(e))return{handoff:!1,reason:`macos_host`};let i=r(e);return i!==`ios`&&i!==`ipados`?{handoff:!1,reason:`physical_non_ios_os`}:e.iosPhysicalDeviceBackend===`xctest`?{handoff:!1,reason:`xctest_backend`}:{handoff:!0,lane:`physical_coredevice`}}function l(e,t){return o[e].sdkName[h(t)]}function u(e){return o[s(e)].derivedBaseName[h(e.kind)]}function d(e){return o[s(e)].xctestrunHints[h(e.kind)]}function f(e){let t=s(e);return t===`macOS`?`platform=macOS,arch=${g()}`:e.kind===`simulator`?`platform=${t} Simulator,id=${e.id}`:`platform=${t},id=${e.id}`}function p(e){let t=s(e);return t===`macOS`?`platform=macOS,arch=${g()}`:e.kind===`simulator`?`platform=${t} Simulator,id=${e.id}`:`generic/platform=${t}`}function m(e){let t=s(e);return t===`macOS`?`platform=macOS,arch=${g()}`:e.kind===`simulator`?`generic/platform=${t} Simulator`:`generic/platform=${t}`}function h(e){return e===`simulator`?`simulator`:`device`}function g(){return process.arch===`arm64`?`arm64`:`x86_64`}export{f as a,l as c,u as i,d as l,p as n,c as o,m as r,s,a as t};
1
+ import{A as e}from"./sdk-contracts.js";import{f as t,l as n,w as r,x as i}from"./sdk-device.js";const a=3e4,o={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 s(r){if(!n(r.platform))throw new e(`UNSUPPORTED_PLATFORM`,`Unsupported platform for Apple runner: ${r.platform}`);return t(r)?`macOS`:i(r.target,r.appleOs)}function c(e){if(!n(e.platform))return{handoff:!1,reason:`non_apple_target`};if(e.kind===`simulator`)return{handoff:!0,lane:`simulator`};if(t(e))return{handoff:!1,reason:`macos_host`};let i=r(e);return i!==`ios`&&i!==`ipados`?{handoff:!1,reason:`physical_non_ios_os`}:e.iosPhysicalDeviceBackend===`xctest`?{handoff:!1,reason:`xctest_backend`}:{handoff:!0,lane:`physical_coredevice`}}function l(e,t){return o[e].sdkName[h(t)]}function u(e){return o[s(e)].derivedBaseName[h(e.kind)]}function d(e){return o[s(e)].xctestrunHints[h(e.kind)]}function f(e){let t=s(e);return t===`macOS`?`platform=macOS,arch=${g()}`:e.kind===`simulator`?`platform=${t} Simulator,id=${e.id}`:`platform=${t},id=${e.id}`}function p(e){let t=s(e);return t===`macOS`?`platform=macOS,arch=${g()}`:e.kind===`simulator`?`platform=${t} Simulator,id=${e.id}`:`generic/platform=${t}`}function m(e){let t=s(e);return t===`macOS`?`platform=macOS,arch=${g()}`:e.kind===`simulator`?`generic/platform=${t} Simulator`:`generic/platform=${t}`}function h(e){return e===`simulator`?`simulator`:`device`}function g(){return process.arch===`arm64`?`arm64`:`x86_64`}export{f as a,l as c,u as i,d as l,p as n,c as o,m as r,s,a as t};
@@ -1 +1 @@
1
- import{D as e}from"./sdk-contracts.js";import{i as t}from"./sdk-batch-runner.js";import{d 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{A as e}from"./sdk-contracts.js";import{i as t}from"./sdk-batch-runner.js";import{d 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{D as i}from"./sdk-contracts.js";import{t as a}from"./yauzl.js";import o from"node:path";import{createReadStream as s,createWriteStream as c,promises as l}from"node:fs";import{pipeline as u}from"node:stream/promises";import{createGunzip as d}from"node:zlib";const f=2147483648;var p=class{maxBytes;maxEntries;maxDepth;#e=0;#t=0;constructor(e={}){this.maxBytes=b(e.maxBytes??4294967296,`maxBytes`),this.maxEntries=b(e.maxEntries??1e5,`maxEntries`),this.maxDepth=b(e.maxDepth??3,`maxDepth`)}get bytes(){return this.#e}get entries(){return this.#t}preflightArchive(e){let t=b(e.depth,`depth`),n=b(e.entryCount,`entryCount`),r=b(e.declaredBytes,`declaredBytes`);if(t<1||t>this.maxDepth)throw y(`ARCHIVE_NESTING_LIMIT`,`Archive nesting depth exceeds the limit`);if(n>this.maxEntries-this.#t)throw y(`ARCHIVE_ENTRY_LIMIT`,`Archive contains too many entries`);if(r>this.maxBytes-this.#e)throw y(`ARCHIVE_EXPANDED_BYTES_LIMIT`,`Archive expands beyond the byte limit`);return new m(e=>this.#n(e),()=>this.#r(),e.entryCount,e.declaredBytes)}#n(e){let t=b(e,`bytes`);if(t>this.maxBytes-this.#e)throw y(`ARCHIVE_EXPANDED_BYTES_LIMIT`,`Archive expands beyond the byte limit`);this.#e+=t}#r(){if(this.#t>=this.maxEntries)throw y(`ARCHIVE_ENTRY_LIMIT`,`Archive contains too many entries`);this.#t+=1}},m=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=b(e,`bytes`);if(t>this.#r-this.#a)throw y(`ARCHIVE_MANIFEST_MISMATCH`,`Archive contents changed after inspection`);this.#e(t),this.#a+=t}commitEntry(){if(this.#i>=this.#n)throw y(`ARCHIVE_MANIFEST_MISMATCH`,`Archive contents changed after inspection`);this.#t(),this.#i+=1}finish(){if(this.#i!==this.#n||this.#a!==this.#r)throw y(`ARCHIVE_MANIFEST_MISMATCH`,`Archive contents changed after inspection`)}};function h(e,t,n){return e.preflightArchive({depth:t,entryCount:n.length,declaredBytes:n.reduce((e,t)=>e+t.size,0)})}function g(e,t){return e.name===t.name&&e.kind===t.kind&&e.size===t.size&&e.mode===t.mode}function _(e){if(!e||e.includes(`\0`)||e.includes(`\\`)||o.posix.isAbsolute(e)||/^[a-zA-Z]:/.test(e)||e.startsWith(`//`))throw y(`ARCHIVE_UNSAFE_PATH`,`Archive contains an unsafe entry path`);let t=o.posix.normalize(e).replace(/^(\.\/)+/,``).replace(/\/$/,``);if(!t||t===`.`||t===`..`||t.startsWith(`../`))throw y(`ARCHIVE_UNSAFE_PATH`,`Archive contains an unsafe entry path`);return t}function v(e,t){let n=_(t),r=o.resolve(e),i=o.resolve(r,...n.split(`/`));if(!i.startsWith(`${r}${o.sep}`))throw y(`ARCHIVE_UNSAFE_PATH`,`Archive entry escapes the extraction root`);return i}function y(e,t,n){return new i(`INVALID_ARGS`,t,{reason:e},n)}function b(e,t){if(!Number.isSafeInteger(e)||e<0)throw RangeError(`${t} must be a non-negative safe integer`);return e}var x=r(((e,n)=>{n.exports=t(`events`)})),S=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}}})),C=r(((e,t)=>{let n=S();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}}})),w=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 ee(e,t){return b(e).readInt32LE(t)}function O(e,t){return b(e).readUInt32BE(t)}function k(e,t){return b(e).readUInt32LE(t)}function A(e,t,n){return b(e).writeDoubleBE(t,n)}function j(e,t,n){return b(e).writeDoubleLE(t,n)}function M(e,t,n){return b(e).writeFloatBE(t,n)}function N(e,t,n){return b(e).writeFloatLE(t,n)}function P(e,t,n){return b(e).writeInt32BE(t,n)}function F(e,t,n){return b(e).writeInt32LE(t,n)}function I(e,t,n){return b(e).writeUInt32BE(t,n)}function L(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:ee,readUInt32BE:O,readUInt32LE:k,writeDoubleBE:A,writeDoubleLE:j,writeFloatBE:M,writeFloatLE:N,writeInt32BE:P,writeInt32LE:F,writeUInt32BE:I,writeUInt32LE:L}})),T=r(((e,t)=>{let n=w();t.exports=class{constructor(e){this.encoding=e}get remaining(){return 0}decode(e){return n.toString(e,this.encoding)}flush(){return``}}})),E=r(((e,t)=>{let n=w();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}})),D=r(((e,t)=>{let n=T(),r=E();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)}}})),ee=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}=x(),r=C(),i=D(),a=ee(),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,b=32<<18,S=64<<18,w=128<<18,T=512<<18,E=1024<<18,O=503316479,k=268435455,A=262160,j=8404992,M=8405006,N=33587200,P=33587215,F=16527,I=270794767,L=Symbol.asyncIterator||Symbol(`asyncIterator`);var R=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=H.bind(this),this.afterUpdateNextTick=W.bind(this)}get ending(){return!!(this.stream._duplexState&T)}get ended(){return!!(this.stream._duplexState&b)}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&I)==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&I)==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(re.bind(this));return}if((e._duplexState&14)==4){e._duplexState&N||(e._duplexState|=A,e._destroy(V.bind(this)));return}(e._duplexState&P)==1&&(e._duplexState=(e._duplexState|A)&s,e._open(G.bind(this)))}continueUpdate(){return this.stream._duplexState&w?(this.stream._duplexState&=O,!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))}},z=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=U.bind(this),this.afterUpdateNextTick=ie.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 B(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`,ne.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&F)==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&F)==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&M)==j&&(e._duplexState|=4),this.pipeTo!==null&&this.pipeTo.end()),(e._duplexState&14)==4){e._duplexState&N||(e._duplexState|=A,e._destroy(V.bind(this)));return}(e._duplexState&P)==1&&(e._duplexState=(e._duplexState|A)&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))}},te=class{constructor(e){this.data=null,this.afterTransform=K.bind(e),this.afterFinal=null}},B=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 ne(){this.stream._duplexState|=512,this.updateCallback()}function re(e){let t=this.stream;e&&t.destroy(e),t._duplexState&14||(t._duplexState|=b,t.emit(`finish`)),(t._duplexState&M)==j&&(t._duplexState|=4),t._duplexState&=402391039,t._duplexState&_?this.updateNextTick():this.update()}function V(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 H(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&S)==S&&t.emit(`drain`)),this.updateCallback()}function U(e){e&&this.stream.destroy(e),this.stream._duplexState&=536870895,this.readAhead===!1&&!(this.stream._duplexState&256)&&(this.stream._duplexState&=g),this.updateCallback()}function ie(){this.stream._duplexState&32||(this.stream._duplexState&=h,this.update())}function W(){this.stream._duplexState&_||(this.stream._duplexState&=O,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 K(e,t){t!=null&&this.push(t),this._writableState.afterWrite(e)}function q(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|=S,this._writableState.updateNextTick())}var J=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`,q)}_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())}},Y=class e extends J{constructor(e){super(e),this._duplexState|=8519681,this._readableState=new z(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[L])return this._fromAsyncIterator(t[L](),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)}[L](){let e=this,t=null,n=null,r=null;return this.on(`error`,e=>{t=e}),this.on(`readable`,i),this.on(`close`,o),{[L](){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})})})}}},oe=class extends J{constructor(e){super(e),this._duplexState|=16385,this._writableState=new R(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|=E}uncork(){this._duplexState&=k,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 Y{constructor(e){super(e),this._duplexState=1|this._duplexState&f,this._writableState=new R(this,e),e&&(e.writev&&(this._writev=e.writev),e.write&&(this._write=e.write),e.final&&(this._final=e.final))}cork(){this._duplexState|=E}uncork(){this._duplexState&=k,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 te(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&N)}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!==oe.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:J,Writable:oe,Readable:Y,Duplex:X,Transform:se,PassThrough:ce}})),k=r((e=>{let t=w(),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{A as i}from"./sdk-contracts.js";import{t as a}from"./yauzl.js";import o from"node:path";import{createReadStream as s,createWriteStream as c,promises as l}from"node:fs";import{pipeline as u}from"node:stream/promises";import{createGunzip as d}from"node:zlib";const f=2147483648;var p=class{maxBytes;maxEntries;maxDepth;#e=0;#t=0;constructor(e={}){this.maxBytes=b(e.maxBytes??4294967296,`maxBytes`),this.maxEntries=b(e.maxEntries??1e5,`maxEntries`),this.maxDepth=b(e.maxDepth??3,`maxDepth`)}get bytes(){return this.#e}get entries(){return this.#t}preflightArchive(e){let t=b(e.depth,`depth`),n=b(e.entryCount,`entryCount`),r=b(e.declaredBytes,`declaredBytes`);if(t<1||t>this.maxDepth)throw y(`ARCHIVE_NESTING_LIMIT`,`Archive nesting depth exceeds the limit`);if(n>this.maxEntries-this.#t)throw y(`ARCHIVE_ENTRY_LIMIT`,`Archive contains too many entries`);if(r>this.maxBytes-this.#e)throw y(`ARCHIVE_EXPANDED_BYTES_LIMIT`,`Archive expands beyond the byte limit`);return new m(e=>this.#n(e),()=>this.#r(),e.entryCount,e.declaredBytes)}#n(e){let t=b(e,`bytes`);if(t>this.maxBytes-this.#e)throw y(`ARCHIVE_EXPANDED_BYTES_LIMIT`,`Archive expands beyond the byte limit`);this.#e+=t}#r(){if(this.#t>=this.maxEntries)throw y(`ARCHIVE_ENTRY_LIMIT`,`Archive contains too many entries`);this.#t+=1}},m=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=b(e,`bytes`);if(t>this.#r-this.#a)throw y(`ARCHIVE_MANIFEST_MISMATCH`,`Archive contents changed after inspection`);this.#e(t),this.#a+=t}commitEntry(){if(this.#i>=this.#n)throw y(`ARCHIVE_MANIFEST_MISMATCH`,`Archive contents changed after inspection`);this.#t(),this.#i+=1}finish(){if(this.#i!==this.#n||this.#a!==this.#r)throw y(`ARCHIVE_MANIFEST_MISMATCH`,`Archive contents changed after inspection`)}};function h(e,t,n){return e.preflightArchive({depth:t,entryCount:n.length,declaredBytes:n.reduce((e,t)=>e+t.size,0)})}function g(e,t){return e.name===t.name&&e.kind===t.kind&&e.size===t.size&&e.mode===t.mode}function _(e){if(!e||e.includes(`\0`)||e.includes(`\\`)||o.posix.isAbsolute(e)||/^[a-zA-Z]:/.test(e)||e.startsWith(`//`))throw y(`ARCHIVE_UNSAFE_PATH`,`Archive contains an unsafe entry path`);let t=o.posix.normalize(e).replace(/^(\.\/)+/,``).replace(/\/$/,``);if(!t||t===`.`||t===`..`||t.startsWith(`../`))throw y(`ARCHIVE_UNSAFE_PATH`,`Archive contains an unsafe entry path`);return t}function v(e,t){let n=_(t),r=o.resolve(e),i=o.resolve(r,...n.split(`/`));if(!i.startsWith(`${r}${o.sep}`))throw y(`ARCHIVE_UNSAFE_PATH`,`Archive entry escapes the extraction root`);return i}function y(e,t,n){return new i(`INVALID_ARGS`,t,{reason:e},n)}function b(e,t){if(!Number.isSafeInteger(e)||e<0)throw RangeError(`${t} must be a non-negative safe integer`);return e}var x=r(((e,n)=>{n.exports=t(`events`)})),S=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}}})),C=r(((e,t)=>{let n=S();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}}})),w=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 ee(e,t){return b(e).readInt32LE(t)}function O(e,t){return b(e).readUInt32BE(t)}function k(e,t){return b(e).readUInt32LE(t)}function A(e,t,n){return b(e).writeDoubleBE(t,n)}function j(e,t,n){return b(e).writeDoubleLE(t,n)}function M(e,t,n){return b(e).writeFloatBE(t,n)}function N(e,t,n){return b(e).writeFloatLE(t,n)}function P(e,t,n){return b(e).writeInt32BE(t,n)}function F(e,t,n){return b(e).writeInt32LE(t,n)}function I(e,t,n){return b(e).writeUInt32BE(t,n)}function L(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:ee,readUInt32BE:O,readUInt32LE:k,writeDoubleBE:A,writeDoubleLE:j,writeFloatBE:M,writeFloatLE:N,writeInt32BE:P,writeInt32LE:F,writeUInt32BE:I,writeUInt32LE:L}})),T=r(((e,t)=>{let n=w();t.exports=class{constructor(e){this.encoding=e}get remaining(){return 0}decode(e){return n.toString(e,this.encoding)}flush(){return``}}})),E=r(((e,t)=>{let n=w();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}})),D=r(((e,t)=>{let n=T(),r=E();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)}}})),ee=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}=x(),r=C(),i=D(),a=ee(),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,b=32<<18,S=64<<18,w=128<<18,T=512<<18,E=1024<<18,O=503316479,k=268435455,A=262160,j=8404992,M=8405006,N=33587200,P=33587215,F=16527,I=270794767,L=Symbol.asyncIterator||Symbol(`asyncIterator`);var R=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=H.bind(this),this.afterUpdateNextTick=W.bind(this)}get ending(){return!!(this.stream._duplexState&T)}get ended(){return!!(this.stream._duplexState&b)}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&I)==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&I)==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(re.bind(this));return}if((e._duplexState&14)==4){e._duplexState&N||(e._duplexState|=A,e._destroy(V.bind(this)));return}(e._duplexState&P)==1&&(e._duplexState=(e._duplexState|A)&s,e._open(G.bind(this)))}continueUpdate(){return this.stream._duplexState&w?(this.stream._duplexState&=O,!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))}},z=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=U.bind(this),this.afterUpdateNextTick=ie.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 B(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`,ne.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&F)==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&F)==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&M)==j&&(e._duplexState|=4),this.pipeTo!==null&&this.pipeTo.end()),(e._duplexState&14)==4){e._duplexState&N||(e._duplexState|=A,e._destroy(V.bind(this)));return}(e._duplexState&P)==1&&(e._duplexState=(e._duplexState|A)&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))}},te=class{constructor(e){this.data=null,this.afterTransform=K.bind(e),this.afterFinal=null}},B=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 ne(){this.stream._duplexState|=512,this.updateCallback()}function re(e){let t=this.stream;e&&t.destroy(e),t._duplexState&14||(t._duplexState|=b,t.emit(`finish`)),(t._duplexState&M)==j&&(t._duplexState|=4),t._duplexState&=402391039,t._duplexState&_?this.updateNextTick():this.update()}function V(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 H(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&S)==S&&t.emit(`drain`)),this.updateCallback()}function U(e){e&&this.stream.destroy(e),this.stream._duplexState&=536870895,this.readAhead===!1&&!(this.stream._duplexState&256)&&(this.stream._duplexState&=g),this.updateCallback()}function ie(){this.stream._duplexState&32||(this.stream._duplexState&=h,this.update())}function W(){this.stream._duplexState&_||(this.stream._duplexState&=O,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 K(e,t){t!=null&&this.push(t),this._writableState.afterWrite(e)}function q(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|=S,this._writableState.updateNextTick())}var J=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`,q)}_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())}},Y=class e extends J{constructor(e){super(e),this._duplexState|=8519681,this._readableState=new z(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[L])return this._fromAsyncIterator(t[L](),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)}[L](){let e=this,t=null,n=null,r=null;return this.on(`error`,e=>{t=e}),this.on(`readable`,i),this.on(`close`,o),{[L](){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})})})}}},oe=class extends J{constructor(e){super(e),this._duplexState|=16385,this._writableState=new R(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|=E}uncork(){this._duplexState&=k,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 Y{constructor(e){super(e),this._duplexState=1|this._duplexState&f,this._writableState=new R(this,e),e&&(e.writev&&(this._writev=e.writev),e.write&&(this._write=e.write),e.final&&(this._final=e.final))}cork(){this._duplexState|=E}uncork(){this._duplexState&=k,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 te(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&N)}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!==oe.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:J,Writable:oe,Readable:Y,Duplex:X,Transform:se,PassThrough:ce}})),k=r((e=>{let t=w(),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=C(),o=w(),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=w(),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 p,n=e.depth??1,r=await F(e,t,n);await e.validateManifest?.(r);let i=h(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||!g(a,n))throw y(`ARCHIVE_MANIFEST_MISMATCH`,`Archive contents changed after inspection`);await te(t,a,e.outputRoot,i),i.commitEntry()}await o}catch(e){throw a.destroy(),await o.catch(()=>{}),e}if(r.length!==0)throw y(`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?u(s(e),d(),n,{signal:r}):u(s(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`?y(`ARCHIVE_UNSAFE_ENTRY`,`Uploaded app bundle archive cannot contain symlinks or hard links`):y(`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(ne(e.name,e.type))return;let t=_(e.name),n=L(e.type),r=n===`directory`?0:e.size??0;if(!Number.isSafeInteger(r)||r<0)throw y(`ARCHIVE_INVALID_ENTRY`,`Archive entry has an invalid size`);return{name:t,kind:n,size:r,mode:R(e.mode,n)}}async function te(e,t,n,r){let i=v(n,t.name);if(t.kind===`directory`){await l.mkdir(i,{recursive:!0,mode:t.mode}),await B(e);return}await l.mkdir(o.dirname(i),{recursive:!0}),await u(e,async function*(e){for await(let t of e)r.chargeBytes(Buffer.byteLength(t)),yield t},c(i,{flags:`wx`,mode:t.mode}))}async function B(e){for await(let t of e);}function ne(e,t){return t===`directory`&&(e===`.`||e===`./`||e===``)}var re=e(a(),1);async function V(e){e.signal?.throwIfAborted();let t=e.budget??new p,n=e.depth??1,r=[],i=0;await H(e.archivePath,e.signal,e=>{t.preflightArchive({depth:n,entryCount:r.length+1,declaredBytes:i});let a=W(e);i+=a.size,t.preflightArchive({depth:n,entryCount:r.length+1,declaredBytes:i}),r.push(a)}),await e.validateManifest?.(r);let a=h(t,n,r),s=await H(e.archivePath,e.signal,(e,t)=>{t>=r.length&&K()});s.length!==r.length&&K();let d=await U(e.archivePath);try{for(let t=0;t<s.length;t+=1){e.signal?.throwIfAborted();let n=s[t],i=r[t];(!n||!i||!g(W(n),i))&&K();let f=v(e.outputRoot,i.name);if(i.kind===`directory`)await l.mkdir(f,{recursive:!0,mode:i.mode});else{await l.mkdir(o.dirname(f),{recursive:!0});let t=await ie(d,n);await u(t,async function*(e){for await(let t of e)a.chargeBytes(Buffer.byteLength(t)),yield t},c(f,{flags:`wx`,mode:i.mode}),{signal:e.signal})}a.commitEntry()}a.finish()}finally{d.close()}}async function H(e,t,n){let r=await U(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 U(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 ie(e,t){return new Promise((n,r)=>{e.openReadStream(t,(e,t)=>e?r(e):n(t))})}function W(e){ae(e);let t=_(e.fileName),n=e.externalFileAttributes>>>16&65535,r=G(e.fileName,n),i=r?493:420;return{name:t,kind:r?`directory`:`file`,size:r?0:e.uncompressedSize,mode:n&511||i}}function ae(e){if(e.isEncrypted())throw y(`ARCHIVE_UNSAFE_ENTRY`,`Encrypted archive entries are not supported`);let t=e.externalFileAttributes>>>16&61440;if(t!==0&&t!==16384&&t!==32768)throw y(`ARCHIVE_UNSAFE_ENTRY`,`Archive contains a link or special entry`)}function G(e,t){return e.endsWith(`/`)||(t&61440)==16384}function K(){throw y(`ARCHIVE_MANIFEST_MISMATCH`,`Archive contents changed after inspection`)}async function q(e){e.signal?.throwIfAborted();let t=o.resolve(e.archivePath),n=o.resolve(e.outputRoot);if(t===n||t.startsWith(`${n}${o.sep}`))throw RangeError(`archivePath must be outside outputRoot`);await l.mkdir(n,{recursive:!1});try{e.type===`zip`?await V({...e,archivePath:t,outputRoot:n}):await P({...e,archivePath:t,outputRoot:n,gzip:e.type===`tgz`})}catch(e){throw await l.rm(n,{recursive:!0,force:!0}),e}}function J(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 Y=n({MAX_ARTIFACT_COMPRESSED_BYTES:()=>f,extractArchiveSafely:()=>q});export{f as a,p as i,J as n,q as r,Y as t};
@@ -1 +1 @@
1
- import{D 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{A 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{D 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};
1
+ import{A 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{D as e}from"./sdk-contracts.js";import{t}from"./daemon-resolution.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{A as e}from"./sdk-contracts.js";import{t}from"./daemon-resolution.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
- import{x 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
+ import{w 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{O 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{j 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};
@@ -1 +1 @@
1
- import{D as e}from"./sdk-contracts.js";import{N as t,n,v as r}from"./runtime.js";import{n as i}from"./ios-system-surface.js";import{t as a}from"./ios-target-activation.js";function o(t,n={}){let r=n.plural===!0?`do`:`does`;return{resolveInput:async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} ${r} not resolve input artifacts`)},reserveOutput:async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} ${r} not reserve output artifacts`)},createTempFile:async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} ${r} not create temporary files`)}}}function s(e,t={}){return{artifacts:o(e,t),policy:r()}}function c(e,t){return e!==void 0&&e.state===void 0&&t.targetActivation!==void 0&&(e.state=t),t}function l(e,t){let r=t?.iosSystemSurfaceBundleId?i(t.iosSystemSurfaceBundleId):n(t);return r?p(e,r,`warning`):e}function u(e,t,n,r){if(!n)return e;let i=p(e,r(n),`warnings`);return i.ok?{...i,data:{...i.data,[t]:n}}:{...i,error:{...i.error,details:{...i.error.details,[t]:n}}}}function d(e,t){return u(e,`targetActivation`,t?.targetActivation,a)}function f(e){let{response:n,consumedTree:r,activationProof:i}=e;return d(u(l(n,r),`unsettledGesture`,r?.unsettledGesture,t),i?.state)}function p(e,t,n){if(m(e,t))return e;if(!e.ok){let n=e.error.details??{};return{...e,error:{...e.error,details:{...n,hint:h(n.hint,t)}}}}return n===`warnings`?{...e,data:{...e.data,warnings:[...g(e.data?.warnings),t]}}:{...e,data:{...e.data,warning:h(e.data?.warning,t)}}}function m(e,t){return(e.ok?[e.data?.warning,...g(e.data?.warnings)]:[e.error.details?.hint]).some(e=>typeof e==`string`&&e.includes(t))}function h(e,t){return typeof e==`string`&&e.trim()!==``?`${e}\n${t}`:t}function g(e){return Array.isArray(e)?e.filter(e=>e!==void 0):[]}export{s as i,f as n,d as r,c as t};
1
+ import{A as e}from"./sdk-contracts.js";import{A as t,n,v as r}from"./runtime.js";import{n as i}from"./ios-system-surface.js";import{t as a}from"./ios-target-activation.js";function o(t,n={}){let r=n.plural===!0?`do`:`does`;return{resolveInput:async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} ${r} not resolve input artifacts`)},reserveOutput:async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} ${r} not reserve output artifacts`)},createTempFile:async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} ${r} not create temporary files`)}}}function s(e,t={}){return{artifacts:o(e,t),policy:r()}}function c(e,t){return e===void 0?t:(e.targetActivation??=t.targetActivation,e.postGestureOutcome??=t.postGestureOutcome,t)}function l(e,t){let r=t?.iosSystemSurfaceBundleId?i(t.iosSystemSurfaceBundleId):n(t);return r?p(e,r,`warning`):e}function u(e,t,n,r){if(!n)return e;let i=p(e,r(n),`warnings`);return i.ok?{...i,data:{...i.data,[t]:n}}:{...i,error:{...i.error,details:{...i.error.details,[t]:n}}}}function d(e,t){return u(e,`targetActivation`,t?.targetActivation,a)}function f(e){let{response:n,consumedTree:r,captureProof:i}=e;return d(u(l(n,r),`postGestureOutcome`,r?.postGestureOutcome,t),i)}function p(e,t,n){if(m(e,t))return e;if(!e.ok){let n=e.error.hint??e.error.details?.hint;return{...e,error:{...e.error,hint:h(n,t)}}}return n===`warnings`?{...e,data:{...e.data,warnings:[...g(e.data?.warnings),t]}}:{...e,data:{...e.data,warning:h(e.data?.warning,t)}}}function m(e,t){return(e.ok?[e.data?.warning,...g(e.data?.warnings)]:[e.error.hint]).some(e=>typeof e==`string`&&e.includes(t))}function h(e,t){return typeof e==`string`&&e.trim()!==``?`${e}\n${t}`:t}function g(e){return Array.isArray(e)?e.filter(e=>e!==void 0):[]}export{s as i,f as n,d as r,c as t};
@@ -1 +1 @@
1
- import{D as e}from"./sdk-contracts.js";const t={min:.01,max:1},n={flagKey:`screenshotMaxSize`,cliToken:`--max-size`,envVar:`AGENT_DEVICE_SCREENSHOT_MAX_SIZE`,publicOptionKey:`maxSize`,migration:{screenshot:`screenshot --max-size was removed; use --scale <0.01-1> (or AGENT_DEVICE_SCREENSHOT_SCALE) to downscale proportionally`,record:`record --max-size was removed; recordings capture at native resolution`}};function r(e,t){return t&&Object.hasOwn(t,n.flagKey)?n.migration[e]:void 0}function i(t,r){if(Object.hasOwn(r,n.publicOptionKey)||Object.hasOwn(r,n.flagKey))throw new e(`INVALID_ARGS`,n.migration[t])}const a={selectorInvalid:`CROP_SELECTOR_INVALID`,targetNotFound:`CROP_TARGET_NOT_FOUND`,targetAmbiguous:`CROP_TARGET_AMBIGUOUS`,captureUnreadable:`CROP_CAPTURE_UNREADABLE`,captureIncomplete:`CROP_CAPTURE_INCOMPLETE`,emptyIntersection:`CROP_EMPTY_INTERSECTION`,partialIntersection:`CROP_PARTIAL_INTERSECTION`,targetNotAccepted:`CROP_TARGET_NOT_ACCEPTED`,frameMismatch:`CROP_FRAME_MISMATCH`,pendingPixelIdentityEvidence:`PENDING_PIXEL_IDENTITY_EVIDENCE`},o={macOsHelperSurfaceFixedFrame:`SCREENSHOT_FULLSCREEN_MACOS_HELPER_SURFACE_FIXED_FRAME`},s=[`out`,`overlayRefs`,`screenshotCropOn`,`screenshotPixelDensity`,`screenshotFullscreen`,`screenshotScale`,`screenshotNoStabilize`,`screenshotNormalizeStatusBar`],c=[{key:`screenshotCropOn`,names:[`--crop-on`],type:`string`,usageLabel:`--crop-on <selector-expression>`,usageDescription:`Screenshot: crop the capture to the frame of the selector resolved on the same screen`,projectConfig:!1,recorded:!0},{key:`screenshotPixelDensity`,names:[`--pixel-density`],type:`int`,min:1,usageLabel:`--pixel-density <n>`,usageDescription:`Screenshot: output PNG pixel density in pixels per logical point (currently supported on iOS simulators)`,projectConfig:!0,recorded:!0},{key:`screenshotFullscreen`,names:[`--fullscreen`,`--full`,`-f`],type:`boolean`,usageLabel:`--fullscreen, --full, -f`,usageDescription:`Screenshot: on web capture the full page; on macOS app sessions capture the full desktop instead of the app window`,projectConfig:!0,recorded:!0},{key:`screenshotScale`,names:[`--scale`],type:`number`,min:t.min,max:t.max,usageLabel:`--scale <0.01-1>`,usageDescription:`Screenshot: resize both dimensions by this factor (or use AGENT_DEVICE_SCREENSHOT_SCALE)`,projectConfig:!0,recorded:!0},{key:`screenshotNoStabilize`,names:[`--no-stabilize`],type:`boolean`,usageLabel:`--no-stabilize`,usageDescription:`Screenshot: skip Android demo-mode/status-bar stabilization and settle delay for low-latency capture loops`,projectConfig:!0,recorded:!0},{key:`screenshotNormalizeStatusBar`,names:[`--normalize-status-bar`],type:`boolean`,usageLabel:`--normalize-status-bar`,usageDescription:`Screenshot: on iOS simulators temporarily normalize status-bar chrome for deterministic screenshot diffs`,projectConfig:!0,recorded:!0}],l=[{tokens:[`--fullscreen`,`--full`,`-f`],key:`screenshotFullscreen`},{tokens:[`--no-stabilize`],key:`screenshotNoStabilize`},{tokens:[`--normalize-status-bar`],key:`screenshotNormalizeStatusBar`}],u=[{token:`--pixel-density`,key:`screenshotPixelDensity`,label:`screenshot --pixel-density`}],d=[{token:`--scale`,key:`screenshotScale`,label:`screenshot --scale`,min:t.min,max:t.max}],f=[{token:`--crop-on`,key:`screenshotCropOn`,label:`screenshot --crop-on`}];function p(e){return y({overlayRefs:e?.overlayRefs,cropOn:e?.screenshotCropOn,pixelDensity:e?.screenshotPixelDensity,fullscreen:e?.screenshotFullscreen,scale:e?.screenshotScale,stabilize:!e?.screenshotNoStabilize&&void 0,normalizeStatusBar:e?.screenshotNormalizeStatusBar})}function m(e={}){return y({overlayRefs:e.overlayRefs,screenshotCropOn:e.screenshotCropOn??e.cropOn,screenshotPixelDensity:e.screenshotPixelDensity??e.pixelDensity,screenshotFullscreen:e.screenshotFullscreen??e.fullscreen,screenshotScale:e.screenshotScale,screenshotNoStabilize:e.screenshotNoStabilize??(e.stabilize===!1||void 0),screenshotNormalizeStatusBar:e.screenshotNormalizeStatusBar??e.normalizeStatusBar})}function h(e={}){return m({...e,screenshotScale:e.screenshotScale??e.scale})}function g(n){let{min:r,max:i}=t;if(n.scale!==void 0&&(!Number.isFinite(n.scale)||n.scale<r||n.scale>i))throw new e(`INVALID_ARGS`,`screenshot scale must be between ${r} and ${i}`)}function _(e,t){typeof t?.screenshotPixelDensity==`number`&&e.push(`--pixel-density`,String(t.screenshotPixelDensity)),t?.screenshotFullscreen&&e.push(`--fullscreen`),typeof t?.screenshotScale==`number`&&e.push(`--scale`,String(t.screenshotScale)),t?.screenshotNoStabilize&&e.push(`--no-stabilize`),t?.screenshotNormalizeStatusBar&&e.push(`--normalize-status-bar`)}function v(t){let{args:r,flags:i,index:a}=t,o=r[a];if(o===n.cliToken)throw new e(`INVALID_ARGS`,n.migration.screenshot);return b(o,i,a)??x({args:r,index:a,flags:i,token:o})??S({args:r,index:a,flags:i,token:o})??C({args:r,index:a,flags:i,token:o})??{handled:!1}}function y(e){return Object.fromEntries(Object.entries(e).filter(e=>e[1]!==void 0))}function b(e,t,n){let r=l.find(t=>t.tokens.some(t=>t===e));if(r)return t[r.key]=!0,{handled:!0,nextIndex:n}}function x(t){let n=u.find(e=>e.token===t.token);if(!n)return;let r=Number(t.args[t.index+1]);if(!Number.isInteger(r)||r<1)throw new e(`INVALID_ARGS`,`${n.label} requires a positive integer`);return t.flags[n.key]=r,{handled:!0,nextIndex:t.index+1}}function S(t){let n=d.find(e=>e.token===t.token);if(!n)return;let r=Number(t.args[t.index+1]);if(!Number.isFinite(r)||r<n.min||r>n.max)throw new e(`INVALID_ARGS`,`${n.label} requires a number from ${n.min} to ${n.max}`);return t.flags[n.key]=r,{handled:!0,nextIndex:t.index+1}}function C(t){let n=f.find(e=>e.token===t.token);if(!n)return;let r=t.args[t.index+1];if(typeof r!=`string`||r.length===0)throw new e(`INVALID_ARGS`,`${n.label} requires a selector expression`);return t.flags[n.key]=r,{handled:!0,nextIndex:t.index+1}}export{t as a,v as c,h as d,p as f,o as i,r as l,g as m,s as n,c as o,i as p,a as r,_ as s,n as t,m as u};
1
+ import{A as e}from"./sdk-contracts.js";const t={min:.01,max:1},n={flagKey:`screenshotMaxSize`,cliToken:`--max-size`,envVar:`AGENT_DEVICE_SCREENSHOT_MAX_SIZE`,publicOptionKey:`maxSize`,migration:{screenshot:`screenshot --max-size was removed; use --scale <0.01-1> (or AGENT_DEVICE_SCREENSHOT_SCALE) to downscale proportionally`,record:`record --max-size was removed; recordings capture at native resolution`}};function r(e,t){return t&&Object.hasOwn(t,n.flagKey)?n.migration[e]:void 0}function i(t,r){if(Object.hasOwn(r,n.publicOptionKey)||Object.hasOwn(r,n.flagKey))throw new e(`INVALID_ARGS`,n.migration[t])}const a={selectorInvalid:`CROP_SELECTOR_INVALID`,targetNotFound:`CROP_TARGET_NOT_FOUND`,targetAmbiguous:`CROP_TARGET_AMBIGUOUS`,captureUnreadable:`CROP_CAPTURE_UNREADABLE`,captureIncomplete:`CROP_CAPTURE_INCOMPLETE`,emptyIntersection:`CROP_EMPTY_INTERSECTION`,partialIntersection:`CROP_PARTIAL_INTERSECTION`,targetNotAccepted:`CROP_TARGET_NOT_ACCEPTED`,frameMismatch:`CROP_FRAME_MISMATCH`,pendingPixelIdentityEvidence:`PENDING_PIXEL_IDENTITY_EVIDENCE`},o={macOsHelperSurfaceFixedFrame:`SCREENSHOT_FULLSCREEN_MACOS_HELPER_SURFACE_FIXED_FRAME`},s=[`out`,`overlayRefs`,`screenshotCropOn`,`screenshotPixelDensity`,`screenshotFullscreen`,`screenshotScale`,`screenshotNoStabilize`,`screenshotNormalizeStatusBar`],c=[{key:`screenshotCropOn`,names:[`--crop-on`],type:`string`,usageLabel:`--crop-on <selector-expression>`,usageDescription:`Screenshot: crop the capture to the frame of the selector resolved on the same screen`,projectConfig:!1,recorded:!0},{key:`screenshotPixelDensity`,names:[`--pixel-density`],type:`int`,min:1,usageLabel:`--pixel-density <n>`,usageDescription:`Screenshot: output PNG pixel density in pixels per logical point (currently supported on iOS simulators)`,projectConfig:!0,recorded:!0},{key:`screenshotFullscreen`,names:[`--fullscreen`,`--full`,`-f`],type:`boolean`,usageLabel:`--fullscreen, --full, -f`,usageDescription:`Screenshot: on web capture the full page; on macOS app sessions capture the full desktop instead of the app window`,projectConfig:!0,recorded:!0},{key:`screenshotScale`,names:[`--scale`],type:`number`,min:t.min,max:t.max,usageLabel:`--scale <0.01-1>`,usageDescription:`Screenshot: resize both dimensions by this factor (or use AGENT_DEVICE_SCREENSHOT_SCALE)`,projectConfig:!0,recorded:!0},{key:`screenshotNoStabilize`,names:[`--no-stabilize`],type:`boolean`,usageLabel:`--no-stabilize`,usageDescription:`Screenshot: skip Android demo-mode/status-bar stabilization and settle delay for low-latency capture loops`,projectConfig:!0,recorded:!0},{key:`screenshotNormalizeStatusBar`,names:[`--normalize-status-bar`],type:`boolean`,usageLabel:`--normalize-status-bar`,usageDescription:`Screenshot: on iOS simulators temporarily normalize status-bar chrome for deterministic screenshot diffs`,projectConfig:!0,recorded:!0}],l=[{tokens:[`--fullscreen`,`--full`,`-f`],key:`screenshotFullscreen`},{tokens:[`--no-stabilize`],key:`screenshotNoStabilize`},{tokens:[`--normalize-status-bar`],key:`screenshotNormalizeStatusBar`}],u=[{token:`--pixel-density`,key:`screenshotPixelDensity`,label:`screenshot --pixel-density`}],d=[{token:`--scale`,key:`screenshotScale`,label:`screenshot --scale`,min:t.min,max:t.max}],f=[{token:`--crop-on`,key:`screenshotCropOn`,label:`screenshot --crop-on`}];function p(e){return y({overlayRefs:e?.overlayRefs,cropOn:e?.screenshotCropOn,pixelDensity:e?.screenshotPixelDensity,fullscreen:e?.screenshotFullscreen,scale:e?.screenshotScale,stabilize:!e?.screenshotNoStabilize&&void 0,normalizeStatusBar:e?.screenshotNormalizeStatusBar})}function m(e={}){return y({overlayRefs:e.overlayRefs,screenshotCropOn:e.screenshotCropOn??e.cropOn,screenshotPixelDensity:e.screenshotPixelDensity??e.pixelDensity,screenshotFullscreen:e.screenshotFullscreen??e.fullscreen,screenshotScale:e.screenshotScale,screenshotNoStabilize:e.screenshotNoStabilize??(e.stabilize===!1||void 0),screenshotNormalizeStatusBar:e.screenshotNormalizeStatusBar??e.normalizeStatusBar})}function h(e={}){return m({...e,screenshotScale:e.screenshotScale??e.scale})}function g(n){let{min:r,max:i}=t;if(n.scale!==void 0&&(!Number.isFinite(n.scale)||n.scale<r||n.scale>i))throw new e(`INVALID_ARGS`,`screenshot scale must be between ${r} and ${i}`)}function _(e,t){typeof t?.screenshotPixelDensity==`number`&&e.push(`--pixel-density`,String(t.screenshotPixelDensity)),t?.screenshotFullscreen&&e.push(`--fullscreen`),typeof t?.screenshotScale==`number`&&e.push(`--scale`,String(t.screenshotScale)),t?.screenshotNoStabilize&&e.push(`--no-stabilize`),t?.screenshotNormalizeStatusBar&&e.push(`--normalize-status-bar`)}function v(t){let{args:r,flags:i,index:a}=t,o=r[a];if(o===n.cliToken)throw new e(`INVALID_ARGS`,n.migration.screenshot);return b(o,i,a)??x({args:r,index:a,flags:i,token:o})??S({args:r,index:a,flags:i,token:o})??C({args:r,index:a,flags:i,token:o})??{handled:!1}}function y(e){return Object.fromEntries(Object.entries(e).filter(e=>e[1]!==void 0))}function b(e,t,n){let r=l.find(t=>t.tokens.some(t=>t===e));if(r)return t[r.key]=!0,{handled:!0,nextIndex:n}}function x(t){let n=u.find(e=>e.token===t.token);if(!n)return;let r=Number(t.args[t.index+1]);if(!Number.isInteger(r)||r<1)throw new e(`INVALID_ARGS`,`${n.label} requires a positive integer`);return t.flags[n.key]=r,{handled:!0,nextIndex:t.index+1}}function S(t){let n=d.find(e=>e.token===t.token);if(!n)return;let r=Number(t.args[t.index+1]);if(!Number.isFinite(r)||r<n.min||r>n.max)throw new e(`INVALID_ARGS`,`${n.label} requires a number from ${n.min} to ${n.max}`);return t.flags[n.key]=r,{handled:!0,nextIndex:t.index+1}}function C(t){let n=f.find(e=>e.token===t.token);if(!n)return;let r=t.args[t.index+1];if(typeof r!=`string`||r.length===0)throw new e(`INVALID_ARGS`,`${n.label} requires a selector expression`);return t.flags[n.key]=r,{handled:!0,nextIndex:t.index+1}}export{t as a,v as c,h as d,p as f,o as i,r as l,g as m,s as n,c as o,i as p,a as r,_ as s,n as t,m as u};
@@ -1 +1 @@
1
- import{D as e}from"./sdk-contracts.js";import{t}from"./capture.js";import{i as n}from"./catalog.js";import{a as r,r as i}from"./back-mode.js";import{a,s as o}from"./sdk-remote-config.js";import{c as s,p as c}from"./registry.js";import{n as l,t as u}from"./path-resolution.js";import"./file.js";import{n as d}from"./command-schema.js";import f from"node:path";import p from"node:fs";const m=new Set([`config`,`remoteConfig`,`help`,`version`,`batchSteps`,`githubActionsArtifact`]),h=new Set([`appsFilter`,`iosSimulatorDeviceSet`]),g=S(),_=new Map(g.map(e=>[e.key,e]));function v(e){return _.get(e)}function y(e){return g.filter(t=>t.configurable&&t.supportsCommand(e))}function b(e,t){return v(e)?.supportsCommand(t)??!1}function x(e,t,n,r){return o(T(e),t,n,r)}function S(){let e=new Map;for(let t of i()){let n=e.get(t.key);n?n.push(t):e.set(t.key,[t])}let t=new Map;for(let e of c)t.set(e,new Set([`*`]));for(let e of n()){let n=d(e);for(let r of[...n.allowedFlags??[],...n.supportedFlags??[]]){let n=t.get(r);n&&n.has(`*`)||(n?n.add(e):t.set(r,new Set([e])))}}return[...e.entries()].map(([e,n])=>({key:e,flagDefinitions:n,configurable:!m.has(e),env:{names:h.has(e)?[]:[a(e)]},supportsCommand(n){let r=t.get(e);return r?r.has(`*`)?!0:n?r.has(n):!1:!1}})).sort((e,t)=>C(e.key,t.key))}function C(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r?e<t?-1:+(e>t):n<r?-1:1}function w(e){let t=e.flagDefinitions[0];if(!t)throw Error(`Missing flag definition for option ${e.key}`);return t}function T(e){let t=e.flagDefinitions.find(e=>e.setValue===void 0);if(t)return t;let n=w(e);if(n.type===`enum`){let t=n.enumValues??e.flagDefinitions.map(e=>e.setValue).filter(e=>e!==void 0);return{...n,setValue:void 0,enumValues:t}}return n}function E(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&(e[n]=r);return e}function D(e){let t=e.env??process.env;return E(E({},M(k(e.cwd,e.cliFlags.config,t))),I(t,e.command))}const O=r();function k(e,t,n){let r=t??n.AGENT_DEVICE_CONFIG;return r?[{path:j(r,e,n),required:!0,source:`explicit`}]:[{path:A(n),required:!1,source:`user`},{path:f.resolve(e,`agent-device.json`),required:!1,source:`project`}]}function A(e){return f.join(u(`~`,{env:e}),`.agent-device`,`config.json`)}function j(e,t,n){return l(e,{cwd:t,env:n})}function M(e){let t={};for(let n of e)E(t,N(n));return t}function N(t){let{path:n,required:r}=t;if(!p.existsSync(n)){if(r)throw new e(`INVALID_ARGS`,`Config file not found: ${n}`);return{}}let i;try{i=p.readFileSync(n,`utf8`)}catch(t){throw new e(`INVALID_ARGS`,`Failed to read config file: ${n}`,{cause:t instanceof Error?t.message:String(t)})}let a;try{a=JSON.parse(i)}catch(t){throw new e(`INVALID_ARGS`,`Invalid JSON in config file: ${n}`,{cause:t instanceof Error?t.message:String(t)})}if(!a||typeof a!=`object`||Array.isArray(a))throw new e(`INVALID_ARGS`,`Config file must contain a JSON object: ${n}`);return P(a,{source:t.source,label:`${t.source===`project`?`project `:``}config file ${n}`})}function P(n,r){let i={};for(let[a,o]of Object.entries(n)){let n=a,c=v(n);if(!c)throw a===t.flagKey?new e(`INVALID_ARGS`,`Config key "${a}" in ${r.label} was removed; use "screenshotScale" (0.01-1) to downscale screenshots. Recordings capture at native resolution.`):new e(`INVALID_ARGS`,`Unknown config key "${a}" in ${r.label}.`);if(!c.configurable)throw new e(`INVALID_ARGS`,`Config key "${a}" is not allowed in ${r.label}. This key is not supported in config files.`);if(r.source===`project`&&!O.has(n))throw new e(`INVALID_ARGS`,`Config key "${a}" is not allowed in ${r.label}. Move it to ~/.agent-device/config.json, pass it with --config or AGENT_DEVICE_CONFIG, or provide it through CLI flags/environment variables.`);if(n===`installSource`){i.installSource=s(o,r.label);continue}i[n]=x(c,o,r.label,a)}return i}const F=new Set([`screenshot`,`record`]);function I(n,r){let i=n[t.envVar];if(r!==null&&F.has(r)&&typeof i==`string`&&i.trim().length>0)throw new e(`INVALID_ARGS`,`${t.envVar} was removed. ${t.migration[r===`record`?`record`:`screenshot`]}`);let a={};for(let e of y(r)){if(e.key===`installSource`)continue;let t=e.env.names.map(e=>({name:e,value:n[e]})).find(e=>typeof e.value==`string`&&e.value.trim().length>0);t&&(a[e.key]=x(e,t.value,`environment variable ${t.name}`,t.name))}return a}export{E as n,b as r,D as t};
1
+ import{A as e}from"./sdk-contracts.js";import{t}from"./capture.js";import{i as n}from"./catalog.js";import{a as r,r as i}from"./back-mode.js";import{a,s as o}from"./sdk-remote-config.js";import{c as s,p as c}from"./registry.js";import{n as l,t as u}from"./path-resolution.js";import"./file.js";import{n as d}from"./command-schema.js";import f from"node:path";import p from"node:fs";const m=new Set([`config`,`remoteConfig`,`help`,`version`,`batchSteps`,`githubActionsArtifact`]),h=new Set([`appsFilter`,`iosSimulatorDeviceSet`]),g=S(),_=new Map(g.map(e=>[e.key,e]));function v(e){return _.get(e)}function y(e){return g.filter(t=>t.configurable&&t.supportsCommand(e))}function b(e,t){return v(e)?.supportsCommand(t)??!1}function x(e,t,n,r){return o(T(e),t,n,r)}function S(){let e=new Map;for(let t of i()){let n=e.get(t.key);n?n.push(t):e.set(t.key,[t])}let t=new Map;for(let e of c)t.set(e,new Set([`*`]));for(let e of n()){let n=d(e);for(let r of[...n.allowedFlags??[],...n.supportedFlags??[]]){let n=t.get(r);n&&n.has(`*`)||(n?n.add(e):t.set(r,new Set([e])))}}return[...e.entries()].map(([e,n])=>({key:e,flagDefinitions:n,configurable:!m.has(e),env:{names:h.has(e)?[]:[a(e)]},supportsCommand(n){let r=t.get(e);return r?r.has(`*`)?!0:n?r.has(n):!1:!1}})).sort((e,t)=>C(e.key,t.key))}function C(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r?e<t?-1:+(e>t):n<r?-1:1}function w(e){let t=e.flagDefinitions[0];if(!t)throw Error(`Missing flag definition for option ${e.key}`);return t}function T(e){let t=e.flagDefinitions.find(e=>e.setValue===void 0);if(t)return t;let n=w(e);if(n.type===`enum`){let t=n.enumValues??e.flagDefinitions.map(e=>e.setValue).filter(e=>e!==void 0);return{...n,setValue:void 0,enumValues:t}}return n}function E(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&(e[n]=r);return e}function D(e){let t=e.env??process.env;return E(E({},M(k(e.cwd,e.cliFlags.config,t))),I(t,e.command))}const O=r();function k(e,t,n){let r=t??n.AGENT_DEVICE_CONFIG;return r?[{path:j(r,e,n),required:!0,source:`explicit`}]:[{path:A(n),required:!1,source:`user`},{path:f.resolve(e,`agent-device.json`),required:!1,source:`project`}]}function A(e){return f.join(u(`~`,{env:e}),`.agent-device`,`config.json`)}function j(e,t,n){return l(e,{cwd:t,env:n})}function M(e){let t={};for(let n of e)E(t,N(n));return t}function N(t){let{path:n,required:r}=t;if(!p.existsSync(n)){if(r)throw new e(`INVALID_ARGS`,`Config file not found: ${n}`);return{}}let i;try{i=p.readFileSync(n,`utf8`)}catch(t){throw new e(`INVALID_ARGS`,`Failed to read config file: ${n}`,{cause:t instanceof Error?t.message:String(t)})}let a;try{a=JSON.parse(i)}catch(t){throw new e(`INVALID_ARGS`,`Invalid JSON in config file: ${n}`,{cause:t instanceof Error?t.message:String(t)})}if(!a||typeof a!=`object`||Array.isArray(a))throw new e(`INVALID_ARGS`,`Config file must contain a JSON object: ${n}`);return P(a,{source:t.source,label:`${t.source===`project`?`project `:``}config file ${n}`})}function P(n,r){let i={};for(let[a,o]of Object.entries(n)){let n=a,c=v(n);if(!c)throw a===t.flagKey?new e(`INVALID_ARGS`,`Config key "${a}" in ${r.label} was removed; use "screenshotScale" (0.01-1) to downscale screenshots. Recordings capture at native resolution.`):new e(`INVALID_ARGS`,`Unknown config key "${a}" in ${r.label}.`);if(!c.configurable)throw new e(`INVALID_ARGS`,`Config key "${a}" is not allowed in ${r.label}. This key is not supported in config files.`);if(r.source===`project`&&!O.has(n))throw new e(`INVALID_ARGS`,`Config key "${a}" is not allowed in ${r.label}. Move it to ~/.agent-device/config.json, pass it with --config or AGENT_DEVICE_CONFIG, or provide it through CLI flags/environment variables.`);if(n===`installSource`){i.installSource=s(o,r.label);continue}i[n]=x(c,o,r.label,a)}return i}const F=new Set([`screenshot`,`record`]);function I(n,r){let i=n[t.envVar];if(r!==null&&F.has(r)&&typeof i==`string`&&i.trim().length>0)throw new e(`INVALID_ARGS`,`${t.envVar} was removed. ${t.migration[r===`record`?`record`:`screenshot`]}`);let a={};for(let e of y(r)){if(e.key===`installSource`)continue;let t=e.env.names.map(e=>({name:e,value:n[e]})).find(e=>typeof e.value==`string`&&e.value.trim().length>0);t&&(a[e.key]=x(e,t.value,`environment variable ${t.name}`,t.name))}return a}export{E as n,b as r,D as t};
@@ -688,11 +688,11 @@ Screens are handled for you:
688
688
 
689
689
  Changing the pose:
690
690
  agent-device fold closed | half-open | open
691
- fold sends a private HID hinge event inside the selected simulator and then reads the hinge angle back from CoreDevice until it agrees: closed is 0 degrees, open is 180, and half-open is any angle between them (requested at 130 degrees). An angle in that interval only proves the category, so half-open is reported once two consecutive readings both fall inside it and agree within 0.5 degrees. The response reports the verified pose, the hinge angle, and the panel the device now lights with its native panel point size, marked coordinateSpace "native-panel". That point size is the panel's own geometry, not the next snapshot's viewport, so it cannot place a tap: the active app window can differ (a 669x951 inner panel hosts a 951x669 window). A hinge whose last reading is some other pose fails with COMMAND_FAILED and reason fold-pose-unverified, naming the angle CoreDevice still reports; a hinge seen half-open but never at rest fails with reason fold-pose-unsettled, naming the observed and previous angles. A single-panel simulator fails with UNSUPPORTED_OPERATION.
691
+ fold sends a private HID hinge event inside the selected simulator and then reads the hinge angle back from CoreDevice until it agrees: closed is 0 degrees, open is 180, and half-open is any angle between them (requested at 130 degrees). An angle in that interval only proves the category, so half-open is reported once two consecutive readings both fall inside it and agree within 0.5 degrees. The response reports the verified pose, the hinge angle, and the panel the device now lights with its native panel point size, marked coordinateSpace "native-panel". That point size is the panel's own geometry, not the next snapshot's viewport, so it cannot place a tap: the active app window can differ (a 669x951 inner panel hosts a 951x669 window). A hinge whose last reading is some other pose fails with COMMAND_FAILED and reason fold-pose-unverified, naming the angle CoreDevice still reports; a hinge seen half-open but never at rest fails with reason fold-pose-unsettled, naming the observed and previous angles. A single-panel simulator fails with UNSUPPORTED_OPERATION. A simulator scoped to a non-default set with --ios-simulator-device-set is refused before any hinge is touched, with UNSUPPORTED_OPERATION and reason unsupported-device-scope: the HID send honors the set, but CoreDevice's display inventory and hinge-angle readback resolve a scoped simulator as not found, so the pose could not be verified. Run fold without --ios-simulator-device-set (in the default set).
692
692
  Expect a fold to take 10-16 seconds: each hinge read is a five-second devicectl stream, and half-open waits for the hinge to stop moving. Re-snapshot after every fold; refs and coordinates from before it are stale, and the command's message says so.
693
693
  Timed motion: fold --keyframes '[{"atMs":0,"angle":0},{"atMs":5000,"angle":180}]'. Use 2–64 frames starting at 0ms, increasing integer timestamps up to 60000ms, and angles from 0 to 180. The last timestamp sets motion duration, excluding setup and verification. Equal angles hold; cancellation stops motion. See the fold examples in the command and Node API documentation for trajectories.
694
694
 
695
- Requirements: an iOS simulator session on a foldable device and an Xcode toolchain with the iOS simulator SDK and foldable HID support (verified on Xcode 27.1). Device Hub and host Accessibility permission are not required. The command builds a small temporary helper with the selected Xcode and runs it through simctl spawn for the session UDID; build or dispatch failures are reported without a UI fallback. The app under test reads the resulting pose as UIHinge.status.
695
+ Requirements: an iOS simulator session on a foldable device and an Xcode toolchain with the iOS simulator SDK and foldable HID support (verified on Xcode 27.1). Device Hub and host Accessibility permission are not required. The command runs a small helper through simctl spawn for the session UDID; the helper is built once per Fold.m source hash and Xcode toolchain, cached under ~/.agent-device/fold-helper, and rebuilt only when the source or the toolchain changes. Build or dispatch failures are reported without a UI fallback. The app under test reads the resulting pose as UIHinge.status.
696
696
  If a task asserts behavior for more than one pose, fold to each pose and re-snapshot, and report which poses the run covered.`},remote:{summary:`Direct proxy, cloud profiles, and remote config`,body:`agent-device help remote
697
697
 
698
698
  Remote connection providers use the same lifecycle: