@indigoai-us/hq-cli 5.345.215-beta.0 → 5.345.217

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/CHANGELOG.md +206 -1
  2. package/README.md +45 -0
  3. package/assets/scaffold/core/scripts/hq-delegate-verify.sh +5 -2
  4. package/assets/scaffold/core/scripts/lib/epochrealtime.sh +30 -0
  5. package/assets/scaffold/core/scripts/lib/work-mesh-enqueue.sh +12 -5
  6. package/dist/command-catalog.generated.d.ts +105 -10
  7. package/dist/command-catalog.generated.js +127 -10
  8. package/dist/command-help.js +3 -1
  9. package/dist/command-registration-plan.d.ts +6 -0
  10. package/dist/command-registration-plan.js +1 -0
  11. package/dist/commands/auth.d.ts +1 -1
  12. package/dist/commands/auth.js +11 -52
  13. package/dist/commands/bot.js +75 -10
  14. package/dist/commands/capacity.d.ts +4 -1
  15. package/dist/commands/capacity.js +46 -10
  16. package/dist/commands/cloud-demote.d.ts +19 -4
  17. package/dist/commands/cloud-demote.js +85 -12
  18. package/dist/commands/cloud-provision.d.ts +5 -1
  19. package/dist/commands/cloud-provision.js +6 -2
  20. package/dist/commands/cloud.d.ts +36 -0
  21. package/dist/commands/cloud.js +110 -27
  22. package/dist/commands/core-delegate-w1b.js +15 -1
  23. package/dist/commands/core-policy.js +67 -8
  24. package/dist/commands/core.js +1 -0
  25. package/dist/commands/daemon.js +9 -1
  26. package/dist/commands/dm.js +7 -0
  27. package/dist/commands/doctor-usage.d.ts +8 -0
  28. package/dist/commands/doctor-usage.js +20 -0
  29. package/dist/commands/doctor.js +7 -1
  30. package/dist/commands/env.d.ts +18 -0
  31. package/dist/commands/env.js +82 -0
  32. package/dist/commands/files-browse.d.ts +11 -4
  33. package/dist/commands/files-browse.js +21 -4
  34. package/dist/commands/files.d.ts +1 -1
  35. package/dist/commands/files.js +25 -11
  36. package/dist/commands/install-global.js +2 -2
  37. package/dist/commands/integrations-auth-rules.d.ts +27 -0
  38. package/dist/commands/integrations-auth-rules.js +79 -0
  39. package/dist/commands/integrations-import.js +124 -12
  40. package/dist/commands/lanes.js +102 -26
  41. package/dist/commands/logout.d.ts +7 -0
  42. package/dist/commands/logout.js +41 -34
  43. package/dist/commands/mesh.d.ts +2 -0
  44. package/dist/commands/mesh.js +60 -35
  45. package/dist/commands/sources.d.ts +8 -2
  46. package/dist/commands/sources.js +65 -9
  47. package/dist/commands/sync-held.js +5 -2
  48. package/dist/commands/whoami.js +26 -1
  49. package/dist/data/command-states.json +15 -0
  50. package/dist/index.js +52 -4
  51. package/dist/lazy-commands.js +5 -6
  52. package/dist/lib/anywhere-person-setting.d.ts +2 -0
  53. package/dist/lib/anywhere-person-setting.js +6 -3
  54. package/dist/lib/billing/usage-card.d.ts +25 -4
  55. package/dist/lib/billing/usage-card.js +76 -9
  56. package/dist/lib/billing/usage-cost.d.ts +3 -3
  57. package/dist/lib/billing/usage-cost.js +35 -13
  58. package/dist/lib/billing/usage-only.js +4 -2
  59. package/dist/lib/billing/usage-rate-card.d.ts +2 -2
  60. package/dist/lib/billing/usage-rate-card.js +3 -0
  61. package/dist/lib/bot/fleet-cron.d.ts +8 -0
  62. package/dist/lib/bot/fleet-cron.js +126 -7
  63. package/dist/lib/bot/fleet-daemon.d.ts +46 -0
  64. package/dist/lib/bot/fleet-daemon.js +99 -1
  65. package/dist/lib/bot/inflight.d.ts +9 -0
  66. package/dist/lib/bot/inflight.js +10 -0
  67. package/dist/lib/bot/jobs/hot-signal-sync.js +12 -1
  68. package/dist/lib/bot/probe.js +7 -1
  69. package/dist/lib/bot/run.js +20 -1
  70. package/dist/lib/bot/runtime/codex.js +1 -1
  71. package/dist/lib/bot/runtime/grok-acp.d.ts +6 -1
  72. package/dist/lib/bot/runtime/grok-acp.js +32 -14
  73. package/dist/lib/bot/runtime/grok.js +1 -1
  74. package/dist/lib/bot/runtime/index.js +19 -9
  75. package/dist/lib/bot/runtime/messages-stream.js +2 -2
  76. package/dist/lib/bot/runtime/types.d.ts +15 -0
  77. package/dist/lib/bot/runtime/types.js +9 -0
  78. package/dist/lib/bot/runtime-failure.d.ts +23 -0
  79. package/dist/lib/bot/runtime-failure.js +43 -1
  80. package/dist/lib/capacity/accounts.d.ts +8 -0
  81. package/dist/lib/capacity/accounts.js +19 -0
  82. package/dist/lib/capacity/available.d.ts +154 -0
  83. package/dist/lib/capacity/available.js +905 -0
  84. package/dist/lib/capacity/codex-availability.d.ts +14 -1
  85. package/dist/lib/capacity/codex-availability.js +26 -1
  86. package/dist/lib/capacity/collectors/claude-oauth.d.ts +29 -2
  87. package/dist/lib/capacity/collectors/claude-oauth.js +104 -7
  88. package/dist/lib/capacity/collectors/codex.js +10 -7
  89. package/dist/lib/capacity/ledger.d.ts +37 -1
  90. package/dist/lib/capacity/ledger.js +207 -30
  91. package/dist/lib/capacity/project.d.ts +26 -0
  92. package/dist/lib/capacity/project.js +137 -8
  93. package/dist/lib/capacity/refusal-rows.d.ts +31 -0
  94. package/dist/lib/capacity/refusal-rows.js +61 -0
  95. package/dist/lib/capacity/refusal.d.ts +53 -2
  96. package/dist/lib/capacity/refusal.js +284 -65
  97. package/dist/lib/capacity/route.js +46 -11
  98. package/dist/lib/capacity/widget.d.ts +12 -1
  99. package/dist/lib/capacity/widget.js +91 -3
  100. package/dist/lib/daemon/flag-monitor.d.ts +8 -0
  101. package/dist/lib/daemon/flag-monitor.js +17 -6
  102. package/dist/lib/daemon/flag.d.ts +65 -1
  103. package/dist/lib/daemon/flag.js +190 -40
  104. package/dist/lib/daemon/ops/policy.js +62 -5
  105. package/dist/lib/daemon/paths.d.ts +72 -2
  106. package/dist/lib/daemon/paths.js +154 -3
  107. package/dist/lib/daemon/resolver.d.ts +2 -0
  108. package/dist/lib/daemon/resolver.js +3 -0
  109. package/dist/lib/daemon/run.d.ts +9 -0
  110. package/dist/lib/daemon/run.js +79 -21
  111. package/dist/lib/daemon/selfcheck.d.ts +22 -0
  112. package/dist/lib/daemon/selfcheck.js +40 -1
  113. package/dist/lib/daemon/server.d.ts +5 -1
  114. package/dist/lib/daemon/server.js +17 -23
  115. package/dist/lib/daemon/state-file-switch.d.ts +57 -0
  116. package/dist/lib/daemon/state-file-switch.js +88 -0
  117. package/dist/lib/daemon/state-file.d.ts +198 -0
  118. package/dist/lib/daemon/state-file.js +419 -0
  119. package/dist/lib/daemon/tcc-eperm.d.ts +153 -0
  120. package/dist/lib/daemon/tcc-eperm.js +310 -0
  121. package/dist/lib/daemon/timed-flag-monitors.d.ts +47 -0
  122. package/dist/lib/daemon/timed-flag-monitors.js +75 -0
  123. package/dist/lib/delivery/admission.d.ts +86 -0
  124. package/dist/lib/delivery/admission.js +148 -0
  125. package/dist/lib/delivery/artifacts.d.ts +7 -1
  126. package/dist/lib/delivery/artifacts.js +29 -10
  127. package/dist/lib/delivery/attempt-id.d.ts +13 -0
  128. package/dist/lib/delivery/attempt-id.js +16 -0
  129. package/dist/lib/delivery/disposable-target.d.ts +42 -0
  130. package/dist/lib/delivery/disposable-target.js +111 -0
  131. package/dist/lib/delivery/effects.d.ts +136 -0
  132. package/dist/lib/delivery/effects.js +541 -0
  133. package/dist/lib/delivery/enrollment.d.ts +21 -17
  134. package/dist/lib/delivery/enrollment.js +83 -5
  135. package/dist/lib/delivery/escalations.d.ts +51 -0
  136. package/dist/lib/delivery/escalations.js +60 -0
  137. package/dist/lib/delivery/lease.d.ts +80 -0
  138. package/dist/lib/delivery/lease.js +134 -0
  139. package/dist/lib/delivery/migrations.d.ts +120 -4
  140. package/dist/lib/delivery/migrations.js +215 -15
  141. package/dist/lib/delivery/mqtt.d.ts +2 -0
  142. package/dist/lib/delivery/mqtt.js +7 -0
  143. package/dist/lib/delivery/reconciler.d.ts +65 -1
  144. package/dist/lib/delivery/reconciler.js +224 -13
  145. package/dist/lib/delivery/rpc/client.d.ts +22 -0
  146. package/dist/lib/delivery/rpc/client.js +159 -0
  147. package/dist/lib/delivery/rpc/port.d.ts +40 -0
  148. package/dist/lib/delivery/rpc/port.js +16 -0
  149. package/dist/lib/delivery/rpc/server.d.ts +30 -0
  150. package/dist/lib/delivery/rpc/server.js +205 -0
  151. package/dist/lib/delivery/rpc/wire.d.ts +85 -0
  152. package/dist/lib/delivery/rpc/wire.js +143 -0
  153. package/dist/lib/delivery/store.d.ts +2 -0
  154. package/dist/lib/delivery/store.js +4 -0
  155. package/dist/lib/delivery/windows-service-install.d.ts +262 -0
  156. package/dist/lib/delivery/windows-service-install.js +892 -0
  157. package/dist/lib/delivery/workers/macos.d.ts +16 -1
  158. package/dist/lib/delivery/workers/macos.js +54 -12
  159. package/dist/lib/delivery/workers/windows-service-live.d.ts +121 -0
  160. package/dist/lib/delivery/workers/windows-service-live.js +711 -0
  161. package/dist/lib/delivery/workers/windows-service-runner.d.ts +33 -0
  162. package/dist/lib/delivery/workers/windows-service-runner.js +82 -0
  163. package/dist/lib/delivery/workers/windows-service.d.ts +140 -0
  164. package/dist/lib/delivery/workers/windows-service.js +584 -0
  165. package/dist/lib/delivery/workers/windows.d.ts +32 -22
  166. package/dist/lib/delivery/workers/windows.js +50 -64
  167. package/dist/lib/doctor/checks/host-core.d.ts +50 -0
  168. package/dist/lib/doctor/checks/host-core.js +269 -0
  169. package/dist/lib/doctor/checks/replay-recorder.d.ts +39 -0
  170. package/dist/lib/doctor/checks/replay-recorder.js +261 -0
  171. package/dist/lib/doctor/registry.js +4 -0
  172. package/dist/lib/environment/profile.d.ts +239 -0
  173. package/dist/lib/environment/profile.js +251 -0
  174. package/dist/lib/hook-engine/reconcile.js +39 -13
  175. package/dist/lib/hook-engine/registration.d.ts +9 -0
  176. package/dist/lib/hook-engine/registration.js +19 -0
  177. package/dist/lib/hot-channels/adapters/meetings.d.ts +15 -0
  178. package/dist/lib/hot-channels/adapters/meetings.js +36 -3
  179. package/dist/lib/hot-channels/adapters/slack.d.ts +21 -5
  180. package/dist/lib/hot-channels/adapters/slack.js +64 -21
  181. package/dist/lib/hot-channels/alert.d.ts +2 -0
  182. package/dist/lib/hot-channels/alert.js +8 -1
  183. package/dist/lib/hot-channels/contract.d.ts +12 -0
  184. package/dist/lib/hot-channels/contract.js +7 -0
  185. package/dist/lib/hot-channels/loop.js +1 -0
  186. package/dist/lib/hot-channels/run.d.ts +6 -0
  187. package/dist/lib/hot-channels/run.js +4 -0
  188. package/dist/lib/hot-channels/signals-pass.d.ts +74 -1
  189. package/dist/lib/hot-channels/signals-pass.js +82 -41
  190. package/dist/lib/hot-channels/signals-redo.js +10 -2
  191. package/dist/lib/install/claude-targets.d.ts +12 -1
  192. package/dist/lib/install/claude-targets.js +57 -5
  193. package/dist/lib/install/codex-targets.d.ts +2 -2
  194. package/dist/lib/install/codex-targets.js +36 -6
  195. package/dist/lib/install/hook-target.d.ts +3 -0
  196. package/dist/lib/install/hook-target.js +11 -0
  197. package/dist/lib/lanes/canonical-host.d.ts +35 -0
  198. package/dist/lib/lanes/canonical-host.js +65 -0
  199. package/dist/lib/lanes/host-capacity.d.ts +30 -0
  200. package/dist/lib/lanes/host-capacity.js +29 -3
  201. package/dist/lib/lanes/watcher.js +35 -0
  202. package/dist/lib/mesh/live/daemon/run.d.ts +2 -0
  203. package/dist/lib/mesh/live/daemon/run.js +5 -2
  204. package/dist/lib/mesh/live/flush.d.ts +5 -1
  205. package/dist/lib/mesh/live/flush.js +12 -6
  206. package/dist/lib/mesh/live/reporting-privacy.d.ts +32 -0
  207. package/dist/lib/mesh/live/reporting-privacy.js +56 -1
  208. package/dist/lib/mesh/live/spool.d.ts +7 -0
  209. package/dist/lib/mesh/live/spool.js +25 -0
  210. package/dist/lib/person-setting-cache.d.ts +38 -0
  211. package/dist/lib/person-setting-cache.js +98 -0
  212. package/dist/lib/safe-store.d.ts +245 -0
  213. package/dist/lib/safe-store.js +777 -0
  214. package/dist/lib/signals/engine.d.ts +29 -2
  215. package/dist/lib/signals/engine.js +103 -4
  216. package/dist/lib/signals/reply.js +73 -18
  217. package/dist/lib/signals/steps/adapters.js +7 -2
  218. package/dist/lib/signals/steps/extract.d.ts +13 -0
  219. package/dist/lib/signals/steps/extract.js +122 -6
  220. package/dist/main.js +46 -3
  221. package/dist/schemas/hq-available-ai.v1.schema.json +76 -0
  222. package/dist/schemas/hq-environment-profile.v1.schema.json +438 -0
  223. package/dist/utils/auth-expiry.d.ts +8 -0
  224. package/dist/utils/auth-expiry.js +53 -0
  225. package/dist/utils/catalog-runtime-paths.d.ts +34 -0
  226. package/dist/utils/catalog-runtime-paths.js +53 -0
  227. package/dist/utils/cli-telemetry.d.ts +21 -0
  228. package/dist/utils/cli-telemetry.js +34 -0
  229. package/dist/utils/command-usage.d.ts +275 -0
  230. package/dist/utils/command-usage.js +797 -0
  231. package/dist/utils/files-browse-acl.js +1 -1
  232. package/dist/utils/hook-trust.d.ts +7 -0
  233. package/dist/utils/hook-trust.js +31 -4
  234. package/dist/utils/host-registration.d.ts +126 -0
  235. package/dist/utils/host-registration.js +378 -0
  236. package/dist/utils/resident-package-preload.js +2 -0
  237. package/package.json +10 -8
  238. package/scripts/bench-core.mjs +1096 -0
  239. package/scripts/check-function-manifest.mjs +702 -0
  240. package/dist/lib/delivery/workers/windows-boundary.d.ts +0 -453
  241. package/dist/lib/delivery/workers/windows-boundary.js +0 -693
@@ -0,0 +1,892 @@
1
+ /**
2
+ * Installer and rollback for the US-006 service pilot (proposal 040).
3
+ *
4
+ * Usage (bundled to us006-service.mjs by scripts/windows/build-us006-service.mjs):
5
+ * node us006-service.mjs install --stage <dir> [--pilot-unsigned-wrapper] [--apply] (wrapper pinned in WRAPPER_PIN)
6
+ * node us006-service.mjs rollback [--apply]
7
+ * Without --apply nothing on the host changes: the exact steps are printed.
8
+ * --apply runs only on Windows, from an elevated prompt, and stops at the
9
+ * first failed step.
10
+ *
11
+ * Footprint: one manual-start service running as its own virtual account
12
+ * (no password), one directory under C:\ProgramData. No port, scheduled task,
13
+ * autostart, user account, LSA right or vault secret. Built-in tools only
14
+ * (sc.exe, icacls.exe, csc.exe); the service wrapper (WinSW) is supplied by
15
+ * the operator in the stage directory and pinned by sha256.
16
+ */
17
+ import { spawnSync } from "node:child_process";
18
+ import { createHash } from "node:crypto";
19
+ import { closeSync, copyFileSync, existsSync, lstatSync, mkdirSync, openSync, readdirSync, readFileSync, rmdirSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
20
+ import { join } from "node:path";
21
+ import { HELPER_SOURCE } from "./workers/windows-job-helper.js";
22
+ import { MANIFEST_VERSION } from "./workers/windows-service-runner.js";
23
+ import { PILOT040, serviceSidFor, SPOOL_DIRS } from "./workers/windows-service.js";
24
+ /**
25
+ * The approved service wrapper, pinned in the repo (review 040).
26
+ *
27
+ * sha256: WinSW-x64.exe v2.12.0, 18,243,033 bytes.
28
+ *
29
+ * signer: empty. The file has no Authenticode signature (its PE security
30
+ * directory is empty; Get-AuthenticodeSignature on Beaker reports NotSigned),
31
+ * so there is no subject to pin.
32
+ *
33
+ * unsignedAccepted: owner decision 2026-11-10, "Hash-only, Beaker test only".
34
+ * This one sha256 may be installed unsigned, for the pilot service and root
35
+ * only, and only when the operator passes --pilot-unsigned-wrapper. The hash
36
+ * check stays. It is not approved for any customer or production machine and
37
+ * must not be copied to another pin.
38
+ */
39
+ export const WRAPPER_PIN = {
40
+ file: "winsw.exe",
41
+ sha256: "05b82d46ad331cc16bdc00de5c6332c1ef818df8ceefcd49c726553209b3a0da",
42
+ signer: "",
43
+ unsignedAccepted: {
44
+ sha256: "05b82d46ad331cc16bdc00de5c6332c1ef818df8ceefcd49c726553209b3a0da",
45
+ service: "HQNDUS006040",
46
+ root: "C:\\ProgramData\\HQNativeDelivery-US006-040",
47
+ decision: "owner decision 2026-11-10 (Hash-only, Beaker test only): accepted unsigned for this one test in the Beaker pilot, by sha256 only. Not approved for any customer or production machine.",
48
+ },
49
+ };
50
+ export const PILOT_UNSIGNED_FLAG = "--pilot-unsigned-wrapper";
51
+ /** True when the pin has no signer and its acceptance marker covers exactly its own sha256. */
52
+ function unsignedMarked(pin) {
53
+ return pin.signer.trim() === "" && pin.unsignedAccepted !== undefined && pin.unsignedAccepted.sha256 === pin.sha256;
54
+ }
55
+ /**
56
+ * Why a pin cannot be used, or null. The sha256 is always required. The
57
+ * signer subject is required too, except for the one file marked accepted
58
+ * unsigned, and then only for the pilot names with the explicit flag.
59
+ */
60
+ export function pinProblem(pin, use) {
61
+ if (!/^[0-9a-f]{64}$/.test(pin.sha256))
62
+ return "the service wrapper has no pinned sha256 (WRAPPER_PIN); the owner must approve the file and a reviewed commit must record its sha256";
63
+ if (pin.signer.trim() !== "")
64
+ return null;
65
+ if (!unsignedMarked(pin))
66
+ return "the pinned service wrapper has no signer subject (WRAPPER_PIN.signer) and is not marked accepted unsigned, so install stops";
67
+ const ok = pin.unsignedAccepted;
68
+ if (!use || use.service !== ok.service || use.root !== ok.root)
69
+ return `the pinned service wrapper has no signer subject; it is accepted unsigned only for service ${ok.service} at ${ok.root} (${ok.decision})`;
70
+ if (!use.pilotUnsignedWrapper)
71
+ return `the pinned service wrapper has no signer subject; it is accepted unsigned only for the Beaker pilot and only with ${PILOT_UNSIGNED_FLAG} (${ok.decision})`;
72
+ return null;
73
+ }
74
+ /**
75
+ * sha256 of the runner.mjs built next to this installer. The build script
76
+ * (scripts/windows/build-us006-service.mjs) builds runner.mjs first and
77
+ * compiles its hash in here. Run from source it is empty, and install refuses.
78
+ */
79
+ export const BUNDLED_RUNNER_SHA256 = typeof __US006_RUNNER_SHA256__ === "string" ? __US006_RUNNER_SHA256__ : "";
80
+ function runnerPinProblem(sha256) {
81
+ return /^[0-9a-f]{64}$/.test(sha256) ? null : "this installer carries no runner.mjs sha256; use the us006-service.mjs written by scripts/windows/build-us006-service.mjs together with its runner.mjs";
82
+ }
83
+ /**
84
+ * sha256 of the reviewed job helper source. The .NET Framework csc.exe does
85
+ * not build deterministically, so the source, not the exe, is pinned; the
86
+ * built exe's hash is recorded in the manifest and checked on every launch.
87
+ */
88
+ export const HELPER_SOURCE_SHA256 = "b61e7ab7148b90e172086621cb5271099788fdb774b89dce06d89edbb92e0038";
89
+ const ADMINS_NAME = "BUILTIN\\Administrators";
90
+ const SYSTEM = "*S-1-5-18";
91
+ const ADMINS = "*S-1-5-32-544";
92
+ export function validateNames(n) {
93
+ if (!/^HQND[A-Z0-9]{4,20}$/.test(n.service))
94
+ return "service name must be HQND followed by 4 to 20 upper-case letters or digits";
95
+ if (!/^C:\\ProgramData\\HQNativeDelivery-[A-Za-z0-9-]{1,40}$/.test(n.root))
96
+ return "root must be C:\\ProgramData\\HQNativeDelivery-<name>";
97
+ return null;
98
+ }
99
+ function win(...parts) {
100
+ return parts.join("\\");
101
+ }
102
+ export function systemTools(systemRoot = "C:\\Windows") {
103
+ return {
104
+ sc: win(systemRoot, "System32", "sc.exe"),
105
+ icacls: win(systemRoot, "System32", "icacls.exe"),
106
+ reg: win(systemRoot, "System32", "reg.exe"),
107
+ tasklist: win(systemRoot, "System32", "tasklist.exe"),
108
+ csc: win(systemRoot, "Microsoft.NET", "Framework64", "v4.0.30319", "csc.exe"),
109
+ powershell: win(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
110
+ };
111
+ }
112
+ /** The WinSW service definition. Manual start, no recovery actions, logs under logs. */
113
+ export function wrapperXml(n) {
114
+ const esc = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
115
+ return [
116
+ "<service>",
117
+ ` <id>${esc(n.service)}</id>`,
118
+ ` <name>${esc(n.service)}</name>`,
119
+ " <description>HQ native delivery US-006 pilot runner (proposal 040). Manual start only.</description>",
120
+ ` <executable>${esc(win(n.root, "runtime", "node.exe"))}</executable>`,
121
+ ` <arguments>"${esc(win(n.root, "bin", "runner.mjs"))}" --root "${esc(n.root)}"</arguments>`,
122
+ ` <workingdirectory>${esc(win(n.root, "bin"))}</workingdirectory>`,
123
+ " <startmode>Manual</startmode>",
124
+ " <onfailure action=\"none\" />",
125
+ " <stoptimeout>20 sec</stoptimeout>",
126
+ ` <log mode="roll-by-size"><logpath>${esc(win(n.root, "logs"))}</logpath><sizeThreshold>10240</sizeThreshold><keepFiles>4</keepFiles></log>`,
127
+ "</service>",
128
+ "",
129
+ ].join("\n");
130
+ }
131
+ export function installPlan(input) {
132
+ const n = { service: input.service, root: input.root };
133
+ const t = systemTools(input.systemRoot);
134
+ const sid = `*${serviceSidFor(n.service)}`;
135
+ const account = `NT SERVICE\\${n.service}`;
136
+ const bin = win(n.root, "bin");
137
+ const wrapper = input.wrapper ?? WRAPPER_PIN;
138
+ const ps = (s) => s.replace(/'/g, "''");
139
+ const problem = pinProblem(wrapper, { ...n, pilotUnsignedWrapper: input.pilotUnsignedWrapper });
140
+ if (problem)
141
+ throw new Error(`refused: ${problem}`);
142
+ const runnerSha256 = input.runnerSha256 ?? BUNDLED_RUNNER_SHA256;
143
+ const runnerProblem = runnerPinProblem(runnerSha256);
144
+ if (runnerProblem)
145
+ throw new Error(`refused: ${runnerProblem}`);
146
+ // Reached with an empty signer only for the one marked file, the pilot names and the explicit flag.
147
+ const unsigned = unsignedMarked(wrapper) ? wrapper.unsignedAccepted : undefined;
148
+ const stagedWrapper = win(input.stage, "winsw.exe");
149
+ const signatureStep = unsigned
150
+ ? {
151
+ kind: "check",
152
+ label: `record the wrapper's Authenticode status (unsigned, accepted by ${unsigned.decision}); the signer check is dropped for this file only`,
153
+ file: t.powershell,
154
+ args: ["-NoProfile", "-NonInteractive", "-Command", `$s = Get-AuthenticodeSignature -LiteralPath '${ps(stagedWrapper)}'; Write-Output ('wrapper Authenticode status: ' + $s.Status); exit 0`],
155
+ expect: "exit0",
156
+ }
157
+ : {
158
+ kind: "check",
159
+ label: "staged wrapper has a valid Authenticode signature from the pinned signer",
160
+ file: t.powershell,
161
+ args: [
162
+ "-NoProfile",
163
+ "-NonInteractive",
164
+ "-Command",
165
+ `$s = Get-AuthenticodeSignature -LiteralPath '${ps(stagedWrapper)}'; if ($s.Status -ne 'Valid') { exit 1 }; if ($s.SignerCertificate.Subject -ne '${ps(wrapper.signer)}') { exit 2 }`,
166
+ ],
167
+ expect: "exit0",
168
+ };
169
+ const manifestWrapper = unsigned
170
+ ? { sha256: wrapper.sha256, signed: false, signer: "", acceptedUnsigned: unsigned.decision }
171
+ : { sha256: wrapper.sha256, signed: true, signer: wrapper.signer };
172
+ const steps = [
173
+ { kind: "check", label: "service name is unused", file: t.sc, args: ["query", n.service], expect: "absent-service" },
174
+ { kind: "refuse-if-present", label: "pilot root does not exist yet", path: n.root },
175
+ {
176
+ kind: "refuse-if-service-profile",
177
+ label: "no service profile left from a previous run",
178
+ path: win(input.systemRoot ?? "C:\\Windows", "ServiceProfiles", n.service),
179
+ key: `HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\${serviceSidFor(n.service)}`,
180
+ reg: t.reg,
181
+ },
182
+ { kind: "check", label: "record Windows edition", file: t.reg, args: ["query", "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "/v", "EditionID"], expect: "exit0" },
183
+ { kind: "check", label: "record Windows build", file: t.reg, args: ["query", "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "/v", "CurrentBuild"], expect: "exit0" },
184
+ { kind: "refuse-if-absent", label: "C# compiler present", path: t.csc },
185
+ { kind: "refuse-if-absent", label: "staged wrapper present", path: win(input.stage, "winsw.exe") },
186
+ { kind: "refuse-if-sha256", label: "staged wrapper matches the approved sha256", path: win(input.stage, "winsw.exe"), sha256: wrapper.sha256 },
187
+ signatureStep,
188
+ { kind: "refuse-if-absent", label: "staged runner present", path: win(input.stage, "runner.mjs") },
189
+ { kind: "refuse-if-sha256", label: "staged runner matches the sha256 built into this installer", path: win(input.stage, "runner.mjs"), sha256: runnerSha256 },
190
+ // Nothing in the stage folder is executed: node.exe is copied and asked for its version only from the protected root.
191
+ { kind: "refuse-if-absent", label: "staged node.exe present", path: win(input.stage, "node.exe") },
192
+ { kind: "mkdir", label: "create pilot root", path: n.root },
193
+ { kind: "exec", label: "root: owner Administrators", file: t.icacls, args: [n.root, "/setowner", ADMINS] },
194
+ // The per-service SID (NT SERVICE\<name>) only resolves once the service exists: icacls looked it up and failed
195
+ // with 1332 on Beaker (2026-11-10) when the ACLs came first. So the service is created here, before the first
196
+ // ACL that names its SID. The account is set in the same call, so it is never LocalSystem; start is manual,
197
+ // nothing in the installer starts it, and its binary does not exist yet. Privileges and recovery are fixed at once.
198
+ { kind: "exec", label: "create the service as its virtual account, manual start", file: t.sc, args: ["create", n.service, "binPath=", win(bin, `${n.service}.exe`), "start=", "demand", "obj=", account, "DisplayName=", n.service] },
199
+ { kind: "exec", label: "required privileges: SeChangeNotifyPrivilege only", file: t.sc, args: ["privs", n.service, "SeChangeNotifyPrivilege"] },
200
+ { kind: "exec", label: "no recovery actions", file: t.sc, args: ["failure", n.service, "reset=", "0", "actions=", ""] },
201
+ { kind: "exec", label: "root: protected DACL, SYSTEM and Administrators full, service read", file: t.icacls, args: [n.root, "/inheritance:r", "/grant:r", `${SYSTEM}:(OI)(CI)F`, `${ADMINS}:(OI)(CI)F`, `${sid}:(RX)`] },
202
+ { kind: "verify-new-root", label: "verify new root", path: n.root },
203
+ ];
204
+ for (const d of ["bin", "runtime", "config", ...SPOOL_DIRS]) {
205
+ const path = win(n.root, d);
206
+ const mask = d === "state" || d === "logs" || d === "runs" ? "M" : "RX";
207
+ steps.push({ kind: "mkdir", label: `create ${d}`, path });
208
+ steps.push({ kind: "exec", label: `${d}: service ${mask === "M" ? "modify" : "read"}`, file: t.icacls, args: [path, "/grant:r", `${sid}:(OI)(CI)${mask}`] });
209
+ }
210
+ steps.push({ kind: "copy", label: "install wrapper", from: win(input.stage, "winsw.exe"), to: win(bin, `${n.service}.exe`) },
211
+ // The stage folder may be writable by others; the pin has to hold for the copy under the protected root, which is the file that runs.
212
+ { kind: "refuse-if-sha256", label: "installed wrapper matches the approved sha256", path: win(bin, `${n.service}.exe`), sha256: wrapper.sha256 }, { kind: "write", label: "write wrapper definition", path: win(bin, `${n.service}.xml`), content: wrapperXml(n) }, { kind: "copy", label: "install runner", from: win(input.stage, "runner.mjs"), to: win(bin, "runner.mjs") }, { kind: "refuse-if-sha256", label: "installed runner matches the sha256 built into this installer", path: win(bin, "runner.mjs"), sha256: runnerSha256 }, { kind: "copy", label: "install pinned node.exe", from: win(input.stage, "node.exe"), to: win(n.root, "runtime", "node.exe") }, { kind: "refuse-if-helper-source-changed", label: "helper source matches the reviewed sha256" }, { kind: "write", label: "stage job helper source", path: win(bin, "hqjob.cs"), content: HELPER_SOURCE }, { kind: "exec", label: "build job helper", file: t.csc, args: ["/nologo", "/target:exe", "/platform:anycpu", "/optimize+", `/out:${win(bin, "hqjob.exe")}`, win(bin, "hqjob.cs")] }, { kind: "remove", label: "remove job helper source", path: win(bin, "hqjob.cs") }, { kind: "check", label: "job helper self test", file: win(bin, "hqjob.exe"), args: ["--selftest"], expect: "exit0" }, { kind: "manifest", label: "write manifest", path: win(n.root, "config", "manifest.json"), files: [`bin/${n.service}.exe`, `bin/${n.service}.xml`, "bin/runner.mjs", "bin/hqjob.exe", "runtime/node.exe"], wrapper: manifestWrapper, expect: { [`bin/${n.service}.exe`]: wrapper.sha256, "bin/runner.mjs": runnerSha256 } }, { kind: "exec", label: "confirm manual start, virtual account", file: t.sc, args: ["config", n.service, "start=", "demand", "obj=", account] }, { kind: "check", label: "record service configuration", file: t.sc, args: ["qc", n.service], expect: "exit0" }, { kind: "check", label: "record root ACL", file: t.icacls, args: [n.root], expect: "exit0" });
213
+ return steps;
214
+ }
215
+ export function rollbackPlan(n, systemRoot = "C:\\Windows") {
216
+ const t = systemTools(systemRoot);
217
+ const sid = serviceSidFor(n.service);
218
+ const profilesDir = win(systemRoot, "ServiceProfiles");
219
+ const profile = win(profilesDir, n.service);
220
+ const profileKey = `HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\${sid}`;
221
+ return [
222
+ { kind: "exec", label: "stop service (1060 absent and 1062 not started are fine)", file: t.sc, args: ["stop", n.service], okExitCodes: [0, 1060, 1062] },
223
+ { kind: "wait-stopped", label: "wait until stopped or absent", service: n.service },
224
+ { kind: "refuse-if-account-processes", label: "no process runs as the service account", account: `NT SERVICE\\${n.service}` },
225
+ { kind: "exec", label: "delete service (1060 absent is fine)", file: t.sc, args: ["delete", n.service], okExitCodes: [0, 1060] },
226
+ { kind: "refuse-if-reparse", label: "no reparse point under the pilot root", path: n.root },
227
+ { kind: "rmtree", label: "remove pilot root (checks the root and its ancestors are not links and the owner is Administrators, then deletes)", path: n.root },
228
+ { kind: "check", label: "service is gone", file: t.sc, args: ["query", n.service], expect: "absent-service" },
229
+ { kind: "refuse-if-present", label: "pilot root is gone", path: n.root },
230
+ // Windows creates a profile for the virtual account the first time the service starts, and sc delete leaves it
231
+ // (Beaker 2026-11-10). Removed only now: the service is deleted and nothing ran as its account. The SID is
232
+ // computed from the validated name; no name lookup, no wildcard. The folder goes first so that a refused
233
+ // folder also leaves the key, and N3 still reports both.
234
+ // Windows keeps both hives of the account loaded after its first start even with no process left
235
+ // (Beaker run 4: EBUSY on UsrClass.dat). Unloaded here, Classes first, only after sc delete and the no-process check.
236
+ { kind: "unload-service-hives", label: "unload the service account's registry hives", sid, hives: [`HKU\\${sid}_Classes`, `HKU\\${sid}`], reg: t.reg },
237
+ { kind: "remove-service-profile-folder", label: "remove the service profile folder", path: profile, profilesDir, service: n.service, sid, key: profileKey, reg: t.reg, systemRoot },
238
+ { kind: "remove-profile-key", label: "remove the service profile key", key: profileKey, sid, imagePath: profile, systemRoot, reg: t.reg },
239
+ { kind: "refuse-if-present", label: "service profile folder is gone", path: profile },
240
+ { kind: "check", label: "service profile key is gone", file: t.reg, args: ["query", profileKey], expect: "absent-key" },
241
+ ];
242
+ }
243
+ export function describeStep(s) {
244
+ const q = (a) => (a === "" || /[\s"]/.test(a) ? `"${a.replace(/"/g, '\\"')}"` : a);
245
+ switch (s.kind) {
246
+ case "check":
247
+ case "exec":
248
+ return `${s.label}: ${[s.file, ...s.args].map(q).join(" ")}`;
249
+ case "mkdir":
250
+ return `${s.label}: mkdir ${q(s.path)}`;
251
+ case "copy":
252
+ return `${s.label}: copy ${q(s.from)} ${q(s.to)}`;
253
+ case "write":
254
+ return `${s.label}: write ${q(s.path)} (${Buffer.byteLength(s.content)} bytes, sha256 ${createHash("sha256").update(s.content).digest("hex")})`;
255
+ case "remove":
256
+ return `${s.label}: delete ${q(s.path)}`;
257
+ case "manifest":
258
+ return `${s.label}: write ${q(s.path)} with sha256 of ${s.files.join(", ")}, the node.exe version, and wrapper ${s.wrapper.signed ? `signed by ${s.wrapper.signer}` : `UNSIGNED, ${s.wrapper.acceptedUnsigned}`}`;
259
+ case "refuse-if-absent":
260
+ return `${s.label}: stop unless ${q(s.path)} exists`;
261
+ case "refuse-if-present":
262
+ return `${s.label}: stop if ${q(s.path)} exists`;
263
+ case "refuse-if-sha256":
264
+ return `${s.label}: stop unless sha256(${q(s.path)}) = ${s.sha256}`;
265
+ case "refuse-if-reparse":
266
+ return `${s.label}: stop, leaving everything in place, if any symlink or junction exists under ${q(s.path)}`;
267
+ case "refuse-if-account-processes":
268
+ return `${s.label}: stop if tasklist shows a process for ${s.account}`;
269
+ case "wait-stopped":
270
+ return `${s.label}: poll sc.exe query ${s.service} up to 60 s`;
271
+ case "rmtree":
272
+ return `${s.label}: remove ${q(s.path)} recursively`;
273
+ case "refuse-if-helper-source-changed":
274
+ return `${s.label}: stop unless sha256(HELPER_SOURCE) = ${HELPER_SOURCE_SHA256}`;
275
+ case "remove-service-profile-folder":
276
+ return `${s.label}: remove ${q(s.path)} recursively, deleting links inside it without following them; stop unless it and ${q(s.profilesDir)} are not links, its owner is S-1-5-18, S-1-5-32-544 or ${s.sid}, its ACL has an explicit allow ACE for ${s.sid}, and ${q(s.key)} is absent or its ProfileImagePath is this folder; then stop if a hive of ${s.sid} is loaded or a hive file cannot be opened exclusively, before anything is deleted`;
277
+ case "unload-service-hives":
278
+ return `${s.label}: if loaded, ${q(s.reg)} unload ${s.hives.join(", then ")}; stop if either is still loaded (a reboot unloads them; then run rollback again)`;
279
+ case "remove-profile-key":
280
+ return `${s.label}: ${q(s.reg)} delete ${q(s.key)} /f, after reg.exe query shows ProfileImagePath ${q(s.imagePath)}`;
281
+ case "refuse-if-service-profile":
282
+ return `${s.label}: stop if ${q(s.path)} exists (any type, a link included) or reg.exe query ${q(s.key)} finds the key`;
283
+ case "verify-new-root":
284
+ return `${s.label}: stop unless ${q(s.path)} and its ancestors are not links, its owner is ${ADMINS_NAME} and it is empty`;
285
+ }
286
+ }
287
+ function tryOpenFile(host, path) {
288
+ if (host.tryOpen)
289
+ return host.tryOpen(path);
290
+ try {
291
+ // Windows holds a loaded hive and its logs with no sharing, so even this open fails with EBUSY while it is loaded.
292
+ closeSync(openSync(path, "r+"));
293
+ return null;
294
+ }
295
+ catch (err) {
296
+ return err.code ?? String(err);
297
+ }
298
+ }
299
+ export const realHost = {
300
+ run(file, args) {
301
+ const r = spawnSync(file, args, { encoding: "utf8", windowsHide: true, timeout: 120_000 });
302
+ return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? (r.error ? r.error.message : "") };
303
+ },
304
+ sleep(ms) {
305
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
306
+ },
307
+ };
308
+ function sha256File(path) {
309
+ return createHash("sha256").update(readFileSync(path)).digest("hex");
310
+ }
311
+ /** The path and each ancestor up to (not including) the drive or C:\\ProgramData, as given. */
312
+ function chain(path) {
313
+ const sep = path.includes("\\") ? "\\" : "/";
314
+ const parts = path.split(sep);
315
+ const out = [];
316
+ for (let i = parts.length; i > 1; i--) {
317
+ const p = parts.slice(0, i).join(sep);
318
+ if (/^[A-Za-z]:$/.test(p) || /^[A-Za-z]:\\ProgramData$/i.test(p) || p === "")
319
+ break;
320
+ out.push(p);
321
+ }
322
+ return out;
323
+ }
324
+ /** A link at the path or at an ancestor below C:\\ProgramData, or null. */
325
+ export function linkInChain(path) {
326
+ for (const p of chain(path)) {
327
+ try {
328
+ if (lstatSync(p).isSymbolicLink())
329
+ return p;
330
+ }
331
+ catch {
332
+ // A missing ancestor is not a link.
333
+ }
334
+ }
335
+ return null;
336
+ }
337
+ function ownerOf(host, path) {
338
+ const r = host.run(systemTools().powershell, ["-NoProfile", "-NonInteractive", "-Command", `(Get-Acl -LiteralPath '${path.replace(/'/g, "''")}').Owner`]);
339
+ return r.status === 0 ? r.stdout.trim() : `unknown (exit ${r.status})`;
340
+ }
341
+ function isLink(path) {
342
+ try {
343
+ return lstatSync(path).isSymbolicLink();
344
+ }
345
+ catch {
346
+ return false;
347
+ }
348
+ }
349
+ const PROFILE_OWNERS = ["S-1-5-18", "S-1-5-32-544"];
350
+ /** The hive files of a profile, relative to the profile folder. */
351
+ const HIVE_FILES = [
352
+ ["NTUSER.DAT"],
353
+ ["ntuser.dat.LOG1"],
354
+ ["ntuser.dat.LOG2"],
355
+ ["AppData", "Local", "Microsoft", "Windows", "UsrClass.dat"],
356
+ ["AppData", "Local", "Microsoft", "Windows", "UsrClass.dat.LOG1"],
357
+ ["AppData", "Local", "Microsoft", "Windows", "UsrClass.dat.LOG2"],
358
+ ];
359
+ /** Which of the given HKU keys are loaded (reg query exit 0), not loaded (exit 1), or unknown (anything else). */
360
+ function hiveState(host, reg, hives) {
361
+ const loaded = [];
362
+ const unknown = [];
363
+ for (const hive of hives) {
364
+ if (!/^HKU\\S-1-5-80(-\d+){5}(_Classes)?$/.test(hive)) {
365
+ unknown.push(hive);
366
+ continue;
367
+ }
368
+ const r = host.run(reg, ["query", hive]);
369
+ if (r.status === 0)
370
+ loaded.push(hive);
371
+ else if (r.status !== 1)
372
+ unknown.push(hive);
373
+ }
374
+ return { loaded, unknown };
375
+ }
376
+ /**
377
+ * Owner, whether the DACL is protected, and every allow rule with its rights, all as SID strings: no name lookup,
378
+ * so it works after sc delete. null when unreadable or incomplete.
379
+ */
380
+ function readOwnerAndDacl(host, path) {
381
+ const lit = path.replace(/'/g, "''");
382
+ const script = `$a = Get-Acl -LiteralPath '${lit}'; $t = [System.Security.Principal.SecurityIdentifier]; 'owner=' + $a.GetOwner($t).Value; 'protected=' + $a.AreAccessRulesProtected; foreach ($r in $a.GetAccessRules($true, $true, $t)) { if ($r.AccessControlType -eq 'Allow') { 'rule=' + $r.IdentityReference.Value + '|' + [int64]$r.FileSystemRights + '|' + $r.IsInherited } }`;
383
+ const r = host.run(systemTools().powershell, ["-NoProfile", "-NonInteractive", "-Command", script]);
384
+ if (r.status !== 0)
385
+ return null;
386
+ const lines = r.stdout.split(/\r?\n/).map((l) => l.trim());
387
+ const owner = lines.find((l) => l.startsWith("owner="))?.slice("owner=".length) ?? "";
388
+ const prot = lines.find((l) => l.startsWith("protected="))?.slice("protected=".length).toLowerCase();
389
+ if (!/^S-1-\d+(-\d+)+$/.test(owner) || (prot !== "true" && prot !== "false"))
390
+ return null;
391
+ const rules = [];
392
+ for (const l of lines.filter((x) => x.startsWith("rule="))) {
393
+ const [sid, rights, inherited] = l.slice("rule=".length).split("|");
394
+ if (!/^S-1-\d+(-\d+)+$/.test(sid) || !/^\d+$/.test(rights ?? ""))
395
+ return null;
396
+ rules.push({ sid, rights: Number(rights), inherited: (inherited ?? "").toLowerCase() === "true" });
397
+ }
398
+ return { owner, protected: prot === "true", rules };
399
+ }
400
+ /**
401
+ * Rights that let a holder change the folder or what is in it: WriteData/CreateFiles, AppendData/CreateDirectories,
402
+ * WriteExtendedAttributes, DeleteSubdirectoriesAndFiles, WriteAttributes, Delete, WRITE_DAC, WRITE_OWNER,
403
+ * GENERIC_ALL, GENERIC_WRITE.
404
+ */
405
+ const WRITE_TYPE_RIGHTS = 0x2 | 0x4 | 0x10 | 0x40 | 0x100 | 0x10000 | 0x40000 | 0x80000 | 0x10000000 | 0x40000000;
406
+ /**
407
+ * Whether C:\Windows\ServiceProfiles\<service> is this service's own profile, every check required:
408
+ * 1. exact path from the validated name, and neither it nor ServiceProfiles is a link;
409
+ * 2a. the DACL is protected and grants write-type rights only to SYSTEM, Administrators or the service SID;
410
+ * 2. owner SID is SYSTEM, Administrators or the service SID (Windows created Beaker's as Administrators; only
411
+ * SYSTEM and Administrators can create entries under ServiceProfiles, so the owner alone binds nothing);
412
+ * 3. the DACL has an explicit allow ACE for the service SID;
413
+ * 4. if the ProfileList key for the SID exists, its ProfileImagePath (only a leading %SystemRoot% expanded) is this folder.
414
+ * Shared by --apply and the dry-run probe.
415
+ */
416
+ export function profileFolderCheck(host, s) {
417
+ const sep = s.path.includes("\\") ? "\\" : "/";
418
+ const cut = s.path.lastIndexOf(sep);
419
+ if (s.path.slice(0, cut) !== s.profilesDir || s.path.slice(cut + 1) !== s.service || !/^HQND[A-Z0-9]{4,20}$/.test(s.service))
420
+ return { state: "refuse", reason: `${s.path} is not this service's own profile folder; nothing deleted`, present: false };
421
+ for (const p of [s.path, s.profilesDir]) {
422
+ if (isLink(p))
423
+ return { state: "refuse", reason: `left in place; ${p} is a symlink or junction`, present: false };
424
+ }
425
+ if (!existsSync(s.path))
426
+ return { state: "absent" };
427
+ const acl = readOwnerAndDacl(host, s.path);
428
+ if (!acl)
429
+ return { state: "refuse", reason: "left in place; owner and ACL could not be read", present: true };
430
+ const trusted = [...PROFILE_OWNERS, s.sid];
431
+ if (!trusted.includes(acl.owner))
432
+ return { state: "refuse", reason: `left in place; owner is ${acl.owner}, expected S-1-5-18 (SYSTEM), S-1-5-32-544 (Administrators) or ${s.sid}`, present: true };
433
+ // Review C4: a standard user who planted the folder owns it and could have rewritten its DACL. Windows creates the
434
+ // real one protected, writable only by SYSTEM, Administrators and the service (Beaker run 3 and 4).
435
+ if (!acl.protected)
436
+ return { state: "refuse", reason: "left in place; the DACL is not protected (inheritance is enabled)", present: true };
437
+ const writer = acl.rules.find((x) => (x.rights & WRITE_TYPE_RIGHTS) !== 0 && !trusted.includes(x.sid));
438
+ if (writer)
439
+ return { state: "refuse", reason: `left in place; the DACL grants write-type rights 0x${(writer.rights & WRITE_TYPE_RIGHTS).toString(16)} to ${writer.sid}`, present: true };
440
+ if (!acl.rules.some((x) => x.sid === s.sid && !x.inherited))
441
+ return { state: "refuse", reason: `left in place; the ACL has no explicit allow ACE for ${s.sid}`, present: true };
442
+ const q = host.run(s.reg, ["query", s.key]);
443
+ const passed = `owner ${acl.owner}, DACL protected, no other writers, explicit allow ACE for ${s.sid}`;
444
+ if (q.status === 1)
445
+ return { state: "ok", detail: `owner ${acl.owner}, allow ACE for ${s.sid}, ProfileList key absent, bound by the ACE`, checks: `${passed}, ProfileList key absent (bound by the ACE)` };
446
+ if (q.status !== 0)
447
+ return { state: "refuse", reason: `left in place; reg.exe query of ${s.key} exit ${q.status}`, present: true };
448
+ const v = host.run(s.reg, ["query", s.key, "/v", "ProfileImagePath"]);
449
+ const raw = /ProfileImagePath\s+REG_(?:EXPAND_)?SZ\s+(.*?)\s*$/m.exec(v.stdout)?.[1] ?? "";
450
+ const norm = (x) => x.replace(/\//g, "\\").toLowerCase();
451
+ if (v.status !== 0 || raw === "" || norm(raw.replace(/^%systemroot%/i, s.systemRoot)) !== norm(s.path))
452
+ return { state: "refuse", reason: `left in place; ProfileImagePath is ${raw || "unreadable"}, expected ${s.path}`, present: true };
453
+ return { state: "ok", detail: `owner ${acl.owner}, allow ACE for ${s.sid}, ProfileImagePath matches`, checks: `${passed}, ProfileImagePath matches` };
454
+ }
455
+ /** Delete a tree; a symlink or junction inside it is removed as a link and never followed. Returns the number of links. */
456
+ function removeNoFollow(path) {
457
+ const st = lstatSync(path);
458
+ if (st.isSymbolicLink()) {
459
+ try {
460
+ rmdirSync(path); // a Windows directory junction or directory symlink
461
+ }
462
+ catch {
463
+ unlinkSync(path);
464
+ }
465
+ return 1;
466
+ }
467
+ if (!st.isDirectory()) {
468
+ unlinkSync(path);
469
+ return 0;
470
+ }
471
+ let links = 0;
472
+ for (const name of readdirSync(path))
473
+ links += removeNoFollow(join(path, name));
474
+ rmdirSync(path);
475
+ return links;
476
+ }
477
+ /** Every symlink or junction below root, without following any. */
478
+ export function findReparse(root) {
479
+ const out = [];
480
+ const walk = (dir) => {
481
+ for (const name of readdirSync(dir)) {
482
+ const p = join(dir, name);
483
+ const st = lstatSync(p);
484
+ if (st.isSymbolicLink())
485
+ out.push(p);
486
+ else if (st.isDirectory())
487
+ walk(p);
488
+ }
489
+ };
490
+ if (existsSync(root))
491
+ walk(root);
492
+ return out;
493
+ }
494
+ /** Run steps in order and stop at the first failure. */
495
+ export function applySteps(steps, host, ctx) {
496
+ const log = [];
497
+ const fail = (s, why) => (log.push(`FAIL ${s.label}: ${why}`), { ok: false, log });
498
+ for (const s of steps) {
499
+ log.push(`STEP ${describeStep(s)}`);
500
+ try {
501
+ const stopped = runStep(s);
502
+ if (stopped)
503
+ return stopped;
504
+ }
505
+ catch (err) {
506
+ // mkdir, copy, write and delete throw; the steps so far must still reach the operator.
507
+ return fail(s, err instanceof Error ? err.message : String(err));
508
+ }
509
+ }
510
+ return { ok: true, log };
511
+ function runStep(s) {
512
+ switch (s.kind) {
513
+ case "check":
514
+ case "exec": {
515
+ const r = host.run(s.file, s.args);
516
+ log.push(` exit ${r.status}`, ...r.stdout.trim().split("\n").filter(Boolean).map((l) => ` out ${l}`), ...r.stderr.trim().split("\n").filter(Boolean).map((l) => ` err ${l}`));
517
+ if (s.kind === "check" && s.expect === "absent-service") {
518
+ if (r.status !== 1060)
519
+ return fail(s, `expected exit 1060 (service does not exist), got ${r.status}`);
520
+ }
521
+ else if (s.kind === "check" && s.expect === "absent-key") {
522
+ if (r.status !== 1)
523
+ return fail(s, `expected exit 1 (key does not exist), got ${r.status}`);
524
+ }
525
+ else if (!(s.kind === "exec" ? (s.okExitCodes ?? [0]) : [0]).includes(r.status ?? -1))
526
+ return fail(s, `exit ${r.status}`);
527
+ break;
528
+ }
529
+ case "mkdir":
530
+ mkdirSync(s.path);
531
+ break;
532
+ case "copy":
533
+ copyFileSync(s.from, s.to);
534
+ break;
535
+ case "write":
536
+ writeFileSync(s.path, s.content);
537
+ break;
538
+ case "remove":
539
+ rmSync(s.path);
540
+ break;
541
+ case "manifest": {
542
+ const files = {};
543
+ for (const f of s.files)
544
+ files[f] = sha256File(join(ctx.root, ...f.split("/")));
545
+ for (const [f, want] of Object.entries(s.expect)) {
546
+ if (files[f] !== want)
547
+ return fail(s, `installed ${f} sha256 is ${files[f]}, expected ${want}`);
548
+ }
549
+ const nodeExe = join(ctx.root, "runtime", "node.exe");
550
+ const v = host.run(nodeExe, ["--version"]);
551
+ const version = v.stdout.trim();
552
+ if (v.status !== 0 || !/^v\d+\.\d+\.\d+/.test(version))
553
+ return fail(s, `${nodeExe} --version gave exit ${v.status} and ${version || "no output"}`);
554
+ log.push(` node.exe ${version} sha256 ${files["runtime/node.exe"]}`);
555
+ const m = { schemaVersion: MANIFEST_VERSION, service: ctx.service, root: ctx.root, files, wrapper: s.wrapper, node: { version, sha256: files["runtime/node.exe"] } };
556
+ writeFileSync(s.path, JSON.stringify(m, null, 2) + "\n");
557
+ log.push(` manifest sha256 ${sha256File(s.path)}`);
558
+ break;
559
+ }
560
+ case "refuse-if-absent":
561
+ if (!existsSync(s.path))
562
+ return fail(s, `${s.path} does not exist`);
563
+ break;
564
+ case "refuse-if-present":
565
+ if (existsSync(s.path))
566
+ return fail(s, `${s.path} exists`);
567
+ break;
568
+ case "refuse-if-sha256": {
569
+ const got = sha256File(s.path);
570
+ if (got !== s.sha256)
571
+ return fail(s, `sha256 is ${got}`);
572
+ break;
573
+ }
574
+ case "refuse-if-reparse": {
575
+ const found = findReparse(s.path);
576
+ if (found.length > 0)
577
+ return fail(s, `left in place for review; reparse points: ${found.join(", ")}`);
578
+ break;
579
+ }
580
+ case "refuse-if-account-processes": {
581
+ const list = host.run(systemTools().tasklist, ["/v", "/fo", "csv", "/nh", "/fi", `USERNAME eq ${s.account}`]);
582
+ const rows = list.stdout.split("\n").filter((l) => l.startsWith('"'));
583
+ if (list.status !== 0)
584
+ return fail(s, `tasklist exit ${list.status}`);
585
+ if (rows.length > 0)
586
+ return fail(s, `${rows.length} process(es) still run as ${s.account}`);
587
+ break;
588
+ }
589
+ case "wait-stopped": {
590
+ let state = "";
591
+ for (let i = 0; i < 60; i++) {
592
+ const r = host.run(systemTools().sc, ["query", s.service]);
593
+ if (r.status === 1060) {
594
+ state = "absent";
595
+ break;
596
+ }
597
+ if (/STATE\s*:\s*1\s+STOPPED/.test(r.stdout)) {
598
+ state = "stopped";
599
+ break;
600
+ }
601
+ host.sleep(1000);
602
+ }
603
+ if (!state)
604
+ return fail(s, "service did not stop within 60 s");
605
+ log.push(` ${state}`);
606
+ break;
607
+ }
608
+ case "rmtree": {
609
+ // Checked immediately before the delete, not earlier in the plan.
610
+ const link = linkInChain(s.path);
611
+ if (link)
612
+ return fail(s, `left in place; ${link} is a symlink or junction`);
613
+ if (!existsSync(s.path))
614
+ break;
615
+ const owner = ownerOf(host, s.path);
616
+ if (owner !== ADMINS_NAME)
617
+ return fail(s, `left in place; owner is ${owner}, expected ${ADMINS_NAME}`);
618
+ rmSync(s.path, { recursive: true, force: true });
619
+ break;
620
+ }
621
+ case "refuse-if-helper-source-changed": {
622
+ const got = createHash("sha256").update(HELPER_SOURCE).digest("hex");
623
+ if (got !== HELPER_SOURCE_SHA256)
624
+ return fail(s, `helper source sha256 is ${got}`);
625
+ break;
626
+ }
627
+ case "refuse-if-service-profile": {
628
+ let present = true;
629
+ try {
630
+ lstatSync(s.path);
631
+ }
632
+ catch {
633
+ present = false;
634
+ }
635
+ if (present)
636
+ return fail(s, `${s.path} exists; a previous service profile must be cleared by rollback first`);
637
+ const r = host.run(s.reg, ["query", s.key]);
638
+ if (r.status === 0)
639
+ return fail(s, `${s.key} exists; a previous service profile must be cleared by rollback first`);
640
+ if (r.status !== 1)
641
+ return fail(s, `reg.exe query exit ${r.status}; cannot tell whether a previous service profile exists`);
642
+ break;
643
+ }
644
+ case "unload-service-hives": {
645
+ const before = hiveState(host, s.reg, s.hives);
646
+ if (before.unknown.length > 0)
647
+ return fail(s, `reg.exe query could not tell whether ${before.unknown.join(", ")} is loaded; folder and key left in place`);
648
+ for (const hive of before.loaded) {
649
+ const r = host.run(s.reg, ["unload", hive]);
650
+ log.push(` reg.exe unload ${hive}: exit ${r.status}${r.stdout.trim() ? ` ${r.stdout.trim()}` : ""}`);
651
+ }
652
+ const after = hiveState(host, s.reg, s.hives);
653
+ if (after.unknown.length > 0)
654
+ return fail(s, `reg.exe query could not tell whether ${after.unknown.join(", ")} is loaded; folder and key left in place`);
655
+ if (after.loaded.length > 0) {
656
+ // Beaker run 5: Windows keeps a virtual account's hives loaded until restart. Not a failure of this run,
657
+ // the first phase of a two-phase uninstall; main() confirms the rest is gone before reporting it.
658
+ log.push(`PENDING ${s.label}: still loaded: ${after.loaded.join(", ")}; folder and key left in place; a reboot unloads them; then run rollback again`);
659
+ return { ok: false, log, pendingReboot: after.loaded };
660
+ }
661
+ log.push(before.loaded.length > 0 ? ` unloaded ${before.loaded.join(", ")}` : " not loaded");
662
+ break;
663
+ }
664
+ case "remove-service-profile-folder": {
665
+ const v = profileFolderCheck(host, s);
666
+ if (v.state === "refuse")
667
+ return fail(s, v.reason);
668
+ if (v.state === "absent") {
669
+ log.push(" absent");
670
+ break;
671
+ }
672
+ // Nothing is deleted unless both hives are unloaded and every hive file opens; no partial delete from a known lock.
673
+ const hives = hiveState(host, s.reg, [`HKU\\${s.sid}_Classes`, `HKU\\${s.sid}`]);
674
+ const loadedNow = [...hives.loaded, ...hives.unknown];
675
+ if (loadedNow.length > 0)
676
+ return fail(s, `left in place; hive still loaded: ${loadedNow.join(", ")}; a reboot unloads it; then run rollback again`);
677
+ for (const rel of HIVE_FILES) {
678
+ const f = join(s.path, ...rel);
679
+ if (!existsSync(f))
680
+ continue;
681
+ const err = tryOpenFile(host, f);
682
+ if (err)
683
+ return fail(s, `left in place; ${f} cannot be opened exclusively (${err}); nothing was deleted; a reboot releases it; then run rollback again`);
684
+ }
685
+ const links = removeNoFollow(s.path);
686
+ log.push(` ${v.detail}; removed, ${links} link(s) inside deleted without following`);
687
+ break;
688
+ }
689
+ case "remove-profile-key": {
690
+ if (!/^HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\S-1-5-80(-\d+){5}$/.test(s.key) || !s.key.endsWith(`\\${s.sid}`))
691
+ return fail(s, `${s.key} is not this service's own ProfileList key; nothing deleted`);
692
+ const q = host.run(s.reg, ["query", s.key]);
693
+ if (q.status === 1) {
694
+ log.push(" absent");
695
+ break;
696
+ }
697
+ if (q.status !== 0)
698
+ return fail(s, `reg.exe query exit ${q.status}`);
699
+ const v = host.run(s.reg, ["query", s.key, "/v", "ProfileImagePath"]);
700
+ const raw = /ProfileImagePath\s+REG_(?:EXPAND_)?SZ\s+(.*?)\s*$/m.exec(v.stdout)?.[1] ?? "";
701
+ const image = raw.replace(/^%systemroot%/i, s.systemRoot);
702
+ if (v.status !== 0 || image.toLowerCase() !== s.imagePath.toLowerCase())
703
+ return fail(s, `left in place; ProfileImagePath is ${raw || "unreadable"}, expected ${s.imagePath}`);
704
+ const d = host.run(s.reg, ["delete", s.key, "/f"]);
705
+ log.push(` reg.exe delete exit ${d.status}`);
706
+ if (d.status !== 0)
707
+ return fail(s, `reg.exe delete exit ${d.status}`);
708
+ break;
709
+ }
710
+ case "verify-new-root": {
711
+ const link = linkInChain(s.path);
712
+ if (link)
713
+ return fail(s, `${link} is a symlink or junction`);
714
+ const entries = readdirSync(s.path);
715
+ if (entries.length > 0)
716
+ return fail(s, `${s.path} is not empty: ${entries.join(", ")}`);
717
+ const owner = ownerOf(host, s.path);
718
+ if (owner !== ADMINS_NAME)
719
+ return fail(s, `owner is ${owner}, expected ${ADMINS_NAME}`);
720
+ break;
721
+ }
722
+ }
723
+ return null;
724
+ }
725
+ }
726
+ /**
727
+ * Read-only probes for the rollback dry run (Beaker run 3): what each rollback
728
+ * target looks like now and what --apply would do to it. Runs only sc query,
729
+ * tasklist, reg query and Get-Acl owner reads, plus local lstat and readdir.
730
+ * Never stops, deletes, or changes an ACL, and never runs anything from the
731
+ * stage folder. The checks mirror the ones --apply makes before each delete.
732
+ */
733
+ export function probeRollback(steps, host) {
734
+ const out = ["PROBE (read-only; nothing is changed):"];
735
+ const t = systemTools();
736
+ const seen = { service: false, root: false, profile: false, key: false, hives: false, hivesUnknown: false };
737
+ for (const s of steps) {
738
+ if (s.kind === "exec" && s.args[0] === "stop") {
739
+ const service = s.args[1];
740
+ const r = host.run(t.sc, ["query", service]);
741
+ const state = /STATE\s*:\s*\d+\s+\w+/.exec(r.stdout)?.[0];
742
+ seen.service = r.status !== 1060;
743
+ out.push(`PROBE service ${service}: ${r.status === 1060 ? "absent (1060)" : r.status === 0 ? `present (${state ?? "state unreadable"}); would stop and delete` : `unknown (sc query exit ${r.status})`}`);
744
+ }
745
+ else if (s.kind === "refuse-if-account-processes") {
746
+ const r = host.run(t.tasklist, ["/v", "/fo", "csv", "/nh", "/fi", `USERNAME eq ${s.account}`]);
747
+ const rows = r.stdout.split("\n").filter((l) => l.startsWith('"'));
748
+ out.push(`PROBE account processes: ${r.status !== 0 ? `would refuse: tasklist exit ${r.status}` : rows.length > 0 ? `would refuse: ${rows.length} process(es) run as ${s.account}` : "none"}`);
749
+ }
750
+ else if (s.kind === "rmtree") {
751
+ const link = linkInChain(s.path);
752
+ let verdict;
753
+ if (link)
754
+ verdict = `would refuse: ${link} is a symlink or junction`;
755
+ else if (!existsSync(s.path))
756
+ verdict = "absent";
757
+ else {
758
+ const inner = findReparse(s.path);
759
+ const owner = ownerOf(host, s.path);
760
+ if (inner.length > 0)
761
+ verdict = `present; would refuse: reparse points ${inner.join(", ")}`;
762
+ else if (owner !== ADMINS_NAME)
763
+ verdict = `present; would refuse: owner is ${owner}, expected ${ADMINS_NAME}`;
764
+ else
765
+ verdict = `present, owner ${owner}, no links; would remove`;
766
+ }
767
+ seen.root = verdict !== "absent";
768
+ out.push(`PROBE pilot root ${s.path}: ${verdict}`);
769
+ }
770
+ else if (s.kind === "remove-service-profile-folder") {
771
+ const v = profileFolderCheck(host, s);
772
+ const verdict = v.state === "absent" ? "absent" : v.state === "ok" ? `present, ${v.checks}, not a link; would remove` : v.present ? `present; would refuse: ${v.reason.replace(/^left in place; /, "")}` : `would refuse: ${v.reason.replace(/^left in place; /, "")}`;
773
+ const hives = hiveState(host, s.reg, [`HKU\\${s.sid}_Classes`, `HKU\\${s.sid}`]);
774
+ seen.profile = v.state !== "absent";
775
+ seen.hives = hives.loaded.length > 0;
776
+ seen.hivesUnknown = hives.unknown.length > 0;
777
+ const hiveText = hives.unknown.length > 0 ? `hive state unknown (${hives.unknown.join(", ")})` : hives.loaded.length > 0 ? `hives loaded (${hives.loaded.join(", ")}); would unload first` : "hives not loaded";
778
+ out.push(`PROBE service profile folder ${s.path}: ${verdict}; ${hiveText}`);
779
+ }
780
+ else if (s.kind === "remove-profile-key") {
781
+ let verdict;
782
+ const q = host.run(s.reg, ["query", s.key]);
783
+ if (q.status === 1)
784
+ verdict = "absent";
785
+ else if (q.status !== 0)
786
+ verdict = `unknown (reg query exit ${q.status})`;
787
+ else {
788
+ const v = host.run(s.reg, ["query", s.key, "/v", "ProfileImagePath"]);
789
+ const raw = /ProfileImagePath\s+REG_(?:EXPAND_)?SZ\s+(.*?)\s*$/m.exec(v.stdout)?.[1] ?? "";
790
+ const ok = raw.replace(/^%systemroot%/i, s.systemRoot).toLowerCase() === s.imagePath.toLowerCase();
791
+ verdict = ok ? `present, ProfileImagePath ${raw}; would remove` : `present; would refuse: ProfileImagePath is ${raw || "unreadable"}, expected ${s.imagePath}`;
792
+ }
793
+ seen.key = verdict !== "absent";
794
+ out.push(`PROBE service profile key ${s.key}: ${verdict}`);
795
+ }
796
+ }
797
+ if (seen.service || seen.root)
798
+ out.push("PHASE 1: full rollback: the service and its files, then the service profile");
799
+ // apply stops with exit 1 when it cannot tell whether the hives are loaded, so the dry run must not promise a phase.
800
+ else if (seen.hivesUnknown)
801
+ out.push("PHASE unknown: the service account's hive state could not be read; rollback --apply would stop with exit 1");
802
+ else if ((seen.profile || seen.key) && seen.hives)
803
+ out.push("PHASE 1 will end in PENDING REBOOT: only the service profile is left and Windows holds its hives; restart the machine, then run rollback --apply again");
804
+ else if (seen.profile || seen.key)
805
+ out.push("PHASE 2: post-restart cleanup of the service profile only");
806
+ else
807
+ out.push("PHASE none: nothing to remove");
808
+ return out;
809
+ }
810
+ function arg(argv, name) {
811
+ const i = argv.indexOf(name);
812
+ return i >= 0 ? argv[i + 1] : undefined;
813
+ }
814
+ export function main(argv, host = realHost, platform = process.platform, out = (s) => process.stdout.write(s + "\n"),
815
+ /** The wrapper pin. Only tests pass one; the command line cannot. */
816
+ pin = WRAPPER_PIN,
817
+ /** The runner pin. Only tests pass one; the build compiles the real one in. */
818
+ runnerSha256 = BUNDLED_RUNNER_SHA256) {
819
+ const [cmd] = argv;
820
+ const names = { service: arg(argv, "--service") ?? PILOT040.service, root: arg(argv, "--root") ?? PILOT040.root };
821
+ const bad = validateNames(names);
822
+ if (bad)
823
+ return (out(`refused: ${bad}`), 2);
824
+ const apply = argv.includes("--apply");
825
+ const notices = [];
826
+ let steps;
827
+ if (cmd === "install") {
828
+ const stage = arg(argv, "--stage");
829
+ if (!stage)
830
+ return (out("usage: install --stage <dir> [--pilot-unsigned-wrapper] [--apply]"), 2);
831
+ const pilotUnsignedWrapper = argv.includes(PILOT_UNSIGNED_FLAG);
832
+ const problem = pinProblem(pin, { ...names, pilotUnsignedWrapper });
833
+ if (problem)
834
+ return (out(`refused: ${problem}`), 2);
835
+ if (unsignedMarked(pin))
836
+ notices.push(`NOTICE: the service wrapper is UNSIGNED and accepted by hash only: ${pin.unsignedAccepted.decision}`);
837
+ const runnerProblem = runnerPinProblem(runnerSha256);
838
+ if (runnerProblem)
839
+ return (out(`refused: ${runnerProblem}`), 2);
840
+ if (!apply) {
841
+ // Read-only and nothing is executed: the staged node.exe is only hashed.
842
+ const nodeExe = win(stage, "node.exe");
843
+ const local = existsSync(nodeExe) ? nodeExe : existsSync(join(stage, "node.exe")) ? join(stage, "node.exe") : "";
844
+ notices.push(local ? `staged node.exe: sha256 ${sha256File(local)} (not pinned in the repo; its version is read at apply from the installed copy and recorded in the manifest)` : `staged node.exe: not found at ${nodeExe}; stage it before --apply`);
845
+ }
846
+ steps = installPlan({ ...names, stage, wrapper: pin, pilotUnsignedWrapper, runnerSha256 });
847
+ }
848
+ else if (cmd === "rollback") {
849
+ steps = rollbackPlan(names);
850
+ }
851
+ else {
852
+ out("usage: install|rollback [--apply]");
853
+ return 2;
854
+ }
855
+ if (!apply) {
856
+ out(`DRY RUN ${cmd} ${names.service} ${names.root}; nothing is changed. Steps:`);
857
+ for (const n of notices)
858
+ out(n);
859
+ steps.forEach((s, i) => out(`${String(i + 1).padStart(2)}. ${describeStep(s)}`));
860
+ if (cmd === "rollback") {
861
+ if (platform === "win32")
862
+ for (const l of probeRollback(steps, host))
863
+ out(l);
864
+ else {
865
+ out("PHASE unknown: the probes run only on Windows");
866
+ out("PROBE skipped: the probes run only on Windows");
867
+ }
868
+ }
869
+ return 0;
870
+ }
871
+ if (platform !== "win32")
872
+ return (out("refused: --apply runs only on Windows"), 2);
873
+ for (const n of notices)
874
+ out(n);
875
+ const r = applySteps(steps, host, names);
876
+ for (const l of r.log)
877
+ out(l);
878
+ if (cmd === "rollback" && !r.ok && r.pendingReboot) {
879
+ // Exit 3 only when everything but the profile is confirmed gone right now: the service and the pilot root.
880
+ const sc = host.run(systemTools().sc, ["query", names.service]);
881
+ if (sc.status === 1060 && !existsSync(names.root)) {
882
+ const folder = steps.find((x) => x.kind === "remove-service-profile-folder");
883
+ const key = steps.find((x) => x.kind === "remove-profile-key");
884
+ out(`PENDING REBOOT: the service and its files are removed; the service profile (${folder?.kind === "remove-service-profile-folder" ? folder.path : "?"}, ${key?.kind === "remove-profile-key" ? key.key : "?"}) is held by Windows until restart. Restart the machine, then run \`rollback --apply\` again to remove it.`);
885
+ return 3;
886
+ }
887
+ out(`FAIL final re-probe: sc.exe query exit ${sc.status}${existsSync(names.root) ? `, ${names.root} exists` : ""}; not a pending reboot`);
888
+ }
889
+ out(r.ok ? `${cmd} complete` : `${cmd} stopped; see FAIL above`);
890
+ return r.ok ? 0 : 1;
891
+ }
892
+ //# sourceMappingURL=windows-service-install.js.map