dsh-remote-vs 0.25.0 → 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/README.en.md +12 -15
- package/README.md +11 -12
- package/THIRD-PARTY-NOTICES.md +193 -0
- package/lib/client.js +7313 -79961
- package/lib/index.js +1529 -964
- package/lib/p2-router-fs.js +1 -1
- package/lib/types/client/CodeEditor.d.ts +22 -0
- package/lib/types/client/OutlinePanel.d.ts +22 -0
- package/lib/types/client/ProcessesSection.d.ts +19 -0
- package/lib/types/client/RemoteExplorer.d.ts +53 -0
- package/lib/types/client/api.d.ts +42 -3
- package/lib/types/client/blame-model.d.ts +77 -0
- package/lib/types/client/changes/review-state.d.ts +19 -0
- package/lib/types/client/connection.d.ts +16 -0
- package/lib/types/client/i18n.d.ts +1 -1
- package/lib/types/client/outline-model.d.ts +59 -0
- package/lib/types/client/request-gate.d.ts +110 -0
- package/lib/types/client/scm/DiffView.d.ts +45 -7
- package/lib/types/client/scm/actions.d.ts +43 -4
- package/lib/types/client/store.d.ts +71 -0
- package/lib/types/client/vsc/FindWidget.d.ts +6 -0
- package/lib/types/client/vsc/blame.d.ts +19 -0
- package/lib/types/client/vsc/change-marks.d.ts +16 -6
- package/lib/types/client/vsc/editor-keymap.d.ts +35 -1
- package/lib/types/client/vsc/kit.d.ts +11 -2
- package/lib/types/client/vsc/preview-document.d.ts +46 -0
- package/lib/types/client/vsc/preview-model.d.ts +31 -0
- package/lib/types/client/vsc/preview-services.d.ts +24 -0
- package/lib/types/client/vsc/save-shortcut.d.ts +21 -0
- package/lib/types/client/vsc/terminal-theme.d.ts +28 -2
- package/lib/types/forward.d.ts +12 -0
- package/lib/types/fs-ops.d.ts +42 -0
- package/lib/types/git-ops.d.ts +18 -0
- package/lib/types/http.d.ts +2 -0
- package/lib/types/keygen.d.ts +9 -0
- package/lib/types/monitor.d.ts +8 -0
- package/lib/types/notices.d.ts +16 -1
- package/lib/types/p2/helper-rpc.d.ts +45 -0
- package/lib/types/processes.d.ts +43 -0
- package/lib/types/protocol.d.ts +34 -0
- package/lib/types/routes.d.ts +2 -0
- package/lib/types/store.d.ts +7 -0
- package/lib/types/terminal.d.ts +8 -0
- package/lib/types/view-settings.d.ts +5 -0
- package/lib/{worlds-B7gEDBzC.js → worlds-RG8K5eom.js} +113 -15
- package/package.json +3 -1
- package/src/client/CodeEditor.tsx +194 -9
- package/src/client/DirectoryFlow.tsx +16 -0
- package/src/client/DoctorPanel.tsx +70 -7
- package/src/client/EditorPane.tsx +574 -42
- package/src/client/HostsView.tsx +12 -3
- package/src/client/MonitorView.tsx +16 -5
- package/src/client/OutlinePanel.tsx +287 -0
- package/src/client/ProcessesSection.tsx +292 -0
- package/src/client/RemoteDirectoryPicker.tsx +12 -0
- package/src/client/RemoteExplorer.tsx +929 -40
- package/src/client/RemoteRoot.tsx +147 -22
- package/src/client/SearchView.tsx +8 -0
- package/src/client/TerminalSnippets.tsx +83 -8
- package/src/client/api.ts +114 -13
- package/src/client/blame-model.ts +242 -0
- package/src/client/changes/ChangesDock.tsx +188 -6
- package/src/client/changes/changes.css +10 -3
- package/src/client/changes/review-state.ts +34 -0
- package/src/client/connection.ts +29 -0
- package/src/client/downloads.ts +49 -4
- package/src/client/i18n.ts +276 -8
- package/src/client/index.tsx +4 -0
- package/src/client/outline-model.ts +775 -0
- package/src/client/request-gate.ts +221 -0
- package/src/client/scm/CommitPane.tsx +20 -2
- package/src/client/scm/DiffView.tsx +343 -117
- package/src/client/scm/HistoryPanel.tsx +61 -3
- package/src/client/scm/RepoPicker.tsx +1 -1
- package/src/client/scm/ScmPanel.tsx +391 -87
- package/src/client/scm/actions.ts +150 -14
- package/src/client/store.tsx +426 -14
- package/src/client/ui.tsx +4 -0
- package/src/client/vsc/FindWidget.tsx +24 -9
- package/src/client/vsc/blame.ts +147 -0
- package/src/client/vsc/breadcrumb.tsx +91 -3
- package/src/client/vsc/change-marks.ts +93 -44
- package/src/client/vsc/editor-keymap.ts +59 -1
- package/src/client/vsc/file-icons.tsx +17 -3
- package/src/client/vsc/kit.tsx +29 -20
- package/src/client/vsc/preview-document.tsx +323 -0
- package/src/client/vsc/preview-model.ts +216 -0
- package/src/client/vsc/preview-services.ts +118 -0
- package/src/client/vsc/save-shortcut.ts +47 -1
- package/src/client/vsc/terminal-theme.ts +44 -18
- package/src/client/vsc/vsc.css +6509 -5458
- package/src/forward.ts +47 -9
- package/src/fs-ops.ts +124 -4
- package/src/git-ops.ts +54 -3
- package/src/http.ts +35 -4
- package/src/keygen.ts +55 -4
- package/src/monitor.ts +13 -0
- package/src/notices.ts +23 -1
- package/src/p2/helper-rpc.ts +113 -7
- package/src/p2/worlds.ts +14 -1
- package/src/processes.ts +177 -0
- package/src/protocol.ts +37 -0
- package/src/routes.ts +330 -43
- package/src/sftp.ts +51 -14
- package/src/store.ts +10 -0
- package/src/terminal.ts +73 -26
- package/src/view-settings.ts +50 -10
- package/lib/types/client/Dialog.d.ts +0 -14
- package/src/client/Dialog.tsx +0 -76
package/lib/types/monitor.d.ts
CHANGED
|
@@ -53,5 +53,13 @@ export declare class HostMonitor {
|
|
|
53
53
|
sample(alias: string, force?: boolean): Promise<RemoteHostMetrics>;
|
|
54
54
|
/** Drop everything known about one alias (host edited or deleted). */
|
|
55
55
|
forget(alias: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Snapshots already in the cache, without dialing anything.
|
|
58
|
+
*
|
|
59
|
+
* A GET must not have a dial side effect: listing what the Host knows is the
|
|
60
|
+
* read-only shape, and only an explicit per-host request (or the opt-in batch
|
|
61
|
+
* flag) may wake a sleeping host.
|
|
62
|
+
*/
|
|
63
|
+
cached(): RemoteHostMetrics[];
|
|
56
64
|
private probe;
|
|
57
65
|
}
|
package/lib/types/notices.d.ts
CHANGED
|
@@ -18,5 +18,20 @@ export interface HostNotice {
|
|
|
18
18
|
}
|
|
19
19
|
/** Queue one notice for the next JSON response. */
|
|
20
20
|
export declare function pushHostNotice(notice: HostNotice): void;
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Take the notices queued for ONE host alias.
|
|
23
|
+
*
|
|
24
|
+
* A response only reports news about the host it is about. Draining the whole
|
|
25
|
+
* queue from whichever response was written first delivered host A's helper
|
|
26
|
+
* push into a window looking at host B — and consumed it, so A never saw it.
|
|
27
|
+
* Notices for other aliases stay queued for a response about their host.
|
|
28
|
+
*/
|
|
29
|
+
export declare function takeHostNotices(alias: string): HostNotice[];
|
|
30
|
+
/**
|
|
31
|
+
* Take everything queued (no host filtering).
|
|
32
|
+
*
|
|
33
|
+
* Kept for callers that own the whole queue — the offline probes reset it, and
|
|
34
|
+
* a response written OUTSIDE the route table has no host to filter by
|
|
35
|
+
* (`src/http.ts` keeps that historical drain-all answer).
|
|
36
|
+
*/
|
|
22
37
|
export declare function drainHostNotices(): HostNotice[];
|
|
@@ -38,6 +38,21 @@ export declare class RpcConnection {
|
|
|
38
38
|
private heartbeat;
|
|
39
39
|
private dead;
|
|
40
40
|
private disposed;
|
|
41
|
+
/**
|
|
42
|
+
* Transport generation, bumped by every teardown.
|
|
43
|
+
*
|
|
44
|
+
* ssh2 does not close synchronously: `Channel.close()` is a PROTOCOL message
|
|
45
|
+
* and `Client.end()`'s socket 'close' arrives later. Those late
|
|
46
|
+
* 'close'/'error' events used to call `invalidate()` after `reconnect()` had
|
|
47
|
+
* already cleared `dead`, marking the BRAND-NEW dial dead: `open()` then
|
|
48
|
+
* released the fresh transport and the retry rejected with the OLD
|
|
49
|
+
* transport's error (probe T6 measured exactly this — a close 5 ms late, a
|
|
50
|
+
* new dial 20 ms). Every transport callback therefore captures the generation
|
|
51
|
+
* it was created under and compares it before acting; a teardown invalidates
|
|
52
|
+
* every callback of the transport it releases, without removing listeners
|
|
53
|
+
* (ssh2 offers no per-callback unsubscribe that would survive a destroy).
|
|
54
|
+
*/
|
|
55
|
+
private generation;
|
|
41
56
|
/**
|
|
42
57
|
* The helper's own error output, kept so its reason survives.
|
|
43
58
|
*
|
|
@@ -80,10 +95,40 @@ export declare class RpcConnection {
|
|
|
80
95
|
* `stderrTail` is cleared too: it describes the connection being torn down, and
|
|
81
96
|
* keeping it would attribute the NEXT failure to the previous transport's error
|
|
82
97
|
* output.
|
|
98
|
+
*
|
|
99
|
+
* The generation bump comes FIRST: the close calls below can emit their events
|
|
100
|
+
* synchronously, and anything this transport has queued must already count as
|
|
101
|
+
* stale by then.
|
|
83
102
|
*/
|
|
84
103
|
private teardownTransport;
|
|
85
104
|
private open;
|
|
86
105
|
/** The part of {@link open} that runs once the socket object exists. */
|
|
87
106
|
private dialAndHello;
|
|
107
|
+
/**
|
|
108
|
+
* Mark the connection dead AND release its transport.
|
|
109
|
+
*
|
|
110
|
+
* Closing the peer alone was not enough: `SshRpcPeer.close()` destroys the
|
|
111
|
+
* exec streams, and ssh2's `Channel.destroy()` does not end the `Client` that
|
|
112
|
+
* carries them — so the session stayed open (30s keepalive and all) while its
|
|
113
|
+
* owner had already written it off as dead. One leaked socket per invalidation,
|
|
114
|
+
* until the process exits. `teardownTransport()` is the only path that ends the
|
|
115
|
+
* Client, so an invalidated connection goes through it too; that is safe to
|
|
116
|
+
* repeat because each field is cleared as it is closed and `closeQuietly`
|
|
117
|
+
* ignores a second close — a later `dispose()`, `reconnect()` or failed
|
|
118
|
+
* `open()` teardown therefore finds nothing left to release.
|
|
119
|
+
*
|
|
120
|
+
* Ordering is deliberate: the peer is closed FIRST so in-flight requests reject
|
|
121
|
+
* with THIS error (the teardown's own close would raise a generic
|
|
122
|
+
* "channel closed" instead), and `stderrTail` is captured BEFORE the teardown,
|
|
123
|
+
* which clears it — otherwise `diagnostics` in the dial path would always
|
|
124
|
+
* report "the helper wrote nothing to stderr".
|
|
125
|
+
*
|
|
126
|
+
* Only an ESTABLISHED transport is released here. While `open()` is still
|
|
127
|
+
* dialing, `conn` is alive and `channel`/`peer` are not, and ending that Client
|
|
128
|
+
* would strand the handshake: ssh2 clears its own ready timer when the socket
|
|
129
|
+
* closes and emits 'close' without an 'error', so the promise `open()` awaits
|
|
130
|
+
* would never settle. `open()` itself releases the attempt instead, once it has
|
|
131
|
+
* a definitive outcome.
|
|
132
|
+
*/
|
|
88
133
|
private invalidate;
|
|
89
134
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote process snapshots for the monitor page.
|
|
3
|
+
*
|
|
4
|
+
* Same model as `listen-ports.ts`: one bounded POSIX probe (GNU `ps`, a BSD
|
|
5
|
+
* `ps` fallback, then an explicit `none`), with all parsing done host-side so
|
|
6
|
+
* the browser only receives a bounded table. A process is never killed by a
|
|
7
|
+
* command assembled in the browser: the route validates the PID against the
|
|
8
|
+
* latest snapshot and builds the one signal command here.
|
|
9
|
+
*/
|
|
10
|
+
import type { RemoteProcessesResult } from './protocol.ts';
|
|
11
|
+
/** Marker proving which probe branch actually ran. */
|
|
12
|
+
export declare const PROCESSES_MARK = "@@RVS-PROCS";
|
|
13
|
+
/** Budget for the whole probe; a stuck process table must not pin a channel. */
|
|
14
|
+
export declare const PROCESSES_TIMEOUT_MS = 15000;
|
|
15
|
+
/** Hard cap on rows per snapshot (a container host can have thousands). */
|
|
16
|
+
export declare const PROCESSES_MAX = 500;
|
|
17
|
+
/** Longest command string sent to the browser per row. */
|
|
18
|
+
export declare const PROCESS_COMMAND_MAX = 300;
|
|
19
|
+
/**
|
|
20
|
+
* One bounded probe.
|
|
21
|
+
*
|
|
22
|
+
* GNU first (`--sort` + `etimes`), then the portable `ps aux` table for BSD /
|
|
23
|
+
* old systems (`ppid` and elapsed time are unknown there). The marker
|
|
24
|
+
* line is printed BEFORE the table so an interrupted probe is distinguishable
|
|
25
|
+
* from a genuinely empty one; the final marker lets the parser reject a
|
|
26
|
+
* truncated run.
|
|
27
|
+
*/
|
|
28
|
+
export declare function processesCommand(max?: number): string;
|
|
29
|
+
/** A kill signal the route accepts; never an arbitrary string from the client. */
|
|
30
|
+
export type KillSignal = 'TERM' | 'KILL';
|
|
31
|
+
export declare function isKillSignal(value: unknown): value is KillSignal;
|
|
32
|
+
/** Assert a PID a process snapshot may contain (1 is the remote init). */
|
|
33
|
+
export declare function assertProcessPid(value: unknown): number;
|
|
34
|
+
/**
|
|
35
|
+
* Build the one kill command. The PID has already passed the snapshot check;
|
|
36
|
+
* single-quoting it keeps the command shape uniform with every other builder.
|
|
37
|
+
*/
|
|
38
|
+
export declare function killCommand(pid: number, signal: KillSignal): string;
|
|
39
|
+
/**
|
|
40
|
+
* Parse one probe. `exitCode === null` (channel died) or a missing end marker
|
|
41
|
+
* means `unknown`, never an empty process table.
|
|
42
|
+
*/
|
|
43
|
+
export declare function parseProcesses(stdout: string, exitCode: number | null): RemoteProcessesResult;
|
package/lib/types/protocol.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export declare const REMOTE_API: {
|
|
|
41
41
|
readonly listenPorts: "/api/dsh-remote/listen-ports";
|
|
42
42
|
/** Live system metrics for the monitor panel (one bounded probe per host). */
|
|
43
43
|
readonly metrics: "/api/dsh-remote/metrics";
|
|
44
|
+
/** One bounded process table for the monitor page, plus TERM/KILL actions. */
|
|
45
|
+
readonly processes: "/api/dsh-remote/processes";
|
|
44
46
|
};
|
|
45
47
|
/**
|
|
46
48
|
* Most entries one multi-selection download may archive. The selection rides in
|
|
@@ -695,6 +697,38 @@ export interface RemoteListenPortsResult {
|
|
|
695
697
|
/** Why the probe could not be used, when it could not. */
|
|
696
698
|
error?: string;
|
|
697
699
|
}
|
|
700
|
+
/** One row of the remote process table. */
|
|
701
|
+
export interface RemoteProcess {
|
|
702
|
+
pid: number;
|
|
703
|
+
/** Parent PID; 0 on a BSD `ps aux` table that does not print it. */
|
|
704
|
+
ppid: number;
|
|
705
|
+
user: string;
|
|
706
|
+
cpuPercent: number;
|
|
707
|
+
memPercent: number;
|
|
708
|
+
/** Elapsed seconds when the probe can provide them; null on BSD `ps aux`. */
|
|
709
|
+
elapsedSeconds: number | null;
|
|
710
|
+
command: string;
|
|
711
|
+
}
|
|
712
|
+
/**
|
|
713
|
+
* The remote process probe's answer.
|
|
714
|
+
*
|
|
715
|
+
* `tool: 'none' | 'unknown'` means "cannot enumerate", never "no processes";
|
|
716
|
+
* the monitor page must explain that instead of rendering an empty table.
|
|
717
|
+
*/
|
|
718
|
+
export interface RemoteProcessesResult {
|
|
719
|
+
tool: 'gnu' | 'bsd' | 'none' | 'unknown';
|
|
720
|
+
processes: RemoteProcess[];
|
|
721
|
+
truncated: boolean;
|
|
722
|
+
error?: string;
|
|
723
|
+
}
|
|
724
|
+
/** Result of one TERM/KILL request (the route validates the PID first). */
|
|
725
|
+
export interface RemoteProcessKillResult {
|
|
726
|
+
ok: boolean;
|
|
727
|
+
pid: number;
|
|
728
|
+
signal: 'TERM' | 'KILL';
|
|
729
|
+
/** Remote error text when the signal was refused. */
|
|
730
|
+
error?: string;
|
|
731
|
+
}
|
|
698
732
|
/**
|
|
699
733
|
* How one host metrics sample ended.
|
|
700
734
|
*
|
package/lib/types/routes.d.ts
CHANGED
package/lib/types/store.d.ts
CHANGED
|
@@ -25,6 +25,13 @@ export declare class RemoteStore {
|
|
|
25
25
|
/** File identity when `doc` was read from disk (undefined = `doc` is not known fresh). */
|
|
26
26
|
private stamp;
|
|
27
27
|
constructor(file?: string);
|
|
28
|
+
/**
|
|
29
|
+
* Absolute path of the JSON document.
|
|
30
|
+
*
|
|
31
|
+
* Diagnostics only: a corrupt file must name itself in the error a surface
|
|
32
|
+
* shows, otherwise the user only sees "the request failed".
|
|
33
|
+
*/
|
|
34
|
+
get filePath(): string;
|
|
28
35
|
/**
|
|
29
36
|
* Reload from disk (picks up external edits).
|
|
30
37
|
*
|
package/lib/types/terminal.d.ts
CHANGED
|
@@ -72,4 +72,12 @@ export declare class TerminalSessionRegistry {
|
|
|
72
72
|
private setPaused;
|
|
73
73
|
private send;
|
|
74
74
|
private broadcast;
|
|
75
|
+
/**
|
|
76
|
+
* Send one already-stringified `out` frame to ONE socket with accounting.
|
|
77
|
+
*
|
|
78
|
+
* Shared by `broadcast` and by the replay on `attach`; the byte count must be
|
|
79
|
+
* counted once per socket so the session's brake reflects every socket's
|
|
80
|
+
* backlog (see `Session.pending`).
|
|
81
|
+
*/
|
|
82
|
+
private sendOutTo;
|
|
75
83
|
}
|
|
@@ -21,6 +21,11 @@ export declare class RemoteViewSettingsStore {
|
|
|
21
21
|
* @returns the settings as stored.
|
|
22
22
|
*/
|
|
23
23
|
patch(patch: Record<string, unknown>): RemoteViewSettings;
|
|
24
|
+
/**
|
|
25
|
+
* File identity right now; `null` when the file is absent (or cannot be
|
|
26
|
+
* statted — `get()` fails loud on that case anyway).
|
|
27
|
+
*/
|
|
28
|
+
private stampOf;
|
|
24
29
|
/** Write one document atomically: a crash never leaves a half-written file. */
|
|
25
30
|
private save;
|
|
26
31
|
}
|
|
@@ -17333,8 +17333,14 @@ var RemoteFiles = class {
|
|
|
17333
17333
|
});
|
|
17334
17334
|
this.trackPartial(alias, partial);
|
|
17335
17335
|
const size = await streamIntoFile(sftp, partial, source, maxBytes);
|
|
17336
|
-
if (overwrite)
|
|
17337
|
-
|
|
17336
|
+
if (overwrite) {
|
|
17337
|
+
const targetStat = await lstatAsync(sftp, path).catch((error) => {
|
|
17338
|
+
if (error.code === SFTP_NO_SUCH_FILE) return void 0;
|
|
17339
|
+
throw error;
|
|
17340
|
+
});
|
|
17341
|
+
if (targetStat !== void 0 && (typeof targetStat.isDirectory === "function" ? targetStat.isDirectory() : (targetStat.mode & 61440) === 16384)) throw new Error(`not a file: ${path} is a directory`);
|
|
17342
|
+
await replaceFile(sftp, partial, path);
|
|
17343
|
+
} else await renameAsync(sftp, partial, path);
|
|
17338
17344
|
this.forgetPartial(alias, partial);
|
|
17339
17345
|
this.remember(this.knownDirs, dirKey(alias, dir));
|
|
17340
17346
|
await this.sweepOrphanDirs(sftp, alias, dir);
|
|
@@ -17477,8 +17483,8 @@ var RemoteFiles = class {
|
|
|
17477
17483
|
await mkdirAsync(sftp, path);
|
|
17478
17484
|
} catch (error) {
|
|
17479
17485
|
const code = error.code;
|
|
17480
|
-
if (code !==
|
|
17481
|
-
|
|
17486
|
+
if (code !== SFTP_FAILURE && code !== void 0) throw error;
|
|
17487
|
+
try {
|
|
17482
17488
|
await lstatAsync(sftp, path);
|
|
17483
17489
|
} catch {
|
|
17484
17490
|
throw error;
|
|
@@ -17692,7 +17698,10 @@ async function explainSftpFailure(sftp, path, wanted, cause) {
|
|
|
17692
17698
|
const code = cause?.code;
|
|
17693
17699
|
if (code !== SFTP_NO_SUCH_FILE && code !== SFTP_FAILURE) return void 0;
|
|
17694
17700
|
const kind = await pathKind(sftp, path);
|
|
17695
|
-
if (kind.kind === "missing")
|
|
17701
|
+
if (kind.kind === "missing") {
|
|
17702
|
+
const hint = code === SFTP_FAILURE ? " (the server reported only status 4: this can also be a permission or disk-space problem)" : "";
|
|
17703
|
+
return /* @__PURE__ */ new Error(wanted === "directory" ? `no such directory: ${path}${hint}` : `no such file: ${path}${hint}`);
|
|
17704
|
+
}
|
|
17696
17705
|
if (wanted === "directory" && kind.kind !== "dir") return /* @__PURE__ */ new Error(`not a directory: ${path} is ${describeKind(kind)}`);
|
|
17697
17706
|
if (wanted === "file" && kind.kind === "dir") return /* @__PURE__ */ new Error(`not a file: ${path} is a directory`);
|
|
17698
17707
|
}
|
|
@@ -19006,7 +19015,28 @@ function pushHostNotice(notice) {
|
|
|
19006
19015
|
if (pending.length >= MAX_PENDING$1) return;
|
|
19007
19016
|
pending = [...pending, notice];
|
|
19008
19017
|
}
|
|
19009
|
-
/**
|
|
19018
|
+
/**
|
|
19019
|
+
* Take the notices queued for ONE host alias.
|
|
19020
|
+
*
|
|
19021
|
+
* A response only reports news about the host it is about. Draining the whole
|
|
19022
|
+
* queue from whichever response was written first delivered host A's helper
|
|
19023
|
+
* push into a window looking at host B — and consumed it, so A never saw it.
|
|
19024
|
+
* Notices for other aliases stay queued for a response about their host.
|
|
19025
|
+
*/
|
|
19026
|
+
function takeHostNotices(alias) {
|
|
19027
|
+
if (pending.length === 0) return [];
|
|
19028
|
+
const taken = pending.filter((notice) => notice.alias === alias);
|
|
19029
|
+
if (taken.length === 0) return [];
|
|
19030
|
+
pending = pending.filter((notice) => notice.alias !== alias);
|
|
19031
|
+
return taken;
|
|
19032
|
+
}
|
|
19033
|
+
/**
|
|
19034
|
+
* Take everything queued (no host filtering).
|
|
19035
|
+
*
|
|
19036
|
+
* Kept for callers that own the whole queue — the offline probes reset it, and
|
|
19037
|
+
* a response written OUTSIDE the route table has no host to filter by
|
|
19038
|
+
* (`src/http.ts` keeps that historical drain-all answer).
|
|
19039
|
+
*/
|
|
19010
19040
|
function drainHostNotices() {
|
|
19011
19041
|
if (pending.length === 0) return [];
|
|
19012
19042
|
const drained = pending;
|
|
@@ -19191,6 +19221,21 @@ var RpcConnection = class {
|
|
|
19191
19221
|
dead;
|
|
19192
19222
|
disposed = false;
|
|
19193
19223
|
/**
|
|
19224
|
+
* Transport generation, bumped by every teardown.
|
|
19225
|
+
*
|
|
19226
|
+
* ssh2 does not close synchronously: `Channel.close()` is a PROTOCOL message
|
|
19227
|
+
* and `Client.end()`'s socket 'close' arrives later. Those late
|
|
19228
|
+
* 'close'/'error' events used to call `invalidate()` after `reconnect()` had
|
|
19229
|
+
* already cleared `dead`, marking the BRAND-NEW dial dead: `open()` then
|
|
19230
|
+
* released the fresh transport and the retry rejected with the OLD
|
|
19231
|
+
* transport's error (probe T6 measured exactly this — a close 5 ms late, a
|
|
19232
|
+
* new dial 20 ms). Every transport callback therefore captures the generation
|
|
19233
|
+
* it was created under and compares it before acting; a teardown invalidates
|
|
19234
|
+
* every callback of the transport it releases, without removing listeners
|
|
19235
|
+
* (ssh2 offers no per-callback unsubscribe that would survive a destroy).
|
|
19236
|
+
*/
|
|
19237
|
+
generation = 0;
|
|
19238
|
+
/**
|
|
19194
19239
|
* The helper's own error output, kept so its reason survives.
|
|
19195
19240
|
*
|
|
19196
19241
|
* Nothing read this stream before, so a helper that died on startup took its
|
|
@@ -19223,11 +19268,13 @@ var RpcConnection = class {
|
|
|
19223
19268
|
let attempt = 0;
|
|
19224
19269
|
for (;;) {
|
|
19225
19270
|
const peer = await this.peerReady();
|
|
19271
|
+
const generation = this.generation;
|
|
19226
19272
|
await this.gate.acquire(signal);
|
|
19227
19273
|
try {
|
|
19228
19274
|
return await this.withDeadline(peer.request(method, params, schema, signal), method, mutating);
|
|
19229
19275
|
} catch (error) {
|
|
19230
19276
|
if (!(error instanceof HelperTimeoutError)) throw error;
|
|
19277
|
+
if (generation !== this.generation) throw error;
|
|
19231
19278
|
this.invalidate(error);
|
|
19232
19279
|
if (mutating || attempt >= 1) throw error;
|
|
19233
19280
|
attempt += 1;
|
|
@@ -19273,6 +19320,7 @@ var RpcConnection = class {
|
|
|
19273
19320
|
async dispose() {
|
|
19274
19321
|
if (this.disposed) return;
|
|
19275
19322
|
this.disposed = true;
|
|
19323
|
+
if (this.peer === void 0 && this.channel === void 0 && this.conn !== void 0) return;
|
|
19276
19324
|
this.teardownTransport();
|
|
19277
19325
|
}
|
|
19278
19326
|
async peerReady() {
|
|
@@ -19290,8 +19338,13 @@ var RpcConnection = class {
|
|
|
19290
19338
|
* `stderrTail` is cleared too: it describes the connection being torn down, and
|
|
19291
19339
|
* keeping it would attribute the NEXT failure to the previous transport's error
|
|
19292
19340
|
* output.
|
|
19341
|
+
*
|
|
19342
|
+
* The generation bump comes FIRST: the close calls below can emit their events
|
|
19343
|
+
* synchronously, and anything this transport has queued must already count as
|
|
19344
|
+
* stale by then.
|
|
19293
19345
|
*/
|
|
19294
19346
|
teardownTransport() {
|
|
19347
|
+
this.generation += 1;
|
|
19295
19348
|
if (this.heartbeat !== void 0) {
|
|
19296
19349
|
clearTimeout(this.heartbeat);
|
|
19297
19350
|
this.heartbeat = void 0;
|
|
@@ -19310,7 +19363,12 @@ var RpcConnection = class {
|
|
|
19310
19363
|
const conn = new import_lib.Client();
|
|
19311
19364
|
this.conn = conn;
|
|
19312
19365
|
try {
|
|
19313
|
-
|
|
19366
|
+
const hello = await this.dialAndHello(conn);
|
|
19367
|
+
if (this.dead !== void 0 || this.disposed) {
|
|
19368
|
+
this.teardownTransport();
|
|
19369
|
+
throw this.dead ?? /* @__PURE__ */ new Error("helper RPC was disposed");
|
|
19370
|
+
}
|
|
19371
|
+
return hello;
|
|
19314
19372
|
} catch (error) {
|
|
19315
19373
|
this.teardownTransport();
|
|
19316
19374
|
throw error;
|
|
@@ -19319,6 +19377,7 @@ var RpcConnection = class {
|
|
|
19319
19377
|
/** The part of {@link open} that runs once the socket object exists. */
|
|
19320
19378
|
async dialAndHello(conn) {
|
|
19321
19379
|
const { entry } = this.opts;
|
|
19380
|
+
const generation = this.generation;
|
|
19322
19381
|
await new Promise((resolve, reject) => {
|
|
19323
19382
|
let settled = false;
|
|
19324
19383
|
conn.on("ready", () => {
|
|
@@ -19331,10 +19390,14 @@ var RpcConnection = class {
|
|
|
19331
19390
|
if (!settled) {
|
|
19332
19391
|
settled = true;
|
|
19333
19392
|
reject(error);
|
|
19334
|
-
} else this.invalidate(error);
|
|
19393
|
+
} else if (generation === this.generation) this.invalidate(error);
|
|
19335
19394
|
});
|
|
19336
19395
|
conn.on("close", () => {
|
|
19337
|
-
|
|
19396
|
+
if (!settled) {
|
|
19397
|
+
settled = true;
|
|
19398
|
+
reject(/* @__PURE__ */ new Error("ssh connection closed before it became ready"));
|
|
19399
|
+
}
|
|
19400
|
+
if (generation === this.generation) this.invalidate(/* @__PURE__ */ new Error("ssh connection closed"));
|
|
19338
19401
|
});
|
|
19339
19402
|
try {
|
|
19340
19403
|
if (entry.auth.kind === "key") conn.connect({
|
|
@@ -19369,13 +19432,14 @@ var RpcConnection = class {
|
|
|
19369
19432
|
});
|
|
19370
19433
|
this.channel = channel;
|
|
19371
19434
|
channel.stderr.on("data", (chunk) => {
|
|
19435
|
+
if (generation !== this.generation) return;
|
|
19372
19436
|
this.stderrTail = (this.stderrTail + chunk.toString("utf8")).slice(-2e3);
|
|
19373
19437
|
});
|
|
19374
19438
|
channel.on("close", () => {
|
|
19375
|
-
this.invalidate(/* @__PURE__ */ new Error("helper channel closed"));
|
|
19439
|
+
if (generation === this.generation) this.invalidate(/* @__PURE__ */ new Error("helper channel closed"));
|
|
19376
19440
|
});
|
|
19377
19441
|
channel.on("error", (error) => {
|
|
19378
|
-
this.invalidate(error);
|
|
19442
|
+
if (generation === this.generation) this.invalidate(error);
|
|
19379
19443
|
});
|
|
19380
19444
|
const leaseMs = this.opts.leaseMs ?? 3e4;
|
|
19381
19445
|
const peer = new SshRpcPeer(channel, channel, MAX_FRAME, MAX_PENDING);
|
|
@@ -19390,9 +19454,10 @@ var RpcConnection = class {
|
|
|
19390
19454
|
if (hello.hash !== this.opts.helperHash) throw new Error("helper digest differs from the deployed artifact");
|
|
19391
19455
|
if (hello.bootstrapHash !== void 0) throw new Error("helper reported an unexpected PTC bootstrap digest");
|
|
19392
19456
|
const beat = () => {
|
|
19393
|
-
if (this.disposed || this.dead !== void 0) return;
|
|
19457
|
+
if (this.disposed || generation !== this.generation || this.dead !== void 0) return;
|
|
19394
19458
|
this.heartbeat = setTimeout(() => {
|
|
19395
19459
|
peer.request("heartbeat", {}, z.null(), AbortSignal.timeout(Math.floor(leaseMs / 2))).catch((error) => {
|
|
19460
|
+
if (generation !== this.generation) return;
|
|
19396
19461
|
this.invalidate(error instanceof Error ? error : new Error(String(error)));
|
|
19397
19462
|
}).finally(beat);
|
|
19398
19463
|
}, Math.floor(leaseMs / 3));
|
|
@@ -19407,13 +19472,45 @@ var RpcConnection = class {
|
|
|
19407
19472
|
nodeVersion: hello.nodeVersion
|
|
19408
19473
|
};
|
|
19409
19474
|
}
|
|
19475
|
+
/**
|
|
19476
|
+
* Mark the connection dead AND release its transport.
|
|
19477
|
+
*
|
|
19478
|
+
* Closing the peer alone was not enough: `SshRpcPeer.close()` destroys the
|
|
19479
|
+
* exec streams, and ssh2's `Channel.destroy()` does not end the `Client` that
|
|
19480
|
+
* carries them — so the session stayed open (30s keepalive and all) while its
|
|
19481
|
+
* owner had already written it off as dead. One leaked socket per invalidation,
|
|
19482
|
+
* until the process exits. `teardownTransport()` is the only path that ends the
|
|
19483
|
+
* Client, so an invalidated connection goes through it too; that is safe to
|
|
19484
|
+
* repeat because each field is cleared as it is closed and `closeQuietly`
|
|
19485
|
+
* ignores a second close — a later `dispose()`, `reconnect()` or failed
|
|
19486
|
+
* `open()` teardown therefore finds nothing left to release.
|
|
19487
|
+
*
|
|
19488
|
+
* Ordering is deliberate: the peer is closed FIRST so in-flight requests reject
|
|
19489
|
+
* with THIS error (the teardown's own close would raise a generic
|
|
19490
|
+
* "channel closed" instead), and `stderrTail` is captured BEFORE the teardown,
|
|
19491
|
+
* which clears it — otherwise `diagnostics` in the dial path would always
|
|
19492
|
+
* report "the helper wrote nothing to stderr".
|
|
19493
|
+
*
|
|
19494
|
+
* Only an ESTABLISHED transport is released here. While `open()` is still
|
|
19495
|
+
* dialing, `conn` is alive and `channel`/`peer` are not, and ending that Client
|
|
19496
|
+
* would strand the handshake: ssh2 clears its own ready timer when the socket
|
|
19497
|
+
* closes and emits 'close' without an 'error', so the promise `open()` awaits
|
|
19498
|
+
* would never settle. `open()` itself releases the attempt instead, once it has
|
|
19499
|
+
* a definitive outcome.
|
|
19500
|
+
*/
|
|
19410
19501
|
invalidate(error) {
|
|
19411
19502
|
if (this.dead !== void 0 || this.disposed) return;
|
|
19412
19503
|
this.dead = error;
|
|
19413
|
-
if (this.heartbeat !== void 0)
|
|
19504
|
+
if (this.heartbeat !== void 0) {
|
|
19505
|
+
clearTimeout(this.heartbeat);
|
|
19506
|
+
this.heartbeat = void 0;
|
|
19507
|
+
}
|
|
19508
|
+
const tail = this.stderrTail;
|
|
19414
19509
|
try {
|
|
19415
19510
|
this.peer?.close(error);
|
|
19416
19511
|
} catch {}
|
|
19512
|
+
if (this.peer !== void 0 || this.channel !== void 0) this.teardownTransport();
|
|
19513
|
+
this.stderrTail = tail;
|
|
19417
19514
|
}
|
|
19418
19515
|
};
|
|
19419
19516
|
//#endregion
|
|
@@ -19953,9 +20050,10 @@ var RemoteWorlds = class {
|
|
|
19953
20050
|
}
|
|
19954
20051
|
const conn = await pending;
|
|
19955
20052
|
if (!conn.alive) {
|
|
20053
|
+
const detail = conn.diagnostics;
|
|
20054
|
+
conn.dispose().catch(() => void 0);
|
|
19956
20055
|
this.rpcs.delete(alias);
|
|
19957
20056
|
if (attempt < DIAL_IMMEDIATE_RETRIES) return this.dial(alias, attempt + 1);
|
|
19958
|
-
const detail = conn.diagnostics;
|
|
19959
20057
|
const reason = "helper connection closed right after dialing" + (detail === "" ? " (the helper wrote nothing to stderr)" : ` — helper stderr: ${detail}`);
|
|
19960
20058
|
this.noteDialFailure(alias, new Error(reason));
|
|
19961
20059
|
throw new Error(`helper RPC for ${alias} is unavailable after ${attempt + 1} attempt(s): ${reason}`);
|
|
@@ -20051,4 +20149,4 @@ var RemoteWorlds = class {
|
|
|
20051
20149
|
}
|
|
20052
20150
|
};
|
|
20053
20151
|
//#endregion
|
|
20054
|
-
export {
|
|
20152
|
+
export { dshHome as C, viewSettingsPath as D, storePath as E, aliasRoot as S, keysDir as T, MAX_TIMEOUT_MS as _, takeHostNotices as a, resolveTimeouts as b, pushPipeline as c, WriteConflictError as d, attachmentHeader as f, DeadlineError as g, DEFAULT_TIMEOUTS as h, drainHostNotices as i, seedHelperCache as l, DEFAULT_READ_TIMEOUT_MS as m, TombstonedError as n, helperAvailability as o, DEFAULT_GIT_TIMEOUT_MS as p, isWindowsAbsolute as r, probe as s, RemoteWorlds as t, RemoteFiles as u, MIN_TIMEOUT_MS as v, ensurePrivateDir as w, require_lib as x, clampExecTimeout as y };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-remote-vs",
|
|
3
3
|
"description": "VSCode-style remote development for DSH: SSH host manager (key/password), helper deploy pipeline with version check, remote file explorer + editor + terminal in dsh-better-sidebar.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.27.0",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"dsh",
|
|
@@ -83,6 +83,7 @@
|
|
|
83
83
|
"cordis.patch.yml",
|
|
84
84
|
"README.md",
|
|
85
85
|
"README.en.md",
|
|
86
|
+
"THIRD-PARTY-NOTICES.md",
|
|
86
87
|
"LICENSE",
|
|
87
88
|
"icon.svg",
|
|
88
89
|
"locale/*.json"
|
|
@@ -149,6 +150,7 @@
|
|
|
149
150
|
"@deepseek-ai/dsh-api-remotes": "0.2.2-rc.5",
|
|
150
151
|
"@deepseek-ai/dsh-bash-local": "0.2.2-rc.5",
|
|
151
152
|
"@deepseek-ai/dsh-client-locale": "0.2.2-rc.5",
|
|
153
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.5",
|
|
152
154
|
"@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.5",
|
|
153
155
|
"@deepseek-ai/dsh-client-ui-settings": "0.2.2-rc.5",
|
|
154
156
|
"@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.2-rc.5",
|