stim 1.20.2 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -8
- 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-Dzgv6lgR.mjs → agent-device-usage-output-zh1vhbLp.mjs} +21 -65
- package/dist/{android-HqP1_vB_.mjs → android-BEJ8Jpl7.mjs} +2 -2
- package/dist/{android-DCKZrNvV.mjs → android-BLgbNqox.mjs} +128 -78
- package/dist/{android-Dlzxshgp.mjs → android-CV_GCELZ.mjs} +5 -5
- package/dist/{android-Mz_Inn3w.mjs → android-DUYkNF4u.mjs} +184 -102
- package/dist/{android-cas-Bl-cLJBk.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-HSwkIWEQ.mjs → artifact-B8T3S5gi.mjs} +223 -201
- package/dist/{artifact-D3czlUvT.mjs → artifact-DAuZ-FNU.mjs} +158 -148
- package/dist/{browser-web-CA-F1GQo.mjs → browser-web-QQzVjz3O.mjs} +26 -24
- package/dist/budget-Bs6SxxzO.mjs +9154 -0
- package/dist/{build-DYDbfkk5.mjs → build-CoPzQRNw.mjs} +144 -96
- package/dist/build-cache-DmyR9Zzc.mjs +602 -0
- package/dist/build-plan-CaFskB7_.mjs +188 -0
- package/dist/{cache-manifest-XH-fvDUj.mjs → cache-manifest-DkkqguoK.mjs} +2 -2
- package/dist/cache-manifest.mjs +1 -1
- package/dist/{ccache-zdKiYQ3E.mjs → ccache-BJRZ9pG3.mjs} +10 -9
- package/dist/{cdp-Dq_ypAlJ.mjs → cdp-CWmIUMbw.mjs} +18 -5
- package/dist/{chrome-BnzZMqsR.mjs → chrome-B6tfCta1.mjs} +7 -4
- package/dist/{cli-CLP3diBm.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 -40
- package/dist/collector-run.mjs +9 -8
- package/dist/{command-output-BTy8hZ0F.mjs → command-output-B1UrjZHL.mjs} +1 -1
- package/dist/config-CYcBF478.mjs +949 -0
- package/dist/{created-devices-Dzd5C2LF.mjs → created-devices-CqeBlrEn.mjs} +3 -3
- package/dist/{dependency-state-DG0p31-y.mjs → dependency-state-BbKQW83h.mjs} +20 -5
- package/dist/{detached-entry-B9C_zeQC.mjs → detached-entry-DFRyG1_o.mjs} +1 -1
- package/dist/{dev-client-DAWVIGBu.mjs → dev-client-UOeESKm6.mjs} +2 -2
- package/dist/device-DCxH7_By.mjs +1068 -0
- package/dist/{device-BECOiufl.mjs → device-ExJq8Ei7.mjs} +35 -35
- package/dist/{device-capacity-CBUAcRyQ.mjs → device-capacity-CMlqEcvw.mjs} +43 -13
- package/dist/device-host-worker.mjs +65 -61
- package/dist/{device-ios-COSi6oS1.mjs → device-ios-DRUeKaFV.mjs} +48 -45
- package/dist/{device-lease-run-Cw2M4z51.mjs → device-lease-run-C8raGFoP.mjs} +14 -26
- package/dist/{device-pool-Bf-pOhSw.mjs → device-pool-DMRpVX9a.mjs} +5 -5
- package/dist/doctor-BLHCYxzi.mjs +2 -0
- package/dist/{doctor-kfMBnUw6.mjs → doctor-DTvaDOda.mjs} +281 -317
- package/dist/{doctor-CB8oZKCk.mjs → doctor-Dhqebm0q.mjs} +183 -91
- package/dist/doctor-fingerprint.mjs +19 -0
- package/dist/{doctor-watchman-BRyV2adA.mjs → doctor-watchman-Cv1F10Kj.mjs} +40 -21
- package/dist/{eas-build-JyfqyHfC.mjs → eas-build-BomfRnFT.mjs} +53 -20
- package/dist/{build-plan-B7SZsc2N.mjs → eas-fallback-DJwZpy0c.mjs} +26 -208
- package/dist/{watchman-CPQFZLXY.mjs → eas-session-ledger-op6A54yi.mjs} +229 -11
- package/dist/{error-diagnostics-BR677IDM.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-qWOMdnER.mjs → gc-_-dCXdyL.mjs} +584 -796
- package/dist/git-C3iTsJaZ.mjs +73 -0
- package/dist/{guide-G9cAbVAc.mjs → guide-Yqwt2bd6.mjs} +941 -269
- package/dist/{hosted-android-C3MHGld1.mjs → hosted-android-Bw-honsd.mjs} +8 -6
- package/dist/{hosted-client-ZEKpS9vw.mjs → hosted-client-DB_gBPfY.mjs} +34 -19
- package/dist/{hosted-ios-l-o3iM9J.mjs → hosted-ios-CUvOf4Vr.mjs} +1 -1
- package/dist/{hosted-logs-EzQM7-3Z.mjs → hosted-logs-DL_P5AdN.mjs} +77 -43
- package/dist/{hosted-macos-BACVAVqE.mjs → hosted-macos-QI141yKk.mjs} +21 -17
- package/dist/{hosted-native-A4s1QPXe.mjs → hosted-native-Ksyjgzq-.mjs} +30 -21
- package/dist/idle-BVeRGroT.d.mts +24 -0
- package/dist/{idle-shutdown-DtxhPTKe.mjs → idle-shutdown-DaKmZi0z.mjs} +11 -10
- package/dist/{ios-BwVCF7oA.mjs → ios-CQ68hG9s.mjs} +8 -8
- package/dist/{ios-RkW4pnQf.mjs → ios-CpByZy12.mjs} +140 -80
- package/dist/{ios-device-B5veSDDQ.mjs → ios-device-CXGP1bsD.mjs} +1 -1
- package/dist/{ios-device-D7pi2Sca.mjs → ios-device-CwFMehUS.mjs} +51 -26
- package/dist/{ios-project-K9hY_Jab.mjs → ios-project-WuwwBdvW.mjs} +13 -13
- package/dist/{ios-nOLJGVdy.mjs → ios-qNJt4dFm.mjs} +1 -1
- package/dist/ios-signing-DTTIChGs.mjs +489 -0
- package/dist/{ios-state-CBLe1xYw.mjs → ios-state-DvFX-K_l.mjs} +1 -1
- package/dist/{ios-Ce7bc7br.mjs → ios-ubFsBzwq.mjs} +129 -86
- package/dist/{js-swap-Bb3nsS07.mjs → js-swap-Cc1dttps.mjs} +53 -26
- package/dist/{launch-F4sOqAhB.mjs → launch-CD1yVc7U.mjs} +91 -90
- package/dist/{launch-C3qJ6Agb.mjs → launch-Zq2mOSDy.mjs} +82 -541
- package/dist/logs-BS00Anxf.mjs +352 -0
- package/dist/logs-CMm05HxN.mjs +255 -0
- package/dist/{macos-D7uDvO-z.mjs → macos-B65--pPd.mjs} +1 -1
- package/dist/{macos-Ch5VJmcS.mjs → macos-C-0qJ6zq.mjs} +225 -212
- package/dist/macos-run.mjs +1 -1
- package/dist/maintenance-run.mjs +122 -247
- package/dist/{metro-DnCEjCxs.mjs → metro-DEXpIhHC.mjs} +67 -12
- package/dist/{metro-gateway-CX9Xlkq2.mjs → metro-gateway-BMJNlj3E.mjs} +20 -12
- package/dist/{named-ports-4WopRPg-.mjs → named-ports-BWTzt6mu.mjs} +8 -63
- package/dist/native-android-JACyjTZs.mjs +844 -0
- package/dist/{native-gradle-inputs-BsLRrl7u.mjs → native-gradle-inputs-Bep9JcSF.mjs} +128 -140
- package/dist/native-inputs-TRTTTRxt.mjs +91 -0
- package/dist/native-run-DY_RLx3C.mjs +277 -0
- package/dist/{native-runtime-k8dTIrbK.mjs → native-runtime-Dg1Q7tfF.mjs} +9 -8
- package/dist/{native-xcode-inputs-CykopJdM.mjs → native-xcode-inputs-CB2iQeWq.mjs} +27 -18
- package/dist/{native-xcode-ios-Bbf30Gm0.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 +197 -66
- package/dist/{ownership-DCtw_2IA.mjs → ownership-DEmM5vhh.mjs} +3 -3
- package/dist/{page-DRHy329N.mjs → page-CPaHeYqj.mjs} +7 -4
- package/dist/paths-BsJMoPP2.mjs +12 -0
- package/dist/paths-DQtTgsBf.mjs +42 -0
- package/dist/{placement-log-MOfPVgaM.mjs → placement-log-BqGbTa61.mjs} +5 -5
- package/dist/{plan-placement-V0TdzYXp.mjs → plan-placement-Bwj-IjY1.mjs} +6 -6
- package/dist/{ports-DdSUicVo.mjs → ports-D-MmCTdv.mjs} +3 -3
- package/dist/prebuild-uD_ipCxF.mjs +449 -0
- package/dist/{project-_phNIJfs.mjs → project-BZNjmW_8.mjs} +65 -37
- package/dist/{pull-request-CQ8sPbZa.mjs → pull-request-Lfetn8Kr.mjs} +2 -2
- 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-CM1XRDwv.mjs → react-native-android-DuzH0cn3.mjs} +74 -48
- package/dist/{gradle-DSrXb6lG.mjs → react-native-build-rhk4smwQ.mjs} +292 -15
- package/dist/react-native-doctor-CQpuIMso.mjs +234 -0
- package/dist/{react-native-ios-Dhq_eiYQ.mjs → react-native-ios-Bhq1rJeV.mjs} +46 -28
- package/dist/{recordings-D0d5aQt0.mjs → recordings-DYteQSu4.mjs} +12 -9
- package/dist/{reload-C8JhxjSh.mjs → reload-CmTRFJaX.mjs} +93 -47
- package/dist/reload-DzjSl5P_.mjs +2 -0
- package/dist/{remote-BiR6aYjy.mjs → remote-ByYkXdGD.mjs} +15 -10
- package/dist/result-DNiS-tTP.mjs +434 -0
- package/dist/{run-BtPgpKks.mjs → run-D23HmJMs.mjs} +4 -5
- package/dist/selection-CSl9i5qU.mjs +619 -0
- package/dist/{server-bare-R2m_gsH8.mjs → server-bare-CxTrvDg8.mjs} +3 -4
- package/dist/{server-command-CTtCkmcQ.mjs → server-command-CtzloH3v.mjs} +14 -7
- package/dist/server-expo-C-90EhcG.mjs +2 -0
- package/dist/{server-expo-DsguMGUF.mjs → server-expo-DT_F_uVI.mjs} +50 -9
- package/dist/{settings-B717odTD.mjs → settings-CsJDEXgK.mjs} +234 -24
- 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-CCr3rE-A.mjs → simslim-Cgk17SXV.mjs} +14 -12
- package/dist/{slot-launch-DPt0m9Nd.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-BWqzODpb.mjs → start-7lpH7hmN.mjs} +63 -44
- package/dist/{start-TXeMmmO2.mjs → start-RChynRDp.mjs} +1 -1
- package/dist/{state-D1Icyjlu.mjs → state-C4ZtUisW.mjs} +40 -13
- package/dist/{state-CG_OFoaA.mjs → state-XMziexv2.mjs} +3 -2
- package/dist/{stats-BoY5sEPU.mjs → stats-53T7OTb9.mjs} +7 -13
- package/dist/stats-report-BFfMpWWF.mjs +16 -0
- package/dist/{status-WgFbkRzj.mjs → status-BL7jVyAB.mjs} +535 -447
- package/dist/status-CSi6tlRq.mjs +2 -0
- package/dist/{status-BTA7kKiQ.mjs → status-DqEUSSxs.mjs} +6 -4
- package/dist/{status-watch-C23ILtf9.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-DR6VoDIk.mjs → stop-Bk_1qiV6.mjs} +2 -2
- package/dist/{stop-BNmBMi1F.mjs → stop-CPzlM1L-.mjs} +138 -98
- package/dist/{stop-DPEhunlw.mjs → stop-D7h6jAXQ.mjs} +11 -10
- package/dist/supervisor-run.d.mts +8 -17
- package/dist/supervisor-run.mjs +63 -27
- package/dist/{support-DMTqj3Hm.mjs → support-67vraa1Q.mjs} +18 -11
- package/dist/{support-CwjbFs9H.mjs → support-Dlu37g6H.mjs} +12 -12
- package/dist/{swiftpm-macos-DRNVJWlb.mjs → swiftpm-macos-p8WZbxKU.mjs} +35 -24
- package/dist/toolchain-DhKwp9iI.mjs +2 -0
- package/dist/toolchain-Hp9sCpK4.mjs +873 -0
- package/dist/{trigger-CigAYjeL.mjs → trigger-BAahxUPq.mjs} +20 -5
- package/dist/trigger-Bf3uDcpv.mjs +2 -0
- package/dist/{warm-progress-BuY-Fvfn.mjs → warm-progress-BHX5r0Ei.mjs} +250 -156
- package/dist/{web-BDBMxDpx.mjs → web-CJmIj6AI.mjs} +18 -13
- package/dist/web-DknQETPs.mjs +2 -0
- package/dist/web-run.mjs +11 -12
- 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-DJt_MMvf.mjs → workspace-state-Cjuigeeu.mjs} +62 -58
- package/dist/{workspaces-C36s2jb9.mjs → workspaces-BccMFmGQ.mjs} +1188 -1079
- package/dist/worktree-CK2MpJW5.mjs +2 -0
- package/dist/{worktree-CgvJYJ-Q.mjs → worktree-DQ6Zi2Mv.mjs} +304 -53
- package/dist/xcode-Zlx3qjEs.mjs +896 -0
- package/package.json +7 -5
- package/shim/android-optimizations.gradle +7 -5
- package/dist/activity-BSV745Kz.mjs +0 -629
- package/dist/api-qvOzWyfO.mjs +0 -154
- package/dist/api-run.mjs +0 -294
- package/dist/app-install-BIKtMfPq.mjs +0 -896
- package/dist/artifact-lifecycle-DzPpBYvK.mjs +0 -30
- package/dist/budget-f7516Zk0.mjs +0 -4106
- package/dist/build-facts-DcLv2HSd.d.mts +0 -111
- package/dist/cancellation-C_22VQTH.mjs +0 -24
- package/dist/client-qQAaXSUs.mjs +0 -1771
- package/dist/config-BYDxlMY3.mjs +0 -562
- package/dist/device-DuiPJQSn.mjs +0 -290
- package/dist/device-lease-BX1sJQ2E.mjs +0 -1224
- package/dist/device-remote-xRT0Vmo9.mjs +0 -1272
- package/dist/eas-session-ledger-Cm0Gwq2F.mjs +0 -207
- package/dist/exec-DqKo9GKJ.mjs +0 -268
- package/dist/git-DDfFzkMm.mjs +0 -45
- package/dist/launch-verify-B6Q8hZP-.mjs +0 -428
- package/dist/logs-BGrEUaEs.mjs +0 -383
- package/dist/miss-reason-mKzZ4VvN.mjs +0 -238
- package/dist/native-android-D5qc3-_v.mjs +0 -226
- package/dist/ndjson-Du3j0AQ9.d.mts +0 -17
- package/dist/plan-C4TjdPsR.mjs +0 -260
- package/dist/prebuild-DYbucPXy.mjs +0 -212
- package/dist/preview-78a9kR_-.mjs +0 -1011
- package/dist/react-native-build-CtCccJtb.mjs +0 -239
- package/dist/react-native-doctor-CfRnFfjs.mjs +0 -78
- package/dist/remote-cache-OyOyVIS3.mjs +0 -526
- package/dist/result-CaJg5Iat.mjs +0 -186
- package/dist/server-expo-Bigriskl.mjs +0 -2
- package/dist/settings-BORNaaCO.mjs +0 -402
- package/dist/spawn-claims-DVS5RkMS.mjs +0 -72
- package/dist/stage-KNTQopqv.mjs +0 -157
- package/dist/stim-desktop-BzBN2Em2.mjs +0 -63
- package/dist/tailnet-Dh-qiYzG.mjs +0 -265
- package/dist/toolchain-BFkAcstd.mjs +0 -2
- package/dist/toolchain-DxSsNssu.mjs +0 -1657
- package/dist/trigger-9_USgmxz.mjs +0 -2
- package/dist/web-Dq-i3wzJ.mjs +0 -2
- package/dist/worktree-DpLdCHga.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
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { p as process_identity_exports } from "./exec-_UbtCQcG.mjs";
|
|
2
|
+
import { m as workspaceLogsDir$1 } from "./paths-DQtTgsBf.mjs";
|
|
3
|
+
import { K as projectDeviceSlots, _ as loadConfig$1 } from "./config-CYcBF478.mjs";
|
|
4
|
+
import { n as pullHostedNativeLogs, t as pullHostedMacosLogs } from "./hosted-logs-DL_P5AdN.mjs";
|
|
5
|
+
import { l as phaseLine } from "./command-output-B1UrjZHL.mjs";
|
|
6
|
+
import { f as readAgentDeviceRecordsAsync, n as agentDeviceLiveness } from "./activity-BzVfHSrY.mjs";
|
|
7
|
+
import { l as connectHost } from "./hosted-client-DB_gBPfY.mjs";
|
|
8
|
+
import { n as readHostedIos, t as readHostedAndroid } from "./ios-state-DvFX-K_l.mjs";
|
|
9
|
+
import "./hosted-macos-QI141yKk.mjs";
|
|
10
|
+
import { i as captureWorkspaceCrashes } from "./error-diagnostics-Bf0rZvG9.mjs";
|
|
11
|
+
import { watch } from "node:fs";
|
|
12
|
+
import { homedir } from "node:os";
|
|
13
|
+
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
14
|
+
import { ambientWrite, configDir } from "@stim-cli/core";
|
|
15
|
+
import { LEVELS, SOURCES, agentDeviceStateDirsAsync, buildCriteria, compileGrep, createAsyncAgentActionReader, followLogs, logFiles, openLogDir, parseSince, readMacosRecord, recordMatches, workspaceStateFile } from "@stim-cli/core/state";
|
|
16
|
+
import { setImmediate } from "node:timers/promises";
|
|
17
|
+
import { realpath } from "node:fs/promises";
|
|
18
|
+
//#region src/devices/agent-actions.ts
|
|
19
|
+
function workspaceAgentTargets(project, macos) {
|
|
20
|
+
const targets = [];
|
|
21
|
+
if (macos?.app && macos.bundleId) targets.push({
|
|
22
|
+
platform: "macos",
|
|
23
|
+
id: macos.launchId,
|
|
24
|
+
slot: "default",
|
|
25
|
+
bundleId: macos.bundleId,
|
|
26
|
+
launchedAt: macos.app.startedAtMicros / 1e3
|
|
27
|
+
});
|
|
28
|
+
let slots;
|
|
29
|
+
try {
|
|
30
|
+
slots = projectDeviceSlots(project);
|
|
31
|
+
} catch {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
for (const { slot, platforms } of slots) {
|
|
35
|
+
const { ios, android } = platforms;
|
|
36
|
+
if (ios?.owned && typeof ios.deviceUdid === "string") targets.push({
|
|
37
|
+
platform: "ios",
|
|
38
|
+
id: ios.deviceUdid,
|
|
39
|
+
slot
|
|
40
|
+
});
|
|
41
|
+
if (android?.owned && typeof android.consolePort === "number" && typeof android.avdName === "string") targets.push({
|
|
42
|
+
platform: "android",
|
|
43
|
+
id: `emulator-${android.consolePort}`,
|
|
44
|
+
slot,
|
|
45
|
+
name: android.avdName
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return targets;
|
|
49
|
+
}
|
|
50
|
+
function createAsyncAgentActionReader$1({ targets, sinceTs, home = homedir(), env, now, startOf = process_identity_exports.inspectProcessStart }, signal) {
|
|
51
|
+
let sessionsDirs = [];
|
|
52
|
+
let claimed = /* @__PURE__ */ new Map();
|
|
53
|
+
let canonical = /* @__PURE__ */ new Map();
|
|
54
|
+
const read = createAsyncAgentActionReader({
|
|
55
|
+
sessionsDirs: () => sessionsDirs,
|
|
56
|
+
targets,
|
|
57
|
+
sinceTs,
|
|
58
|
+
now,
|
|
59
|
+
claimedDevice: (session, sessionsDir) => claimed.get(`${canonical.get(dirname(sessionsDir))}\0${session}`) ?? claimed.get(`\0${session}`) ?? null
|
|
60
|
+
}, signal);
|
|
61
|
+
return async (selection) => {
|
|
62
|
+
signal?.throwIfAborted();
|
|
63
|
+
const roots = await agentDeviceStateDirsAsync(home, env);
|
|
64
|
+
canonical = /* @__PURE__ */ new Map();
|
|
65
|
+
const canonicalize = async (path) => {
|
|
66
|
+
if (canonical.has(path)) return canonical.get(path);
|
|
67
|
+
const value = await realpath(path).catch(() => resolve(path));
|
|
68
|
+
canonical.set(path, value);
|
|
69
|
+
return value;
|
|
70
|
+
};
|
|
71
|
+
for (const root of roots) await canonicalize(root);
|
|
72
|
+
sessionsDirs = roots.map((root) => join(root, "sessions"));
|
|
73
|
+
claimed = /* @__PURE__ */ new Map();
|
|
74
|
+
const byId = new Map((typeof targets === "function" ? targets() : targets).map((target) => [target.id, target]));
|
|
75
|
+
if ([...byId.values()].some((target) => target.platform !== "macos")) for (const record of await readAgentDeviceRecordsAsync(home, env)) {
|
|
76
|
+
signal?.throwIfAborted();
|
|
77
|
+
if (record.kind !== "claim" || !record.session || !record.deviceId) continue;
|
|
78
|
+
const target = byId.get(record.deviceId);
|
|
79
|
+
if (!target || target.platform === "macos" || target.name !== void 0 && target.name !== record.deviceName) continue;
|
|
80
|
+
if (agentDeviceLiveness(record, startOf) === "live") claimed.set(`${record.stateDir ? await canonicalize(record.stateDir) : ""}\0${record.session}`, record.deviceId);
|
|
81
|
+
await setImmediate();
|
|
82
|
+
}
|
|
83
|
+
signal?.throwIfAborted();
|
|
84
|
+
return read(selection);
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/device-host/hosted-logs-sync.ts
|
|
89
|
+
function warn(context, machine, error) {
|
|
90
|
+
const text = `${warning(machine, error)}\n`;
|
|
91
|
+
if (context) context.output("stderr", text);
|
|
92
|
+
else ambientWrite("stderr", text);
|
|
93
|
+
}
|
|
94
|
+
function warning(machine, error) {
|
|
95
|
+
const message = error.message.replace(/\.$/, "");
|
|
96
|
+
const hint = message.includes("refused device-host.logs.query") ? ` If ${machine} runs an older stim-server, update it.` : "";
|
|
97
|
+
return phaseLine("device", `Could not read the app's logs from ${machine}: ${message}. Showing the logs already copied here.${hint}`);
|
|
98
|
+
}
|
|
99
|
+
async function syncHostedMacosLogs(root, placement, slot, warnings, platform = "ios", context) {
|
|
100
|
+
let host;
|
|
101
|
+
const cancel = () => host?.connection.close();
|
|
102
|
+
context?.signal.addEventListener("abort", cancel, { once: true });
|
|
103
|
+
try {
|
|
104
|
+
host = await connectHost(placement.machine, void 0, false, context?.signal);
|
|
105
|
+
if (slot !== void 0) await pullHostedNativeLogs(root, slot, placement, host, false, platform, context?.signal);
|
|
106
|
+
else await pullHostedMacosLogs(root, placement, host, void 0, void 0, false, context?.signal);
|
|
107
|
+
return true;
|
|
108
|
+
} catch (error) {
|
|
109
|
+
context?.signal.throwIfAborted();
|
|
110
|
+
if (!warnings?.has(placement.machine)) {
|
|
111
|
+
warn(context, placement.machine, error);
|
|
112
|
+
warnings?.add(placement.machine);
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
115
|
+
} finally {
|
|
116
|
+
context?.signal.removeEventListener("abort", cancel);
|
|
117
|
+
host?.connection.close();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function followHostedMacosLogs(root, { failing = false, intervalMs = 500, retryMs = 5e3, slot, platform = "ios", context } = {}) {
|
|
121
|
+
let host;
|
|
122
|
+
const controller = new AbortController();
|
|
123
|
+
const signal = context ? AbortSignal.any([context.signal, controller.signal]) : controller.signal;
|
|
124
|
+
const cancel = () => host?.connection.close();
|
|
125
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
126
|
+
let retryAt = 0;
|
|
127
|
+
let stopped = false;
|
|
128
|
+
let running = false;
|
|
129
|
+
const tick = async () => {
|
|
130
|
+
if (running || stopped || signal.aborted || Date.now() < retryAt) return;
|
|
131
|
+
running = true;
|
|
132
|
+
try {
|
|
133
|
+
const placement = slot !== void 0 ? (platform === "ios" ? readHostedIos(root) : readHostedAndroid(root))[slot] : readMacosRecord(root)?.host;
|
|
134
|
+
if (!placement) {
|
|
135
|
+
host?.connection.close();
|
|
136
|
+
host = void 0;
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
host ??= await connectHost(placement.machine, void 0, false, signal);
|
|
140
|
+
if (slot !== void 0) await pullHostedNativeLogs(root, slot, placement, host, false, platform, signal);
|
|
141
|
+
else await pullHostedMacosLogs(root, placement, host, void 0, void 0, false, signal);
|
|
142
|
+
failing = false;
|
|
143
|
+
} catch (error) {
|
|
144
|
+
host?.connection.close();
|
|
145
|
+
host = void 0;
|
|
146
|
+
if (signal.aborted) return;
|
|
147
|
+
if (!failing) warn(context, (slot !== void 0 ? (platform === "ios" ? readHostedIos(root) : readHostedAndroid(root))[slot] : readMacosRecord(root)?.host)?.machine ?? "the host", error);
|
|
148
|
+
failing = true;
|
|
149
|
+
retryAt = Date.now() + retryMs;
|
|
150
|
+
} finally {
|
|
151
|
+
running = false;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const timer = setInterval(() => void tick(), intervalMs);
|
|
155
|
+
return () => {
|
|
156
|
+
stopped = true;
|
|
157
|
+
controller.abort();
|
|
158
|
+
signal.removeEventListener("abort", cancel);
|
|
159
|
+
clearInterval(timer);
|
|
160
|
+
host?.connection.close();
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
async function syncHostedLogs(root, context) {
|
|
164
|
+
const macos = readMacosRecord(root)?.host;
|
|
165
|
+
const warnings = /* @__PURE__ */ new Set();
|
|
166
|
+
return (await Promise.all([
|
|
167
|
+
...macos ? [syncHostedMacosLogs(root, macos, void 0, warnings, "ios", context)] : [],
|
|
168
|
+
...Object.entries(readHostedIos(root)).map(([slot, placement]) => syncHostedMacosLogs(root, placement, slot, warnings, "ios", context)),
|
|
169
|
+
...Object.entries(readHostedAndroid(root)).map(([slot, placement]) => syncHostedMacosLogs(root, placement, slot, warnings, "android", context))
|
|
170
|
+
])).every(Boolean);
|
|
171
|
+
}
|
|
172
|
+
function followHostedLogs(root, failing, context) {
|
|
173
|
+
const stops = /* @__PURE__ */ new Map();
|
|
174
|
+
let closed = false;
|
|
175
|
+
const refresh = () => {
|
|
176
|
+
if (closed) return;
|
|
177
|
+
const active = /* @__PURE__ */ new Set();
|
|
178
|
+
if (readMacosRecord(root)?.host) {
|
|
179
|
+
active.add("macos");
|
|
180
|
+
if (!stops.has("macos")) stops.set("macos", followHostedMacosLogs(root, {
|
|
181
|
+
failing,
|
|
182
|
+
context
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
for (const platform of ["ios", "android"]) for (const slot of Object.keys(platform === "ios" ? readHostedIos(root) : readHostedAndroid(root))) {
|
|
186
|
+
const key = `${platform}:${slot}`;
|
|
187
|
+
active.add(key);
|
|
188
|
+
if (!stops.has(key)) stops.set(key, followHostedMacosLogs(root, {
|
|
189
|
+
failing,
|
|
190
|
+
slot,
|
|
191
|
+
platform,
|
|
192
|
+
context
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
195
|
+
for (const [key, stop] of stops) {
|
|
196
|
+
if (active.has(key)) continue;
|
|
197
|
+
stop();
|
|
198
|
+
stops.delete(key);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
const stateFile = workspaceStateFile(root);
|
|
202
|
+
const home = resolve(configDir());
|
|
203
|
+
let watcher = null;
|
|
204
|
+
const observe = () => {
|
|
205
|
+
if (closed) return;
|
|
206
|
+
watcher?.close();
|
|
207
|
+
watcher = null;
|
|
208
|
+
let directory = dirname(stateFile);
|
|
209
|
+
for (;;) try {
|
|
210
|
+
const entry = relative(directory, stateFile).split(sep)[0];
|
|
211
|
+
const next = watch(directory, (_event, name) => {
|
|
212
|
+
if (name !== null && name.toString() !== entry) return;
|
|
213
|
+
if (directory !== dirname(stateFile)) observe();
|
|
214
|
+
refresh();
|
|
215
|
+
});
|
|
216
|
+
next.on("error", () => {
|
|
217
|
+
next.close();
|
|
218
|
+
if (watcher === next) watcher = null;
|
|
219
|
+
});
|
|
220
|
+
next.unref();
|
|
221
|
+
watcher = next;
|
|
222
|
+
return;
|
|
223
|
+
} catch (error) {
|
|
224
|
+
if (directory === home || !(error instanceof Error && "code" in error && error.code === "ENOENT")) return;
|
|
225
|
+
directory = dirname(directory);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
observe();
|
|
229
|
+
refresh();
|
|
230
|
+
const timer = setInterval(() => {
|
|
231
|
+
observe();
|
|
232
|
+
refresh();
|
|
233
|
+
}, 1e4);
|
|
234
|
+
return () => {
|
|
235
|
+
closed = true;
|
|
236
|
+
watcher?.close();
|
|
237
|
+
clearInterval(timer);
|
|
238
|
+
for (const stop of stops.values()) stop();
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
//#endregion
|
|
242
|
+
//#region src/engine/logs.ts
|
|
243
|
+
async function openWorkspaceLogs(context, options = {}, follow = false) {
|
|
244
|
+
context.signal.throwIfAborted();
|
|
245
|
+
const root = context.projectRoot;
|
|
246
|
+
const dir = workspaceLogsDir$1(root);
|
|
247
|
+
if (!logFiles(dir).length) throw Object.assign(/* @__PURE__ */ new Error(`No Stim workspace has run in ${root}. Run stim start, stim ios, or stim android in the app first.`), { code: "STIM_NO_PROJECT" });
|
|
248
|
+
const hostedReachable = await syncHostedLogs(root, context);
|
|
249
|
+
context.signal.throwIfAborted();
|
|
250
|
+
const initial = await openLogDir(dir, { signal: context.signal });
|
|
251
|
+
let attempts;
|
|
252
|
+
try {
|
|
253
|
+
attempts = initial.launchAttempts();
|
|
254
|
+
} finally {
|
|
255
|
+
await initial.close();
|
|
256
|
+
}
|
|
257
|
+
await captureWorkspaceCrashes(root, dir, attempts, context.signal, context.env);
|
|
258
|
+
const view = await openLogDir(dir, {
|
|
259
|
+
order: follow ? "name" : "timeline",
|
|
260
|
+
signal: context.signal
|
|
261
|
+
});
|
|
262
|
+
const agentSince = view.firstTs ?? (follow ? Date.now() : void 0);
|
|
263
|
+
const project = loadConfig$1()?.projects?.[root];
|
|
264
|
+
return {
|
|
265
|
+
view,
|
|
266
|
+
readAgent: (options.sources ? options.sources.includes("agent") : !options.errorsOnly) && agentSince !== void 0 ? createAsyncAgentActionReader$1({
|
|
267
|
+
targets: () => workspaceAgentTargets(project, readMacosRecord(root)),
|
|
268
|
+
sinceTs: agentSince,
|
|
269
|
+
home: context.env.HOME,
|
|
270
|
+
env: context.env
|
|
271
|
+
}, context.signal) : null,
|
|
272
|
+
hostedReachable
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
async function readWorkspaceLogs(context, options = {}) {
|
|
276
|
+
validateLogOptions(options);
|
|
277
|
+
const { view, readAgent } = await openWorkspaceLogs(context, options);
|
|
278
|
+
try {
|
|
279
|
+
return await view.query({
|
|
280
|
+
...options,
|
|
281
|
+
extra: await readAgent?.({
|
|
282
|
+
tail: options.tail,
|
|
283
|
+
matches: view.filter(options)
|
|
284
|
+
})
|
|
285
|
+
});
|
|
286
|
+
} finally {
|
|
287
|
+
await view.close();
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
function validateLogOptions(options) {
|
|
291
|
+
const invalid = (options.tail !== void 0 && (!Number.isSafeInteger(options.tail) || options.tail < 0) ? "tail must be a non-negative integer." : options.sources?.some((source) => !SOURCES.includes(source)) ? `sources must contain only ${SOURCES.join(", ")}.` : options.minLevel !== void 0 && !LEVELS.includes(options.minLevel) ? `minLevel must be one of ${LEVELS.join(", ")}.` : void 0) ?? (options.since !== void 0 ? parseSince(options.since).error : void 0) ?? (options.grep !== void 0 ? compileGrep(options.grep).error : void 0);
|
|
292
|
+
if (invalid) throw Object.assign(new Error(invalid), { code: "STIM_BAD_ARG" });
|
|
293
|
+
}
|
|
294
|
+
async function followWorkspaceLogs(context, options, onRecord, onBackfill) {
|
|
295
|
+
validateLogOptions(options);
|
|
296
|
+
const { view, readAgent, hostedReachable } = await openWorkspaceLogs(context, options, true);
|
|
297
|
+
try {
|
|
298
|
+
const query = {
|
|
299
|
+
...options,
|
|
300
|
+
extra: await readAgent?.({
|
|
301
|
+
tail: options.tail,
|
|
302
|
+
matches: view.filter(options)
|
|
303
|
+
})
|
|
304
|
+
};
|
|
305
|
+
if (onBackfill && options.tail === void 0) for await (const batch of view.batches(query)) {
|
|
306
|
+
await onBackfill(batch);
|
|
307
|
+
context.signal.throwIfAborted();
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
const records = await view.query(query);
|
|
311
|
+
context.signal.throwIfAborted();
|
|
312
|
+
if (onBackfill) await onBackfill(records);
|
|
313
|
+
else for (const record of records) onRecord(record);
|
|
314
|
+
}
|
|
315
|
+
} catch (error) {
|
|
316
|
+
await view.close();
|
|
317
|
+
throw error;
|
|
318
|
+
}
|
|
319
|
+
const criteria = buildCriteria(options);
|
|
320
|
+
const stopLog = followLogs({
|
|
321
|
+
dir: workspaceLogsDir$1(context.projectRoot),
|
|
322
|
+
offsets: view.sizes,
|
|
323
|
+
criteria,
|
|
324
|
+
onRecord,
|
|
325
|
+
errorContext: options.errorsOnly ? "field" : void 0
|
|
326
|
+
});
|
|
327
|
+
await view.close();
|
|
328
|
+
let readingAgent = false;
|
|
329
|
+
let stopped = false;
|
|
330
|
+
const agentTimer = readAgent ? setInterval(() => {
|
|
331
|
+
if (readingAgent || context.signal.aborted) return;
|
|
332
|
+
readingAgent = true;
|
|
333
|
+
readAgent().then((records) => {
|
|
334
|
+
for (const record of records) if (!stopped && !context.signal.aborted && recordMatches(record, criteria)) onRecord(record);
|
|
335
|
+
}, () => {}).finally(() => {
|
|
336
|
+
readingAgent = false;
|
|
337
|
+
});
|
|
338
|
+
}, 500) : null;
|
|
339
|
+
const stopHosted = followHostedLogs(context.projectRoot, !hostedReachable, context);
|
|
340
|
+
const stop = () => {
|
|
341
|
+
stopped = true;
|
|
342
|
+
stopLog();
|
|
343
|
+
stopHosted();
|
|
344
|
+
if (agentTimer) clearInterval(agentTimer);
|
|
345
|
+
context.signal.removeEventListener("abort", stop);
|
|
346
|
+
};
|
|
347
|
+
context.signal.addEventListener("abort", stop, { once: true });
|
|
348
|
+
if (context.signal.aborted) stop();
|
|
349
|
+
return stop;
|
|
350
|
+
}
|
|
351
|
+
//#endregion
|
|
352
|
+
export { followHostedLogs as i, openWorkspaceLogs as n, readWorkspaceLogs as r, followWorkspaceLogs as t };
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { m as workspaceLogsDir$1 } from "./paths-DQtTgsBf.mjs";
|
|
2
|
+
import { G as parseDeviceSlotOption, _ as loadConfig$1, g as isPathPrefix } from "./config-CYcBF478.mjs";
|
|
3
|
+
import { f as refuseNoProject, v as launchErrorPreview } from "./command-output-B1UrjZHL.mjs";
|
|
4
|
+
import { r as readWorkspaceState$1 } from "./workspace-state-Cjuigeeu.mjs";
|
|
5
|
+
import { n as findCommandWorkspace } from "./project-BZNjmW_8.mjs";
|
|
6
|
+
import { n as SOURCES$1, t as LEVELS$1 } from "./ndjson-CgE_o3Dl.mjs";
|
|
7
|
+
import { i as followHostedLogs, n as openWorkspaceLogs } from "./logs-BS00Anxf.mjs";
|
|
8
|
+
import { t as errorDiagnostics } from "./error-diagnostics-Bf0rZvG9.mjs";
|
|
9
|
+
import { t as watchStdoutReader } from "./stdout-reader-C8yjre1x.mjs";
|
|
10
|
+
import { realpathSync } from "node:fs";
|
|
11
|
+
import { relative, sep } from "node:path";
|
|
12
|
+
import { configDir } from "@stim-cli/core";
|
|
13
|
+
import { buildCriteria, compileGrep, followLogs, logFiles, parseSince, queryLogs, recordMatches, runId, sortByTs } from "@stim-cli/core/state";
|
|
14
|
+
import chalk from "chalk";
|
|
15
|
+
//#region src/commands/logs.ts
|
|
16
|
+
const LEVEL_WIDTH = 5;
|
|
17
|
+
const SRC_WIDTH = 6;
|
|
18
|
+
const INDENT = " ";
|
|
19
|
+
function padTimePart(value, width = 2) {
|
|
20
|
+
return String(value).padStart(width, "0");
|
|
21
|
+
}
|
|
22
|
+
function formatTime(ts) {
|
|
23
|
+
if (typeof ts !== "number" || !Number.isFinite(ts)) return "--:--:--.---";
|
|
24
|
+
const d = new Date(ts);
|
|
25
|
+
return `${padTimePart(d.getHours())}:${padTimePart(d.getMinutes())}:${padTimePart(d.getSeconds())}.${padTimePart(d.getMilliseconds(), 3)}`;
|
|
26
|
+
}
|
|
27
|
+
function formatStackFrame(frame) {
|
|
28
|
+
if (!frame || typeof frame !== "object") return null;
|
|
29
|
+
const where = [
|
|
30
|
+
frame.file,
|
|
31
|
+
frame.line,
|
|
32
|
+
frame.column
|
|
33
|
+
].filter((p) => p !== void 0 && p !== null && p !== "").join(":");
|
|
34
|
+
if (frame.fn && where) return `at ${frame.fn} (${where})`;
|
|
35
|
+
if (frame.fn) return `at ${frame.fn}`;
|
|
36
|
+
if (where) return `at ${where}`;
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
function formatRecord(record, { paint } = {}) {
|
|
40
|
+
const colour = paint || ((t) => t);
|
|
41
|
+
const level = String(record?.level ?? "").padEnd(LEVEL_WIDTH);
|
|
42
|
+
const src = String(record?.src ?? "").padEnd(SRC_WIDTH);
|
|
43
|
+
const [first, ...rest] = (record?.msg === void 0 || record?.msg === null ? "" : String(record.msg)).split("\n");
|
|
44
|
+
const lines = [`${formatTime(record?.ts)} ${colour(level)} ${src} ${first}`];
|
|
45
|
+
for (const line of rest) lines.push(`${INDENT}${line}`);
|
|
46
|
+
for (const frame of Array.isArray(record?.stack) ? record.stack : []) {
|
|
47
|
+
const rendered = formatStackFrame(frame);
|
|
48
|
+
if (rendered) lines.push(`${INDENT}${rendered}`);
|
|
49
|
+
}
|
|
50
|
+
return lines.join("\n");
|
|
51
|
+
}
|
|
52
|
+
function parseTail(value) {
|
|
53
|
+
if (typeof value === "number" && Number.isInteger(value) && value >= 0) return { n: value };
|
|
54
|
+
if (typeof value !== "string" || !/^\d+$/.test(value.trim())) return { error: `Invalid --tail value ${JSON.stringify(value)}. Use a non-negative whole number, e.g. --tail 50.` };
|
|
55
|
+
return { n: parseInt(value.trim(), 10) };
|
|
56
|
+
}
|
|
57
|
+
function validateSources(sources) {
|
|
58
|
+
if (sources === void 0 || sources === null) return { sources: void 0 };
|
|
59
|
+
const list = Array.isArray(sources) ? sources : [sources];
|
|
60
|
+
if (list.includes("all")) return { sources: [...SOURCES$1] };
|
|
61
|
+
const unknown = list.filter((s) => !SOURCES$1.includes(s));
|
|
62
|
+
if (unknown.length > 0) return { error: `Unknown --source value(s): ${unknown.join(", ")}. Use one or more of: ${SOURCES$1.join(", ")}, or all.` };
|
|
63
|
+
return { sources: list };
|
|
64
|
+
}
|
|
65
|
+
function validateLevel(level) {
|
|
66
|
+
if (LEVELS$1.includes(level)) return { level };
|
|
67
|
+
return { error: `Invalid --level value ${JSON.stringify(level)}. Use one of: ${LEVELS$1.join(", ")}.` };
|
|
68
|
+
}
|
|
69
|
+
const ERRORS_PRINT_CAP = 20;
|
|
70
|
+
function nearestRegisteredLogsProject(root, candidates) {
|
|
71
|
+
return candidates.filter((candidate) => candidate !== root && isPathPrefix(root, candidate)).toSorted((a, b) => {
|
|
72
|
+
const depth = (path) => relative(root, path).split(sep).length;
|
|
73
|
+
return depth(a) - depth(b) || a.length - b.length || a.localeCompare(b);
|
|
74
|
+
})[0] ?? null;
|
|
75
|
+
}
|
|
76
|
+
function registeredDescendantWithLogs(root) {
|
|
77
|
+
const candidates = Object.keys(loadConfig$1()?.projects ?? {}).flatMap((path) => {
|
|
78
|
+
try {
|
|
79
|
+
const canonical = realpathSync(path);
|
|
80
|
+
return logFiles(workspaceLogsDir$1(canonical)).length > 0 ? [canonical] : [];
|
|
81
|
+
} catch {
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return nearestRegisteredLogsProject(root, [...new Set(candidates)]);
|
|
86
|
+
}
|
|
87
|
+
function requireLogsWorkspace(root, dir) {
|
|
88
|
+
if (logFiles(dir).length > 0) return;
|
|
89
|
+
const descendant = registeredDescendantWithLogs(root);
|
|
90
|
+
fail(`STIM_NO_PROJECT: No Stim workspace has run in ${root}.${descendant ? ` The nearest registered app with logs is ${descendant}; run this command from there.` : " Run `stim start`, `stim ios`, or `stim android` in the app first."}`);
|
|
91
|
+
}
|
|
92
|
+
const LEVEL_COLOURS = {
|
|
93
|
+
debug: chalk.dim,
|
|
94
|
+
info: chalk.reset,
|
|
95
|
+
warn: chalk.yellow,
|
|
96
|
+
error: chalk.red,
|
|
97
|
+
fatal: chalk.bgRed
|
|
98
|
+
};
|
|
99
|
+
function logsCommand(program) {
|
|
100
|
+
program.command("logs").description("Query this workspace's merged NDJSON log timeline (bundler, client, device, build, agent actions, maintenance). Prints and exits; an existing timeline with nothing matching is a successful, empty result. Use --follow to stream.").option("--slot <name>", "Only this device slot's records, plus the shared Metro and app client records once it has launched", parseDeviceSlotOption).option("--source <s...>", "Only these sources: metro, client, device, build, agent, maintenance, placement, or all").option("--level <l>", `Minimum level: ${LEVELS$1.join(", ")}`).option("--since <d>", "Only records newer than this, e.g. 30s, 5m, 2h").option("--grep <re>", "Only records whose message matches this regular expression").option("--tail <n>", "Only the last n matching records").option("--errors", "Errors and fatals since the last marker, from metro, client and build, plus confirmed native app-crash reports and stim web browser errors. Add --source maintenance for maintenance failures, or --source device or --source all for general device errors.").option("--follow", "Keep streaming new records until interrupted").option("--json", "Emit the raw records, one per line (valid NDJSON; zero matches is zero bytes, exit 0)").action(async (opts) => {
|
|
101
|
+
const root = findCommandWorkspace(process.cwd());
|
|
102
|
+
if (!root) {
|
|
103
|
+
refuseNoProject({ json: false });
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const dir = workspaceLogsDir$1(root);
|
|
107
|
+
let sources;
|
|
108
|
+
if (opts.source !== void 0) {
|
|
109
|
+
const checked = validateSources(opts.source);
|
|
110
|
+
if (checked.error) fail(checked.error);
|
|
111
|
+
sources = checked.sources;
|
|
112
|
+
}
|
|
113
|
+
let minLevel;
|
|
114
|
+
if (opts.level !== void 0) {
|
|
115
|
+
const checked = validateLevel(opts.level);
|
|
116
|
+
if (checked.error) fail(checked.error);
|
|
117
|
+
minLevel = checked.level;
|
|
118
|
+
}
|
|
119
|
+
if (opts.since !== void 0) {
|
|
120
|
+
const parsed = parseSince(opts.since);
|
|
121
|
+
if (parsed.error) fail(parsed.error);
|
|
122
|
+
}
|
|
123
|
+
let tail;
|
|
124
|
+
if (opts.tail !== void 0) {
|
|
125
|
+
const parsed = parseTail(opts.tail);
|
|
126
|
+
if (parsed.error) fail(parsed.error);
|
|
127
|
+
tail = parsed.n;
|
|
128
|
+
}
|
|
129
|
+
if (opts.grep !== void 0) {
|
|
130
|
+
const compiled = compileGrep(opts.grep);
|
|
131
|
+
if (compiled.error) fail(compiled.error);
|
|
132
|
+
}
|
|
133
|
+
requireLogsWorkspace(root, dir);
|
|
134
|
+
const query = {
|
|
135
|
+
slot: opts.slot,
|
|
136
|
+
dir,
|
|
137
|
+
sources,
|
|
138
|
+
minLevel,
|
|
139
|
+
since: opts.since,
|
|
140
|
+
grep: opts.grep,
|
|
141
|
+
tail,
|
|
142
|
+
errorsOnly: Boolean(opts.errors),
|
|
143
|
+
errorContext: Boolean(opts.errors && !opts.json && !opts.follow)
|
|
144
|
+
};
|
|
145
|
+
const emit = (record) => {
|
|
146
|
+
if (opts.json) {
|
|
147
|
+
console.log(JSON.stringify(record));
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const rendered = {
|
|
151
|
+
...record,
|
|
152
|
+
msg: launchErrorPreview([record], root, { full: true }).join("\n"),
|
|
153
|
+
stack: void 0
|
|
154
|
+
};
|
|
155
|
+
console.log(formatRecord(rendered, { paint: record?.level ? LEVEL_COLOURS[record.level] : void 0 }));
|
|
156
|
+
};
|
|
157
|
+
const context = {
|
|
158
|
+
home: configDir(),
|
|
159
|
+
buildCache: null,
|
|
160
|
+
projectRoot: root,
|
|
161
|
+
cwd: root,
|
|
162
|
+
runId: runId(),
|
|
163
|
+
env: process.env,
|
|
164
|
+
signal: new AbortController().signal,
|
|
165
|
+
output: (stream, text) => process[stream].write(text)
|
|
166
|
+
};
|
|
167
|
+
const { view, readAgent, hostedReachable } = await openWorkspaceLogs(context, query, Boolean(opts.follow));
|
|
168
|
+
const offsets = opts.follow ? view.sizes : null;
|
|
169
|
+
let timeline = [];
|
|
170
|
+
let rawRecords;
|
|
171
|
+
try {
|
|
172
|
+
const extra = await readAgent?.(opts.json ? {
|
|
173
|
+
tail: query.tail,
|
|
174
|
+
matches: view.filter(query)
|
|
175
|
+
} : void 0) ?? [];
|
|
176
|
+
if (opts.json) rawRecords = await view.query({
|
|
177
|
+
...query,
|
|
178
|
+
extra
|
|
179
|
+
});
|
|
180
|
+
else {
|
|
181
|
+
timeline = sortByTs([...await view.query(), ...extra]);
|
|
182
|
+
rawRecords = queryLogs({
|
|
183
|
+
...query,
|
|
184
|
+
records: timeline
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
} finally {
|
|
188
|
+
await view.close();
|
|
189
|
+
}
|
|
190
|
+
const supervisorPort = readWorkspaceState$1(root)?.supervisor?.port;
|
|
191
|
+
const records = opts.json ? rawRecords : await errorDiagnostics(rawRecords, {
|
|
192
|
+
root,
|
|
193
|
+
logsDir: dir,
|
|
194
|
+
port: typeof supervisorPort === "number" ? supervisorPort : null,
|
|
195
|
+
allowRequest: true,
|
|
196
|
+
timeline
|
|
197
|
+
});
|
|
198
|
+
const errorCount = records.filter((record) => record.errorContext !== true).length;
|
|
199
|
+
let seenErrors = 0;
|
|
200
|
+
const capped = opts.errors && !opts.json && tail === void 0 && errorCount > 20 ? records.filter((record) => {
|
|
201
|
+
if (record.errorContext === true) return seenErrors <= 20;
|
|
202
|
+
seenErrors += 1;
|
|
203
|
+
return seenErrors <= 20;
|
|
204
|
+
}) : records;
|
|
205
|
+
for (const record of capped) emit(record);
|
|
206
|
+
const hidden = errorCount - capped.filter((record) => record.errorContext !== true).length;
|
|
207
|
+
if (hidden > 0) console.log(chalk.dim(`Showing 20 of ${errorCount} matching error records; ${hidden} not shown. Add --tail ${rawRecords.length} to include all captured records before grouping, or --json for raw records. Stacks are shown in full.`));
|
|
208
|
+
if (!opts.follow) {
|
|
209
|
+
if (records.length === 0 && !opts.json) console.error(chalk.dim(`No matching log records in ${dir}`));
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const criteria = buildCriteria({
|
|
213
|
+
slot: opts.slot,
|
|
214
|
+
sources,
|
|
215
|
+
minLevel,
|
|
216
|
+
since: opts.since,
|
|
217
|
+
grep: opts.grep,
|
|
218
|
+
errorsOnly: Boolean(opts.errors)
|
|
219
|
+
});
|
|
220
|
+
const stop = followLogs({
|
|
221
|
+
dir,
|
|
222
|
+
offsets,
|
|
223
|
+
criteria,
|
|
224
|
+
onRecord: emit,
|
|
225
|
+
errorContext: opts.errors ? opts.json ? "field" : "msg" : void 0
|
|
226
|
+
});
|
|
227
|
+
let readingAgent = false;
|
|
228
|
+
const agentTimer = readAgent ? setInterval(() => {
|
|
229
|
+
if (readingAgent) return;
|
|
230
|
+
readingAgent = true;
|
|
231
|
+
readAgent().then((actions) => {
|
|
232
|
+
for (const record of actions) if (recordMatches(record, criteria)) emit(record);
|
|
233
|
+
}, () => {}).finally(() => {
|
|
234
|
+
readingAgent = false;
|
|
235
|
+
});
|
|
236
|
+
}, 500) : null;
|
|
237
|
+
const stopHosted = followHostedLogs(root, !hostedReachable);
|
|
238
|
+
const finish = () => {
|
|
239
|
+
stop();
|
|
240
|
+
stopHosted?.();
|
|
241
|
+
stopReader();
|
|
242
|
+
if (agentTimer) clearInterval(agentTimer);
|
|
243
|
+
process.exit(0);
|
|
244
|
+
};
|
|
245
|
+
const stopReader = watchStdoutReader(finish);
|
|
246
|
+
process.on("SIGINT", finish);
|
|
247
|
+
process.on("SIGTERM", finish);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
function fail(message) {
|
|
251
|
+
console.error(chalk.red(message));
|
|
252
|
+
process.exit(1);
|
|
253
|
+
}
|
|
254
|
+
//#endregion
|
|
255
|
+
export { ERRORS_PRINT_CAP, logsCommand as default, formatRecord, formatStackFrame, formatTime, parseTail, validateLevel, validateSources };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as runMacos, r as waitForLaunchServices, t as macosCommand } from "./macos-
|
|
1
|
+
import { n as runMacos, r as waitForLaunchServices, t as macosCommand } from "./macos-C-0qJ6zq.mjs";
|
|
2
2
|
export { macosCommand as default, runMacos, waitForLaunchServices };
|