stim 1.20.2 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/README.md +88 -8
  2. package/dist/acquire-artifact-CD4lbiWE.mjs +153 -0
  3. package/dist/act-DHAw2A2S.mjs +2667 -0
  4. package/dist/activity-BzVfHSrY.mjs +1376 -0
  5. package/dist/{agent-device-usage-output-Dzgv6lgR.mjs → agent-device-usage-output-zh1vhbLp.mjs} +21 -65
  6. package/dist/{android-HqP1_vB_.mjs → android-BEJ8Jpl7.mjs} +2 -2
  7. package/dist/{android-DCKZrNvV.mjs → android-BLgbNqox.mjs} +128 -78
  8. package/dist/{android-Dlzxshgp.mjs → android-CV_GCELZ.mjs} +5 -5
  9. package/dist/{android-Mz_Inn3w.mjs → android-DUYkNF4u.mjs} +184 -102
  10. package/dist/{android-cas-Bl-cLJBk.mjs → android-cas-Ct5b1xCK.mjs} +7 -6
  11. package/dist/android-cas-compiler.mjs +2 -2
  12. package/dist/android-project-BCAAmMwz.mjs +12 -0
  13. package/dist/api.d.mts +740 -8
  14. package/dist/api.mjs +585 -1
  15. package/dist/{artifact-HSwkIWEQ.mjs → artifact-B8T3S5gi.mjs} +223 -201
  16. package/dist/{artifact-D3czlUvT.mjs → artifact-DAuZ-FNU.mjs} +158 -148
  17. package/dist/{browser-web-CA-F1GQo.mjs → browser-web-QQzVjz3O.mjs} +26 -24
  18. package/dist/budget-Bs6SxxzO.mjs +9154 -0
  19. package/dist/{build-DYDbfkk5.mjs → build-CoPzQRNw.mjs} +144 -96
  20. package/dist/build-cache-DmyR9Zzc.mjs +602 -0
  21. package/dist/build-plan-CaFskB7_.mjs +188 -0
  22. package/dist/{cache-manifest-XH-fvDUj.mjs → cache-manifest-DkkqguoK.mjs} +2 -2
  23. package/dist/cache-manifest.mjs +1 -1
  24. package/dist/{ccache-zdKiYQ3E.mjs → ccache-BJRZ9pG3.mjs} +10 -9
  25. package/dist/{cdp-Dq_ypAlJ.mjs → cdp-CWmIUMbw.mjs} +18 -5
  26. package/dist/{chrome-BnzZMqsR.mjs → chrome-B6tfCta1.mjs} +7 -4
  27. package/dist/{cli-CLP3diBm.mjs → cli-0DYf8QhQ.mjs} +20 -20
  28. package/dist/cli.mjs +1 -1
  29. package/dist/client-B7QVOlCr.d.mts +253 -0
  30. package/dist/client-UXD70ZbM.mjs +1406 -0
  31. package/dist/collector-run.d.mts +4 -40
  32. package/dist/collector-run.mjs +9 -8
  33. package/dist/{command-output-BTy8hZ0F.mjs → command-output-B1UrjZHL.mjs} +1 -1
  34. package/dist/config-CYcBF478.mjs +949 -0
  35. package/dist/{created-devices-Dzd5C2LF.mjs → created-devices-CqeBlrEn.mjs} +3 -3
  36. package/dist/{dependency-state-DG0p31-y.mjs → dependency-state-BbKQW83h.mjs} +20 -5
  37. package/dist/{detached-entry-B9C_zeQC.mjs → detached-entry-DFRyG1_o.mjs} +1 -1
  38. package/dist/{dev-client-DAWVIGBu.mjs → dev-client-UOeESKm6.mjs} +2 -2
  39. package/dist/device-DCxH7_By.mjs +1068 -0
  40. package/dist/{device-BECOiufl.mjs → device-ExJq8Ei7.mjs} +35 -35
  41. package/dist/{device-capacity-CBUAcRyQ.mjs → device-capacity-CMlqEcvw.mjs} +43 -13
  42. package/dist/device-host-worker.mjs +65 -61
  43. package/dist/{device-ios-COSi6oS1.mjs → device-ios-DRUeKaFV.mjs} +48 -45
  44. package/dist/{device-lease-run-Cw2M4z51.mjs → device-lease-run-C8raGFoP.mjs} +14 -26
  45. package/dist/{device-pool-Bf-pOhSw.mjs → device-pool-DMRpVX9a.mjs} +5 -5
  46. package/dist/doctor-BLHCYxzi.mjs +2 -0
  47. package/dist/{doctor-kfMBnUw6.mjs → doctor-DTvaDOda.mjs} +281 -317
  48. package/dist/{doctor-CB8oZKCk.mjs → doctor-Dhqebm0q.mjs} +183 -91
  49. package/dist/doctor-fingerprint.mjs +19 -0
  50. package/dist/{doctor-watchman-BRyV2adA.mjs → doctor-watchman-Cv1F10Kj.mjs} +40 -21
  51. package/dist/{eas-build-JyfqyHfC.mjs → eas-build-BomfRnFT.mjs} +53 -20
  52. package/dist/{build-plan-B7SZsc2N.mjs → eas-fallback-DJwZpy0c.mjs} +26 -208
  53. package/dist/{watchman-CPQFZLXY.mjs → eas-session-ledger-op6A54yi.mjs} +229 -11
  54. package/dist/{error-diagnostics-BR677IDM.mjs → error-diagnostics-Bf0rZvG9.mjs} +172 -82
  55. package/dist/exec-H20xSg2T.d.mts +65 -0
  56. package/dist/exec-_UbtCQcG.mjs +750 -0
  57. package/dist/gc-C-WwL0yi.mjs +3 -0
  58. package/dist/{gc-qWOMdnER.mjs → gc-_-dCXdyL.mjs} +584 -796
  59. package/dist/git-C3iTsJaZ.mjs +73 -0
  60. package/dist/{guide-G9cAbVAc.mjs → guide-Yqwt2bd6.mjs} +941 -269
  61. package/dist/{hosted-android-C3MHGld1.mjs → hosted-android-Bw-honsd.mjs} +8 -6
  62. package/dist/{hosted-client-ZEKpS9vw.mjs → hosted-client-DB_gBPfY.mjs} +34 -19
  63. package/dist/{hosted-ios-l-o3iM9J.mjs → hosted-ios-CUvOf4Vr.mjs} +1 -1
  64. package/dist/{hosted-logs-EzQM7-3Z.mjs → hosted-logs-DL_P5AdN.mjs} +77 -43
  65. package/dist/{hosted-macos-BACVAVqE.mjs → hosted-macos-QI141yKk.mjs} +21 -17
  66. package/dist/{hosted-native-A4s1QPXe.mjs → hosted-native-Ksyjgzq-.mjs} +30 -21
  67. package/dist/idle-BVeRGroT.d.mts +24 -0
  68. package/dist/{idle-shutdown-DtxhPTKe.mjs → idle-shutdown-DaKmZi0z.mjs} +11 -10
  69. package/dist/{ios-BwVCF7oA.mjs → ios-CQ68hG9s.mjs} +8 -8
  70. package/dist/{ios-RkW4pnQf.mjs → ios-CpByZy12.mjs} +140 -80
  71. package/dist/{ios-device-B5veSDDQ.mjs → ios-device-CXGP1bsD.mjs} +1 -1
  72. package/dist/{ios-device-D7pi2Sca.mjs → ios-device-CwFMehUS.mjs} +51 -26
  73. package/dist/{ios-project-K9hY_Jab.mjs → ios-project-WuwwBdvW.mjs} +13 -13
  74. package/dist/{ios-nOLJGVdy.mjs → ios-qNJt4dFm.mjs} +1 -1
  75. package/dist/ios-signing-DTTIChGs.mjs +489 -0
  76. package/dist/{ios-state-CBLe1xYw.mjs → ios-state-DvFX-K_l.mjs} +1 -1
  77. package/dist/{ios-Ce7bc7br.mjs → ios-ubFsBzwq.mjs} +129 -86
  78. package/dist/{js-swap-Bb3nsS07.mjs → js-swap-Cc1dttps.mjs} +53 -26
  79. package/dist/{launch-F4sOqAhB.mjs → launch-CD1yVc7U.mjs} +91 -90
  80. package/dist/{launch-C3qJ6Agb.mjs → launch-Zq2mOSDy.mjs} +82 -541
  81. package/dist/logs-BS00Anxf.mjs +352 -0
  82. package/dist/logs-CMm05HxN.mjs +255 -0
  83. package/dist/{macos-D7uDvO-z.mjs → macos-B65--pPd.mjs} +1 -1
  84. package/dist/{macos-Ch5VJmcS.mjs → macos-C-0qJ6zq.mjs} +225 -212
  85. package/dist/macos-run.mjs +1 -1
  86. package/dist/maintenance-run.mjs +122 -247
  87. package/dist/{metro-DnCEjCxs.mjs → metro-DEXpIhHC.mjs} +67 -12
  88. package/dist/{metro-gateway-CX9Xlkq2.mjs → metro-gateway-BMJNlj3E.mjs} +20 -12
  89. package/dist/{named-ports-4WopRPg-.mjs → named-ports-BWTzt6mu.mjs} +8 -63
  90. package/dist/native-android-JACyjTZs.mjs +844 -0
  91. package/dist/{native-gradle-inputs-BsLRrl7u.mjs → native-gradle-inputs-Bep9JcSF.mjs} +128 -140
  92. package/dist/native-inputs-TRTTTRxt.mjs +91 -0
  93. package/dist/native-run-DY_RLx3C.mjs +277 -0
  94. package/dist/{native-runtime-k8dTIrbK.mjs → native-runtime-Dg1Q7tfF.mjs} +9 -8
  95. package/dist/{native-xcode-inputs-CykopJdM.mjs → native-xcode-inputs-CB2iQeWq.mjs} +27 -18
  96. package/dist/{native-xcode-ios-Bbf30Gm0.mjs → native-xcode-ios-CXX39F7o.mjs} +96 -47
  97. package/dist/{ndjson-GOnbyvso.mjs → ndjson-CgE_o3Dl.mjs} +3 -3
  98. package/dist/offload-worker.d.mts +1 -46
  99. package/dist/offload-worker.mjs +197 -66
  100. package/dist/{ownership-DCtw_2IA.mjs → ownership-DEmM5vhh.mjs} +3 -3
  101. package/dist/{page-DRHy329N.mjs → page-CPaHeYqj.mjs} +7 -4
  102. package/dist/paths-BsJMoPP2.mjs +12 -0
  103. package/dist/paths-DQtTgsBf.mjs +42 -0
  104. package/dist/{placement-log-MOfPVgaM.mjs → placement-log-BqGbTa61.mjs} +5 -5
  105. package/dist/{plan-placement-V0TdzYXp.mjs → plan-placement-Bwj-IjY1.mjs} +6 -6
  106. package/dist/{ports-DdSUicVo.mjs → ports-D-MmCTdv.mjs} +3 -3
  107. package/dist/prebuild-uD_ipCxF.mjs +449 -0
  108. package/dist/{project-_phNIJfs.mjs → project-BZNjmW_8.mjs} +65 -37
  109. package/dist/{pull-request-CQ8sPbZa.mjs → pull-request-Lfetn8Kr.mjs} +2 -2
  110. package/dist/pull-request-zjCSAryH.d.mts +120 -0
  111. package/dist/pull-requests.d.mts +1 -119
  112. package/dist/pull-requests.mjs +1 -1
  113. package/dist/{react-native-android-CM1XRDwv.mjs → react-native-android-DuzH0cn3.mjs} +74 -48
  114. package/dist/{gradle-DSrXb6lG.mjs → react-native-build-rhk4smwQ.mjs} +292 -15
  115. package/dist/react-native-doctor-CQpuIMso.mjs +234 -0
  116. package/dist/{react-native-ios-Dhq_eiYQ.mjs → react-native-ios-Bhq1rJeV.mjs} +46 -28
  117. package/dist/{recordings-D0d5aQt0.mjs → recordings-DYteQSu4.mjs} +12 -9
  118. package/dist/{reload-C8JhxjSh.mjs → reload-CmTRFJaX.mjs} +93 -47
  119. package/dist/reload-DzjSl5P_.mjs +2 -0
  120. package/dist/{remote-BiR6aYjy.mjs → remote-ByYkXdGD.mjs} +15 -10
  121. package/dist/result-DNiS-tTP.mjs +434 -0
  122. package/dist/{run-BtPgpKks.mjs → run-D23HmJMs.mjs} +4 -5
  123. package/dist/selection-CSl9i5qU.mjs +619 -0
  124. package/dist/{server-bare-R2m_gsH8.mjs → server-bare-CxTrvDg8.mjs} +3 -4
  125. package/dist/{server-command-CTtCkmcQ.mjs → server-command-CtzloH3v.mjs} +14 -7
  126. package/dist/server-expo-C-90EhcG.mjs +2 -0
  127. package/dist/{server-expo-DsguMGUF.mjs → server-expo-DT_F_uVI.mjs} +50 -9
  128. package/dist/{settings-B717odTD.mjs → settings-CsJDEXgK.mjs} +234 -24
  129. package/dist/{settings-vk3mJGSm.d.mts → settings-DkdmlelE.d.mts} +6 -4
  130. package/dist/settings-T1gtc3bf.mjs +114 -0
  131. package/dist/settings-write-HyVZ8eQ8.mjs +359 -0
  132. package/dist/settings.schema.json +163 -16
  133. package/dist/{simslim-CCr3rE-A.mjs → simslim-Cgk17SXV.mjs} +14 -12
  134. package/dist/{slot-launch-DPt0m9Nd.mjs → slot-launch-DF8VfT64.mjs} +15 -20
  135. package/dist/{spawn-entry-Dcb7sDUz.mjs → spawn-entry-jw19m8Nl.mjs} +0 -1
  136. package/dist/stage-BIS0ydsV.mjs +183 -0
  137. package/dist/{start-BWqzODpb.mjs → start-7lpH7hmN.mjs} +63 -44
  138. package/dist/{start-TXeMmmO2.mjs → start-RChynRDp.mjs} +1 -1
  139. package/dist/{state-D1Icyjlu.mjs → state-C4ZtUisW.mjs} +40 -13
  140. package/dist/{state-CG_OFoaA.mjs → state-XMziexv2.mjs} +3 -2
  141. package/dist/{stats-BoY5sEPU.mjs → stats-53T7OTb9.mjs} +7 -13
  142. package/dist/stats-report-BFfMpWWF.mjs +16 -0
  143. package/dist/{status-WgFbkRzj.mjs → status-BL7jVyAB.mjs} +535 -447
  144. package/dist/status-CSi6tlRq.mjs +2 -0
  145. package/dist/{status-BTA7kKiQ.mjs → status-DqEUSSxs.mjs} +6 -4
  146. package/dist/{status-watch-C23ILtf9.mjs → status-watch-GDCfqpTE.mjs} +187 -22
  147. package/dist/status-worker.d.mts +1 -0
  148. package/dist/status-worker.mjs +19 -0
  149. package/dist/stim-desktop-C12we7lz.mjs +112 -0
  150. package/dist/{stop-DR6VoDIk.mjs → stop-Bk_1qiV6.mjs} +2 -2
  151. package/dist/{stop-BNmBMi1F.mjs → stop-CPzlM1L-.mjs} +138 -98
  152. package/dist/{stop-DPEhunlw.mjs → stop-D7h6jAXQ.mjs} +11 -10
  153. package/dist/supervisor-run.d.mts +8 -17
  154. package/dist/supervisor-run.mjs +63 -27
  155. package/dist/{support-DMTqj3Hm.mjs → support-67vraa1Q.mjs} +18 -11
  156. package/dist/{support-CwjbFs9H.mjs → support-Dlu37g6H.mjs} +12 -12
  157. package/dist/{swiftpm-macos-DRNVJWlb.mjs → swiftpm-macos-p8WZbxKU.mjs} +35 -24
  158. package/dist/toolchain-DhKwp9iI.mjs +2 -0
  159. package/dist/toolchain-Hp9sCpK4.mjs +873 -0
  160. package/dist/{trigger-CigAYjeL.mjs → trigger-BAahxUPq.mjs} +20 -5
  161. package/dist/trigger-Bf3uDcpv.mjs +2 -0
  162. package/dist/{warm-progress-BuY-Fvfn.mjs → warm-progress-BHX5r0Ei.mjs} +250 -156
  163. package/dist/{web-BDBMxDpx.mjs → web-CJmIj6AI.mjs} +18 -13
  164. package/dist/web-DknQETPs.mjs +2 -0
  165. package/dist/web-run.mjs +11 -12
  166. package/dist/windows-report.d.mts +1 -0
  167. package/dist/windows-report.mjs +18 -0
  168. package/dist/windows-report.ps1 +43 -0
  169. package/dist/workspace-process-lock-1_1OoVW5.mjs +57 -0
  170. package/dist/{workspace-state-DJt_MMvf.mjs → workspace-state-Cjuigeeu.mjs} +62 -58
  171. package/dist/{workspaces-C36s2jb9.mjs → workspaces-BccMFmGQ.mjs} +1188 -1079
  172. package/dist/worktree-CK2MpJW5.mjs +2 -0
  173. package/dist/{worktree-CgvJYJ-Q.mjs → worktree-DQ6Zi2Mv.mjs} +304 -53
  174. package/dist/xcode-Zlx3qjEs.mjs +896 -0
  175. package/package.json +7 -5
  176. package/shim/android-optimizations.gradle +7 -5
  177. package/dist/activity-BSV745Kz.mjs +0 -629
  178. package/dist/api-qvOzWyfO.mjs +0 -154
  179. package/dist/api-run.mjs +0 -294
  180. package/dist/app-install-BIKtMfPq.mjs +0 -896
  181. package/dist/artifact-lifecycle-DzPpBYvK.mjs +0 -30
  182. package/dist/budget-f7516Zk0.mjs +0 -4106
  183. package/dist/build-facts-DcLv2HSd.d.mts +0 -111
  184. package/dist/cancellation-C_22VQTH.mjs +0 -24
  185. package/dist/client-qQAaXSUs.mjs +0 -1771
  186. package/dist/config-BYDxlMY3.mjs +0 -562
  187. package/dist/device-DuiPJQSn.mjs +0 -290
  188. package/dist/device-lease-BX1sJQ2E.mjs +0 -1224
  189. package/dist/device-remote-xRT0Vmo9.mjs +0 -1272
  190. package/dist/eas-session-ledger-Cm0Gwq2F.mjs +0 -207
  191. package/dist/exec-DqKo9GKJ.mjs +0 -268
  192. package/dist/git-DDfFzkMm.mjs +0 -45
  193. package/dist/launch-verify-B6Q8hZP-.mjs +0 -428
  194. package/dist/logs-BGrEUaEs.mjs +0 -383
  195. package/dist/miss-reason-mKzZ4VvN.mjs +0 -238
  196. package/dist/native-android-D5qc3-_v.mjs +0 -226
  197. package/dist/ndjson-Du3j0AQ9.d.mts +0 -17
  198. package/dist/plan-C4TjdPsR.mjs +0 -260
  199. package/dist/prebuild-DYbucPXy.mjs +0 -212
  200. package/dist/preview-78a9kR_-.mjs +0 -1011
  201. package/dist/react-native-build-CtCccJtb.mjs +0 -239
  202. package/dist/react-native-doctor-CfRnFfjs.mjs +0 -78
  203. package/dist/remote-cache-OyOyVIS3.mjs +0 -526
  204. package/dist/result-CaJg5Iat.mjs +0 -186
  205. package/dist/server-expo-Bigriskl.mjs +0 -2
  206. package/dist/settings-BORNaaCO.mjs +0 -402
  207. package/dist/spawn-claims-DVS5RkMS.mjs +0 -72
  208. package/dist/stage-KNTQopqv.mjs +0 -157
  209. package/dist/stim-desktop-BzBN2Em2.mjs +0 -63
  210. package/dist/tailnet-Dh-qiYzG.mjs +0 -265
  211. package/dist/toolchain-BFkAcstd.mjs +0 -2
  212. package/dist/toolchain-DxSsNssu.mjs +0 -1657
  213. package/dist/trigger-9_USgmxz.mjs +0 -2
  214. package/dist/web-Dq-i3wzJ.mjs +0 -2
  215. package/dist/worktree-DpLdCHga.mjs +0 -2
  216. package/dist/{api-run.d.mts → doctor-fingerprint.d.mts} +0 -0
  217. package/dist/{errors-DzkMYh8Q.mjs → errors-ccaPc4ox.mjs} +2 -2
@@ -1,21 +1,21 @@
1
- import { A as acquireAvdClaim, D as withConfigLock, V as deviceSlotPlatforms, W as projectDeviceSlots, _ as loadConfig, a as clearDevice, b as releaseAndroidConsolePort, i as clearAndroidBootPending, j as ownership_claim_exports, t as allConsolePortsAndSerials, w as setDevice } from "./config-BYDxlMY3.mjs";
2
- import { t as getExecutor } from "./exec-DqKo9GKJ.mjs";
3
- import { l as androidDataPartitionSizeGbSetting, o as androidAvdConfigSetting } from "./settings-B717odTD.mjs";
4
- import { l as phaseLine } from "./command-output-BTy8hZ0F.mjs";
5
- import { o as ownedDeviceLabel } from "./project-_phNIJfs.mjs";
6
- import { A as listAvds, B as ownedAvdSystemImage, E as getAvdNameForSerial, F as ownedAvdDeviceProfile, J as resolveOwnedAvdSerial, L as ownedAvdMatchesConfiguration, O as listAdbDevices, P as nextConsolePort, R as ownedAvdName, W as pickDefaultSystemImage, b as createOwnedAvd, dt as parkedMaxSetting, f as assertOwnedAvdStopped, ft as readParked, g as avdPoolConfiguration, j as listInstalledSystemImages, lt as isLegacyDeletionClaim, n as OWNED_AVD_CONFIG_DEFAULTS, ot as adoptParked, t as DEFAULT_AVD_DEVICE_PROFILE, tt as waitForBoot, v as bootAndroidEmulator, y as configureNewOwnedAvd } from "./android-Mz_Inn3w.mjs";
7
- import { s as pidExists } from "./metro-DnCEjCxs.mjs";
8
- import { v as teardownOwnedAvd, x as teardownParkedAvd } from "./workspaces-C36s2jb9.mjs";
9
- import { F as memoryCulpritAdvice, N as memoryCulpritsUnder, P as readHostMemoryPressure, d as listAllIosSims } from "./ios-RkW4pnQf.mjs";
10
- import { t as clearDeviceIdleShutdown } from "./idle-shutdown-DtxhPTKe.mjs";
11
- import { i as countLiveOwnedDevices, n as DeviceAdmissionRefusal, p as withDeviceBootAdmission } from "./device-capacity-CBUAcRyQ.mjs";
12
- import { t as reconcileSimSlim } from "./simslim-CCr3rE-A.mjs";
13
- import { i as ensureOwnedIosDevice, r as ensureIosBooted } from "./device-ios-COSi6oS1.mjs";
14
- import { claimRemoveCommand, clearClaimChild, markClaimChildPending, processGroupAlive, releaseClaim, setClaimChild } from "@stim-cli/core/ownership-claim";
15
- import { captureProcessIdentity } from "@stim-cli/core/process-identity";
1
+ import { f as ownership_claim_exports, t as getExecutor } from "./exec-_UbtCQcG.mjs";
2
+ import { D as withConfigLock, K as projectDeviceSlots, O as withConfigLockAsync, U as deviceSlotPlatforms, _ as loadConfig, a as clearDevice, b as releaseAndroidConsolePort, i as clearAndroidBootPending, j as acquireAvdClaim, t as allConsolePortsAndSerials, w as setDevice } from "./config-CYcBF478.mjs";
3
+ import { l as phaseLine } from "./command-output-B1UrjZHL.mjs";
4
+ import { l as androidDataPartitionSizeGbSetting, o as androidAvdConfigSetting } from "./settings-CsJDEXgK.mjs";
5
+ import { s as ownedDeviceLabel } from "./project-BZNjmW_8.mjs";
6
+ import { l as pidExists } from "./metro-DEXpIhHC.mjs";
7
+ import { E as teardownOwnedAvd, k as teardownParkedAvd } from "./workspaces-BccMFmGQ.mjs";
8
+ import { A as listAdbDevicesAsync, B as ownedAvdMatchesConfiguration, D as getAvdNameForSerialAsync, J as pickDefaultSystemImage, L as nextConsolePort, N as listAvdsAsync, P as listInstalledSystemImages, Q as resolveOwnedAvdSerialAsync, R as ownedAvdDeviceProfile, V as ownedAvdName, W as ownedAvdSystemImage, b as createOwnedAvd, f as assertOwnedAvdStopped, g as avdPoolConfiguration, gt as readParked, ht as parkedMaxSetting, it as waitForBoot, k as listAdbDevices, n as OWNED_AVD_CONFIG_DEFAULTS, pt as isLegacyDeletionClaim, t as DEFAULT_AVD_DEVICE_PROFILE, ut as adoptParked, v as bootAndroidEmulator, y as configureNewOwnedAvd } from "./android-DUYkNF4u.mjs";
9
+ import { I as memoryCulpritAdvice, N as memoryCulpritsUnder, P as readHostMemoryPressure, d as listAllIosSims } from "./ios-CpByZy12.mjs";
10
+ import { t as clearDeviceIdleShutdown } from "./idle-shutdown-DaKmZi0z.mjs";
11
+ import { i as countLiveOwnedDevices, m as withDeviceBootAdmission, n as DeviceAdmissionRefusal } from "./device-capacity-CMlqEcvw.mjs";
12
+ import { i as ensureOwnedIosDevice, r as ensureIosBooted } from "./device-ios-DRUeKaFV.mjs";
13
+ import { t as reconcileSimSlim } from "./simslim-Cgk17SXV.mjs";
16
14
  import { randomUUID } from "node:crypto";
17
- import chalk from "chalk";
18
15
  import { isDeepStrictEqual } from "node:util";
16
+ import { captureProcessIdentity } from "@stim-cli/core/process-identity";
17
+ import { claimRemoveCommand, clearClaimChild, markClaimChildPending, processGroupAlive, releaseClaim, setClaimChild } from "@stim-cli/core/ownership-claim";
18
+ import chalk from "chalk";
19
19
  import { request } from "node:http";
20
20
  //#region src/engine/metro-warmup.ts
21
21
  const WARMUP_TIMEOUT_MS = 6e4;
@@ -93,7 +93,7 @@ function findOtherOwner(avdName, projectPath, selectedSlot = "default") {
93
93
  return null;
94
94
  }
95
95
  async function prepareOwnedAvd({ projectPath, slot, label, previousAvdName, systemImage, deviceProfile, configuration, configure, teardown = teardownOwnedAvd }) {
96
- const { claim, reservation, previous, avdName } = withConfigLock(() => {
96
+ const { claim, reservation, previous, avdName } = await withConfigLockAsync(() => {
97
97
  const previous = deviceSlotPlatforms(loadConfig()?.projects?.[projectPath], slot)?.android;
98
98
  if (previous?.avdName && previous.avdName !== previousAvdName) throw new Error(`Another Stim run assigned AVD ${previous.avdName} to this workspace. Retry to use it.`);
99
99
  if (readParked("android").some((entry) => entry.name === ownedAvdName(label)) || findOtherOwner(ownedAvdName(label), projectPath, slot)) label = `${label}-${randomUUID().slice(0, 8)}`;
@@ -165,9 +165,9 @@ async function prepareOwnedAvd({ projectPath, slot, label, previousAvdName, syst
165
165
  const message = String(error?.message || error);
166
166
  if (!message.includes("already exists")) throw error;
167
167
  try {
168
- if (!listAvds().includes(avdName)) throw new AvdRecoveryError(`AVD ${avdName} already exists on disk but is not listed by the emulator. ${message}`, "Run `npx stim gc` to inspect orphaned owned AVDs, then `npx stim gc --delete` to reclaim those safe to delete. Retry `stim android` after cleanup; keep any AVD that GC cannot verify.", error);
169
- withConfigLock(assertReservation);
170
- const resolved = resolveOwnedAvdSerial(avdName);
168
+ if (!(await listAvdsAsync()).includes(avdName)) throw new AvdRecoveryError(`AVD ${avdName} already exists on disk but is not listed by the emulator. ${message}`, "Run `npx stim gc` to inspect orphaned owned AVDs, then `npx stim gc --delete` to reclaim those safe to delete. Retry `stim android` after cleanup; keep any AVD that GC cannot verify.", error);
169
+ await withConfigLockAsync(assertReservation);
170
+ const resolved = await resolveOwnedAvdSerialAsync(avdName);
171
171
  if (resolved.missing || resolved.notOwned) throw new Error(`AVD ${avdName} could not be verified for recovery. Retry after checking its registration.`, { cause: error });
172
172
  if (!resolved.serial) assertOwnedAvdStopped(avdName);
173
173
  prepared = {
@@ -181,7 +181,7 @@ async function prepareOwnedAvd({ projectPath, slot, label, previousAvdName, syst
181
181
  } : {}
182
182
  };
183
183
  } catch (recoveryError) {
184
- withConfigLock(() => {
184
+ await withConfigLockAsync(() => {
185
185
  if (!isDeepStrictEqual(currentRecord(), reservation)) return;
186
186
  if (previous) setDevice(projectPath, "android", previous, slot);
187
187
  else clearDevice(projectPath, "android", slot, avdName);
@@ -195,7 +195,7 @@ async function prepareOwnedAvd({ projectPath, slot, label, previousAvdName, syst
195
195
  } catch (error) {
196
196
  configurationFailure = { error };
197
197
  }
198
- if (!configurationFailure) withConfigLock(() => {
198
+ if (!configurationFailure) await withConfigLockAsync(() => {
199
199
  assertReservation();
200
200
  setDevice(projectPath, "android", {
201
201
  avdName,
@@ -218,7 +218,7 @@ async function prepareOwnedAvd({ projectPath, slot, label, previousAvdName, syst
218
218
  }
219
219
  if (configurationFailure) {
220
220
  const { error } = configurationFailure;
221
- const cleanup = teardown(avdName, {
221
+ const cleanup = await teardown(avdName, {
222
222
  del: true,
223
223
  owner: {
224
224
  projectPath,
@@ -248,7 +248,7 @@ async function ensureOwnedAndroidDevice({ record, projectPath, slot, settingsRoo
248
248
  let replacedProfile = null;
249
249
  if (record?.setupIncomplete && record.avdName) {
250
250
  const avdName = record.avdName;
251
- const cleanup = teardownAvd(avdName, {
251
+ const cleanup = await teardownAvd(avdName, {
252
252
  del: true,
253
253
  owner: {
254
254
  projectPath,
@@ -268,7 +268,7 @@ async function ensureOwnedAndroidDevice({ record, projectPath, slot, settingsRoo
268
268
  const avdName = record.avdName;
269
269
  if (!record.bootPending) throw new AvdRecoveryError(`this project's emulator ${avdName} uses system image ${currentImage}, but ${requestedImage} was requested. --system-image replaces only an emulator that never finished a boot, and this one has.`, "Run `stim worktree remove` (or `stim gc --delete`) to reap the current emulator, then `stim android` again to create the requested one, or pass `--slot <name>` to create it beside the current one.");
270
270
  replacedProfile = ownedAvdDeviceProfile(avdName);
271
- const cleanup = teardownAvd(avdName, {
271
+ const cleanup = await teardownAvd(avdName, {
272
272
  del: true,
273
273
  owner: {
274
274
  projectPath,
@@ -288,7 +288,7 @@ async function ensureOwnedAndroidDevice({ record, projectPath, slot, settingsRoo
288
288
  const configurationBeforeDefaults = avdPoolConfiguration(androidDataPartitionSizeGbSetting(settings), projectAvdConfig, deviceProfile);
289
289
  if (record?.avdName) {
290
290
  if (record.owned) {
291
- const resolved = resolveOwnedAvdSerial(record.avdName);
291
+ const resolved = await resolveOwnedAvdSerialAsync(record.avdName);
292
292
  const currentProfile = resolved.notOwned || resolved.missing ? null : ownedAvdDeviceProfile(record.avdName);
293
293
  if (requestedProfile && currentProfile && currentProfile !== requestedProfile) throw new AvdRecoveryError(`this project's emulator uses device profile ${currentProfile}, but ${requestedProfile} was requested. Stim will not silently boot a different model.`, "Run `stim worktree remove` (or `stim gc --delete`) to reap the current emulator, then `stim android` again to create the requested one, or pass `--slot <name>` to create it beside the current one.");
294
294
  if (resolved.notOwned) note(chalk.yellow(`Note: recorded AVD ${record.avdName} is not Stim-owned -- creating a fresh owned AVD instead of reusing it.`));
@@ -326,8 +326,8 @@ async function ensureOwnedAndroidDevice({ record, projectPath, slot, settingsRoo
326
326
  deviceProfile: currentProfile
327
327
  };
328
328
  }
329
- } else if (listAvds().includes(record.avdName)) {
330
- if (!listAdbDevices().emulators.some((e) => e.consolePort === record.consolePort)) {
329
+ } else if ((await listAvdsAsync()).includes(record.avdName)) {
330
+ if (!(await listAdbDevicesAsync()).emulators.some((e) => e.consolePort === record.consolePort)) {
331
331
  note(chalk.yellow(`Note: assigned AVD ${record.avdName} (emulator-${record.consolePort}) is shut down and is not owned by Stim, so it will not be booted automatically.`));
332
332
  note(chalk.dim("Boot it yourself, or run `stim gc --delete` to clear the assignment so Stim can create an owned AVD."));
333
333
  }
@@ -342,9 +342,9 @@ async function ensureOwnedAndroidDevice({ record, projectPath, slot, settingsRoo
342
342
  const candidates = readParked("android").filter((entry) => entry.systemImage === systemImage && (entry.configuration === configuration || entry.configuration === configurationBeforeDefaults)).toSorted((a, b) => a.parkedAt.localeCompare(b.parkedAt));
343
343
  for (const parked of candidates) {
344
344
  if (isLegacyDeletionClaim(parked.deletionClaim)) continue;
345
- const resolved = resolveOwnedAvdSerial(parked.name);
345
+ const resolved = await resolveOwnedAvdSerialAsync(parked.name);
346
346
  if (resolved.missing) {
347
- const result = teardownParkedAvd(parked.name);
347
+ const result = await teardownParkedAvd(parked.name);
348
348
  if (result.status === "failed") out(phaseLine("device", `kept ${parked.name}: ${result.reason}`));
349
349
  continue;
350
350
  }
@@ -356,7 +356,7 @@ async function ensureOwnedAndroidDevice({ record, projectPath, slot, settingsRoo
356
356
  continue;
357
357
  }
358
358
  if (ownedAvdSystemImage(parked.name) !== systemImage || !ownedAvdMatchesConfiguration(parked.name, parked.configuration)) {
359
- const result = teardownParkedAvd(parked.name);
359
+ const result = await teardownParkedAvd(parked.name);
360
360
  if (result.status === "failed") out(phaseLine("device", `kept ${parked.name}: ${result.reason}`));
361
361
  continue;
362
362
  }
@@ -478,7 +478,7 @@ async function bootOwnedAvdOnFreshPort({ avdName, deviceSlotWait, metadata, proj
478
478
  const serial = `emulator-${claim.consolePort}`;
479
479
  try {
480
480
  reportAndroidMemoryPressure(out);
481
- const pid = bootAndroidEmulator(avdName, claim.consolePort, { logFile });
481
+ const pid = await bootAndroidEmulator(avdName, claim.consolePort, { logFile });
482
482
  out(chalk.dim(phaseLine("device", `waiting for ${serial} to finish booting`)));
483
483
  const result = await waitForAndroidBoot({
484
484
  serial,
@@ -488,7 +488,7 @@ async function bootOwnedAvdOnFreshPort({ avdName, deviceSlotWait, metadata, proj
488
488
  out
489
489
  });
490
490
  if (result.failed) throw new AvdBootError(result.reason, result.remedy);
491
- const running = getAvdNameForSerial(serial);
491
+ const running = await getAvdNameForSerialAsync(serial);
492
492
  if (running && running !== avdName) throw new Error(`${serial} is running AVD ${running}, not this workspace's owned AVD ${avdName}; refusing to use it.`);
493
493
  clearAndroidBootPending(projectPath, avdName, slot);
494
494
  const { bootPending: _booted, ...booted } = claim;
@@ -571,7 +571,7 @@ async function ensureAndroidBooted({ device, deviceSlotWait, projectPath, slot,
571
571
  };
572
572
  let resolved;
573
573
  try {
574
- resolved = resolveOwnedAvdSerial(device.avdName);
574
+ resolved = await resolveOwnedAvdSerialAsync(device.avdName);
575
575
  } catch (e) {
576
576
  return {
577
577
  failed: true,
@@ -616,7 +616,7 @@ async function ensureAndroidBooted({ device, deviceSlotWait, projectPath, slot,
616
616
  out(chalk.dim(phaseLine("device", `booting ${avdName} as ${serial}`)));
617
617
  let pid = null;
618
618
  try {
619
- pid = bootAndroidEmulator(avdName, claim.consolePort, { logFile });
619
+ pid = await bootAndroidEmulator(avdName, claim.consolePort, { logFile });
620
620
  } catch (e) {
621
621
  releaseAndroidConsolePort(projectPath, claim.consolePort, slot);
622
622
  return {
@@ -1,18 +1,20 @@
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 { f as ownership_claim_exports } from "./exec-_UbtCQcG.mjs";
2
+ import { m as workspaceLogsDir$1 } from "./paths-DQtTgsBf.mjs";
3
+ import { K as projectDeviceSlots, U as deviceSlotPlatforms, _ as loadConfig$1, d as getConfigDir, u as getConcurrencyLimits } from "./config-CYcBF478.mjs";
4
+ import { a as formatElapsed, l as phaseLine } from "./command-output-B1UrjZHL.mjs";
5
+ import { g as deviceReclaimIdleMinutesSetting } from "./settings-CsJDEXgK.mjs";
6
+ import { r as createNdjsonWriter } from "./ndjson-CgE_o3Dl.mjs";
7
+ import { K as recordCapacityRefusal, q as recordCapacityWait } from "./budget-Bs6SxxzO.mjs";
8
+ import { t as canonicalPath } from "./paths-BsJMoPP2.mjs";
9
+ import { f as withIdleWorkspace } from "./workspaces-BccMFmGQ.mjs";
10
+ import { A as listAdbDevicesAsync, k as listAdbDevices } from "./android-DUYkNF4u.mjs";
11
+ import { d as listAllIosSims, f as listAllIosSimsAsync, l as iosRuntimeMatches, y as parseRuntimeVersion } from "./ios-CpByZy12.mjs";
12
+ import { n as workspaceProcessLockError, t as withWorkspaceProcessLock } from "./workspace-process-lock-1_1OoVW5.mjs";
13
+ import { n as dueIdleDevices, r as shutDownIdleDevices } from "./idle-shutdown-DaKmZi0z.mjs";
12
14
  import { realpathSync } from "node:fs";
13
15
  import { basename, join } from "node:path";
14
- import { DEVICE_RECLAIM_REASON, automaticMachineEnabled } from "@stim-cli/core/state";
15
16
  import { LOG_ROTATE_BYTES, workspaceId } from "@stim-cli/core";
17
+ import { DEVICE_RECLAIM_REASON, automaticMachineEnabled } from "@stim-cli/core/state";
16
18
  import { setTimeout } from "node:timers/promises";
17
19
  //#region src/devices/queue-reclaim.ts
18
20
  async function reclaimIdleDevice(root, idleMs, out, now, skipped) {
@@ -203,6 +205,34 @@ function countLiveOwnedDevices(sources = {}, { exclude = [] } = {}) {
203
205
  throw error;
204
206
  }
205
207
  }
208
+ async function listedAsync(source, empty) {
209
+ try {
210
+ return await source();
211
+ } catch (error) {
212
+ if (toolAbsent(error)) return empty;
213
+ throw new DeviceCountUnavailable("", { cause: error });
214
+ }
215
+ }
216
+ async function countLiveOwnedDevicesAsync(operation) {
217
+ try {
218
+ operation.signal.throwIfAborted();
219
+ const config = loadConfig$1();
220
+ const booting = readBootingDevices();
221
+ 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]);
222
+ operation.signal.throwIfAborted();
223
+ return countLiveOwnedDevices({
224
+ config,
225
+ booting,
226
+ sims,
227
+ adb
228
+ });
229
+ } catch (error) {
230
+ operation.signal.throwIfAborted();
231
+ if ((0, ownership_claim_exports.isClaimRefusal)(error)) return { unknown: error.message };
232
+ if (error instanceof DeviceCountUnavailable) return { unknown: uncountedRefusal(error.cause).message };
233
+ throw error;
234
+ }
235
+ }
206
236
  function workspaceHasLiveDevice({ platform, project, slot = "default", sims = [], adbEmulators = [] } = {}) {
207
237
  if (!platform) return false;
208
238
  const record = deviceSlotPlatforms(project, slot)?.[platform];
@@ -586,4 +616,4 @@ function unknownAndroidDeviceProfileRefusal(requested, profiles) {
586
616
  };
587
617
  }
588
618
  //#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 };
619
+ 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,26 @@
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";
1
+ import { p as process_identity_exports, t as getExecutor } from "./exec-_UbtCQcG.mjs";
2
+ import { n as ensureWorkspaceStorage } from "./paths-DQtTgsBf.mjs";
3
+ import { O as withConfigLockAsync$1, _ as loadConfig$1, c as ensureConfig } from "./config-CYcBF478.mjs";
4
+ import { d as writeWorkspaceState } from "./workspace-state-Cjuigeeu.mjs";
5
+ import { i as macosProcess, o as requiredMacosRecord } from "./state-XMziexv2.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-Bs6SxxzO.mjs";
8
+ import { E as teardownOwnedAvd, O as teardownOwnedIosSim } from "./workspaces-BccMFmGQ.mjs";
9
+ import { t as forgetCreatedDevice } from "./created-devices-CqeBlrEn.mjs";
10
+ import { D as getAvdNameForSerialAsync, E as getAvdNameForSerial, J as pickDefaultSystemImage, N as listAvdsAsync, O as hostSystemImageArch, P as listInstalledSystemImages, Q as resolveOwnedAvdSerialAsync, V as ownedAvdName, W as ownedAvdSystemImage, Z as resetAdoptedAvd, _ as avdStorageRoots, a as androidDeviceAbi, b as createOwnedAvd, d as androidToolPath, f as assertOwnedAvdStopped, h as avdPathExists, it as waitForBoot, j as listAvdDeviceProfiles, k as listAdbDevices, t as DEFAULT_AVD_DEVICE_PROFILE, v as bootAndroidEmulator } from "./android-DUYkNF4u.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-CpByZy12.mjs";
12
+ import { r as stopMacosAppHeld } from "./stop-D7h6jAXQ.mjs";
13
+ import { i as countLiveOwnedDevices } from "./device-capacity-CMlqEcvw.mjs";
14
+ import { n as parseLogcatLine, r as parsePidof, t as androidClockOffset } from "./android-BEJ8Jpl7.mjs";
15
+ import { t as spawnEntry } from "./spawn-entry-jw19m8Nl.mjs";
16
+ import { _ as findAapt } from "./support-67vraa1Q.mjs";
17
+ import { n as parseLogStreamLine } from "./ios-qNJt4dFm.mjs";
18
+ import { createHash, randomUUID } from "node:crypto";
17
19
  import { chmodSync, closeSync, copyFileSync, createReadStream, existsSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statfsSync, symlinkSync, writeFileSync } from "node:fs";
20
+ import { availableParallelism, freemem, homedir, loadavg } from "node:os";
18
21
  import { dirname, isAbsolute, join, posix, relative, sep } from "node:path";
22
+ import { LOG_ROTATE_BYTES, configDir, withDirLock, withDirLockAsync } from "@stim-cli/core";
19
23
  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";
21
- import { createHash, randomUUID } from "node:crypto";
22
- import { availableParallelism, freemem, homedir, loadavg } from "node:os";
23
24
  //#region src/device-host/android-app.ts
24
25
  async function digest$1(path) {
25
26
  const hash = createHash("sha256");
@@ -60,7 +61,7 @@ async function installHostedAndroidApp(home, session, attempt, device, metro) {
60
61
  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
62
  assertHostedAndroidTarget(home, device);
62
63
  const sdkExecutor = hostedAndroidExecutor();
63
- const installed = installAndroidApp({
64
+ const installed = await installAndroidApp({
64
65
  serial: device.serial,
65
66
  apkPath: apk,
66
67
  packageName: record.bundleId
@@ -68,14 +69,14 @@ async function installHostedAndroidApp(home, session, attempt, device, metro) {
68
69
  if (!installed.ok) throw new Error(installed.reason ?? "Hosted APK installation was not established.");
69
70
  assertHostedAndroidTarget(home, device);
70
71
  if (record.mode === "development" && !metro) throw new Error("Hosted Android development launch requires its Metro bridge.");
71
- const launched = record.mode === "development" && metro ? launchAndroidApp({
72
+ const launched = record.mode === "development" && metro ? await launchAndroidApp({
72
73
  serial: device.serial,
73
74
  packageName: record.bundleId,
74
75
  metroPort: metro.devicePort,
75
76
  bridgePort: metro.bridgePort,
76
77
  physical: true,
77
78
  devClientScheme: record.devClientScheme
78
- }, { exec: sdkExecutor }) : launchAndroidReleaseApp({
79
+ }, { exec: sdkExecutor }) : await launchAndroidReleaseApp({
79
80
  serial: device.serial,
80
81
  packageName: record.bundleId
81
82
  }, { exec: sdkExecutor });
@@ -83,7 +84,7 @@ async function installHostedAndroidApp(home, session, attempt, device, metro) {
83
84
  if (record.mode === "development") return "unverified";
84
85
  for (let tries = 0; tries < 10; tries++) {
85
86
  await new Promise((resolve) => setTimeout(resolve, 200));
86
- if (androidAppProcess(device.serial, record.bundleId, { exec: sdkExecutor }).state === "running") return true;
87
+ if ((await androidAppProcess(device.serial, record.bundleId, { exec: sdkExecutor })).state === "running") return true;
87
88
  }
88
89
  return "unverified";
89
90
  }
@@ -99,24 +100,27 @@ function assertHostedAndroidTarget(home, device) {
99
100
  function hostedAndroidExecutor() {
100
101
  const executor = getExecutor();
101
102
  const adb = androidToolPath("adb");
103
+ const tool = (file) => file === "adb" ? adb : file;
102
104
  return {
103
105
  ...executor,
104
- runFile: (file, args, options) => executor.runFile(file === "adb" ? adb : file, args, options)
106
+ runFile: (file, args, options) => executor.runFile(tool(file), args, options),
107
+ runFileAsync: (file, args, options) => executor.runFileAsync(tool(file), args, options),
108
+ runFileQuietAsync: (file, args, options) => executor.runFileQuietAsync(tool(file), args, options)
105
109
  };
106
110
  }
107
- function restoreHostedAndroidMetro(home, session, attempt, device, metro) {
111
+ async function restoreHostedAndroidMetro(home, session, attempt, device, metro) {
108
112
  const record = readHostedApp(session, attempt, home);
109
113
  if (record.state !== "installed" || record.mode !== "development") throw new Error("Metro restore requires an installed development app.");
110
114
  assertHostedAndroidTarget(home, device);
111
115
  const exec = hostedAndroidExecutor();
112
- const reversed = reverseMetroPorts({
116
+ const reversed = await reverseMetroPorts({
113
117
  serial: device.serial,
114
118
  metroPort: metro.bridgePort,
115
119
  devicePorts: [metro.devicePort]
116
120
  }, { exec });
117
121
  if (reversed.failed) throw new Error(reversed.reason);
118
122
  assertHostedAndroidTarget(home, device);
119
- writeDebugHttpHost({
123
+ await writeDebugHttpHost({
120
124
  serial: device.serial,
121
125
  packageName: record.bundleId,
122
126
  metroPort: metro.devicePort,
@@ -501,7 +505,7 @@ async function installHostedApp(home, session, attempt, device, metroPort) {
501
505
  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
506
  assertHostedDeviceLedger(home, device.udid);
503
507
  if (readHostedDevice(home).udid !== device.udid) throw new Error("The hosted device identity changed.");
504
- const installed = installIosApp({
508
+ const installed = await installIosApp({
505
509
  udid: device.udid,
506
510
  appPath: app,
507
511
  bundleId: record.bundleId,
@@ -511,7 +515,7 @@ async function installHostedApp(home, session, attempt, device, metroPort) {
511
515
  if (!installed.ok) throw new Error(installed.reason ?? "Hosted app installation was not established.");
512
516
  assertHostedDeviceLedger(home, device.udid);
513
517
  if (readHostedDevice(home).udid !== device.udid) throw new Error("The hosted device identity changed.");
514
- const launched = launchIosApp({
518
+ const launched = await launchIosApp({
515
519
  udid: device.udid,
516
520
  bundleId: record.bundleId,
517
521
  metroPort: record.mode === "development" ? metroPort ?? null : null,
@@ -521,7 +525,7 @@ async function installHostedApp(home, session, attempt, device, metroPort) {
521
525
  if (record.mode === "development") return "unverified";
522
526
  for (let tries = 0; tries < 10; tries++) {
523
527
  await new Promise((resolve) => setTimeout(resolve, 200));
524
- if (iosAppProcess(device.udid, record.bundleId).state === "running") return true;
528
+ if ((await iosAppProcess(device.udid, record.bundleId)).state === "running") return true;
525
529
  }
526
530
  return "unverified";
527
531
  }
@@ -530,10 +534,10 @@ async function installHostedApp(home, session, attempt, device, metroPort) {
530
534
  function inventory() {
531
535
  return listAllIosSims({ includeUnavailable: true });
532
536
  }
533
- function selectHostedIosDevice(selectors) {
537
+ async function selectHostedIosDevice(selectors) {
534
538
  inventory();
535
539
  if (readHostMemoryPressure(getExecutor()) !== "normal") throw new Error("Host memory pressure is unknown or elevated.");
536
- const selected = resolveIosCreation(selectors);
540
+ const selected = await resolveIosCreation(selectors);
537
541
  if (!selected.deviceType || !selected.runtime) throw new Error("The installed simulator type or runtime could not be established.");
538
542
  if (process.arch !== "arm64" && process.arch !== "x64") throw new Error("Unsupported simulator host architecture.");
539
543
  return {
@@ -553,15 +557,15 @@ async function runHostedDevice(mode, selectors, app) {
553
557
  if (mode === "prepare") {
554
558
  creationStarted = existsSync(join(home, "hosted-device.json")) || existsSync(join(home, "created-devices.json"));
555
559
  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);
560
+ const selected = await selectHostedIosDevice(selectors);
557
561
  creationStarted = true;
558
- const created = createOwnedIosSim("hosted", {}, selected);
562
+ const created = await createOwnedIosSim("hosted", {}, selected);
559
563
  device = {
560
564
  ...selected,
561
565
  udid: created.udid,
562
566
  name: created.name
563
567
  };
564
- withDirLock(join(home, "hosted-device.lock"), () => {
568
+ await withDirLockAsync(join(home, "hosted-device.lock"), () => {
565
569
  const temporary = join(home, "hosted-device.json.tmp");
566
570
  writeFileSync(temporary, JSON.stringify(device), { mode: 384 });
567
571
  renameSync(temporary, join(home, "hosted-device.json"));
@@ -581,7 +585,7 @@ async function runHostedDevice(mode, selectors, app) {
581
585
  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
586
  let choice;
583
587
  try {
584
- choice = selectHostedIosDevice(selectors);
588
+ choice = await selectHostedIosDevice(selectors);
585
589
  } catch (error) {
586
590
  if (mode === "inspect") return {
587
591
  state: "incompatible",
@@ -603,10 +607,10 @@ async function runHostedDevice(mode, selectors, app) {
603
607
  };
604
608
  await bootIosSim(device.udid, { openViewer: false });
605
609
  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"), () => {
610
+ await resetIosPrivacy(device.udid);
611
+ await resetIosKeychain(device.udid);
612
+ for (const bundleId of await listUserApps(device.udid)) await uninstallIosApp(device.udid, bundleId);
613
+ await withDirLockAsync(join(home, "hosted-device.lock"), () => {
610
614
  const temporary = join(home, "hosted-device.json.tmp");
611
615
  writeFileSync(temporary, JSON.stringify(device), { mode: 384 });
612
616
  renameSync(temporary, join(home, "hosted-device.json"));
@@ -618,7 +622,7 @@ async function runHostedDevice(mode, selectors, app) {
618
622
  };
619
623
  }
620
624
  if (mode === "park") {
621
- const outcome = teardownOwnedIosSim(device.udid);
625
+ const outcome = await teardownOwnedIosSim(device.udid);
622
626
  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
627
  removeHostedAppData(home, { keepBlobs: true });
624
628
  return {
@@ -643,7 +647,7 @@ async function runHostedDevice(mode, selectors, app) {
643
647
  device
644
648
  };
645
649
  }
646
- const outcome = teardownOwnedIosSim(device.udid, { del: true });
650
+ const outcome = await teardownOwnedIosSim(device.udid, { del: true });
647
651
  if (outcome.status !== "torn-down" && outcome.status !== "missing") throw new Error(outcome.reason ?? "Hosted simulator teardown was not established.");
648
652
  const after = inventory().find((sim) => sim.udid === device.udid);
649
653
  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 +700,7 @@ async function runHostedAndroidDevice(mode, request, app) {
696
700
  } : void 0;
697
701
  if (mode === "reverse") {
698
702
  if (!metro) throw new Error("Hosted Android Metro restore needs its bridge and device ports.");
699
- restoreHostedAndroidMetro(home, request.session, app.attempt, device, metro);
703
+ await restoreHostedAndroidMetro(home, request.session, app.attempt, device, metro);
700
704
  return {
701
705
  state: "ready",
702
706
  device
@@ -715,7 +719,7 @@ async function runHostedAndroidDevice(mode, request, app) {
715
719
  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
720
  const choice = selectHostedAndroidDevice(request);
717
721
  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.");
722
+ 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
723
  const selected = {
720
724
  avdName,
721
725
  serial: `emulator-${request.consolePort}`,
@@ -742,7 +746,7 @@ async function runHostedAndroidDevice(mode, request, app) {
742
746
  });
743
747
  assertHostedDeviceLedger(home, avdName, "android");
744
748
  if (portIsOccupied(selected.consolePort)) throw new Error("The selected Android console port became occupied.");
745
- bootAndroidEmulator(avdName, selected.consolePort, {
749
+ await bootAndroidEmulator(avdName, selected.consolePort, {
746
750
  openViewer: false,
747
751
  logFile: join(home, "emulator.log")
748
752
  });
@@ -756,7 +760,7 @@ async function runHostedAndroidDevice(mode, request, app) {
756
760
  packageManager
757
761
  })}`);
758
762
  }
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.");
763
+ 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
764
  return {
761
765
  state: "ready",
762
766
  device: selected
@@ -765,10 +769,10 @@ async function runHostedAndroidDevice(mode, request, app) {
765
769
  device = readHostedDevice(home, "android");
766
770
  const ledger = assertHostedDeviceLedger(home, device.avdName, "android", { allowEmpty: mode === "stop" });
767
771
  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.");
772
+ 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.");
773
+ if (!(await resolveOwnedAvdSerialAsync(device.avdName, { timeoutMs: 5e3 })).notRunning) throw new Error("The parked hosted AVD is missing, not owned or running.");
770
774
  assertOwnedAvdStopped(device.avdName);
771
- if (getAvdNameForSerial(device.serial) === device.avdName) throw new Error("The parked hosted emulator is still running.");
775
+ if (await getAvdNameForSerialAsync(device.serial) === device.avdName) throw new Error("The parked hosted emulator is still running.");
772
776
  if (ownedAvdSystemImage(device.avdName) !== device.systemImage) throw new Error("The parked hosted AVD system image no longer matches its device record.");
773
777
  let choice;
774
778
  try {
@@ -798,12 +802,12 @@ async function runHostedAndroidDevice(mode, request, app) {
798
802
  consolePort: request.consolePort,
799
803
  serial: `emulator-${request.consolePort}`
800
804
  };
801
- withDirLock(join(home, "hosted-device.lock"), () => {
805
+ await withDirLockAsync(join(home, "hosted-device.lock"), () => {
802
806
  const temporary = join(home, "hosted-device.json.tmp");
803
807
  writeFileSync(temporary, JSON.stringify(device), { mode: 384 });
804
808
  renameSync(temporary, join(home, "hosted-device.json"));
805
809
  });
806
- bootAndroidEmulator(device.avdName, device.consolePort, {
810
+ await bootAndroidEmulator(device.avdName, device.consolePort, {
807
811
  openViewer: false,
808
812
  logFile: join(home, "emulator.log")
809
813
  });
@@ -817,7 +821,7 @@ async function runHostedAndroidDevice(mode, request, app) {
817
821
  packageManager
818
822
  })}`);
819
823
  }
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.");
824
+ 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
825
  await resetAdoptedAvd(device.avdName, device.serial, "");
822
826
  removeHostedAppData(home, { keepBlobs: true });
823
827
  return {
@@ -826,10 +830,10 @@ async function runHostedAndroidDevice(mode, request, app) {
826
830
  };
827
831
  }
828
832
  if (mode === "park") {
829
- const outcome = teardownOwnedAvd(device.avdName, {});
833
+ const outcome = await teardownOwnedAvd(device.avdName, {});
830
834
  if (outcome.status !== "torn-down") throw new Error(outcome.reason ?? "Hosted Android shutdown was not established.");
831
835
  assertOwnedAvdStopped(device.avdName);
832
- if (getAvdNameForSerial(device.serial) === device.avdName) throw new Error("The hosted Android emulator is still running.");
836
+ if (await getAvdNameForSerialAsync(device.serial) === device.avdName) throw new Error("The hosted Android emulator is still running.");
833
837
  removeHostedAppData(home, { keepBlobs: true });
834
838
  return {
835
839
  state: "parked",
@@ -837,15 +841,15 @@ async function runHostedAndroidDevice(mode, request, app) {
837
841
  };
838
842
  }
839
843
  if (ledger === "listed") {
840
- withConfigLock$1(() => {
844
+ await withConfigLockAsync$1(() => {
841
845
  if (!loadConfig$1()) ensureConfig();
842
846
  });
843
- const outcome = teardownOwnedAvd(device.avdName, { del: true });
847
+ const outcome = await teardownOwnedAvd(device.avdName, { del: true });
844
848
  if (outcome.status !== "torn-down" && outcome.status !== "missing") throw new Error(outcome.reason ?? "Hosted Android deletion was not established.");
845
849
  }
846
850
  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.");
851
+ 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.");
852
+ if (await getAvdNameForSerialAsync(device.serial) === device.avdName) throw new Error("The hosted Android emulator is still running.");
849
853
  if (ledger === "listed") forgetCreatedDevice("android", device.avdName);
850
854
  removeHostedAppData(home);
851
855
  return {
@@ -1131,7 +1135,7 @@ async function runHostedMacosApp(mode, request, app) {
1131
1135
  }
1132
1136
  //#endregion
1133
1137
  //#region src/device-host/offer.ts
1134
- function inspectHostedDevice(request, options) {
1138
+ async function inspectHostedDevice(request, options) {
1135
1139
  const cpus = availableParallelism();
1136
1140
  let workerDiskFreeBytes = null;
1137
1141
  try {
@@ -1156,7 +1160,7 @@ function inspectHostedDevice(request, options) {
1156
1160
  declined: null
1157
1161
  } : request.platform === "ios" ? {
1158
1162
  platform: "ios",
1159
- choice: selectHostedIosDevice(request),
1163
+ choice: await selectHostedIosDevice(request),
1160
1164
  resources,
1161
1165
  declined: null
1162
1166
  } : {
@@ -1209,7 +1213,7 @@ async function main() {
1209
1213
  if (input.mode === "offer") {
1210
1214
  const request = parseHostedOfferRequest(input);
1211
1215
  if (!request) throw new Error("Invalid hosted offer selectors.");
1212
- process.stdout.write(`${JSON.stringify(inspectHostedDevice(request, exclude ? { exclude } : void 0))}\n`);
1216
+ process.stdout.write(`${JSON.stringify(await inspectHostedDevice(request, exclude ? { exclude } : void 0))}\n`);
1213
1217
  return;
1214
1218
  }
1215
1219
  if (process.platform !== "darwin") {