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.
@@ -115,11 +115,11 @@ the 0.12.0 productization list.
115
115
 
116
116
  | ID | Outcome | Acceptance gate | Size |
117
117
  |---|---|---|---|
118
- | P0.1 | `distro: auto` coordinate routing across shell, fs, terminal, shell-env and the session runtime | Default Ubuntu + Debian workspace runs in Debian; two distro sessions concurrent; explicit pin still wins; cross-distro paths still refuse | L |
119
- | P0.2 | One `doctor`/`setup` path covering bwrap, systemd, Linger, optional tools, peers and config | Clean Win11 + Ubuntu passes in five minutes; missing bwrap, non-systemd, stopped distro and wrong peer each produce a copy-paste remedy | M |
120
- | P0.3 | Safe `preset-wsl` override helper and validation | Changing `sessionSandbox` or `distro` works in one step; an invalid nested patch fails loudly instead of warning | M |
121
- | P0.4 | Documentation and gate hygiene | The three known drifts are fixed; `fs-routing` enters the test lists; `probe:fs-routing` exists; links resolve | S |
122
- | P0.5 | Preflight visible before the first command | A missing bwrap or systemd/Linger is visible in the session UI, not only in `logger.warn` | M |
118
+ | [P0.1](#wsl-101--multi-distro-coordinate-routing) | `distro: auto` coordinate routing across shell, fs, terminal, shell-env and the session runtime | Default Ubuntu + Debian workspace runs in Debian; two distro sessions concurrent; explicit pin still wins; cross-distro paths still refuse | L |
119
+ | [P0.2](#wsl-102--doctor-and-one-command-setup) | One `doctor`/`setup` path covering bwrap, systemd, Linger, optional tools, peers and config | Clean Win11 + Ubuntu passes in five minutes; missing bwrap, non-systemd, stopped distro and wrong peer each produce a copy-paste remedy | M |
120
+ | [P0.3](#wsl-103--preset-override-guardrail) | Safe `preset-wsl` override helper and validation | Changing `sessionSandbox` or `distro` works in one step; an invalid nested patch fails loudly instead of warning | M |
121
+ | [P0.4](#wsl-104--documentation-and-gate-hygiene) | Documentation and gate hygiene | The three known drifts are fixed; `fs-routing` enters the test lists; `probe:fs-routing` exists; links resolve | S |
122
+ | [P0.5](#wsl-105--visible-preflight-and-systemdlinger-coverage) | Preflight visible before the first command | A missing bwrap or systemd/Linger is visible in the session UI, not only in `logger.warn` | M |
123
123
 
124
124
  P0 is not a performance phase. It is the difference between "the plugin is
125
125
  correct once configured" and "the plugin is correct on first contact".
@@ -128,15 +128,15 @@ correct once configured" and "the plugin is correct on first contact".
128
128
 
129
129
  | ID | Outcome | Acceptance gate | Size |
130
130
  |---|---|---|---|
131
- | P1.1 | `sessionSandbox: auto` for distros without systemd | Non-systemd distro runs the first command under per-command bwrap and reports the narrower scope; explicit `true` still refuses | M |
132
- | P1.2 | Compatibility matrix and real validation | Tier 1 (Ubuntu/Debian, systemd, x86_64) green; aarch64 spike runs under qemu; Tier 2 status documented | L |
133
- | P1.3 | Install/upgrade/uninstall E2E | Temporary `DSH_HOME`, packed tarball, `dsh plugin add`, `--dump-config`, remove; upgrade from the previous minor | M |
134
- | P1.4 | `@` references seam | Measure the 9p cost; land the upstream `FileReferenceTraversal` seam or a declared, tested fallback | L |
135
- | P1.5 | LSP provider spike | A documented plan and prototype for `ctx.lsp` over fs + subprocess, conditional on the desktop composition mounting LSP | M |
136
- | P1.6 | GUI preview performance | Baseline measured; p95 <= 1s/MiB for a representative page; v6 only if the measurement justifies it | M |
137
- | P1.7 | Agent recovery and status | In-flight death recovers within 2s or fails with a named state; `doctor`/status shows agent and scope health | M |
138
- | P1.8 | Security posture | Strict preset documented and probed; interop visibility/mask matrix; no claim beyond `partial` | S |
139
- | P1.9 | Peer upgrade canary | A scheduled check against the latest DSH line reports breakage before users do | S |
131
+ | [P1.1](#wsl-201--sessionsandbox-auto) | `sessionSandbox: auto` for distros without systemd | Non-systemd distro runs the first command under per-command bwrap and reports the narrower scope; explicit `true` still refuses | M |
132
+ | [P1.2](#wsl-202--compatibility-matrix-and-aarch64) | Compatibility matrix and real validation | Tier 1 (Ubuntu/Debian, systemd, x86_64) green; aarch64 spike runs under qemu; Tier 2 status documented | L |
133
+ | [P1.3](#wsl-203--installupgradeuninstall-e2e) | Install/upgrade/uninstall E2E | Temporary `DSH_HOME`, packed tarball, `dsh plugin add`, `--dump-config`, remove; upgrade from the previous minor | M |
134
+ | [P1.4](#wsl-204--references-seam) | `@` references seam | Measure the 9p cost; land the upstream `FileReferenceTraversal` seam or a declared, tested fallback | L |
135
+ | [P1.5](#wsl-205--lsp-provider-spike) | LSP provider spike | A documented plan and prototype for `ctx.lsp` over fs + subprocess, conditional on the desktop composition mounting LSP | M |
136
+ | [P1.6](#wsl-206--gui-preview-performance) | GUI preview performance | Baseline measured; p95 <= 1s/MiB for a representative page; v6 only if the measurement justifies it | M |
137
+ | [P1.7](#wsl-207--agent-recovery-and-status) | Agent recovery and status | In-flight death recovers within 2s or fails with a named state; `doctor`/status shows agent and scope health | M |
138
+ | [P1.8](#wsl-208--security-strict-profile-and-interop-matrix) | Security posture | Strict preset documented and probed; interop visibility/mask matrix; no claim beyond `partial` | S |
139
+ | [P1.9](#wsl-209--peer-upgrade-canary) | Peer upgrade canary | A scheduled check against the latest DSH line reports breakage before users do | S |
140
140
 
141
141
  ### P2 — make it the ecosystem default (3-6 months)
142
142
 
package/docs/ROADMAP.md CHANGED
@@ -20,7 +20,7 @@ section.
20
20
  | A4 | the native-session probe (scope, EXEC, FS, KILL, digest, teardown, 8/8) in the real-machine suite; the warm-cache and stdin-EPIPE fixes |
21
21
  | A5 | the native agent is the documented default; 0.10.0 published (npm + GitHub Release) |
22
22
  | A6 | `WslAgent.metrics()` and `test/probe/fs-queue.mjs`; the shared shell read agent is the measured batch bottleneck |
23
- | A7 | native shared read agent (v5); 16 concurrent shared reads 2.4–4.1 ms; shell remains the fallback |
23
+ | A7 | native shared read agent (protocol v5 at the time); 16 concurrent shared reads 2.4–4.1 ms at the A7 measurement; shell remains the fallback |
24
24
  | A8 | aarch64 18-check under qemu-user in CI (built binary and committed `linux-aarch64` artifact); physical aarch64 WSL out of scope, see COMPATIBILITY.md |
25
25
 
26
26
  ## Next
@@ -40,12 +40,14 @@ shell as the fallback:
40
40
  probe); the `WslAgent` with `expectedDigest` and `signalable: false`; on a
41
41
  preparation or HELLO failure the shell agent serves the reads — fail-open to
42
42
  the shell, never fail-closed;
43
- - **surface:** the same six v5 FS ops and `dsh-fs` side channel; the
43
+ - **surface:** the same six FS ops (unchanged since v5) and `dsh-fs` side
44
+ channel; the
44
45
  `fs-substrate`/`DistroFs` parse is unchanged; the A2 differential covers the
45
46
  records;
46
47
  - **result:** `WslAgent` gained a `prepare()` hook and the shared agent now
47
48
  selects the native entry through it. `test/probe/fs-queue.mjs` measures 16
48
- concurrent shared reads at **2.4-4.1 ms** (from 342-614 ms); the first start
49
+ concurrent shared reads at **2.4-4.1 ms** (from 342-614 ms; later reruns
50
+ span 2.4-8.2 ms); the first start
49
51
  pays the ensure/cache cost (~70 ms once). The shell still serves the reads
50
52
  under `agentBackend: shell` and after a native failure.
51
53
 
@@ -65,10 +67,12 @@ real aarch64 hardware is not planned.
65
67
 
66
68
  ## Deferred
67
69
 
68
- - **v6 (FS concurrency / ERR frames / per-request env).** The A6 measurement
70
+ - **v6 remainder (FS write-lock removal / per-request ERR frames).** The EXEC
71
+ stdin payload and the per-request env (`env --` argv prefix) landed with
72
+ protocol v6 in 0.17.0. The A6 measurement
69
73
  shows the lock-removal gain is marginal (~7.7 -> ~5 ms per 16 writes, ~12.2
70
- -> ~8 ms per 16 reads). Revisit only if the native shared v5 still queues
71
- measurably or the ERR/env framing is needed for another reason.
74
+ -> ~8 ms per 16 reads). Revisit only if the native shared agent still queues
75
+ measurably or per-request ERR framing is needed for another reason.
72
76
  - **Event stream.** No current consumer: the `fs.watch` contract is coarse and
73
77
  the inotify watcher satisfies it; terminal activity and ports poll.
74
78
  - **Shell retirement.** Not planned. The shell agent remains the fallback
@@ -1,6 +1,9 @@
1
1
  # Upstream seam: `@` references over a WSL workspace
2
2
 
3
- Status: measured and deferred (2026-10-19). The `@` completion in
3
+ Status: measured and deferred (2026-10-19; checked against a
4
+ `dsh-v0.2.1-rc.2`-era upstream — the checked version was not recorded at
5
+ the time. Plugin-side behavior re-verified 2026-11-02 against the current
6
+ peer floor, `>=0.2.1-rc.3`). The `@` completion in
4
7
  `@deepseek-ai/dsh-file-reference-local` walks the workspace with
5
8
  `node:fs/promises` (`readdir` + `lstat`) from the **Windows** harness process.
6
9
  For a WSL workspace that walk crosses the 9p share on every directory; the
@@ -120,8 +120,8 @@ locally (`src/fsio-agent.ts:27-36`, `src/fs-substrate.ts:37`,
120
120
  are.
121
121
 
122
122
  Importing from the entry costs this consumer nothing new: it already imports
123
- `LocalFileSystem` from the same entry (`src/index.ts:45`,
124
- `src/fs-routing.ts:35`) and `@deepseek-ai/dsh-fs` (`src/index.ts:46`). The
123
+ `LocalFileSystem` from the same entry (`src/index.ts:46`,
124
+ `src/fs-routing.ts:36`) and `@deepseek-ai/dsh-fs` (`src/index.ts:47`). The
125
125
  entry's non-builtin static imports are `chokidar` (`lib/index.js:3`),
126
126
  `@deepseek-ai/schemastery` (`:6`) and the `@deepseek-ai/dsh-fs` peer (`:7`) —
127
127
  all three already in this consumer's graph; `koffi` loads lazily (`await
@@ -0,0 +1,124 @@
1
+ # Upstream proposal: a same-name service swap that survives live recomposition
2
+
3
+ Status: observed, not yet filed. The failure was first seen on the desktop
4
+ `0.2.2-rc.1` release (app-bundled `@deepseek-ai/cordis@4.1.0` +
5
+ `@deepseek-ai/cordis-plugin-loader@1.1.0`; the npm line still ships
6
+ cordis `4.0.5` / loader `1.0.5`, which this repository pins), reproduced
7
+ in isolation against both version pairs on 2026-11-05, and the mechanism
8
+ is confirmed down to the `_unload` diff. Filing payload not yet drafted.
9
+
10
+ ## The gap
11
+
12
+ A plugin row that **replaces** a shipped row providing the same cordis
13
+ service (this plugin's `subprocess-wsl` over `subprocess`,
14
+ `fs-routing` over `fs-sandbox`, `directory-picker-wsl` over
15
+ `directory-picker`) cannot activate through a **live** bundle
16
+ enable/disable cycle while any consumer still holds the shipped
17
+ service. The enable reports `operation-error` with a diagnostic of the
18
+ shape:
19
+
20
+ ```
21
+ dsh: warning: 3 entries did not activate
22
+ subprocess-wsl (dsh-plugin-wsl-env/subprocess): Error: service "subprocess" has been registered at <LocalSubprocessRuntime>
23
+ directory-picker-wsl (dsh-plugin-wsl-env/picker): Error: service "directoryPicker" has been registered at <NativeDirectoryPicker>
24
+ fs-routing (dsh-plugin-wsl-env/fs-routing): Error: service "fs" has been registered at <SandboxedFileSystem>
25
+ ```
26
+
27
+ The composition itself is correct — the same patch list over an empty
28
+ root (a restart, or the install-time path) disables the shipped rows and
29
+ activates the replacements cleanly. Only the hot path fails.
30
+
31
+ ## Mechanism
32
+
33
+ Two independent version changes compose into the failure.
34
+
35
+ 1. **cordis 4.1.0 defers provision disposal behind dependent drain.**
36
+ `Fiber._unload` gained a first step that 4.0.5 did not have:
37
+
38
+ ```js
39
+ // 4.1.0 — provisions release only after every dependent has released
40
+ while ([...this.provisions].some((impl) => impl.dependents.size))
41
+ await new Promise((resolve) => this._release = resolve);
42
+ await Promise.all(this._disposables.clear().map(...)); // disposers run HERE
43
+ ```
44
+
45
+ 4.0.5 ran the disposers first thing. The provide disposer's
46
+ synchronous `delete this.store[...]` — the moment the service
47
+ registration slot frees — therefore moves from "at dispose() call
48
+ time" to "after every dependent fiber has released the service".
49
+
50
+ 2. **loader 1.1.0 awaits the disabled transition.** `Entry.update`'s
51
+ disabled branch changed from `this.fiber?.dispose()` (1.0.5,
52
+ fire-and-forget) to `await this.fiber?.dispose()` (1.1.0), so the
53
+ disable parks on the same dependent drain.
54
+
55
+ `EntryGroup.update` runs the disable and the insert of one
56
+ recomposition in one `Promise.all`, so the challenger fiber starts —
57
+ imports, applies, calls `ctx.provide` — while the shipped fiber still
58
+ holds the registration. Cordis's guard throws, the challenger's fiber
59
+ enters `FAILED`, and `recompose` reports every such entry as an
60
+ introduced failure. With live sessions holding the service, the drain
61
+ gate is exactly the thing that cannot clear: the old implementation
62
+ waits for dependents to release, and the dependents would only release
63
+ onto a replacement that cannot register. The enable fails deterministically
64
+ on a busy profile and stays failed until a restart.
65
+
66
+ ## Isolated reproduction
67
+
68
+ One file, driven against both version pairs (`cordis:group` group, one
69
+ provider, one challenger for the same service name, one dependent that
70
+ releases on a 2 s timer):
71
+
72
+ | Versions | During the hold | Error |
73
+ |---|---|---|
74
+ | cordis 4.0.5 + loader 1.0.5 (the 0.2.1 npm line) | challenger `ACTIVE` | none — the shipped slot frees at dispose() call time |
75
+ | cordis 4.1.0 + loader 1.1.0 (bundled in 0.2.2-rc.1) | challenger `FAILED`, shipped `UNLOADING` | `service "demo" has been registered at <shipper>` |
76
+
77
+ After the hold drains, the 4.1.0 challenger stays `FAILED` — the
78
+ collision error is terminal for that fiber; recomposition does not
79
+ retry it.
80
+
81
+ ## Impact scope
82
+
83
+ Any bundle whose rows take over a shipped service **by the same service
84
+ name** on a profile that hot-reloads (the desktop with HMR enabled).
85
+ Rows that provide distinct service names, config-only patches, and
86
+ preset-realm mounts are unaffected — the collision needs the same
87
+ isolate label on the same realm. This plugin's three root-plane
88
+ takeovers are the full affected set here; `wsl-shell-env`,
89
+ `auto-preset`, `wsl-preflight`, and `preset-wsl` activate through the
90
+ same toggle without complaint.
91
+
92
+ ## What would fix it upstream
93
+
94
+ The disable-then-insert ordering inside one group update cannot fix
95
+ this by itself — under the retain-until-drained semantics the old
96
+ registration survives the whole drain, however ordered. Directions
97
+ that would:
98
+
99
+ - **Stage the swap on the provide side**: when a fiber's
100
+ `ctx.provide` collides with an implementation that is currently
101
+ UNLOADING, queue the registration and complete it when the old
102
+ implementation's disposer frees the slot, instead of throwing.
103
+ - **Two-phase group updates**: run every disable transition to
104
+ settlement (or at least to provision release) before starting any
105
+ insert transition — the reverse of the `Promise.all` ordering, and
106
+ enough for every takeover where the old service's dependents can
107
+ drain onto nothing (no live sessions) or onto preset-realm
108
+ replacements.
109
+ - **A loader-level retry**: an entry whose activation failed with a
110
+ registration collision against a draining fiber is retried once that
111
+ fiber reaches `DISPOSED`. The failed state is otherwise terminal, so
112
+ today's behavior converts a transient overlap into a permanent
113
+ per-entry failure.
114
+
115
+ ## The plugin's posture until then
116
+
117
+ [docs/LIMITATIONS.md](LIMITATIONS.md#enabling-the-plugin-on-a-running-profile)
118
+ records the operator-facing rule: enabling (or re-enabling) the bundle
119
+ on a running profile reports the three entries as failed; the selection
120
+ is persisted, and **restarting the app applies it** — the cold
121
+ composition is correct. Closing sessions first also clears the drain
122
+ gate on the hot path, since with no dependents the shipped
123
+ implementation releases within the recomposition and the challengers
124
+ activate.
@@ -34,8 +34,14 @@ import z from "@deepseek-ai/schemastery";
34
34
  import { LocalFileSystem } from "@deepseek-ai/dsh-fs-local";
35
35
  import { WslFileSystem } from "./index.js";
36
36
  import type { Context } from "@deepseek-ai/cordis";
37
- import type { FsTarget, FsVersion, FsWriteIntent, FsEditRequest } from "@deepseek-ai/dsh-fs";
37
+ import type { FileSystem, FsEditRequest, FsTarget, FsVersion, FsWriteIntent } from "@deepseek-ai/dsh-fs";
38
38
  import type { SandboxExecutionPolicy } from "@deepseek-ai/dsh-sandbox";
39
+ /**
40
+ * The 0.2.2-rc.1 patch/move parameter shapes, derived from the peer's abstract
41
+ * surface so this file needs no dependency on `@deepseek-ai/dsh-fs-patch`.
42
+ */
43
+ type PatchHunks = Parameters<FileSystem["patchText"]>[1];
44
+ type MoveFileOptions = Parameters<FileSystem["moveFile"]>[2];
39
45
  /**
40
46
  * The router's config: the host backend's own knobs plus the distro knobs the
41
47
  * routed backend reads. The distro keys are `??`-defaulted, so a host-only
@@ -203,6 +209,50 @@ export declare class WslRoutingFileSystem extends LocalFileSystem {
203
209
  editText(target: FsTarget, edit: FsEditRequest, expected?: {
204
210
  version: FsVersion;
205
211
  }, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<import("@deepseek-ai/dsh-fs").FsEditOutcome>;
212
+ /**
213
+ * Route the peer's 0.2.2-rc.1 patch operation by the same coordinate rule
214
+ * as {@link editText}: a distro target reaches the distro backend (which
215
+ * refuses the operation honestly — the agent substrate has no patch op),
216
+ * a Windows target keeps the inherited host implementation.
217
+ *
218
+ * @param target - the resolved target.
219
+ * @param hunks - ordered hunks from the caller's patch parse.
220
+ * @param expected - the version the patch was based on.
221
+ * @param signal - cancels the patch.
222
+ * @param sandboxPolicy - the confined policy the distro side honors; the
223
+ * host backend takes no such parameter.
224
+ */
225
+ patchText(target: FsTarget, hunks: PatchHunks, expected?: {
226
+ version: FsVersion;
227
+ }, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<import("@deepseek-ai/dsh-fs").FsEditOutcome>;
228
+ /**
229
+ * Route the peer's 0.2.2-rc.1 delete operation like {@link patchText}:
230
+ * distro targets refuse at the distro backend, Windows targets keep the
231
+ * inherited host implementation.
232
+ *
233
+ * @param target - the resolved target.
234
+ * @param expected - the version the removal was based on.
235
+ * @param signal - cancels the removal.
236
+ * @param sandboxPolicy - the confined policy the distro side honors; the
237
+ * host backend takes no such parameter.
238
+ */
239
+ deleteFile(target: FsTarget, expected?: {
240
+ version: FsVersion;
241
+ }, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<import("@deepseek-ai/dsh-fs").FsDeleteOutcome>;
242
+ /**
243
+ * Route the peer's 0.2.2-rc.1 move operation like {@link patchText}: any
244
+ * distro-side endpoint sends the call to the distro backend (which refuses
245
+ * it honestly), two Windows endpoints keep the inherited host
246
+ * implementation.
247
+ *
248
+ * @param source - the resolved source.
249
+ * @param destination - the resolved destination.
250
+ * @param options - the hunks and the source/destination guards.
251
+ * @param signal - checked before the destination stages.
252
+ * @param sandboxPolicy - the confined policy the distro side honors; the
253
+ * host backend takes no such parameter.
254
+ */
255
+ moveFile(source: FsTarget, destination: FsTarget, options: MoveFileOptions, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<import("@deepseek-ai/dsh-fs").FsMoveOutcome>;
206
256
  /**
207
257
  * @param target - the resolved target.
208
258
  * @param changed - the change callback.
package/lib/fs-routing.js CHANGED
@@ -281,6 +281,61 @@ export class WslRoutingFileSystem extends LocalFileSystem {
281
281
  }
282
282
  return super.editText(target, edit, expected, signal);
283
283
  }
284
+ /**
285
+ * Route the peer's 0.2.2-rc.1 patch operation by the same coordinate rule
286
+ * as {@link editText}: a distro target reaches the distro backend (which
287
+ * refuses the operation honestly — the agent substrate has no patch op),
288
+ * a Windows target keeps the inherited host implementation.
289
+ *
290
+ * @param target - the resolved target.
291
+ * @param hunks - ordered hunks from the caller's patch parse.
292
+ * @param expected - the version the patch was based on.
293
+ * @param signal - cancels the patch.
294
+ * @param sandboxPolicy - the confined policy the distro side honors; the
295
+ * host backend takes no such parameter.
296
+ */
297
+ async patchText(target, hunks, expected, signal, sandboxPolicy) {
298
+ if (targetIsDistro(target.targetKey)) {
299
+ return (await this.distro()).patchText(target, hunks, expected, signal, sandboxPolicy);
300
+ }
301
+ return super.patchText(target, hunks, expected, signal);
302
+ }
303
+ /**
304
+ * Route the peer's 0.2.2-rc.1 delete operation like {@link patchText}:
305
+ * distro targets refuse at the distro backend, Windows targets keep the
306
+ * inherited host implementation.
307
+ *
308
+ * @param target - the resolved target.
309
+ * @param expected - the version the removal was based on.
310
+ * @param signal - cancels the removal.
311
+ * @param sandboxPolicy - the confined policy the distro side honors; the
312
+ * host backend takes no such parameter.
313
+ */
314
+ async deleteFile(target, expected, signal, sandboxPolicy) {
315
+ if (targetIsDistro(target.targetKey)) {
316
+ return (await this.distro()).deleteFile(target, expected, signal, sandboxPolicy);
317
+ }
318
+ return super.deleteFile(target, expected, signal);
319
+ }
320
+ /**
321
+ * Route the peer's 0.2.2-rc.1 move operation like {@link patchText}: any
322
+ * distro-side endpoint sends the call to the distro backend (which refuses
323
+ * it honestly), two Windows endpoints keep the inherited host
324
+ * implementation.
325
+ *
326
+ * @param source - the resolved source.
327
+ * @param destination - the resolved destination.
328
+ * @param options - the hunks and the source/destination guards.
329
+ * @param signal - checked before the destination stages.
330
+ * @param sandboxPolicy - the confined policy the distro side honors; the
331
+ * host backend takes no such parameter.
332
+ */
333
+ async moveFile(source, destination, options, signal, sandboxPolicy) {
334
+ if (targetIsDistro(source.targetKey) || targetIsDistro(destination.targetKey)) {
335
+ return (await this.distro()).moveFile(source, destination, options, signal, sandboxPolicy);
336
+ }
337
+ return super.moveFile(source, destination, options, signal);
338
+ }
284
339
  /**
285
340
  * @param target - the resolved target.
286
341
  * @param changed - the change callback.
package/lib/index.d.ts CHANGED
@@ -50,9 +50,17 @@ import { SessionRuntimes } from "./session-runtime.js";
50
50
  import type { AgentBackend } from "./native-agent.js";
51
51
  import type { SessionRuntimeEntry } from "./session-runtime.js";
52
52
  import type { Context } from "@deepseek-ai/cordis";
53
- import type { FsDirEntry, FsEditOutcome, FsEditRequest, FsInfo, FsPathInfo, FsTarget, FsVersion, FsWriteIntent, FsWriteOutcome } from "@deepseek-ai/dsh-fs";
53
+ import type { FsDeleteOutcome, FsDirEntry, FsEditOutcome, FsEditRequest, FsInfo, FsMoveOutcome, FsPathInfo, FsTarget, FsVersion, FsWriteIntent, FsWriteOutcome, FileSystem } from "@deepseek-ai/dsh-fs";
54
54
  import type { SandboxExecutionPolicy, SandboxMode } from "@deepseek-ai/dsh-sandbox";
55
55
  import type { SubprocessSpawnSpec } from "@deepseek-ai/dsh-subprocess";
56
+ /**
57
+ * The 0.2.2-rc.1 patch/move operations' parameter shapes, derived from the
58
+ * peer's abstract surface: `PatchHunk` lives in `@deepseek-ai/dsh-fs-patch`,
59
+ * which this package does not depend on, so the types ride in through the
60
+ * `FileSystem` declaration instead.
61
+ */
62
+ type PatchHunks = Parameters<FileSystem["patchText"]>[1];
63
+ type MoveFileOptions = Parameters<FileSystem["moveFile"]>[2];
56
64
  /**
57
65
  * Upstream shell vocabulary, derived through `@deepseek-ai/dsh-bash-local` —
58
66
  * this package does not depend on `@deepseek-ai/dsh-shell` directly, so the
@@ -1326,5 +1334,46 @@ export declare class WslFileSystem extends LocalFileSystem {
1326
1334
  editText(target: FsTarget, edit: FsEditRequest, expected?: {
1327
1335
  version: FsVersion;
1328
1336
  }, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsEditOutcome>;
1337
+ /**
1338
+ * Refuse the peer's 0.2.2-rc.1 patch operation. This backend serves the
1339
+ * distro world only, and every target it resolves carries a UNC identity:
1340
+ * the inherited host implementation would apply the hunks to a same-named
1341
+ * path on the Windows filesystem — or refuse with a host-dialect
1342
+ * `FS_NOT_FOUND` that names the wrong world. Fail closed here until the
1343
+ * agent substrate grows a patch op (see `docs/PEER-PARITY.md`, the new-peer
1344
+ * operations section).
1345
+ *
1346
+ * @param target - the resolved target.
1347
+ * @param _hunks - ordered hunks from the caller's patch parse; unused while the operation refuses.
1348
+ * @param _expected - the version guard; unused while the operation refuses.
1349
+ * @param _signal - cancellation; unused while the operation refuses.
1350
+ * @param _sandboxPolicy - the per-call policy; unused while the operation refuses.
1351
+ */
1352
+ patchText(target: FsTarget, _hunks: PatchHunks, _expected?: {
1353
+ version: FsVersion;
1354
+ }, _signal?: AbortSignal, _sandboxPolicy?: SandboxExecutionPolicy): Promise<FsEditOutcome>;
1355
+ /**
1356
+ * Refuse the peer's 0.2.2-rc.1 delete operation, for the same wrong-world
1357
+ * reason as {@link patchText}.
1358
+ *
1359
+ * @param target - the resolved target.
1360
+ * @param _expected - the version guard; unused while the operation refuses.
1361
+ * @param _signal - cancellation; unused while the operation refuses.
1362
+ * @param _sandboxPolicy - the per-call policy; unused while the operation refuses.
1363
+ */
1364
+ deleteFile(target: FsTarget, _expected?: {
1365
+ version: FsVersion;
1366
+ }, _signal?: AbortSignal, _sandboxPolicy?: SandboxExecutionPolicy): Promise<FsDeleteOutcome>;
1367
+ /**
1368
+ * Refuse the peer's 0.2.2-rc.1 move operation, for the same wrong-world
1369
+ * reason as {@link patchText}.
1370
+ *
1371
+ * @param source - the resolved source.
1372
+ * @param destination - the resolved destination.
1373
+ * @param _options - the hunks and guards; unused while the operation refuses.
1374
+ * @param _signal - cancellation; unused while the operation refuses.
1375
+ * @param _sandboxPolicy - the per-call policy; unused while the operation refuses.
1376
+ */
1377
+ moveFile(source: FsTarget, destination: FsTarget, _options?: MoveFileOptions, _signal?: AbortSignal, _sandboxPolicy?: SandboxExecutionPolicy): Promise<FsMoveOutcome>;
1329
1378
  }
1330
1379
  export {};
package/lib/index.js CHANGED
@@ -44,7 +44,7 @@ import { randomUUID } from "node:crypto";
44
44
  import { LocalBashExecutor } from "@deepseek-ai/dsh-bash-local";
45
45
  import { LocalFileSystem } from "@deepseek-ai/dsh-fs-local";
46
46
  import { FsError } from "@deepseek-ai/dsh-fs";
47
- import { canonicalPath, classifyRunnerFailure, isRunnerSpawnFailure, matchesSignature, SandboxUnavailableError, writableRoots } from "@deepseek-ai/dsh-sandbox";
47
+ import { canonicalPath, classifyRunnerFailure, isRunnerSpawnFailure, matchesSignature, SandboxInvalidRootError, SandboxUnavailableError, writableRoots } from "@deepseek-ai/dsh-sandbox";
48
48
  import { isAnotherDistrosUnc, isRelativeWorldPath, isWorldPathUnder, isWslUnc, posixToUnc, toLinuxPath, toWorldPath, uncToPosix, windowsToLinuxMount } from "./paths.js";
49
49
  import { isConfinedMutation, mutationModeRefusal, outsideDistroRefusal, shareSubstrateRefusal, substrateFailure, workspaceWriteDenial } from "./fs-decisions.js";
50
50
  import { distroOfUnc, isDefaultDistro, pinnedDistro, selectDistro } from "./distro-route.js";
@@ -135,13 +135,21 @@ async function distroHome(owner, distro) {
135
135
  * The roots a `workspace-write` policy may write under, in the vocabulary this
136
136
  * backend's targets are spelled in.
137
137
  *
138
- * Upstream's {@link writableRoots} grants the workspace plus the platform temp
139
- * areas (`/tmp`, `os.tmpdir()`). A session whose workspace lives inside a
140
- * distro speaks UNC, where neither host spelling matches anything, and the temp
141
- * area that world actually exposes is the distro's own `/tmp` — so that is what
142
- * is granted instead, and the Windows temp dir deliberately is NOT: it lies
143
- * outside the execution world the policy describes. A session whose workspace
144
- * is a Windows folder keeps upstream's grant verbatim.
138
+ * Upstream's {@link writableRoots} grants the workspace, its explicit extra
139
+ * directories (`additionalWritableRoots`), and the platform temp areas (`/tmp`,
140
+ * `os.tmpdir()`). A session whose workspace lives inside a distro speaks UNC,
141
+ * where neither host spelling matches anything, and the temp area that world
142
+ * actually exposes is the distro's own `/tmp` — so that is what is granted
143
+ * instead, and the Windows temp dir deliberately is NOT: it lies outside the
144
+ * execution world the policy describes. A session whose workspace is a Windows
145
+ * folder keeps upstream's grant verbatim.
146
+ *
147
+ * Extra directories follow the same world rule as the temp areas, and the same
148
+ * together-grant contract: an extra root that is a UNC path of the same distro
149
+ * is granted as-is; a Windows-path extra root cannot be granted inside the
150
+ * distro, and upstream's contract is that every backend grants every extra
151
+ * root together — so it fails closed with {@link SandboxInvalidRootError}
152
+ * rather than silently narrowing what `workspace-write` promised.
145
153
  *
146
154
  * @param policy - the per-call file-effect policy.
147
155
  * @param distro - the distro a UNC workspace belongs to.
@@ -153,6 +161,13 @@ function wslWritableRoots(policy, distro) {
153
161
  const roots = new Set([canonicalPath(policy.workspaceRoot)]);
154
162
  if (isWslUnc(policy.workspaceRoot)) {
155
163
  roots.add(canonicalPath(posixToUnc(distro, "/tmp")));
164
+ for (const root of policy.additionalWritableRoots ?? []) {
165
+ const parsed = uncToPosix(root);
166
+ if (parsed === undefined || parsed.distro !== distro) {
167
+ throw new SandboxInvalidRootError(root, `the workspace is inside distro ${JSON.stringify(distro)}; a Windows-path extra directory cannot be granted there`);
168
+ }
169
+ roots.add(canonicalPath(root));
170
+ }
156
171
  }
157
172
  else {
158
173
  for (const root of writableRoots(policy))
@@ -1801,4 +1816,47 @@ export class WslFileSystem extends LocalFileSystem {
1801
1816
  throw this.peerError(error);
1802
1817
  }
1803
1818
  }
1819
+ /**
1820
+ * Refuse the peer's 0.2.2-rc.1 patch operation. This backend serves the
1821
+ * distro world only, and every target it resolves carries a UNC identity:
1822
+ * the inherited host implementation would apply the hunks to a same-named
1823
+ * path on the Windows filesystem — or refuse with a host-dialect
1824
+ * `FS_NOT_FOUND` that names the wrong world. Fail closed here until the
1825
+ * agent substrate grows a patch op (see `docs/PEER-PARITY.md`, the new-peer
1826
+ * operations section).
1827
+ *
1828
+ * @param target - the resolved target.
1829
+ * @param _hunks - ordered hunks from the caller's patch parse; unused while the operation refuses.
1830
+ * @param _expected - the version guard; unused while the operation refuses.
1831
+ * @param _signal - cancellation; unused while the operation refuses.
1832
+ * @param _sandboxPolicy - the per-call policy; unused while the operation refuses.
1833
+ */
1834
+ async patchText(target, _hunks, _expected, _signal, _sandboxPolicy) {
1835
+ throw new FsError(`cannot patch "${target.displayPath}": the WSL substrate does not serve patch operations; the host implementation would target the wrong filesystem`, "FS_IO_ERROR");
1836
+ }
1837
+ /**
1838
+ * Refuse the peer's 0.2.2-rc.1 delete operation, for the same wrong-world
1839
+ * reason as {@link patchText}.
1840
+ *
1841
+ * @param target - the resolved target.
1842
+ * @param _expected - the version guard; unused while the operation refuses.
1843
+ * @param _signal - cancellation; unused while the operation refuses.
1844
+ * @param _sandboxPolicy - the per-call policy; unused while the operation refuses.
1845
+ */
1846
+ async deleteFile(target, _expected, _signal, _sandboxPolicy) {
1847
+ throw new FsError(`cannot delete "${target.displayPath}": the WSL substrate does not serve delete operations; the host implementation would target the wrong filesystem`, "FS_IO_ERROR");
1848
+ }
1849
+ /**
1850
+ * Refuse the peer's 0.2.2-rc.1 move operation, for the same wrong-world
1851
+ * reason as {@link patchText}.
1852
+ *
1853
+ * @param source - the resolved source.
1854
+ * @param destination - the resolved destination.
1855
+ * @param _options - the hunks and guards; unused while the operation refuses.
1856
+ * @param _signal - cancellation; unused while the operation refuses.
1857
+ * @param _sandboxPolicy - the per-call policy; unused while the operation refuses.
1858
+ */
1859
+ async moveFile(source, destination, _options, _signal, _sandboxPolicy) {
1860
+ throw new FsError(`cannot move "${source.displayPath}" to "${destination.displayPath}": the WSL substrate does not serve move operations; the host implementation would target the wrong filesystem`, "FS_IO_ERROR");
1861
+ }
1804
1862
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-plugin-wsl-env",
3
- "version": "0.17.0",
4
- "description": "\u5728 WSL \u7684 Linux \u5b9e\u4f8b\u4e2d\u6253\u5f00\u9879\u76ee\u5de5\u4f5c\u533a\uff0c\u5728\u5bf9\u5e94 Linux \u7a7a\u95f4\u4e2d\u8fdb\u884c\u547d\u4ee4\u6267\u884c\u3001\u8fd0\u884c shell \u811a\u672c\u548c\u6587\u4ef6\u8bbf\u95ee\uff0c\u4ee5\u83b7\u5f97\u5168\u5957 Linux Shell \u5de5\u5177\u94fe\u6536\u76ca\uff0c\u5e76\u901a\u8fc7 bubblewrap \u5bf9\u547d\u4ee4\u8fdb\u884c\u6c99\u7bb1\u9694\u79bb",
3
+ "version": "0.18.0",
4
+ "description": "在 WSL 的 Linux 实例中打开项目工作区,在对应 Linux 空间中进行命令执行、运行 shell 脚本和文件访问,以获得全套 Linux Shell 工具链收益,并通过 bubblewrap 对命令进行沙箱隔离",
5
5
  "keywords": [
6
6
  "deepseek-harness",
7
7
  "dsh",
@@ -100,6 +100,9 @@
100
100
  "docs/PERFORMANCE.md",
101
101
  "docs/COMPATIBILITY.md",
102
102
  "docs/CONFIGURATION.md",
103
+ "docs/LIMITATIONS.zh.md",
104
+ "docs/CONFIGURATION.zh.md",
105
+ "docs/QUICKSTART.zh.md",
103
106
  "docs/LIMITATIONS.md",
104
107
  "docs/RELEASING.md",
105
108
  "docs/REQUIREMENTS.zh.md",
@@ -114,6 +117,7 @@
114
117
  "docs/UPSTREAM-FILE-REFERENCE-SEAM.md",
115
118
  "docs/MIGRATION.md",
116
119
  "docs/UPSTREAM-SESSION-NOTICE.md",
120
+ "docs/UPSTREAM-SERVICE-SWAP.md",
117
121
  "docs/UPSTREAM-TERMINAL-TITLE.md",
118
122
  "docs/ARCHITECTURE.md",
119
123
  "docs/ROADMAP.md",
@@ -129,7 +133,7 @@
129
133
  "scripts/profile-preset.mjs"
130
134
  ],
131
135
  "scripts": {
132
- "test": "pnpm run lint:style && pnpm run lint:links && pnpm run test:syntax && pnpm run lint:build && pnpm run lint:types && pnpm run test:unit",
136
+ "test": "pnpm run lint:style && pnpm run lint:links && pnpm run lint:requirements && pnpm run test:syntax && pnpm run lint:build && pnpm run lint:types && pnpm run test:unit",
133
137
  "lint:types": "tsc --noEmit",
134
138
  "build": "node scripts/build.mjs",
135
139
  "lint:build": "node test/build-freshness.mjs",
@@ -138,6 +142,7 @@
138
142
  "test:unit": "node --test test/fs.boot.test.mjs test/fsio-text.test.mjs test/composition.test.mjs test/provider.test.mjs test/file-reference-wsl.test.mjs test/paths.test.mjs test/listing.test.mjs test/shell.test.mjs test/shell-env.test.mjs test/terminal.test.mjs test/probe-cache.test.mjs test/preflight.test.mjs test/preset-choice.test.mjs test/sandbox.test.mjs test/agent-protocol.test.mjs test/agent.test.mjs test/agent-fs-script.test.mjs test/fsio-agent.test.mjs test/fs-substrate.test.mjs test/agent-exec.test.mjs test/ports.test.mjs test/watcher.test.mjs test/wsl.test.mjs test/fs-decisions.test.mjs test/git-route.test.mjs test/search-route.test.mjs test/search-exec.test.mjs test/terminal-activity.test.mjs test/session-scope.test.mjs test/session-runtime.test.mjs test/native-agent.test.mjs test/peers.test.mjs test/agent-shared.test.mjs test/distro-route.test.mjs test/fs-routing.test.mjs test/doctor.test.mjs test/profile-preset.test.mjs test/packaging.test.mjs test/peer-canary.test.mjs test/probe-runner.test.mjs",
139
143
  "lint:style": "node test/style.mjs",
140
144
  "lint:links": "node scripts/check-links.mjs",
145
+ "lint:requirements": "node scripts/check-requirements.mjs",
141
146
  "prepublishOnly": "pnpm test",
142
147
  "probe": "bash test/probe/run.sh",
143
148
  "probe:missing-wsl": "bash test/probe/missing-wsl.sh",
@@ -185,35 +190,35 @@
185
190
  "url": "https://github.com/Big-Dao/dsh-plugin-wsl-env/issues"
186
191
  },
187
192
  "devDependencies": {
188
- "@deepseek-ai/cordis": "4.0.5",
189
- "@deepseek-ai/cordis-plugin-include": "*",
190
- "@deepseek-ai/cordis-plugin-loader": "*",
191
- "@deepseek-ai/dsh-bash-local": "0.2.1-rc.3",
192
- "@deepseek-ai/dsh-fs": "0.2.1-rc.3",
193
- "@deepseek-ai/dsh-fs-local": "0.2.1-rc.3",
194
- "@deepseek-ai/dsh-fs-sandbox": "0.2.1-rc.3",
195
- "@deepseek-ai/dsh-host-directory-picker": "0.2.1-rc.3",
196
- "@deepseek-ai/dsh-sandbox": "0.2.1-rc.3",
197
- "@deepseek-ai/dsh-sandbox-policy": "0.2.1-rc.3",
198
- "@deepseek-ai/dsh-subprocess": "0.2.1-rc.3",
199
- "@deepseek-ai/dsh-subprocess-local": "0.2.1-rc.3",
200
- "@deepseek-ai/dsh-typert-protocol": "0.2.1-rc.3",
193
+ "@deepseek-ai/cordis": "4.1.0",
194
+ "@deepseek-ai/cordis-plugin-include": "1.1.0",
195
+ "@deepseek-ai/cordis-plugin-loader": "1.1.0",
196
+ "@deepseek-ai/dsh-bash-local": "0.2.2-rc.1",
197
+ "@deepseek-ai/dsh-fs": "0.2.2-rc.1",
198
+ "@deepseek-ai/dsh-fs-local": "0.2.2-rc.1",
199
+ "@deepseek-ai/dsh-fs-sandbox": "0.2.2-rc.1",
200
+ "@deepseek-ai/dsh-host-directory-picker": "0.2.2-rc.1",
201
+ "@deepseek-ai/dsh-sandbox": "0.2.2-rc.1",
202
+ "@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.1",
203
+ "@deepseek-ai/dsh-subprocess": "0.2.2-rc.1",
204
+ "@deepseek-ai/dsh-subprocess-local": "0.2.2-rc.1",
205
+ "@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.1",
201
206
  "@types/js-yaml": "^4.0.9",
202
207
  "@types/node": "~22.20.5",
203
208
  "js-yaml": "4.3.2",
204
209
  "typescript": "~6.0.3"
205
210
  },
206
211
  "peerDependencies": {
207
- "@deepseek-ai/cordis": "^4.0.5",
208
- "@deepseek-ai/dsh-bash-local": ">=0.2.1-rc.3",
209
- "@deepseek-ai/dsh-fs": ">=0.2.1-rc.3",
210
- "@deepseek-ai/dsh-fs-local": ">=0.2.1-rc.3",
211
- "@deepseek-ai/dsh-host-directory-picker": ">=0.2.1-rc.3",
212
- "@deepseek-ai/dsh-sandbox": ">=0.2.1-rc.3",
213
- "@deepseek-ai/dsh-subprocess": ">=0.2.1-rc.3",
214
- "@deepseek-ai/dsh-subprocess-local": ">=0.2.1-rc.3",
215
- "@deepseek-ai/dsh-typert-protocol": ">=0.2.1-rc.3",
216
- "@deepseek-ai/schemastery": "^3.18.5"
212
+ "@deepseek-ai/cordis": "^4.1.0",
213
+ "@deepseek-ai/dsh-bash-local": ">=0.2.2-rc.1",
214
+ "@deepseek-ai/dsh-fs": ">=0.2.2-rc.1",
215
+ "@deepseek-ai/dsh-fs-local": ">=0.2.2-rc.1",
216
+ "@deepseek-ai/dsh-host-directory-picker": ">=0.2.2-rc.1",
217
+ "@deepseek-ai/dsh-sandbox": ">=0.2.2-rc.1",
218
+ "@deepseek-ai/dsh-subprocess": ">=0.2.2-rc.1",
219
+ "@deepseek-ai/dsh-subprocess-local": ">=0.2.2-rc.1",
220
+ "@deepseek-ai/dsh-typert-protocol": ">=0.2.2-rc.1",
221
+ "@deepseek-ai/schemastery": "^3.19.0"
217
222
  },
218
223
  "peerDependenciesMeta": {
219
224
  "@deepseek-ai/cordis": {