@namzu/sandbox 23.0.1 → 25.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/CHANGELOG.md +290 -0
  2. package/dist/backends/http-worker-client.d.ts +3 -1
  3. package/dist/backends/http-worker-client.d.ts.map +1 -1
  4. package/dist/backends/http-worker-client.js +15 -4
  5. package/dist/backends/http-worker-client.js.map +1 -1
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +1 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/local-virtual-computer/client.d.ts +21 -0
  11. package/dist/local-virtual-computer/client.d.ts.map +1 -0
  12. package/dist/local-virtual-computer/client.js +503 -0
  13. package/dist/local-virtual-computer/client.js.map +1 -0
  14. package/dist/local-virtual-computer/detached-process.d.ts +15 -0
  15. package/dist/local-virtual-computer/detached-process.d.ts.map +1 -0
  16. package/dist/local-virtual-computer/detached-process.js +111 -0
  17. package/dist/local-virtual-computer/detached-process.js.map +1 -0
  18. package/dist/local-virtual-computer/detached-worker.d.ts +11 -0
  19. package/dist/local-virtual-computer/detached-worker.d.ts.map +1 -0
  20. package/dist/local-virtual-computer/detached-worker.js +97 -0
  21. package/dist/local-virtual-computer/detached-worker.js.map +1 -0
  22. package/dist/local-virtual-computer/dialect.d.ts +26 -0
  23. package/dist/local-virtual-computer/dialect.d.ts.map +1 -0
  24. package/dist/local-virtual-computer/dialect.js +61 -0
  25. package/dist/local-virtual-computer/dialect.js.map +1 -0
  26. package/dist/local-virtual-computer/engine.d.ts +63 -0
  27. package/dist/local-virtual-computer/engine.d.ts.map +1 -0
  28. package/dist/local-virtual-computer/engine.js +125 -0
  29. package/dist/local-virtual-computer/engine.js.map +1 -0
  30. package/dist/local-virtual-computer/guest-stdio.d.ts +15 -0
  31. package/dist/local-virtual-computer/guest-stdio.d.ts.map +1 -0
  32. package/dist/local-virtual-computer/guest-stdio.js +330 -0
  33. package/dist/local-virtual-computer/guest-stdio.js.map +1 -0
  34. package/dist/local-virtual-computer/index.d.ts +36 -0
  35. package/dist/local-virtual-computer/index.d.ts.map +1 -0
  36. package/dist/local-virtual-computer/index.js +341 -0
  37. package/dist/local-virtual-computer/index.js.map +1 -0
  38. package/dist/local-virtual-computer/podman-machine.d.ts +17 -0
  39. package/dist/local-virtual-computer/podman-machine.d.ts.map +1 -0
  40. package/dist/local-virtual-computer/podman-machine.js +181 -0
  41. package/dist/local-virtual-computer/podman-machine.js.map +1 -0
  42. package/dist/local-virtual-computer/setup/contract.d.ts +360 -0
  43. package/dist/local-virtual-computer/setup/contract.d.ts.map +1 -0
  44. package/dist/local-virtual-computer/setup/contract.js +3 -0
  45. package/dist/local-virtual-computer/setup/contract.js.map +1 -0
  46. package/dist/local-virtual-computer/setup/elevated.d.ts +78 -0
  47. package/dist/local-virtual-computer/setup/elevated.d.ts.map +1 -0
  48. package/dist/local-virtual-computer/setup/elevated.js +548 -0
  49. package/dist/local-virtual-computer/setup/elevated.js.map +1 -0
  50. package/dist/local-virtual-computer/setup/host.d.ts +12 -0
  51. package/dist/local-virtual-computer/setup/host.d.ts.map +1 -0
  52. package/dist/local-virtual-computer/setup/host.js +93 -0
  53. package/dist/local-virtual-computer/setup/host.js.map +1 -0
  54. package/dist/local-virtual-computer/setup/idle.d.ts +18 -0
  55. package/dist/local-virtual-computer/setup/idle.d.ts.map +1 -0
  56. package/dist/local-virtual-computer/setup/idle.js +38 -0
  57. package/dist/local-virtual-computer/setup/idle.js.map +1 -0
  58. package/dist/local-virtual-computer/setup/image.d.ts +7 -0
  59. package/dist/local-virtual-computer/setup/image.d.ts.map +1 -0
  60. package/dist/local-virtual-computer/setup/image.js +124 -0
  61. package/dist/local-virtual-computer/setup/image.js.map +1 -0
  62. package/dist/local-virtual-computer/setup/index.d.ts +17 -0
  63. package/dist/local-virtual-computer/setup/index.d.ts.map +1 -0
  64. package/dist/local-virtual-computer/setup/index.js +17 -0
  65. package/dist/local-virtual-computer/setup/index.js.map +1 -0
  66. package/dist/local-virtual-computer/setup/limits.d.ts +30 -0
  67. package/dist/local-virtual-computer/setup/limits.d.ts.map +1 -0
  68. package/dist/local-virtual-computer/setup/limits.js +58 -0
  69. package/dist/local-virtual-computer/setup/limits.js.map +1 -0
  70. package/dist/local-virtual-computer/setup/plan.d.ts +8 -0
  71. package/dist/local-virtual-computer/setup/plan.d.ts.map +1 -0
  72. package/dist/local-virtual-computer/setup/plan.js +131 -0
  73. package/dist/local-virtual-computer/setup/plan.js.map +1 -0
  74. package/dist/local-virtual-computer/setup/readiness.d.ts +11 -0
  75. package/dist/local-virtual-computer/setup/readiness.d.ts.map +1 -0
  76. package/dist/local-virtual-computer/setup/readiness.js +320 -0
  77. package/dist/local-virtual-computer/setup/readiness.js.map +1 -0
  78. package/dist/local-virtual-computer/setup/registry.d.ts +18 -0
  79. package/dist/local-virtual-computer/setup/registry.d.ts.map +1 -0
  80. package/dist/local-virtual-computer/setup/registry.js +50 -0
  81. package/dist/local-virtual-computer/setup/registry.js.map +1 -0
  82. package/dist/local-virtual-computer/setup/restart.d.ts +8 -0
  83. package/dist/local-virtual-computer/setup/restart.d.ts.map +1 -0
  84. package/dist/local-virtual-computer/setup/restart.js +60 -0
  85. package/dist/local-virtual-computer/setup/restart.js.map +1 -0
  86. package/dist/local-virtual-computer/setup/resume.d.ts +14 -0
  87. package/dist/local-virtual-computer/setup/resume.d.ts.map +1 -0
  88. package/dist/local-virtual-computer/setup/resume.js +58 -0
  89. package/dist/local-virtual-computer/setup/resume.js.map +1 -0
  90. package/dist/local-virtual-computer/setup/run.d.ts +8 -0
  91. package/dist/local-virtual-computer/setup/run.d.ts.map +1 -0
  92. package/dist/local-virtual-computer/setup/run.js +200 -0
  93. package/dist/local-virtual-computer/setup/run.js.map +1 -0
  94. package/dist/local-virtual-computer/setup/windows-folder.d.ts +11 -0
  95. package/dist/local-virtual-computer/setup/windows-folder.d.ts.map +1 -0
  96. package/dist/local-virtual-computer/setup/windows-folder.js +14 -0
  97. package/dist/local-virtual-computer/setup/windows-folder.js.map +1 -0
  98. package/dist/local-virtual-computer/setup/wsl-package.d.ts +19 -0
  99. package/dist/local-virtual-computer/setup/wsl-package.d.ts.map +1 -0
  100. package/dist/local-virtual-computer/setup/wsl-package.js +242 -0
  101. package/dist/local-virtual-computer/setup/wsl-package.js.map +1 -0
  102. package/dist/local-virtual-computer/setup/wslc-shared.d.ts +27 -0
  103. package/dist/local-virtual-computer/setup/wslc-shared.d.ts.map +1 -0
  104. package/dist/local-virtual-computer/setup/wslc-shared.js +137 -0
  105. package/dist/local-virtual-computer/setup/wslc-shared.js.map +1 -0
  106. package/dist/local-virtual-computer/ssh-forward.d.ts +19 -0
  107. package/dist/local-virtual-computer/ssh-forward.d.ts.map +1 -0
  108. package/dist/local-virtual-computer/ssh-forward.js +179 -0
  109. package/dist/local-virtual-computer/ssh-forward.js.map +1 -0
  110. package/dist/local-virtual-computer/wslc-engine.d.ts +27 -0
  111. package/dist/local-virtual-computer/wslc-engine.d.ts.map +1 -0
  112. package/dist/local-virtual-computer/wslc-engine.js +98 -0
  113. package/dist/local-virtual-computer/wslc-engine.js.map +1 -0
  114. package/local-computer/Dockerfile +99 -0
  115. package/local-computer/app-catalog.cjs +240 -0
  116. package/local-computer/app-native-host.cjs +144 -0
  117. package/local-computer/browser-home.cjs +249 -0
  118. package/local-computer/build-image.mjs +310 -0
  119. package/local-computer/desktop-worker.cjs +477 -0
  120. package/local-computer/entrypoint.sh +161 -0
  121. package/local-computer/home.html +28 -0
  122. package/local-computer/new-tab/home.css +255 -0
  123. package/local-computer/new-tab/home.js +65 -0
  124. package/local-computer/new-tab/manifest.json +12 -0
  125. package/local-computer/new-tab/wordmark.svg +33 -0
  126. package/local-computer/openbox-rc.xml +41 -0
  127. package/local-computer/prepare-home.cjs +121 -0
  128. package/local-computer/tint2rc +44 -0
  129. package/package.json +13 -4
  130. package/src/backends/http-worker-client.ts +31 -3
  131. package/src/index.ts +13 -0
  132. package/src/local-virtual-computer/client.ts +573 -0
  133. package/src/local-virtual-computer/detached-process.ts +133 -0
  134. package/src/local-virtual-computer/detached-worker.ts +124 -0
  135. package/src/local-virtual-computer/dialect.ts +83 -0
  136. package/src/local-virtual-computer/engine.ts +197 -0
  137. package/src/local-virtual-computer/guest-stdio.ts +332 -0
  138. package/src/local-virtual-computer/index.ts +447 -0
  139. package/src/local-virtual-computer/podman-machine.ts +264 -0
  140. package/src/local-virtual-computer/setup/contract.ts +395 -0
  141. package/src/local-virtual-computer/setup/elevated.ts +655 -0
  142. package/src/local-virtual-computer/setup/host.ts +100 -0
  143. package/src/local-virtual-computer/setup/idle.ts +39 -0
  144. package/src/local-virtual-computer/setup/image.ts +159 -0
  145. package/src/local-virtual-computer/setup/index.ts +16 -0
  146. package/src/local-virtual-computer/setup/limits.ts +68 -0
  147. package/src/local-virtual-computer/setup/plan.ts +144 -0
  148. package/src/local-virtual-computer/setup/readiness.ts +386 -0
  149. package/src/local-virtual-computer/setup/registry.ts +50 -0
  150. package/src/local-virtual-computer/setup/restart.ts +64 -0
  151. package/src/local-virtual-computer/setup/resume.ts +65 -0
  152. package/src/local-virtual-computer/setup/run.ts +225 -0
  153. package/src/local-virtual-computer/setup/windows-folder.ts +13 -0
  154. package/src/local-virtual-computer/setup/wsl-package.ts +242 -0
  155. package/src/local-virtual-computer/setup/wslc-shared.ts +147 -0
  156. package/src/local-virtual-computer/ssh-forward.ts +195 -0
  157. package/src/local-virtual-computer/wslc-engine.ts +124 -0
  158. package/worker/server.js +1499 -0
@@ -0,0 +1,360 @@
1
+ /**
2
+ * The contract of the Windows Pal computer setup: what a readiness inspection
3
+ * reports, the plan a person consents to, and how running that plan reports
4
+ * progress and ends. The provider never installs, updates, loads or starts
5
+ * anything; everything here is a separate operation an application runs after
6
+ * the person agrees.
7
+ */
8
+ import type { LocalComputerCommandRunner } from '../engine.js';
9
+ /**
10
+ * One state per machine, checked in this order: the first that applies wins.
11
+ * - `unsupported`: not Windows, not x64, or a Windows build below 19041.
12
+ * - `blocked-by-policy`: `AllowWSL` or `AllowWSLContainer` is 0 under
13
+ * `HKLM\Software\Policies\WSL`.
14
+ * - `restart-pending`: setup recorded that Windows needs a restart, and the PC
15
+ * has not restarted since; or Virtual Machine Platform is on, no hypervisor
16
+ * runs yet, and Windows itself reports a restart pending (no marker then).
17
+ * A marker that cannot be read, or a boot time that cannot be fetched while
18
+ * a marker exists, also reads `restart-pending`: the steps still to run
19
+ * after the restart are then unknown and treated as none. So does a marker
20
+ * that can be neither read nor dated (no file date): `restart` is then
21
+ * absent, since there is no record time to report.
22
+ * - `platform-off`: Virtual Machine Platform is off, or (Windows 10 only) the
23
+ * Windows Subsystem for Linux optional component is.
24
+ * - `wsl-missing`: no WSL package with wslc.
25
+ * - `wsl-outdated`: WSL is present, but wslc is missing or below the floor.
26
+ * - `sdk-mismatch`: the installed WSL refuses this client (`0x8004060B`).
27
+ * - `virtualization-off`: the session's virtual machine cannot start
28
+ * (`0x80370102`), or (without a session probe) no hypervisor runs although
29
+ * the platform is on and Windows reports no restart pending.
30
+ * - `image-missing`: wslc works, but the Pal computer image is not loaded.
31
+ * - `ready`: wslc works and the image is loaded and matches its manifest.
32
+ */
33
+ export type WslcReadinessState = 'unsupported' | 'blocked-by-policy' | 'restart-pending' | 'platform-off' | 'wsl-missing' | 'wsl-outdated' | 'sdk-mismatch' | 'virtualization-off' | 'image-missing' | 'ready';
34
+ /** Why a machine is `unsupported`. */
35
+ export type WslcUnsupportedReason = 'platform' | 'architecture' | 'windows-build';
36
+ /** What a readiness inspection found. Plain data; safe to print as JSON. */
37
+ export interface WslcReadiness {
38
+ readonly state: WslcReadinessState;
39
+ /** Set only when `state` is `unsupported`. */
40
+ readonly unsupportedReason?: WslcUnsupportedReason;
41
+ readonly windows?: {
42
+ readonly build: number;
43
+ readonly architecture: 'x64' | 'arm64' | 'other';
44
+ readonly isWindows11: boolean;
45
+ };
46
+ readonly policy: {
47
+ readonly allowWsl: boolean;
48
+ readonly allowWslContainer: boolean;
49
+ };
50
+ readonly components: {
51
+ readonly virtualMachinePlatform: boolean | 'unknown';
52
+ /** Windows 11 does not need the optional component. */
53
+ readonly wslOptionalComponent: boolean | 'unknown' | 'not-needed';
54
+ readonly hypervisorPresent: boolean | 'unknown';
55
+ };
56
+ readonly wsl: {
57
+ /** `x.y.z.w` from `wsl.exe --version`, when a WSL package answers. */
58
+ readonly version?: string;
59
+ /** The wslc binary found, if any. */
60
+ readonly wslcBinary?: string;
61
+ /** `x.y.z` from `wslc version`. */
62
+ readonly wslcVersion?: string;
63
+ };
64
+ readonly image: {
65
+ /** The reference the inspection looked for, e.g. `namzu-local-computer:2`. */
66
+ readonly ref: string;
67
+ readonly loaded: boolean;
68
+ /** A manifest and archive the application carries, if it has them. */
69
+ readonly bundled?: {
70
+ readonly manifestPath: string;
71
+ readonly archivePath: string;
72
+ };
73
+ };
74
+ /** Set when setup recorded a required restart (see {@link WslcRestartMarker}). */
75
+ readonly restart?: {
76
+ readonly recordedAt: string;
77
+ readonly bootTime?: string;
78
+ };
79
+ /** ISO time of the inspection. */
80
+ readonly checkedAt: string;
81
+ }
82
+ /**
83
+ * The image manifest `local-computer/build-image.mjs` writes and the Windows
84
+ * installer carries in `resources/pal-computer/manifest.json`.
85
+ */
86
+ export interface WslcImageManifest {
87
+ readonly revision: number;
88
+ readonly stage: 'base' | 'creative';
89
+ /** `namzu-local-computer:<revision>`; a test tag is never bundled. */
90
+ readonly imageRef: string;
91
+ readonly imageId: string;
92
+ /** The image's `org.namzu.local-computer.protocol` label. */
93
+ readonly protocol: string;
94
+ /** The archive's file name, beside the manifest. */
95
+ readonly file: string;
96
+ /** SHA-256 of the archive as shipped. */
97
+ readonly sha256: string;
98
+ /** SHA-256 of the uncompressed tar. */
99
+ readonly tarSha256: string;
100
+ /** Size of the uncompressed tar. */
101
+ readonly sizeBytes: number;
102
+ /** Size of the archive. */
103
+ readonly compressedBytes: number;
104
+ readonly format: 'zst' | 'xz' | 'gz' | 'tar';
105
+ }
106
+ /** The WSL release setup installs when WSL is missing or too old. */
107
+ export interface PinnedWslPackage {
108
+ /** `x.y.z.w`, for example `3.0.1.0`. */
109
+ readonly version: string;
110
+ readonly architecture: 'x64';
111
+ /** An `https://github.com/microsoft/WSL/releases/download/...` URL. */
112
+ readonly url: string;
113
+ readonly sha256: string;
114
+ readonly sizeBytes: number;
115
+ }
116
+ /**
117
+ * One step of a plan, in the order it runs.
118
+ * - `download-wsl`: fetch the pinned WSL package into the setup directory and
119
+ * check its size and SHA-256. Not elevated.
120
+ * - `enable-windows-features`: turn on Virtual Machine Platform (and on
121
+ * Windows 10 the WSL optional component). Elevated.
122
+ * - `install-wsl`: install the downloaded WSL package. Elevated.
123
+ * - `restart`: the person restarts the PC; setup continues after sign-in.
124
+ * - `load-image`: check the bundled archive against its manifest and load it
125
+ * with `wslc load -i`. Not elevated.
126
+ *
127
+ * Every elevated step of one plan runs in ONE elevated process, so a plan
128
+ * causes at most one Windows permission prompt.
129
+ */
130
+ export type WslcSetupStepKind = 'download-wsl' | 'enable-windows-features' | 'install-wsl' | 'restart' | 'load-image';
131
+ export interface WslcSetupStep {
132
+ readonly kind: WslcSetupStepKind;
133
+ readonly elevated: boolean;
134
+ /** Bytes this step downloads, if any. */
135
+ readonly downloadBytes?: number;
136
+ /** Bytes this step adds on disk, if known. */
137
+ readonly diskBytes?: number;
138
+ /** A rough duration for the sentence the person reads. */
139
+ readonly estimatedSeconds: number;
140
+ readonly mayRequireRestart: boolean;
141
+ }
142
+ /** Why a plan has nothing Namzu can do. */
143
+ export type WslcSetupBlock = 'unsupported' | 'blocked-by-policy' | 'virtualization-off' | 'sdk-mismatch'
144
+ /** No bundled image and no other way to get one. */
145
+ | 'image-unavailable';
146
+ export interface WslcSetupPlan {
147
+ /**
148
+ * A digest of the readiness state and the steps. Consent names it, and
149
+ * running refuses a plan whose id no longer matches a fresh inspection.
150
+ */
151
+ readonly id: string;
152
+ readonly state: WslcReadinessState;
153
+ readonly steps: readonly WslcSetupStep[];
154
+ /** 0 or 1: all elevated steps share one elevated process. */
155
+ readonly elevationPrompts: 0 | 1;
156
+ readonly mayRequireRestart: boolean;
157
+ /** Set when setup cannot proceed; `steps` is then empty. */
158
+ readonly blocked?: WslcSetupBlock;
159
+ }
160
+ /** The person's agreement to one specific plan. */
161
+ export interface WslcSetupConsent {
162
+ readonly planId: string;
163
+ /** ISO time of the click or the typed answer. */
164
+ readonly approvedAt: string;
165
+ }
166
+ /** Progress, emitted in order. Byte counts are raw; the caller humanises them. */
167
+ export type WslcSetupProgress = {
168
+ readonly step: WslcSetupStepKind;
169
+ readonly phase: 'started';
170
+ } | {
171
+ readonly step: WslcSetupStepKind;
172
+ readonly phase: 'progress';
173
+ readonly done: number;
174
+ readonly total?: number;
175
+ readonly unit: 'bytes' | 'percent';
176
+ } | {
177
+ readonly step: WslcSetupStepKind;
178
+ readonly phase: 'finished';
179
+ readonly result: 'ok' | 'restart-required';
180
+ };
181
+ /** Stable reasons a failed setup step carries. */
182
+ export type WslcSetupFailureCode = 'download-failed' | 'download-corrupt' | 'elevation-failed' | 'feature-enable-failed' | 'wsl-install-failed' | 'image-corrupt' | 'image-load-failed' | 'image-mismatch' | 'engine-failed';
183
+ /** How running a plan ended. */
184
+ export type WslcSetupResult = {
185
+ readonly outcome: 'ready';
186
+ } | {
187
+ readonly outcome: 'restart-required';
188
+ }
189
+ /** The person declined the Windows permission prompt. */
190
+ | {
191
+ readonly outcome: 'cancelled';
192
+ }
193
+ /** The account cannot elevate and no administrator approved. */
194
+ | {
195
+ readonly outcome: 'needs-administrator';
196
+ }
197
+ /** The consent names a plan that no longer matches the machine. */
198
+ | {
199
+ readonly outcome: 'plan-changed';
200
+ readonly plan: WslcSetupPlan;
201
+ } | {
202
+ readonly outcome: 'blocked';
203
+ readonly blocked: WslcSetupBlock;
204
+ } | {
205
+ readonly outcome: 'failed';
206
+ readonly step: WslcSetupStepKind;
207
+ readonly code: WslcSetupFailureCode;
208
+ /** Plain words for a Details fold. Never engine output or paths with user names. */
209
+ readonly detail?: string;
210
+ /** The Windows exit code of the failed step, when Windows gave one. */
211
+ readonly exitCode?: number;
212
+ };
213
+ /**
214
+ * Written to `<stateDirectory>/restart.json` when an elevated step reports
215
+ * that Windows needs a restart; cleared once readiness sees a boot later than
216
+ * `recordedAt`.
217
+ */
218
+ export interface WslcRestartMarker {
219
+ readonly recordedAt: string;
220
+ readonly planId: string;
221
+ /** Steps still to run after the restart. */
222
+ readonly remaining: readonly WslcSetupStepKind[];
223
+ }
224
+ /** Exit status of the elevated process, before it is mapped to a result. */
225
+ export type WslcElevatedOutcome = {
226
+ readonly outcome: 'ok';
227
+ } | {
228
+ readonly outcome: 'restart-required';
229
+ } | {
230
+ readonly outcome: 'cancelled';
231
+ } | {
232
+ readonly outcome: 'needs-administrator';
233
+ } | {
234
+ readonly outcome: 'failed';
235
+ readonly step: 'enable-windows-features' | 'install-wsl';
236
+ readonly code: 'feature-enable-failed' | 'wsl-install-failed' | 'elevation-failed';
237
+ /** The Windows exit code, for a Details fold. */
238
+ readonly exitCode?: number;
239
+ };
240
+ /**
241
+ * Everything the setup touches on the machine, injected so tests can stand in
242
+ * for Windows. Implementations for a real Windows host live beside the
243
+ * functions that use them.
244
+ */
245
+ export interface WslcSetupHost {
246
+ readonly platform: NodeJS.Platform;
247
+ readonly arch: string;
248
+ /** Windows build number, e.g. 19045; undefined off Windows. */
249
+ readonly windowsBuild: number | undefined;
250
+ readonly env: NodeJS.ProcessEnv;
251
+ readonly runner: LocalComputerCommandRunner;
252
+ /** A DWORD from the registry; undefined when the value or key is absent. */
253
+ readDword(key: string, name: string): Promise<number | undefined>;
254
+ /** Whether a registry key exists; `unknown` when the check failed or timed out. */
255
+ keyExists(key: string): Promise<boolean | 'unknown'>;
256
+ /** The last boot time of Windows. */
257
+ bootTime(): Promise<Date>;
258
+ now(): Date;
259
+ /** `%LOCALAPPDATA%\Namzu\setup` unless the caller chooses otherwise. */
260
+ readonly stateDirectory: string;
261
+ /**
262
+ * The registry key the resume command is written under. Defaults to
263
+ * {@link RESUME_AT_SIGN_IN_KEY}; a trial run on a real PC points it at a
264
+ * scratch key so nothing runs at the next sign-in.
265
+ */
266
+ readonly resumeRegistryKey: string;
267
+ }
268
+ /** Where Windows keeps the command it runs once at the next sign-in. */
269
+ export declare const RESUME_AT_SIGN_IN_KEY = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce";
270
+ /** Options every setup entry point takes. */
271
+ export interface WslcSetupOptions {
272
+ /** The image the application runs, e.g. `namzu-local-computer:2`. */
273
+ readonly imageRef: string;
274
+ /** The manifest the application carries, with its archive beside it. */
275
+ readonly bundledManifestPath?: string;
276
+ /** Defaults to the release pinned in this package. */
277
+ readonly wslPackage?: PinnedWslPackage;
278
+ readonly host?: Partial<WslcSetupHost>;
279
+ readonly signal?: AbortSignal;
280
+ /**
281
+ * Start the wslc session to check the loaded image and the virtual machine
282
+ * itself. Off by default, so opening a panel never starts a virtual machine
283
+ * of about 2 GB; without it, `image.loaded` comes from the record setup
284
+ * writes after a successful load (`<stateDirectory>/image.json`).
285
+ * `runWslcSetup` always probes.
286
+ */
287
+ readonly probeSession?: boolean;
288
+ }
289
+ /** Run the one elevated process for the elevated steps of a plan. */
290
+ export type RunElevatedWslcSteps = (request: {
291
+ readonly steps: readonly ('enable-windows-features' | 'install-wsl')[];
292
+ /** Required when `install-wsl` is among the steps; re-verified while elevated. */
293
+ readonly wslPackage?: {
294
+ readonly path: string;
295
+ readonly sha256: string;
296
+ };
297
+ readonly host: WslcSetupHost;
298
+ readonly onProgress?: (progress: WslcSetupProgress) => void;
299
+ readonly signal?: AbortSignal;
300
+ }) => Promise<WslcElevatedOutcome>;
301
+ /** The entry points, as the CLI and Desktop call them. */
302
+ export type InspectWslcReadiness = (options: WslcSetupOptions) => Promise<WslcReadiness>;
303
+ export type PlanWslcSetup = (readiness: WslcReadiness, options: Pick<WslcSetupOptions, 'wslPackage'> & {
304
+ readonly manifest?: WslcImageManifest;
305
+ }) => WslcSetupPlan;
306
+ export type RunWslcSetup = (consent: WslcSetupConsent, options: WslcSetupOptions & {
307
+ readonly onProgress?: (progress: WslcSetupProgress) => void;
308
+ /** Defaults to the real elevated runner; tests pass a stand-in. */
309
+ readonly runElevated?: RunElevatedWslcSteps;
310
+ /** The command Windows runs once at the next sign-in to continue setup. */
311
+ readonly resumeCommand?: string;
312
+ }) => Promise<WslcSetupResult>;
313
+ /**
314
+ * Stop the wslc session's virtual machine when nothing runs in it. Answers
315
+ * `busy` and does nothing while any container runs, Namzu's or not.
316
+ */
317
+ export type StopIdleWslcSession = (options: Pick<WslcSetupOptions, 'host' | 'signal'>) => Promise<{
318
+ readonly outcome: 'stopped' | 'busy' | 'not-running';
319
+ }>;
320
+ /** Check the bundled archive against its manifest, load it, and check what loaded. */
321
+ export type LoadWslcImage = (options: {
322
+ readonly manifestPath: string;
323
+ readonly host?: Partial<WslcSetupHost>;
324
+ readonly onProgress?: (progress: WslcSetupProgress) => void;
325
+ readonly signal?: AbortSignal;
326
+ }) => Promise<{
327
+ readonly outcome: 'loaded' | 'already-loaded';
328
+ } | {
329
+ readonly outcome: 'failed';
330
+ readonly code: 'image-corrupt' | 'image-load-failed' | 'image-mismatch';
331
+ readonly detail?: string;
332
+ }>;
333
+ /**
334
+ * Fetch the pinned WSL package into `directory`, resuming a partial file, and
335
+ * check its size and SHA-256. A file that fails the check is deleted.
336
+ */
337
+ export type DownloadWslPackage = (options: {
338
+ readonly pinned: PinnedWslPackage;
339
+ readonly directory: string;
340
+ readonly fetch?: typeof fetch;
341
+ readonly onProgress?: (progress: WslcSetupProgress) => void;
342
+ readonly signal?: AbortSignal;
343
+ }) => Promise<{
344
+ readonly outcome: 'ok';
345
+ readonly path: string;
346
+ } | {
347
+ readonly outcome: 'failed';
348
+ readonly code: 'download-failed' | 'download-corrupt';
349
+ readonly detail?: string;
350
+ }>;
351
+ /** The restart marker in `<stateDirectory>/restart.json`. */
352
+ export type ReadRestartMarker = (host: WslcSetupHost) => Promise<WslcRestartMarker | undefined>;
353
+ export type WriteRestartMarker = (host: WslcSetupHost, marker: WslcRestartMarker) => Promise<void>;
354
+ export type ClearRestartMarker = (host: WslcSetupHost) => Promise<void>;
355
+ /** Ask Windows to run `command` once at the next sign-in, and take that back. */
356
+ export type RegisterResumeAtSignIn = (host: WslcSetupHost, command: string) => Promise<void>;
357
+ export type ClearResumeAtSignIn = (host: WslcSetupHost) => Promise<void>;
358
+ /** The real Windows host, with `overrides` applied. */
359
+ export type CreateWslcSetupHost = (overrides?: Partial<WslcSetupHost>) => WslcSetupHost;
360
+ //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../src/local-virtual-computer/setup/contract.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAA;AAE9D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,kBAAkB,GAC3B,aAAa,GACb,mBAAmB,GACnB,iBAAiB,GACjB,cAAc,GACd,aAAa,GACb,cAAc,GACd,cAAc,GACd,oBAAoB,GACpB,eAAe,GACf,OAAO,CAAA;AAEV,sCAAsC;AACtC,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,cAAc,GAAG,eAAe,CAAA;AAEjF,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAA;IAClC,8CAA8C;IAC9C,QAAQ,CAAC,iBAAiB,CAAC,EAAE,qBAAqB,CAAA;IAClD,QAAQ,CAAC,OAAO,CAAC,EAAE;QAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;QACtB,QAAQ,CAAC,YAAY,EAAE,KAAK,GAAG,OAAO,GAAG,OAAO,CAAA;QAChD,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAA;KAC7B,CAAA;IACD,QAAQ,CAAC,MAA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AAO,CAAC,IAAI,CAAC,CAAA;AAExE,uDAAuD;AACvD,MAAM,MAAM,mBAAmB,GAAG,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,aAAa,CAAA"}
@@ -0,0 +1,3 @@
1
+ /** Where Windows keeps the command it runs once at the next sign-in. */
2
+ export const RESUME_AT_SIGN_IN_KEY = 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce';
3
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../src/local-virtual-computer/setup/contract.ts"],"names":[],"mappings":"AAqSA,wEAAwE;AACxE,MAAM,CAAC,MAAM,qBAAqB,GAAG,6DAA6D,CAAA"}
@@ -0,0 +1,78 @@
1
+ import type { RunElevatedWslcSteps, WslcElevatedOutcome } from './contract.js';
2
+ /**
3
+ * The one elevated process of a setup plan.
4
+ *
5
+ * Windows PowerShell (a Microsoft-signed program, so the Windows prompt names
6
+ * Microsoft rather than an unknown publisher) is started with
7
+ * `Start-Process -Verb RunAs` and runs a FIXED script handed over with
8
+ * `-EncodedCommand`. There is no script file anyone could edit between the
9
+ * prompt and the run. Values reach the script only as single-quoted PowerShell
10
+ * literals, after being validated here. Inside, only Microsoft tools run:
11
+ * dism.exe, msiexec.exe and Get-FileHash.
12
+ *
13
+ * Exit codes of the elevated script: 0 ok, 3010 restart required,
14
+ * 20 enabling Windows features failed, 21 installing the WSL package failed,
15
+ * 22 the package did not match the pinned digest. The launcher (a second,
16
+ * non-elevated PowerShell) prints `NAMZU_EXIT=<code>` with the child's exit
17
+ * code, 1223 when the person declined the prompt, or `NAMZU_LAUNCH_FAILED`,
18
+ * and exits 0 itself: the command runner keeps no output from a process that
19
+ * exits nonzero, so the code travels on stdout.
20
+ *
21
+ * The elevated child cannot be stopped from here. Aborting the signal stops
22
+ * waiting and stops reading progress; if the person already approved, the
23
+ * elevated steps run to the end.
24
+ */
25
+ export declare const ELEVATED_EXIT: {
26
+ readonly ok: 0;
27
+ readonly restartRequired: 3010;
28
+ readonly enableFeaturesFailed: 20;
29
+ readonly installWslFailed: 21;
30
+ readonly packageMismatch: 22;
31
+ readonly folderFailed: 23;
32
+ readonly cancelled: 1223;
33
+ };
34
+ type ElevatedStep = 'enable-windows-features' | 'install-wsl';
35
+ type Request = Parameters<RunElevatedWslcSteps>[0];
36
+ export interface ElevatedScripts {
37
+ /** The script that runs elevated (the user's SID is filled in by the launcher). */
38
+ readonly inner: string;
39
+ /** The script the non-elevated launcher runs; it starts `inner`. */
40
+ readonly launcher: string;
41
+ /** `powershell.exe` arguments that run the launcher. */
42
+ readonly launcherArgs: readonly string[];
43
+ /** Where the elevated process writes progress, under the protected folder. */
44
+ readonly progressFile: string;
45
+ readonly isWindows11: boolean;
46
+ }
47
+ export interface ElevatedBuildOptions {
48
+ /** 32 hex characters naming the protected folder; random per run. */
49
+ readonly runId?: string;
50
+ /** The Windows folder as the host reports it, used only to locate the progress file. */
51
+ readonly windowsDirectory?: string;
52
+ }
53
+ /**
54
+ * Validate a request and build both scripts. Exported for tests; the public
55
+ * entry point is {@link runElevatedWslcSteps}. Throws on any request that
56
+ * could put a foreign value into a script.
57
+ */
58
+ export declare function buildElevatedScripts(request: Request, options?: ElevatedBuildOptions): ElevatedScripts;
59
+ export declare function encodeCommand(script: string): string;
60
+ /** What `whoami /groups` lists for an account: an administrator, even with a filtered token, has the group. */
61
+ export declare function isAdministratorAccount(whoamiGroupsOutput: string): boolean;
62
+ interface ProgressLine {
63
+ readonly step: ElevatedStep;
64
+ readonly phase: 'started' | 'finished' | 'failed';
65
+ readonly result?: 'ok' | 'restart-required';
66
+ readonly exitCode?: number;
67
+ }
68
+ export declare function parseProgressLine(line: string): ProgressLine | undefined;
69
+ /** Map the launcher's answer to an outcome. `standardUser` is only consulted when needed. */
70
+ export declare function mapElevatedExit(code: number, steps: readonly ElevatedStep[], failure: {
71
+ readonly step?: ElevatedStep;
72
+ readonly exitCode?: number;
73
+ }): WslcElevatedOutcome | 'cancelled';
74
+ export declare const runElevatedWslcSteps: RunElevatedWslcSteps;
75
+ /** {@link runElevatedWslcSteps} with the run id and Windows folder a test pins. */
76
+ export declare function runElevatedWith(request: Request, options: ElevatedBuildOptions): Promise<WslcElevatedOutcome>;
77
+ export {};
78
+ //# sourceMappingURL=elevated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elevated.d.ts","sourceRoot":"","sources":["../../../src/local-virtual-computer/setup/elevated.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACX,oBAAoB,EACpB,mBAAmB,EAGnB,MAAM,eAAe,CAAA;AAGtB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,eAAO,MAAM,aAAa;;;;;;;;CAQhB,CAAA;AAEV,KAAK,YAAY,GAAG,yBAAyB,GAAG,aAAa,CAAA;AAY7D,KAAK,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAA;AAkClD,MAAM,WAAW,eAAe;IAC/B,mFAAmF;IACnF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,wDAAwD;IACxD,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;IACxC,8EAA8E;IAC9E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAA;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACpC,qEAAqE;IACrE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,wFAAwF;IACxF,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAClC;AAWD;;;;GAIG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,oBAAyB,GAChC,eAAe,CA8EjB;AAED,wBAAgB,aAAa,CAAC,MA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