@fish-under-sea/dsh-ssh-fish 2.2.2 → 2.3.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 +4 -4
- package/README.md +4 -4
- package/package.json +5 -4
- package/README.i18n.yaml +0 -6
- package/README.zh.md +0 -31
- package/lib/client.js +0 -17100
- package/lib/client.js.map +0 -1
- package/lib/index.js +0 -3625
- package/lib/types/client/api.d.ts +0 -162
- package/lib/types/client/index.d.ts +0 -37
- package/lib/types/client/locales.d.ts +0 -175
- package/lib/types/client/native-panel.d.ts +0 -70
- package/lib/types/client/panel/ClusterTab.d.ts +0 -7
- package/lib/types/client/panel/HostFormDialog.d.ts +0 -12
- package/lib/types/client/panel/HostsTab.d.ts +0 -25
- package/lib/types/client/panel/SshPanel.d.ts +0 -14
- package/lib/types/client/panel/TerminalTab.d.ts +0 -27
- package/lib/types/client/panel/TransferTab.d.ts +0 -7
- package/lib/types/client/panel/TunnelsTab.d.ts +0 -19
- package/lib/types/client/panel/controller.d.ts +0 -253
- package/lib/types/client/panel/helpers.d.ts +0 -45
- package/lib/types/client/panel/xterm.css.d.ts +0 -2
- package/lib/types/client/settings-binding.d.ts +0 -61
- package/lib/types/dsh-home.d.ts +0 -16
- package/lib/types/engine/cluster.d.ts +0 -19
- package/lib/types/engine/connection-pool.d.ts +0 -163
- package/lib/types/engine/proxy-command.d.ts +0 -36
- package/lib/types/engine/pty.d.ts +0 -32
- package/lib/types/engine/sftp.d.ts +0 -20
- package/lib/types/engine/terminal-sessions.d.ts +0 -67
- package/lib/types/engine/tunnel.d.ts +0 -36
- package/lib/types/engine.d.ts +0 -96
- package/lib/types/http.d.ts +0 -59
- package/lib/types/index.d.ts +0 -93
- package/lib/types/loopback.d.ts +0 -64
- package/lib/types/mount-once.d.ts +0 -55
- package/lib/types/protocol.d.ts +0 -256
- package/lib/types/routes.d.ts +0 -33
- package/lib/types/ssh-config.d.ts +0 -34
- package/lib/types/store.d.ts +0 -78
- package/lib/types/tool-surface.d.ts +0 -72
- package/lib/types/tools.d.ts +0 -43
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SSH panel controller: the single owner of the panel's view state.
|
|
3
|
-
*
|
|
4
|
-
* Framework-free (structural runtime faces, task-board core/controller.ts
|
|
5
|
-
* style) so the sidebar row and the React panel share one tiny subscription
|
|
6
|
-
* surface. The state lives only for the browser session (no persistence).
|
|
7
|
-
*
|
|
8
|
-
* The active tab, the hosts-tab connect request, the terminal tabs and their
|
|
9
|
-
* host session ids live here rather than inside the panel components: the
|
|
10
|
-
* layout mounts a keyed page only while its panel is selected, so
|
|
11
|
-
* component-local state would reset the tab on every panel switch and lose
|
|
12
|
-
* the ids a reattach needs.
|
|
13
|
-
*
|
|
14
|
-
* Terminal tabs (issue #1950) are records, not sockets. One tab is the tab
|
|
15
|
-
* shown in the single xterm; a tab that is not shown either owns a detached
|
|
16
|
-
* host session (reattached by id, which replays the host scrollback) or no
|
|
17
|
-
* session at all. The controller is also the place where a still-connecting
|
|
18
|
-
* socket is adopted when a view goes away: a connection that has not reported
|
|
19
|
-
* its session id yet cannot be detached, so dropping it would leave the host
|
|
20
|
-
* PTY with no owner (the orphan the reference implementation produced).
|
|
21
|
-
*/
|
|
22
|
-
import type { TerminalConnection } from '../api.ts';
|
|
23
|
-
/** The panel's tab identifiers. */
|
|
24
|
-
export type SshTab = 'hosts' | 'terminal' | 'transfer' | 'tunnels' | 'cluster';
|
|
25
|
-
/** Stable id shared by the sidebar panel row and the main-slot page. */
|
|
26
|
-
export declare const SSH_PANEL_ID = "ssh";
|
|
27
|
-
/** Lifecycle of one terminal tab. */
|
|
28
|
-
export type TerminalTabStatus =
|
|
29
|
-
/** Socket open, the host has not reported a session id yet. */
|
|
30
|
-
'connecting'
|
|
31
|
-
/** The host reported a session id; the shell is live. */
|
|
32
|
-
| 'connected'
|
|
33
|
-
/** The remote shell ended. The tab keeps its screen; the session id is cleared. */
|
|
34
|
-
| 'exited'
|
|
35
|
-
/** The connection failed. The tab keeps the reason; the session id is cleared. */
|
|
36
|
-
| 'error';
|
|
37
|
-
/** A keyboard-interactive challenge waiting for this tab's answer. */
|
|
38
|
-
export interface TerminalAuthPrompt {
|
|
39
|
-
name: string;
|
|
40
|
-
instructions: string;
|
|
41
|
-
prompts: Array<{
|
|
42
|
-
prompt: string;
|
|
43
|
-
echo: boolean;
|
|
44
|
-
}>;
|
|
45
|
-
}
|
|
46
|
-
/** One terminal tab, independent of the socket that currently serves it. */
|
|
47
|
-
export interface TerminalTabRecord {
|
|
48
|
-
/** Local tab id, stable across panel switches (never the host session id). */
|
|
49
|
-
id: string;
|
|
50
|
-
/** Host alias this tab opened. Several tabs may share one alias. */
|
|
51
|
-
alias: string;
|
|
52
|
-
status: TerminalTabStatus;
|
|
53
|
-
/** Host-side PTY session id, present only while the shell is live. */
|
|
54
|
-
sessionId?: string;
|
|
55
|
-
/** Exit or failure text for the `exited` / `error` states. */
|
|
56
|
-
detail?: string;
|
|
57
|
-
/** Code of a close that never reached the host; the tab is kept. */
|
|
58
|
-
closeError?: string;
|
|
59
|
-
/** Challenge captured for this tab, whoever was on screen when it arrived. */
|
|
60
|
-
authPrompt?: TerminalAuthPrompt;
|
|
61
|
-
/**
|
|
62
|
-
* The answer being typed for {@link TerminalTabRecord.authPrompt}, owned by
|
|
63
|
-
* this tab: one shared draft let a challenge on tab B inherit (and submit)
|
|
64
|
-
* the characters typed for tab A.
|
|
65
|
-
*/
|
|
66
|
-
authAnswers?: string[];
|
|
67
|
-
}
|
|
68
|
-
/** The terminal fields a later step may change on one tab. */
|
|
69
|
-
export type TerminalTabPatch = Omit<TerminalTabRecord, 'id' | 'alias'>;
|
|
70
|
-
/** What to do with an adopted connection once the host reports its session. */
|
|
71
|
-
export type TerminalLinkIntent = 'detach' | 'close';
|
|
72
|
-
/** Immutable controller snapshot for UI subscriptions. */
|
|
73
|
-
export interface PanelControllerSnapshot {
|
|
74
|
-
/** Whether the center column shows this panel. */
|
|
75
|
-
panelOpen: boolean;
|
|
76
|
-
/** The tab the panel is showing. */
|
|
77
|
-
activeTab: SshTab;
|
|
78
|
-
/** Every terminal tab, in strip order. */
|
|
79
|
-
terminalTabs: readonly TerminalTabRecord[];
|
|
80
|
-
/** The tab the single xterm is bound to, or undefined when there is none. */
|
|
81
|
-
activeTerminalTabId: string | undefined;
|
|
82
|
-
/** Host picked in the terminal toolbar; the next tab opens on it. */
|
|
83
|
-
draftAlias: string;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* The layout's panel-navigation face: selecting the panel is the layout's
|
|
87
|
-
* business, and this is the one call that asks for it (null returns the column
|
|
88
|
-
* to the conversation). Optional, so a shell-less composition keeps the pure
|
|
89
|
-
* state transitions testable.
|
|
90
|
-
*/
|
|
91
|
-
export interface PanelNavigationFace {
|
|
92
|
-
/** Select this panel, or null to hand the column back to the conversation. */
|
|
93
|
-
select(panelId: string | null): void;
|
|
94
|
-
}
|
|
95
|
-
/** Controller dependencies. */
|
|
96
|
-
export interface PanelControllerDeps {
|
|
97
|
-
/** Layout panel selection; absent keeps the controller state-only. */
|
|
98
|
-
panel?: PanelNavigationFace;
|
|
99
|
-
}
|
|
100
|
-
/** The panel state owner the sidebar row and the view both read. */
|
|
101
|
-
export declare class PanelController {
|
|
102
|
-
private readonly deps;
|
|
103
|
-
private panelOpen;
|
|
104
|
-
private activeTab;
|
|
105
|
-
private terminalTabs;
|
|
106
|
-
private activeTerminalTabId;
|
|
107
|
-
private draftAlias;
|
|
108
|
-
private nextTerminalTabSeq;
|
|
109
|
-
private listeners;
|
|
110
|
-
/**
|
|
111
|
-
* Last screen of each tab, kept outside the snapshot: terminal output must
|
|
112
|
-
* not re-render the panel on every chunk, and only the terminal view reads
|
|
113
|
-
* this (when a tab has no session left to replay from).
|
|
114
|
-
*/
|
|
115
|
-
private readonly retainedScreens;
|
|
116
|
-
/**
|
|
117
|
-
* Sockets that outlived their view while still connecting. Their session id
|
|
118
|
-
* is unknown, so they cannot be detached yet; keeping them here is what
|
|
119
|
-
* prevents a host PTY with no owner.
|
|
120
|
-
*/
|
|
121
|
-
private readonly adoptedLinks;
|
|
122
|
-
/** Cached so getSnapshot is referentially stable between changes. */
|
|
123
|
-
private snapshot;
|
|
124
|
-
constructor(deps?: PanelControllerDeps);
|
|
125
|
-
getSnapshot(): PanelControllerSnapshot;
|
|
126
|
-
subscribe(fn: () => void): () => void;
|
|
127
|
-
/**
|
|
128
|
-
* Show the panel. The layout owns which panel the column renders, so the
|
|
129
|
-
* state flip and the selection travel together; the selection is requested
|
|
130
|
-
* after the snapshot flips, so a subscriber never observes "open" while the
|
|
131
|
-
* shell still shows the conversation.
|
|
132
|
-
*/
|
|
133
|
-
open(): void;
|
|
134
|
-
/** Return the column to the conversation, asking the layout explicitly. */
|
|
135
|
-
close(): void;
|
|
136
|
-
toggle(): void;
|
|
137
|
-
/**
|
|
138
|
-
* Reflect a selection made outside this controller (the user clicked another
|
|
139
|
-
* sidebar row, or the layout dropped the panel id).
|
|
140
|
-
* @param panelId - the layout's current panel id, or null for the conversation.
|
|
141
|
-
*/
|
|
142
|
-
syncPanelSelection(panelId: string | null): void;
|
|
143
|
-
/** Switch tabs, keeping every other piece of view state. */
|
|
144
|
-
setActiveTab(tab: SshTab): void;
|
|
145
|
-
/**
|
|
146
|
-
* Hand the terminal tab a host to connect to (the hosts-tab "connect"
|
|
147
|
-
* action): the tab exists before the view does, so a panel switch during the
|
|
148
|
-
* handshake still shows the connecting tab and adopts its socket.
|
|
149
|
-
* @param alias - the configured host alias.
|
|
150
|
-
*/
|
|
151
|
-
requestConnect(alias: string): void;
|
|
152
|
-
/**
|
|
153
|
-
* Add a terminal tab on the alias and make it the shown one. Several tabs
|
|
154
|
-
* may target one alias on purpose: each owns its own host PTY.
|
|
155
|
-
* @param alias - the configured host alias.
|
|
156
|
-
* @returns the new tab id.
|
|
157
|
-
*/
|
|
158
|
-
openTerminalTab(alias: string): string;
|
|
159
|
-
/**
|
|
160
|
-
* Show an existing tab and make the toolbar follow its host, so a new tab
|
|
161
|
-
* opens on the host the user is looking at.
|
|
162
|
-
* @param id - the tab id.
|
|
163
|
-
*/
|
|
164
|
-
setActiveTerminalTab(id: string): void;
|
|
165
|
-
/**
|
|
166
|
-
* Remove one tab and forget its screen. When the shown tab closes, the
|
|
167
|
-
* neighbours decide what the xterm shows next: the tab that took its place,
|
|
168
|
-
* else the one before it, else nothing.
|
|
169
|
-
* @param id - the tab id.
|
|
170
|
-
*/
|
|
171
|
-
closeTerminalTab(id: string): void;
|
|
172
|
-
/** The tab record with this id, or undefined when it no longer exists. */
|
|
173
|
-
terminalTab(id: string): TerminalTabRecord | undefined;
|
|
174
|
-
/**
|
|
175
|
-
* Apply a partial update to one tab; a tab that was closed in the meantime
|
|
176
|
-
* is left alone rather than resurrected.
|
|
177
|
-
* @param id - the tab id.
|
|
178
|
-
* @param patch - the fields to change.
|
|
179
|
-
*/
|
|
180
|
-
patchTerminalTab(id: string, patch: Partial<TerminalTabPatch>): void;
|
|
181
|
-
/**
|
|
182
|
-
* Record the host session of a ready tab and clear the challenge it carried.
|
|
183
|
-
* @param id - the tab id.
|
|
184
|
-
* @param sessionId - the id the host reported on its ready frame.
|
|
185
|
-
*/
|
|
186
|
-
readyTerminalTab(id: string, sessionId: string): void;
|
|
187
|
-
/**
|
|
188
|
-
* The remote shell ended: the tab keeps its screen and its place, and the
|
|
189
|
-
* dead session id is dropped so nothing tries to reattach to it.
|
|
190
|
-
* @param id - the tab id.
|
|
191
|
-
* @param detail - why it ended, when the transport said.
|
|
192
|
-
*/
|
|
193
|
-
exitTerminalTab(id: string, detail?: string): void;
|
|
194
|
-
/**
|
|
195
|
-
* The connection failed. The tab stays with the reason so the user can read
|
|
196
|
-
* it and close the tab themselves.
|
|
197
|
-
* @param id - the tab id.
|
|
198
|
-
* @param detail - the failure text.
|
|
199
|
-
*/
|
|
200
|
-
failTerminalTab(id: string, detail: string): void;
|
|
201
|
-
/**
|
|
202
|
-
* A background close never reached the host. The tab keeps its live session
|
|
203
|
-
* id (so a retry can still end it) and says so instead of vanishing.
|
|
204
|
-
* @param id - the tab id.
|
|
205
|
-
* @param reason - the reason code shown by the view.
|
|
206
|
-
*/
|
|
207
|
-
markTerminalCloseFailed(id: string, reason: string): void;
|
|
208
|
-
/**
|
|
209
|
-
* Store the keyboard-interactive challenge this tab has to answer, with a
|
|
210
|
-
* blank answer of this challenge's own length. A prompt on another tab never
|
|
211
|
-
* touches this record, which is what keeps two challenges from sharing input.
|
|
212
|
-
* @param id - the tab id.
|
|
213
|
-
* @param prompt - the challenge the host asked for.
|
|
214
|
-
*/
|
|
215
|
-
setTerminalAuthPrompt(id: string, prompt: TerminalAuthPrompt): void;
|
|
216
|
-
/**
|
|
217
|
-
* Record one character typed for this tab's challenge.
|
|
218
|
-
* @param id - the tab id.
|
|
219
|
-
* @param index - which prompt of the challenge.
|
|
220
|
-
* @param value - the field's current text.
|
|
221
|
-
*/
|
|
222
|
-
setTerminalAuthAnswer(id: string, index: number, value: string): void;
|
|
223
|
-
/** Drop the challenge once it was answered, cancelled, or could not apply. */
|
|
224
|
-
clearTerminalAuthPrompt(id: string): void;
|
|
225
|
-
/** Choose the alias the next terminal tab opens on. */
|
|
226
|
-
setDraftAlias(alias: string): void;
|
|
227
|
-
/** Append one output chunk to the retained screen of a tab. */
|
|
228
|
-
appendTerminalOutput(id: string, chunk: string): void;
|
|
229
|
-
/** The retained screen of a tab, concatenated for a redraw. */
|
|
230
|
-
readTerminalOutput(id: string): string;
|
|
231
|
-
/** Forget the retained screen (a fresh replay from the host replaces it). */
|
|
232
|
-
clearTerminalOutput(id: string): void;
|
|
233
|
-
/**
|
|
234
|
-
* Keep a still-connecting socket alive after its view went away. The socket
|
|
235
|
-
* cannot be detached yet (no session id), so the intent is applied when the
|
|
236
|
-
* host reports it: `detach` leaves the shell for a later reattach, `close`
|
|
237
|
-
* ends the session of a tab the user closed.
|
|
238
|
-
* @param tabId - the tab the socket belongs to.
|
|
239
|
-
* @param connection - the live connection.
|
|
240
|
-
* @param intent - what to do once the session id arrives.
|
|
241
|
-
*/
|
|
242
|
-
adoptTerminalLink(tabId: string, connection: TerminalConnection, intent: TerminalLinkIntent): void;
|
|
243
|
-
/**
|
|
244
|
-
* Take an adopted socket back when its tab is shown again, so the host never
|
|
245
|
-
* opens a second PTY for the same tab.
|
|
246
|
-
* @param tabId - the tab id.
|
|
247
|
-
* @returns the connection, or undefined when nothing was adopted.
|
|
248
|
-
*/
|
|
249
|
-
reclaimTerminalLink(tabId: string): TerminalConnection | undefined;
|
|
250
|
-
private commit;
|
|
251
|
-
/** Ask the layout to select a panel; a shell without the face is a no-op. */
|
|
252
|
-
private selectPanel;
|
|
253
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared panel helpers: the active-dictionary pick (document-language based,
|
|
3
|
-
* task-board precedent) bound to the dsh-ssh interpolator in locales.ts, plus
|
|
4
|
-
* a small error-message extractor. All copy stays in the locale dictionaries.
|
|
5
|
-
*/
|
|
6
|
-
import { type SshKey } from '../locales.ts';
|
|
7
|
-
/** Template values accepted by the interpolator. */
|
|
8
|
-
export type TranslateValues = Record<string, string | number>;
|
|
9
|
-
/** Active dictionary, picked by the document language at call time. */
|
|
10
|
-
export declare function dictionary(): Record<string, string>;
|
|
11
|
-
/** Wire the SDK translate seat; pass undefined to restore the document-language pick. */
|
|
12
|
-
export declare function setRuntimeTranslate(t: ((key: SshKey, values?: TranslateValues) => string) | undefined): void;
|
|
13
|
-
/** Translate a key with optional {name} template params (current language). */
|
|
14
|
-
export declare function tt(key: SshKey, values?: TranslateValues): string;
|
|
15
|
-
/** Human-readable error text from an unknown thrown value. */
|
|
16
|
-
export declare function errorMessage(error: unknown): string;
|
|
17
|
-
/**
|
|
18
|
-
* The terminal font stack used before issue #577, kept as the last resort
|
|
19
|
-
* when neither the plugin setting nor a CSS custom property names a font.
|
|
20
|
-
*/
|
|
21
|
-
export declare const TERMINAL_FONT_FALLBACK = "Menlo, Consolas, \"Liberation Mono\", monospace";
|
|
22
|
-
/**
|
|
23
|
-
* Live source of the user's configured terminal font family: the client
|
|
24
|
-
* entry binds the dsh-ssh settings namespace into one of these and hands it
|
|
25
|
-
* to the panel, so a settings change re-applies without a remount.
|
|
26
|
-
*/
|
|
27
|
-
export interface TerminalFontSource {
|
|
28
|
-
/** Current configured family, or undefined when unset / not yet loaded. */
|
|
29
|
-
get(): string | undefined;
|
|
30
|
-
/** Subscribe to changes; the returned function unsubscribes. */
|
|
31
|
-
subscribe(listener: () => void): () => void;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Resolve the xterm `fontFamily` (issue #577). xterm's DOM renderer takes
|
|
35
|
-
* the font only from constructor/options, so a plain stylesheet rule cannot
|
|
36
|
-
* retarget it — the value must be read back into the options. The chain,
|
|
37
|
-
* first non-empty value wins:
|
|
38
|
-
* 1. `override` — the `terminalFontFamily` plugin setting;
|
|
39
|
-
* 2. `--dsh-ssh-terminal-font` — dedicated hook for skins and user CSS
|
|
40
|
-
* (e.g. a Nerd Font for powerline glyphs);
|
|
41
|
-
* 3. `--ds-font-family-code` — the official code-font token several skins
|
|
42
|
-
* already remap;
|
|
43
|
-
* 4. {@link TERMINAL_FONT_FALLBACK}.
|
|
44
|
-
*/
|
|
45
|
-
export declare function resolveTerminalFontFamily(override?: string): string;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Settings reader of the dsh-ssh browser half.
|
|
3
|
-
*
|
|
4
|
-
* The plugin's browser half owns one preference: the xterm `fontFamily` the
|
|
5
|
-
* panel applies to its terminals. Under the 0.1.7 settings model that field
|
|
6
|
-
* belongs to the plugin's own profile entry (its Cordis Config schema), and
|
|
7
|
-
* the browser surface addresses settings as one form per profile entry id — so
|
|
8
|
-
* the entry has to be resolved before its section can be read:
|
|
9
|
-
*
|
|
10
|
-
* - the family binder (`ctx.get('webUiSettings')`, published while
|
|
11
|
-
* dsh-web-settings is loaded) resolves the dsh-ssh namespace to its entry id
|
|
12
|
-
* through the Host bridge and hands back the native shared form;
|
|
13
|
-
* - without that group the shared configuration forms serve the form directly,
|
|
14
|
-
* and the entry is recognised by the one field this plugin's own schema
|
|
15
|
-
* declares: the entry whose resolved section carries `terminalFontFamily`.
|
|
16
|
-
*/
|
|
17
|
-
import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
18
|
-
import type { ConfigForm, ConfigFormSnapshot } from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
19
|
-
/** Domain-owned description of one settings namespace a family surface binds. */
|
|
20
|
-
export interface ConfigFormSpec<T> {
|
|
21
|
-
/** Settings namespace the surface edits. */
|
|
22
|
-
namespace: string;
|
|
23
|
-
/**
|
|
24
|
-
* Narrow one wire section; undefined keeps the section the Host resolved.
|
|
25
|
-
* The shared form already validates against the namespace's serialized
|
|
26
|
-
* schema, so a decoder exists only to narrow beyond it.
|
|
27
|
-
*/
|
|
28
|
-
decode?: (section: unknown) => T | undefined;
|
|
29
|
-
}
|
|
30
|
-
declare module '@deepseek-ai/cordis' {
|
|
31
|
-
interface Context {
|
|
32
|
-
/**
|
|
33
|
-
* Optional family settings binder provided by dsh-web-settings; absent when
|
|
34
|
-
* that group plugin is not installed, so callers fall back to the shared
|
|
35
|
-
* configuration forms service (`ctx.configForms`).
|
|
36
|
-
*/
|
|
37
|
-
webUiSettings?: {
|
|
38
|
-
bind<S>(spec: ConfigFormSpec<S>): ConfigForm<S>;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
/** The read face this plugin needs from its own settings entry. */
|
|
43
|
-
export interface SettingsReader<T> {
|
|
44
|
-
/** @returns the current snapshot (stable reference until the next change). */
|
|
45
|
-
getSnapshot(): ConfigFormSnapshot<T>;
|
|
46
|
-
/** Observe snapshot replacements. */
|
|
47
|
-
subscribe(listener: () => void): () => void;
|
|
48
|
-
}
|
|
49
|
-
/** A reader plus the release of every subscription it installed. */
|
|
50
|
-
export interface SettingsBinding<T> extends SettingsReader<T> {
|
|
51
|
-
/** Release the reader's subscriptions; later calls are no-ops. */
|
|
52
|
-
dispose(): void;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Bind this plugin's settings reader.
|
|
56
|
-
* @param ctx - client context carrying the family binder and/or the shared forms service.
|
|
57
|
-
* @param namespace - the family settings namespace this plugin owns.
|
|
58
|
-
* @param field - the field this plugin's own schema declares, used to recognise its entry when the family binder is absent.
|
|
59
|
-
* @returns the reader and the release of its subscriptions.
|
|
60
|
-
*/
|
|
61
|
-
export declare function bindSettingsReader<T>(ctx: ClientContext, namespace: string, field: string): SettingsBinding<T>;
|
package/lib/types/dsh-home.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DSH_HOME resolution shared by the plugin family's Host halves: the
|
|
3
|
-
* environment override wins, the platform home fallback follows. Mirrors
|
|
4
|
-
* what dsh-pet and dsh-liangshen each used to implement locally.
|
|
5
|
-
*/
|
|
6
|
-
/** Expand a leading ~ (or ~user) in a path, platform-style. */
|
|
7
|
-
export declare function expandHome(path: string, home?: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* Resolve the DSH home directory.
|
|
10
|
-
* @param env - process environment to read DSH_HOME from.
|
|
11
|
-
* @param home - platform home directory fallback (test seam).
|
|
12
|
-
* @returns the absolute DSH home path.
|
|
13
|
-
*/
|
|
14
|
-
export declare function resolveDshHome(env?: NodeJS.ProcessEnv, home?: string): string;
|
|
15
|
-
/** Resolve the DSH home directory from the live environment. */
|
|
16
|
-
export declare function dshHome(): string;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cluster execution: run one command concurrently across selected hosts; the
|
|
3
|
-
* caller must provide at least one non-empty aliases / environment / tags filter.
|
|
4
|
-
*/
|
|
5
|
-
import type { ClusterResult } from '../protocol.ts';
|
|
6
|
-
import { type PoolEngine } from './connection-pool.ts';
|
|
7
|
-
interface ClusterOptions {
|
|
8
|
-
command: string;
|
|
9
|
-
aliases?: string[];
|
|
10
|
-
environment?: string;
|
|
11
|
-
tags?: string[];
|
|
12
|
-
timeoutMs?: number;
|
|
13
|
-
maxWorkers?: number;
|
|
14
|
-
/** Caller cancellation, forwarded to every host's command. */
|
|
15
|
-
signal?: AbortSignal;
|
|
16
|
-
}
|
|
17
|
-
/** Run one command against many hosts concurrently. */
|
|
18
|
-
export declare function cluster(engine: PoolEngine, options: ClusterOptions): Promise<ClusterResult[]>;
|
|
19
|
-
export {};
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Connection pool: per-alias persistent ssh2 connections with multi-hop jump
|
|
3
|
-
* support, the acquire / dispose / sweep lifecycle, and the pooled exec path.
|
|
4
|
-
*/
|
|
5
|
-
import { Client, type ConnectConfig } from 'ssh2';
|
|
6
|
-
import type { ExecResult, SshHostEntry } from '../protocol.ts';
|
|
7
|
-
import { type HostStore } from '../store.ts';
|
|
8
|
-
/** Default engine knobs. */
|
|
9
|
-
export interface EngineOptions {
|
|
10
|
-
/** Connections idle longer than this are closed (ms). */
|
|
11
|
-
idleTimeoutMs?: number;
|
|
12
|
-
/**
|
|
13
|
-
* Ceiling for the whole pre-ready sequence (ms): TCP connect, SSH key
|
|
14
|
-
* exchange and user authentication. Passed to ssh2's `readyTimeout`.
|
|
15
|
-
*/
|
|
16
|
-
connectTimeoutMs?: number;
|
|
17
|
-
/** Keepalive ping interval (ms). */
|
|
18
|
-
keepaliveIntervalMs?: number;
|
|
19
|
-
/** Cap on captured stdout/stderr bytes per exec (ms). */
|
|
20
|
-
maxOutputBytes?: number;
|
|
21
|
-
/** Default exec timeout (ms). */
|
|
22
|
-
defaultExecTimeoutMs?: number;
|
|
23
|
-
/** Default cluster concurrency. */
|
|
24
|
-
defaultMaxWorkers?: number;
|
|
25
|
-
/** SFTP concurrent channel count for transfers. */
|
|
26
|
-
sftpConcurrency?: number;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Default ceiling for TCP connect, SSH key exchange and user authentication
|
|
30
|
-
* together (ms). Password authentication behind PAM / LDAP can outlast the
|
|
31
|
-
* previous 15 s ceiling while the server still eventually accepts it.
|
|
32
|
-
*/
|
|
33
|
-
export declare const DEFAULT_CONNECT_TIMEOUT_MS = 30000;
|
|
34
|
-
/** Default engine knobs (applied when an option is omitted). */
|
|
35
|
-
export declare const DEFAULTS: Required<EngineOptions>;
|
|
36
|
-
/** One pooled connection record. */
|
|
37
|
-
export interface PoolRecord {
|
|
38
|
-
client: Client;
|
|
39
|
-
/** Jump-chain clients kept alive under the target. */
|
|
40
|
-
hops: Client[];
|
|
41
|
-
idleAt: number;
|
|
42
|
-
/** Pinned connections (tunnels) are never swept. */
|
|
43
|
-
pinned: boolean;
|
|
44
|
-
broken: boolean;
|
|
45
|
-
/** Operations currently running on this connection (sweep guard). */
|
|
46
|
-
inFlight: number;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* The slice of the engine the pool and exec paths need. The host class
|
|
50
|
-
* (engine.ts facade) satisfies this structurally.
|
|
51
|
-
*/
|
|
52
|
-
export interface PoolEngine {
|
|
53
|
-
readonly store: HostStore;
|
|
54
|
-
readonly opts: Required<EngineOptions>;
|
|
55
|
-
readonly pool: Map<string, PoolRecord>;
|
|
56
|
-
readonly acquireQueue: Map<string, Promise<PoolRecord>>;
|
|
57
|
-
}
|
|
58
|
-
/** Build the ssh2 connect config for one entry (key read from disk). */
|
|
59
|
-
export declare function buildConnectConfig(entry: SshHostEntry, sock: ConnectConfig['sock'] | undefined, opts: Required<EngineOptions>): ConnectConfig;
|
|
60
|
-
/**
|
|
61
|
-
* The default ssh-agent endpoint on Windows: the named pipe the native
|
|
62
|
-
* OpenSSH ssh-agent service listens on. ssh2 connects to a named pipe for any
|
|
63
|
-
* path matching its Windows pipe form, so the default is a real endpoint
|
|
64
|
-
* rather than a protocol name (#1910). PuTTY Pageant is still reachable — it
|
|
65
|
-
* is what the literal `pageant` agent path selects — but it is no longer the
|
|
66
|
-
* assumption.
|
|
67
|
-
*/
|
|
68
|
-
export declare const WINDOWS_AGENT_PIPE = "\\\\.\\pipe\\openssh-ssh-agent";
|
|
69
|
-
/** Resolve the ssh2 agent path for 'agent' auth. */
|
|
70
|
-
export declare function resolveAgentPath(agentPath?: string): string | undefined;
|
|
71
|
-
/**
|
|
72
|
-
* Resolve the ssh-agent endpoint that forwarding brokers signatures through:
|
|
73
|
-
* an explicitly configured agent path wins, then SSH_AUTH_SOCK, then the
|
|
74
|
-
* native OpenSSH named pipe on Windows. Undefined means no endpoint exists on
|
|
75
|
-
* this machine.
|
|
76
|
-
*
|
|
77
|
-
* Forwarding shares the auth resolution on purpose — the endpoint a host
|
|
78
|
-
* signs through is the same one it authenticates with — but it is a separate
|
|
79
|
-
* name so the forwarding path can evolve without touching auth.
|
|
80
|
-
*/
|
|
81
|
-
export declare function resolveForwardAgentPath(agentPath?: string): string | undefined;
|
|
82
|
-
/** Keyboard-interactive handler callback for 2FA / dynamic prompt flow. */
|
|
83
|
-
export type KeyboardInteractiveHandler = (name: string, instructions: string, instructionsLang: string, prompts: Array<{
|
|
84
|
-
prompt: string;
|
|
85
|
-
echo: boolean;
|
|
86
|
-
}>, finish: (responses: string[]) => void) => void;
|
|
87
|
-
/**
|
|
88
|
-
* Name the phase that actually stalled. ssh2 reports every pre-ready timeout
|
|
89
|
-
* as "Timed out while waiting for handshake", including one that expires
|
|
90
|
-
* during user authentication after a completed key exchange.
|
|
91
|
-
*
|
|
92
|
-
* @param timeoutMs - the configured `readyTimeout` (0 disables it).
|
|
93
|
-
* @param handshakeComplete - whether ssh2 completed the key exchange.
|
|
94
|
-
* @returns the operator-facing timeout message.
|
|
95
|
-
*/
|
|
96
|
-
export declare function readyTimeoutMessage(timeoutMs: number | undefined, handshakeComplete: boolean): string;
|
|
97
|
-
/**
|
|
98
|
-
* Whether ssh2 ended the attempt with its pre-ready timeout. The level is the
|
|
99
|
-
* stable discriminator; the message is reused for connect, key exchange and
|
|
100
|
-
* authentication alike.
|
|
101
|
-
*/
|
|
102
|
-
export declare function isReadyTimeout(error: Error): boolean;
|
|
103
|
-
/** Connect one ssh2 client (resolve on ready, reject on error/close). */
|
|
104
|
-
export declare function connectClient(config: ConnectConfig, onKeyboardInteractive?: KeyboardInteractiveHandler): Promise<Client>;
|
|
105
|
-
/** Cap captured output at the configured byte budget (marks truncation). */
|
|
106
|
-
export declare function appendOutput(target: {
|
|
107
|
-
text: string;
|
|
108
|
-
truncated: boolean;
|
|
109
|
-
}, chunk: Buffer, maxBytes: number): void;
|
|
110
|
-
/**
|
|
111
|
-
* Parse an OpenSSH jump hop written as an address: `[user@]host[:port]`
|
|
112
|
-
* (an IPv6 literal must be bracketed). Returns undefined when the value is not
|
|
113
|
-
* an address at all.
|
|
114
|
-
*/
|
|
115
|
-
export declare function parseJumpSpec(spec: string): {
|
|
116
|
-
host: string;
|
|
117
|
-
port?: number;
|
|
118
|
-
user?: string;
|
|
119
|
-
} | undefined;
|
|
120
|
-
/**
|
|
121
|
-
* Resolve one ProxyJump spec: an alias configured in this plugin wins, and any
|
|
122
|
-
* other value is read as an OpenSSH address whose credentials come from the
|
|
123
|
-
* target entry (an ad-hoc hop has no stored auth of its own).
|
|
124
|
-
*
|
|
125
|
-
* An address hop deliberately carries no forwardAgent flag: OpenSSH's
|
|
126
|
-
* ForwardAgent is a per-Host setting and an ad-hoc address was never
|
|
127
|
-
* configured, so it must never inherit the target's opt-in. A hop written as
|
|
128
|
-
* an alias uses that alias's own entry, which is how a user forwards on a
|
|
129
|
-
* bastion on purpose.
|
|
130
|
-
*/
|
|
131
|
-
export declare function resolveHop(engine: PoolEngine, entry: SshHostEntry, spec: string): SshHostEntry;
|
|
132
|
-
/**
|
|
133
|
-
* Build one full jump chain for an entry: hop clients connected through in
|
|
134
|
-
* order, each forwarding a stream to the next destination, ending with the
|
|
135
|
-
* target client. Shared by the pool and standalone shell sessions.
|
|
136
|
-
*
|
|
137
|
-
* A ProxyCommand is the transport that reaches its own host, so the entry's
|
|
138
|
-
* own command seeds the chain when there is no jump chain, and the first hop's
|
|
139
|
-
* command is used when the hop carries one.
|
|
140
|
-
*/
|
|
141
|
-
export declare function connectChain(engine: PoolEngine, entry: SshHostEntry, onKeyboardInteractive?: KeyboardInteractiveHandler): Promise<{
|
|
142
|
-
client: Client;
|
|
143
|
-
hops: Client[];
|
|
144
|
-
}>;
|
|
145
|
-
/** Connect (or reuse) the pooled chain for one alias; pins nothing. */
|
|
146
|
-
export declare function acquire(engine: PoolEngine, alias: string): Promise<PoolRecord>;
|
|
147
|
-
/**
|
|
148
|
-
* Tear down one alias's record. When `record` is given and no longer the
|
|
149
|
-
* pooled record for the alias (a concurrent acquire replaced it), nothing
|
|
150
|
-
* is torn down — the connection belongs to someone else now.
|
|
151
|
-
*/
|
|
152
|
-
export declare function disposeRecord(engine: PoolEngine, alias: string, record?: PoolRecord): void;
|
|
153
|
-
/** End one record's client and hop chain (best-effort, safe to repeat). */
|
|
154
|
-
export declare function endRecordChain(record: PoolRecord): void;
|
|
155
|
-
/** Close connections idle beyond the threshold (skips pinned and in-flight). */
|
|
156
|
-
export declare function sweepPool(engine: PoolEngine): void;
|
|
157
|
-
/**
|
|
158
|
-
* Run `fn` with a live client for `alias`, reconnecting (up to the
|
|
159
|
-
* attempt budget) when the connection broke mid-flight.
|
|
160
|
-
*/
|
|
161
|
-
export declare function withClient<T>(engine: PoolEngine, alias: string, fn: (client: Client) => Promise<T>, attempts?: number, signal?: AbortSignal): Promise<T>;
|
|
162
|
-
/** Run one command on `alias` (reusing the pooled connection). */
|
|
163
|
-
export declare function execCommand(engine: PoolEngine, alias: string, command: string, timeoutMs?: number, signal?: AbortSignal): Promise<ExecResult>;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenSSH-compatible ProxyCommand transport: run the command with the user's
|
|
3
|
-
* shell and expose its stdio as a Duplex that ssh2 accepts as `sock`.
|
|
4
|
-
*
|
|
5
|
-
* The command comes verbatim from the user's own 0600 store file and runs with
|
|
6
|
-
* the DSH host process's privileges — the same trust the `ssh(1)` client gives
|
|
7
|
-
* the identical line in `~/.ssh/config`.
|
|
8
|
-
*/
|
|
9
|
-
import { type ChildProcess } from 'node:child_process';
|
|
10
|
-
import { Duplex } from 'node:stream';
|
|
11
|
-
/** Token source for one host: the values %h / %p / %r / %n expand to. */
|
|
12
|
-
export interface ProxyTarget {
|
|
13
|
-
host: string;
|
|
14
|
-
port: number;
|
|
15
|
-
user: string;
|
|
16
|
-
/** The name the user addresses this host by (OpenSSH's %n). */
|
|
17
|
-
alias: string;
|
|
18
|
-
}
|
|
19
|
-
/** Expand the OpenSSH ProxyCommand tokens; unknown %X sequences stay verbatim. */
|
|
20
|
-
export declare function expandProxyTokens(command: string, target: ProxyTarget): string;
|
|
21
|
-
/** One running proxy command: its transport plus the process behind it. */
|
|
22
|
-
export interface ProxyCommandProcess {
|
|
23
|
-
/** The duplex transport handed to ssh2 as `sock`. */
|
|
24
|
-
stream: Duplex;
|
|
25
|
-
/** The spawned shell; killing the stream kills it (and its process group). */
|
|
26
|
-
child: ChildProcess;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Start one ProxyCommand and bridge its stdio into a Duplex.
|
|
30
|
-
*
|
|
31
|
-
* Failure modes are reported through the stream: a spawn error, or an exit
|
|
32
|
-
* before the SSH handshake finished, destroys it with the exit status and the
|
|
33
|
-
* tail of the command's stderr instead of letting ssh2 wait for its own
|
|
34
|
-
* `readyTimeout`.
|
|
35
|
-
*/
|
|
36
|
-
export declare function startProxyCommand(rawCommand: string, target: ProxyTarget): ProxyCommandProcess;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PTY shell sessions for the web terminal: a standalone (non-pooled)
|
|
3
|
-
* ssh2 connection with a long-lived shell channel, resize, and pausable
|
|
4
|
-
* output delivery.
|
|
5
|
-
*/
|
|
6
|
-
import { type KeyboardInteractiveHandler, type PoolEngine } from './connection-pool.ts';
|
|
7
|
-
/** A live PTY shell session. */
|
|
8
|
-
export interface ShellSession {
|
|
9
|
-
/** Assign to receive remote output. */
|
|
10
|
-
onData?: (data: Buffer) => void;
|
|
11
|
-
/** Assign to be notified when the channel closes. */
|
|
12
|
-
onExit?: (code: number | null, error?: string) => void;
|
|
13
|
-
/** Write raw input to the shell. */
|
|
14
|
-
send(data: string): void;
|
|
15
|
-
/** Resize the remote PTY. */
|
|
16
|
-
resize(cols: number, rows: number): void;
|
|
17
|
-
/** Close the session and its channel. */
|
|
18
|
-
close(): void;
|
|
19
|
-
/** Pause remote output delivery (transport backpressure). */
|
|
20
|
-
pause(): void;
|
|
21
|
-
/** Resume remote output delivery. */
|
|
22
|
-
resume(): void;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Open a PTY shell session for the web terminal (standalone connection).
|
|
26
|
-
* The shell is a long-lived exclusive stream: it uses its own connection so
|
|
27
|
-
* closing it can never tear down a pooled exec/tunnel sharing the alias.
|
|
28
|
-
*/
|
|
29
|
-
export declare function openShell(engine: PoolEngine, alias: string, size: {
|
|
30
|
-
cols: number;
|
|
31
|
-
rows: number;
|
|
32
|
-
}, onKeyboardInteractive?: KeyboardInteractiveHandler): Promise<ShellSession>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SFTP transfers: upload (file or recursive tree), single-file download, and
|
|
3
|
-
* remote directory listing. Every channel is opened once per operation and
|
|
4
|
-
* released exactly once so sshd's MaxSessions cap is never exhausted.
|
|
5
|
-
*/
|
|
6
|
-
import type { RemoteDirEntry, TransferProgress } from '../protocol.ts';
|
|
7
|
-
import { type PoolEngine } from './connection-pool.ts';
|
|
8
|
-
/** Walk a local directory, collecting relative paths of every file. */
|
|
9
|
-
export declare function walkLocalDir(root: string): string[];
|
|
10
|
-
/** Upload one local file (or directory tree) to a remote path. */
|
|
11
|
-
export declare function upload(engine: PoolEngine, alias: string, localPath: string, remotePath: string, recursive: boolean, onProgress?: (progress: TransferProgress) => void): Promise<{
|
|
12
|
-
bytes: number;
|
|
13
|
-
files: number;
|
|
14
|
-
}>;
|
|
15
|
-
/** Download one remote file to a local path. */
|
|
16
|
-
export declare function download(engine: PoolEngine, alias: string, remotePath: string, localPath: string, onProgress?: (progress: TransferProgress) => void): Promise<{
|
|
17
|
-
bytes: number;
|
|
18
|
-
}>;
|
|
19
|
-
/** List a remote directory (file browser). */
|
|
20
|
-
export declare function ls(engine: PoolEngine, alias: string, path: string): Promise<RemoteDirEntry[]>;
|