@fish-under-sea/dsh-ssh-fish 1.0.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/NOTICE +1 -1
  2. package/README.en.md +7 -5
  3. package/README.md +7 -5
  4. package/README.zh.md +7 -5
  5. package/icon.png +0 -0
  6. package/lib/client.js +783 -170
  7. package/lib/client.js.map +1 -1
  8. package/lib/index.js +128 -14
  9. package/lib/types/client/api.d.ts +21 -0
  10. package/lib/types/client/locales.d.ts +13 -2
  11. package/lib/types/client/panel/TerminalTab.d.ts +12 -7
  12. package/lib/types/client/panel/controller.d.ts +185 -21
  13. package/lib/types/engine/connection-pool.d.ts +52 -1
  14. package/lib/types/engine.d.ts +7 -0
  15. package/lib/types/index.d.ts +10 -0
  16. package/lib/types/loopback.d.ts +41 -1
  17. package/lib/types/protocol.d.ts +18 -1
  18. package/lib/types/store.d.ts +7 -0
  19. package/lib/types/tool-surface.d.ts +1 -0
  20. package/lib/types/tools.d.ts +1 -0
  21. package/locale/en.json +6 -0
  22. package/locale/zh.json +6 -0
  23. package/package.json +25 -22
  24. package/src/client/api.ts +70 -0
  25. package/src/client/index.ts +1 -2
  26. package/src/client/locales.ts +26 -4
  27. package/src/client/panel/HostFormDialog.tsx +16 -2
  28. package/src/client/panel/HostsTab.tsx +3 -0
  29. package/src/client/panel/SshPanel.tsx +7 -15
  30. package/src/client/panel/TerminalTab.tsx +371 -151
  31. package/src/client/panel/controller.ts +370 -30
  32. package/src/client/panel/panel.module.css +108 -0
  33. package/src/client/settings-binding.ts +0 -1
  34. package/src/engine/connection-pool.ts +96 -4
  35. package/src/engine.ts +10 -0
  36. package/src/index.ts +16 -1
  37. package/src/loopback.ts +57 -1
  38. package/src/protocol.ts +18 -1
  39. package/src/routes.ts +4 -1
  40. package/src/store.ts +26 -0
  41. package/src/tool-surface.ts +1 -0
  42. package/src/tools.ts +9 -4
  43. package/icon.svg +0 -3
@@ -5,31 +5,82 @@
5
5
  * style) so the sidebar row and the React panel share one tiny subscription
6
6
  * surface. The state lives only for the browser session (no persistence).
7
7
  *
8
- * The active tab, the hosts-tab connect request and the live terminal session
9
- * id live here rather than inside the panel components: the layout mounts a
10
- * keyed page only while its panel is selected, so component-local state would
11
- * reset the tab on every panel switch and lose the id a reattach needs.
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).
12
21
  */
22
+ import type { TerminalConnection } from '../api.ts';
13
23
  /** The panel's tab identifiers. */
14
24
  export type SshTab = 'hosts' | 'terminal' | 'transfer' | 'tunnels' | 'cluster';
15
- /** A "connect" action from the hosts tab, handed to the terminal tab. */
16
- export interface ConnectRequest {
17
- alias: string;
18
- /** Monotonic id so a repeated connect for the same alias still re-applies. */
19
- nonce: number;
20
- }
21
25
  /** Stable id shared by the sidebar panel row and the main-slot page. */
22
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';
23
72
  /** Immutable controller snapshot for UI subscriptions. */
24
73
  export interface PanelControllerSnapshot {
25
74
  /** Whether the center column shows this panel. */
26
75
  panelOpen: boolean;
27
76
  /** The tab the panel is showing. */
28
77
  activeTab: SshTab;
29
- /** Pending hosts-tab connect request, or null. */
30
- connectRequest: ConnectRequest | null;
31
- /** Host-side terminal session the terminal tab should reattach to, if any. */
32
- terminalSessionId: string | undefined;
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;
33
84
  }
34
85
  /**
35
86
  * The layout's panel-navigation face: selecting the panel is the layout's
@@ -51,9 +102,23 @@ export declare class PanelController {
51
102
  private readonly deps;
52
103
  private panelOpen;
53
104
  private activeTab;
54
- private connectRequest;
55
- private terminalSessionId;
105
+ private terminalTabs;
106
+ private activeTerminalTabId;
107
+ private draftAlias;
108
+ private nextTerminalTabSeq;
56
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;
57
122
  /** Cached so getSnapshot is referentially stable between changes. */
58
123
  private snapshot;
59
124
  constructor(deps?: PanelControllerDeps);
@@ -77,12 +142,111 @@ export declare class PanelController {
77
142
  syncPanelSelection(panelId: string | null): void;
78
143
  /** Switch tabs, keeping every other piece of view state. */
79
144
  setActiveTab(tab: SshTab): void;
80
- /** Hand the terminal tab a host to connect to (hosts-tab "connect" action). */
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
+ */
81
151
  requestConnect(alias: string): void;
82
- /** Record the host-side session so a later page mount can reattach. */
83
- setTerminalSession(sessionId: string): void;
84
- /** Forget the session (it exited, or the user disconnected). */
85
- clearTerminalSession(): 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;
86
250
  private commit;
87
251
  /** Ask the layout to select a panel; a shell without the face is a no-op. */
88
252
  private selectPanel;
@@ -9,7 +9,10 @@ import { type HostStore } from '../store.ts';
9
9
  export interface EngineOptions {
10
10
  /** Connections idle longer than this are closed (ms). */
11
11
  idleTimeoutMs?: number;
12
- /** SSH handshake timeout (ms). */
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
+ */
13
16
  connectTimeoutMs?: number;
14
17
  /** Keepalive ping interval (ms). */
15
18
  keepaliveIntervalMs?: number;
@@ -22,6 +25,12 @@ export interface EngineOptions {
22
25
  /** SFTP concurrent channel count for transfers. */
23
26
  sftpConcurrency?: number;
24
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;
25
34
  /** Default engine knobs (applied when an option is omitted). */
26
35
  export declare const DEFAULTS: Required<EngineOptions>;
27
36
  /** One pooled connection record. */
@@ -48,13 +57,49 @@ export interface PoolEngine {
48
57
  }
49
58
  /** Build the ssh2 connect config for one entry (key read from disk). */
50
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";
51
69
  /** Resolve the ssh2 agent path for 'agent' auth. */
52
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;
53
82
  /** Keyboard-interactive handler callback for 2FA / dynamic prompt flow. */
54
83
  export type KeyboardInteractiveHandler = (name: string, instructions: string, instructionsLang: string, prompts: Array<{
55
84
  prompt: string;
56
85
  echo: boolean;
57
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;
58
103
  /** Connect one ssh2 client (resolve on ready, reject on error/close). */
59
104
  export declare function connectClient(config: ConnectConfig, onKeyboardInteractive?: KeyboardInteractiveHandler): Promise<Client>;
60
105
  /** Cap captured output at the configured byte budget (marks truncation). */
@@ -76,6 +121,12 @@ export declare function parseJumpSpec(spec: string): {
76
121
  * Resolve one ProxyJump spec: an alias configured in this plugin wins, and any
77
122
  * other value is read as an OpenSSH address whose credentials come from the
78
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.
79
130
  */
80
131
  export declare function resolveHop(engine: PoolEngine, entry: SshHostEntry, spec: string): SshHostEntry;
81
132
  /**
@@ -31,6 +31,13 @@ export declare class SshEngine {
31
31
  * @param options - engine knobs (defaults applied).
32
32
  */
33
33
  constructor(store: HostStore, options?: EngineOptions);
34
+ /**
35
+ * Change the pre-ready ceiling (TCP connect + key exchange + user
36
+ * authentication) for connections opened from now on. A pooled connection
37
+ * keeps serving until it reconnects, because the ceiling governs the
38
+ * connect path only.
39
+ */
40
+ setConnectTimeout(timeoutMs: number): void;
34
41
  /** Secret-free host list (filtered by the optional query). */
35
42
  list(query?: string): SshHostSummary[];
36
43
  /** One host summary by alias. */
@@ -40,6 +40,13 @@ export interface Config {
40
40
  * Nerd Font stack here to render powerline/Nerd glyphs.
41
41
  */
42
42
  terminalFontFamily?: string;
43
+ /**
44
+ * Ceiling for the whole pre-ready SSH sequence in milliseconds: TCP
45
+ * connect, key exchange and user authentication (default 30000). Raise it
46
+ * for hosts whose password authentication is slow (for example PAM / LDAP
47
+ * behind a distant directory service).
48
+ */
49
+ connectTimeoutMs?: number;
43
50
  }
44
51
  /** The stable reference a `volatile()` config field resolves to; its owner updates it in place. */
45
52
  interface ConfigRef<T> {
@@ -53,6 +60,7 @@ export interface ResolvedConfig {
53
60
  announceToAgent?: ConfigField<boolean>;
54
61
  enabled?: ConfigField<boolean>;
55
62
  terminalFontFamily?: ConfigField<string>;
63
+ connectTimeoutMs?: ConfigField<number>;
56
64
  }
57
65
  /**
58
66
  * Plugin config schema. Under the 0.1.7 settings model this schema IS the
@@ -66,10 +74,12 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
66
74
  announceToAgent: z<boolean, boolean, "volatile-defined">;
67
75
  enabled: z<boolean, boolean, "volatile-defined">;
68
76
  terminalFontFamily: z<string, string, "volatile-defined">;
77
+ connectTimeoutMs: z<number, number, "volatile-defined">;
69
78
  }>>, Schemastery.ObjectT<NoInfer<{
70
79
  announceToAgent: z<boolean, boolean, "volatile-defined">;
71
80
  enabled: z<boolean, boolean, "volatile-defined">;
72
81
  terminalFontFamily: z<string, string, "volatile-defined">;
82
+ connectTimeoutMs: z<number, number, "volatile-defined">;
73
83
  }>>, "plain">;
74
84
  /** Model-facing announcement: plugin presence, capabilities, and limits. */
75
85
  export declare const SSH_GUIDANCE = "\u672C\u673A\u5DF2\u5B89\u88C5 dsh-ssh \u63D2\u4EF6\uFF08DSH \u8FDC\u7A0B SSH \u8FD0\u7EF4\uFF09\uFF1A\u4FA7\u8FB9\u680F\u300CSSH\u300D\u5165\u53E3\uFF1B\u5728 dsh-web \u63D2\u4EF6\u5168\u5BB6\u6876\u4ED3\u5E93\uFF08packages/dsh-ssh\uFF09\u7EDF\u4E00\u7EF4\u62A4\u3002\u80FD\u529B\uFF1A\u4E3B\u673A\u914D\u7F6E\u5B58 $DSH_HOME/dsh-ssh.json\uFF08\u9ED8\u8BA4 ~/.dsh\uFF09\uFF08\u53EF\u4ECE ~/.ssh/config \u5BFC\u5165\uFF09\uFF1B\u6301\u4E45\u8FDE\u63A5\u6C60\u590D\u7528\u957F\u8FDE\u63A5\uFF08\u7A7A\u95F2 30 \u5206\u949F\u81EA\u52A8\u65AD\u5F00\uFF09\uFF1Bssh_list \u5217\u51FA\u4E3B\u673A\u3001ssh_exec \u6267\u884C\u8FDC\u7A0B\u547D\u4EE4\u3001ssh_upload/ssh_download \u4F20\u8F93\u6587\u4EF6\u3001ssh_tunnel \u672C\u5730\u7AEF\u53E3\u8F6C\u53D1\uFF08\u8BBF\u95EE\u8FDC\u7A0B\u6570\u636E\u5E93/\u5185\u7F51\u670D\u52A1\uFF09\u3001ssh_cluster \u6309 aliases/environment/tags \u81F3\u5C11\u4E00\u79CD\u975E\u7A7A selector \u7B5B\u9009\u540E\u96C6\u7FA4\u5E76\u53D1\u6267\u884C\uFF1B\u652F\u6301\u5BC6\u94A5/\u5BC6\u7801/ssh-agent \u8BA4\u8BC1\u3001passphrase \u5BC6\u94A5\u3001ProxyJump \u8DF3\u677F\u673A\uFF08\u522B\u540D\u6216 [user@]host[:port] \u5730\u5740\uFF09\u4E0E OpenSSH \u8BED\u4E49\u7684 ProxyCommand\uFF08\u8DF3\u8FC7\u5821\u5792\u673A\u5BA2\u6237\u7AEF\u573A\u666F\uFF0C\u53EA\u80FD\u7531\u7528\u6237\u5728 GUI \u914D\u7F6E\uFF0Cagent \u4E0D\u53EF\u5199\uFF09\uFF1BWeb \u7EC8\u7AEF\u8D70 WebSocket\u3002\u9650\u5236\uFF1A\u4E3B\u673A\u64CD\u4F5C\u7531\u7528\u6237\u5728 GUI \u4E2D\u914D\u7F6E\u540E agent \u65B9\u53EF\u4F7F\u7528\uFF1B\u5BC6\u7801\u4EE5\u660E\u6587\u5B58\u5728\u7528\u6237\u4E3B\u76EE\u5F55\u79C1\u6709\u6587\u4EF6\uFF08\u6743\u9650 0600\uFF09\uFF1B\u547D\u4EE4\u8F93\u51FA\u539F\u6837\u8FD4\u56DE\u3001\u53EF\u80FD\u542B\u654F\u611F\u4FE1\u606F\uFF1B\u65AD\u7EBF\u91CD\u8FDE\u53EF\u80FD\u91CD\u653E\u975E\u5E42\u7B49\u547D\u4EE4\uFF1B\u4F20\u8F93/\u6267\u884C\u6D88\u8017\u771F\u5B9E\u8FDC\u7A0B\u8D44\u6E90\uFF0C\u5148\u786E\u8BA4\u518D\u64CD\u4F5C\u3002\u8DEF\u5F84\u533A\u5206\uFF1A\u672C\u673A\uFF08dsh host\uFF09\u4E0A\u7684\u6587\u4EF6\u4E0E\u547D\u4EE4\u4E00\u5F8B\u7528\u672C\u5730\u5DE5\u5177\uFF08read / write / edit / bash\uFF09\uFF0Cssh_* \u5DE5\u5177\u53EA\u9488\u5BF9\u8FDC\u7A0B\u4E3B\u673A\u4E0A\u7684\u8DEF\u5F84\u3002\u7528\u6237\u63D0\u5230\u300CSSH / \u8FDC\u7A0B\u670D\u52A1\u5668 / \u670D\u52A1\u5668\u64CD\u4F5C / \u8DF3\u677F\u673A / \u96A7\u9053 / \u90E8\u7F72 / \u4E0A\u4F20\u4E0B\u8F7D\u300D\u65F6\u5373\u6307\u672C\u63D2\u4EF6\uFF0C\u8BF7\u636E\u6B64\u534F\u4F5C\u3002";
@@ -7,6 +7,19 @@
7
7
  * Semantics: RFC 5735 IPv4 127/8, ::1, IPv4-mapped ::ffff:127/8 (matching the
8
8
  * remote-web-ui gate), localhost hostnames, plus the browser same-origin
9
9
  * markers (sec-fetch-site and Origin) for the request-level fence.
10
+ *
11
+ * A reverse proxy in front of the host rewrites the Host header to its own
12
+ * upstream literal (a Cloudflare tunnel, frp and an nginx reverse proxy all
13
+ * dial 127.0.0.1:<port>), and the socket the origin sees is the proxy's, which
14
+ * is loopback by construction. Both halves of the fence then hold for a public
15
+ * request. Forwarding headers are the signal that a hop stands in between: a
16
+ * request that carries CF-Connecting-IP or X-Forwarded-For is answered through
17
+ * a proxy and is never treated as a local one (issue #1906).
18
+ *
19
+ * An operator who runs that proxy or tunnel themselves can opt into the
20
+ * narrower case: isForwardedLoopbackRequest describes a forwarded request that
21
+ * still landed on this machine's loopback upstream, and a route family admits
22
+ * it only behind its own default-off switch (issue #1918).
10
23
  * @module dsh-web-shared/host/loopback
11
24
  */
12
25
  import type { IncomingMessage } from 'node:http';
@@ -16,9 +29,36 @@ export declare function isIPv4Loopback(v4: string): boolean;
16
29
  export declare function isLoopbackAddress(address: string | undefined): boolean;
17
30
  /** Whether a normalized URL hostname names the loopback authority (localhost, [::1], 127/8). */
18
31
  export declare function isLoopbackHostname(hostname: string): boolean;
32
+ /**
33
+ * Whether a reverse proxy stood between the client and this host: the request
34
+ * carries CF-Connecting-IP or X-Forwarded-For. Either header is stamped by a
35
+ * hop that forwards traffic, so the request did not originate on this machine.
36
+ * @param request - node HTTP request.
37
+ * @returns true when a forwarding header is present.
38
+ */
39
+ export declare function isProxiedRequest(request: IncomingMessage): boolean;
19
40
  /**
20
41
  * Request-level trust fence: a loopback socket address AND a loopback Host
21
42
  * header, plus browser same-origin markers. The socket address is
22
- * authoritative; X-Forwarded-For is never trusted.
43
+ * authoritative for a direct connection; a request that carries a forwarding
44
+ * header is refused outright, because a proxy in front of the host makes both
45
+ * the socket address and the Host header describe the proxy rather than the
46
+ * client. X-Forwarded-For is therefore never evidence *for* loopback.
23
47
  */
24
48
  export declare function isLoopbackRequest(request: IncomingMessage): boolean;
49
+ /**
50
+ * Whether a forwarded request landed on this machine's loopback upstream: a
51
+ * forwarding header (the proxy's own stamp), a loopback socket address (the
52
+ * proxy dials 127.0.0.1:<port>), and a loopback Host header (the proxy rewrote
53
+ * the authority to its upstream literal).
54
+ *
55
+ * This is a fact about the route, not a trust decision. A public request to a
56
+ * tunnel satisfies all three by construction, because the proxy is the client
57
+ * of this process: only a caller that operates the proxy can decide it stands
58
+ * for the browser, which is why every consumer keeps this behind an explicit
59
+ * default-off switch and its own browser markers. isLoopbackRequest is
60
+ * unchanged and still refuses a forwarded request (issue #1906).
61
+ * @param request - node HTTP request.
62
+ * @returns true when a forwarding header, a loopback socket, and a loopback Host all hold.
63
+ */
64
+ export declare function isForwardedLoopbackRequest(request: IncomingMessage): boolean;
@@ -27,7 +27,7 @@ export interface SshHostEntry {
27
27
  /**
28
28
  * ssh-agent endpoint for 'agent' auth. A socket path, the special value
29
29
  * 'pageant' (PuTTY Pageant on Windows), or undefined for auto-detect
30
- * (SSH_AUTH_SOCK, then Pageant on Windows).
30
+ * (SSH_AUTH_SOCK, then the native OpenSSH named pipe on Windows).
31
31
  */
32
32
  agentPath?: string;
33
33
  };
@@ -48,6 +48,12 @@ export interface SshHostEntry {
48
48
  tags: string[];
49
49
  /** Physical location note. */
50
50
  location?: string;
51
+ /**
52
+ * Opt-in ssh-agent forwarding (OpenSSH ForwardAgent / ssh -A): the host's
53
+ * sessions request agent forwarding so the remote can sign with this
54
+ * machine's agent. Default off; stored only when enabled.
55
+ */
56
+ forwardAgent?: boolean;
51
57
  createdAt: number;
52
58
  updatedAt: number;
53
59
  }
@@ -67,6 +73,12 @@ export interface SshHostSummary {
67
73
  environment?: string;
68
74
  tags: string[];
69
75
  location?: string;
76
+ /**
77
+ * Whether agent forwarding is enabled. Always projected as a definite
78
+ * boolean: the browser and the tool bridge need a value even for entries
79
+ * stored before the feature existed.
80
+ */
81
+ forwardAgent: boolean;
70
82
  createdAt: number;
71
83
  updatedAt: number;
72
84
  }
@@ -150,6 +162,11 @@ export interface HostPayload {
150
162
  environment?: string;
151
163
  tags?: string[];
152
164
  location?: string;
165
+ /**
166
+ * Agent forwarding for this host. Omitted on update keeps the stored value;
167
+ * false clears it (PATCH semantics).
168
+ */
169
+ forwardAgent?: boolean;
153
170
  }
154
171
  /** Why one ssh_config Host block was not imported. */
155
172
  export type ImportSkipReason = 'wildcard' | 'existing' | 'match' | 'invalid';
@@ -67,5 +67,12 @@ export declare function normalizeAgentPath(agentPath: string | undefined): strin
67
67
  * OpenSSH's `none` keyword as "no proxy command" (an explicit clear).
68
68
  */
69
69
  export declare function normalizeProxyCommand(raw: string | undefined): string | undefined;
70
+ /**
71
+ * Read an ssh_config `ForwardAgent` value into the stored boolean flag. Only
72
+ * an explicit yes/true/on enables forwarding; an absent value, no/false/off,
73
+ * and anything unrecognized leave it off instead of failing the import — an
74
+ * unknown keyword must never cost the user the whole Host block.
75
+ */
76
+ export declare function parseForwardAgentValue(raw: string | undefined): boolean;
70
77
  /** Expand a leading `~` in a filesystem path. */
71
78
  export declare function expandHome(path: string): string;
@@ -30,6 +30,7 @@
30
30
  export declare const PLUGIN_TOOL_SECTION_ORDERS: {
31
31
  readonly ssh: 150;
32
32
  readonly 'task-board': 200;
33
+ readonly agents: 220;
33
34
  };
34
35
  /** One plugin id keyed by {@link PLUGIN_TOOL_SECTION_ORDERS}. */
35
36
  export type PluginToolSectionId = keyof typeof PLUGIN_TOOL_SECTION_ORDERS;
@@ -19,6 +19,7 @@ export interface AgentHostRow {
19
19
  keyReady: boolean;
20
20
  proxyJump: string[];
21
21
  proxyCommandConfigured: boolean;
22
+ forwardAgent: boolean;
22
23
  description?: string;
23
24
  environment?: string;
24
25
  tags: string[];
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "SSH terminal",
4
+ "description": "Run commands and transfer files on remote hosts."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "SSH 终端",
4
+ "description": "连远程主机执行命令并传文件"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@fish-under-sea/dsh-ssh-fish",
3
3
  "description": "Remote SSH operations for the dsh web GUI: host config store (~/.dsh/dsh-ssh.json, import from ~/.ssh/config), a persistent ssh2 connection pool with jump-host support, exec / PTY web terminal / SFTP transfer / local port-forward tunnels / cluster execution, plus agent tools (ssh_list, ssh_exec, ssh_upload, ssh_download, ssh_tunnel, ssh_cluster). Hot-pluggable — mounted via ~/.dsh/cordis.patch.yml + a profile node_modules symlink, no dsh source changes.",
4
- "version": "1.0.2",
5
- "icon": "icon.svg",
4
+ "version": "2.0.0",
5
+ "icon": "./icon.png",
6
6
  "type": "module",
7
7
  "packageManager": "pnpm@11.7.0",
8
8
  "engines": {
9
- "node": "^22.19.0 || >=24.0.0"
9
+ "node": ">=24.9.0"
10
10
  },
11
11
  "main": "lib/index.js",
12
12
  "types": "lib/types/index.d.ts",
@@ -20,11 +20,13 @@
20
20
  "default": "./lib/client.js"
21
21
  },
22
22
  "./src/*": "./src/*",
23
+ "./locale/en.json": "./locale/en.json",
24
+ "./locale/zh.json": "./locale/zh.json",
23
25
  "./package.json": "./package.json"
24
26
  },
25
27
  "dsh": {
26
28
  "engines": {
27
- "dsh": ">=0.2.0-rc.2"
29
+ "dsh": ">=0.2.2-rc.1"
28
30
  },
29
31
  "bundle": {
30
32
  "patch": "./cordis.patch.yml"
@@ -46,33 +48,33 @@
46
48
  "typecheck": "tsc --noEmit"
47
49
  },
48
50
  "dependencies": {
49
- "@deepseek-ai/schemastery": "^3.18.4",
51
+ "@deepseek-ai/schemastery": "^3.19.0",
50
52
  "@xterm/addon-fit": "^0.11.0",
51
53
  "@xterm/xterm": "^6.0.0",
52
54
  "ssh2": "^1.17.0",
53
55
  "ws": "^8.18.0"
54
56
  },
55
57
  "peerDependencies": {
56
- "@deepseek-ai/dsh": ">=0.2.0-rc.2",
58
+ "@deepseek-ai/dsh": ">=0.2.2-rc.1",
57
59
  "react": "^18.2.0",
58
60
  "react-dom": "^18.2.0"
59
61
  },
60
62
  "devDependencies": {
61
- "@deepseek-ai/cordis": "^4.0.4",
62
- "@deepseek-ai/dsh-client-connection": "^0.2.0-rc.2",
63
- "@deepseek-ai/dsh-client-locale": "^0.2.0-rc.2",
64
- "@deepseek-ai/dsh-client-ui-renderer": "^0.2.0-rc.2",
65
- "@deepseek-ai/dsh-client-ui-layout": "^0.2.0-rc.2",
66
- "@deepseek-ai/dsh-client-ui-settings": "^0.2.0-rc.2",
67
- "@deepseek-ai/dsh-client-ui-sidebar": "^0.2.0-rc.2",
68
- "@deepseek-ai/dsh-client-ui-slots": "^0.2.0-rc.2",
69
- "@deepseek-ai/dsh-host-webserver": "^0.2.0-rc.2",
70
- "@deepseek-ai/dsh-llm": "^0.2.0-rc.2",
71
- "@deepseek-ai/dsh-scope": "^0.2.0-rc.2",
72
- "@deepseek-ai/dsh-settings": "^0.2.0-rc.2",
73
- "@deepseek-ai/dsh-system-prompt": "^0.2.0-rc.2",
74
- "@deepseek-ai/dsh-timeout": "^0.2.0-rc.2",
75
- "@deepseek-ai/dsh-tools": "^0.2.0-rc.2",
63
+ "@deepseek-ai/cordis": "^4.1.0",
64
+ "@deepseek-ai/dsh-client-connection": "^0.2.2-rc.1",
65
+ "@deepseek-ai/dsh-client-locale": "^0.2.2-rc.1",
66
+ "@deepseek-ai/dsh-client-ui-layout": "^0.2.2-rc.1",
67
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.2.2-rc.1",
68
+ "@deepseek-ai/dsh-client-ui-settings": "^0.2.2-rc.1",
69
+ "@deepseek-ai/dsh-client-ui-sidebar": "^0.2.2-rc.1",
70
+ "@deepseek-ai/dsh-client-ui-slots": "^0.2.2-rc.1",
71
+ "@deepseek-ai/dsh-host-webserver": "^0.2.2-rc.1",
72
+ "@deepseek-ai/dsh-llm": "^0.2.2-rc.1",
73
+ "@deepseek-ai/dsh-scope": "^0.2.2-rc.1",
74
+ "@deepseek-ai/dsh-settings": "^0.2.2-rc.1",
75
+ "@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.1",
76
+ "@deepseek-ai/dsh-timeout": "^0.2.2-rc.1",
77
+ "@deepseek-ai/dsh-tools": "^0.2.2-rc.1",
76
78
  "@types/node": "^22.20.0",
77
79
  "@types/react": "~18.3.1",
78
80
  "@types/react-dom": "^18.3.5",
@@ -94,7 +96,8 @@
94
96
  "src",
95
97
  "cordis.patch.yml",
96
98
  "README.md",
97
- "icon.svg",
99
+ "icon.png",
100
+ "locale",
98
101
  "README.en.md",
99
102
  "LICENSE",
100
103
  "NOTICE"