stim 1.28.0 → 1.29.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 (153) hide show
  1. package/dist/{acquire-artifact-CKByBnTD.mjs → acquire-artifact-C2DKfenN.mjs} +1 -1
  2. package/dist/{act-8iswyfRa.mjs → act-CrTcskiE.mjs} +479 -29
  3. package/dist/{activity-DRMg4_mD.mjs → activity-BR5oHSO5.mjs} +6 -5
  4. package/dist/{agent-device-usage-output-tE90fDdo.mjs → agent-device-usage-output-W0x4SoC7.mjs} +4 -4
  5. package/dist/{android-CsPs-7Mg.mjs → android-BHKgeOuq.mjs} +5 -5
  6. package/dist/{android-YWCbmkVK.mjs → android-BPmCmyAy.mjs} +5 -5
  7. package/dist/{android-D577ApKG.mjs → android-CLU_MMnb.mjs} +1 -1
  8. package/dist/{android-cas-_aDifWW0.mjs → android-cas-BH6K12__.mjs} +4 -4
  9. package/dist/{android-CHmSU4B4.mjs → android-l616dRP1.mjs} +37 -37
  10. package/dist/{android-project-DUGMbq28.d.mts → android-project-CCEQyYJK.d.mts} +6 -2
  11. package/dist/api.d.mts +7 -4
  12. package/dist/api.mjs +27 -27
  13. package/dist/{apk-signed-tail-CQbwM0qO.mjs → apk-signed-tail-B-wKoF_8.mjs} +2 -2
  14. package/dist/{artifact-bFkfD3vf.mjs → artifact-DHuFYfhD.mjs} +12 -12
  15. package/dist/{artifact-DYtHjxsn.mjs → artifact-Dm9ScLrh.mjs} +12 -12
  16. package/dist/{auto-placement-BVqs8AJi.mjs → auto-placement-C8sJsyMN.mjs} +8 -8
  17. package/dist/{browser-web-BUaLcafY.mjs → browser-web-_tQTbQUs.mjs} +12 -12
  18. package/dist/{build-cQURy_KW.mjs → build-DtCU9Kim.mjs} +23 -23
  19. package/dist/{build-cache-CZULpXVl.mjs → build-cache-BGwTsIEa.mjs} +4 -4
  20. package/dist/{build-plan-CxoYfxsc.mjs → build-plan-CWyjMPKo.mjs} +6 -6
  21. package/dist/{cache-manifest-DEjqGGat.mjs → cache-manifest-evF_zJ9U.mjs} +1 -1
  22. package/dist/cache-manifest.mjs +1 -1
  23. package/dist/{ccache-Bm_A1xX9.mjs → ccache-DsDkdP72.mjs} +17 -17
  24. package/dist/{cli-CpbaLDa7.mjs → cli-3fjOg-Oc.mjs} +19 -19
  25. package/dist/cli.mjs +1 -1
  26. package/dist/{client-YxCer6ab.mjs → client-BTUH8TF1.mjs} +5 -5
  27. package/dist/collector-run.mjs +5 -5
  28. package/dist/{command-output-C8R1KIvi.mjs → command-output-DjCsmzLZ.mjs} +1 -1
  29. package/dist/{config-Cn94Jc0g.mjs → config-AbUjIBOQ.mjs} +121 -19
  30. package/dist/{dependencies-DKeMzwXY.mjs → dependencies-CHNqX6Pr.mjs} +38 -38
  31. package/dist/{dependency-state-CojA2o0t.mjs → dependency-state-CPKAKCZ8.mjs} +1 -1
  32. package/dist/{dev-client-D-BW5uiq.mjs → dev-client-CROrxj1x.mjs} +2 -2
  33. package/dist/{device-CgXfbcz5.mjs → device-Bmm5qjM-.mjs} +14 -14
  34. package/dist/device-BvpasThQ.mjs +297 -0
  35. package/dist/{device-capacity-Cd8lMSn3.mjs → device-capacity-B2ChA-bz.mjs} +7 -7
  36. package/dist/device-host-worker.mjs +12 -12
  37. package/dist/{device-ios-Cc9ulihb.mjs → device-ios-CYzivd31.mjs} +9 -9
  38. package/dist/{device-lease-run-Mtzp4THX.mjs → device-lease-run-qRq_2W2V.mjs} +4 -4
  39. package/dist/{device-pool-eRz6DtCg.mjs → device-pool-CrmiE4_x.mjs} +3 -3
  40. package/dist/{device-eeK95Lir.mjs → device-provision-CK2XiEp1.mjs} +11 -302
  41. package/dist/{doctor-C2QyhejJ.mjs → doctor-BO_kaFWX.mjs} +1 -1
  42. package/dist/{doctor-Bz_ouYAW.mjs → doctor-Cp4-HN1f.mjs} +20 -15
  43. package/dist/{doctor-xf7ht-5n.mjs → doctor-Dr3C1iXV.mjs} +19 -19
  44. package/dist/doctor-fingerprint.mjs +1 -1
  45. package/dist/{doctor-watchman-BTW82PDC.mjs → doctor-watchman-CJr2aXXv.mjs} +4 -4
  46. package/dist/{eas-build-Dm6q68QY.mjs → eas-build-D-9HmGZS.mjs} +2 -2
  47. package/dist/{eas-fallback-DajNpxf-.mjs → eas-fallback-Cemt2GVL.mjs} +4 -4
  48. package/dist/{eas-session-ledger-CBFo_Uo1.mjs → eas-session-ledger-B0KLZx5m.mjs} +5 -5
  49. package/dist/{error-diagnostics-D1QfyJzQ.mjs → error-diagnostics-CV_1RoEH.mjs} +8 -8
  50. package/dist/{gc-DM5oMm-J.mjs → gc-CKHqL4aS.mjs} +80 -18
  51. package/dist/{gc-PLFwb0k4.mjs → gc-DjXwQXHK.mjs} +2 -2
  52. package/dist/{guide-C4I46XAk.mjs → guide-CeRlWVsS.mjs} +129 -25
  53. package/dist/{hosted-android-DlaKLbW0.mjs → hosted-android-DI_vvv7U.mjs} +3 -3
  54. package/dist/{hosted-client-DDRm9hPJ.mjs → hosted-client-CgoxdU9j.mjs} +3 -3
  55. package/dist/{hosted-logs-bSebOKbz.mjs → hosted-logs-C-4INmkn.mjs} +17 -8
  56. package/dist/{hosted-logs-sync-B0c53W_c.mjs → hosted-logs-sync-Bf5s02fi.mjs} +5 -5
  57. package/dist/{hosted-macos-B7-8Pv4H.mjs → hosted-macos-Doh85YUM.mjs} +5 -5
  58. package/dist/{hosted-native-CDe33CSr.mjs → hosted-native-DvZENAL-.mjs} +6 -6
  59. package/dist/{idle-shutdown-CQ0QwU9J.mjs → idle-shutdown-BM37gMfU.mjs} +7 -7
  60. package/dist/{ios-B1HvafEG.mjs → ios-CNDH6fNF.mjs} +8 -8
  61. package/dist/{ios-B1DYuOjh.mjs → ios-CoMCWfub.mjs} +4 -4
  62. package/dist/{ios-tg4tp3q1.mjs → ios-UM_dManb.mjs} +28 -28
  63. package/dist/{ios-device-B4elVFKi.mjs → ios-device-L1-pota_.mjs} +1 -1
  64. package/dist/{ios-project-CR4mZ7CH.mjs → ios-project-DJYptOCh.mjs} +7 -7
  65. package/dist/{ios-state-BPHqMDdZ.mjs → ios-state-Ce_dystM.mjs} +1 -1
  66. package/dist/{js-swap-CVpSW1fn.mjs → js-swap-BthE4kZC.mjs} +4 -4
  67. package/dist/{launch-DoySmhjz.mjs → launch-D798aSm8.mjs} +19 -19
  68. package/dist/{lightened-DFAJgfIk.mjs → lightened-vSxkstg6.mjs} +4 -4
  69. package/dist/{logs-BGsW7iPe.mjs → logs-BND8MiBq.mjs} +9 -8
  70. package/dist/{logs-DI5ILkYB.mjs → logs-CilPftm3.mjs} +5 -5
  71. package/dist/{macos-C12RMJQF.mjs → macos-BOQrKYeJ.mjs} +1 -1
  72. package/dist/{macos-Bo9st9Di.mjs → macos-CxUi9xcE.mjs} +20 -20
  73. package/dist/macos-run.mjs +1 -1
  74. package/dist/maintenance-run.mjs +13 -9
  75. package/dist/{metro-BnhXV2Mj.mjs → metro-BMQHczcf.mjs} +2 -2
  76. package/dist/{metro-request-DXyKjVDF.mjs → metro-request-BtF7ox53.mjs} +1 -1
  77. package/dist/{named-ports-Phoi2POD.mjs → named-ports-DcktE2Pw.mjs} +2 -2
  78. package/dist/{native-android-vxgtLD7w.mjs → native-android-BkhrCjdX.mjs} +16 -16
  79. package/dist/{native-gradle-artifact-inputs-BN96IVw8.mjs → native-gradle-artifact-inputs-Cw4P6Gyr.mjs} +3 -3
  80. package/dist/{native-runtime-DG4Rodzj.mjs → native-runtime-DyH2gkXK.mjs} +6 -6
  81. package/dist/{native-xcode-inputs-BKarCoKg.mjs → native-xcode-inputs-DV8jr3kJ.mjs} +2 -2
  82. package/dist/{native-xcode-ios-8A-efGa5.mjs → native-xcode-ios-DdpPG2iT.mjs} +15 -15
  83. package/dist/{ndjson-Dy2W4vRa.mjs → ndjson-CrjIsGzw.mjs} +2 -2
  84. package/dist/offload-worker.d.mts +1 -1
  85. package/dist/offload-worker.mjs +22 -22
  86. package/dist/{ownership-DJCq48IJ.mjs → ownership-Dtz9G5Gl.mjs} +2 -2
  87. package/dist/{phone-reverses-BzTa8g1F.mjs → phone-reverses-DZRad8HT.mjs} +4 -4
  88. package/dist/{placement-log-Cvhta5ib.mjs → placement-log-CoN6xrjY.mjs} +1 -1
  89. package/dist/{plan-placement-WkZdccuN.mjs → plan-placement-7sHuqR-r.mjs} +6 -6
  90. package/dist/{ports-UV4mJgyC.mjs → ports-VQSAPZhl.mjs} +3 -3
  91. package/dist/{prebuild-k8d_tqOq.mjs → prebuild-Bqp0LFGN.mjs} +9 -9
  92. package/dist/{project-Sui52ywT.mjs → project-D1n0K4yg.mjs} +15 -15
  93. package/dist/{react-native-android-DANlGGQf.mjs → react-native-android-FQ-yX3Mv.mjs} +22 -22
  94. package/dist/{react-native-build-jUHnIfZ9.mjs → react-native-build-D58bIqV9.mjs} +7 -7
  95. package/dist/{react-native-doctor-DCWRjS7K.mjs → react-native-doctor-AkUH2aca.mjs} +5 -5
  96. package/dist/{react-native-ios-BwMsFMXi.mjs → react-native-ios-Dmsv8j7T.mjs} +14 -14
  97. package/dist/{recordings-iy0mkm7b.mjs → recordings-CHMaF73C.mjs} +1 -1
  98. package/dist/{reload-c_uEyc_X.mjs → reload-BV0nD-k9.mjs} +14 -14
  99. package/dist/{reload-Bj7QyuDy.mjs → reload-CDKEzzaf.mjs} +1 -1
  100. package/dist/{remote-DFlpAqdV.mjs → remote-C8xyslUa.mjs} +8 -8
  101. package/dist/{result-BIcXREyC.mjs → result-9fqcJ90W.mjs} +16 -16
  102. package/dist/{run-y2HwyNvg.mjs → run-BQAmrohh.mjs} +2 -2
  103. package/dist/{selection-CXgM_VK_.mjs → selection-D1ZDzHFX.mjs} +105 -62
  104. package/dist/{server-bare-2N4vSRZG.mjs → server-bare-CEQdB_F4.mjs} +37 -1
  105. package/dist/{server-command-qneHPcRI.mjs → server-command-RlS-Kl4a.mjs} +5 -5
  106. package/dist/server-expo-BVV9qy31.mjs +2 -0
  107. package/dist/{server-expo-Ccm9zB0o.mjs → server-expo-bB1VV2k-.mjs} +8 -5
  108. package/dist/{settings-Cfd_Q6ys.mjs → settings-BcVCcAT5.mjs} +2 -2
  109. package/dist/{settings-CY5JZlNN.mjs → settings-D776ygML.mjs} +1 -1
  110. package/dist/{settings-Djl-mpjX.mjs → settings-D9LtQaUw.mjs} +2 -1
  111. package/dist/{settings-payload-DwQiEMCn.mjs → settings-payload-_aatELz2.mjs} +4 -4
  112. package/dist/{settings-write-CJpjkeAd.mjs → settings-write-CkTVGQ4O.mjs} +5 -5
  113. package/dist/settings.schema.json +58 -9
  114. package/dist/{simslim-DCQwzoPy.mjs → simslim-CbpHERcv.mjs} +1 -1
  115. package/dist/{slot-launch-BpmanOnk.mjs → slot-launch-Dbgfh8gc.mjs} +6 -6
  116. package/dist/{stage-CmugrSG5.mjs → stage-BuHuRj1y.mjs} +1 -1
  117. package/dist/{start-CHH3zgIU.mjs → start-Cr-c3Xhq.mjs} +1 -1
  118. package/dist/{start-DYLk6GXn.mjs → start-Dlv4XXTP.mjs} +11 -11
  119. package/dist/{state-BXC1Lfxw.mjs → state-C2AUjjhg.mjs} +1 -1
  120. package/dist/{state-B2QJbDwz.mjs → state-D5ZxwCGJ.mjs} +2 -2
  121. package/dist/{stats-DxKqhcGp.mjs → stats-D5c-uIBp.mjs} +4 -4
  122. package/dist/{status-7ULDEJ1e.mjs → status-CK7ZoEhV.mjs} +2 -2
  123. package/dist/{status-BHCkOZga.mjs → status-D6PBK6_-.mjs} +24 -24
  124. package/dist/{status-D_Ljc89p.mjs → status-DbQv--Yb.mjs} +1 -1
  125. package/dist/{status-watch-BmsPqYSU.mjs → status-watch-okrpea4i.mjs} +4 -4
  126. package/dist/status-worker.mjs +1 -1
  127. package/dist/{stim-desktop-CbWo21kb.mjs → stim-desktop-CYXLFpFS.mjs} +1 -1
  128. package/dist/{stop-b2pouxAO.mjs → stop-CHtAiv79.mjs} +2 -2
  129. package/dist/{stop-D-dGE9gh.mjs → stop-p9uSKuGE.mjs} +20 -19
  130. package/dist/{stop-DQvE-P76.mjs → stop-uRQ-zYcl.mjs} +4 -4
  131. package/dist/supervisor-run.d.mts +1 -0
  132. package/dist/supervisor-run.mjs +23 -19
  133. package/dist/{support-BtlJKjyQ.mjs → support-BMpQIug0.mjs} +9 -9
  134. package/dist/{support-04IhBUTT.mjs → support-PFyTkrnr.mjs} +4 -4
  135. package/dist/{swiftpm-artifact-inputs-Cj2UpmPN.mjs → swiftpm-artifact-inputs-Cddq6jN2.mjs} +1 -1
  136. package/dist/{swiftpm-macos-BhF2stxY.mjs → swiftpm-macos-BSj9iZlI.mjs} +8 -8
  137. package/dist/{toolchain-qktiV8xc.mjs → toolchain-B-mzR9Rh.mjs} +1 -1
  138. package/dist/{toolchain-mLA_km-b.mjs → toolchain-CLGnEUgT.mjs} +4 -4
  139. package/dist/{trigger-DMou-X7j.mjs → trigger-CfnOfpDd.mjs} +1 -1
  140. package/dist/trigger-DBZ-GBrl.mjs +2 -0
  141. package/dist/{warm-progress-B0Vpuvpl.mjs → warm-progress--KkkBBaq.mjs} +3 -3
  142. package/dist/web-BxSo493O.mjs +2 -0
  143. package/dist/web-run.mjs +5 -5
  144. package/dist/{web-BYmK0TjL.mjs → web-xlVssjQf.mjs} +8 -8
  145. package/dist/{workspace-state-kIZrdlSg.mjs → workspace-state-DGwkPXwq.mjs} +2 -2
  146. package/dist/{workspaces-CmOcceDN.mjs → workspaces-CvSYD_78.mjs} +11 -11
  147. package/dist/{worktree-2dk5edza.mjs → worktree-CaQBf6kh.mjs} +25 -25
  148. package/dist/{worktree-nliAoHxB.mjs → worktree-DTOIohFe.mjs} +1 -1
  149. package/package.json +7 -7
  150. package/shim/bundle-response.cjs +37 -0
  151. package/dist/server-expo-WulkyAwT.mjs +0 -2
  152. package/dist/trigger-qp2ji5wE.mjs +0 -2
  153. package/dist/web-CrVLVQZY.mjs +0 -2
@@ -0,0 +1,297 @@
1
+ import { G as projectDeviceSlots, V as deviceSlotKey, W as parseDeviceSlotOption, p as getProject } from "./config-AbUjIBOQ.mjs";
2
+ import { r as clockTime } from "./command-output-DjCsmzLZ.mjs";
3
+ import { i as findProjectRoot, t as NO_PROJECT_REFUSAL } from "./project-D1n0K4yg.mjs";
4
+ import { A as listAdbDevices, O as getAvdNameForSerialAsync, R as memoizeEmulatorProbe, Y as physicalDeviceModel, Z as probeEmulatorSerial, c as androidPoolNoCandidatesRefusal, rt as resolvePhysicalDevice, s as androidPoolCandidates } from "./android-BHKgeOuq.mjs";
5
+ import { En as runProcessOperation } from "./ccache-DsDkdP72.mjs";
6
+ import { C as parseLeaseDuration, D as releaseWorkspaceLeases, j as takeLease, y as fileLeaseIo } from "./activity-BR5oHSO5.mjs";
7
+ import { l as parseDeviceWait, p as waitForDevice } from "./device-lease-run-qRq_2W2V.mjs";
8
+ import { n as runProvision } from "./device-provision-CK2XiEp1.mjs";
9
+ import { a as iosPoolCandidates, c as isWirelessIosDevice, f as resolveIosPhysicalDevice, l as listIosDevices, o as iosPoolNoCandidatesRefusal } from "./ios-device-L1-pota_.mjs";
10
+ import { t as selectFromPool } from "./device-pool-CrmiE4_x.mjs";
11
+ import chalk from "chalk";
12
+ //#region src/commands/device.ts
13
+ const DEFAULT_FOR = "5m";
14
+ const DEFAULT_DEPS = {
15
+ findProjectRoot,
16
+ getProject,
17
+ avdNameOf: getAvdNameForSerialAsync,
18
+ listIosDevices,
19
+ listAdbDevices,
20
+ physicalDeviceModel,
21
+ probeEmulatorSerial,
22
+ takeLease,
23
+ releaseLeases: releaseWorkspaceLeases,
24
+ waitForDevice,
25
+ selectFromPool,
26
+ io: fileLeaseIo,
27
+ now: () => Date.now(),
28
+ sleep: (ms) => new Promise((r) => setTimeout(r, ms)),
29
+ out: (line) => console.log(line),
30
+ note: (line) => console.error(line)
31
+ };
32
+ function grantLine(facts, durationText) {
33
+ return `locked ${facts.deviceName ? `${facts.deviceName} (${facts.id})` : facts.id} for ${facts.holder} until ${clockTime(facts.expiresAt)} (${durationText}). Renew: stim device lock ${facts.platform}${facts.slot ? ` --slot ${facts.slot}` : ""} --for ${durationText}. Release: stim device unlock${facts.slot ? ` --slot ${facts.slot}` : ""}.`;
34
+ }
35
+ function releasedLine(lease) {
36
+ return `unlocked ${lease.deviceName ? `${lease.deviceName} (${lease.id})` : lease.id} -- the ${lease.platform} lease ran until ${clockTime(lease.expiresAt)}.`;
37
+ }
38
+ function readPlatform(value) {
39
+ return value === "ios" || value === "android" ? value : null;
40
+ }
41
+ async function resolveDevice(platform, requested, d) {
42
+ if (platform === "ios") {
43
+ const resolved = resolveIosPhysicalDevice(requested, await d.listIosDevices());
44
+ if (!resolved.udid) return {
45
+ code: "STIM_NO_DEVICE",
46
+ message: resolved.error,
47
+ remedy: resolved.remedy ?? null
48
+ };
49
+ return {
50
+ id: resolved.udid,
51
+ deviceName: resolved.name ?? resolved.udid
52
+ };
53
+ }
54
+ const resolved = resolvePhysicalDevice(requested, d.listAdbDevices(), d.probeEmulatorSerial);
55
+ if (!resolved.serial) return {
56
+ code: "STIM_NO_DEVICE",
57
+ message: resolved.error,
58
+ remedy: resolved.remedy ?? null
59
+ };
60
+ return {
61
+ id: resolved.serial,
62
+ deviceName: d.physicalDeviceModel(resolved.serial) ?? resolved.serial
63
+ };
64
+ }
65
+ async function findOwnedVirtualDevice(project, platform, id, avdNameOf) {
66
+ let running;
67
+ for (const { slot, platforms } of projectDeviceSlots(project)) {
68
+ if (platform === "ios") {
69
+ const sim = platforms.ios;
70
+ if (sim?.owned && sim.deviceUdid && sim.deviceUdid.toLowerCase() === id.toLowerCase()) return {
71
+ id: sim.deviceUdid,
72
+ deviceName: sim.deviceName ?? null,
73
+ slot
74
+ };
75
+ continue;
76
+ }
77
+ const emulator = platforms.android;
78
+ if (!emulator?.owned || !emulator.avdName || !/^emulator-\d+$/.test(id)) continue;
79
+ running ??= { name: await avdNameOf(id) };
80
+ if (running.name === emulator.avdName) return {
81
+ id,
82
+ deviceName: emulator.deviceName ?? emulator.avdName,
83
+ slot
84
+ };
85
+ }
86
+ return null;
87
+ }
88
+ function isFailure(value) {
89
+ return "code" in value;
90
+ }
91
+ async function poolDevice(platform, idLabel, waitSeconds, deadline, root, d, slot) {
92
+ const isEmulator = memoizeEmulatorProbe(d.probeEmulatorSerial);
93
+ const pooled = await d.selectFromPool({
94
+ ...slot ? { slot } : {},
95
+ root,
96
+ platform,
97
+ idLabel,
98
+ list: async () => platform === "ios" ? iosPoolCandidates(await d.listIosDevices()).map((entry) => ({
99
+ id: entry.udid,
100
+ name: entry.name,
101
+ fallback: isWirelessIosDevice(entry)
102
+ })) : androidPoolCandidates(d.listAdbDevices(), isEmulator).map((entry) => ({ id: entry.serial })),
103
+ noCandidates: async () => {
104
+ const resolved = platform === "ios" ? iosPoolNoCandidatesRefusal(await d.listIosDevices()) : androidPoolNoCandidatesRefusal(d.listAdbDevices(), isEmulator);
105
+ return {
106
+ message: resolved.error,
107
+ remedy: resolved.remedy
108
+ };
109
+ },
110
+ waitSeconds,
111
+ deadline,
112
+ now: d.now,
113
+ sleep: d.sleep,
114
+ warn: (line) => d.note(chalk.yellow(line)),
115
+ io: d.io
116
+ });
117
+ if (pooled.status === "refused") return {
118
+ code: pooled.refusal.code,
119
+ message: pooled.refusal.message,
120
+ remedy: pooled.refusal.remedy,
121
+ ...pooled.refusal.lease === null ? {} : { lease: pooled.refusal.lease }
122
+ };
123
+ const name = pooled.candidate.name ?? (platform === "ios" ? pooled.candidate.id : d.physicalDeviceModel(pooled.candidate.id));
124
+ return {
125
+ id: pooled.candidate.id,
126
+ deviceName: name ?? pooled.candidate.id
127
+ };
128
+ }
129
+ async function runLock(platformArg, idArg, opts = {}, overrides = {}) {
130
+ const d = {
131
+ ...DEFAULT_DEPS,
132
+ ...overrides
133
+ };
134
+ const json = Boolean(opts.json);
135
+ const report = (failure) => {
136
+ d.note(chalk.red(`${failure.code}: ${failure.message}`));
137
+ if (failure.remedy) d.note(chalk.dim(failure.remedy));
138
+ if (json) d.out(JSON.stringify({
139
+ code: failure.code,
140
+ message: failure.message,
141
+ remedy: failure.remedy,
142
+ ...failure.lease === void 0 ? {} : { lease: failure.lease }
143
+ }));
144
+ return failure;
145
+ };
146
+ const platform = readPlatform(platformArg);
147
+ if (!platform) return report({
148
+ code: "STIM_BAD_ARG",
149
+ message: `\`stim device lock\` takes ios or android, not ${JSON.stringify(platformArg)}.`,
150
+ remedy: "Run `stim device lock ios` or `stim device lock android`."
151
+ });
152
+ const root = d.findProjectRoot(process.cwd());
153
+ if (!root) return report(NO_PROJECT_REFUSAL);
154
+ const durationText = String(opts.for ?? DEFAULT_FOR).trim();
155
+ const duration = parseLeaseDuration(durationText);
156
+ if ("error" in duration) return report({
157
+ code: "STIM_BAD_ARG",
158
+ message: duration.error,
159
+ remedy: "Pass a whole number of seconds or minutes from 10s to 30m, e.g. --for 90s or --for 10m."
160
+ });
161
+ const wait = parseDeviceWait(opts.wait);
162
+ if ("error" in wait) return report({
163
+ code: "STIM_BAD_ARG",
164
+ message: wait.error,
165
+ remedy: "Pass a whole number of seconds, e.g. --wait 90. `--wait 0` refuses a leased device at once."
166
+ });
167
+ const idLabel = platform === "ios" ? "udid" : "serial";
168
+ const deadline = d.now() + wait.seconds * 1e3;
169
+ const lastLine = { at: null };
170
+ const owned = idArg ? await findOwnedVirtualDevice(d.getProject(root), platform, idArg, d.avdNameOf) : null;
171
+ if (owned && opts.slot && opts.slot !== owned.slot) return report({
172
+ code: "STIM_BAD_ARG",
173
+ message: `${owned.id} is this workspace's ${platform} device in slot ${owned.slot}, not ${opts.slot}.`,
174
+ remedy: `Run \`stim device lock ${platform} ${owned.id}\` without --slot, or with --slot ${owned.slot}.`
175
+ });
176
+ const held = owned ? d.io.readHolder(root)[deviceSlotKey(platform, owned.slot)] : void 0;
177
+ if (owned && held && held.id !== owned.id) return report({
178
+ code: "STIM_DEVICE_BUSY",
179
+ message: `This workspace already leases ${held.id} for ${platform} in slot ${owned.slot}, and a workspace holds one lease per platform and slot.`,
180
+ remedy: `Release it with \`stim device unlock ${platform}${owned.slot === "default" ? "" : ` --slot ${owned.slot}`}\` once nothing depends on it, then lock ${owned.id}.`
181
+ });
182
+ const slot = owned ? owned.slot === "default" ? void 0 : owned.slot : opts.slot;
183
+ const device = owned ? owned : idArg ? await resolveDevice(platform, idArg, d) : await poolDevice(platform, idLabel, wait.seconds, deadline, root, d, opts.slot);
184
+ if (isFailure(device)) return report(device);
185
+ for (;;) {
186
+ const outcome = await d.waitForDevice({
187
+ ...slot ? { slot } : {},
188
+ root,
189
+ platform,
190
+ id: device.id,
191
+ idLabel,
192
+ waitSeconds: wait.seconds,
193
+ now: d.now,
194
+ sleep: d.sleep,
195
+ warn: (line) => d.note(chalk.yellow(line)),
196
+ io: d.io,
197
+ deadline,
198
+ lastLine
199
+ });
200
+ if (outcome.status === "refused") return report({
201
+ ...outcome.refusal,
202
+ lease: outcome.refusal.lease
203
+ });
204
+ const taken = d.takeLease({
205
+ ...slot ? { slot } : {},
206
+ root,
207
+ platform,
208
+ id: device.id,
209
+ deviceName: device.deviceName,
210
+ kind: "declared",
211
+ durationMs: duration.ms
212
+ }, d.io);
213
+ if (taken.status === "unreadable") return report({
214
+ code: "STIM_DEVICE_BUSY",
215
+ message: `The lease file at ${taken.path} does not parse, so Stim cannot tell who holds that device.`,
216
+ remedy: `Read ${taken.path} and, once you know no run depends on it, delete it. \`stim gc\` reports it on every run.`,
217
+ lease: {
218
+ platform: null,
219
+ id: null,
220
+ deviceName: null,
221
+ holder: null,
222
+ expiresAt: null
223
+ }
224
+ });
225
+ if (taken.status === "held") continue;
226
+ const facts = {
227
+ ...taken.lease.slot ? { slot: taken.lease.slot } : {},
228
+ platform,
229
+ id: taken.lease.id,
230
+ deviceName: taken.lease.deviceName,
231
+ holder: taken.lease.holder,
232
+ kind: "declared",
233
+ grantedAt: taken.lease.grantedAt,
234
+ expiresAt: taken.lease.expiresAt,
235
+ leaseSeconds: Math.round(duration.ms / 1e3)
236
+ };
237
+ if (json) d.out(JSON.stringify(facts));
238
+ else d.out(chalk.green(grantLine(facts, durationText)));
239
+ return facts;
240
+ }
241
+ }
242
+ async function runUnlock(platformArg, opts = {}, overrides = {}) {
243
+ const d = {
244
+ ...DEFAULT_DEPS,
245
+ ...overrides
246
+ };
247
+ const json = Boolean(opts.json);
248
+ const report = (failure) => {
249
+ d.note(chalk.red(`${failure.code}: ${failure.message}`));
250
+ if (failure.remedy) d.note(chalk.dim(failure.remedy));
251
+ if (json) d.out(JSON.stringify({
252
+ code: failure.code,
253
+ message: failure.message,
254
+ remedy: failure.remedy
255
+ }));
256
+ return failure;
257
+ };
258
+ const platform = platformArg === void 0 ? null : readPlatform(platformArg);
259
+ if (platformArg !== void 0 && !platform) return report({
260
+ code: "STIM_BAD_ARG",
261
+ message: `\`stim device unlock\` takes ios or android, not ${JSON.stringify(platformArg)}.`,
262
+ remedy: "Run `stim device unlock` for every lease this workspace holds, or name one platform."
263
+ });
264
+ const root = d.findProjectRoot(process.cwd());
265
+ if (!root) return report(NO_PROJECT_REFUSAL);
266
+ const released = d.releaseLeases(root, {
267
+ platform,
268
+ ...opts.slot ? { slot: opts.slot } : {}
269
+ }, d.io);
270
+ if (released.length === 0) d.note(chalk.dim(`No ${platform ? `${platform} ` : ""}device lease to release for ${root}. \`stim status\` lists every lease on this machine.`));
271
+ if (json) d.out(JSON.stringify(released.map((lease) => ({
272
+ ...lease,
273
+ holder: root
274
+ }))));
275
+ else for (const lease of released) d.out(chalk.green(releasedLine(lease)));
276
+ return released;
277
+ }
278
+ function registerDevice(program, deps = {}) {
279
+ const device = program.command("device").description("Lease a connected physical device to this workspace, give it back, or provision iOS signing for it");
280
+ device.command("lock").argument("<platform>", "ios or android").argument("[id]", "the UDID or serial to lease, a connected device or this workspace's own simulator or emulator; without one, the first free connected device is used").description("Lease a connected physical device, or this workspace's own simulator or emulator, to this workspace for a declared time, so another workspace's `--device` run waits and agents see the device as driven. Nothing but this command and a `--device` run moves the expiry.").option("--for <duration>", `How long to hold it: a whole number of seconds or minutes from 10s to 30m (default ${DEFAULT_FOR})`).option("--wait <seconds>", "How long to wait for a device another workspace holds, before refusing with STIM_DEVICE_BUSY (default 60, 0 refuses at once)").option("--slot <name>", "Use this workspace device slot", parseDeviceSlotOption).option("--json", "print the lease as JSON on stdout").action(async (platform, id, opts) => {
281
+ if ("code" in await runLock(platform, id, opts, deps)) process.exit(1);
282
+ });
283
+ device.command("unlock").argument("[platform]", "ios or android; without one, every lease this workspace holds is released").description("Release the device lease or leases this workspace holds. Releasing nothing is not an error.").option("--slot <name>", "Use this workspace device slot", parseDeviceSlotOption).option("--json", "print the released leases as JSON on stdout").action(async (platform, opts) => {
284
+ const result = await runUnlock(platform, opts, deps);
285
+ if (!Array.isArray(result)) process.exit(1);
286
+ });
287
+ device.command("provision").argument("<platform>", "ios").argument("[udid]", "the connected iPhone or iPad to provision for; required when more than one is connected").description("Register a connected iPhone with the project's Apple Developer team and create or refresh its iOS App Development profile, through xcodebuild -allowProvisioningUpdates. It lists the account changes and asks first; no build ever does this.").option("--scheme <name>", "Xcode scheme whose signed targets to provision (default: ios.scheme, then detected)").option("--configuration <name>", "build configuration to provision (default: ios.configuration, then Debug)").option("--yes", "confirm the listed Apple Developer account changes without a prompt").option("--json", "print the plan and result, or the refusal, as JSON on stdout").action(async (platform, udid, opts) => {
288
+ const root = findProjectRoot(process.cwd()) ?? process.cwd();
289
+ const { value: result, interrupted } = await runProcessOperation(root, (operation) => runProvision(platform, udid, opts, { operation }));
290
+ if ("code" in result) process.exit(interrupted ?? 1);
291
+ });
292
+ }
293
+ function deviceCommand(program) {
294
+ registerDevice(program);
295
+ }
296
+ //#endregion
297
+ export { deviceCommand as default, grantLine, registerDevice, releasedLine, runLock, runUnlock };
@@ -1,12 +1,12 @@
1
1
  import { D as ownership_claim_exports, d as workspaceProcessLockError, u as withWorkspaceProcessLock } from "./exec-aULwtNly.mjs";
2
- import { G as projectDeviceSlots, H as deviceSlotPlatforms, O as withConfigLockAsync$1, _ as loadConfig$1, d as getConfigDir, u as getConcurrencyLimits } from "./config-Cn94Jc0g.mjs";
3
- import { a as formatElapsed, l as phaseLine } from "./command-output-C8R1KIvi.mjs";
4
- import { g as deviceReclaimIdleMinutesSetting } from "./settings-CY5JZlNN.mjs";
5
- import { A as listAdbDevices, j as listAdbDevicesAsync } from "./android-CsPs-7Mg.mjs";
6
- import { ot as recordCapacityRefusal, st as recordCapacityWait, v as withIdleWorkspace } from "./workspaces-CmOcceDN.mjs";
2
+ import { G as projectDeviceSlots, H as deviceSlotPlatforms, O as withConfigLockAsync$1, _ as loadConfig$1, d as getConfigDir, u as getConcurrencyLimits } from "./config-AbUjIBOQ.mjs";
3
+ import { a as formatElapsed, l as phaseLine } from "./command-output-DjCsmzLZ.mjs";
4
+ import { g as deviceReclaimIdleMinutesSetting } from "./settings-D776ygML.mjs";
5
+ import { A as listAdbDevices, j as listAdbDevicesAsync } from "./android-BHKgeOuq.mjs";
6
+ import { ot as recordCapacityRefusal, st as recordCapacityWait, v as withIdleWorkspace } from "./workspaces-CvSYD_78.mjs";
7
7
  import { t as canonicalPath } from "./paths-BsJMoPP2.mjs";
8
- import { d as listAllIosSims, f as listAllIosSimsAsync, l as iosRuntimeMatches, y as parseRuntimeVersion } from "./ios-B1DYuOjh.mjs";
9
- import { i as writeIdleShutdownEvent, n as dueIdleDevices, r as shutDownIdleDevices } from "./idle-shutdown-CQ0QwU9J.mjs";
8
+ import { d as listAllIosSims, f as listAllIosSimsAsync, l as iosRuntimeMatches, y as parseRuntimeVersion } from "./ios-CoMCWfub.mjs";
9
+ import { i as writeIdleShutdownEvent, n as dueIdleDevices, r as shutDownIdleDevices } from "./idle-shutdown-BM37gMfU.mjs";
10
10
  import { realpathSync } from "node:fs";
11
11
  import { basename, join } from "node:path";
12
12
  import { workspaceId } from "@stim-cli/core";
@@ -1,17 +1,17 @@
1
1
  import { t as getExecutor } from "./exec-aULwtNly.mjs";
2
- import { _ as ensureWorkspaceStorage, d as writeWorkspaceState } from "./workspace-state-kIZrdlSg.mjs";
3
- import { O as withConfigLockAsync$1, _ as loadConfig$1, c as ensureConfig } from "./config-Cn94Jc0g.mjs";
4
- import { i as macosProcess, o as requiredMacosRecord } from "./state-BXC1Lfxw.mjs";
5
- import { A as listAdbDevices, Ct as forgetCreatedDeviceAsync, D as getAvdNameForSerial, F as listAvdsAsync, I as listInstalledSystemImages, K as ownedAvdSystemImage, M as listAvdDeviceProfiles, O as getAvdNameForSerialAsync, U as ownedAvdName, X as pickDefaultSystemImage, a as androidDeviceAbi, ct as waitForBoot, d as androidToolPath, f as assertOwnedAvdStopped, g as avdPathExists, k as hostSystemImageArch, nt as resolveOwnedAvdSerialAsync, t as DEFAULT_AVD_DEVICE_PROFILE, tt as resetAdoptedAvd, v as avdStorageRoots, x as createOwnedAvd, y as bootAndroidEmulator } from "./android-CsPs-7Mg.mjs";
6
- import { a as parsePidof, i as parseLogcatLine, t as androidClockOffset } from "./android-D577ApKG.mjs";
7
- import { i as createNdjsonWriter } from "./ndjson-Dy2W4vRa.mjs";
8
- import { _n as reverseMetroPorts, dn as installIosApp, fn as iosAppProcess, hn as launchIosApp, ln as installAndroidApp, mn as launchAndroidReleaseApp, pn as launchAndroidApp, tn as androidAppProcess, vn as writeDebugHttpHost } from "./ccache-Bm_A1xX9.mjs";
9
- import { ht as teardownOwnedIosSim, pt as teardownOwnedAvd } from "./workspaces-CmOcceDN.mjs";
10
- import { E as resolveIosCreation, R as readHostMemoryPressure, T as resetIosPrivacy, a as createOwnedIosSim, d as listAllIosSims, g as listUserApps, j as uninstallIosApp, n as bootIosSim, w as resetIosKeychain } from "./ios-B1DYuOjh.mjs";
11
- import { i as stopMacosAppHeld, n as stopHostedBundleInstances } from "./stop-DQvE-P76.mjs";
2
+ import { _ as ensureWorkspaceStorage, d as writeWorkspaceState } from "./workspace-state-DGwkPXwq.mjs";
3
+ import { O as withConfigLockAsync$1, _ as loadConfig$1, c as ensureConfig } from "./config-AbUjIBOQ.mjs";
4
+ import { i as macosProcess, o as requiredMacosRecord } from "./state-C2AUjjhg.mjs";
5
+ import { A as listAdbDevices, Ct as forgetCreatedDeviceAsync, D as getAvdNameForSerial, F as listAvdsAsync, I as listInstalledSystemImages, K as ownedAvdSystemImage, M as listAvdDeviceProfiles, O as getAvdNameForSerialAsync, U as ownedAvdName, X as pickDefaultSystemImage, a as androidDeviceAbi, ct as waitForBoot, d as androidToolPath, f as assertOwnedAvdStopped, g as avdPathExists, k as hostSystemImageArch, nt as resolveOwnedAvdSerialAsync, t as DEFAULT_AVD_DEVICE_PROFILE, tt as resetAdoptedAvd, v as avdStorageRoots, x as createOwnedAvd, y as bootAndroidEmulator } from "./android-BHKgeOuq.mjs";
6
+ import { a as parsePidof, i as parseLogcatLine, t as androidClockOffset } from "./android-CLU_MMnb.mjs";
7
+ import { i as createNdjsonWriter } from "./ndjson-CrjIsGzw.mjs";
8
+ import { _n as reverseMetroPorts, dn as installIosApp, fn as iosAppProcess, hn as launchIosApp, ln as installAndroidApp, mn as launchAndroidReleaseApp, pn as launchAndroidApp, tn as androidAppProcess, vn as writeDebugHttpHost } from "./ccache-DsDkdP72.mjs";
9
+ import { ht as teardownOwnedIosSim, pt as teardownOwnedAvd } from "./workspaces-CvSYD_78.mjs";
10
+ import { E as resolveIosCreation, R as readHostMemoryPressure, T as resetIosPrivacy, a as createOwnedIosSim, d as listAllIosSims, g as listUserApps, j as uninstallIosApp, n as bootIosSim, w as resetIosKeychain } from "./ios-CoMCWfub.mjs";
11
+ import { i as stopMacosAppHeld, n as stopHostedBundleInstances } from "./stop-uRQ-zYcl.mjs";
12
12
  import { t as spawnEntry } from "./spawn-entry-jw19m8Nl.mjs";
13
- import { i as countLiveOwnedDevices } from "./device-capacity-Cd8lMSn3.mjs";
14
- import { _ as findAapt } from "./support-04IhBUTT.mjs";
13
+ import { i as countLiveOwnedDevices } from "./device-capacity-B2ChA-bz.mjs";
14
+ import { _ as findAapt } from "./support-PFyTkrnr.mjs";
15
15
  import { t as waitForMacosRegistration } from "./registration-BwCe64PH.mjs";
16
16
  import { n as parseLogStreamLine } from "./ios-CsRVik64.mjs";
17
17
  import { createHash, randomUUID } from "node:crypto";
@@ -1,13 +1,13 @@
1
1
  import { D as ownership_claim_exports, o as cancellableSleep, t as getExecutor, u as withWorkspaceProcessLock } from "./exec-aULwtNly.mjs";
2
- import { D as workspaceId$1, k as workspaceLogsDir$1 } from "./workspace-state-kIZrdlSg.mjs";
3
- import { C as saveConfig, G as projectDeviceSlots, H as deviceSlotPlatforms, O as withConfigLockAsync$1, _ as loadConfig$1, a as clearDevice, d as getConfigDir, w as setDevice } from "./config-Cn94Jc0g.mjs";
4
- import { l as phaseLine } from "./command-output-C8R1KIvi.mjs";
5
- import { D as iosSimSlimProfileSetting, E as iosSimSlimDefaultSetting } from "./settings-CY5JZlNN.mjs";
6
- import { mt as dropParked, pt as adoptParked, vt as parkedMaxSetting, xt as selectParked, yt as readParked } from "./android-CsPs-7Mg.mjs";
7
- import { i as createNdjsonWriter } from "./ndjson-Dy2W4vRa.mjs";
8
- import { _t as teardownParkedIosSim, ht as teardownOwnedIosSim } from "./workspaces-CmOcceDN.mjs";
9
- import { A as springBoardRunning, B as reportMemoryCulprits, C as renameIosSim, D as resolveOwnedIosSim, E as resolveIosCreation, F as hostMemoryPressureAdvice, M as waitForSpringBoard, N as configuredIosSimulatorViewer, R as readHostMemoryPressure, S as readSpringBoardPid, T as resetIosPrivacy, _ as ownedSimName, a as createOwnedIosSim, d as listAllIosSims, f as listAllIosSimsAsync, h as listIosRuntimesAsync, n as bootIosSim, p as listIosDeviceTypesAsync, u as iosSimulatorFailureAdvice, w as resetIosKeychain, y as parseRuntimeVersion } from "./ios-B1DYuOjh.mjs";
10
- import { c as deviceTypeMismatch, d as runtimeMismatch, g as withDeviceBootAdmission, n as DeviceAdmissionRefusal } from "./device-capacity-Cd8lMSn3.mjs";
2
+ import { D as workspaceId$1, k as workspaceLogsDir$1 } from "./workspace-state-DGwkPXwq.mjs";
3
+ import { C as saveConfig, G as projectDeviceSlots, H as deviceSlotPlatforms, O as withConfigLockAsync$1, _ as loadConfig$1, a as clearDevice, d as getConfigDir, w as setDevice } from "./config-AbUjIBOQ.mjs";
4
+ import { l as phaseLine } from "./command-output-DjCsmzLZ.mjs";
5
+ import { D as iosSimSlimProfileSetting, E as iosSimSlimDefaultSetting } from "./settings-D776ygML.mjs";
6
+ import { mt as dropParked, pt as adoptParked, vt as parkedMaxSetting, xt as selectParked, yt as readParked } from "./android-BHKgeOuq.mjs";
7
+ import { i as createNdjsonWriter } from "./ndjson-CrjIsGzw.mjs";
8
+ import { _t as teardownParkedIosSim, ht as teardownOwnedIosSim } from "./workspaces-CvSYD_78.mjs";
9
+ import { A as springBoardRunning, B as reportMemoryCulprits, C as renameIosSim, D as resolveOwnedIosSim, E as resolveIosCreation, F as hostMemoryPressureAdvice, M as waitForSpringBoard, N as configuredIosSimulatorViewer, R as readHostMemoryPressure, S as readSpringBoardPid, T as resetIosPrivacy, _ as ownedSimName, a as createOwnedIosSim, d as listAllIosSims, f as listAllIosSimsAsync, h as listIosRuntimesAsync, n as bootIosSim, p as listIosDeviceTypesAsync, u as iosSimulatorFailureAdvice, w as resetIosKeychain, y as parseRuntimeVersion } from "./ios-CoMCWfub.mjs";
10
+ import { c as deviceTypeMismatch, d as runtimeMismatch, g as withDeviceBootAdmission, n as DeviceAdmissionRefusal } from "./device-capacity-B2ChA-bz.mjs";
11
11
  import { createHash } from "node:crypto";
12
12
  import { readFileSync } from "node:fs";
13
13
  import { homedir } from "node:os";
@@ -1,8 +1,8 @@
1
1
  import { b as operationState } from "./exec-aULwtNly.mjs";
2
- import { V as deviceSlotKey } from "./config-Cn94Jc0g.mjs";
3
- import { a as formatElapsed, r as clockTime } from "./command-output-C8R1KIvi.mjs";
4
- import { Xt as APP_READINESS_TIMEOUT_MS, zt as MANIFEST_VERIFY_TIMEOUT_MS } from "./ccache-Bm_A1xX9.mjs";
5
- import { E as releaseRunLease, S as parseLease, T as raiseLease, b as leaseIsExpired, j as takeLease, v as deviceLeasePath, y as fileLeaseIo } from "./activity-DRMg4_mD.mjs";
2
+ import { V as deviceSlotKey } from "./config-AbUjIBOQ.mjs";
3
+ import { a as formatElapsed, r as clockTime } from "./command-output-DjCsmzLZ.mjs";
4
+ import { Xt as APP_READINESS_TIMEOUT_MS, zt as MANIFEST_VERIFY_TIMEOUT_MS } from "./ccache-DsDkdP72.mjs";
5
+ import { E as releaseRunLease, S as parseLease, T as raiseLease, b as leaseIsExpired, j as takeLease, v as deviceLeasePath, y as fileLeaseIo } from "./activity-BR5oHSO5.mjs";
6
6
  //#region src/engine/device-lease-run.ts
7
7
  const LEASE_STEP_FLOOR_MS = 6e4;
8
8
  const DEBUG_VERIFY_STEP_MS = MANIFEST_VERIFY_TIMEOUT_MS + APP_READINESS_TIMEOUT_MS;
@@ -1,6 +1,6 @@
1
- import { V as deviceSlotKey } from "./config-Cn94Jc0g.mjs";
2
- import { A as selectPoolDevice, S as parseLease, b as leaseIsExpired, v as deviceLeasePath, y as fileLeaseIo } from "./activity-DRMg4_mD.mjs";
3
- import { i as DEVICE_WAIT_POLL_MS, n as DEVICE_BUSY, o as leaseExpiryText } from "./device-lease-run-Mtzp4THX.mjs";
1
+ import { V as deviceSlotKey } from "./config-AbUjIBOQ.mjs";
2
+ import { A as selectPoolDevice, S as parseLease, b as leaseIsExpired, v as deviceLeasePath, y as fileLeaseIo } from "./activity-BR5oHSO5.mjs";
3
+ import { i as DEVICE_WAIT_POLL_MS, n as DEVICE_BUSY, o as leaseExpiryText } from "./device-lease-run-qRq_2W2V.mjs";
4
4
  //#region src/engine/device-pool.ts
5
5
  function heldPoolId(root, platform, now, io = fileLeaseIo, slot = "default") {
6
6
  const record = io.readHolder(root)[deviceSlotKey(platform, slot)];