dsh-plugin-wsl-env 0.24.0 → 0.26.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 +136 -0
- package/CODE_OF_CONDUCT.md +85 -0
- package/CODE_OF_CONDUCT.zh.md +85 -0
- package/CONTRIBUTING.md +19 -3
- package/CONTRIBUTING.zh.md +200 -0
- package/README.md +18 -6
- package/SECURITY.md +12 -0
- package/SECURITY.zh.md +108 -0
- package/SUPPORT.md +2 -0
- package/SUPPORT.zh.md +99 -0
- package/client.js +409 -8
- package/cordis.patch.yml +17 -0
- package/docs/AGENT-PROTOCOL-V7.md +2 -2
- package/docs/API.md +2 -0
- package/docs/API.zh.md +38 -0
- package/docs/ARCHITECTURE.md +30 -9
- package/docs/ARCHITECTURE.zh.md +511 -0
- package/docs/COMPATIBILITY.md +2 -0
- package/docs/COMPATIBILITY.zh.md +117 -0
- package/docs/CONFIGURATION.md +45 -2
- package/docs/CONFIGURATION.zh.md +39 -3
- package/docs/DIAGNOSTICS.md +12 -2
- package/docs/DIAGNOSTICS.zh.md +5 -1
- package/docs/LIMITATIONS.md +60 -9
- package/docs/LIMITATIONS.zh.md +45 -9
- package/docs/MIGRATION.md +6 -3
- package/docs/MIGRATION.zh.md +91 -0
- package/docs/PEER-PARITY.md +63 -51
- package/docs/PERFORMANCE.md +2 -0
- package/docs/PERFORMANCE.zh.md +59 -0
- package/docs/QUICKSTART.md +21 -6
- package/docs/QUICKSTART.zh.md +16 -4
- package/docs/README.zh.md +28 -19
- package/docs/RELEASING.md +19 -14
- package/docs/REQUIREMENTS.zh.md +6 -3
- package/docs/ROADMAP-1.0.md +1 -1
- package/docs/UPSTREAM-FILE-REFERENCE-SEAM.md +1 -1
- package/docs/UPSTREAM-FSIO-EXPORT.md +5 -4
- package/docs/UPSTREAM-OPEN-IN-APP.md +33 -11
- package/docs/UPSTREAM-PROMPT-ADAPTERS.md +85 -0
- package/docs/UPSTREAM-SESSION-NOTICE.md +7 -0
- package/docs/VALUE.md +146 -0
- package/docs/VALUE.zh.md +15 -13
- package/docs/root-fs-routing.md +1 -1
- package/lib/agent-confined.d.ts +7 -1
- package/lib/agent-confined.js +3 -3
- package/lib/auto-preset-seam.d.ts +45 -0
- package/lib/auto-preset-seam.js +47 -0
- package/lib/auto-preset.d.ts +33 -10
- package/lib/auto-preset.js +148 -44
- package/lib/bwrap.d.ts +14 -0
- package/lib/bwrap.js +11 -0
- package/lib/cwd-prompt.d.ts +41 -3
- package/lib/cwd-prompt.js +125 -8
- package/lib/doctor-live.d.ts +30 -0
- package/lib/doctor-live.js +37 -0
- package/lib/doctor-report.d.ts +50 -0
- package/lib/doctor-report.js +172 -0
- package/lib/fs-routing.d.ts +1 -1
- package/lib/fs-routing.js +1 -1
- package/lib/fs.d.ts +1 -1
- package/lib/fs.js +1 -1
- package/lib/index.d.ts +6 -1464
- package/lib/index.js +5 -2120
- package/lib/messages.d.ts +20 -1
- package/lib/messages.js +31 -3
- package/lib/open-in-app.d.ts +206 -0
- package/lib/open-in-app.js +300 -0
- package/lib/preflight.d.ts +7 -4
- package/lib/preflight.js +27 -13
- package/lib/preset-choice.d.ts +13 -0
- package/lib/preset-choice.js +18 -1
- package/lib/provider-common.d.ts +58 -0
- package/lib/provider-common.js +123 -0
- package/lib/sandbox-core.d.ts +1 -0
- package/lib/sandbox-core.js +4 -2
- package/lib/session-runtime.d.ts +7 -1
- package/lib/session-runtime.js +9 -2
- package/lib/shell.d.ts +1 -1
- package/lib/shell.js +1 -1
- package/lib/status.js +2 -1
- package/lib/writable-roots.d.ts +109 -0
- package/lib/writable-roots.js +257 -0
- package/lib/wsl-doctor-command.js +2 -1
- package/lib/wsl-doctor-tool.js +2 -2
- package/lib/wsl-filesystem.d.ts +692 -0
- package/lib/wsl-filesystem.js +897 -0
- package/lib/wsl-shell.d.ts +742 -0
- package/lib/wsl-shell.js +965 -0
- package/lib/wsl.d.ts +1 -1
- package/lib/wsl.js +1 -1
- package/package.json +48 -24
- package/scripts/doctor.mjs +1 -1
- package/scripts/profile-preset.mjs +17 -5
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Architecture
|
|
2
2
|
|
|
3
|
+
[中文](ARCHITECTURE.zh.md)
|
|
4
|
+
|
|
3
5
|
This file describes the plugin as it is today. It covers what the code does and
|
|
4
6
|
where each piece lives. The reasoning behind the design, including the designs that
|
|
5
7
|
were rejected, is recorded in [`CHANGELOG.md`](../CHANGELOG.md) and in
|
|
@@ -19,8 +21,8 @@ smaller integrations listed below.
|
|
|
19
21
|
|
|
20
22
|
| Service | Class | File | What it does |
|
|
21
23
|
|---|---|---|---|
|
|
22
|
-
| `ctx.shell` | `WslShellExecutor` | [`lib/
|
|
23
|
-
| `ctx.fs` | `WslFileSystem` | [`lib/
|
|
24
|
+
| `ctx.shell` | `WslShellExecutor` | [`lib/wsl-shell.js`](../lib/wsl-shell.js) | Runs each command in the distro's login shell over the resident in-distro agent (the default), wrapped in a distro-side `bwrap` sandbox; while the agent is out, or with `agent: false`, the same command falls back to one `wsl.exe -d <distro> --cd <linux dir> --exec <login shell> -lc <cmd>` process. |
|
|
25
|
+
| `ctx.fs` | `WslFileSystem` | [`lib/wsl-filesystem.js`](../lib/wsl-filesystem.js) | Serves WSL-routed file operations through the resident in-distro agent; the former Windows-side share substrate is retired (see below). |
|
|
24
26
|
| `ctx.subprocess` | `WslSubprocessRuntime` | [`lib/subprocess.js`](../lib/subprocess.js) | Opens the GUI terminal inside the distro, in the session workspace, and rewrites the file-search and git-snapshot spawns into the distro (see below). |
|
|
25
27
|
|
|
26
28
|
`WslShellExecutor` extends the shipped `LocalBashExecutor`, and `WslFileSystem`
|
|
@@ -70,18 +72,23 @@ functions.
|
|
|
70
72
|
| `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. |
|
|
71
73
|
| `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. |
|
|
72
74
|
| `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. |
|
|
73
|
-
| `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. |
|
|
75
|
+
| `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). |
|
|
74
76
|
| `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. |
|
|
75
77
|
| `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. |
|
|
76
78
|
| `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. |
|
|
77
79
|
| `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` (labeled repair when stale scopes or a broken agent cache are repairable, a full check otherwise; both re-verified). 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. |
|
|
78
80
|
| `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. |
|
|
79
81
|
|
|
80
|
-
Three
|
|
82
|
+
Three path and interop helpers import no DSH package.
|
|
81
83
|
[`lib/paths.js`](../lib/paths.js) translates paths.
|
|
82
84
|
[`lib/listing.js`](../lib/listing.js) builds directory listings and breadcrumbs.
|
|
83
85
|
[`lib/wsl.js`](../lib/wsl.js) holds the `wsl.exe` interop primitives.
|
|
84
86
|
|
|
87
|
+
[`lib/provider-common.js`](../lib/provider-common.js) is provider glue rather
|
|
88
|
+
than a peer-free helper: it imports `@deepseek-ai/dsh-sandbox` and shares distro
|
|
89
|
+
resolution, home caching, runtime selection and writable-root translation
|
|
90
|
+
between the shell and filesystem providers.
|
|
91
|
+
|
|
85
92
|
## How the pieces are mounted
|
|
86
93
|
|
|
87
94
|
[`cordis.patch.yml`](../cordis.patch.yml) is the bundle layer. It is a top-level
|
|
@@ -223,7 +230,7 @@ distro, and the argv is the same either way:
|
|
|
223
230
|
```text
|
|
224
231
|
wsl.exe -d <distro> --cd <linux dir> --exec bwrap \
|
|
225
232
|
--ro-bind / / --dev /dev --unshare-pid --proc /proc --die-with-parent \
|
|
226
|
-
[--tmpfs /tmp --bind <workspace> <workspace>] [--tmpfs /mnt] -- <shell> -lc <cmd>
|
|
233
|
+
[--tmpfs /tmp --bind <workspace> <workspace> [--bind <root> <root> ...]] [--tmpfs /mnt] -- <shell> -lc <cmd>
|
|
227
234
|
```
|
|
228
235
|
|
|
229
236
|
By default the profile wraps the session's resident agent ONCE, under
|
|
@@ -244,10 +251,19 @@ cannot be read or exfiltrated and its executables cannot be launched through
|
|
|
244
251
|
interop. The option is off by default; [CONFIGURATION.md](CONFIGURATION.md) lists
|
|
245
252
|
the row keys, and `lib/sandbox-core.js` states its honest ceiling.
|
|
246
253
|
|
|
254
|
+
The optional `--bind <root> <root>` pairs come from the row's `writableRoots`
|
|
255
|
+
and the shared policy's `additionalWritableRoots`. `lib/writable-roots.js`
|
|
256
|
+
resolves them (`~` expansion, UNC/Linux spelling), drops entries already
|
|
257
|
+
writable under the workspace, `/tmp` or `/dev/shm` and entries nested inside
|
|
258
|
+
another grant, then checks once per process that each remaining root is an
|
|
259
|
+
existing physical directory. The same effective list goes into the command
|
|
260
|
+
profile, the confined-write resident and the session runtime — and into their
|
|
261
|
+
cache keys, because the mount table is fixed for an agent's lifetime.
|
|
262
|
+
|
|
247
263
|
| Mode | What a command inside the distro can do |
|
|
248
264
|
|---|---|
|
|
249
265
|
| `read-only` | read the whole distro; a fresh `/dev` is mounted writable, so `/dev/null` and `/dev/shm` work, and nothing else does |
|
|
250
|
-
| `workspace-write` | the above, plus the session workspace
|
|
266
|
+
| `workspace-write` | the above, plus the session workspace and any explicitly granted roots are writable; `/tmp` is the distro's real `/tmp` in the session runtime, and a fresh tmpfs in the per-command profile (`sessionSandbox: false`) |
|
|
251
267
|
| `danger-full-access` | no sandbox; used for an approved wider-permission request |
|
|
252
268
|
|
|
253
269
|
`WslFileSystem` checks writes against the same policy and the same writable list,
|
|
@@ -320,11 +336,12 @@ own dialect, described after the table.
|
|
|
320
336
|
| Code | Raised by | Meaning | What clears it |
|
|
321
337
|
|---|---|---|---|
|
|
322
338
|
| `SANDBOX_UNAVAILABLE` | `WslSandbox.confine` | the requested mode cannot be enforced: no usable `bwrap` in the distro | install `bubblewrap` there (a failed probe is re-run, so no restart is needed), or set `sandbox: false` |
|
|
339
|
+
| `SANDBOX_INVALID_ROOT` | `effectiveWritableRoots` (both providers) | an entry in `writableRoots` or `additionalWritableRoots` is malformed, names another world, or fails the one-time physical-directory check | fix the entry; create the directory inside the distro first, use an absolute Linux path or `~/...`, and use the physical directory rather than a symlink |
|
|
323
340
|
| `FS_SANDBOX_DENIED` | `WslFileSystem.checkedTarget`, and `lib/fsio-agent.js` (a write the confined resident's mount table refused, classified from the kernel's `read-only file system`) | the file-effect policy refused the write: `read-only`, or a target outside the writable roots — or the kernel refused it at the resident's profile | a wider permission for that one call, or a session workspace that contains the target |
|
|
324
341
|
| `FS_OUTSIDE_DISTRO` | `WslFileSystem.worldPath` | `distro` is fixed (`default` or a name), `restrictToDistro` is on, and the path names **another distro**'s share — a configuration fence, not a sandbox decision. With `distro: ''`/`auto` a UNC target is served by its own distro, so the fence has nothing foreign to refuse | set `distro` to `''`/`auto` (the default), or open a session in that distro. A wider permission does **not** lift it |
|
|
325
342
|
| `FS_NOT_OBSERVED` | `lib/fs-substrate.js` (`writeText`; the agent's `exists` conclusion, mapped in `lib/fsio-agent.js`) | a guarded create (`createIfAbsent`) targeted a file that exists and had not been read first | read the file, then overwrite with the version guard or edit it |
|
|
326
343
|
| `FS_STALE_VERSION` | `lib/fs-substrate.js` (`writeText`, `editText`; the agent's `stale` conclusion, mapped in `lib/fsio-agent.js`) | the version the caller holds no longer matches: the file changed, or is gone | read it again and retry with the fresh version |
|
|
327
|
-
| `FS_IO_ERROR` | the filesystem stack: `lib/fs-decisions.js` (the substrate is unavailable), `lib/fsio-agent.js` (a `perm`/`loop`/`io` reason or a malformed record), `lib/
|
|
344
|
+
| `FS_IO_ERROR` | the filesystem stack: `lib/fs-decisions.js` (the substrate is unavailable), `lib/fsio-agent.js` (a `perm`/`loop`/`io` reason or a malformed record), `lib/wsl-filesystem.js` (a path that cannot be mapped, or a `SandboxUnavailableError`), and `WslFileSystem.watch` | the catch-all I/O failure — most often the resident agent is out or the distro returned an I/O error, the "agent outage fails closed" case above. A watch target outside the selected distro is the narrow one | get the resident back (check `wsl.exe -l -v`, then restart the session); for a watch, aim it at a distro path — the watch itself runs where the files live (`lib/watcher.js`) |
|
|
328
345
|
| `FS_NOT_FOUND` | `lib/fsio-agent.js` and `lib/fs-substrate.js` (the agent's `notfound`/`notdir` conclusion, an empty path, or a missing edit target), and the host filesystem stack behind a drive path | the path does not exist — the ordinary answer | — |
|
|
329
346
|
| `FS_NOT_REGULAR_FILE` | `lib/fsio-agent.js`, `lib/fs-substrate.js` | the target is not a regular file where one is required: a directory, symlink or device on a read, or a non-file target on a write | point the call at a regular file |
|
|
330
347
|
| `FS_NOT_DIRECTORY` | `lib/fsio-agent.js` (`listChildren`) | the target is not a directory, so there are no children to list | list a directory |
|
|
@@ -448,7 +465,7 @@ src/bwrap.ts the bwrap command line every confinement site
|
|
|
448
465
|
assert it)
|
|
449
466
|
src/client-host.ts the bare-name host half — a deliberate no-op that
|
|
450
467
|
anchors the browser client
|
|
451
|
-
src/cwd-prompt.ts rewrites the
|
|
468
|
+
src/cwd-prompt.ts rewrites the working directory; applies the temporary prompt adapters
|
|
452
469
|
to the distro's POSIX form
|
|
453
470
|
src/cwd-prompt-tool.ts serves the model's read/cd tool with distro-POSIX
|
|
454
471
|
cwd output
|
|
@@ -469,7 +486,11 @@ src/fsio-text.ts the peer's pure text mechanics, replicated pending
|
|
|
469
486
|
src/git-exec.ts the agent-backed execution handle for the
|
|
470
487
|
git-snapshot spawn
|
|
471
488
|
src/git-route.ts which git spawns belong inside the distro (pure)
|
|
472
|
-
src/index.ts
|
|
489
|
+
src/index.ts public provider exports
|
|
490
|
+
src/wsl-shell.ts WslShellExecutor (ctx.shell)
|
|
491
|
+
src/wsl-filesystem.ts WslFileSystem (ctx.fs)
|
|
492
|
+
src/doctor-report.ts in-process doctor collector used by the tool
|
|
493
|
+
src/provider-common.ts distro, home, runtime and writable-root helpers
|
|
473
494
|
src/listing.ts pure directory listing and breadcrumb helpers
|
|
474
495
|
src/messages.ts the en/zh message catalogs and the host-locale wiring
|
|
475
496
|
src/native-agent.ts native binary selection and preparation
|