dsh-plugin-wsl-env 0.26.3-rc.0 → 0.26.4

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 (48) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/CONTRIBUTING.md +25 -21
  3. package/SUPPORT.md +2 -2
  4. package/SUPPORT.zh.md +2 -2
  5. package/docs/AGENT-PROTOCOL-V7.md +4 -2
  6. package/docs/API.md +1 -0
  7. package/docs/API.zh.md +1 -0
  8. package/docs/CONFIGURATION.md +21 -5
  9. package/docs/CONFIGURATION.zh.md +17 -3
  10. package/docs/MIGRATION.md +1 -1
  11. package/docs/MIGRATION.zh.md +1 -1
  12. package/docs/PARITY.md +3 -1
  13. package/docs/RELEASING.md +25 -3
  14. package/docs/REQUIREMENTS.zh.md +4 -4
  15. package/docs/ROADMAP-1.0.md +11 -7
  16. package/lib/agent.d.ts +54 -18
  17. package/lib/agent.js +86 -19
  18. package/lib/fs-routing.d.ts +3 -0
  19. package/lib/fs-routing.js +5 -0
  20. package/lib/fs-substrate.d.ts +1 -1
  21. package/lib/fs-substrate.js +10 -18
  22. package/lib/fsio-agent.d.ts +4 -0
  23. package/lib/fsio-agent.js +37 -10
  24. package/lib/listing.d.ts +2 -2
  25. package/lib/listing.js +5 -4
  26. package/lib/messages.d.ts +70 -0
  27. package/lib/messages.js +80 -0
  28. package/lib/open-in-app.js +12 -9
  29. package/lib/picker.d.ts +4 -1
  30. package/lib/picker.js +35 -11
  31. package/lib/ports.js +8 -1
  32. package/lib/provider-common.d.ts +22 -0
  33. package/lib/provider-common.js +18 -0
  34. package/lib/provider-marker.d.ts +23 -0
  35. package/lib/provider-marker.js +21 -0
  36. package/lib/status.js +8 -5
  37. package/lib/subprocess.d.ts +3 -0
  38. package/lib/subprocess.js +5 -0
  39. package/lib/takeover-report.js +4 -11
  40. package/lib/watcher.d.ts +1 -1
  41. package/lib/watcher.js +1 -1
  42. package/lib/wsl-doctor-command.d.ts +6 -2
  43. package/lib/wsl-doctor-command.js +24 -15
  44. package/lib/wsl-filesystem.d.ts +14 -11
  45. package/lib/wsl-filesystem.js +39 -27
  46. package/lib/wsl-shell.d.ts +42 -37
  47. package/lib/wsl-shell.js +53 -42
  48. package/package.json +1 -1
@@ -34,6 +34,7 @@ import { distroOfUnc } from "./distro-route.js";
34
34
  import { withHostPeerVersions } from "./peer-versions.js";
35
35
  import { digestReport, renderDigest, SECTIONS } from "./wsl-doctor-tool.js";
36
36
  import { mergeAutoPresetSeam } from "./doctor-live.js";
37
+ import { installMessagesLocale, t } from "./messages.js";
37
38
  import { mergeTakeoverReport, takeoverSnapshot } from "./takeover-report.js";
38
39
  export const name = "wsl-doctor-command";
39
40
  /**
@@ -65,9 +66,14 @@ export const DOCTOR_CLI_TIMEOUT_MS = 120_000;
65
66
  export const DOCTOR_CLI_SWEEP_TIMEOUT_MS = 60_000;
66
67
  /** The doctor CLI this row spawns, resolved from the built module's package root. */
67
68
  export const DOCTOR_SCRIPT = resolve(dirname(fileURLToPath(import.meta.url)), "..", "scripts", "doctor.mjs");
68
- /** The usage text a grammar violation settles with. */
69
- export const USAGE = "用法:/wsl-doctor [quick|full|<section>] [--distro <名称>]\n" +
70
- "section ∈ " + SECTIONS.join(" | ") + ";空输入等价 quick。省略 --distro 时用当前会话的工作目录推断 distro。";
69
+ /**
70
+ * The usage text a grammar violation settles with.
71
+ *
72
+ * @returns the usage block in the active catalog language.
73
+ */
74
+ export function doctorUsage() {
75
+ return t("doctorUsage", { sections: SECTIONS.join(" | ") });
76
+ }
71
77
  /**
72
78
  * Parse the raw input after the command name. Tokens: one mode word or
73
79
  * section name, plus an optional `--distro <name>` / `--distro=<name>`; a
@@ -108,10 +114,10 @@ export function parseDoctorInput(rawInput) {
108
114
  parsed.distro = token;
109
115
  continue;
110
116
  }
111
- throw new Error(`无法识别的参数:${token}`);
117
+ throw new Error(t("doctorUnknownToken", { token }));
112
118
  }
113
119
  if (expectingDistro)
114
- throw new Error("--distro 需要一个名称");
120
+ throw new Error(t("doctorDistroNeedsName", {}));
115
121
  return parsed;
116
122
  }
117
123
  /**
@@ -165,7 +171,7 @@ export function runDoctorCli(argv, signal, timeoutMs = DOCTOR_CLI_TIMEOUT_MS) {
165
171
  child.on("error", (error) => {
166
172
  // An abort arrives here as an AbortError; normalize it so the settled
167
173
  // message names the run rather than the DOMException.
168
- settle(() => rejectPromise(error.name === "AbortError" ? new Error("doctor CLI 已取消") : error));
174
+ settle(() => rejectPromise(error.name === "AbortError" ? new Error(t("doctorCliCancelled", {})) : error));
169
175
  });
170
176
  child.on("close", (code, signalName) => {
171
177
  const text = stdout.trim();
@@ -174,10 +180,13 @@ export function runDoctorCli(argv, signal, timeoutMs = DOCTOR_CLI_TIMEOUT_MS) {
174
180
  return;
175
181
  }
176
182
  if (timedOut) {
177
- settle(() => rejectPromise(new Error(`doctor CLI 在 ${timeoutMs / 1000} 秒内没有给出报告;用 --distro <名称> 收窄到单个发行版,或改用 quick / <分区> 重试`)));
183
+ settle(() => rejectPromise(new Error(t("doctorCliTimeout", { seconds: timeoutMs / 1000 }))));
178
184
  return;
179
185
  }
180
- settle(() => rejectPromise(new Error(`doctor CLI 未能给出报告(exit ${code ?? signalName ?? "signal"})${stderr.trim().length > 0 ? `:${stderr.trim().slice(0, 400)}` : ""}`)));
186
+ settle(() => rejectPromise(new Error(t("doctorCliNoReport", {
187
+ status: String(code ?? signalName ?? "signal"),
188
+ detail: stderr.trim().length > 0 ? `: ${stderr.trim().slice(0, 400)}` : "",
189
+ }))));
181
190
  });
182
191
  });
183
192
  }
@@ -329,6 +338,8 @@ export function formatDoctorReport(json, distro, providers = []) {
329
338
  * registry and the harness cwd service are reachable).
330
339
  */
331
340
  export async function apply(ctx) {
341
+ // The test seam is structural; production hands the row a cordis Context.
342
+ installMessagesLocale(ctx);
332
343
  const commands = resolveCommands(ctx);
333
344
  // No command adapter: nothing to register, nothing to fail. The doctor CLI
334
345
  // (`pnpm run doctor`) stays the surface for headless deployments.
@@ -350,15 +361,15 @@ export async function apply(ctx) {
350
361
  })();
351
362
  commands.register({
352
363
  name: "wsl-doctor",
353
- description: "运行 WSL 环境诊断(独立 doctor CLI):结果直接显示在此,不进入模型对话。省略参数为快速诊断。",
354
- input: { hint: "[quick|full|<section>] [--distro <名称>]" },
364
+ description: t("doctorCommandDescription", {}),
365
+ input: { hint: t("doctorInputHint", {}) },
355
366
  handler: async (invocation) => {
356
367
  let parsed;
357
368
  try {
358
369
  parsed = parseDoctorInput(invocation.rawInput);
359
370
  }
360
371
  catch (error) {
361
- return { kind: "error", text: `${error instanceof Error ? error.message : String(error)}\n\n${USAGE}` };
372
+ return { kind: "error", text: `${error instanceof Error ? error.message : String(error)}\n\n${doctorUsage()}` };
362
373
  }
363
374
  const distro = await resolveDistro(ctx, invocation, parsed.distro);
364
375
  const argv = ["--json"];
@@ -377,10 +388,8 @@ export async function apply(ctx) {
377
388
  return { kind: "success", text: formatDoctorReport(json, distro, takeoverSnapshot(ctx)) };
378
389
  }
379
390
  catch (error) {
380
- const target = distro.length > 0
381
- ? `发行版 ${distro}`
382
- : "配置指定的目标(未从会话工作目录解析出发行版,auto 会逐个检查所有已安装发行版)";
383
- return { kind: "error", text: `doctor 运行失败(${target}):${error instanceof Error ? error.message : String(error)}` };
391
+ const target = distro.length > 0 ? t("doctorTargetDistro", { distro }) : t("doctorTargetConfigured", {});
392
+ return { kind: "error", text: t("doctorRunFailed", { target, message: error instanceof Error ? error.message : String(error) }) };
384
393
  }
385
394
  },
386
395
  });
@@ -9,6 +9,7 @@ import type { SessionRuntimeEntry } from "./session-runtime.js";
9
9
  import type { Context } from "@deepseek-ai/cordis";
10
10
  import type { FileSystem, FsDeleteOutcome, FsDirEntry, FsEditOutcome, FsEditRequest, FsInfo, FsMoveOutcome, FsPathInfo, FsTarget, FsVersion, FsWriteIntent, FsWriteOutcome } from "@deepseek-ai/dsh-fs";
11
11
  import type { SandboxExecutionPolicy, SandboxMode } from "@deepseek-ai/dsh-sandbox";
12
+ import { ProviderRuntimeBook } from "./provider-common.js";
12
13
  type PatchHunks = Parameters<FileSystem["patchText"]>[1];
13
14
  type MoveFileOptions = Parameters<FileSystem["moveFile"]>[2];
14
15
  /**
@@ -246,8 +247,8 @@ export declare class WslFileSystem extends LocalFileSystem {
246
247
  resolvedDistro: string;
247
248
  /** Cached distro-user home, the base for relative input when `cwd` is empty. */
248
249
  resolvedHome: string | undefined;
249
- /** Per-distro homes, so two concurrent distros cannot share one. */
250
- resolvedHomes: Map<string, string>;
250
+ /** Shared per-provider bookkeeping (homes, session runtimes, preflight caches). */
251
+ runtimeBook: ProviderRuntimeBook;
251
252
  /** The deployment default mode — the capability fact the tool layer reads. */
252
253
  defaultMode: SandboxMode;
253
254
  /** The lazy default-distro substrate, kept for the legacy accessor and tests. */
@@ -262,21 +263,23 @@ export declare class WslFileSystem extends LocalFileSystem {
262
263
  agentInstances: Map<string, WslAgent>;
263
264
  /** The session-runtime registry; tests substitute it. */
264
265
  sessionRuntimes: SessionRuntimes;
265
- /** The runtimes this provider holds, by registry key. */
266
- sessionRuntimeEntries: Map<string, SessionRuntimeEntry>;
267
266
  /** Isolates calls that have no session identity. */
268
267
  sessionRuntimeOwner: string;
269
268
  /** The preflight's host runner; tests substitute it. */
270
269
  sessionScopeProbe: (argv: string[]) => Promise<string>;
271
270
  /** The one-time writable-root check's runner; tests substitute it. */
272
271
  writableRootsProbe: (argv: string[]) => Promise<string>;
273
- /** Distros whose session-runtime preflight has succeeded. */
274
- sessionRuntimePreflight: Set<string>;
275
- /** Per-distro `auto` verdicts, re-probed when they were negative and stale. */
276
- autoSessionScope: Map<string, {
277
- usable: boolean;
278
- checkedAt: number;
279
- }>;
272
+ /**
273
+ * Per-distro homes, delegated to the shared runtime book: `provider-common`'s
274
+ * `distroHome` reads this view, and tests pin the cache through it.
275
+ */
276
+ get resolvedHomes(): Map<string, string>;
277
+ /**
278
+ * The row's config without the peer's volatile wrapper. The schema validates
279
+ * the plain shape; the wrapper only widens the type, so one accessor states
280
+ * the cast instead of every method repeating it.
281
+ */
282
+ private get wslConfig();
280
283
  /**
281
284
  * @param ctx - the composition context.
282
285
  * @param config - the validated plugin config.
@@ -18,7 +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 { distroHome, effectiveWritableRoots, resolveOperationDistro, sessionRuntimeWanted, wslWritableRoots } from "./provider-common.js";
21
+ import { ProviderRuntimeBook, distroHome, effectiveWritableRoots, resolveOperationDistro, sessionRuntimeWanted, wslWritableRoots } from "./provider-common.js";
22
22
  /**
23
23
  * Filesystem backend over a WSL distro's UNC share.
24
24
  *
@@ -131,6 +131,21 @@ export class WslFileSystem extends LocalFileSystem {
131
131
  */
132
132
  substrate: z.union(["share", "agent"]).default("agent"),
133
133
  });
134
+ /**
135
+ * Per-distro homes, delegated to the shared runtime book: `provider-common`'s
136
+ * `distroHome` reads this view, and tests pin the cache through it.
137
+ */
138
+ get resolvedHomes() {
139
+ return this.runtimeBook.homes;
140
+ }
141
+ /**
142
+ * The row's config without the peer's volatile wrapper. The schema validates
143
+ * the plain shape; the wrapper only widens the type, so one accessor states
144
+ * the cast instead of every method repeating it.
145
+ */
146
+ get wslConfig() {
147
+ return this.config;
148
+ }
134
149
  /**
135
150
  * @param ctx - the composition context.
136
151
  * @param config - the validated plugin config.
@@ -147,7 +162,7 @@ export class WslFileSystem extends LocalFileSystem {
147
162
  installMessagesLocale(ctx);
148
163
  this.resolvedDistro = pinnedDistro(config.distro) ?? "";
149
164
  this.resolvedHome = undefined;
150
- this.resolvedHomes = new Map();
165
+ this.runtimeBook = new ProviderRuntimeBook();
151
166
  this.defaultMode = ctx.sandboxPolicy.defaultMode;
152
167
  this.agentSubstrateInstance = undefined;
153
168
  this.agentSubstrates = new Map();
@@ -155,12 +170,9 @@ export class WslFileSystem extends LocalFileSystem {
155
170
  this.agentInstance = undefined;
156
171
  this.agentInstances = new Map();
157
172
  this.sessionRuntimes = sessionRuntimes;
158
- this.sessionRuntimeEntries = new Map();
159
173
  this.sessionRuntimeOwner = randomUUID();
160
174
  this.sessionScopeProbe = (argv) => runCapture(argv);
161
175
  this.writableRootsProbe = (argv) => runCapture(argv);
162
- this.sessionRuntimePreflight = new Set();
163
- this.autoSessionScope = new Map();
164
176
  // The preset's disposer releases the runtime; the shell executor's effect
165
177
  // releases its own reference, so the scope stops after the last one.
166
178
  ctx.effect(() => () => this.disposeSessionRuntimes().catch(() => { }), "wsl fs session runtimes");
@@ -174,7 +186,7 @@ export class WslFileSystem extends LocalFileSystem {
174
186
  * @returns the deployment default mode, or `undefined` when unfenced.
175
187
  */
176
188
  get sandboxMode() {
177
- const config = this.config;
189
+ const config = this.wslConfig;
178
190
  return config.sandbox ? this.defaultMode : undefined;
179
191
  }
180
192
  /**
@@ -214,7 +226,7 @@ export class WslFileSystem extends LocalFileSystem {
214
226
  * @returns the substrate.
215
227
  */
216
228
  async agentSubstrate() {
217
- const config = this.config;
229
+ const config = this.wslConfig;
218
230
  if (this.agentSubstrateInstance === undefined) {
219
231
  this.agentSubstrateInstance = new AgentSubstrate({
220
232
  agent: await this.publicationAgent(),
@@ -240,7 +252,7 @@ export class WslFileSystem extends LocalFileSystem {
240
252
  const cached = this.agentSubstrates.get(distro);
241
253
  if (cached !== undefined)
242
254
  return cached;
243
- const config = this.config;
255
+ const config = this.wslConfig;
244
256
  const substrate = new AgentSubstrate({
245
257
  agent: await this.publicationAgentFor(distro),
246
258
  distro,
@@ -271,7 +283,7 @@ export class WslFileSystem extends LocalFileSystem {
271
283
  * @throws {SandboxInvalidRootError} when an entry cannot be granted or checked.
272
284
  */
273
285
  async writableRootsFor(distro, policy, check = true) {
274
- const config = this.config;
286
+ const config = this.wslConfig;
275
287
  if (!config.sandbox || policy === undefined || policy.mode !== "workspace-write")
276
288
  return [];
277
289
  if ((config.writableRoots?.length ?? 0) === 0 && (policy.additionalWritableRoots?.length ?? 0) === 0)
@@ -304,13 +316,13 @@ export class WslFileSystem extends LocalFileSystem {
304
316
  * @returns the runtime entry, or undefined when the mode is off.
305
317
  */
306
318
  sessionRuntimeFor(policy, distro, writableRoots = []) {
307
- const config = this.config;
319
+ const config = this.wslConfig;
308
320
  if (!config.sessionSandbox)
309
321
  return undefined;
310
322
  const workspaceRoot = policy.workspaceRoot || config.cwd;
311
323
  const sessionId = policy.sessionId || this.sessionRuntimeOwner;
312
324
  const key = SessionRuntimes.key({ sessionId, distro, workspaceRoot, mode: policy.mode, maskWindowsDrive: config.maskWindowsDrive, writableRoots });
313
- const held = this.sessionRuntimeEntries.get(key);
325
+ const held = this.runtimeBook.sessionRuntimeEntries.get(key);
314
326
  if (held !== undefined)
315
327
  return held;
316
328
  const entry = this.sessionRuntimes.acquire({
@@ -322,7 +334,7 @@ export class WslFileSystem extends LocalFileSystem {
322
334
  maskWindowsDrive: config.maskWindowsDrive,
323
335
  writableRoots,
324
336
  });
325
- this.sessionRuntimeEntries.set(key, entry);
337
+ this.runtimeBook.sessionRuntimeEntries.set(key, entry);
326
338
  return entry;
327
339
  }
328
340
  /**
@@ -334,14 +346,14 @@ export class WslFileSystem extends LocalFileSystem {
334
346
  * @throws {Error} with the remedy when it cannot.
335
347
  */
336
348
  async ensureSessionRuntimeUsable(distro) {
337
- if (this.sessionRuntimePreflight.has(distro))
349
+ if (this.runtimeBook.sessionRuntimePreflight.has(distro))
338
350
  return;
339
- const config = this.config;
351
+ const config = this.wslConfig;
340
352
  const problem = await probeSessionRuntime({ wslPath: config.wslPath, distro, run: this.sessionScopeProbe });
341
353
  if (problem !== null)
342
354
  throw new Error(problem);
343
355
  await ensureNativeSessionAgent({ wslPath: config.wslPath, distro, setNative: setSessionNativeAgent });
344
- this.sessionRuntimePreflight.add(distro);
356
+ this.runtimeBook.sessionRuntimePreflight.add(distro);
345
357
  }
346
358
  /**
347
359
  * Whether this provider should use the session runtime for one distro, with
@@ -352,8 +364,8 @@ export class WslFileSystem extends LocalFileSystem {
352
364
  * @returns whether to acquire the per-session scope.
353
365
  */
354
366
  async wantsSessionRuntime(distro) {
355
- const config = this.config;
356
- return sessionRuntimeWanted(config.sessionSandbox, distro, () => this.ensureSessionRuntimeUsable(distro), this.autoSessionScope);
367
+ const config = this.wslConfig;
368
+ return sessionRuntimeWanted(config.sessionSandbox, distro, () => this.ensureSessionRuntimeUsable(distro), this.runtimeBook.autoSessionScope);
357
369
  }
358
370
  /**
359
371
  * Release every runtime this provider holds. Called from the preset's
@@ -362,8 +374,8 @@ export class WslFileSystem extends LocalFileSystem {
362
374
  * @returns resolved once every reference is released.
363
375
  */
364
376
  async disposeSessionRuntimes() {
365
- const entries = [...this.sessionRuntimeEntries.values()];
366
- this.sessionRuntimeEntries.clear();
377
+ const entries = [...this.runtimeBook.sessionRuntimeEntries.values()];
378
+ this.runtimeBook.sessionRuntimeEntries.clear();
367
379
  for (const entry of entries)
368
380
  await this.sessionRuntimes.release(entry.key);
369
381
  }
@@ -383,7 +395,7 @@ export class WslFileSystem extends LocalFileSystem {
383
395
  * @returns the agent to publish through.
384
396
  */
385
397
  async mutationAgent(policy, forDistro) {
386
- const config = this.config;
398
+ const config = this.wslConfig;
387
399
  const distro = forDistro ?? await this.distroForPolicy(policy);
388
400
  if (!isConfinedMutation({ policy, sandboxEnabled: config.sandbox })) {
389
401
  return this.publicationAgentFor(distro);
@@ -441,7 +453,7 @@ export class WslFileSystem extends LocalFileSystem {
441
453
  * @returns the distro name.
442
454
  */
443
455
  async distro() {
444
- const config = this.config;
456
+ const config = this.wslConfig;
445
457
  if (this.resolvedDistro.length === 0)
446
458
  this.resolvedDistro = await defaultDistro({ wslPath: config.wslPath });
447
459
  return this.resolvedDistro;
@@ -456,7 +468,7 @@ export class WslFileSystem extends LocalFileSystem {
456
468
  * @returns the distro name.
457
469
  */
458
470
  async distroForPath(path, cwd) {
459
- const config = this.config;
471
+ const config = this.wslConfig;
460
472
  return resolveOperationDistro(config.distro, [path, cwd ?? config.cwd], () => this.distro());
461
473
  }
462
474
  /**
@@ -477,7 +489,7 @@ export class WslFileSystem extends LocalFileSystem {
477
489
  * @returns the distro name.
478
490
  */
479
491
  async distroForPolicy(policy) {
480
- const config = this.config;
492
+ const config = this.wslConfig;
481
493
  return resolveOperationDistro(config.distro, [policy?.workspaceRoot, config.cwd], () => this.distro());
482
494
  }
483
495
  /**
@@ -488,7 +500,7 @@ export class WslFileSystem extends LocalFileSystem {
488
500
  * @returns the host path to operate on.
489
501
  */
490
502
  async worldPath(path, cwd) {
491
- const config = this.config;
503
+ const config = this.wslConfig;
492
504
  const distro = await this.distroForPath(path, cwd);
493
505
  let base = cwd ?? config.cwd;
494
506
  if (String(base ?? "").trim().length === 0 && isRelativeWorldPath(path)) {
@@ -550,7 +562,7 @@ export class WslFileSystem extends LocalFileSystem {
550
562
  * @throws {FsError} with `FS_SANDBOX_DENIED` when the policy refuses it.
551
563
  */
552
564
  async checkedTarget(target, sandboxPolicy) {
553
- const config = this.config;
565
+ const config = this.wslConfig;
554
566
  if (!config.sandbox)
555
567
  return target;
556
568
  const policy = sandboxPolicy ?? this.ctx.sandboxPolicy.resolve();
@@ -715,7 +727,7 @@ export class WslFileSystem extends LocalFileSystem {
715
727
  * mapped with what is already known.
716
728
  */
717
729
  processPathFromHostPath(hostPath) {
718
- const config = this.config;
730
+ const config = this.wslConfig;
719
731
  const choice = selectDistro({
720
732
  configured: config.distro,
721
733
  candidates: [hostPath, config.cwd],
@@ -752,7 +764,7 @@ export class WslFileSystem extends LocalFileSystem {
752
764
  */
753
765
  async watch(target, changed, signal) {
754
766
  signal.throwIfAborted();
755
- const config = this.config;
767
+ const config = this.wslConfig;
756
768
  const parsed = uncToPosix(target.targetKey);
757
769
  if (parsed === undefined) {
758
770
  throw new FsError(`cannot watch "${target.displayPath}": not a path inside the distro`, "FS_IO_ERROR");
@@ -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 { ProviderRuntimeBook } from "./provider-common.js";
8
9
  import type { Context } from "@deepseek-ai/cordis";
9
10
  import type { SandboxExecutionPolicy, SandboxMode } from "@deepseek-ai/dsh-sandbox";
10
11
  import type { SubprocessSpawnSpec } from "@deepseek-ai/dsh-subprocess";
@@ -151,19 +152,6 @@ export declare class WslShellExecutor extends LocalBashExecutor {
151
152
  * unconfined and `sandboxMode` is `undefined`, so the model is told so.
152
153
  */
153
154
  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
155
  /**
168
156
  * The interop stance in one key (WSL-314), expanding to the per-key
169
157
  * values the measured matrix documents:
@@ -184,6 +172,20 @@ export declare class WslShellExecutor extends LocalBashExecutor {
184
172
  * boolean answer); the boolean remains for existing profiles.
185
173
  */
186
174
  interopVisibility: z<"masked" | "visible" | "disabled", "masked" | "visible" | "disabled", "plain">;
175
+ /**
176
+ * Shadow `/mnt` with an empty tmpfs in every confined profile, hiding the
177
+ * Windows drive from confined commands: its files cannot be read or
178
+ * exfiltrated and its executables cannot be launched through interop —
179
+ * the hole that lets a "sandboxed" command reach your full Windows token.
180
+ * A narrowing, not a closure (a command can still write an executable
181
+ * into the workspace and run it — binfmt dispatches on content, not
182
+ * location), so enforcement stays `partial` and the sandbox fact reports
183
+ * `windowsDrive: "masked"`. Costs: confined commands cannot read or touch
184
+ * anything under `/mnt`, and tools that probe the drive degrade. The
185
+ * complete closure is distro-level: `[interop] enabled=false` in
186
+ * `wsl.conf`. The mask covers the COMMAND path only; the file tools'
187
+ * read side still reaches `/mnt` through the shared read agent.
188
+ */
187
189
  maskWindowsDrive: z<boolean, boolean, "defined">;
188
190
  /**
189
191
  * Extra directories under `workspace-write`, in distro spelling. The
@@ -262,19 +264,6 @@ export declare class WslShellExecutor extends LocalBashExecutor {
262
264
  * unconfined and `sandboxMode` is `undefined`, so the model is told so.
263
265
  */
264
266
  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
267
  /**
279
268
  * The interop stance in one key (WSL-314), expanding to the per-key
280
269
  * values the measured matrix documents:
@@ -295,6 +284,20 @@ export declare class WslShellExecutor extends LocalBashExecutor {
295
284
  * boolean answer); the boolean remains for existing profiles.
296
285
  */
297
286
  interopVisibility: z<"masked" | "visible" | "disabled", "masked" | "visible" | "disabled", "plain">;
287
+ /**
288
+ * Shadow `/mnt` with an empty tmpfs in every confined profile, hiding the
289
+ * Windows drive from confined commands: its files cannot be read or
290
+ * exfiltrated and its executables cannot be launched through interop —
291
+ * the hole that lets a "sandboxed" command reach your full Windows token.
292
+ * A narrowing, not a closure (a command can still write an executable
293
+ * into the workspace and run it — binfmt dispatches on content, not
294
+ * location), so enforcement stays `partial` and the sandbox fact reports
295
+ * `windowsDrive: "masked"`. Costs: confined commands cannot read or touch
296
+ * anything under `/mnt`, and tools that probe the drive degrade. The
297
+ * complete closure is distro-level: `[interop] enabled=false` in
298
+ * `wsl.conf`. The mask covers the COMMAND path only; the file tools'
299
+ * read side still reaches `/mnt` through the shared read agent.
300
+ */
298
301
  maskWindowsDrive: z<boolean, boolean, "defined">;
299
302
  /**
300
303
  * Extra directories under `workspace-write`, in distro spelling. The
@@ -352,35 +355,37 @@ export declare class WslShellExecutor extends LocalBashExecutor {
352
355
  resolvedShells: Map<string, string>;
353
356
  /** Cached distro-user home, the workdir when `cwd` is empty. */
354
357
  resolvedHome: string | undefined;
355
- /** Per-distro homes, so two concurrent distros cannot share one. */
356
- resolvedHomes: Map<string, string>;
358
+ /** Shared per-provider bookkeeping (homes, session runtimes, preflight caches). */
359
+ runtimeBook: ProviderRuntimeBook;
357
360
  /** The default mode — the capability fact the tool layer reads. */
358
361
  mode: SandboxMode | undefined;
359
362
  /** The distro-side confinement, or nothing when the operator opted out. */
360
363
  sandbox: InstanceType<typeof WslSandbox> | undefined;
361
364
  /** The session-runtime registry; tests substitute it. */
362
365
  sessionRuntimes: SessionRuntimes;
363
- /** The runtimes this executor holds, by registry key. */
364
- sessionRuntimeEntries: Map<string, SessionRuntimeEntry>;
365
366
  /** Isolates calls that have no session identity. */
366
367
  sessionRuntimeOwner: string;
367
368
  /** The preflight's host runner; tests substitute it. */
368
369
  sessionScopeProbe: (argv: string[]) => Promise<string>;
369
370
  /** The one-time writable-root check's runner; tests substitute it. */
370
371
  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
372
  /**
379
373
  * Per-process confinement facts retained until settlement. Overlapping calls
380
374
  * can carry different policies, so a shared latest-wrap value would classify
381
375
  * a process against the wrong facts. Unconfined processes have no entry.
382
376
  */
383
377
  processFacts: Map<ShellExecution, ProcessFacts>;
378
+ /**
379
+ * Per-distro homes, delegated to the shared runtime book: `provider-common`'s
380
+ * `distroHome` reads this view, and tests pin the cache through it.
381
+ */
382
+ get resolvedHomes(): Map<string, string>;
383
+ /**
384
+ * The row's config without the peer's volatile wrapper. The schema validates
385
+ * the plain shape; the wrapper only widens the type, so one accessor states
386
+ * the cast instead of every method repeating it.
387
+ */
388
+ private get wslConfig();
384
389
  /**
385
390
  * @param ctx - the composition context.
386
391
  * @param config - the validated plugin config.