dsh-plugin-wsl-env 0.26.4 → 0.27.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 +61 -0
- package/CONTRIBUTING.md +7 -4
- package/CONTRIBUTING.zh.md +3 -2
- package/README.md +1 -1
- package/SECURITY.md +21 -7
- package/SECURITY.zh.md +18 -5
- package/client.js +351 -48
- package/cordis.patch.yml +26 -10
- package/docs/API.md +2 -1
- package/docs/API.zh.md +2 -1
- package/docs/ARCHITECTURE.md +22 -4
- package/docs/ARCHITECTURE.zh.md +18 -4
- package/docs/CONFIGURATION.md +96 -12
- package/docs/CONFIGURATION.zh.md +80 -8
- package/docs/DIAGNOSTICS.md +22 -11
- package/docs/DIAGNOSTICS.zh.md +17 -9
- package/docs/LIMITATIONS.md +27 -4
- package/docs/LIMITATIONS.zh.md +20 -3
- package/docs/MIGRATION.md +2 -2
- package/docs/MIGRATION.zh.md +2 -2
- package/docs/QUICKSTART.md +31 -20
- package/docs/QUICKSTART.zh.md +16 -9
- package/docs/README.zh.md +1 -1
- package/docs/REQUIREMENTS.zh.md +3 -2
- package/lib/agent-confined.d.ts +9 -1
- package/lib/agent-confined.js +3 -3
- package/lib/bwrap.d.ts +16 -0
- package/lib/bwrap.js +9 -0
- package/lib/fs-routing.d.ts +3 -0
- package/lib/fs-routing.js +2 -0
- package/lib/messages.js +2 -2
- package/lib/plugin-update.d.ts +212 -0
- package/lib/plugin-update.js +283 -0
- package/lib/sandbox-core.d.ts +2 -0
- package/lib/sandbox-core.js +5 -3
- package/lib/session-runtime.d.ts +10 -1
- package/lib/session-runtime.js +3 -1
- package/lib/shell-env.js +1 -1
- package/lib/socket-isolation.d.ts +103 -0
- package/lib/socket-isolation.js +166 -0
- package/lib/status.d.ts +21 -8
- package/lib/status.js +53 -18
- package/lib/update-check.d.ts +49 -9
- package/lib/update-check.js +81 -28
- package/lib/wsl-doctor-tool.js +2 -0
- package/lib/wsl-filesystem.d.ts +39 -1
- package/lib/wsl-filesystem.js +51 -4
- package/lib/wsl-shell.d.ts +67 -3
- package/lib/wsl-shell.js +75 -12
- package/package.json +8 -3
- package/scripts/doctor.mjs +199 -3
- package/scripts/profile-preset.mjs +10 -2
package/lib/update-check.js
CHANGED
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
* the host's `pluginManager` for this package's version list and, when the
|
|
11
11
|
* stable channel has moved, publishes one fact. Applying the update stays a
|
|
12
12
|
* user action — a plugin that silently replaces its own code under a running
|
|
13
|
-
* harness is a posture this plugin rejects
|
|
14
|
-
*
|
|
13
|
+
* harness is a posture this plugin rejects. The sidebar's plugin-update row
|
|
14
|
+
* exposes the same answer and a confirmed one-click upgrade; this module owns
|
|
15
|
+
* the check itself and the fact the shell-env row serves.
|
|
15
16
|
*
|
|
16
17
|
* Delegation is the whole network story: the check spawns nothing and fetches
|
|
17
18
|
* nothing itself. `pluginManager` is read with `ctx.get`, the sanctioned read
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
import z from "@deepseek-ai/schemastery";
|
|
30
31
|
export const name = "wsl-update-check";
|
|
31
32
|
/** The checked package: this plugin, by its npm name. */
|
|
32
|
-
const PACKAGE = "dsh-plugin-wsl-env";
|
|
33
|
+
export const PACKAGE = "dsh-plugin-wsl-env";
|
|
33
34
|
/** The interval the row ships with. */
|
|
34
35
|
export const DEFAULT_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
35
36
|
/** The smallest interval a config may ask for; one check spawns `pnpm view` in the profile. */
|
|
@@ -104,45 +105,97 @@ export function updateTarget(list) {
|
|
|
104
105
|
return list.versions.find((version) => version.bundle && version.tags.includes("latest"));
|
|
105
106
|
}
|
|
106
107
|
/**
|
|
107
|
-
* Run one check
|
|
108
|
+
* Run one version check and publish (or clear) the shell-environment fact.
|
|
108
109
|
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
110
|
+
* The fact is the only observable for the periodic check, so the three
|
|
111
|
+
* outcomes are handled together: an available target publishes it, an
|
|
112
|
+
* up-to-date list clears a stale one, and a non-answer (no manager, a refused
|
|
113
|
+
* list, a throwing service) leaves the previous fact standing. A check must
|
|
114
|
+
* never become the noisiest thing in the app, so none of these throws.
|
|
113
115
|
*
|
|
114
116
|
* @param manager - the host plugin-manager, or undefined when the host has none.
|
|
115
|
-
* @
|
|
117
|
+
* @param installed - the installed version to name when the host has no manager.
|
|
118
|
+
* @param now - the check's timestamp, injectable for tests.
|
|
119
|
+
* @returns what the check learned.
|
|
116
120
|
*/
|
|
117
|
-
export async function
|
|
118
|
-
if (manager === undefined)
|
|
119
|
-
return
|
|
121
|
+
export async function inspectVersions(manager, installed, now = Date.now()) {
|
|
122
|
+
if (manager === undefined) {
|
|
123
|
+
return {
|
|
124
|
+
status: "unavailable",
|
|
125
|
+
installed,
|
|
126
|
+
checkedAt: now,
|
|
127
|
+
problem: "no-manager",
|
|
128
|
+
reason: "the host has no plugin-manager",
|
|
129
|
+
};
|
|
130
|
+
}
|
|
120
131
|
let list;
|
|
121
132
|
try {
|
|
122
133
|
list = await manager.listVersions(PACKAGE);
|
|
123
134
|
}
|
|
124
|
-
catch {
|
|
135
|
+
catch (error) {
|
|
125
136
|
// `listVersions` resolves refusals into its result; a throw means the
|
|
126
137
|
// service itself is broken. The next tick retries; nothing is published.
|
|
127
|
-
return
|
|
138
|
+
return {
|
|
139
|
+
status: "unavailable",
|
|
140
|
+
installed,
|
|
141
|
+
checkedAt: now,
|
|
142
|
+
problem: "unknown",
|
|
143
|
+
reason: messageOf(error),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (list.status !== "listed") {
|
|
147
|
+
// A linked checkout (`not-updatable`), an unreachable registry, or an
|
|
148
|
+
// unreadable listing is not news; the previous fact stays.
|
|
149
|
+
return {
|
|
150
|
+
status: "unavailable",
|
|
151
|
+
installed,
|
|
152
|
+
checkedAt: now,
|
|
153
|
+
problem: list.problem,
|
|
154
|
+
reason: list.reason,
|
|
155
|
+
};
|
|
128
156
|
}
|
|
129
|
-
if (list.status !== "listed")
|
|
130
|
-
return undefined;
|
|
131
157
|
const target = updateTarget(list);
|
|
132
|
-
if (target
|
|
158
|
+
if (target !== undefined) {
|
|
159
|
+
const next = {
|
|
160
|
+
installed: list.installed,
|
|
161
|
+
latest: target.version,
|
|
162
|
+
...(target.publishedAt === undefined ? {} : { publishedAt: target.publishedAt }),
|
|
163
|
+
incompatible: target.incompatible !== undefined,
|
|
164
|
+
...(target.deprecated === undefined ? {} : { deprecated: target.deprecated }),
|
|
165
|
+
checkedAt: now,
|
|
166
|
+
};
|
|
167
|
+
setUpdateFact(next);
|
|
168
|
+
return { status: "available", installed: list.installed, checkedAt: now, registry: list.registry, latest: target };
|
|
169
|
+
}
|
|
170
|
+
// A `latest` tag the update could not install is a registry state worth
|
|
171
|
+
// naming: saying "up to date" would imply the installed version is newest.
|
|
172
|
+
const latest = list.versions.find((version) => version.tags.includes("latest"));
|
|
173
|
+
if (latest !== undefined && !latest.bundle) {
|
|
133
174
|
setUpdateFact(undefined);
|
|
134
|
-
return
|
|
175
|
+
return {
|
|
176
|
+
status: "unavailable",
|
|
177
|
+
installed: list.installed,
|
|
178
|
+
checkedAt: now,
|
|
179
|
+
problem: "unknown",
|
|
180
|
+
reason: `the registry's latest release ${latest.version} declares no dsh.bundle`,
|
|
181
|
+
};
|
|
135
182
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
183
|
+
setUpdateFact(undefined);
|
|
184
|
+
return { status: "current", installed: list.installed, checkedAt: now, registry: list.registry };
|
|
185
|
+
}
|
|
186
|
+
/** The error text behind an unknown thrown value. */
|
|
187
|
+
function messageOf(error) {
|
|
188
|
+
return error instanceof Error ? error.message : String(error);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Run one check against the host's plugin-manager and publish the fact.
|
|
192
|
+
*
|
|
193
|
+
* @param manager - the host plugin-manager, or undefined when the host has none.
|
|
194
|
+
* @returns the published fact, or undefined when the check learned nothing.
|
|
195
|
+
*/
|
|
196
|
+
export async function checkForUpdate(manager) {
|
|
197
|
+
const check = await inspectVersions(manager, "unknown");
|
|
198
|
+
return check.status === "available" ? currentUpdateFact() : undefined;
|
|
146
199
|
}
|
|
147
200
|
/**
|
|
148
201
|
* The fact as one line, for the managed `DSH_*` variable and the log. The
|
package/lib/wsl-doctor-tool.js
CHANGED
package/lib/wsl-filesystem.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { WslAgent } from "./agent.js";
|
|
|
6
6
|
import { AgentSubstrate } from "./fs-substrate.js";
|
|
7
7
|
import { SessionRuntimes } from "./session-runtime.js";
|
|
8
8
|
import type { SessionRuntimeEntry } from "./session-runtime.js";
|
|
9
|
+
import { type SocketIsolation } from "./socket-isolation.js";
|
|
9
10
|
import type { Context } from "@deepseek-ai/cordis";
|
|
10
11
|
import type { FileSystem, FsDeleteOutcome, FsDirEntry, FsEditOutcome, FsEditRequest, FsInfo, FsMoveOutcome, FsPathInfo, FsTarget, FsVersion, FsWriteIntent, FsWriteOutcome } from "@deepseek-ai/dsh-fs";
|
|
11
12
|
import type { SandboxExecutionPolicy, SandboxMode } from "@deepseek-ai/dsh-sandbox";
|
|
@@ -36,6 +37,8 @@ interface WslFileSystemConfig {
|
|
|
36
37
|
sessionSandbox: boolean | "auto";
|
|
37
38
|
/** Whether confined profiles mask `/mnt`. */
|
|
38
39
|
maskWindowsDrive: boolean;
|
|
40
|
+
/** Which socket surfaces a confined resident cannot reach. */
|
|
41
|
+
socketIsolation: SocketIsolation;
|
|
39
42
|
/** Extra distro directories granted read-write under `workspace-write`. */
|
|
40
43
|
writableRoots?: string[];
|
|
41
44
|
/** Whether paths leaving the distro are refused. */
|
|
@@ -121,6 +124,16 @@ export declare class WslFileSystem extends LocalFileSystem {
|
|
|
121
124
|
* reads and the share substrate are unaffected.
|
|
122
125
|
*/
|
|
123
126
|
maskWindowsDrive: z<boolean, boolean, "defined">;
|
|
127
|
+
/**
|
|
128
|
+
* Which socket surfaces the confined write resident cannot reach — the
|
|
129
|
+
* same stance as `wsl-shell`'s key. The resident runs this plugin's fsio
|
|
130
|
+
* protocol, not model-authored commands, but the masks keep one mount
|
|
131
|
+
* table across the command and write planes and close the same
|
|
132
|
+
* process-authority path if the protocol is ever compromised. Keep the
|
|
133
|
+
* same value on the command row (`wsl-shell`) and, for the routed root,
|
|
134
|
+
* on `fs-routing`.
|
|
135
|
+
*/
|
|
136
|
+
socketIsolation: z<"off" | "session-bus" | "strict", "off" | "session-bus" | "strict", "defined">;
|
|
124
137
|
/**
|
|
125
138
|
* Extra directories under `workspace-write`, in distro spelling — the
|
|
126
139
|
* same list and same rules as `wsl-shell`'s key. Confined writes bind
|
|
@@ -203,6 +216,16 @@ export declare class WslFileSystem extends LocalFileSystem {
|
|
|
203
216
|
* reads and the share substrate are unaffected.
|
|
204
217
|
*/
|
|
205
218
|
maskWindowsDrive: z<boolean, boolean, "defined">;
|
|
219
|
+
/**
|
|
220
|
+
* Which socket surfaces the confined write resident cannot reach — the
|
|
221
|
+
* same stance as `wsl-shell`'s key. The resident runs this plugin's fsio
|
|
222
|
+
* protocol, not model-authored commands, but the masks keep one mount
|
|
223
|
+
* table across the command and write planes and close the same
|
|
224
|
+
* process-authority path if the protocol is ever compromised. Keep the
|
|
225
|
+
* same value on the command row (`wsl-shell`) and, for the routed root,
|
|
226
|
+
* on `fs-routing`.
|
|
227
|
+
*/
|
|
228
|
+
socketIsolation: z<"off" | "session-bus" | "strict", "off" | "session-bus" | "strict", "defined">;
|
|
206
229
|
/**
|
|
207
230
|
* Extra directories under `workspace-write`, in distro spelling — the
|
|
208
231
|
* same list and same rules as `wsl-shell`'s key. Confined writes bind
|
|
@@ -269,6 +292,8 @@ export declare class WslFileSystem extends LocalFileSystem {
|
|
|
269
292
|
sessionScopeProbe: (argv: string[]) => Promise<string>;
|
|
270
293
|
/** The one-time writable-root check's runner; tests substitute it. */
|
|
271
294
|
writableRootsProbe: (argv: string[]) => Promise<string>;
|
|
295
|
+
/** The socket-facts probe's runner; tests substitute it. */
|
|
296
|
+
socketIsolationProbe: (argv: string[]) => Promise<string>;
|
|
272
297
|
/**
|
|
273
298
|
* Per-distro homes, delegated to the shared runtime book: `provider-common`'s
|
|
274
299
|
* `distroHome` reads this view, and tests pin the cache through it.
|
|
@@ -350,6 +375,19 @@ export declare class WslFileSystem extends LocalFileSystem {
|
|
|
350
375
|
workspaceRoot: string;
|
|
351
376
|
additionalWritableRoots?: readonly string[];
|
|
352
377
|
} | undefined, check?: boolean): Promise<string[]>;
|
|
378
|
+
/**
|
|
379
|
+
* The socket masks one confined resident's profile binds, resolved once per
|
|
380
|
+
* distro from the row's `socketIsolation` stance. Empty when the sandbox is
|
|
381
|
+
* off, the mutation is escalated, or the stance is `off`. A probe failure is
|
|
382
|
+
* a sandbox refusal, never an unmasked resident.
|
|
383
|
+
*
|
|
384
|
+
* @param distro - the distro the resident serves.
|
|
385
|
+
* @param mode - the file-effect mode.
|
|
386
|
+
* @param signal - optional cancellation for the one-time probe.
|
|
387
|
+
* @returns the existing socket paths to mask.
|
|
388
|
+
* @throws {SandboxUnavailableError} when a configured isolation cannot be resolved.
|
|
389
|
+
*/
|
|
390
|
+
socketMasksFor(distro: string, mode: string, signal?: AbortSignal): Promise<string[]>;
|
|
353
391
|
/**
|
|
354
392
|
* The persistent session runtime for one confined mutation, when
|
|
355
393
|
* `sessionSandbox` is on. The key is the shell executor's key for the same
|
|
@@ -365,7 +403,7 @@ export declare class WslFileSystem extends LocalFileSystem {
|
|
|
365
403
|
mode: string;
|
|
366
404
|
workspaceRoot: string;
|
|
367
405
|
sessionId?: string;
|
|
368
|
-
}, distro: string, writableRoots?: readonly string[]): SessionRuntimeEntry | undefined;
|
|
406
|
+
}, distro: string, writableRoots?: readonly string[], socketMasks?: readonly string[], maskInterop?: boolean): SessionRuntimeEntry | undefined;
|
|
369
407
|
/**
|
|
370
408
|
* Run the session runtime's preflight once per provider. Only success is
|
|
371
409
|
* cached, so following the remedy does not need an app restart.
|
package/lib/wsl-filesystem.js
CHANGED
|
@@ -18,6 +18,7 @@ import { ensureNativeSessionAgent } from "./native-agent.js";
|
|
|
18
18
|
import { installMessagesLocale } from "./messages.js";
|
|
19
19
|
import { defaultDistro, runCapture } from "./wsl.js";
|
|
20
20
|
import { validateWritableRootsConfig } from "./writable-roots.js";
|
|
21
|
+
import { SocketIsolationError, socketMasksFor as resolveSocketMasks } from "./socket-isolation.js";
|
|
21
22
|
import { ProviderRuntimeBook, distroHome, effectiveWritableRoots, resolveOperationDistro, sessionRuntimeWanted, wslWritableRoots } from "./provider-common.js";
|
|
22
23
|
/**
|
|
23
24
|
* Filesystem backend over a WSL distro's UNC share.
|
|
@@ -91,6 +92,16 @@ export class WslFileSystem extends LocalFileSystem {
|
|
|
91
92
|
* reads and the share substrate are unaffected.
|
|
92
93
|
*/
|
|
93
94
|
maskWindowsDrive: z.boolean().default(false),
|
|
95
|
+
/**
|
|
96
|
+
* Which socket surfaces the confined write resident cannot reach — the
|
|
97
|
+
* same stance as `wsl-shell`'s key. The resident runs this plugin's fsio
|
|
98
|
+
* protocol, not model-authored commands, but the masks keep one mount
|
|
99
|
+
* table across the command and write planes and close the same
|
|
100
|
+
* process-authority path if the protocol is ever compromised. Keep the
|
|
101
|
+
* same value on the command row (`wsl-shell`) and, for the routed root,
|
|
102
|
+
* on `fs-routing`.
|
|
103
|
+
*/
|
|
104
|
+
socketIsolation: z.union(["off", "session-bus", "strict"]).default("off"),
|
|
94
105
|
/**
|
|
95
106
|
* Extra directories under `workspace-write`, in distro spelling — the
|
|
96
107
|
* same list and same rules as `wsl-shell`'s key. Confined writes bind
|
|
@@ -173,6 +184,7 @@ export class WslFileSystem extends LocalFileSystem {
|
|
|
173
184
|
this.sessionRuntimeOwner = randomUUID();
|
|
174
185
|
this.sessionScopeProbe = (argv) => runCapture(argv);
|
|
175
186
|
this.writableRootsProbe = (argv) => runCapture(argv);
|
|
187
|
+
this.socketIsolationProbe = (argv) => runCapture(argv);
|
|
176
188
|
// The preset's disposer releases the runtime; the shell executor's effect
|
|
177
189
|
// releases its own reference, so the scope stops after the last one.
|
|
178
190
|
ctx.effect(() => () => this.disposeSessionRuntimes().catch(() => { }), "wsl fs session runtimes");
|
|
@@ -304,6 +316,37 @@ export class WslFileSystem extends LocalFileSystem {
|
|
|
304
316
|
check,
|
|
305
317
|
});
|
|
306
318
|
}
|
|
319
|
+
/**
|
|
320
|
+
* The socket masks one confined resident's profile binds, resolved once per
|
|
321
|
+
* distro from the row's `socketIsolation` stance. Empty when the sandbox is
|
|
322
|
+
* off, the mutation is escalated, or the stance is `off`. A probe failure is
|
|
323
|
+
* a sandbox refusal, never an unmasked resident.
|
|
324
|
+
*
|
|
325
|
+
* @param distro - the distro the resident serves.
|
|
326
|
+
* @param mode - the file-effect mode.
|
|
327
|
+
* @param signal - optional cancellation for the one-time probe.
|
|
328
|
+
* @returns the existing socket paths to mask.
|
|
329
|
+
* @throws {SandboxUnavailableError} when a configured isolation cannot be resolved.
|
|
330
|
+
*/
|
|
331
|
+
async socketMasksFor(distro, mode, signal) {
|
|
332
|
+
const config = this.wslConfig;
|
|
333
|
+
if (!config.sandbox || mode === "danger-full-access" || config.socketIsolation === "off")
|
|
334
|
+
return [];
|
|
335
|
+
try {
|
|
336
|
+
return await resolveSocketMasks({
|
|
337
|
+
mode: config.socketIsolation,
|
|
338
|
+
wslPath: config.wslPath,
|
|
339
|
+
distro,
|
|
340
|
+
run: this.socketIsolationProbe,
|
|
341
|
+
...(signal === undefined ? {} : { signal }),
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
catch (error) {
|
|
345
|
+
if (error instanceof SocketIsolationError)
|
|
346
|
+
throw new SandboxUnavailableError(mode, error.message);
|
|
347
|
+
throw error;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
307
350
|
/**
|
|
308
351
|
* The persistent session runtime for one confined mutation, when
|
|
309
352
|
* `sessionSandbox` is on. The key is the shell executor's key for the same
|
|
@@ -315,13 +358,13 @@ export class WslFileSystem extends LocalFileSystem {
|
|
|
315
358
|
* @param writableRoots - the effective extra roots the runtime binds.
|
|
316
359
|
* @returns the runtime entry, or undefined when the mode is off.
|
|
317
360
|
*/
|
|
318
|
-
sessionRuntimeFor(policy, distro, writableRoots = []) {
|
|
361
|
+
sessionRuntimeFor(policy, distro, writableRoots = [], socketMasks = [], maskInterop = false) {
|
|
319
362
|
const config = this.wslConfig;
|
|
320
363
|
if (!config.sessionSandbox)
|
|
321
364
|
return undefined;
|
|
322
365
|
const workspaceRoot = policy.workspaceRoot || config.cwd;
|
|
323
366
|
const sessionId = policy.sessionId || this.sessionRuntimeOwner;
|
|
324
|
-
const key = SessionRuntimes.key({ sessionId, distro, workspaceRoot, mode: policy.mode, maskWindowsDrive: config.maskWindowsDrive, writableRoots });
|
|
367
|
+
const key = SessionRuntimes.key({ sessionId, distro, workspaceRoot, mode: policy.mode, maskWindowsDrive: config.maskWindowsDrive, writableRoots, socketMasks, maskInterop });
|
|
325
368
|
const held = this.runtimeBook.sessionRuntimeEntries.get(key);
|
|
326
369
|
if (held !== undefined)
|
|
327
370
|
return held;
|
|
@@ -333,6 +376,8 @@ export class WslFileSystem extends LocalFileSystem {
|
|
|
333
376
|
mode: policy.mode,
|
|
334
377
|
maskWindowsDrive: config.maskWindowsDrive,
|
|
335
378
|
writableRoots,
|
|
379
|
+
socketMasks,
|
|
380
|
+
maskInterop,
|
|
336
381
|
});
|
|
337
382
|
this.runtimeBook.sessionRuntimeEntries.set(key, entry);
|
|
338
383
|
return entry;
|
|
@@ -405,6 +450,8 @@ export class WslFileSystem extends LocalFileSystem {
|
|
|
405
450
|
// the parameter, so the confined shape is asserted once here (type-level
|
|
406
451
|
// only; `confinedPolicy` is the same value as `policy`).
|
|
407
452
|
const confinedPolicy = policy;
|
|
453
|
+
const socketMasks = await this.socketMasksFor(distro, confinedPolicy.mode);
|
|
454
|
+
const maskInterop = config.sandbox && config.socketIsolation === "strict";
|
|
408
455
|
if (!(await this.sandbox.usable(distro))) {
|
|
409
456
|
// The probe's classified remedy — missing vs present-but-broken, with the
|
|
410
457
|
// distro's own package family — is what every other refusal surfaces;
|
|
@@ -412,11 +459,11 @@ export class WslFileSystem extends LocalFileSystem {
|
|
|
412
459
|
throw new SandboxUnavailableError(confinedPolicy.mode, bwrapFailure(config.wslPath, distro) ?? missingBwrapRemedy(distro));
|
|
413
460
|
}
|
|
414
461
|
if (await this.wantsSessionRuntime(distro)) {
|
|
415
|
-
const runtime = this.sessionRuntimeFor(confinedPolicy, distro, writableRoots);
|
|
462
|
+
const runtime = this.sessionRuntimeFor(confinedPolicy, distro, writableRoots, socketMasks, maskInterop);
|
|
416
463
|
if (runtime !== undefined)
|
|
417
464
|
return runtime.agent;
|
|
418
465
|
}
|
|
419
|
-
return confinedAgent({ distro, wslPath: config.wslPath, policy: confinedPolicy, maskWindowsDrive: config.maskWindowsDrive, writableRoots });
|
|
466
|
+
return confinedAgent({ distro, wslPath: config.wslPath, policy: confinedPolicy, maskWindowsDrive: config.maskWindowsDrive, writableRoots, socketMasks, maskInterop });
|
|
420
467
|
}
|
|
421
468
|
/**
|
|
422
469
|
* Map a substrate error onto the peer's `FsError`, so the tool layer reads
|
package/lib/wsl-shell.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { WslAgent } from "./agent.js";
|
|
|
5
5
|
import { SessionRuntimes } from "./session-runtime.js";
|
|
6
6
|
import type { AgentBackend } from "./native-agent.js";
|
|
7
7
|
import type { SessionRuntimeEntry } from "./session-runtime.js";
|
|
8
|
+
import { type SocketIsolation } from "./socket-isolation.js";
|
|
8
9
|
import { ProviderRuntimeBook } from "./provider-common.js";
|
|
9
10
|
import type { Context } from "@deepseek-ai/cordis";
|
|
10
11
|
import type { SandboxExecutionPolicy, SandboxMode } from "@deepseek-ai/dsh-sandbox";
|
|
@@ -39,6 +40,8 @@ interface WslShellExecutorConfig {
|
|
|
39
40
|
sandbox: boolean;
|
|
40
41
|
/** Whether confined profiles mask `/mnt`. */
|
|
41
42
|
maskWindowsDrive: boolean;
|
|
43
|
+
/** Which socket surfaces confined commands cannot reach. */
|
|
44
|
+
socketIsolation: SocketIsolation;
|
|
42
45
|
/** Extra distro directories granted read-write under `workspace-write`. */
|
|
43
46
|
writableRoots: string[];
|
|
44
47
|
/** The interop stance; set at all, it takes precedence over `maskWindowsDrive`. */
|
|
@@ -187,6 +190,29 @@ export declare class WslShellExecutor extends LocalBashExecutor {
|
|
|
187
190
|
* read side still reaches `/mnt` through the shared read agent.
|
|
188
191
|
*/
|
|
189
192
|
maskWindowsDrive: z<boolean, boolean, "defined">;
|
|
193
|
+
/**
|
|
194
|
+
* The socket surfaces a confined COMMAND cannot reach. The sandbox's mount
|
|
195
|
+
* profile confines file effects, not process authority: a command can
|
|
196
|
+
* otherwise ask the user's systemd manager to start a unit outside the
|
|
197
|
+
* fence, or connect to a container daemon and start work outside it.
|
|
198
|
+
*
|
|
199
|
+
* - `off` (default) — nothing masked; the boundary is the documented
|
|
200
|
+
* `enforcement: partial`.
|
|
201
|
+
* - `session-bus` — masks `$XDG_RUNTIME_DIR/bus` and
|
|
202
|
+
* `$XDG_RUNTIME_DIR/systemd/private`, so `systemd-run --user` and
|
|
203
|
+
* `systemctl --user` fail inside the command.
|
|
204
|
+
* - `strict` — adds `/run/dbus/system_bus_socket` and the container
|
|
205
|
+
* sockets (`docker`, `podman`, `containerd`, `crio`) that exist and are
|
|
206
|
+
* reachable by the distro user; D-Bus and container clients inside the
|
|
207
|
+
* command fail.
|
|
208
|
+
*
|
|
209
|
+
* The masks are a narrowing, not a closure: same-user `/proc`, the
|
|
210
|
+
* interop transport and other IPC remain, and `enforcement` stays
|
|
211
|
+
* `partial`. The key applies to the command plane (`wsl-shell`); the
|
|
212
|
+
* filesystem rows' confined agent runs only this plugin's fs protocol,
|
|
213
|
+
* never model-authored commands. Verified by `pnpm run probe:sandbox`.
|
|
214
|
+
*/
|
|
215
|
+
socketIsolation: z<"off" | "session-bus" | "strict", "off" | "session-bus" | "strict", "defined">;
|
|
190
216
|
/**
|
|
191
217
|
* Extra directories under `workspace-write`, in distro spelling. The
|
|
192
218
|
* plugin grants them together with the workspace, so toolchain caches
|
|
@@ -299,6 +325,29 @@ export declare class WslShellExecutor extends LocalBashExecutor {
|
|
|
299
325
|
* read side still reaches `/mnt` through the shared read agent.
|
|
300
326
|
*/
|
|
301
327
|
maskWindowsDrive: z<boolean, boolean, "defined">;
|
|
328
|
+
/**
|
|
329
|
+
* The socket surfaces a confined COMMAND cannot reach. The sandbox's mount
|
|
330
|
+
* profile confines file effects, not process authority: a command can
|
|
331
|
+
* otherwise ask the user's systemd manager to start a unit outside the
|
|
332
|
+
* fence, or connect to a container daemon and start work outside it.
|
|
333
|
+
*
|
|
334
|
+
* - `off` (default) — nothing masked; the boundary is the documented
|
|
335
|
+
* `enforcement: partial`.
|
|
336
|
+
* - `session-bus` — masks `$XDG_RUNTIME_DIR/bus` and
|
|
337
|
+
* `$XDG_RUNTIME_DIR/systemd/private`, so `systemd-run --user` and
|
|
338
|
+
* `systemctl --user` fail inside the command.
|
|
339
|
+
* - `strict` — adds `/run/dbus/system_bus_socket` and the container
|
|
340
|
+
* sockets (`docker`, `podman`, `containerd`, `crio`) that exist and are
|
|
341
|
+
* reachable by the distro user; D-Bus and container clients inside the
|
|
342
|
+
* command fail.
|
|
343
|
+
*
|
|
344
|
+
* The masks are a narrowing, not a closure: same-user `/proc`, the
|
|
345
|
+
* interop transport and other IPC remain, and `enforcement` stays
|
|
346
|
+
* `partial`. The key applies to the command plane (`wsl-shell`); the
|
|
347
|
+
* filesystem rows' confined agent runs only this plugin's fs protocol,
|
|
348
|
+
* never model-authored commands. Verified by `pnpm run probe:sandbox`.
|
|
349
|
+
*/
|
|
350
|
+
socketIsolation: z<"off" | "session-bus" | "strict", "off" | "session-bus" | "strict", "defined">;
|
|
302
351
|
/**
|
|
303
352
|
* Extra directories under `workspace-write`, in distro spelling. The
|
|
304
353
|
* plugin grants them together with the workspace, so toolchain caches
|
|
@@ -369,6 +418,8 @@ export declare class WslShellExecutor extends LocalBashExecutor {
|
|
|
369
418
|
sessionScopeProbe: (argv: string[]) => Promise<string>;
|
|
370
419
|
/** The one-time writable-root check's runner; tests substitute it. */
|
|
371
420
|
writableRootsProbe: (argv: string[]) => Promise<string>;
|
|
421
|
+
/** The socket-facts probe's runner; tests substitute it. */
|
|
422
|
+
socketIsolationProbe: (argv: string[]) => Promise<string>;
|
|
372
423
|
/**
|
|
373
424
|
* Per-process confinement facts retained until settlement. Overlapping calls
|
|
374
425
|
* can carry different policies, so a shared latest-wrap value would classify
|
|
@@ -472,7 +523,7 @@ export declare class WslShellExecutor extends LocalBashExecutor {
|
|
|
472
523
|
mode: string;
|
|
473
524
|
workspaceRoot: string;
|
|
474
525
|
sessionId?: string;
|
|
475
|
-
} | undefined, resolved: WslExecSpec, distro: string, writableRoots?: readonly string[]): SessionRuntimeEntry | undefined;
|
|
526
|
+
} | undefined, resolved: WslExecSpec, distro: string, writableRoots?: readonly string[], socketMasks?: readonly string[], maskInterop?: boolean): SessionRuntimeEntry | undefined;
|
|
476
527
|
/**
|
|
477
528
|
* Run the session runtime's preflight once per executor. A failure is a
|
|
478
529
|
* configuration verdict, not an agent outage: it is raised as an Error with
|
|
@@ -658,6 +709,19 @@ export declare class WslShellExecutor extends LocalBashExecutor {
|
|
|
658
709
|
* @throws {SandboxInvalidRootError} when an entry cannot be granted or checked.
|
|
659
710
|
*/
|
|
660
711
|
writableRootsFor(distro: string, policy: SandboxExecutionPolicy | undefined, signal?: AbortSignal): Promise<string[]>;
|
|
712
|
+
/**
|
|
713
|
+
* The socket masks one confined command's profile binds, resolved once per
|
|
714
|
+
* distro from the row's `socketIsolation` stance. Empty when the sandbox is
|
|
715
|
+
* off, the command is unconfined, or the stance is `off`. A probe failure is
|
|
716
|
+
* a sandbox refusal, never an unmasked run.
|
|
717
|
+
*
|
|
718
|
+
* @param distro - the distro the command runs in.
|
|
719
|
+
* @param mode - the per-call file-effect mode.
|
|
720
|
+
* @param signal - optional cancellation for the one-time probe.
|
|
721
|
+
* @returns the existing socket paths to mask.
|
|
722
|
+
* @throws {SandboxUnavailableError} when a configured isolation cannot be resolved.
|
|
723
|
+
*/
|
|
724
|
+
socketMasksFor(distro: string, mode: SandboxMode | undefined, signal?: AbortSignal): Promise<string[]>;
|
|
661
725
|
/**
|
|
662
726
|
* Execute one resolved spec inside the distro, confined by the per-call policy
|
|
663
727
|
* when there is one.
|
|
@@ -695,7 +759,7 @@ export declare class WslShellExecutor extends LocalBashExecutor {
|
|
|
695
759
|
* @param shell - the resolved distro shell.
|
|
696
760
|
* @returns the decorated execution result.
|
|
697
761
|
*/
|
|
698
|
-
executeViaAgent(resolved: WslExecSpec, distro: string, shell: string, writableRoots?: readonly string[]): Promise<ShellExecution>;
|
|
762
|
+
executeViaAgent(resolved: WslExecSpec, distro: string, shell: string, writableRoots?: readonly string[], socketMasks?: readonly string[], maskInterop?: boolean): Promise<ShellExecution>;
|
|
699
763
|
/**
|
|
700
764
|
* The pre-agent execution path, verbatim: one `wsl.exe` per command through
|
|
701
765
|
* the inherited `executeArgv` machinery. Kept as the permanent fallback for
|
|
@@ -706,7 +770,7 @@ export declare class WslShellExecutor extends LocalBashExecutor {
|
|
|
706
770
|
* @param shell - the resolved distro shell.
|
|
707
771
|
* @returns the decorated execution result.
|
|
708
772
|
*/
|
|
709
|
-
executeOneShot(resolved: WslExecSpec, distro: string, shell: string, writableRoots?: readonly string[]): Promise<ShellExecution>;
|
|
773
|
+
executeOneShot(resolved: WslExecSpec, distro: string, shell: string, writableRoots?: readonly string[], socketMasks?: readonly string[], maskInterop?: boolean): Promise<ShellExecution>;
|
|
710
774
|
/**
|
|
711
775
|
* The confined one-shot's argv prepare: confine the distro argv under the
|
|
712
776
|
* policy, keep the resulting profile for the fact-stamper and the settlement
|