aegisone 1.0.34 → 1.0.35

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 (226) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +1 -1
  3. package/SOURCE-OFFER.txt +9 -0
  4. package/bin/aegis.js +1 -322
  5. package/package.json +4 -5
  6. package/scripts/bump.mjs +1 -211
  7. package/scripts/bundle.js +1 -129
  8. package/scripts/predist.mjs +1 -976
  9. package/src/child.js +1 -285
  10. package/src/dispatch.js +1 -269
  11. package/src/doctor.js +1 -639
  12. package/src/host.js +1 -111
  13. package/src/permissions.js +1 -383
  14. package/src/probes.js +1 -159
  15. package/src/release.js +1 -409
  16. package/vendor/cli/package.json +3 -7
  17. package/vendor/cli/scripts/check.mjs +1 -52
  18. package/vendor/cli/scripts/demo.mjs +1 -94
  19. package/vendor/cli/scripts/predist.mjs +1 -75
  20. package/vendor/cli/scripts/runtests.mjs +1 -56
  21. package/vendor/cli/scripts/seal-gate.mjs +1 -74
  22. package/vendor/cli/src/agents.js +1 -139
  23. package/vendor/cli/src/app.js +1 -2957
  24. package/vendor/cli/src/art.js +1 -289
  25. package/vendor/cli/src/chatflow.js +1 -3023
  26. package/vendor/cli/src/checkpoint.js +1 -90
  27. package/vendor/cli/src/clipboard.js +1 -424
  28. package/vendor/cli/src/cloudsync.js +1 -528
  29. package/vendor/cli/src/commands.js +1 -4089
  30. package/vendor/cli/src/config.js +1 -581
  31. package/vendor/cli/src/connect.js +1 -349
  32. package/vendor/cli/src/credentials.js +1 -33
  33. package/vendor/cli/src/deps.js +1 -232
  34. package/vendor/cli/src/devrun.js +1 -187
  35. package/vendor/cli/src/diff.js +1 -333
  36. package/vendor/cli/src/diffview.js +1 -296
  37. package/vendor/cli/src/engine.js +1 -297
  38. package/vendor/cli/src/entitlement.js +1 -355
  39. package/vendor/cli/src/events.js +1 -707
  40. package/vendor/cli/src/export.js +1 -67
  41. package/vendor/cli/src/filepreview.js +1 -153
  42. package/vendor/cli/src/fingerprint.js +1 -592
  43. package/vendor/cli/src/format.js +1 -259
  44. package/vendor/cli/src/fuzzy.js +1 -119
  45. package/vendor/cli/src/history.js +1 -423
  46. package/vendor/cli/src/init.js +1 -175
  47. package/vendor/cli/src/input.js +1 -139
  48. package/vendor/cli/src/keys.js +1 -183
  49. package/vendor/cli/src/markdown.js +1 -306
  50. package/vendor/cli/src/models.js +1 -507
  51. package/vendor/cli/src/naming.js +1 -57
  52. package/vendor/cli/src/overlays.js +1 -462
  53. package/vendor/cli/src/panels.js +1 -1418
  54. package/vendor/cli/src/ping.js +1 -226
  55. package/vendor/cli/src/presence.js +1 -238
  56. package/vendor/cli/src/render.js +1 -516
  57. package/vendor/cli/src/screen.js +1 -518
  58. package/vendor/cli/src/screens.js +1 -896
  59. package/vendor/cli/src/secret.js +1 -59
  60. package/vendor/cli/src/securefs.js +1 -359
  61. package/vendor/cli/src/settings.js +1 -155
  62. package/vendor/cli/src/shared.js +1 -52
  63. package/vendor/cli/src/sharedpaths.js +1 -53
  64. package/vendor/cli/src/signup.js +1 -156
  65. package/vendor/cli/src/summarize.js +1 -95
  66. package/vendor/cli/src/sysdiag.js +1 -585
  67. package/vendor/cli/src/system.js +1 -40
  68. package/vendor/cli/src/theme.js +1 -570
  69. package/vendor/cli/src/title.js +1 -220
  70. package/vendor/cli/src/todos.js +1 -115
  71. package/vendor/cli/src/tokens.js +1 -263
  72. package/vendor/cli/src/topup.js +1 -210
  73. package/vendor/cli/src/update.js +1 -191
  74. package/vendor/cli/vendor/client/aegis.js +1 -2441
  75. package/vendor/cli/vendor/client/attest.js +1 -518
  76. package/vendor/cli/vendor/client/authorship-key.js +1 -410
  77. package/vendor/cli/vendor/client/auto-provision.js +1 -134
  78. package/vendor/cli/vendor/client/brain-catalog.js +1 -268
  79. package/vendor/cli/vendor/client/byok-catalog.js +1 -199
  80. package/vendor/cli/vendor/client/catalog-client.js +1 -487
  81. package/vendor/cli/vendor/client/conversation-export.js +1 -177
  82. package/vendor/cli/vendor/client/credentials.js +1 -494
  83. package/vendor/cli/vendor/client/device-fingerprint.js +1 -141
  84. package/vendor/cli/vendor/client/drive-connect.js +1 -110
  85. package/vendor/cli/vendor/client/drive-upload.js +1 -234
  86. package/vendor/cli/vendor/client/env-file.js +1 -1273
  87. package/vendor/cli/vendor/client/fingerprint.js +1 -1064
  88. package/vendor/cli/vendor/client/foreign-memory.js +1 -669
  89. package/vendor/cli/vendor/client/google-signin.js +1 -133
  90. package/vendor/cli/vendor/client/hooks.js +1 -430
  91. package/vendor/cli/vendor/client/model-discovery.js +1 -373
  92. package/vendor/cli/vendor/client/naming.js +1 -283
  93. package/vendor/cli/vendor/client/platform.js +1 -937
  94. package/vendor/cli/vendor/client/prefs.js +1 -351
  95. package/vendor/cli/vendor/client/presence-constants.js +1 -107
  96. package/vendor/cli/vendor/client/presence.js +1 -438
  97. package/vendor/cli/vendor/client/record-vault.js +3 -1055
  98. package/vendor/cli/vendor/client/session-store.js +1 -575
  99. package/vendor/cli/vendor/client/topup.js +1 -297
  100. package/vendor/cli/vendor/client/touch.js +1 -458
  101. package/vendor/cli/vendor/client/update.js +1 -763
  102. package/vendor/cli/vendor/client/user-models.js +1 -381
  103. package/vendor/cli/vendor/desktop/lib/local/agents.js +1 -105
  104. package/vendor/cli/vendor/desktop/lib/local/attachments.js +1 -276
  105. package/vendor/cli/vendor/desktop/lib/local/autonomous.js +1 -1045
  106. package/vendor/cli/vendor/desktop/lib/local/claude-pro.js +1 -1028
  107. package/vendor/cli/vendor/desktop/lib/local/context.js +1 -125
  108. package/vendor/cli/vendor/desktop/lib/local/engine.js +1 -3666
  109. package/vendor/cli/vendor/desktop/lib/local/entitlement.js +1 -660
  110. package/vendor/cli/vendor/desktop/lib/local/git-scope.js +1 -228
  111. package/vendor/cli/vendor/desktop/lib/local/local.js +1 -2145
  112. package/vendor/cli/vendor/desktop/lib/local/prompt.js +1 -280
  113. package/vendor/cli/vendor/desktop/lib/local/queue.js +1 -560
  114. package/vendor/cli/vendor/desktop/lib/local/session-rounds.js +1 -238
  115. package/vendor/cli/vendor/desktop/lib/local/spill.js +1 -75
  116. package/vendor/cli/vendor/desktop/lib/local/turn-guard.js +1 -300
  117. package/vendor/cli/vendor/desktop/lib/local/worktree-lock.js +1 -235
  118. package/vendor/cli/vendor/desktop/lib/settings.js +1 -890
  119. package/vendor/cli/vendor/desktop/renderer/usage.js +1 -1239
  120. package/vendor/cli/vendor/hosts/install.js +1 -638
  121. package/vendor/cli/vendor/hosts/openai-shim.js +1 -515
  122. package/vendor/cli/vendor/hosts/spec.js +1 -164
  123. package/vendor/cli/vendor/hosts/targets.js +1 -346
  124. package/vendor/cli/vendor/mcp/server.js +1 -221
  125. package/vendor/cli/vendor/mcp/tools.js +1 -408
  126. package/vendor/cli/vendor/one/src/child.js +1 -285
  127. package/vendor/cli/vendor/one/src/permissions.js +1 -383
  128. package/vendor/desktop/bin/aegis.js +1 -32
  129. package/vendor/desktop/lib/account-key.js +1 -56
  130. package/vendor/desktop/lib/auto.js +1 -461
  131. package/vendor/desktop/lib/avatar/companion.js +1 -698
  132. package/vendor/desktop/lib/avatar/cosmetics.js +1 -532
  133. package/vendor/desktop/lib/avatar/events.js +1 -344
  134. package/vendor/desktop/lib/avatar/holder-turn.js +1 -350
  135. package/vendor/desktop/lib/avatar/holders.js +1 -612
  136. package/vendor/desktop/lib/avatar/identity.js +1 -641
  137. package/vendor/desktop/lib/avatar/level.js +1 -368
  138. package/vendor/desktop/lib/avatar/mirror.js +1 -524
  139. package/vendor/desktop/lib/avatar/persona.js +1 -388
  140. package/vendor/desktop/lib/avatar/profile.js +1 -977
  141. package/vendor/desktop/lib/avatar/register.js +1 -307
  142. package/vendor/desktop/lib/avatar/store.js +1 -472
  143. package/vendor/desktop/lib/avatar/tiers.js +1 -38
  144. package/vendor/desktop/lib/avatar/transfer.js +1 -415
  145. package/vendor/desktop/lib/avatar/turn.js +1 -216
  146. package/vendor/desktop/lib/avatar/voice.js +1 -328
  147. package/vendor/desktop/lib/avatar/xp.js +1 -404
  148. package/vendor/desktop/lib/deep-link.js +1 -120
  149. package/vendor/desktop/lib/fingerprint.js +2 -347
  150. package/vendor/desktop/lib/google-connect.js +1 -323
  151. package/vendor/desktop/lib/local/agents.js +1 -105
  152. package/vendor/desktop/lib/local/attachments.js +1 -276
  153. package/vendor/desktop/lib/local/autonomous.js +1 -1045
  154. package/vendor/desktop/lib/local/claude-pro.js +1 -1028
  155. package/vendor/desktop/lib/local/context.js +1 -125
  156. package/vendor/desktop/lib/local/engine.js +1 -3666
  157. package/vendor/desktop/lib/local/entitlement.js +1 -660
  158. package/vendor/desktop/lib/local/git-scope.js +1 -228
  159. package/vendor/desktop/lib/local/local.js +1 -2145
  160. package/vendor/desktop/lib/local/prompt.js +1 -280
  161. package/vendor/desktop/lib/local/queue.js +1 -560
  162. package/vendor/desktop/lib/local/session-rounds.js +1 -238
  163. package/vendor/desktop/lib/local/spill.js +1 -75
  164. package/vendor/desktop/lib/local/telemetry.js +1 -470
  165. package/vendor/desktop/lib/local/turn-guard.js +1 -300
  166. package/vendor/desktop/lib/local/worktree-lock.js +1 -235
  167. package/vendor/desktop/lib/provider-key-mirror.js +1 -252
  168. package/vendor/desktop/lib/quick-launcher.js +1 -84
  169. package/vendor/desktop/lib/settings.js +1 -890
  170. package/vendor/desktop/lib/sync/memory-queue.js +1 -60
  171. package/vendor/desktop/lib/sync/persist-gate.js +1 -148
  172. package/vendor/desktop/lib/sync/sessions.js +1 -106
  173. package/vendor/desktop/lib/window-state.js +1 -66
  174. package/vendor/desktop/package.json +2 -4
  175. package/vendor/desktop/preload.js +1 -679
  176. package/vendor/desktop/renderer/app.js +1 -7250
  177. package/vendor/desktop/renderer/avatar/assemble.js +1 -335
  178. package/vendor/desktop/renderer/avatar/avatar.js +1 -380
  179. package/vendor/desktop/renderer/avatar/cards.js +1 -141
  180. package/vendor/desktop/renderer/avatar/hud.js +1 -206
  181. package/vendor/desktop/renderer/avatar/machine.js +1 -213
  182. package/vendor/desktop/renderer/avatar/pane.js +1 -439
  183. package/vendor/desktop/renderer/avatar/parts.js +1 -437
  184. package/vendor/desktop/renderer/budget.js +1 -172
  185. package/vendor/desktop/renderer/companion.js +1 -223
  186. package/vendor/desktop/renderer/diff.js +1 -359
  187. package/vendor/desktop/renderer/diffview.js +1 -336
  188. package/vendor/desktop/renderer/filepreview.js +1 -211
  189. package/vendor/desktop/renderer/fingerprint.js +3 -789
  190. package/vendor/desktop/renderer/markdown.js +1 -168
  191. package/vendor/desktop/renderer/provider-mark.js +1 -311
  192. package/vendor/desktop/renderer/provider-toolbar.js +1 -134
  193. package/vendor/desktop/renderer/providers.js +1 -259
  194. package/vendor/desktop/renderer/quick.js +1 -285
  195. package/vendor/desktop/renderer/stream-policy.js +1 -387
  196. package/vendor/desktop/renderer/transcript-view.js +1 -323
  197. package/vendor/desktop/renderer/usage.js +1 -1239
  198. package/vendor/desktop/vendor/aegis.js +1 -2441
  199. package/vendor/desktop/vendor/attest.js +1 -518
  200. package/vendor/desktop/vendor/authorship-key.js +1 -410
  201. package/vendor/desktop/vendor/auto-provision.js +1 -134
  202. package/vendor/desktop/vendor/brain-catalog.js +1 -268
  203. package/vendor/desktop/vendor/byok-catalog.js +1 -199
  204. package/vendor/desktop/vendor/catalog-client.js +1 -487
  205. package/vendor/desktop/vendor/conversation-export.js +1 -177
  206. package/vendor/desktop/vendor/credentials.js +1 -494
  207. package/vendor/desktop/vendor/device-fingerprint.js +1 -141
  208. package/vendor/desktop/vendor/drive-connect.js +1 -110
  209. package/vendor/desktop/vendor/drive-upload.js +1 -234
  210. package/vendor/desktop/vendor/env-file.js +1 -1273
  211. package/vendor/desktop/vendor/fingerprint.js +1 -1064
  212. package/vendor/desktop/vendor/foreign-memory.js +1 -669
  213. package/vendor/desktop/vendor/google-signin.js +1 -133
  214. package/vendor/desktop/vendor/hooks.js +1 -430
  215. package/vendor/desktop/vendor/model-discovery.js +1 -373
  216. package/vendor/desktop/vendor/naming.js +1 -283
  217. package/vendor/desktop/vendor/platform.js +1 -937
  218. package/vendor/desktop/vendor/prefs.js +1 -351
  219. package/vendor/desktop/vendor/presence-constants.js +1 -107
  220. package/vendor/desktop/vendor/presence.js +1 -438
  221. package/vendor/desktop/vendor/record-vault.js +3 -1055
  222. package/vendor/desktop/vendor/session-store.js +1 -575
  223. package/vendor/desktop/vendor/topup.js +1 -297
  224. package/vendor/desktop/vendor/touch.js +1 -458
  225. package/vendor/desktop/vendor/update.js +1 -763
  226. package/vendor/desktop/vendor/user-models.js +1 -381
@@ -1,587 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
- // Conveying a modified copy, or running one as a network service, owes the
5
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
- 'use strict';
7
-
8
- /**
9
- * System health — the nine machine checks, and the exact remedy for each.
10
- *
11
- * ## Why this module exists
12
- *
13
- * `system-problems.md` (2026-10-12, from the Windows machine `Dator`) is a
14
- * hand-assembled audit of the *host* rather than of AEGIS: no restore points
15
- * and a VSS that dies inside `DoSnapshotSet` (event 8193, `0x80070006`),
16
- * Windows 10 22H2 whose consumer-ESU window closed the day after the report,
17
- * two Kernel-Power 41 shutdowns with no dump to read, a Defender full scan that
18
- * has provably never run (`FullScanAge` = 0xFFFFFFFF), a spinning system disk,
19
- * a pending-reboot cleanup, recurring LoadPerf `WmiApRpl` errors, and a `python`
20
- * that is the Microsoft Store stub.
21
- *
22
- * The report is only useful if something re-runs it. That is this module's job:
23
- * the same nine findings, measured on the machine AEGIS is actually running on,
24
- * with the remedy printed verbatim instead of remembered.
25
- *
26
- * ## Three rules this module is built to keep
27
- *
28
- * 1. **Absence of evidence is not a pass.** Every check is tri-state: a finding,
29
- * clean, or *unassessed* with the reason. A probe that could not read
30
- * `FullScanAge` says so; it never renders as "Defender is fine". This is the
31
- * same defect that made an audit of this machine score 20/100 POOR purely
32
- * because an optional Python dependency was missing — a missing measurement
33
- * scored as `high`, and a crashing check scored as `ok`.
34
- * 2. **`0` and `false` are evidence.** `shadowCopies: 0` is the whole finding in
35
- * item 1; a truthiness test would silently drop it. Hence `has()`, not `if`.
36
- * 3. **Diagnose here, mutate never.** Nothing in this file changes the machine,
37
- * not even behind `fix`: `lodctr /R`, `vssadmin`, `net stop vss` and
38
- * `Start-MpScan` all need elevation, and the report's own ordering matters
39
- * (VSS has to be alive before a restore point can be created). So the output
40
- * is an ordered, copy-pasteable elevated script — `remedyScript()` — not a
41
- * silent rewrite. `cli/src/commands.js`'s `/doctor` has said the same thing
42
- * about the data directory since it was written: a diagnostic that quietly
43
- * changes the system is a surprise, not a fix.
44
- *
45
- * ## Shape
46
- *
47
- * `probeScript()` → one PowerShell program, one JSON object out (pure string).
48
- * `collect()` → runs it, win32 only; returns `{ ok, data }` or `{ ok:false,
49
- * reason }`. Never throws, never spawns on another platform.
50
- * `assess(raw)` → pure: `{ findings, clean, unassessed, summary }`.
51
- * `remedyScript()` → the ordered elevated fix, for the findings it can name.
52
- */
53
-
54
- const { spawnSync } = require('node:child_process');
55
-
56
- /** Severities, worst first. The order is the report's own priority ranking. */
57
- const SEVERITIES = ['critical', 'high', 'medium', 'low'];
58
-
59
- /** Rank for sorting: lower is worse. Unknown severities sort last. */
60
- function severityRank(sev) {
61
- const i = SEVERITIES.indexOf(sev);
62
- return i === -1 ? SEVERITIES.length : i;
63
- }
64
-
65
- /**
66
- * The nine checks, in the report's order, each with the remedy the report gives.
67
- *
68
- * `remedy` is data, not prose decoration: it is what `remedyScript()` and the
69
- * `/doctor system` panel print, so it is asserted in the tests character for
70
- * character. Where the report itself says "verify this, I could not", the remedy
71
- * says the same rather than inventing certainty.
72
- */
73
- const CHECKS = [
74
- {
75
- id: 'restore-protection',
76
- title: 'Restore protection',
77
- severity: 'critical',
78
- why: 'Without a restore point there is no way back from a bad driver or update.',
79
- remedy: 'Enable System Protection on C: and create a restore point — SystemPropertiesProtection.exe',
80
- },
81
- {
82
- id: 'vss-snapshot',
83
- title: 'VSS snapshot',
84
- severity: 'critical',
85
- why: 'Event 8193 inside DoSnapshotSet means the snapshot never completes, which is why no restore point exists.',
86
- remedy: 'vssadmin list writers → net stop vss && net stop swprv → net start swprv && net start vss',
87
- },
88
- {
89
- id: 'os-support',
90
- title: 'OS support window',
91
- severity: 'high',
92
- why: 'A build past its support end gets no security fixes; consumer ESU has its own closing date.',
93
- remedy: 'Verify ESU status in Windows Update, then plan Windows 11 (or a supported Linux) — Settings → Update & Security',
94
- },
95
- {
96
- id: 'unexpected-shutdown',
97
- title: 'Unexpected shutdowns',
98
- severity: 'high',
99
- why: 'Kernel-Power 41 with no bugcheck is a power loss or a hard lock, and an empty dump directory means the cause cannot be read after the fact.',
100
- remedy: 'powercfg /h off (kills fast startup) → check PSU and cabling → update BIOS',
101
- },
102
- {
103
- id: 'defender-full-scan',
104
- title: 'Defender full scan',
105
- severity: 'high',
106
- why: 'Real-time protection on with a full scan that has never run leaves an unscanned surface.',
107
- remedy: 'Start-MpScan -ScanType FullScan',
108
- },
109
- {
110
- id: 'system-disk',
111
- title: 'System disk',
112
- severity: 'medium',
113
- why: 'A mechanical system disk is the single largest cost on everything the machine does, updates included.',
114
- remedy: 'Plan an SSD (no action required today)',
115
- },
116
- {
117
- id: 'pending-reboot',
118
- title: 'Pending reboot',
119
- severity: 'low',
120
- why: 'Files deferred for deletion at next boot, and a long uptime, also deny VSS a clean start.',
121
- remedy: 'Restart at the next opportunity',
122
- },
123
- {
124
- id: 'perf-counters',
125
- title: 'Performance counters',
126
- severity: 'low',
127
- why: 'LoadPerf events naming WmiApRpl are cosmetic but they fill the event log.',
128
- remedy: 'lodctr /R (run twice in a row if the first pass does not clear it)',
129
- },
130
- {
131
- id: 'python-runtime',
132
- title: 'Python runtime',
133
- severity: 'low',
134
- why: '`python` resolving to WindowsApps is the Microsoft Store stub: it runs nothing and exits into the Store.',
135
- remedy: 'winget install Python.Python.3.12 — or turn the app-execution aliases off in Settings → Apps',
136
- },
137
- ];
138
-
139
- const CHECK_BY_ID = new Map(CHECKS.map((c) => [c.id, c]));
140
-
141
- /** Is this key present in the probe output at all? `0` and `false` count. */
142
- function has(raw, key) {
143
- return !!raw && Object.prototype.hasOwnProperty.call(raw, key) && raw[key] !== null && raw[key] !== undefined;
144
- }
145
-
146
- /** A number we are willing to compare, or null. */
147
- function num(v) {
148
- if (typeof v === 'number' && Number.isFinite(v)) return v;
149
- if (typeof v === 'string' && v.trim() !== '' && Number.isFinite(Number(v))) return Number(v);
150
- return null;
151
- }
152
-
153
- function gb(bytes) {
154
- const n = num(bytes);
155
- return n === null ? null : `${(n / 1024 ** 3).toFixed(1)} GB`;
156
- }
157
-
158
- function days(seconds) {
159
- const n = num(seconds);
160
- return n === null ? null : `${(n / 86400).toFixed(1)} days`;
161
- }
162
-
163
- /**
164
- * `FullScanAge` is written in *days*, and "never" is the sentinel 0xFFFFFFFF.
165
- * Reading that sentinel as a large number of days would be technically true and
166
- * completely useless, so it gets its own branch and its own words.
167
- */
168
- function fullScanPhrase(age) {
169
- const n = num(age);
170
- if (n === null) return null;
171
- if (n === 4294967295 || n >= 4294967295) return 'never (FullScanAge is 0xFFFFFFFF)';
172
- return `${n} days ago`;
173
- }
174
-
175
- /** The nine Windows 10 22H2 / build 19045 boundary, from the report. */
176
- const WIN10_22H2_END = '2025-10-14';
177
- const CONSUMER_ESU_END = '2026-10-13';
178
-
179
- /**
180
- * Assess a probe result. Pure — no clock, no filesystem, no platform branch.
181
- *
182
- * Returns every check in exactly one of three buckets, and the buckets always
183
- * account for all nine; a check that is in none of them is a bug in this file,
184
- * which `test/sysdiag.test.mjs` asserts against.
185
- */
186
- function assess(raw) {
187
- const findings = [];
188
- const clean = [];
189
- const unassessed = [];
190
-
191
- const finding = (id, detail, extra) => {
192
- const check = CHECK_BY_ID.get(id);
193
- findings.push({ ...check, detail, evidence: extra || {}, remedyText: check.remedy });
194
- };
195
- const passing = (id, detail) => clean.push({ ...CHECK_BY_ID.get(id), detail });
196
- const unknown = (id, reason) => unassessed.push({ ...CHECK_BY_ID.get(id), reason });
197
-
198
- const src = raw && typeof raw === 'object' ? raw : {};
199
-
200
- // 1. Restore protection — 0 shadow copies is the finding, so `has()` first.
201
- if (has(src, 'shadowCopies')) {
202
- const n = num(src.shadowCopies);
203
- const points = num(src.restorePoints);
204
- if (n === 0 || points === 0) {
205
- finding('restore-protection', `no shadow copies (${n ?? '?'}) and ${points ?? 'unknown'} restore point(s)`, {
206
- shadowCopies: n,
207
- restorePoints: points,
208
- });
209
- } else {
210
- passing('restore-protection', `${n} shadow copy(ies), ${points ?? 'unknown'} restore point(s)`);
211
- }
212
- } else {
213
- unknown('restore-protection', 'Win32_ShadowCopy returned nothing readable');
214
- }
215
-
216
- // 2. VSS — event 8193 is the report's reproduced failure, hr included.
217
- if (has(src, 'vss8193')) {
218
- const n = num(src.vss8193);
219
- if (n > 0) {
220
- const hr = src.vss8193Hr ? ` hr=${src.vss8193Hr}` : '';
221
- const when = src.vss8193Last ? ` last ${src.vss8193Last}` : '';
222
- finding('vss-snapshot', `${n} × event 8193 (Volume Shadow Copy failure)${hr}${when}`, {
223
- events: n,
224
- hr: src.vss8193Hr || null,
225
- last: src.vss8193Last || null,
226
- });
227
- } else {
228
- passing('vss-snapshot', 'no event 8193 in the window read');
229
- }
230
- } else {
231
- unknown('vss-snapshot', 'the Volume Shadow Copy event log was not read');
232
- }
233
-
234
- // 3. OS support window. The report could not settle whether ESU was active,
235
- // so neither does this: it states the window and asks for the confirmation.
236
- if (has(src, 'windowsCaption') || has(src, 'windowsBuild')) {
237
- const caption = src.windowsCaption ? String(src.windowsCaption) : 'Windows';
238
- const build = src.windowsBuild ? ` build ${src.windowsBuild}` : '';
239
- const win10 = /Windows 10/i.test(caption) || String(src.windowsBuild || '').startsWith('1904');
240
- if (win10) {
241
- const esu = has(src, 'esuKeyPresent') ? !!src.esuKeyPresent : null;
242
- const consumer = has(src, 'consumerEsuStatus') ? num(src.consumerEsuStatus) : null;
243
- const bits = [];
244
- bits.push(`mainstream support ended ${WIN10_22H2_END}`);
245
- bits.push(`consumer ESU ends at the latest ${CONSUMER_ESU_END}`);
246
- bits.push(esu === null ? 'ESU key presence not read' : esu ? 'ESU key present' : 'no ESU key in the registry');
247
- if (consumer !== null) bits.push(`win10ConsumerESUStatus=${consumer}`);
248
- finding('os-support', `${caption}${build} — ${bits.join('; ')}`, {
249
- caption,
250
- build: src.windowsBuild || null,
251
- esuKeyPresent: esu,
252
- consumerEsuStatus: consumer,
253
- });
254
- } else {
255
- passing('os-support', `${caption}${build}`);
256
- }
257
- } else {
258
- unknown('os-support', 'the OS version was not read');
259
- }
260
-
261
- // 4. Unexpected shutdowns + the dump that would explain them + fast startup.
262
- if (has(src, 'kernelPower41') || has(src, 'event6008')) {
263
- const kp = num(src.kernelPower41) || 0;
264
- const e6 = num(src.event6008) || 0;
265
- const dump = src.crashDumpEnabled === undefined ? null : num(src.crashDumpEnabled);
266
- const dumpFile = has(src, 'dumpFileExists') ? !!src.dumpFileExists : null;
267
- const miniDir = has(src, 'minidumpDirExists') ? !!src.minidumpDirExists : null;
268
- if (kp > 0) {
269
- const bits = [`${kp} × Kernel-Power 41`, `${e6} × unexpected-shutdown 6008`];
270
- if (dump !== null) bits.push(`CrashDumpEnabled=${dump}`);
271
- if (dumpFile !== null) bits.push(`MEMORY.DMP ${dumpFile ? 'present' : 'missing'}`);
272
- if (miniDir !== null) bits.push(`Minidump ${miniDir ? 'present' : 'missing'}`);
273
- const uptime = days(src.uptimeSeconds);
274
- if (uptime) bits.push(`uptime ${uptime}`);
275
- finding('unexpected-shutdown', bits.join(', '), {
276
- kernelPower41: kp,
277
- event6008: e6,
278
- crashDumpEnabled: dump,
279
- dumpFileExists: dumpFile,
280
- minidumpDirExists: miniDir,
281
- uptimeSeconds: num(src.uptimeSeconds),
282
- });
283
- } else {
284
- passing('unexpected-shutdown', `no Kernel-Power 41 in the window read (${e6} × 6008)`);
285
- }
286
- } else {
287
- unknown('unexpected-shutdown', 'the System log was not read');
288
- }
289
-
290
- // 5. Defender. `FullScanAge` is read here even when it is 0xFFFFFFFF, which is
291
- // exactly the case that used to be dropped by a truthiness test.
292
- if (has(src, 'defenderFullScanAge') || src.defenderAvailable === false) {
293
- if (src.defenderAvailable === false) {
294
- unknown('defender-full-scan', 'Get-MpComputerStatus is unavailable on this host');
295
- } else if (!has(src, 'defenderFullScanAge')) {
296
- // Available but the age never came back: still unmeasured, never a pass.
297
- unknown('defender-full-scan', 'Defender answered but FullScanAge was not in the reply');
298
- } else {
299
- const phrase = fullScanPhrase(src.defenderFullScanAge);
300
- const quick = src.quickScanEnd ? `quick scan ${src.quickScanEnd}` : 'no quick-scan timestamp';
301
- const realtime = src.defenderRealtime === undefined ? null : !!src.defenderRealtime;
302
- if (phrase === null || phrase.startsWith('never')) {
303
- finding(
304
- 'defender-full-scan',
305
- `full scan ${phrase || 'unreadable'}, ${quick}` +
306
- (realtime === null ? '' : `, real-time ${realtime ? 'on' : 'OFF'}`),
307
- { fullScanAge: num(src.defenderFullScanAge), quickScanEnd: src.quickScanEnd || null, realtime },
308
- );
309
- } else {
310
- passing('defender-full-scan', `full scan ${phrase}, ${quick}`);
311
- }
312
- }
313
- } else {
314
- unknown('defender-full-scan', 'Defender status was not read');
315
- }
316
-
317
- // 6. System disk. Advisory: a healthy HDD is still a slow machine, and the
318
- // report is explicit that nothing here is failing.
319
- if (has(src, 'diskMediaType') || has(src, 'freeBytes')) {
320
- const media = (src.diskMediaType && String(src.diskMediaType)) || 'unknown media';
321
- const model = src.diskModel ? String(src.diskModel) : '';
322
- const free = gb(src.freeBytes);
323
- const freePct = num(src.freeBytes) !== null && num(src.sizeBytes) ? Math.round((num(src.freeBytes) / num(src.sizeBytes)) * 100) : null;
324
- const spinning = /fixed hard disk|hdd/i.test(media) && !/ssd|solid/i.test(media);
325
- const detail = [model, media, free ? `${free} free${freePct === null ? '' : ` (${freePct}%)`}` : null]
326
- .filter(Boolean)
327
- .join(', ');
328
- if (spinning) {
329
- finding('system-disk', `${detail} — mechanical, so this is a performance ceiling, not a failure`, {
330
- media,
331
- model,
332
- freeBytes: num(src.freeBytes),
333
- });
334
- } else {
335
- passing('system-disk', detail || media);
336
- }
337
- } else {
338
- unknown('system-disk', 'the disk description was not read');
339
- }
340
-
341
- // 7. Pending reboot — deferred deletions at next boot, plus uptime.
342
- if (has(src, 'pendingRenameCount')) {
343
- const n = num(src.pendingRenameCount) || 0;
344
- const uptime = days(src.uptimeSeconds);
345
- if (n > 0) {
346
- finding('pending-reboot', `${n} deferred file operation(s) waiting for a restart${uptime ? `, uptime ${uptime}` : ''}`, {
347
- pendingRenameCount: n,
348
- uptimeSeconds: num(src.uptimeSeconds),
349
- });
350
- } else {
351
- passing('pending-reboot', `nothing pending${uptime ? `, uptime ${uptime}` : ''}`);
352
- }
353
- } else {
354
- unknown('pending-reboot', 'PendingFileRenameOperations was not read');
355
- }
356
-
357
- // 8. Performance counters.
358
- if (has(src, 'loadPerfEvents')) {
359
- const n = num(src.loadPerfEvents) || 0;
360
- const wmi = src.loadPerfWmiApRpl === undefined ? null : !!src.loadPerfWmiApRpl;
361
- if (n > 0) {
362
- finding('perf-counters', `${n} LoadPerf 1000/1001 event(s)${wmi === null ? '' : wmi ? ' naming WmiApRpl' : ''}`, {
363
- events: n,
364
- wmiApRpl: wmi,
365
- });
366
- } else {
367
- passing('perf-counters', 'no LoadPerf counter errors in the window read');
368
- }
369
- } else {
370
- unknown('perf-counters', 'the LoadPerf log was not read');
371
- }
372
-
373
- // 9. Python — the Store stub is a real path that runs nothing.
374
- if (has(src, 'pythonPath') || has(src, 'pyPresent')) {
375
- const p = src.pythonPath ? String(src.pythonPath) : '';
376
- const stub = /WindowsApps/i.test(p) || (has(src, 'pythonStoreStub') && !!src.pythonStoreStub);
377
- const py = has(src, 'pyPresent') ? !!src.pyPresent : null;
378
- if (stub || py === false) {
379
- finding(
380
- 'python-runtime',
381
- [p ? `python → ${p}${stub ? ' (Microsoft Store stub)' : ''}` : 'python not on PATH', py === null ? null : `py ${py ? 'present' : 'missing'}`]
382
- .filter(Boolean)
383
- .join(', '),
384
- { pythonPath: p || null, storeStub: stub, pyPresent: py },
385
- );
386
- } else {
387
- passing('python-runtime', `${p || 'python resolved'}${py ? ', py present' : ''}`);
388
- }
389
- } else {
390
- unknown('python-runtime', 'the Python resolution was not read');
391
- }
392
-
393
- findings.sort((a, b) => severityRank(a.severity) - severityRank(b.severity) || CHECKS.findIndex((c) => c.id === a.id) - CHECKS.findIndex((c) => c.id === b.id));
394
-
395
- return {
396
- findings,
397
- clean,
398
- unassessed,
399
- // `assessed` is a count of what was actually measured — never of the nine.
400
- summary: {
401
- assessed: findings.length + clean.length,
402
- total: CHECKS.length,
403
- findings: findings.length,
404
- unassessed: unassessed.length,
405
- worst: findings.length ? findings[0].severity : null,
406
- },
407
- };
408
- }
409
-
410
- /**
411
- * The probe: one PowerShell program, one JSON object on stdout.
412
- *
413
- * Read-only by construction — Get-*, Test-Path and Get-WinEvent only. Every
414
- * property is emitted even when it is empty so that `assess()` can tell
415
- * "measured zero" apart from "never measured"; `ConvertTo-Json -Depth 4
416
- * -Compress` keeps it to a single line for the caller to parse.
417
- */
418
- function probeScript() {
419
- return [
420
- '$ErrorActionPreference = "SilentlyContinue"',
421
- '$out = [ordered]@{}',
422
- // 1. Shadow copies — 0 is the finding, so the count is always emitted.
423
- '$sc = @(Get-CimInstance Win32_ShadowCopy)',
424
- '$out.shadowCopies = $sc.Count',
425
- '$rp = @(Get-CimInstance -ClassName Win32_ShadowCopy -Namespace root\\default)',
426
- '$out.restorePoints = (Get-ComputerRestorePoint | Measure-Object).Count',
427
- // 2. VSS 8193, last 30 days, plus the hr code inside the message.
428
- '$since = (Get-Date).AddDays(-30)',
429
- '$vss = @(Get-WinEvent -FilterHashtable @{LogName="Application"; ProviderName="VSS"; Id=8193; StartTime=$since})',
430
- '$out.vss8193 = $vss.Count',
431
- 'if ($vss.Count -gt 0) {',
432
- ' $m = $vss[0].Message',
433
- ' if ($m -match "0x[0-9a-fA-F]{8}") { $out.vss8193Hr = $Matches[0] }',
434
- ' $out.vss8193Last = $vss[0].TimeCreated.ToString("yyyy-MM-dd HH:mm:ss")',
435
- '}',
436
- // 3. OS + the ESU question the report could not settle.
437
- '$os = Get-CimInstance Win32_OperatingSystem',
438
- '$out.windowsCaption = $os.Caption',
439
- '$out.windowsBuild = $os.BuildNumber',
440
- '$out.windowsVersion = $os.Version',
441
- '$out.uptimeSeconds = [int]((Get-Date) - $os.LastBootUpTime).TotalSeconds',
442
- 'if ($os.LastBootUpTime) { $out.lastBoot = $os.LastBootUpTime.ToString("yyyy-MM-dd HH:mm:ss") }',
443
- '$out.esuKeyPresent = Test-Path "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ESU"',
444
- '$esu = Get-ItemProperty "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ESU" -Name win10ConsumerESUStatus -ErrorAction SilentlyContinue',
445
- 'if ($null -ne $esu) { $out.consumerEsuStatus = $esu.win10ConsumerESUStatus }',
446
- // 4. Shutdowns, the dump that would explain them, fast startup.
447
- '$kp = @(Get-WinEvent -FilterHashtable @{LogName="System"; ProviderName="Microsoft-Windows-Kernel-Power"; Id=41; StartTime=(Get-Date).AddDays(-14)})',
448
- '$out.kernelPower41 = $kp.Count',
449
- '$out.event6008 = @(Get-WinEvent -FilterHashtable @{LogName="System"; Id=6008; StartTime=(Get-Date).AddDays(-14)}).Count',
450
- '$cc = Get-ItemProperty "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\CrashControl" -ErrorAction SilentlyContinue',
451
- 'if ($cc) { $out.crashDumpEnabled = $cc.CrashDumpEnabled; $out.dumpFilePath = $cc.DumpFile }',
452
- '$out.dumpFileExists = Test-Path "C:\\Windows\\MEMORY.DMP"',
453
- '$out.minidumpDirExists = Test-Path "C:\\Windows\\Minidump"',
454
- '$pwr = Get-ItemProperty "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power" -Name HiberbootEnabled -ErrorAction SilentlyContinue',
455
- 'if ($null -ne $pwr) { $out.hiberbootEnabled = $pwr.HiberbootEnabled }',
456
- // 5. Defender.
457
- '$mp = Get-MpComputerStatus -ErrorAction SilentlyContinue',
458
- 'if ($null -ne $mp) {',
459
- ' $out.defenderAvailable = $true',
460
- ' $out.defenderFullScanAge = $mp.FullScanAge',
461
- ' $out.defenderRealtime = $mp.RealTimeProtectionEnabled',
462
- ' if ($mp.QuickScanEndTime) { $out.quickScanEnd = $mp.QuickScanEndTime.ToString("yyyy-MM-dd HH:mm") }',
463
- ' if ($mp.FullScanEndTime) { $out.fullScanEnd = $mp.FullScanEndTime.ToString("yyyy-MM-dd HH:mm") }',
464
- '} else { $out.defenderAvailable = $false }',
465
- // 6. The system disk.
466
- '$d = Get-CimInstance Win32_DiskDrive | Where-Object { $_.Index -eq 0 } | Select-Object -First 1',
467
- 'if ($d) { $out.diskModel = $d.Model; $out.diskMediaType = $d.MediaType; $out.sizeBytes = [int64]$d.Size; $out.diskHealth = $d.Status }',
468
- '$c = Get-CimInstance Win32_LogicalDisk -Filter "DeviceID=\'C:\'"',
469
- 'if ($c) { $out.freeBytes = [int64]$c.FreeSpace; $out.sizeBytes = [int64]$c.Size }',
470
- // 7. Pending reboot.
471
- '$sm = Get-ItemProperty "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager" -Name PendingFileRenameOperations -ErrorAction SilentlyContinue',
472
- 'if ($null -ne $sm) { $out.pendingRenameCount = @($sm.PendingFileRenameOperations).Count }',
473
- // 8. LoadPerf counters.
474
- '$lp = @(Get-WinEvent -FilterHashtable @{LogName="Application"; ProviderName="Microsoft-Windows-LoadPerf"; StartTime=(Get-Date).AddDays(-14)})',
475
- '$out.loadPerfEvents = $lp.Count',
476
- 'if ($lp.Count -gt 0) { $out.loadPerfWmiApRpl = [bool]($lp | Where-Object { $_.Message -match "WmiApRpl" } | Select-Object -First 1) }',
477
- // 9. Python — the path is the evidence, WindowsApps means the Store stub.
478
- '$py = Get-Command python -ErrorAction SilentlyContinue',
479
- 'if ($py) { $out.pythonPath = $py.Source; $out.pythonStoreStub = [bool]($py.Source -match "WindowsApps") } else { $out.pythonPath = "" }',
480
- '$out.pyPresent = [bool](Get-Command py -ErrorAction SilentlyContinue)',
481
- '$out.pythonCore = [bool](Test-Path "HKLM:\\SOFTWARE\\Python\\PythonCore")',
482
- '$out | ConvertTo-Json -Depth 4 -Compress',
483
- ].join('\n');
484
- }
485
-
486
- /**
487
- * Run the probe — on Windows only.
488
- *
489
- * Returns `{ ok: true, data }`, `{ ok: false, reason }`, or `{ ok: false,
490
- * reason: 'not-windows' }`. It never throws and never spawns a process on
491
- * another platform: a Linux or macOS run must not be reported as a machine
492
- * check that found nothing.
493
- */
494
- function collect(opts) {
495
- const o = opts || {};
496
- const platform = o.platform || process.platform;
497
- if (platform !== 'win32') return { ok: false, reason: 'not-windows', platform };
498
- const run = o.spawnSync || spawnSync;
499
- const exe = o.powershell || 'powershell.exe';
500
- const timeout = o.timeoutMs || 60000;
501
- let res;
502
- try {
503
- res = run(exe, ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-Command', probeScript()], {
504
- timeout,
505
- maxBuffer: 8 * 1024 * 1024,
506
- windowsHide: true,
507
- encoding: 'utf8',
508
- });
509
- } catch (err) {
510
- return { ok: false, reason: `probe failed to start: ${err && err.message ? err.message : err}` };
511
- }
512
- if (!res || res.error) return { ok: false, reason: `probe failed to start: ${(res && res.error && res.error.message) || 'unknown'}` };
513
- if (res.status !== 0) {
514
- const err = String(res.stderr || '').trim().split('\n')[0];
515
- return { ok: false, reason: `probe exited ${res.status}${err ? `: ${err}` : ''}` };
516
- }
517
- const text = String(res.stdout || '').trim();
518
- if (!text) return { ok: false, reason: 'probe returned nothing' };
519
- try {
520
- return { ok: true, data: JSON.parse(text.split('\n').filter(Boolean).pop()) };
521
- } catch {
522
- return { ok: false, reason: 'probe output was not JSON' };
523
- }
524
- }
525
-
526
- /**
527
- * The ordered remedy, as one elevated PowerShell program.
528
- *
529
- * Order is the report's, and it is not cosmetic: point 1 (no restore point) is
530
- * *caused* by point 2 (VSS dying in DoSnapshotSet), so VSS is repaired first and
531
- * system protection is enabled after. Nothing here is executed by this module.
532
- */
533
- function remedyScript() {
534
- return [
535
- '# Run in an ELEVATED PowerShell (Run as Administrator).',
536
- '# Order matters: VSS has to survive DoSnapshotSet before a restore point can exist.',
537
- '',
538
- '# 2. VSS — see which writer is not Stable, then restart the two services.',
539
- 'vssadmin list writers',
540
- 'vssadmin list providers',
541
- 'net stop vss',
542
- 'net stop swprv',
543
- 'net start swprv',
544
- 'net start vss',
545
- '',
546
- '# System files, if 8193 survives the restart.',
547
- 'sfc /scannow',
548
- 'DISM /Online /Cleanup-Image /RestoreHealth',
549
- '',
550
- '# 1. Restore protection — only meaningful once VSS completes.',
551
- 'Enable-ComputerRestore -Drive "C:\\"',
552
- 'Checkpoint-Computer -Description "AEGIS baseline" -RestorePointType MODIFY_SETTINGS',
553
- 'Get-ComputerRestorePoint',
554
- '',
555
- '# 4. No more mystery shutdowns: fast startup off, so a shutdown is a shutdown.',
556
- 'powercfg /h off # removes hiberfil.sys, fast startup and the hard-lock blur',
557
- '# then: check PSU and cabling, and look for a newer BIOS.',
558
- '',
559
- '# 5. Defender — a full scan has never run on this machine.',
560
- 'Start-MpScan -ScanType FullScan',
561
- '',
562
- '# 8. Performance counters.',
563
- 'lodctr /R',
564
- 'lodctr /R # run twice in a row if the first pass does not clear it',
565
- '',
566
- '# 9. Python, if you want one:',
567
- 'winget install Python.Python.3.12',
568
- '',
569
- '# 3. This one cannot be scripted — verify it by hand:',
570
- '# Settings -> Update & Security -> Windows Update (ESU status)',
571
- '# Windows 10 22H2 mainstream support ended 2025-10-14;',
572
- '# consumer ESU ends at the latest 2026-10-13.',
573
- '',
574
- '# 7. Then restart: it clears the deferred files AND gives VSS a clean start.',
575
- ].join('\n');
576
- }
577
-
578
- module.exports = {
579
- CHECKS,
580
- SEVERITIES,
581
- assess,
582
- collect,
583
- probeScript,
584
- remedyScript,
585
- fullScanPhrase,
586
- severityRank,
587
- };
3
+ "use strict";const{spawnSync:spawnSync}=require("node:child_process"),SEVERITIES=["critical","high","medium","low"];function severityRank(e){const t=SEVERITIES.indexOf(e);return-1===t?SEVERITIES.length:t}const CHECKS=[{id:"restore-protection",title:"Restore protection",severity:"critical",why:"Without a restore point there is no way back from a bad driver or update.",remedy:"Enable System Protection on C: and create a restore point — SystemPropertiesProtection.exe"},{id:"vss-snapshot",title:"VSS snapshot",severity:"critical",why:"Event 8193 inside DoSnapshotSet means the snapshot never completes, which is why no restore point exists.",remedy:"vssadmin list writers → net stop vss && net stop swprv → net start swprv && net start vss"},{id:"os-support",title:"OS support window",severity:"high",why:"A build past its support end gets no security fixes; consumer ESU has its own closing date.",remedy:"Verify ESU status in Windows Update, then plan Windows 11 (or a supported Linux) — Settings → Update & Security"},{id:"unexpected-shutdown",title:"Unexpected shutdowns",severity:"high",why:"Kernel-Power 41 with no bugcheck is a power loss or a hard lock, and an empty dump directory means the cause cannot be read after the fact.",remedy:"powercfg /h off (kills fast startup) → check PSU and cabling → update BIOS"},{id:"defender-full-scan",title:"Defender full scan",severity:"high",why:"Real-time protection on with a full scan that has never run leaves an unscanned surface.",remedy:"Start-MpScan -ScanType FullScan"},{id:"system-disk",title:"System disk",severity:"medium",why:"A mechanical system disk is the single largest cost on everything the machine does, updates included.",remedy:"Plan an SSD (no action required today)"},{id:"pending-reboot",title:"Pending reboot",severity:"low",why:"Files deferred for deletion at next boot, and a long uptime, also deny VSS a clean start.",remedy:"Restart at the next opportunity"},{id:"perf-counters",title:"Performance counters",severity:"low",why:"LoadPerf events naming WmiApRpl are cosmetic but they fill the event log.",remedy:"lodctr /R (run twice in a row if the first pass does not clear it)"},{id:"python-runtime",title:"Python runtime",severity:"low",why:"`python` resolving to WindowsApps is the Microsoft Store stub: it runs nothing and exits into the Store.",remedy:"winget install Python.Python.3.12 — or turn the app-execution aliases off in Settings → Apps"}],CHECK_BY_ID=new Map(CHECKS.map((e=>[e.id,e])));function has(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)&&null!==e[t]&&void 0!==e[t]}function num(e){return"number"==typeof e&&Number.isFinite(e)?e:"string"==typeof e&&""!==e.trim()&&Number.isFinite(Number(e))?Number(e):null}function gb(e){const t=num(e);return null===t?null:`${(t/1024**3).toFixed(1)} GB`}function days(e){const t=num(e);return null===t?null:`${(t/86400).toFixed(1)} days`}function fullScanPhrase(e){const t=num(e);return null===t?null:4294967295===t||t>=4294967295?"never (FullScanAge is 0xFFFFFFFF)":`${t} days ago`}const WIN10_22H2_END="2025-10-14",CONSUMER_ESU_END="2026-10-13";function assess(e){const t=[],n=[],s=[],o=(e,n,s)=>{const o=CHECK_BY_ID.get(e);t.push({...o,detail:n,evidence:s||{},remedyText:o.remedy})},i=(e,t)=>n.push({...CHECK_BY_ID.get(e),detail:t}),r=(e,t)=>s.push({...CHECK_BY_ID.get(e),reason:t}),a=e&&"object"==typeof e?e:{};if(has(a,"shadowCopies")){const e=num(a.shadowCopies),t=num(a.restorePoints);0===e||0===t?o("restore-protection",`no shadow copies (${e??"?"}) and ${t??"unknown"} restore point(s)`,{shadowCopies:e,restorePoints:t}):i("restore-protection",`${e} shadow copy(ies), ${t??"unknown"} restore point(s)`)}else r("restore-protection","Win32_ShadowCopy returned nothing readable");if(has(a,"vss8193")){const e=num(a.vss8193);e>0?o("vss-snapshot",`${e} × event 8193 (Volume Shadow Copy failure)${a.vss8193Hr?` hr=${a.vss8193Hr}`:""}${a.vss8193Last?` last ${a.vss8193Last}`:""}`,{events:e,hr:a.vss8193Hr||null,last:a.vss8193Last||null}):i("vss-snapshot","no event 8193 in the window read")}else r("vss-snapshot","the Volume Shadow Copy event log was not read");if(has(a,"windowsCaption")||has(a,"windowsBuild")){const e=a.windowsCaption?String(a.windowsCaption):"Windows",t=a.windowsBuild?` build ${a.windowsBuild}`:"";if(/Windows 10/i.test(e)||String(a.windowsBuild||"").startsWith("1904")){const n=has(a,"esuKeyPresent")?!!a.esuKeyPresent:null,s=has(a,"consumerEsuStatus")?num(a.consumerEsuStatus):null,i=[];i.push("mainstream support ended 2025-10-14"),i.push("consumer ESU ends at the latest 2026-10-13"),i.push(null===n?"ESU key presence not read":n?"ESU key present":"no ESU key in the registry"),null!==s&&i.push(`win10ConsumerESUStatus=${s}`),o("os-support",`${e}${t} — ${i.join("; ")}`,{caption:e,build:a.windowsBuild||null,esuKeyPresent:n,consumerEsuStatus:s})}else i("os-support",`${e}${t}`)}else r("os-support","the OS version was not read");if(has(a,"kernelPower41")||has(a,"event6008")){const e=num(a.kernelPower41)||0,t=num(a.event6008)||0,n=void 0===a.crashDumpEnabled?null:num(a.crashDumpEnabled),s=has(a,"dumpFileExists")?!!a.dumpFileExists:null,r=has(a,"minidumpDirExists")?!!a.minidumpDirExists:null;if(e>0){const i=[`${e} × Kernel-Power 41`,`${t} × unexpected-shutdown 6008`];null!==n&&i.push(`CrashDumpEnabled=${n}`),null!==s&&i.push("MEMORY.DMP "+(s?"present":"missing")),null!==r&&i.push("Minidump "+(r?"present":"missing"));const l=days(a.uptimeSeconds);l&&i.push(`uptime ${l}`),o("unexpected-shutdown",i.join(", "),{kernelPower41:e,event6008:t,crashDumpEnabled:n,dumpFileExists:s,minidumpDirExists:r,uptimeSeconds:num(a.uptimeSeconds)})}else i("unexpected-shutdown",`no Kernel-Power 41 in the window read (${t} × 6008)`)}else r("unexpected-shutdown","the System log was not read");if(has(a,"defenderFullScanAge")||!1===a.defenderAvailable)if(!1===a.defenderAvailable)r("defender-full-scan","Get-MpComputerStatus is unavailable on this host");else if(has(a,"defenderFullScanAge")){const e=fullScanPhrase(a.defenderFullScanAge),t=a.quickScanEnd?`quick scan ${a.quickScanEnd}`:"no quick-scan timestamp",n=void 0===a.defenderRealtime?null:!!a.defenderRealtime;null===e||e.startsWith("never")?o("defender-full-scan",`full scan ${e||"unreadable"}, ${t}`+(null===n?"":", real-time "+(n?"on":"OFF")),{fullScanAge:num(a.defenderFullScanAge),quickScanEnd:a.quickScanEnd||null,realtime:n}):i("defender-full-scan",`full scan ${e}, ${t}`)}else r("defender-full-scan","Defender answered but FullScanAge was not in the reply");else r("defender-full-scan","Defender status was not read");if(has(a,"diskMediaType")||has(a,"freeBytes")){const e=a.diskMediaType&&String(a.diskMediaType)||"unknown media",t=a.diskModel?String(a.diskModel):"",n=gb(a.freeBytes),s=null!==num(a.freeBytes)&&num(a.sizeBytes)?Math.round(num(a.freeBytes)/num(a.sizeBytes)*100):null,r=/fixed hard disk|hdd/i.test(e)&&!/ssd|solid/i.test(e),l=[t,e,n?`${n} free${null===s?"":` (${s}%)`}`:null].filter(Boolean).join(", ");r?o("system-disk",`${l} — mechanical, so this is a performance ceiling, not a failure`,{media:e,model:t,freeBytes:num(a.freeBytes)}):i("system-disk",l||e)}else r("system-disk","the disk description was not read");if(has(a,"pendingRenameCount")){const e=num(a.pendingRenameCount)||0,t=days(a.uptimeSeconds);e>0?o("pending-reboot",`${e} deferred file operation(s) waiting for a restart${t?`, uptime ${t}`:""}`,{pendingRenameCount:e,uptimeSeconds:num(a.uptimeSeconds)}):i("pending-reboot","nothing pending"+(t?`, uptime ${t}`:""))}else r("pending-reboot","PendingFileRenameOperations was not read");if(has(a,"loadPerfEvents")){const e=num(a.loadPerfEvents)||0,t=void 0===a.loadPerfWmiApRpl?null:!!a.loadPerfWmiApRpl;e>0?o("perf-counters",`${e} LoadPerf 1000/1001 event(s)${null===t?"":t?" naming WmiApRpl":""}`,{events:e,wmiApRpl:t}):i("perf-counters","no LoadPerf counter errors in the window read")}else r("perf-counters","the LoadPerf log was not read");if(has(a,"pythonPath")||has(a,"pyPresent")){const e=a.pythonPath?String(a.pythonPath):"",t=/WindowsApps/i.test(e)||has(a,"pythonStoreStub")&&!!a.pythonStoreStub,n=has(a,"pyPresent")?!!a.pyPresent:null;t||!1===n?o("python-runtime",[e?`python → ${e}${t?" (Microsoft Store stub)":""}`:"python not on PATH",null===n?null:"py "+(n?"present":"missing")].filter(Boolean).join(", "),{pythonPath:e||null,storeStub:t,pyPresent:n}):i("python-runtime",`${e||"python resolved"}${n?", py present":""}`)}else r("python-runtime","the Python resolution was not read");return t.sort(((e,t)=>severityRank(e.severity)-severityRank(t.severity)||CHECKS.findIndex((t=>t.id===e.id))-CHECKS.findIndex((e=>e.id===t.id)))),{findings:t,clean:n,unassessed:s,summary:{assessed:t.length+n.length,total:CHECKS.length,findings:t.length,unassessed:s.length,worst:t.length?t[0].severity:null}}}function probeScript(){return['$ErrorActionPreference = "SilentlyContinue"',"$out = [ordered]@{}","$sc = @(Get-CimInstance Win32_ShadowCopy)","$out.shadowCopies = $sc.Count","$rp = @(Get-CimInstance -ClassName Win32_ShadowCopy -Namespace root\\default)","$out.restorePoints = (Get-ComputerRestorePoint | Measure-Object).Count","$since = (Get-Date).AddDays(-30)",'$vss = @(Get-WinEvent -FilterHashtable @{LogName="Application"; ProviderName="VSS"; Id=8193; StartTime=$since})',"$out.vss8193 = $vss.Count","if ($vss.Count -gt 0) {"," $m = $vss[0].Message",' if ($m -match "0x[0-9a-fA-F]{8}") { $out.vss8193Hr = $Matches[0] }',' $out.vss8193Last = $vss[0].TimeCreated.ToString("yyyy-MM-dd HH:mm:ss")',"}","$os = Get-CimInstance Win32_OperatingSystem","$out.windowsCaption = $os.Caption","$out.windowsBuild = $os.BuildNumber","$out.windowsVersion = $os.Version","$out.uptimeSeconds = [int]((Get-Date) - $os.LastBootUpTime).TotalSeconds",'if ($os.LastBootUpTime) { $out.lastBoot = $os.LastBootUpTime.ToString("yyyy-MM-dd HH:mm:ss") }','$out.esuKeyPresent = Test-Path "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ESU"','$esu = Get-ItemProperty "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ESU" -Name win10ConsumerESUStatus -ErrorAction SilentlyContinue',"if ($null -ne $esu) { $out.consumerEsuStatus = $esu.win10ConsumerESUStatus }",'$kp = @(Get-WinEvent -FilterHashtable @{LogName="System"; ProviderName="Microsoft-Windows-Kernel-Power"; Id=41; StartTime=(Get-Date).AddDays(-14)})',"$out.kernelPower41 = $kp.Count",'$out.event6008 = @(Get-WinEvent -FilterHashtable @{LogName="System"; Id=6008; StartTime=(Get-Date).AddDays(-14)}).Count','$cc = Get-ItemProperty "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\CrashControl" -ErrorAction SilentlyContinue',"if ($cc) { $out.crashDumpEnabled = $cc.CrashDumpEnabled; $out.dumpFilePath = $cc.DumpFile }",'$out.dumpFileExists = Test-Path "C:\\Windows\\MEMORY.DMP"','$out.minidumpDirExists = Test-Path "C:\\Windows\\Minidump"','$pwr = Get-ItemProperty "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power" -Name HiberbootEnabled -ErrorAction SilentlyContinue',"if ($null -ne $pwr) { $out.hiberbootEnabled = $pwr.HiberbootEnabled }","$mp = Get-MpComputerStatus -ErrorAction SilentlyContinue","if ($null -ne $mp) {"," $out.defenderAvailable = $true"," $out.defenderFullScanAge = $mp.FullScanAge"," $out.defenderRealtime = $mp.RealTimeProtectionEnabled",' if ($mp.QuickScanEndTime) { $out.quickScanEnd = $mp.QuickScanEndTime.ToString("yyyy-MM-dd HH:mm") }',' if ($mp.FullScanEndTime) { $out.fullScanEnd = $mp.FullScanEndTime.ToString("yyyy-MM-dd HH:mm") }',"} else { $out.defenderAvailable = $false }","$d = Get-CimInstance Win32_DiskDrive | Where-Object { $_.Index -eq 0 } | Select-Object -First 1","if ($d) { $out.diskModel = $d.Model; $out.diskMediaType = $d.MediaType; $out.sizeBytes = [int64]$d.Size; $out.diskHealth = $d.Status }","$c = Get-CimInstance Win32_LogicalDisk -Filter \"DeviceID='C:'\"","if ($c) { $out.freeBytes = [int64]$c.FreeSpace; $out.sizeBytes = [int64]$c.Size }",'$sm = Get-ItemProperty "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager" -Name PendingFileRenameOperations -ErrorAction SilentlyContinue',"if ($null -ne $sm) { $out.pendingRenameCount = @($sm.PendingFileRenameOperations).Count }",'$lp = @(Get-WinEvent -FilterHashtable @{LogName="Application"; ProviderName="Microsoft-Windows-LoadPerf"; StartTime=(Get-Date).AddDays(-14)})',"$out.loadPerfEvents = $lp.Count",'if ($lp.Count -gt 0) { $out.loadPerfWmiApRpl = [bool]($lp | Where-Object { $_.Message -match "WmiApRpl" } | Select-Object -First 1) }',"$py = Get-Command python -ErrorAction SilentlyContinue",'if ($py) { $out.pythonPath = $py.Source; $out.pythonStoreStub = [bool]($py.Source -match "WindowsApps") } else { $out.pythonPath = "" }',"$out.pyPresent = [bool](Get-Command py -ErrorAction SilentlyContinue)",'$out.pythonCore = [bool](Test-Path "HKLM:\\SOFTWARE\\Python\\PythonCore")',"$out | ConvertTo-Json -Depth 4 -Compress"].join("\n")}function collect(e){const t=e||{},n=t.platform||process.platform;if("win32"!==n)return{ok:!1,reason:"not-windows",platform:n};const s=t.spawnSync||spawnSync,o=t.powershell||"powershell.exe",i=t.timeoutMs||6e4;let r;try{r=s(o,["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command",probeScript()],{timeout:i,maxBuffer:8388608,windowsHide:!0,encoding:"utf8"})}catch(e){return{ok:!1,reason:`probe failed to start: ${e&&e.message?e.message:e}`}}if(!r||r.error)return{ok:!1,reason:`probe failed to start: ${r&&r.error&&r.error.message||"unknown"}`};if(0!==r.status){const e=String(r.stderr||"").trim().split("\n")[0];return{ok:!1,reason:`probe exited ${r.status}${e?`: ${e}`:""}`}}const a=String(r.stdout||"").trim();if(!a)return{ok:!1,reason:"probe returned nothing"};try{return{ok:!0,data:JSON.parse(a.split("\n").filter(Boolean).pop())}}catch{return{ok:!1,reason:"probe output was not JSON"}}}function remedyScript(){return["# Run in an ELEVATED PowerShell (Run as Administrator).","# Order matters: VSS has to survive DoSnapshotSet before a restore point can exist.","","# 2. VSS — see which writer is not Stable, then restart the two services.","vssadmin list writers","vssadmin list providers","net stop vss","net stop swprv","net start swprv","net start vss","","# System files, if 8193 survives the restart.","sfc /scannow","DISM /Online /Cleanup-Image /RestoreHealth","","# 1. Restore protection — only meaningful once VSS completes.",'Enable-ComputerRestore -Drive "C:\\"','Checkpoint-Computer -Description "AEGIS baseline" -RestorePointType MODIFY_SETTINGS',"Get-ComputerRestorePoint","","# 4. No more mystery shutdowns: fast startup off, so a shutdown is a shutdown.","powercfg /h off # removes hiberfil.sys, fast startup and the hard-lock blur","# then: check PSU and cabling, and look for a newer BIOS.","","# 5. Defender — a full scan has never run on this machine.","Start-MpScan -ScanType FullScan","","# 8. Performance counters.","lodctr /R","lodctr /R # run twice in a row if the first pass does not clear it","","# 9. Python, if you want one:","winget install Python.Python.3.12","","# 3. This one cannot be scripted — verify it by hand:","# Settings -> Update & Security -> Windows Update (ESU status)","# Windows 10 22H2 mainstream support ended 2025-10-14;","# consumer ESU ends at the latest 2026-10-13.","","# 7. Then restart: it clears the deferred files AND gives VSS a clean start."].join("\n")}module.exports={CHECKS:CHECKS,SEVERITIES:SEVERITIES,assess:assess,collect:collect,probeScript:probeScript,remedyScript:remedyScript,fullScanPhrase:fullScanPhrase,severityRank:severityRank};
@@ -1,42 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
- // Conveying a modified copy, or running one as a network service, owes the
5
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
- 'use strict';
7
-
8
- /**
9
- * Small system helpers: best-effort URL opening (never blocks or errors) and
10
- * a few constants shared by the support/easter-egg commands.
11
- *
12
- * Ported from the upstream engine reference (ESM → CommonJS). The URLS table
13
- * pointed at Anthropic/Claude support endpoints; those are re-homed to the
14
- * AEGIS base (https://aegiscloud.org) and the project repo. Deep paths that
15
- * had no AEGIS equivalent collapse to the base rather than inventing a route.
16
- */
17
-
18
- const { spawn } = require('node:child_process');
19
-
20
- /** Best-effort open of a URL in the system browser. Returns true if launched. */
21
- function openUrl(url) {
22
- try {
23
- const platform = process.platform;
24
- const cmd = platform === 'darwin' ? ['open'] : platform === 'win32' ? ['cmd', '/c', 'start', ''] : ['xdg-open'];
25
- const child = spawn(cmd[0], [...cmd.slice(1), url], { stdio: 'ignore', detached: true });
26
- child.unref();
27
- return true;
28
- } catch {
29
- return false;
30
- }
31
- }
32
-
33
- // AEGIS support URLs (used by /troubleshooting, /feedback…).
34
- const URLS = {
35
- troubleshooting: 'https://aegiscloud.org',
36
- feedback: 'https://aegiscloud.org',
37
- issues: 'https://aegiscloud.org',
38
- docs: 'https://aegiscloud.org',
39
- radio: 'https://www.youtube.com/watch?v=cP8jB6YQWbQ',
40
- };
41
-
42
- module.exports = { openUrl, URLS };
3
+ "use strict";const{spawn:spawn}=require("node:child_process");function openUrl(o){try{const s=process.platform,t="darwin"===s?["open"]:"win32"===s?["cmd","/c","start",""]:["xdg-open"];return spawn(t[0],[...t.slice(1),o],{stdio:"ignore",detached:!0}).unref(),!0}catch{return!1}}const URLS={troubleshooting:"https://aegiscloud.org",feedback:"https://aegiscloud.org",issues:"https://aegiscloud.org",docs:"https://aegiscloud.org",radio:"https://www.youtube.com/watch?v=cP8jB6YQWbQ"};module.exports={openUrl:openUrl,URLS:URLS};