dsh-plugin-wsl-env 0.26.3 → 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 +142 -0
- package/CONTRIBUTING.md +32 -25
- package/CONTRIBUTING.zh.md +3 -2
- package/README.md +1 -1
- package/SECURITY.md +21 -7
- package/SECURITY.zh.md +18 -5
- package/SUPPORT.md +2 -2
- package/SUPPORT.zh.md +2 -2
- package/client.js +351 -48
- package/cordis.patch.yml +26 -10
- package/docs/AGENT-PROTOCOL-V7.md +4 -2
- package/docs/API.md +3 -1
- package/docs/API.zh.md +3 -1
- package/docs/ARCHITECTURE.md +22 -4
- package/docs/ARCHITECTURE.zh.md +18 -4
- package/docs/CONFIGURATION.md +117 -17
- package/docs/CONFIGURATION.zh.md +97 -11
- 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/PARITY.md +3 -1
- package/docs/QUICKSTART.md +31 -20
- package/docs/QUICKSTART.zh.md +16 -9
- package/docs/README.zh.md +1 -1
- package/docs/RELEASING.md +25 -3
- package/docs/REQUIREMENTS.zh.md +7 -6
- package/docs/ROADMAP-1.0.md +11 -7
- package/lib/agent-confined.d.ts +9 -1
- package/lib/agent-confined.js +3 -3
- package/lib/agent.d.ts +54 -18
- package/lib/agent.js +86 -19
- package/lib/bwrap.d.ts +16 -0
- package/lib/bwrap.js +9 -0
- package/lib/fs-routing.d.ts +6 -0
- package/lib/fs-routing.js +7 -0
- package/lib/fs-substrate.d.ts +1 -1
- package/lib/fs-substrate.js +10 -18
- package/lib/fsio-agent.d.ts +4 -0
- package/lib/fsio-agent.js +37 -10
- package/lib/listing.d.ts +2 -2
- package/lib/listing.js +5 -4
- package/lib/messages.d.ts +70 -0
- package/lib/messages.js +80 -0
- package/lib/open-in-app.js +12 -9
- package/lib/picker.d.ts +4 -1
- package/lib/picker.js +35 -11
- package/lib/plugin-update.d.ts +212 -0
- package/lib/plugin-update.js +283 -0
- package/lib/ports.js +8 -1
- package/lib/provider-common.d.ts +22 -0
- package/lib/provider-common.js +18 -0
- package/lib/provider-marker.d.ts +23 -0
- package/lib/provider-marker.js +21 -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 +61 -23
- package/lib/subprocess.d.ts +3 -0
- package/lib/subprocess.js +5 -0
- package/lib/takeover-report.js +4 -11
- package/lib/update-check.d.ts +49 -9
- package/lib/update-check.js +81 -28
- package/lib/watcher.d.ts +1 -1
- package/lib/watcher.js +1 -1
- package/lib/wsl-doctor-command.d.ts +6 -2
- package/lib/wsl-doctor-command.js +24 -15
- package/lib/wsl-doctor-tool.js +2 -0
- package/lib/wsl-filesystem.d.ts +53 -12
- package/lib/wsl-filesystem.js +90 -31
- package/lib/wsl-shell.d.ts +109 -40
- package/lib/wsl-shell.js +128 -54
- package/package.json +8 -3
- package/scripts/doctor.mjs +199 -3
- package/scripts/profile-preset.mjs +10 -2
package/lib/update-check.d.ts
CHANGED
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
* the host's `pluginManager` for this package's version list and, when the
|
|
11
11
|
* stable channel has moved, publishes one fact. Applying the update stays a
|
|
12
12
|
* user action — a plugin that silently replaces its own code under a running
|
|
13
|
-
* harness is a posture this plugin rejects
|
|
14
|
-
*
|
|
13
|
+
* harness is a posture this plugin rejects. The sidebar's plugin-update row
|
|
14
|
+
* exposes the same answer and a confirmed one-click upgrade; this module owns
|
|
15
|
+
* the check itself and the fact the shell-env row serves.
|
|
15
16
|
*
|
|
16
17
|
* Delegation is the whole network story: the check spawns nothing and fetches
|
|
17
18
|
* nothing itself. `pluginManager` is read with `ctx.get`, the sanctioned read
|
|
@@ -29,6 +30,8 @@
|
|
|
29
30
|
import z from "@deepseek-ai/schemastery";
|
|
30
31
|
import type { Context } from "@deepseek-ai/cordis";
|
|
31
32
|
export declare const name = "wsl-update-check";
|
|
33
|
+
/** The checked package: this plugin, by its npm name. */
|
|
34
|
+
export declare const PACKAGE = "dsh-plugin-wsl-env";
|
|
32
35
|
/** The interval the row ships with. */
|
|
33
36
|
export declare const DEFAULT_INTERVAL_MS: number;
|
|
34
37
|
/** The smallest interval a config may ask for; one check spawns `pnpm view` in the profile. */
|
|
@@ -52,7 +55,7 @@ interface UpdateCheckConfig {
|
|
|
52
55
|
intervalMs?: number;
|
|
53
56
|
}
|
|
54
57
|
/** One published version, reduced to what the fact reads (host plugin-manager types). */
|
|
55
|
-
interface ListedVersion {
|
|
58
|
+
export interface ListedVersion {
|
|
56
59
|
readonly version: string;
|
|
57
60
|
readonly publishedAt?: string;
|
|
58
61
|
readonly tags: readonly string[];
|
|
@@ -71,7 +74,7 @@ interface ListedVersion {
|
|
|
71
74
|
export type VersionList = {
|
|
72
75
|
readonly status: "listed";
|
|
73
76
|
readonly installed: string;
|
|
74
|
-
readonly registry: string;
|
|
77
|
+
readonly registry: string | null;
|
|
75
78
|
readonly attempts: readonly unknown[];
|
|
76
79
|
/** Published versions newer than `installed`, newest first. */
|
|
77
80
|
readonly versions: readonly ListedVersion[];
|
|
@@ -82,6 +85,33 @@ export type VersionList = {
|
|
|
82
85
|
readonly reason: string;
|
|
83
86
|
readonly attempts: readonly unknown[];
|
|
84
87
|
};
|
|
88
|
+
/** Why a check could not produce a version list. */
|
|
89
|
+
export type VersionProblem = "no-manager" | Extract<VersionList, {
|
|
90
|
+
status: "refused";
|
|
91
|
+
}>["problem"];
|
|
92
|
+
/**
|
|
93
|
+
* What one version check learned, for the panel's version card. Unlike
|
|
94
|
+
* {@link UpdateFact}, this keeps the "up to date" answer and the reasons a
|
|
95
|
+
* check learned nothing, so the panel can say which of the three happened.
|
|
96
|
+
*/
|
|
97
|
+
export type VersionCheck = {
|
|
98
|
+
readonly status: "available";
|
|
99
|
+
readonly installed: string;
|
|
100
|
+
readonly checkedAt: number;
|
|
101
|
+
readonly registry: string | null;
|
|
102
|
+
readonly latest: ListedVersion;
|
|
103
|
+
} | {
|
|
104
|
+
readonly status: "current";
|
|
105
|
+
readonly installed: string;
|
|
106
|
+
readonly checkedAt: number;
|
|
107
|
+
readonly registry: string | null;
|
|
108
|
+
} | {
|
|
109
|
+
readonly status: "unavailable";
|
|
110
|
+
readonly installed: string;
|
|
111
|
+
readonly checkedAt: number;
|
|
112
|
+
readonly problem: VersionProblem;
|
|
113
|
+
readonly reason: string;
|
|
114
|
+
};
|
|
85
115
|
/**
|
|
86
116
|
* The slice of the host's plugin-manager this row calls. The service belongs
|
|
87
117
|
* to the harness and its declaration is not visible to this plugin, so it is
|
|
@@ -155,12 +185,22 @@ export declare function updateTarget(list: Extract<VersionList, {
|
|
|
155
185
|
status: "listed";
|
|
156
186
|
}>): ListedVersion | undefined;
|
|
157
187
|
/**
|
|
158
|
-
* Run one check
|
|
188
|
+
* Run one version check and publish (or clear) the shell-environment fact.
|
|
159
189
|
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
190
|
+
* The fact is the only observable for the periodic check, so the three
|
|
191
|
+
* outcomes are handled together: an available target publishes it, an
|
|
192
|
+
* up-to-date list clears a stale one, and a non-answer (no manager, a refused
|
|
193
|
+
* list, a throwing service) leaves the previous fact standing. A check must
|
|
194
|
+
* never become the noisiest thing in the app, so none of these throws.
|
|
195
|
+
*
|
|
196
|
+
* @param manager - the host plugin-manager, or undefined when the host has none.
|
|
197
|
+
* @param installed - the installed version to name when the host has no manager.
|
|
198
|
+
* @param now - the check's timestamp, injectable for tests.
|
|
199
|
+
* @returns what the check learned.
|
|
200
|
+
*/
|
|
201
|
+
export declare function inspectVersions(manager: PluginManagerSlice | undefined, installed: string, now?: number): Promise<VersionCheck>;
|
|
202
|
+
/**
|
|
203
|
+
* Run one check against the host's plugin-manager and publish the fact.
|
|
164
204
|
*
|
|
165
205
|
* @param manager - the host plugin-manager, or undefined when the host has none.
|
|
166
206
|
* @returns the published fact, or undefined when the check learned nothing.
|
package/lib/update-check.js
CHANGED
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
* the host's `pluginManager` for this package's version list and, when the
|
|
11
11
|
* stable channel has moved, publishes one fact. Applying the update stays a
|
|
12
12
|
* user action — a plugin that silently replaces its own code under a running
|
|
13
|
-
* harness is a posture this plugin rejects
|
|
14
|
-
*
|
|
13
|
+
* harness is a posture this plugin rejects. The sidebar's plugin-update row
|
|
14
|
+
* exposes the same answer and a confirmed one-click upgrade; this module owns
|
|
15
|
+
* the check itself and the fact the shell-env row serves.
|
|
15
16
|
*
|
|
16
17
|
* Delegation is the whole network story: the check spawns nothing and fetches
|
|
17
18
|
* nothing itself. `pluginManager` is read with `ctx.get`, the sanctioned read
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
import z from "@deepseek-ai/schemastery";
|
|
30
31
|
export const name = "wsl-update-check";
|
|
31
32
|
/** The checked package: this plugin, by its npm name. */
|
|
32
|
-
const PACKAGE = "dsh-plugin-wsl-env";
|
|
33
|
+
export const PACKAGE = "dsh-plugin-wsl-env";
|
|
33
34
|
/** The interval the row ships with. */
|
|
34
35
|
export const DEFAULT_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
35
36
|
/** The smallest interval a config may ask for; one check spawns `pnpm view` in the profile. */
|
|
@@ -104,45 +105,97 @@ export function updateTarget(list) {
|
|
|
104
105
|
return list.versions.find((version) => version.bundle && version.tags.includes("latest"));
|
|
105
106
|
}
|
|
106
107
|
/**
|
|
107
|
-
* Run one check
|
|
108
|
+
* Run one version check and publish (or clear) the shell-environment fact.
|
|
108
109
|
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
110
|
+
* The fact is the only observable for the periodic check, so the three
|
|
111
|
+
* outcomes are handled together: an available target publishes it, an
|
|
112
|
+
* up-to-date list clears a stale one, and a non-answer (no manager, a refused
|
|
113
|
+
* list, a throwing service) leaves the previous fact standing. A check must
|
|
114
|
+
* never become the noisiest thing in the app, so none of these throws.
|
|
113
115
|
*
|
|
114
116
|
* @param manager - the host plugin-manager, or undefined when the host has none.
|
|
115
|
-
* @
|
|
117
|
+
* @param installed - the installed version to name when the host has no manager.
|
|
118
|
+
* @param now - the check's timestamp, injectable for tests.
|
|
119
|
+
* @returns what the check learned.
|
|
116
120
|
*/
|
|
117
|
-
export async function
|
|
118
|
-
if (manager === undefined)
|
|
119
|
-
return
|
|
121
|
+
export async function inspectVersions(manager, installed, now = Date.now()) {
|
|
122
|
+
if (manager === undefined) {
|
|
123
|
+
return {
|
|
124
|
+
status: "unavailable",
|
|
125
|
+
installed,
|
|
126
|
+
checkedAt: now,
|
|
127
|
+
problem: "no-manager",
|
|
128
|
+
reason: "the host has no plugin-manager",
|
|
129
|
+
};
|
|
130
|
+
}
|
|
120
131
|
let list;
|
|
121
132
|
try {
|
|
122
133
|
list = await manager.listVersions(PACKAGE);
|
|
123
134
|
}
|
|
124
|
-
catch {
|
|
135
|
+
catch (error) {
|
|
125
136
|
// `listVersions` resolves refusals into its result; a throw means the
|
|
126
137
|
// service itself is broken. The next tick retries; nothing is published.
|
|
127
|
-
return
|
|
138
|
+
return {
|
|
139
|
+
status: "unavailable",
|
|
140
|
+
installed,
|
|
141
|
+
checkedAt: now,
|
|
142
|
+
problem: "unknown",
|
|
143
|
+
reason: messageOf(error),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (list.status !== "listed") {
|
|
147
|
+
// A linked checkout (`not-updatable`), an unreachable registry, or an
|
|
148
|
+
// unreadable listing is not news; the previous fact stays.
|
|
149
|
+
return {
|
|
150
|
+
status: "unavailable",
|
|
151
|
+
installed,
|
|
152
|
+
checkedAt: now,
|
|
153
|
+
problem: list.problem,
|
|
154
|
+
reason: list.reason,
|
|
155
|
+
};
|
|
128
156
|
}
|
|
129
|
-
if (list.status !== "listed")
|
|
130
|
-
return undefined;
|
|
131
157
|
const target = updateTarget(list);
|
|
132
|
-
if (target
|
|
158
|
+
if (target !== undefined) {
|
|
159
|
+
const next = {
|
|
160
|
+
installed: list.installed,
|
|
161
|
+
latest: target.version,
|
|
162
|
+
...(target.publishedAt === undefined ? {} : { publishedAt: target.publishedAt }),
|
|
163
|
+
incompatible: target.incompatible !== undefined,
|
|
164
|
+
...(target.deprecated === undefined ? {} : { deprecated: target.deprecated }),
|
|
165
|
+
checkedAt: now,
|
|
166
|
+
};
|
|
167
|
+
setUpdateFact(next);
|
|
168
|
+
return { status: "available", installed: list.installed, checkedAt: now, registry: list.registry, latest: target };
|
|
169
|
+
}
|
|
170
|
+
// A `latest` tag the update could not install is a registry state worth
|
|
171
|
+
// naming: saying "up to date" would imply the installed version is newest.
|
|
172
|
+
const latest = list.versions.find((version) => version.tags.includes("latest"));
|
|
173
|
+
if (latest !== undefined && !latest.bundle) {
|
|
133
174
|
setUpdateFact(undefined);
|
|
134
|
-
return
|
|
175
|
+
return {
|
|
176
|
+
status: "unavailable",
|
|
177
|
+
installed: list.installed,
|
|
178
|
+
checkedAt: now,
|
|
179
|
+
problem: "unknown",
|
|
180
|
+
reason: `the registry's latest release ${latest.version} declares no dsh.bundle`,
|
|
181
|
+
};
|
|
135
182
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
183
|
+
setUpdateFact(undefined);
|
|
184
|
+
return { status: "current", installed: list.installed, checkedAt: now, registry: list.registry };
|
|
185
|
+
}
|
|
186
|
+
/** The error text behind an unknown thrown value. */
|
|
187
|
+
function messageOf(error) {
|
|
188
|
+
return error instanceof Error ? error.message : String(error);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Run one check against the host's plugin-manager and publish the fact.
|
|
192
|
+
*
|
|
193
|
+
* @param manager - the host plugin-manager, or undefined when the host has none.
|
|
194
|
+
* @returns the published fact, or undefined when the check learned nothing.
|
|
195
|
+
*/
|
|
196
|
+
export async function checkForUpdate(manager) {
|
|
197
|
+
const check = await inspectVersions(manager, "unknown");
|
|
198
|
+
return check.status === "available" ? currentUpdateFact() : undefined;
|
|
146
199
|
}
|
|
147
200
|
/**
|
|
148
201
|
* The fact as one line, for the managed `DSH_*` variable and the log. The
|
package/lib/watcher.d.ts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* rename-over or an in-place write is seen), and a positive `maxDepth` keeps
|
|
19
19
|
* the polling scan because inotify cannot bound its own walk.
|
|
20
20
|
*
|
|
21
|
-
* The loop speaks
|
|
21
|
+
* The loop speaks five one-letter lines, the watcher protocol:
|
|
22
22
|
*
|
|
23
23
|
* - `R` — READY: the activation barrier; the host resolves the watch promise
|
|
24
24
|
* on it, never before.
|
package/lib/watcher.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* rename-over or an in-place write is seen), and a positive `maxDepth` keeps
|
|
19
19
|
* the polling scan because inotify cannot bound its own walk.
|
|
20
20
|
*
|
|
21
|
-
* The loop speaks
|
|
21
|
+
* The loop speaks five one-letter lines, the watcher protocol:
|
|
22
22
|
*
|
|
23
23
|
* - `R` — READY: the activation barrier; the host resolves the watch promise
|
|
24
24
|
* on it, never before.
|
|
@@ -83,8 +83,12 @@ interface ParsedDoctorInput {
|
|
|
83
83
|
}
|
|
84
84
|
/** The doctor CLI this row spawns, resolved from the built module's package root. */
|
|
85
85
|
export declare const DOCTOR_SCRIPT: string;
|
|
86
|
-
/**
|
|
87
|
-
|
|
86
|
+
/**
|
|
87
|
+
* The usage text a grammar violation settles with.
|
|
88
|
+
*
|
|
89
|
+
* @returns the usage block in the active catalog language.
|
|
90
|
+
*/
|
|
91
|
+
export declare function doctorUsage(): string;
|
|
88
92
|
/**
|
|
89
93
|
* Parse the raw input after the command name. Tokens: one mode word or
|
|
90
94
|
* section name, plus an optional `--distro <name>` / `--distro=<name>`; a
|
|
@@ -34,6 +34,7 @@ import { distroOfUnc } from "./distro-route.js";
|
|
|
34
34
|
import { withHostPeerVersions } from "./peer-versions.js";
|
|
35
35
|
import { digestReport, renderDigest, SECTIONS } from "./wsl-doctor-tool.js";
|
|
36
36
|
import { mergeAutoPresetSeam } from "./doctor-live.js";
|
|
37
|
+
import { installMessagesLocale, t } from "./messages.js";
|
|
37
38
|
import { mergeTakeoverReport, takeoverSnapshot } from "./takeover-report.js";
|
|
38
39
|
export const name = "wsl-doctor-command";
|
|
39
40
|
/**
|
|
@@ -65,9 +66,14 @@ export const DOCTOR_CLI_TIMEOUT_MS = 120_000;
|
|
|
65
66
|
export const DOCTOR_CLI_SWEEP_TIMEOUT_MS = 60_000;
|
|
66
67
|
/** The doctor CLI this row spawns, resolved from the built module's package root. */
|
|
67
68
|
export const DOCTOR_SCRIPT = resolve(dirname(fileURLToPath(import.meta.url)), "..", "scripts", "doctor.mjs");
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
/**
|
|
70
|
+
* The usage text a grammar violation settles with.
|
|
71
|
+
*
|
|
72
|
+
* @returns the usage block in the active catalog language.
|
|
73
|
+
*/
|
|
74
|
+
export function doctorUsage() {
|
|
75
|
+
return t("doctorUsage", { sections: SECTIONS.join(" | ") });
|
|
76
|
+
}
|
|
71
77
|
/**
|
|
72
78
|
* Parse the raw input after the command name. Tokens: one mode word or
|
|
73
79
|
* section name, plus an optional `--distro <name>` / `--distro=<name>`; a
|
|
@@ -108,10 +114,10 @@ export function parseDoctorInput(rawInput) {
|
|
|
108
114
|
parsed.distro = token;
|
|
109
115
|
continue;
|
|
110
116
|
}
|
|
111
|
-
throw new Error(
|
|
117
|
+
throw new Error(t("doctorUnknownToken", { token }));
|
|
112
118
|
}
|
|
113
119
|
if (expectingDistro)
|
|
114
|
-
throw new Error("
|
|
120
|
+
throw new Error(t("doctorDistroNeedsName", {}));
|
|
115
121
|
return parsed;
|
|
116
122
|
}
|
|
117
123
|
/**
|
|
@@ -165,7 +171,7 @@ export function runDoctorCli(argv, signal, timeoutMs = DOCTOR_CLI_TIMEOUT_MS) {
|
|
|
165
171
|
child.on("error", (error) => {
|
|
166
172
|
// An abort arrives here as an AbortError; normalize it so the settled
|
|
167
173
|
// message names the run rather than the DOMException.
|
|
168
|
-
settle(() => rejectPromise(error.name === "AbortError" ? new Error("
|
|
174
|
+
settle(() => rejectPromise(error.name === "AbortError" ? new Error(t("doctorCliCancelled", {})) : error));
|
|
169
175
|
});
|
|
170
176
|
child.on("close", (code, signalName) => {
|
|
171
177
|
const text = stdout.trim();
|
|
@@ -174,10 +180,13 @@ export function runDoctorCli(argv, signal, timeoutMs = DOCTOR_CLI_TIMEOUT_MS) {
|
|
|
174
180
|
return;
|
|
175
181
|
}
|
|
176
182
|
if (timedOut) {
|
|
177
|
-
settle(() => rejectPromise(new Error(
|
|
183
|
+
settle(() => rejectPromise(new Error(t("doctorCliTimeout", { seconds: timeoutMs / 1000 }))));
|
|
178
184
|
return;
|
|
179
185
|
}
|
|
180
|
-
settle(() => rejectPromise(new Error(
|
|
186
|
+
settle(() => rejectPromise(new Error(t("doctorCliNoReport", {
|
|
187
|
+
status: String(code ?? signalName ?? "signal"),
|
|
188
|
+
detail: stderr.trim().length > 0 ? `: ${stderr.trim().slice(0, 400)}` : "",
|
|
189
|
+
}))));
|
|
181
190
|
});
|
|
182
191
|
});
|
|
183
192
|
}
|
|
@@ -329,6 +338,8 @@ export function formatDoctorReport(json, distro, providers = []) {
|
|
|
329
338
|
* registry and the harness cwd service are reachable).
|
|
330
339
|
*/
|
|
331
340
|
export async function apply(ctx) {
|
|
341
|
+
// The test seam is structural; production hands the row a cordis Context.
|
|
342
|
+
installMessagesLocale(ctx);
|
|
332
343
|
const commands = resolveCommands(ctx);
|
|
333
344
|
// No command adapter: nothing to register, nothing to fail. The doctor CLI
|
|
334
345
|
// (`pnpm run doctor`) stays the surface for headless deployments.
|
|
@@ -350,15 +361,15 @@ export async function apply(ctx) {
|
|
|
350
361
|
})();
|
|
351
362
|
commands.register({
|
|
352
363
|
name: "wsl-doctor",
|
|
353
|
-
description: "
|
|
354
|
-
input: { hint: "
|
|
364
|
+
description: t("doctorCommandDescription", {}),
|
|
365
|
+
input: { hint: t("doctorInputHint", {}) },
|
|
355
366
|
handler: async (invocation) => {
|
|
356
367
|
let parsed;
|
|
357
368
|
try {
|
|
358
369
|
parsed = parseDoctorInput(invocation.rawInput);
|
|
359
370
|
}
|
|
360
371
|
catch (error) {
|
|
361
|
-
return { kind: "error", text: `${error instanceof Error ? error.message : String(error)}\n\n${
|
|
372
|
+
return { kind: "error", text: `${error instanceof Error ? error.message : String(error)}\n\n${doctorUsage()}` };
|
|
362
373
|
}
|
|
363
374
|
const distro = await resolveDistro(ctx, invocation, parsed.distro);
|
|
364
375
|
const argv = ["--json"];
|
|
@@ -377,10 +388,8 @@ export async function apply(ctx) {
|
|
|
377
388
|
return { kind: "success", text: formatDoctorReport(json, distro, takeoverSnapshot(ctx)) };
|
|
378
389
|
}
|
|
379
390
|
catch (error) {
|
|
380
|
-
const target = distro.length > 0
|
|
381
|
-
|
|
382
|
-
: "配置指定的目标(未从会话工作目录解析出发行版,auto 会逐个检查所有已安装发行版)";
|
|
383
|
-
return { kind: "error", text: `doctor 运行失败(${target}):${error instanceof Error ? error.message : String(error)}` };
|
|
391
|
+
const target = distro.length > 0 ? t("doctorTargetDistro", { distro }) : t("doctorTargetConfigured", {});
|
|
392
|
+
return { kind: "error", text: t("doctorRunFailed", { target, message: error instanceof Error ? error.message : String(error) }) };
|
|
384
393
|
}
|
|
385
394
|
},
|
|
386
395
|
});
|
package/lib/wsl-doctor-tool.js
CHANGED
package/lib/wsl-filesystem.d.ts
CHANGED
|
@@ -6,9 +6,11 @@ import type { WslAgent } from "./agent.js";
|
|
|
6
6
|
import { AgentSubstrate } from "./fs-substrate.js";
|
|
7
7
|
import { SessionRuntimes } from "./session-runtime.js";
|
|
8
8
|
import type { SessionRuntimeEntry } from "./session-runtime.js";
|
|
9
|
+
import { type SocketIsolation } from "./socket-isolation.js";
|
|
9
10
|
import type { Context } from "@deepseek-ai/cordis";
|
|
10
11
|
import type { FileSystem, FsDeleteOutcome, FsDirEntry, FsEditOutcome, FsEditRequest, FsInfo, FsMoveOutcome, FsPathInfo, FsTarget, FsVersion, FsWriteIntent, FsWriteOutcome } from "@deepseek-ai/dsh-fs";
|
|
11
12
|
import type { SandboxExecutionPolicy, SandboxMode } from "@deepseek-ai/dsh-sandbox";
|
|
13
|
+
import { ProviderRuntimeBook } from "./provider-common.js";
|
|
12
14
|
type PatchHunks = Parameters<FileSystem["patchText"]>[1];
|
|
13
15
|
type MoveFileOptions = Parameters<FileSystem["moveFile"]>[2];
|
|
14
16
|
/**
|
|
@@ -35,6 +37,8 @@ interface WslFileSystemConfig {
|
|
|
35
37
|
sessionSandbox: boolean | "auto";
|
|
36
38
|
/** Whether confined profiles mask `/mnt`. */
|
|
37
39
|
maskWindowsDrive: boolean;
|
|
40
|
+
/** Which socket surfaces a confined resident cannot reach. */
|
|
41
|
+
socketIsolation: SocketIsolation;
|
|
38
42
|
/** Extra distro directories granted read-write under `workspace-write`. */
|
|
39
43
|
writableRoots?: string[];
|
|
40
44
|
/** Whether paths leaving the distro are refused. */
|
|
@@ -120,6 +124,16 @@ export declare class WslFileSystem extends LocalFileSystem {
|
|
|
120
124
|
* reads and the share substrate are unaffected.
|
|
121
125
|
*/
|
|
122
126
|
maskWindowsDrive: z<boolean, boolean, "defined">;
|
|
127
|
+
/**
|
|
128
|
+
* Which socket surfaces the confined write resident cannot reach — the
|
|
129
|
+
* same stance as `wsl-shell`'s key. The resident runs this plugin's fsio
|
|
130
|
+
* protocol, not model-authored commands, but the masks keep one mount
|
|
131
|
+
* table across the command and write planes and close the same
|
|
132
|
+
* process-authority path if the protocol is ever compromised. Keep the
|
|
133
|
+
* same value on the command row (`wsl-shell`) and, for the routed root,
|
|
134
|
+
* on `fs-routing`.
|
|
135
|
+
*/
|
|
136
|
+
socketIsolation: z<"off" | "session-bus" | "strict", "off" | "session-bus" | "strict", "defined">;
|
|
123
137
|
/**
|
|
124
138
|
* Extra directories under `workspace-write`, in distro spelling — the
|
|
125
139
|
* same list and same rules as `wsl-shell`'s key. Confined writes bind
|
|
@@ -202,6 +216,16 @@ export declare class WslFileSystem extends LocalFileSystem {
|
|
|
202
216
|
* reads and the share substrate are unaffected.
|
|
203
217
|
*/
|
|
204
218
|
maskWindowsDrive: z<boolean, boolean, "defined">;
|
|
219
|
+
/**
|
|
220
|
+
* Which socket surfaces the confined write resident cannot reach — the
|
|
221
|
+
* same stance as `wsl-shell`'s key. The resident runs this plugin's fsio
|
|
222
|
+
* protocol, not model-authored commands, but the masks keep one mount
|
|
223
|
+
* table across the command and write planes and close the same
|
|
224
|
+
* process-authority path if the protocol is ever compromised. Keep the
|
|
225
|
+
* same value on the command row (`wsl-shell`) and, for the routed root,
|
|
226
|
+
* on `fs-routing`.
|
|
227
|
+
*/
|
|
228
|
+
socketIsolation: z<"off" | "session-bus" | "strict", "off" | "session-bus" | "strict", "defined">;
|
|
205
229
|
/**
|
|
206
230
|
* Extra directories under `workspace-write`, in distro spelling — the
|
|
207
231
|
* same list and same rules as `wsl-shell`'s key. Confined writes bind
|
|
@@ -246,8 +270,8 @@ export declare class WslFileSystem extends LocalFileSystem {
|
|
|
246
270
|
resolvedDistro: string;
|
|
247
271
|
/** Cached distro-user home, the base for relative input when `cwd` is empty. */
|
|
248
272
|
resolvedHome: string | undefined;
|
|
249
|
-
/**
|
|
250
|
-
|
|
273
|
+
/** Shared per-provider bookkeeping (homes, session runtimes, preflight caches). */
|
|
274
|
+
runtimeBook: ProviderRuntimeBook;
|
|
251
275
|
/** The deployment default mode — the capability fact the tool layer reads. */
|
|
252
276
|
defaultMode: SandboxMode;
|
|
253
277
|
/** The lazy default-distro substrate, kept for the legacy accessor and tests. */
|
|
@@ -262,21 +286,25 @@ export declare class WslFileSystem extends LocalFileSystem {
|
|
|
262
286
|
agentInstances: Map<string, WslAgent>;
|
|
263
287
|
/** The session-runtime registry; tests substitute it. */
|
|
264
288
|
sessionRuntimes: SessionRuntimes;
|
|
265
|
-
/** The runtimes this provider holds, by registry key. */
|
|
266
|
-
sessionRuntimeEntries: Map<string, SessionRuntimeEntry>;
|
|
267
289
|
/** Isolates calls that have no session identity. */
|
|
268
290
|
sessionRuntimeOwner: string;
|
|
269
291
|
/** The preflight's host runner; tests substitute it. */
|
|
270
292
|
sessionScopeProbe: (argv: string[]) => Promise<string>;
|
|
271
293
|
/** The one-time writable-root check's runner; tests substitute it. */
|
|
272
294
|
writableRootsProbe: (argv: string[]) => Promise<string>;
|
|
273
|
-
/**
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
295
|
+
/** The socket-facts probe's runner; tests substitute it. */
|
|
296
|
+
socketIsolationProbe: (argv: string[]) => Promise<string>;
|
|
297
|
+
/**
|
|
298
|
+
* Per-distro homes, delegated to the shared runtime book: `provider-common`'s
|
|
299
|
+
* `distroHome` reads this view, and tests pin the cache through it.
|
|
300
|
+
*/
|
|
301
|
+
get resolvedHomes(): Map<string, string>;
|
|
302
|
+
/**
|
|
303
|
+
* The row's config without the peer's volatile wrapper. The schema validates
|
|
304
|
+
* the plain shape; the wrapper only widens the type, so one accessor states
|
|
305
|
+
* the cast instead of every method repeating it.
|
|
306
|
+
*/
|
|
307
|
+
private get wslConfig();
|
|
280
308
|
/**
|
|
281
309
|
* @param ctx - the composition context.
|
|
282
310
|
* @param config - the validated plugin config.
|
|
@@ -347,6 +375,19 @@ export declare class WslFileSystem extends LocalFileSystem {
|
|
|
347
375
|
workspaceRoot: string;
|
|
348
376
|
additionalWritableRoots?: readonly string[];
|
|
349
377
|
} | undefined, check?: boolean): Promise<string[]>;
|
|
378
|
+
/**
|
|
379
|
+
* The socket masks one confined resident's profile binds, resolved once per
|
|
380
|
+
* distro from the row's `socketIsolation` stance. Empty when the sandbox is
|
|
381
|
+
* off, the mutation is escalated, or the stance is `off`. A probe failure is
|
|
382
|
+
* a sandbox refusal, never an unmasked resident.
|
|
383
|
+
*
|
|
384
|
+
* @param distro - the distro the resident serves.
|
|
385
|
+
* @param mode - the file-effect mode.
|
|
386
|
+
* @param signal - optional cancellation for the one-time probe.
|
|
387
|
+
* @returns the existing socket paths to mask.
|
|
388
|
+
* @throws {SandboxUnavailableError} when a configured isolation cannot be resolved.
|
|
389
|
+
*/
|
|
390
|
+
socketMasksFor(distro: string, mode: string, signal?: AbortSignal): Promise<string[]>;
|
|
350
391
|
/**
|
|
351
392
|
* The persistent session runtime for one confined mutation, when
|
|
352
393
|
* `sessionSandbox` is on. The key is the shell executor's key for the same
|
|
@@ -362,7 +403,7 @@ export declare class WslFileSystem extends LocalFileSystem {
|
|
|
362
403
|
mode: string;
|
|
363
404
|
workspaceRoot: string;
|
|
364
405
|
sessionId?: string;
|
|
365
|
-
}, distro: string, writableRoots?: readonly string[]): SessionRuntimeEntry | undefined;
|
|
406
|
+
}, distro: string, writableRoots?: readonly string[], socketMasks?: readonly string[], maskInterop?: boolean): SessionRuntimeEntry | undefined;
|
|
366
407
|
/**
|
|
367
408
|
* Run the session runtime's preflight once per provider. Only success is
|
|
368
409
|
* cached, so following the remedy does not need an app restart.
|