dsh-remote-vs 0.24.0 → 0.26.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 +50 -16
- package/README.md +40 -15
- package/THIRD-PARTY-NOTICES.md +188 -0
- package/lib/client.js +6512 -77887
- package/lib/index.js +1461 -1024
- package/lib/p2-router-fs.js +1 -1
- package/lib/types/client/CodeEditor.d.ts +25 -0
- package/lib/types/client/EditorPane.d.ts +16 -5
- package/lib/types/client/FloatingPlaceholder.d.ts +16 -5
- package/lib/types/client/RemoteEditorView.d.ts +13 -10
- package/lib/types/client/RemoteExplorer.d.ts +53 -0
- package/lib/types/client/RemoteRoot.d.ts +5 -5
- package/lib/types/client/TerminalSnippets.d.ts +36 -0
- package/lib/types/client/TerminalView.d.ts +1 -1
- package/lib/types/client/XTerm.d.ts +33 -0
- package/lib/types/client/api.d.ts +37 -2
- package/lib/types/client/changes/review-state.d.ts +19 -0
- package/lib/types/client/connection.d.ts +16 -0
- package/lib/types/client/editor-capability.d.ts +27 -0
- package/lib/types/client/i18n.d.ts +1 -1
- 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 +31 -3
- package/lib/types/client/store.d.ts +112 -4
- package/lib/types/client/terminal-input.d.ts +23 -0
- package/lib/types/client/terminal-snippets.d.ts +86 -0
- package/lib/types/client/vsc/FindWidget.d.ts +6 -0
- package/lib/types/client/vsc/breadcrumb.d.ts +30 -0
- package/lib/types/client/vsc/change-marks.d.ts +16 -6
- package/lib/types/client/vsc/editor-caret.d.ts +32 -0
- package/lib/types/client/vsc/editor-keymap.d.ts +35 -1
- package/lib/types/client/vsc/editor-langs.d.ts +9 -0
- package/lib/types/client/vsc/editor-settings.d.ts +55 -0
- package/lib/types/client/vsc/image-preview.d.ts +36 -0
- package/lib/types/client/vsc/kit.d.ts +13 -0
- package/lib/types/client/vsc/save-shortcut.d.ts +21 -0
- package/lib/types/client/vsc/terminal-clipboard.d.ts +15 -0
- package/lib/types/client/vsc/terminal-line.d.ts +25 -0
- package/lib/types/client/vsc/terminal-links.d.ts +62 -0
- package/lib/types/client/vsc/terminal-theme.d.ts +48 -0
- package/lib/types/client/vsc/terminal-writer.d.ts +52 -0
- package/lib/types/forward.d.ts +12 -0
- package/lib/types/fs-ops.d.ts +42 -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/pool.d.ts +25 -0
- package/lib/types/routes.d.ts +2 -0
- package/lib/types/store.d.ts +7 -0
- package/lib/types/terminal.d.ts +33 -1
- package/lib/types/view-settings.d.ts +5 -0
- package/lib/{worlds-B7gEDBzC.js → worlds-RG8K5eom.js} +113 -15
- package/package.json +2 -1
- package/src/client/CodeEditor.tsx +205 -10
- package/src/client/DirectoryFlow.tsx +16 -0
- package/src/client/DoctorPanel.tsx +70 -7
- package/src/client/EditorPane.tsx +545 -118
- package/src/client/FloatingPlaceholder.tsx +34 -5
- package/src/client/HostsView.tsx +12 -3
- package/src/client/RemoteDirectoryPicker.tsx +12 -0
- package/src/client/RemoteEditorView.tsx +14 -11
- package/src/client/RemoteExplorer.tsx +929 -40
- package/src/client/RemoteRoot.tsx +167 -147
- package/src/client/SearchView.tsx +8 -0
- package/src/client/TerminalSnippets.tsx +432 -0
- package/src/client/TerminalView.tsx +50 -1
- package/src/client/XTerm.tsx +228 -58
- package/src/client/api.ts +106 -13
- package/src/client/auto-open-remote.ts +11 -9
- 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/editor-capability.ts +42 -0
- package/src/client/i18n.ts +228 -12
- package/src/client/index.tsx +22 -6
- 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 +23 -2
- package/src/client/scm/RepoPicker.tsx +1 -1
- package/src/client/scm/ScmPanel.tsx +391 -87
- package/src/client/scm/actions.ts +95 -12
- package/src/client/store.tsx +537 -22
- package/src/client/terminal-input.ts +44 -0
- package/src/client/terminal-snippets.ts +216 -0
- package/src/client/ui.tsx +4 -0
- package/src/client/vsc/FindWidget.tsx +24 -9
- package/src/client/vsc/breadcrumb.tsx +339 -0
- package/src/client/vsc/change-marks.ts +93 -44
- package/src/client/vsc/editor-caret.ts +30 -0
- package/src/client/vsc/editor-keymap.ts +59 -1
- package/src/client/vsc/editor-langs.ts +20 -0
- package/src/client/vsc/editor-settings.ts +146 -0
- package/src/client/vsc/editor-theme.ts +4 -5
- package/src/client/vsc/file-icons.tsx +17 -3
- package/src/client/vsc/image-preview.tsx +110 -0
- package/src/client/vsc/kit.tsx +46 -10
- package/src/client/vsc/save-shortcut.ts +47 -1
- package/src/client/vsc/terminal-clipboard.ts +19 -0
- package/src/client/vsc/terminal-line.ts +101 -0
- package/src/client/vsc/terminal-links.ts +166 -0
- package/src/client/vsc/terminal-theme.ts +97 -0
- package/src/client/vsc/terminal-writer.ts +112 -0
- package/src/client/vsc/vsc.css +1078 -181
- package/src/forward.ts +47 -9
- package/src/fs-ops.ts +124 -4
- package/src/git-ops.ts +20 -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/pool.ts +99 -27
- package/src/routes.ts +212 -43
- package/src/sftp.ts +51 -14
- package/src/store.ts +10 -0
- package/src/terminal.ts +225 -24
- package/src/view-settings.ts +50 -10
- package/lib/types/client/Dialog.d.ts +0 -14
- package/src/client/Dialog.tsx +0 -76
|
@@ -32,6 +32,18 @@ export interface SaveShortcutEvent {
|
|
|
32
32
|
defaultPrevented: boolean;
|
|
33
33
|
target: EventTarget | null;
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Areas where Ctrl+S belongs to somebody else.
|
|
37
|
+
*
|
|
38
|
+
* A terminal (xterm) forwards keys to the remote shell and a themed dialog's
|
|
39
|
+
* input is mid-edit; hijacking the key there would be a surprise, and for the
|
|
40
|
+
* shell it would also steal a control character (`^S`).
|
|
41
|
+
*
|
|
42
|
+
* Exported so the plugin's OTHER window-level shortcut (Ctrl+P in `RemoteRoot`)
|
|
43
|
+
* draws the same line instead of re-inventing a narrower one — it used to
|
|
44
|
+
* exclude only `.xterm` and hijacked the host's chat composer.
|
|
45
|
+
*/
|
|
46
|
+
export declare const FOREIGN_TARGET = ".xterm, textarea, input, [contenteditable=\"true\"]";
|
|
35
47
|
/**
|
|
36
48
|
* Is this the save shortcut this module should act on?
|
|
37
49
|
*
|
|
@@ -41,6 +53,15 @@ export interface SaveShortcutEvent {
|
|
|
41
53
|
export declare function isSaveShortcut(event: SaveShortcutEvent): boolean;
|
|
42
54
|
/** A registered save target: `undefined` = this surface has nothing to save. */
|
|
43
55
|
export type SaveShortcutResolver = () => (() => void) | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Is a modal layer (host approval / settings, our own dialog, an open menu) on
|
|
58
|
+
* screen right now?
|
|
59
|
+
*
|
|
60
|
+
* Called from the DOM listener entry points only: `isSaveShortcut` stays a pure
|
|
61
|
+
* predicate on the event. Without it Ctrl+S silently saved the remote file
|
|
62
|
+
* underneath a pending host approval dialog — a write the user never confirmed.
|
|
63
|
+
*/
|
|
64
|
+
export declare function isModalLayerOpen(): boolean;
|
|
44
65
|
/**
|
|
45
66
|
* Install the window-level save shortcut for one surface.
|
|
46
67
|
*
|
|
@@ -49,6 +49,21 @@ export interface TerminalChordInput {
|
|
|
49
49
|
export declare function clipboardChordFor(input: TerminalChordInput): TerminalClipboardChord | undefined;
|
|
50
50
|
/** Copy and paste chords take the key over; the native-paste chord must not. */
|
|
51
51
|
export declare function chordTakesKey(chord: TerminalClipboardChord): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Map ONE keyboard event to a terminal clipboard command.
|
|
54
|
+
*
|
|
55
|
+
* xterm calls its custom key handler for keydown, keyup AND keypress. Only the
|
|
56
|
+
* keydown PRESS is a command: handling keyup too ran every chord twice, which is
|
|
57
|
+
* what made Shift+Insert paste the clipboard twice (reported 2026-11-23) — two
|
|
58
|
+
* Clipboard-API reads and two input frames for one gesture, with no native paste
|
|
59
|
+
* event involved.
|
|
60
|
+
*
|
|
61
|
+
* Pure, so the gate can pin the "keyup is not a command" rule directly instead
|
|
62
|
+
* of matching source text.
|
|
63
|
+
*/
|
|
64
|
+
export declare function terminalKeyCommand(input: TerminalChordInput & {
|
|
65
|
+
type: string;
|
|
66
|
+
}): TerminalClipboardChord | undefined;
|
|
52
67
|
/** Dependencies of {@link createPasteFallback}. */
|
|
53
68
|
export interface PasteFallbackDeps {
|
|
54
69
|
/** Clipboard read; `undefined` when the browser denies it. */
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Track what the user has typed on the CURRENT terminal line (pure).
|
|
3
|
+
*
|
|
4
|
+
* Why this exists: `Ctrl+B` should save the command the user is about to run as
|
|
5
|
+
* a snippet, pre-filled. The PTY protocol has no "current line" query, and asking
|
|
6
|
+
* the shell would mean typing into it — so the client reconstructs the line from
|
|
7
|
+
* the same `onData` stream it forwards: printable characters append, backspace
|
|
8
|
+
* removes, Enter/Ctrl+C/Ctrl+U clear, escape sequences (arrows, F-keys, history
|
|
9
|
+
* recall) are ignored.
|
|
10
|
+
*
|
|
11
|
+
* The result is a BEST-EFFORT draft, not a shell parser: after cursor movement or
|
|
12
|
+
* history recall it can differ from the real line. That is acceptable because it
|
|
13
|
+
* only pre-fills an editable form — nothing is executed, and the user can fix it.
|
|
14
|
+
*/
|
|
15
|
+
/** Longest line worth remembering (a snippet's command is capped separately). */
|
|
16
|
+
export declare const TERMINAL_LINE_MAX = 4000;
|
|
17
|
+
/**
|
|
18
|
+
* Apply one chunk of terminal INPUT to the current line.
|
|
19
|
+
*
|
|
20
|
+
* @param line - the line reconstructed so far.
|
|
21
|
+
* @param data - the chunk as handed to the PTY (bracketed-paste markers already
|
|
22
|
+
* stripped by the caller).
|
|
23
|
+
* @returns the new line.
|
|
24
|
+
*/
|
|
25
|
+
export declare function applyTerminalInput(line: string, data: string): string;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal path links: find path-like tokens in a terminal line and turn them
|
|
3
|
+
* into absolute remote paths (pure, no xterm/DOM).
|
|
4
|
+
*
|
|
5
|
+
* The terminal prints paths constantly (compiler errors, `ls`, `grep`, logs) and
|
|
6
|
+
* the tree already knows how to reveal a folder over SFTP, so the missing piece
|
|
7
|
+
* is only "which text is a path, and what absolute path does it mean". Both
|
|
8
|
+
* questions are decided here; the xterm link provider and the store action are
|
|
9
|
+
* thin wiring on top.
|
|
10
|
+
*
|
|
11
|
+
* Scope decisions (kept deliberately conservative — a wrong jump is worse than a
|
|
12
|
+
* missing one):
|
|
13
|
+
* - absolute (`/opt/src/a.c`), home-relative (`~/build.log`) and relative
|
|
14
|
+
* tokens that contain a `/` (`v_sys/system/core.c`) are offered;
|
|
15
|
+
* - a `:line` / `:line:col` suffix is stripped (`src/a.ts:12:5` → `src/a.ts`);
|
|
16
|
+
* - URLs, flags (`--opt/x`) and pure numbers are not links;
|
|
17
|
+
* - resolution never guesses silently: it returns a CANDIDATE list, and the
|
|
18
|
+
* caller validates each candidate against the host before acting.
|
|
19
|
+
*/
|
|
20
|
+
/** One path-looking range inside a terminal line. */
|
|
21
|
+
export interface TerminalPathToken {
|
|
22
|
+
/** 0-based index of the first character. */
|
|
23
|
+
start: number;
|
|
24
|
+
/** 0-based index of the LAST character (inclusive). */
|
|
25
|
+
end: number;
|
|
26
|
+
/** The path itself, with any `:line(:col)` suffix removed. */
|
|
27
|
+
path: string;
|
|
28
|
+
}
|
|
29
|
+
/** Everything {@link resolutionCandidates} may use to anchor a relative token. */
|
|
30
|
+
export interface PathResolutionContext {
|
|
31
|
+
/** Remote home directory, when knowable (derived from the SSH user). */
|
|
32
|
+
home?: string;
|
|
33
|
+
/** Shell working directory, when the shell reports it (OSC 7). */
|
|
34
|
+
cwd?: string;
|
|
35
|
+
/** Remote workspace roots on this host, most specific first. */
|
|
36
|
+
roots?: readonly string[];
|
|
37
|
+
}
|
|
38
|
+
/** Collapse `//`, resolve `.`/`..` and drop a trailing slash (POSIX semantics). */
|
|
39
|
+
export declare function normalizeRemotePath(path: string): string;
|
|
40
|
+
/** Join a base directory and a relative token (POSIX, no trailing slash). */
|
|
41
|
+
export declare function joinRemotePath(base: string, token: string): string;
|
|
42
|
+
/** The parent directory of an absolute path (`/a/b/c` → `/a/b`; `/a` → `/`). */
|
|
43
|
+
export declare function parentDirectoryOf(path: string): string;
|
|
44
|
+
/** Whether `path` is `root` itself or lives under it. */
|
|
45
|
+
export declare function isWithinRoot(path: string, root: string): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Every path-looking token of one terminal line, in order.
|
|
48
|
+
*
|
|
49
|
+
* Trailing sentence punctuation is trimmed rather than excluded beforehand, so
|
|
50
|
+
* `see /opt/src/a.c.` links `a.c`; a location suffix is removed before that trim
|
|
51
|
+
* so `a.c:12` links `a.c` (not `a.c:12`).
|
|
52
|
+
*/
|
|
53
|
+
export declare function findTerminalPathTokens(text: string): TerminalPathToken[];
|
|
54
|
+
/**
|
|
55
|
+
* Absolute candidates for one token, in the order they should be validated.
|
|
56
|
+
*
|
|
57
|
+
* The caller stats each in turn (bounded) and acts on the first hit, which is
|
|
58
|
+
* why the order matters: the shell's reported cwd beats a workspace-root guess,
|
|
59
|
+
* and the home directory is the last resort (most relative paths a shell prints
|
|
60
|
+
* are relative to where the user is).
|
|
61
|
+
*/
|
|
62
|
+
export declare function resolutionCandidates(token: string, ctx?: PathResolutionContext): string[];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* xterm colour theme, kept free of React/DOM so a gate can assert it.
|
|
3
|
+
*
|
|
4
|
+
* The palette is OPAQUE on purpose: xterm's contrast engine cannot reason about
|
|
5
|
+
* translucent colours, and a terminal over a wallpaper needs a definite surface.
|
|
6
|
+
*
|
|
7
|
+
* Selection colours are explicit per scheme. xterm's defaults assume a dark
|
|
8
|
+
* background, so in the light theme a selected block rendered white-on-white —
|
|
9
|
+
* copy worked while "selecting" looked like it did nothing (reported
|
|
10
|
+
* 2026-11-23). These are the VS Code selection colours, with a dimmer variant
|
|
11
|
+
* for an unfocused window.
|
|
12
|
+
*
|
|
13
|
+
* Only a TYPE import from xterm here: the module must stay loadable in Node for
|
|
14
|
+
* the gate (`@xterm/xterm`'s entry pulls CSS/UMD code).
|
|
15
|
+
*/
|
|
16
|
+
import type { ITheme } from '@xterm/xterm';
|
|
17
|
+
/**
|
|
18
|
+
* The dark scheme palette.
|
|
19
|
+
*
|
|
20
|
+
* Contrast is measured against `background` (#0e0e13): the VS Code Dark+ ANSI
|
|
21
|
+
* set, with red / blue / magenta / brightBlack lifted just past 4.5:1 (`black`
|
|
22
|
+
* is left at #000000 on purpose — ANSI black is a background-fill colour by
|
|
23
|
+
* convention and is not read as text; 1.09:1). `brightCyan` is lifted off the
|
|
24
|
+
* plain cyan (#29b8db sat only ΔE76 6.0 from #11a8cd — the pair read as one
|
|
25
|
+
* colour) to #4dd0e1: ΔE76 18.5, 10.5:1 on the terminal surface.
|
|
26
|
+
*/
|
|
27
|
+
export declare const DARK_TERMINAL_THEME: ITheme;
|
|
28
|
+
/**
|
|
29
|
+
* The light scheme palette.
|
|
30
|
+
*
|
|
31
|
+
* Re-taken for a WHITE background (2026-11-23): the Dark+ ANSI set this used to
|
|
32
|
+
* copy measured 1.0–3.6:1 on #ffffff (brightWhite was white-on-white = 1.00,
|
|
33
|
+
* brightYellow 1.17). Text here is targeted at ≥4.5:1, and every colour is.
|
|
34
|
+
*
|
|
35
|
+
* "Bright" cannot mean "lighter" on white, so the bright group is the more
|
|
36
|
+
* saturated sibling of its hue rather than a lighter one; where a hue had to be
|
|
37
|
+
* re-picked the normal/bright pair keeps a visible difference. `brightWhite` is
|
|
38
|
+
* the one colour that has no readable white-ish form: it is #767676, the
|
|
39
|
+
* lightest neutral of the ramp, which keeps "bright white" distinguishable from
|
|
40
|
+
* `white`/`brightBlack` while reaching 4.54:1 (VS Code Light+ ships #e5e5e5,
|
|
41
|
+
* 1.05:1 — unreadable). `black` stays #000000 (ANSI background-fill convention).
|
|
42
|
+
* `brightCyan` moves to the teal step #0f766e: the previous #0e7490 sat ΔE76
|
|
43
|
+
* 4.0 from `cyan` (#0b6d84) and read as the same colour; the new value is ΔE76
|
|
44
|
+
* 20.5 away at 5.47:1.
|
|
45
|
+
*/
|
|
46
|
+
export declare const LIGHT_TERMINAL_THEME: ITheme;
|
|
47
|
+
/** The palette for one scheme. */
|
|
48
|
+
export declare function terminalTheme(dark: boolean): ITheme;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal OUTPUT writer: an ordered, coalescing buffer between the WebSocket
|
|
3
|
+
* frames and `term.write`.
|
|
4
|
+
*
|
|
5
|
+
* Why this is not just `term.write(frame.d)` per frame, and NOT a chain of
|
|
6
|
+
* `write(..., callback)`:
|
|
7
|
+
*
|
|
8
|
+
* - xterm parses writes in slices of a few milliseconds; handing it one string
|
|
9
|
+
* per frame costs per-call overhead on a busy stream (`cat`, `dmesg`).
|
|
10
|
+
* - chaining on the write CALLBACK couples our queue to xterm's parse/render
|
|
11
|
+
* completion. A callback is delivered after the data is parsed AND rendered,
|
|
12
|
+
* and rendering is driven by the browser's frames — a throttled window, an
|
|
13
|
+
* occluded tab or a very large previous chunk delays it, and while it is
|
|
14
|
+
* delayed this queue refuses to hand xterm anything new. That is exactly the
|
|
15
|
+
* "typing sometimes has no echo for a while, then it catches up" symptom:
|
|
16
|
+
* the echo was sitting in our queue behind a callback that had not fired yet.
|
|
17
|
+
*
|
|
18
|
+
* So: order is preserved by APPENDING to one buffer and flushing it on a timer
|
|
19
|
+
* (or immediately when the buffer is large). Nothing here waits for a write to
|
|
20
|
+
* finish — xterm's own queue already serialises the chunks we hand it.
|
|
21
|
+
*
|
|
22
|
+
* Pure for the gate (`scripts/check-terminal-writer.mjs`): the scheduler and the
|
|
23
|
+
* write sink are injected, no DOM, no timers at import time.
|
|
24
|
+
*/
|
|
25
|
+
/** Dependencies of {@link createTerminalWriter}. */
|
|
26
|
+
export interface TerminalWriterDeps {
|
|
27
|
+
/** Hand one chunk to the terminal (xterm's `write`). Must not throw. */
|
|
28
|
+
write: (text: string) => void;
|
|
29
|
+
/** Schedule one flush; the default is `setTimeout(run, 0)`. */
|
|
30
|
+
schedule?: (run: () => void) => unknown;
|
|
31
|
+
/**
|
|
32
|
+
* Largest string handed to `write` in one call.
|
|
33
|
+
*
|
|
34
|
+
* Joining a multi-megabyte backlog into ONE string would itself block the main
|
|
35
|
+
* thread (and the join is O(total) on every flush), so a big queue is written
|
|
36
|
+
* in pieces and the rest is scheduled immediately.
|
|
37
|
+
*/
|
|
38
|
+
maxChunkChars?: number;
|
|
39
|
+
}
|
|
40
|
+
/** Handle returned by {@link createTerminalWriter}. */
|
|
41
|
+
export interface TerminalWriter {
|
|
42
|
+
/** Append output; the returned value is ignored (kept for symmetry/tests). */
|
|
43
|
+
push: (text: string) => void;
|
|
44
|
+
/** Flush everything right now (tab closing, exit frame). */
|
|
45
|
+
flush: () => void;
|
|
46
|
+
/** Characters still waiting (diagnostics/tests). */
|
|
47
|
+
pendingChars: () => number;
|
|
48
|
+
}
|
|
49
|
+
/** Default cap for one `write` call (256 Ki UTF-16 units). */
|
|
50
|
+
export declare const WRITER_MAX_CHUNK_CHARS: number;
|
|
51
|
+
/** Create one ordered, coalescing writer. */
|
|
52
|
+
export declare function createTerminalWriter(deps: TerminalWriterDeps): TerminalWriter;
|
package/lib/types/forward.d.ts
CHANGED
|
@@ -61,6 +61,18 @@ export declare class ForwardManager {
|
|
|
61
61
|
* first listener orphaned — unreachable from the panel and never closed.
|
|
62
62
|
*/
|
|
63
63
|
private readonly starting;
|
|
64
|
+
/**
|
|
65
|
+
* Rules stopped while their listener was still BINDING.
|
|
66
|
+
*
|
|
67
|
+
* A pending bind is not in `forwards` yet, so `stop()`, `stopAlias()`,
|
|
68
|
+
* `stopAll()` and `dispose()` used to see nothing to close: the listener the
|
|
69
|
+
* OS was about to hand out stayed bound with no panel row left to stop it
|
|
70
|
+
* (click a forward, immediately disable the plugin or delete the host, and
|
|
71
|
+
* `127.0.0.1:<port>` stayed taken until the Host restarted). The id sits here
|
|
72
|
+
* until the bind settles; a settling bind that finds its id records itself as
|
|
73
|
+
* stopped and closes the fresh listener instead of entering `forwards`.
|
|
74
|
+
*/
|
|
75
|
+
private readonly stoppedWhileBinding;
|
|
64
76
|
/** Set on unload so a bind that settles afterwards closes itself. */
|
|
65
77
|
private disposed;
|
|
66
78
|
constructor(deps: ForwardManagerDeps);
|
package/lib/types/fs-ops.d.ts
CHANGED
|
@@ -6,3 +6,45 @@ export declare function joinAbs(dir: string, name: string): string;
|
|
|
6
6
|
export declare function copyIntoCommand(from: string, intoDir: string, name?: string): string;
|
|
7
7
|
/** Move one path into a directory (`mv`), optionally under a new name. */
|
|
8
8
|
export declare function moveToCommand(from: string, intoDir: string, name?: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Validate one removal target: absolute, no `..`, no control characters, and
|
|
11
|
+
* never the filesystem root.
|
|
12
|
+
*
|
|
13
|
+
* `assertAbsPath` legitimately accepts `/` (one character away from `rm -rf -- /`)
|
|
14
|
+
* and rewrites `\` to `/` for Windows-shaped input. A remote POSIX name may
|
|
15
|
+
* legitimately contain a literal backslash, and rewriting it would delete a
|
|
16
|
+
* DIFFERENT path, so removal validation keeps every character as-is and only
|
|
17
|
+
* rejects what cannot be deleted safely.
|
|
18
|
+
*/
|
|
19
|
+
export declare function assertRemovablePath(path: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Build the POSIX sh script that removes `paths`, in order.
|
|
22
|
+
*
|
|
23
|
+
* Each entry prints an indexed marker before and after its own `rm`, so the
|
|
24
|
+
* client can show which path is on the wire, count settled entries and retry
|
|
25
|
+
* exactly the ones that failed. The script ends with `exit 0` on purpose: one
|
|
26
|
+
* failed path is not a failed batch — the markers own the per-path truth (see
|
|
27
|
+
* `parseDeleteMarker`), and the caller falls back to the per-entry route for
|
|
28
|
+
* whatever they report as FAIL.
|
|
29
|
+
*/
|
|
30
|
+
export declare function batchRemoveScript(paths: string[]): string;
|
|
31
|
+
/**
|
|
32
|
+
* Split one multi-selection into bounded batches, dropping duplicate paths.
|
|
33
|
+
*
|
|
34
|
+
* Order is preserved (markers are index-based within a batch); the inputs are
|
|
35
|
+
* validated here, before anything touches the remote, so an unquotable path
|
|
36
|
+
* rejects the whole delete instead of starting a half-executed batch.
|
|
37
|
+
*/
|
|
38
|
+
export declare function splitBatchRemovePaths(paths: string[]): string[][];
|
|
39
|
+
/**
|
|
40
|
+
* Parse one marker line printed by `batchRemoveScript`.
|
|
41
|
+
*
|
|
42
|
+
* Strict on purpose: remote `rm` diagnostics ("rm: cannot remove …") and a
|
|
43
|
+
* mangled marker must never be mistaken for a settled entry. The index is a
|
|
44
|
+
* plain non-negative integer (no sign, no decimal) because it indexes the
|
|
45
|
+
* batch's path list.
|
|
46
|
+
*/
|
|
47
|
+
export declare function parseDeleteMarker(line: string): {
|
|
48
|
+
kind: 'item' | 'ok' | 'fail';
|
|
49
|
+
index: number;
|
|
50
|
+
} | undefined;
|
package/lib/types/http.d.ts
CHANGED
|
@@ -44,6 +44,8 @@ export declare function readJsonBody(req: IncomingMessage, opts?: {
|
|
|
44
44
|
maxBytes?: number;
|
|
45
45
|
objectOnly?: boolean;
|
|
46
46
|
}): Promise<unknown | null>;
|
|
47
|
+
/** Declare which host the response being written concerns (`null` = no host). */
|
|
48
|
+
export declare function scopeHostNotices(res: ServerResponse, alias: string | null): void;
|
|
47
49
|
/** Write one JSON response. */
|
|
48
50
|
export declare function writeJson(res: ServerResponse, status: number, body: unknown, headers?: OutgoingHttpHeaders): void;
|
|
49
51
|
/**
|
package/lib/types/keygen.d.ts
CHANGED
|
@@ -7,6 +7,15 @@ export interface BootstrapResult {
|
|
|
7
7
|
flipped: boolean;
|
|
8
8
|
detail: string;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Normalize one `.pub` line to `ssh-ed25519 <base64> dsh-remote-vs/<alias>`.
|
|
12
|
+
*
|
|
13
|
+
* Throws when the line is not a well-formed ed25519 public key, so the caller
|
|
14
|
+
* sees a clear "this file is not a key" error instead of a remote login that
|
|
15
|
+
* fails later. The returned text is the only form that may enter the shell
|
|
16
|
+
* command: its comment is ours, and both remaining fields are shell-inert.
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatPublicKey(raw: string, alias: string): string;
|
|
10
19
|
/** Ensure the managed keypair exists; return the private key path. */
|
|
11
20
|
export declare function ensureKeypair(alias: string, dir?: string): Promise<{
|
|
12
21
|
privatePath: string;
|
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
|
}
|
package/lib/types/pool.d.ts
CHANGED
|
@@ -45,6 +45,24 @@ export interface SftpOptions {
|
|
|
45
45
|
export declare class RemotePool {
|
|
46
46
|
private readonly store;
|
|
47
47
|
private readonly conns;
|
|
48
|
+
/**
|
|
49
|
+
* Dedicated connections for PTY shells (one per alias).
|
|
50
|
+
*
|
|
51
|
+
* Why a SECOND connection instead of a channel on the shared one: ssh2
|
|
52
|
+
* multiplexes channels over ONE TCP connection, and SSH has no per-channel
|
|
53
|
+
* priority or flow control. A large SFTP transfer / git output on that
|
|
54
|
+
* connection therefore delays everything else on it — including the echo of a
|
|
55
|
+
* keystroke — which is exactly the "typing stutters when something else is
|
|
56
|
+
* moving data" report. A terminal gets its own connection, so its bytes never
|
|
57
|
+
* queue behind browse/exec traffic, and shells stop consuming the shared
|
|
58
|
+
* connection's channel budget as well.
|
|
59
|
+
*
|
|
60
|
+
* Cost: one extra SSH handshake per alias the first time a terminal opens,
|
|
61
|
+
* plus one held TCP connection per host with a terminal. `shell()` falls back
|
|
62
|
+
* to the shared connection if this one cannot be established at all, so a host
|
|
63
|
+
* that refuses extra connections still gets a working terminal.
|
|
64
|
+
*/
|
|
65
|
+
private readonly shellConns;
|
|
48
66
|
/** TOFU fingerprints observed this process (alias -> sha256). */
|
|
49
67
|
private readonly hostKeys;
|
|
50
68
|
/** Per-alias `setsid --wait` capability, probed once (see supportsSetsid). */
|
|
@@ -285,8 +303,15 @@ export declare class RemotePool {
|
|
|
285
303
|
private supportsSetsid;
|
|
286
304
|
/** Hold the connection against idle eviction (balanced by release). */
|
|
287
305
|
private hold;
|
|
306
|
+
private holdIn;
|
|
288
307
|
private release;
|
|
308
|
+
private releaseIn;
|
|
289
309
|
private acquire;
|
|
310
|
+
/** `acquire` for the dedicated PTY connection map. */
|
|
311
|
+
private acquireShell;
|
|
312
|
+
private acquireIn;
|
|
313
|
+
/** Evict ONE alias from ONE map (host removal drops both maps explicitly). */
|
|
314
|
+
private evictFrom;
|
|
290
315
|
/**
|
|
291
316
|
* The ssh2 client factory.
|
|
292
317
|
*
|
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
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { WebSocket } from 'ws';
|
|
2
2
|
import type { RemotePool } from './pool.ts';
|
|
3
|
+
/** Construction options (the terminal gate drives the registry directly). */
|
|
4
|
+
export interface TerminalRegistryOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Output coalescing window in ms; `0` sends every chunk as its own frame.
|
|
7
|
+
*
|
|
8
|
+
* The existing checks use `0` so their assertions stay synchronous; one
|
|
9
|
+
* dedicated check drives a non-zero window to pin the coalescing itself.
|
|
10
|
+
*/
|
|
11
|
+
coalesceMs?: number;
|
|
12
|
+
}
|
|
3
13
|
/**
|
|
4
14
|
* The largest client frame accepted, in bytes.
|
|
5
15
|
*
|
|
@@ -13,8 +23,11 @@ import type { RemotePool } from './pool.ts';
|
|
|
13
23
|
export declare const TERMINAL_MAX_FRAME_BYTES: number;
|
|
14
24
|
export declare class TerminalSessionRegistry {
|
|
15
25
|
private readonly pool;
|
|
26
|
+
private readonly options;
|
|
16
27
|
private readonly sessions;
|
|
17
|
-
constructor(pool: RemotePool);
|
|
28
|
+
constructor(pool: RemotePool, options?: TerminalRegistryOptions);
|
|
29
|
+
/** The window this registry coalesces within (`0` = every chunk is a frame). */
|
|
30
|
+
private get coalesceMs();
|
|
18
31
|
/** Open a shell and attach the first socket. */
|
|
19
32
|
open(ws: WebSocket, alias: string, cols: number, rows: number): Promise<string>;
|
|
20
33
|
/**
|
|
@@ -45,7 +58,26 @@ export declare class TerminalSessionRegistry {
|
|
|
45
58
|
/** Keep the shell for a while (reload can reattach), then close it for good. */
|
|
46
59
|
private armReap;
|
|
47
60
|
private cancelReap;
|
|
61
|
+
/**
|
|
62
|
+
* Queue one output chunk and schedule the coalesced frame.
|
|
63
|
+
*
|
|
64
|
+
* `coalesceMs === 0` broadcasts immediately (the checks rely on that
|
|
65
|
+
* synchrony). A chunk that arrives after an idle gap is also sent at once —
|
|
66
|
+
* that is the interactive echo path (a keystroke must not wait for the
|
|
67
|
+
* window) — while a stream that keeps producing coalesces.
|
|
68
|
+
*/
|
|
69
|
+
private queueOut;
|
|
70
|
+
/** Send the buffered output as ONE `out` frame (no-op when empty). */
|
|
71
|
+
private flushOut;
|
|
48
72
|
private setPaused;
|
|
49
73
|
private send;
|
|
50
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;
|
|
51
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
|
}
|