dsh-plugin-wsl-env 0.17.1 → 0.19.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 +225 -0
- package/CONTRIBUTING.md +37 -5
- package/README.md +61 -6
- package/SUPPORT.md +3 -3
- package/agent/native/linux-aarch64/dsh-wsl-agent +0 -0
- package/agent/native/linux-x86_64/dsh-wsl-agent +0 -0
- package/agent/wsl-agent.sh +331 -11
- package/cordis.patch.yml +10 -5
- package/docs/AGENT-PROTOCOL-V7.md +175 -0
- package/docs/API.md +24 -0
- package/docs/ARCHITECTURE.md +20 -6
- package/docs/COMPATIBILITY.md +1 -1
- package/docs/CONFIGURATION.md +33 -5
- package/docs/CONFIGURATION.zh.md +25 -4
- package/docs/LIMITATIONS.md +39 -7
- package/docs/LIMITATIONS.zh.md +31 -6
- package/docs/MIGRATION.md +4 -4
- package/docs/PEER-PARITY.md +94 -35
- package/docs/QUICKSTART.md +19 -2
- package/docs/QUICKSTART.zh.md +16 -1
- package/docs/README.zh.md +47 -7
- package/docs/RELEASING.md +3 -2
- package/docs/REQUIREMENTS.zh.md +11 -6
- package/docs/ROADMAP-1.0.md +40 -29
- package/docs/ROADMAP.md +10 -6
- package/docs/UPSTREAM-FILE-REFERENCE-SEAM.md +6 -1
- package/docs/UPSTREAM-FSIO-EXPORT.md +2 -2
- package/docs/UPSTREAM-SERVICE-SWAP.md +124 -0
- package/docs/UPSTREAM-SESSION-NOTICE.md +3 -1
- package/docs/UPSTREAM-TERMINAL-TITLE.md +3 -0
- package/docs/root-fs-routing.md +3 -3
- package/lib/agent-confined.js +4 -4
- package/lib/agent-errors.d.ts +1 -1
- package/lib/agent-errors.js +1 -1
- package/lib/agent-exec.d.ts +1 -1
- package/lib/agent-exec.js +1 -1
- package/lib/agent-protocol.d.ts +58 -8
- package/lib/agent-protocol.js +40 -7
- package/lib/agent-shared.d.ts +1 -1
- package/lib/agent-shared.js +1 -1
- package/lib/agent.d.ts +171 -1
- package/lib/agent.js +448 -288
- package/lib/auto-preset.d.ts +1 -1
- package/lib/auto-preset.js +1 -1
- package/lib/bwrap.d.ts +1 -1
- package/lib/bwrap.js +1 -1
- package/lib/distro-route.d.ts +1 -1
- package/lib/distro-route.js +1 -1
- package/lib/doctor-live.d.ts +53 -0
- package/lib/doctor-live.js +37 -0
- package/lib/file-reference-wsl.d.ts +1 -1
- package/lib/file-reference-wsl.js +1 -1
- package/lib/fs-decisions.d.ts +1 -1
- package/lib/fs-decisions.js +1 -1
- package/lib/fs-routing.d.ts +52 -2
- package/lib/fs-routing.js +56 -1
- package/lib/fs-substrate.d.ts +90 -11
- package/lib/fs-substrate.js +202 -1
- package/lib/fs.d.ts +1 -1
- package/lib/fs.js +1 -1
- package/lib/fsio-agent.d.ts +128 -4
- package/lib/fsio-agent.js +224 -15
- package/lib/fsio-text.d.ts +1 -1
- package/lib/fsio-text.js +1 -1
- package/lib/git-exec.d.ts +1 -1
- package/lib/git-exec.js +1 -1
- package/lib/git-route.d.ts +1 -1
- package/lib/git-route.js +1 -1
- package/lib/index.d.ts +127 -3
- package/lib/index.js +301 -99
- package/lib/listing.d.ts +1 -1
- package/lib/listing.js +1 -1
- package/lib/native-agent.d.ts +1 -1
- package/lib/native-agent.js +2 -2
- package/lib/paths.d.ts +6 -3
- package/lib/paths.js +4 -4
- package/lib/picker.d.ts +1 -1
- package/lib/picker.js +7 -7
- package/lib/ports.d.ts +1 -1
- package/lib/ports.js +1 -1
- package/lib/preflight.d.ts +1 -1
- package/lib/preflight.js +1 -1
- package/lib/sandbox-core.d.ts +1 -1
- package/lib/sandbox-core.js +2 -2
- package/lib/sandbox.d.ts +1 -1
- package/lib/sandbox.js +1 -1
- package/lib/search-exec.d.ts +1 -1
- package/lib/search-exec.js +1 -1
- package/lib/search-route.d.ts +1 -1
- package/lib/search-route.js +1 -1
- package/lib/session-runtime.d.ts +1 -1
- package/lib/session-runtime.js +2 -2
- package/lib/session-scope.d.ts +1 -1
- package/lib/session-scope.js +1 -1
- package/lib/shell-env.d.ts +1 -1
- package/lib/shell-env.js +1 -1
- package/lib/shell.d.ts +1 -1
- package/lib/shell.js +1 -1
- package/lib/subprocess.d.ts +1 -1
- package/lib/subprocess.js +2 -2
- package/lib/terminal-activity.d.ts +1 -1
- package/lib/terminal-activity.js +1 -1
- package/lib/terminal-route.d.ts +1 -1
- package/lib/terminal-route.js +1 -1
- package/lib/watcher.d.ts +1 -1
- package/lib/watcher.js +1 -1
- package/lib/wsl.d.ts +1 -31
- package/lib/wsl.js +1 -21
- package/package.json +41 -28
- package/scripts/doctor.mjs +34 -11
package/lib/fs-substrate.js
CHANGED
|
@@ -28,11 +28,17 @@
|
|
|
28
28
|
* and run `pnpm run build` — the artifact under `lib/` is generated, and
|
|
29
29
|
* `pnpm test` fails when it drifts.
|
|
30
30
|
*
|
|
31
|
-
* @module dsh-plugin-wsl/fs-substrate
|
|
31
|
+
* @module dsh-plugin-wsl-env/fs-substrate
|
|
32
32
|
*/
|
|
33
|
+
import { applyHunks } from "@deepseek-ai/dsh-fs-patch";
|
|
34
|
+
import { reasonToCode } from "./fsio-agent.js";
|
|
33
35
|
import { applyLiteralEdit, FsCodedError, normalizeLineEndings, restoreLineEndings } from "./fsio-text.js";
|
|
34
36
|
import { DistroFs } from "./fsio-agent.js";
|
|
35
37
|
import { posixToUnc, uncToPosix } from "./paths.js";
|
|
38
|
+
/**
|
|
39
|
+
* A resolved target: the Linux spelling the model sees and the UNC identity
|
|
40
|
+
* the harness keys on, as returned by {@linkcode AgentSubstrate#resolve}.
|
|
41
|
+
*/
|
|
36
42
|
/**
|
|
37
43
|
* The provider's stat/lstat row, type-spelled the way the tool layer reads it.
|
|
38
44
|
*
|
|
@@ -287,5 +293,200 @@ export class AgentSubstrate {
|
|
|
287
293
|
};
|
|
288
294
|
});
|
|
289
295
|
}
|
|
296
|
+
/**
|
|
297
|
+
* Apply parsed hunks to a text file (protocol 7): the peer's `patchText`
|
|
298
|
+
* semantics, using the peer's own `applyHunks` for matching and its exact
|
|
299
|
+
* `FS_PATCH_MISMATCH` dialect, then the same guarded atomic publication a
|
|
300
|
+
* write takes. The hunks travel in-process; the distro sees one read and
|
|
301
|
+
* one guarded replace.
|
|
302
|
+
*
|
|
303
|
+
* @param target - the resolved regular file.
|
|
304
|
+
* @param hunks - ordered hunks from the caller's patch parse.
|
|
305
|
+
* @param expected - the version the patch was based on.
|
|
306
|
+
* @param signal - cancels the patch.
|
|
307
|
+
* @param policy - the resolved policy this patch was fenced with.
|
|
308
|
+
* @returns the pre/post text and the published version.
|
|
309
|
+
*/
|
|
310
|
+
async patchText(target, hunks, expected, signal, policy) {
|
|
311
|
+
const mutationAgent = await this.mutationAgent(policy);
|
|
312
|
+
return this.lock(target.targetKey, async () => {
|
|
313
|
+
const linuxPath = this.linuxOf(target);
|
|
314
|
+
const existing = await this.fs.stat(linuxPath, { signal });
|
|
315
|
+
if (!existing)
|
|
316
|
+
throw new FsCodedError(`cannot patch "${target.displayPath}": file changed since it was read`, "FS_STALE_VERSION");
|
|
317
|
+
if (existing.type !== "f")
|
|
318
|
+
throw new FsCodedError(`cannot patch "${target.displayPath}": not a regular file`, "FS_NOT_REGULAR_FILE");
|
|
319
|
+
if (expected && existing.version !== expected.version) {
|
|
320
|
+
throw new FsCodedError(`cannot patch "${target.displayPath}": file changed since it was read`, "FS_STALE_VERSION");
|
|
321
|
+
}
|
|
322
|
+
const original = await this.fs.readForEdit(target, signal);
|
|
323
|
+
const result = applyHunks(original.content, hunks);
|
|
324
|
+
if (!result.ok) {
|
|
325
|
+
throw new FsCodedError(`cannot patch "${target.displayPath}": hunk at patch line ${result.failure.hunkLineNumber} (${result.failure.stage}) does not match`, "FS_PATCH_MISMATCH");
|
|
326
|
+
}
|
|
327
|
+
const content = restoreLineEndings(result.after, original.lineEndings);
|
|
328
|
+
await this.fs.writeFileAtomic(linuxPath, content, { mode: existing.mode, expectedVersion: existing.version, signal, agent: mutationAgent });
|
|
329
|
+
const after = await this.fs.stat(linuxPath, { signal });
|
|
330
|
+
return {
|
|
331
|
+
version: after ? after.version : `missing:${target.targetKey}`,
|
|
332
|
+
before: original.content,
|
|
333
|
+
after: result.after,
|
|
334
|
+
};
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Remove one regular file (protocol 7), mirroring the peer's
|
|
339
|
+
* `deleteFile`: missing/stale/mismatched targets refuse, the read-basis is
|
|
340
|
+
* best effort and bounded by `diffBasisMaxBytes`, and the removal itself is
|
|
341
|
+
* re-guarded distro-side by the expected version.
|
|
342
|
+
*
|
|
343
|
+
* @param target - the resolved file.
|
|
344
|
+
* @param expected - the version the removal was based on.
|
|
345
|
+
* @param signal - cancels the removal.
|
|
346
|
+
* @param policy - the resolved policy this removal was fenced with.
|
|
347
|
+
* @returns the bounded pre-removal text basis.
|
|
348
|
+
*/
|
|
349
|
+
async deleteFile(target, expected, signal, policy) {
|
|
350
|
+
const mutationAgent = await this.mutationAgent(policy);
|
|
351
|
+
if (!this.fs.supportsDestructive(mutationAgent)) {
|
|
352
|
+
throw new FsCodedError(`cannot delete "${target.displayPath}": the resident agent does not serve protocol-7 operations — restart the app to rebuild the resident`, "FS_IO_ERROR");
|
|
353
|
+
}
|
|
354
|
+
return this.lock(target.targetKey, async () => {
|
|
355
|
+
const linuxPath = this.linuxOf(target);
|
|
356
|
+
const existing = await this.fs.stat(linuxPath, { signal });
|
|
357
|
+
if (!existing)
|
|
358
|
+
throw new FsCodedError(`cannot delete "${target.displayPath}": file changed since it was read`, "FS_STALE_VERSION");
|
|
359
|
+
if (existing.type !== "f")
|
|
360
|
+
throw new FsCodedError(`cannot delete "${target.displayPath}": not a regular file`, "FS_NOT_REGULAR_FILE");
|
|
361
|
+
if (expected && existing.version !== expected.version) {
|
|
362
|
+
throw new FsCodedError(`cannot delete "${target.displayPath}": file changed since it was read`, "FS_STALE_VERSION");
|
|
363
|
+
}
|
|
364
|
+
const before = await this.fs.readTextForDiff(target, this.diffBasisMaxBytes, signal);
|
|
365
|
+
await this.fs.removeFile(linuxPath, expected?.version, signal, mutationAgent);
|
|
366
|
+
return { before };
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Move a regular file (protocol 7), mirroring the peer's `moveFile`: the
|
|
371
|
+
* source passes `requireFile`, the destination `writeTarget`, an optional
|
|
372
|
+
* hunk set transforms the text on the way, and the two effects (publish,
|
|
373
|
+
* remove) are reported separately — a destination that landed while the
|
|
374
|
+
* source survived returns `sourceDeleted: false` plus the failure.
|
|
375
|
+
*
|
|
376
|
+
* @param source - the resolved source.
|
|
377
|
+
* @param destination - the resolved destination.
|
|
378
|
+
* @param options - the hunks and the source/destination guards.
|
|
379
|
+
* @param signal - cancels before publication.
|
|
380
|
+
* @param policy - the resolved policy both paths run under.
|
|
381
|
+
* @returns the bounded source basis and the destination outcome.
|
|
382
|
+
*/
|
|
383
|
+
async moveFile(source, destination, options, signal, policy) {
|
|
384
|
+
if (source.targetKey === destination.targetKey) {
|
|
385
|
+
throw new FsCodedError(`cannot move "${source.displayPath}" to itself`, "FS_SAME_TARGET");
|
|
386
|
+
}
|
|
387
|
+
const mutationAgent = await this.mutationAgent(policy);
|
|
388
|
+
if (!this.fs.supportsDestructive(mutationAgent)) {
|
|
389
|
+
throw new FsCodedError(`cannot move "${source.displayPath}": the resident agent does not serve protocol-7 operations — restart the app to rebuild the resident`, "FS_IO_ERROR");
|
|
390
|
+
}
|
|
391
|
+
const keys = [source.targetKey, destination.targetKey].sort();
|
|
392
|
+
return this.lock(keys[0], () => this.lock(keys[1], async () => {
|
|
393
|
+
const sourcePath = this.linuxOf(source);
|
|
394
|
+
const destinationPath = this.linuxOf(destination);
|
|
395
|
+
const sourceInfo = await this.fs.stat(sourcePath, { signal });
|
|
396
|
+
if (!sourceInfo)
|
|
397
|
+
throw new FsCodedError(`cannot move "${source.displayPath}": file changed since it was read`, "FS_STALE_VERSION");
|
|
398
|
+
if (sourceInfo.type !== "f")
|
|
399
|
+
throw new FsCodedError(`cannot move "${source.displayPath}": not a regular file`, "FS_NOT_REGULAR_FILE");
|
|
400
|
+
if (options.expectedSource && sourceInfo.version !== options.expectedSource.version) {
|
|
401
|
+
throw new FsCodedError(`cannot move "${source.displayPath}": file changed since it was read`, "FS_STALE_VERSION");
|
|
402
|
+
}
|
|
403
|
+
const destinationExisting = await this.fs.stat(destinationPath, { signal });
|
|
404
|
+
if (destinationExisting && destinationExisting.type !== "f") {
|
|
405
|
+
throw new FsCodedError(`cannot write "${destination.displayPath}": not a regular file`, "FS_NOT_REGULAR_FILE");
|
|
406
|
+
}
|
|
407
|
+
if (options.expectedDestination?.kind === "replaceIfVersion") {
|
|
408
|
+
if (!destinationExisting)
|
|
409
|
+
throw new FsCodedError(`cannot write "${destination.displayPath}": file no longer exists`, "FS_STALE_VERSION");
|
|
410
|
+
if (destinationExisting.version !== options.expectedDestination.version) {
|
|
411
|
+
throw new FsCodedError(`cannot write "${destination.displayPath}": file changed since it was read`, "FS_STALE_VERSION");
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
else if (options.expectedDestination?.kind === "createIfAbsent" && destinationExisting) {
|
|
415
|
+
throw new FsCodedError(`cannot overwrite existing "${destination.displayPath}" without reading it first`, "FS_NOT_OBSERVED");
|
|
416
|
+
}
|
|
417
|
+
const original = await this.fs.readForEdit(source, signal);
|
|
418
|
+
let after = original.content;
|
|
419
|
+
let content = original.content;
|
|
420
|
+
if (options.hunks !== undefined) {
|
|
421
|
+
const patched = applyHunks(original.content, options.hunks);
|
|
422
|
+
if (!patched.ok) {
|
|
423
|
+
throw new FsCodedError(`cannot patch "${source.displayPath}": hunk at patch line ${patched.failure.hunkLineNumber} (${patched.failure.stage}) does not match`, "FS_PATCH_MISMATCH");
|
|
424
|
+
}
|
|
425
|
+
after = patched.after;
|
|
426
|
+
content = restoreLineEndings(after, original.lineEndings);
|
|
427
|
+
}
|
|
428
|
+
const destinationBefore = destinationExisting !== null && Buffer.byteLength(content, "utf8") < this.diffBasisMaxBytes
|
|
429
|
+
? await this.fs.readTextForDiff(destination, this.diffBasisMaxBytes, signal)
|
|
430
|
+
: null;
|
|
431
|
+
// A hunk set transforms the text on the way, so the agent cannot copy
|
|
432
|
+
// the source bytes: publish the patched content through the guarded
|
|
433
|
+
// write, then remove the source (the two effects stay separate).
|
|
434
|
+
let destinationRow;
|
|
435
|
+
let sourceFailure;
|
|
436
|
+
if (options.hunks !== undefined) {
|
|
437
|
+
try {
|
|
438
|
+
await this.fs.writeFileAtomic(destinationPath, content, {
|
|
439
|
+
mode: sourceInfo.mode,
|
|
440
|
+
createIfAbsent: options.expectedDestination?.kind === "createIfAbsent" ? { displayPath: destination.displayPath } : undefined,
|
|
441
|
+
expectedVersion: options.expectedDestination?.kind === "replaceIfVersion" ? options.expectedDestination.version : undefined,
|
|
442
|
+
signal,
|
|
443
|
+
agent: mutationAgent,
|
|
444
|
+
});
|
|
445
|
+
const published = await this.fs.stat(destinationPath, { signal });
|
|
446
|
+
destinationRow = { version: published ? published.version : `missing:${destination.targetKey}` };
|
|
447
|
+
}
|
|
448
|
+
catch (error) {
|
|
449
|
+
throw error;
|
|
450
|
+
}
|
|
451
|
+
try {
|
|
452
|
+
await this.fs.removeFile(sourcePath, sourceInfo.version, signal, mutationAgent);
|
|
453
|
+
}
|
|
454
|
+
catch (error) {
|
|
455
|
+
sourceFailure = {
|
|
456
|
+
reason: error instanceof FsCodedError && error.code === "FS_STALE_VERSION" ? "stale" : "io",
|
|
457
|
+
message: error instanceof Error ? error.message : String(error),
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
const moved = await this.fs.moveAtomic(sourcePath, destinationPath, {
|
|
463
|
+
mode: sourceInfo.mode,
|
|
464
|
+
guard: options.expectedDestination?.kind === "createIfAbsent" ? "no-replace" : "replace",
|
|
465
|
+
sourceVersion: sourceInfo.version,
|
|
466
|
+
destinationVersion: options.expectedDestination?.kind === "replaceIfVersion" ? options.expectedDestination.version : undefined,
|
|
467
|
+
signal,
|
|
468
|
+
agent: mutationAgent,
|
|
469
|
+
});
|
|
470
|
+
destinationRow = { version: moved.destination.version };
|
|
471
|
+
sourceFailure = moved.sourceFailure;
|
|
472
|
+
}
|
|
473
|
+
const destinationOutcome = {
|
|
474
|
+
operation: destinationExisting ? "update" : "create",
|
|
475
|
+
version: destinationRow.version,
|
|
476
|
+
before: destinationBefore,
|
|
477
|
+
after: normalizeLineEndings(after),
|
|
478
|
+
};
|
|
479
|
+
const sourceBefore = Buffer.byteLength(original.content, "utf8") < this.diffBasisMaxBytes ? original.content : null;
|
|
480
|
+
if (sourceFailure !== undefined) {
|
|
481
|
+
return {
|
|
482
|
+
sourceBefore,
|
|
483
|
+
destination: destinationOutcome,
|
|
484
|
+
sourceDeleted: false,
|
|
485
|
+
sourceFailure: { code: reasonToCode(sourceFailure.reason), message: sourceFailure.message },
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
return { sourceBefore, destination: destinationOutcome, sourceDeleted: true };
|
|
489
|
+
}));
|
|
490
|
+
}
|
|
290
491
|
}
|
|
291
492
|
export default AgentSubstrate;
|
package/lib/fs.d.ts
CHANGED
package/lib/fs.js
CHANGED
package/lib/fsio-agent.d.ts
CHANGED
|
@@ -19,11 +19,10 @@
|
|
|
19
19
|
* run `pnpm run build` — the artifact under `lib/` is generated, and `pnpm test`
|
|
20
20
|
* fails when it drifts.
|
|
21
21
|
*
|
|
22
|
-
* @module dsh-plugin-wsl/fsio-agent
|
|
22
|
+
* @module dsh-plugin-wsl-env/fsio-agent
|
|
23
23
|
*/
|
|
24
24
|
import { normalizeLineEndings, restoreLineEndings, applyLiteralEdit } from "./fsio-text.js";
|
|
25
25
|
import type { WslAgent } from "./agent.js";
|
|
26
|
-
import type { ResolvedTarget } from "./fs-substrate.js";
|
|
27
26
|
/** One agent FS round trip's result — the shape `WslAgent#fs` resolves to. */
|
|
28
27
|
export interface AgentFsResult {
|
|
29
28
|
/** The op's exit status. */
|
|
@@ -32,6 +31,12 @@ export interface AgentFsResult {
|
|
|
32
31
|
stdout: Buffer;
|
|
33
32
|
/** The op's diagnostic line(s). */
|
|
34
33
|
stderr: Buffer;
|
|
34
|
+
/**
|
|
35
|
+
* Protocol 7's FS refusal token, when the op failed through the structured
|
|
36
|
+
* FSERR line; the adapter maps it onto `FsErrorCode` directly. Undefined
|
|
37
|
+
* for legacy (v6) agents, whose refusal rides the stderr convention.
|
|
38
|
+
*/
|
|
39
|
+
reason?: string;
|
|
35
40
|
}
|
|
36
41
|
/**
|
|
37
42
|
* Normalize one agent timestamp ("seconds.frac", 9 or 10 fractional digits
|
|
@@ -44,8 +49,11 @@ export interface AgentFsResult {
|
|
|
44
49
|
export declare function nanoseconds(value: string): string;
|
|
45
50
|
/**
|
|
46
51
|
* The peer's `versionOf`: dev, inode, size and both nanosecond timestamps.
|
|
47
|
-
* Self-consistency within this provider is what versions need
|
|
48
|
-
*
|
|
52
|
+
* Self-consistency within this provider is what versions need. The string's
|
|
53
|
+
* granularity is the file's stat identity, not its bytes: a write that moves
|
|
54
|
+
* size or either timestamp moves the string, while a same-size write that
|
|
55
|
+
* leaves both timestamps untouched does not — the peer's own `versionOf`
|
|
56
|
+
* has exactly the same granularity, so guard comparisons behave alike.
|
|
49
57
|
*
|
|
50
58
|
* @param ingredients - the stat record's identity fields.
|
|
51
59
|
* @returns the opaque version string.
|
|
@@ -72,6 +80,25 @@ export declare function parseStatRecord(stdout: Buffer): {
|
|
|
72
80
|
ino: string;
|
|
73
81
|
version: string;
|
|
74
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* One resolved filesystem target: the display spelling the model sees and the
|
|
85
|
+
* UNC identity the operations key on. Lives here because the substrate's
|
|
86
|
+
* operations consume it and the substrate layer builds on this one.
|
|
87
|
+
*/
|
|
88
|
+
export interface ResolvedTarget {
|
|
89
|
+
/** The canonical Linux path spelling. */
|
|
90
|
+
displayPath: string;
|
|
91
|
+
/** The UNC identity this target keys on. */
|
|
92
|
+
targetKey: string;
|
|
93
|
+
}
|
|
94
|
+
export declare const REASON_CODES: Record<string, string>;
|
|
95
|
+
/**
|
|
96
|
+
* Map one wire reason token onto the peer's `FsErrorCode` vocabulary.
|
|
97
|
+
*
|
|
98
|
+
* @param reason - the agent's reason token (`notfound`, `stale`, …).
|
|
99
|
+
* @returns the corresponding code; unknown tokens read as I/O failures.
|
|
100
|
+
*/
|
|
101
|
+
export declare function reasonToCode(reason: string): string;
|
|
75
102
|
/** One `find` listing row, as `listChildren` shapes it. */
|
|
76
103
|
export interface ChildRow {
|
|
77
104
|
name: string;
|
|
@@ -209,6 +236,25 @@ export declare class DistroFs {
|
|
|
209
236
|
* @returns the full decoded text, byte-for-byte.
|
|
210
237
|
*/
|
|
211
238
|
readWholeText(target: ResolvedTarget, signal?: AbortSignal): Promise<string>;
|
|
239
|
+
/**
|
|
240
|
+
* The single-frame fallback for {@link readWholeText}: one stat, then the
|
|
241
|
+
* windowed read loop (a v6 peer).
|
|
242
|
+
*
|
|
243
|
+
* @param target - the resolved file.
|
|
244
|
+
* @param signal - aborts the read.
|
|
245
|
+
* @returns the file's bytes.
|
|
246
|
+
*/
|
|
247
|
+
private statThenReadWhole;
|
|
248
|
+
/**
|
|
249
|
+
* The protocol-7 batch path for {@link readWholeText}: the stat and the
|
|
250
|
+
* first read window ride ONE FSB frame — the GUI preview's dominant
|
|
251
|
+
* shape — and further windows stay single reads.
|
|
252
|
+
*
|
|
253
|
+
* @param target - the resolved file.
|
|
254
|
+
* @param signal - aborts the read.
|
|
255
|
+
* @returns the file's bytes.
|
|
256
|
+
*/
|
|
257
|
+
private readWholeBatched;
|
|
212
258
|
/**
|
|
213
259
|
* Read a whole regular file as raw bytes, bounded by `maxBytes`.
|
|
214
260
|
*
|
|
@@ -278,6 +324,84 @@ export declare class DistroFs {
|
|
|
278
324
|
*/
|
|
279
325
|
agent?: WslAgent;
|
|
280
326
|
}): Promise<void>;
|
|
327
|
+
/**
|
|
328
|
+
* Whether the resident accepts protocol-7 batch frames.
|
|
329
|
+
*
|
|
330
|
+
* @param agent - the agent to ask; the default resident by default.
|
|
331
|
+
* @returns true when the negotiated version and capabilities allow FSB.
|
|
332
|
+
*/
|
|
333
|
+
supportsBatch(agent?: WslAgent): boolean;
|
|
334
|
+
/**
|
|
335
|
+
* Whether the resident serves the protocol-7 destructive ops
|
|
336
|
+
* (`delete`, `move`) and the structured FSERR channel.
|
|
337
|
+
*
|
|
338
|
+
* @param agent - the agent to ask; the default resident by default.
|
|
339
|
+
* @returns true for a protocol-7 resident.
|
|
340
|
+
*/
|
|
341
|
+
supportsDestructive(agent?: WslAgent): boolean;
|
|
342
|
+
/**
|
|
343
|
+
* Run one batched FS frame and parse its per-op records.
|
|
344
|
+
*
|
|
345
|
+
* @param ops - the ordered ops (`stat`, `list`, `read`, …).
|
|
346
|
+
* @param signal - cancels the batch.
|
|
347
|
+
* @param agent - the agent to run it on.
|
|
348
|
+
* @returns one record per op, in order.
|
|
349
|
+
*/
|
|
350
|
+
batch(ops: Array<{
|
|
351
|
+
op: string;
|
|
352
|
+
args: string[];
|
|
353
|
+
}>, signal: AbortSignal | undefined, agent?: WslAgent): Promise<Array<{
|
|
354
|
+
ok: true;
|
|
355
|
+
payload: Buffer;
|
|
356
|
+
} | {
|
|
357
|
+
ok: false;
|
|
358
|
+
reason: string;
|
|
359
|
+
message: string;
|
|
360
|
+
}>>;
|
|
361
|
+
/**
|
|
362
|
+
* Remove one regular file through the protocol-7 `delete` op, whose guards
|
|
363
|
+
* mirror the peer's `requireFile`: a vanished file is stale, a non-regular
|
|
364
|
+
* target its own refusal, an expected version re-verified distro-side.
|
|
365
|
+
*
|
|
366
|
+
* @param linuxPath - the resolved Linux path.
|
|
367
|
+
* @param expectedVersion - the version the removal was based on.
|
|
368
|
+
* @param signal - cancels the removal.
|
|
369
|
+
* @param agent - the agent that must run it.
|
|
370
|
+
* @returns resolves when the file is gone.
|
|
371
|
+
*/
|
|
372
|
+
removeFile(linuxPath: string, expectedVersion: string | undefined, signal: AbortSignal | undefined, agent?: WslAgent): Promise<void>;
|
|
373
|
+
/**
|
|
374
|
+
* Move one regular file through the protocol-7 `move` op: the destination
|
|
375
|
+
* publishes through the write machinery's staging (atomic rename, or the
|
|
376
|
+
* no-replace link for a guarded create), then the source is removed. A
|
|
377
|
+
* destination that published while the source survived comes back as
|
|
378
|
+
* `sourceFailure` — the peer's two-effect outcome.
|
|
379
|
+
*
|
|
380
|
+
* @param source - the resolved source path.
|
|
381
|
+
* @param destination - the resolved destination path.
|
|
382
|
+
* @param options - the destination mode, publish guard and version guards.
|
|
383
|
+
* @param signal - cancels the move.
|
|
384
|
+
* @param agent - the agent that must run it.
|
|
385
|
+
* @returns the destination's fresh stat row and the source-removal outcome.
|
|
386
|
+
*/
|
|
387
|
+
moveAtomic(source: string, destination: string, options: {
|
|
388
|
+
/** The mode to publish at the destination (the source's, in practice). */
|
|
389
|
+
mode: number | undefined;
|
|
390
|
+
/** `no-replace` for a guarded create, otherwise `replace`. */
|
|
391
|
+
guard: "replace" | "no-replace";
|
|
392
|
+
/** The source version the move was based on. */
|
|
393
|
+
sourceVersion?: string;
|
|
394
|
+
/** The destination version the move was based on. */
|
|
395
|
+
destinationVersion?: string;
|
|
396
|
+
signal?: AbortSignal;
|
|
397
|
+
agent?: WslAgent;
|
|
398
|
+
}): Promise<{
|
|
399
|
+
destination: StatRow;
|
|
400
|
+
sourceFailure?: {
|
|
401
|
+
reason: string;
|
|
402
|
+
message: string;
|
|
403
|
+
};
|
|
404
|
+
}>;
|
|
281
405
|
/**
|
|
282
406
|
* Read and decode a file for editing: LF-normalized content plus the style
|
|
283
407
|
* to restore on write-back.
|