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
@@ -0,0 +1,694 @@
1
+ import { d as spawnDeclared, h as withDrainingCancellation, i as withWorkspaceProcessLock, t as getExecutor } from "./exec-DEoAhcze.mjs";
2
+ import { d as workspaceDir, l as workspaceAgentDeviceDir, m as workspaceLogsDir$1, n as ensureWorkspaceStorage } from "./paths-DQtTgsBf.mjs";
3
+ import { E as upsertProject, u as getConcurrencyLimits } from "./config-DlrsduwG.mjs";
4
+ import { l as phaseLine } from "./command-output-gwpm28fu.mjs";
5
+ import { f as throwIfCancelled } from "./operation-exec-BW0em61G.mjs";
6
+ import { d as writeWorkspaceState, i as recordWorkspaceUse } from "./workspace-state-U08dEzhG.mjs";
7
+ import { J as resolveProjectSettingsAsync, a as SETTING_SHAPE_REMEDY, et as settingShapeErrors } from "./settings-C7O8A6ZI.mjs";
8
+ import { f as projectRegistry, i as findProjectRoot$1, s as ownedDeviceLabel } from "./project-wM_XFTvE.mjs";
9
+ import { i as macosProcess, n as macosDir, o as requiredMacosRecord, r as macosLogFile } from "./state-08I3hw3_.mjs";
10
+ import { r as createNdjsonWriter } from "./ndjson-CgE_o3Dl.mjs";
11
+ import { B as recordFinishedBuild, Fn as processContext, H as tapBuildLog, In as runProcessOperation, M as NO_BUILD_PROGRESS, V as startBuildProgress, z as recordBuildPhase } from "./budget-Cvwn54qV.mjs";
12
+ import { d as runCancellationSignal, f as withNativeBuildRun } from "./native-run-NwUuxbkg.mjs";
13
+ import { I as acquireBuildSlot, R as releaseBuildSlot } from "./workspaces-CpANmBlq.mjs";
14
+ import { D as sanitizeDeviceLabel } from "./ios-hcBpnEGk.mjs";
15
+ import { c as offloadPlacement, h as setRemoteLogSink, i as closeOffload, l as placementLoad, n as buildPlacementCandidates, o as offloadBuild, r as chooseBuildMachine, u as remotePhaseText } from "./client-OyRoEuSr.mjs";
16
+ import { a as requireLocalBuild, i as parseBuildMachineOption, r as namedBuildMachine, s as resolveBuildPlacement, t as OffloadRefusal } from "./selection-DSMbWEX2.mjs";
17
+ import { l as connectHost } from "./hosted-client-DZAPrcro.mjs";
18
+ import { t as placeHostedMacos } from "./hosted-macos-_awYSpfv.mjs";
19
+ import { r as stopMacosAppHeld, t as stopBundleInstances } from "./stop-Dky10AEJ.mjs";
20
+ import { t as spawnEntry } from "./spawn-entry-jw19m8Nl.mjs";
21
+ import { t as buildPlacementRecord } from "./placement-log-BnGgJRRZ.mjs";
22
+ import { t as reidentifyBundle } from "./stage-Bps5oius.mjs";
23
+ import { t as validateMacosArtifactPlatform } from "./artifact-platform-CXcmX_j3.mjs";
24
+ import { t as waitForMacosRegistration } from "./registration-BcRgF6Ox.mjs";
25
+ import { createHash, randomUUID } from "node:crypto";
26
+ import { closeSync, existsSync, openSync, promises, realpathSync, renameSync } from "node:fs";
27
+ import { join } from "node:path";
28
+ import { LOG_ROTATE_BYTES, ambientEnv } from "@stim-cli/core";
29
+ import { machineCapacity, validHostedAppArguments } from "@stim-cli/core/state";
30
+ //#region src/macos/build.ts
31
+ async function buildMacosBundle({ context, root, recipe, bundle, bundleId, displayName, scratch, writer, note, record, buildMachine, progress = NO_BUILD_PROGRESS }) {
32
+ const signal = runCancellationSignal(context) ?? context.signal;
33
+ return withDrainingCancellation(context, signal, async () => {
34
+ throwIfCancelled(signal, "macOS build");
35
+ if (record) record.buildMachine = buildMachine;
36
+ setRemoteLogSink(context, (entry) => writer.write({
37
+ ...entry,
38
+ platform: "macos"
39
+ }));
40
+ const write = (msg) => {
41
+ writer.write({
42
+ src: "build",
43
+ platform: "macos",
44
+ level: "info",
45
+ msg
46
+ });
47
+ note(msg);
48
+ };
49
+ let offloadFallback = null;
50
+ let asked = [];
51
+ let failedMachine;
52
+ const fallBack = (reason) => {
53
+ writer.write(buildPlacementRecord({
54
+ platform: "macos",
55
+ buildMachine,
56
+ candidates: asked,
57
+ event: "placement_fallback",
58
+ fallback: {
59
+ code: failedMachine ? "offload-failed" : "no-remote-mac-took-it",
60
+ reason,
61
+ machine: failedMachine
62
+ }
63
+ }));
64
+ if (namedBuildMachine(buildMachine)) throw new OffloadRefusal(buildMachine, reason);
65
+ requireLocalBuild(buildMachine);
66
+ offloadFallback = reason;
67
+ if (record) record.offloadFallback = reason;
68
+ writer.write({
69
+ src: "build",
70
+ platform: "macos",
71
+ level: "warn",
72
+ event: "offload_failed",
73
+ msg: reason
74
+ });
75
+ write(`${reason} -> building here`);
76
+ write(`placement: here (${reason})`);
77
+ };
78
+ await promises.mkdir(macosDir(root), { recursive: true });
79
+ const staging = await promises.mkdtemp(join(macosDir(root), "staging-"));
80
+ const promote = (path) => {
81
+ const backup = join(staging, "previous.app");
82
+ const previous = existsSync(bundle);
83
+ if (previous) renameSync(bundle, backup);
84
+ try {
85
+ renameSync(path, bundle);
86
+ } catch (error) {
87
+ if (previous) renameSync(backup, bundle);
88
+ throw error;
89
+ }
90
+ };
91
+ let choice = null;
92
+ let retainStaging = false;
93
+ let identity = null;
94
+ const save = async (path) => {
95
+ if (!recipe.cache || !identity) return;
96
+ try {
97
+ if ((await recipe.cache.identity()).hash !== identity.hash) {
98
+ if (record) {
99
+ delete record.fingerprint;
100
+ delete record.cacheKey;
101
+ }
102
+ write("macOS inputs changed during the build; installing without caching.");
103
+ return;
104
+ }
105
+ const directory = join(staging, "cache-store");
106
+ await promises.mkdir(directory);
107
+ await recipe.cache.store(identity.key, path, directory);
108
+ } catch (error) {
109
+ if (error instanceof Error && "reportCleanup" in error) {
110
+ retainStaging = true;
111
+ throw error;
112
+ }
113
+ throwIfCancelled(signal, "macOS cache store");
114
+ write(`macOS cache store skipped: ${error instanceof Error ? error.message : String(error)}`);
115
+ }
116
+ };
117
+ try {
118
+ if (record) record.cacheHit = false;
119
+ if (recipe.cache) try {
120
+ identity = await recipe.cache.identity();
121
+ if (record) {
122
+ record.fingerprint = identity.hash;
123
+ record.cacheKey = identity.key;
124
+ }
125
+ const hit = await recipe.cache.restore(identity.key, join(staging, "cache-read"));
126
+ if (hit && (await recipe.cache.identity()).hash === identity.hash) {
127
+ await reidentifyBundle(context, hit.bundle, bundleId, displayName);
128
+ await recipe.validateFetched(hit.bundle, bundleId, displayName);
129
+ throwIfCancelled(signal, "macOS cache restore");
130
+ promote(hit.bundle);
131
+ if (record) {
132
+ record.cacheHit = true;
133
+ record.cacheSource = hit.tier;
134
+ }
135
+ write(`macOS cache hit (${hit.tier})`);
136
+ return {
137
+ bundleId,
138
+ offloadedTo: null,
139
+ offloadFallback: null,
140
+ handoff: null
141
+ };
142
+ }
143
+ } catch (error) {
144
+ if (error instanceof Error && "reportCleanup" in error) {
145
+ retainStaging = true;
146
+ throw error;
147
+ }
148
+ throwIfCancelled(signal, "macOS cache lookup");
149
+ write(`macOS cache lookup skipped: ${error instanceof Error ? error.message : String(error)}`);
150
+ }
151
+ let cacheOnly = false;
152
+ try {
153
+ const { mode, machines, localEnabled } = buildPlacementCandidates(buildMachine);
154
+ const peer = recipe.cache?.peer?.() ?? null;
155
+ const request = {
156
+ ...recipe.offload.request(bundleId),
157
+ ...peer ? {
158
+ artifactInputs: peer.inputs,
159
+ cacheArtifact: peer.write
160
+ } : {}
161
+ };
162
+ const here = machineCapacity();
163
+ const placement = offloadPlacement({
164
+ mode,
165
+ localEnabled,
166
+ machines: machines.length,
167
+ here,
168
+ unsupported: null,
169
+ selected: buildMachine
170
+ });
171
+ cacheOnly = !placement.offload && placement.code === "this-mac-free" && peer !== null;
172
+ if (placement.offload || cacheOnly) {
173
+ const chosen = await chooseBuildMachine({
174
+ projectRoot: root,
175
+ target: await recipe.offload.target(),
176
+ mode,
177
+ here,
178
+ machines,
179
+ selected: buildMachine,
180
+ note: (line) => write(`offload: ${line}`),
181
+ onCandidates: (each) => asked = each,
182
+ cacheOnly,
183
+ ...peer ? { swiftpmArtifact: request } : {}
184
+ });
185
+ if (typeof chosen === "string") throw new Error(chosen);
186
+ choice = chosen;
187
+ failedMachine = chosen.machine;
188
+ writer.write(buildPlacementRecord({
189
+ platform: "macos",
190
+ buildMachine,
191
+ candidates: asked,
192
+ chose: {
193
+ machine: chosen.machine,
194
+ reason: `${placement.reason}${placementLoad(chosen)}`
195
+ }
196
+ }));
197
+ write(`placement: ${choice.machine} (${placement.reason}${placementLoad(choice)})`);
198
+ const outcome = await offloadBuild({
199
+ choice,
200
+ request,
201
+ stagingDir: join(staging, "offload"),
202
+ onPhase: (phase, line) => note(remotePhaseText(phase, line, choice.machine)),
203
+ onEnter: (phase) => {
204
+ if (record && [
205
+ "compile",
206
+ "build",
207
+ "prebuild",
208
+ "pods"
209
+ ].includes(phase)) record.builtOn = choice.machine;
210
+ progress.place({
211
+ host: choice.machine,
212
+ phase
213
+ });
214
+ progress.step(phase === "fetch" ? "install" : "compile");
215
+ },
216
+ onRecord: (entry) => writer.write({
217
+ ...entry,
218
+ offloadedTo: choice.machine
219
+ }),
220
+ note: write
221
+ });
222
+ progress.place(null);
223
+ if (!outcome.ok) throw new Error(`${outcome.machine}: ${outcome.reason}`);
224
+ progress.step("install");
225
+ if (outcome.cacheHit) {
226
+ await reidentifyBundle(context, outcome.artifactPath, bundleId, displayName);
227
+ await validateMacosArtifactPlatform(context, outcome.artifactPath, recipe.product, signal);
228
+ }
229
+ await recipe.validateFetched(outcome.artifactPath, bundleId, displayName);
230
+ throwIfCancelled(signal, "macOS build");
231
+ promote(outcome.artifactPath);
232
+ if (record) {
233
+ delete record.fingerprint;
234
+ delete record.cacheKey;
235
+ record.offloadedTo = outcome.machine;
236
+ record.builtOn = outcome.machine;
237
+ record.cacheHit = outcome.cacheHit === true;
238
+ if (outcome.cacheHit) record.cacheSource = "peer";
239
+ }
240
+ return {
241
+ bundleId,
242
+ offloadedTo: outcome.machine,
243
+ offloadFallback: null,
244
+ handoff: outcome.handoff ?? null
245
+ };
246
+ }
247
+ writer.write(buildPlacementRecord({
248
+ platform: "macos",
249
+ buildMachine,
250
+ stays: {
251
+ code: placement.code,
252
+ reason: placement.reason
253
+ }
254
+ }));
255
+ write(`placement: here (${placement.reason})`);
256
+ } catch (error) {
257
+ if (error instanceof Error && "reportCleanup" in error) {
258
+ retainStaging = true;
259
+ throw error;
260
+ }
261
+ throwIfCancelled(signal, "macOS build");
262
+ if (cacheOnly) write(`placement: here (no reusable peer artifact)`);
263
+ else fallBack(error instanceof Error ? error.message : String(error));
264
+ } finally {
265
+ if (choice) closeOffload(choice);
266
+ }
267
+ let slot;
268
+ try {
269
+ slot = await acquireBuildSlot({
270
+ signal,
271
+ automatic: buildMachine === "auto",
272
+ max: getConcurrencyLimits().maxBuilds,
273
+ root,
274
+ logFile: writer.file,
275
+ out: note,
276
+ waitingFor: (info) => progress.waitingFor(info, "build-slot")
277
+ });
278
+ requireLocalBuild(buildMachine);
279
+ if (record) record.builtOn = "here";
280
+ progress.step("compile");
281
+ const bin = await recipe.compile({
282
+ scratch,
283
+ writer,
284
+ note
285
+ });
286
+ progress.step("install");
287
+ const staged = join(staging, `${recipe.product}.app`);
288
+ await recipe.stage(bin, staged, bundleId, displayName);
289
+ throwIfCancelled(signal, "macOS build");
290
+ releaseBuildSlot(slot);
291
+ slot = void 0;
292
+ await save(staged);
293
+ promote(staged);
294
+ return {
295
+ bundleId,
296
+ offloadedTo: null,
297
+ offloadFallback,
298
+ handoff: null
299
+ };
300
+ } finally {
301
+ releaseBuildSlot(slot);
302
+ }
303
+ } finally {
304
+ try {
305
+ if (!retainStaging) await promises.rm(staging, {
306
+ recursive: true,
307
+ force: true
308
+ });
309
+ } catch {}
310
+ }
311
+ });
312
+ }
313
+ //#endregion
314
+ //#region src/macos/app-name.ts
315
+ const DOT = String.fromCodePoint(183);
316
+ const ELLIPSIS = String.fromCodePoint(8230);
317
+ const LABEL_MAX = 24;
318
+ const PRODUCT_MAX = 40;
319
+ function clip(text, max) {
320
+ const chars = [...text];
321
+ return chars.length <= max ? text : `${chars.slice(0, max - 1).join("")}${ELLIPSIS}`;
322
+ }
323
+ /** The visible app name for a run: `<product> <dot> <label>`, or just the product when the label is empty. */
324
+ function macosAppName(product, label) {
325
+ const name = clip(product.replace(/[\p{Cc}/:\\]+/gu, " ").trim(), PRODUCT_MAX) || "App";
326
+ const suffix = clip(sanitizeDeviceLabel(label), LABEL_MAX);
327
+ return suffix ? `${name} ${DOT} ${suffix}` : name;
328
+ }
329
+ function workspaceAppName(root, product) {
330
+ return macosAppName(product, ownedDeviceLabel(root));
331
+ }
332
+ //#endregion
333
+ //#region src/macos/plan.ts
334
+ async function planMacos(context, root, buildMachineFlag) {
335
+ if (process.platform !== "darwin") throw new Error("stim macos requires a Mac with Swift installed.");
336
+ root = realpathSync(root);
337
+ if (!existsSync(join(root, "Package.swift"))) throw new Error("Run stim macos from the directory containing Package.swift.");
338
+ const { settings } = await resolveProjectSettingsAsync(root, {
339
+ env: context.env,
340
+ signal: context.signal
341
+ });
342
+ const [shape] = settingShapeErrors(settings);
343
+ if (shape) throw new Error(`${shape} ${SETTING_SHAPE_REMEDY}`);
344
+ const selected = resolveBuildPlacement(buildMachineFlag);
345
+ if (selected.failure) throw Object.assign(new Error(selected.failure.message), selected.failure);
346
+ const macos = settings.macos;
347
+ if (!macos?.product || !macos.infoPlist) throw Object.assign(/* @__PURE__ */ new Error("Set macos.product and macos.infoPlist explicitly in .stim.json. See stim guide macos."), { code: "STIM_BAD_ARG" });
348
+ const { swiftpmMacosProject } = await import("./swiftpm-macos-BIak-Rxv.mjs");
349
+ const recipe = await swiftpmMacosProject(root).prepare(context, settings);
350
+ let identity = null;
351
+ let cacheHit = false;
352
+ if (recipe.cache) try {
353
+ identity = await recipe.cache.identity();
354
+ cacheHit = await recipe.cache.has(identity.key);
355
+ } catch (error) {
356
+ if (error instanceof Error && "reportCleanup" in error) throw error;
357
+ context.signal.throwIfAborted();
358
+ }
359
+ return {
360
+ platform: "macos",
361
+ product: macos.product,
362
+ buildMachine: selected.selected,
363
+ fingerprint: identity?.hash ?? null,
364
+ cacheKey: identity?.key ?? null,
365
+ cacheHit,
366
+ provider: null,
367
+ cacheSkipped: identity === null,
368
+ prebuild: null,
369
+ outcome: null,
370
+ expectedMs: null,
371
+ basis: 0
372
+ };
373
+ }
374
+ //#endregion
375
+ //#region src/commands/macos.ts
376
+ /**
377
+ * Builds the Debug app and launches it here, or with `remote` on that approved remote Mac. A named host never falls
378
+ * back to a local launch.
379
+ */
380
+ async function runMacos(context, root, note = console.error, remote, buildMachineFlag) {
381
+ const backend = remote?.trim().toLowerCase();
382
+ if (backend === "eas" || backend === "proxy") throw Object.assign(/* @__PURE__ */ new Error("stim macos --remote takes a remote Mac name from remote.machines; macOS has no eas or proxy backend."), { code: "STIM_BAD_ARG" });
383
+ if (backend === "auto") throw Object.assign(/* @__PURE__ */ new Error("stim macos --remote auto is not available yet: automatic placement has not shipped. Name a hosting Mac from remote.machines."), { code: "STIM_BAD_ARG" });
384
+ if (process.platform !== "darwin") throw new Error("stim macos requires a Mac with Swift installed.");
385
+ root = realpathSync(root);
386
+ const operation = projectRegistry.selectMacos(root);
387
+ if ("problem" in operation) throw Object.assign(new Error(operation.problem.message), {
388
+ code: "STIM_NO_PROJECT",
389
+ remedy: operation.problem.remedy
390
+ });
391
+ const { settings } = await resolveProjectSettingsAsync(root, {
392
+ env: context.env,
393
+ signal: runCancellationSignal(context) ?? context.signal
394
+ });
395
+ const [shape] = settingShapeErrors(settings);
396
+ if (shape) throw new Error(`${shape} ${SETTING_SHAPE_REMEDY}`);
397
+ const selected = resolveBuildPlacement(buildMachineFlag);
398
+ if (selected.failure) throw Object.assign(new Error(selected.failure.message), selected.failure);
399
+ const buildMachine = selected.selected;
400
+ const macos = await (await operation.load()).prepare(context, settings);
401
+ ensureWorkspaceStorage(root);
402
+ return withNativeBuildRun(context, root, {
403
+ command: "macos",
404
+ platform: "macos"
405
+ }, async (claim) => {
406
+ const progress = startBuildProgress({
407
+ root,
408
+ platform: "macos",
409
+ slot: "default",
410
+ claim,
411
+ note
412
+ });
413
+ return withWorkspaceProcessLock(workspaceDir(root), "macos-launch", async () => {
414
+ const previous = requiredMacosRecord(root);
415
+ if (previous?.host && previous.host.machine !== remote) throw new Error(`This workspace's macOS app runs on ${previous.host.machine}. Run stim stop first, then stim macos${remote ? ` --remote ${remote}` : ""}.`);
416
+ if (remote && !validHostedAppArguments(macos.arguments)) throw new Error("macos.arguments is too large for a hosted app: at most 32 arguments of 1024 characters (8192 in total), without NUL or line breaks.");
417
+ if (remote) (await connectHost(remote)).connection.close();
418
+ if (!previous?.host) await stopMacosAppHeld(root);
419
+ upsertProject(root, {});
420
+ recordWorkspaceUse(root, /* @__PURE__ */ new Date(), context.env, context.cwd);
421
+ const bundle = join(macosDir(root), `${macos.product}.app`);
422
+ const record = {
423
+ product: macos.product,
424
+ bundle,
425
+ bundleId: "",
426
+ executable: join(bundle, "Contents", "MacOS", macos.product),
427
+ launchId: randomUUID(),
428
+ arguments: macos.arguments,
429
+ supervisor: macosProcess(process.pid),
430
+ build: {
431
+ state: "running",
432
+ startedAt: (/* @__PURE__ */ new Date()).toISOString(),
433
+ buildMachine
434
+ },
435
+ ...previous?.host ? {
436
+ host: previous.host,
437
+ hostLaunched: previous.hostLaunched ?? false
438
+ } : {}
439
+ };
440
+ const handoff = await buildBundle(context, root, macos, record, remote !== void 0, note, progress);
441
+ progress.step("launch");
442
+ const launched = () => {
443
+ try {
444
+ recordBuildPhase(root, "macos", record.build.startedAt, "launch", progress.durations().launch ?? 0);
445
+ } catch (error) {
446
+ note(`The launch time could not be recorded in the build history: ${error?.message || error}`);
447
+ }
448
+ };
449
+ if (!remote) {
450
+ const here = await launchHere(context, root, record, note);
451
+ launched();
452
+ return here;
453
+ }
454
+ const connection = await connectHost(remote);
455
+ const write = (patch) => writeWorkspaceState(root, { macos: {
456
+ ...record,
457
+ ...patch
458
+ } });
459
+ let placement = record.host;
460
+ try {
461
+ const run = await placeHostedMacos(connection, {
462
+ root,
463
+ bundle: record.bundle,
464
+ bundleId: record.bundleId,
465
+ handoff,
466
+ arguments: macos.arguments,
467
+ recorded: previous?.host,
468
+ reserved: (reserved) => {
469
+ placement = reserved;
470
+ write({
471
+ host: reserved,
472
+ hostLaunched: false
473
+ });
474
+ },
475
+ note
476
+ });
477
+ const placed = {
478
+ ...record,
479
+ supervisor: void 0,
480
+ arguments: run.arguments,
481
+ host: run.placement,
482
+ hostLaunched: run.launched
483
+ };
484
+ writeWorkspaceState(root, { macos: placed });
485
+ launched();
486
+ return placed;
487
+ } catch (error) {
488
+ write({
489
+ supervisor: void 0,
490
+ ...placement ? {
491
+ host: placement,
492
+ hostLaunched: false
493
+ } : {}
494
+ });
495
+ throw error;
496
+ } finally {
497
+ connection.connection.close();
498
+ }
499
+ }, {
500
+ external: true,
501
+ declareSpawnsFor: context,
502
+ ownerPurpose: "build and launch macOS app"
503
+ }).finally(() => progress.clear());
504
+ }, { write: note });
505
+ }
506
+ async function buildBundle(context, root, recipe, record, hosted, note, progress = NO_BUILD_PROGRESS) {
507
+ const started = Date.parse(record.build.startedAt);
508
+ const scratch = join(macosDir(root), "build");
509
+ writeWorkspaceState(root, { macos: record });
510
+ const writer = tapBuildLog(createNdjsonWriter(macosLogFile(root), { maxBytes: LOG_ROTATE_BYTES }), progress);
511
+ try {
512
+ const base = recipe.bundleId;
513
+ const bundleId = hosted ? base : `${base}.stim.${createHash("sha256").update(root).digest("hex").slice(0, 12)}`;
514
+ const displayName = workspaceAppName(root, record.product);
515
+ const built = await buildMacosBundle({
516
+ context,
517
+ root,
518
+ recipe,
519
+ bundle: record.bundle,
520
+ bundleId,
521
+ displayName,
522
+ scratch,
523
+ writer,
524
+ note,
525
+ progress,
526
+ record: record.build,
527
+ buildMachine: record.build.buildMachine
528
+ });
529
+ record.bundleId = built.bundleId;
530
+ record.displayName = displayName;
531
+ record.bundle = realpathSync(record.bundle);
532
+ record.executable = realpathSync(join(record.bundle, "Contents", "MacOS", record.product));
533
+ record.build = {
534
+ ...record.build,
535
+ state: "ok",
536
+ finishedAt: (/* @__PURE__ */ new Date()).toISOString(),
537
+ durationMs: Date.now() - started
538
+ };
539
+ writeWorkspaceState(root, { macos: record });
540
+ recordMacosBuild(root, record.build, progress.steps());
541
+ return built.handoff;
542
+ } catch (error) {
543
+ const message = error instanceof Error ? error.message : String(error);
544
+ writer.write({
545
+ src: "build",
546
+ platform: "macos",
547
+ level: "error",
548
+ msg: message
549
+ });
550
+ const build = {
551
+ ...record.build,
552
+ state: "failed",
553
+ finishedAt: (/* @__PURE__ */ new Date()).toISOString(),
554
+ durationMs: Date.now() - started,
555
+ error: message,
556
+ ..."code" in Object(error) && typeof error.code === "string" ? { errorCode: error.code } : {}
557
+ };
558
+ writeWorkspaceState(root, { macos: {
559
+ ...record,
560
+ supervisor: void 0,
561
+ build
562
+ } });
563
+ recordMacosBuild(root, build, progress.steps());
564
+ throw error;
565
+ } finally {
566
+ writer.close();
567
+ }
568
+ }
569
+ function recordMacosBuild(root, build, compileSteps) {
570
+ recordFinishedBuild(root, {
571
+ platform: "macos",
572
+ status: build.state === "ok" ? "ok" : "failed",
573
+ configuration: "Debug",
574
+ fingerprint: build.fingerprint ?? null,
575
+ cacheKey: build.cacheKey ?? null,
576
+ cacheHit: build.cacheHit ? build.cacheSource === "provider" ? "remote" : "local" : false,
577
+ cacheSkipped: !build.cacheKey,
578
+ durationMs: build.durationMs,
579
+ startedAt: build.startedAt,
580
+ errorCode: build.errorCode,
581
+ buildMachine: build.buildMachine,
582
+ builtOn: build.builtOn,
583
+ offloadedTo: build.offloadedTo,
584
+ offloadFallback: build.offloadFallback,
585
+ ...compileSteps === null ? {} : { compileSteps }
586
+ });
587
+ }
588
+ const LAUNCH_SERVICES_CALL_MS = 2e3;
589
+ async function waitForLaunchServices(record, deadline) {
590
+ if (record.host || !record.app) return "skipped";
591
+ const args = [
592
+ "find",
593
+ `bundleid=${record.bundleId}`,
594
+ `pid=${record.app.pid}`
595
+ ];
596
+ while (Date.now() < deadline) {
597
+ if ((await getExecutor().runFileAsync("lsappinfo", args, { timeoutMs: LAUNCH_SERVICES_CALL_MS }).catch(() => "")).includes("ASN:")) return "listed";
598
+ await new Promise((done) => setTimeout(done, 100));
599
+ }
600
+ return "timeout";
601
+ }
602
+ async function launchHere(context, root, record, note) {
603
+ await stopBundleInstances(root);
604
+ const fd = openSync(join(workspaceLogsDir$1(root), "macos-supervisor.log"), "a");
605
+ let child;
606
+ try {
607
+ child = spawnDeclared(context, () => getExecutor().spawn(process.execPath, [
608
+ spawnEntry("macos-run"),
609
+ root,
610
+ record.launchId
611
+ ], {
612
+ cwd: root,
613
+ detached: true,
614
+ stdio: [
615
+ "ignore",
616
+ fd,
617
+ fd,
618
+ "ipc"
619
+ ],
620
+ env: {
621
+ ...ambientEnv(),
622
+ STIM_BACKGROUND_LAUNCH: "1"
623
+ }
624
+ }));
625
+ child.unref();
626
+ } finally {
627
+ closeSync(fd);
628
+ }
629
+ const deadline = Date.now() + 2e4;
630
+ const current = await waitForMacosRegistration(root, record.launchId, child, deadline);
631
+ if (current) {
632
+ if (await waitForLaunchServices(current, deadline) === "timeout") note("macOS LaunchServices does not list the app yet. agent-device open may start a second copy; wait and check lsappinfo.");
633
+ return current;
634
+ }
635
+ throw new Error("The macOS app did not register. See macos-supervisor.log in the workspace logs.");
636
+ }
637
+ function launchPayload(root, record) {
638
+ const agentDevice = { stateDir: workspaceAgentDeviceDir(root) };
639
+ if (!record.host) return {
640
+ agentDevice,
641
+ platform: "macos",
642
+ ...record
643
+ };
644
+ const { product, displayName, launchId, build, host } = record;
645
+ return {
646
+ agentDevice,
647
+ platform: "macos",
648
+ product,
649
+ displayName,
650
+ launchId,
651
+ build,
652
+ host
653
+ };
654
+ }
655
+ function macosCommand(program) {
656
+ program.command("macos").description("Build and launch an owned Swift Package macOS Debug app.").option("--remote-build <value>", "Build on auto, local, or one named machine; a name refuses without fallback", parseBuildMachineOption).option("--json", "print one launch or plan payload; build output goes to stderr").option("--plan", "validate the next SwiftPM Debug build without building or launching").option("--remote <machine>", "run it on this approved remote Mac from remote.machines").action(async (options) => {
657
+ const root = findProjectRoot$1(process.cwd());
658
+ if (options.plan) {
659
+ try {
660
+ if (!root) throw new Error("Run stim macos from the Swift Package directory.");
661
+ if (options.remote !== void 0) throw Object.assign(/* @__PURE__ */ new Error("--remote selects a launch host and does not apply to --plan."), { code: "STIM_BAD_ARG" });
662
+ const plan = await planMacos(processContext(root, new AbortController().signal), root, options.remoteBuild);
663
+ if (options.json) console.log(JSON.stringify(plan));
664
+ else {
665
+ console.log(phaseLine("plan", `macos ${plan.product}: SwiftPM Debug build, then stage and launch`));
666
+ console.log(phaseLine("build", `selection: ${plan.buildMachine}; worker availability is not checked`));
667
+ console.log(phaseLine("expect", "unknown: SwiftPM determines incremental work when the build runs"));
668
+ }
669
+ } catch (error) {
670
+ const failure = {
671
+ code: error.code ?? "STIM_BAD_ARG",
672
+ message: error instanceof Error ? error.message : String(error),
673
+ remedy: error.remedy ?? "Check the macOS project settings in stim guide macos."
674
+ };
675
+ console.error(failure.message);
676
+ if (options.json) console.log(JSON.stringify(failure));
677
+ process.exitCode = 1;
678
+ }
679
+ return;
680
+ }
681
+ if (!root) throw new Error("Run stim macos from the Swift Package directory.");
682
+ const { value: record } = await runProcessOperation(root, (context) => runMacos(context, root, console.error, options.remote, options.remoteBuild)).catch((error) => {
683
+ const remedy = error.remedy;
684
+ if (typeof remedy === "string") console.error(`remedy: ${remedy}`);
685
+ throw error;
686
+ });
687
+ if (options.json) console.log(JSON.stringify(launchPayload(root, record)));
688
+ else if (record.host) console.log(`Started ${record.product} on ${record.host.machine} as ${record.host.bundleId}${record.hostLaunched === true ? "" : " (launch not confirmed)"}.`);
689
+ else console.log(`Started ${record.product} (pid ${record.app?.pid}).`);
690
+ if (!options.json) console.log(phaseLine("agent-device", `AGENT_DEVICE_STATE_DIR=${workspaceAgentDeviceDir(root)}`));
691
+ });
692
+ }
693
+ //#endregion
694
+ export { buildMacosBundle as a, planMacos as i, runMacos as n, waitForLaunchServices as r, macosCommand as t };
@@ -1,2 +1,2 @@
1
- import { n as runMacosSupervisor, t as logLines } from "./run-BtPgpKks.mjs";
1
+ import { n as runMacosSupervisor, t as logLines } from "./run-DidHghD1.mjs";
2
2
  export { logLines, runMacosSupervisor };