dsh-plugin-wsl-env 0.26.3 → 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.
Files changed (82) hide show
  1. package/CHANGELOG.md +142 -0
  2. package/CONTRIBUTING.md +32 -25
  3. package/CONTRIBUTING.zh.md +3 -2
  4. package/README.md +1 -1
  5. package/SECURITY.md +21 -7
  6. package/SECURITY.zh.md +18 -5
  7. package/SUPPORT.md +2 -2
  8. package/SUPPORT.zh.md +2 -2
  9. package/client.js +351 -48
  10. package/cordis.patch.yml +26 -10
  11. package/docs/AGENT-PROTOCOL-V7.md +4 -2
  12. package/docs/API.md +3 -1
  13. package/docs/API.zh.md +3 -1
  14. package/docs/ARCHITECTURE.md +22 -4
  15. package/docs/ARCHITECTURE.zh.md +18 -4
  16. package/docs/CONFIGURATION.md +117 -17
  17. package/docs/CONFIGURATION.zh.md +97 -11
  18. package/docs/DIAGNOSTICS.md +22 -11
  19. package/docs/DIAGNOSTICS.zh.md +17 -9
  20. package/docs/LIMITATIONS.md +27 -4
  21. package/docs/LIMITATIONS.zh.md +20 -3
  22. package/docs/MIGRATION.md +2 -2
  23. package/docs/MIGRATION.zh.md +2 -2
  24. package/docs/PARITY.md +3 -1
  25. package/docs/QUICKSTART.md +31 -20
  26. package/docs/QUICKSTART.zh.md +16 -9
  27. package/docs/README.zh.md +1 -1
  28. package/docs/RELEASING.md +25 -3
  29. package/docs/REQUIREMENTS.zh.md +7 -6
  30. package/docs/ROADMAP-1.0.md +11 -7
  31. package/lib/agent-confined.d.ts +9 -1
  32. package/lib/agent-confined.js +3 -3
  33. package/lib/agent.d.ts +54 -18
  34. package/lib/agent.js +86 -19
  35. package/lib/bwrap.d.ts +16 -0
  36. package/lib/bwrap.js +9 -0
  37. package/lib/fs-routing.d.ts +6 -0
  38. package/lib/fs-routing.js +7 -0
  39. package/lib/fs-substrate.d.ts +1 -1
  40. package/lib/fs-substrate.js +10 -18
  41. package/lib/fsio-agent.d.ts +4 -0
  42. package/lib/fsio-agent.js +37 -10
  43. package/lib/listing.d.ts +2 -2
  44. package/lib/listing.js +5 -4
  45. package/lib/messages.d.ts +70 -0
  46. package/lib/messages.js +80 -0
  47. package/lib/open-in-app.js +12 -9
  48. package/lib/picker.d.ts +4 -1
  49. package/lib/picker.js +35 -11
  50. package/lib/plugin-update.d.ts +212 -0
  51. package/lib/plugin-update.js +283 -0
  52. package/lib/ports.js +8 -1
  53. package/lib/provider-common.d.ts +22 -0
  54. package/lib/provider-common.js +18 -0
  55. package/lib/provider-marker.d.ts +23 -0
  56. package/lib/provider-marker.js +21 -0
  57. package/lib/sandbox-core.d.ts +2 -0
  58. package/lib/sandbox-core.js +5 -3
  59. package/lib/session-runtime.d.ts +10 -1
  60. package/lib/session-runtime.js +3 -1
  61. package/lib/shell-env.js +1 -1
  62. package/lib/socket-isolation.d.ts +103 -0
  63. package/lib/socket-isolation.js +166 -0
  64. package/lib/status.d.ts +21 -8
  65. package/lib/status.js +61 -23
  66. package/lib/subprocess.d.ts +3 -0
  67. package/lib/subprocess.js +5 -0
  68. package/lib/takeover-report.js +4 -11
  69. package/lib/update-check.d.ts +49 -9
  70. package/lib/update-check.js +81 -28
  71. package/lib/watcher.d.ts +1 -1
  72. package/lib/watcher.js +1 -1
  73. package/lib/wsl-doctor-command.d.ts +6 -2
  74. package/lib/wsl-doctor-command.js +24 -15
  75. package/lib/wsl-doctor-tool.js +2 -0
  76. package/lib/wsl-filesystem.d.ts +53 -12
  77. package/lib/wsl-filesystem.js +90 -31
  78. package/lib/wsl-shell.d.ts +109 -40
  79. package/lib/wsl-shell.js +128 -54
  80. package/package.json +8 -3
  81. package/scripts/doctor.mjs +199 -3
  82. package/scripts/profile-preset.mjs +10 -2
@@ -18,7 +18,8 @@ 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 { distroHome, effectiveWritableRoots, resolveOperationDistro, sessionRuntimeWanted, wslWritableRoots } from "./provider-common.js";
21
+ import { SocketIsolationError, socketMasksFor as resolveSocketMasks } from "./socket-isolation.js";
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.
24
25
  *
@@ -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
@@ -131,6 +142,21 @@ export class WslFileSystem extends LocalFileSystem {
131
142
  */
132
143
  substrate: z.union(["share", "agent"]).default("agent"),
133
144
  });
145
+ /**
146
+ * Per-distro homes, delegated to the shared runtime book: `provider-common`'s
147
+ * `distroHome` reads this view, and tests pin the cache through it.
148
+ */
149
+ get resolvedHomes() {
150
+ return this.runtimeBook.homes;
151
+ }
152
+ /**
153
+ * The row's config without the peer's volatile wrapper. The schema validates
154
+ * the plain shape; the wrapper only widens the type, so one accessor states
155
+ * the cast instead of every method repeating it.
156
+ */
157
+ get wslConfig() {
158
+ return this.config;
159
+ }
134
160
  /**
135
161
  * @param ctx - the composition context.
136
162
  * @param config - the validated plugin config.
@@ -147,7 +173,7 @@ export class WslFileSystem extends LocalFileSystem {
147
173
  installMessagesLocale(ctx);
148
174
  this.resolvedDistro = pinnedDistro(config.distro) ?? "";
149
175
  this.resolvedHome = undefined;
150
- this.resolvedHomes = new Map();
176
+ this.runtimeBook = new ProviderRuntimeBook();
151
177
  this.defaultMode = ctx.sandboxPolicy.defaultMode;
152
178
  this.agentSubstrateInstance = undefined;
153
179
  this.agentSubstrates = new Map();
@@ -155,12 +181,10 @@ export class WslFileSystem extends LocalFileSystem {
155
181
  this.agentInstance = undefined;
156
182
  this.agentInstances = new Map();
157
183
  this.sessionRuntimes = sessionRuntimes;
158
- this.sessionRuntimeEntries = new Map();
159
184
  this.sessionRuntimeOwner = randomUUID();
160
185
  this.sessionScopeProbe = (argv) => runCapture(argv);
161
186
  this.writableRootsProbe = (argv) => runCapture(argv);
162
- this.sessionRuntimePreflight = new Set();
163
- this.autoSessionScope = new Map();
187
+ this.socketIsolationProbe = (argv) => runCapture(argv);
164
188
  // The preset's disposer releases the runtime; the shell executor's effect
165
189
  // releases its own reference, so the scope stops after the last one.
166
190
  ctx.effect(() => () => this.disposeSessionRuntimes().catch(() => { }), "wsl fs session runtimes");
@@ -174,7 +198,7 @@ export class WslFileSystem extends LocalFileSystem {
174
198
  * @returns the deployment default mode, or `undefined` when unfenced.
175
199
  */
176
200
  get sandboxMode() {
177
- const config = this.config;
201
+ const config = this.wslConfig;
178
202
  return config.sandbox ? this.defaultMode : undefined;
179
203
  }
180
204
  /**
@@ -214,7 +238,7 @@ export class WslFileSystem extends LocalFileSystem {
214
238
  * @returns the substrate.
215
239
  */
216
240
  async agentSubstrate() {
217
- const config = this.config;
241
+ const config = this.wslConfig;
218
242
  if (this.agentSubstrateInstance === undefined) {
219
243
  this.agentSubstrateInstance = new AgentSubstrate({
220
244
  agent: await this.publicationAgent(),
@@ -240,7 +264,7 @@ export class WslFileSystem extends LocalFileSystem {
240
264
  const cached = this.agentSubstrates.get(distro);
241
265
  if (cached !== undefined)
242
266
  return cached;
243
- const config = this.config;
267
+ const config = this.wslConfig;
244
268
  const substrate = new AgentSubstrate({
245
269
  agent: await this.publicationAgentFor(distro),
246
270
  distro,
@@ -271,7 +295,7 @@ export class WslFileSystem extends LocalFileSystem {
271
295
  * @throws {SandboxInvalidRootError} when an entry cannot be granted or checked.
272
296
  */
273
297
  async writableRootsFor(distro, policy, check = true) {
274
- const config = this.config;
298
+ const config = this.wslConfig;
275
299
  if (!config.sandbox || policy === undefined || policy.mode !== "workspace-write")
276
300
  return [];
277
301
  if ((config.writableRoots?.length ?? 0) === 0 && (policy.additionalWritableRoots?.length ?? 0) === 0)
@@ -292,6 +316,37 @@ export class WslFileSystem extends LocalFileSystem {
292
316
  check,
293
317
  });
294
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
+ }
295
350
  /**
296
351
  * The persistent session runtime for one confined mutation, when
297
352
  * `sessionSandbox` is on. The key is the shell executor's key for the same
@@ -303,14 +358,14 @@ export class WslFileSystem extends LocalFileSystem {
303
358
  * @param writableRoots - the effective extra roots the runtime binds.
304
359
  * @returns the runtime entry, or undefined when the mode is off.
305
360
  */
306
- sessionRuntimeFor(policy, distro, writableRoots = []) {
307
- const config = this.config;
361
+ sessionRuntimeFor(policy, distro, writableRoots = [], socketMasks = [], maskInterop = false) {
362
+ const config = this.wslConfig;
308
363
  if (!config.sessionSandbox)
309
364
  return undefined;
310
365
  const workspaceRoot = policy.workspaceRoot || config.cwd;
311
366
  const sessionId = policy.sessionId || this.sessionRuntimeOwner;
312
- const key = SessionRuntimes.key({ sessionId, distro, workspaceRoot, mode: policy.mode, maskWindowsDrive: config.maskWindowsDrive, writableRoots });
313
- const held = this.sessionRuntimeEntries.get(key);
367
+ const key = SessionRuntimes.key({ sessionId, distro, workspaceRoot, mode: policy.mode, maskWindowsDrive: config.maskWindowsDrive, writableRoots, socketMasks, maskInterop });
368
+ const held = this.runtimeBook.sessionRuntimeEntries.get(key);
314
369
  if (held !== undefined)
315
370
  return held;
316
371
  const entry = this.sessionRuntimes.acquire({
@@ -321,8 +376,10 @@ export class WslFileSystem extends LocalFileSystem {
321
376
  mode: policy.mode,
322
377
  maskWindowsDrive: config.maskWindowsDrive,
323
378
  writableRoots,
379
+ socketMasks,
380
+ maskInterop,
324
381
  });
325
- this.sessionRuntimeEntries.set(key, entry);
382
+ this.runtimeBook.sessionRuntimeEntries.set(key, entry);
326
383
  return entry;
327
384
  }
328
385
  /**
@@ -334,14 +391,14 @@ export class WslFileSystem extends LocalFileSystem {
334
391
  * @throws {Error} with the remedy when it cannot.
335
392
  */
336
393
  async ensureSessionRuntimeUsable(distro) {
337
- if (this.sessionRuntimePreflight.has(distro))
394
+ if (this.runtimeBook.sessionRuntimePreflight.has(distro))
338
395
  return;
339
- const config = this.config;
396
+ const config = this.wslConfig;
340
397
  const problem = await probeSessionRuntime({ wslPath: config.wslPath, distro, run: this.sessionScopeProbe });
341
398
  if (problem !== null)
342
399
  throw new Error(problem);
343
400
  await ensureNativeSessionAgent({ wslPath: config.wslPath, distro, setNative: setSessionNativeAgent });
344
- this.sessionRuntimePreflight.add(distro);
401
+ this.runtimeBook.sessionRuntimePreflight.add(distro);
345
402
  }
346
403
  /**
347
404
  * Whether this provider should use the session runtime for one distro, with
@@ -352,8 +409,8 @@ export class WslFileSystem extends LocalFileSystem {
352
409
  * @returns whether to acquire the per-session scope.
353
410
  */
354
411
  async wantsSessionRuntime(distro) {
355
- const config = this.config;
356
- return sessionRuntimeWanted(config.sessionSandbox, distro, () => this.ensureSessionRuntimeUsable(distro), this.autoSessionScope);
412
+ const config = this.wslConfig;
413
+ return sessionRuntimeWanted(config.sessionSandbox, distro, () => this.ensureSessionRuntimeUsable(distro), this.runtimeBook.autoSessionScope);
357
414
  }
358
415
  /**
359
416
  * Release every runtime this provider holds. Called from the preset's
@@ -362,8 +419,8 @@ export class WslFileSystem extends LocalFileSystem {
362
419
  * @returns resolved once every reference is released.
363
420
  */
364
421
  async disposeSessionRuntimes() {
365
- const entries = [...this.sessionRuntimeEntries.values()];
366
- this.sessionRuntimeEntries.clear();
422
+ const entries = [...this.runtimeBook.sessionRuntimeEntries.values()];
423
+ this.runtimeBook.sessionRuntimeEntries.clear();
367
424
  for (const entry of entries)
368
425
  await this.sessionRuntimes.release(entry.key);
369
426
  }
@@ -383,7 +440,7 @@ export class WslFileSystem extends LocalFileSystem {
383
440
  * @returns the agent to publish through.
384
441
  */
385
442
  async mutationAgent(policy, forDistro) {
386
- const config = this.config;
443
+ const config = this.wslConfig;
387
444
  const distro = forDistro ?? await this.distroForPolicy(policy);
388
445
  if (!isConfinedMutation({ policy, sandboxEnabled: config.sandbox })) {
389
446
  return this.publicationAgentFor(distro);
@@ -393,6 +450,8 @@ export class WslFileSystem extends LocalFileSystem {
393
450
  // the parameter, so the confined shape is asserted once here (type-level
394
451
  // only; `confinedPolicy` is the same value as `policy`).
395
452
  const confinedPolicy = policy;
453
+ const socketMasks = await this.socketMasksFor(distro, confinedPolicy.mode);
454
+ const maskInterop = config.sandbox && config.socketIsolation === "strict";
396
455
  if (!(await this.sandbox.usable(distro))) {
397
456
  // The probe's classified remedy — missing vs present-but-broken, with the
398
457
  // distro's own package family — is what every other refusal surfaces;
@@ -400,11 +459,11 @@ export class WslFileSystem extends LocalFileSystem {
400
459
  throw new SandboxUnavailableError(confinedPolicy.mode, bwrapFailure(config.wslPath, distro) ?? missingBwrapRemedy(distro));
401
460
  }
402
461
  if (await this.wantsSessionRuntime(distro)) {
403
- const runtime = this.sessionRuntimeFor(confinedPolicy, distro, writableRoots);
462
+ const runtime = this.sessionRuntimeFor(confinedPolicy, distro, writableRoots, socketMasks, maskInterop);
404
463
  if (runtime !== undefined)
405
464
  return runtime.agent;
406
465
  }
407
- 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 });
408
467
  }
409
468
  /**
410
469
  * Map a substrate error onto the peer's `FsError`, so the tool layer reads
@@ -441,7 +500,7 @@ export class WslFileSystem extends LocalFileSystem {
441
500
  * @returns the distro name.
442
501
  */
443
502
  async distro() {
444
- const config = this.config;
503
+ const config = this.wslConfig;
445
504
  if (this.resolvedDistro.length === 0)
446
505
  this.resolvedDistro = await defaultDistro({ wslPath: config.wslPath });
447
506
  return this.resolvedDistro;
@@ -456,7 +515,7 @@ export class WslFileSystem extends LocalFileSystem {
456
515
  * @returns the distro name.
457
516
  */
458
517
  async distroForPath(path, cwd) {
459
- const config = this.config;
518
+ const config = this.wslConfig;
460
519
  return resolveOperationDistro(config.distro, [path, cwd ?? config.cwd], () => this.distro());
461
520
  }
462
521
  /**
@@ -477,7 +536,7 @@ export class WslFileSystem extends LocalFileSystem {
477
536
  * @returns the distro name.
478
537
  */
479
538
  async distroForPolicy(policy) {
480
- const config = this.config;
539
+ const config = this.wslConfig;
481
540
  return resolveOperationDistro(config.distro, [policy?.workspaceRoot, config.cwd], () => this.distro());
482
541
  }
483
542
  /**
@@ -488,7 +547,7 @@ export class WslFileSystem extends LocalFileSystem {
488
547
  * @returns the host path to operate on.
489
548
  */
490
549
  async worldPath(path, cwd) {
491
- const config = this.config;
550
+ const config = this.wslConfig;
492
551
  const distro = await this.distroForPath(path, cwd);
493
552
  let base = cwd ?? config.cwd;
494
553
  if (String(base ?? "").trim().length === 0 && isRelativeWorldPath(path)) {
@@ -550,7 +609,7 @@ export class WslFileSystem extends LocalFileSystem {
550
609
  * @throws {FsError} with `FS_SANDBOX_DENIED` when the policy refuses it.
551
610
  */
552
611
  async checkedTarget(target, sandboxPolicy) {
553
- const config = this.config;
612
+ const config = this.wslConfig;
554
613
  if (!config.sandbox)
555
614
  return target;
556
615
  const policy = sandboxPolicy ?? this.ctx.sandboxPolicy.resolve();
@@ -715,7 +774,7 @@ export class WslFileSystem extends LocalFileSystem {
715
774
  * mapped with what is already known.
716
775
  */
717
776
  processPathFromHostPath(hostPath) {
718
- const config = this.config;
777
+ const config = this.wslConfig;
719
778
  const choice = selectDistro({
720
779
  configured: config.distro,
721
780
  candidates: [hostPath, config.cwd],
@@ -752,7 +811,7 @@ export class WslFileSystem extends LocalFileSystem {
752
811
  */
753
812
  async watch(target, changed, signal) {
754
813
  signal.throwIfAborted();
755
- const config = this.config;
814
+ const config = this.wslConfig;
756
815
  const parsed = uncToPosix(target.targetKey);
757
816
  if (parsed === undefined) {
758
817
  throw new FsError(`cannot watch "${target.displayPath}": not a path inside the distro`, "FS_IO_ERROR");
@@ -5,6 +5,8 @@ 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";
9
+ import { ProviderRuntimeBook } from "./provider-common.js";
8
10
  import type { Context } from "@deepseek-ai/cordis";
9
11
  import type { SandboxExecutionPolicy, SandboxMode } from "@deepseek-ai/dsh-sandbox";
10
12
  import type { SubprocessSpawnSpec } from "@deepseek-ai/dsh-subprocess";
@@ -38,6 +40,8 @@ interface WslShellExecutorConfig {
38
40
  sandbox: boolean;
39
41
  /** Whether confined profiles mask `/mnt`. */
40
42
  maskWindowsDrive: boolean;
43
+ /** Which socket surfaces confined commands cannot reach. */
44
+ socketIsolation: SocketIsolation;
41
45
  /** Extra distro directories granted read-write under `workspace-write`. */
42
46
  writableRoots: string[];
43
47
  /** The interop stance; set at all, it takes precedence over `maskWindowsDrive`. */
@@ -151,19 +155,6 @@ export declare class WslShellExecutor extends LocalBashExecutor {
151
155
  * unconfined and `sandboxMode` is `undefined`, so the model is told so.
152
156
  */
153
157
  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
158
  /**
168
159
  * The interop stance in one key (WSL-314), expanding to the per-key
169
160
  * values the measured matrix documents:
@@ -184,7 +175,44 @@ export declare class WslShellExecutor extends LocalBashExecutor {
184
175
  * boolean answer); the boolean remains for existing profiles.
185
176
  */
186
177
  interopVisibility: z<"masked" | "visible" | "disabled", "masked" | "visible" | "disabled", "plain">;
178
+ /**
179
+ * Shadow `/mnt` with an empty tmpfs in every confined profile, hiding the
180
+ * Windows drive from confined commands: its files cannot be read or
181
+ * exfiltrated and its executables cannot be launched through interop —
182
+ * the hole that lets a "sandboxed" command reach your full Windows token.
183
+ * A narrowing, not a closure (a command can still write an executable
184
+ * into the workspace and run it — binfmt dispatches on content, not
185
+ * location), so enforcement stays `partial` and the sandbox fact reports
186
+ * `windowsDrive: "masked"`. Costs: confined commands cannot read or touch
187
+ * anything under `/mnt`, and tools that probe the drive degrade. The
188
+ * complete closure is distro-level: `[interop] enabled=false` in
189
+ * `wsl.conf`. The mask covers the COMMAND path only; the file tools'
190
+ * read side still reaches `/mnt` through the shared read agent.
191
+ */
187
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">;
188
216
  /**
189
217
  * Extra directories under `workspace-write`, in distro spelling. The
190
218
  * plugin grants them together with the workspace, so toolchain caches
@@ -262,19 +290,6 @@ export declare class WslShellExecutor extends LocalBashExecutor {
262
290
  * unconfined and `sandboxMode` is `undefined`, so the model is told so.
263
291
  */
264
292
  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
293
  /**
279
294
  * The interop stance in one key (WSL-314), expanding to the per-key
280
295
  * values the measured matrix documents:
@@ -295,7 +310,44 @@ export declare class WslShellExecutor extends LocalBashExecutor {
295
310
  * boolean answer); the boolean remains for existing profiles.
296
311
  */
297
312
  interopVisibility: z<"masked" | "visible" | "disabled", "masked" | "visible" | "disabled", "plain">;
313
+ /**
314
+ * Shadow `/mnt` with an empty tmpfs in every confined profile, hiding the
315
+ * Windows drive from confined commands: its files cannot be read or
316
+ * exfiltrated and its executables cannot be launched through interop —
317
+ * the hole that lets a "sandboxed" command reach your full Windows token.
318
+ * A narrowing, not a closure (a command can still write an executable
319
+ * into the workspace and run it — binfmt dispatches on content, not
320
+ * location), so enforcement stays `partial` and the sandbox fact reports
321
+ * `windowsDrive: "masked"`. Costs: confined commands cannot read or touch
322
+ * anything under `/mnt`, and tools that probe the drive degrade. The
323
+ * complete closure is distro-level: `[interop] enabled=false` in
324
+ * `wsl.conf`. The mask covers the COMMAND path only; the file tools'
325
+ * read side still reaches `/mnt` through the shared read agent.
326
+ */
298
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">;
299
351
  /**
300
352
  * Extra directories under `workspace-write`, in distro spelling. The
301
353
  * plugin grants them together with the workspace, so toolchain caches
@@ -352,35 +404,39 @@ export declare class WslShellExecutor extends LocalBashExecutor {
352
404
  resolvedShells: Map<string, string>;
353
405
  /** Cached distro-user home, the workdir when `cwd` is empty. */
354
406
  resolvedHome: string | undefined;
355
- /** Per-distro homes, so two concurrent distros cannot share one. */
356
- resolvedHomes: Map<string, string>;
407
+ /** Shared per-provider bookkeeping (homes, session runtimes, preflight caches). */
408
+ runtimeBook: ProviderRuntimeBook;
357
409
  /** The default mode — the capability fact the tool layer reads. */
358
410
  mode: SandboxMode | undefined;
359
411
  /** The distro-side confinement, or nothing when the operator opted out. */
360
412
  sandbox: InstanceType<typeof WslSandbox> | undefined;
361
413
  /** The session-runtime registry; tests substitute it. */
362
414
  sessionRuntimes: SessionRuntimes;
363
- /** The runtimes this executor holds, by registry key. */
364
- sessionRuntimeEntries: Map<string, SessionRuntimeEntry>;
365
415
  /** Isolates calls that have no session identity. */
366
416
  sessionRuntimeOwner: string;
367
417
  /** The preflight's host runner; tests substitute it. */
368
418
  sessionScopeProbe: (argv: string[]) => Promise<string>;
369
419
  /** The one-time writable-root check's runner; tests substitute it. */
370
420
  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
- }>;
421
+ /** The socket-facts probe's runner; tests substitute it. */
422
+ socketIsolationProbe: (argv: string[]) => Promise<string>;
378
423
  /**
379
424
  * Per-process confinement facts retained until settlement. Overlapping calls
380
425
  * can carry different policies, so a shared latest-wrap value would classify
381
426
  * a process against the wrong facts. Unconfined processes have no entry.
382
427
  */
383
428
  processFacts: Map<ShellExecution, ProcessFacts>;
429
+ /**
430
+ * Per-distro homes, delegated to the shared runtime book: `provider-common`'s
431
+ * `distroHome` reads this view, and tests pin the cache through it.
432
+ */
433
+ get resolvedHomes(): Map<string, string>;
434
+ /**
435
+ * The row's config without the peer's volatile wrapper. The schema validates
436
+ * the plain shape; the wrapper only widens the type, so one accessor states
437
+ * the cast instead of every method repeating it.
438
+ */
439
+ private get wslConfig();
384
440
  /**
385
441
  * @param ctx - the composition context.
386
442
  * @param config - the validated plugin config.
@@ -467,7 +523,7 @@ export declare class WslShellExecutor extends LocalBashExecutor {
467
523
  mode: string;
468
524
  workspaceRoot: string;
469
525
  sessionId?: string;
470
- } | 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;
471
527
  /**
472
528
  * Run the session runtime's preflight once per executor. A failure is a
473
529
  * configuration verdict, not an agent outage: it is raised as an Error with
@@ -653,6 +709,19 @@ export declare class WslShellExecutor extends LocalBashExecutor {
653
709
  * @throws {SandboxInvalidRootError} when an entry cannot be granted or checked.
654
710
  */
655
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[]>;
656
725
  /**
657
726
  * Execute one resolved spec inside the distro, confined by the per-call policy
658
727
  * when there is one.
@@ -690,7 +759,7 @@ export declare class WslShellExecutor extends LocalBashExecutor {
690
759
  * @param shell - the resolved distro shell.
691
760
  * @returns the decorated execution result.
692
761
  */
693
- 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>;
694
763
  /**
695
764
  * The pre-agent execution path, verbatim: one `wsl.exe` per command through
696
765
  * the inherited `executeArgv` machinery. Kept as the permanent fallback for
@@ -701,7 +770,7 @@ export declare class WslShellExecutor extends LocalBashExecutor {
701
770
  * @param shell - the resolved distro shell.
702
771
  * @returns the decorated execution result.
703
772
  */
704
- 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>;
705
774
  /**
706
775
  * The confined one-shot's argv prepare: confine the distro argv under the
707
776
  * policy, keep the resulting profile for the fact-stamper and the settlement