stim 1.20.2 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/README.md +141 -8
  2. package/dist/acquire-artifact-Co2k4f7O.mjs +171 -0
  3. package/dist/act-DsuqEkiM.mjs +2801 -0
  4. package/dist/activity-CMLmzp7o.mjs +1397 -0
  5. package/dist/{agent-device-usage-output-Dzgv6lgR.mjs → agent-device-usage-output-DUFaTMdd.mjs} +23 -67
  6. package/dist/{android-DCKZrNvV.mjs → android-ByRMUoiJ.mjs} +157 -93
  7. package/dist/{android-Mz_Inn3w.mjs → android-C7sVmyI9.mjs} +299 -116
  8. package/dist/{android-Dlzxshgp.mjs → android-DGkNqa_c.mjs} +5 -5
  9. package/dist/{android-HqP1_vB_.mjs → android-DR5lZ2Az.mjs} +2 -2
  10. package/dist/android-cas-compiler.mjs +2 -2
  11. package/dist/{android-cas-Bl-cLJBk.mjs → android-cas-ngferVq2.mjs} +7 -6
  12. package/dist/android-project-BCAAmMwz.mjs +12 -0
  13. package/dist/android-project-DVWyCbWU.d.mts +391 -0
  14. package/dist/api.d.mts +810 -64
  15. package/dist/api.mjs +782 -1
  16. package/dist/{artifact-HSwkIWEQ.mjs → artifact-8EY8SAPw.mjs} +240 -213
  17. package/dist/{artifact-D3czlUvT.mjs → artifact-DJPy518Y.mjs} +203 -164
  18. package/dist/artifact-platform-CXcmX_j3.mjs +27 -0
  19. package/dist/{browser-web-CA-F1GQo.mjs → browser-web-Bcv99PBM.mjs} +194 -64
  20. package/dist/budget-Cvwn54qV.mjs +9285 -0
  21. package/dist/{build-DYDbfkk5.mjs → build-CabC3G23.mjs} +153 -98
  22. package/dist/build-cache-Dv7RN200.mjs +602 -0
  23. package/dist/build-plan-DUC8Ka9y.mjs +248 -0
  24. package/dist/{cache-manifest-XH-fvDUj.mjs → cache-manifest-DSeQjt-Q.mjs} +2 -2
  25. package/dist/cache-manifest.mjs +1 -1
  26. package/dist/{ccache-zdKiYQ3E.mjs → ccache-Btwc36-I.mjs} +10 -9
  27. package/dist/{cdp-Dq_ypAlJ.mjs → cdp-3fwICjzi.mjs} +18 -5
  28. package/dist/{chrome-BnzZMqsR.mjs → chrome-Bbw689-6.mjs} +7 -4
  29. package/dist/{cli-CLP3diBm.mjs → cli-CHZa9Lvk.mjs} +20 -20
  30. package/dist/cli.mjs +1 -1
  31. package/dist/client-OyRoEuSr.mjs +1577 -0
  32. package/dist/collector-run.d.mts +4 -40
  33. package/dist/collector-run.mjs +9 -8
  34. package/dist/{command-output-BTy8hZ0F.mjs → command-output-gwpm28fu.mjs} +1 -1
  35. package/dist/config-DlrsduwG.mjs +955 -0
  36. package/dist/{created-devices-Dzd5C2LF.mjs → created-devices-x9rN6bhs.mjs} +14 -4
  37. package/dist/{dependency-state-DG0p31-y.mjs → dependency-state-1I9KZT1Y.mjs} +20 -5
  38. package/dist/{detached-entry-B9C_zeQC.mjs → detached-entry-BwNEtIrP.mjs} +1 -1
  39. package/dist/{dev-client-DAWVIGBu.mjs → dev-client-BSDR5h3F.mjs} +2 -2
  40. package/dist/{device-BECOiufl.mjs → device-B-L3Fbxy.mjs} +91 -34
  41. package/dist/device-DklWZLqb.mjs +1068 -0
  42. package/dist/{device-capacity-CBUAcRyQ.mjs → device-capacity-DK5_EwRS.mjs} +42 -13
  43. package/dist/device-host-worker.mjs +76 -79
  44. package/dist/{device-ios-COSi6oS1.mjs → device-ios-DoB6KFCO.mjs} +77 -51
  45. package/dist/{device-lease-run-Cw2M4z51.mjs → device-lease-run-xJPQ_QQG.mjs} +14 -26
  46. package/dist/{device-pool-Bf-pOhSw.mjs → device-pool-BMkdsefq.mjs} +5 -5
  47. package/dist/{doctor-kfMBnUw6.mjs → doctor-Bo7BXLux.mjs} +271 -320
  48. package/dist/{doctor-CB8oZKCk.mjs → doctor-D5_EzwfA.mjs} +186 -91
  49. package/dist/doctor-fingerprint-DZLoYFVb.mjs +16 -0
  50. package/dist/doctor-fingerprint.mjs +19 -0
  51. package/dist/doctor-thjWAV0z.mjs +2 -0
  52. package/dist/{doctor-watchman-BRyV2adA.mjs → doctor-watchman-N2wDotwQ.mjs} +40 -21
  53. package/dist/{eas-build-JyfqyHfC.mjs → eas-build-CwknaQYj.mjs} +53 -20
  54. package/dist/{build-plan-B7SZsc2N.mjs → eas-fallback-CSgAulr5.mjs} +41 -214
  55. package/dist/{watchman-CPQFZLXY.mjs → eas-session-ledger-DlY_serQ.mjs} +230 -11
  56. package/dist/{error-diagnostics-BR677IDM.mjs → error-diagnostics-DBWO2rxE.mjs} +172 -82
  57. package/dist/exec-DEoAhcze.mjs +858 -0
  58. package/dist/exec-DnYc4HGH.d.mts +78 -0
  59. package/dist/{gc-qWOMdnER.mjs → gc-CXxN-4SE.mjs} +1091 -1029
  60. package/dist/gc-DnNDQyaP.mjs +3 -0
  61. package/dist/{guide-G9cAbVAc.mjs → guide-Br0LEfKy.mjs} +1165 -297
  62. package/dist/{hosted-android-C3MHGld1.mjs → hosted-android-B-9f-jkd.mjs} +10 -8
  63. package/dist/{hosted-client-ZEKpS9vw.mjs → hosted-client-DZAPrcro.mjs} +34 -19
  64. package/dist/{hosted-ios-l-o3iM9J.mjs → hosted-ios-CsCS21hn.mjs} +1 -1
  65. package/dist/{hosted-logs-EzQM7-3Z.mjs → hosted-logs-FIRx9X2f.mjs} +77 -43
  66. package/dist/{hosted-macos-BACVAVqE.mjs → hosted-macos-_awYSpfv.mjs} +35 -22
  67. package/dist/{hosted-native-A4s1QPXe.mjs → hosted-native-BdzE668-.mjs} +49 -27
  68. package/dist/idle-C4cZ757K.d.mts +24 -0
  69. package/dist/{idle-shutdown-DtxhPTKe.mjs → idle-shutdown-DDg3SdvY.mjs} +11 -10
  70. package/dist/ios-CDvlmUs7.d.mts +24 -0
  71. package/dist/{ios-BwVCF7oA.mjs → ios-Ds1clbIt.mjs} +8 -8
  72. package/dist/{ios-device-D7pi2Sca.mjs → ios-device--h_-8ENa.mjs} +51 -26
  73. package/dist/{ios-device-B5veSDDQ.mjs → ios-device-BXZ0c7Kb.mjs} +1 -1
  74. package/dist/{ios-RkW4pnQf.mjs → ios-hcBpnEGk.mjs} +200 -93
  75. package/dist/{ios-Ce7bc7br.mjs → ios-pm4nL6By.mjs} +160 -108
  76. package/dist/{ios-project-K9hY_Jab.mjs → ios-project-CZhKODF3.mjs} +13 -13
  77. package/dist/ios-signing-BtAffm0A.mjs +489 -0
  78. package/dist/{ios-state-CBLe1xYw.mjs → ios-state-Dtw5K2aI.mjs} +1 -1
  79. package/dist/{ios-nOLJGVdy.mjs → ios-xtlRHaeB.mjs} +1 -1
  80. package/dist/{js-swap-Bb3nsS07.mjs → js-swap-Bwhh4S7V.mjs} +30 -25
  81. package/dist/{launch-C3qJ6Agb.mjs → launch-BjxemNpK.mjs} +85 -543
  82. package/dist/{launch-F4sOqAhB.mjs → launch-CCzXlc8r.mjs} +91 -90
  83. package/dist/logs-BfwwadsZ.mjs +479 -0
  84. package/dist/logs-jTS_lHSo.mjs +248 -0
  85. package/dist/{macos-D7uDvO-z.mjs → macos-DVlSSyUg.mjs} +1 -1
  86. package/dist/macos-NfV2D7dO.mjs +694 -0
  87. package/dist/macos-run.mjs +1 -1
  88. package/dist/maintenance-run.mjs +123 -248
  89. package/dist/{metro-DnCEjCxs.mjs → metro-DiXtA3Ty.mjs} +107 -30
  90. package/dist/metro-gateway-CKZqKqx7.mjs +209 -0
  91. package/dist/{named-ports-4WopRPg-.mjs → named-ports-DkEzOfzO.mjs} +42 -90
  92. package/dist/native-android-CqgnOgsT.mjs +645 -0
  93. package/dist/native-gradle-artifact-inputs-DHFnmrVf.mjs +270 -0
  94. package/dist/native-gradle-inputs-Dnh84Zbd.mjs +211 -0
  95. package/dist/native-inputs-TRTTTRxt.mjs +91 -0
  96. package/dist/native-run-NwUuxbkg.mjs +276 -0
  97. package/dist/{native-runtime-k8dTIrbK.mjs → native-runtime-B7KIafpM.mjs} +11 -9
  98. package/dist/native-source-Y0yLhFyQ.mjs +133 -0
  99. package/dist/{native-xcode-inputs-CykopJdM.mjs → native-xcode-inputs-D_VOfFL7.mjs} +26 -18
  100. package/dist/{native-xcode-ios-Bbf30Gm0.mjs → native-xcode-ios-BYDOHWLN.mjs} +104 -60
  101. package/dist/{ndjson-GOnbyvso.mjs → ndjson-CgE_o3Dl.mjs} +3 -3
  102. package/dist/offload-worker.d.mts +59 -41
  103. package/dist/offload-worker.mjs +478 -115
  104. package/dist/operation-exec-BW0em61G.mjs +171 -0
  105. package/dist/{ownership-DCtw_2IA.mjs → ownership-C5fo5Edb.mjs} +3 -3
  106. package/dist/{page-DRHy329N.mjs → page-DBL2PiUU.mjs} +12 -5
  107. package/dist/paths-BsJMoPP2.mjs +12 -0
  108. package/dist/paths-DQtTgsBf.mjs +42 -0
  109. package/dist/{placement-log-MOfPVgaM.mjs → placement-log-BnGgJRRZ.mjs} +5 -5
  110. package/dist/{plan-placement-V0TdzYXp.mjs → plan-placement-DIsMtN-d.mjs} +15 -11
  111. package/dist/{ports-DdSUicVo.mjs → ports-Cy1RkmuQ.mjs} +3 -3
  112. package/dist/prebuild-D4JoEAEs.mjs +484 -0
  113. package/dist/{project-_phNIJfs.mjs → project-wM_XFTvE.mjs} +65 -37
  114. package/dist/{pull-request-CQ8sPbZa.mjs → pull-request-W1IuLXDt.mjs} +102 -20
  115. package/dist/pull-request-eODyIqZF.d.mts +124 -0
  116. package/dist/pull-requests.d.mts +2 -120
  117. package/dist/pull-requests.mjs +2 -2
  118. package/dist/{react-native-android-CM1XRDwv.mjs → react-native-android-6OZ7MSM7.mjs} +121 -72
  119. package/dist/{gradle-DSrXb6lG.mjs → react-native-build-Dvd8hC21.mjs} +292 -15
  120. package/dist/react-native-doctor-DsoSF1Y9.mjs +234 -0
  121. package/dist/{react-native-ios-Dhq_eiYQ.mjs → react-native-ios-4u1Rn-GR.mjs} +71 -39
  122. package/dist/{recordings-D0d5aQt0.mjs → recordings-CQmfzAh7.mjs} +12 -9
  123. package/dist/registration-BcRgF6Ox.mjs +51 -0
  124. package/dist/{reload-C8JhxjSh.mjs → reload-BzkYabB-.mjs} +94 -47
  125. package/dist/reload-D7AVlb8N.mjs +2 -0
  126. package/dist/{remote-BiR6aYjy.mjs → remote-DjGDmlTZ.mjs} +26 -18
  127. package/dist/result-D2Ykz_iD.mjs +435 -0
  128. package/dist/{run-BtPgpKks.mjs → run-DidHghD1.mjs} +5 -5
  129. package/dist/selection-DSMbWEX2.mjs +620 -0
  130. package/dist/{server-bare-R2m_gsH8.mjs → server-bare-CafzuyFB.mjs} +3 -4
  131. package/dist/{server-command-CTtCkmcQ.mjs → server-command-C6QjeupS.mjs} +14 -7
  132. package/dist/{server-expo-DsguMGUF.mjs → server-expo-CrjB29pq.mjs} +54 -11
  133. package/dist/server-expo-D58c9L0M.mjs +2 -0
  134. package/dist/{settings-B717odTD.mjs → settings-C7O8A6ZI.mjs} +309 -119
  135. package/dist/settings-DpR-1Wnn.mjs +114 -0
  136. package/dist/settings-write-CzD60rOD.mjs +360 -0
  137. package/dist/settings.schema.json +176 -16
  138. package/dist/{simslim-CCr3rE-A.mjs → simslim-BNckWpXi.mjs} +14 -12
  139. package/dist/{slot-launch-DPt0m9Nd.mjs → slot-launch-CbfmNgM6.mjs} +15 -20
  140. package/dist/{spawn-entry-Dcb7sDUz.mjs → spawn-entry-jw19m8Nl.mjs} +0 -1
  141. package/dist/stage-Bps5oius.mjs +200 -0
  142. package/dist/{start-TXeMmmO2.mjs → start-Br-oxqMD.mjs} +1 -1
  143. package/dist/start-EojN4WFz.mjs +1364 -0
  144. package/dist/{state-D1Icyjlu.mjs → state--smjFSTL.mjs} +55 -13
  145. package/dist/{state-CG_OFoaA.mjs → state-08I3hw3_.mjs} +3 -2
  146. package/dist/{stats-BoY5sEPU.mjs → stats-D3GerlFW.mjs} +7 -13
  147. package/dist/stats-report-BzaPrRm6.mjs +16 -0
  148. package/dist/{status-BTA7kKiQ.mjs → status-BRROykC8.mjs} +7 -5
  149. package/dist/status-EvrK72L2.mjs +2 -0
  150. package/dist/{status-WgFbkRzj.mjs → status-WBDajew2.mjs} +554 -452
  151. package/dist/{status-watch-C23ILtf9.mjs → status-watch-Bg_u-pwR.mjs} +222 -25
  152. package/dist/status-worker.d.mts +1 -0
  153. package/dist/status-worker.mjs +19 -0
  154. package/dist/stim-desktop-D5OGpYZM.mjs +112 -0
  155. package/dist/{stop-DR6VoDIk.mjs → stop-DTZ9uTw3.mjs} +2 -2
  156. package/dist/{stop-DPEhunlw.mjs → stop-Dky10AEJ.mjs} +33 -23
  157. package/dist/{stop-BNmBMi1F.mjs → stop-Mv6W9FAk.mjs} +137 -98
  158. package/dist/supervisor-run.d.mts +8 -17
  159. package/dist/supervisor-run.mjs +56 -28
  160. package/dist/{support-CwjbFs9H.mjs → support-CNioewsd.mjs} +14 -14
  161. package/dist/{support-DMTqj3Hm.mjs → support-yUiOjnVY.mjs} +20 -13
  162. package/dist/swiftpm-artifact-inputs-DFcGsXDP.mjs +153 -0
  163. package/dist/swiftpm-macos-BIak-Rxv.mjs +532 -0
  164. package/dist/toolchain-BY8X8HXx.mjs +2 -0
  165. package/dist/toolchain-DpJMHq0n.mjs +876 -0
  166. package/dist/{trigger-CigAYjeL.mjs → trigger-Cbyc41d_.mjs} +21 -6
  167. package/dist/trigger-yb_nFzPF.mjs +2 -0
  168. package/dist/{warm-progress-BuY-Fvfn.mjs → warm-progress-CA3TgT3-.mjs} +263 -156
  169. package/dist/web-CZ07gd77.mjs +2 -0
  170. package/dist/{web-BDBMxDpx.mjs → web-DKx6yoFA.mjs} +20 -14
  171. package/dist/web-run.mjs +13 -12
  172. package/dist/windows-report.d.mts +1 -0
  173. package/dist/windows-report.mjs +18 -0
  174. package/dist/windows-report.ps1 +43 -0
  175. package/dist/{workspace-state-DJt_MMvf.mjs → workspace-state-U08dEzhG.mjs} +62 -58
  176. package/dist/{workspaces-C36s2jb9.mjs → workspaces-CpANmBlq.mjs} +1723 -1286
  177. package/dist/{worktree-CgvJYJ-Q.mjs → worktree-CHecZ4Oq.mjs} +1097 -547
  178. package/dist/worktree-ZqZVjD9K.mjs +2 -0
  179. package/dist/xcode-BXn9-xYx.mjs +896 -0
  180. package/package.json +7 -5
  181. package/shim/android-audio/Main.java +24 -0
  182. package/shim/android-audio/README.md +17 -0
  183. package/shim/android-audio.jar +0 -0
  184. package/shim/android-optimizations.gradle +7 -5
  185. package/dist/activity-BSV745Kz.mjs +0 -629
  186. package/dist/api-qvOzWyfO.mjs +0 -154
  187. package/dist/api-run.mjs +0 -294
  188. package/dist/app-install-BIKtMfPq.mjs +0 -896
  189. package/dist/artifact-lifecycle-DzPpBYvK.mjs +0 -30
  190. package/dist/budget-f7516Zk0.mjs +0 -4106
  191. package/dist/build-facts-DcLv2HSd.d.mts +0 -111
  192. package/dist/cancellation-C_22VQTH.mjs +0 -24
  193. package/dist/client-qQAaXSUs.mjs +0 -1771
  194. package/dist/config-BYDxlMY3.mjs +0 -562
  195. package/dist/device-DuiPJQSn.mjs +0 -290
  196. package/dist/device-lease-BX1sJQ2E.mjs +0 -1224
  197. package/dist/device-remote-xRT0Vmo9.mjs +0 -1272
  198. package/dist/eas-session-ledger-Cm0Gwq2F.mjs +0 -207
  199. package/dist/exec-DqKo9GKJ.mjs +0 -268
  200. package/dist/git-DDfFzkMm.mjs +0 -45
  201. package/dist/launch-verify-B6Q8hZP-.mjs +0 -428
  202. package/dist/logs-BGrEUaEs.mjs +0 -383
  203. package/dist/macos-Ch5VJmcS.mjs +0 -584
  204. package/dist/metro-gateway-CX9Xlkq2.mjs +0 -103
  205. package/dist/miss-reason-mKzZ4VvN.mjs +0 -238
  206. package/dist/native-android-D5qc3-_v.mjs +0 -226
  207. package/dist/native-gradle-inputs-BsLRrl7u.mjs +0 -349
  208. package/dist/ndjson-Du3j0AQ9.d.mts +0 -17
  209. package/dist/plan-C4TjdPsR.mjs +0 -260
  210. package/dist/prebuild-DYbucPXy.mjs +0 -212
  211. package/dist/preview-78a9kR_-.mjs +0 -1011
  212. package/dist/react-native-build-CtCccJtb.mjs +0 -239
  213. package/dist/react-native-doctor-CfRnFfjs.mjs +0 -78
  214. package/dist/remote-cache-OyOyVIS3.mjs +0 -526
  215. package/dist/result-CaJg5Iat.mjs +0 -186
  216. package/dist/server-expo-Bigriskl.mjs +0 -2
  217. package/dist/settings-BORNaaCO.mjs +0 -402
  218. package/dist/settings-vk3mJGSm.d.mts +0 -13
  219. package/dist/spawn-claims-DVS5RkMS.mjs +0 -72
  220. package/dist/stage-KNTQopqv.mjs +0 -157
  221. package/dist/start-BWqzODpb.mjs +0 -1116
  222. package/dist/stim-desktop-BzBN2Em2.mjs +0 -63
  223. package/dist/swiftpm-macos-DRNVJWlb.mjs +0 -119
  224. package/dist/tailnet-Dh-qiYzG.mjs +0 -265
  225. package/dist/toolchain-BFkAcstd.mjs +0 -2
  226. package/dist/toolchain-DxSsNssu.mjs +0 -1657
  227. package/dist/trigger-9_USgmxz.mjs +0 -2
  228. package/dist/web-Dq-i3wzJ.mjs +0 -2
  229. package/dist/worktree-DpLdCHga.mjs +0 -2
  230. package/dist/{api-run.d.mts → doctor-fingerprint.d.mts} +0 -0
  231. package/dist/{errors-DzkMYh8Q.mjs → errors-ccaPc4ox.mjs} +2 -2
@@ -1,18 +1,19 @@
1
- import { V as deviceSlotPlatforms, W as projectDeviceSlots, _ as loadConfig$1, d as getConfigDir, j as ownership_claim_exports, u as getConcurrencyLimits } from "./config-BYDxlMY3.mjs";
2
- import { g as deviceReclaimIdleMinutesSetting } from "./settings-B717odTD.mjs";
3
- import { w as workspaceLogsDir$1 } from "./workspace-state-DJt_MMvf.mjs";
4
- import { a as formatElapsed, l as phaseLine } from "./command-output-BTy8hZ0F.mjs";
5
- import { O as listAdbDevices } from "./android-Mz_Inn3w.mjs";
6
- import { T as canonicalPath, f as withIdleWorkspace } from "./workspaces-C36s2jb9.mjs";
7
- import { Nt as recordCapacityRefusal, Pt as recordCapacityWait } from "./budget-f7516Zk0.mjs";
8
- import { a as withWorkspaceProcessLock, o as workspaceProcessLockError } from "./named-ports-4WopRPg-.mjs";
9
- import { r as createNdjsonWriter } from "./ndjson-GOnbyvso.mjs";
10
- import { d as listAllIosSims, l as iosRuntimeMatches, y as parseRuntimeVersion } from "./ios-RkW4pnQf.mjs";
11
- import { n as dueIdleDevices, r as shutDownIdleDevices } from "./idle-shutdown-DtxhPTKe.mjs";
1
+ import { a as workspaceProcessLockError, i as withWorkspaceProcessLock, x as ownership_claim_exports } from "./exec-DEoAhcze.mjs";
2
+ import { m as workspaceLogsDir$1 } from "./paths-DQtTgsBf.mjs";
3
+ import { G as projectDeviceSlots, H as deviceSlotPlatforms, _ as loadConfig$1, d as getConfigDir, u as getConcurrencyLimits } from "./config-DlrsduwG.mjs";
4
+ import { a as formatElapsed, l as phaseLine } from "./command-output-gwpm28fu.mjs";
5
+ import { g as deviceReclaimIdleMinutesSetting } from "./settings-C7O8A6ZI.mjs";
6
+ import { r as createNdjsonWriter } from "./ndjson-CgE_o3Dl.mjs";
7
+ import { K as recordCapacityRefusal, q as recordCapacityWait } from "./budget-Cvwn54qV.mjs";
8
+ import { t as canonicalPath } from "./paths-BsJMoPP2.mjs";
9
+ import { f as withIdleWorkspace } from "./workspaces-CpANmBlq.mjs";
10
+ import { A as listAdbDevices, j as listAdbDevicesAsync } from "./android-C7sVmyI9.mjs";
11
+ import { d as listAllIosSims, f as listAllIosSimsAsync, l as iosRuntimeMatches, y as parseRuntimeVersion } from "./ios-hcBpnEGk.mjs";
12
+ import { n as dueIdleDevices, r as shutDownIdleDevices } from "./idle-shutdown-DDg3SdvY.mjs";
12
13
  import { realpathSync } from "node:fs";
13
14
  import { basename, join } from "node:path";
14
- import { DEVICE_RECLAIM_REASON, automaticMachineEnabled } from "@stim-cli/core/state";
15
15
  import { LOG_ROTATE_BYTES, workspaceId } from "@stim-cli/core";
16
+ import { DEVICE_RECLAIM_REASON, automaticMachineEnabled } from "@stim-cli/core/state";
16
17
  import { setTimeout } from "node:timers/promises";
17
18
  //#region src/devices/queue-reclaim.ts
18
19
  async function reclaimIdleDevice(root, idleMs, out, now, skipped) {
@@ -203,6 +204,34 @@ function countLiveOwnedDevices(sources = {}, { exclude = [] } = {}) {
203
204
  throw error;
204
205
  }
205
206
  }
207
+ async function listedAsync(source, empty) {
208
+ try {
209
+ return await source();
210
+ } catch (error) {
211
+ if (toolAbsent(error)) return empty;
212
+ throw new DeviceCountUnavailable("", { cause: error });
213
+ }
214
+ }
215
+ async function countLiveOwnedDevicesAsync(operation) {
216
+ try {
217
+ operation.signal.throwIfAborted();
218
+ const config = loadConfig$1();
219
+ const booting = readBootingDevices();
220
+ const [sims, adb] = await Promise.all([process.platform === "darwin" ? listedAsync(() => listAllIosSimsAsync({ timeoutMs: LISTING_TIMEOUT_MS }), []) : [], recordsOwnedEmulator(config) ? listedAsync(() => listAdbDevicesAsync({ timeoutMs: LISTING_TIMEOUT_MS }), NO_ADB) : NO_ADB]);
221
+ operation.signal.throwIfAborted();
222
+ return countLiveOwnedDevices({
223
+ config,
224
+ booting,
225
+ sims,
226
+ adb
227
+ });
228
+ } catch (error) {
229
+ operation.signal.throwIfAborted();
230
+ if ((0, ownership_claim_exports.isClaimRefusal)(error)) return { unknown: error.message };
231
+ if (error instanceof DeviceCountUnavailable) return { unknown: uncountedRefusal(error.cause).message };
232
+ throw error;
233
+ }
234
+ }
206
235
  function workspaceHasLiveDevice({ platform, project, slot = "default", sims = [], adbEmulators = [] } = {}) {
207
236
  if (!platform) return false;
208
237
  const record = deviceSlotPlatforms(project, slot)?.[platform];
@@ -586,4 +615,4 @@ function unknownAndroidDeviceProfileRefusal(requested, profiles) {
586
615
  };
587
616
  }
588
617
  //#endregion
589
- export { deviceTypeMismatch as a, runtimeMismatch as c, unknownIosDeviceTypeRefusal as d, unknownIosRuntimeRefusal as f, countLiveOwnedDevices as i, unknownAndroidDeviceProfileRefusal as l, DeviceAdmissionRefusal as n, layerNote as o, withDeviceBootAdmission as p, checkDeviceCapacity as r, peekDeviceSlots as s, DEFAULT_DEVICE_SLOT_WAIT_MS as t, unknownAndroidSystemImageRefusal as u };
618
+ export { countLiveOwnedDevicesAsync as a, peekDeviceSlots as c, unknownAndroidSystemImageRefusal as d, unknownIosDeviceTypeRefusal as f, countLiveOwnedDevices as i, runtimeMismatch as l, withDeviceBootAdmission as m, DeviceAdmissionRefusal as n, deviceTypeMismatch as o, unknownIosRuntimeRefusal as p, checkDeviceCapacity as r, layerNote as s, DEFAULT_DEVICE_SLOT_WAIT_MS as t, unknownAndroidDeviceProfileRefusal as u };
@@ -1,25 +1,27 @@
1
- import { D as withConfigLock$1, _ as loadConfig$1, c as ensureConfig, k as process_identity_exports } from "./config-BYDxlMY3.mjs";
2
- import { t as getExecutor } from "./exec-DqKo9GKJ.mjs";
3
- import { t as spawnEntry } from "./spawn-entry-Dcb7sDUz.mjs";
4
- import { c as writeWorkspaceState, p as ensureWorkspaceStorage } from "./workspace-state-DJt_MMvf.mjs";
5
- import { A as listAvds, B as ownedAvdSystemImage, D as hostSystemImageArch, E as getAvdNameForSerial, J as resolveOwnedAvdSerial, O as listAdbDevices, R as ownedAvdName, W as pickDefaultSystemImage, _ as avdStorageRoots, a as androidDeviceAbi, b as createOwnedAvd, d as androidToolPath, f as assertOwnedAvdStopped, h as avdPathExists, j as listInstalledSystemImages, k as listAvdDeviceProfiles, q as resetAdoptedAvd, t as DEFAULT_AVD_DEVICE_PROFILE, tt as waitForBoot, v as bootAndroidEmulator } from "./android-Mz_Inn3w.mjs";
6
- import { t as forgetCreatedDevice } from "./created-devices-Dzd5C2LF.mjs";
7
- import { b as teardownOwnedIosSim, v as teardownOwnedAvd } from "./workspaces-C36s2jb9.mjs";
8
- import { r as createNdjsonWriter } from "./ndjson-GOnbyvso.mjs";
9
- import { C as resetIosKeychain, P as readHostMemoryPressure, T as resolveIosCreation, a as createOwnedIosSim, d as listAllIosSims, g as listUserApps, k as uninstallIosApp, n as bootIosSim, w as resetIosPrivacy } from "./ios-RkW4pnQf.mjs";
10
- import { i as macosProcess, o as requiredMacosRecord } from "./state-CG_OFoaA.mjs";
11
- import { S as launchIosApp, T as writeDebugHttpHost, b as launchAndroidApp, g as installAndroidApp, s as androidAppProcess, v as installIosApp, w as reverseMetroPorts, x as launchAndroidReleaseApp, y as iosAppProcess } from "./app-install-BIKtMfPq.mjs";
12
- import { i as countLiveOwnedDevices } from "./device-capacity-CBUAcRyQ.mjs";
13
- import { _ as findAapt } from "./support-DMTqj3Hm.mjs";
14
- import { n as parseLogcatLine, r as parsePidof, t as androidClockOffset } from "./android-HqP1_vB_.mjs";
15
- import { r as stopMacosAppHeld } from "./stop-DPEhunlw.mjs";
16
- import { n as parseLogStreamLine } from "./ios-nOLJGVdy.mjs";
17
- import { chmodSync, closeSync, copyFileSync, createReadStream, existsSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statfsSync, symlinkSync, writeFileSync } from "node:fs";
18
- import { dirname, isAbsolute, join, posix, relative, sep } from "node:path";
19
- import { assertHostedDeviceLedger, hostedAppArea, hostedAppAttempt, hostedAppBlobs, hostedConsolePort, hostedMacosAppSlot, hostedMacosBundleId, hostedNativeLogsDir, isJsonObject, parseHostedOfferRequest, readHostedApp, readHostedAppMetadata, readHostedDevice, readHostedNativeLogsCheckpoint, readMacosRecord, readNdjsonGenerations } from "@stim-cli/core/state";
20
- import { LOG_ROTATE_BYTES, configDir, withDirLock } from "@stim-cli/core";
1
+ import { t as getExecutor } from "./exec-DEoAhcze.mjs";
2
+ import { n as ensureWorkspaceStorage } from "./paths-DQtTgsBf.mjs";
3
+ import { O as withConfigLockAsync$1, _ as loadConfig$1, c as ensureConfig } from "./config-DlrsduwG.mjs";
4
+ import { d as writeWorkspaceState } from "./workspace-state-U08dEzhG.mjs";
5
+ import { i as macosProcess, o as requiredMacosRecord } from "./state-08I3hw3_.mjs";
6
+ import { r as createNdjsonWriter } from "./ndjson-CgE_o3Dl.mjs";
7
+ import { Cn as launchAndroidApp, Dn as reverseMetroPorts, On as writeDebugHttpHost, Sn as iosAppProcess, Tn as launchIosApp, dn as androidAppProcess, wn as launchAndroidReleaseApp, xn as installIosApp, yn as installAndroidApp } from "./budget-Cvwn54qV.mjs";
8
+ import { D as teardownOwnedAvd, k as teardownOwnedIosSim } from "./workspaces-CpANmBlq.mjs";
9
+ import { t as forgetCreatedDevice } from "./created-devices-x9rN6bhs.mjs";
10
+ import { $ as resetAdoptedAvd, A as listAdbDevices, D as getAvdNameForSerial, F as listAvdsAsync, I as listInstalledSystemImages, K as ownedAvdSystemImage, M as listAvdDeviceProfiles, O as getAvdNameForSerialAsync, U as ownedAvdName, X as pickDefaultSystemImage, a as androidDeviceAbi, d as androidToolPath, et as resolveOwnedAvdSerialAsync, f as assertOwnedAvdStopped, g as avdPathExists, k as hostSystemImageArch, ot as waitForBoot, t as DEFAULT_AVD_DEVICE_PROFILE, v as avdStorageRoots, x as createOwnedAvd, y as bootAndroidEmulator } from "./android-C7sVmyI9.mjs";
11
+ import { C as resetIosKeychain, P as readHostMemoryPressure, T as resolveIosCreation, a as createOwnedIosSim, d as listAllIosSims, g as listUserApps, k as uninstallIosApp, n as bootIosSim, w as resetIosPrivacy } from "./ios-hcBpnEGk.mjs";
12
+ import { r as stopMacosAppHeld } from "./stop-Dky10AEJ.mjs";
13
+ import { t as spawnEntry } from "./spawn-entry-jw19m8Nl.mjs";
14
+ import { i as countLiveOwnedDevices } from "./device-capacity-DK5_EwRS.mjs";
15
+ import { n as parseLogcatLine, r as parsePidof, t as androidClockOffset } from "./android-DR5lZ2Az.mjs";
16
+ import { _ as findAapt } from "./support-yUiOjnVY.mjs";
17
+ import { t as waitForMacosRegistration } from "./registration-BcRgF6Ox.mjs";
18
+ import { n as parseLogStreamLine } from "./ios-xtlRHaeB.mjs";
21
19
  import { createHash, randomUUID } from "node:crypto";
20
+ import { chmodSync, closeSync, copyFileSync, createReadStream, existsSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statfsSync, symlinkSync, writeFileSync } from "node:fs";
22
21
  import { availableParallelism, freemem, homedir, loadavg } from "node:os";
22
+ import { dirname, isAbsolute, join, posix, relative, sep } from "node:path";
23
+ import { LOG_ROTATE_BYTES, configDir, withDirLock, withDirLockAsync } from "@stim-cli/core";
24
+ import { assertHostedDeviceLedger, hostedAppArea, hostedAppAttempt, hostedAppBlobs, hostedConsolePort, hostedMacosAppSlot, hostedMacosBundleId, hostedNativeLogsDir, isJsonObject, parseHostedOfferRequest, readHostedApp, readHostedAppMetadata, readHostedDevice, readHostedNativeLogsCheckpoint, readNdjsonGenerations } from "@stim-cli/core/state";
23
25
  //#region src/device-host/android-app.ts
24
26
  async function digest$1(path) {
25
27
  const hash = createHash("sha256");
@@ -60,7 +62,7 @@ async function installHostedAndroidApp(home, session, attempt, device, metro) {
60
62
  if (nativeCode !== void 0 && !nativeCode.split(/\s+/).includes(`'${device.architecture}'`)) throw new Error("The APK has no native library slice for the hosted emulator architecture.");
61
63
  assertHostedAndroidTarget(home, device);
62
64
  const sdkExecutor = hostedAndroidExecutor();
63
- const installed = installAndroidApp({
65
+ const installed = await installAndroidApp({
64
66
  serial: device.serial,
65
67
  apkPath: apk,
66
68
  packageName: record.bundleId
@@ -68,14 +70,14 @@ async function installHostedAndroidApp(home, session, attempt, device, metro) {
68
70
  if (!installed.ok) throw new Error(installed.reason ?? "Hosted APK installation was not established.");
69
71
  assertHostedAndroidTarget(home, device);
70
72
  if (record.mode === "development" && !metro) throw new Error("Hosted Android development launch requires its Metro bridge.");
71
- const launched = record.mode === "development" && metro ? launchAndroidApp({
73
+ const launched = record.mode === "development" && metro ? await launchAndroidApp({
72
74
  serial: device.serial,
73
75
  packageName: record.bundleId,
74
76
  metroPort: metro.devicePort,
75
77
  bridgePort: metro.bridgePort,
76
78
  physical: true,
77
79
  devClientScheme: record.devClientScheme
78
- }, { exec: sdkExecutor }) : launchAndroidReleaseApp({
80
+ }, { exec: sdkExecutor }) : await launchAndroidReleaseApp({
79
81
  serial: device.serial,
80
82
  packageName: record.bundleId
81
83
  }, { exec: sdkExecutor });
@@ -83,7 +85,7 @@ async function installHostedAndroidApp(home, session, attempt, device, metro) {
83
85
  if (record.mode === "development") return "unverified";
84
86
  for (let tries = 0; tries < 10; tries++) {
85
87
  await new Promise((resolve) => setTimeout(resolve, 200));
86
- if (androidAppProcess(device.serial, record.bundleId, { exec: sdkExecutor }).state === "running") return true;
88
+ if ((await androidAppProcess(device.serial, record.bundleId, { exec: sdkExecutor })).state === "running") return true;
87
89
  }
88
90
  return "unverified";
89
91
  }
@@ -99,24 +101,27 @@ function assertHostedAndroidTarget(home, device) {
99
101
  function hostedAndroidExecutor() {
100
102
  const executor = getExecutor();
101
103
  const adb = androidToolPath("adb");
104
+ const tool = (file) => file === "adb" ? adb : file;
102
105
  return {
103
106
  ...executor,
104
- runFile: (file, args, options) => executor.runFile(file === "adb" ? adb : file, args, options)
107
+ runFile: (file, args, options) => executor.runFile(tool(file), args, options),
108
+ runFileAsync: (file, args, options) => executor.runFileAsync(tool(file), args, options),
109
+ runFileQuietAsync: (file, args, options) => executor.runFileQuietAsync(tool(file), args, options)
105
110
  };
106
111
  }
107
- function restoreHostedAndroidMetro(home, session, attempt, device, metro) {
112
+ async function restoreHostedAndroidMetro(home, session, attempt, device, metro) {
108
113
  const record = readHostedApp(session, attempt, home);
109
114
  if (record.state !== "installed" || record.mode !== "development") throw new Error("Metro restore requires an installed development app.");
110
115
  assertHostedAndroidTarget(home, device);
111
116
  const exec = hostedAndroidExecutor();
112
- const reversed = reverseMetroPorts({
117
+ const reversed = await reverseMetroPorts({
113
118
  serial: device.serial,
114
119
  metroPort: metro.bridgePort,
115
120
  devicePorts: [metro.devicePort]
116
121
  }, { exec });
117
122
  if (reversed.failed) throw new Error(reversed.reason);
118
123
  assertHostedAndroidTarget(home, device);
119
- writeDebugHttpHost({
124
+ await writeDebugHttpHost({
120
125
  serial: device.serial,
121
126
  packageName: record.bundleId,
122
127
  metroPort: metro.devicePort,
@@ -501,7 +506,7 @@ async function installHostedApp(home, session, attempt, device, metroPort) {
501
506
  if (!/^\s*platform\s+IOSSIMULATOR\s*$/m.test(build) || !minimum || newer(minimum, device.runtime) || newer(plist("MinimumOSVersion"), device.runtime)) throw new Error("The executable platform or minimum OS is incompatible with the hosted simulator.");
502
507
  assertHostedDeviceLedger(home, device.udid);
503
508
  if (readHostedDevice(home).udid !== device.udid) throw new Error("The hosted device identity changed.");
504
- const installed = installIosApp({
509
+ const installed = await installIosApp({
505
510
  udid: device.udid,
506
511
  appPath: app,
507
512
  bundleId: record.bundleId,
@@ -511,7 +516,7 @@ async function installHostedApp(home, session, attempt, device, metroPort) {
511
516
  if (!installed.ok) throw new Error(installed.reason ?? "Hosted app installation was not established.");
512
517
  assertHostedDeviceLedger(home, device.udid);
513
518
  if (readHostedDevice(home).udid !== device.udid) throw new Error("The hosted device identity changed.");
514
- const launched = launchIosApp({
519
+ const launched = await launchIosApp({
515
520
  udid: device.udid,
516
521
  bundleId: record.bundleId,
517
522
  metroPort: record.mode === "development" ? metroPort ?? null : null,
@@ -521,7 +526,7 @@ async function installHostedApp(home, session, attempt, device, metroPort) {
521
526
  if (record.mode === "development") return "unverified";
522
527
  for (let tries = 0; tries < 10; tries++) {
523
528
  await new Promise((resolve) => setTimeout(resolve, 200));
524
- if (iosAppProcess(device.udid, record.bundleId).state === "running") return true;
529
+ if ((await iosAppProcess(device.udid, record.bundleId)).state === "running") return true;
525
530
  }
526
531
  return "unverified";
527
532
  }
@@ -530,10 +535,10 @@ async function installHostedApp(home, session, attempt, device, metroPort) {
530
535
  function inventory() {
531
536
  return listAllIosSims({ includeUnavailable: true });
532
537
  }
533
- function selectHostedIosDevice(selectors) {
538
+ async function selectHostedIosDevice(selectors) {
534
539
  inventory();
535
540
  if (readHostMemoryPressure(getExecutor()) !== "normal") throw new Error("Host memory pressure is unknown or elevated.");
536
- const selected = resolveIosCreation(selectors);
541
+ const selected = await resolveIosCreation(selectors);
537
542
  if (!selected.deviceType || !selected.runtime) throw new Error("The installed simulator type or runtime could not be established.");
538
543
  if (process.arch !== "arm64" && process.arch !== "x64") throw new Error("Unsupported simulator host architecture.");
539
544
  return {
@@ -553,15 +558,15 @@ async function runHostedDevice(mode, selectors, app) {
553
558
  if (mode === "prepare") {
554
559
  creationStarted = existsSync(join(home, "hosted-device.json")) || existsSync(join(home, "created-devices.json"));
555
560
  if (creationStarted) throw new Error("This hosted worker home already has a device record. Attach or stop its existing session.");
556
- const selected = selectHostedIosDevice(selectors);
561
+ const selected = await selectHostedIosDevice(selectors);
557
562
  creationStarted = true;
558
- const created = createOwnedIosSim("hosted", {}, selected);
563
+ const created = await createOwnedIosSim("hosted", {}, selected);
559
564
  device = {
560
565
  ...selected,
561
566
  udid: created.udid,
562
567
  name: created.name
563
568
  };
564
- withDirLock(join(home, "hosted-device.lock"), () => {
569
+ await withDirLockAsync(join(home, "hosted-device.lock"), () => {
565
570
  const temporary = join(home, "hosted-device.json.tmp");
566
571
  writeFileSync(temporary, JSON.stringify(device), { mode: 384 });
567
572
  renameSync(temporary, join(home, "hosted-device.json"));
@@ -581,7 +586,7 @@ async function runHostedDevice(mode, selectors, app) {
581
586
  if (!current || !current.available || !current.name.startsWith("stim-") || current.name !== device.name || current.state !== "Shutdown") throw new Error("The parked hosted simulator is missing, renamed or not Shutdown.");
582
587
  let choice;
583
588
  try {
584
- choice = selectHostedIosDevice(selectors);
589
+ choice = await selectHostedIosDevice(selectors);
585
590
  } catch (error) {
586
591
  if (mode === "inspect") return {
587
592
  state: "incompatible",
@@ -603,10 +608,10 @@ async function runHostedDevice(mode, selectors, app) {
603
608
  };
604
609
  await bootIosSim(device.udid, { openViewer: false });
605
610
  if (inventory().find((sim) => sim.udid === device.udid)?.state !== "Booted") throw new Error("Hosted simulator boot could not be verified.");
606
- resetIosPrivacy(device.udid);
607
- resetIosKeychain(device.udid);
608
- for (const bundleId of listUserApps(device.udid)) uninstallIosApp(device.udid, bundleId);
609
- withDirLock(join(home, "hosted-device.lock"), () => {
611
+ await resetIosPrivacy(device.udid);
612
+ await resetIosKeychain(device.udid);
613
+ for (const bundleId of await listUserApps(device.udid)) await uninstallIosApp(device.udid, bundleId);
614
+ await withDirLockAsync(join(home, "hosted-device.lock"), () => {
610
615
  const temporary = join(home, "hosted-device.json.tmp");
611
616
  writeFileSync(temporary, JSON.stringify(device), { mode: 384 });
612
617
  renameSync(temporary, join(home, "hosted-device.json"));
@@ -618,7 +623,7 @@ async function runHostedDevice(mode, selectors, app) {
618
623
  };
619
624
  }
620
625
  if (mode === "park") {
621
- const outcome = teardownOwnedIosSim(device.udid);
626
+ const outcome = await teardownOwnedIosSim(device.udid);
622
627
  if (outcome.status !== "torn-down" || inventory().find((sim) => sim.udid === device.udid)?.state !== "Shutdown") throw new Error(outcome.reason ?? "Hosted simulator shutdown could not be verified.");
623
628
  removeHostedAppData(home, { keepBlobs: true });
624
629
  return {
@@ -643,7 +648,7 @@ async function runHostedDevice(mode, selectors, app) {
643
648
  device
644
649
  };
645
650
  }
646
- const outcome = teardownOwnedIosSim(device.udid, { del: true });
651
+ const outcome = await teardownOwnedIosSim(device.udid, { del: true });
647
652
  if (outcome.status !== "torn-down" && outcome.status !== "missing") throw new Error(outcome.reason ?? "Hosted simulator teardown was not established.");
648
653
  const after = inventory().find((sim) => sim.udid === device.udid);
649
654
  if (after) throw new Error(`Hosted simulator ${device.udid} is still listed (${after.state}); deletion could not be verified. If its runtime is unavailable, delete it with xcrun simctl delete and stop the session again.`);
@@ -696,7 +701,7 @@ async function runHostedAndroidDevice(mode, request, app) {
696
701
  } : void 0;
697
702
  if (mode === "reverse") {
698
703
  if (!metro) throw new Error("Hosted Android Metro restore needs its bridge and device ports.");
699
- restoreHostedAndroidMetro(home, request.session, app.attempt, device, metro);
704
+ await restoreHostedAndroidMetro(home, request.session, app.attempt, device, metro);
700
705
  return {
701
706
  state: "ready",
702
707
  device
@@ -715,7 +720,7 @@ async function runHostedAndroidDevice(mode, request, app) {
715
720
  if (!/^[a-f0-9-]{36}$/.test(request.session) || !hostedConsolePort(request.consolePort)) throw new Error("Hosted Android prepare needs its server-selected session and console port.");
716
721
  const choice = selectHostedAndroidDevice(request);
717
722
  const avdName = ownedAvdName(`hosted-${request.session}`);
718
- if (listAvds({ timeoutMs: 5e3 }).includes(avdName) || portIsOccupied(request.consolePort)) throw new Error("The hosted AVD name or selected console port is already in use.");
723
+ if ((await listAvdsAsync({ timeoutMs: 5e3 })).includes(avdName) || portIsOccupied(request.consolePort)) throw new Error("The hosted AVD name or selected console port is already in use.");
719
724
  const selected = {
720
725
  avdName,
721
726
  serial: `emulator-${request.consolePort}`,
@@ -742,7 +747,7 @@ async function runHostedAndroidDevice(mode, request, app) {
742
747
  });
743
748
  assertHostedDeviceLedger(home, avdName, "android");
744
749
  if (portIsOccupied(selected.consolePort)) throw new Error("The selected Android console port became occupied.");
745
- bootAndroidEmulator(avdName, selected.consolePort, {
750
+ await bootAndroidEmulator(avdName, selected.consolePort, {
746
751
  openViewer: false,
747
752
  logFile: join(home, "emulator.log")
748
753
  });
@@ -756,7 +761,7 @@ async function runHostedAndroidDevice(mode, request, app) {
756
761
  packageManager
757
762
  })}`);
758
763
  }
759
- if (getAvdNameForSerial(selected.serial) !== avdName || androidDeviceAbi(selected.serial) !== selected.architecture) throw new Error("Hosted Android boot could not be verified for its exact owned AVD.");
764
+ if (await getAvdNameForSerialAsync(selected.serial) !== avdName || androidDeviceAbi(selected.serial) !== selected.architecture) throw new Error("Hosted Android boot could not be verified for its exact owned AVD.");
760
765
  return {
761
766
  state: "ready",
762
767
  device: selected
@@ -765,10 +770,10 @@ async function runHostedAndroidDevice(mode, request, app) {
765
770
  device = readHostedDevice(home, "android");
766
771
  const ledger = assertHostedDeviceLedger(home, device.avdName, "android", { allowEmpty: mode === "stop" });
767
772
  if (mode === "inspect" || mode === "adopt") {
768
- if (device.avdName !== ownedAvdName(`hosted-${request.session}`) || !listAvds({ timeoutMs: 5e3 }).includes(device.avdName)) throw new Error("The parked hosted AVD is missing or names another session.");
769
- if (!resolveOwnedAvdSerial(device.avdName, { timeoutMs: 5e3 }).notRunning) throw new Error("The parked hosted AVD is missing, not owned or running.");
773
+ if (device.avdName !== ownedAvdName(`hosted-${request.session}`) || !(await listAvdsAsync({ timeoutMs: 5e3 })).includes(device.avdName)) throw new Error("The parked hosted AVD is missing or names another session.");
774
+ if (!(await resolveOwnedAvdSerialAsync(device.avdName, { timeoutMs: 5e3 })).notRunning) throw new Error("The parked hosted AVD is missing, not owned or running.");
770
775
  assertOwnedAvdStopped(device.avdName);
771
- if (getAvdNameForSerial(device.serial) === device.avdName) throw new Error("The parked hosted emulator is still running.");
776
+ if (await getAvdNameForSerialAsync(device.serial) === device.avdName) throw new Error("The parked hosted emulator is still running.");
772
777
  if (ownedAvdSystemImage(device.avdName) !== device.systemImage) throw new Error("The parked hosted AVD system image no longer matches its device record.");
773
778
  let choice;
774
779
  try {
@@ -798,12 +803,12 @@ async function runHostedAndroidDevice(mode, request, app) {
798
803
  consolePort: request.consolePort,
799
804
  serial: `emulator-${request.consolePort}`
800
805
  };
801
- withDirLock(join(home, "hosted-device.lock"), () => {
806
+ await withDirLockAsync(join(home, "hosted-device.lock"), () => {
802
807
  const temporary = join(home, "hosted-device.json.tmp");
803
808
  writeFileSync(temporary, JSON.stringify(device), { mode: 384 });
804
809
  renameSync(temporary, join(home, "hosted-device.json"));
805
810
  });
806
- bootAndroidEmulator(device.avdName, device.consolePort, {
811
+ await bootAndroidEmulator(device.avdName, device.consolePort, {
807
812
  openViewer: false,
808
813
  logFile: join(home, "emulator.log")
809
814
  });
@@ -817,7 +822,7 @@ async function runHostedAndroidDevice(mode, request, app) {
817
822
  packageManager
818
823
  })}`);
819
824
  }
820
- if (getAvdNameForSerial(device.serial) !== device.avdName || androidDeviceAbi(device.serial) !== device.architecture) throw new Error("Hosted Android boot could not be verified for its exact owned AVD.");
825
+ if (await getAvdNameForSerialAsync(device.serial) !== device.avdName || androidDeviceAbi(device.serial) !== device.architecture) throw new Error("Hosted Android boot could not be verified for its exact owned AVD.");
821
826
  await resetAdoptedAvd(device.avdName, device.serial, "");
822
827
  removeHostedAppData(home, { keepBlobs: true });
823
828
  return {
@@ -826,10 +831,10 @@ async function runHostedAndroidDevice(mode, request, app) {
826
831
  };
827
832
  }
828
833
  if (mode === "park") {
829
- const outcome = teardownOwnedAvd(device.avdName, {});
834
+ const outcome = await teardownOwnedAvd(device.avdName, {});
830
835
  if (outcome.status !== "torn-down") throw new Error(outcome.reason ?? "Hosted Android shutdown was not established.");
831
836
  assertOwnedAvdStopped(device.avdName);
832
- if (getAvdNameForSerial(device.serial) === device.avdName) throw new Error("The hosted Android emulator is still running.");
837
+ if (await getAvdNameForSerialAsync(device.serial) === device.avdName) throw new Error("The hosted Android emulator is still running.");
833
838
  removeHostedAppData(home, { keepBlobs: true });
834
839
  return {
835
840
  state: "parked",
@@ -837,15 +842,15 @@ async function runHostedAndroidDevice(mode, request, app) {
837
842
  };
838
843
  }
839
844
  if (ledger === "listed") {
840
- withConfigLock$1(() => {
845
+ await withConfigLockAsync$1(() => {
841
846
  if (!loadConfig$1()) ensureConfig();
842
847
  });
843
- const outcome = teardownOwnedAvd(device.avdName, { del: true });
848
+ const outcome = await teardownOwnedAvd(device.avdName, { del: true });
844
849
  if (outcome.status !== "torn-down" && outcome.status !== "missing") throw new Error(outcome.reason ?? "Hosted Android deletion was not established.");
845
850
  }
846
851
  const name = device.avdName;
847
- if (listAvds({ timeoutMs: 5e3 }).includes(name) || avdStorageRoots().some((root) => avdPathExists(join(root, `${name}.ini`)) || avdPathExists(join(root, `${name}.avd`)))) throw new Error("The hosted AVD or its data still exists; deletion could not be verified.");
848
- if (getAvdNameForSerial(device.serial) === device.avdName) throw new Error("The hosted Android emulator is still running.");
852
+ if ((await listAvdsAsync({ timeoutMs: 5e3 })).includes(name) || avdStorageRoots().some((root) => avdPathExists(join(root, `${name}.ini`)) || avdPathExists(join(root, `${name}.avd`)))) throw new Error("The hosted AVD or its data still exists; deletion could not be verified.");
853
+ if (await getAvdNameForSerialAsync(device.serial) === device.avdName) throw new Error("The hosted Android emulator is still running.");
849
854
  if (ledger === "listed") forgetCreatedDevice("android", device.avdName);
850
855
  removeHostedAppData(home);
851
856
  return {
@@ -1067,7 +1072,6 @@ async function runHostedMacosApp(mode, request, app) {
1067
1072
  });
1068
1073
  const fd = openSync(join(home, "macos-supervisor.log"), "a", 384);
1069
1074
  let child;
1070
- let spawnError;
1071
1075
  const env = {};
1072
1076
  for (const key of [
1073
1077
  "PATH",
@@ -1095,31 +1099,24 @@ async function runHostedMacosApp(mode, request, app) {
1095
1099
  stdio: [
1096
1100
  "ignore",
1097
1101
  fd,
1098
- fd
1102
+ fd,
1103
+ "ipc"
1099
1104
  ],
1100
1105
  cwd: canonicalRunRoot,
1101
1106
  env
1102
1107
  });
1103
- child.once("error", (error) => {
1104
- spawnError = error;
1105
- });
1106
1108
  child.unref();
1107
1109
  } finally {
1108
1110
  closeSync(fd);
1109
1111
  }
1110
1112
  const deadline = Date.now() + 2e4;
1111
- while (Date.now() < deadline) {
1112
- if (spawnError) throw spawnError;
1113
- const current = readMacosRecord(canonicalRunRoot);
1114
- if (current?.launchId === launch.launchId && current.app && current.supervisor && (0, process_identity_exports.inspectProcessIdentity)(current.app) === "same" && (0, process_identity_exports.inspectProcessIdentity)(current.supervisor) === "same") return {
1115
- state: "installed",
1116
- device,
1117
- launched: true,
1118
- pid: current.app.pid
1119
- };
1120
- if (child.exitCode !== null || child.signalCode !== null) break;
1121
- await new Promise((resolve) => setTimeout(resolve, 100));
1122
- }
1113
+ const current = await waitForMacosRegistration(canonicalRunRoot, launch.launchId, child, deadline);
1114
+ if (current?.app) return {
1115
+ state: "installed",
1116
+ device,
1117
+ launched: true,
1118
+ pid: current.app.pid
1119
+ };
1123
1120
  throw new Error("The hosted macOS app did not register. See macos-supervisor.log in the worker home.");
1124
1121
  } catch (error) {
1125
1122
  return {
@@ -1131,7 +1128,7 @@ async function runHostedMacosApp(mode, request, app) {
1131
1128
  }
1132
1129
  //#endregion
1133
1130
  //#region src/device-host/offer.ts
1134
- function inspectHostedDevice(request, options) {
1131
+ async function inspectHostedDevice(request, options) {
1135
1132
  const cpus = availableParallelism();
1136
1133
  let workerDiskFreeBytes = null;
1137
1134
  try {
@@ -1156,7 +1153,7 @@ function inspectHostedDevice(request, options) {
1156
1153
  declined: null
1157
1154
  } : request.platform === "ios" ? {
1158
1155
  platform: "ios",
1159
- choice: selectHostedIosDevice(request),
1156
+ choice: await selectHostedIosDevice(request),
1160
1157
  resources,
1161
1158
  declined: null
1162
1159
  } : {
@@ -1209,7 +1206,7 @@ async function main() {
1209
1206
  if (input.mode === "offer") {
1210
1207
  const request = parseHostedOfferRequest(input);
1211
1208
  if (!request) throw new Error("Invalid hosted offer selectors.");
1212
- process.stdout.write(`${JSON.stringify(inspectHostedDevice(request, exclude ? { exclude } : void 0))}\n`);
1209
+ process.stdout.write(`${JSON.stringify(await inspectHostedDevice(request, exclude ? { exclude } : void 0))}\n`);
1213
1210
  return;
1214
1211
  }
1215
1212
  if (process.platform !== "darwin") {