stim 1.20.1 → 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.
- package/README.md +94 -11
- package/dist/acquire-artifact-CD4lbiWE.mjs +153 -0
- package/dist/act-DHAw2A2S.mjs +2667 -0
- package/dist/activity-BzVfHSrY.mjs +1376 -0
- package/dist/{agent-device-usage-output-VPaOgGaF.mjs → agent-device-usage-output-zh1vhbLp.mjs} +21 -66
- package/dist/{android-CZh6ElG5.mjs → android-BEJ8Jpl7.mjs} +3 -3
- package/dist/{android-CLbBJ2ve.mjs → android-BLgbNqox.mjs} +128 -79
- package/dist/{android-eXfIjKJr.mjs → android-CV_GCELZ.mjs} +5 -5
- package/dist/{android-DE8-JfGW.mjs → android-DUYkNF4u.mjs} +188 -106
- package/dist/{android-cas-BFpS84v2.mjs → android-cas-Ct5b1xCK.mjs} +7 -6
- package/dist/android-cas-compiler.mjs +2 -2
- package/dist/android-project-BCAAmMwz.mjs +12 -0
- package/dist/api.d.mts +740 -8
- package/dist/api.mjs +585 -1
- package/dist/{artifact-Ctb2jpw6.mjs → artifact-B8T3S5gi.mjs} +223 -201
- package/dist/{artifact-DXk_Fle_.mjs → artifact-DAuZ-FNU.mjs} +158 -148
- package/dist/{browser-web-xQWC2RWl.mjs → browser-web-QQzVjz3O.mjs} +28 -26
- package/dist/budget-Bs6SxxzO.mjs +9154 -0
- package/dist/{build-COBA1tBc.mjs → build-CoPzQRNw.mjs} +144 -101
- package/dist/build-cache-DmyR9Zzc.mjs +602 -0
- package/dist/build-plan-CaFskB7_.mjs +188 -0
- package/dist/{cache-manifest-qA3dT2x2.mjs → cache-manifest-DkkqguoK.mjs} +10 -5
- package/dist/cache-manifest.mjs +1 -1
- package/dist/{ccache-CtbqWxIC.mjs → ccache-BJRZ9pG3.mjs} +10 -9
- package/dist/{cdp-Dq_ypAlJ.mjs → cdp-CWmIUMbw.mjs} +18 -5
- package/dist/{chrome-Dp2lMLBe.mjs → chrome-B6tfCta1.mjs} +7 -4
- package/dist/{cli-sGqlPu1n.mjs → cli-0DYf8QhQ.mjs} +20 -20
- package/dist/cli.mjs +1 -1
- package/dist/client-B7QVOlCr.d.mts +253 -0
- package/dist/client-UXD70ZbM.mjs +1406 -0
- package/dist/collector-run.d.mts +4 -39
- package/dist/collector-run.mjs +9 -9
- package/dist/{command-output-CPDq_90S.mjs → command-output-B1UrjZHL.mjs} +1 -1
- package/dist/config-CYcBF478.mjs +949 -0
- package/dist/{created-devices-CXBMtoj5.mjs → created-devices-CqeBlrEn.mjs} +3 -3
- package/dist/{dependency-state-B2m8eqsS.mjs → dependency-state-BbKQW83h.mjs} +20 -5
- package/dist/{detached-entry-BXq4fIl-.mjs → detached-entry-DFRyG1_o.mjs} +1 -1
- package/dist/{dev-client-BqYjMIaC.mjs → dev-client-UOeESKm6.mjs} +2 -2
- package/dist/device-DCxH7_By.mjs +1068 -0
- package/dist/{device-D4DqjSZZ.mjs → device-ExJq8Ei7.mjs} +35 -36
- package/dist/{device-capacity-DrwHwR97.mjs → device-capacity-CMlqEcvw.mjs} +43 -14
- package/dist/device-host-worker.mjs +65 -62
- package/dist/{device-ios-DE8KJd3b.mjs → device-ios-DRUeKaFV.mjs} +49 -49
- package/dist/{device-lease-run-Baelt3nc.mjs → device-lease-run-C8raGFoP.mjs} +14 -26
- package/dist/{device-pool-DtK9S6AD.mjs → device-pool-DMRpVX9a.mjs} +5 -5
- package/dist/doctor-BLHCYxzi.mjs +2 -0
- package/dist/{doctor-Dunu3Nv1.mjs → doctor-DTvaDOda.mjs} +317 -344
- package/dist/{doctor-DiP9HsIP.mjs → doctor-Dhqebm0q.mjs} +183 -91
- package/dist/doctor-fingerprint.mjs +19 -0
- package/dist/{doctor-watchman-XJzT8tK-.mjs → doctor-watchman-Cv1F10Kj.mjs} +40 -23
- package/dist/{eas-build-0gadvrca.mjs → eas-build-BomfRnFT.mjs} +53 -20
- package/dist/{build-plan-CRjAA6Qi.mjs → eas-fallback-DJwZpy0c.mjs} +26 -208
- package/dist/{watchman-CqmaGcIb.mjs → eas-session-ledger-op6A54yi.mjs} +229 -11
- package/dist/{error-diagnostics-BhQtoLrZ.mjs → error-diagnostics-Bf0rZvG9.mjs} +172 -82
- package/dist/exec-H20xSg2T.d.mts +65 -0
- package/dist/exec-_UbtCQcG.mjs +750 -0
- package/dist/gc-C-WwL0yi.mjs +3 -0
- package/dist/{gc-D5cz5G0k.mjs → gc-_-dCXdyL.mjs} +625 -786
- package/dist/git-C3iTsJaZ.mjs +73 -0
- package/dist/{guide-DakjcoUt.mjs → guide-Yqwt2bd6.mjs} +990 -280
- package/dist/{hosted-android-C-D8Dj0_.mjs → hosted-android-Bw-honsd.mjs} +8 -6
- package/dist/{hosted-client--hNFgixu.mjs → hosted-client-DB_gBPfY.mjs} +47 -24
- package/dist/{hosted-ios-Chx9XQyI.mjs → hosted-ios-CUvOf4Vr.mjs} +1 -1
- package/dist/{hosted-logs-Bkz0Hxzh.mjs → hosted-logs-DL_P5AdN.mjs} +77 -43
- package/dist/{hosted-macos-ckTjN-0V.mjs → hosted-macos-QI141yKk.mjs} +21 -15
- package/dist/{hosted-native-3KXZ5-qn.mjs → hosted-native-Ksyjgzq-.mjs} +31 -20
- package/dist/idle-BVeRGroT.d.mts +24 -0
- package/dist/{idle-shutdown-DhAUyf5s.mjs → idle-shutdown-DaKmZi0z.mjs} +11 -10
- package/dist/{ios-BDBN-xpf.mjs → ios-CQ68hG9s.mjs} +8 -8
- package/dist/{ios-o896T9PE.mjs → ios-CpByZy12.mjs} +141 -81
- package/dist/{ios-device-B1B14xND.mjs → ios-device-CXGP1bsD.mjs} +1 -1
- package/dist/{ios-device-BWHKGaJq.mjs → ios-device-CwFMehUS.mjs} +60 -35
- package/dist/{ios-project-BeOXKPt2.mjs → ios-project-WuwwBdvW.mjs} +13 -13
- package/dist/{ios-VGvNdsv2.mjs → ios-qNJt4dFm.mjs} +1 -1
- package/dist/ios-signing-DTTIChGs.mjs +489 -0
- package/dist/{ios-state-BsXMwo5y.mjs → ios-state-DvFX-K_l.mjs} +1 -1
- package/dist/{ios-CQ8bHQXB.mjs → ios-ubFsBzwq.mjs} +129 -86
- package/dist/{js-swap-Z_mSuRrx.mjs → js-swap-Cc1dttps.mjs} +60 -33
- package/dist/{launch-V1zqiOYn.mjs → launch-CD1yVc7U.mjs} +92 -91
- package/dist/{launch-BootbMk4.mjs → launch-Zq2mOSDy.mjs} +87 -545
- package/dist/logs-BS00Anxf.mjs +352 -0
- package/dist/logs-CMm05HxN.mjs +255 -0
- package/dist/macos-B65--pPd.mjs +2 -0
- package/dist/{macos-D7irBW3A.mjs → macos-C-0qJ6zq.mjs} +244 -215
- package/dist/macos-run.mjs +1 -1
- package/dist/maintenance-run.mjs +122 -247
- package/dist/{metro-_ZIE3Axg.mjs → metro-DEXpIhHC.mjs} +71 -17
- package/dist/{metro-gateway-BzlQZQmU.mjs → metro-gateway-BMJNlj3E.mjs} +20 -12
- package/dist/{named-ports-O1TIl7tx.mjs → named-ports-BWTzt6mu.mjs} +8 -64
- package/dist/native-android-JACyjTZs.mjs +844 -0
- package/dist/{native-gradle-inputs-BQnIdAlL.mjs → native-gradle-inputs-Bep9JcSF.mjs} +128 -147
- package/dist/native-inputs-TRTTTRxt.mjs +91 -0
- package/dist/native-run-DY_RLx3C.mjs +277 -0
- package/dist/{native-runtime-D024BAvm.mjs → native-runtime-Dg1Q7tfF.mjs} +10 -10
- package/dist/{native-xcode-inputs-UElfGs59.mjs → native-xcode-inputs-CB2iQeWq.mjs} +28 -20
- package/dist/{native-xcode-ios-CjS-nDVY.mjs → native-xcode-ios-CXX39F7o.mjs} +96 -47
- package/dist/{ndjson-GOnbyvso.mjs → ndjson-CgE_o3Dl.mjs} +3 -3
- package/dist/offload-worker.d.mts +1 -46
- package/dist/offload-worker.mjs +213 -86
- package/dist/{ownership-BrjepDiv.mjs → ownership-DEmM5vhh.mjs} +3 -3
- package/dist/{page-Bv9s2KwY.mjs → page-CPaHeYqj.mjs} +7 -4
- package/dist/paths-BsJMoPP2.mjs +12 -0
- package/dist/paths-DQtTgsBf.mjs +42 -0
- package/dist/{placement-log-BItXET1x.mjs → placement-log-BqGbTa61.mjs} +5 -5
- package/dist/{plan-placement-B466UYMU.mjs → plan-placement-Bwj-IjY1.mjs} +6 -6
- package/dist/{ports-BFRL6JTj.mjs → ports-D-MmCTdv.mjs} +3 -3
- package/dist/prebuild-uD_ipCxF.mjs +449 -0
- package/dist/{project-DX8fXyw_.mjs → project-BZNjmW_8.mjs} +65 -38
- package/dist/{pull-request-vOhLNmIb.mjs → pull-request-Lfetn8Kr.mjs} +5 -18
- package/dist/pull-request-zjCSAryH.d.mts +120 -0
- package/dist/pull-requests.d.mts +1 -119
- package/dist/pull-requests.mjs +1 -1
- package/dist/{react-native-android-CuXM3QS8.mjs → react-native-android-DuzH0cn3.mjs} +83 -53
- package/dist/{gradle-CZZo1TSA.mjs → react-native-build-rhk4smwQ.mjs} +292 -15
- package/dist/react-native-doctor-CQpuIMso.mjs +234 -0
- package/dist/{react-native-ios-DtVO4qf2.mjs → react-native-ios-Bhq1rJeV.mjs} +46 -28
- package/dist/{recordings-Bk-VivUV.mjs → recordings-DYteQSu4.mjs} +12 -9
- package/dist/{reload-D9V7D8gP.mjs → reload-CmTRFJaX.mjs} +95 -49
- package/dist/reload-DzjSl5P_.mjs +2 -0
- package/dist/{remote-CZiTijxG.mjs → remote-ByYkXdGD.mjs} +15 -10
- package/dist/result-DNiS-tTP.mjs +434 -0
- package/dist/{run-ClC8UVB5.mjs → run-D23HmJMs.mjs} +4 -5
- package/dist/selection-CSl9i5qU.mjs +619 -0
- package/dist/{server-bare-dWjAarki.mjs → server-bare-CxTrvDg8.mjs} +3 -4
- package/dist/{server-command-DnJYLnr4.mjs → server-command-CtzloH3v.mjs} +14 -7
- package/dist/server-expo-C-90EhcG.mjs +2 -0
- package/dist/{server-expo-CUuzP9Mp.mjs → server-expo-DT_F_uVI.mjs} +51 -15
- package/dist/{settings-Bbztm4oV.mjs → settings-CsJDEXgK.mjs} +301 -132
- package/dist/{settings-vk3mJGSm.d.mts → settings-DkdmlelE.d.mts} +6 -4
- package/dist/settings-T1gtc3bf.mjs +114 -0
- package/dist/settings-write-HyVZ8eQ8.mjs +359 -0
- package/dist/settings.schema.json +163 -16
- package/dist/{simslim-ChMfe8rg.mjs → simslim-Cgk17SXV.mjs} +14 -13
- package/dist/{slot-launch-CeCRr6MK.mjs → slot-launch-DF8VfT64.mjs} +15 -20
- package/dist/{spawn-entry-Dcb7sDUz.mjs → spawn-entry-jw19m8Nl.mjs} +0 -1
- package/dist/stage-BIS0ydsV.mjs +183 -0
- package/dist/{start-CRkG-mZ7.mjs → start-7lpH7hmN.mjs} +66 -48
- package/dist/{start-mh6bS27z.mjs → start-RChynRDp.mjs} +1 -1
- package/dist/{state-lqxdOH_g.mjs → state-C4ZtUisW.mjs} +41 -14
- package/dist/{state-BUpAmt2r.mjs → state-XMziexv2.mjs} +3 -2
- package/dist/{stats-CaB1MxMi.mjs → stats-53T7OTb9.mjs} +7 -13
- package/dist/stats-report-BFfMpWWF.mjs +16 -0
- package/dist/{status-C7vzkInu.mjs → status-BL7jVyAB.mjs} +538 -467
- package/dist/status-CSi6tlRq.mjs +2 -0
- package/dist/{status-BDGHwkCs.mjs → status-DqEUSSxs.mjs} +6 -4
- package/dist/{status-watch-ZaVqRdtW.mjs → status-watch-GDCfqpTE.mjs} +187 -22
- package/dist/status-worker.d.mts +1 -0
- package/dist/status-worker.mjs +19 -0
- package/dist/stim-desktop-C12we7lz.mjs +112 -0
- package/dist/{stop-BU7JaFCg.mjs → stop-Bk_1qiV6.mjs} +2 -2
- package/dist/{stop-BO80KJoT.mjs → stop-CPzlM1L-.mjs} +138 -99
- package/dist/{stop-Cftw_sXJ.mjs → stop-D7h6jAXQ.mjs} +11 -10
- package/dist/supervisor-run.d.mts +8 -17
- package/dist/supervisor-run.mjs +63 -28
- package/dist/{support-Ca6PZbpr.mjs → support-67vraa1Q.mjs} +18 -11
- package/dist/{support-Co0wk8Cv.mjs → support-Dlu37g6H.mjs} +12 -12
- package/dist/{swiftpm-macos-siFSkmCO.mjs → swiftpm-macos-p8WZbxKU.mjs} +35 -24
- package/dist/toolchain-DhKwp9iI.mjs +2 -0
- package/dist/toolchain-Hp9sCpK4.mjs +873 -0
- package/dist/{trigger-C0MWBi8O.mjs → trigger-BAahxUPq.mjs} +20 -5
- package/dist/trigger-Bf3uDcpv.mjs +2 -0
- package/dist/{warm-progress-5FAXkXIg.mjs → warm-progress-BHX5r0Ei.mjs} +252 -176
- package/dist/{web-BTjzE8mc.mjs → web-CJmIj6AI.mjs} +18 -13
- package/dist/web-DknQETPs.mjs +2 -0
- package/dist/web-run.mjs +16 -17
- package/dist/windows-report.d.mts +1 -0
- package/dist/windows-report.mjs +18 -0
- package/dist/windows-report.ps1 +43 -0
- package/dist/workspace-process-lock-1_1OoVW5.mjs +57 -0
- package/dist/{workspace-state-CvgTFe-h.mjs → workspace-state-Cjuigeeu.mjs} +70 -56
- package/dist/{workspaces-C4kqIOlx.mjs → workspaces-BccMFmGQ.mjs} +1188 -1080
- package/dist/worktree-CK2MpJW5.mjs +2 -0
- package/dist/{worktree-DtRsh6go.mjs → worktree-DQ6Zi2Mv.mjs} +368 -110
- package/dist/xcode-Zlx3qjEs.mjs +896 -0
- package/package.json +7 -5
- package/shim/android-optimizations.gradle +7 -5
- package/dist/activity-BaMpUQ4-.mjs +0 -629
- package/dist/api-run.mjs +0 -296
- package/dist/api-zuX3ynYN.mjs +0 -154
- package/dist/app-install-Cg9YJy3x.mjs +0 -873
- package/dist/artifact-lifecycle-DzPpBYvK.mjs +0 -30
- package/dist/budget-RFbwFpG5.mjs +0 -4109
- package/dist/build-facts-DcLv2HSd.d.mts +0 -111
- package/dist/client-zqjFd79D.mjs +0 -1779
- package/dist/config-D0LhTY3S.mjs +0 -524
- package/dist/device-BgNj-qVj.mjs +0 -290
- package/dist/device-lease-C309csaB.mjs +0 -1228
- package/dist/device-remote-DjsNw8DD.mjs +0 -1272
- package/dist/eas-session-ledger-DJDeL4Uq.mjs +0 -205
- package/dist/exec-B81Qodjn.mjs +0 -254
- package/dist/launch-verify-Dl78EVgR.mjs +0 -428
- package/dist/logs-Bh4eqCCc.mjs +0 -384
- package/dist/macos-kivF8qKz.mjs +0 -2
- package/dist/miss-reason-SuTptY-I.mjs +0 -238
- package/dist/native-android-D94RlJ-X.mjs +0 -226
- package/dist/ndjson-Du3j0AQ9.d.mts +0 -17
- package/dist/plan-Jwu_vr-F.mjs +0 -260
- package/dist/prebuild-DB_zLOLc.mjs +0 -213
- package/dist/preview-BRLFRhTz.mjs +0 -1004
- package/dist/process-identity-Biv3arCO.mjs +0 -40
- package/dist/react-native-build-JUF31S8U.mjs +0 -239
- package/dist/react-native-doctor-BQHqiXaQ.mjs +0 -78
- package/dist/remote-cache-fxcl5C-L.mjs +0 -526
- package/dist/result-BrfgXtdO.mjs +0 -186
- package/dist/server-expo-Dvkd7JcF.mjs +0 -2
- package/dist/settings-BuKMOANA.mjs +0 -402
- package/dist/spawn-claims-Kqiifsk2.mjs +0 -72
- package/dist/stage-BNKKdDNc.mjs +0 -157
- package/dist/stim-desktop-8GQX2OV8.mjs +0 -63
- package/dist/tailnet-D7-tE_ug.mjs +0 -265
- package/dist/toolchain-B12psPA2.mjs +0 -2
- package/dist/toolchain-SqehyPLw.mjs +0 -1657
- package/dist/trigger-SHLOWJ4O.mjs +0 -2
- package/dist/web-CHN5gh34.mjs +0 -2
- package/dist/worktree-Cgnm6vZt.mjs +0 -2
- package/dist/{api-run.d.mts → doctor-fingerprint.d.mts} +0 -0
- package/dist/{errors-DzkMYh8Q.mjs → errors-ccaPc4ox.mjs} +2 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { en as throwIfCancelled } from "./settings-CsJDEXgK.mjs";
|
|
2
|
+
import { c as call, l as connectHost } from "./hosted-client-DB_gBPfY.mjs";
|
|
3
|
+
import { i as requestHostedMetro } from "./metro-gateway-BMJNlj3E.mjs";
|
|
4
|
+
import { n as prepareHostedNative, r as stopHostedNative, t as placeHostedNative } from "./hosted-native-Ksyjgzq-.mjs";
|
|
4
5
|
//#region src/device-host/hosted-android.ts
|
|
5
6
|
async function prepareHostedAndroid(machine, selectors, recorded, mode) {
|
|
6
7
|
return await prepareHostedNative(machine, selectors, recorded, "android", false, mode);
|
|
@@ -15,10 +16,11 @@ async function placeHostedAndroid(target, options) {
|
|
|
15
16
|
async function stopHostedAndroid(root, slot) {
|
|
16
17
|
await stopHostedNative(root, slot, "android");
|
|
17
18
|
}
|
|
18
|
-
async function reopenHostedAndroidMetro(root, placement, clientMetroPort) {
|
|
19
|
-
const host = await connectHost(placement.machine, void 0, true);
|
|
19
|
+
async function reopenHostedAndroidMetro(root, placement, clientMetroPort, signal) {
|
|
20
|
+
const host = await connectHost(placement.machine, void 0, true, signal);
|
|
20
21
|
try {
|
|
21
|
-
const gateway = await requestHostedMetro(root, placement.session, host.credential);
|
|
22
|
+
const gateway = await requestHostedMetro(root, placement.session, host.credential, signal);
|
|
23
|
+
throwIfCancelled(signal, "reload");
|
|
22
24
|
await call(host, "device-host.metro.open", {
|
|
23
25
|
session: placement.session,
|
|
24
26
|
clientMetroPort,
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { it as resolveEndpoint } from "./config-CYcBF478.mjs";
|
|
2
|
+
import { Qt as cancellableSleep, en as throwIfCancelled } from "./settings-CsJDEXgK.mjs";
|
|
3
|
+
import { t as BuildConnection } from "./client-UXD70ZbM.mjs";
|
|
4
|
+
import { u as configuredMachines } from "./selection-CSl9i5qU.mjs";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
3
6
|
import { lstatSync, readFileSync, readdirSync, readlinkSync } from "node:fs";
|
|
4
7
|
import { join } from "node:path";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
8
|
+
import { configDir } from "@stim-cli/core";
|
|
9
|
+
import { DEVICE_HOST_LIMITS, HOSTED_APP_CHUNK_BYTES, HOSTED_PARKED_CANDIDATES, hostedMacosAppSlot, hostedWorkerSettleMs, isJsonObject, readDeviceHostMachines } from "@stim-cli/core/state";
|
|
7
10
|
//#region src/device-host/hosted-client.ts
|
|
8
11
|
const CONNECT_TIMEOUT_MS = 1e4;
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const HOSTED_POLL_MARGIN_MS = 45e3;
|
|
13
|
+
const HOSTED_REQUEST_MARGIN_MS = 5e3;
|
|
14
|
+
const workerBoundMs = (deadlineMs) => deadlineMs + hostedWorkerSettleMs();
|
|
15
|
+
const SESSION_TIMEOUT_MS = hostedWorkerSettleMs() + workerBoundMs(DEVICE_HOST_LIMITS.logsMs) + 2 * workerBoundMs(DEVICE_HOST_LIMITS.stopMs) + HOSTED_POLL_MARGIN_MS;
|
|
16
|
+
const PREPARE_TIMEOUT_MS = workerBoundMs(DEVICE_HOST_LIMITS.prepareMs) + HOSTED_POLL_MARGIN_MS;
|
|
17
|
+
const INSTALL_TIMEOUT_MS = workerBoundMs(DEVICE_HOST_LIMITS.prepareMs) + HOSTED_POLL_MARGIN_MS;
|
|
18
|
+
const OFFER_TIMEOUT_MS = workerBoundMs(DEVICE_HOST_LIMITS.offerMs) + HOSTED_REQUEST_MARGIN_MS;
|
|
19
|
+
const RESERVE_TIMEOUT_MS = HOSTED_PARKED_CANDIDATES * (workerBoundMs(DEVICE_HOST_LIMITS.offerMs) + workerBoundMs(DEVICE_HOST_LIMITS.stopMs)) + workerBoundMs(DEVICE_HOST_LIMITS.offerMs) + HOSTED_REQUEST_MARGIN_MS;
|
|
14
20
|
const sha256 = (content) => createHash("sha256").update(content).digest("hex");
|
|
15
21
|
function credentialRefusal(message, remedy = "Run stim doctor.") {
|
|
16
22
|
return Object.assign(new Error(message), {
|
|
@@ -29,22 +35,26 @@ function hostingCredential(machine) {
|
|
|
29
35
|
throw credentialRefusal("The hosting credentials are unreadable. Run stim doctor.");
|
|
30
36
|
}
|
|
31
37
|
const credential = credentials.find((each) => each.machine === machine);
|
|
32
|
-
if (!credential) throw credentialRefusal(`This
|
|
38
|
+
if (!credential) throw credentialRefusal(`This machine has not asked ${machine} for hosting access. Run stim doctor --fix.`, "Run stim doctor --fix.");
|
|
33
39
|
if (credential.state !== "approved") {
|
|
34
|
-
const remedy = `A person on ${machine}
|
|
35
|
-
throw credentialRefusal(`${machine} has not confirmed hosting access for this
|
|
40
|
+
const remedy = `A person on ${machine} runs the stim-server setup command stim doctor --fix printed; then run stim doctor.`;
|
|
41
|
+
throw credentialRefusal(`${machine} has not confirmed hosting access for this machine. ${remedy}`, remedy);
|
|
36
42
|
}
|
|
37
43
|
return credential;
|
|
38
44
|
}
|
|
39
|
-
/** Connects only to the
|
|
40
|
-
async function connectHost(machine, timeoutMs = CONNECT_TIMEOUT_MS, strict = false) {
|
|
45
|
+
/** Connects only to the stim-server that proves it holds the approved machine's pinned key, and only for `device-host`. */
|
|
46
|
+
async function connectHost(machine, timeoutMs = CONNECT_TIMEOUT_MS, strict = false, signal) {
|
|
47
|
+
signal?.throwIfAborted();
|
|
41
48
|
const credential = hostingCredential(machine);
|
|
42
|
-
const target = await
|
|
49
|
+
const target = await resolveEndpoint(credential, void 0, signal);
|
|
50
|
+
signal?.throwIfAborted();
|
|
43
51
|
if (typeof target === "string") throw Object.assign(/* @__PURE__ */ new Error(`Stim does not connect to ${machine}: ${target}.`), { code: "STIM_HOSTING_REFUSED" });
|
|
44
|
-
const opened = await BuildConnection.open(target, credential.
|
|
52
|
+
const opened = await BuildConnection.open(target, credential.serverKey, timeoutMs, "device-host", signal).catch((error) => {
|
|
45
53
|
throw Object.assign(new Error(`${machine} is unreachable. Check stim-server and its tailnet serve route on ${machine}.`, { cause: error }), { code: strict ? "STIM_HOSTING_REFUSED" : "closed" });
|
|
46
54
|
});
|
|
47
|
-
if (
|
|
55
|
+
if (signal?.aborted && opened instanceof BuildConnection) opened.close();
|
|
56
|
+
signal?.throwIfAborted();
|
|
57
|
+
if (!(opened instanceof BuildConnection)) throw Object.assign(/* @__PURE__ */ new Error(opened.code === "server-outdated" ? `${machine} runs a stim-server that speaks an older protocol than this Stim. Run stim doctor for the command that updates it there, then retry.` : opened.refused ? `${machine} refused this machine: ${opened.failure.replace(/\.+$/, "")}. Run stim doctor.` : `${machine} is unreachable: ${opened.failure}. Check stim-server and its tailnet serve route on ${machine}.`), {
|
|
48
58
|
code: strict ? "STIM_HOSTING_REFUSED" : opened.refused ? "STIM_HOSTING_REFUSED" : opened.code ?? "closed",
|
|
49
59
|
hostCode: opened.code
|
|
50
60
|
});
|
|
@@ -60,8 +70,8 @@ function requireHostedAppMode(host, platform, mode) {
|
|
|
60
70
|
}
|
|
61
71
|
const gatewaySecrets = /* @__PURE__ */ new WeakMap();
|
|
62
72
|
function redactHostText(host, message) {
|
|
63
|
-
|
|
64
|
-
return message;
|
|
73
|
+
const secret = gatewaySecrets.get(host);
|
|
74
|
+
return secret ? message.replaceAll(secret, "[redacted]") : message;
|
|
65
75
|
}
|
|
66
76
|
async function call(host, method, params, timeoutMs) {
|
|
67
77
|
if (method === "device-host.metro.open" && isJsonObject(params) && typeof params.secret === "string") gatewaySecrets.set(host, params.secret);
|
|
@@ -89,7 +99,11 @@ async function attach(host, session, timeoutMs, platform = "macos") {
|
|
|
89
99
|
}
|
|
90
100
|
const probeCache = /* @__PURE__ */ new Map();
|
|
91
101
|
function probeHostedSession(placement, { timeoutMs = 3e3, ttlMs = 1e4 } = {}) {
|
|
92
|
-
const key = JSON.stringify([
|
|
102
|
+
const key = JSON.stringify([
|
|
103
|
+
configDir(),
|
|
104
|
+
placement.machine,
|
|
105
|
+
placement.session
|
|
106
|
+
]);
|
|
93
107
|
const cached = probeCache.get(key);
|
|
94
108
|
if (ttlMs > 0 && cached && cached.expiresAt > Date.now()) return cached.promise;
|
|
95
109
|
const promise = probeSession(placement, timeoutMs);
|
|
@@ -128,17 +142,26 @@ async function probeSession(placement, timeoutMs) {
|
|
|
128
142
|
host?.connection.close();
|
|
129
143
|
}
|
|
130
144
|
}
|
|
131
|
-
async function settle(host, session, passing, timeoutMs, platform = "macos") {
|
|
145
|
+
async function settle(host, session, passing, timeoutMs, platform = "macos", signal) {
|
|
132
146
|
const deadline = Date.now() + timeoutMs;
|
|
147
|
+
const what = `wait for hosted session ${session.id}`;
|
|
133
148
|
while (passing.includes(session.state)) {
|
|
149
|
+
throwIfCancelled(signal, what);
|
|
134
150
|
if (Date.now() > deadline) throw new Error(`The hosted session ${session.id} on ${host.machine} stayed ${session.state}.`);
|
|
135
|
-
await
|
|
151
|
+
await cancellableSleep(500, {
|
|
152
|
+
signal,
|
|
153
|
+
what
|
|
154
|
+
});
|
|
136
155
|
session = await attach(host, session.id, void 0, platform);
|
|
137
156
|
}
|
|
138
157
|
return session;
|
|
139
158
|
}
|
|
159
|
+
const reason = (session) => session.notice ? `: ${session.notice.replace(/\.+$/, "")}` : "";
|
|
140
160
|
function unknownSession(host, session) {
|
|
141
|
-
return /* @__PURE__ */ new Error(`The hosted session ${session.id} on ${host.machine} is in an unknown state${session
|
|
161
|
+
return /* @__PURE__ */ new Error(`The hosted session ${session.id} on ${host.machine} is in an unknown state${reason(session)}. Run stim stop to reconcile it.`);
|
|
162
|
+
}
|
|
163
|
+
function stoppedSession(host, session) {
|
|
164
|
+
return /* @__PURE__ */ new Error(`The hosted session ${session.id} on ${host.machine} stopped before it was ready${reason(session)}. Retry when the host can take it; it needs no stim stop.`);
|
|
142
165
|
}
|
|
143
166
|
function bundleManifest(bundle) {
|
|
144
167
|
const files = [];
|
|
@@ -199,4 +222,4 @@ async function upload(host, ids, missing, content) {
|
|
|
199
222
|
}
|
|
200
223
|
}
|
|
201
224
|
//#endregion
|
|
202
|
-
export {
|
|
225
|
+
export { unknownSession as _, SESSION_TIMEOUT_MS as a, call as c, hostedSession as d, probeHostedSession as f, stoppedSession as g, sha256 as h, RESERVE_TIMEOUT_MS as i, connectHost as l, settle as m, OFFER_TIMEOUT_MS as n, attach as o, requireHostedAppMode as p, PREPARE_TIMEOUT_MS as r, bundleManifest as s, INSTALL_TIMEOUT_MS as t, heldNoLonger as u, upload as v };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as prepareHostedNative, r as stopHostedNative, t as placeHostedNative } from "./hosted-native-
|
|
1
|
+
import { n as prepareHostedNative, r as stopHostedNative, t as placeHostedNative } from "./hosted-native-Ksyjgzq-.mjs";
|
|
2
2
|
//#region src/device-host/hosted-ios.ts
|
|
3
3
|
async function prepareHostedIos(machine, selectors, recorded, mode) {
|
|
4
4
|
return await prepareHostedNative(machine, selectors, recorded, "ios", false, mode);
|
|
@@ -1,52 +1,84 @@
|
|
|
1
|
-
import { t as getExecutor } from "./exec-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { l as phaseLine } from "./command-output-
|
|
5
|
-
import {
|
|
6
|
-
import { r as createNdjsonWriter } from "./ndjson-
|
|
7
|
-
import {
|
|
8
|
-
import { o as call } from "./hosted-client--hNFgixu.mjs";
|
|
1
|
+
import { t as getExecutor } from "./exec-_UbtCQcG.mjs";
|
|
2
|
+
import { d as workspaceDir, m as workspaceLogsDir$1 } from "./paths-DQtTgsBf.mjs";
|
|
3
|
+
import { J as validateDeviceSlot, V as deviceSlotFileKey, tt as parseMachine$1 } from "./config-CYcBF478.mjs";
|
|
4
|
+
import { l as phaseLine } from "./command-output-B1UrjZHL.mjs";
|
|
5
|
+
import { n as macosDir } from "./state-XMziexv2.mjs";
|
|
6
|
+
import { r as createNdjsonWriter } from "./ndjson-CgE_o3Dl.mjs";
|
|
7
|
+
import { c as call } from "./hosted-client-DB_gBPfY.mjs";
|
|
9
8
|
import { mkdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
10
9
|
import { dirname, join } from "node:path";
|
|
10
|
+
import { LOG_ROTATE_BYTES, ambientWrite, withDirLockAsync } from "@stim-cli/core";
|
|
11
11
|
import { isJsonObject, parseHostedAgentGrant, parseHostedLogsCursor } from "@stim-cli/core/state";
|
|
12
|
-
import {
|
|
12
|
+
import { loadAgentDriverModule } from "@stim-cli/agent-driver";
|
|
13
|
+
//#region src/device-host/agent-drivers.ts
|
|
14
|
+
const DRIVERS = { "agent-device": {
|
|
15
|
+
load: () => import("@stim-cli/agent-driver-agent-device"),
|
|
16
|
+
configFile: "agent-device-remote.json"
|
|
17
|
+
} };
|
|
18
|
+
function registered(name) {
|
|
19
|
+
return Object.hasOwn(DRIVERS, name);
|
|
20
|
+
}
|
|
21
|
+
/** The client side of a first-party driver, or a reason it is unavailable to this Stim. */
|
|
22
|
+
async function agentDriverClient(name) {
|
|
23
|
+
if (!registered(name)) return { unavailable: `this Stim has no ${name} driver` };
|
|
24
|
+
const { load, configFile } = DRIVERS[name];
|
|
25
|
+
const loaded = await loadAgentDriverModule(name, load);
|
|
26
|
+
if ("unavailable" in loaded) return loaded;
|
|
27
|
+
const { client } = loaded.module;
|
|
28
|
+
if (!client) return { unavailable: `the ${name} driver has no client` };
|
|
29
|
+
if (client.configFile !== configFile) return { unavailable: `the ${name} driver writes ${client.configFile}, not ${configFile}` };
|
|
30
|
+
return { client };
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The config file names every first-party driver's client writes beside a placement. They are listed here rather
|
|
34
|
+
* than read from the drivers, so access is removed even when a driver package does not load.
|
|
35
|
+
*/
|
|
36
|
+
function agentClientFiles() {
|
|
37
|
+
return Object.values(DRIVERS).map((driver) => driver.configFile);
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
13
40
|
//#region src/device-host/hosted-agent.ts
|
|
14
|
-
|
|
41
|
+
/** Removes every driver's client file beside `file`, the placement's agent-device config path. */
|
|
42
|
+
async function removeAgentAccess(file, keep) {
|
|
43
|
+
for (const name of agentClientFiles()) {
|
|
44
|
+
const path = join(dirname(file), name);
|
|
45
|
+
if (path !== keep) rmSync(path, { force: true });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function agentAccess(file, credential, grant, note, platform = "macos") {
|
|
15
49
|
const parsed = grant === void 0 ? null : parseHostedAgentGrant(grant);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
50
|
+
const issued = parsed && "token" in parsed ? parsed : null;
|
|
51
|
+
const loaded = issued ? await agentDriverClient(issued.driver) : null;
|
|
52
|
+
if (grant !== void 0 && !parsed || loaded && "unavailable" in loaded) note(`${credential.machine} offered agent control this Stim does not support.`);
|
|
53
|
+
const port = parseMachine$1(credential.machine)?.port ?? 443;
|
|
54
|
+
const client = loaded && "client" in loaded ? loaded.client : null;
|
|
55
|
+
const target = client ? join(dirname(file), client.configFile) : file;
|
|
56
|
+
const access = client && issued ? client.access({
|
|
57
|
+
grant: issued,
|
|
58
|
+
baseUrl: `https://${credential.address}${port === 443 ? "" : `:${port}`}${issued.path}`,
|
|
59
|
+
file: target,
|
|
60
|
+
platform
|
|
61
|
+
}) : null;
|
|
62
|
+
if (!issued || !access) {
|
|
63
|
+
await removeAgentAccess(file);
|
|
19
64
|
return {
|
|
20
65
|
driver: "none",
|
|
21
66
|
setting: "hosting.agentDriver"
|
|
22
67
|
};
|
|
23
68
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
daemonAuthToken: parsed.token,
|
|
28
|
-
tenant: parsed.lease.tenant,
|
|
29
|
-
sessionIsolation: "tenant",
|
|
30
|
-
runId: parsed.lease.runId,
|
|
31
|
-
...platform === "macos" ? { leaseId: parsed.scope } : {},
|
|
32
|
-
leaseBackend: platform === "macos" ? "macos-app" : `${platform}-instance`,
|
|
33
|
-
leaseProvider: "proxy",
|
|
34
|
-
clientId: parsed.lease.clientId,
|
|
35
|
-
deviceKey: parsed.lease.deviceKey,
|
|
36
|
-
platform
|
|
37
|
-
};
|
|
38
|
-
mkdirSync(dirname(file), { recursive: true });
|
|
39
|
-
const tmp = `${file}.${process.pid}.tmp`;
|
|
69
|
+
await removeAgentAccess(file, target);
|
|
70
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
71
|
+
const tmp = `${target}.${process.pid}.tmp`;
|
|
40
72
|
try {
|
|
41
|
-
writeFileSync(tmp,
|
|
42
|
-
renameSync(tmp,
|
|
73
|
+
writeFileSync(tmp, access.config, { mode: 384 });
|
|
74
|
+
renameSync(tmp, target);
|
|
43
75
|
} finally {
|
|
44
76
|
rmSync(tmp, { force: true });
|
|
45
77
|
}
|
|
46
78
|
return {
|
|
47
|
-
driver:
|
|
48
|
-
remoteConfig:
|
|
49
|
-
command:
|
|
79
|
+
driver: issued.driver,
|
|
80
|
+
remoteConfig: target,
|
|
81
|
+
command: access.command
|
|
50
82
|
};
|
|
51
83
|
}
|
|
52
84
|
//#endregion
|
|
@@ -59,7 +91,7 @@ function canonical(path) {
|
|
|
59
91
|
}
|
|
60
92
|
}
|
|
61
93
|
function report(message) {
|
|
62
|
-
|
|
94
|
+
ambientWrite("stderr", `${phaseLine("device", message.replace(/\s+/g, " "))}\n`);
|
|
63
95
|
}
|
|
64
96
|
function closeAgentConnection(remoteConfig) {
|
|
65
97
|
const exec = getExecutor();
|
|
@@ -118,10 +150,10 @@ function readCursor(root, session, target) {
|
|
|
118
150
|
} catch {}
|
|
119
151
|
}
|
|
120
152
|
const sameCursor = (a, b) => JSON.stringify(Object.entries(a ?? {}).toSorted()) === JSON.stringify(Object.entries(b ?? {}).toSorted());
|
|
121
|
-
function commitPage(root, session, before, records, cursor, target) {
|
|
153
|
+
async function commitPage(root, session, before, records, cursor, target) {
|
|
122
154
|
if (!records.length && sameCursor(before, cursor)) return;
|
|
123
155
|
const directory = logsStateDir(root, target);
|
|
124
|
-
|
|
156
|
+
await withDirLockAsync(join(directory, "host-logs.lock"), () => {
|
|
125
157
|
if (!sameCursor(readCursor(root, session, target), before)) return;
|
|
126
158
|
if (records.length) {
|
|
127
159
|
const writer = createNdjsonWriter(hostLogFile(root, target), { maxBytes: LOG_ROTATE_BYTES });
|
|
@@ -149,14 +181,15 @@ function commitPage(root, session, before, records, cursor, target) {
|
|
|
149
181
|
}
|
|
150
182
|
}, { ensureParent: () => mkdirSync(directory, { recursive: true }) });
|
|
151
183
|
}
|
|
152
|
-
async function pullHostedMacosLogs(root, placement, host, target = MACOS, maxPages = MAX_PAGES, final = false) {
|
|
184
|
+
async function pullHostedMacosLogs(root, placement, host, target = MACOS, maxPages = MAX_PAGES, final = false, signal) {
|
|
153
185
|
const deadline = Date.now() + (final ? 3e4 : 12e4);
|
|
154
186
|
let checkpoint;
|
|
155
187
|
let progressAt = 0;
|
|
156
188
|
for (let page = 0; page < maxPages && Date.now() < deadline; page++) {
|
|
189
|
+
signal?.throwIfAborted();
|
|
157
190
|
const before = readCursor(root, placement.session, target);
|
|
158
191
|
if (final && Date.now() >= progressAt) {
|
|
159
|
-
|
|
192
|
+
ambientWrite("stderr", `Copying final native logs from ${host.machine} (page ${page + 1})\n`);
|
|
160
193
|
progressAt = Date.now() + 5e3;
|
|
161
194
|
}
|
|
162
195
|
const result = await call(host, "device-host.logs.query", {
|
|
@@ -165,7 +198,8 @@ async function pullHostedMacosLogs(root, placement, host, target = MACOS, maxPag
|
|
|
165
198
|
}, Math.max(1, Math.min(2e4, deadline - Date.now())));
|
|
166
199
|
const cursor = isJsonObject(result) ? parseHostedLogsCursor(result.cursor) : null;
|
|
167
200
|
if (!isJsonObject(result) || !cursor || !Array.isArray(result.records) || !result.records.every(isJsonObject) || typeof result.more !== "boolean") throw new Error(`${host.machine} answered device-host.logs.query with an unexpected result.`);
|
|
168
|
-
|
|
201
|
+
signal?.throwIfAborted();
|
|
202
|
+
await commitPage(root, placement.session, before, result.records, cursor, target);
|
|
169
203
|
if (!result.more) return;
|
|
170
204
|
const nextCheckpoint = typeof result.checkpoint === "number" ? result.checkpoint : void 0;
|
|
171
205
|
if (sameCursor(cursor, before) && nextCheckpoint === checkpoint) {
|
|
@@ -176,12 +210,12 @@ async function pullHostedMacosLogs(root, placement, host, target = MACOS, maxPag
|
|
|
176
210
|
}
|
|
177
211
|
if (target.platform !== "macos") throw new Error(final ? "Final native log copy reached its time or page bound; the host keeps collected logs after stop." : "Hosted native logs still have unread pages; run stim logs again.");
|
|
178
212
|
}
|
|
179
|
-
async function pullHostedNativeLogs(root, slot, placement, host, final = false, platform = "ios") {
|
|
213
|
+
async function pullHostedNativeLogs(root, slot, placement, host, final = false, platform = "ios", signal) {
|
|
180
214
|
if (!host.connection.supports(platform === "ios" ? "hosted-ios-data" : "hosted-android-data")) throw new Error(`${host.machine} needs a newer stim-server to collect hosted ${platform === "ios" ? "iOS" : "Android"} native logs.`);
|
|
181
215
|
await pullHostedMacosLogs(root, placement, host, {
|
|
182
216
|
platform,
|
|
183
217
|
slot
|
|
184
|
-
}, final ? 1024 : MAX_PAGES, final);
|
|
218
|
+
}, final ? 1024 : MAX_PAGES, final, signal);
|
|
185
219
|
}
|
|
186
220
|
//#endregion
|
|
187
|
-
export { agentAccess as i, pullHostedNativeLogs as n, closeAgentConnection as r, pullHostedMacosLogs as t };
|
|
221
|
+
export { removeAgentAccess as a, agentAccess as i, pullHostedNativeLogs as n, closeAgentConnection as r, pullHostedMacosLogs as t };
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { a as removeAgentAccess, i as agentAccess, r as closeAgentConnection, t as pullHostedMacosLogs } from "./hosted-logs-DL_P5AdN.mjs";
|
|
2
|
+
import { l as phaseLine } from "./command-output-B1UrjZHL.mjs";
|
|
3
|
+
import { Qt as cancellableSleep } from "./settings-CsJDEXgK.mjs";
|
|
4
|
+
import { n as macosDir } from "./state-XMziexv2.mjs";
|
|
5
|
+
import { d as runCancellationSignal } from "./native-run-DY_RLx3C.mjs";
|
|
6
|
+
import { _ as unknownSession, a as SESSION_TIMEOUT_MS, c as call, d as hostedSession, g as stoppedSession, h as sha256, i as RESERVE_TIMEOUT_MS, l as connectHost, m as settle, o as attach, r as PREPARE_TIMEOUT_MS, s as bundleManifest, t as INSTALL_TIMEOUT_MS, u as heldNoLonger, v as upload } from "./hosted-client-DB_gBPfY.mjs";
|
|
7
|
+
import { randomUUID } from "node:crypto";
|
|
6
8
|
import { join } from "node:path";
|
|
9
|
+
import { ambientContext, ambientWrite } from "@stim-cli/core";
|
|
7
10
|
import { hostedMacosBundleId, parseHostedMacosDevice, validHostedAppArguments } from "@stim-cli/core/state";
|
|
8
|
-
import { randomUUID } from "node:crypto";
|
|
9
11
|
//#region src/device-host/hosted-macos.ts
|
|
10
12
|
const HANDOFF_TIMEOUT_MS = 3e5;
|
|
11
13
|
const agentRemoteConfig = (root) => join(macosDir(root), "agent-device-remote.json");
|
|
@@ -18,8 +20,8 @@ async function placeHostedMacos(host, { root, bundle, bundleId, handoff, argumen
|
|
|
18
20
|
let session = null;
|
|
19
21
|
if (recorded) {
|
|
20
22
|
try {
|
|
21
|
-
session = await settle(host, await attach(host, recorded.session), ["preparing"], PREPARE_TIMEOUT_MS);
|
|
22
|
-
session = await settle(host, session, ["stopping"], SESSION_TIMEOUT_MS);
|
|
23
|
+
session = await settle(host, await attach(host, recorded.session), ["preparing"], PREPARE_TIMEOUT_MS, "macos", runCancellationSignal(ambientContext()));
|
|
24
|
+
session = await settle(host, session, ["stopping"], SESSION_TIMEOUT_MS, "macos", runCancellationSignal(ambientContext()));
|
|
23
25
|
} catch (error) {
|
|
24
26
|
if (!heldNoLonger(error)) throw error;
|
|
25
27
|
}
|
|
@@ -33,7 +35,7 @@ async function placeHostedMacos(host, { root, bundle, bundleId, handoff, argumen
|
|
|
33
35
|
slot: "default",
|
|
34
36
|
attempt: randomUUID(),
|
|
35
37
|
platform: "macos"
|
|
36
|
-
}));
|
|
38
|
+
}, RESERVE_TIMEOUT_MS));
|
|
37
39
|
}
|
|
38
40
|
const appSlot = session.appSlot;
|
|
39
41
|
if (appSlot === void 0) throw new Error(`${host.machine} reserved a session without a macOS app slot.`);
|
|
@@ -50,8 +52,9 @@ async function placeHostedMacos(host, { root, bundle, bundleId, handoff, argumen
|
|
|
50
52
|
}
|
|
51
53
|
};
|
|
52
54
|
reserved(placement);
|
|
53
|
-
session = await settle(host, session, ["preparing"], PREPARE_TIMEOUT_MS);
|
|
55
|
+
session = await settle(host, session, ["preparing"], PREPARE_TIMEOUT_MS, "macos", runCancellationSignal(ambientContext()));
|
|
54
56
|
if (session.state === "unknown") throw unknownSession(host, session);
|
|
57
|
+
if (session.state === "stopped") throw stoppedSession(host, session);
|
|
55
58
|
if (session.state !== "ready") throw new Error(`The hosted session ${session.id} on ${host.machine} is ${session.state}.`);
|
|
56
59
|
const device = parseHostedMacosDevice(session.device);
|
|
57
60
|
if (!device || device.appSlot !== appSlot) throw new Error(`${host.machine} reported a ready session without its reserved macOS app slot.`);
|
|
@@ -75,7 +78,7 @@ async function placeHostedMacos(host, { root, bundle, bundleId, handoff, argumen
|
|
|
75
78
|
note(`Delivering ${files.length} files to ${host.machine} (macOS ${device.macosVersion}, ${device.architecture})`);
|
|
76
79
|
await upload(host, ids, (await call(host, "device-host.app.offer", offer)).missing, content);
|
|
77
80
|
let missing = (await call(host, "device-host.app.offer", offer)).missing;
|
|
78
|
-
if (handoff && handoff.
|
|
81
|
+
if (handoff && handoff.serverKey === host.credential.serverKey && Array.isArray(missing) && missing.length) {
|
|
79
82
|
try {
|
|
80
83
|
const taken = await call(host, "device-host.app.handoff", {
|
|
81
84
|
...ids,
|
|
@@ -97,7 +100,10 @@ async function placeHostedMacos(host, { root, bundle, bundleId, handoff, argumen
|
|
|
97
100
|
while (delivery.state !== "installed") {
|
|
98
101
|
if (delivery.state === "unknown") throw new Error(`${host.machine} could not install or launch the app${typeof delivery.notice === "string" ? `: ${delivery.notice}` : ""}.`);
|
|
99
102
|
if (Date.now() > deadline) throw new Error(`${host.machine} did not finish installing the app.`);
|
|
100
|
-
await
|
|
103
|
+
await cancellableSleep(500, {
|
|
104
|
+
signal: runCancellationSignal(ambientContext()),
|
|
105
|
+
what: "hosted app installation"
|
|
106
|
+
});
|
|
101
107
|
delivery = await call(host, "device-host.app.attach", ids);
|
|
102
108
|
}
|
|
103
109
|
const appliedArguments = validHostedAppArguments(delivery.arguments) ? delivery.arguments : [];
|
|
@@ -106,7 +112,7 @@ async function placeHostedMacos(host, { root, bundle, bundleId, handoff, argumen
|
|
|
106
112
|
return {
|
|
107
113
|
placement: {
|
|
108
114
|
...placement,
|
|
109
|
-
agent: agentAccess(agentRemoteConfig(root), host.credential, delivery.agent, note)
|
|
115
|
+
agent: await agentAccess(agentRemoteConfig(root), host.credential, delivery.agent, note)
|
|
110
116
|
},
|
|
111
117
|
launched: delivery.launched === true ? true : "unverified",
|
|
112
118
|
arguments: appliedArguments
|
|
@@ -122,7 +128,7 @@ async function stopHostedMacos(root, placement) {
|
|
|
122
128
|
session = await settle(host, session, ["stopping"], SESSION_TIMEOUT_MS);
|
|
123
129
|
if (session.state !== "stopped") throw unknownSession(host, session);
|
|
124
130
|
await pullHostedMacosLogs(root, placement, host).catch((error) => {
|
|
125
|
-
|
|
131
|
+
ambientWrite("stderr", `${phaseLine("device", `Could not copy the final logs from ${host.machine}: ${error.message}`)}\n`);
|
|
126
132
|
});
|
|
127
133
|
} catch (error) {
|
|
128
134
|
if (!heldNoLonger(error)) throw error;
|
|
@@ -130,7 +136,7 @@ async function stopHostedMacos(root, placement) {
|
|
|
130
136
|
} finally {
|
|
131
137
|
host.connection.close();
|
|
132
138
|
}
|
|
133
|
-
|
|
139
|
+
await removeAgentAccess(agentRemoteConfig(root));
|
|
134
140
|
}
|
|
135
141
|
//#endregion
|
|
136
142
|
export { stopHostedMacos as n, placeHostedMacos as t };
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { d as workspaceDir } from "./paths-DQtTgsBf.mjs";
|
|
2
|
+
import { a as removeAgentAccess, i as agentAccess, n as pullHostedNativeLogs, r as closeAgentConnection } from "./hosted-logs-DL_P5AdN.mjs";
|
|
3
|
+
import { l as withWorkspaceStateLockAsync, r as readWorkspaceState$1 } from "./workspace-state-Cjuigeeu.mjs";
|
|
4
|
+
import { Qt as cancellableSleep } from "./settings-CsJDEXgK.mjs";
|
|
5
|
+
import { d as runCancellationSignal } from "./native-run-DY_RLx3C.mjs";
|
|
6
|
+
import { _ as unknownSession, a as SESSION_TIMEOUT_MS, c as call, d as hostedSession, g as stoppedSession, h as sha256, i as RESERVE_TIMEOUT_MS, l as connectHost, m as settle, n as OFFER_TIMEOUT_MS, o as attach, p as requireHostedAppMode, r as PREPARE_TIMEOUT_MS, s as bundleManifest, t as INSTALL_TIMEOUT_MS, u as heldNoLonger, v as upload } from "./hosted-client-DB_gBPfY.mjs";
|
|
7
|
+
import { a as requireHostedMetro, i as requestHostedMetro, n as closeHostedMetro } from "./metro-gateway-BMJNlj3E.mjs";
|
|
8
|
+
import { s as writeHostedNative } from "./ios-state-DvFX-K_l.mjs";
|
|
9
|
+
import { randomUUID } from "node:crypto";
|
|
10
|
+
import { readFileSync } from "node:fs";
|
|
7
11
|
import { join } from "node:path";
|
|
12
|
+
import { ambientContext, ambientWrite } from "@stim-cli/core";
|
|
8
13
|
import { hostedNativeRecords, isJsonObject, parseHostedAndroidDevice, parseHostedChoice, parseHostedDevice, parseHostedNativeOffer, parseHostedNativePlacement, requireAutomaticMachine, unreadableHostedNative } from "@stim-cli/core/state";
|
|
9
|
-
import { randomUUID } from "node:crypto";
|
|
10
14
|
//#region src/device-host/hosted-native.ts
|
|
11
15
|
function hostingRefusal(machine, error) {
|
|
12
16
|
return Object.assign(/* @__PURE__ */ new Error(`${machine}: ${error instanceof Error ? error.message : String(error)}`), {
|
|
@@ -24,8 +28,8 @@ async function prepareHostedNative(machine, selectors, recorded, platform = "ios
|
|
|
24
28
|
if (recorded) {
|
|
25
29
|
let session = null;
|
|
26
30
|
try {
|
|
27
|
-
session = await settle(host, await attach(host, recorded.session, void 0, platform), ["preparing"], PREPARE_TIMEOUT_MS, platform);
|
|
28
|
-
session = await settle(host, session, ["stopping"], SESSION_TIMEOUT_MS, platform);
|
|
31
|
+
session = await settle(host, await attach(host, recorded.session, void 0, platform), ["preparing"], PREPARE_TIMEOUT_MS, platform, runCancellationSignal(ambientContext()));
|
|
32
|
+
session = await settle(host, session, ["stopping"], SESSION_TIMEOUT_MS, platform, runCancellationSignal(ambientContext()));
|
|
29
33
|
} catch (error) {
|
|
30
34
|
if (!heldNoLonger(error)) throw error;
|
|
31
35
|
}
|
|
@@ -49,7 +53,7 @@ async function prepareHostedNative(machine, selectors, recorded, platform = "ios
|
|
|
49
53
|
const offer = await call(host, "device-host.offer", {
|
|
50
54
|
platform,
|
|
51
55
|
...selectors
|
|
52
|
-
},
|
|
56
|
+
}, OFFER_TIMEOUT_MS);
|
|
53
57
|
const parsedOffer = parseHostedNativeOffer(offer);
|
|
54
58
|
const choice = platform === "ios" ? offer.platform === "ios" ? parseHostedChoice(offer.choice) : null : parsedOffer?.platform === "android" ? parsedOffer.choice : null;
|
|
55
59
|
if (typeof offer.declined === "string") throw new Error(offer.declined);
|
|
@@ -71,7 +75,7 @@ async function prepareHostedNative(machine, selectors, recorded, platform = "ios
|
|
|
71
75
|
async function reserveHostedNative(host, target, params, platform) {
|
|
72
76
|
try {
|
|
73
77
|
if (target.selection?.selected === "auto") requireAutomaticMachine("device", host.machine);
|
|
74
|
-
return hostedSession(host, await call(host, "device-host.reserve", params), platform);
|
|
78
|
+
return hostedSession(host, await call(host, "device-host.reserve", params, RESERVE_TIMEOUT_MS), platform);
|
|
75
79
|
} catch (error) {
|
|
76
80
|
if (target.selection?.selected !== "auto") throw error;
|
|
77
81
|
throw Object.assign(/* @__PURE__ */ new Error(`${error instanceof Error ? error.message : String(error)} Retry stim ${platform} --remote auto; the build already targets ${host.machine}'s architecture.`), { remedy: `Retry stim ${platform} --remote auto.` });
|
|
@@ -109,7 +113,8 @@ async function placeHostedNative(target, { root, slot, bundle, handoff, bundleId
|
|
|
109
113
|
}
|
|
110
114
|
};
|
|
111
115
|
reserved(placement);
|
|
112
|
-
session = await settle(host, session, ["preparing"], PREPARE_TIMEOUT_MS, platform);
|
|
116
|
+
session = await settle(host, session, ["preparing"], PREPARE_TIMEOUT_MS, platform, runCancellationSignal(ambientContext()));
|
|
117
|
+
if (session.state === "stopped") throw stoppedSession(host, session);
|
|
113
118
|
if (session.state !== "ready") throw unknownSession(host, session);
|
|
114
119
|
const device = platform === "ios" ? parseHostedDevice(session.device) : parseHostedAndroidDevice(session.device);
|
|
115
120
|
if (!device || device.architecture !== target.choice.architecture || "avdName" in device && "systemImage" in target.choice && (device.systemImage !== target.choice.systemImage || device.deviceProfile !== target.choice.deviceProfile)) throw new Error(platform === "ios" ? "The reserved simulator does not match the offered architecture." : "The reserved emulator does not match the offered architecture or selectors.");
|
|
@@ -162,7 +167,7 @@ async function placeHostedNative(target, { root, slot, bundle, handoff, bundleId
|
|
|
162
167
|
note(`Delivering ${files.length} files to ${host.machine} (${"runtime" in device ? device.runtime : device.systemImage}, ${device.architecture})`);
|
|
163
168
|
await upload(host, ids, (await call(host, "device-host.app.offer", offer)).missing, content);
|
|
164
169
|
let missing = (await call(host, "device-host.app.offer", offer)).missing;
|
|
165
|
-
if (handoff && handoff.
|
|
170
|
+
if (handoff && handoff.serverKey === host.credential.serverKey && Array.isArray(missing) && missing.length) {
|
|
166
171
|
if (!host.connection.supports(platform === "android" ? "hosted-android-data" : "hosted-ios-data")) note(`${host.machine} needs a newer stim-server for ${platform === "ios" ? "iOS" : "Android"} build handoff; uploading the app instead`);
|
|
167
172
|
else try {
|
|
168
173
|
const taken = await call(host, "device-host.app.handoff", {
|
|
@@ -182,7 +187,10 @@ async function placeHostedNative(target, { root, slot, bundle, handoff, bundleId
|
|
|
182
187
|
break;
|
|
183
188
|
} catch (offerError) {
|
|
184
189
|
if (!String(offerError).includes("native operation in progress") || Date.now() >= fallbackDeadline) throw offerError;
|
|
185
|
-
await
|
|
190
|
+
await cancellableSleep(Math.min(500, Math.max(0, fallbackDeadline - Date.now())), {
|
|
191
|
+
signal: runCancellationSignal(ambientContext()),
|
|
192
|
+
what: "hosted app offer"
|
|
193
|
+
});
|
|
186
194
|
}
|
|
187
195
|
}
|
|
188
196
|
}
|
|
@@ -194,13 +202,16 @@ async function placeHostedNative(target, { root, slot, bundle, handoff, bundleId
|
|
|
194
202
|
while (delivery.state !== "installed") {
|
|
195
203
|
if (delivery.state === "unknown") throw new Error(typeof delivery.notice === "string" ? delivery.notice : "App installation or launch is unknown.");
|
|
196
204
|
if (Date.now() > deadline) throw new Error("App installation did not finish.");
|
|
197
|
-
await
|
|
205
|
+
await cancellableSleep(500, {
|
|
206
|
+
signal: runCancellationSignal(ambientContext()),
|
|
207
|
+
what: "hosted app installation"
|
|
208
|
+
});
|
|
198
209
|
delivery = await call(host, "device-host.app.attach", ids);
|
|
199
210
|
}
|
|
200
211
|
if (typeof delivery.notice === "string") note(delivery.notice);
|
|
201
212
|
placement = {
|
|
202
213
|
...placement,
|
|
203
|
-
agent: agentAccess(platform === "ios" ? iosAgentRemoteConfig(root, slot) : androidAgentRemoteConfig(root, slot), host.credential, host.connection.supports(platform === "ios" ? "hosted-ios-agent" : "hosted-android-agent") ? delivery.agent : void 0, note, platform)
|
|
214
|
+
agent: await agentAccess(platform === "ios" ? iosAgentRemoteConfig(root, slot) : androidAgentRemoteConfig(root, slot), host.credential, host.connection.supports(platform === "ios" ? "hosted-ios-agent" : "hosted-android-agent") ? delivery.agent : void 0, note, platform)
|
|
204
215
|
};
|
|
205
216
|
return {
|
|
206
217
|
placement,
|
|
@@ -228,14 +239,14 @@ async function stopHostedNative(root, slot, platform = "ios") {
|
|
|
228
239
|
try {
|
|
229
240
|
await pullHostedNativeLogs(root, name, placement, host, true, platform);
|
|
230
241
|
} catch (error) {
|
|
231
|
-
|
|
242
|
+
ambientWrite("stderr", `Could not copy final native logs from ${placement.machine}: ${error.message}\n`);
|
|
232
243
|
}
|
|
233
244
|
const stopped = await settle(host, hostedSession(host, await call(host, "device-host.stop", { session: placement.session }), platform), ["stopping"], SESSION_TIMEOUT_MS, platform);
|
|
234
245
|
if (stopped.state !== "stopped") throw unknownSession(host, stopped);
|
|
235
246
|
try {
|
|
236
247
|
await pullHostedNativeLogs(root, name, placement, host, true, platform);
|
|
237
248
|
} catch (error) {
|
|
238
|
-
|
|
249
|
+
ambientWrite("stderr", `Could not copy the host's final native logs from ${placement.machine}: ${error.message}\n`);
|
|
239
250
|
}
|
|
240
251
|
} catch (error) {
|
|
241
252
|
const code = error instanceof Error && "code" in error ? error.code : void 0;
|
|
@@ -250,8 +261,8 @@ async function stopHostedNative(root, slot, platform = "ios") {
|
|
|
250
261
|
}
|
|
251
262
|
try {
|
|
252
263
|
await closeHostedMetro(root, placement.session);
|
|
253
|
-
|
|
254
|
-
writeHostedNative(root, name, null, platform);
|
|
264
|
+
await removeAgentAccess(platform === "ios" ? iosAgentRemoteConfig(root, name) : androidAgentRemoteConfig(root, name));
|
|
265
|
+
await withWorkspaceStateLockAsync(root, () => writeHostedNative(root, name, null, platform));
|
|
255
266
|
} catch (error) {
|
|
256
267
|
failures.push(`${placement.machine}: ${error.message}. The placement is kept; rerun stim stop.`);
|
|
257
268
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "./settings-DkdmlelE.mjs";
|
|
2
|
+
import "./exec-H20xSg2T.mjs";
|
|
3
|
+
import { DeviceActivity, IOS_SIMULATOR_APPS } from "@stim-cli/core/state";
|
|
4
|
+
//#region src/commands/gc/idle.d.ts
|
|
5
|
+
interface IdleDevice {
|
|
6
|
+
kind: "ios" | "android";
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
project: string;
|
|
10
|
+
slot: string;
|
|
11
|
+
lastActivityAt: string | null;
|
|
12
|
+
idleForMs: number | null;
|
|
13
|
+
buildInProgress: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface OwnedDeviceActivity {
|
|
16
|
+
kind: "ios" | "android";
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
project: string;
|
|
20
|
+
slot: string;
|
|
21
|
+
activity: DeviceActivity;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { OwnedDeviceActivity as n, IdleDevice as t };
|