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
@@ -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, and the harness has no HMR, so
14
- * even a correct swap needs a restart to take effect.
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,6 +30,8 @@
29
30
  import z from "@deepseek-ai/schemastery";
30
31
  import type { Context } from "@deepseek-ai/cordis";
31
32
  export declare const name = "wsl-update-check";
33
+ /** The checked package: this plugin, by its npm name. */
34
+ export declare const PACKAGE = "dsh-plugin-wsl-env";
32
35
  /** The interval the row ships with. */
33
36
  export declare const DEFAULT_INTERVAL_MS: number;
34
37
  /** The smallest interval a config may ask for; one check spawns `pnpm view` in the profile. */
@@ -52,7 +55,7 @@ interface UpdateCheckConfig {
52
55
  intervalMs?: number;
53
56
  }
54
57
  /** One published version, reduced to what the fact reads (host plugin-manager types). */
55
- interface ListedVersion {
58
+ export interface ListedVersion {
56
59
  readonly version: string;
57
60
  readonly publishedAt?: string;
58
61
  readonly tags: readonly string[];
@@ -71,7 +74,7 @@ interface ListedVersion {
71
74
  export type VersionList = {
72
75
  readonly status: "listed";
73
76
  readonly installed: string;
74
- readonly registry: string;
77
+ readonly registry: string | null;
75
78
  readonly attempts: readonly unknown[];
76
79
  /** Published versions newer than `installed`, newest first. */
77
80
  readonly versions: readonly ListedVersion[];
@@ -82,6 +85,33 @@ export type VersionList = {
82
85
  readonly reason: string;
83
86
  readonly attempts: readonly unknown[];
84
87
  };
88
+ /** Why a check could not produce a version list. */
89
+ export type VersionProblem = "no-manager" | Extract<VersionList, {
90
+ status: "refused";
91
+ }>["problem"];
92
+ /**
93
+ * What one version check learned, for the panel's version card. Unlike
94
+ * {@link UpdateFact}, this keeps the "up to date" answer and the reasons a
95
+ * check learned nothing, so the panel can say which of the three happened.
96
+ */
97
+ export type VersionCheck = {
98
+ readonly status: "available";
99
+ readonly installed: string;
100
+ readonly checkedAt: number;
101
+ readonly registry: string | null;
102
+ readonly latest: ListedVersion;
103
+ } | {
104
+ readonly status: "current";
105
+ readonly installed: string;
106
+ readonly checkedAt: number;
107
+ readonly registry: string | null;
108
+ } | {
109
+ readonly status: "unavailable";
110
+ readonly installed: string;
111
+ readonly checkedAt: number;
112
+ readonly problem: VersionProblem;
113
+ readonly reason: string;
114
+ };
85
115
  /**
86
116
  * The slice of the host's plugin-manager this row calls. The service belongs
87
117
  * to the harness and its declaration is not visible to this plugin, so it is
@@ -155,12 +185,22 @@ export declare function updateTarget(list: Extract<VersionList, {
155
185
  status: "listed";
156
186
  }>): ListedVersion | undefined;
157
187
  /**
158
- * Run one check against the host's plugin-manager and publish the fact.
188
+ * Run one version check and publish (or clear) the shell-environment fact.
159
189
  *
160
- * Every non-answer is quiet by design: a missing manager, a linked checkout
161
- * (`not-updatable`), a registry the host cannot reach (`network`), or a stable
162
- * channel that has not moved all leave the previous fact (or none) standing —
163
- * an update check must never become the noisiest thing in the app.
190
+ * The fact is the only observable for the periodic check, so the three
191
+ * outcomes are handled together: an available target publishes it, an
192
+ * up-to-date list clears a stale one, and a non-answer (no manager, a refused
193
+ * list, a throwing service) leaves the previous fact standing. A check must
194
+ * never become the noisiest thing in the app, so none of these throws.
195
+ *
196
+ * @param manager - the host plugin-manager, or undefined when the host has none.
197
+ * @param installed - the installed version to name when the host has no manager.
198
+ * @param now - the check's timestamp, injectable for tests.
199
+ * @returns what the check learned.
200
+ */
201
+ export declare function inspectVersions(manager: PluginManagerSlice | undefined, installed: string, now?: number): Promise<VersionCheck>;
202
+ /**
203
+ * Run one check against the host's plugin-manager and publish the fact.
164
204
  *
165
205
  * @param manager - the host plugin-manager, or undefined when the host has none.
166
206
  * @returns the published fact, or undefined when the check learned nothing.
@@ -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, and the harness has no HMR, so
14
- * even a correct swap needs a restart to take effect.
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 against the host's plugin-manager and publish the fact.
108
+ * Run one version check and publish (or clear) the shell-environment fact.
108
109
  *
109
- * Every non-answer is quiet by design: a missing manager, a linked checkout
110
- * (`not-updatable`), a registry the host cannot reach (`network`), or a stable
111
- * channel that has not moved all leave the previous fact (or none) standing —
112
- * an update check must never become the noisiest thing in the app.
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
- * @returns the published fact, or undefined when the check learned nothing.
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 checkForUpdate(manager) {
118
- if (manager === undefined)
119
- return undefined;
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 undefined;
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 === undefined) {
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 undefined;
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
- const next = {
137
- installed: list.installed,
138
- latest: target.version,
139
- ...(target.publishedAt === undefined ? {} : { publishedAt: target.publishedAt }),
140
- incompatible: target.incompatible !== undefined,
141
- ...(target.deprecated === undefined ? {} : { deprecated: target.deprecated }),
142
- checkedAt: Date.now(),
143
- };
144
- setUpdateFact(next);
145
- return next;
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/watcher.d.ts CHANGED
@@ -18,7 +18,7 @@
18
18
  * rename-over or an in-place write is seen), and a positive `maxDepth` keeps
19
19
  * the polling scan because inotify cannot bound its own walk.
20
20
  *
21
- * The loop speaks three one-letter lines, the watcher protocol:
21
+ * The loop speaks five one-letter lines, the watcher protocol:
22
22
  *
23
23
  * - `R` — READY: the activation barrier; the host resolves the watch promise
24
24
  * on it, never before.
package/lib/watcher.js CHANGED
@@ -18,7 +18,7 @@
18
18
  * rename-over or an in-place write is seen), and a positive `maxDepth` keeps
19
19
  * the polling scan because inotify cannot bound its own walk.
20
20
  *
21
- * The loop speaks three one-letter lines, the watcher protocol:
21
+ * The loop speaks five one-letter lines, the watcher protocol:
22
22
  *
23
23
  * - `R` — READY: the activation barrier; the host resolves the watch promise
24
24
  * on it, never before.
@@ -83,8 +83,12 @@ interface ParsedDoctorInput {
83
83
  }
84
84
  /** The doctor CLI this row spawns, resolved from the built module's package root. */
85
85
  export declare const DOCTOR_SCRIPT: string;
86
- /** The usage text a grammar violation settles with. */
87
- export declare const USAGE: string;
86
+ /**
87
+ * The usage text a grammar violation settles with.
88
+ *
89
+ * @returns the usage block in the active catalog language.
90
+ */
91
+ export declare function doctorUsage(): string;
88
92
  /**
89
93
  * Parse the raw input after the command name. Tokens: one mode word or
90
94
  * section name, plus an optional `--distro <name>` / `--distro=<name>`; a
@@ -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
  });
@@ -116,6 +116,8 @@ export const CHECK_CATALOG = [
116
116
  "runtime.scopes",
117
117
  "sandbox.bwrap",
118
118
  "sandbox.bwrap-usable",
119
+ "sandbox.grants",
120
+ "sandbox.isolation",
119
121
  "session.linger",
120
122
  "session.systemd",
121
123
  "session.systemd-run",
@@ -6,9 +6,11 @@ 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";
13
+ import { ProviderRuntimeBook } from "./provider-common.js";
12
14
  type PatchHunks = Parameters<FileSystem["patchText"]>[1];
13
15
  type MoveFileOptions = Parameters<FileSystem["moveFile"]>[2];
14
16
  /**
@@ -35,6 +37,8 @@ interface WslFileSystemConfig {
35
37
  sessionSandbox: boolean | "auto";
36
38
  /** Whether confined profiles mask `/mnt`. */
37
39
  maskWindowsDrive: boolean;
40
+ /** Which socket surfaces a confined resident cannot reach. */
41
+ socketIsolation: SocketIsolation;
38
42
  /** Extra distro directories granted read-write under `workspace-write`. */
39
43
  writableRoots?: string[];
40
44
  /** Whether paths leaving the distro are refused. */
@@ -120,6 +124,16 @@ export declare class WslFileSystem extends LocalFileSystem {
120
124
  * reads and the share substrate are unaffected.
121
125
  */
122
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">;
123
137
  /**
124
138
  * Extra directories under `workspace-write`, in distro spelling — the
125
139
  * same list and same rules as `wsl-shell`'s key. Confined writes bind
@@ -202,6 +216,16 @@ export declare class WslFileSystem extends LocalFileSystem {
202
216
  * reads and the share substrate are unaffected.
203
217
  */
204
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">;
205
229
  /**
206
230
  * Extra directories under `workspace-write`, in distro spelling — the
207
231
  * same list and same rules as `wsl-shell`'s key. Confined writes bind
@@ -246,8 +270,8 @@ export declare class WslFileSystem extends LocalFileSystem {
246
270
  resolvedDistro: string;
247
271
  /** Cached distro-user home, the base for relative input when `cwd` is empty. */
248
272
  resolvedHome: string | undefined;
249
- /** Per-distro homes, so two concurrent distros cannot share one. */
250
- resolvedHomes: Map<string, string>;
273
+ /** Shared per-provider bookkeeping (homes, session runtimes, preflight caches). */
274
+ runtimeBook: ProviderRuntimeBook;
251
275
  /** The deployment default mode — the capability fact the tool layer reads. */
252
276
  defaultMode: SandboxMode;
253
277
  /** The lazy default-distro substrate, kept for the legacy accessor and tests. */
@@ -262,21 +286,25 @@ export declare class WslFileSystem extends LocalFileSystem {
262
286
  agentInstances: Map<string, WslAgent>;
263
287
  /** The session-runtime registry; tests substitute it. */
264
288
  sessionRuntimes: SessionRuntimes;
265
- /** The runtimes this provider holds, by registry key. */
266
- sessionRuntimeEntries: Map<string, SessionRuntimeEntry>;
267
289
  /** Isolates calls that have no session identity. */
268
290
  sessionRuntimeOwner: string;
269
291
  /** The preflight's host runner; tests substitute it. */
270
292
  sessionScopeProbe: (argv: string[]) => Promise<string>;
271
293
  /** The one-time writable-root check's runner; tests substitute it. */
272
294
  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
- }>;
295
+ /** The socket-facts probe's runner; tests substitute it. */
296
+ socketIsolationProbe: (argv: string[]) => Promise<string>;
297
+ /**
298
+ * Per-distro homes, delegated to the shared runtime book: `provider-common`'s
299
+ * `distroHome` reads this view, and tests pin the cache through it.
300
+ */
301
+ get resolvedHomes(): Map<string, string>;
302
+ /**
303
+ * The row's config without the peer's volatile wrapper. The schema validates
304
+ * the plain shape; the wrapper only widens the type, so one accessor states
305
+ * the cast instead of every method repeating it.
306
+ */
307
+ private get wslConfig();
280
308
  /**
281
309
  * @param ctx - the composition context.
282
310
  * @param config - the validated plugin config.
@@ -347,6 +375,19 @@ export declare class WslFileSystem extends LocalFileSystem {
347
375
  workspaceRoot: string;
348
376
  additionalWritableRoots?: readonly string[];
349
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[]>;
350
391
  /**
351
392
  * The persistent session runtime for one confined mutation, when
352
393
  * `sessionSandbox` is on. The key is the shell executor's key for the same
@@ -362,7 +403,7 @@ export declare class WslFileSystem extends LocalFileSystem {
362
403
  mode: string;
363
404
  workspaceRoot: string;
364
405
  sessionId?: string;
365
- }, distro: string, writableRoots?: readonly string[]): SessionRuntimeEntry | undefined;
406
+ }, distro: string, writableRoots?: readonly string[], socketMasks?: readonly string[], maskInterop?: boolean): SessionRuntimeEntry | undefined;
366
407
  /**
367
408
  * Run the session runtime's preflight once per provider. Only success is
368
409
  * cached, so following the remedy does not need an app restart.