stim 1.34.0 → 1.36.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/dist/{acquire-artifact-B0SWoVNt.mjs → acquire-artifact-DGTHCd0Q.mjs} +19 -3
- package/dist/{act-7f7wIvCQ.mjs → act-CvN9xyV6.mjs} +18 -19
- package/dist/{activity-DkS-Ir6V.mjs → activity-BpdDvA8Q.mjs} +4 -4
- package/dist/{agent-device-usage-output-BVdgKbfz.mjs → agent-device-usage-output-pbhaW7_k.mjs} +4 -4
- package/dist/{android-B2DSKg-A.mjs → android-5wkcMFDG.mjs} +1 -1
- package/dist/{android-BU4uBX8I.mjs → android-B0qTdwnt.mjs} +5 -5
- package/dist/{android-Iq0M2t2d.mjs → android-SJx1V3R3.mjs} +5 -5
- package/dist/{android-cas-Dhcjkys1.mjs → android-cas-BS9_55U5.mjs} +4 -4
- package/dist/{android-D7qjT2fq.mjs → android-e9WP10cE.mjs} +47 -41
- package/dist/{android-image-DFk26aY6.mjs → android-image-BZ57YL6R.mjs} +2 -2
- package/dist/{android-project-DhO6el8N.d.mts → android-project-v_1nej_x.d.mts} +3 -1
- package/dist/api.d.mts +20 -6
- package/dist/api.mjs +31 -26
- package/dist/{apk-signed-tail-CPpA-3vu.mjs → apk-signed-tail-eZyXIrnc.mjs} +2 -2
- package/dist/{artifact-DmRtKFXW.mjs → artifact-C3srrGVU.mjs} +36 -14
- package/dist/{artifact-CNnTZs3R.mjs → artifact-ubNdxo_K.mjs} +52 -19
- package/dist/{auto-placement-DA65VQH7.mjs → auto-placement-CKFpFCuq.mjs} +7 -8
- package/dist/{browser-web-Dn_hgKZC.mjs → browser-web-B63vLrj6.mjs} +11 -11
- package/dist/{build-D7SuVoRX.mjs → build-B_Dx9SKJ.mjs} +72 -25
- package/dist/{build-cache-Cqj4FGnX.mjs → build-cache-BW8T4oD2.mjs} +10 -5
- package/dist/{build-plan-Ct1FiA3E.mjs → build-plan-CeIooJqn.mjs} +6 -6
- package/dist/{cache-manifest-8JX9S1QJ.mjs → cache-manifest-CxWkZmUr.mjs} +1 -1
- package/dist/cache-manifest.mjs +1 -1
- package/dist/{cli-DjdvQG5U.mjs → cli-COdXswmc.mjs} +19 -18
- package/dist/cli.mjs +1 -1
- package/dist/{client-kU37gURU.mjs → client-KSWIeQLA.mjs} +9 -8
- package/dist/collector-run.mjs +4 -4
- package/dist/{command-output-DjExb_tZ.mjs → command-output-T3cDctRE.mjs} +1 -1
- package/dist/{config-BW0fAtoK.mjs → config-BA3TgoIP.mjs} +59 -10
- package/dist/{dependencies-CZ7c8XX_.mjs → dependencies-LH-7k1Vr.mjs} +35 -38
- package/dist/{dependency-state-mL5g4H6K.mjs → dependency-state-Blfp3AkG.mjs} +1 -1
- package/dist/{dev-client-D3wOllNd.mjs → dev-client-MO_DjTZr.mjs} +2 -2
- package/dist/{device-DH5yf6TU.mjs → device-BZWt_aPJ.mjs} +11 -11
- package/dist/{device-CWPFAqs0.mjs → device-DNTWFFB1.mjs} +12 -12
- package/dist/{device-android-ChfF5I9A.mjs → device-android-BB9Lugr8.mjs} +8 -8
- package/dist/{ccache-ChBMXlBq.mjs → device-capacity-CpAVcKgq.mjs} +1006 -23
- package/dist/device-host-worker.mjs +13 -14
- package/dist/{device-pool-EZziQ0uS.mjs → device-pool-BJToGG-q.mjs} +3 -3
- package/dist/{device-provision-CfpEy-Vm.mjs → device-provision-CxQDCtrc.mjs} +9 -9
- package/dist/{doctor-CGBsS_68.mjs → doctor-C-46SkBe.mjs} +1 -1
- package/dist/{doctor-dwRboaXx.mjs → doctor-CYZ45LnX.mjs} +20 -21
- package/dist/{doctor-B5uEZiKp.mjs → doctor-DV639Iw_.mjs} +15 -16
- package/dist/doctor-fingerprint.mjs +1 -1
- package/dist/{doctor-watchman-r7M9UPi0.mjs → doctor-watchman-TZxYt_98.mjs} +4 -4
- package/dist/{eas-build-BpHIt_M3.mjs → eas-build-Xf5Jd6LR.mjs} +2 -2
- package/dist/{eas-fallback-CNPcjq3K.mjs → eas-fallback-DNYPNinw.mjs} +4 -4
- package/dist/{eas-session-ledger-CXwagcQ7.mjs → eas-session-ledger-CXZ4aix0.mjs} +5 -5
- package/dist/{error-diagnostics-Ym2mjmJ0.mjs → error-diagnostics-CvB5bpPU.mjs} +8 -8
- package/dist/{gc-B464w_a5.mjs → gc-8Qm_K1iy.mjs} +2 -2
- package/dist/{gc-C7YxKNci.mjs → gc-DiUhrVFo.mjs} +17 -17
- package/dist/{guide-BFW-cB7R.mjs → guide-CuvHRP53.mjs} +130 -65
- package/dist/{hosted-android-B7yfqXEy.mjs → hosted-android-D__HGVIO.mjs} +3 -3
- package/dist/{hosted-client-CQuzZwAu.mjs → hosted-client-DMOOu8vD.mjs} +6 -6
- package/dist/{hosted-logs-DfYCqrrR.mjs → hosted-logs-CClIktQM.mjs} +6 -6
- package/dist/{hosted-logs-sync-Dlpa2mQF.mjs → hosted-logs-sync-B7XCeqVm.mjs} +5 -5
- package/dist/{hosted-macos-JKefapEm.mjs → hosted-macos-D4sDJIbB.mjs} +5 -5
- package/dist/{hosted-native-B7OFt5gB.mjs → hosted-native-BiiUG_Q6.mjs} +7 -7
- package/dist/{ios-sUPbWqEh.mjs → ios-BZuhvLGr.mjs} +8 -8
- package/dist/{ios-BdZdNsAj.mjs → ios-BhfpRfNf.mjs} +4 -4
- package/dist/{ios-DSBs9c6d.mjs → ios-BhpUWyN7.mjs} +39 -32
- package/dist/{ios-device-Drplrgzo.mjs → ios-device-vhYL1N--.mjs} +1 -1
- package/dist/{ios-project-DoTQYghg.mjs → ios-project-Cz0S1Sz-.mjs} +7 -7
- package/dist/{ios-signing-R34vbrNU.mjs → ios-signing-BcH88ecn.mjs} +1 -1
- package/dist/{ios-state-CWsBysyN.mjs → ios-state-Avwz2cbZ.mjs} +1 -1
- package/dist/{js-swap-DrokhOfo.mjs → js-swap-Desu2iII.mjs} +4 -4
- package/dist/{launch-Cy-MWEZc.mjs → launch-6ckG9UrC.mjs} +19 -19
- package/dist/{lightened-ALwQcQtV.mjs → lightened-B6TnpHMX.mjs} +4 -4
- package/dist/{logs-DuED-01Z.mjs → logs-B-DMy1K0.mjs} +7 -7
- package/dist/{logs-DWT7jGpF.mjs → logs-CO0CJRiC.mjs} +5 -5
- package/dist/{macos-CtBtA_hW.mjs → macos-B1aCXhem.mjs} +19 -19
- package/dist/{macos-kWGcfLzx.mjs → macos-CduEmWAK.mjs} +1 -1
- package/dist/macos-run.mjs +1 -1
- package/dist/maintenance-run.mjs +5 -5
- package/dist/{metro-B5PVz0Wv.mjs → metro-DM3yJL1M.mjs} +2 -2
- package/dist/{metro-request-2LmFpC1z.mjs → metro-request-O8Q-JvBg.mjs} +1 -1
- package/dist/{named-ports-CA0nB9Yw.mjs → named-ports-BvB_CO9B.mjs} +2 -2
- package/dist/{native-android-tISP2EVp.mjs → native-android-28NOG2-y.mjs} +17 -17
- package/dist/{native-gradle-artifact-inputs-DVoeZkrw.mjs → native-gradle-artifact-inputs-DxVEtS6_.mjs} +3 -3
- package/dist/{native-runtime-CNgxeOCG.mjs → native-runtime-C3_NkUlW.mjs} +6 -6
- package/dist/{native-xcode-inputs-DGzkhpu4.mjs → native-xcode-inputs-BWFTw5cJ.mjs} +2 -2
- package/dist/{native-xcode-ios-B9nsfId2.mjs → native-xcode-ios-B4Qoc7-U.mjs} +16 -16
- package/dist/offload-worker.d.mts +1 -1
- package/dist/offload-worker.mjs +19 -19
- package/dist/{ownership-hC7xvvxF.mjs → ownership-C3y8wLSl.mjs} +2 -2
- package/dist/{phone-reverses-Bo0EzJ-P.mjs → phone-reverses-BhSxbqom.mjs} +4 -4
- package/dist/{placement-log-BsGvKLtU.mjs → placement-log-B8RCSzOm.mjs} +1 -1
- package/dist/{plan-placement-Am0IjuxB.mjs → plan-placement-BI4r55aP.mjs} +6 -6
- package/dist/{ports-CNzg1LYD.mjs → ports-DhOSyWm9.mjs} +3 -3
- package/dist/{prebuild-BfJII57G.mjs → prebuild-Di2IhUue.mjs} +9 -9
- package/dist/{project-DU3jjnBE.mjs → project-Clk1JAWL.mjs} +15 -15
- package/dist/{react-native-android-3dZiJv-4.mjs → react-native-android-bdHBMrnf.mjs} +23 -23
- package/dist/{react-native-build-CuvNPt-q.mjs → react-native-build-CJega_NM.mjs} +7 -7
- package/dist/{react-native-doctor-a35BwMUO.mjs → react-native-doctor-CY7BGITE.mjs} +5 -5
- package/dist/{react-native-ios-CqnReM1t.mjs → react-native-ios-Bo5EDVel.mjs} +25 -20
- package/dist/recorded-build-BuGL_fnm.mjs +58 -0
- package/dist/{recordings-AKZfsW2W.mjs → recordings-6i2-x8LU.mjs} +1 -1
- package/dist/{reload-CC3sNo10.mjs → reload-A_axEbeS.mjs} +14 -14
- package/dist/{reload-YPnvXGlB.mjs → reload-BvDuvygc.mjs} +1 -1
- package/dist/remote-PD6CM0xp.mjs +158 -0
- package/dist/{remote-BfaIHnhM.mjs → remote-WK_swZEw.mjs} +8 -8
- package/dist/{result-H-AxY7Ud.mjs → result-BkDpN5Mz.mjs} +23 -18
- package/dist/{run-N-BbRxnC.mjs → run-CTFi4Nq2.mjs} +1 -1
- package/dist/{server-bare-BTlICuaX.mjs → server-bare-W0aPsRZE.mjs} +1 -1
- package/dist/{server-command-Bn_gOObU.mjs → server-command-S00-ddjK.mjs} +4 -4
- package/dist/server-expo-BWJDa7Qb.mjs +2 -0
- package/dist/{server-expo-CUJ2fuv1.mjs → server-expo-cc-cmfsl.mjs} +2 -2
- package/dist/{settings-B5IBDfTx.mjs → settings-Bap-qjnp.mjs} +1 -1
- package/dist/{settings-DoWHJopy.mjs → settings-C_Xu4RNZ.mjs} +2 -2
- package/dist/{settings-payload-Bxw3hid5.mjs → settings-payload-D5jjhmrw.mjs} +4 -4
- package/dist/{settings-write-C6d7EC54.mjs → settings-write-C5huI-iS.mjs} +5 -5
- package/dist/settings.schema.json +1 -1
- package/dist/{simslim-DKdJx0LL.mjs → simslim-DlBvwgeF.mjs} +1 -1
- package/dist/{slot-launch-kq0-7w9C.mjs → slot-launch-qEQVTth7.mjs} +6 -6
- package/dist/{stage-CBfMTUK3.mjs → stage-CxVI_MlP.mjs} +1 -1
- package/dist/{start-Diu8q6_U.mjs → start-CVzivp35.mjs} +1 -1
- package/dist/{start-WTMumMHi.mjs → start-YpT_JpQQ.mjs} +10 -10
- package/dist/{state-DSOUqO-o.mjs → state-B4B5P4LU.mjs} +1 -1
- package/dist/{state-CtmYTRWm.mjs → state-B9VFI6r0.mjs} +2 -2
- package/dist/{stats-D4cW247z.mjs → stats-COoePEri.mjs} +4 -4
- package/dist/{status-CEwxo-PS.mjs → status-CIg0k7Qb.mjs} +21 -22
- package/dist/{status-B-oeWS0Z.mjs → status-CIvU5-TF.mjs} +1 -1
- package/dist/{status-DTFhDnd1.mjs → status-CQWmNl1f.mjs} +1 -1
- package/dist/{status-watch-D63R5nSI.mjs → status-watch--rfZynD_.mjs} +4 -4
- package/dist/status-worker.mjs +1 -1
- package/dist/{stim-desktop-_WTria-r.mjs → stim-desktop-D0P_bzmd.mjs} +1 -1
- package/dist/{stop-HL2RvhrE.mjs → stop-BEBBruvD.mjs} +4 -4
- package/dist/{stop-Dm9ON6Os.mjs → stop-BiI4_VFG.mjs} +2 -2
- package/dist/{stop-vX4w3_8V.mjs → stop-C3d5qG7C.mjs} +15 -15
- package/dist/supervisor-run.mjs +12 -13
- package/dist/support-BJbXovoO.mjs +2089 -0
- package/dist/{support-BNe1_Hg7.mjs → support-Vckdzrmk.mjs} +5 -5
- package/dist/{swiftpm-artifact-inputs-uq5oV7xR.mjs → swiftpm-artifact-inputs-DbuF-Yrr.mjs} +1 -1
- package/dist/{swiftpm-macos-ClF203_2.mjs → swiftpm-macos-Bu8xeBfM.mjs} +8 -8
- package/dist/{toolchain-CECahBDa.mjs → toolchain-CIRdNl-c.mjs} +1 -1
- package/dist/{toolchain-CYonNjd_.mjs → toolchain-DCnWAxQL.mjs} +71 -7
- package/dist/{warm-progress-q11Vdvhh.mjs → warm-progress-DwsGBpph.mjs} +3 -3
- package/dist/{web-BdaMBr2O.mjs → web-D2En0Wa5.mjs} +8 -8
- package/dist/web-Dpj70t4p.mjs +2 -0
- package/dist/web-run.mjs +4 -4
- package/dist/{workspace-state-BdZ-QgmB.mjs → workspace-state-BhwAJBgA.mjs} +2 -2
- package/dist/{workspaces-B9v5V7Es.mjs → workspaces-Dh5N70qW.mjs} +11 -11
- package/dist/{worktree-C4MBOMz7.mjs → worktree-DLm4s2Ib.mjs} +1 -1
- package/dist/{worktree-C3N86KpI.mjs → worktree-Yw3EW77B.mjs} +24 -24
- package/package.json +7 -7
- package/dist/device-capacity-CHC3dKWg.mjs +0 -867
- package/dist/device-ios-B3-Ah--R.mjs +0 -716
- package/dist/device-lease-run-i3FNX4OE.mjs +0 -282
- package/dist/idle-shutdown-DPD8oV36.mjs +0 -142
- package/dist/selection-CH-MUVGD.mjs +0 -791
- package/dist/server-expo-B59N16uT.mjs +0 -2
- package/dist/support-ivsfDj0v.mjs +0 -287
- package/dist/web-CIpHpGp8.mjs +0 -2
|
@@ -1,791 +0,0 @@
|
|
|
1
|
-
import { C as operationState, r as reportSignal } from "./exec-CGuDzt40.mjs";
|
|
2
|
-
import { M as withDirLock$1 } from "./workspace-state-BdZ-QgmB.mjs";
|
|
3
|
-
import { $ as unconfirmedKeyFinding, F as diagnoseOutcome, G as realIo, H as outdatedServer, I as diagnoseTailscale, J as setupRemedy, Q as notOnTailnetDiagnosis, R as endpoint$1, U as parseMachine$1, W as reachMachine, X as diagnoseLocalUnreachable, Y as tailscaleStatusAsync, Z as diagnosisFinding, d as getConfigDir, et as readHostPermissions, v as loadConfig$1, z as findPeer$1 } from "./config-BW0fAtoK.mjs";
|
|
4
|
-
import { s as cocoapodsInstall } from "./toolchain-CYonNjd_.mjs";
|
|
5
|
-
import { releaseClaim, tryAcquireClaim } from "@stim-cli/core/ownership-claim";
|
|
6
|
-
import { mkdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
7
|
-
import { hostname } from "node:os";
|
|
8
|
-
import { ambientContext, ambientEnv, withDirLockAsync } from "@stim-cli/core";
|
|
9
|
-
import { MACHINE_CREDENTIALS_VERSION, acceptsShape, automaticMachineEnabled, buildMachinesFile, buildMachinesLock, cannotHost, deviceHostMachinesClaims, deviceHostMachinesFile, deviceHostMachinesLock, isJsonObject, localEndpoint, parseMachine, placementWord, readBuildMachines, readDeviceHostMachines, settingDefinition } from "@stim-cli/core/state";
|
|
10
|
-
import { InvalidArgumentError } from "commander";
|
|
11
|
-
//#region src/device-host/machines.ts
|
|
12
|
-
function note$1(title, detail, fix = null) {
|
|
13
|
-
return {
|
|
14
|
-
code: "device-host-machine",
|
|
15
|
-
level: "note",
|
|
16
|
-
title,
|
|
17
|
-
detail,
|
|
18
|
-
fix
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function configuredMachines() {
|
|
22
|
-
const remote = loadConfig$1()?.remote;
|
|
23
|
-
if (remote !== void 0 && !isJsonObject(remote)) return null;
|
|
24
|
-
const machines = remote?.machines;
|
|
25
|
-
if (machines === void 0) return [];
|
|
26
|
-
return acceptsShape(settingDefinition("remote.machines"), machines) ? machines : null;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* The `remote.machines` entries this machine asked for device-host access, in setting order, without the ones the
|
|
30
|
-
* tailnet reports as running another OS than macOS, which can never host; null when the setting is invalid.
|
|
31
|
-
*/
|
|
32
|
-
async function hostingMachines(status, signal) {
|
|
33
|
-
const configured = configuredMachines();
|
|
34
|
-
if (configured === null) return null;
|
|
35
|
-
let candidates = configured;
|
|
36
|
-
try {
|
|
37
|
-
const asked = readDeviceHostMachines();
|
|
38
|
-
candidates = configured.filter((machine) => asked.some((each) => each.machine === machine));
|
|
39
|
-
} catch {
|
|
40
|
-
candidates = configured;
|
|
41
|
-
}
|
|
42
|
-
if (!candidates.some((machine) => parseMachine$1(machine)?.transport === "tailscale")) return candidates;
|
|
43
|
-
const current = await (status ? status() : tailscaleStatusAsync(signal));
|
|
44
|
-
signal?.throwIfAborted();
|
|
45
|
-
return candidates.filter((machine) => !cannotHost(current, machine));
|
|
46
|
-
}
|
|
47
|
-
async function store(machines, operation) {
|
|
48
|
-
reportSignal(operation)?.throwIfAborted();
|
|
49
|
-
const write = () => {
|
|
50
|
-
reportSignal(operation)?.throwIfAborted();
|
|
51
|
-
const file = deviceHostMachinesFile();
|
|
52
|
-
const tmp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
53
|
-
try {
|
|
54
|
-
writeFileSync(tmp, `${JSON.stringify({
|
|
55
|
-
version: MACHINE_CREDENTIALS_VERSION,
|
|
56
|
-
machines
|
|
57
|
-
}, null, 2)}\n`, { mode: 384 });
|
|
58
|
-
renameSync(tmp, file);
|
|
59
|
-
} finally {
|
|
60
|
-
rmSync(tmp, { force: true });
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const options = { ensureParent: () => mkdirSync(getConfigDir(), { recursive: true }) };
|
|
64
|
-
const signal = reportSignal(operation);
|
|
65
|
-
if (signal) await withDirLockAsync(deviceHostMachinesLock(), write, {
|
|
66
|
-
...options,
|
|
67
|
-
signal
|
|
68
|
-
});
|
|
69
|
-
else withDirLock$1(deviceHostMachinesLock(), write, options);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Reports the device-host approval of each remote machine, separate from its build approval. Only --fix makes a setup
|
|
73
|
-
* ticket or forgets credentials; every server key stays pinned.
|
|
74
|
-
*/
|
|
75
|
-
async function inspectDeviceHostMachines({ fix, version = "<version>", tickets = /* @__PURE__ */ new Map(), operation, confirmKey }, io = realIo, entries = configuredMachines()) {
|
|
76
|
-
if (entries === null) return {
|
|
77
|
-
findings: [note$1("Invalid remote.machines setting", "Use a remote object with machines as an array of tailnet names. Existing hosting credentials and pinned keys are preserved.", "Run `stim guide settings` and correct the setting before running doctor again.")],
|
|
78
|
-
machines: []
|
|
79
|
-
};
|
|
80
|
-
const unavailable = (state, finding) => ({
|
|
81
|
-
findings: [finding],
|
|
82
|
-
machines: entries.map((machine) => ({
|
|
83
|
-
machine,
|
|
84
|
-
state
|
|
85
|
-
}))
|
|
86
|
-
});
|
|
87
|
-
const unreadable = () => unavailable("credentials-unavailable", note$1("Hosting credentials are unreadable", `Stim preserves ${deviceHostMachinesFile()} and its pinned keys.`, "Restore the existing file from a trusted backup or restore read access before running doctor again."));
|
|
88
|
-
if (!entries.length) {
|
|
89
|
-
if (!fix) return {
|
|
90
|
-
findings: [],
|
|
91
|
-
machines: []
|
|
92
|
-
};
|
|
93
|
-
try {
|
|
94
|
-
if (!readDeviceHostMachines().length) return {
|
|
95
|
-
findings: [],
|
|
96
|
-
machines: []
|
|
97
|
-
};
|
|
98
|
-
} catch {
|
|
99
|
-
return unreadable();
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
const claim = tryAcquireClaim({
|
|
103
|
-
root: deviceHostMachinesClaims(),
|
|
104
|
-
mode: "exclusive",
|
|
105
|
-
label: "device-host approval"
|
|
106
|
-
});
|
|
107
|
-
if (!claim.acquired) {
|
|
108
|
-
releaseClaim(claim.pending);
|
|
109
|
-
return unavailable("busy", note$1("Device-host approval is in use", "Another doctor run holds the hosting credential claim. Run doctor again after it finishes."));
|
|
110
|
-
}
|
|
111
|
-
try {
|
|
112
|
-
let credentials;
|
|
113
|
-
try {
|
|
114
|
-
credentials = readDeviceHostMachines();
|
|
115
|
-
} catch {
|
|
116
|
-
return unreadable();
|
|
117
|
-
}
|
|
118
|
-
if (fix) {
|
|
119
|
-
const kept = credentials.filter((each) => entries.includes(each.machine));
|
|
120
|
-
if (kept.length !== credentials.length) {
|
|
121
|
-
await store(kept, operation);
|
|
122
|
-
credentials = kept;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
if (!entries.length) return {
|
|
126
|
-
findings: [],
|
|
127
|
-
machines: []
|
|
128
|
-
};
|
|
129
|
-
const tailnet = entries.some((entry) => parseMachine$1(entry)?.transport !== "local");
|
|
130
|
-
const status = tailnet ? await io.status() : null;
|
|
131
|
-
const inspected = {
|
|
132
|
-
findings: [],
|
|
133
|
-
machines: []
|
|
134
|
-
};
|
|
135
|
-
let off = null;
|
|
136
|
-
if (tailnet && !isJsonObject(status)) {
|
|
137
|
-
off = await diagnoseTailscale(io);
|
|
138
|
-
inspected.findings.push(note$1("Remote machines are unreachable", `remote.machines names remote machines. ${off.message}`, off.remedy));
|
|
139
|
-
}
|
|
140
|
-
const self = isJsonObject(status) && isJsonObject(status.Self) ? status.Self : {};
|
|
141
|
-
const deviceName = (typeof self.HostName === "string" && self.HostName ? self.HostName : hostname()).replace(/[\p{Cc}\p{Cf}]/gu, "").trim().slice(0, 64) || "Mac";
|
|
142
|
-
const namedNodes = /* @__PURE__ */ new Set();
|
|
143
|
-
for (const machine of new Set(entries)) {
|
|
144
|
-
const parsed = parseMachine$1(machine);
|
|
145
|
-
if (!parsed) {
|
|
146
|
-
inspected.machines.push({
|
|
147
|
-
machine,
|
|
148
|
-
state: "invalid"
|
|
149
|
-
});
|
|
150
|
-
inspected.findings.push(note$1(`Remote machine ${machine} is not a tailnet name or local: address`, "Expected `name`, `name:port`, `local:<host>` or `local:<host>:port`."));
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
const local = parsed.transport === "local";
|
|
154
|
-
if (!local && off) {
|
|
155
|
-
inspected.machines.push({
|
|
156
|
-
machine,
|
|
157
|
-
state: "tailscale-off",
|
|
158
|
-
diagnosis: off
|
|
159
|
-
});
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
const current = local ? null : await io.status();
|
|
163
|
-
if (!local && !isJsonObject(current)) {
|
|
164
|
-
const diagnosis = await diagnoseTailscale(io);
|
|
165
|
-
inspected.machines.push({
|
|
166
|
-
machine,
|
|
167
|
-
state: "tailscale-off",
|
|
168
|
-
diagnosis
|
|
169
|
-
});
|
|
170
|
-
inspected.findings.push(diagnosisFinding("device-host-machine", machine, diagnosis));
|
|
171
|
-
continue;
|
|
172
|
-
}
|
|
173
|
-
const peer = local ? null : findPeer$1(current, parsed.name);
|
|
174
|
-
if (peer === "missing" || peer === "ambiguous") {
|
|
175
|
-
const diagnosis = notOnTailnetDiagnosis(machine, peer === "ambiguous");
|
|
176
|
-
inspected.machines.push({
|
|
177
|
-
machine,
|
|
178
|
-
state: "not-on-tailnet",
|
|
179
|
-
diagnosis
|
|
180
|
-
});
|
|
181
|
-
inspected.findings.push(diagnosisFinding("device-host-machine", machine, diagnosis));
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
const target = peer ? endpoint$1(peer, parsed.port) : localEndpoint(parsed.name, parsed.port);
|
|
185
|
-
const dnsName = peer ? { dnsName: peer.dnsName } : {};
|
|
186
|
-
const nodeRoute = peer ? `${peer.nodeId}:${parsed.port}` : `local:${parsed.name}:${parsed.port}`;
|
|
187
|
-
if (namedNodes.has(nodeRoute)) {
|
|
188
|
-
inspected.machines.push({
|
|
189
|
-
machine,
|
|
190
|
-
...dnsName,
|
|
191
|
-
state: "invalid"
|
|
192
|
-
});
|
|
193
|
-
inspected.findings.push(note$1(`Remote machine ${machine} repeats a named node`, "Name each tailnet node and serve port only once in remote.machines."));
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
namedNodes.add(nodeRoute);
|
|
197
|
-
if (cannotHost(current, machine)) {
|
|
198
|
-
inspected.machines.push({
|
|
199
|
-
machine,
|
|
200
|
-
...dnsName,
|
|
201
|
-
state: "not-asked"
|
|
202
|
-
});
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
205
|
-
const credential = credentials.find((each) => each.machine === machine);
|
|
206
|
-
reportSignal(operation)?.throwIfAborted();
|
|
207
|
-
const outcome = await reachMachine({
|
|
208
|
-
machine,
|
|
209
|
-
access: "device-host",
|
|
210
|
-
endpoint: target,
|
|
211
|
-
address: peer?.dnsName ?? parsed.name,
|
|
212
|
-
credential,
|
|
213
|
-
other: () => readBuildMachines().find((each) => each.machine === machine),
|
|
214
|
-
persist: async (next) => {
|
|
215
|
-
credentials = [...credentials.filter((each) => each.machine !== machine), next];
|
|
216
|
-
await store(credentials, operation);
|
|
217
|
-
},
|
|
218
|
-
fix,
|
|
219
|
-
deviceName,
|
|
220
|
-
setupFlags: ["build", "device-host"],
|
|
221
|
-
serverVersion: version,
|
|
222
|
-
io,
|
|
223
|
-
tickets,
|
|
224
|
-
...local ? { confirmKey: (serverKey) => confirmKey?.(machine, serverKey) ?? Promise.resolve(false) } : {}
|
|
225
|
-
});
|
|
226
|
-
reportSignal(operation)?.throwIfAborted();
|
|
227
|
-
if (outcome.state !== "not-asked" && outcome.credential) {
|
|
228
|
-
const next = outcome.credential;
|
|
229
|
-
if (JSON.stringify(next) !== JSON.stringify(credential)) {
|
|
230
|
-
credentials = [...credentials.filter((each) => each.machine !== machine), next];
|
|
231
|
-
await store(credentials, operation);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
const saved = outcome.state !== "not-asked" ? outcome.credential : void 0;
|
|
235
|
-
const known = {
|
|
236
|
-
machine,
|
|
237
|
-
...dnsName,
|
|
238
|
-
...saved?.deviceId ? { deviceId: saved.deviceId } : {},
|
|
239
|
-
...saved ? { requestedAt: saved.requestedAt } : {}
|
|
240
|
-
};
|
|
241
|
-
if (outcome.state === "approved") {
|
|
242
|
-
const host = readHostPermissions(outcome.result.host);
|
|
243
|
-
if (host && (host.screenRecording === false || host.accessibility === false)) {
|
|
244
|
-
const panes = [...host.screenRecording === false ? ["Screen & System Audio Recording (Screen Recording on macOS 14)"] : [], ...host.accessibility === false ? ["Device Control and Data Access (Accessibility on macOS 26 and earlier)"] : []];
|
|
245
|
-
const detail = [...host.screenRecording === false ? ["Viewing hosted macOS apps needs Screen Recording."] : [], ...host.accessibility === false ? ["Controlling them needs the control permission."] : []];
|
|
246
|
-
inspected.findings.push(note$1(`Remote Mac ${machine} needs ${panes.join(" and ")} for ${host.name}`, detail.join(" "), `On ${machine}, approve ${host.name} in System Settings > Privacy & Security, or run \`stim-server service install\` there again to show the requests.`));
|
|
247
|
-
}
|
|
248
|
-
inspected.machines.push({
|
|
249
|
-
...known,
|
|
250
|
-
state: "approved",
|
|
251
|
-
...host ? { host } : {}
|
|
252
|
-
});
|
|
253
|
-
continue;
|
|
254
|
-
}
|
|
255
|
-
if (outcome.state === "pending") {
|
|
256
|
-
inspected.machines.push({
|
|
257
|
-
...known,
|
|
258
|
-
state: "pending",
|
|
259
|
-
...outcome.credential.expiresAt ? { expiresAt: outcome.credential.expiresAt } : {}
|
|
260
|
-
});
|
|
261
|
-
inspected.findings.push(note$1(`Remote machine ${machine} has not approved this machine for device hosting yet`, `It does not hold this machine's setup ticket yet${outcome.credential.expiresAt ? `; the ticket expires at ${outcome.credential.expiresAt}` : ""}.`, setupRemedy(machine, outcome.command)));
|
|
262
|
-
continue;
|
|
263
|
-
}
|
|
264
|
-
if (outcome.state === "not-asked") {
|
|
265
|
-
inspected.machines.push({
|
|
266
|
-
...known,
|
|
267
|
-
state: "not-asked"
|
|
268
|
-
});
|
|
269
|
-
inspected.findings.push(note$1(`Remote machine ${machine} has not approved this machine for device hosting`, "This machine has not asked for hosting access.", "Run `stim doctor --fix` to make a setup ticket and print the command to run there."));
|
|
270
|
-
continue;
|
|
271
|
-
}
|
|
272
|
-
if (outcome.state === "outdated") {
|
|
273
|
-
const outdated = outdatedServer(machine, version, outcome.command);
|
|
274
|
-
inspected.machines.push({
|
|
275
|
-
...known,
|
|
276
|
-
state: "outdated",
|
|
277
|
-
diagnosis: {
|
|
278
|
-
layer: "compat",
|
|
279
|
-
code: "server-outdated",
|
|
280
|
-
title: "Server is outdated",
|
|
281
|
-
message: outdated.detail,
|
|
282
|
-
remedy: outdated.fix
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
inspected.findings.push(note$1(outdated.title, outdated.detail, outdated.fix));
|
|
286
|
-
continue;
|
|
287
|
-
}
|
|
288
|
-
if (outcome.state === "unconfirmed") {
|
|
289
|
-
inspected.machines.push({
|
|
290
|
-
...known,
|
|
291
|
-
state: "key-unconfirmed",
|
|
292
|
-
fingerprint: outcome.fingerprint
|
|
293
|
-
});
|
|
294
|
-
inspected.findings.push(unconfirmedKeyFinding("device-host-machine", machine, outcome.fingerprint));
|
|
295
|
-
continue;
|
|
296
|
-
}
|
|
297
|
-
if (outcome.state === "unreachable") {
|
|
298
|
-
const failure = {
|
|
299
|
-
entry: machine,
|
|
300
|
-
port: parsed.port,
|
|
301
|
-
target,
|
|
302
|
-
reason: outcome.reason,
|
|
303
|
-
transport: outcome.transport
|
|
304
|
-
};
|
|
305
|
-
const startup = !peer && outcome.transport?.kind === "http" && outcome.transport.status === 503 ? await io.startup?.(target) : null;
|
|
306
|
-
const diagnosis = peer ? await diagnoseOutcome(io, {
|
|
307
|
-
...failure,
|
|
308
|
-
peer
|
|
309
|
-
}) : diagnoseLocalUnreachable({
|
|
310
|
-
...failure,
|
|
311
|
-
startup
|
|
312
|
-
});
|
|
313
|
-
inspected.machines.push({
|
|
314
|
-
...known,
|
|
315
|
-
state: "unreachable",
|
|
316
|
-
diagnosis
|
|
317
|
-
});
|
|
318
|
-
inspected.findings.push(diagnosisFinding("device-host-machine", machine, diagnosis));
|
|
319
|
-
continue;
|
|
320
|
-
}
|
|
321
|
-
inspected.machines.push({
|
|
322
|
-
...known,
|
|
323
|
-
state: outcome.state
|
|
324
|
-
});
|
|
325
|
-
inspected.findings.push(outcome.state === "key-changed" ? note$1(`Remote machine ${machine} answered with a different server key`, "Stim refuses to connect to a stim-server that does not prove it holds the key pinned at approval.", `If that machine or its Stim home was replaced, remove ${machine} from remote.machines, run \`stim doctor --fix\`, then add it back and run \`stim doctor --fix\` again.`) : outcome.state === "lapsed" ? note$1(`Hosting request to ${machine} lapsed`, `${machine} did not approve this machine before its setup ticket expired at ${outcome.credential.expiresAt}.`, "Run `stim doctor --fix` to make a new ticket.") : note$1(`Remote machine ${machine} no longer accepts this machine for device hosting`, `${outcome.reason} The pinned key is preserved.`, "Run `stim doctor --fix` to ask again."));
|
|
326
|
-
}
|
|
327
|
-
return inspected;
|
|
328
|
-
} finally {
|
|
329
|
-
releaseClaim(claim.acquired);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
//#endregion
|
|
333
|
-
//#region src/offload/build-machines.ts
|
|
334
|
-
/** The `remote.machines` entries that approved this machine for builds, in that order. */
|
|
335
|
-
function pairedMachines(entries = configuredMachines() ?? []) {
|
|
336
|
-
const credentials = readBuildMachines().filter((each) => each.state === "approved");
|
|
337
|
-
return entries.flatMap((entry) => credentials.filter((each) => each.machine === entry));
|
|
338
|
-
}
|
|
339
|
-
async function updateCredentials(change, operation) {
|
|
340
|
-
reportSignal(operation)?.throwIfAborted();
|
|
341
|
-
const dir = getConfigDir();
|
|
342
|
-
const write = () => {
|
|
343
|
-
reportSignal(operation)?.throwIfAborted();
|
|
344
|
-
const file = buildMachinesFile();
|
|
345
|
-
const tmp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
346
|
-
writeFileSync(tmp, `${JSON.stringify({
|
|
347
|
-
version: MACHINE_CREDENTIALS_VERSION,
|
|
348
|
-
machines: change(readBuildMachines())
|
|
349
|
-
}, null, 2)}\n`, { mode: 384 });
|
|
350
|
-
try {
|
|
351
|
-
renameSync(tmp, file);
|
|
352
|
-
} catch (error) {
|
|
353
|
-
rmSync(tmp, { force: true });
|
|
354
|
-
throw error;
|
|
355
|
-
}
|
|
356
|
-
};
|
|
357
|
-
const options = { ensureParent: () => mkdirSync(dir, { recursive: true }) };
|
|
358
|
-
const signal = reportSignal(operation);
|
|
359
|
-
if (signal) await withDirLockAsync(buildMachinesLock(), write, {
|
|
360
|
-
...options,
|
|
361
|
-
signal
|
|
362
|
-
});
|
|
363
|
-
else withDirLock$1(buildMachinesLock(), write, options);
|
|
364
|
-
}
|
|
365
|
-
function note(title, detail, fix = null) {
|
|
366
|
-
return {
|
|
367
|
-
code: "build-machine",
|
|
368
|
-
level: "note",
|
|
369
|
-
title,
|
|
370
|
-
detail,
|
|
371
|
-
fix
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
const PROBLEM_TITLES = {
|
|
375
|
-
unreachable: "does not answer a build offer",
|
|
376
|
-
checkout: "cannot build an app outside a git checkout",
|
|
377
|
-
"stim-build": "runs an incompatible Stim build",
|
|
378
|
-
arch: "has another CPU architecture",
|
|
379
|
-
xcode: "has another Xcode",
|
|
380
|
-
"macos-sdk": "has another macOS SDK",
|
|
381
|
-
"simulator-sdk": "has another simulator SDK",
|
|
382
|
-
cocoapods: "has no CocoaPods, or another version",
|
|
383
|
-
bundler: "has no Bundler",
|
|
384
|
-
runtime: "has no simulator for this project's iOS runtime",
|
|
385
|
-
jdk: "runs another JDK major version",
|
|
386
|
-
"android-sdk": "has no Android SDK",
|
|
387
|
-
ndk: "lacks this project's NDK",
|
|
388
|
-
"build-tools": "lacks this project's Android build-tools",
|
|
389
|
-
"compile-sdk": "lacks this project's Android compile platform",
|
|
390
|
-
disk: "is low on disk",
|
|
391
|
-
busy: "is too busy to take builds",
|
|
392
|
-
platform: "cannot build this platform"
|
|
393
|
-
};
|
|
394
|
-
const NOTE_TITLES = {
|
|
395
|
-
jdk: "builds Android with its own JDK",
|
|
396
|
-
ndk: "downloads this project's NDK on its first Android build",
|
|
397
|
-
"build-tools": "downloads this project's Android build-tools on its first Android build",
|
|
398
|
-
"compile-sdk": "downloads this project's Android compile platform on its first Android build"
|
|
399
|
-
};
|
|
400
|
-
function commandFix(problem, entry) {
|
|
401
|
-
return problem.commands?.length && problem.lead ? [`On ${entry}, ${problem.lead}:`, ...problem.commands].join("\n") : null;
|
|
402
|
-
}
|
|
403
|
-
function problemFix(problem, entry) {
|
|
404
|
-
const { code } = problem;
|
|
405
|
-
if (problem.followsFrom) return `Fix the ${problem.followsFrom} problem on ${entry} first; this follows from it.`;
|
|
406
|
-
switch (code) {
|
|
407
|
-
case "unreachable": return `Check that stim-server runs on ${entry} and that its tailscale serve route answers, then run \`stim doctor\` again. To keep it running there, run \`stim-server service install --serve\` on ${entry}.`;
|
|
408
|
-
case "checkout": return "Offload syncs the files git lists; run Stim from a git checkout of the app.";
|
|
409
|
-
case "stim-build": return `Update stim-server on ${entry} to a Stim release with the same build compatibility version as this machine (an older stim-server needs the same Stim build): there, run \`stim-server service update --release <version>\` for this machine's release, or \`--from <dir>\` with the packed packages of this machine's checkout.`;
|
|
410
|
-
case "arch": return "Use a remote machine with the same CPU architecture as this machine.";
|
|
411
|
-
case "xcode":
|
|
412
|
-
case "simulator-sdk":
|
|
413
|
-
case "macos-sdk": return commandFix(problem, entry) ?? `Install and select the same Xcode on ${entry} and this Mac (\`xcode-select -p\` on each).`;
|
|
414
|
-
case "cocoapods": return commandFix(problem, entry) ?? `Install the same CocoaPods version on ${entry}, on the PATH its stim-server sets. A build sent there with --remote-build ${entry} still runs; a version that differs rewrites the COCOAPODS line of a committed Podfile.lock.`;
|
|
415
|
-
case "bundler": return `Install Bundler (\`gem install bundler\`) on ${entry}, on the PATH its stim-server's login shell sets.`;
|
|
416
|
-
case "runtime": return commandFix(problem, entry) ?? `Install that iOS simulator runtime on ${entry} with at least one iPhone simulator, or set ios.runtime here to one ${entry} has.`;
|
|
417
|
-
case "jdk": return commandFix(problem, entry) ?? `Start stim-server on ${entry} with JAVA_HOME at a JDK of the same major version as this machine's.`;
|
|
418
|
-
case "android-sdk":
|
|
419
|
-
case "ndk":
|
|
420
|
-
case "build-tools":
|
|
421
|
-
case "compile-sdk": return commandFix(problem, entry) ?? `Install the missing package with sdkmanager in the Android SDK stim-server on ${entry} uses (its ANDROID_HOME, else ~/Library/Android/sdk on macOS or ~/Android/Sdk on Linux).`;
|
|
422
|
-
case "disk": return `Free space on ${entry}'s worker root (server.workerRoot there).`;
|
|
423
|
-
case "platform": return `iOS and macOS builds need a Mac; ${entry} can take Android builds only.`;
|
|
424
|
-
case "busy": return `Builds stay on this machine until ${entry} has capacity. On ${entry}, server.maxLoadPerCore sets the load it accepts and concurrency.maxBuilds how many of its own builds it runs; it takes one offloaded build at a time.`;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
const TRANSIENT = /* @__PURE__ */ new Set(["unreachable", "busy"]);
|
|
428
|
-
const UNPREDICTABLE = /* @__PURE__ */ new Set([
|
|
429
|
-
"unreachable",
|
|
430
|
-
"busy",
|
|
431
|
-
"disk",
|
|
432
|
-
"checkout",
|
|
433
|
-
"cocoapods"
|
|
434
|
-
]);
|
|
435
|
-
/** Why a build on the machine named for it cannot work, from the toolchain differences found before this machine changes the checkout. */
|
|
436
|
-
function predictedRefusal(entry, problems) {
|
|
437
|
-
const known = problems.filter((problem) => !UNPREDICTABLE.has(problem.code));
|
|
438
|
-
if (known.length === 0) return null;
|
|
439
|
-
return {
|
|
440
|
-
reason: known.map((problem) => problem.reason).join("; "),
|
|
441
|
-
remedy: known.map((problem) => problemFix(problem, entry)).join("\n")
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
function offloadFindings(entry, problems, notes, operation) {
|
|
445
|
-
const selected = operation?.env.STIM_REMOTE_BUILD?.trim() || loadConfig$1()?.remote?.build;
|
|
446
|
-
const consequence = typeof selected === "string" && placementWord(selected) === "remote-only" ? "remote.build is remote-only, so automatic builds skip this machine and refuse rather than build on this Mac:" : "Builds fall back to this machine:";
|
|
447
|
-
return [...problems.map((problem) => ({
|
|
448
|
-
code: `build-machine-${problem.code}`,
|
|
449
|
-
level: TRANSIENT.has(problem.code) ? "note" : "cost",
|
|
450
|
-
title: `Remote machine ${entry} ${PROBLEM_TITLES[problem.code]}`,
|
|
451
|
-
detail: `${consequence} ${problem.reason}.${problem.code === "cocoapods" ? ` A build sent there with --remote-build ${entry} still runs.` : ""}`,
|
|
452
|
-
fix: problemFix(problem, entry)
|
|
453
|
-
})), ...notes.map((each) => ({
|
|
454
|
-
code: `build-machine-${each.code}`,
|
|
455
|
-
level: "note",
|
|
456
|
-
title: `Remote machine ${entry} ${NOTE_TITLES[each.code] ?? "needs a first-build download"}`,
|
|
457
|
-
detail: `The build goes there anyway: ${each.reason}.`,
|
|
458
|
-
fix: commandFix(each, entry)
|
|
459
|
-
}))];
|
|
460
|
-
}
|
|
461
|
-
async function inspectMachine(entry, tailnet, deviceName, fix, version, tickets, io, check, operation, confirmKey) {
|
|
462
|
-
const parsed = parseMachine$1(entry);
|
|
463
|
-
if (!parsed) return {
|
|
464
|
-
report: {
|
|
465
|
-
machine: entry,
|
|
466
|
-
state: "invalid"
|
|
467
|
-
},
|
|
468
|
-
finding: note(`Remote machine ${entry} is not a tailnet name or local: address`, "Expected `name`, `name:port`, `local:<host>` or `local:<host>:port`.")
|
|
469
|
-
};
|
|
470
|
-
const local = parsed.transport === "local";
|
|
471
|
-
if (!local && "off" in tailnet) return {
|
|
472
|
-
report: {
|
|
473
|
-
machine: entry,
|
|
474
|
-
state: "tailscale-off",
|
|
475
|
-
diagnosis: tailnet.off
|
|
476
|
-
},
|
|
477
|
-
finding: null
|
|
478
|
-
};
|
|
479
|
-
const status = "status" in tailnet ? tailnet.status : {};
|
|
480
|
-
const peer = local ? null : findPeer$1(status, parsed.name);
|
|
481
|
-
if (peer === "missing" || peer === "ambiguous") {
|
|
482
|
-
const diagnosis = notOnTailnetDiagnosis(entry, peer === "ambiguous");
|
|
483
|
-
return {
|
|
484
|
-
report: {
|
|
485
|
-
machine: entry,
|
|
486
|
-
state: "not-on-tailnet",
|
|
487
|
-
diagnosis
|
|
488
|
-
},
|
|
489
|
-
finding: diagnosisFinding("build-machine", entry, diagnosis)
|
|
490
|
-
};
|
|
491
|
-
}
|
|
492
|
-
const target = peer ? endpoint$1(peer, parsed.port) : localEndpoint(parsed.name, parsed.port);
|
|
493
|
-
const address = peer?.dnsName ?? parsed.name;
|
|
494
|
-
const credential = readBuildMachines().find((each) => each.machine === entry);
|
|
495
|
-
const other = () => {
|
|
496
|
-
try {
|
|
497
|
-
return readDeviceHostMachines().find((each) => each.machine === entry);
|
|
498
|
-
} catch {
|
|
499
|
-
return;
|
|
500
|
-
}
|
|
501
|
-
};
|
|
502
|
-
const persist = (next) => updateCredentials((credentials) => [...credentials.filter((each) => each.machine !== entry), next], operation);
|
|
503
|
-
reportSignal(operation)?.throwIfAborted();
|
|
504
|
-
const outcome = await reachMachine({
|
|
505
|
-
machine: entry,
|
|
506
|
-
access: "build",
|
|
507
|
-
endpoint: target,
|
|
508
|
-
address,
|
|
509
|
-
credential,
|
|
510
|
-
other,
|
|
511
|
-
persist,
|
|
512
|
-
fix,
|
|
513
|
-
deviceName,
|
|
514
|
-
setupFlags: cannotHost(status, entry) ? ["build"] : ["build", "device-host"],
|
|
515
|
-
serverVersion: version,
|
|
516
|
-
io,
|
|
517
|
-
tickets,
|
|
518
|
-
...local ? { confirmKey: (serverKey) => confirmKey?.(entry, serverKey) ?? Promise.resolve(false) } : {}
|
|
519
|
-
});
|
|
520
|
-
const known = {
|
|
521
|
-
machine: entry,
|
|
522
|
-
...peer ? { dnsName: peer.dnsName } : {}
|
|
523
|
-
};
|
|
524
|
-
reportSignal(operation)?.throwIfAborted();
|
|
525
|
-
if (outcome.state !== "not-asked" && outcome.credential) {
|
|
526
|
-
const next = outcome.credential;
|
|
527
|
-
if (JSON.stringify(next) !== JSON.stringify(credential)) await updateCredentials((credentials) => [...credentials.filter((each) => each.machine !== entry), next], operation);
|
|
528
|
-
}
|
|
529
|
-
const paired = {
|
|
530
|
-
...known,
|
|
531
|
-
...outcome.state !== "not-asked" && outcome.credential?.deviceId ? { deviceId: outcome.credential.deviceId } : {},
|
|
532
|
-
...outcome.state !== "not-asked" && outcome.credential ? { requestedAt: outcome.credential.requestedAt } : {}
|
|
533
|
-
};
|
|
534
|
-
switch (outcome.state) {
|
|
535
|
-
case "not-asked": return {
|
|
536
|
-
report: {
|
|
537
|
-
...known,
|
|
538
|
-
state: "not-asked"
|
|
539
|
-
},
|
|
540
|
-
finding: note(`Remote machine ${entry} has not approved this machine for builds`, "This machine has not asked it for build access.", "Run `stim doctor --fix` to make a setup ticket and print the command to run there.")
|
|
541
|
-
};
|
|
542
|
-
case "key-changed": return {
|
|
543
|
-
report: {
|
|
544
|
-
...paired,
|
|
545
|
-
state: "key-changed"
|
|
546
|
-
},
|
|
547
|
-
finding: note(`Remote machine ${entry} answered with a different server key`, `${address} did not prove it holds the stim-server key this machine pinned at approval. Stim does not connect to it.`, `If that machine or its Stim home was replaced, remove ${entry} from remote.machines, run \`stim doctor --fix\` to forget the old pairing, then add it back and run \`stim doctor --fix\` again.`)
|
|
548
|
-
};
|
|
549
|
-
case "unconfirmed": return {
|
|
550
|
-
report: {
|
|
551
|
-
...paired,
|
|
552
|
-
state: "key-unconfirmed",
|
|
553
|
-
fingerprint: outcome.fingerprint
|
|
554
|
-
},
|
|
555
|
-
finding: unconfirmedKeyFinding("build-machine", entry, outcome.fingerprint)
|
|
556
|
-
};
|
|
557
|
-
case "pending": return {
|
|
558
|
-
report: {
|
|
559
|
-
...paired,
|
|
560
|
-
state: "pending",
|
|
561
|
-
...outcome.credential.expiresAt ? { expiresAt: outcome.credential.expiresAt } : {}
|
|
562
|
-
},
|
|
563
|
-
finding: note(`Remote machine ${entry} has not approved this machine for builds yet`, `It does not hold this machine's setup ticket yet${outcome.credential.expiresAt ? `; the ticket expires at ${outcome.credential.expiresAt}` : ""}.`, setupRemedy(entry, outcome.command))
|
|
564
|
-
};
|
|
565
|
-
case "lapsed": return {
|
|
566
|
-
report: {
|
|
567
|
-
...paired,
|
|
568
|
-
state: "lapsed"
|
|
569
|
-
},
|
|
570
|
-
finding: note(`Build request to ${entry} lapsed`, `${entry} did not approve this machine before its setup ticket expired at ${outcome.credential.expiresAt}.`, "Run `stim doctor --fix` to make a new ticket.")
|
|
571
|
-
};
|
|
572
|
-
case "revoked": return {
|
|
573
|
-
report: {
|
|
574
|
-
...paired,
|
|
575
|
-
state: "revoked"
|
|
576
|
-
},
|
|
577
|
-
finding: note(`Remote machine ${entry} no longer accepts this machine for builds`, `${outcome.reason} It was revoked.`, "Run `stim doctor --fix` to ask again.")
|
|
578
|
-
};
|
|
579
|
-
case "outdated": {
|
|
580
|
-
const outdated = outdatedServer(entry, version, outcome.command);
|
|
581
|
-
const diagnosis = {
|
|
582
|
-
layer: "compat",
|
|
583
|
-
code: "server-outdated",
|
|
584
|
-
title: "Server is outdated",
|
|
585
|
-
message: outdated.detail,
|
|
586
|
-
remedy: outdated.fix
|
|
587
|
-
};
|
|
588
|
-
return {
|
|
589
|
-
report: {
|
|
590
|
-
...paired,
|
|
591
|
-
state: "outdated",
|
|
592
|
-
diagnosis
|
|
593
|
-
},
|
|
594
|
-
finding: note(outdated.title, outdated.detail, outdated.fix)
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
|
-
case "unreachable": {
|
|
598
|
-
const failure = {
|
|
599
|
-
entry,
|
|
600
|
-
port: parsed.port,
|
|
601
|
-
target,
|
|
602
|
-
reason: outcome.reason,
|
|
603
|
-
transport: outcome.transport
|
|
604
|
-
};
|
|
605
|
-
const startup = !peer && outcome.transport?.kind === "http" && outcome.transport.status === 503 ? await io.startup?.(target) : null;
|
|
606
|
-
const diagnosis = peer ? await diagnoseOutcome(io, {
|
|
607
|
-
...failure,
|
|
608
|
-
peer
|
|
609
|
-
}) : diagnoseLocalUnreachable({
|
|
610
|
-
...failure,
|
|
611
|
-
startup
|
|
612
|
-
});
|
|
613
|
-
return {
|
|
614
|
-
report: {
|
|
615
|
-
...paired,
|
|
616
|
-
state: "unreachable",
|
|
617
|
-
diagnosis
|
|
618
|
-
},
|
|
619
|
-
finding: diagnosisFinding("build-machine", entry, diagnosis)
|
|
620
|
-
};
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
const permissions = readHostPermissions(outcome.result.host);
|
|
624
|
-
const host = permissions ? { host: permissions } : {};
|
|
625
|
-
if (!check) return {
|
|
626
|
-
report: {
|
|
627
|
-
...paired,
|
|
628
|
-
state: "approved",
|
|
629
|
-
...host
|
|
630
|
-
},
|
|
631
|
-
finding: null
|
|
632
|
-
};
|
|
633
|
-
const { capacity, problems, notes = [] } = await check(outcome.credential);
|
|
634
|
-
return {
|
|
635
|
-
report: {
|
|
636
|
-
...paired,
|
|
637
|
-
state: "approved",
|
|
638
|
-
...host,
|
|
639
|
-
offloadable: problems.length === 0,
|
|
640
|
-
reasons: problems.map((problem) => problem.reason),
|
|
641
|
-
problems,
|
|
642
|
-
...notes.length ? { notes } : {},
|
|
643
|
-
...capacity ? { capacity } : {}
|
|
644
|
-
},
|
|
645
|
-
finding: null,
|
|
646
|
-
extra: offloadFindings(entry, problems, notes, operation)
|
|
647
|
-
};
|
|
648
|
-
}
|
|
649
|
-
/**
|
|
650
|
-
* Doctor findings and a report for each `remote.machines` entry. The worker's stim-server key is pinned on first
|
|
651
|
-
* contact; every later connection must prove it holds that key. With `fix`, makes a setup ticket for a named machine
|
|
652
|
-
* this machine holds no pairing for, or that revoked it, and forgets pairings of machines no longer named. With
|
|
653
|
-
* `check`, each approved machine is asked for one build offer and reports every reason it would not take this
|
|
654
|
-
* project's build.
|
|
655
|
-
*/
|
|
656
|
-
async function inspectBuildMachines({ fix, check = null, version = "<version>", tickets = /* @__PURE__ */ new Map(), operation, confirmKey }, io = realIo, entries = configuredMachines()) {
|
|
657
|
-
if (entries === null) return {
|
|
658
|
-
findings: [note("Invalid remote.machines setting", "Use a remote object with machines as an array of tailnet names. Existing credentials and pinned keys are preserved.", "Run `stim guide settings` and correct the setting before running doctor again.")],
|
|
659
|
-
machines: []
|
|
660
|
-
};
|
|
661
|
-
const unnamed = (each) => !entries.includes(each.machine);
|
|
662
|
-
if (fix && readBuildMachines().some(unnamed)) await updateCredentials((credentials) => credentials.filter((each) => !unnamed(each)), operation);
|
|
663
|
-
if (entries.length === 0) return {
|
|
664
|
-
findings: [],
|
|
665
|
-
machines: []
|
|
666
|
-
};
|
|
667
|
-
const tailnet = entries.some((entry) => parseMachine$1(entry)?.transport !== "local");
|
|
668
|
-
const read = tailnet ? await io.status() : null;
|
|
669
|
-
const view = isJsonObject(read) ? { status: read } : tailnet ? { off: await diagnoseTailscale(io) } : { status: {} };
|
|
670
|
-
const inspection = {
|
|
671
|
-
findings: [],
|
|
672
|
-
machines: []
|
|
673
|
-
};
|
|
674
|
-
if ("off" in view) inspection.findings.push(note("Remote machines are unreachable", `remote.machines names remote machines. ${view.off.message}`, view.off.remedy));
|
|
675
|
-
const self = "status" in view && isJsonObject(view.status.Self) ? view.status.Self : {};
|
|
676
|
-
const deviceName = (typeof self.HostName === "string" && self.HostName ? self.HostName : hostname()).replace(/[\p{Cc}\p{Cf}]/gu, "").trim().slice(0, 64) || "Mac";
|
|
677
|
-
const inspected = await Promise.all(entries.map((entry) => inspectMachine(entry, view, deviceName, fix, version, tickets, io, check, operation, confirmKey)));
|
|
678
|
-
for (const { report, finding, extra = [] } of inspected) {
|
|
679
|
-
inspection.machines.push(report);
|
|
680
|
-
if (finding) inspection.findings.push(finding);
|
|
681
|
-
inspection.findings.push(...extra);
|
|
682
|
-
}
|
|
683
|
-
return inspection;
|
|
684
|
-
}
|
|
685
|
-
//#endregion
|
|
686
|
-
//#region src/offload/selection.ts
|
|
687
|
-
const FINGERPRINT_MISMATCH_REMEDY = "The build Mac fingerprints the synced checkout differently; the message names the sources that differ. Stim sends tracked and untracked files and the gitignored files the fingerprint reads, except under node_modules. A source still differs when the build Mac's dependency install or pod install writes it differently, or when the app config reads an environment variable or file that differs. Make that input agree on both Macs, for example by committing the lockfile pod install rewrote there, or rerun with --remote-build auto or --remote-build local.";
|
|
688
|
-
/** The remedy for a React Native worker's fingerprint-mismatch reason, or undefined for any other reason. */
|
|
689
|
-
function fingerprintMismatchRemedy(reason) {
|
|
690
|
-
return reason.startsWith("fingerprint-mismatch: the checkout there ") ? FINGERPRINT_MISMATCH_REMEDY : void 0;
|
|
691
|
-
}
|
|
692
|
-
const MISSING_PACKAGE_MANAGER = /^deps-failed: spawn (pnpm|yarn|npm) ENOENT/;
|
|
693
|
-
/** The remedy for a worker whose dependency install could not start its package manager; undefined for any other reason. */
|
|
694
|
-
function missingPackageManagerRemedy(machine, reason) {
|
|
695
|
-
const tool = MISSING_PACKAGE_MANAGER.exec(reason)?.[1];
|
|
696
|
-
if (!tool) return void 0;
|
|
697
|
-
return `${machine} has no ${tool} on the PATH of its stim-server service, and the app's lockfile needs it. ${tool === "npm" ? "Reinstall Node there, which ships npm" : `Install it with \`corepack enable ${tool}\` or \`npm install --global ${tool}\`, using sudo where Node is installed system-wide`}, then run the same command again, or rerun with --remote-build auto or --remote-build local.`;
|
|
698
|
-
}
|
|
699
|
-
const PODS_FAILED_PREFIX = "pod install failed: ";
|
|
700
|
-
/** The reason a failed worker job is reported with: a `pods-failed` code reads as a failed pod install. */
|
|
701
|
-
function workerFailureReason(code, message) {
|
|
702
|
-
return code === "pods-failed" ? `${PODS_FAILED_PREFIX}${String(message ?? "")}` : `${String(code ?? "failed")}: ${String(message ?? "")}`;
|
|
703
|
-
}
|
|
704
|
-
/** The remedy for a worker whose `pod install` failed, naming the install when it has no CocoaPods; undefined for any other reason. */
|
|
705
|
-
function podsFailedRemedy(machine, reason, localCocoapods) {
|
|
706
|
-
if (!reason.startsWith(PODS_FAILED_PREFIX)) return void 0;
|
|
707
|
-
const retry = "run the same command again, or rerun with --remote-build auto or --remote-build local";
|
|
708
|
-
if (!reason.includes("CocoaPods is not installed: no `pod` executable on PATH.")) return `Fix the pod install error on ${machine} (run pod install in its checkout under server.workerRoot there to see all of it), then ${retry}.`;
|
|
709
|
-
const { lead, commands } = cocoapodsInstall(localCocoapods);
|
|
710
|
-
return [
|
|
711
|
-
`On ${machine}, ${lead}:`,
|
|
712
|
-
...commands,
|
|
713
|
-
`Then ${retry}.`
|
|
714
|
-
].join("\n");
|
|
715
|
-
}
|
|
716
|
-
var OffloadRefusal = class extends Error {
|
|
717
|
-
code = "STIM_OFFLOAD_REFUSED";
|
|
718
|
-
remedy;
|
|
719
|
-
constructor(machine, reason, remedy = "Run stim doctor --fix to ask for build access if not paired; it prints the stim-server setup command a person runs on the worker to approve this machine. Check stim settings get remote.machines, or rerun with --remote-build auto, remote or local.") {
|
|
720
|
-
super(reason.startsWith(`${machine}: `) ? reason : `${machine}: ${reason}`);
|
|
721
|
-
this.remedy = remedy;
|
|
722
|
-
}
|
|
723
|
-
};
|
|
724
|
-
function resolveBuildMachine(flag, env, setting) {
|
|
725
|
-
const selected = flag ?? (env?.trim() || void 0) ?? setting ?? "auto";
|
|
726
|
-
if (typeof selected !== "string" || !selected.trim() || !parseMachine(selected)) throw Object.assign(/* @__PURE__ */ new Error("--remote-build / remote.build must be local, auto, remote, remote-only, or a tailnet machine name."), { code: "STIM_BAD_ARG" });
|
|
727
|
-
return placementWord(selected) ?? selected.trim();
|
|
728
|
-
}
|
|
729
|
-
function parseBuildMachineOption(value) {
|
|
730
|
-
try {
|
|
731
|
-
return resolveBuildMachine(value);
|
|
732
|
-
} catch (error) {
|
|
733
|
-
throw new InvalidArgumentError(error.message);
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
function automaticBuild(selected) {
|
|
737
|
-
const word = placementWord(selected);
|
|
738
|
-
return word !== null && word !== "local";
|
|
739
|
-
}
|
|
740
|
-
function requireLocalBuild(selected, reason) {
|
|
741
|
-
const word = placementWord(selected);
|
|
742
|
-
const lead = reason ? `${reason}; ` : "";
|
|
743
|
-
if (word === "remote-only") throw new OffloadRefusal(selected, `${lead}remote-only never builds on this machine`);
|
|
744
|
-
if ((word === "auto" || word === "remote") && !automaticMachineEnabled("build", "local")) throw new OffloadRefusal(selected, `${lead}local is disabled in remote.buildPoolDisabled; enable it or select a machine explicitly`);
|
|
745
|
-
}
|
|
746
|
-
function namedBuildMachine(selected) {
|
|
747
|
-
return placementWord(selected) === null;
|
|
748
|
-
}
|
|
749
|
-
function requireConfiguredMachine(selected, machines) {
|
|
750
|
-
if (!namedBuildMachine(selected)) return selected;
|
|
751
|
-
const parsed = parseMachine(selected);
|
|
752
|
-
const entries = Array.isArray(machines) ? machines.filter((entry) => typeof entry === "string") : [];
|
|
753
|
-
const match = entries.find((entry) => {
|
|
754
|
-
const candidate = parseMachine(entry);
|
|
755
|
-
return candidate?.transport === parsed.transport && candidate.name === parsed.name && candidate.port === parsed.port;
|
|
756
|
-
});
|
|
757
|
-
if (!match) throw new OffloadRefusal(selected, `not listed in remote.machines (configured: ${entries.join(", ") || "none"})`);
|
|
758
|
-
return match;
|
|
759
|
-
}
|
|
760
|
-
const settingSource = (flag, env, setting) => flag !== void 0 ? "flag" : env?.trim() ? "env" : setting !== void 0 ? "setting" : "default";
|
|
761
|
-
/** The settings that decide where a build runs, with the layer each value came from, for this run's `--remote-build`. */
|
|
762
|
-
function buildPlacementSettings(selected) {
|
|
763
|
-
const flag = operationState(ambientContext()).buildMachineFlag;
|
|
764
|
-
return [{
|
|
765
|
-
key: "remote.build",
|
|
766
|
-
value: selected,
|
|
767
|
-
from: settingSource(flag, ambientEnv().STIM_REMOTE_BUILD, loadConfig$1()?.remote?.build)
|
|
768
|
-
}];
|
|
769
|
-
}
|
|
770
|
-
function resolveBuildPlacement(flag) {
|
|
771
|
-
const remote = loadConfig$1()?.remote;
|
|
772
|
-
operationState(ambientContext()).buildMachineFlag = flag;
|
|
773
|
-
let selected = "auto";
|
|
774
|
-
try {
|
|
775
|
-
selected = resolveBuildMachine(flag, ambientEnv().STIM_REMOTE_BUILD, remote?.build);
|
|
776
|
-
selected = requireConfiguredMachine(selected, remote?.machines);
|
|
777
|
-
if (namedBuildMachine(selected) && pairedMachines([selected]).length === 0) throw new OffloadRefusal(selected, "no remote machine is paired");
|
|
778
|
-
return { selected };
|
|
779
|
-
} catch (error) {
|
|
780
|
-
return {
|
|
781
|
-
selected,
|
|
782
|
-
failure: {
|
|
783
|
-
code: error.code,
|
|
784
|
-
message: error.message,
|
|
785
|
-
remedy: error instanceof OffloadRefusal ? error.remedy : "Pass --remote-build local, auto, remote, remote-only, or an entry from stim settings get remote.machines."
|
|
786
|
-
}
|
|
787
|
-
};
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
//#endregion
|
|
791
|
-
export { hostingMachines as _, missingPackageManagerRemedy as a, podsFailedRemedy as c, resolveBuildPlacement as d, workerFailureReason as f, configuredMachines as g, predictedRefusal as h, fingerprintMismatchRemedy as i, requireLocalBuild as l, pairedMachines as m, automaticBuild as n, namedBuildMachine as o, inspectBuildMachines as p, buildPlacementSettings as r, parseBuildMachineOption as s, OffloadRefusal as t, resolveBuildMachine as u, inspectDeviceHostMachines as v };
|