dsh-plugin-wsl-env 0.26.4 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/CONTRIBUTING.md +7 -4
- package/CONTRIBUTING.zh.md +3 -2
- package/README.md +1 -1
- package/SECURITY.md +21 -7
- package/SECURITY.zh.md +18 -5
- package/client.js +351 -48
- package/cordis.patch.yml +26 -10
- package/docs/API.md +2 -1
- package/docs/API.zh.md +2 -1
- package/docs/ARCHITECTURE.md +22 -4
- package/docs/ARCHITECTURE.zh.md +18 -4
- package/docs/CONFIGURATION.md +96 -12
- package/docs/CONFIGURATION.zh.md +80 -8
- package/docs/DIAGNOSTICS.md +22 -11
- package/docs/DIAGNOSTICS.zh.md +17 -9
- package/docs/LIMITATIONS.md +27 -4
- package/docs/LIMITATIONS.zh.md +20 -3
- package/docs/MIGRATION.md +2 -2
- package/docs/MIGRATION.zh.md +2 -2
- package/docs/QUICKSTART.md +31 -20
- package/docs/QUICKSTART.zh.md +16 -9
- package/docs/README.zh.md +1 -1
- package/docs/REQUIREMENTS.zh.md +3 -2
- package/lib/agent-confined.d.ts +9 -1
- package/lib/agent-confined.js +3 -3
- package/lib/bwrap.d.ts +16 -0
- package/lib/bwrap.js +9 -0
- package/lib/fs-routing.d.ts +3 -0
- package/lib/fs-routing.js +2 -0
- package/lib/messages.js +2 -2
- package/lib/plugin-update.d.ts +212 -0
- package/lib/plugin-update.js +283 -0
- package/lib/sandbox-core.d.ts +2 -0
- package/lib/sandbox-core.js +5 -3
- package/lib/session-runtime.d.ts +10 -1
- package/lib/session-runtime.js +3 -1
- package/lib/shell-env.js +1 -1
- package/lib/socket-isolation.d.ts +103 -0
- package/lib/socket-isolation.js +166 -0
- package/lib/status.d.ts +21 -8
- package/lib/status.js +53 -18
- package/lib/update-check.d.ts +49 -9
- package/lib/update-check.js +81 -28
- package/lib/wsl-doctor-tool.js +2 -0
- package/lib/wsl-filesystem.d.ts +39 -1
- package/lib/wsl-filesystem.js +51 -4
- package/lib/wsl-shell.d.ts +67 -3
- package/lib/wsl-shell.js +75 -12
- package/package.json +8 -3
- package/scripts/doctor.mjs +199 -3
- package/scripts/profile-preset.mjs +10 -2
package/docs/API.md
CHANGED
|
@@ -24,7 +24,8 @@ this page is the quick tour.
|
|
|
24
24
|
| `./file-reference-wsl` | `traversalArgv`, `parseTraversalListing`, `FileReferenceTraversal`, … | the distro-side traversal strategy for `@` completion (pure library — built and tested, not yet wired to a row; see ARCHITECTURE) |
|
|
25
25
|
| `./wsl-doctor-tool` | the `wsl-doctor-tool` row | the `wsl_doctor` model tool: in-process diagnosis with scoping (`depth`, `section`) |
|
|
26
26
|
| `./wsl-doctor-command` | the `wsl-doctor-command` row | the `/wsl-doctor` UI command: spawns the standalone doctor CLI, renders detached from model history |
|
|
27
|
-
| `./status` | the `wsl-status` row | the sidebar panel's route over `/api`: installed distros, one distro's quick doctor, and the `--fix-owned` full
|
|
27
|
+
| `./status` | the `wsl-status` row | the sidebar panel's route over `/api`: installed distros, one distro's quick doctor, and the `--fix-owned` full check (which also repairs plugin-owned state); the last result persists across reloads and running distros' stored results refresh in the background; `DELETE` clears one stored result (`?distro=<name>`) or every result without enumerating or probing a distro |
|
|
28
|
+
| `./plugin-update` | the `wsl-plugin-update` row | the panel's version and upgrade route over `/api`: installed/running plugin versions, the newest installable stable release and its compatibility, and the confirmed one-click `updateBundle` action |
|
|
28
29
|
| `./paths` | `uncToPosix`, `toLinuxPath`, `toWorldPath`, … | the coordinate mappers |
|
|
29
30
|
| `./picker` | `WslDirectoryPicker` | the distro-aware directory picker |
|
|
30
31
|
| `./auto-preset` | the `auto-preset` row | first-run profile bootstrap |
|
package/docs/API.zh.md
CHANGED
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
| `./file-reference-wsl` | `traversalArgv`、`parseTraversalListing`、`FileReferenceTraversal`、… | 用于 `@` 补全的发行版侧遍历策略(纯库——已构建并测试,尚未接入行;见 ARCHITECTURE) |
|
|
24
24
|
| `./wsl-doctor-tool` | `wsl-doctor-tool` 行 | `wsl_doctor` 模型工具:带作用域(`depth`、`section`)的进程内诊断 |
|
|
25
25
|
| `./wsl-doctor-command` | `wsl-doctor-command` 行 | `/wsl-doctor` UI 命令:启动独立 doctor CLI,渲染结果不进入模型历史 |
|
|
26
|
-
| `./status` | `wsl-status` 行 | 侧栏面板经 `/api` 的路由:已安装发行版、单个发行版的快速 doctor,以及 `--fix-owned`
|
|
26
|
+
| `./status` | `wsl-status` 行 | 侧栏面板经 `/api` 的路由:已安装发行版、单个发行版的快速 doctor,以及 `--fix-owned` 完整检查(同时修复插件自有状态);最近结果跨重载保留,运行中发行版的已存结果在后台刷新;`DELETE` 清除单个(`?distro=<名称>`)或全部已存结果,不枚举、不探测发行版 |
|
|
27
|
+
| `./plugin-update` | `wsl-plugin-update` 行 | 面板经 `/api` 的版本与升级路由:已安装/运行中的插件版本、最新的可安装稳定版及其兼容性,以及点击确认后的一键 `updateBundle` |
|
|
27
28
|
| `./paths` | `uncToPosix`、`toLinuxPath`、`toWorldPath`、… | 坐标映射器 |
|
|
28
29
|
| `./picker` | `WslDirectoryPicker` | 能感知发行版的目录选择器 |
|
|
29
30
|
| `./auto-preset` | `auto-preset` 行 | 首次运行的 profile 引导 |
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -76,11 +76,12 @@ functions.
|
|
|
76
76
|
| `dsh-plugin-wsl-env/shell-env` | `wsl-shell-env` | [`lib/shell-env.js`](../lib/shell-env.js) | Contributes `DSH_WSL_DISTRO`, `DSH_WSL_SHELL`, `DSH_WSL_HOME` and `DSH_WSL_PORTS` to the managed `DSH_*` namespace, choosing the session workspace's distro (default/pinned facts are probed at mount; other distros are warmed when their session appears). The port list is a snapshot per active distro, refreshed every `portsRefreshMs` (10000 by default), so a server started moments ago may not be listed yet. |
|
|
77
77
|
| `dsh-plugin-wsl-env/preflight` | `wsl-preflight` | [`lib/preflight.js`](../lib/preflight.js) | Runs the environment advisory at session start — and, with `startup: true` (the default), once at plugin load — surfacing the doctor-style verdict as a non-gating warning. |
|
|
78
78
|
| `dsh-plugin-wsl-env/update-check` | `wsl-update-check` | [`lib/update-check.js`](../lib/update-check.js) | Asks the app's plugin manager about a newer stable release about once a day and carries the fact in `DSH_WSL_PLUGIN_UPDATE`; never fetches on its own. |
|
|
79
|
+
| `dsh-plugin-wsl-env/plugin-update` | `wsl-plugin-update` | [`lib/plugin-update.js`](../lib/plugin-update.js) | The sidebar panel's version and upgrade route (`GET`/`POST /api/wsl-env/plugin-update`): reports the installed/running plugin versions and the newest installable stable release from the host plugin manager's `listVersions`, cached for `cacheMs`; `POST` calls `updateBundle` only after a click in the panel and reports the host's restart, rollback, or refusal outcome. |
|
|
79
80
|
| `dsh-plugin-wsl-env/cwd-prompt` | `wsl-cwd-prompt` | [`lib/cwd-prompt.js`](../lib/cwd-prompt.js) | Rewrites the runtime context's working-directory entry to the distro's POSIX form; adds the one-sentence `wsl:shell` note; replaces `sandbox:policy` with a POSIX-only rendering; and suppresses the host `harness:source` value in WSL sessions. The last three are temporary adapters tracked in [UPSTREAM-PROMPT-ADAPTERS.md](UPSTREAM-PROMPT-ADAPTERS.md). |
|
|
80
81
|
| `dsh-plugin-wsl-env/cwd-prompt-tool` | `wsl-cwd-prompt-tool` | [`lib/cwd-prompt-tool.js`](../lib/cwd-prompt-tool.js) | Serves the model's read/`cd` tool with the same semantics the harness ships, rewriting the returned `cwd` to the distro's POSIX form. |
|
|
81
82
|
| `dsh-plugin-wsl-env/wsl-doctor-tool` | `wsl-doctor-tool` | [`lib/wsl-doctor-tool.js`](../lib/wsl-doctor-tool.js) | The `wsl_doctor` model tool: the doctor in-process (merging the live resident's state), scoped by `depth`/`section`, rendered as the itemized digest. |
|
|
82
83
|
| `dsh-plugin-wsl-env/wsl-doctor-command` | `wsl-doctor-command` | [`lib/wsl-doctor-command.js`](../lib/wsl-doctor-command.js) | The `/wsl-doctor` UI command: spawns the standalone doctor CLI as a host subprocess and renders the same digest detached from model history. |
|
|
83
|
-
| `dsh-plugin-wsl-env/status` | `wsl-status` | [`lib/status.js`](../lib/status.js) | The sidebar panel's route (`GET /api/wsl-env/status`): lists the installed distros and runs one distro's quick doctor; `POST` on the same route runs the full doctor with `--fix-owned` (
|
|
84
|
+
| `dsh-plugin-wsl-env/status` | `wsl-status` | [`lib/status.js`](../lib/status.js) | The sidebar panel's route (`GET /api/wsl-env/status`): lists the installed distros and runs one distro's quick doctor; `POST` on the same route runs the full doctor with `--fix-owned` (which also repairs stale scopes or a broken agent cache and re-verifies both). `DELETE` on the same route clears one stored result (`?distro=<name>`) or every stored result, without listing or probing a distro. Answered over the Host connection's authenticated exact-Fetch channel; the last result per distro is persisted under `$DSH_HOME/cache/dsh-plugin-wsl-env/status.json` and stored results for running distros are refreshed in the background. |
|
|
84
85
|
| `dsh-plugin-wsl-env` (bare name) | `wsl-env-client-host` | [`lib/client-host.js`](../lib/client-host.js) | The deliberate no-op host half whose bare-name mount lets the web client roster serve `./client`: the sidebar's WSL environment panel and the post-add access-mode prompt. |
|
|
85
86
|
|
|
86
87
|
Three path and interop helpers import no DSH package.
|
|
@@ -108,7 +109,7 @@ The environment is per session, not per process:
|
|
|
108
109
|
| `subprocess-wsl` | at the app level, called the composition; the shipped `subprocess` row is disabled | because no session identity reaches the terminal controller, see below |
|
|
109
110
|
| `workspace-files` | shipped, not replaced | its client half is the browser `file` resource provider the Sidebar previews need; it reads WSL paths through the routed root filesystem |
|
|
110
111
|
| `fs-routing` | at the app level; the shipped `fs-sandbox` row is disabled | the root `ctx.fs` is session-less, and its write fence has no root-plane consumers |
|
|
111
|
-
| `directory-picker-wsl`, `wsl-shell-env`, `auto-preset`, `wsl-preflight`, `wsl-update-check`, `wsl-cwd-prompt`, `wsl-cwd-prompt-tool`, `wsl-doctor-command`, `wsl-status`, `wsl-env-client-host` | at the app level | they answer questions that are not scoped to a single preset; `shell-env` resolves its facts per session workspace, and the advisory/diagnosis rows must answer even when a session never opens |
|
|
112
|
+
| `directory-picker-wsl`, `wsl-shell-env`, `auto-preset`, `wsl-preflight`, `wsl-update-check`, `wsl-cwd-prompt`, `wsl-cwd-prompt-tool`, `wsl-doctor-command`, `wsl-status`, `wsl-plugin-update`, `wsl-env-client-host` | at the app level | they answer questions that are not scoped to a single preset; `shell-env` resolves its facts per session workspace, and the advisory/diagnosis rows must answer even when a session never opens |
|
|
112
113
|
| `wsl-doctor-tool` | inside `preset-wsl` (model-facing) | the tool surface follows the preset: a session on a Windows folder keeps the shipped tools |
|
|
113
114
|
|
|
114
115
|
The preset mount requires the isolate realms. Without them the registry rejects the
|
|
@@ -289,6 +290,20 @@ through `checkedTarget`, so the fence covers every mutation the provider can
|
|
|
289
290
|
serve. Both providers report their mode through `sandboxMode`. The tool layer
|
|
290
291
|
and the Permissions selector read that value.
|
|
291
292
|
|
|
293
|
+
**Socket isolation.** `bwrapProfileArgs` also accepts `socketMasks`: existing
|
|
294
|
+
socket paths bound `/dev/null` after the read-only root, plus `maskInterop`,
|
|
295
|
+
which mounts an empty tmpfs over `/run/WSL` — the WSL interop transport. The
|
|
296
|
+
confined providers (`wsl-shell`, `wsl-fs`, `fs-routing`) resolve them from
|
|
297
|
+
their `socketIsolation` stance — `session-bus` masks
|
|
298
|
+
the user systemd manager's bus and private socket, `strict` adds the system bus
|
|
299
|
+
and the container sockets the distro user can reach; `strict` also sets the
|
|
300
|
+
interop mask, so a copied PE fails at the host bridge. The masks close the
|
|
301
|
+
process-authority path the mount profile leaves open; they do not change the
|
|
302
|
+
file hierarchy, and same-user `/proc` and other IPC remain (the interop
|
|
303
|
+
closure for the rest of the distro is still `[interop] enabled=false`). The
|
|
304
|
+
in-distro probe that finds the paths lives in `lib/socket-isolation.js`; a
|
|
305
|
+
probe failure refuses the command instead of running unmasked.
|
|
306
|
+
|
|
292
307
|
### Reported enforcement
|
|
293
308
|
|
|
294
309
|
`WslSandbox` reports `enforcement: partial`, not `full`. A process inside the
|
|
@@ -419,7 +434,7 @@ leaves behind — neither feeds the runtime nor counts in the check.
|
|
|
419
434
|
| Doc consistency | [`scripts/check-doc-consistency.mjs`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/scripts/check-doc-consistency.mjs) | no; repeated facts, doctor surface and bilingual pair completeness |
|
|
420
435
|
| 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 |
|
|
421
436
|
| 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 |
|
|
422
|
-
| 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 |
|
|
437
|
+
| 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`, `cache-write.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 |
|
|
423
438
|
| 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 |
|
|
424
439
|
| 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 |
|
|
425
440
|
|
|
@@ -516,6 +531,7 @@ src/messages.ts the en/zh message catalogs and the host-locale wiri
|
|
|
516
531
|
src/native-agent.ts native binary selection and preparation
|
|
517
532
|
src/paths.ts pure conversion between the three path formats
|
|
518
533
|
src/picker.ts WslDirectoryPicker (ctx.directoryPicker)
|
|
534
|
+
src/plugin-update.ts the panel's version and one-click upgrade route
|
|
519
535
|
src/ports.ts the listening-port snapshot behind DSH_WSL_PORTS
|
|
520
536
|
src/preflight.ts session-start environment advisories
|
|
521
537
|
src/preset-choice.ts whether a new session adopts the WSL preset (pure)
|
|
@@ -529,6 +545,8 @@ src/session-runtime.ts shared session runtime and agent lifecycle
|
|
|
529
545
|
src/session-scope.ts systemd scope creation and cleanup
|
|
530
546
|
src/shell.ts the ctx.shell subpath entry point
|
|
531
547
|
src/shell-env.ts registers the DSH_WSL_* environment variables
|
|
548
|
+
src/socket-isolation.ts the socket facts probe and the /dev/null masks a
|
|
549
|
+
confined command's stance binds
|
|
532
550
|
src/subprocess.ts WslSubprocessRuntime (ctx.subprocess), the GUI
|
|
533
551
|
terminal window
|
|
534
552
|
src/terminal-activity.ts the distro-side activity probe for idle terminal
|
|
@@ -579,7 +597,7 @@ standalone CLI (peer-free by design, so it starts when the plugin's own
|
|
|
579
597
|
runtime is broken), the `/wsl-doctor` UI command (spawns the CLI host-side,
|
|
580
598
|
renders detached from model history), and the `wsl_doctor` model tool
|
|
581
599
|
(in-process, merging the live resident's state through `lib/doctor-live.js`).
|
|
582
|
-
The sidebar panel renders the quick digest and posts the
|
|
600
|
+
The sidebar panel renders the quick digest and posts the full-check action the
|
|
583
601
|
same way (`--fix-owned`: plugin-owned state only). A run can be scoped (`--quick`, `--sections <csv>` on the CLI; `depth` /
|
|
584
602
|
`section` on the tool), and the report itemizes every check grouped by
|
|
585
603
|
distro. See [DIAGNOSTICS.md](DIAGNOSTICS.md) for the surfaces and the
|
package/docs/ARCHITECTURE.zh.md
CHANGED
|
@@ -67,11 +67,12 @@ GUI 文件树与预览保留随包的 `workspace-files` 行。它的客户端半
|
|
|
67
67
|
| `dsh-plugin-wsl-env/shell-env` | `wsl-shell-env` | [`lib/shell-env.js`](../lib/shell-env.js) | 向受管的 `DSH_*` 命名空间贡献 `DSH_WSL_DISTRO`、`DSH_WSL_SHELL`、`DSH_WSL_HOME` 和 `DSH_WSL_PORTS`,并选取会话工作区所属的发行版(默认/钉死的事实于挂载时探测;其他发行版在其会话出现时预热)。端口列表是每个活跃发行版的快照,每 `portsRefreshMs`(默认 10000)刷新一次,因此刚启动的服务器可能尚未列出。 |
|
|
68
68
|
| `dsh-plugin-wsl-env/preflight` | `wsl-preflight` | [`lib/preflight.js`](../lib/preflight.js) | 在会话开始时运行环境提示——若 `startup: true`(默认值),还在插件加载时运行一次——把 doctor 风格的判定作为不阻断的警告呈现。 |
|
|
69
69
|
| `dsh-plugin-wsl-env/update-check` | `wsl-update-check` | [`lib/update-check.js`](../lib/update-check.js) | 大约每天一次向应用的插件管理器询问是否有更新的稳定版本,并把该事实带在 `DSH_WSL_PLUGIN_UPDATE` 中;自身从不抓取。 |
|
|
70
|
+
| `dsh-plugin-wsl-env/plugin-update` | `wsl-plugin-update` | [`lib/plugin-update.js`](../lib/plugin-update.js) | 侧边栏面板的版本与升级路由(`GET`/`POST /api/wsl-env/plugin-update`):经宿主插件管理器的 `listVersions` 报告已安装/运行中的插件版本与最新的可安装稳定版,按 `cacheMs` 缓存;只有点击后 `POST` 才调用 `updateBundle`,并报告宿主的重启、回滚或拒绝结果。 |
|
|
70
71
|
| `dsh-plugin-wsl-env/cwd-prompt` | `wsl-cwd-prompt` | [`lib/cwd-prompt.js`](../lib/cwd-prompt.js) | 把运行时上下文的工作目录条目改写为发行版的 POSIX 形式;新增一句 `wsl:shell` 说明;把 `sandbox:policy` 替换为仅 POSIX 的渲染;并在 WSL 会话中抑制宿主的 `harness:source` 值。后三项是临时适配器,跟踪于 [UPSTREAM-PROMPT-ADAPTERS.md](UPSTREAM-PROMPT-ADAPTERS.md)。 |
|
|
71
72
|
| `dsh-plugin-wsl-env/cwd-prompt-tool` | `wsl-cwd-prompt-tool` | [`lib/cwd-prompt-tool.js`](../lib/cwd-prompt-tool.js) | 以 harness 随包提供的相同语义提供模型的 read/`cd` 工具,把返回的 `cwd` 改写为发行版的 POSIX 形式。 |
|
|
72
73
|
| `dsh-plugin-wsl-env/wsl-doctor-tool` | `wsl-doctor-tool` | [`lib/wsl-doctor-tool.js`](../lib/wsl-doctor-tool.js) | `wsl_doctor` 模型工具:进程内的 doctor(合并活跃常驻 agent 的状态),按 `depth`/`section` 限定范围,渲染为逐项摘要。 |
|
|
73
74
|
| `dsh-plugin-wsl-env/wsl-doctor-command` | `wsl-doctor-command` | [`lib/wsl-doctor-command.js`](../lib/wsl-doctor-command.js) | `/wsl-doctor` UI 命令:把独立的 doctor CLI 作为宿主子进程启动,并在与模型历史分离的界面中渲染同一份摘要。 |
|
|
74
|
-
| `dsh-plugin-wsl-env/status` | `wsl-status` | [`lib/status.js`](../lib/status.js) | 侧边栏面板的路由(`GET /api/wsl-env/status`):列出已安装的发行版,并对其中一个发行版运行 quick doctor;同一路由上的 `POST`
|
|
75
|
+
| `dsh-plugin-wsl-env/status` | `wsl-status` | [`lib/status.js`](../lib/status.js) | 侧边栏面板的路由(`GET /api/wsl-env/status`):列出已安装的发行版,并对其中一个发行版运行 quick doctor;同一路由上的 `POST` 运行 `--fix-owned` 完整检查(同时修复陈旧的 scope 或损坏的 agent 缓存并重新验证);同一路由上的 `DELETE` 清除单个(`?distro=<名称>`)或全部已存结果,不枚举、不探测发行版。响应经 Host 连接已认证的 exact-Fetch 通道返回;每个发行版的最近结果持久化在 `$DSH_HOME/cache/dsh-plugin-wsl-env/status.json`,运行中发行版的已存结果会在后台刷新。 |
|
|
75
76
|
| `dsh-plugin-wsl-env`(裸名) | `wsl-env-client-host` | [`lib/client-host.js`](../lib/client-host.js) | 有意为之的空操作宿主半边;它的裸名挂载让 web 客户端名册能够提供 `./client`:侧边栏的 WSL 环境面板,以及添加后的访问模式提示。 |
|
|
76
77
|
|
|
77
78
|
三个路径与 interop 助手不导入任何 DSH 包。
|
|
@@ -97,7 +98,7 @@ YAML 数组;桌面应用通过侧边栏 **Plugins** 页面(**Add plugin**)
|
|
|
97
98
|
| `subprocess-wsl` | 在应用层(即组合层);随包的 `subprocess` 行被禁用 | 因为没有会话标识能到达终端控制器,见下文 |
|
|
98
99
|
| `workspace-files` | 随包、未替换 | 其客户端半边是侧边栏预览所需的浏览器 `file` 资源提供者;它通过被路由的根文件系统读取 WSL 路径 |
|
|
99
100
|
| `fs-routing` | 在应用层;随包的 `fs-sandbox` 行被禁用 | 根 `ctx.fs` 无会话,且其写围栏在根平面没有消费者 |
|
|
100
|
-
| `directory-picker-wsl`、`wsl-shell-env`、`auto-preset`、`wsl-preflight`、`wsl-update-check`、`wsl-cwd-prompt`、`wsl-cwd-prompt-tool`、`wsl-doctor-command`、`wsl-status`、`wsl-env-client-host` | 在应用层 | 它们回答的问题不限定于单个 preset;`shell-env` 按会话工作区解析其事实,而提示/诊断类行必须在会话从未打开时也能应答 |
|
|
101
|
+
| `directory-picker-wsl`、`wsl-shell-env`、`auto-preset`、`wsl-preflight`、`wsl-update-check`、`wsl-cwd-prompt`、`wsl-cwd-prompt-tool`、`wsl-doctor-command`、`wsl-status`、`wsl-plugin-update`、`wsl-env-client-host` | 在应用层 | 它们回答的问题不限定于单个 preset;`shell-env` 按会话工作区解析其事实,而提示/诊断类行必须在会话从未打开时也能应答 |
|
|
101
102
|
| `wsl-doctor-tool` | 位于 `preset-wsl` 内(面向模型) | 工具面跟随 preset:在 Windows 文件夹上的会话保留随包工具 |
|
|
102
103
|
|
|
103
104
|
preset 挂载需要隔离域。缺少时,registry 以
|
|
@@ -251,6 +252,16 @@ UNC/Linux 写法),丢弃已在工作区、`/tmp` 或 `/dev/shm` 下可写的
|
|
|
251
252
|
`checkedTarget`,因此围栏覆盖该提供者能服务的每个变更。两个提供者都通过
|
|
252
253
|
`sandboxMode` 上报模式。工具层和 Permissions 选择器读取该值。
|
|
253
254
|
|
|
255
|
+
**Socket 隔离。** `bwrapProfileArgs` 还接受 `socketMasks`:在只读根之后把已存在
|
|
256
|
+
的 socket 路径绑定到 `/dev/null`,以及 `maskInterop`:在 `/run/WSL`(WSL
|
|
257
|
+
interop 传输)上挂空的 tmpfs。受限提供者(`wsl-shell`、`wsl-fs`、
|
|
258
|
+
`fs-routing`)按各自的 `socketIsolation` 档位解析它们——`session-bus` 遮蔽用户
|
|
259
|
+
systemd 管理器的 bus 与 private socket,
|
|
260
|
+
`strict` 追加系统总线与发行版用户可触达的容器 socket。遮蔽关闭的是挂载 profile
|
|
261
|
+
留下的进程权限路径;不改变文件层级,同用户 `/proc`、interop 与其他 IPC 仍在。
|
|
262
|
+
在发行版内寻找这些路径的探针位于 `lib/socket-isolation.js`;探针失败时命令
|
|
263
|
+
被拒绝,而不是无遮蔽运行。
|
|
264
|
+
|
|
254
265
|
### 上报的强制程度
|
|
255
266
|
|
|
256
267
|
`WslSandbox` 上报 `enforcement: partial`,而不是 `full`。发行版内的进程仍可
|
|
@@ -368,7 +379,7 @@ peer 投影到安装处的同一份副本,因此镜像与运行中的应用共
|
|
|
368
379
|
| 文档一致性 | [`scripts/check-doc-consistency.mjs`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/scripts/check-doc-consistency.mjs) | 否;覆盖重复事实、doctor 面与双语对完整性 |
|
|
369
380
|
| 沙箱探针 | [`test/probe/sandbox.sh`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/test/probe/sandbox.sh) | 否;它直接应用 profile 参数 |
|
|
370
381
|
| Harness 探针 | [`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` | 是:Windows、WSL2、已挂载的 profile 和链接的检出目录 |
|
|
371
|
-
| 发行版探针 | [`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 和 WSL2,但不需要启动 harness,也不需要 profile:它们在装有 Node 的发行版终端中运行,经 interop 触达 `wsl.exe` |
|
|
382
|
+
| 发行版探针 | [`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`、`cache-write.sh`、`gui-preview.sh`、`file-reference-9p.sh` | 需要 Windows 和 WSL2,但不需要启动 harness,也不需要 profile:它们在装有 Node 的发行版终端中运行,经 interop 触达 `wsl.exe` |
|
|
372
383
|
| 宿主探针 | [`test/probe/mode.sh`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/test/probe/mode.sh) | Windows Node,无 harness |
|
|
373
384
|
| 探针插件 | `test/probe/` 中的 `*-probe.mjs` 与 `*-probe.yml` 文件(以及诸如 `gui-preview.mjs`、`native-session.mjs`、`fs-probe.mjs`、`fs-queue.mjs` 之类的独立测量器) | 由上述脚本加载或调用 |
|
|
374
385
|
|
|
@@ -464,6 +475,7 @@ src/messages.ts the en/zh message catalogs and the host-locale wiri
|
|
|
464
475
|
src/native-agent.ts native binary selection and preparation
|
|
465
476
|
src/paths.ts pure conversion between the three path formats
|
|
466
477
|
src/picker.ts WslDirectoryPicker (ctx.directoryPicker)
|
|
478
|
+
src/plugin-update.ts the panel's version and one-click upgrade route
|
|
467
479
|
src/ports.ts the listening-port snapshot behind DSH_WSL_PORTS
|
|
468
480
|
src/preflight.ts session-start environment advisories
|
|
469
481
|
src/preset-choice.ts whether a new session adopts the WSL preset (pure)
|
|
@@ -477,6 +489,8 @@ src/session-runtime.ts shared session runtime and agent lifecycle
|
|
|
477
489
|
src/session-scope.ts systemd scope creation and cleanup
|
|
478
490
|
src/shell.ts the ctx.shell subpath entry point
|
|
479
491
|
src/shell-env.ts registers the DSH_WSL_* environment variables
|
|
492
|
+
src/socket-isolation.ts the socket facts probe and the /dev/null masks a
|
|
493
|
+
confined command's stance binds
|
|
480
494
|
src/subprocess.ts WslSubprocessRuntime (ctx.subprocess), the GUI
|
|
481
495
|
terminal window
|
|
482
496
|
src/terminal-activity.ts the distro-side activity probe for idle terminal
|
|
@@ -521,7 +535,7 @@ peer 下限、新 agent 握手和陈旧的会话 scope,并报告带版本的 `
|
|
|
521
535
|
同一份报告通过三个界面应答:这个独立 CLI(设计上无 peer 依赖,因此插件自身
|
|
522
536
|
运行时损坏时它仍能启动)、`/wsl-doctor` UI 命令(在宿主侧启动 CLI,渲染与
|
|
523
537
|
模型历史分离),以及 `wsl_doctor` 模型工具(进程内,通过 `lib/doctor-live.js`
|
|
524
|
-
合并活跃常驻 agent
|
|
538
|
+
合并活跃常驻 agent 的状态)。侧边栏面板以同样方式渲染快速摘要并提交完整检查动作
|
|
525
539
|
(`--fix-owned`:仅插件自有状态)。运行可以限定范围(CLI 上的 `--quick`、
|
|
526
540
|
`--sections <csv>`;工具上的 `depth` / `section`),报告按发行版分组逐项列出
|
|
527
541
|
每项检查。各界面与判定契约见 [DIAGNOSTICS.zh.md](DIAGNOSTICS.zh.md)。
|
package/docs/CONFIGURATION.md
CHANGED
|
@@ -12,10 +12,11 @@ rows and values shipped by this plugin.
|
|
|
12
12
|
A profile layer can target a top-level row by `id`. Plugin rows at that level
|
|
13
13
|
include `fs-routing`, `directory-picker-wsl`, `subprocess-wsl`, `wsl-shell-env`,
|
|
14
14
|
`wsl-preflight`, `auto-preset`, `wsl-cwd-prompt`, `wsl-cwd-prompt-tool`,
|
|
15
|
-
`wsl-update-check`, `wsl-doctor-command`, `wsl-status`, `wsl-
|
|
16
|
-
`preset-wsl`. The `wsl-shell`, `wsl-fs` and
|
|
17
|
-
inside `preset-wsl.config.plugins`; a profile
|
|
18
|
-
is ignored with a `patch: entry <id> not
|
|
15
|
+
`wsl-update-check`, `wsl-doctor-command`, `wsl-status`, `wsl-plugin-update`,
|
|
16
|
+
`wsl-env-client-host`, and `preset-wsl`. The `wsl-shell`, `wsl-fs` and
|
|
17
|
+
`wsl-doctor-tool` rows are nested inside `preset-wsl.config.plugins`; a profile
|
|
18
|
+
entry targeting those ids directly is ignored with a `patch: entry <id> not
|
|
19
|
+
found` warning.
|
|
19
20
|
|
|
20
21
|
A root-level `- id: wsl-shell` / `wsl-fs` entry patches a top-level row that
|
|
21
22
|
does not exist in the shipped composition, so it is ignored with a warning.
|
|
@@ -40,7 +41,8 @@ pnpm run preset --distro Ubuntu --session-sandbox false
|
|
|
40
41
|
```
|
|
41
42
|
|
|
42
43
|
Supported edits are `--distro`, `--session-sandbox`, `--sandbox`,
|
|
43
|
-
`--mask-windows-drive`,
|
|
44
|
+
`--mask-windows-drive`, `--socket-isolation`, `--strict`, `--agent-backend` and
|
|
45
|
+
`--writable-roots`. Without `--out`, the helper
|
|
44
46
|
prints the full `preset-wsl` block to merge into the profile manually. Use
|
|
45
47
|
`pnpm run preset --check <file>` to detect profile layers that target nested
|
|
46
48
|
rows directly; on detecting them it prints the block to use. `--out` replaces
|
|
@@ -66,6 +68,7 @@ values. Re-copy it after a plugin upgrade that changes the preset.
|
|
|
66
68
|
| `sandbox` | `true` | Confine commands with `bwrap`. A missing or unusable `bwrap` fails closed. `false` runs commands without confinement. |
|
|
67
69
|
| `interopVisibility` | Unset; effective default is `visible` | `visible`, `masked`, or `disabled`. When set, this takes precedence over `maskWindowsDrive`. See [Windows interop](#windows-interop). |
|
|
68
70
|
| `maskWindowsDrive` | `false` | For confined commands, mount an empty tmpfs over `/mnt`. See [Windows interop](#windows-interop). |
|
|
71
|
+
| `socketIsolation` | `off` | Which socket surfaces a confined process cannot reach: `off`, `session-bus`, or `strict`. See [Socket isolation](#socket-isolation). |
|
|
69
72
|
| `writableRoots` | `[]` | Extra distro directories granted read-write under `workspace-write` (`~` allowed), for toolchain caches or a linked worktree's shared Git directory. Each entry must be an existing physical directory; entries already inside the workspace, `/tmp` or `/dev/shm`, or nested inside another grant, are ignored. Put the same list on `wsl-fs`. See [Toolchain caches](#toolchain-caches-and-extra-writable-roots). |
|
|
70
73
|
| `cwd` | `''` | Default workdir. Empty uses the distro user's home. |
|
|
71
74
|
| `timeoutMs` / `maxTimeoutMs` | `120000` / `600000` (shipped) | Default per-call timeout and the maximum timeout a call may request. |
|
|
@@ -82,6 +85,7 @@ values. Re-copy it after a plugin upgrade that changes the preset.
|
|
|
82
85
|
| `sandbox` | `true` | Check writes against the sandbox policy. Confined writes fail closed if `bwrap` is unavailable. |
|
|
83
86
|
| `sessionSandbox` | `false`; shipped `true` | Use the same session runtime as `wsl-shell`. `auto` falls back to a per-policy confined resident when the session runtime is unavailable. |
|
|
84
87
|
| `maskWindowsDrive` | `false` | Hide `/mnt` from confined mutations. Reads are unaffected. |
|
|
88
|
+
| `socketIsolation` | `off` | Same stance as on `wsl-shell`; the confined write resident and its session runtime use it. Keep the command, write and routing rows equal. See [Socket isolation](#socket-isolation). |
|
|
85
89
|
| `writableRoots` | `[]` | Same key and rules as on `wsl-shell`. Confined writes and commands must see one mount table, so configure the same list on both rows. See [Toolchain caches](#toolchain-caches-and-extra-writable-roots). |
|
|
86
90
|
| `substrate` | `agent` (shipped) | File operations use the in-distro agent. The legacy `share` value is refused at startup. |
|
|
87
91
|
| `cwd` | `''` | Base directory for relative paths. Empty uses the distro user's home. |
|
|
@@ -130,6 +134,13 @@ Rules:
|
|
|
130
134
|
UNC or Linux spelling), but it applies to the whole profile. When the same
|
|
131
135
|
profile also serves Windows sessions, prefer the plugin key above.
|
|
132
136
|
|
|
137
|
+
The doctor's `sandbox.grants` row lists both rows' configured roots, the
|
|
138
|
+
`~`-expanded absolute paths, and the physical check result, and warns when the
|
|
139
|
+
two lists differ; it creates no directory and edits no configuration.
|
|
140
|
+
`pnpm run probe:cache-write` proves the same path on a real machine — the
|
|
141
|
+
granted root is writable, an ungranted sibling stays `EROFS` — for both the
|
|
142
|
+
per-command profile and the session runtime.
|
|
143
|
+
|
|
133
144
|
### `fs-routing`
|
|
134
145
|
|
|
135
146
|
This top-level row serves root-level `ctx.fs` calls. It routes distro UNC paths
|
|
@@ -145,6 +156,7 @@ field value uses its schema default.
|
|
|
145
156
|
| `wslPath` | `wsl.exe` (shipped) | Path to `wsl.exe`, used to resolve the default distro. |
|
|
146
157
|
| `sandbox` | `true` (shipped) | Check routed mutations against `ctx.sandboxPolicy`; fail closed if `bwrap` is unavailable. The row reports `sandboxMode: undefined` whether the fence is enabled or disabled. |
|
|
147
158
|
| `maskWindowsDrive` | `false` (shipped) | Hide `/mnt` from confined routed mutations. |
|
|
159
|
+
| `socketIsolation` | `off` (shipped) | Same stance for the routed root's per-policy confined resident. See [Socket isolation](#socket-isolation). |
|
|
148
160
|
| `restrictToDistro` | `true` (shipped) | Refuse paths in another distro's share when `distro` is pinned. |
|
|
149
161
|
| `watchMaxDepth` | `0` (shipped) | Watch the full tree. A positive depth uses bounded polling. |
|
|
150
162
|
| `distroCwd` | `''` | Default distro workdir; empty uses the distro user's home. |
|
|
@@ -200,8 +212,9 @@ takes no configuration.
|
|
|
200
212
|
| `wsl-shell-env` | `distro` | `''` | Distro used to populate the `DSH_WSL_*` environment facts. |
|
|
201
213
|
| | `portsRefreshMs` | `10000` | Listening-port snapshot interval, in milliseconds. |
|
|
202
214
|
| `wsl-cwd-prompt` | `enabled` | `true` (shipped) | Rewrite the runtime context's working-directory entry to the distro's POSIX form. |
|
|
203
|
-
| `wsl-update-check` | `enabled` | `true` | Whether the plugin checks the app's plugin manager for a newer stable release. The result is served as `DSH_WSL_PLUGIN_UPDATE`; the check never installs. |
|
|
215
|
+
| `wsl-update-check` | `enabled` | `true` | Whether the plugin checks the app's plugin manager for a newer stable release. The result is served as `DSH_WSL_PLUGIN_UPDATE`; the background check never installs (the panel's one-click upgrade is a separate explicit POST). |
|
|
204
216
|
| | `intervalMs` | `86400000` | Check interval, in milliseconds (first check 2–10 minutes after startup); floored at one minute. |
|
|
217
|
+
| `wsl-plugin-update` | `cacheMs` | `600000` | How long the panel's version answer stays fresh, in milliseconds. The card shows the installed/running plugin versions and the newest installable stable release; **一键升级** calls the host plugin manager's `updateBundle` only on a click. |
|
|
205
218
|
|
|
206
219
|
The GUI file tree and previews use the bundled `workspace-files` row through
|
|
207
220
|
`fs-routing`; they do not use a separate WSL provider row. To change its
|
|
@@ -335,6 +348,68 @@ is covered by `test/probe/interop-shell.sh` for both resident and one-shot
|
|
|
335
348
|
commands. The distro-level disabled state requires a manual check because it
|
|
336
349
|
changes WSL configuration.
|
|
337
350
|
|
|
351
|
+
## Socket isolation
|
|
352
|
+
|
|
353
|
+
`socketIsolation` on the confined rows — `wsl-shell` (commands), `wsl-fs`
|
|
354
|
+
(confined writes) and `fs-routing` (the routed root) — decides which socket
|
|
355
|
+
surfaces a confined process cannot reach. The mount profile confines file
|
|
356
|
+
effects, not process authority: without this key a command can still ask the
|
|
357
|
+
user's systemd manager to start a unit outside the fence (the escape in
|
|
358
|
+
[SECURITY.md](../SECURITY.md)), or use a container daemon socket.
|
|
359
|
+
|
|
360
|
+
| Value | Effect |
|
|
361
|
+
|---|---|
|
|
362
|
+
| `off` (default) | Nothing masked. The documented `enforcement: partial` includes this path. |
|
|
363
|
+
| `session-bus` | Masks `$XDG_RUNTIME_DIR/bus` and `$XDG_RUNTIME_DIR/systemd/private`; `systemd-run --user` and `systemctl --user` fail inside the command. |
|
|
364
|
+
| `strict` | Adds `/run/dbus/system_bus_socket`, the container sockets (`docker`, `podman`, `containerd`, `crio`) that exist and are reachable by the distro user, and shadows `/run/WSL` — the WSL interop transport — so a Windows executable fails to start inside the profile. |
|
|
365
|
+
|
|
366
|
+
The paths are resolved inside the distro and bound `/dev/null`; a path that
|
|
367
|
+
does not exist is not masked. The key applies to every confined profile:
|
|
368
|
+
`wsl-shell` commands, the `wsl-fs` write resident, and the routed root's
|
|
369
|
+
per-policy resident. The filesystem rows run this plugin's fsio protocol,
|
|
370
|
+
never model-authored commands, but the masks keep one mount table across the
|
|
371
|
+
command and write planes and defend the resident if that protocol is ever
|
|
372
|
+
compromised. Keep the three rows equal.
|
|
373
|
+
|
|
374
|
+
The masks are a narrowing, not a closure: same-user `/proc` and other IPC
|
|
375
|
+
remain, so `enforcement` stays `partial`. `strict` additionally hides the WSL
|
|
376
|
+
interop transport; a PE copied into the workspace still exists but its
|
|
377
|
+
`/init` cannot reach the host bridge, so it fails at `connect`. That is not
|
|
378
|
+
the distro-wide closure: other distro processes and the Windows side still
|
|
379
|
+
interop, and `[interop] enabled=false` in `/etc/wsl.conf` plus `wsl.exe
|
|
380
|
+
--shutdown` remains the complete switch. `strict` breaks `systemctl --user`,
|
|
381
|
+
D-Bus, container clients and Windows-program launches inside confined
|
|
382
|
+
processes; `off` keeps the previous behavior.
|
|
383
|
+
|
|
384
|
+
`pnpm run probe:sandbox` measures the stances: the default profile reaches the
|
|
385
|
+
user manager, `session-bus` refuses `systemd-run --user` and masks the user
|
|
386
|
+
bus and private socket, and `strict` also masks the system bus, the reachable
|
|
387
|
+
container sockets and `/run/WSL`, and blocks a copied Windows executable. The
|
|
388
|
+
doctor's `sandbox.isolation` row reports the effective stance and the detected
|
|
389
|
+
surfaces. Configure it on the command and write rows:
|
|
390
|
+
|
|
391
|
+
```yaml
|
|
392
|
+
- id: wsl-shell
|
|
393
|
+
config:
|
|
394
|
+
socketIsolation: session-bus
|
|
395
|
+
- id: wsl-fs
|
|
396
|
+
config:
|
|
397
|
+
socketIsolation: session-bus
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
For the routed root, set the same value on the top-level `fs-routing` row:
|
|
401
|
+
|
|
402
|
+
```yaml
|
|
403
|
+
- id: fs-routing
|
|
404
|
+
config:
|
|
405
|
+
socketIsolation: session-bus
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
`pnpm run preset --socket-isolation session-bus` writes the two nested rows;
|
|
409
|
+
`pnpm run preset --strict` sets `socketIsolation: strict` and
|
|
410
|
+
`maskWindowsDrive: true` there. It does not rewrite the top-level `fs-routing`
|
|
411
|
+
row; add that by hand when the routed root is in use.
|
|
412
|
+
|
|
338
413
|
## Sandbox and preflight
|
|
339
414
|
|
|
340
415
|
`sandbox: true` is the default for `wsl-shell`, `wsl-fs`, and
|
|
@@ -445,7 +520,7 @@ error-code map. Whether a row override applied, read from the profile's
|
|
|
445
520
|
`cordis.patch.yml` and the Plugins page: the desktop app has no `dsh` command,
|
|
446
521
|
so the composed profile has no command-line view.
|
|
447
522
|
The sidebar's **WSL environment** panel renders the same quick digest over
|
|
448
|
-
`GET /api/wsl-env/status` and posts the full-
|
|
523
|
+
`GET /api/wsl-env/status` and posts the full-check action to the same route: a
|
|
449
524
|
doctor run with `--fix-owned`, which sweeps stale session scopes and purges a
|
|
450
525
|
broken agent cache, then re-verifies both. Each row states when the check ran, its source (manual or background) and its
|
|
451
526
|
result structure (per-status totals and per-section tallies). The last result
|
|
@@ -453,11 +528,20 @@ per distro is stored at `$DSH_HOME/cache/dsh-plugin-wsl-env/status.json`
|
|
|
453
528
|
(`~/.dsh/...` when the host names no home), so a page reload or app restart
|
|
454
529
|
still shows it. On load, a stored result for a distro that is currently
|
|
455
530
|
running is re-checked in the background; a failed background run overwrites
|
|
456
|
-
the stored result. Nothing is labeled expired —
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
531
|
+
the stored result. Nothing is labeled expired — each checked row offers
|
|
532
|
+
**清除** and the card offers **清除全部**; both `DELETE` the same route
|
|
533
|
+
(optionally with `?distro=`) to drop the stored verdict without enumerating,
|
|
534
|
+
probing or modifying a distro. Deleting the file still resets the panel's
|
|
535
|
+
history equivalently. Every row offers **快速检查** and **完整检查**: the
|
|
536
|
+
latter is the full doctor with `--fix-owned`, which repairs plugin-owned state
|
|
537
|
+
(stale session scopes or a broken agent cache) and re-verifies it. Both keep
|
|
538
|
+
their names after a result and run again on every click; every other warning
|
|
539
|
+
keeps its manual remedy. It never installs packages or rewrites Windows-owned
|
|
540
|
+
or user configuration.
|
|
541
|
+
Above the distro rows, the **Plugin version** card reads the installed and
|
|
542
|
+
running plugin versions and the newest installable stable release; its
|
|
543
|
+
**一键升级** button posts to `/api/wsl-env/plugin-update`, and only that click
|
|
544
|
+
asks the host plugin manager's `updateBundle` to install.
|
|
461
545
|
Use `scripts/bootstrap.sh <distro>` to inspect distro prerequisites.
|
|
462
546
|
|
|
463
547
|
| Symptom | Result | Action |
|
package/docs/CONFIGURATION.zh.md
CHANGED
|
@@ -12,7 +12,7 @@ profile 设置存放在 `$DSH_HOME/profiles/<name>/cordis.patch.yml`。可以用
|
|
|
12
12
|
profile 层可以按 `id` 指向顶层行。这一层的插件行包括 `fs-routing`、
|
|
13
13
|
`directory-picker-wsl`、`subprocess-wsl`、`wsl-shell-env`、`wsl-preflight`、
|
|
14
14
|
`auto-preset`、`wsl-cwd-prompt`、`wsl-cwd-prompt-tool`、`wsl-update-check`、
|
|
15
|
-
`wsl-doctor-command`、`wsl-status`、`wsl-env-client-host` 和 `preset-wsl`。
|
|
15
|
+
`wsl-doctor-command`、`wsl-status`、`wsl-plugin-update`、`wsl-env-client-host` 和 `preset-wsl`。
|
|
16
16
|
`wsl-shell`、`wsl-fs` 与 `wsl-doctor-tool` 嵌套在
|
|
17
17
|
`preset-wsl.config.plugins` 内;直接按这些 id 配置的 profile 条目会被忽略,
|
|
18
18
|
并产生 `patch: entry <id> not found` 警告。
|
|
@@ -38,7 +38,8 @@ pnpm run preset --distro Ubuntu --session-sandbox false
|
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
支持的修改是 `--distro`、`--session-sandbox`、`--sandbox`、
|
|
41
|
-
`--mask-windows-drive
|
|
41
|
+
`--mask-windows-drive`、`--socket-isolation`、`--strict`、`--agent-backend`
|
|
42
|
+
和 `--writable-roots`。不带 `--out` 时,辅助脚本
|
|
42
43
|
把完整的 `preset-wsl` 块打印出来,供你手动合并进 profile。
|
|
43
44
|
使用 `pnpm run preset --check <file>` 可以检测直接指向嵌套行的
|
|
44
45
|
profile 层;检测到时会打印应使用的块。`--out` 会整体替换目标文件,
|
|
@@ -64,6 +65,7 @@ profile 层;检测到时会打印应使用的块。`--out` 会整体替换目
|
|
|
64
65
|
| `sandbox` | `true` | 用 `bwrap` 约束命令。`bwrap` 缺失或不可用时关闭(fail closed)。`false` 则不加约束地运行命令。 |
|
|
65
66
|
| `interopVisibility` | 未设置;有效默认值为 `visible` | `visible`、`masked` 或 `disabled`。设置后优先于 `maskWindowsDrive`。见 [Windows interop](#windows-interop)。 |
|
|
66
67
|
| `maskWindowsDrive` | `false` | 对受限命令,在 `/mnt` 上挂载空的 tmpfs。见 [Windows interop](#windows-interop)。 |
|
|
68
|
+
| `socketIsolation` | `off` | 受限进程不能触达的 socket 面:`off`、`session-bus` 或 `strict`。见 [Socket isolation](#socket-isolation)。 |
|
|
67
69
|
| `writableRoots` | `[]` | `workspace-write` 下额外可写的发行版目录(`~` 可用),用于工具链缓存或 linked worktree 的共享 Git 目录。条目必须是已存在的物理目录;已在工作区、`/tmp`、`/dev/shm` 内或嵌套在另一条授权内的条目会被忽略。`wsl-fs` 上应配置同一列表。见[工具链缓存](#工具链缓存与额外可写目录)。 |
|
|
68
70
|
| `cwd` | `''` | 默认工作目录。空则使用发行版用户家目录。 |
|
|
69
71
|
| `timeoutMs` / `maxTimeoutMs` | `120000` / `600000`(shipped) | 默认的单次调用超时,以及一次调用可请求的最大超时。 |
|
|
@@ -80,6 +82,7 @@ profile 层;检测到时会打印应使用的块。`--out` 会整体替换目
|
|
|
80
82
|
| `sandbox` | `true` | 按沙箱策略检查写入。`bwrap` 不可用时,受限写入关闭(fail closed)。 |
|
|
81
83
|
| `sessionSandbox` | `false`;shipped 为 `true` | 使用与 `wsl-shell` 相同的会话 runtime。`auto` 在会话 runtime 不可用时回退到按策略约束的常驻 agent。 |
|
|
82
84
|
| `maskWindowsDrive` | `false` | 对受限变更隐藏 `/mnt`。读取不受影响。 |
|
|
85
|
+
| `socketIsolation` | `off` | 与 `wsl-shell` 同义的 socket 姿态;受限写入 resident 与其 session runtime 使用。命令、写入与路由三行应保持一致。见 [Socket isolation](#socket-isolation)。 |
|
|
83
86
|
| `writableRoots` | `[]` | 与 `wsl-shell` 的键同义、同规则。受限写入与命令必须看到同一挂载表,因此两行应配置同一个列表。见[工具链缓存](#工具链缓存与额外可写目录)。 |
|
|
84
87
|
| `substrate` | `agent`(shipped) | 文件操作使用发行版内 agent。旧值 `share` 在启动时被拒绝。 |
|
|
85
88
|
| `cwd` | `''` | 相对路径的基准目录。空则使用发行版用户家目录。 |
|
|
@@ -121,6 +124,11 @@ profile 层;检测到时会打印应使用的块。`--out` 会整体替换目
|
|
|
121
124
|
或 Linux 拼写),但它作用于整个 profile;同一 profile 里还有 Windows 会话时,
|
|
122
125
|
用上面的插件键更安全。
|
|
123
126
|
|
|
127
|
+
doctor 的 `sandbox.grants` 行会列出两行配置的根、`~` 展开后的绝对路径与物理
|
|
128
|
+
检查结果,并在两行列表不一致时告警;它不创建目录,也不修改配置。
|
|
129
|
+
`pnpm run probe:cache-write` 在真机上验证授予根可写、未授予的兄弟目录仍为
|
|
130
|
+
`EROFS`,覆盖 per-command profile 与 session runtime 两种形态。
|
|
131
|
+
|
|
124
132
|
### `fs-routing`
|
|
125
133
|
|
|
126
134
|
这个顶层行为根级 `ctx.fs` 调用提供服务。它把发行版 UNC 路径
|
|
@@ -136,6 +144,7 @@ Loader 在挂载该行之前会校验宿主和发行版设置;
|
|
|
136
144
|
| `wslPath` | `wsl.exe`(shipped) | `wsl.exe` 的路径,用于解析默认发行版。 |
|
|
137
145
|
| `sandbox` | `true`(shipped) | 按 `ctx.sandboxPolicy` 检查被路由的变更;`bwrap` 不可用时关闭(fail closed)。无论该围栏启用与否,该行都报告 `sandboxMode: undefined`。 |
|
|
138
146
|
| `maskWindowsDrive` | `false`(shipped) | 对受限的被路由变更隐藏 `/mnt`。 |
|
|
147
|
+
| `socketIsolation` | `off`(shipped) | 路由根平面按策略创建的受限 resident 使用同一 socket 姿态。见 [Socket isolation](#socket-isolation)。 |
|
|
139
148
|
| `restrictToDistro` | `true`(shipped) | `distro` 被固定时,拒绝属于其他发行版共享的路径。 |
|
|
140
149
|
| `watchMaxDepth` | `0`(shipped) | 监视整棵树。正值深度使用有界轮询。 |
|
|
141
150
|
| `distroCwd` | `''` | 默认发行版工作目录;空则使用发行版用户家目录。 |
|
|
@@ -190,8 +199,9 @@ Loader 在挂载该行之前会校验宿主和发行版设置;
|
|
|
190
199
|
| `wsl-shell-env` | `distro` | `''` | 用于填充 `DSH_WSL_*` 环境事实的发行版。 |
|
|
191
200
|
| | `portsRefreshMs` | `10000` | 监听端口快照的刷新间隔,单位毫秒。 |
|
|
192
201
|
| `wsl-cwd-prompt` | `enabled` | `true`(shipped) | 把 runtime context 的工作目录条目改写为发行版的 POSIX 形式。 |
|
|
193
|
-
| `wsl-update-check` | `enabled` | `true` | 插件是否向应用的插件管理器查询更新的稳定版。结果经 `DSH_WSL_PLUGIN_UPDATE`
|
|
202
|
+
| `wsl-update-check` | `enabled` | `true` | 插件是否向应用的插件管理器查询更新的稳定版。结果经 `DSH_WSL_PLUGIN_UPDATE` 送达;后台检查从不安装(面板的一键升级是独立的显式 POST)。 |
|
|
194
203
|
| | `intervalMs` | `86400000` | 检查间隔,单位毫秒(启动后 2–10 分钟首查);下限一分钟。 |
|
|
204
|
+
| `wsl-plugin-update` | `cacheMs` | `600000` | 面板内版本答案的新鲜时间,单位毫秒。卡片显示已安装/运行中的插件版本与最新的可安装稳定版;「一键升级」只在点击时调用宿主插件管理器的 `updateBundle`。 |
|
|
195
205
|
|
|
196
206
|
GUI 文件树和预览通过 `fs-routing` 使用随包的 `workspace-files` 行;
|
|
197
207
|
它们不使用单独的 WSL 提供者行。要修改其 peer 定义的限额,
|
|
@@ -317,6 +327,62 @@ pnpm run preset --sandbox true --mask-windows-drive true
|
|
|
317
327
|
由 `test/probe/interop-shell.sh` 对常驻与一次性两种命令都有覆盖。
|
|
318
328
|
发行版级的 disabled 状态需要手动检查,因为它会改动 WSL 配置。
|
|
319
329
|
|
|
330
|
+
## Socket isolation
|
|
331
|
+
|
|
332
|
+
受限行上的 `socketIsolation`——`wsl-shell`(命令)、`wsl-fs`(受限写入)与
|
|
333
|
+
`fs-routing`(路由根平面)——决定受限进程不能触达哪些 socket 面。挂载 profile
|
|
334
|
+
约束的是文件效果,不是进程权限:没有这个键,命令仍可请用户的 systemd 管理器在
|
|
335
|
+
围栏外启动 unit([SECURITY.zh.md](../SECURITY.zh.md) 记录的逃逸),或使用容器
|
|
336
|
+
守护进程的 socket。
|
|
337
|
+
|
|
338
|
+
| 值 | 效果 |
|
|
339
|
+
|---|---|
|
|
340
|
+
| `off`(默认) | 不遮蔽。文档化的 `enforcement: partial` 已包含这条路径。 |
|
|
341
|
+
| `session-bus` | 遮蔽 `$XDG_RUNTIME_DIR/bus` 与 `$XDG_RUNTIME_DIR/systemd/private`;命令内的 `systemd-run --user`、`systemctl --user` 失败。 |
|
|
342
|
+
| `strict` | 追加 `/run/dbus/system_bus_socket`、发行版用户可触达的容器 socket(`docker`、`podman`、`containerd`、`crio`),并遮蔽 `/run/WSL`——WSL interop 传输——profile 内的 Windows 可执行文件因此无法启动。 |
|
|
343
|
+
|
|
344
|
+
路径在发行版内解析后以 `/dev/null` 绑定;不存在的路径不遮蔽。该键作用于
|
|
345
|
+
每个受限 profile:`wsl-shell` 命令、`wsl-fs` 写入 resident 与路由根平面的
|
|
346
|
+
按策略 resident。文件行运行本插件的 fsio 协议,不执行模型编写的命令,但遮蔽
|
|
347
|
+
让命令面与写面保持同一张挂载表,并在该协议被攻破时保护 resident。三行应保持
|
|
348
|
+
一致。
|
|
349
|
+
|
|
350
|
+
遮蔽是收窄,不是关闭:同用户 `/proc` 与其他 IPC 仍在,因此 `enforcement`
|
|
351
|
+
仍是 `partial`。`strict` 额外遮蔽 WSL interop 传输;被复制进工作区的 PE
|
|
352
|
+
仍然存在,但它的 `/init` 连不到 host bridge,执行在 `connect` 处失败。这不是
|
|
353
|
+
整发行版关闭:其他 distro 进程与 Windows 侧仍可 interop,完整开关仍是
|
|
354
|
+
`/etc/wsl.conf` 的 `[interop] enabled=false` 加 `wsl.exe --shutdown`。
|
|
355
|
+
`strict` 会打断受限进程内的 `systemctl --user`、D-Bus、容器客户端与 Windows
|
|
356
|
+
程序启动;`off` 保持原行为。
|
|
357
|
+
|
|
358
|
+
`pnpm run probe:sandbox` 实测各档位:默认 profile 可达用户管理器,
|
|
359
|
+
`session-bus` 拒绝 `systemd-run --user` 并遮蔽总线与 private socket,
|
|
360
|
+
`strict` 还遮蔽系统总线、可达的容器 socket 与 `/run/WSL`,并阻止复制出的
|
|
361
|
+
Windows 可执行文件。doctor 的 `sandbox.isolation` 行报告生效档位与探测到的
|
|
362
|
+
面。在命令与写入行上配置:
|
|
363
|
+
|
|
364
|
+
```yaml
|
|
365
|
+
- id: wsl-shell
|
|
366
|
+
config:
|
|
367
|
+
socketIsolation: session-bus
|
|
368
|
+
- id: wsl-fs
|
|
369
|
+
config:
|
|
370
|
+
socketIsolation: session-bus
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
路由根平面使用顶层 `fs-routing` 行上的同一值:
|
|
374
|
+
|
|
375
|
+
```yaml
|
|
376
|
+
- id: fs-routing
|
|
377
|
+
config:
|
|
378
|
+
socketIsolation: session-bus
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
`pnpm run preset --socket-isolation session-bus` 写入两个嵌套行;
|
|
382
|
+
`pnpm run preset --strict` 在那里设置 `socketIsolation: strict` 与
|
|
383
|
+
`maskWindowsDrive: true`。它不重写顶层 `fs-routing` 行;使用路由根平面时需
|
|
384
|
+
手工添加。
|
|
385
|
+
|
|
320
386
|
## 沙箱与预检
|
|
321
387
|
|
|
322
388
|
`wsl-shell`、`wsl-fs` 和 `fs-routing` 的默认值都是 `sandbox: true`。
|
|
@@ -403,14 +469,20 @@ profile 补丁与废弃键陷阱——每个失败附可复制的修复。运行
|
|
|
403
469
|
某行的覆盖是否生效,直接查看 profile 的 `cordis.patch.yml` 与 Plugins 页面:
|
|
404
470
|
桌面应用没有 `dsh` 命令,合成后的 profile 没有命令行视图。
|
|
405
471
|
侧边栏的 **WSL 环境** 面板经 `GET /api/wsl-env/status` 渲染同一份快速摘要,
|
|
406
|
-
|
|
472
|
+
并把“完整检查”动作提交到同一路由:以 `--fix-owned` 运行 doctor,清扫残留
|
|
407
473
|
session scope、清理损坏的 agent 缓存并逐一复检。行内显示上次检查时间、来源(手动或后台)与结果结构(各状态计数与分区分布)。
|
|
408
474
|
每个发行版的最后一次结果存放在 `$DSH_HOME/cache/dsh-plugin-wsl-env/status.json`
|
|
409
475
|
(宿主未指定 home 时为 `~/.dsh/...`),页面刷新或应用重启后仍可见。加载时会对
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
476
|
+
正在运行的发行版在后台复核;后台失败会覆盖已存结果。不标记“已过期”——每个
|
|
477
|
+
已检查行提供“清除”、卡片头部提供“清除全部”,经同一路由的 `DELETE`(可带
|
|
478
|
+
`?distro=`)删除本地保存的结果,不枚举、不探测也不修改发行版;直接删除该文件
|
|
479
|
+
仍可等效重置面板历史。每行固定提供“快速检查”和“完整检查”两个检查动作:后者
|
|
480
|
+
以 `--fix-owned` 运行完整 doctor,会修复插件自有状态(残留 session scope、
|
|
481
|
+
损坏的 agent 缓存)并复检;两个按钮在结果出现后仍保持原名,再次点击即再次执行。
|
|
482
|
+
其余告警保留各自的手动处理办法。它不会安装软件包,也不会改写 Windows 或用户所有的配置。
|
|
483
|
+
在发行版行上方,「插件版本」卡片读取已安装与运行中的插件版本及最新的可安装稳定版;
|
|
484
|
+
它的「一键升级」提交到 `/api/wsl-env/plugin-update`,只有这次点击会调用宿主插件
|
|
485
|
+
管理器的 `updateBundle` 执行安装。
|
|
414
486
|
使用 `scripts/bootstrap.sh <distro>` 检查发行版前置依赖。
|
|
415
487
|
|
|
416
488
|
| 现象 | 结果 | 处理 |
|
package/docs/DIAGNOSTICS.md
CHANGED
|
@@ -46,7 +46,7 @@ and the verdict is recomputed — `ready`, or the remaining blockers. The
|
|
|
46
46
|
plugin-owned state is repaired automatically: the stale-scope sweep and a
|
|
47
47
|
purge of the agent cache when an entry is not executable (the handshake is
|
|
48
48
|
re-probed after the purge). `--fix-owned` narrows a run to exactly those two —
|
|
49
|
-
the sidebar panel's
|
|
49
|
+
the sidebar panel's full-check action uses it — and cannot be combined with
|
|
50
50
|
`--install`. Remedies that rewrite user- or distro-owned files (`.wslconfig`,
|
|
51
51
|
`/etc/wsl.conf`, a WSL1 conversion, installing a distro) are never automated;
|
|
52
52
|
the remedy text says so.
|
|
@@ -60,7 +60,10 @@ environment variables, and no telemetry.
|
|
|
60
60
|
|
|
61
61
|
The doctor answers through three surfaces with one report; the sidebar's
|
|
62
62
|
**WSL environment** panel renders the same quick digest over its own route and
|
|
63
|
-
posts the full-
|
|
63
|
+
posts the full-check action (`--fix-owned`, which also repairs plugin-owned
|
|
64
|
+
state). The same panel's **Plugin version** card is separate from the doctor: it reads the
|
|
65
|
+
installed/running plugin versions and offers the one-click upgrade through the
|
|
66
|
+
host plugin manager ([CONFIGURATION](CONFIGURATION.md), `wsl-plugin-update`).
|
|
64
67
|
|
|
65
68
|
- **The standalone CLI** — `node scripts/doctor.mjs [distro] [--all] [--json] [--quick] [--sections host,sandbox,session,conf,net,agent] [--fix] [--fix-owned] [--install] [--yes] [--read-only] [--bundle <path>] [--redact] [--locale <tag>]`
|
|
66
69
|
(the same line `--help` prints).
|
|
@@ -77,10 +80,12 @@ posts the full-run action (`--fix-owned`, labeled 修复 or 完整检查):
|
|
|
77
80
|
the itemized report renders detached from model history (no model turn, no
|
|
78
81
|
tokens). The sidebar's **WSL environment** panel runs the same quick
|
|
79
82
|
check per distro through the authenticated status route, showing a badge with
|
|
80
|
-
numbered failing items and warnings
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
numbered failing items and warnings. Every row offers two fixed check
|
|
84
|
+
actions: **快速检查** (the quick doctor scope) and **完整检查** (the full
|
|
85
|
+
doctor with `--fix-owned`, which also repairs plugin-owned state — stale
|
|
86
|
+
scopes or a broken agent cache — and answers with its before → after fix
|
|
87
|
+
rows). Both keep their names after a result and run again on every click;
|
|
88
|
+
there is no separate "recheck" action. The row also states when the check ran, its source
|
|
84
89
|
(manual or the page-load background refresh), and how its results landed —
|
|
85
90
|
per-status totals and per-section tallies. Each checked row expands to the
|
|
86
91
|
full list of checks that run executed, grouped by section with each status
|
|
@@ -89,7 +94,10 @@ posts the full-run action (`--fix-owned`, labeled 修复 or 完整检查):
|
|
|
89
94
|
(`$DSH_HOME/cache/dsh-plugin-wsl-env/status.json`, falling back to `~/.dsh`)
|
|
90
95
|
so a reload still shows it; a background refresh runs only for distros that
|
|
91
96
|
are already up, and a failed one replaces the stored result as observed.
|
|
92
|
-
|
|
97
|
+
Each checked row offers **清除** and the card offers **清除全部**; both
|
|
98
|
+
`DELETE` the same route, dropping the local store without starting a doctor
|
|
99
|
+
run or enumerating a distro. Manual warnings keep their remedies; full
|
|
100
|
+
diagnosis still uses the entry above and `/wsl-doctor`. Without a command adapter (headless, ACP) the row is a no-op and
|
|
93
101
|
the CLI is the surface. Without `--distro` the handler names the distro from
|
|
94
102
|
the session's live working directory (the agent-scoped `workingDirectory`
|
|
95
103
|
service first, then the Session header's `cwd`); when neither yields a WSL
|
|
@@ -162,9 +170,9 @@ Class legend:
|
|
|
162
170
|
|
|
163
171
|
| Code | Class | Doctor checks | In one line |
|
|
164
172
|
|---|---|---|---|
|
|
165
|
-
| `SANDBOX_UNAVAILABLE` | environment | `sandbox.bwrap`, `sandbox.bwrap-usable`, `functional.sandbox` | the requested confinement cannot be enforced
|
|
173
|
+
| `SANDBOX_UNAVAILABLE` | environment | `sandbox.bwrap`, `sandbox.bwrap-usable`, `functional.sandbox` | the requested confinement cannot be enforced: no usable bubblewrap, or a configured `socketIsolation` probe could not answer |
|
|
166
174
|
| `FS_SANDBOX_DENIED` | policy | `functional.sandbox` (the fence shape) | the file-effect policy refused the write, or the kernel refused it at the resident's profile |
|
|
167
|
-
| `SANDBOX_INVALID_ROOT` | configuration |
|
|
175
|
+
| `SANDBOX_INVALID_ROOT` | configuration | `sandbox.grants` (the `writableRoots` shape and physical directory; the `additionalWritableRoots` cross-world check still runs on first use) | an extra writable root is malformed, names another world, or fails the physical-directory check |
|
|
168
176
|
| `FS_OUTSIDE_DISTRO` | policy | `config.effective` (the effective `distro`) | the path names another distro's share while the fence is pinned |
|
|
169
177
|
| `FS_IO_ERROR` | environment | `distro.reachable`, `distro.disk`, `host.disk`, `agent.handshake`, `agent.home-writable`, `functional.exec`, `functional.fs` | the catch-all: an agent outage, a wedged distro, a full disk, an unmappable path |
|
|
170
178
|
| `FS_NOT_FOUND` | data | — | the path does not exist — the ordinary answer |
|
|
@@ -188,8 +196,11 @@ dialect itself is [AGENT-PROTOCOL-V7.md](AGENT-PROTOCOL-V7.md).
|
|
|
188
196
|
## When the doctor is green but a call still fails
|
|
189
197
|
|
|
190
198
|
That is the **policy** and **data** classes doing their jobs: a refusal the
|
|
191
|
-
doctor cannot predict because it depends on the call, not the machine.
|
|
192
|
-
|
|
199
|
+
doctor cannot predict because it depends on the call, not the machine. A
|
|
200
|
+
configured `socketIsolation` probe failure is the one environment refusal the
|
|
201
|
+
doctor does not preflight: the command names the stance and the remedy, and
|
|
202
|
+
`pnpm run probe:sandbox` is the verification. If a call fails repeatedly with
|
|
203
|
+
an **environment**-class code while the doctor
|
|
193
204
|
says `ready`, that is a bug — file it with the `doctor --bundle` output (a
|
|
194
205
|
[setup report](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/.github/ISSUE_TEMPLATE/setup_report.yml)
|
|
195
206
|
carries it).
|