dsh-plugin-wsl-env 0.22.0 → 0.23.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 +54 -0
- package/CONTRIBUTING.md +7 -3
- package/README.md +11 -9
- package/SUPPORT.md +1 -1
- package/cordis.patch.yml +4 -4
- package/docs/AGENT-PROTOCOL-V7.md +4 -4
- package/docs/API.md +12 -2
- package/docs/ARCHITECTURE.md +59 -19
- package/docs/CONFIGURATION.md +40 -18
- package/docs/CONFIGURATION.zh.md +44 -8
- package/docs/DIAGNOSTICS.md +19 -6
- package/docs/DIAGNOSTICS.zh.md +15 -6
- package/docs/LIMITATIONS.md +42 -17
- package/docs/LIMITATIONS.zh.md +47 -12
- package/docs/MIGRATION.md +1 -1
- package/docs/PEER-PARITY.md +8 -7
- package/docs/QUICKSTART.md +16 -8
- package/docs/QUICKSTART.zh.md +22 -4
- package/docs/README.zh.md +19 -10
- package/docs/RELEASING.md +8 -3
- package/docs/REQUIREMENTS.zh.md +11 -6
- package/docs/ROADMAP-1.0.md +12 -11
- package/docs/ROADMAP.md +10 -8
- package/docs/UPSTREAM-FILE-REFERENCE-SEAM.md +3 -2
- package/docs/UPSTREAM-FSIO-EXPORT.md +8 -9
- package/docs/UPSTREAM-SERVICE-SWAP.md +9 -5
- package/docs/UPSTREAM-TERMINAL-TITLE.md +9 -8
- package/docs/VALUE.zh.md +5 -5
- package/docs/root-fs-routing.md +26 -19
- package/lib/agent-confined.d.ts +2 -2
- package/lib/agent-confined.js +0 -1
- package/lib/agent-exec.d.ts +2 -11
- package/lib/agent-protocol.d.ts +6 -5
- package/lib/agent.d.ts +5 -5
- package/lib/auto-preset.d.ts +4 -3
- package/lib/bwrap.d.ts +2 -1
- package/lib/client-host.d.ts +1 -1
- package/lib/client-host.js +1 -1
- package/lib/cwd-prompt-tool.d.ts +4 -20
- package/lib/cwd-prompt.d.ts +11 -10
- package/lib/distro-route.d.ts +3 -2
- package/lib/doctor-live.d.ts +2 -1
- package/lib/fs-routing.d.ts +29 -1
- package/lib/fs-routing.js +30 -3
- package/lib/fs-substrate.d.ts +0 -1
- package/lib/fs-substrate.js +0 -1
- package/lib/fsio-agent.d.ts +3 -21
- package/lib/fsio-agent.js +2 -4
- package/lib/git-exec.d.ts +3 -2
- package/lib/git-route.d.ts +4 -2
- package/lib/git-route.js +4 -2
- package/lib/index.d.ts +9 -10
- package/lib/index.js +124 -12
- package/lib/listing.d.ts +2 -1
- package/lib/messages.d.ts +1 -1
- package/lib/native-agent.d.ts +3 -2
- package/lib/paths.d.ts +2 -1
- package/lib/picker.d.ts +1 -14
- package/lib/picker.js +1 -2
- package/lib/preflight.d.ts +5 -4
- package/lib/probe-cache.d.ts +2 -1
- package/lib/sandbox-core.d.ts +2 -11
- package/lib/sandbox-core.js +1 -1
- package/lib/sandbox.d.ts +0 -1
- package/lib/sandbox.js +0 -4
- package/lib/search-exec.d.ts +2 -1
- package/lib/session-runtime.d.ts +3 -2
- package/lib/shell-env.d.ts +3 -2
- package/lib/shell.d.ts +1 -1
- package/lib/shell.js +1 -1
- package/lib/subprocess.d.ts +1 -1
- package/lib/update-check.d.ts +3 -3
- package/lib/wsl-doctor-command.d.ts +38 -10
- package/lib/wsl-doctor-command.js +168 -27
- package/lib/wsl-doctor-tool.d.ts +9 -16
- package/lib/wsl-doctor-tool.js +10 -4
- package/lib/wsl.d.ts +3 -2
- package/package.json +27 -33
- package/scripts/bootstrap-import.sh +189 -0
- package/scripts/open-wsl-vscode.ps1 +36 -0
- package/examples/preset-wsl-session-sandbox.cordis.patch.yml +0 -178
package/lib/index.js
CHANGED
|
@@ -61,7 +61,7 @@ import { SessionRuntimes, probeSessionRuntime, sessionRuntimes, setSessionNative
|
|
|
61
61
|
import { configureAgentBackend, ensureNativeSessionAgent } from "./native-agent.js";
|
|
62
62
|
import { installMessagesLocale, t } from "./messages.js";
|
|
63
63
|
import { mergeLiveResidentStatus } from "./doctor-live.js";
|
|
64
|
-
import {
|
|
64
|
+
import { spawn } from "node:child_process";
|
|
65
65
|
import { fileURLToPath } from "node:url";
|
|
66
66
|
import { dirname, join } from "node:path";
|
|
67
67
|
// `runCapture` and distro discovery live in ./wsl.js so the directory picker
|
|
@@ -182,6 +182,114 @@ function wslWritableRoots(policy, distro) {
|
|
|
182
182
|
}
|
|
183
183
|
/** The doctor script this package ships, resolved from the compiled module. */
|
|
184
184
|
const DOCTOR_SCRIPT = join(dirname(fileURLToPath(import.meta.url)), "..", "scripts", "doctor.mjs");
|
|
185
|
+
/** How long the doctor subprocess may run before the collector kills it. */
|
|
186
|
+
const DOCTOR_TIMEOUT_MS = 120_000;
|
|
187
|
+
/**
|
|
188
|
+
* How much of one doctor stream the collector retains. The `--json` report is
|
|
189
|
+
* a few dozen KiB; the cap exists so a runaway child cannot grow the Host's
|
|
190
|
+
* memory without bound.
|
|
191
|
+
*/
|
|
192
|
+
const DOCTOR_OUTPUT_LIMIT_BYTES = 4 * 1024 * 1024;
|
|
193
|
+
/**
|
|
194
|
+
* How long after the doctor exits the collector waits for its pipes. A
|
|
195
|
+
* grandchild that inherited the pipes can keep them open forever; the report
|
|
196
|
+
* on stdout is complete once the doctor itself has exited, so the wait is
|
|
197
|
+
* bounded instead of following the pipes to EOF.
|
|
198
|
+
*/
|
|
199
|
+
const DOCTOR_DRAIN_GRACE_MS = 500;
|
|
200
|
+
/**
|
|
201
|
+
* Run the doctor CLI asynchronously and collect its streams.
|
|
202
|
+
*
|
|
203
|
+
* `spawnSync` would block the Host's event loop for the whole run — up to the
|
|
204
|
+
* deadline, with no way to cancel and every other tool stalled behind it — so
|
|
205
|
+
* the collector spawns, arms a deadline and the caller's abort signal, and
|
|
206
|
+
* settles on the child's exit plus a bounded drain window. A grandchild that
|
|
207
|
+
* inherits the pipes cannot hold the collector past that window.
|
|
208
|
+
*
|
|
209
|
+
* @param argv - the node argv (script path first).
|
|
210
|
+
* @param options - the child env, the deadline, and the caller's signal.
|
|
211
|
+
* @returns the finished run, including the spawn failure when it never started.
|
|
212
|
+
*/
|
|
213
|
+
function runDoctorProcess(argv, options) {
|
|
214
|
+
return new Promise((resolvePromise) => {
|
|
215
|
+
let stdout = "";
|
|
216
|
+
let stderr = "";
|
|
217
|
+
let timedOut = false;
|
|
218
|
+
let overLimit = false;
|
|
219
|
+
let spawnError;
|
|
220
|
+
let exit;
|
|
221
|
+
let drainTimer;
|
|
222
|
+
let settled = false;
|
|
223
|
+
const child = spawn(process.execPath, argv, {
|
|
224
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
225
|
+
windowsHide: true,
|
|
226
|
+
...(options.env === undefined ? {} : { env: options.env }),
|
|
227
|
+
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
228
|
+
});
|
|
229
|
+
const settle = () => {
|
|
230
|
+
if (settled)
|
|
231
|
+
return;
|
|
232
|
+
settled = true;
|
|
233
|
+
clearTimeout(deadlineTimer);
|
|
234
|
+
if (drainTimer !== undefined)
|
|
235
|
+
clearTimeout(drainTimer);
|
|
236
|
+
resolvePromise({
|
|
237
|
+
stdout,
|
|
238
|
+
stderr,
|
|
239
|
+
status: exit?.status ?? null,
|
|
240
|
+
signal: exit?.signal ?? null,
|
|
241
|
+
timedOut,
|
|
242
|
+
overLimit,
|
|
243
|
+
...(spawnError === undefined ? {} : { spawnError }),
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
const kill = () => {
|
|
247
|
+
try {
|
|
248
|
+
child.kill();
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
// An already-exited child: the exit handler settles the run.
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
const deadlineTimer = setTimeout(() => {
|
|
255
|
+
timedOut = true;
|
|
256
|
+
kill();
|
|
257
|
+
}, options.timeoutMs);
|
|
258
|
+
const capture = (chunk, which) => {
|
|
259
|
+
if (settled)
|
|
260
|
+
return;
|
|
261
|
+
if (which === "stdout")
|
|
262
|
+
stdout += chunk;
|
|
263
|
+
else
|
|
264
|
+
stderr += chunk;
|
|
265
|
+
if (stdout.length + stderr.length > DOCTOR_OUTPUT_LIMIT_BYTES) {
|
|
266
|
+
overLimit = true;
|
|
267
|
+
kill();
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
child.stdout?.on("data", (chunk) => capture(chunk.toString("utf8"), "stdout"));
|
|
271
|
+
child.stderr?.on("data", (chunk) => capture(chunk.toString("utf8"), "stderr"));
|
|
272
|
+
child.on("error", (error) => {
|
|
273
|
+
// A spawn failure never reaches `exit`; an abort is reported with the
|
|
274
|
+
// same event, so the marker is normalized into a plain message.
|
|
275
|
+
spawnError = error.name === "AbortError"
|
|
276
|
+
? new Error("doctor run aborted")
|
|
277
|
+
: error;
|
|
278
|
+
if (exit === undefined)
|
|
279
|
+
settle();
|
|
280
|
+
});
|
|
281
|
+
child.on("exit", (code, signalName) => {
|
|
282
|
+
exit = { status: code, signal: signalName ?? null };
|
|
283
|
+
// The report is complete at exit; give the pipes one bounded window to
|
|
284
|
+
// flush (a grandchild holding them must not stall the collector).
|
|
285
|
+
drainTimer = setTimeout(settle, DOCTOR_DRAIN_GRACE_MS);
|
|
286
|
+
});
|
|
287
|
+
child.on("close", () => {
|
|
288
|
+
if (exit !== undefined)
|
|
289
|
+
settle();
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
}
|
|
185
293
|
/**
|
|
186
294
|
* Collect the doctor's versioned JSON report and merge the live resident's
|
|
187
295
|
* own lifecycle facts when this process holds one (WSL-313).
|
|
@@ -198,6 +306,7 @@ const DOCTOR_SCRIPT = join(dirname(fileURLToPath(import.meta.url)), "..", "scrip
|
|
|
198
306
|
*
|
|
199
307
|
* @param distro - the distro the doctor examines.
|
|
200
308
|
* @param options - `doctorPath` overrides the shipped script (tests);
|
|
309
|
+
* `timeoutMs` bounds the run; `signal` lets the caller cancel it;
|
|
201
310
|
* `liveStatus` overrides the in-process status snapshot (tests).
|
|
202
311
|
* @returns the merged report.
|
|
203
312
|
*/
|
|
@@ -214,23 +323,26 @@ export async function doctorReport(distro, options) {
|
|
|
214
323
|
// machine being examined — that is a valid report, not a broken collection.
|
|
215
324
|
// The stdout is parsed regardless; only a run that produced no versioned
|
|
216
325
|
// report rejects.
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
windowsHide: true,
|
|
221
|
-
encoding: "utf8",
|
|
326
|
+
const timeoutMs = options?.timeoutMs ?? DOCTOR_TIMEOUT_MS;
|
|
327
|
+
const run = await runDoctorProcess(argv, {
|
|
328
|
+
timeoutMs,
|
|
222
329
|
...(options?.envPath !== undefined ? { env: { ...process.env, PATH: `${options.envPath}:${process.env.PATH ?? ""}` } } : {}),
|
|
330
|
+
...(options?.signal === undefined ? {} : { signal: options.signal }),
|
|
223
331
|
});
|
|
224
|
-
// A nonzero doctor exit usually means an environment check FAILED on the
|
|
225
|
-
// machine being examined — the versioned report on stdout is still the
|
|
226
|
-
// deliverable, so it parses whenever present. Only a run that produced no
|
|
227
|
-
// report rejects, naming the spawn failure and any stderr tail.
|
|
228
332
|
let report;
|
|
229
333
|
try {
|
|
230
|
-
report = JSON.parse(
|
|
334
|
+
report = JSON.parse(run.stdout);
|
|
231
335
|
}
|
|
232
336
|
catch {
|
|
233
|
-
|
|
337
|
+
// A run that produced no report rejects, naming the transport failure
|
|
338
|
+
// (spawn error, deadline, output cap, exit) and any stderr tail.
|
|
339
|
+
const cause = run.spawnError?.message
|
|
340
|
+
?? (run.timedOut
|
|
341
|
+
? `timed out after ${timeoutMs}ms`
|
|
342
|
+
: run.overLimit
|
|
343
|
+
? `produced more than ${DOCTOR_OUTPUT_LIMIT_BYTES} bytes`
|
|
344
|
+
: `exited with code ${run.status ?? run.signal ?? "unknown"}`);
|
|
345
|
+
throw new Error(`doctor run failed: ${cause}${run.stderr.length > 0 ? ` — ${run.stderr.trim().slice(-400)}` : ""}`);
|
|
234
346
|
}
|
|
235
347
|
const status = options?.liveStatus ?? sharedAgent(distro).status();
|
|
236
348
|
return mergeLiveResidentStatus(report, status);
|
package/lib/listing.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @module dsh-plugin-wsl-env/listing
|
|
12
12
|
*/
|
|
13
13
|
/** One picker row: a display name, its jump target, and the dot-entry flag. */
|
|
14
|
-
|
|
14
|
+
interface ListingRow {
|
|
15
15
|
/** The row's display name. */
|
|
16
16
|
name: string;
|
|
17
17
|
/** The row's jump target, Windows spelling. */
|
|
@@ -119,3 +119,4 @@ export declare function parseDirListing(stdout: string | Buffer, linuxDir: strin
|
|
|
119
119
|
rows: ListingRow[];
|
|
120
120
|
truncated: boolean;
|
|
121
121
|
};
|
|
122
|
+
export {};
|
package/lib/messages.d.ts
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import type { Context } from "@deepseek-ai/cordis";
|
|
25
25
|
/** The languages the catalogs ship. More locales are additive: add a table and widen the resolver. */
|
|
26
|
-
|
|
26
|
+
type MessagesLocale = "en" | "zh";
|
|
27
27
|
/**
|
|
28
28
|
* The message templates, keyed by call site. Each entry owns its parameter
|
|
29
29
|
* shape; the `zh` table is type-checked against the `en` table's key and
|
package/lib/native-agent.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export declare const NATIVE_AGENT_ENV = "DSH_WSL_AGENT_NATIVE";
|
|
|
33
33
|
*/
|
|
34
34
|
export declare function nativeCacheScript(digest: string): string;
|
|
35
35
|
/** The injectable edges. */
|
|
36
|
-
|
|
36
|
+
interface NativeBackendOptions {
|
|
37
37
|
/** The `wsl.exe` path. */
|
|
38
38
|
wslPath: string;
|
|
39
39
|
/** The distro. */
|
|
@@ -53,7 +53,7 @@ export interface NativeBackendOptions {
|
|
|
53
53
|
copy?: (script: string, binary: Buffer) => Promise<string>;
|
|
54
54
|
}
|
|
55
55
|
/** A prepared native binary: its in-distro path and the sha256 of its bytes. */
|
|
56
|
-
|
|
56
|
+
interface NativeBackendResult {
|
|
57
57
|
/** The Linux path the session runtime spawns. */
|
|
58
58
|
path: string;
|
|
59
59
|
/** Lowercase hex sha256; the agent's HELLO digest must match it. */
|
|
@@ -122,3 +122,4 @@ export declare function ensureNativeSessionAgent({ wslPath, distro, setNative, e
|
|
|
122
122
|
/** Prepare the binary; tests substitute. */
|
|
123
123
|
ensure?: (options: NativeBackendOptions) => Promise<NativeBackendResult | undefined>;
|
|
124
124
|
}): Promise<void>;
|
|
125
|
+
export {};
|
package/lib/paths.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export interface DistroPath {
|
|
|
30
30
|
* What the two world-path translators may consult: the pinned distro and the
|
|
31
31
|
* fallback directory for relative input.
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
interface WorldPathOptions {
|
|
34
34
|
/**
|
|
35
35
|
* The pinned distro, which maps a POSIX-absolute input onto its UNC identity
|
|
36
36
|
* in {@link toWorldPath}.
|
|
@@ -198,3 +198,4 @@ export declare function distroRoot(distro: string): string;
|
|
|
198
198
|
* @returns true for `\\wsl.localhost` and `\\wsl$` in any casing.
|
|
199
199
|
*/
|
|
200
200
|
export declare function isProviderRoot(value: string): boolean;
|
|
201
|
+
export {};
|
package/lib/picker.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ import type { DirectoryEntry, DirectoryListing, DirectoryPickerBrowseCapability
|
|
|
54
54
|
/**
|
|
55
55
|
* The resolved service configuration, as {@link WslDirectoryPicker.Config} yields.
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
interface PickerConfig {
|
|
58
58
|
/** Path to `wsl.exe`; overridable for a non-standard install. */
|
|
59
59
|
wslPath: string;
|
|
60
60
|
/**
|
|
@@ -74,18 +74,6 @@ export interface PickerConfig {
|
|
|
74
74
|
/** How long a resolved distro list stays fresh. */
|
|
75
75
|
distroCacheMs: number;
|
|
76
76
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Await `operation`, but reject with the signal's reason the moment it aborts.
|
|
79
|
-
* Node's filesystem reads are not retractable, so the operation itself keeps
|
|
80
|
-
* running against a handle the caller then closes; its late settlement is
|
|
81
|
-
* swallowed so an abandoned read cannot surface as an unhandled rejection.
|
|
82
|
-
*
|
|
83
|
-
* @template T
|
|
84
|
-
* @param operation - the in-flight filesystem step.
|
|
85
|
-
* @param signal - caller lifetime; absent means plain awaiting.
|
|
86
|
-
* @returns the operation's value.
|
|
87
|
-
*/
|
|
88
|
-
export declare function raceAbort<T>(operation: Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
89
77
|
/**
|
|
90
78
|
* The `ctx.directoryPicker` WSL implementation.
|
|
91
79
|
*
|
|
@@ -263,4 +251,3 @@ export declare class WslDirectoryPicker extends DirectoryPicker {
|
|
|
263
251
|
createDistroDirectory(parent: string, name: string, target: string): Promise<string>;
|
|
264
252
|
}
|
|
265
253
|
export default WslDirectoryPicker;
|
|
266
|
-
export { ancestryCrumbs, boundedInsert, breadcrumbs, fullyQualified } from "./listing.js";
|
package/lib/picker.js
CHANGED
|
@@ -70,7 +70,7 @@ const DEFAULT_DISTRO_CACHE_MS = 5_000;
|
|
|
70
70
|
* @param signal - caller lifetime; absent means plain awaiting.
|
|
71
71
|
* @returns the operation's value.
|
|
72
72
|
*/
|
|
73
|
-
|
|
73
|
+
function raceAbort(operation, signal) {
|
|
74
74
|
if (signal === void 0)
|
|
75
75
|
return operation;
|
|
76
76
|
return new Promise((resolve, reject) => {
|
|
@@ -471,4 +471,3 @@ export class WslDirectoryPicker extends DirectoryPicker {
|
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
473
|
export default WslDirectoryPicker;
|
|
474
|
-
export { ancestryCrumbs, boundedInsert, breadcrumbs, fullyQualified } from "./listing.js";
|
package/lib/preflight.d.ts
CHANGED
|
@@ -86,7 +86,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
86
86
|
startup: z<boolean, boolean, "defined">;
|
|
87
87
|
}>>, "plain">;
|
|
88
88
|
/** The config schema's validated output. */
|
|
89
|
-
|
|
89
|
+
interface PreflightConfig {
|
|
90
90
|
/** The distro mode: empty/`auto`, an explicit name, or `default`. */
|
|
91
91
|
distro?: string;
|
|
92
92
|
/** The `wsl.exe` path the probe spawns. */
|
|
@@ -102,7 +102,7 @@ export interface PreflightConfig {
|
|
|
102
102
|
* The slice of a created agent this service inspects; the harness's agent
|
|
103
103
|
* object is structural here, the same view `auto-preset` uses.
|
|
104
104
|
*/
|
|
105
|
-
|
|
105
|
+
interface PreflightAgent {
|
|
106
106
|
/** The agent's id. */
|
|
107
107
|
id: string;
|
|
108
108
|
/** The session stub, when mounted. */
|
|
@@ -122,7 +122,7 @@ export interface PreflightAgent {
|
|
|
122
122
|
} | undefined;
|
|
123
123
|
}
|
|
124
124
|
/** The slice of a session context that can carry the advisory. */
|
|
125
|
-
|
|
125
|
+
interface PreflightPromptScope {
|
|
126
126
|
systemPrompt: {
|
|
127
127
|
context: (entry: {
|
|
128
128
|
name: string;
|
|
@@ -137,7 +137,7 @@ export interface PreflightPromptScope {
|
|
|
137
137
|
* visible to this plugin, so they are spelled structurally on top of the
|
|
138
138
|
* framework's {@link Context}.
|
|
139
139
|
*/
|
|
140
|
-
|
|
140
|
+
type PreflightContext = Context & {
|
|
141
141
|
logger?: {
|
|
142
142
|
debug?: (message: string) => void;
|
|
143
143
|
warn?: (message: string) => void;
|
|
@@ -156,3 +156,4 @@ export type PreflightContext = Context & {
|
|
|
156
156
|
* @param config - the schema-validated plugin config.
|
|
157
157
|
*/
|
|
158
158
|
export declare function apply(ctx: PreflightContext, config?: PreflightConfig): Promise<void>;
|
|
159
|
+
export {};
|
package/lib/probe-cache.d.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* fails when it drifts.
|
|
20
20
|
*/
|
|
21
21
|
/** One probe cache's surface. */
|
|
22
|
-
|
|
22
|
+
interface ProbeCache {
|
|
23
23
|
/**
|
|
24
24
|
* Run one probe under the policy.
|
|
25
25
|
*
|
|
@@ -49,3 +49,4 @@ export interface ProbeCache {
|
|
|
49
49
|
* @returns the policy object `lib/sandbox-core.js` holds per provider.
|
|
50
50
|
*/
|
|
51
51
|
export declare function createProbeCache(): ProbeCache;
|
|
52
|
+
export {};
|
package/lib/sandbox-core.d.ts
CHANGED
|
@@ -28,16 +28,6 @@
|
|
|
28
28
|
* @returns the operator-facing remedy text.
|
|
29
29
|
*/
|
|
30
30
|
export declare function missingBwrapRemedy(distro: string, family?: string): string;
|
|
31
|
-
/**
|
|
32
|
-
* The remedy for a bwrap that PROBED healthy but failed a run — the runtime
|
|
33
|
-
* twin of {@link missingBwrapRemedy}. No family knowledge exists on this path
|
|
34
|
-
* (the probe succeeded, so no family probe ever ran), and reinstalling is only
|
|
35
|
-
* one of the plausible fixes, so the hint leads with diagnosis.
|
|
36
|
-
*
|
|
37
|
-
* @param distro - the distro whose bwrap failed at run time.
|
|
38
|
-
* @returns the operator-facing hint text.
|
|
39
|
-
*/
|
|
40
|
-
export declare function bwrapInstallHint(distro: string): string;
|
|
41
31
|
/**
|
|
42
32
|
* Append {@link bwrapInstallHint} to a runner-failure detail that names bwrap.
|
|
43
33
|
* A probe-time failure composes its own classified remedy; this covers the
|
|
@@ -90,7 +80,7 @@ export declare function bwrapFailure(wslPath: string, distro: string): string |
|
|
|
90
80
|
* The seam's `ConfinedArgv` settlement facts, plus this core's `windowsDrive`
|
|
91
81
|
* mitigation flag.
|
|
92
82
|
*/
|
|
93
|
-
|
|
83
|
+
interface WslConfined {
|
|
94
84
|
/** The wrapped argv (bwrap prefix, separator, the caller's argv). */
|
|
95
85
|
argv: string[];
|
|
96
86
|
/**
|
|
@@ -147,3 +137,4 @@ export declare function createSandboxCore({ SandboxUnavailableError }: {
|
|
|
147
137
|
wslPath?: string;
|
|
148
138
|
maskWindowsDrive?: boolean;
|
|
149
139
|
} | undefined) => WslSandboxCoreInstance;
|
|
140
|
+
export {};
|
package/lib/sandbox-core.js
CHANGED
|
@@ -177,7 +177,7 @@ export function missingBwrapRemedy(distro, family) {
|
|
|
177
177
|
* @param distro - the distro whose bwrap failed at run time.
|
|
178
178
|
* @returns the operator-facing hint text.
|
|
179
179
|
*/
|
|
180
|
-
|
|
180
|
+
function bwrapInstallHint(distro) {
|
|
181
181
|
return t("bwrapRuntimeFailure", { distro });
|
|
182
182
|
}
|
|
183
183
|
/**
|
package/lib/sandbox.d.ts
CHANGED
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
*
|
|
37
37
|
* @module dsh-plugin-wsl-env/sandbox
|
|
38
38
|
*/
|
|
39
|
-
export { bwrapProfileArgs } from "./bwrap.js";
|
|
40
39
|
/**
|
|
41
40
|
* The confinement over WSL: the probe-then-confine class bound to the peer's
|
|
42
41
|
* failure type. See the core module for the probe policy and the profile.
|
package/lib/sandbox.js
CHANGED
|
@@ -38,10 +38,6 @@
|
|
|
38
38
|
*/
|
|
39
39
|
import { SandboxUnavailableError } from "@deepseek-ai/dsh-sandbox";
|
|
40
40
|
import { createSandboxCore } from "./sandbox-core.js";
|
|
41
|
-
// The profile and the argv prefix are also what `lib/agent-confined.js` builds
|
|
42
|
-
// for its residents, so both live in the peer-free `lib/bwrap.js` and are
|
|
43
|
-
// re-exported here, where the sandbox's callers have always found them.
|
|
44
|
-
export { bwrapProfileArgs } from "./bwrap.js";
|
|
45
41
|
/**
|
|
46
42
|
* The confinement over WSL: the probe-then-confine class bound to the peer's
|
|
47
43
|
* failure type. See the core module for the probe policy and the profile.
|
package/lib/search-exec.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ import type { AgentExecRunner } from "./agent-exec.js";
|
|
|
34
34
|
* The output-stream reader the search tool consumes: `handle.collected.stdout`
|
|
35
35
|
* / `stderr` expose `readFrom(offset)` with the seam's standard shape.
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
interface SearchCollectedReader {
|
|
38
38
|
/** Read the stream from a byte offset. */
|
|
39
39
|
readFrom: (from: number) => {
|
|
40
40
|
text: string;
|
|
@@ -94,3 +94,4 @@ export declare function searchExecutionHandle({ agent, cwd, argv, maxOutputBytes
|
|
|
94
94
|
*/
|
|
95
95
|
spawnFallback: () => SearchExecutionHandle;
|
|
96
96
|
}): SearchExecutionHandle;
|
|
97
|
+
export {};
|
package/lib/session-runtime.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export declare function probeSessionRuntime({ wslPath, distro, run }: {
|
|
|
42
42
|
run: (argv: string[]) => Promise<string>;
|
|
43
43
|
}): Promise<string | null>;
|
|
44
44
|
/** One request for a session runtime. */
|
|
45
|
-
|
|
45
|
+
interface SessionRuntimeRequest {
|
|
46
46
|
/** The session identity; absent requests each get a separate runtime. */
|
|
47
47
|
sessionId?: string;
|
|
48
48
|
/** The distro the runtime lives in. */
|
|
@@ -74,7 +74,7 @@ export interface SessionRuntimeEntry {
|
|
|
74
74
|
refs: number;
|
|
75
75
|
}
|
|
76
76
|
/** The injectable edges, so the registry is testable without systemd. */
|
|
77
|
-
|
|
77
|
+
interface SessionRuntimeOptions {
|
|
78
78
|
/** Create the agent; tests substitute a fake. */
|
|
79
79
|
spawnAgent?: (options: {
|
|
80
80
|
/** The distro. */
|
|
@@ -161,3 +161,4 @@ export declare class SessionRuntimes {
|
|
|
161
161
|
}
|
|
162
162
|
/** The process-wide registry the providers will share. */
|
|
163
163
|
export declare const sessionRuntimes: SessionRuntimes;
|
|
164
|
+
export {};
|
package/lib/shell-env.d.ts
CHANGED
|
@@ -73,7 +73,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
73
73
|
portsRefreshMs: z<number, number, "defined">;
|
|
74
74
|
}>>, "plain">;
|
|
75
75
|
/** The config schema's validated output. */
|
|
76
|
-
|
|
76
|
+
interface ShellEnvConfig {
|
|
77
77
|
/** The distro mode: empty/`auto`, an explicit name, or `default`. */
|
|
78
78
|
distro?: string;
|
|
79
79
|
/** How often the listening-port snapshot refreshes, in milliseconds. */
|
|
@@ -83,7 +83,7 @@ export interface ShellEnvConfig {
|
|
|
83
83
|
* The execution slice the shell-env registry hands a contributor's `resolve`;
|
|
84
84
|
* the harness's execution object is structural here.
|
|
85
85
|
*/
|
|
86
|
-
|
|
86
|
+
interface ShellEnvExecution {
|
|
87
87
|
/** The executing session's agent stub. */
|
|
88
88
|
agent?: {
|
|
89
89
|
session?: {
|
|
@@ -117,3 +117,4 @@ export type ShellEnvContext = Context & {
|
|
|
117
117
|
* @param config - the schema-validated plugin config.
|
|
118
118
|
*/
|
|
119
119
|
export declare function apply(ctx: ShellEnvContext, config?: ShellEnvConfig): Promise<void>;
|
|
120
|
+
export {};
|
package/lib/shell.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `ctx.shell` executor for the WSL agent preset — load as
|
|
3
|
-
* `dsh-plugin-wsl-env/shell` (before 0.
|
|
3
|
+
* `dsh-plugin-wsl-env/shell` (before 0.21.0 the package root resolved here;
|
|
4
4
|
* the root is now the no-op web client host half, see `src/client-host.ts`).
|
|
5
5
|
*
|
|
6
6
|
* This is a TypeScript source built to `lib/shell.js`; edit THIS file and run
|
package/lib/shell.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `ctx.shell` executor for the WSL agent preset — load as
|
|
3
|
-
* `dsh-plugin-wsl-env/shell` (before 0.
|
|
3
|
+
* `dsh-plugin-wsl-env/shell` (before 0.21.0 the package root resolved here;
|
|
4
4
|
* the root is now the no-op web client host half, see `src/client-host.ts`).
|
|
5
5
|
*
|
|
6
6
|
* This is a TypeScript source built to `lib/shell.js`; edit THIS file and run
|
package/lib/subprocess.d.ts
CHANGED
|
@@ -92,7 +92,7 @@ import type { SubprocessTerminalActivity } from "./terminal-activity.js";
|
|
|
92
92
|
* present after validation; `hostCwd` is the volatile accessor the schema
|
|
93
93
|
* builds.
|
|
94
94
|
*/
|
|
95
|
-
|
|
95
|
+
interface WslSubprocessConfig {
|
|
96
96
|
/**
|
|
97
97
|
* Distro mode: empty/`"auto"` follows the launch directory, `"default"`
|
|
98
98
|
* forces WSL's default, and an explicit name pins.
|
package/lib/update-check.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
45
45
|
intervalMs: z<number, number, "defined">;
|
|
46
46
|
}>>, "plain">;
|
|
47
47
|
/** The config schema's validated output. */
|
|
48
|
-
|
|
48
|
+
interface UpdateCheckConfig {
|
|
49
49
|
/** Whether the update check runs at all. */
|
|
50
50
|
enabled?: boolean;
|
|
51
51
|
/** How often the registry is asked, in milliseconds. */
|
|
@@ -92,7 +92,7 @@ export interface PluginManagerSlice {
|
|
|
92
92
|
listVersions: (name: string) => Promise<VersionList>;
|
|
93
93
|
}
|
|
94
94
|
/** The update fact one successful check publishes. */
|
|
95
|
-
|
|
95
|
+
interface UpdateFact {
|
|
96
96
|
/** The version this process runs. */
|
|
97
97
|
installed: string;
|
|
98
98
|
/** The version the stable channel offers. */
|
|
@@ -181,7 +181,7 @@ export declare function updateFactMessage(update: UpdateFact | undefined): strin
|
|
|
181
181
|
* visible to this plugin, so they are spelled structurally on top of the
|
|
182
182
|
* framework's {@link Context}.
|
|
183
183
|
*/
|
|
184
|
-
|
|
184
|
+
type UpdateCheckContext = Context & {
|
|
185
185
|
logger?: {
|
|
186
186
|
debug?: (message: string) => void;
|
|
187
187
|
};
|
|
@@ -9,11 +9,11 @@ export declare const name = "wsl-doctor-command";
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const inject: string[];
|
|
11
11
|
/** The host commands registry slice this row consumes. */
|
|
12
|
-
|
|
12
|
+
interface CommandsRegistrySlice {
|
|
13
13
|
register: (definition: WslDoctorCommandDefinition) => unknown;
|
|
14
14
|
}
|
|
15
15
|
/** The invocation face the registry hands a handler. */
|
|
16
|
-
|
|
16
|
+
interface WslDoctorCommandInvocation {
|
|
17
17
|
/** The receiving agent, when the command ran against a session. */
|
|
18
18
|
agent?: unknown;
|
|
19
19
|
/** Everything after the command name, separator whitespace trimmed. */
|
|
@@ -31,27 +31,48 @@ export interface WslDoctorCommandDefinition {
|
|
|
31
31
|
handler: (invocation: WslDoctorCommandInvocation) => Promise<WslDoctorCommandResult>;
|
|
32
32
|
}
|
|
33
33
|
/** The settled result the adapter renders detached from model history. */
|
|
34
|
-
|
|
34
|
+
interface WslDoctorCommandResult {
|
|
35
35
|
kind: "success" | "error";
|
|
36
36
|
text: string;
|
|
37
37
|
}
|
|
38
38
|
/** The context slice this service consumes. */
|
|
39
|
-
|
|
39
|
+
type WslDoctorCommandContext = {
|
|
40
40
|
/** The commands registry, when the deployment has a command adapter. */
|
|
41
41
|
commands?: CommandsRegistrySlice;
|
|
42
42
|
/** The harness's cwd service, used to name the session's distro. */
|
|
43
|
-
workingDirectory?:
|
|
44
|
-
ensure: (agent: unknown, signal?: unknown) => Promise<string>;
|
|
45
|
-
};
|
|
43
|
+
workingDirectory?: WorkingDirectorySlice;
|
|
46
44
|
/** Optional cordis-style lookup: how production resolves both without an inject. */
|
|
47
45
|
get?: (name: string) => unknown;
|
|
48
46
|
/** The test seam: a provided CLI runner replaces the real subprocess. */
|
|
49
47
|
doctorCli?: DoctorCliRunner;
|
|
50
48
|
};
|
|
49
|
+
/** The harness's `workingDirectory` service slice. */
|
|
50
|
+
interface WorkingDirectorySlice {
|
|
51
|
+
/** The Session's current directory, recorded synchronously when available. */
|
|
52
|
+
get?: (session: unknown) => string | null | undefined;
|
|
53
|
+
/** Resolve (and repair) the Session's current directory. */
|
|
54
|
+
ensure?: (agent: unknown, signal?: unknown) => Promise<string>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* How long a distro-scoped doctor CLI run may take. A scoped quick run takes
|
|
58
|
+
* seconds and a scoped full run ~15 s, so only a stall reaches this; it sits
|
|
59
|
+
* below the command dispatcher's own deadline so the run settles with a
|
|
60
|
+
* message naming what happened instead of the dispatcher's opaque "operation
|
|
61
|
+
* was aborted".
|
|
62
|
+
*/
|
|
63
|
+
export declare const DOCTOR_CLI_TIMEOUT_MS = 120000;
|
|
64
|
+
/**
|
|
65
|
+
* How long an UNRESOLVED-target run may take. Without a distro the CLI's
|
|
66
|
+
* effective configuration decides, and the shipped `auto` probes every
|
|
67
|
+
* installed distro — minutes on a machine with several, with no progress to
|
|
68
|
+
* show in the UI. Failing fast with the narrowing hint beats a card that sits
|
|
69
|
+
* "executing" for the dispatcher's whole budget.
|
|
70
|
+
*/
|
|
71
|
+
export declare const DOCTOR_CLI_SWEEP_TIMEOUT_MS = 60000;
|
|
51
72
|
/** The CLI runner seam: argv in (node-less — the runner owns the runtime), JSON text out. */
|
|
52
|
-
|
|
73
|
+
type DoctorCliRunner = (argv: string[], signal?: AbortSignal, timeoutMs?: number) => Promise<string>;
|
|
53
74
|
/** The parsed `/wsl-doctor` line. */
|
|
54
|
-
|
|
75
|
+
interface ParsedDoctorInput {
|
|
55
76
|
/** quick → `--quick`; full → no flag; section → `--sections <name>`. */
|
|
56
77
|
mode: "quick" | "full" | "section";
|
|
57
78
|
/** The section name, when `mode` is `"section"`. */
|
|
@@ -81,11 +102,17 @@ export declare function parseDoctorInput(rawInput: string): ParsedDoctorInput;
|
|
|
81
102
|
* verdict*, which is a successful diagnosis — the JSON on stdout still parses;
|
|
82
103
|
* only a spawn failure or unparseable output is an infrastructure error.
|
|
83
104
|
*
|
|
105
|
+
* The run is bounded by {@link DOCTOR_CLI_TIMEOUT_MS}. Without a deadline a
|
|
106
|
+
* doctor that never reports keeps the command "executing" until the command
|
|
107
|
+
* dispatcher aborts it, and that abort surfaces as an opaque "operation was
|
|
108
|
+
* aborted" that names neither what ran nor how to narrow it.
|
|
109
|
+
*
|
|
84
110
|
* @param argv - flags after the script path (no node, no script — added here).
|
|
85
111
|
* @param signal - the dispatcher's abort signal; abort kills the child.
|
|
112
|
+
* @param timeoutMs - the deadline; tests shrink it to exercise the timeout.
|
|
86
113
|
* @returns the CLI's stdout (one JSON report).
|
|
87
114
|
*/
|
|
88
|
-
export declare function runDoctorCli(argv: string[], signal?: AbortSignal): Promise<string>;
|
|
115
|
+
export declare function runDoctorCli(argv: string[], signal?: AbortSignal, timeoutMs?: number): Promise<string>;
|
|
89
116
|
/**
|
|
90
117
|
* Format the CLI's JSON report into the itemized text the UI renders — the
|
|
91
118
|
* same digest the `wsl_doctor` tool returns, so both surfaces itemize every
|
|
@@ -103,3 +130,4 @@ export declare function formatDoctorReport(json: string, distro: string): string
|
|
|
103
130
|
* registry and the harness cwd service are reachable).
|
|
104
131
|
*/
|
|
105
132
|
export declare function apply(ctx: WslDoctorCommandContext): Promise<void>;
|
|
133
|
+
export {};
|