@fish-under-sea/dsh-ssh-fish 0.0.0-stage → 0.5.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/LICENSE +202 -0
- package/README.i18n.yaml +6 -0
- package/README.md +98 -2
- package/README.zh.md +99 -0
- package/cordis.patch.yml +12 -0
- package/icon.svg +3 -0
- package/lib/client.js +16487 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +3511 -0
- package/lib/types/client/api.d.ts +141 -0
- package/lib/types/client/index.d.ts +37 -0
- package/lib/types/client/locales.d.ts +164 -0
- package/lib/types/client/native-panel.d.ts +70 -0
- package/lib/types/client/panel/ClusterTab.d.ts +7 -0
- package/lib/types/client/panel/HostFormDialog.d.ts +12 -0
- package/lib/types/client/panel/HostsTab.d.ts +25 -0
- package/lib/types/client/panel/SshPanel.d.ts +14 -0
- package/lib/types/client/panel/TerminalTab.d.ts +22 -0
- package/lib/types/client/panel/TransferTab.d.ts +7 -0
- package/lib/types/client/panel/TunnelsTab.d.ts +19 -0
- package/lib/types/client/panel/controller.d.ts +89 -0
- package/lib/types/client/panel/helpers.d.ts +45 -0
- package/lib/types/client/panel/xterm.css.d.ts +2 -0
- package/lib/types/client/settings-binding.d.ts +61 -0
- package/lib/types/dsh-home.d.ts +16 -0
- package/lib/types/engine/cluster.d.ts +19 -0
- package/lib/types/engine/connection-pool.d.ts +112 -0
- package/lib/types/engine/proxy-command.d.ts +36 -0
- package/lib/types/engine/pty.d.ts +32 -0
- package/lib/types/engine/sftp.d.ts +20 -0
- package/lib/types/engine/terminal-sessions.d.ts +67 -0
- package/lib/types/engine/tunnel.d.ts +36 -0
- package/lib/types/engine.d.ts +89 -0
- package/lib/types/http.d.ts +59 -0
- package/lib/types/index.d.ts +83 -0
- package/lib/types/loopback.d.ts +24 -0
- package/lib/types/mount-once.d.ts +55 -0
- package/lib/types/protocol.d.ts +239 -0
- package/lib/types/routes.d.ts +33 -0
- package/lib/types/ssh-config.d.ts +34 -0
- package/lib/types/store.d.ts +71 -0
- package/lib/types/tool-surface.d.ts +71 -0
- package/lib/types/tools.d.ts +42 -0
- package/package.json +106 -4
- package/src/client/api.ts +562 -0
- package/src/client/css-modules.d.ts +5 -0
- package/src/client/index.ts +137 -0
- package/src/client/locales.ts +338 -0
- package/src/client/native-panel.tsx +141 -0
- package/src/client/panel/ClusterTab.tsx +123 -0
- package/src/client/panel/HostFormDialog.tsx +258 -0
- package/src/client/panel/HostsTab.tsx +325 -0
- package/src/client/panel/SshPanel.tsx +90 -0
- package/src/client/panel/TerminalTab.tsx +330 -0
- package/src/client/panel/TransferTab.tsx +232 -0
- package/src/client/panel/TunnelsTab.tsx +244 -0
- package/src/client/panel/controller.ts +167 -0
- package/src/client/panel/helpers.ts +84 -0
- package/src/client/panel/panel.module.css +876 -0
- package/src/client/panel/xterm.css.ts +2 -0
- package/src/client/settings-binding.ts +165 -0
- package/src/dsh-home.ts +42 -0
- package/src/engine/cluster.ts +60 -0
- package/src/engine/connection-pool.ts +543 -0
- package/src/engine/proxy-command.ts +248 -0
- package/src/engine/pty.ts +78 -0
- package/src/engine/sftp.ts +226 -0
- package/src/engine/terminal-sessions.ts +280 -0
- package/src/engine/tunnel.ts +194 -0
- package/src/engine.ts +176 -0
- package/src/http.ts +127 -0
- package/src/index.ts +234 -0
- package/src/loopback.ts +63 -0
- package/src/mount-once.ts +142 -0
- package/src/protocol.ts +230 -0
- package/src/routes.ts +494 -0
- package/src/ssh-config.ts +153 -0
- package/src/store.ts +419 -0
- package/src/tool-surface.ts +95 -0
- package/src/tools.ts +404 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-side API client for the /api/dsh-ssh route family. The only data
|
|
3
|
+
* access path the panel components use — plain fetch/WebSocket, same origin.
|
|
4
|
+
*/
|
|
5
|
+
import { type ClusterResult, type ExecResult, type HostPayload, type ImportResult, type RemoteDirEntry, type SshHostSummary, type TestResult, type TransferProgress, type TunnelInfo } from '../protocol.ts';
|
|
6
|
+
/** Error carrying the route's JSON error message. */
|
|
7
|
+
export declare class SshApiError extends Error {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
/** The location facts a terminal socket URL is built from. */
|
|
11
|
+
interface PageLocation {
|
|
12
|
+
/** Page scheme with its colon (for example `https:` or `dsh-app:`). */
|
|
13
|
+
protocol: string;
|
|
14
|
+
/** Page authority, empty for a scheme that carries none. */
|
|
15
|
+
host: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The WebSocket URL the terminal route is reached at, or undefined when this
|
|
19
|
+
* page cannot carry one.
|
|
20
|
+
*
|
|
21
|
+
* A web page resolves the socket against its own origin, exactly as before.
|
|
22
|
+
*
|
|
23
|
+
* A page delivered by an application on this machine (the official DSH Desktop
|
|
24
|
+
* shell serves its Web GUI from `dsh-app://app/`) cannot carry a socket on its
|
|
25
|
+
* own scheme: the protocol handler forwards HTTP to the local Host but has no
|
|
26
|
+
* upgrade to forward. That is exactly the case the official transport hook
|
|
27
|
+
* covers - the shell publishes `__DSH_TRANSPORT__.streamBaseUrl`, the loopback
|
|
28
|
+
* authority of the Host it owns and already forwards every other request to
|
|
29
|
+
* (issue #1744). The socket is therefore dialed there instead, with the `ws`/
|
|
30
|
+
* `wss` scheme derived from that base, which is what the shell's
|
|
31
|
+
* `onBeforeSendHeaders` hook expects to see before it attaches its
|
|
32
|
+
* authority-bound credential.
|
|
33
|
+
*
|
|
34
|
+
* The base is used only on an application-delivered page. A web page that
|
|
35
|
+
* somehow carries the hook (the remote channel grants `ownsHost` to a paired
|
|
36
|
+
* LAN page, and that page is fenced behind a pairing channel) keeps resolving
|
|
37
|
+
* against its own origin, so this cannot reroute gated traffic onto a host the
|
|
38
|
+
* page is not entitled to reach. A blank authority is treated the same as an
|
|
39
|
+
* application scheme with no base: there is nothing to dial, and the caller
|
|
40
|
+
* gets the actionable reason instead of a socket that can only fail.
|
|
41
|
+
*
|
|
42
|
+
* @param location - the page location to read.
|
|
43
|
+
* @param search - the query string carrying `alias` or `session`.
|
|
44
|
+
* @param streamBaseUrl - `__DSH_TRANSPORT__.streamBaseUrl`, when the shell published one.
|
|
45
|
+
* @returns the absolute `ws:`/`wss:` URL, or undefined when the page cannot carry one.
|
|
46
|
+
*/
|
|
47
|
+
export declare function terminalSocketUrl(location: PageLocation, search: string, streamBaseUrl?: string | undefined): string | undefined;
|
|
48
|
+
/** One open terminal connection (WebSocket JSON frames). */
|
|
49
|
+
export interface TerminalConnection {
|
|
50
|
+
/** Fired on the ready frame (shell is up); carries the host session id and alias. */
|
|
51
|
+
onReady: ((sessionId: string, alias: string) => void) | undefined;
|
|
52
|
+
/** Fired on every output frame. */
|
|
53
|
+
onOutput: ((data: string) => void) | undefined;
|
|
54
|
+
/** Fired on the exit frame (or transport error). */
|
|
55
|
+
onExit: ((code: number | null, error?: string) => void) | undefined;
|
|
56
|
+
/** Fired when the server requests keyboard-interactive 2FA. */
|
|
57
|
+
onAuthPrompt: ((name: string, instructions: string, prompts: Array<{
|
|
58
|
+
prompt: string;
|
|
59
|
+
echo: boolean;
|
|
60
|
+
}>) => void) | undefined;
|
|
61
|
+
/** Send raw input to the remote shell. */
|
|
62
|
+
send(data: string): void;
|
|
63
|
+
/** Resize the remote PTY. */
|
|
64
|
+
resize(cols: number, rows: number): void;
|
|
65
|
+
/** Send interactive 2FA response codes to the remote server. */
|
|
66
|
+
sendAuthResponse(responses: string[]): void;
|
|
67
|
+
/**
|
|
68
|
+
* Leave the socket while the host keeps the remote shell alive, so a later
|
|
69
|
+
* {@link SshApi.attachTerminal} picks the session up where it left off.
|
|
70
|
+
* This is what a view does on unmount; it is not a disconnect.
|
|
71
|
+
*/
|
|
72
|
+
detach(): void;
|
|
73
|
+
/** Close the socket and end the remote session. */
|
|
74
|
+
close(): void;
|
|
75
|
+
}
|
|
76
|
+
/** The browser half's only data entry point. */
|
|
77
|
+
export declare class SshApi {
|
|
78
|
+
listHosts(queryText?: string): Promise<SshHostSummary[]>;
|
|
79
|
+
createHost(payload: HostPayload): Promise<SshHostSummary>;
|
|
80
|
+
updateHost(alias: string, patch: HostPayload): Promise<SshHostSummary>;
|
|
81
|
+
deleteHost(alias: string): Promise<void>;
|
|
82
|
+
importSshConfig(): Promise<ImportResult>;
|
|
83
|
+
testHost(alias: string): Promise<TestResult>;
|
|
84
|
+
exec(alias: string, command: string, timeoutMs?: number): Promise<ExecResult>;
|
|
85
|
+
cluster(options: {
|
|
86
|
+
command: string;
|
|
87
|
+
aliases?: string[];
|
|
88
|
+
environment?: string;
|
|
89
|
+
tags?: string[];
|
|
90
|
+
timeoutMs?: number;
|
|
91
|
+
maxWorkers?: number;
|
|
92
|
+
}): Promise<ClusterResult[]>;
|
|
93
|
+
ls(alias: string, path: string): Promise<RemoteDirEntry[]>;
|
|
94
|
+
listTunnels(): Promise<TunnelInfo[]>;
|
|
95
|
+
startTunnel(options: {
|
|
96
|
+
alias: string;
|
|
97
|
+
remotePort: number;
|
|
98
|
+
remoteHost?: string;
|
|
99
|
+
localPort?: number;
|
|
100
|
+
}): Promise<TunnelInfo>;
|
|
101
|
+
stopTunnel(tunnelId: string): Promise<boolean>;
|
|
102
|
+
stopAllTunnels(alias?: string): Promise<number>;
|
|
103
|
+
/**
|
|
104
|
+
* Upload one file (raw bytes) to a remote path. Progress arrives through
|
|
105
|
+
* the NDJSON response stream; resolves when the result frame lands.
|
|
106
|
+
*/
|
|
107
|
+
uploadFile(file: File, alias: string, remotePath: string, onProgress?: (progress: TransferProgress) => void): Promise<{
|
|
108
|
+
transferredBytes: number;
|
|
109
|
+
}>;
|
|
110
|
+
/**
|
|
111
|
+
* Download a remote file with client-side progress. Streams straight to
|
|
112
|
+
* disk when the File System Access API is available (no full-file RAM
|
|
113
|
+
* copy); otherwise falls back to an in-memory Blob.
|
|
114
|
+
*/
|
|
115
|
+
downloadFile(alias: string, remotePath: string, onProgress?: (progress: TransferProgress) => void): Promise<{
|
|
116
|
+
blob?: Blob;
|
|
117
|
+
filename: string;
|
|
118
|
+
streamed: boolean;
|
|
119
|
+
bytes: number;
|
|
120
|
+
}>;
|
|
121
|
+
/**
|
|
122
|
+
* Open a new host terminal session for the alias.
|
|
123
|
+
* @param alias - the configured host alias.
|
|
124
|
+
* @param cols - initial PTY width.
|
|
125
|
+
* @param rows - initial PTY height.
|
|
126
|
+
* @returns the live connection; its ready callback carries the session id
|
|
127
|
+
* {@link attachTerminal} uses after a view detach.
|
|
128
|
+
*/
|
|
129
|
+
openTerminal(alias: string, cols: number, rows: number): TerminalConnection;
|
|
130
|
+
/**
|
|
131
|
+
* Reattach to a host-side session that outlived its view (a panel switch, a
|
|
132
|
+
* page navigation). The host replays its scrollback before the ready frame.
|
|
133
|
+
* @param sessionId - the id the previous connection reported on ready.
|
|
134
|
+
* @param cols - the view's current width.
|
|
135
|
+
* @param rows - the view's current height.
|
|
136
|
+
*/
|
|
137
|
+
attachTerminal(sessionId: string, cols: number, rows: number): TerminalConnection;
|
|
138
|
+
/** One terminal socket over either an alias (open) or a session id (attach). */
|
|
139
|
+
private terminalSocket;
|
|
140
|
+
}
|
|
141
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-half entry for the dsh-ssh plugin — runs inside the dsh web GUI.
|
|
3
|
+
*
|
|
4
|
+
* Registers the dsh-ssh locale dictionaries and mounts the two DOM surfaces:
|
|
5
|
+
* the sidebar entry row (toggles the panel) and the SSH operations panel in
|
|
6
|
+
* the center column. Failure policy: DOM mounting problems are logged, never
|
|
7
|
+
* thrown — the web shell fails the whole boot when a plugin apply throws, and
|
|
8
|
+
* an external plugin must not take the GUI down.
|
|
9
|
+
*
|
|
10
|
+
* Export discipline (packages/client rule): the /client surface carries what
|
|
11
|
+
* cordis loading needs plus types only — all value exports stay internal.
|
|
12
|
+
*/
|
|
13
|
+
import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
14
|
+
import { type SshKey } from './locales.ts';
|
|
15
|
+
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
16
|
+
interface LocaleNamespaceMap {
|
|
17
|
+
/** dsh-ssh surface copy. */
|
|
18
|
+
'dsh-ssh': SshKey;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Required services (fiber inject waiting — the runtime must be up first). */
|
|
22
|
+
export declare const inject: string[];
|
|
23
|
+
/** Type-only surface (export discipline: no value exports beyond the plugin contract). */
|
|
24
|
+
export type { PanelControllerSnapshot } from './panel/controller.ts';
|
|
25
|
+
export type { SshPanelProps } from './panel/SshPanel.tsx';
|
|
26
|
+
export type { HostsTabProps } from './panel/HostsTab.tsx';
|
|
27
|
+
export type { HostFormDialogProps } from './panel/HostFormDialog.tsx';
|
|
28
|
+
export type { TerminalTabProps } from './panel/TerminalTab.tsx';
|
|
29
|
+
export type { TransferTabProps } from './panel/TransferTab.tsx';
|
|
30
|
+
export type { TunnelsTabProps } from './panel/TunnelsTab.tsx';
|
|
31
|
+
export type { ClusterTabProps } from './panel/ClusterTab.tsx';
|
|
32
|
+
export type { SshKey } from './locales.ts';
|
|
33
|
+
/**
|
|
34
|
+
* Mount the SSH panel.
|
|
35
|
+
* @param ctx - client root context (locale service).
|
|
36
|
+
*/
|
|
37
|
+
export declare function apply(ctx: ClientContext): void;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-ssh surface copy: zh is the key source, en mirrors every key.
|
|
3
|
+
*/
|
|
4
|
+
export declare const zh: {
|
|
5
|
+
readonly 'entry.label': "SSH";
|
|
6
|
+
readonly 'entry.tooltip': "远程 SSH 运维面板";
|
|
7
|
+
readonly 'panel.title': "远程 SSH";
|
|
8
|
+
readonly 'panel.backToConversation': "返回会话";
|
|
9
|
+
readonly 'tab.hosts': "主机";
|
|
10
|
+
readonly 'tab.terminal': "终端";
|
|
11
|
+
readonly 'tab.transfer': "传输";
|
|
12
|
+
readonly 'tab.tunnels': "隧道";
|
|
13
|
+
readonly 'tab.cluster': "集群";
|
|
14
|
+
readonly 'hosts.empty': "尚未配置主机。点击「新增主机」添加,或从 ~/.ssh/config 导入。";
|
|
15
|
+
readonly 'hosts.add': "新增主机";
|
|
16
|
+
readonly 'hosts.import': "导入 ~/.ssh/config";
|
|
17
|
+
readonly 'hosts.search': "搜索别名 / 描述 / 标签…";
|
|
18
|
+
readonly 'hosts.groupBy.label': "分组方式";
|
|
19
|
+
readonly 'hosts.groupBy.none': "不分组";
|
|
20
|
+
readonly 'hosts.groupBy.environment': "按环境分组";
|
|
21
|
+
readonly 'hosts.groupBy.tags': "按标签分组";
|
|
22
|
+
readonly 'hosts.group.ungrouped': "未设置环境";
|
|
23
|
+
readonly 'hosts.group.noTags': "无标签";
|
|
24
|
+
readonly 'hosts.group.count': "{count} 台";
|
|
25
|
+
readonly 'hosts.group.testAll': "测试全部";
|
|
26
|
+
readonly 'hosts.col.alias': "别名";
|
|
27
|
+
readonly 'hosts.col.host': "主机";
|
|
28
|
+
readonly 'hosts.col.user': "用户";
|
|
29
|
+
readonly 'hosts.col.auth': "认证";
|
|
30
|
+
readonly 'hosts.col.environment': "环境";
|
|
31
|
+
readonly 'hosts.col.tags': "标签";
|
|
32
|
+
readonly 'hosts.col.description': "备注";
|
|
33
|
+
readonly 'hosts.col.actions': "操作";
|
|
34
|
+
readonly 'hosts.test': "测试";
|
|
35
|
+
readonly 'hosts.edit': "编辑";
|
|
36
|
+
readonly 'hosts.delete': "删除";
|
|
37
|
+
readonly 'hosts.deleteConfirm': "确定删除主机「{alias}」?将同时停止其隧道。";
|
|
38
|
+
readonly 'hosts.imported': "解析 {parsed} 个配置块,新增 {added} 台主机,跳过 {skipped} 个。";
|
|
39
|
+
readonly 'hosts.proxyBadge': "代理";
|
|
40
|
+
readonly 'import.reason.wildcard': "通配符 pattern,需手动配置";
|
|
41
|
+
readonly 'import.reason.existing': "别名已存在";
|
|
42
|
+
readonly 'import.reason.match': "Match 条件块,不支持";
|
|
43
|
+
readonly 'import.reason.invalid': "字段不合法,无法导入";
|
|
44
|
+
readonly 'import.more': "其余 {count} 个未显示";
|
|
45
|
+
readonly 'hosts.testing': "连接测试中…";
|
|
46
|
+
readonly 'hosts.testOk': "连接成功({latency} ms)";
|
|
47
|
+
readonly 'hosts.testFail': "连接失败:{error}";
|
|
48
|
+
readonly 'hosts.connected': "连接";
|
|
49
|
+
readonly 'hosts.notConnected': "未连接";
|
|
50
|
+
readonly 'form.title.create': "新增主机";
|
|
51
|
+
readonly 'form.title.edit': "编辑主机 {alias}";
|
|
52
|
+
readonly 'form.alias': "别名";
|
|
53
|
+
readonly 'form.aliasHint': "小写字母、数字与单连字符,操作时使用";
|
|
54
|
+
readonly 'form.host': "主机地址";
|
|
55
|
+
readonly 'form.port': "端口";
|
|
56
|
+
readonly 'form.user': "用户名";
|
|
57
|
+
readonly 'form.auth': "认证方式";
|
|
58
|
+
readonly 'form.auth.key': "密钥";
|
|
59
|
+
readonly 'form.auth.password': "密码";
|
|
60
|
+
readonly 'form.auth.agent': "SSH Agent";
|
|
61
|
+
readonly 'form.agentPath': "Agent 路径";
|
|
62
|
+
readonly 'form.agentPathHint': "留空自动检测(SSH_AUTH_SOCK / Windows Pageant);也可填 socket 路径或 pageant";
|
|
63
|
+
readonly 'form.authKeepHint': "编辑时密钥/密码/Agent 留空将保留原认证方式与已存凭据;如需更换认证方式请填写新凭据。";
|
|
64
|
+
readonly 'form.keyPath': "私钥路径";
|
|
65
|
+
readonly 'form.keyPathHint': "如 ~/.ssh/id_ed25519";
|
|
66
|
+
readonly 'form.passphrase': "密钥口令";
|
|
67
|
+
readonly 'form.password': "密码";
|
|
68
|
+
readonly 'form.passwordHint': "明文保存在 $DSH_HOME/dsh-ssh.json(本机私有文件)";
|
|
69
|
+
readonly 'form.passwordRequired': "密码认证需要填写密码。";
|
|
70
|
+
readonly 'form.proxyJump': "跳板机别名";
|
|
71
|
+
readonly 'form.proxyJumpHint': "逗号分隔的本地主机别名,或 [user@]host[:port] 地址,按顺序连接";
|
|
72
|
+
readonly 'form.proxyCommand': "ProxyCommand";
|
|
73
|
+
readonly 'form.proxyCommandHint': "OpenSSH ProxyCommand:%h 主机、%p 端口、%r 用户、%n 别名;留空或填 none 表示不使用。与跳板机别名互斥。";
|
|
74
|
+
readonly 'form.description': "备注";
|
|
75
|
+
readonly 'form.environment': "环境";
|
|
76
|
+
readonly 'form.environmentHint': "如 development / production";
|
|
77
|
+
readonly 'form.tags': "标签";
|
|
78
|
+
readonly 'form.tagsHint': "逗号分隔";
|
|
79
|
+
readonly 'form.location': "位置";
|
|
80
|
+
readonly 'form.save': "保存";
|
|
81
|
+
readonly 'form.cancel': "取消";
|
|
82
|
+
readonly 'form.required': "请填写必填字段:别名、主机地址、用户名。";
|
|
83
|
+
readonly 'form.portInvalid': "端口必须是 1-65535 之间的整数。";
|
|
84
|
+
readonly 'terminal.selectHost': "选择主机";
|
|
85
|
+
readonly 'terminal.connect': "连接";
|
|
86
|
+
readonly 'terminal.disconnect': "断开";
|
|
87
|
+
readonly 'terminal.placeholder': "选择主机后点击「连接」打开远程终端。";
|
|
88
|
+
readonly 'terminal.connecting': "正在连接…";
|
|
89
|
+
readonly 'terminal.ready': "终端已连接({alias})";
|
|
90
|
+
readonly 'terminal.exited': "终端已退出({alias})";
|
|
91
|
+
readonly 'terminal.error': "终端错误:{error}";
|
|
92
|
+
readonly 'terminal.noWebSocket': "当前页面不支持 WebSocket(应用外壳没有可连接的本地主机地址),请改用浏览器打开的 Web 界面使用终端。";
|
|
93
|
+
readonly 'terminal.auth.title': "二次身份验证 (2FA / 交互式认证)";
|
|
94
|
+
readonly 'terminal.auth.submit': "提交验证码";
|
|
95
|
+
readonly 'terminal.auth.cancel': "取消";
|
|
96
|
+
readonly 'terminal.auth.placeholder': "请输入验证码或口令";
|
|
97
|
+
readonly 'terminal.auth.hint': "服务器请求进行交互式二次验证(输入仅本次生效,不落盘):";
|
|
98
|
+
readonly 'transfer.selectHost': "选择主机";
|
|
99
|
+
readonly 'transfer.remotePath': "远程路径";
|
|
100
|
+
readonly 'transfer.remotePathHint': "如 /tmp/ 或 /home/user/app.tar.gz";
|
|
101
|
+
readonly 'transfer.upload': "上传";
|
|
102
|
+
readonly 'transfer.uploading': "正在上传 {file}…";
|
|
103
|
+
readonly 'transfer.download': "下载";
|
|
104
|
+
readonly 'transfer.downloading': "正在下载…";
|
|
105
|
+
readonly 'transfer.done': "完成:{bytes} 字节";
|
|
106
|
+
readonly 'transfer.failed': "传输失败:{error}";
|
|
107
|
+
readonly 'transfer.browseRemote': "浏览远程目录";
|
|
108
|
+
readonly 'transfer.refresh': "刷新";
|
|
109
|
+
readonly 'transfer.name': "名称";
|
|
110
|
+
readonly 'transfer.upLevel': "上级目录";
|
|
111
|
+
readonly 'transfer.size': "大小";
|
|
112
|
+
readonly 'transfer.modified': "修改时间";
|
|
113
|
+
readonly 'transfer.bytes': "{value} B";
|
|
114
|
+
readonly 'transfer.kib': "{value} KB";
|
|
115
|
+
readonly 'transfer.mib': "{value} MB";
|
|
116
|
+
readonly 'transfer.gib': "{value} GB";
|
|
117
|
+
readonly 'transfer.percent': "{value}%";
|
|
118
|
+
readonly 'transfer.speed': "{value}/s";
|
|
119
|
+
readonly 'transfer.dir': "目录";
|
|
120
|
+
readonly 'transfer.file': "文件";
|
|
121
|
+
readonly 'tunnel.empty': "没有活跃的隧道。";
|
|
122
|
+
readonly 'tunnel.start': "新建隧道";
|
|
123
|
+
readonly 'tunnel.alias': "主机别名";
|
|
124
|
+
readonly 'tunnel.remotePort': "远程端口";
|
|
125
|
+
readonly 'tunnel.remoteHost': "远程主机";
|
|
126
|
+
readonly 'tunnel.remoteHostHint': "默认 127.0.0.1(服务器自身)";
|
|
127
|
+
readonly 'tunnel.localPort': "本地端口";
|
|
128
|
+
readonly 'tunnel.localPortHint': "留空自动分配";
|
|
129
|
+
readonly 'tunnel.stop': "停止";
|
|
130
|
+
readonly 'tunnel.stopAll': "全部停止";
|
|
131
|
+
readonly 'tunnel.stopAllConfirm': "确定停止全部隧道吗?";
|
|
132
|
+
readonly 'tunnel.row': "{alias}: 127.0.0.1:{localPort} -> {remoteHost}:{remotePort}";
|
|
133
|
+
readonly 'tunnel.started': "隧道已建立:127.0.0.1:{localPort}";
|
|
134
|
+
readonly 'tunnel.failed': "隧道启动失败:{error}";
|
|
135
|
+
readonly 'cluster.command': "命令";
|
|
136
|
+
readonly 'cluster.run': "执行";
|
|
137
|
+
readonly 'cluster.confirm': "确定在匹配的主机上执行该命令吗?该操作会真实运行在远程服务器上。";
|
|
138
|
+
readonly 'cluster.aliases': "主机别名(逗号分隔,与环境、标签至少填一项)";
|
|
139
|
+
readonly 'cluster.environment': "环境过滤";
|
|
140
|
+
readonly 'cluster.tags': "标签过滤(逗号分隔)";
|
|
141
|
+
readonly 'cluster.results': "执行结果";
|
|
142
|
+
readonly 'cluster.empty': "输入命令后点击「执行」。";
|
|
143
|
+
readonly 'cluster.noMatch': "没有匹配的主机。";
|
|
144
|
+
readonly 'cluster.ok': "成功";
|
|
145
|
+
readonly 'cluster.fail': "失败";
|
|
146
|
+
readonly 'cluster.timeout': "超时";
|
|
147
|
+
readonly 'cluster.col.alias': "主机";
|
|
148
|
+
readonly 'cluster.col.status': "状态";
|
|
149
|
+
readonly 'cluster.col.exit': "退出码";
|
|
150
|
+
readonly 'cluster.col.stdout': "标准输出";
|
|
151
|
+
readonly 'cluster.col.stderr': "标准错误";
|
|
152
|
+
readonly 'cluster.col.error': "错误";
|
|
153
|
+
readonly 'cluster.col.duration': "耗时";
|
|
154
|
+
readonly 'common.loading': "加载中…";
|
|
155
|
+
readonly 'common.error': "出错:{error}";
|
|
156
|
+
readonly 'common.refresh': "刷新";
|
|
157
|
+
readonly 'common.confirm': "确定";
|
|
158
|
+
readonly 'error.disabled': "SSH 插件在宿主端未启用。请前往「设置 → Web 插件 → SSH」打开 enabled 开关。";
|
|
159
|
+
};
|
|
160
|
+
export declare const en: Record<keyof typeof zh, string>;
|
|
161
|
+
/** Locale key union. */
|
|
162
|
+
export type SshKey = keyof typeof zh;
|
|
163
|
+
/** Tiny interpolation: {name} -> value. */
|
|
164
|
+
export declare function t(dictionary: Record<string, string>, key: string, values?: Record<string, string | number>): string;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native panel registration for the SSH panel.
|
|
3
|
+
*
|
|
4
|
+
* The panel is an official-style center-column page, not a DOM takeover: it
|
|
5
|
+
* contributes a row into the sidebar shell's own global panel list
|
|
6
|
+
* (`sidebar.panellist`) and its page into the layout's keyed `main` slot. The
|
|
7
|
+
* shell then owns the row box, the label, the active highlight, the collapsed
|
|
8
|
+
* rail and the panel switch, exactly as it does for the shipped Plugins and
|
|
9
|
+
* Schedule pages and for the task board and the skill center.
|
|
10
|
+
*
|
|
11
|
+
* Both registrations go through `ctx.slots.inject`, which fires only once the
|
|
12
|
+
* owning shell entry has declared the seat: load order between this plugin and
|
|
13
|
+
* ui-layout / ui-sidebar therefore does not matter, and neither does a shell
|
|
14
|
+
* that cannot serve the seats (the callback simply never runs).
|
|
15
|
+
*
|
|
16
|
+
* The terminal's PTY shell lives on the host and outlives this page (see
|
|
17
|
+
* engine/terminal-sessions.ts), so the layout unmounting a deselected page
|
|
18
|
+
* costs the view its xterm instance, not the remote session: the terminal tab
|
|
19
|
+
* reattaches by session id when the page mounts again.
|
|
20
|
+
*
|
|
21
|
+
* @module @fish-under-sea/dsh-ssh-fish/client
|
|
22
|
+
*/
|
|
23
|
+
import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
24
|
+
import type { SshApi } from './api.ts';
|
|
25
|
+
import { SSH_PANEL_ID, type PanelController } from './panel/controller.ts';
|
|
26
|
+
import { type TerminalFontSource } from './panel/helpers.ts';
|
|
27
|
+
/** The panel id shared by the sidebar row and the main-slot occupant. */
|
|
28
|
+
export { SSH_PANEL_ID };
|
|
29
|
+
/**
|
|
30
|
+
* The sidebar row glyph the shell asks for at its own size and active state.
|
|
31
|
+
* The shell owns the button, label, tooltip and rail geometry; this component
|
|
32
|
+
* draws only the glyph, like every other panel row.
|
|
33
|
+
*
|
|
34
|
+
* The glyph carries `data-dsh-panel-entry` because it is the only DOM this
|
|
35
|
+
* panel's own code owns inside that shell-owned row: the L2 contract (skins)
|
|
36
|
+
* resolves which row belongs to which plugin through it, since the shell
|
|
37
|
+
* stamps no per-entry hook of its own (see contracts/semantic-attrs-v1.md).
|
|
38
|
+
* @param props - the shell's icon share: square edge and selection state.
|
|
39
|
+
* @returns the decorative terminal glyph.
|
|
40
|
+
*/
|
|
41
|
+
export declare function SshPanelIcon({ size }: {
|
|
42
|
+
size: number;
|
|
43
|
+
active: boolean;
|
|
44
|
+
}): React.ReactElement;
|
|
45
|
+
/**
|
|
46
|
+
* The main-slot page. The layout mounts it only while this panel is selected;
|
|
47
|
+
* the wrapper carries the pinned `data-dsh-ssh-view` semantic anchor (L2
|
|
48
|
+
* contract, skins) the takeover container used to own.
|
|
49
|
+
* @param props - the framework main-slot share plus this entry's injected face.
|
|
50
|
+
* @returns the SSH panel page.
|
|
51
|
+
*/
|
|
52
|
+
export declare function SshPanelPage({ controller, api, terminalFont }: {
|
|
53
|
+
controller: PanelController;
|
|
54
|
+
api: SshApi;
|
|
55
|
+
terminalFont?: TerminalFontSource;
|
|
56
|
+
}): React.ReactElement;
|
|
57
|
+
/**
|
|
58
|
+
* Register the SSH panel's sidebar row and center-column page.
|
|
59
|
+
*
|
|
60
|
+
* Both seats are declared by shell plugins this package does not depend on at
|
|
61
|
+
* runtime, so each registration is wrapped in `ctx.slots.inject`: the callback
|
|
62
|
+
* runs only after the owning entry declares the seat, and a shell that never
|
|
63
|
+
* declares it leaves the panel simply absent instead of failing boot.
|
|
64
|
+
* @param ctx - client root context (services: slots).
|
|
65
|
+
* @param controller - the controller the page and the row drive.
|
|
66
|
+
* @param api - the SSH API client the page operates through.
|
|
67
|
+
* @param terminalFont - live terminal-font setting source (issue #577).
|
|
68
|
+
* @returns disposer releasing both registrations.
|
|
69
|
+
*/
|
|
70
|
+
export declare function registerSshPanel(ctx: ClientContext, controller: PanelController, api: SshApi, terminalFont?: TerminalFontSource): () => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SshApi } from '../api.ts';
|
|
2
|
+
import type { SshHostSummary } from '../../protocol.ts';
|
|
3
|
+
/** Host form dialog props. */
|
|
4
|
+
export interface HostFormDialogProps {
|
|
5
|
+
api: SshApi;
|
|
6
|
+
/** The host being edited; null/undefined means create. */
|
|
7
|
+
editing?: SshHostSummary | null;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
onSaved: (host: SshHostSummary) => void;
|
|
10
|
+
}
|
|
11
|
+
/** The create/edit host modal. */
|
|
12
|
+
export declare function HostFormDialog({ api, editing, onClose, onSaved }: HostFormDialogProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { SshApi } from '../api.ts';
|
|
2
|
+
import type { SshHostSummary } from '../../protocol.ts';
|
|
3
|
+
/** Hosts tab props. */
|
|
4
|
+
export interface HostsTabProps {
|
|
5
|
+
api: SshApi;
|
|
6
|
+
/** Connect the given alias in the terminal tab. */
|
|
7
|
+
onConnect: (alias: string) => void;
|
|
8
|
+
}
|
|
9
|
+
/** Host list grouping modes (#379). */
|
|
10
|
+
export type HostGroupBy = 'none' | 'environment' | 'tags';
|
|
11
|
+
/** One collapsible group section of the grouped host list. */
|
|
12
|
+
export interface HostGroup {
|
|
13
|
+
/** Group key: the environment name, one tag, or '' for the ungrouped bucket. */
|
|
14
|
+
key: string;
|
|
15
|
+
hosts: SshHostSummary[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Bucket hosts into collapsible groups (#379). Grouping by tags places a
|
|
19
|
+
* multi-tag host in every one of its tag groups (folder view); hosts without
|
|
20
|
+
* the grouping key land in the '' bucket, which always sorts last. Groups
|
|
21
|
+
* sort alphabetically; host order inside a group follows the API listing.
|
|
22
|
+
*/
|
|
23
|
+
export declare function groupHosts(hosts: SshHostSummary[], groupBy: HostGroupBy): HostGroup[];
|
|
24
|
+
/** The hosts table plus its toolbar and dialogs. */
|
|
25
|
+
export declare function HostsTab({ api, onConnect }: HostsTabProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SshApi } from '../api.ts';
|
|
2
|
+
import type { PanelController } from './controller.ts';
|
|
3
|
+
import { type TerminalFontSource } from './helpers.ts';
|
|
4
|
+
/** Panel shell props. */
|
|
5
|
+
export interface SshPanelProps {
|
|
6
|
+
/** The panel state owner (open/close/toggle, active tab, terminal session). */
|
|
7
|
+
controller: PanelController;
|
|
8
|
+
/** The SSH API client every tab operates through. */
|
|
9
|
+
api: SshApi;
|
|
10
|
+
/** Live terminal-font setting source handed to the terminal tab (issue #577). */
|
|
11
|
+
terminalFont?: TerminalFontSource;
|
|
12
|
+
}
|
|
13
|
+
/** The tabbed SSH panel. */
|
|
14
|
+
export declare function SshPanel({ controller, api, terminalFont }: SshPanelProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { SshApi } from '../api.ts';
|
|
2
|
+
import type { PanelController } from './controller.ts';
|
|
3
|
+
import { type TerminalFontSource } from './helpers.ts';
|
|
4
|
+
/** Terminal tab props. */
|
|
5
|
+
export interface TerminalTabProps {
|
|
6
|
+
api: SshApi;
|
|
7
|
+
/** The panel controller that owns the live host session id across mounts. */
|
|
8
|
+
controller: PanelController;
|
|
9
|
+
/** Host session to reattach to on mount (survives a panel switch). */
|
|
10
|
+
sessionId?: string;
|
|
11
|
+
/** Alias preselected by a "connect" action from the hosts tab. */
|
|
12
|
+
presetAlias?: string;
|
|
13
|
+
/** Monotonic id of the connect request (re-applies presetAlias). */
|
|
14
|
+
requestId?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Live terminal-font setting source (issue #577). Absent in tests and
|
|
17
|
+
* legacy mounts: the font then comes from the CSS custom-property chain.
|
|
18
|
+
*/
|
|
19
|
+
terminalFont?: TerminalFontSource;
|
|
20
|
+
}
|
|
21
|
+
/** The xterm terminal view. */
|
|
22
|
+
export declare function TerminalTab({ api, controller, sessionId, presetAlias, requestId, terminalFont }: TerminalTabProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SshApi } from '../api.ts';
|
|
2
|
+
import type { TunnelInfo } from '../../protocol.ts';
|
|
3
|
+
/** Live-tunnel polling interval while the tab and page are visible (ms). */
|
|
4
|
+
export declare const TUNNEL_POLL_MS = 5000;
|
|
5
|
+
/**
|
|
6
|
+
* Return `next` only when the tunnel list changed in a user-visible way
|
|
7
|
+
* (identity, ordering or any renderable field), else `null` so a poll tick
|
|
8
|
+
* with no real change keeps the previous reference and React skips the
|
|
9
|
+
* re-render. `prev === null` (first load) always accepts the list.
|
|
10
|
+
*/
|
|
11
|
+
export declare function diffTunnels(prev: TunnelInfo[] | null, next: TunnelInfo[]): TunnelInfo[] | null;
|
|
12
|
+
/** Tunnels tab props. */
|
|
13
|
+
export interface TunnelsTabProps {
|
|
14
|
+
api: SshApi;
|
|
15
|
+
/** Pause automatic reads while the owning panel is closed, preserving form state. */
|
|
16
|
+
active?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** The tunnels tab. */
|
|
19
|
+
export declare function TunnelsTab({ api, active }: TunnelsTabProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,89 @@
|
|
|
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 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.
|
|
12
|
+
*/
|
|
13
|
+
/** The panel's tab identifiers. */
|
|
14
|
+
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
|
+
/** Stable id shared by the sidebar panel row and the main-slot page. */
|
|
22
|
+
export declare const SSH_PANEL_ID = "ssh";
|
|
23
|
+
/** Immutable controller snapshot for UI subscriptions. */
|
|
24
|
+
export interface PanelControllerSnapshot {
|
|
25
|
+
/** Whether the center column shows this panel. */
|
|
26
|
+
panelOpen: boolean;
|
|
27
|
+
/** The tab the panel is showing. */
|
|
28
|
+
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;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The layout's panel-navigation face: selecting the panel is the layout's
|
|
36
|
+
* business, and this is the one call that asks for it (null returns the column
|
|
37
|
+
* to the conversation). Optional, so a shell-less composition keeps the pure
|
|
38
|
+
* state transitions testable.
|
|
39
|
+
*/
|
|
40
|
+
export interface PanelNavigationFace {
|
|
41
|
+
/** Select this panel, or null to hand the column back to the conversation. */
|
|
42
|
+
select(panelId: string | null): void;
|
|
43
|
+
}
|
|
44
|
+
/** Controller dependencies. */
|
|
45
|
+
export interface PanelControllerDeps {
|
|
46
|
+
/** Layout panel selection; absent keeps the controller state-only. */
|
|
47
|
+
panel?: PanelNavigationFace;
|
|
48
|
+
}
|
|
49
|
+
/** The panel state owner the sidebar row and the view both read. */
|
|
50
|
+
export declare class PanelController {
|
|
51
|
+
private readonly deps;
|
|
52
|
+
private panelOpen;
|
|
53
|
+
private activeTab;
|
|
54
|
+
private connectRequest;
|
|
55
|
+
private terminalSessionId;
|
|
56
|
+
private listeners;
|
|
57
|
+
/** Cached so getSnapshot is referentially stable between changes. */
|
|
58
|
+
private snapshot;
|
|
59
|
+
constructor(deps?: PanelControllerDeps);
|
|
60
|
+
getSnapshot(): PanelControllerSnapshot;
|
|
61
|
+
subscribe(fn: () => void): () => void;
|
|
62
|
+
/**
|
|
63
|
+
* Show the panel. The layout owns which panel the column renders, so the
|
|
64
|
+
* state flip and the selection travel together; the selection is requested
|
|
65
|
+
* after the snapshot flips, so a subscriber never observes "open" while the
|
|
66
|
+
* shell still shows the conversation.
|
|
67
|
+
*/
|
|
68
|
+
open(): void;
|
|
69
|
+
/** Return the column to the conversation, asking the layout explicitly. */
|
|
70
|
+
close(): void;
|
|
71
|
+
toggle(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Reflect a selection made outside this controller (the user clicked another
|
|
74
|
+
* sidebar row, or the layout dropped the panel id).
|
|
75
|
+
* @param panelId - the layout's current panel id, or null for the conversation.
|
|
76
|
+
*/
|
|
77
|
+
syncPanelSelection(panelId: string | null): void;
|
|
78
|
+
/** Switch tabs, keeping every other piece of view state. */
|
|
79
|
+
setActiveTab(tab: SshTab): void;
|
|
80
|
+
/** Hand the terminal tab a host to connect to (hosts-tab "connect" action). */
|
|
81
|
+
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;
|
|
86
|
+
private commit;
|
|
87
|
+
/** Ask the layout to select a panel; a shell without the face is a no-op. */
|
|
88
|
+
private selectPanel;
|
|
89
|
+
}
|