dsh-plugin-wsl-env 0.23.1 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +212 -0
- package/README.md +9 -5
- package/SECURITY.md +10 -0
- package/client.js +974 -165
- package/cordis.patch.yml +28 -3
- package/docs/API.md +2 -1
- package/docs/ARCHITECTURE.md +36 -13
- package/docs/COMPATIBILITY.md +5 -0
- package/docs/CONFIGURATION.md +80 -9
- package/docs/CONFIGURATION.zh.md +64 -8
- package/docs/DIAGNOSTICS.md +48 -20
- package/docs/DIAGNOSTICS.zh.md +36 -14
- package/docs/LIMITATIONS.md +36 -9
- package/docs/LIMITATIONS.zh.md +26 -7
- package/docs/MIGRATION.md +1 -1
- package/docs/PEER-PARITY.md +4 -4
- package/docs/QUICKSTART.md +42 -12
- package/docs/QUICKSTART.zh.md +29 -8
- package/docs/README.zh.md +9 -5
- package/docs/RELEASING.md +17 -13
- package/docs/REQUIREMENTS.zh.md +5 -4
- package/docs/UPSTREAM-FSIO-EXPORT.md +5 -4
- package/docs/UPSTREAM-PROMPT-ADAPTERS.md +85 -0
- package/docs/root-fs-routing.md +1 -1
- package/lib/agent-confined.d.ts +7 -1
- package/lib/agent-confined.js +3 -3
- package/lib/auto-preset.d.ts +27 -0
- package/lib/auto-preset.js +40 -3
- package/lib/bwrap.d.ts +14 -0
- package/lib/bwrap.js +11 -0
- package/lib/client-host.d.ts +2 -2
- package/lib/client-host.js +2 -2
- package/lib/cwd-prompt.d.ts +41 -3
- package/lib/cwd-prompt.js +125 -8
- package/lib/doctor-report.d.ts +50 -0
- package/lib/doctor-report.js +172 -0
- package/lib/fs-routing.d.ts +1 -1
- package/lib/fs-routing.js +1 -1
- package/lib/fs.d.ts +1 -1
- package/lib/fs.js +1 -1
- package/lib/index.d.ts +6 -1464
- package/lib/index.js +5 -2120
- package/lib/listing.d.ts +21 -9
- package/lib/listing.js +25 -21
- package/lib/messages.d.ts +1 -1
- package/lib/messages.js +3 -3
- package/lib/picker.d.ts +50 -16
- package/lib/picker.js +103 -23
- package/lib/preflight.d.ts +7 -4
- package/lib/preflight.js +27 -13
- package/lib/preset-choice.d.ts +22 -3
- package/lib/preset-choice.js +36 -3
- package/lib/provider-common.d.ts +58 -0
- package/lib/provider-common.js +123 -0
- package/lib/sandbox-core.d.ts +1 -0
- package/lib/sandbox-core.js +4 -2
- package/lib/session-runtime.d.ts +7 -1
- package/lib/session-runtime.js +9 -2
- package/lib/shell.d.ts +1 -1
- package/lib/shell.js +1 -1
- package/lib/status.d.ts +261 -0
- package/lib/status.js +425 -0
- package/lib/writable-roots.d.ts +109 -0
- package/lib/writable-roots.js +257 -0
- package/lib/wsl-doctor-tool.d.ts +8 -0
- package/lib/wsl-doctor-tool.js +18 -20
- package/lib/wsl-filesystem.d.ts +692 -0
- package/lib/wsl-filesystem.js +897 -0
- package/lib/wsl-shell.d.ts +742 -0
- package/lib/wsl-shell.js +965 -0
- package/lib/wsl.d.ts +13 -1
- package/lib/wsl.js +16 -1
- package/locale/doctor/en.json +3 -2
- package/locale/doctor/zh.json +3 -2
- package/package.json +12 -4
- package/scripts/doctor.mjs +436 -226
- package/scripts/profile-preset.mjs +17 -5
package/lib/index.d.ts
CHANGED
|
@@ -1,1464 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* The model-facing tools (`dsh-tool-fs`, `dsh-tool-fs-search`, `dsh-tool-bash`)
|
|
8
|
-
* consume those seams and never talk to a filesystem or a shell directly. A WSL
|
|
9
|
-
* integration is therefore a seam provider, not a new tool.
|
|
10
|
-
*
|
|
11
|
-
* This package provides two of them:
|
|
12
|
-
*
|
|
13
|
-
* - {@link WslShellExecutor} registers `ctx.shell` and runs every command
|
|
14
|
-
* inside the distro as `wsl.exe -d <distro> --cd <linux dir> --exec <shell> -lc <cmd>`,
|
|
15
|
-
* where `<shell>` is the distro user's login shell (not a hardcoded bash).
|
|
16
|
-
* - {@link WslFileSystem} registers `ctx.fs` and maps Linux paths onto the
|
|
17
|
-
* distro's UNC share so the host's own fs stack (including the packaged
|
|
18
|
-
* ripgrep used by `dsh-tool-fs-search`) reads and writes real distro files.
|
|
19
|
-
*
|
|
20
|
-
* ## The one constraint that shapes everything
|
|
21
|
-
*
|
|
22
|
-
* On Windows, DSH confines commands with `dsh-sandbox-windows-acl`: a
|
|
23
|
-
* restricted, low-integrity token plus a capability-SID write allowlist. That
|
|
24
|
-
* token cannot reach WSL at all — `wsl.exe` fails with `Wsl/E_ACCESSDENIED` and
|
|
25
|
-
* the UNC share `\\wsl.localhost\<distro>` reports access denied. Both work
|
|
26
|
-
* normally outside the sandbox.
|
|
27
|
-
*
|
|
28
|
-
* The confinement is applied by the *sandboxing* executor (`pwsh-sandbox`),
|
|
29
|
-
* which wraps the argv through `ctx.sandbox.confine`. This plugin therefore
|
|
30
|
-
* subclasses the NON-sandboxing `LocalBashExecutor`, and inherits
|
|
31
|
-
* `sandboxMode === undefined` from the seam — which is the honest capability
|
|
32
|
-
* fact: the tool layer reads it and advertises that these commands are not
|
|
33
|
-
* confined. WSL access is inherently outside the harness's file sandbox; do not
|
|
34
|
-
* paper over that by reporting a mode this provider does not enforce.
|
|
35
|
-
*
|
|
36
|
-
* This is a TypeScript source built to `lib/index.js`; edit THIS file and run
|
|
37
|
-
* `pnpm run build` — the artifact under `lib/` is generated, and `pnpm test`
|
|
38
|
-
* fails when it drifts.
|
|
39
|
-
*
|
|
40
|
-
* @module dsh-plugin-wsl
|
|
41
|
-
*/
|
|
42
|
-
import z from "@deepseek-ai/schemastery";
|
|
43
|
-
import { LocalBashExecutor } from "@deepseek-ai/dsh-bash-local";
|
|
44
|
-
import { LocalFileSystem } from "@deepseek-ai/dsh-fs-local";
|
|
45
|
-
import { FsError } from "@deepseek-ai/dsh-fs";
|
|
46
|
-
import { WslSandbox } from "./sandbox.js";
|
|
47
|
-
import type { WslAgent, AgentStatus } from "./agent.js";
|
|
48
|
-
import { AgentSubstrate } from "./fs-substrate.js";
|
|
49
|
-
import { SessionRuntimes } from "./session-runtime.js";
|
|
50
|
-
import { type DoctorReport } from "./doctor-live.js";
|
|
51
|
-
import type { AgentBackend } from "./native-agent.js";
|
|
52
|
-
import type { SessionRuntimeEntry } from "./session-runtime.js";
|
|
53
|
-
import type { Context } from "@deepseek-ai/cordis";
|
|
54
|
-
import type { FsDeleteOutcome, FsDirEntry, FsEditOutcome, FsEditRequest, FsInfo, FsMoveOutcome, FsPathInfo, FsTarget, FsVersion, FsWriteIntent, FsWriteOutcome, FileSystem } from "@deepseek-ai/dsh-fs";
|
|
55
|
-
import type { SandboxExecutionPolicy, SandboxMode } from "@deepseek-ai/dsh-sandbox";
|
|
56
|
-
import type { SubprocessSpawnSpec } from "@deepseek-ai/dsh-subprocess";
|
|
57
|
-
/**
|
|
58
|
-
* The 0.2.2-rc.1 patch/move operations' parameter shapes, derived from the
|
|
59
|
-
* peer's abstract surface: `PatchHunk` lives in `@deepseek-ai/dsh-fs-patch`,
|
|
60
|
-
* which this package does not depend on, so the types ride in through the
|
|
61
|
-
* `FileSystem` declaration instead.
|
|
62
|
-
*/
|
|
63
|
-
type PatchHunks = Parameters<FileSystem["patchText"]>[1];
|
|
64
|
-
type MoveFileOptions = Parameters<FileSystem["moveFile"]>[2];
|
|
65
|
-
/**
|
|
66
|
-
* Upstream shell vocabulary, derived through `@deepseek-ai/dsh-bash-local` —
|
|
67
|
-
* this package does not depend on `@deepseek-ai/dsh-shell` directly, so the
|
|
68
|
-
* execution types ride in through the executor's own signatures.
|
|
69
|
-
*/
|
|
70
|
-
export type ShellExecSpec = Parameters<LocalBashExecutor["execute"]>[0];
|
|
71
|
-
type ShellExecRequest = Parameters<LocalBashExecutor["resolve"]>[0];
|
|
72
|
-
export type ShellExecution = Awaited<ReturnType<LocalBashExecutor["execute"]>>;
|
|
73
|
-
/**
|
|
74
|
-
* The resolved spec this executor stamps with its home-marker fields: an empty
|
|
75
|
-
* `workdir` plus the relative tail that {@link WslShellExecutor.withDefaultWorkdir}
|
|
76
|
-
* joins against the distro home. The extra keys are this provider's own; the
|
|
77
|
-
* seam's `ShellExecSpec` does not know them.
|
|
78
|
-
*/
|
|
79
|
-
type WslExecSpec = ShellExecSpec & {
|
|
80
|
-
relativeWorkdir?: string;
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* Collect the doctor's versioned JSON report and merge the live resident's
|
|
84
|
-
* own lifecycle facts when this process holds one (WSL-313).
|
|
85
|
-
*
|
|
86
|
-
* The doctor CLI is a separate process, so its handshake check can only probe
|
|
87
|
-
* a fresh resident; a live resident's `deaths` and `lastError` are
|
|
88
|
-
* host-process state with no IPC to reach them. This entry point runs from
|
|
89
|
-
* the plugin's own context instead: it collects the report as a subprocess
|
|
90
|
-
* (no plugin code is re-entered) and folds `sharedAgent(distro).status()` in
|
|
91
|
-
* — the sanctioned merge, since a snapshot that answers for no resident
|
|
92
|
-
* changes nothing. Outside the app the singleton was never started, so the
|
|
93
|
-
* returned report is the fresh probe verbatim; inside it, a wedged live
|
|
94
|
-
* resident's failures finally reach the report.
|
|
95
|
-
*
|
|
96
|
-
* @param distro - the distro the doctor examines.
|
|
97
|
-
* @param options - `doctorPath` overrides the shipped script (tests);
|
|
98
|
-
* `timeoutMs` bounds the run; `signal` lets the caller cancel it;
|
|
99
|
-
* `liveStatus` overrides the in-process status snapshot (tests).
|
|
100
|
-
* @returns the merged report.
|
|
101
|
-
*/
|
|
102
|
-
export declare function doctorReport(distro: string, options?: {
|
|
103
|
-
doctorPath?: string;
|
|
104
|
-
/** The `wsl.exe` the doctor probes with; forwarded as `--wsl <path>`. */
|
|
105
|
-
wslPath?: string;
|
|
106
|
-
/**
|
|
107
|
-
* Run the quick profile instead of the full scan: first-command
|
|
108
|
-
* prerequisites only (host/session/sandbox, no smokes, no registry query,
|
|
109
|
-
* no port survey) — forwarded as `--quick`.
|
|
110
|
-
*/
|
|
111
|
-
quick?: boolean;
|
|
112
|
-
/**
|
|
113
|
-
* Restrict the run to these doctor sections (host, sandbox, session, conf,
|
|
114
|
-
* net, agent); forwarded as `--sections <csv>`. Undefined runs everything.
|
|
115
|
-
*/
|
|
116
|
-
sections?: readonly string[];
|
|
117
|
-
/**
|
|
118
|
-
* Prepended to the doctor subprocess's PATH — a caller that stages a fake
|
|
119
|
-
* `wsl.exe` (tests) passes the staging directory here instead of mutating
|
|
120
|
-
* `process.env`, whose visibility across spawned grandchildren is exactly
|
|
121
|
-
* the ambiguity this option removes.
|
|
122
|
-
*/
|
|
123
|
-
envPath?: string;
|
|
124
|
-
/** Hard deadline for the subprocess; defaults to two minutes. */
|
|
125
|
-
timeoutMs?: number;
|
|
126
|
-
/** The caller's cancellation (the tool's `exec.signal`); aborts the child. */
|
|
127
|
-
signal?: AbortSignal;
|
|
128
|
-
liveStatus?: AgentStatus;
|
|
129
|
-
}): Promise<DoctorReport>;
|
|
130
|
-
/**
|
|
131
|
-
* The WSL shell executor's validated config — the keys of
|
|
132
|
-
* {@link WslShellExecutor.Config}, which the upstream `LocalBashExecutor`
|
|
133
|
-
* config type does not know. The seven volatile fields arrive as live
|
|
134
|
-
* wrappers, so they are spelled as their `.get()` shape (the reading
|
|
135
|
-
* {@link configuredCwd} and `hostCwd` perform).
|
|
136
|
-
*/
|
|
137
|
-
/**
|
|
138
|
-
* The effective `/mnt` mask for a config: `interopVisibility` is the stance
|
|
139
|
-
* key (WSL-314) and takes precedence whenever it names a stance; the legacy
|
|
140
|
-
* `maskWindowsDrive` boolean answers only when the stance key is left at its
|
|
141
|
-
* `visible` default. `disabled` masks in-session — the belt — while the
|
|
142
|
-
* distro-level closure (`[interop] enabled=false` + `wsl --shutdown`)
|
|
143
|
-
* remains a documented, user-applied step a config key must not perform.
|
|
144
|
-
*
|
|
145
|
-
* @param config - anything carrying the two keys.
|
|
146
|
-
* @returns whether confined profiles shadow `/mnt`.
|
|
147
|
-
*/
|
|
148
|
-
export declare function effectiveMaskWindowsDrive(config: {
|
|
149
|
-
interopVisibility?: "visible" | "masked" | "disabled";
|
|
150
|
-
maskWindowsDrive?: boolean;
|
|
151
|
-
}): boolean;
|
|
152
|
-
interface WslShellExecutorConfig {
|
|
153
|
-
/** The pinned distro; empty means WSL's default. */
|
|
154
|
-
distro: string;
|
|
155
|
-
/** The `wsl.exe` path. */
|
|
156
|
-
wslPath: string;
|
|
157
|
-
/** The distro shell; empty resolves the login shell. */
|
|
158
|
-
shell: string;
|
|
159
|
-
/** Whether `<shell> -lc` semantics apply. */
|
|
160
|
-
loginShell: boolean;
|
|
161
|
-
/** Whether commands confine inside the distro. */
|
|
162
|
-
sandbox: boolean;
|
|
163
|
-
/** Whether confined profiles mask `/mnt`. */
|
|
164
|
-
maskWindowsDrive: boolean;
|
|
165
|
-
/** The interop stance; set at all, it takes precedence over `maskWindowsDrive`. */
|
|
166
|
-
interopVisibility?: "visible" | "masked" | "disabled";
|
|
167
|
-
/** The volatile default workdir. */
|
|
168
|
-
cwd: {
|
|
169
|
-
get(): string | undefined;
|
|
170
|
-
};
|
|
171
|
-
/** The volatile Windows spawn directory. */
|
|
172
|
-
hostCwd: {
|
|
173
|
-
get(): string | undefined;
|
|
174
|
-
};
|
|
175
|
-
/** Extra env names forwarded through WSLENV. */
|
|
176
|
-
forwardEnv: string[];
|
|
177
|
-
/** The volatile default timeout. */
|
|
178
|
-
timeoutMs: {
|
|
179
|
-
get(): number;
|
|
180
|
-
};
|
|
181
|
-
/** The volatile timeout cap. */
|
|
182
|
-
maxTimeoutMs: {
|
|
183
|
-
get(): number;
|
|
184
|
-
};
|
|
185
|
-
/** The volatile per-stream output cap. */
|
|
186
|
-
maxOutputBytes: {
|
|
187
|
-
get(): number;
|
|
188
|
-
};
|
|
189
|
-
/** The volatile spill-file cap. */
|
|
190
|
-
maxSpillBytes: {
|
|
191
|
-
get(): number;
|
|
192
|
-
};
|
|
193
|
-
/** The volatile kill-escalation grace. */
|
|
194
|
-
graceMs: {
|
|
195
|
-
get(): number;
|
|
196
|
-
};
|
|
197
|
-
/** Whether execution prefers the resident agent. */
|
|
198
|
-
agent: boolean;
|
|
199
|
-
/** Session runtime: `true` requires it, `false` disables it, `"auto"` uses it when usable. */
|
|
200
|
-
sessionSandbox: boolean | "auto";
|
|
201
|
-
/** The session runtime's agent backend; `auto` when omitted. */
|
|
202
|
-
agentBackend?: AgentBackend;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* The upstream executor's spawn-spec builder, re-opened for this subclass —
|
|
206
|
-
* see docs/UPSTREAM-SPAWN-SEAM.md. Type-level bridge only; the runtime class
|
|
207
|
-
* is untouched.
|
|
208
|
-
*/
|
|
209
|
-
export type SpawnSeamExecutor = Omit<LocalBashExecutor, "spawnSpec"> & {
|
|
210
|
-
spawnSpec: (spec: ShellExecSpec, argv: string[], stdoutMaxBytes: number, signal?: AbortSignal) => SubprocessSpawnSpec;
|
|
211
|
-
};
|
|
212
|
-
/** The per-process confinement facts retained until settlement. */
|
|
213
|
-
interface ProcessFacts {
|
|
214
|
-
/** The mode the process ran under. */
|
|
215
|
-
mode: SandboxMode | undefined;
|
|
216
|
-
/** The seam's enforcement completeness. */
|
|
217
|
-
enforcement: "full" | "partial";
|
|
218
|
-
/** The case-insensitive stderr substrings a denial produces. */
|
|
219
|
-
denialSignatures: string[];
|
|
220
|
-
/** Structured runner-failure evidence rules. */
|
|
221
|
-
runnerFailureRules: Array<{
|
|
222
|
-
fatalSignatures: string[];
|
|
223
|
-
allowedExitCodes?: number[];
|
|
224
|
-
informationalLines?: string[];
|
|
225
|
-
}>;
|
|
226
|
-
/** The confinement runner program (`argv[0]`), for spawn-failure attribution. */
|
|
227
|
-
runnerProgram: string;
|
|
228
|
-
/** The Linux workdir the process was given. */
|
|
229
|
-
workdir: string;
|
|
230
|
-
/** Whether the profile masks the Windows drive. */
|
|
231
|
-
windowsDrive: "masked" | "visible";
|
|
232
|
-
/** Which runtime the process used: the session scope or a per-command profile. */
|
|
233
|
-
sessionScope: "session" | "per-command";
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Bash executor that runs every command inside a WSL distro.
|
|
237
|
-
*
|
|
238
|
-
* Extends the unconfined `LocalBashExecutor`, so command defaulting, deadline
|
|
239
|
-
* handling, output caps, spill files and background-process management are the
|
|
240
|
-
* shipped implementation's; this subclass replaces only the argv (prefix with
|
|
241
|
-
* `wsl.exe`) and the process working directory (wsl.exe must be started from a
|
|
242
|
-
* Windows directory, while the Linux directory rides on `--cd`).
|
|
243
|
-
*/
|
|
244
|
-
export declare class WslShellExecutor extends LocalBashExecutor {
|
|
245
|
-
static inject: string[];
|
|
246
|
-
static Config: z<Schemastery.ObjectS<NoInfer<{
|
|
247
|
-
/**
|
|
248
|
-
* Distro mode: empty/`"auto"` follows the request workdir, `"default"`
|
|
249
|
-
* forces WSL's default, and an explicit name pins every command.
|
|
250
|
-
*/
|
|
251
|
-
distro: z<string, string, "defined">;
|
|
252
|
-
/** Path to `wsl.exe`; overridable for a non-standard install. */
|
|
253
|
-
wslPath: z<string, string, "defined">;
|
|
254
|
-
/**
|
|
255
|
-
* The shell commands run in. Empty means "resolve the login shell of the
|
|
256
|
-
* distro's user" — hardcoding bash silently ignores a user whose passwd
|
|
257
|
-
* entry points at zsh, fish, dash, or anything else, losing their PATH and
|
|
258
|
-
* rc setup. Set an absolute path inside the distro to pin one.
|
|
259
|
-
*/
|
|
260
|
-
shell: z<string, string, "defined">;
|
|
261
|
-
/**
|
|
262
|
-
* Login-shell semantics (`<shell> -lc`) source the profile scripts, which is
|
|
263
|
-
* what makes an interactive WSL setup's PATH (nvm, cargo, pyenv) visible.
|
|
264
|
-
* Set false for a fast, fully deterministic `<shell> -c`. Applies only to the
|
|
265
|
-
* POSIX family — see `shellArgs` for why other shells get a bare `-c`.
|
|
266
|
-
*/
|
|
267
|
-
loginShell: z<boolean, boolean, "defined">;
|
|
268
|
-
/**
|
|
269
|
-
* Confine every command inside the distro with `bwrap`, and report the
|
|
270
|
-
* policy's mode through {@link sandboxMode}. Fails closed: a distro without
|
|
271
|
-
* a usable `bwrap` produces `SANDBOX_UNAVAILABLE` rather than an unconfined
|
|
272
|
-
* run. `false` restores the pre-sandbox behaviour exactly — commands run
|
|
273
|
-
* unconfined and `sandboxMode` is `undefined`, so the model is told so.
|
|
274
|
-
*/
|
|
275
|
-
sandbox: z<boolean, boolean, "defined">;
|
|
276
|
-
/**
|
|
277
|
-
* Shadow `/mnt` with an empty tmpfs in every confined profile, hiding the
|
|
278
|
-
* Windows drive from confined commands: its files cannot be read or
|
|
279
|
-
* exfiltrated and its executables cannot be launched through interop —
|
|
280
|
-
* the hole that lets a "sandboxed" command reach your full Windows token.
|
|
281
|
-
* A narrowing, not a closure (a command can still write an executable
|
|
282
|
-
* into the workspace and run it — binfmt dispatches on content, not
|
|
283
|
-
* location), so enforcement stays `partial` and the sandbox fact reports
|
|
284
|
-
* `windowsDrive: "masked"`. Costs: confined commands cannot read or touch
|
|
285
|
-
* anything under `/mnt`, and tools that probe the drive degrade. The
|
|
286
|
-
* complete closure is distro-level: `[interop] enabled=false` in
|
|
287
|
-
* `wsl.conf`.
|
|
288
|
-
*/
|
|
289
|
-
/**
|
|
290
|
-
* The interop stance in one key (WSL-314), expanding to the per-key
|
|
291
|
-
* values the measured matrix documents:
|
|
292
|
-
*
|
|
293
|
-
* - `visible` (default) — nothing masked; a confined command can read
|
|
294
|
-
* `/mnt` and launch Windows executables through interop, which escapes
|
|
295
|
-
* the Linux sandbox entirely.
|
|
296
|
-
* - `masked` — `maskWindowsDrive: true`: `/mnt` is shadowed with an empty
|
|
297
|
-
* tmpfs; the drive's files and executables are unreachable (binfmt can
|
|
298
|
-
* still run a workspace-written .exe, so enforcement stays `partial`).
|
|
299
|
-
* - `disabled` — `masked`, plus the distro-level closure: `[interop]
|
|
300
|
-
* enabled=false` in `/etc/wsl.conf` + `wsl --shutdown`, which the
|
|
301
|
-
* doctor's remedy prints as copy-paste (a config key does not write
|
|
302
|
-
* distro config; enforcement is the kernel's, not the schema's).
|
|
303
|
-
*
|
|
304
|
-
* When set at all it takes precedence over the legacy
|
|
305
|
-
* `maskWindowsDrive` boolean below (unset — the default — lets that
|
|
306
|
-
* boolean answer); the boolean remains for existing profiles.
|
|
307
|
-
*/
|
|
308
|
-
interopVisibility: z<"masked" | "visible" | "disabled", "masked" | "visible" | "disabled", "plain">;
|
|
309
|
-
maskWindowsDrive: z<boolean, boolean, "defined">;
|
|
310
|
-
/**
|
|
311
|
-
* Default workdir for a request that names none; accepts `/home/andy/proj`,
|
|
312
|
-
* a UNC path, or `C:\...`. Empty — the default — means the distro user's
|
|
313
|
-
* home, resolved inside the distro.
|
|
314
|
-
*/
|
|
315
|
-
cwd: z<string, string, "volatile">;
|
|
316
|
-
/** Windows directory the `wsl.exe` process itself starts in. */
|
|
317
|
-
hostCwd: z<string, string, "volatile">;
|
|
318
|
-
/** Extra env names to forward into the distro through WSLENV. */
|
|
319
|
-
forwardEnv: z<string[], string[], "defined">;
|
|
320
|
-
timeoutMs: z<number, number, "volatile-defined">;
|
|
321
|
-
maxTimeoutMs: z<number, number, "volatile-defined">;
|
|
322
|
-
maxOutputBytes: z<number, number, "volatile-defined">;
|
|
323
|
-
maxSpillBytes: z<number, number, "volatile-defined">;
|
|
324
|
-
graceMs: z<number, number, "volatile-defined">;
|
|
325
|
-
/**
|
|
326
|
-
* Run commands through the resident agent when it is up (one long-lived
|
|
327
|
-
* in-distro process; in-distro timeout semantics), falling back to the
|
|
328
|
-
* one-shot `wsl.exe` path whenever the agent is out. `false` never uses
|
|
329
|
-
* the agent. The confinement, the output budgets' shapes and the result
|
|
330
|
-
* decoration are identical on both paths.
|
|
331
|
-
*/
|
|
332
|
-
agent: z<boolean, boolean, "defined">;
|
|
333
|
-
agentBackend: z<"auto" | "native" | "shell", "auto" | "native" | "shell", "defined">;
|
|
334
|
-
/**
|
|
335
|
-
* Run this session's commands in one persistent systemd user scope (ADR
|
|
336
|
-
* 0001): background processes survive the command that started them, `/tmp`
|
|
337
|
-
* is the distro's real `/tmp` under workspace-write, and `ps` sees the
|
|
338
|
-
* session. The executor holds the runtime until the session's scope
|
|
339
|
-
* disposes, then stops it. Requires systemd, a reachable user manager and
|
|
340
|
-
* `Linger`; the preflight refuses with the remedy when one is missing, and
|
|
341
|
-
* only a success is cached. Off by default; requires `agent: true`.
|
|
342
|
-
*/
|
|
343
|
-
sessionSandbox: z<boolean | "auto", boolean | "auto", "defined">;
|
|
344
|
-
}>>, Schemastery.ObjectT<NoInfer<{
|
|
345
|
-
/**
|
|
346
|
-
* Distro mode: empty/`"auto"` follows the request workdir, `"default"`
|
|
347
|
-
* forces WSL's default, and an explicit name pins every command.
|
|
348
|
-
*/
|
|
349
|
-
distro: z<string, string, "defined">;
|
|
350
|
-
/** Path to `wsl.exe`; overridable for a non-standard install. */
|
|
351
|
-
wslPath: z<string, string, "defined">;
|
|
352
|
-
/**
|
|
353
|
-
* The shell commands run in. Empty means "resolve the login shell of the
|
|
354
|
-
* distro's user" — hardcoding bash silently ignores a user whose passwd
|
|
355
|
-
* entry points at zsh, fish, dash, or anything else, losing their PATH and
|
|
356
|
-
* rc setup. Set an absolute path inside the distro to pin one.
|
|
357
|
-
*/
|
|
358
|
-
shell: z<string, string, "defined">;
|
|
359
|
-
/**
|
|
360
|
-
* Login-shell semantics (`<shell> -lc`) source the profile scripts, which is
|
|
361
|
-
* what makes an interactive WSL setup's PATH (nvm, cargo, pyenv) visible.
|
|
362
|
-
* Set false for a fast, fully deterministic `<shell> -c`. Applies only to the
|
|
363
|
-
* POSIX family — see `shellArgs` for why other shells get a bare `-c`.
|
|
364
|
-
*/
|
|
365
|
-
loginShell: z<boolean, boolean, "defined">;
|
|
366
|
-
/**
|
|
367
|
-
* Confine every command inside the distro with `bwrap`, and report the
|
|
368
|
-
* policy's mode through {@link sandboxMode}. Fails closed: a distro without
|
|
369
|
-
* a usable `bwrap` produces `SANDBOX_UNAVAILABLE` rather than an unconfined
|
|
370
|
-
* run. `false` restores the pre-sandbox behaviour exactly — commands run
|
|
371
|
-
* unconfined and `sandboxMode` is `undefined`, so the model is told so.
|
|
372
|
-
*/
|
|
373
|
-
sandbox: z<boolean, boolean, "defined">;
|
|
374
|
-
/**
|
|
375
|
-
* Shadow `/mnt` with an empty tmpfs in every confined profile, hiding the
|
|
376
|
-
* Windows drive from confined commands: its files cannot be read or
|
|
377
|
-
* exfiltrated and its executables cannot be launched through interop —
|
|
378
|
-
* the hole that lets a "sandboxed" command reach your full Windows token.
|
|
379
|
-
* A narrowing, not a closure (a command can still write an executable
|
|
380
|
-
* into the workspace and run it — binfmt dispatches on content, not
|
|
381
|
-
* location), so enforcement stays `partial` and the sandbox fact reports
|
|
382
|
-
* `windowsDrive: "masked"`. Costs: confined commands cannot read or touch
|
|
383
|
-
* anything under `/mnt`, and tools that probe the drive degrade. The
|
|
384
|
-
* complete closure is distro-level: `[interop] enabled=false` in
|
|
385
|
-
* `wsl.conf`.
|
|
386
|
-
*/
|
|
387
|
-
/**
|
|
388
|
-
* The interop stance in one key (WSL-314), expanding to the per-key
|
|
389
|
-
* values the measured matrix documents:
|
|
390
|
-
*
|
|
391
|
-
* - `visible` (default) — nothing masked; a confined command can read
|
|
392
|
-
* `/mnt` and launch Windows executables through interop, which escapes
|
|
393
|
-
* the Linux sandbox entirely.
|
|
394
|
-
* - `masked` — `maskWindowsDrive: true`: `/mnt` is shadowed with an empty
|
|
395
|
-
* tmpfs; the drive's files and executables are unreachable (binfmt can
|
|
396
|
-
* still run a workspace-written .exe, so enforcement stays `partial`).
|
|
397
|
-
* - `disabled` — `masked`, plus the distro-level closure: `[interop]
|
|
398
|
-
* enabled=false` in `/etc/wsl.conf` + `wsl --shutdown`, which the
|
|
399
|
-
* doctor's remedy prints as copy-paste (a config key does not write
|
|
400
|
-
* distro config; enforcement is the kernel's, not the schema's).
|
|
401
|
-
*
|
|
402
|
-
* When set at all it takes precedence over the legacy
|
|
403
|
-
* `maskWindowsDrive` boolean below (unset — the default — lets that
|
|
404
|
-
* boolean answer); the boolean remains for existing profiles.
|
|
405
|
-
*/
|
|
406
|
-
interopVisibility: z<"masked" | "visible" | "disabled", "masked" | "visible" | "disabled", "plain">;
|
|
407
|
-
maskWindowsDrive: z<boolean, boolean, "defined">;
|
|
408
|
-
/**
|
|
409
|
-
* Default workdir for a request that names none; accepts `/home/andy/proj`,
|
|
410
|
-
* a UNC path, or `C:\...`. Empty — the default — means the distro user's
|
|
411
|
-
* home, resolved inside the distro.
|
|
412
|
-
*/
|
|
413
|
-
cwd: z<string, string, "volatile">;
|
|
414
|
-
/** Windows directory the `wsl.exe` process itself starts in. */
|
|
415
|
-
hostCwd: z<string, string, "volatile">;
|
|
416
|
-
/** Extra env names to forward into the distro through WSLENV. */
|
|
417
|
-
forwardEnv: z<string[], string[], "defined">;
|
|
418
|
-
timeoutMs: z<number, number, "volatile-defined">;
|
|
419
|
-
maxTimeoutMs: z<number, number, "volatile-defined">;
|
|
420
|
-
maxOutputBytes: z<number, number, "volatile-defined">;
|
|
421
|
-
maxSpillBytes: z<number, number, "volatile-defined">;
|
|
422
|
-
graceMs: z<number, number, "volatile-defined">;
|
|
423
|
-
/**
|
|
424
|
-
* Run commands through the resident agent when it is up (one long-lived
|
|
425
|
-
* in-distro process; in-distro timeout semantics), falling back to the
|
|
426
|
-
* one-shot `wsl.exe` path whenever the agent is out. `false` never uses
|
|
427
|
-
* the agent. The confinement, the output budgets' shapes and the result
|
|
428
|
-
* decoration are identical on both paths.
|
|
429
|
-
*/
|
|
430
|
-
agent: z<boolean, boolean, "defined">;
|
|
431
|
-
agentBackend: z<"auto" | "native" | "shell", "auto" | "native" | "shell", "defined">;
|
|
432
|
-
/**
|
|
433
|
-
* Run this session's commands in one persistent systemd user scope (ADR
|
|
434
|
-
* 0001): background processes survive the command that started them, `/tmp`
|
|
435
|
-
* is the distro's real `/tmp` under workspace-write, and `ps` sees the
|
|
436
|
-
* session. The executor holds the runtime until the session's scope
|
|
437
|
-
* disposes, then stops it. Requires systemd, a reachable user manager and
|
|
438
|
-
* `Linger`; the preflight refuses with the remedy when one is missing, and
|
|
439
|
-
* only a success is cached. Off by default; requires `agent: true`.
|
|
440
|
-
*/
|
|
441
|
-
sessionSandbox: z<boolean | "auto", boolean | "auto", "defined">;
|
|
442
|
-
}>>, "plain">;
|
|
443
|
-
/** Cached default distro, resolved once from `wsl.exe -l -q`. */
|
|
444
|
-
resolvedDistro: string;
|
|
445
|
-
/** Cached distro-user login shell, resolved once. */
|
|
446
|
-
resolvedShell: string;
|
|
447
|
-
/** Per-distro login shells, for a workspace that is not the default distro. */
|
|
448
|
-
resolvedShells: Map<string, string>;
|
|
449
|
-
/** Cached distro-user home, the workdir when `cwd` is empty. */
|
|
450
|
-
resolvedHome: string | undefined;
|
|
451
|
-
/** Per-distro homes, so two concurrent distros cannot share one. */
|
|
452
|
-
resolvedHomes: Map<string, string>;
|
|
453
|
-
/** The default mode — the capability fact the tool layer reads. */
|
|
454
|
-
mode: SandboxMode | undefined;
|
|
455
|
-
/** The distro-side confinement, or nothing when the operator opted out. */
|
|
456
|
-
sandbox: InstanceType<typeof WslSandbox> | undefined;
|
|
457
|
-
/** The session-runtime registry; tests substitute it. */
|
|
458
|
-
sessionRuntimes: SessionRuntimes;
|
|
459
|
-
/** The runtimes this executor holds, by registry key. */
|
|
460
|
-
sessionRuntimeEntries: Map<string, SessionRuntimeEntry>;
|
|
461
|
-
/** Isolates calls that have no session identity. */
|
|
462
|
-
sessionRuntimeOwner: string;
|
|
463
|
-
/** The preflight's host runner; tests substitute it. */
|
|
464
|
-
sessionScopeProbe: (argv: string[]) => Promise<string>;
|
|
465
|
-
/** Distros whose session-runtime preflight has succeeded. */
|
|
466
|
-
sessionRuntimePreflight: Set<string>;
|
|
467
|
-
/** Per-distro `auto` verdicts, re-probed when they were negative and stale. */
|
|
468
|
-
autoSessionScope: Map<string, {
|
|
469
|
-
usable: boolean;
|
|
470
|
-
checkedAt: number;
|
|
471
|
-
}>;
|
|
472
|
-
/**
|
|
473
|
-
* Per-process confinement facts retained until settlement. Overlapping calls
|
|
474
|
-
* can carry different policies, so a shared latest-wrap value would classify
|
|
475
|
-
* a process against the wrong facts. Unconfined processes have no entry.
|
|
476
|
-
*/
|
|
477
|
-
processFacts: Map<ShellExecution, ProcessFacts>;
|
|
478
|
-
/**
|
|
479
|
-
* @param ctx - the composition context.
|
|
480
|
-
* @param config - the validated plugin config.
|
|
481
|
-
*/
|
|
482
|
-
constructor(ctx: Context, config: WslShellExecutorConfig);
|
|
483
|
-
/**
|
|
484
|
-
* The mode this executor confines with, or `undefined` when it does not
|
|
485
|
-
* confine at all. `dsh-tool-bash` reads exactly this to decide whether to
|
|
486
|
-
* advertise the escalation field, so it must disappear together with the
|
|
487
|
-
* enforcement — never claim a boundary that is not applied.
|
|
488
|
-
*
|
|
489
|
-
* @returns the deployment default mode, or `undefined` when unconfined.
|
|
490
|
-
*/
|
|
491
|
-
get sandboxMode(): SandboxMode | undefined;
|
|
492
|
-
/**
|
|
493
|
-
* The distro used when no path supplies evidence: the pinned name, WSL's
|
|
494
|
-
* default, or the default for the automatic modes.
|
|
495
|
-
*
|
|
496
|
-
* @returns the distro name.
|
|
497
|
-
*/
|
|
498
|
-
distro(): Promise<string>;
|
|
499
|
-
/**
|
|
500
|
-
* The distro one command belongs to: an explicit pin wins; otherwise the
|
|
501
|
-
* request workdir, then the configured `cwd`, may name a distro; both
|
|
502
|
-
* absent falls back to WSL's default.
|
|
503
|
-
*
|
|
504
|
-
* @param workdir - the request's workdir, in any coordinate system.
|
|
505
|
-
* @param cwd - the configured default workdir, when the caller has it.
|
|
506
|
-
* @returns the distro name.
|
|
507
|
-
*/
|
|
508
|
-
distroFor(workdir?: string, cwd?: string): Promise<string>;
|
|
509
|
-
/**
|
|
510
|
-
* The shell name for the default/pinned distro, as the shell tool presents
|
|
511
|
-
* it.
|
|
512
|
-
*
|
|
513
|
-
* @returns the basename of the shell; `shell` while the probe fails, and
|
|
514
|
-
* `bash` for an implausible basename.
|
|
515
|
-
*/
|
|
516
|
-
shellName(): Promise<string>;
|
|
517
|
-
/**
|
|
518
|
-
* The shell for one distro: the configured shell, else that distro's login
|
|
519
|
-
* shell. The default/pinned distro keeps the legacy {@link resolvedShell}
|
|
520
|
-
* cache; every other distro gets an entry in {@link resolvedShells}.
|
|
521
|
-
*
|
|
522
|
-
* @param distro - the distro name.
|
|
523
|
-
* @returns an absolute path to the shell inside the distro.
|
|
524
|
-
* @throws {Error} when neither the config nor the distro names a usable
|
|
525
|
-
* shell — the failure is not cached, so the next call re-probes.
|
|
526
|
-
*/
|
|
527
|
-
shellFor(distro: string): Promise<string>;
|
|
528
|
-
/**
|
|
529
|
-
* The shell for the default/pinned distro: the configured one, else the
|
|
530
|
-
* login shell, resolved once and cached.
|
|
531
|
-
*
|
|
532
|
-
* @returns an absolute path to the shell inside the distro.
|
|
533
|
-
* @throws {Error} when neither the config nor the distro names a usable
|
|
534
|
-
* shell — the failure is not cached, so the next call re-probes.
|
|
535
|
-
*/
|
|
536
|
-
shell(): Promise<string>;
|
|
537
|
-
/**
|
|
538
|
-
* Windows directory the `wsl.exe` process is started from.
|
|
539
|
-
*
|
|
540
|
-
* @returns the host directory to spawn in.
|
|
541
|
-
*/
|
|
542
|
-
hostCwd(): string;
|
|
543
|
-
/**
|
|
544
|
-
* The shared resident agent serving this executor's distro.
|
|
545
|
-
*
|
|
546
|
-
* @param distro - the resolved distro name.
|
|
547
|
-
* @returns the shared agent.
|
|
548
|
-
*/
|
|
549
|
-
executionAgent(distro: string): WslAgent;
|
|
550
|
-
/**
|
|
551
|
-
* The persistent session runtime for one policy, when `sessionSandbox` is
|
|
552
|
-
* on. The executor holds one reference per `(session, distro, workspace, policy)` and
|
|
553
|
-
* releases them when the session's scope disposes.
|
|
554
|
-
*
|
|
555
|
-
* @param policy - the resolved file-effect policy, when the executor has one.
|
|
556
|
-
* @param resolved - the resolved spec, for the fallback workspace.
|
|
557
|
-
* @param distro - the resolved distro name.
|
|
558
|
-
* @returns the runtime entry, or undefined when the mode is off.
|
|
559
|
-
*/
|
|
560
|
-
sessionRuntimeFor(policy: {
|
|
561
|
-
mode: string;
|
|
562
|
-
workspaceRoot: string;
|
|
563
|
-
sessionId?: string;
|
|
564
|
-
} | undefined, resolved: WslExecSpec, distro: string): SessionRuntimeEntry | undefined;
|
|
565
|
-
/**
|
|
566
|
-
* Run the session runtime's preflight once per executor. A failure is a
|
|
567
|
-
* configuration verdict, not an agent outage: it is raised as an Error with
|
|
568
|
-
* the remedy, so the command fails closed instead of falling back to the
|
|
569
|
-
* per-command sandbox. Only success is cached, so a user who follows the
|
|
570
|
-
* remedy (`loginctl enable-linger`, `[boot] systemd=true`) does not need to
|
|
571
|
-
* restart the app.
|
|
572
|
-
*
|
|
573
|
-
* @param distro - the resolved distro name.
|
|
574
|
-
* @returns resolved once the platform can host a session runtime.
|
|
575
|
-
* @throws {Error} with the remedy when it cannot.
|
|
576
|
-
*/
|
|
577
|
-
ensureSessionRuntimeUsable(distro: string): Promise<void>;
|
|
578
|
-
/**
|
|
579
|
-
* Whether this executor should use the session runtime for one distro, with
|
|
580
|
-
* the `auto` downgrade and its bounded re-probe. `true` keeps the refusing
|
|
581
|
-
* behavior; `false` stays off.
|
|
582
|
-
*
|
|
583
|
-
* @param distro - the resolved distro.
|
|
584
|
-
* @returns whether to acquire the per-session scope.
|
|
585
|
-
*/
|
|
586
|
-
wantsSessionRuntime(distro: string): Promise<boolean>;
|
|
587
|
-
/**
|
|
588
|
-
* Release every runtime this executor holds, stopping each scope. Called
|
|
589
|
-
* from the session's dispose hook; public so tests and shutdown paths can
|
|
590
|
-
* await it.
|
|
591
|
-
*
|
|
592
|
-
* @returns resolved once every runtime is torn down.
|
|
593
|
-
*/
|
|
594
|
-
disposeSessionRuntimes(): Promise<void>;
|
|
595
|
-
/**
|
|
596
|
-
* The argv that runs INSIDE the distro for one spec: the resolved shell, its
|
|
597
|
-
* login/command flags, and the command string. This is the argv a
|
|
598
|
-
* distro-side sandbox wraps, which is why it is built separately from the
|
|
599
|
-
* `wsl.exe` invocation around it.
|
|
600
|
-
*
|
|
601
|
-
* @param spec - the resolved spec from {@link LocalBashExecutor.resolve}.
|
|
602
|
-
* @param shell - the resolved distro shell.
|
|
603
|
-
* @returns the distro-side argv.
|
|
604
|
-
*/
|
|
605
|
-
distroArgv(spec: ShellExecSpec, shell: string): string[];
|
|
606
|
-
/**
|
|
607
|
-
* Build the `wsl.exe` argv for one resolved spec. The command string is
|
|
608
|
-
* passed as a single argv element to the resolved shell, so there is no
|
|
609
|
-
* quoting layer of our own; Node's argv array reaches `wsl.exe` verbatim.
|
|
610
|
-
*
|
|
611
|
-
* `--exec` is load-bearing — see the comment inside.
|
|
612
|
-
*
|
|
613
|
-
* @param spec - the resolved spec from {@link LocalBashExecutor.resolve}.
|
|
614
|
-
* @param distro - the resolved distro name.
|
|
615
|
-
* @param shell - the resolved distro shell.
|
|
616
|
-
* @param inner - the already-confined distro argv, when confinement applies.
|
|
617
|
-
* @returns the argv to spawn.
|
|
618
|
-
*/
|
|
619
|
-
argv(spec: ShellExecSpec, distro: string, shell: string, inner?: string[]): string[];
|
|
620
|
-
/**
|
|
621
|
-
* Override only the spawn's working directory and environment. `spec.workdir`
|
|
622
|
-
* is a Linux path, which a Windows CreateProcess call cannot use as `cwd`.
|
|
623
|
-
*
|
|
624
|
-
* The inherited builder is private, so the call goes through the
|
|
625
|
-
* {@link SpawnSeamExecutor} bridge (`inheritedSpawnSpec`) instead of `super`
|
|
626
|
-
* — see docs/UPSTREAM-SPAWN-SEAM.md.
|
|
627
|
-
*
|
|
628
|
-
* @param spec - resolved execution settings.
|
|
629
|
-
* @param argv - the argv from {@link WslShellExecutor.argv}.
|
|
630
|
-
* @param stdoutMaxBytes - per-call stdout cap.
|
|
631
|
-
* @param signal - the spawn cancellation signal.
|
|
632
|
-
* @returns the subprocess spawn spec.
|
|
633
|
-
*/
|
|
634
|
-
spawnSpec(spec: ShellExecSpec, argv: string[], stdoutMaxBytes: number, signal?: AbortSignal): SubprocessSpawnSpec;
|
|
635
|
-
/**
|
|
636
|
-
* Resolve a request into a spec, replacing the parent's `process.cwd()`
|
|
637
|
-
* fallback with this provider's distro-home marker and stamping the per-call
|
|
638
|
-
* sandbox policy.
|
|
639
|
-
*
|
|
640
|
-
* The seam requires this step to be synchronous — the tool layer calls
|
|
641
|
-
* `ctx.shell.execute(ctx.shell.resolve(…))` with no `await` between them — so
|
|
642
|
-
* neither the home nor a confinement decision can be made here. Two request
|
|
643
|
-
* shapes default to the home when no `cwd` is configured: one that names no
|
|
644
|
-
* `workdir` at all, and one that names it only RELATIVELY — the parent
|
|
645
|
-
* resolves the first against `process.cwd()` (a Windows directory) and has
|
|
646
|
-
* nothing of its own to join the second onto. Both are stamped as the empty
|
|
647
|
-
* marker, with a relative tail carried verbatim in `relativeWorkdir`;
|
|
648
|
-
* {@link withDefaultWorkdir} resolves the pair against the home. The policy
|
|
649
|
-
* travels on the spec to {@link execute}, which awaits the wrap.
|
|
650
|
-
*
|
|
651
|
-
* @param request - the caller's request.
|
|
652
|
-
* @returns the fully-resolved spec.
|
|
653
|
-
*/
|
|
654
|
-
resolve(request: ShellExecRequest): WslExecSpec;
|
|
655
|
-
/**
|
|
656
|
-
* The spec to execute, with the home marker resolved against the distro
|
|
657
|
-
* user's home: `workdir: ""` becomes the home itself, and a relative tail
|
|
658
|
-
* carried by {@link WslShellExecutor.resolve} is joined under it. That is one
|
|
659
|
-
* `sh -c 'printf %s "$HOME"'` per provider instance, cached, and it happens
|
|
660
|
-
* only for a request that defaulted — an absolute workdir never reaches here.
|
|
661
|
-
*
|
|
662
|
-
* @param spec - the resolved spec.
|
|
663
|
-
* @returns the spec to execute.
|
|
664
|
-
*/
|
|
665
|
-
withDefaultWorkdir(spec: WslExecSpec): Promise<WslExecSpec>;
|
|
666
|
-
/**
|
|
667
|
-
* Decorate a handle's foreground projection in place, memoized once. The
|
|
668
|
-
* handle keeps its identity — never wrapped in a second object — because the
|
|
669
|
-
* per-process facts and `onProcessDone` key on the exact instance.
|
|
670
|
-
*
|
|
671
|
-
* @template H - the concrete handle type, preserved so the decorated handle
|
|
672
|
-
* keeps its identity in the callers' types; the settled result row the maps
|
|
673
|
-
* are spelled in is derived from its `result()`.
|
|
674
|
-
* @param ex - the execution handle to decorate.
|
|
675
|
-
* @param map - maps the settled result.
|
|
676
|
-
* @param mapError - maps a rejection, when the caller has one.
|
|
677
|
-
* @returns the same handle.
|
|
678
|
-
*/
|
|
679
|
-
static decorateResult<H extends {
|
|
680
|
-
result(): Promise<unknown>;
|
|
681
|
-
}>(ex: H, map: (result: Awaited<ReturnType<H["result"]>>) => Awaited<ReturnType<H["result"]>>, mapError: (error: unknown) => Awaited<ReturnType<H["result"]>> | Promise<Awaited<ReturnType<H["result"]>>>): H;
|
|
682
|
-
/**
|
|
683
|
-
* Stamp the per-process sandbox facts before `done` settles, so a background
|
|
684
|
-
* process reports the same mode, denial and enforcement a foreground run
|
|
685
|
-
* would. Signal deaths are not denials.
|
|
686
|
-
*
|
|
687
|
-
* @param proc - the settled process handle.
|
|
688
|
-
* @param stderr - the process's retained stderr tail used by subclasses for settlement classification.
|
|
689
|
-
* @param providerRejected - whether the subprocess promise rejected without a direct outcome.
|
|
690
|
-
* @param providerError - the provider rejection reason, which may itself be undefined.
|
|
691
|
-
*/
|
|
692
|
-
onProcessDone(proc: ShellExecution, stderr: string, providerRejected: boolean, providerError?: unknown): void;
|
|
693
|
-
/**
|
|
694
|
-
* Reject a settled command that failed because the distro itself is missing,
|
|
695
|
-
* stopped or unregistered.
|
|
696
|
-
*
|
|
697
|
-
* `wsl.exe` exits non-zero for that with an EMPTY stderr and its diagnostic on
|
|
698
|
-
* stdout, so nothing else here can see it: the denial signatures read stderr, and
|
|
699
|
-
* the result would otherwise reach the model as a bare non-zero code with no
|
|
700
|
-
* cause. The message names the remedy and says plainly that a wider permission
|
|
701
|
-
* cannot help — a sandbox flag does not create a distro.
|
|
702
|
-
*
|
|
703
|
-
* @param result - the settled shell result.
|
|
704
|
-
* @param distro - the distro the command asked for.
|
|
705
|
-
* @throws {Error} carrying the `WSL_E_*` code and the remedy.
|
|
706
|
-
*/
|
|
707
|
-
throwIfDistroUnavailable(result: {
|
|
708
|
-
exitCode?: number | null;
|
|
709
|
-
stdout?: {
|
|
710
|
-
text?: string;
|
|
711
|
-
};
|
|
712
|
-
stderr?: {
|
|
713
|
-
text?: string;
|
|
714
|
-
};
|
|
715
|
-
} | undefined, distro: string): void;
|
|
716
|
-
/**
|
|
717
|
-
* Reject a command that ran in the wrong directory.
|
|
718
|
-
*
|
|
719
|
-
* `wsl.exe --cd <path>` does not fail on a missing directory: it warns on stderr,
|
|
720
|
-
* runs the command in `/`, and exits 0. Reporting that as success would let a write
|
|
721
|
-
* or a build act on the wrong tree while every signal says it worked, so it becomes
|
|
722
|
-
* an error naming the directory that could not be entered.
|
|
723
|
-
*
|
|
724
|
-
* @param result - the settled shell result.
|
|
725
|
-
* @param workdir - the Linux directory the request asked for.
|
|
726
|
-
* @throws {Error} naming the directory and the fallback that happened.
|
|
727
|
-
*/
|
|
728
|
-
throwIfWorkdirMissing(result: {
|
|
729
|
-
exitCode?: number | null;
|
|
730
|
-
stdout?: {
|
|
731
|
-
text?: string;
|
|
732
|
-
};
|
|
733
|
-
stderr?: {
|
|
734
|
-
text?: string;
|
|
735
|
-
};
|
|
736
|
-
} | undefined, workdir: string): void;
|
|
737
|
-
/**
|
|
738
|
-
* Execute one resolved spec inside the distro, confined by the per-call policy
|
|
739
|
-
* when there is one.
|
|
740
|
-
*
|
|
741
|
-
* Confinement wraps the DISTRO-side argv (`<shell> -lc <command>`) in `bwrap`
|
|
742
|
-
* and hands the result to `wsl.exe --exec`, so the sandbox is built inside the
|
|
743
|
-
* distro while the process that spawns it stays the ordinary Windows one. The
|
|
744
|
-
* `danger-full-access` escalation — and an operator's `sandbox: false` — skip
|
|
745
|
-
* the wrap entirely and run the command as before.
|
|
746
|
-
*
|
|
747
|
-
* @param spec - resolved execution settings.
|
|
748
|
-
* @returns the live shell process handle.
|
|
749
|
-
*/
|
|
750
|
-
execute(spec: ShellExecSpec): Promise<ShellExecution>;
|
|
751
|
-
/**
|
|
752
|
-
* Refuse a workdir that names another WSL distro — the shell-side twin of
|
|
753
|
-
* the filesystem's `FS_OUTSIDE_DISTRO` fence. Left unguarded, `toLinuxPath`
|
|
754
|
-
* strips the UNC's distro name and the command runs inside THIS distro
|
|
755
|
-
* against whatever tree happens to share the path, silently, while the fs
|
|
756
|
-
* side refuses the same workspace outright. The wording mirrors the fs
|
|
757
|
-
* refusal (minus `restrictToDistro`, which is an fs-only key).
|
|
758
|
-
*
|
|
759
|
-
* @param workdir - the resolved workdir (UNC, Linux path, or Windows path).
|
|
760
|
-
* @param distro - the pinned distro name.
|
|
761
|
-
* @throws {Error} naming both distros and both ways out.
|
|
762
|
-
*/
|
|
763
|
-
throwIfWorkdirInAnotherDistro(workdir: string, distro: string): void;
|
|
764
|
-
/**
|
|
765
|
-
* The agent-backed execution path: one long-lived in-distro process, the
|
|
766
|
-
* confinement argv unchanged, the handle shape unchanged. Any
|
|
767
|
-
* {@link AgentUnavailableError} propagates for the caller's fallback.
|
|
768
|
-
*
|
|
769
|
-
* @param resolved - the resolved spec from {@link WslShellExecutor.execute}.
|
|
770
|
-
* @param distro - the resolved distro name.
|
|
771
|
-
* @param shell - the resolved distro shell.
|
|
772
|
-
* @returns the decorated execution result.
|
|
773
|
-
*/
|
|
774
|
-
executeViaAgent(resolved: WslExecSpec, distro: string, shell: string): Promise<ShellExecution>;
|
|
775
|
-
/**
|
|
776
|
-
* The pre-agent execution path, verbatim: one `wsl.exe` per command through
|
|
777
|
-
* the inherited `executeArgv` machinery. Kept as the permanent fallback for
|
|
778
|
-
* an out-of-service agent and as the `agent: false` behaviour.
|
|
779
|
-
*
|
|
780
|
-
* @param resolved - the resolved spec.
|
|
781
|
-
* @param distro - the resolved distro name.
|
|
782
|
-
* @param shell - the resolved distro shell.
|
|
783
|
-
* @returns the decorated execution result.
|
|
784
|
-
*/
|
|
785
|
-
executeOneShot(resolved: WslExecSpec, distro: string, shell: string): Promise<ShellExecution>;
|
|
786
|
-
/**
|
|
787
|
-
* The confined one-shot's argv prepare: confine the distro argv under the
|
|
788
|
-
* policy, keep the resulting profile for the fact-stamper and the settlement
|
|
789
|
-
* mapping, and hand back the wrapped host argv.
|
|
790
|
-
*
|
|
791
|
-
* @param resolved - the resolved spec.
|
|
792
|
-
* @param distro - the resolved distro name.
|
|
793
|
-
* @param shell - the resolved distro shell.
|
|
794
|
-
* @param policy - the confined policy (narrowed in by `executeOneShot`).
|
|
795
|
-
* @param slot - the closure the builder assigns the profile into.
|
|
796
|
-
* @param signal - the caller's cancellation.
|
|
797
|
-
*/
|
|
798
|
-
private prepareConfinedArgv;
|
|
799
|
-
/**
|
|
800
|
-
* Stamp the per-process sandbox facts before `done` settles, so a background
|
|
801
|
-
* process reports the same mode, denial and enforcement a foreground run
|
|
802
|
-
* would.
|
|
803
|
-
*
|
|
804
|
-
* @param resolved - the resolved spec.
|
|
805
|
-
* @param mode - the confined policy's mode.
|
|
806
|
-
* @param slot - the closure holding the assigned profile.
|
|
807
|
-
* @param process - the spawned handle.
|
|
808
|
-
*/
|
|
809
|
-
private stampConfinedFacts;
|
|
810
|
-
/**
|
|
811
|
-
* Settle one confined one-shot result: the distro and workdir verdicts, the
|
|
812
|
-
* never-armed honesty stamp, the runner-failure throw, and the denial facts.
|
|
813
|
-
*
|
|
814
|
-
* @param result - the settled process result.
|
|
815
|
-
* @param distro - the resolved distro name.
|
|
816
|
-
* @param resolved - the resolved spec.
|
|
817
|
-
* @param mode - the confined policy's mode.
|
|
818
|
-
* @param confined - the profile the argv prepare armed, when it ran.
|
|
819
|
-
*/
|
|
820
|
-
private settleConfinedOneShot;
|
|
821
|
-
}
|
|
822
|
-
/**
|
|
823
|
-
* Filesystem backend over a WSL distro's UNC share.
|
|
824
|
-
*
|
|
825
|
-
* Reads, listings, stats and searches reuse the host backend verbatim: the
|
|
826
|
-
* share is a real filesystem to Node, and the packaged ripgrep walks it too.
|
|
827
|
-
* Two things are deliberately replaced.
|
|
828
|
-
*
|
|
829
|
-
* **Resolution** accepts Linux paths (`/home/andy/proj/src/a.ts`) and shows them
|
|
830
|
-
* back as Linux paths, while `targetKey` stays the UNC path the host I/O uses —
|
|
831
|
-
* the seam treats `targetKey` as opaque and reserves `displayPath` for model and
|
|
832
|
-
* UI output, so this rewrite is contract-legal.
|
|
833
|
-
*
|
|
834
|
-
* **Mutation guards are hoisted.** The host backend publishes a guarded
|
|
835
|
-
* *creation* by hard-linking a staged file into place, and the WSL UNC share
|
|
836
|
-
* rejects hard links with `ENOTSUP`; it also refuses `symlink` with `EPERM`.
|
|
837
|
-
* Guarded creation through the share would therefore fail with `FS_IO_ERROR` on
|
|
838
|
-
* the most common write there is — creating a new file. This backend checks the
|
|
839
|
-
* caller's guard itself and then delegates the unguarded publication, which the
|
|
840
|
-
* share does support. The residual window is the same check-then-act race
|
|
841
|
-
* `dsh-fs-sandbox` already documents and accepts.
|
|
842
|
-
*
|
|
843
|
-
* **Publication is replaced.** Unguarded is not enough on its own: the host
|
|
844
|
-
* backend's Windows branch also copies the replaced file's security descriptor
|
|
845
|
-
* and publishes with `ReplaceFileW`, and neither exists on a 9p share — the
|
|
846
|
-
* descriptor read fails every write to an existing file outright. See the
|
|
847
|
-
* constructor for what runs instead.
|
|
848
|
-
*/
|
|
849
|
-
/**
|
|
850
|
-
* The WSL filesystem provider's validated config — the keys of
|
|
851
|
-
* {@link WslFileSystem.Config}, which the upstream `LocalFileSystem` config
|
|
852
|
-
* type does not know. This provider has no volatile fields: every key is read
|
|
853
|
-
* as its plain value.
|
|
854
|
-
*/
|
|
855
|
-
interface WslFileSystemConfig {
|
|
856
|
-
/** The pinned distro; empty resolves WSL's default. */
|
|
857
|
-
distro: string;
|
|
858
|
-
/** The base directory for relative input. */
|
|
859
|
-
cwd: string;
|
|
860
|
-
/** The `wsl.exe` path, for default-distro resolution. */
|
|
861
|
-
wslPath: string;
|
|
862
|
-
/**
|
|
863
|
-
* The overwrite-diff byte bound per side; schema-defaulted when mounted
|
|
864
|
-
* through cordis, and defaulted again by the substrate when absent.
|
|
865
|
-
*/
|
|
866
|
-
diffBasisMaxBytes?: number;
|
|
867
|
-
/** Whether mutations are fenced by the policy. */
|
|
868
|
-
sandbox: boolean;
|
|
869
|
-
/** Session runtime: `true` requires it, `false` disables it, `"auto"` uses it when usable. */
|
|
870
|
-
sessionSandbox: boolean | "auto";
|
|
871
|
-
/** Whether confined profiles mask `/mnt`. */
|
|
872
|
-
maskWindowsDrive: boolean;
|
|
873
|
-
/** Whether paths leaving the distro are refused. */
|
|
874
|
-
restrictToDistro: boolean;
|
|
875
|
-
/** The in-distro watch scan depth bound. */
|
|
876
|
-
watchMaxDepth: number;
|
|
877
|
-
/**
|
|
878
|
-
* Which I/O substrate serves the file tools; schema-defaulted when mounted
|
|
879
|
-
* through cordis, absent on direct construction (the router), which the
|
|
880
|
-
* constructor's refusal treats as `"agent"`.
|
|
881
|
-
*/
|
|
882
|
-
substrate?: string;
|
|
883
|
-
}
|
|
884
|
-
export declare class WslFileSystem extends LocalFileSystem {
|
|
885
|
-
static inject: string[];
|
|
886
|
-
static Config: z<Schemastery.ObjectS<NoInfer<{
|
|
887
|
-
/**
|
|
888
|
-
* Distro mode: empty/`"auto"` follows the target path, `"default"` forces
|
|
889
|
-
* WSL's default, and an explicit name pins the filesystem.
|
|
890
|
-
*/
|
|
891
|
-
distro: z<string, string, "defined">;
|
|
892
|
-
/**
|
|
893
|
-
* Default workdir for relative input; accepts a Linux path, a UNC path, or
|
|
894
|
-
* `C:\...`. Empty — the default — means the distro user's home, resolved
|
|
895
|
-
* inside the distro.
|
|
896
|
-
*/
|
|
897
|
-
cwd: z<string, string, "defined">;
|
|
898
|
-
/** Path to `wsl.exe`, used only to resolve the default distro. */
|
|
899
|
-
wslPath: z<string, string, "defined">;
|
|
900
|
-
/** UTF-8 byte limit per overwrite-diff side, mirroring the host backend. */
|
|
901
|
-
diffBasisMaxBytes: z<number, number, "defined">;
|
|
902
|
-
/**
|
|
903
|
-
* Fence mutations by `ctx.sandboxPolicy`, and report the mode through
|
|
904
|
-
* {@link sandboxMode}. `false` restores the pre-sandbox behaviour exactly —
|
|
905
|
-
* an unfenced backend that reports `undefined` — for an operator who wants
|
|
906
|
-
* the old posture and accepts what it means: the model is told these
|
|
907
|
-
* operations are unconfined.
|
|
908
|
-
*/
|
|
909
|
-
sandbox: z<boolean, boolean, "defined">;
|
|
910
|
-
/**
|
|
911
|
-
* Run confined mutations in the session's systemd user scope — the same
|
|
912
|
-
* runtime the shell executor acquires for the same session, distro,
|
|
913
|
-
* workspace and policy — instead of a per-policy confined resident. A
|
|
914
|
-
* missing session ID keeps the providers separate. The kernel enforcement
|
|
915
|
-
* is the runtime's mount profile; the scope stops when its providers
|
|
916
|
-
* release it. Requires systemd + `Linger`, like `wsl-shell`'s
|
|
917
|
-
* `sessionSandbox`; the preflight refuses with the remedy. Off for direct
|
|
918
|
-
* constructions; on in the shipped preset.
|
|
919
|
-
*/
|
|
920
|
-
sessionSandbox: z<boolean | "auto", boolean | "auto", "defined">;
|
|
921
|
-
/**
|
|
922
|
-
* Shadow `/mnt` with an empty tmpfs in every confined profile, hiding the
|
|
923
|
-
* Windows drive from confined commands — same meaning and same honest
|
|
924
|
-
* limits as the `wsl-shell` key of the same name (its doc carries the
|
|
925
|
-
* full story). Confined fs mutations publish through the masked resident;
|
|
926
|
-
* reads and the share substrate are unaffected.
|
|
927
|
-
*/
|
|
928
|
-
maskWindowsDrive: z<boolean, boolean, "defined">;
|
|
929
|
-
/**
|
|
930
|
-
* Refuse any path that leaves the pinned distro. A WSL filesystem is a
|
|
931
|
-
* whole-Linux view whose `/mnt/c` also reaches the Windows disk, so without
|
|
932
|
-
* this the backend would silently widen the session far beyond the
|
|
933
|
-
* workspace the operator selected.
|
|
934
|
-
*/
|
|
935
|
-
restrictToDistro: z<boolean, boolean, "defined">;
|
|
936
|
-
/**
|
|
937
|
-
* How deep the in-distro watch scan walks, `1` = the watched directory and
|
|
938
|
-
* its direct children. `0` — the default — walks the whole tree, which is
|
|
939
|
-
* what the invalidation contract asks for but a real cost every poll over
|
|
940
|
-
* a tree containing a `node_modules`; a bound trades that cost for a
|
|
941
|
-
* documented blind spot: a change below the bound is not seen until
|
|
942
|
-
* another change above it fires the same callback.
|
|
943
|
-
*/
|
|
944
|
-
watchMaxDepth: z<number, number, "defined">;
|
|
945
|
-
/**
|
|
946
|
-
* Which I/O substrate serves the file tools. Only `"agent"` exists — the
|
|
947
|
-
* resident in-distro agent (`lib/fs-substrate.js`): reads, writes and
|
|
948
|
-
* identities run where the files live, symlinks and mode bits are native,
|
|
949
|
-
* and the mutation guard survives to the write's no-replace publication,
|
|
950
|
-
* kernel-enforced by the confined resident when the policy is confined.
|
|
951
|
-
* The former `"share"` opt-out — the Windows-side host filesystem stack
|
|
952
|
-
* over the distro's 9p share — is retired: it was the one model-facing
|
|
953
|
-
* I/O path that still crossed the share, and the agent has no fallback
|
|
954
|
-
* that needs it. A profile carrying `"share"` is refused at construction
|
|
955
|
-
* with the migration (`shareSubstrateRefusal`). `watch()` rides the
|
|
956
|
-
* in-distro poll loop for the substrate regardless (`lib/watcher.js`) —
|
|
957
|
-
* it never ran through either substrate. The substrate never changes
|
|
958
|
-
* `sandboxMode`'s honesty.
|
|
959
|
-
*/
|
|
960
|
-
substrate: z<"agent" | "share", "agent" | "share", "defined">;
|
|
961
|
-
}>>, Schemastery.ObjectT<NoInfer<{
|
|
962
|
-
/**
|
|
963
|
-
* Distro mode: empty/`"auto"` follows the target path, `"default"` forces
|
|
964
|
-
* WSL's default, and an explicit name pins the filesystem.
|
|
965
|
-
*/
|
|
966
|
-
distro: z<string, string, "defined">;
|
|
967
|
-
/**
|
|
968
|
-
* Default workdir for relative input; accepts a Linux path, a UNC path, or
|
|
969
|
-
* `C:\...`. Empty — the default — means the distro user's home, resolved
|
|
970
|
-
* inside the distro.
|
|
971
|
-
*/
|
|
972
|
-
cwd: z<string, string, "defined">;
|
|
973
|
-
/** Path to `wsl.exe`, used only to resolve the default distro. */
|
|
974
|
-
wslPath: z<string, string, "defined">;
|
|
975
|
-
/** UTF-8 byte limit per overwrite-diff side, mirroring the host backend. */
|
|
976
|
-
diffBasisMaxBytes: z<number, number, "defined">;
|
|
977
|
-
/**
|
|
978
|
-
* Fence mutations by `ctx.sandboxPolicy`, and report the mode through
|
|
979
|
-
* {@link sandboxMode}. `false` restores the pre-sandbox behaviour exactly —
|
|
980
|
-
* an unfenced backend that reports `undefined` — for an operator who wants
|
|
981
|
-
* the old posture and accepts what it means: the model is told these
|
|
982
|
-
* operations are unconfined.
|
|
983
|
-
*/
|
|
984
|
-
sandbox: z<boolean, boolean, "defined">;
|
|
985
|
-
/**
|
|
986
|
-
* Run confined mutations in the session's systemd user scope — the same
|
|
987
|
-
* runtime the shell executor acquires for the same session, distro,
|
|
988
|
-
* workspace and policy — instead of a per-policy confined resident. A
|
|
989
|
-
* missing session ID keeps the providers separate. The kernel enforcement
|
|
990
|
-
* is the runtime's mount profile; the scope stops when its providers
|
|
991
|
-
* release it. Requires systemd + `Linger`, like `wsl-shell`'s
|
|
992
|
-
* `sessionSandbox`; the preflight refuses with the remedy. Off for direct
|
|
993
|
-
* constructions; on in the shipped preset.
|
|
994
|
-
*/
|
|
995
|
-
sessionSandbox: z<boolean | "auto", boolean | "auto", "defined">;
|
|
996
|
-
/**
|
|
997
|
-
* Shadow `/mnt` with an empty tmpfs in every confined profile, hiding the
|
|
998
|
-
* Windows drive from confined commands — same meaning and same honest
|
|
999
|
-
* limits as the `wsl-shell` key of the same name (its doc carries the
|
|
1000
|
-
* full story). Confined fs mutations publish through the masked resident;
|
|
1001
|
-
* reads and the share substrate are unaffected.
|
|
1002
|
-
*/
|
|
1003
|
-
maskWindowsDrive: z<boolean, boolean, "defined">;
|
|
1004
|
-
/**
|
|
1005
|
-
* Refuse any path that leaves the pinned distro. A WSL filesystem is a
|
|
1006
|
-
* whole-Linux view whose `/mnt/c` also reaches the Windows disk, so without
|
|
1007
|
-
* this the backend would silently widen the session far beyond the
|
|
1008
|
-
* workspace the operator selected.
|
|
1009
|
-
*/
|
|
1010
|
-
restrictToDistro: z<boolean, boolean, "defined">;
|
|
1011
|
-
/**
|
|
1012
|
-
* How deep the in-distro watch scan walks, `1` = the watched directory and
|
|
1013
|
-
* its direct children. `0` — the default — walks the whole tree, which is
|
|
1014
|
-
* what the invalidation contract asks for but a real cost every poll over
|
|
1015
|
-
* a tree containing a `node_modules`; a bound trades that cost for a
|
|
1016
|
-
* documented blind spot: a change below the bound is not seen until
|
|
1017
|
-
* another change above it fires the same callback.
|
|
1018
|
-
*/
|
|
1019
|
-
watchMaxDepth: z<number, number, "defined">;
|
|
1020
|
-
/**
|
|
1021
|
-
* Which I/O substrate serves the file tools. Only `"agent"` exists — the
|
|
1022
|
-
* resident in-distro agent (`lib/fs-substrate.js`): reads, writes and
|
|
1023
|
-
* identities run where the files live, symlinks and mode bits are native,
|
|
1024
|
-
* and the mutation guard survives to the write's no-replace publication,
|
|
1025
|
-
* kernel-enforced by the confined resident when the policy is confined.
|
|
1026
|
-
* The former `"share"` opt-out — the Windows-side host filesystem stack
|
|
1027
|
-
* over the distro's 9p share — is retired: it was the one model-facing
|
|
1028
|
-
* I/O path that still crossed the share, and the agent has no fallback
|
|
1029
|
-
* that needs it. A profile carrying `"share"` is refused at construction
|
|
1030
|
-
* with the migration (`shareSubstrateRefusal`). `watch()` rides the
|
|
1031
|
-
* in-distro poll loop for the substrate regardless (`lib/watcher.js`) —
|
|
1032
|
-
* it never ran through either substrate. The substrate never changes
|
|
1033
|
-
* `sandboxMode`'s honesty.
|
|
1034
|
-
*/
|
|
1035
|
-
substrate: z<"agent" | "share", "agent" | "share", "defined">;
|
|
1036
|
-
}>>, "plain">;
|
|
1037
|
-
/** Cached default distro, resolved once from `wsl.exe -l -q`. */
|
|
1038
|
-
resolvedDistro: string;
|
|
1039
|
-
/** Cached distro-user home, the base for relative input when `cwd` is empty. */
|
|
1040
|
-
resolvedHome: string | undefined;
|
|
1041
|
-
/** Per-distro homes, so two concurrent distros cannot share one. */
|
|
1042
|
-
resolvedHomes: Map<string, string>;
|
|
1043
|
-
/** The deployment default mode — the capability fact the tool layer reads. */
|
|
1044
|
-
defaultMode: SandboxMode;
|
|
1045
|
-
/** The lazy default-distro substrate, kept for the legacy accessor and tests. */
|
|
1046
|
-
agentSubstrateInstance: AgentSubstrate | undefined;
|
|
1047
|
-
/** The per-distro agent-backed substrates. */
|
|
1048
|
-
agentSubstrates: Map<string, AgentSubstrate>;
|
|
1049
|
-
/** The distro-side bwrap usability probe, shared with the confined agents. */
|
|
1050
|
-
sandbox: InstanceType<typeof WslSandbox>;
|
|
1051
|
-
/** The resident agent serving publication for the default/pinned distro. */
|
|
1052
|
-
agentInstance: WslAgent | undefined;
|
|
1053
|
-
/** The per-distro publication agents. */
|
|
1054
|
-
agentInstances: Map<string, WslAgent>;
|
|
1055
|
-
/** The session-runtime registry; tests substitute it. */
|
|
1056
|
-
sessionRuntimes: SessionRuntimes;
|
|
1057
|
-
/** The runtimes this provider holds, by registry key. */
|
|
1058
|
-
sessionRuntimeEntries: Map<string, SessionRuntimeEntry>;
|
|
1059
|
-
/** Isolates calls that have no session identity. */
|
|
1060
|
-
sessionRuntimeOwner: string;
|
|
1061
|
-
/** The preflight's host runner; tests substitute it. */
|
|
1062
|
-
sessionScopeProbe: (argv: string[]) => Promise<string>;
|
|
1063
|
-
/** Distros whose session-runtime preflight has succeeded. */
|
|
1064
|
-
sessionRuntimePreflight: Set<string>;
|
|
1065
|
-
/** Per-distro `auto` verdicts, re-probed when they were negative and stale. */
|
|
1066
|
-
autoSessionScope: Map<string, {
|
|
1067
|
-
usable: boolean;
|
|
1068
|
-
checkedAt: number;
|
|
1069
|
-
}>;
|
|
1070
|
-
/**
|
|
1071
|
-
* @param ctx - the composition context.
|
|
1072
|
-
* @param config - the validated plugin config.
|
|
1073
|
-
*/
|
|
1074
|
-
constructor(ctx: Context, config: WslFileSystemConfig);
|
|
1075
|
-
/**
|
|
1076
|
-
* The mode this backend fences mutations with, or `undefined` when the
|
|
1077
|
-
* operator turned the fence off. This is the capability fact `dsh-tool-fs`
|
|
1078
|
-
* reads to advertise the escalation fields honestly, so it must disappear
|
|
1079
|
-
* together with the enforcement — never claim a boundary that is not applied.
|
|
1080
|
-
*
|
|
1081
|
-
* @returns the deployment default mode, or `undefined` when unfenced.
|
|
1082
|
-
*/
|
|
1083
|
-
get sandboxMode(): SandboxMode | undefined;
|
|
1084
|
-
/**
|
|
1085
|
-
* The resident agent serving the default/pinned distro's in-distro side
|
|
1086
|
-
* work, created on first use and kept for the provider's lifetime.
|
|
1087
|
-
*
|
|
1088
|
-
* @returns the agent for the default/pinned distro.
|
|
1089
|
-
*/
|
|
1090
|
-
publicationAgent(): Promise<WslAgent>;
|
|
1091
|
-
/**
|
|
1092
|
-
* The resident agent for one distro. The default/pinned distro keeps the
|
|
1093
|
-
* legacy {@link publicationAgent} cache; every other distro gets its own
|
|
1094
|
-
* entry, because the shared agent is a per-distro process singleton.
|
|
1095
|
-
*
|
|
1096
|
-
* @param distro - the distro name.
|
|
1097
|
-
* @returns the agent for that distro.
|
|
1098
|
-
*/
|
|
1099
|
-
publicationAgentFor(distro: string): Promise<WslAgent>;
|
|
1100
|
-
/**
|
|
1101
|
-
* The agent-backed substrate for the default/pinned distro, built on first
|
|
1102
|
-
* use over the shared resident agent.
|
|
1103
|
-
*
|
|
1104
|
-
* @returns the substrate.
|
|
1105
|
-
*/
|
|
1106
|
-
agentSubstrate(): Promise<AgentSubstrate>;
|
|
1107
|
-
/**
|
|
1108
|
-
* The agent-backed substrate for one distro. The default/pinned distro keeps
|
|
1109
|
-
* the legacy {@link agentSubstrate} accessor (and its test override); every
|
|
1110
|
-
* other distro gets a substrate that mints its own UNC identities and
|
|
1111
|
-
* addresses its own resident.
|
|
1112
|
-
*
|
|
1113
|
-
* @param distro - the distro name.
|
|
1114
|
-
* @returns the substrate for that distro.
|
|
1115
|
-
*/
|
|
1116
|
-
agentSubstrateFor(distro: string): Promise<AgentSubstrate>;
|
|
1117
|
-
/**
|
|
1118
|
-
* The substrate for one resolved target, following the target's UNC identity.
|
|
1119
|
-
*
|
|
1120
|
-
* @param target - the resolved target.
|
|
1121
|
-
* @returns the substrate for the target's distro.
|
|
1122
|
-
*/
|
|
1123
|
-
substrateForTarget(target: FsTarget): Promise<AgentSubstrate>;
|
|
1124
|
-
/**
|
|
1125
|
-
* The persistent session runtime for one confined mutation, when
|
|
1126
|
-
* `sessionSandbox` is on. The key is the shell executor's key for the same
|
|
1127
|
-
* session/policy, so the write and the commands share one agent, one mount
|
|
1128
|
-
* view and one scope; the provider holds a reference until the session ends.
|
|
1129
|
-
*
|
|
1130
|
-
* @param policy - the resolved confined policy.
|
|
1131
|
-
* @param distro - the resolved distro name.
|
|
1132
|
-
* @returns the runtime entry, or undefined when the mode is off.
|
|
1133
|
-
*/
|
|
1134
|
-
sessionRuntimeFor(policy: {
|
|
1135
|
-
mode: string;
|
|
1136
|
-
workspaceRoot: string;
|
|
1137
|
-
sessionId?: string;
|
|
1138
|
-
}, distro: string): SessionRuntimeEntry | undefined;
|
|
1139
|
-
/**
|
|
1140
|
-
* Run the session runtime's preflight once per provider. Only success is
|
|
1141
|
-
* cached, so following the remedy does not need an app restart.
|
|
1142
|
-
*
|
|
1143
|
-
* @param distro - the resolved distro name.
|
|
1144
|
-
* @returns resolved once the platform can host the runtime.
|
|
1145
|
-
* @throws {Error} with the remedy when it cannot.
|
|
1146
|
-
*/
|
|
1147
|
-
ensureSessionRuntimeUsable(distro: string): Promise<void>;
|
|
1148
|
-
/**
|
|
1149
|
-
* Whether this provider should use the session runtime for one distro, with
|
|
1150
|
-
* the `auto` downgrade and its bounded re-probe. `true` keeps the refusing
|
|
1151
|
-
* behavior; `false` stays off.
|
|
1152
|
-
*
|
|
1153
|
-
* @param distro - the resolved distro.
|
|
1154
|
-
* @returns whether to acquire the per-session scope.
|
|
1155
|
-
*/
|
|
1156
|
-
wantsSessionRuntime(distro: string): Promise<boolean>;
|
|
1157
|
-
/**
|
|
1158
|
-
* Release every runtime this provider holds. Called from the preset's
|
|
1159
|
-
* dispose effect; public so tests and shutdown paths can await it.
|
|
1160
|
-
*
|
|
1161
|
-
* @returns resolved once every reference is released.
|
|
1162
|
-
*/
|
|
1163
|
-
disposeSessionRuntimes(): Promise<void>;
|
|
1164
|
-
/**
|
|
1165
|
-
* The agent a MUTATION runs on under this resolved policy — stage-two
|
|
1166
|
-
* routing. A confined policy addresses the confined resident whose bwrap
|
|
1167
|
-
* profile binds exactly what the mode grants, so the kernel enforces what
|
|
1168
|
-
* the check decided; an escalated write (`danger-full-access`) or a disabled
|
|
1169
|
-
* sandbox addresses the plain resident, which is what those mean. A distro
|
|
1170
|
-
* without a usable bwrap refuses confined mutations instead of downgrading
|
|
1171
|
-
* them — the same closed failure the command path has.
|
|
1172
|
-
*
|
|
1173
|
-
* @param policy - the resolved file-effect policy, or undefined when the
|
|
1174
|
-
* caller pre-checked.
|
|
1175
|
-
* @param forDistro - the distro the mutation belongs to; derived from the
|
|
1176
|
-
* policy when the caller does not know it.
|
|
1177
|
-
* @returns the agent to publish through.
|
|
1178
|
-
*/
|
|
1179
|
-
mutationAgent(policy: {
|
|
1180
|
-
mode: string;
|
|
1181
|
-
workspaceRoot: string;
|
|
1182
|
-
sessionId?: string;
|
|
1183
|
-
} | undefined, forDistro?: string): Promise<WslAgent>;
|
|
1184
|
-
/**
|
|
1185
|
-
* Map a substrate error onto the peer's `FsError`, so the tool layer reads
|
|
1186
|
-
* the same refusal dialect on both substrates. An agent that is out becomes
|
|
1187
|
-
* an I/O error naming the cause — the share backend's "distro is gone" case
|
|
1188
|
-
* is the same availability, but the message says which substrate failed.
|
|
1189
|
-
*
|
|
1190
|
-
* @param error - what the substrate raised.
|
|
1191
|
-
* @returns the error to surface.
|
|
1192
|
-
*/
|
|
1193
|
-
peerError(error: unknown): FsError;
|
|
1194
|
-
/**
|
|
1195
|
-
* One resolved target's Linux path — the substrate's coordinate — falling
|
|
1196
|
-
* back to the display spelling when the identity is not a distro share path.
|
|
1197
|
-
*
|
|
1198
|
-
* @param target - the resolved target.
|
|
1199
|
-
* @returns the absolute Linux path.
|
|
1200
|
-
*/
|
|
1201
|
-
linuxOf(target: FsTarget): string;
|
|
1202
|
-
/**
|
|
1203
|
-
* The distro used when no path supplies evidence: the pinned name, WSL's
|
|
1204
|
-
* default, or the default for the automatic modes.
|
|
1205
|
-
*
|
|
1206
|
-
* @returns the distro name.
|
|
1207
|
-
*/
|
|
1208
|
-
distro(): Promise<string>;
|
|
1209
|
-
/**
|
|
1210
|
-
* The distro one path belongs to: an explicit pin wins; otherwise the path
|
|
1211
|
-
* itself, then the cwd or configured cwd, may name a distro; both absent
|
|
1212
|
-
* falls back to WSL's default.
|
|
1213
|
-
*
|
|
1214
|
-
* @param path - the caller path, in any coordinate system.
|
|
1215
|
-
* @param cwd - the caller's optional cwd override.
|
|
1216
|
-
* @returns the distro name.
|
|
1217
|
-
*/
|
|
1218
|
-
distroForPath(path: string, cwd?: string): Promise<string>;
|
|
1219
|
-
/**
|
|
1220
|
-
* The distro a resolved target belongs to. A UNC identity names it outright;
|
|
1221
|
-
* a host-coordinate target falls back to the configured/default distro.
|
|
1222
|
-
*
|
|
1223
|
-
* @param target - the resolved target.
|
|
1224
|
-
* @returns the distro name.
|
|
1225
|
-
*/
|
|
1226
|
-
distroForTarget(target: FsTarget): Promise<string>;
|
|
1227
|
-
/**
|
|
1228
|
-
* The distro a mutation's policy belongs to: the workspace root is the
|
|
1229
|
-
* strongest evidence, then the configured cwd, then the default.
|
|
1230
|
-
*
|
|
1231
|
-
* @param policy - the resolved policy, when the caller has one.
|
|
1232
|
-
* @returns the distro name.
|
|
1233
|
-
*/
|
|
1234
|
-
distroForPolicy(policy: {
|
|
1235
|
-
mode: string;
|
|
1236
|
-
workspaceRoot: string;
|
|
1237
|
-
} | undefined): Promise<string>;
|
|
1238
|
-
/**
|
|
1239
|
-
* Translate one caller path into the world path, enforcing the distro fence.
|
|
1240
|
-
*
|
|
1241
|
-
* @param path - a Linux, UNC or Windows path.
|
|
1242
|
-
* @param cwd - the caller's override of the configured default workdir.
|
|
1243
|
-
* @returns the host path to operate on.
|
|
1244
|
-
*/
|
|
1245
|
-
worldPath(path: string, cwd?: string): Promise<string>;
|
|
1246
|
-
/**
|
|
1247
|
-
* Resolve a path to a target whose `targetKey` is the UNC identity the host
|
|
1248
|
-
* I/O stack uses and whose `displayPath` is the Linux path the model sees.
|
|
1249
|
-
*
|
|
1250
|
-
* @param path - a Linux, UNC or Windows path.
|
|
1251
|
-
* @param opts - optional `cwd` override and `signal`.
|
|
1252
|
-
* @returns the resolved `FsTarget`.
|
|
1253
|
-
*/
|
|
1254
|
-
resolve(path: string, opts?: {
|
|
1255
|
-
cwd?: string;
|
|
1256
|
-
signal?: AbortSignal;
|
|
1257
|
-
}): Promise<FsTarget>;
|
|
1258
|
-
/**
|
|
1259
|
-
* Enforce the per-call file-effect policy against one target and return the
|
|
1260
|
-
* EXACT target the mutation must use, so the checked identity is the mutated
|
|
1261
|
-
* one (no check-here-write-there window).
|
|
1262
|
-
*
|
|
1263
|
-
* `read-only` denies outright. `workspace-write` re-resolves the target NOW
|
|
1264
|
-
* (reflecting a symlink ancestor swapped since the tool resolved it), requires
|
|
1265
|
-
* containment under a writable root — the workspace plus the temp area of the
|
|
1266
|
-
* world the workspace lives in — and hands back that fresh target.
|
|
1267
|
-
* `danger-full-access` is the approved escalation and is not fenced. Refusal
|
|
1268
|
-
* is the structured `FS_SANDBOX_DENIED` the tool layer maps to its
|
|
1269
|
-
* model-facing `[sandbox: …]` marker and escalation hint.
|
|
1270
|
-
*
|
|
1271
|
-
* @param target - the resolved target to mutate.
|
|
1272
|
-
* @param sandboxPolicy - the per-call mode and workspace root; omit for the
|
|
1273
|
-
* deployment policy.
|
|
1274
|
-
* @returns the target the mutation must use.
|
|
1275
|
-
* @throws {FsError} with `FS_SANDBOX_DENIED` when the policy refuses it.
|
|
1276
|
-
*/
|
|
1277
|
-
checkedTarget(target: FsTarget, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsTarget>;
|
|
1278
|
-
/**
|
|
1279
|
-
* One target's metadata, answered from the distro.
|
|
1280
|
-
*
|
|
1281
|
-
* @param target - the resolved target.
|
|
1282
|
-
* @param signal - optional cancellation.
|
|
1283
|
-
* @returns the metadata, or undefined when absent.
|
|
1284
|
-
*/
|
|
1285
|
-
stat(target: FsTarget, signal?: AbortSignal): Promise<FsInfo | undefined>;
|
|
1286
|
-
/**
|
|
1287
|
-
* No-follow stat one path. The agent substrate answers from the distro,
|
|
1288
|
-
* where a symlink is a first-class entry.
|
|
1289
|
-
*
|
|
1290
|
-
* @param path - a Linux, UNC or Windows path.
|
|
1291
|
-
* @param opts - optional `cwd` override.
|
|
1292
|
-
* @param signal - optional cancellation.
|
|
1293
|
-
* @returns the path info, or undefined when absent.
|
|
1294
|
-
*/
|
|
1295
|
-
lstat(path: string, opts?: {
|
|
1296
|
-
cwd?: string;
|
|
1297
|
-
}, signal?: AbortSignal): Promise<FsPathInfo | undefined>;
|
|
1298
|
-
/**
|
|
1299
|
-
* Read one whole regular UTF-8 file from the distro.
|
|
1300
|
-
*
|
|
1301
|
-
* @param target - the resolved target.
|
|
1302
|
-
* @param signal - optional cancellation.
|
|
1303
|
-
* @returns the file text.
|
|
1304
|
-
*/
|
|
1305
|
-
readText(target: FsTarget, signal?: AbortSignal): Promise<string>;
|
|
1306
|
-
/**
|
|
1307
|
-
* Stream one whole regular UTF-8 file from the distro.
|
|
1308
|
-
*
|
|
1309
|
-
* @param target - the resolved target.
|
|
1310
|
-
* @param signal - optional cancellation.
|
|
1311
|
-
* @returns the text chunks.
|
|
1312
|
-
*/
|
|
1313
|
-
streamText(target: FsTarget, signal?: AbortSignal): Promise<AsyncIterable<string>>;
|
|
1314
|
-
/**
|
|
1315
|
-
* Read one whole regular file as raw bytes, bounded.
|
|
1316
|
-
*
|
|
1317
|
-
* @param target - the resolved target.
|
|
1318
|
-
* @param signal - optional cancellation.
|
|
1319
|
-
* @param maxBytes - inclusive byte cap on the content.
|
|
1320
|
-
* @returns the bytes.
|
|
1321
|
-
*/
|
|
1322
|
-
readBytes(target: FsTarget, signal: AbortSignal | undefined, maxBytes: number): Promise<Uint8Array>;
|
|
1323
|
-
/**
|
|
1324
|
-
* Read one byte window of a regular file.
|
|
1325
|
-
*
|
|
1326
|
-
* @param target - the resolved target.
|
|
1327
|
-
* @param range - the window.
|
|
1328
|
-
* @param signal - optional cancellation.
|
|
1329
|
-
* @returns the window's bytes.
|
|
1330
|
-
*/
|
|
1331
|
-
readByteRange(target: FsTarget, range: {
|
|
1332
|
-
offset: number;
|
|
1333
|
-
length: number;
|
|
1334
|
-
}, signal?: AbortSignal): Promise<Uint8Array>;
|
|
1335
|
-
/**
|
|
1336
|
-
* List one directory level. The substrate's rows already carry Linux display
|
|
1337
|
-
* paths and canonical identities — nothing to rewrite.
|
|
1338
|
-
*
|
|
1339
|
-
* @param target - the resolved directory.
|
|
1340
|
-
* @param signal - optional cancellation.
|
|
1341
|
-
* @returns the directory rows.
|
|
1342
|
-
*/
|
|
1343
|
-
listDir(target: FsTarget, signal?: AbortSignal): Promise<FsDirEntry[]>;
|
|
1344
|
-
/**
|
|
1345
|
-
* Map an absolute host path into this execution world, SYNCHRONOUSLY — the
|
|
1346
|
-
* upstream contract (`FileSystem.processPathFromHostPath`) and what its
|
|
1347
|
-
* consumers rely on: `packages/spill/spill-policy` passes this method as a
|
|
1348
|
-
* plain callback over image attachments, and `packages/api/session-controller`
|
|
1349
|
-
* plus the UI's open/reveal path compare the return value against `undefined`
|
|
1350
|
-
* without awaiting. The mapping is therefore built from facts that are already
|
|
1351
|
-
* known — a UNC host path names its own distro outright; a non-UNC path uses
|
|
1352
|
-
* the pinned/config default once `distro()` has resolved it, and the
|
|
1353
|
-
* configured `cwd`, or the resolved home for a relative path. A call that
|
|
1354
|
-
* would have to ask `wsl.exe` — a cold default distro with no UNC, or a
|
|
1355
|
-
* relative path before the home is known — answers `undefined`, which every
|
|
1356
|
-
* consumer reads as "no mapping", the same answer the ssh provider gives for
|
|
1357
|
-
* a path it cannot map.
|
|
1358
|
-
*
|
|
1359
|
-
* The VALUE is the world spelling the backend keys on (the UNC identity for a
|
|
1360
|
-
* distro path), so the consumers' round trip — map, `resolve`, `processPath`,
|
|
1361
|
-
* compare with the original host path — closes exactly as it does for the
|
|
1362
|
-
* host backend. Real operations are unaffected: they take the async
|
|
1363
|
-
* {@link WslFileSystem.worldPath} and its loud refusals.
|
|
1364
|
-
*
|
|
1365
|
-
* @param hostPath - an absolute host path (a relative one maps only when the
|
|
1366
|
-
* configured `cwd` or a known home gives it a base).
|
|
1367
|
-
* @returns the world path for the same file, or undefined when it cannot be
|
|
1368
|
-
* mapped with what is already known.
|
|
1369
|
-
*/
|
|
1370
|
-
processPathFromHostPath(hostPath: string): string | undefined;
|
|
1371
|
-
/**
|
|
1372
|
-
* Watch from inside the distro, where the kernel can actually report change:
|
|
1373
|
-
* a long-lived `wsl.exe` poll loop (`lib/watcher.js`) fires the seam's
|
|
1374
|
-
* invalidation callback. The seam asks for coarse invalidation, not events,
|
|
1375
|
-
* so a poll is honest — and creations and deletions are both seen, because
|
|
1376
|
-
* they bump the parent directory's mtime. Replaces the previous flat
|
|
1377
|
-
* refusal (`FS_IO_ERROR`), which was the correct answer over 9p only.
|
|
1378
|
-
*
|
|
1379
|
-
* A target that disappears mid-watch ends the loop with a report through
|
|
1380
|
-
* `changed` — never the armed-but-never-fires silence a missing directory
|
|
1381
|
-
* would otherwise produce. The scan's depth is `watchMaxDepth`.
|
|
1382
|
-
*
|
|
1383
|
-
* @param target - the resolved file or directory to observe.
|
|
1384
|
-
* @param changed - the invalidation callback.
|
|
1385
|
-
* @param signal - cancels initialization; the caller closes an armed watcher.
|
|
1386
|
-
* @returns resolves once active, with the async close function.
|
|
1387
|
-
*/
|
|
1388
|
-
watch(target: FsTarget, changed: (error?: Error) => void, signal: AbortSignal): Promise<() => Promise<void>>;
|
|
1389
|
-
/**
|
|
1390
|
-
* Fence the write by the per-call policy, then publish through the
|
|
1391
|
-
* substrate. The fence's fresh target is the one checked and written, so a
|
|
1392
|
-
* refusal costs no I/O and cannot be raced by a swapped symlink; the guard
|
|
1393
|
-
* rides the write op, where the agent re-verifies it before the rename;
|
|
1394
|
-
* the confined resident enforces the mount boundary in the kernel.
|
|
1395
|
-
*
|
|
1396
|
-
* @param target - the resolved target.
|
|
1397
|
-
* @param content - the full new file content.
|
|
1398
|
-
* @param expected - the write intent.
|
|
1399
|
-
* @param signal - optional cancellation.
|
|
1400
|
-
* @param sandboxPolicy - the per-call mode and workspace root; omit for the
|
|
1401
|
-
* deployment policy.
|
|
1402
|
-
* @returns the write outcome.
|
|
1403
|
-
*/
|
|
1404
|
-
writeText(target: FsTarget, content: string, expected?: FsWriteIntent, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsWriteOutcome>;
|
|
1405
|
-
/**
|
|
1406
|
-
* Fence the edit by the same policy, keeping the guard's observable
|
|
1407
|
-
* behaviour.
|
|
1408
|
-
*
|
|
1409
|
-
* @param target - the resolved target.
|
|
1410
|
-
* @param edit - the literal search/replace request.
|
|
1411
|
-
* @param expected - the version guard.
|
|
1412
|
-
* @param signal - optional cancellation.
|
|
1413
|
-
* @param sandboxPolicy - the per-call mode and workspace root; omit for the
|
|
1414
|
-
* deployment policy.
|
|
1415
|
-
* @returns the edit outcome.
|
|
1416
|
-
*/
|
|
1417
|
-
editText(target: FsTarget, edit: FsEditRequest, expected?: {
|
|
1418
|
-
version: FsVersion;
|
|
1419
|
-
}, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsEditOutcome>;
|
|
1420
|
-
/**
|
|
1421
|
-
* Apply parsed hunks (protocol 7): hunk matching and application run
|
|
1422
|
-
* in-process through the peer's own `applyHunks` (the same dialect and
|
|
1423
|
-
* `FS_PATCH_MISMATCH` the peer emits), against the distro's bytes, then
|
|
1424
|
-
* publish through the same guarded atomic write an edit takes.
|
|
1425
|
-
*
|
|
1426
|
-
* @param target - the resolved regular file.
|
|
1427
|
-
* @param hunks - ordered hunks from the caller's patch parse.
|
|
1428
|
-
* @param expected - the version the patch was based on.
|
|
1429
|
-
* @param signal - cancels the patch.
|
|
1430
|
-
* @param sandboxPolicy - the per-call policy; omit for the deployment default.
|
|
1431
|
-
* @returns the pre/post text and the published version.
|
|
1432
|
-
*/
|
|
1433
|
-
patchText(target: FsTarget, hunks: PatchHunks, expected?: {
|
|
1434
|
-
version: FsVersion;
|
|
1435
|
-
}, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsEditOutcome>;
|
|
1436
|
-
/**
|
|
1437
|
-
* Remove one regular file (protocol 7) after fencing the target by the
|
|
1438
|
-
* per-call policy; the guarded removal re-verifies the expected version
|
|
1439
|
-
* distro-side.
|
|
1440
|
-
*
|
|
1441
|
-
* @param target - the resolved file.
|
|
1442
|
-
* @param expected - the version the removal was based on.
|
|
1443
|
-
* @param signal - cancels the removal.
|
|
1444
|
-
* @param sandboxPolicy - the per-call policy; omit for the deployment default.
|
|
1445
|
-
* @returns the bounded pre-removal text basis.
|
|
1446
|
-
*/
|
|
1447
|
-
deleteFile(target: FsTarget, expected?: {
|
|
1448
|
-
version: FsVersion;
|
|
1449
|
-
}, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsDeleteOutcome>;
|
|
1450
|
-
/**
|
|
1451
|
-
* Move one regular file (protocol 7) after fencing BOTH endpoints by the
|
|
1452
|
-
* per-call policy — the destination publishes and the source is removed, so
|
|
1453
|
-
* each must be writable under the same roots.
|
|
1454
|
-
*
|
|
1455
|
-
* @param source - the resolved source.
|
|
1456
|
-
* @param destination - the resolved destination.
|
|
1457
|
-
* @param options - the hunks and the source/destination guards.
|
|
1458
|
-
* @param signal - cancels before publication.
|
|
1459
|
-
* @param sandboxPolicy - the per-call policy; omit for the deployment default.
|
|
1460
|
-
* @returns the bounded source basis and the destination outcome.
|
|
1461
|
-
*/
|
|
1462
|
-
moveFile(source: FsTarget, destination: FsTarget, options: MoveFileOptions, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsMoveOutcome>;
|
|
1463
|
-
}
|
|
1464
|
-
export {};
|
|
1
|
+
/** Public exports for the WSL service providers and compatibility helpers. */
|
|
2
|
+
export { WslShellExecutor } from "./wsl-shell.js";
|
|
3
|
+
export type { ShellExecSpec, ShellExecution, SpawnSeamExecutor } from "./wsl-shell.js";
|
|
4
|
+
export { WslFileSystem } from "./wsl-filesystem.js";
|
|
5
|
+
export { doctorReport } from "./doctor-report.js";
|
|
6
|
+
export { effectiveMaskWindowsDrive } from "./provider-common.js";
|