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.
Files changed (52) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/CONTRIBUTING.md +7 -4
  3. package/CONTRIBUTING.zh.md +3 -2
  4. package/README.md +1 -1
  5. package/SECURITY.md +21 -7
  6. package/SECURITY.zh.md +18 -5
  7. package/client.js +351 -48
  8. package/cordis.patch.yml +26 -10
  9. package/docs/API.md +2 -1
  10. package/docs/API.zh.md +2 -1
  11. package/docs/ARCHITECTURE.md +22 -4
  12. package/docs/ARCHITECTURE.zh.md +18 -4
  13. package/docs/CONFIGURATION.md +96 -12
  14. package/docs/CONFIGURATION.zh.md +80 -8
  15. package/docs/DIAGNOSTICS.md +22 -11
  16. package/docs/DIAGNOSTICS.zh.md +17 -9
  17. package/docs/LIMITATIONS.md +27 -4
  18. package/docs/LIMITATIONS.zh.md +20 -3
  19. package/docs/MIGRATION.md +2 -2
  20. package/docs/MIGRATION.zh.md +2 -2
  21. package/docs/QUICKSTART.md +31 -20
  22. package/docs/QUICKSTART.zh.md +16 -9
  23. package/docs/README.zh.md +1 -1
  24. package/docs/REQUIREMENTS.zh.md +3 -2
  25. package/lib/agent-confined.d.ts +9 -1
  26. package/lib/agent-confined.js +3 -3
  27. package/lib/bwrap.d.ts +16 -0
  28. package/lib/bwrap.js +9 -0
  29. package/lib/fs-routing.d.ts +3 -0
  30. package/lib/fs-routing.js +2 -0
  31. package/lib/messages.js +2 -2
  32. package/lib/plugin-update.d.ts +212 -0
  33. package/lib/plugin-update.js +283 -0
  34. package/lib/sandbox-core.d.ts +2 -0
  35. package/lib/sandbox-core.js +5 -3
  36. package/lib/session-runtime.d.ts +10 -1
  37. package/lib/session-runtime.js +3 -1
  38. package/lib/shell-env.js +1 -1
  39. package/lib/socket-isolation.d.ts +103 -0
  40. package/lib/socket-isolation.js +166 -0
  41. package/lib/status.d.ts +21 -8
  42. package/lib/status.js +53 -18
  43. package/lib/update-check.d.ts +49 -9
  44. package/lib/update-check.js +81 -28
  45. package/lib/wsl-doctor-tool.js +2 -0
  46. package/lib/wsl-filesystem.d.ts +39 -1
  47. package/lib/wsl-filesystem.js +51 -4
  48. package/lib/wsl-shell.d.ts +67 -3
  49. package/lib/wsl-shell.js +75 -12
  50. package/package.json +8 -3
  51. package/scripts/doctor.mjs +199 -3
  52. package/scripts/profile-preset.mjs +10 -2
@@ -0,0 +1,212 @@
1
+ /**
2
+ * The sidebar panel's plugin route: version information, update availability,
3
+ * and the confirmed one-click upgrade.
4
+ *
5
+ * The version answer is the host plugin-manager's, not ours: `listVersions`
6
+ * resolves dist-tags, deprecation, and the `engines.dsh`/peer compatibility of
7
+ * every candidate against the running DSH, and `updateBundle` performs the
8
+ * replacement with the profile's normal package manager rules (bundle
9
+ * selection, exact version, rollback). This row only gives the panel a
10
+ * browser-reachable, authenticated exact-Fetch route to that service:
11
+ *
12
+ * - `GET /api/wsl-env/plugin-update` — the installed and running version,
13
+ * the latest stable release that can replace it, and the last check's
14
+ * outcome. A stale answer is re-read; `refresh=1` forces a fresh check.
15
+ * - `POST /api/wsl-env/plugin-update` — install that release through
16
+ * `updateBundle`. It is one click in the panel, never automatic: a plugin
17
+ * that silently replaces its own code under a running harness is a
18
+ * posture this plugin rejects.
19
+ *
20
+ * Nothing here fetches the registry or runs pnpm directly. A host without a
21
+ * plugin-manager (or one from before `updateBundle` existed) still gets the
22
+ * installed version and an explanation; a linked checkout is refused by the
23
+ * host as `not-updatable` and the panel points at the Plugins page instead.
24
+ *
25
+ * This is a TypeScript source built to `lib/plugin-update.js`; edit THIS file
26
+ * and run `pnpm run build` — the artifact under `lib/` is generated, and
27
+ * `pnpm test` fails when it drifts.
28
+ *
29
+ * @module dsh-plugin-wsl-env/plugin-update
30
+ */
31
+ import z from "@deepseek-ai/schemastery";
32
+ import { type ListedVersion, type PluginManagerSlice, type VersionCheck } from "./update-check.js";
33
+ export declare const name = "wsl-plugin-update";
34
+ /** The one route the panel fetches; it must live under the `/api` channel. */
35
+ export declare const PLUGIN_UPDATE_PATH = "/api/wsl-env/plugin-update";
36
+ /** How long a version answer stays fresh before a panel load re-reads it. */
37
+ export declare const DEFAULT_CACHE_MS: number;
38
+ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
39
+ /** How long a version answer stays fresh, in milliseconds. */
40
+ cacheMs: z<number, number, "defined">;
41
+ }>>, Schemastery.ObjectT<NoInfer<{
42
+ /** How long a version answer stays fresh, in milliseconds. */
43
+ cacheMs: z<number, number, "defined">;
44
+ }>>, "plain">;
45
+ /** The config schema's validated output. */
46
+ export interface PluginUpdateConfig {
47
+ /** How long a version answer stays fresh, in milliseconds. */
48
+ cacheMs?: number;
49
+ }
50
+ /** One application outcome, as the host's plugin-manager reports it. */
51
+ export type ChangeApplication = "applied" | "restart-required" | "overridden" | "failed" | "cancelled";
52
+ /** One host change result, reduced to what this route reads. */
53
+ interface ChangeOutcome {
54
+ readonly changed: boolean;
55
+ readonly application: ChangeApplication;
56
+ readonly restartReason?: string;
57
+ readonly stage: string;
58
+ readonly target: string;
59
+ readonly error?: {
60
+ readonly code?: string;
61
+ readonly diagnostic?: string;
62
+ } | undefined;
63
+ readonly pendingBuilds?: readonly string[];
64
+ }
65
+ /** What `updateBundle` answers (host plugin-manager types). */
66
+ export interface UpdateBundleResult {
67
+ readonly from: string;
68
+ readonly to: string;
69
+ readonly step: "check" | "remove" | "install";
70
+ readonly result: ChangeOutcome;
71
+ readonly restore?: ChangeOutcome | undefined;
72
+ }
73
+ /** The slice of the host's plugin-manager the one-click upgrade needs. */
74
+ export interface UpdateManagerSlice extends PluginManagerSlice {
75
+ /** Replace an installed bundle with one newer exact version. */
76
+ updateBundle: (name: string, version: string, options?: {
77
+ readonly registry?: string | null;
78
+ }) => Promise<UpdateBundleResult>;
79
+ }
80
+ /** The version answer the panel renders. */
81
+ export interface PluginVersionView {
82
+ /** The version installed on disk now. */
83
+ installed: string;
84
+ /** The version this process loaded; it lags `installed` until a reload. */
85
+ running: string;
86
+ /** What the last check learned. */
87
+ status: VersionCheck["status"];
88
+ /** When that check ran, in epoch milliseconds. */
89
+ checkedAt: number;
90
+ /** Whether that answer came from the in-process cache. */
91
+ cached: boolean;
92
+ /** Whether the host's plugin-manager can perform an update. */
93
+ updateSupported: boolean;
94
+ /** Whether the panel may offer the one-click upgrade. */
95
+ canUpdate: boolean;
96
+ /** The registry that answered the check. */
97
+ registry?: string | null;
98
+ /** The installable stable release, when one is available. */
99
+ latest?: ListedVersion;
100
+ /** Why a check produced no answer. */
101
+ problem?: string;
102
+ /** The host's explanation for an unavailable check. */
103
+ reason?: string;
104
+ }
105
+ /** The POST answer: the host's outcome plus the versions now on disk and in memory. */
106
+ export interface PluginUpdateReply {
107
+ /** Whether the target version is now installed. */
108
+ updated: boolean;
109
+ /** The last step's application outcome. */
110
+ application: ChangeApplication;
111
+ /** The version the update started from. */
112
+ from: string;
113
+ /** The version it targeted. */
114
+ to: string;
115
+ /** The last step that ran. */
116
+ step: UpdateBundleResult["step"];
117
+ /** The version installed on disk after the attempt. */
118
+ installed: string;
119
+ /** The version this process still runs. */
120
+ running: string;
121
+ /** When the attempt settled, in epoch milliseconds. */
122
+ checkedAt: number;
123
+ /** Why a successful install needs a restart, when it does. */
124
+ restartReason?: string;
125
+ /** Whether the old version was reinstalled after a failed target install. */
126
+ restored?: boolean;
127
+ /** Why the update could not install its target. */
128
+ error?: {
129
+ code?: string;
130
+ diagnostic?: string;
131
+ };
132
+ /** Package scripts awaiting explicit approval in the profile. */
133
+ pendingBuilds?: readonly string[];
134
+ /** Why the reinstallation of the old version failed, when it did. */
135
+ restoreError?: {
136
+ code?: string;
137
+ diagnostic?: string;
138
+ };
139
+ }
140
+ /** The route handler this module publishes. */
141
+ export type PluginUpdateHandler = (request: Request) => Promise<Response>;
142
+ /** One exact route's registration shape. */
143
+ interface ConnectionRoute {
144
+ readonly path: string;
145
+ readonly methods: readonly string[];
146
+ readonly requestBody: "buffered" | "streaming";
147
+ readonly fetch: (request: Request) => Promise<Response>;
148
+ }
149
+ /** The connection slice this row registers into. */
150
+ interface ConnectionFace {
151
+ /** The exact-Fetch route registry. */
152
+ readonly fetch: {
153
+ /** Register one exact route; the returned disposer withdraws it. */
154
+ register: (route: ConnectionRoute) => () => Promise<void> | void;
155
+ };
156
+ }
157
+ /** The context slice this row consumes. */
158
+ interface PluginUpdateContext {
159
+ /** Optional cordis-style lookup: how production resolves the connection. */
160
+ get?: (name: string) => unknown;
161
+ /** Wait for a service, then run the callback in its scope. */
162
+ inject?: (deps: readonly string[], callback: (scope: PluginUpdateContext) => void) => unknown;
163
+ /** Own one disposer on the calling fiber. */
164
+ effect?: (callback: () => () => void, label?: string) => unknown;
165
+ /** The Host connection whose `/api` channel carries the route. */
166
+ connection?: ConnectionFace;
167
+ }
168
+ /** The handler options a test builds directly. */
169
+ export interface PluginUpdateHandlerOptions {
170
+ /** The host plugin-manager, or undefined when the host has none. */
171
+ manager: () => PluginManagerSlice | undefined;
172
+ /** How long a version answer stays fresh. */
173
+ cacheMs: number;
174
+ /** Clock seam. */
175
+ now?: () => number;
176
+ /** The installed version, read from this package's manifest. */
177
+ installed?: () => string;
178
+ /** The version this process loaded. */
179
+ running?: string;
180
+ }
181
+ /**
182
+ * The version installed on disk now; it moves after an upgrade while
183
+ * {@link RUNNING_VERSION} stays at the loaded generation until a reload.
184
+ *
185
+ * @returns the manifest's version, or the loaded one when the file cannot be read.
186
+ */
187
+ export declare function installedVersion(): string;
188
+ /** The version this process loaded. */
189
+ export declare function runningVersion(): string;
190
+ /**
191
+ * Build the route handler.
192
+ *
193
+ * One handler owns one cache and one update slot, so the row registers exactly
194
+ * one instance and an unload drops both. The version check is cached for
195
+ * `cacheMs` because one answer costs several `pnpm view` calls in the profile;
196
+ * an update is never cached.
197
+ *
198
+ * @param options - the manager, clock, and cache seams.
199
+ * @returns the request handler.
200
+ */
201
+ export declare function createPluginUpdateHandler(options: PluginUpdateHandlerOptions): PluginUpdateHandler;
202
+ /**
203
+ * Mount the row: register the route once the Host connection is available.
204
+ *
205
+ * A composition without `connection` (headless, ACP) leaves the row inert —
206
+ * the same posture the status row takes.
207
+ *
208
+ * @param ctx - the cordis context.
209
+ * @param config - the schema-validated plugin config.
210
+ */
211
+ export declare function apply(ctx: PluginUpdateContext, config?: PluginUpdateConfig): void;
212
+ export {};
@@ -0,0 +1,283 @@
1
+ /**
2
+ * The sidebar panel's plugin route: version information, update availability,
3
+ * and the confirmed one-click upgrade.
4
+ *
5
+ * The version answer is the host plugin-manager's, not ours: `listVersions`
6
+ * resolves dist-tags, deprecation, and the `engines.dsh`/peer compatibility of
7
+ * every candidate against the running DSH, and `updateBundle` performs the
8
+ * replacement with the profile's normal package manager rules (bundle
9
+ * selection, exact version, rollback). This row only gives the panel a
10
+ * browser-reachable, authenticated exact-Fetch route to that service:
11
+ *
12
+ * - `GET /api/wsl-env/plugin-update` — the installed and running version,
13
+ * the latest stable release that can replace it, and the last check's
14
+ * outcome. A stale answer is re-read; `refresh=1` forces a fresh check.
15
+ * - `POST /api/wsl-env/plugin-update` — install that release through
16
+ * `updateBundle`. It is one click in the panel, never automatic: a plugin
17
+ * that silently replaces its own code under a running harness is a
18
+ * posture this plugin rejects.
19
+ *
20
+ * Nothing here fetches the registry or runs pnpm directly. A host without a
21
+ * plugin-manager (or one from before `updateBundle` existed) still gets the
22
+ * installed version and an explanation; a linked checkout is refused by the
23
+ * host as `not-updatable` and the panel points at the Plugins page instead.
24
+ *
25
+ * This is a TypeScript source built to `lib/plugin-update.js`; edit THIS file
26
+ * and run `pnpm run build` — the artifact under `lib/` is generated, and
27
+ * `pnpm test` fails when it drifts.
28
+ *
29
+ * @module dsh-plugin-wsl-env/plugin-update
30
+ */
31
+ import z from "@deepseek-ai/schemastery";
32
+ import { readFileSync } from "node:fs";
33
+ import { inspectVersions, PACKAGE, setUpdateFact, } from "./update-check.js";
34
+ export const name = "wsl-plugin-update";
35
+ /** The one route the panel fetches; it must live under the `/api` channel. */
36
+ export const PLUGIN_UPDATE_PATH = "/api/wsl-env/plugin-update";
37
+ /** How long a version answer stays fresh before a panel load re-reads it. */
38
+ export const DEFAULT_CACHE_MS = 10 * 60 * 1000;
39
+ export const Config = z.object({
40
+ /** How long a version answer stays fresh, in milliseconds. */
41
+ cacheMs: z.natural().default(DEFAULT_CACHE_MS),
42
+ });
43
+ /**
44
+ * Read this package's version from the manifest beside `lib/`.
45
+ * @returns the version, or undefined when the manifest is unreadable.
46
+ */
47
+ function packageVersion() {
48
+ try {
49
+ const parsed = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
50
+ return typeof parsed.version === "string" ? parsed.version : undefined;
51
+ }
52
+ catch {
53
+ return undefined;
54
+ }
55
+ }
56
+ /**
57
+ * The version this process loaded. A successful one-click upgrade replaces
58
+ * the manifest before the old module graph is gone, so the panel must be able
59
+ * to say "installed X, running Y" until the app reloads.
60
+ */
61
+ const RUNNING_VERSION = packageVersion() ?? "unknown";
62
+ /**
63
+ * The version installed on disk now; it moves after an upgrade while
64
+ * {@link RUNNING_VERSION} stays at the loaded generation until a reload.
65
+ *
66
+ * @returns the manifest's version, or the loaded one when the file cannot be read.
67
+ */
68
+ export function installedVersion() {
69
+ return packageVersion() ?? RUNNING_VERSION;
70
+ }
71
+ /** The version this process loaded. */
72
+ export function runningVersion() {
73
+ return RUNNING_VERSION;
74
+ }
75
+ /**
76
+ * The update-capable slice of a manager, when it has one. A host from before
77
+ * `updateBundle` still answers version checks; it just cannot offer the click.
78
+ * @param manager - the host plugin-manager, or undefined.
79
+ * @returns the manager with its updater, or undefined.
80
+ */
81
+ function updaterOf(manager) {
82
+ if (manager === undefined)
83
+ return undefined;
84
+ const candidate = manager;
85
+ return typeof candidate.updateBundle === "function" ? candidate : undefined;
86
+ }
87
+ /**
88
+ * One JSON response with the route's own no-store policy.
89
+ * @param body - the JSON-serializable value.
90
+ * @param status - the HTTP status.
91
+ * @returns a JSON response.
92
+ */
93
+ function json(body, status = 200) {
94
+ return Response.json(body, { status, headers: { "cache-control": "no-store" } });
95
+ }
96
+ /**
97
+ * Build the route handler.
98
+ *
99
+ * One handler owns one cache and one update slot, so the row registers exactly
100
+ * one instance and an unload drops both. The version check is cached for
101
+ * `cacheMs` because one answer costs several `pnpm view` calls in the profile;
102
+ * an update is never cached.
103
+ *
104
+ * @param options - the manager, clock, and cache seams.
105
+ * @returns the request handler.
106
+ */
107
+ export function createPluginUpdateHandler(options) {
108
+ const now = options.now ?? (() => Date.now());
109
+ const installed = options.installed ?? installedVersion;
110
+ const running = options.running ?? RUNNING_VERSION;
111
+ /** One cached check; `at` is the clock read when the check started. */
112
+ let cache;
113
+ /** A check already in flight, so two panel loads share one registry round-trip. */
114
+ let inflight;
115
+ /** One update at a time; a second click must not start a second removal/install pair. */
116
+ let updating = false;
117
+ const currentCheck = async (refresh) => {
118
+ if (!refresh && cache !== undefined && now() - cache.at < options.cacheMs) {
119
+ return { check: cache.check, cached: true };
120
+ }
121
+ if (inflight !== undefined)
122
+ return { check: await inflight, cached: false };
123
+ const manager = options.manager();
124
+ const at = now();
125
+ const pending = inspectVersions(manager, installed(), at);
126
+ inflight = pending;
127
+ try {
128
+ const check = await pending;
129
+ // A missing manager is cheap to re-read, and a host can gain one at
130
+ // runtime; everything else (including a registry refusal) is cached.
131
+ if (!(check.status === "unavailable" && check.problem === "no-manager"))
132
+ cache = { at, check };
133
+ return { check, cached: false };
134
+ }
135
+ finally {
136
+ inflight = undefined;
137
+ }
138
+ };
139
+ const viewOf = (check, cached, updateSupported) => ({
140
+ installed: installed(),
141
+ running,
142
+ status: check.status,
143
+ checkedAt: check.checkedAt,
144
+ cached,
145
+ updateSupported,
146
+ canUpdate: check.status === "available" && updateSupported && check.latest.incompatible === undefined,
147
+ ...(check.status === "unavailable" ? { problem: check.problem, reason: check.reason } : {}),
148
+ ...(check.status === "available" ? { registry: check.registry, latest: check.latest } : {}),
149
+ ...(check.status === "current" ? { registry: check.registry } : {}),
150
+ });
151
+ /**
152
+ * Read the version answer, including the panel's auto-check on first load.
153
+ * @param refresh - whether to ignore a fresh cache entry.
154
+ * @returns the session's JSON response.
155
+ */
156
+ const read = async (refresh) => {
157
+ try {
158
+ const { check, cached } = await currentCheck(refresh);
159
+ return json(viewOf(check, cached, updaterOf(options.manager()) !== undefined));
160
+ }
161
+ catch (error) {
162
+ return json({ error: error instanceof Error ? error.message : String(error) }, 500);
163
+ }
164
+ };
165
+ /**
166
+ * Run the one-click upgrade. The target is the check's installable stable
167
+ * release; `updateBundle` re-validates existence, bundle declaration, and
168
+ * compatibility, and performs the removal/install/rollback itself.
169
+ * @returns the session's JSON response.
170
+ */
171
+ const update = async () => {
172
+ if (updating)
173
+ return json({ error: "An update is already running" }, 409);
174
+ const manager = options.manager();
175
+ if (manager === undefined) {
176
+ return json({ error: "The host has no plugin-manager; update from the Plugins page" }, 503);
177
+ }
178
+ const updater = updaterOf(manager);
179
+ if (updater === undefined) {
180
+ return json({ error: "This plugin-manager cannot update bundles; update from the Plugins page" }, 501);
181
+ }
182
+ let check;
183
+ try {
184
+ check = (await currentCheck(false)).check;
185
+ }
186
+ catch (error) {
187
+ return json({ error: error instanceof Error ? error.message : String(error) }, 500);
188
+ }
189
+ if (check.status === "current")
190
+ return json({ error: "The installed version is up to date" }, 409);
191
+ if (check.status === "unavailable")
192
+ return json({ error: `No update target: ${check.reason}` }, 409);
193
+ if (check.latest.incompatible !== undefined) {
194
+ return json({ error: "The latest release requires a newer DSH; upgrade DeepSeek Harness first" }, 409);
195
+ }
196
+ updating = true;
197
+ try {
198
+ const result = await updater.updateBundle(PACKAGE, check.latest.version, { registry: check.registry });
199
+ cache = undefined;
200
+ const application = result.result.application;
201
+ // `overridden` still installed the target; the host reports it when a
202
+ // higher-priority profile layer overrides the bundle selection.
203
+ const updated = result.step === "install" && application !== "failed" && application !== "cancelled";
204
+ if (updated)
205
+ setUpdateFact(undefined);
206
+ const restoreError = result.restore?.error;
207
+ return json({
208
+ updated,
209
+ application,
210
+ from: result.from,
211
+ to: result.to,
212
+ step: result.step,
213
+ installed: installed(),
214
+ running,
215
+ checkedAt: now(),
216
+ ...(result.result.restartReason === undefined ? {} : { restartReason: result.result.restartReason }),
217
+ ...(result.restore === undefined ? {} : { restored: result.restore.application === "applied" }),
218
+ ...(result.result.error === undefined ? {} : {
219
+ error: {
220
+ ...(result.result.error.code === undefined ? {} : { code: result.result.error.code }),
221
+ ...(result.result.error.diagnostic === undefined ? {} : { diagnostic: result.result.error.diagnostic }),
222
+ },
223
+ }),
224
+ ...(result.result.pendingBuilds === undefined ? {} : { pendingBuilds: result.result.pendingBuilds }),
225
+ ...(restoreError === undefined ? {} : {
226
+ restoreError: {
227
+ ...(restoreError.code === undefined ? {} : { code: restoreError.code }),
228
+ ...(restoreError.diagnostic === undefined ? {} : { diagnostic: restoreError.diagnostic }),
229
+ },
230
+ }),
231
+ });
232
+ }
233
+ catch (error) {
234
+ cache = undefined;
235
+ return json({ error: error instanceof Error ? error.message : String(error) }, 502);
236
+ }
237
+ finally {
238
+ updating = false;
239
+ }
240
+ };
241
+ return async (request) => {
242
+ if (request.method !== "GET" && request.method !== "POST") {
243
+ return json({ error: "Only GET and POST are supported" }, 405);
244
+ }
245
+ if (request.method === "GET") {
246
+ const refresh = new URL(request.url).searchParams.get("refresh") === "1";
247
+ return read(refresh);
248
+ }
249
+ return update();
250
+ };
251
+ }
252
+ /**
253
+ * Mount the row: register the route once the Host connection is available.
254
+ *
255
+ * A composition without `connection` (headless, ACP) leaves the row inert —
256
+ * the same posture the status row takes.
257
+ *
258
+ * @param ctx - the cordis context.
259
+ * @param config - the schema-validated plugin config.
260
+ */
261
+ export function apply(ctx, config = {}) {
262
+ if (typeof ctx.inject !== "function")
263
+ return;
264
+ ctx.inject(["connection"], (scope) => {
265
+ const connection = scope.connection ?? scope.get?.("connection");
266
+ if (connection === undefined || typeof connection.fetch?.register !== "function")
267
+ return;
268
+ const manager = () => (ctx.get?.("pluginManager") ?? scope.get?.("pluginManager"));
269
+ const handler = createPluginUpdateHandler({
270
+ manager,
271
+ cacheMs: config.cacheMs ?? DEFAULT_CACHE_MS,
272
+ installed: installedVersion,
273
+ running: RUNNING_VERSION,
274
+ });
275
+ const dispose = connection.fetch.register({
276
+ path: PLUGIN_UPDATE_PATH,
277
+ methods: ["GET", "POST"],
278
+ requestBody: "buffered",
279
+ fetch: handler,
280
+ });
281
+ scope.effect?.(() => () => { void dispose(); }, `wsl-plugin-update: ${PLUGIN_UPDATE_PATH}`);
282
+ });
283
+ }
@@ -119,6 +119,8 @@ export interface WslSandboxCoreInstance {
119
119
  distro: string;
120
120
  signal?: AbortSignal | undefined;
121
121
  writableRoots?: readonly string[] | undefined;
122
+ socketMasks?: readonly string[] | undefined;
123
+ maskInterop?: boolean | undefined;
122
124
  }) => Promise<WslConfined>;
123
125
  }
124
126
  /**
@@ -277,9 +277,11 @@ export function createSandboxCore({ SandboxUnavailableError }) {
277
277
  * @param argv - the argv to run INSIDE the distro (shell, its flags, command).
278
278
  * @param policy - the resolved confined policy (`mode` is never
279
279
  * `danger-full-access`; the caller does not confine that case at all).
280
- * @param options - the distro to run in, optional cancellation, and the
280
+ * @param options - the distro to run in, optional cancellation, the
281
281
  * resolved extra writable roots (already Linux paths, filtered and
282
- * physically checked by the provider).
282
+ * physically checked by the provider), and the existing socket paths
283
+ * the profile masks (resolved by the provider), and whether to shadow
284
+ * the WSL interop transport at `/run/WSL`.
283
285
  * @returns the wrapped argv plus the settlement-classification facts, in the
284
286
  * seam's `ConfinedArgv` shape.
285
287
  * @throws SandboxUnavailableError when the distro has no usable `bwrap`, so a
@@ -291,7 +293,7 @@ export function createSandboxCore({ SandboxUnavailableError }) {
291
293
  throw new SandboxUnavailableError(policy.mode, bwrapFailure(this.wslPath, distro) ?? missingBwrapRemedy(distro));
292
294
  }
293
295
  const workspaceRoot = toLinuxPath(policy.workspaceRoot);
294
- const prefix = bwrapArgvPrefix({ ...policy, workspaceRoot }, { maskWindowsDrive: this.maskWindowsDrive, writableRoots: options.writableRoots });
296
+ const prefix = bwrapArgvPrefix({ ...policy, workspaceRoot }, { maskWindowsDrive: this.maskWindowsDrive, writableRoots: options.writableRoots, socketMasks: options.socketMasks, maskInterop: options.maskInterop });
295
297
  return {
296
298
  argv: [...prefix, ...argv],
297
299
  enforcement: ENFORCEMENT,
@@ -61,6 +61,15 @@ interface SessionRuntimeRequest {
61
61
  * because the mount table is fixed for the runtime's lifetime.
62
62
  */
63
63
  writableRoots?: readonly string[];
64
+ /**
65
+ * Existing socket paths the runtime's bwrap profile masks: the user systemd
66
+ * manager's sockets and, for `strict`, the system bus and container
67
+ * sockets. Resolved by the provider (`lib/socket-isolation.js`); part of
68
+ * the key because the mount table is fixed for the runtime's lifetime.
69
+ */
70
+ socketMasks?: readonly string[];
71
+ /** Shadow `/run/WSL`, the WSL interop transport, inside the runtime. */
72
+ maskInterop?: boolean;
64
73
  /** The agent's client lease; 0 disables. */
65
74
  leaseMs?: number;
66
75
  }
@@ -140,7 +149,7 @@ export declare class SessionRuntimes {
140
149
  * @param request - the runtime request.
141
150
  * @returns the registry key.
142
151
  */
143
- static key(request: Pick<SessionRuntimeRequest, "distro" | "workspaceRoot" | "mode" | "maskWindowsDrive" | "sessionId" | "writableRoots">): string;
152
+ static key(request: Pick<SessionRuntimeRequest, "distro" | "workspaceRoot" | "mode" | "maskWindowsDrive" | "sessionId" | "writableRoots" | "socketMasks" | "maskInterop">): string;
144
153
  /**
145
154
  * Acquire the runtime for one key, creating it on first use.
146
155
  *
@@ -153,6 +153,8 @@ export class SessionRuntimes {
153
153
  request.mode,
154
154
  request.maskWindowsDrive === true ? "masked" : "visible",
155
155
  (request.writableRoots ?? []).join("\u0000"),
156
+ (request.socketMasks ?? []).join("\u0000"),
157
+ request.maskInterop === true ? "interop-masked" : "interop-visible",
156
158
  ].join("\u0000");
157
159
  }
158
160
  /**
@@ -172,7 +174,7 @@ export class SessionRuntimes {
172
174
  const unit = sessionScopeUnit(request.distro, this.token());
173
175
  const prefix = sessionScopePrefix(unit);
174
176
  if (request.mode !== "danger-full-access") {
175
- prefix.push(...bwrapArgvPrefix({ mode: request.mode, workspaceRoot: toLinuxPath(request.workspaceRoot) }, { maskWindowsDrive: request.maskWindowsDrive, realTmp: true, pidNamespace: false, writableRoots: request.writableRoots }));
177
+ prefix.push(...bwrapArgvPrefix({ mode: request.mode, workspaceRoot: toLinuxPath(request.workspaceRoot) }, { maskWindowsDrive: request.maskWindowsDrive, realTmp: true, pidNamespace: false, writableRoots: request.writableRoots, socketMasks: request.socketMasks, maskInterop: request.maskInterop }));
176
178
  }
177
179
  const agent = this.spawnAgent({
178
180
  distro: request.distro,
package/lib/shell-env.js CHANGED
@@ -155,7 +155,7 @@ export async function apply(ctx, config = {}) {
155
155
  description: `Ports with a listener inside that distro (comma-separated, ascending), as of the last snapshot — refreshed every ${Math.round(portsRefreshMs / 1000)}s, so a dev server started moments ago may not be listed yet. Empty means none were listening at the last successful scan (or no scan has succeeded yet); a failed scan keeps the last successful list.`,
156
156
  },
157
157
  DSH_WSL_PLUGIN_UPDATE: {
158
- description: "A newer release of this plugin (dsh-plugin-wsl-env), as of the last update check — checked against the registry about once a day. Empty means the installed version is current (or the check has not run yet). Applying it is manual: the Plugins page's Versions section, or `dsh plugin --profile <name> add dsh-plugin-wsl-env`, then restart DSH.",
158
+ description: "A newer release of this plugin (dsh-plugin-wsl-env), as of the last update check — checked against the registry about once a day. Empty means the installed version is current (or the check has not run yet). Upgrade from the sidebar WSL environment panel's version card (one-click upgrade), or from the Plugins page's Versions section; restart DSH or reload the page when the host reports it.",
159
159
  },
160
160
  DSH_WSL_DOCTOR: {
161
161
  description: "Ready-to-run command that executes this plugin's environment doctor (scripts/doctor.mjs) from inside a session, using the app's own runtime as Node — no terminal or separate Node install needed. Run it as: sh -c \"$DSH_WSL_DOCTOR --json\" (drop --json for the human report). The output ends in a verdict (ready, or blocked with per-failure copy-paste remedies).",