dsh-plugin-wsl-env 0.18.0 → 0.21.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 (123) hide show
  1. package/CHANGELOG.md +274 -0
  2. package/CONTRIBUTING.md +37 -5
  3. package/README.md +60 -5
  4. package/SUPPORT.md +3 -3
  5. package/agent/native/linux-aarch64/dsh-wsl-agent +0 -0
  6. package/agent/native/linux-x86_64/dsh-wsl-agent +0 -0
  7. package/agent/wsl-agent.sh +331 -11
  8. package/client.d.ts +5 -0
  9. package/client.js +98 -0
  10. package/cordis.patch.yml +66 -1
  11. package/docs/AGENT-PROTOCOL-V7.md +175 -0
  12. package/docs/API.md +25 -0
  13. package/docs/ARCHITECTURE.md +14 -1
  14. package/docs/CONFIGURATION.md +47 -6
  15. package/docs/CONFIGURATION.zh.md +20 -4
  16. package/docs/DIAGNOSTICS.md +83 -0
  17. package/docs/DIAGNOSTICS.zh.md +73 -0
  18. package/docs/LIMITATIONS.md +41 -4
  19. package/docs/LIMITATIONS.zh.md +27 -11
  20. package/docs/MIGRATION.md +4 -4
  21. package/docs/PEER-PARITY.md +50 -33
  22. package/docs/QUICKSTART.md +37 -4
  23. package/docs/QUICKSTART.zh.md +16 -1
  24. package/docs/README.zh.md +43 -4
  25. package/docs/RELEASING.md +4 -1
  26. package/docs/REQUIREMENTS.zh.md +3 -2
  27. package/docs/ROADMAP-1.0.md +75 -19
  28. package/docs/UPSTREAM-FILE-REFERENCE-SEAM.md +8 -1
  29. package/docs/UPSTREAM-OPEN-IN-APP.md +33 -0
  30. package/docs/UPSTREAM-SESSION-NOTICE.md +3 -1
  31. package/docs/UPSTREAM-TERMINAL-TITLE.md +3 -0
  32. package/docs/root-fs-routing.md +3 -3
  33. package/lib/agent-confined.js +4 -4
  34. package/lib/agent-errors.d.ts +1 -1
  35. package/lib/agent-errors.js +1 -1
  36. package/lib/agent-exec.d.ts +1 -1
  37. package/lib/agent-exec.js +1 -1
  38. package/lib/agent-protocol.d.ts +58 -8
  39. package/lib/agent-protocol.js +40 -7
  40. package/lib/agent-shared.d.ts +1 -1
  41. package/lib/agent-shared.js +1 -1
  42. package/lib/agent.d.ts +171 -1
  43. package/lib/agent.js +448 -288
  44. package/lib/auto-preset.d.ts +1 -1
  45. package/lib/auto-preset.js +1 -1
  46. package/lib/bwrap.d.ts +1 -1
  47. package/lib/bwrap.js +1 -1
  48. package/lib/client-host.d.ts +29 -0
  49. package/lib/client-host.js +29 -0
  50. package/lib/cwd-prompt-tool.d.ts +88 -0
  51. package/lib/cwd-prompt-tool.js +94 -0
  52. package/lib/cwd-prompt.d.ts +166 -0
  53. package/lib/cwd-prompt.js +203 -0
  54. package/lib/distro-route.d.ts +1 -1
  55. package/lib/distro-route.js +1 -1
  56. package/lib/doctor-live.d.ts +57 -0
  57. package/lib/doctor-live.js +38 -0
  58. package/lib/file-reference-wsl.d.ts +1 -1
  59. package/lib/file-reference-wsl.js +1 -1
  60. package/lib/fs-decisions.d.ts +1 -1
  61. package/lib/fs-decisions.js +1 -1
  62. package/lib/fs-routing.d.ts +1 -1
  63. package/lib/fs-routing.js +1 -1
  64. package/lib/fs-substrate.d.ts +90 -11
  65. package/lib/fs-substrate.js +202 -1
  66. package/lib/fs.d.ts +1 -1
  67. package/lib/fs.js +1 -1
  68. package/lib/fsio-agent.d.ts +128 -4
  69. package/lib/fsio-agent.js +224 -15
  70. package/lib/fsio-text.d.ts +1 -1
  71. package/lib/fsio-text.js +1 -1
  72. package/lib/git-exec.d.ts +1 -1
  73. package/lib/git-exec.js +1 -1
  74. package/lib/git-route.d.ts +1 -1
  75. package/lib/git-route.js +1 -1
  76. package/lib/index.d.ts +105 -30
  77. package/lib/index.js +272 -130
  78. package/lib/listing.d.ts +1 -1
  79. package/lib/listing.js +1 -1
  80. package/lib/messages.d.ts +157 -0
  81. package/lib/messages.js +199 -0
  82. package/lib/native-agent.d.ts +1 -1
  83. package/lib/native-agent.js +2 -2
  84. package/lib/paths.d.ts +6 -3
  85. package/lib/paths.js +4 -4
  86. package/lib/picker.d.ts +1 -1
  87. package/lib/picker.js +7 -7
  88. package/lib/ports.d.ts +1 -1
  89. package/lib/ports.js +1 -1
  90. package/lib/preflight.d.ts +25 -1
  91. package/lib/preflight.js +112 -12
  92. package/lib/sandbox-core.d.ts +1 -1
  93. package/lib/sandbox-core.js +9 -16
  94. package/lib/sandbox.d.ts +1 -1
  95. package/lib/sandbox.js +1 -1
  96. package/lib/search-exec.d.ts +1 -1
  97. package/lib/search-exec.js +1 -1
  98. package/lib/search-route.d.ts +1 -1
  99. package/lib/search-route.js +1 -1
  100. package/lib/session-runtime.d.ts +1 -1
  101. package/lib/session-runtime.js +2 -2
  102. package/lib/session-scope.d.ts +1 -1
  103. package/lib/session-scope.js +11 -6
  104. package/lib/shell-env.d.ts +26 -1
  105. package/lib/shell-env.js +57 -1
  106. package/lib/shell.d.ts +4 -2
  107. package/lib/shell.js +4 -2
  108. package/lib/subprocess.d.ts +1 -1
  109. package/lib/subprocess.js +2 -2
  110. package/lib/terminal-activity.d.ts +1 -1
  111. package/lib/terminal-activity.js +1 -1
  112. package/lib/terminal-route.d.ts +1 -1
  113. package/lib/terminal-route.js +1 -1
  114. package/lib/update-check.d.ts +197 -0
  115. package/lib/update-check.js +211 -0
  116. package/lib/watcher.d.ts +1 -1
  117. package/lib/watcher.js +1 -1
  118. package/lib/wsl-doctor-tool.d.ts +122 -0
  119. package/lib/wsl-doctor-tool.js +161 -0
  120. package/lib/wsl.d.ts +1 -31
  121. package/lib/wsl.js +1 -21
  122. package/package.json +55 -6
  123. package/scripts/doctor.mjs +1196 -166
package/lib/index.d.ts CHANGED
@@ -44,9 +44,10 @@ import { LocalBashExecutor } from "@deepseek-ai/dsh-bash-local";
44
44
  import { LocalFileSystem } from "@deepseek-ai/dsh-fs-local";
45
45
  import { FsError } from "@deepseek-ai/dsh-fs";
46
46
  import { WslSandbox } from "./sandbox.js";
47
- import type { WslAgent } from "./agent.js";
47
+ import type { WslAgent, AgentStatus } from "./agent.js";
48
48
  import { AgentSubstrate } from "./fs-substrate.js";
49
49
  import { SessionRuntimes } from "./session-runtime.js";
50
+ import { type DoctorReport } from "./doctor-live.js";
50
51
  import type { AgentBackend } from "./native-agent.js";
51
52
  import type { SessionRuntimeEntry } from "./session-runtime.js";
52
53
  import type { Context } from "@deepseek-ai/cordis";
@@ -84,6 +85,38 @@ export type ConfinedProfile = Awaited<ReturnType<InstanceType<typeof WslSandbox>
84
85
  export type WslExecSpec = ShellExecSpec & {
85
86
  relativeWorkdir?: string;
86
87
  };
88
+ /**
89
+ * Collect the doctor's versioned JSON report and merge the live resident's
90
+ * own lifecycle facts when this process holds one (WSL-313).
91
+ *
92
+ * The doctor CLI is a separate process, so its handshake check can only probe
93
+ * a fresh resident; a live resident's `deaths` and `lastError` are
94
+ * host-process state with no IPC to reach them. This entry point runs from
95
+ * the plugin's own context instead: it collects the report as a subprocess
96
+ * (no plugin code is re-entered) and folds `sharedAgent(distro).status()` in
97
+ * — the sanctioned merge, since a snapshot that answers for no resident
98
+ * changes nothing. Outside the app the singleton was never started, so the
99
+ * returned report is the fresh probe verbatim; inside it, a wedged live
100
+ * resident's failures finally reach the report.
101
+ *
102
+ * @param distro - the distro the doctor examines.
103
+ * @param options - `doctorPath` overrides the shipped script (tests);
104
+ * `liveStatus` overrides the in-process status snapshot (tests).
105
+ * @returns the merged report.
106
+ */
107
+ export declare function doctorReport(distro: string, options?: {
108
+ doctorPath?: string;
109
+ /** The `wsl.exe` the doctor probes with; forwarded as `--wsl <path>`. */
110
+ wslPath?: string;
111
+ /**
112
+ * Prepended to the doctor subprocess's PATH — a caller that stages a fake
113
+ * `wsl.exe` (tests) passes the staging directory here instead of mutating
114
+ * `process.env`, whose visibility across spawned grandchildren is exactly
115
+ * the ambiguity this option removes.
116
+ */
117
+ envPath?: string;
118
+ liveStatus?: AgentStatus;
119
+ }): Promise<DoctorReport>;
87
120
  /**
88
121
  * The WSL shell executor's validated config — the keys of
89
122
  * {@link WslShellExecutor.Config}, which the upstream `LocalBashExecutor`
@@ -467,7 +500,8 @@ export declare class WslShellExecutor extends LocalBashExecutor {
467
500
  * The shell name for the default/pinned distro, as the shell tool presents
468
501
  * it.
469
502
  *
470
- * @returns the basename of the shell, or `bash` when it cannot be named.
503
+ * @returns the basename of the shell; `shell` while the probe fails, and
504
+ * `bash` for an implausible basename.
471
505
  */
472
506
  shellName(): Promise<string>;
473
507
  /**
@@ -477,6 +511,8 @@ export declare class WslShellExecutor extends LocalBashExecutor {
477
511
  *
478
512
  * @param distro - the distro name.
479
513
  * @returns an absolute path to the shell inside the distro.
514
+ * @throws {Error} when neither the config nor the distro names a usable
515
+ * shell — the failure is not cached, so the next call re-probes.
480
516
  */
481
517
  shellFor(distro: string): Promise<string>;
482
518
  /**
@@ -484,6 +520,8 @@ export declare class WslShellExecutor extends LocalBashExecutor {
484
520
  * login shell, resolved once and cached.
485
521
  *
486
522
  * @returns an absolute path to the shell inside the distro.
523
+ * @throws {Error} when neither the config nor the distro names a usable
524
+ * shell — the failure is not cached, so the next call re-probes.
487
525
  */
488
526
  shell(): Promise<string>;
489
527
  /**
@@ -735,6 +773,41 @@ export declare class WslShellExecutor extends LocalBashExecutor {
735
773
  * @returns the decorated execution result.
736
774
  */
737
775
  executeOneShot(resolved: WslExecSpec, distro: string, shell: string): Promise<ShellExecution>;
776
+ /**
777
+ * The confined one-shot's argv prepare: confine the distro argv under the
778
+ * policy, keep the resulting profile for the fact-stamper and the settlement
779
+ * mapping, and hand back the wrapped host argv.
780
+ *
781
+ * @param resolved - the resolved spec.
782
+ * @param distro - the resolved distro name.
783
+ * @param shell - the resolved distro shell.
784
+ * @param policy - the confined policy (narrowed in by `executeOneShot`).
785
+ * @param slot - the closure the builder assigns the profile into.
786
+ * @param signal - the caller's cancellation.
787
+ */
788
+ private prepareConfinedArgv;
789
+ /**
790
+ * Stamp the per-process sandbox facts before `done` settles, so a background
791
+ * process reports the same mode, denial and enforcement a foreground run
792
+ * would.
793
+ *
794
+ * @param resolved - the resolved spec.
795
+ * @param mode - the confined policy's mode.
796
+ * @param slot - the closure holding the assigned profile.
797
+ * @param process - the spawned handle.
798
+ */
799
+ private stampConfinedFacts;
800
+ /**
801
+ * Settle one confined one-shot result: the distro and workdir verdicts, the
802
+ * never-armed honesty stamp, the runner-failure throw, and the denial facts.
803
+ *
804
+ * @param result - the settled process result.
805
+ * @param distro - the resolved distro name.
806
+ * @param resolved - the resolved spec.
807
+ * @param mode - the confined policy's mode.
808
+ * @param confined - the profile the argv prepare armed, when it ran.
809
+ */
810
+ private settleConfinedOneShot;
738
811
  }
739
812
  /**
740
813
  * Filesystem backend over a WSL distro's UNC share.
@@ -1335,45 +1408,47 @@ export declare class WslFileSystem extends LocalFileSystem {
1335
1408
  version: FsVersion;
1336
1409
  }, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsEditOutcome>;
1337
1410
  /**
1338
- * Refuse the peer's 0.2.2-rc.1 patch operation. This backend serves the
1339
- * distro world only, and every target it resolves carries a UNC identity:
1340
- * the inherited host implementation would apply the hunks to a same-named
1341
- * path on the Windows filesystem — or refuse with a host-dialect
1342
- * `FS_NOT_FOUND` that names the wrong world. Fail closed here until the
1343
- * agent substrate grows a patch op (see `docs/PEER-PARITY.md`, the new-peer
1344
- * operations section).
1411
+ * Apply parsed hunks (protocol 7): hunk matching and application run
1412
+ * in-process through the peer's own `applyHunks` (the same dialect and
1413
+ * `FS_PATCH_MISMATCH` the peer emits), against the distro's bytes, then
1414
+ * publish through the same guarded atomic write an edit takes.
1345
1415
  *
1346
- * @param target - the resolved target.
1347
- * @param _hunks - ordered hunks from the caller's patch parse; unused while the operation refuses.
1348
- * @param _expected - the version guard; unused while the operation refuses.
1349
- * @param _signal - cancellation; unused while the operation refuses.
1350
- * @param _sandboxPolicy - the per-call policy; unused while the operation refuses.
1416
+ * @param target - the resolved regular file.
1417
+ * @param hunks - ordered hunks from the caller's patch parse.
1418
+ * @param expected - the version the patch was based on.
1419
+ * @param signal - cancels the patch.
1420
+ * @param sandboxPolicy - the per-call policy; omit for the deployment default.
1421
+ * @returns the pre/post text and the published version.
1351
1422
  */
1352
- patchText(target: FsTarget, _hunks: PatchHunks, _expected?: {
1423
+ patchText(target: FsTarget, hunks: PatchHunks, expected?: {
1353
1424
  version: FsVersion;
1354
- }, _signal?: AbortSignal, _sandboxPolicy?: SandboxExecutionPolicy): Promise<FsEditOutcome>;
1425
+ }, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsEditOutcome>;
1355
1426
  /**
1356
- * Refuse the peer's 0.2.2-rc.1 delete operation, for the same wrong-world
1357
- * reason as {@link patchText}.
1427
+ * Remove one regular file (protocol 7) after fencing the target by the
1428
+ * per-call policy; the guarded removal re-verifies the expected version
1429
+ * distro-side.
1358
1430
  *
1359
- * @param target - the resolved target.
1360
- * @param _expected - the version guard; unused while the operation refuses.
1361
- * @param _signal - cancellation; unused while the operation refuses.
1362
- * @param _sandboxPolicy - the per-call policy; unused while the operation refuses.
1431
+ * @param target - the resolved file.
1432
+ * @param expected - the version the removal was based on.
1433
+ * @param signal - cancels the removal.
1434
+ * @param sandboxPolicy - the per-call policy; omit for the deployment default.
1435
+ * @returns the bounded pre-removal text basis.
1363
1436
  */
1364
- deleteFile(target: FsTarget, _expected?: {
1437
+ deleteFile(target: FsTarget, expected?: {
1365
1438
  version: FsVersion;
1366
- }, _signal?: AbortSignal, _sandboxPolicy?: SandboxExecutionPolicy): Promise<FsDeleteOutcome>;
1439
+ }, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsDeleteOutcome>;
1367
1440
  /**
1368
- * Refuse the peer's 0.2.2-rc.1 move operation, for the same wrong-world
1369
- * reason as {@link patchText}.
1441
+ * Move one regular file (protocol 7) after fencing BOTH endpoints by the
1442
+ * per-call policy — the destination publishes and the source is removed, so
1443
+ * each must be writable under the same roots.
1370
1444
  *
1371
1445
  * @param source - the resolved source.
1372
1446
  * @param destination - the resolved destination.
1373
- * @param _options - the hunks and guards; unused while the operation refuses.
1374
- * @param _signal - cancellation; unused while the operation refuses.
1375
- * @param _sandboxPolicy - the per-call policy; unused while the operation refuses.
1447
+ * @param options - the hunks and the source/destination guards.
1448
+ * @param signal - cancels before publication.
1449
+ * @param sandboxPolicy - the per-call policy; omit for the deployment default.
1450
+ * @returns the bounded source basis and the destination outcome.
1376
1451
  */
1377
- moveFile(source: FsTarget, destination: FsTarget, _options?: MoveFileOptions, _signal?: AbortSignal, _sandboxPolicy?: SandboxExecutionPolicy): Promise<FsMoveOutcome>;
1452
+ moveFile(source: FsTarget, destination: FsTarget, options: MoveFileOptions, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsMoveOutcome>;
1378
1453
  }
1379
1454
  export {};