dsh-plugin-wsl-env 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -14,6 +14,79 @@ document: the 0.1.0 entry's `design-history §` references are to
14
14
  keeps the superseded designs under the section numbers they had while they
15
15
  were part of the record.
16
16
 
17
+ ## [Unreleased]
18
+
19
+ ## [0.18.0] - 2026-11-05
20
+
21
+ Track the desktop `0.2.2-rc.1` release: the bundle layer is regenerated from
22
+ its shipped patch file, the peer floor moves to the `0.2.2-rc.1` npm line with
23
+ the peer-parity re-run the layering rule requires, and the one genuinely broken
24
+ path is documented with its operator rule.
25
+
26
+ ### Changed
27
+
28
+ - **Raised the peer floor and dev pins to the `0.2.2-rc.1` npm line, with the
29
+ peer-parity re-run the layering rule requires.** All ten `@deepseek-ai/dsh-*`
30
+ peers move to `0.2.2-rc.1` (`peerDependencies >=0.2.2-rc.1`), cordis to
31
+ `^4.1.0` with dev pins `4.1.0`, and schemastery to `^3.19.0` — the release's
32
+ own pairing. Two companion fixes rode the move: the `cordis-plugin-*` dev
33
+ pins (`*`) resolved to `1.0.x`, which cordis 4.1.0 breaks at boot (the
34
+ `internal/config` waterfall dereferences a null `parent`; both pins are now
35
+ the release's `1.1.0`), and the `pnpm-workspace.yaml`
36
+ `minimumReleaseAgeExclude` list follows the pins as pnpm rewrites it.
37
+ `src/` changes, all defensive and documented in
38
+ [PEER-PARITY.md](docs/PEER-PARITY.md): the peer's new `patchText`/
39
+ `deleteFile`/`moveFile` operations are refused honestly on the distro side
40
+ (`FS_IO_ERROR` naming the substrate gap — the inherited host implementation
41
+ would target the wrong filesystem) and routed by the usual coordinates
42
+ otherwise; `wslWritableRoots` now honors `additionalWritableRoots` under the
43
+ upstream together-grant contract (a same-distro UNC extra root is granted,
44
+ a Windows-path extra root in a distro workspace fails closed with the
45
+ peer's `SandboxInvalidRootError`). The parity table was re-walked against
46
+ the `0.2.2-rc.1` tarballs: every replicated read/edit string survived
47
+ verbatim, both declared divergences stand, and the line references were
48
+ re-recorded (`dsh-fs-local`'s `lib/index.js` grew 909 → 1048 lines).
49
+
50
+ ### Fixed
51
+
52
+ - **Adapted to the desktop `0.2.2-rc.1` release.** The `preset-wsl` row is
53
+ regenerated from the release's `standard.patch.yml` (`dsh-v0.2.2-rc.1`):
54
+ `tool-fs` pins `applyPatch: false` (the base `patchText` is the host-side
55
+ implementation and must not quietly cross the 9p share for a distro
56
+ workspace), the removed `tool-subagent-list-agents` row is dropped,
57
+ `tool-subagent` moves from `modelSelectionSettings` to
58
+ `modelSelection` + `modelDiscovery`, and `tool-plugin-manager` follows the
59
+ shipped contextual disable. No `src/` changes were needed: every peer
60
+ symbol the plugin imports survives unchanged in the release's bundled
61
+ copies (`dsh-fs-local` gained patch machinery the preset keeps disabled;
62
+ `dsh-sandbox`'s `writableRoots` now honors `additionalWritableRoots`,
63
+ matching the upstream dialect), and the compatibility audit ran against
64
+ the release's bundled peer copies. The `peerDependencies` floor against
65
+ the freshly published `0.2.2-rc.1` npm line is raised in its own
66
+ commit — the peer-parity re-run the layering rule requires — not in
67
+ this one.
68
+ - Documented the one genuinely broken path: **enabling the bundle through
69
+ the GUI on a running profile fails on app `0.2.2-rc.1`** while sessions
70
+ hold the replaced services, because cordis 4.1.0 retains a disposing
71
+ provider's registrations until its dependents drain
72
+ ([UPSTREAM-SERVICE-SWAP.md](docs/UPSTREAM-SERVICE-SWAP.md) — mechanism,
73
+ isolated repro on both version pairs, and upstream remediation
74
+ directions; [LIMITATIONS.md](docs/LIMITATIONS.md) records the
75
+ operator rule: the selection persists and a restart applies it).
76
+ Cold-boot composition is unaffected and verified against the release's
77
+ actual bundle layers.
78
+
79
+ ## [0.17.1] - 2026-11-01
80
+
81
+ ### Fixed
82
+
83
+ - **The npm package now ships the Chinese user docs** (`QUICKSTART.zh.md`,
84
+ `CONFIGURATION.zh.md`, `LIMITATIONS.zh.md` — added to the files list after
85
+ the packaging link check caught their absence from the 0.17.0 tarball), and
86
+ `package.json`'s Chinese `description` is readable again instead of
87
+ `\uXXXX` escapes (a release-script `ensure_ascii` slip; the parsed value
88
+ was always correct). No shipped-code changes.
89
+
17
90
  ## [0.17.0] - 2026-11-01
18
91
 
19
92
  ### Changed
package/README.md CHANGED
@@ -96,13 +96,13 @@ Settings live on named rows in `$DSH_HOME/profiles/<name>/cordis.patch.yml`. The
96
96
  |---|---|---|---|
97
97
  | `wsl-shell` | `distro` | `''` | distro mode; empty/`auto` follows the workspace, `default` forces WSL's default |
98
98
  | | `sandbox` | `true` | confine commands with `bubblewrap` |
99
- | | `sessionSandbox` | `true` | run the session's commands in one systemd user scope |
99
+ | | `sessionSandbox` | shipped `true` | run the session's commands in one systemd user scope |
100
100
  | | `agentBackend` | `auto` | `auto`, `native` or `shell` for the in-distro agent |
101
101
  | | `maskWindowsDrive` | `false` | hide `/mnt` from confined commands |
102
102
  | `wsl-fs` | `distro` | `''` | distro mode; empty/`auto` follows each target path |
103
103
  | | `restrictToDistro` | `true` | under a fixed distro, refuse paths that belong to another distro |
104
104
  | | `sandbox` | `true` | check confined writes against the policy |
105
- | | `sessionSandbox` | `true` | run confined writes in the session runtime |
105
+ | | `sessionSandbox` | shipped `true` | run confined writes in the session runtime |
106
106
  | | `substrate` | `agent` | in-distro agent; `share` is rejected at startup |
107
107
  | `directory-picker-wsl` | `includeHostHome` | `true` | also list the Windows home directory |
108
108
  | `subprocess-wsl` | `distro` | `''` | distro mode; empty/`auto` follows the launch directory |
package/cordis.patch.yml CHANGED
@@ -191,7 +191,7 @@
191
191
  # Generated from the shipped standard preset so the embedded plan-mode
192
192
  # section and every nested group survive byte-for-byte: this copy is
193
193
  # `packages/bundle/web-app/presets/standard.patch.yml` of the
194
- # `dsh-v0.2.1-rc.3` source tree (unchanged since `0.2.1-rc.2`), changed
194
+ # `dsh-v0.2.2-rc.1` source tree, changed
195
195
  # in exactly three ways —
196
196
  # 1. every shipped row mounts inside `wsl-env`, so the preset's tools see
197
197
  # the distro's shell and fs (the realm is declared on the group);
@@ -288,6 +288,12 @@
288
288
  disabled: true
289
289
  - id: tool-fs
290
290
  name: '@deepseek-ai/dsh-tool-fs'
291
+ config:
292
+ # Set false to drop the apply_patch tool beside edit. The
293
+ # base patchText is the host-side implementation; the distro
294
+ # substrate serves read/write/edit itself and must not have
295
+ # a patch path that quietly crosses the 9p share instead.
296
+ applyPatch: false
291
297
  - id: tool-fs-search
292
298
  name: '@deepseek-ai/dsh-tool-fs-search'
293
299
  config:
@@ -350,14 +356,13 @@
350
356
  config:
351
357
  - id: tool-subagent-control
352
358
  name: '@deepseek-ai/dsh-tool-subagent-control'
353
- - id: tool-subagent-list-agents
354
- name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
355
359
  - id: tool-subagent
356
360
  name: '@deepseek-ai/dsh-tool-subagent'
357
361
  config:
358
362
  provider: spawn
359
363
  toolName: subagent
360
- modelSelectionSettings: true
364
+ modelSelection: true
365
+ modelDiscovery: true
361
366
  - id: tool-subagent-fork
362
367
  name: '@deepseek-ai/dsh-tool-subagent'
363
368
  config:
@@ -384,7 +389,7 @@
384
389
  name: '@deepseek-ai/dsh-tool-present'
385
390
  - id: tool-plugin-manager
386
391
  name: '@deepseek-ai/dsh-plugin-manager/tools'
387
- disabled: true
392
+ disabled: !!js "!ctx.get('profileContext')"
388
393
  - id: tool-plugin-market
389
394
  name: '@deepseek-ai/dsh-plugin-market/tools'
390
395
  disabled: true
@@ -361,14 +361,15 @@ step with the checkout, and `pnpm run sync:windows` runs that script.
361
361
  | Build consistency | [`test/build-freshness.mjs`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/test/build-freshness.mjs) | no; it re-runs the real build and byte-compares the committed `lib/`, so it also catches an orphan there |
362
362
  | Type check | `tsc --noEmit` over `test/**` and `types/*.d.ts` (`src/` is checked by the build itself) | no |
363
363
  | Unit tests | `test/*.test.mjs` | no |
364
+ | Requirements matrix | [`scripts/check-requirements.mjs`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/scripts/check-requirements.mjs) | no; every cited test must exist and stay wired |
364
365
  | Sandbox probe | [`test/probe/sandbox.sh`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/test/probe/sandbox.sh) | no; it applies the profile arguments directly |
365
- | Harness probes | [`test/probe/run.sh`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/test/probe/run.sh), `terminal.sh`, `sandbox-shell.sh`, `interop-shell.sh`, `picker.sh`, `fs-routing.sh`, `missing-wsl.sh`, `sandbox-off.sh` | yes: Windows, WSL2, a mounted profile, and a linked checkout |
366
- | Distro probes | [`test/probe/substrate.sh`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/test/probe/substrate.sh), `watch.sh`, `agent.sh`, `exec.sh` | Windows and WSL2, but no harness boot and no profile: they run from a distro terminal with Node available, reaching `wsl.exe` through interop |
366
+ | Harness probes | [`test/probe/run.sh`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/test/probe/run.sh), `terminal.sh`, `sandbox-shell.sh`, `interop-shell.sh`, `picker.sh`, `fs-routing.sh`, `missing-wsl.sh`, `sandbox-off.sh`, `native-session.sh` | yes: Windows, WSL2, a mounted profile, and a linked checkout |
367
+ | Distro probes | [`test/probe/substrate.sh`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/test/probe/substrate.sh), `watch.sh`, `agent.sh`, `exec.sh`, `session-sandbox.sh`, `gui-preview.sh`, `file-reference-9p.sh` | Windows and WSL2, but no harness boot and no profile: they run from a distro terminal with Node available, reaching `wsl.exe` through interop |
367
368
  | Host probe | [`test/probe/mode.sh`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/test/probe/mode.sh) | Windows Node, no harness |
368
- | Probe plugins | the `*-probe.mjs` and `*-probe.yml` files in `test/probe/` | loaded by the scripts above |
369
+ | Probe plugins | the `*-probe.mjs` and `*-probe.yml` files in `test/probe/` (plus standalone measurers such as `gui-preview.mjs`, `native-session.mjs`, `fs-probe.mjs`, `fs-queue.mjs`) | loaded or invoked by the scripts above |
369
370
 
370
- `pnpm test` runs `lint:style`, `lint:links`, `test:syntax`, `lint:build`,
371
- `lint:types` and `test:unit`, in that order.
371
+ `pnpm test` runs `lint:style`, `lint:links`, `lint:requirements`,
372
+ `test:syntax`, `lint:build`, `lint:types` and `test:unit`, in that order.
372
373
  [`test/probe/run-all-when-closed.sh`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/test/probe/run-all-when-closed.sh)
373
374
  waits for the app to exit and then runs the whole real-machine suite once —
374
375
  `--include-fs` prepends `run.sh`.
@@ -5,7 +5,7 @@ Measured evidence for the support tiers in [`ROADMAP-1.0.md`](ROADMAP-1.0.md)
5
5
  (x86_64, Windows 11, WSL 2, kernel 6.18) on **2026-10-26**, with the probe
6
6
  suite in [`test/probe/`](https://github.com/Big-Dao/dsh-plugin-wsl-env/tree/main/test/probe/) run from inside each distro against a
7
7
  fresh `--depth 1` clone. The aarch64 native agent is additionally executed per
8
- push under qemu in CI — see the `native packages` job in
8
+ push under qemu in CI — see the `native-package` job in
9
9
  [`.github/workflows/ci.yml`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/.github/workflows/ci.yml); VM-only by
10
10
  decision — see "Scope decisions" below.
11
11
 
@@ -1,5 +1,7 @@
1
1
  # Configuration
2
2
 
3
+ *A Chinese translation lives at [CONFIGURATION.zh](CONFIGURATION.zh.md); the English version is authoritative.*
4
+
3
5
  ## Profile patches
4
6
 
5
7
  Store profile settings in `$DSH_HOME/profiles/<name>/cordis.patch.yml`. Use
@@ -215,6 +217,27 @@ gives the `visible` behavior.
215
217
  When `interopVisibility` is set, it takes precedence over
216
218
  `maskWindowsDrive`.
217
219
 
220
+ ### Three scenarios across four surfaces
221
+
222
+ What a setting changes depends on which surface acts. Confined commands run
223
+ in the `wsl-shell` sandbox; confined writes are checked by the `wsl-fs`
224
+ write sandbox; unrestricted file reads go through the shared read agent and
225
+ are not sandbox-governed; a Windows-side host operation is anything that
226
+ ends up executing on Windows.
227
+
228
+ | Surface | `visible` (default) | `masked` | distro-level `enabled=false` |
229
+ |---|---|---|---|
230
+ | Confined command (`wsl-shell`) | reads Windows files and launches Windows executables under `/mnt` | `/mnt` is an empty tmpfs in the profile: path operations under it fail | interop is refused by the distro itself; `/mnt` visibility still follows the mask above |
231
+ | Confined write (`wsl-fs`) | the write policy checks the target; `/mnt` visibility plays no role | the same mask applies to the write profile | unchanged — the write boundary was never interop-dependent |
232
+ | Unrestricted read (shared read agent) | reads `/mnt` freely | **not covered**: the mask lives in confined profiles only, the read agent still sees `/mnt` | **not governed by the plugin** |
233
+ | Windows-side host operation | reachable through `/mnt` | **still reachable**: `binfmt_misc` dispatches by file content, so a Windows executable copied into the workspace runs anyway (`enforcement: partial`) | the only real closure — and it is a manual `wsl.conf` step |
234
+
235
+ Masking affects real workflows on purpose: a script living under a Windows
236
+ path (a checkout under `/mnt/c`, tools on the Windows `PATH`) can no longer
237
+ be read or run by confined commands — move it into the distro or grant the
238
+ visible stance. Masking never deletes anything: the tmpfs shadows the view
239
+ inside one confined profile; the files on `/mnt/c` are untouched.
240
+
218
241
  Masking narrows access; it does not close interop. WSL can still run a Windows
219
242
  executable written into the workspace because `binfmt_misc` dispatches by file
220
243
  content. Enforcement therefore remains `partial`, and results report
@@ -0,0 +1,307 @@
1
+ # Configuration
2
+
3
+ _本文是 [CONFIGURATION](CONFIGURATION.md) 的中文译本,以英文版为准。_
4
+
5
+ ## Profile patch
6
+
7
+ profile 设置存放在 `$DSH_HOME/profiles/<name>/cordis.patch.yml`。可以用
8
+ [`examples/profile.cordis.patch.yml`](../examples/profile.cordis.patch.yml)
9
+ 作为起点。随包的
10
+ [`cordis.patch.yml`](../cordis.patch.yml) 列出了本插件附带的行和值。
11
+
12
+ profile 层可以按 `id` 指向顶层行。这一层的插件行包括 `fs-routing`、
13
+ `directory-picker-wsl`、`subprocess-wsl`、`wsl-shell-env`、`wsl-preflight`、
14
+ `auto-preset` 和 `preset-wsl`。`wsl-shell` 和 `wsl-fs`
15
+ 两行嵌套在 `preset-wsl.config.plugins` 内;直接按这两个 id 配置的
16
+ profile 条目会被忽略,并产生 `patch: entry <id> not found` 警告。
17
+
18
+ 一行的 `config` 是整体替换。如果你想保留随包行中的非默认值,
19
+ 必须把它们一并写入。这对 `preset-wsl` 尤其重要:
20
+ 它的 config 包含完整的 preset 及其嵌套插件。
21
+
22
+ 在下表中,**shipped** 表示该值在随包行中被显式设置。
23
+ 其他值是 schema 默认值。省略的键使用 schema 默认值。
24
+
25
+ ## 配置 `wsl-shell` 和 `wsl-fs`
26
+
27
+ 这两行嵌套在 `preset-wsl` 内。使用辅助脚本修改它们的设置:
28
+
29
+ ```bash
30
+ pnpm run preset --distro Ubuntu --session-sandbox false
31
+ ```
32
+
33
+ 支持的修改是 `--distro`、`--session-sandbox`、`--sandbox`、
34
+ `--mask-windows-drive` 和 `--agent-backend`。不带 `--out` 时,辅助脚本
35
+ 把完整的 `preset-wsl` 块打印出来,供你手动合并进 profile。
36
+ 使用 `pnpm run preset --check <file>` 可以检测直接指向嵌套行的
37
+ profile 层;检测到时会打印应使用的块。`--out` 会整体替换目标文件,
38
+ 包括其中的其他覆盖,即使它已经包含 `preset-wsl` 行。
39
+ 在不包含该行的文件已存在时,替换会被拒绝,除非传入 `--force`。
40
+ 对已有 profile 建议手动合并。
41
+
42
+ 要手动编辑 preset,需替换整个 `preset-wsl` 行。它的 config
43
+ 不做深度合并:保留 `id`、`order` 以及 `plugins` 中的每一项。
44
+ 从 `cordis.patch.yml` 或 `dsh --profile <name> --dump-config`
45
+ 复制当前块,再修改嵌套的值。插件升级改变了 preset 后要重新复制。
46
+
47
+ ### `wsl-shell`
48
+
49
+ | 键 | 默认 / shipped 值 | 说明 |
50
+ |---|---|---|
51
+ | `distro` | `''`(shipped) | 空或 `auto` 跟随请求工作目录所属的发行版。`default` 选择 WSL 默认发行版;给出名字则把命令固定到该发行版。 |
52
+ | `shell` | `''` | 空则解析发行版用户的登录 shell。设置绝对 Linux 路径可固定一个 shell。 |
53
+ | `loginShell` | `true`(shipped) | 对 POSIX shell 使用登录语义。非 POSIX shell 使用各自的命令形式。 |
54
+ | `agent` | `true` | 使用常驻 agent。不可用时,命令走一次性的 `wsl.exe` 路径。设为 `false` 则总是走该路径。Cwd 与沙箱拒绝会被直接返回。 |
55
+ | `agentBackend` | `auto`(shipped) | `auto` 选择包内 `agent/native/linux-<arch>/dsh-wsl-agent` 的静态 musl 二进制或 `DSH_WSL_AGENT_NATIVE` 覆盖;否则使用 shell agent。`native` 在准备失败时报错;`shell` 强制使用 shell agent。适用于命令、受限写入和共享读取。 |
56
+ | `sessionSandbox` | `false`;shipped 为 `true` | `true` 把会话跑在一个持久的 systemd user scope 中。要求 `agent: true`、systemd 为 PID 1(`/etc/wsl.conf` 中 `[boot] systemd=true`)、一个 user manager、`systemd-run` 和 Linger(`loginctl enable-linger <user>`)。`false` 使用按命令的沙箱。`auto` 在可用时使用 scope,否则按命令约束。结果会报告 `sessionScope: 'session'` 或 `'per-command'`。 |
57
+ | `sandbox` | `true` | 用 `bwrap` 约束命令。`bwrap` 缺失或不可用时关闭(fail closed)。`false` 则不加约束地运行命令。 |
58
+ | `interopVisibility` | 未设置;有效默认值为 `visible` | `visible`、`masked` 或 `disabled`。设置后优先于 `maskWindowsDrive`。见 [Windows interop](#windows-interop)。 |
59
+ | `maskWindowsDrive` | `false` | 对受限命令,在 `/mnt` 上挂载空的 tmpfs。见 [Windows interop](#windows-interop)。 |
60
+ | `cwd` | `''` | 默认工作目录。空则使用发行版用户家目录。 |
61
+ | `timeoutMs` / `maxTimeoutMs` | `120000` / `600000`(shipped) | 默认的单次调用超时,以及一次调用可请求的最大超时。 |
62
+ | `wslPath` | `wsl.exe` | `wsl.exe` 的路径。 |
63
+ | `hostCwd` | 未设置 | `wsl.exe` 进程的 Windows 工作目录。可用时默认为 `%SystemRoot%`。 |
64
+ | `forwardEnv` | `[]` | 额外通过 `WSLENV` 转发的宿主环境变量名。见 [环境变量转发](#环境变量转发)。 |
65
+
66
+ ### `wsl-fs`
67
+
68
+ | 键 | 默认 / shipped 值 | 说明 |
69
+ |---|---|---|
70
+ | `distro` | `''`(shipped) | 空或 `auto` 跟随目标路径所属的发行版。`default` 选择 WSL 默认发行版;给出名字则固定文件系统。 |
71
+ | `restrictToDistro` | `true`(shipped) | 固定发行版时,以 `FS_OUTSIDE_DISTRO` 拒绝属于其他发行版共享的路径。 |
72
+ | `sandbox` | `true` | 按沙箱策略检查写入。`bwrap` 不可用时,受限写入关闭(fail closed)。 |
73
+ | `sessionSandbox` | `false`;shipped 为 `true` | 使用与 `wsl-shell` 相同的会话 runtime。`auto` 在会话 runtime 不可用时回退到按策略约束的常驻 agent。 |
74
+ | `maskWindowsDrive` | `false` | 对受限变更隐藏 `/mnt`。读取不受影响。 |
75
+ | `substrate` | `agent`(shipped) | 文件操作使用发行版内 agent。旧值 `share` 在启动时被拒绝。 |
76
+ | `cwd` | `''` | 相对路径的基准目录。空则使用发行版用户家目录。 |
77
+ | `watchMaxDepth` | `0` | 监视整棵树。正值深度使用有界轮询,可能遗漏边界以下的变更,直到边界之上发生变更触发回调。 |
78
+ | `wslPath` | `wsl.exe` | `wsl.exe` 的路径。 |
79
+ | `diffBasisMaxBytes` | `10485760` | 覆盖写入 diff 每一侧的 UTF-8 字节上限。更大的文件不带 diff 直接写入。 |
80
+
81
+ ### `fs-routing`
82
+
83
+ 这个顶层行为根级 `ctx.fs` 调用提供服务。它把发行版 UNC 路径
84
+ 路由到 agent 支撑的文件系统,把盘符路径路由到宿主文件系统。它的
85
+ 发行版设置独立于 `wsl-fs`。
86
+ Loader 在挂载该行之前会校验宿主和发行版设置;
87
+ 被 schema 拒绝的值会阻止路由器启动。字段值为 `null`
88
+ 时使用其 schema 默认值。
89
+
90
+ | 键 | 默认 / shipped 值 | 说明 |
91
+ |---|---|---|
92
+ | `distro` | `''`(shipped) | 空或 `auto` 把每条 UNC 路径路由到其命名的发行版。`default` 选择 WSL 默认发行版;给出名字则固定路由。 |
93
+ | `wslPath` | `wsl.exe`(shipped) | `wsl.exe` 的路径,用于解析默认发行版。 |
94
+ | `sandbox` | `true`(shipped) | 按 `ctx.sandboxPolicy` 检查被路由的变更;`bwrap` 不可用时关闭(fail closed)。无论该围栏启用与否,该行都报告 `sandboxMode: undefined`。 |
95
+ | `maskWindowsDrive` | `false`(shipped) | 对受限的被路由变更隐藏 `/mnt`。 |
96
+ | `restrictToDistro` | `true`(shipped) | `distro` 被固定时,拒绝属于其他发行版共享的路径。 |
97
+ | `watchMaxDepth` | `0`(shipped) | 监视整棵树。正值深度使用有界轮询。 |
98
+ | `distroCwd` | `''` | 默认发行版工作目录;空则使用发行版用户家目录。 |
99
+ | `cwd` | `process.cwd()` | 宿主文件系统后端的工作目录。 |
100
+ | `diffBasisMaxBytes` | `10485760` | 宿主与被路由后端共享的覆盖写入 diff 上限。 |
101
+
102
+ 根路由器是应用层的,不属于会话,因此不使用
103
+ `sessionSandbox`。
104
+
105
+ ### 选择器与终端行
106
+
107
+ | 行 | 键 | 默认 / shipped 值 | 说明 |
108
+ |---|---|---|---|
109
+ | `directory-picker-wsl` | `preferredDistro` | `''`(shipped) | 首位展示的发行版,也是 Home 位置使用的发行版。 |
110
+ | | `includeHostHome` | `true`(shipped) | 包含 Windows 家目录。 |
111
+ | | `maxEntries` | `1000`(shipped) | 单个目录返回的最大条目数。 |
112
+ | | `wslPath` | `wsl.exe` | `wsl.exe` 的路径。 |
113
+ | | `distroCacheMs` | `5000` | 发行版列表的缓存时长。 |
114
+ | `subprocess-wsl` | `distro` | `''`(shipped) | 空或 `auto` 跟随启动目录所属的发行版。`default` 选择 WSL 默认;给出名字则固定发行版。 |
115
+ | | `shell` | `''` | 在发行版内固定的 shell。空则由 `wsl.exe` 选择登录 shell。 |
116
+ | | `loginShell` | `true` | 固定 shell 时的登录语义。 |
117
+ | | `hostSessions` | `true` | 在 Windows 文件夹上打开的会话,会在该文件夹中获得宿主 PowerShell。WSL 文件夹会话使用发行版 shell。设为 `false` 则所有会话都使用 composition 拥有的终端。 |
118
+ | | `terminalIdleReclaim` | `true` | 依据被标记的进程回收空闲的发行版终端。活动状态未知时暂停回收。 |
119
+ | | `cwd` | `''` | 未提供启动目录时的回退目录。 |
120
+ | | `wslPath` | `wsl.exe` | `wsl.exe` 的路径。 |
121
+ | | `hostCwd` | 未设置 | `wsl.exe` 进程的 Windows 工作目录。可用时默认为 `%SystemRoot%`。 |
122
+ | | `forwardEnv` | `[]` | 额外通过 `WSLENV` 转发的宿主环境变量名。 |
123
+
124
+ ### 其他顶层行
125
+
126
+ | 行 | 键 | 默认值 | 说明 |
127
+ |---|---|---|---|
128
+ | `auto-preset` | `preset` | `wsl` | 会话工作区位于发行版内时绑定的 preset。操作者的显式选择会被保留。 |
129
+ | | `attempts` | `6` | 绑定 preset 的尝试次数。 |
130
+ | | `retryMs` | `150` | 两次尝试之间的延迟,单位毫秒。 |
131
+ | `wsl-preflight` | `distro` | `''` | 要检查的发行版。空或 `auto` 跟随会话工作区。 |
132
+ | | `wslPath` | `wsl.exe` | `wsl.exe` 的路径。 |
133
+ | | `sandbox` | `true` | 运行会话启动时的 `bwrap` 检查。 |
134
+ | | `sessionSandbox` | `true` | 同时检查 systemd、user manager、`systemd-run` 和 Linger。profile 不使用会话 runtime 时设为 false。 |
135
+ | `wsl-shell-env` | `distro` | `''` | 用于填充 `DSH_WSL_*` 环境事实的发行版。 |
136
+ | | `portsRefreshMs` | `10000` | 监听端口快照的刷新间隔,单位毫秒。 |
137
+
138
+ GUI 文件树和预览通过 `fs-routing` 使用随包的 `workspace-files` 行;
139
+ 它们不使用单独的 WSL 提供者行。要修改其 peer 定义的限额,
140
+ 在 profile 层按 id 覆盖 `workspace-files`。
141
+
142
+ ## 共享的命令设置
143
+
144
+ shell 行从 `@deepseek-ai/dsh-bash-local` 继承输出与进程设置:
145
+
146
+ | 键 | 默认值 | 说明 |
147
+ |---|---|---|
148
+ | `maxOutputBytes` | `64000` | 每条流的捕获输出上限。agent 在发行版内执行该限制,并标记被截断的结果。 |
149
+ | `maxSpillBytes` | `67108864` | 一次性路径上每条流的 spill 文件上限。 |
150
+ | `graceMs` | `3000` | SIGTERM 与 SIGKILL 之间的宽限期。 |
151
+
152
+ `agent: true` 时,输出在发行版内被限制,且不写 spill 文件。
153
+ `maxSpillBytes` 和 `graceMs` 适用于 `agent: false`,或常驻 agent
154
+ 不可用而改走一次性 `wsl.exe` 的情况。
155
+
156
+ ### 模型运行命令的 zsh/fnm 配方
157
+
158
+ 命令以 `<shell> -lc` 运行,因此 `~/.zshrc` 永远不会被读取——原因见
159
+ [LIMITATIONS](LIMITATIONS.md#shell-startup-semantics-wsl-shell)。把 fnm 的
160
+ hook 放进 `~/.zprofile`,并为沙箱准备一个回退——沙箱中 `/run` 是只读的,
161
+ fnm 无法创建它的 multishell 符号链接目录:
162
+
163
+ ```zsh
164
+ # ~/.zprofile — fnm for non-interactive login shells (mirrors the ~/.zshrc hook)
165
+ path=("$HOME/.local/share/fnm" $path) # the fnm binary itself
166
+ _fnm_env="$(command -v fnm &>/dev/null && fnm env --shell zsh 2>/dev/null)" && eval "$_fnm_env"
167
+ if [[ -z "${FNM_MULTISHELL_PATH:-}" || ! -e "${FNM_MULTISHELL_PATH}/bin/node" ]]; then
168
+ path=("$HOME/.local/share/fnm/aliases/default/bin" $path) # sandbox fallback
169
+ fi
170
+ unset _fnm_env
171
+ ```
172
+
173
+ 交互式终端仍使用 `~/.zshrc` 中的 hook,不受影响;
174
+ `aliases/default` 回退只在 multishell 链接无法存在时接管。
175
+
176
+ ## 环境变量转发
177
+
178
+ 只有名字列在 `WSLENV` 中的宿主环境变量才会被 WSL 导入。各提供者
179
+ 默认转发 `NO_COLOR`、`TERM`、`PAGER`、`GIT_PAGER`、`LANG`、`LC_ALL`
180
+ 以及托管的 `DSH_*` 名字。`forwardEnv` 向该列表追加名字;
181
+ `PATH` 永远不会被转发。
182
+
183
+ 对 `wsl-shell` 而言,`forwardEnv` 只作用于一次性 `wsl.exe` 路径。
184
+ 常驻 agent 只接收托管的 `DSH_*` 环境,因此 `forwardEnv` 里的自定义名字
185
+ 不会到达经由该 agent 运行的命令。`subprocess-wsl` 的设置
186
+ 作用于它的 WSL 启动。
187
+
188
+ ## 发行版选择
189
+
190
+ 对命令与终端行而言,空的 `distro` 或 `distro: auto` 跟随
191
+ 请求的 UNC 工作目录。当请求未指明发行版时,使用 WSL 的
192
+ 默认发行版。对 `wsl-fs`,`auto` 跟随每个目标路径。对
193
+ `fs-routing`,每条 UNC 目标各自选择自己的发行版。
194
+
195
+ `distro: default` 总是选择 WSL 的默认发行版。给出发行版名字则把该行
196
+ 固定到那个发行版。`restrictToDistro: true` 时,属于其他发行版共享的路径
197
+ 会被以 `FS_OUTSIDE_DISTRO` 拒绝。挂载在 `/mnt/c` 的 Windows 盘
198
+ 位于所选发行版之内,不会被这个围栏拒绝。
199
+
200
+ ## Windows interop
201
+
202
+ `interopVisibility` 控制是否对受限命令遮蔽 `/mnt`;
203
+ 它本身不会禁用 Windows interop。未设置时,`maskWindowsDrive: false`
204
+ 给出 `visible` 行为。
205
+
206
+ | 值 | 效果 |
207
+ |---|---|
208
+ | `visible` | 保持 `/mnt` 可见。受限命令可以读取 Windows 文件,并通过 WSL interop 启动 Windows 可执行文件。 |
209
+ | `masked` | 在受限 profile 中,把空的 tmpfs 挂载到 `/mnt` 上。命令无法访问 `/mnt` 下的路径;其他挂载与不受限的文件读取不在覆盖范围内。 |
210
+ | `disabled` | 施加与 `masked` 相同的 `/mnt` 遮蔽;它不会禁用 interop,也不会修改 `wsl.conf`。请按下文单独配置发行版。 |
211
+
212
+ `maskWindowsDrive: true` 等价于 `interopVisibility: masked`。
213
+ 设置了 `interopVisibility` 时,它优先于
214
+ `maskWindowsDrive`。
215
+
216
+ ### 三个场景 × 四个作用面
217
+
218
+ 设置改变什么,取决于哪个面在起作用。受限命令运行在 `wsl-shell`
219
+ 沙箱中;受限写入由 `wsl-fs` 的写入沙箱检查;非受限文件读取走共享读
220
+ agent,不受沙箱管辖;Windows 侧宿主操作指最终在 Windows 上执行的任何
221
+ 东西。
222
+
223
+ | 作用面 | `visible`(默认) | `masked` | 发行版级 `enabled=false` |
224
+ |---|---|---|---|
225
+ | 受限命令(`wsl-shell`) | 可读 Windows 文件、经 `/mnt` 启动 Windows 可执行文件 | profile 中 `/mnt` 是空 tmpfs:其下的路径操作失败 | interop 由发行版自身拒绝;`/mnt` 可见性仍遵循上方的遮蔽设置 |
226
+ | 受限写入(`wsl-fs`) | 写入策略检查目标;`/mnt` 可见性不起作用 | 同样的遮蔽作用于写入 profile | 不变——写入边界从来不依赖 interop |
227
+ | 非受限读取(共享读 agent) | 自由读 `/mnt` | **不在覆盖范围**:遮蔽只存在于受限 profile 中,读 agent 仍能看到 `/mnt` | **不归插件管辖** |
228
+ | Windows 侧宿主操作 | 可经 `/mnt` 到达 | **仍然可达**:`binfmt_misc` 按文件内容分发,被拷进工作区的 Windows 可执行文件照样运行(`enforcement: partial`) | 唯一真正的关闭手段——且是手工的 `wsl.conf` 步骤 |
229
+
230
+ 遮蔽刻意影响真实工作流:放在 Windows 路径下的脚本(`/mnt/c` 下的
231
+ 检出、Windows `PATH` 上的工具)不再能被受限命令读取或执行——把它移进
232
+ 发行版,或改用 `visible` 姿态。遮蔽不会删除任何东西:tmpfs 只遮蔽单个
233
+ 受限 profile 内的视图,`/mnt/c` 上的文件原样保留。
234
+
235
+ 遮蔽只是收窄访问,并不关闭 interop。WSL 仍能运行被写入工作区的
236
+ Windows 可执行文件,因为 `binfmt_misc` 按文件内容分发。
237
+ 因此强制级别仍是 `partial`,结果会报告 `windowsDrive: 'masked'`。
238
+ 要在该发行版上禁用 interop,把下面这段加进 `/etc/wsl.conf`:
239
+
240
+ ```ini
241
+ [interop]
242
+ enabled=false
243
+ ```
244
+
245
+ 然后运行 `wsl.exe --shutdown`。要关闭 interop,必须做这一发行版级修改。
246
+
247
+ 要对两个嵌套行都应用 masked profile:
248
+
249
+ ```bash
250
+ pnpm run preset --sandbox true --mask-windows-drive true
251
+ ```
252
+
253
+ 把打印出的块合并进 profile。`visible` 与 `masked` 的行为
254
+ 由 `test/probe/interop-shell.sh` 对常驻与一次性两种命令都有覆盖。
255
+ 发行版级的 disabled 状态需要手动检查,因为它会改动 WSL 配置。
256
+
257
+ ## 沙箱与预检
258
+
259
+ `wsl-shell`、`wsl-fs` 和 `fs-routing` 的默认值都是 `sandbox: true`。
260
+ 受限命令与变更要求发行版内有可用的 `bwrap`。缺失或不可用时,
261
+ 命令以 `SANDBOX_UNAVAILABLE` 失败,写入以 `FS_IO_ERROR` 失败;
262
+ 两种操作都不会回退到无约束运行。错误信息会区分
263
+ 包缺失与 `bwrap` 存在但不可用两种情况。
264
+
265
+ 用 bootstrap 辅助脚本安装该前置依赖:
266
+
267
+ ```bash
268
+ scripts/bootstrap.sh <distro> --install
269
+ ```
270
+
271
+ 不带 `--install` 时,辅助脚本只做只读检查。在基于 apt 的
272
+ 发行版上,直接安装命令是:
273
+
274
+ ```bash
275
+ wsl.exe -d <distro> -u root -- apt-get install -y bubblewrap
276
+ ```
277
+
278
+ 会话打开时,`wsl-preflight` 行会运行这些检查。
279
+ `sessionSandbox: true` 时,它还会检查会话 runtime 的前置条件。
280
+ 该警告仅供参考:它不会安装软件包,也不会改变提供者关闭(fail-closed)
281
+ 的行为。在该行设置 `sandbox: false` 或移除该行可让沙箱警告静音。
282
+ profile 不使用会话 runtime 时,设置 `sessionSandbox: false`。
283
+
284
+ 在 `wsl-shell` 或 `wsl-fs` 上设置 `sandbox: false` 后,命令或写入
285
+ 将无约束地运行;其 `sandboxMode` 变为 `undefined`。工具层
286
+ 会报告没有沙箱生效。在 `fs-routing` 上,该设置会禁用变更围栏;
287
+ 无论开关如何,该行都报告 `sandboxMode: undefined`。
288
+
289
+ ## 诊断配置问题与拒绝
290
+
291
+ 使用 `dsh --profile <name> --dump-config` 检查合成后的 profile,
292
+ 无需真正启动。输出会显示某行的覆盖是否生效。
293
+ 使用 `scripts/bootstrap.sh <distro>` 检查发行版前置依赖。
294
+
295
+ | 现象 | 结果 | 处理 |
296
+ |---|---|---|
297
+ | 命令沙箱不可用 | `SANDBOX_UNAVAILABLE`;消息区分 `bwrap` 缺失或不可用。 | 安装 `bubblewrap`、修复用户命名空间,或在 `wsl-shell` 上设置 `sandbox: false`。 |
298
+ | 受限写入不可用 | `FS_IO_ERROR`,附带 `bwrap` 补救方法。 | 安装或修复 `bubblewrap`;要禁用围栏,在 `wsl-fs` 或 `fs-routing` 上设置 `sandbox: false`。 |
299
+ | 发行版已停止时文件操作失败 | `FS_IO_ERROR`:发行版 substrate 不可用。 | 启动该发行版。若 agent 仍不可用,重启会话。 |
300
+ | 命令无法在所选发行版中启动 | `WSL_E_*` 错误码,指明发行版。 | 启动该发行版或修改 `distro`。更宽的权限无法解决发行版已停止的问题。 |
301
+ | `wsl.exe` 无法启动 | 错误指明可执行文件与该行的 `wslPath`。 | 修正 `wslPath`,并确认已安装 WSL。 |
302
+ | 命令执行中 WSL 挂起 | 命令到达截止时间仍未完成。 | 重试一次;仍不行则运行 `wsl.exe --shutdown` 并重新打开会话。 |
303
+ | 被监视的变更没有通知 | 轮询可能遗漏保留所观察元数据的变更;不保证报错。 | 查看 [LIMITATIONS.md](LIMITATIONS.md) 中的监视器限制。 |
304
+ | 其他发行版的路径被拒绝 | `FS_OUTSIDE_DISTRO`。 | 使用 `distro: ''` 或 `auto` 跟随工作区,或在目标发行版中打开会话。 |
305
+
306
+ 完整错误参考见 [ARCHITECTURE.md — Error codes](ARCHITECTURE.md#error-codes),
307
+ 设计边界见 [LIMITATIONS.md](LIMITATIONS.md)。