dsh-plugin-wsl-env 0.24.0 → 0.26.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 +136 -0
- package/CODE_OF_CONDUCT.md +85 -0
- package/CODE_OF_CONDUCT.zh.md +85 -0
- package/CONTRIBUTING.md +19 -3
- package/CONTRIBUTING.zh.md +200 -0
- package/README.md +18 -6
- package/SECURITY.md +12 -0
- package/SECURITY.zh.md +108 -0
- package/SUPPORT.md +2 -0
- package/SUPPORT.zh.md +99 -0
- package/client.js +409 -8
- package/cordis.patch.yml +17 -0
- package/docs/AGENT-PROTOCOL-V7.md +2 -2
- package/docs/API.md +2 -0
- package/docs/API.zh.md +38 -0
- package/docs/ARCHITECTURE.md +30 -9
- package/docs/ARCHITECTURE.zh.md +511 -0
- package/docs/COMPATIBILITY.md +2 -0
- package/docs/COMPATIBILITY.zh.md +117 -0
- package/docs/CONFIGURATION.md +45 -2
- package/docs/CONFIGURATION.zh.md +39 -3
- package/docs/DIAGNOSTICS.md +12 -2
- package/docs/DIAGNOSTICS.zh.md +5 -1
- package/docs/LIMITATIONS.md +60 -9
- package/docs/LIMITATIONS.zh.md +45 -9
- package/docs/MIGRATION.md +6 -3
- package/docs/MIGRATION.zh.md +91 -0
- package/docs/PEER-PARITY.md +63 -51
- package/docs/PERFORMANCE.md +2 -0
- package/docs/PERFORMANCE.zh.md +59 -0
- package/docs/QUICKSTART.md +21 -6
- package/docs/QUICKSTART.zh.md +16 -4
- package/docs/README.zh.md +28 -19
- package/docs/RELEASING.md +19 -14
- package/docs/REQUIREMENTS.zh.md +6 -3
- package/docs/ROADMAP-1.0.md +1 -1
- package/docs/UPSTREAM-FILE-REFERENCE-SEAM.md +1 -1
- package/docs/UPSTREAM-FSIO-EXPORT.md +5 -4
- package/docs/UPSTREAM-OPEN-IN-APP.md +33 -11
- package/docs/UPSTREAM-PROMPT-ADAPTERS.md +85 -0
- package/docs/UPSTREAM-SESSION-NOTICE.md +7 -0
- package/docs/VALUE.md +146 -0
- package/docs/VALUE.zh.md +15 -13
- 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-seam.d.ts +45 -0
- package/lib/auto-preset-seam.js +47 -0
- package/lib/auto-preset.d.ts +33 -10
- package/lib/auto-preset.js +148 -44
- package/lib/bwrap.d.ts +14 -0
- package/lib/bwrap.js +11 -0
- package/lib/cwd-prompt.d.ts +41 -3
- package/lib/cwd-prompt.js +125 -8
- package/lib/doctor-live.d.ts +30 -0
- package/lib/doctor-live.js +37 -0
- 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/messages.d.ts +20 -1
- package/lib/messages.js +31 -3
- package/lib/open-in-app.d.ts +206 -0
- package/lib/open-in-app.js +300 -0
- package/lib/preflight.d.ts +7 -4
- package/lib/preflight.js +27 -13
- package/lib/preset-choice.d.ts +13 -0
- package/lib/preset-choice.js +18 -1
- 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.js +2 -1
- package/lib/writable-roots.d.ts +109 -0
- package/lib/writable-roots.js +257 -0
- package/lib/wsl-doctor-command.js +2 -1
- package/lib/wsl-doctor-tool.js +2 -2
- 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 +1 -1
- package/lib/wsl.js +1 -1
- package/package.json +48 -24
- package/scripts/doctor.mjs +1 -1
- package/scripts/profile-preset.mjs +17 -5
|
@@ -0,0 +1,742 @@
|
|
|
1
|
+
import z from "@deepseek-ai/schemastery";
|
|
2
|
+
import { LocalBashExecutor } from "@deepseek-ai/dsh-bash-local";
|
|
3
|
+
import { WslSandbox } from "./sandbox.js";
|
|
4
|
+
import type { WslAgent } from "./agent.js";
|
|
5
|
+
import { SessionRuntimes } from "./session-runtime.js";
|
|
6
|
+
import type { AgentBackend } from "./native-agent.js";
|
|
7
|
+
import type { SessionRuntimeEntry } from "./session-runtime.js";
|
|
8
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
9
|
+
import type { SandboxExecutionPolicy, SandboxMode } from "@deepseek-ai/dsh-sandbox";
|
|
10
|
+
import type { SubprocessSpawnSpec } from "@deepseek-ai/dsh-subprocess";
|
|
11
|
+
/**
|
|
12
|
+
* Upstream shell vocabulary, derived through `@deepseek-ai/dsh-bash-local` —
|
|
13
|
+
* this package does not depend on `@deepseek-ai/dsh-shell` directly, so the
|
|
14
|
+
* execution types ride in through the executor's own signatures.
|
|
15
|
+
*/
|
|
16
|
+
export type ShellExecSpec = Parameters<LocalBashExecutor["execute"]>[0];
|
|
17
|
+
type ShellExecRequest = Parameters<LocalBashExecutor["resolve"]>[0];
|
|
18
|
+
export type ShellExecution = Awaited<ReturnType<LocalBashExecutor["execute"]>>;
|
|
19
|
+
/**
|
|
20
|
+
* The resolved spec this executor stamps with its home-marker fields: an empty
|
|
21
|
+
* `workdir` plus the relative tail that {@link WslShellExecutor.withDefaultWorkdir}
|
|
22
|
+
* joins against the distro home. The extra keys are this provider's own; the
|
|
23
|
+
* seam's `ShellExecSpec` does not know them.
|
|
24
|
+
*/
|
|
25
|
+
type WslExecSpec = ShellExecSpec & {
|
|
26
|
+
relativeWorkdir?: string;
|
|
27
|
+
};
|
|
28
|
+
interface WslShellExecutorConfig {
|
|
29
|
+
/** The pinned distro; empty means WSL's default. */
|
|
30
|
+
distro: string;
|
|
31
|
+
/** The `wsl.exe` path. */
|
|
32
|
+
wslPath: string;
|
|
33
|
+
/** The distro shell; empty resolves the login shell. */
|
|
34
|
+
shell: string;
|
|
35
|
+
/** Whether `<shell> -lc` semantics apply. */
|
|
36
|
+
loginShell: boolean;
|
|
37
|
+
/** Whether commands confine inside the distro. */
|
|
38
|
+
sandbox: boolean;
|
|
39
|
+
/** Whether confined profiles mask `/mnt`. */
|
|
40
|
+
maskWindowsDrive: boolean;
|
|
41
|
+
/** Extra distro directories granted read-write under `workspace-write`. */
|
|
42
|
+
writableRoots: string[];
|
|
43
|
+
/** The interop stance; set at all, it takes precedence over `maskWindowsDrive`. */
|
|
44
|
+
interopVisibility?: "visible" | "masked" | "disabled";
|
|
45
|
+
/** The volatile default workdir. */
|
|
46
|
+
cwd: {
|
|
47
|
+
get(): string | undefined;
|
|
48
|
+
};
|
|
49
|
+
/** The volatile Windows spawn directory. */
|
|
50
|
+
hostCwd: {
|
|
51
|
+
get(): string | undefined;
|
|
52
|
+
};
|
|
53
|
+
/** Extra env names forwarded through WSLENV. */
|
|
54
|
+
forwardEnv: string[];
|
|
55
|
+
/** The volatile default timeout. */
|
|
56
|
+
timeoutMs: {
|
|
57
|
+
get(): number;
|
|
58
|
+
};
|
|
59
|
+
/** The volatile timeout cap. */
|
|
60
|
+
maxTimeoutMs: {
|
|
61
|
+
get(): number;
|
|
62
|
+
};
|
|
63
|
+
/** The volatile per-stream output cap. */
|
|
64
|
+
maxOutputBytes: {
|
|
65
|
+
get(): number;
|
|
66
|
+
};
|
|
67
|
+
/** The volatile spill-file cap. */
|
|
68
|
+
maxSpillBytes: {
|
|
69
|
+
get(): number;
|
|
70
|
+
};
|
|
71
|
+
/** The volatile kill-escalation grace. */
|
|
72
|
+
graceMs: {
|
|
73
|
+
get(): number;
|
|
74
|
+
};
|
|
75
|
+
/** Whether execution prefers the resident agent. */
|
|
76
|
+
agent: boolean;
|
|
77
|
+
/** Session runtime: `true` requires it, `false` disables it, `"auto"` uses it when usable. */
|
|
78
|
+
sessionSandbox: boolean | "auto";
|
|
79
|
+
/** The session runtime's agent backend; `auto` when omitted. */
|
|
80
|
+
agentBackend?: AgentBackend;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The upstream executor's spawn-spec builder, re-opened for this subclass —
|
|
84
|
+
* see docs/UPSTREAM-SPAWN-SEAM.md. Type-level bridge only; the runtime class
|
|
85
|
+
* is untouched.
|
|
86
|
+
*/
|
|
87
|
+
export type SpawnSeamExecutor = Omit<LocalBashExecutor, "spawnSpec"> & {
|
|
88
|
+
spawnSpec: (spec: ShellExecSpec, argv: string[], stdoutMaxBytes: number, signal?: AbortSignal) => SubprocessSpawnSpec;
|
|
89
|
+
};
|
|
90
|
+
/** The per-process confinement facts retained until settlement. */
|
|
91
|
+
interface ProcessFacts {
|
|
92
|
+
/** The mode the process ran under. */
|
|
93
|
+
mode: SandboxMode | undefined;
|
|
94
|
+
/** The seam's enforcement completeness. */
|
|
95
|
+
enforcement: "full" | "partial";
|
|
96
|
+
/** The case-insensitive stderr substrings a denial produces. */
|
|
97
|
+
denialSignatures: string[];
|
|
98
|
+
/** Structured runner-failure evidence rules. */
|
|
99
|
+
runnerFailureRules: Array<{
|
|
100
|
+
fatalSignatures: string[];
|
|
101
|
+
allowedExitCodes?: number[];
|
|
102
|
+
informationalLines?: string[];
|
|
103
|
+
}>;
|
|
104
|
+
/** The confinement runner program (`argv[0]`), for spawn-failure attribution. */
|
|
105
|
+
runnerProgram: string;
|
|
106
|
+
/** The Linux workdir the process was given. */
|
|
107
|
+
workdir: string;
|
|
108
|
+
/** Whether the profile masks the Windows drive. */
|
|
109
|
+
windowsDrive: "masked" | "visible";
|
|
110
|
+
/** Which runtime the process used: the session scope or a per-command profile. */
|
|
111
|
+
sessionScope: "session" | "per-command";
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Bash executor that runs every command inside a WSL distro.
|
|
115
|
+
*
|
|
116
|
+
* Extends the unconfined `LocalBashExecutor`, so command defaulting, deadline
|
|
117
|
+
* handling, output caps, spill files and background-process management are the
|
|
118
|
+
* shipped implementation's; this subclass replaces only the argv (prefix with
|
|
119
|
+
* `wsl.exe`) and the process working directory (wsl.exe must be started from a
|
|
120
|
+
* Windows directory, while the Linux directory rides on `--cd`).
|
|
121
|
+
*/
|
|
122
|
+
export declare class WslShellExecutor extends LocalBashExecutor {
|
|
123
|
+
static inject: string[];
|
|
124
|
+
static Config: z<Schemastery.ObjectS<NoInfer<{
|
|
125
|
+
/**
|
|
126
|
+
* Distro mode: empty/`"auto"` follows the request workdir, `"default"`
|
|
127
|
+
* forces WSL's default, and an explicit name pins every command.
|
|
128
|
+
*/
|
|
129
|
+
distro: z<string, string, "defined">;
|
|
130
|
+
/** Path to `wsl.exe`; overridable for a non-standard install. */
|
|
131
|
+
wslPath: z<string, string, "defined">;
|
|
132
|
+
/**
|
|
133
|
+
* The shell commands run in. Empty means "resolve the login shell of the
|
|
134
|
+
* distro's user" — hardcoding bash silently ignores a user whose passwd
|
|
135
|
+
* entry points at zsh, fish, dash, or anything else, losing their PATH and
|
|
136
|
+
* rc setup. Set an absolute path inside the distro to pin one.
|
|
137
|
+
*/
|
|
138
|
+
shell: z<string, string, "defined">;
|
|
139
|
+
/**
|
|
140
|
+
* Login-shell semantics (`<shell> -lc`) source the profile scripts, which is
|
|
141
|
+
* what makes an interactive WSL setup's PATH (nvm, cargo, pyenv) visible.
|
|
142
|
+
* Set false for a fast, fully deterministic `<shell> -c`. Applies only to the
|
|
143
|
+
* POSIX family — see `shellArgs` for why other shells get a bare `-c`.
|
|
144
|
+
*/
|
|
145
|
+
loginShell: z<boolean, boolean, "defined">;
|
|
146
|
+
/**
|
|
147
|
+
* Confine every command inside the distro with `bwrap`, and report the
|
|
148
|
+
* policy's mode through {@link sandboxMode}. Fails closed: a distro without
|
|
149
|
+
* a usable `bwrap` produces `SANDBOX_UNAVAILABLE` rather than an unconfined
|
|
150
|
+
* run. `false` restores the pre-sandbox behaviour exactly — commands run
|
|
151
|
+
* unconfined and `sandboxMode` is `undefined`, so the model is told so.
|
|
152
|
+
*/
|
|
153
|
+
sandbox: z<boolean, boolean, "defined">;
|
|
154
|
+
/**
|
|
155
|
+
* Shadow `/mnt` with an empty tmpfs in every confined profile, hiding the
|
|
156
|
+
* Windows drive from confined commands: its files cannot be read or
|
|
157
|
+
* exfiltrated and its executables cannot be launched through interop —
|
|
158
|
+
* the hole that lets a "sandboxed" command reach your full Windows token.
|
|
159
|
+
* A narrowing, not a closure (a command can still write an executable
|
|
160
|
+
* into the workspace and run it — binfmt dispatches on content, not
|
|
161
|
+
* location), so enforcement stays `partial` and the sandbox fact reports
|
|
162
|
+
* `windowsDrive: "masked"`. Costs: confined commands cannot read or touch
|
|
163
|
+
* anything under `/mnt`, and tools that probe the drive degrade. The
|
|
164
|
+
* complete closure is distro-level: `[interop] enabled=false` in
|
|
165
|
+
* `wsl.conf`.
|
|
166
|
+
*/
|
|
167
|
+
/**
|
|
168
|
+
* The interop stance in one key (WSL-314), expanding to the per-key
|
|
169
|
+
* values the measured matrix documents:
|
|
170
|
+
*
|
|
171
|
+
* - `visible` (default) — nothing masked; a confined command can read
|
|
172
|
+
* `/mnt` and launch Windows executables through interop, which escapes
|
|
173
|
+
* the Linux sandbox entirely.
|
|
174
|
+
* - `masked` — `maskWindowsDrive: true`: `/mnt` is shadowed with an empty
|
|
175
|
+
* tmpfs; the drive's files and executables are unreachable (binfmt can
|
|
176
|
+
* still run a workspace-written .exe, so enforcement stays `partial`).
|
|
177
|
+
* - `disabled` — `masked`, plus the distro-level closure: `[interop]
|
|
178
|
+
* enabled=false` in `/etc/wsl.conf` + `wsl --shutdown`, which the
|
|
179
|
+
* doctor's remedy prints as copy-paste (a config key does not write
|
|
180
|
+
* distro config; enforcement is the kernel's, not the schema's).
|
|
181
|
+
*
|
|
182
|
+
* When set at all it takes precedence over the legacy
|
|
183
|
+
* `maskWindowsDrive` boolean below (unset — the default — lets that
|
|
184
|
+
* boolean answer); the boolean remains for existing profiles.
|
|
185
|
+
*/
|
|
186
|
+
interopVisibility: z<"masked" | "visible" | "disabled", "masked" | "visible" | "disabled", "plain">;
|
|
187
|
+
maskWindowsDrive: z<boolean, boolean, "defined">;
|
|
188
|
+
/**
|
|
189
|
+
* Extra directories under `workspace-write`, in distro spelling. The
|
|
190
|
+
* plugin grants them together with the workspace, so toolchain caches
|
|
191
|
+
* (`~/.npm`, pnpm's store, `~/.cargo/registry`) and a linked worktree's
|
|
192
|
+
* shared Git directory work without escalating the whole command to
|
|
193
|
+
* `danger-full-access`. `~` and `~/...` expand against the distro user's
|
|
194
|
+
* home; every entry must be an existing physical directory. Entries
|
|
195
|
+
* already writable (inside the workspace, `/tmp`, `/dev/shm`) and entries
|
|
196
|
+
* nested inside another grant are ignored. The same list belongs on
|
|
197
|
+
* `wsl-fs` so writes and commands see the same mount table. Default empty:
|
|
198
|
+
* the mode still grants only the workspace and the temp areas.
|
|
199
|
+
*/
|
|
200
|
+
writableRoots: z<string[], string[], "defined">;
|
|
201
|
+
/**
|
|
202
|
+
* Default workdir for a request that names none; accepts `/home/andy/proj`,
|
|
203
|
+
* a UNC path, or `C:\...`. Empty — the default — means the distro user's
|
|
204
|
+
* home, resolved inside the distro.
|
|
205
|
+
*/
|
|
206
|
+
cwd: z<string, string, "volatile">;
|
|
207
|
+
/** Windows directory the `wsl.exe` process itself starts in. */
|
|
208
|
+
hostCwd: z<string, string, "volatile">;
|
|
209
|
+
/** Extra env names to forward into the distro through WSLENV. */
|
|
210
|
+
forwardEnv: z<string[], string[], "defined">;
|
|
211
|
+
timeoutMs: z<number, number, "volatile-defined">;
|
|
212
|
+
maxTimeoutMs: z<number, number, "volatile-defined">;
|
|
213
|
+
maxOutputBytes: z<number, number, "volatile-defined">;
|
|
214
|
+
maxSpillBytes: z<number, number, "volatile-defined">;
|
|
215
|
+
graceMs: z<number, number, "volatile-defined">;
|
|
216
|
+
/**
|
|
217
|
+
* Run commands through the resident agent when it is up (one long-lived
|
|
218
|
+
* in-distro process; in-distro timeout semantics), falling back to the
|
|
219
|
+
* one-shot `wsl.exe` path whenever the agent is out. `false` never uses
|
|
220
|
+
* the agent. The confinement, the output budgets' shapes and the result
|
|
221
|
+
* decoration are identical on both paths.
|
|
222
|
+
*/
|
|
223
|
+
agent: z<boolean, boolean, "defined">;
|
|
224
|
+
agentBackend: z<"auto" | "native" | "shell", "auto" | "native" | "shell", "defined">;
|
|
225
|
+
/**
|
|
226
|
+
* Run this session's commands in one persistent systemd user scope (ADR
|
|
227
|
+
* 0001): background processes survive the command that started them, `/tmp`
|
|
228
|
+
* is the distro's real `/tmp` under workspace-write, and `ps` sees the
|
|
229
|
+
* session. The executor holds the runtime until the session's scope
|
|
230
|
+
* disposes, then stops it. Requires systemd, a reachable user manager and
|
|
231
|
+
* `Linger`; the preflight refuses with the remedy when one is missing, and
|
|
232
|
+
* only a success is cached. Off by default; requires `agent: true`.
|
|
233
|
+
*/
|
|
234
|
+
sessionSandbox: z<boolean | "auto", boolean | "auto", "defined">;
|
|
235
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
236
|
+
/**
|
|
237
|
+
* Distro mode: empty/`"auto"` follows the request workdir, `"default"`
|
|
238
|
+
* forces WSL's default, and an explicit name pins every command.
|
|
239
|
+
*/
|
|
240
|
+
distro: z<string, string, "defined">;
|
|
241
|
+
/** Path to `wsl.exe`; overridable for a non-standard install. */
|
|
242
|
+
wslPath: z<string, string, "defined">;
|
|
243
|
+
/**
|
|
244
|
+
* The shell commands run in. Empty means "resolve the login shell of the
|
|
245
|
+
* distro's user" — hardcoding bash silently ignores a user whose passwd
|
|
246
|
+
* entry points at zsh, fish, dash, or anything else, losing their PATH and
|
|
247
|
+
* rc setup. Set an absolute path inside the distro to pin one.
|
|
248
|
+
*/
|
|
249
|
+
shell: z<string, string, "defined">;
|
|
250
|
+
/**
|
|
251
|
+
* Login-shell semantics (`<shell> -lc`) source the profile scripts, which is
|
|
252
|
+
* what makes an interactive WSL setup's PATH (nvm, cargo, pyenv) visible.
|
|
253
|
+
* Set false for a fast, fully deterministic `<shell> -c`. Applies only to the
|
|
254
|
+
* POSIX family — see `shellArgs` for why other shells get a bare `-c`.
|
|
255
|
+
*/
|
|
256
|
+
loginShell: z<boolean, boolean, "defined">;
|
|
257
|
+
/**
|
|
258
|
+
* Confine every command inside the distro with `bwrap`, and report the
|
|
259
|
+
* policy's mode through {@link sandboxMode}. Fails closed: a distro without
|
|
260
|
+
* a usable `bwrap` produces `SANDBOX_UNAVAILABLE` rather than an unconfined
|
|
261
|
+
* run. `false` restores the pre-sandbox behaviour exactly — commands run
|
|
262
|
+
* unconfined and `sandboxMode` is `undefined`, so the model is told so.
|
|
263
|
+
*/
|
|
264
|
+
sandbox: z<boolean, boolean, "defined">;
|
|
265
|
+
/**
|
|
266
|
+
* Shadow `/mnt` with an empty tmpfs in every confined profile, hiding the
|
|
267
|
+
* Windows drive from confined commands: its files cannot be read or
|
|
268
|
+
* exfiltrated and its executables cannot be launched through interop —
|
|
269
|
+
* the hole that lets a "sandboxed" command reach your full Windows token.
|
|
270
|
+
* A narrowing, not a closure (a command can still write an executable
|
|
271
|
+
* into the workspace and run it — binfmt dispatches on content, not
|
|
272
|
+
* location), so enforcement stays `partial` and the sandbox fact reports
|
|
273
|
+
* `windowsDrive: "masked"`. Costs: confined commands cannot read or touch
|
|
274
|
+
* anything under `/mnt`, and tools that probe the drive degrade. The
|
|
275
|
+
* complete closure is distro-level: `[interop] enabled=false` in
|
|
276
|
+
* `wsl.conf`.
|
|
277
|
+
*/
|
|
278
|
+
/**
|
|
279
|
+
* The interop stance in one key (WSL-314), expanding to the per-key
|
|
280
|
+
* values the measured matrix documents:
|
|
281
|
+
*
|
|
282
|
+
* - `visible` (default) — nothing masked; a confined command can read
|
|
283
|
+
* `/mnt` and launch Windows executables through interop, which escapes
|
|
284
|
+
* the Linux sandbox entirely.
|
|
285
|
+
* - `masked` — `maskWindowsDrive: true`: `/mnt` is shadowed with an empty
|
|
286
|
+
* tmpfs; the drive's files and executables are unreachable (binfmt can
|
|
287
|
+
* still run a workspace-written .exe, so enforcement stays `partial`).
|
|
288
|
+
* - `disabled` — `masked`, plus the distro-level closure: `[interop]
|
|
289
|
+
* enabled=false` in `/etc/wsl.conf` + `wsl --shutdown`, which the
|
|
290
|
+
* doctor's remedy prints as copy-paste (a config key does not write
|
|
291
|
+
* distro config; enforcement is the kernel's, not the schema's).
|
|
292
|
+
*
|
|
293
|
+
* When set at all it takes precedence over the legacy
|
|
294
|
+
* `maskWindowsDrive` boolean below (unset — the default — lets that
|
|
295
|
+
* boolean answer); the boolean remains for existing profiles.
|
|
296
|
+
*/
|
|
297
|
+
interopVisibility: z<"masked" | "visible" | "disabled", "masked" | "visible" | "disabled", "plain">;
|
|
298
|
+
maskWindowsDrive: z<boolean, boolean, "defined">;
|
|
299
|
+
/**
|
|
300
|
+
* Extra directories under `workspace-write`, in distro spelling. The
|
|
301
|
+
* plugin grants them together with the workspace, so toolchain caches
|
|
302
|
+
* (`~/.npm`, pnpm's store, `~/.cargo/registry`) and a linked worktree's
|
|
303
|
+
* shared Git directory work without escalating the whole command to
|
|
304
|
+
* `danger-full-access`. `~` and `~/...` expand against the distro user's
|
|
305
|
+
* home; every entry must be an existing physical directory. Entries
|
|
306
|
+
* already writable (inside the workspace, `/tmp`, `/dev/shm`) and entries
|
|
307
|
+
* nested inside another grant are ignored. The same list belongs on
|
|
308
|
+
* `wsl-fs` so writes and commands see the same mount table. Default empty:
|
|
309
|
+
* the mode still grants only the workspace and the temp areas.
|
|
310
|
+
*/
|
|
311
|
+
writableRoots: z<string[], string[], "defined">;
|
|
312
|
+
/**
|
|
313
|
+
* Default workdir for a request that names none; accepts `/home/andy/proj`,
|
|
314
|
+
* a UNC path, or `C:\...`. Empty — the default — means the distro user's
|
|
315
|
+
* home, resolved inside the distro.
|
|
316
|
+
*/
|
|
317
|
+
cwd: z<string, string, "volatile">;
|
|
318
|
+
/** Windows directory the `wsl.exe` process itself starts in. */
|
|
319
|
+
hostCwd: z<string, string, "volatile">;
|
|
320
|
+
/** Extra env names to forward into the distro through WSLENV. */
|
|
321
|
+
forwardEnv: z<string[], string[], "defined">;
|
|
322
|
+
timeoutMs: z<number, number, "volatile-defined">;
|
|
323
|
+
maxTimeoutMs: z<number, number, "volatile-defined">;
|
|
324
|
+
maxOutputBytes: z<number, number, "volatile-defined">;
|
|
325
|
+
maxSpillBytes: z<number, number, "volatile-defined">;
|
|
326
|
+
graceMs: z<number, number, "volatile-defined">;
|
|
327
|
+
/**
|
|
328
|
+
* Run commands through the resident agent when it is up (one long-lived
|
|
329
|
+
* in-distro process; in-distro timeout semantics), falling back to the
|
|
330
|
+
* one-shot `wsl.exe` path whenever the agent is out. `false` never uses
|
|
331
|
+
* the agent. The confinement, the output budgets' shapes and the result
|
|
332
|
+
* decoration are identical on both paths.
|
|
333
|
+
*/
|
|
334
|
+
agent: z<boolean, boolean, "defined">;
|
|
335
|
+
agentBackend: z<"auto" | "native" | "shell", "auto" | "native" | "shell", "defined">;
|
|
336
|
+
/**
|
|
337
|
+
* Run this session's commands in one persistent systemd user scope (ADR
|
|
338
|
+
* 0001): background processes survive the command that started them, `/tmp`
|
|
339
|
+
* is the distro's real `/tmp` under workspace-write, and `ps` sees the
|
|
340
|
+
* session. The executor holds the runtime until the session's scope
|
|
341
|
+
* disposes, then stops it. Requires systemd, a reachable user manager and
|
|
342
|
+
* `Linger`; the preflight refuses with the remedy when one is missing, and
|
|
343
|
+
* only a success is cached. Off by default; requires `agent: true`.
|
|
344
|
+
*/
|
|
345
|
+
sessionSandbox: z<boolean | "auto", boolean | "auto", "defined">;
|
|
346
|
+
}>>, "plain">;
|
|
347
|
+
/** Cached default distro, resolved once from `wsl.exe -l -q`. */
|
|
348
|
+
resolvedDistro: string;
|
|
349
|
+
/** Cached distro-user login shell, resolved once. */
|
|
350
|
+
resolvedShell: string;
|
|
351
|
+
/** Per-distro login shells, for a workspace that is not the default distro. */
|
|
352
|
+
resolvedShells: Map<string, string>;
|
|
353
|
+
/** Cached distro-user home, the workdir when `cwd` is empty. */
|
|
354
|
+
resolvedHome: string | undefined;
|
|
355
|
+
/** Per-distro homes, so two concurrent distros cannot share one. */
|
|
356
|
+
resolvedHomes: Map<string, string>;
|
|
357
|
+
/** The default mode — the capability fact the tool layer reads. */
|
|
358
|
+
mode: SandboxMode | undefined;
|
|
359
|
+
/** The distro-side confinement, or nothing when the operator opted out. */
|
|
360
|
+
sandbox: InstanceType<typeof WslSandbox> | undefined;
|
|
361
|
+
/** The session-runtime registry; tests substitute it. */
|
|
362
|
+
sessionRuntimes: SessionRuntimes;
|
|
363
|
+
/** The runtimes this executor holds, by registry key. */
|
|
364
|
+
sessionRuntimeEntries: Map<string, SessionRuntimeEntry>;
|
|
365
|
+
/** Isolates calls that have no session identity. */
|
|
366
|
+
sessionRuntimeOwner: string;
|
|
367
|
+
/** The preflight's host runner; tests substitute it. */
|
|
368
|
+
sessionScopeProbe: (argv: string[]) => Promise<string>;
|
|
369
|
+
/** The one-time writable-root check's runner; tests substitute it. */
|
|
370
|
+
writableRootsProbe: (argv: string[]) => Promise<string>;
|
|
371
|
+
/** Distros whose session-runtime preflight has succeeded. */
|
|
372
|
+
sessionRuntimePreflight: Set<string>;
|
|
373
|
+
/** Per-distro `auto` verdicts, re-probed when they were negative and stale. */
|
|
374
|
+
autoSessionScope: Map<string, {
|
|
375
|
+
usable: boolean;
|
|
376
|
+
checkedAt: number;
|
|
377
|
+
}>;
|
|
378
|
+
/**
|
|
379
|
+
* Per-process confinement facts retained until settlement. Overlapping calls
|
|
380
|
+
* can carry different policies, so a shared latest-wrap value would classify
|
|
381
|
+
* a process against the wrong facts. Unconfined processes have no entry.
|
|
382
|
+
*/
|
|
383
|
+
processFacts: Map<ShellExecution, ProcessFacts>;
|
|
384
|
+
/**
|
|
385
|
+
* @param ctx - the composition context.
|
|
386
|
+
* @param config - the validated plugin config.
|
|
387
|
+
*/
|
|
388
|
+
constructor(ctx: Context, config: WslShellExecutorConfig);
|
|
389
|
+
/**
|
|
390
|
+
* The mode this executor confines with, or `undefined` when it does not
|
|
391
|
+
* confine at all. `dsh-tool-bash` reads exactly this to decide whether to
|
|
392
|
+
* advertise the escalation field, so it must disappear together with the
|
|
393
|
+
* enforcement — never claim a boundary that is not applied.
|
|
394
|
+
*
|
|
395
|
+
* @returns the deployment default mode, or `undefined` when unconfined.
|
|
396
|
+
*/
|
|
397
|
+
get sandboxMode(): SandboxMode | undefined;
|
|
398
|
+
/**
|
|
399
|
+
* The distro used when no path supplies evidence: the pinned name, WSL's
|
|
400
|
+
* default, or the default for the automatic modes.
|
|
401
|
+
*
|
|
402
|
+
* @returns the distro name.
|
|
403
|
+
*/
|
|
404
|
+
distro(): Promise<string>;
|
|
405
|
+
/**
|
|
406
|
+
* The distro one command belongs to: an explicit pin wins; otherwise the
|
|
407
|
+
* request workdir, then the configured `cwd`, may name a distro; both
|
|
408
|
+
* absent falls back to WSL's default.
|
|
409
|
+
*
|
|
410
|
+
* @param workdir - the request's workdir, in any coordinate system.
|
|
411
|
+
* @param cwd - the configured default workdir, when the caller has it.
|
|
412
|
+
* @returns the distro name.
|
|
413
|
+
*/
|
|
414
|
+
distroFor(workdir?: string, cwd?: string): Promise<string>;
|
|
415
|
+
/**
|
|
416
|
+
* The shell name for the default/pinned distro, as the shell tool presents
|
|
417
|
+
* it.
|
|
418
|
+
*
|
|
419
|
+
* @returns the basename of the shell; `shell` while the probe fails, and
|
|
420
|
+
* `bash` for an implausible basename.
|
|
421
|
+
*/
|
|
422
|
+
shellName(): Promise<string>;
|
|
423
|
+
/**
|
|
424
|
+
* The shell for one distro: the configured shell, else that distro's login
|
|
425
|
+
* shell. The default/pinned distro keeps the legacy {@link resolvedShell}
|
|
426
|
+
* cache; every other distro gets an entry in {@link resolvedShells}.
|
|
427
|
+
*
|
|
428
|
+
* @param distro - the distro name.
|
|
429
|
+
* @returns an absolute path to the shell inside the distro.
|
|
430
|
+
* @throws {Error} when neither the config nor the distro names a usable
|
|
431
|
+
* shell — the failure is not cached, so the next call re-probes.
|
|
432
|
+
*/
|
|
433
|
+
shellFor(distro: string): Promise<string>;
|
|
434
|
+
/**
|
|
435
|
+
* The shell for the default/pinned distro: the configured one, else the
|
|
436
|
+
* login shell, resolved once and cached.
|
|
437
|
+
*
|
|
438
|
+
* @returns an absolute path to the shell inside the distro.
|
|
439
|
+
* @throws {Error} when neither the config nor the distro names a usable
|
|
440
|
+
* shell — the failure is not cached, so the next call re-probes.
|
|
441
|
+
*/
|
|
442
|
+
shell(): Promise<string>;
|
|
443
|
+
/**
|
|
444
|
+
* Windows directory the `wsl.exe` process is started from.
|
|
445
|
+
*
|
|
446
|
+
* @returns the host directory to spawn in.
|
|
447
|
+
*/
|
|
448
|
+
hostCwd(): string;
|
|
449
|
+
/**
|
|
450
|
+
* The shared resident agent serving this executor's distro.
|
|
451
|
+
*
|
|
452
|
+
* @param distro - the resolved distro name.
|
|
453
|
+
* @returns the shared agent.
|
|
454
|
+
*/
|
|
455
|
+
executionAgent(distro: string): WslAgent;
|
|
456
|
+
/**
|
|
457
|
+
* The persistent session runtime for one policy, when `sessionSandbox` is
|
|
458
|
+
* on. The executor holds one reference per `(session, distro, workspace, policy)` and
|
|
459
|
+
* releases them when the session's scope disposes.
|
|
460
|
+
*
|
|
461
|
+
* @param policy - the resolved file-effect policy, when the executor has one.
|
|
462
|
+
* @param resolved - the resolved spec, for the fallback workspace.
|
|
463
|
+
* @param distro - the resolved distro name.
|
|
464
|
+
* @returns the runtime entry, or undefined when the mode is off.
|
|
465
|
+
*/
|
|
466
|
+
sessionRuntimeFor(policy: {
|
|
467
|
+
mode: string;
|
|
468
|
+
workspaceRoot: string;
|
|
469
|
+
sessionId?: string;
|
|
470
|
+
} | undefined, resolved: WslExecSpec, distro: string, writableRoots?: readonly string[]): SessionRuntimeEntry | undefined;
|
|
471
|
+
/**
|
|
472
|
+
* Run the session runtime's preflight once per executor. A failure is a
|
|
473
|
+
* configuration verdict, not an agent outage: it is raised as an Error with
|
|
474
|
+
* the remedy, so the command fails closed instead of falling back to the
|
|
475
|
+
* per-command sandbox. Only success is cached, so a user who follows the
|
|
476
|
+
* remedy (`loginctl enable-linger`, `[boot] systemd=true`) does not need to
|
|
477
|
+
* restart the app.
|
|
478
|
+
*
|
|
479
|
+
* @param distro - the resolved distro name.
|
|
480
|
+
* @returns resolved once the platform can host a session runtime.
|
|
481
|
+
* @throws {Error} with the remedy when it cannot.
|
|
482
|
+
*/
|
|
483
|
+
ensureSessionRuntimeUsable(distro: string): Promise<void>;
|
|
484
|
+
/**
|
|
485
|
+
* Whether this executor should use the session runtime for one distro, with
|
|
486
|
+
* the `auto` downgrade and its bounded re-probe. `true` keeps the refusing
|
|
487
|
+
* behavior; `false` stays off.
|
|
488
|
+
*
|
|
489
|
+
* @param distro - the resolved distro.
|
|
490
|
+
* @returns whether to acquire the per-session scope.
|
|
491
|
+
*/
|
|
492
|
+
wantsSessionRuntime(distro: string): Promise<boolean>;
|
|
493
|
+
/**
|
|
494
|
+
* Release every runtime this executor holds, stopping each scope. Called
|
|
495
|
+
* from the session's dispose hook; public so tests and shutdown paths can
|
|
496
|
+
* await it.
|
|
497
|
+
*
|
|
498
|
+
* @returns resolved once every runtime is torn down.
|
|
499
|
+
*/
|
|
500
|
+
disposeSessionRuntimes(): Promise<void>;
|
|
501
|
+
/**
|
|
502
|
+
* The argv that runs INSIDE the distro for one spec: the resolved shell, its
|
|
503
|
+
* login/command flags, and the command string. This is the argv a
|
|
504
|
+
* distro-side sandbox wraps, which is why it is built separately from the
|
|
505
|
+
* `wsl.exe` invocation around it.
|
|
506
|
+
*
|
|
507
|
+
* @param spec - the resolved spec from {@link LocalBashExecutor.resolve}.
|
|
508
|
+
* @param shell - the resolved distro shell.
|
|
509
|
+
* @returns the distro-side argv.
|
|
510
|
+
*/
|
|
511
|
+
distroArgv(spec: ShellExecSpec, shell: string): string[];
|
|
512
|
+
/**
|
|
513
|
+
* Build the `wsl.exe` argv for one resolved spec. The command string is
|
|
514
|
+
* passed as a single argv element to the resolved shell, so there is no
|
|
515
|
+
* quoting layer of our own; Node's argv array reaches `wsl.exe` verbatim.
|
|
516
|
+
*
|
|
517
|
+
* `--exec` is load-bearing — see the comment inside.
|
|
518
|
+
*
|
|
519
|
+
* @param spec - the resolved spec from {@link LocalBashExecutor.resolve}.
|
|
520
|
+
* @param distro - the resolved distro name.
|
|
521
|
+
* @param shell - the resolved distro shell.
|
|
522
|
+
* @param inner - the already-confined distro argv, when confinement applies.
|
|
523
|
+
* @returns the argv to spawn.
|
|
524
|
+
*/
|
|
525
|
+
argv(spec: ShellExecSpec, distro: string, shell: string, inner?: string[]): string[];
|
|
526
|
+
/**
|
|
527
|
+
* Override only the spawn's working directory and environment. `spec.workdir`
|
|
528
|
+
* is a Linux path, which a Windows CreateProcess call cannot use as `cwd`.
|
|
529
|
+
*
|
|
530
|
+
* The inherited builder is private, so the call goes through the
|
|
531
|
+
* {@link SpawnSeamExecutor} bridge (`inheritedSpawnSpec`) instead of `super`
|
|
532
|
+
* — see docs/UPSTREAM-SPAWN-SEAM.md.
|
|
533
|
+
*
|
|
534
|
+
* @param spec - resolved execution settings.
|
|
535
|
+
* @param argv - the argv from {@link WslShellExecutor.argv}.
|
|
536
|
+
* @param stdoutMaxBytes - per-call stdout cap.
|
|
537
|
+
* @param signal - the spawn cancellation signal.
|
|
538
|
+
* @returns the subprocess spawn spec.
|
|
539
|
+
*/
|
|
540
|
+
spawnSpec(spec: ShellExecSpec, argv: string[], stdoutMaxBytes: number, signal?: AbortSignal): SubprocessSpawnSpec;
|
|
541
|
+
/**
|
|
542
|
+
* Resolve a request into a spec, replacing the parent's `process.cwd()`
|
|
543
|
+
* fallback with this provider's distro-home marker and stamping the per-call
|
|
544
|
+
* sandbox policy.
|
|
545
|
+
*
|
|
546
|
+
* The seam requires this step to be synchronous — the tool layer calls
|
|
547
|
+
* `ctx.shell.execute(ctx.shell.resolve(…))` with no `await` between them — so
|
|
548
|
+
* neither the home nor a confinement decision can be made here. Two request
|
|
549
|
+
* shapes default to the home when no `cwd` is configured: one that names no
|
|
550
|
+
* `workdir` at all, and one that names it only RELATIVELY — the parent
|
|
551
|
+
* resolves the first against `process.cwd()` (a Windows directory) and has
|
|
552
|
+
* nothing of its own to join the second onto. Both are stamped as the empty
|
|
553
|
+
* marker, with a relative tail carried verbatim in `relativeWorkdir`;
|
|
554
|
+
* {@link withDefaultWorkdir} resolves the pair against the home. The policy
|
|
555
|
+
* travels on the spec to {@link execute}, which awaits the wrap.
|
|
556
|
+
*
|
|
557
|
+
* @param request - the caller's request.
|
|
558
|
+
* @returns the fully-resolved spec.
|
|
559
|
+
*/
|
|
560
|
+
resolve(request: ShellExecRequest): WslExecSpec;
|
|
561
|
+
/**
|
|
562
|
+
* The spec to execute, with the home marker resolved against the distro
|
|
563
|
+
* user's home: `workdir: ""` becomes the home itself, and a relative tail
|
|
564
|
+
* carried by {@link WslShellExecutor.resolve} is joined under it. That is one
|
|
565
|
+
* `sh -c 'printf %s "$HOME"'` per provider instance, cached, and it happens
|
|
566
|
+
* only for a request that defaulted — an absolute workdir never reaches here.
|
|
567
|
+
*
|
|
568
|
+
* @param spec - the resolved spec.
|
|
569
|
+
* @returns the spec to execute.
|
|
570
|
+
*/
|
|
571
|
+
withDefaultWorkdir(spec: WslExecSpec): Promise<WslExecSpec>;
|
|
572
|
+
/**
|
|
573
|
+
* Decorate a handle's foreground projection in place, memoized once. The
|
|
574
|
+
* handle keeps its identity — never wrapped in a second object — because the
|
|
575
|
+
* per-process facts and `onProcessDone` key on the exact instance.
|
|
576
|
+
*
|
|
577
|
+
* @template H - the concrete handle type, preserved so the decorated handle
|
|
578
|
+
* keeps its identity in the callers' types; the settled result row the maps
|
|
579
|
+
* are spelled in is derived from its `result()`.
|
|
580
|
+
* @param ex - the execution handle to decorate.
|
|
581
|
+
* @param map - maps the settled result.
|
|
582
|
+
* @param mapError - maps a rejection, when the caller has one.
|
|
583
|
+
* @returns the same handle.
|
|
584
|
+
*/
|
|
585
|
+
static decorateResult<H extends {
|
|
586
|
+
result(): Promise<unknown>;
|
|
587
|
+
}>(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;
|
|
588
|
+
/**
|
|
589
|
+
* Stamp the per-process sandbox facts before `done` settles, so a background
|
|
590
|
+
* process reports the same mode, denial and enforcement a foreground run
|
|
591
|
+
* would. Signal deaths are not denials.
|
|
592
|
+
*
|
|
593
|
+
* @param proc - the settled process handle.
|
|
594
|
+
* @param stderr - the process's retained stderr tail used by subclasses for settlement classification.
|
|
595
|
+
* @param providerRejected - whether the subprocess promise rejected without a direct outcome.
|
|
596
|
+
* @param providerError - the provider rejection reason, which may itself be undefined.
|
|
597
|
+
*/
|
|
598
|
+
onProcessDone(proc: ShellExecution, stderr: string, providerRejected: boolean, providerError?: unknown): void;
|
|
599
|
+
/**
|
|
600
|
+
* Reject a settled command that failed because the distro itself is missing,
|
|
601
|
+
* stopped or unregistered.
|
|
602
|
+
*
|
|
603
|
+
* `wsl.exe` exits non-zero for that with an EMPTY stderr and its diagnostic on
|
|
604
|
+
* stdout, so nothing else here can see it: the denial signatures read stderr, and
|
|
605
|
+
* the result would otherwise reach the model as a bare non-zero code with no
|
|
606
|
+
* cause. The message names the remedy and says plainly that a wider permission
|
|
607
|
+
* cannot help — a sandbox flag does not create a distro.
|
|
608
|
+
*
|
|
609
|
+
* @param result - the settled shell result.
|
|
610
|
+
* @param distro - the distro the command asked for.
|
|
611
|
+
* @throws {Error} carrying the `WSL_E_*` code and the remedy.
|
|
612
|
+
*/
|
|
613
|
+
throwIfDistroUnavailable(result: {
|
|
614
|
+
exitCode?: number | null;
|
|
615
|
+
stdout?: {
|
|
616
|
+
text?: string;
|
|
617
|
+
};
|
|
618
|
+
stderr?: {
|
|
619
|
+
text?: string;
|
|
620
|
+
};
|
|
621
|
+
} | undefined, distro: string): void;
|
|
622
|
+
/**
|
|
623
|
+
* Reject a command that ran in the wrong directory.
|
|
624
|
+
*
|
|
625
|
+
* `wsl.exe --cd <path>` does not fail on a missing directory: it warns on stderr,
|
|
626
|
+
* runs the command in `/`, and exits 0. Reporting that as success would let a write
|
|
627
|
+
* or a build act on the wrong tree while every signal says it worked, so it becomes
|
|
628
|
+
* an error naming the directory that could not be entered.
|
|
629
|
+
*
|
|
630
|
+
* @param result - the settled shell result.
|
|
631
|
+
* @param workdir - the Linux directory the request asked for.
|
|
632
|
+
* @throws {Error} naming the directory and the fallback that happened.
|
|
633
|
+
*/
|
|
634
|
+
throwIfWorkdirMissing(result: {
|
|
635
|
+
exitCode?: number | null;
|
|
636
|
+
stdout?: {
|
|
637
|
+
text?: string;
|
|
638
|
+
};
|
|
639
|
+
stderr?: {
|
|
640
|
+
text?: string;
|
|
641
|
+
};
|
|
642
|
+
} | undefined, workdir: string): void;
|
|
643
|
+
/**
|
|
644
|
+
* The effective extra writable roots for one command: the row's
|
|
645
|
+
* `writableRoots` plus the shared policy's `additionalWritableRoots`,
|
|
646
|
+
* resolved to Linux paths and checked once per process. Empty unless the
|
|
647
|
+
* command is confined under `workspace-write`.
|
|
648
|
+
*
|
|
649
|
+
* @param distro - the distro the command runs in.
|
|
650
|
+
* @param policy - the per-call file-effect policy, when there is one.
|
|
651
|
+
* @param signal - optional cancellation for the one-time check.
|
|
652
|
+
* @returns the roots every confinement site binds.
|
|
653
|
+
* @throws {SandboxInvalidRootError} when an entry cannot be granted or checked.
|
|
654
|
+
*/
|
|
655
|
+
writableRootsFor(distro: string, policy: SandboxExecutionPolicy | undefined, signal?: AbortSignal): Promise<string[]>;
|
|
656
|
+
/**
|
|
657
|
+
* Execute one resolved spec inside the distro, confined by the per-call policy
|
|
658
|
+
* when there is one.
|
|
659
|
+
*
|
|
660
|
+
* Confinement wraps the DISTRO-side argv (`<shell> -lc <command>`) in `bwrap`
|
|
661
|
+
* and hands the result to `wsl.exe --exec`, so the sandbox is built inside the
|
|
662
|
+
* distro while the process that spawns it stays the ordinary Windows one. The
|
|
663
|
+
* `danger-full-access` escalation — and an operator's `sandbox: false` — skip
|
|
664
|
+
* the wrap entirely and run the command as before.
|
|
665
|
+
*
|
|
666
|
+
* @param spec - resolved execution settings.
|
|
667
|
+
* @returns the live shell process handle.
|
|
668
|
+
*/
|
|
669
|
+
execute(spec: ShellExecSpec): Promise<ShellExecution>;
|
|
670
|
+
/**
|
|
671
|
+
* Refuse a workdir that names another WSL distro — the shell-side twin of
|
|
672
|
+
* the filesystem's `FS_OUTSIDE_DISTRO` fence. Left unguarded, `toLinuxPath`
|
|
673
|
+
* strips the UNC's distro name and the command runs inside THIS distro
|
|
674
|
+
* against whatever tree happens to share the path, silently, while the fs
|
|
675
|
+
* side refuses the same workspace outright. The wording mirrors the fs
|
|
676
|
+
* refusal (minus `restrictToDistro`, which is an fs-only key).
|
|
677
|
+
*
|
|
678
|
+
* @param workdir - the resolved workdir (UNC, Linux path, or Windows path).
|
|
679
|
+
* @param distro - the pinned distro name.
|
|
680
|
+
* @throws {Error} naming both distros and both ways out.
|
|
681
|
+
*/
|
|
682
|
+
throwIfWorkdirInAnotherDistro(workdir: string, distro: string): void;
|
|
683
|
+
/**
|
|
684
|
+
* The agent-backed execution path: one long-lived in-distro process, the
|
|
685
|
+
* confinement argv unchanged, the handle shape unchanged. Any
|
|
686
|
+
* {@link AgentUnavailableError} propagates for the caller's fallback.
|
|
687
|
+
*
|
|
688
|
+
* @param resolved - the resolved spec from {@link WslShellExecutor.execute}.
|
|
689
|
+
* @param distro - the resolved distro name.
|
|
690
|
+
* @param shell - the resolved distro shell.
|
|
691
|
+
* @returns the decorated execution result.
|
|
692
|
+
*/
|
|
693
|
+
executeViaAgent(resolved: WslExecSpec, distro: string, shell: string, writableRoots?: readonly string[]): Promise<ShellExecution>;
|
|
694
|
+
/**
|
|
695
|
+
* The pre-agent execution path, verbatim: one `wsl.exe` per command through
|
|
696
|
+
* the inherited `executeArgv` machinery. Kept as the permanent fallback for
|
|
697
|
+
* an out-of-service agent and as the `agent: false` behaviour.
|
|
698
|
+
*
|
|
699
|
+
* @param resolved - the resolved spec.
|
|
700
|
+
* @param distro - the resolved distro name.
|
|
701
|
+
* @param shell - the resolved distro shell.
|
|
702
|
+
* @returns the decorated execution result.
|
|
703
|
+
*/
|
|
704
|
+
executeOneShot(resolved: WslExecSpec, distro: string, shell: string, writableRoots?: readonly string[]): Promise<ShellExecution>;
|
|
705
|
+
/**
|
|
706
|
+
* The confined one-shot's argv prepare: confine the distro argv under the
|
|
707
|
+
* policy, keep the resulting profile for the fact-stamper and the settlement
|
|
708
|
+
* mapping, and hand back the wrapped host argv.
|
|
709
|
+
*
|
|
710
|
+
* @param resolved - the resolved spec.
|
|
711
|
+
* @param distro - the resolved distro name.
|
|
712
|
+
* @param shell - the resolved distro shell.
|
|
713
|
+
* @param policy - the confined policy (narrowed in by `executeOneShot`).
|
|
714
|
+
* @param slot - the closure the builder assigns the profile into.
|
|
715
|
+
* @param writableRoots - the effective extra roots the profile binds.
|
|
716
|
+
* @param signal - the caller's cancellation.
|
|
717
|
+
*/
|
|
718
|
+
private prepareConfinedArgv;
|
|
719
|
+
/**
|
|
720
|
+
* Stamp the per-process sandbox facts before `done` settles, so a background
|
|
721
|
+
* process reports the same mode, denial and enforcement a foreground run
|
|
722
|
+
* would.
|
|
723
|
+
*
|
|
724
|
+
* @param resolved - the resolved spec.
|
|
725
|
+
* @param mode - the confined policy's mode.
|
|
726
|
+
* @param slot - the closure holding the assigned profile.
|
|
727
|
+
* @param process - the spawned handle.
|
|
728
|
+
*/
|
|
729
|
+
private stampConfinedFacts;
|
|
730
|
+
/**
|
|
731
|
+
* Settle one confined one-shot result: the distro and workdir verdicts, the
|
|
732
|
+
* never-armed honesty stamp, the runner-failure throw, and the denial facts.
|
|
733
|
+
*
|
|
734
|
+
* @param result - the settled process result.
|
|
735
|
+
* @param distro - the resolved distro name.
|
|
736
|
+
* @param resolved - the resolved spec.
|
|
737
|
+
* @param mode - the confined policy's mode.
|
|
738
|
+
* @param confined - the profile the argv prepare armed, when it ran.
|
|
739
|
+
*/
|
|
740
|
+
private settleConfinedOneShot;
|
|
741
|
+
}
|
|
742
|
+
export {};
|