@fish-under-sea/dsh-ssh-fish 0.0.0-stage → 1.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.
- package/LICENSE +202 -0
- package/NOTICE +23 -0
- package/README.en.md +29 -0
- package/README.i18n.yaml +6 -0
- package/README.md +28 -2
- package/README.zh.md +29 -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 +109 -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,137 @@
|
|
|
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
|
+
// Type-only: pulls the locale plugin's Context merge (ctx.locale).
|
|
15
|
+
import type {} from '@deepseek-ai/dsh-client-locale/client'
|
|
16
|
+
// Type-only: pulls the shared-forms Context merge (ctx.configForms).
|
|
17
|
+
import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
18
|
+
// Type-only: pulls the ctx.slots merge (the renderer owns the slot registry since 0.1.2).
|
|
19
|
+
import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
|
|
20
|
+
// Type-only: pulls the LocaleNamespaceMap merge table.
|
|
21
|
+
import type {} from '@deepseek-ai/dsh-client-ui-slots'
|
|
22
|
+
import { SshApi } from './api.ts'
|
|
23
|
+
import { en, zh, type SshKey } from './locales.ts'
|
|
24
|
+
import { registerSshPanel } from './native-panel.tsx'
|
|
25
|
+
import { PanelController, SSH_PANEL_ID } from './panel/controller.ts'
|
|
26
|
+
import type { TerminalFontSource } from './panel/helpers.ts'
|
|
27
|
+
import { setRuntimeTranslate } from './panel/helpers.ts'
|
|
28
|
+
import { bindSettingsReader } from './settings-binding.ts'
|
|
29
|
+
|
|
30
|
+
/** Locale namespace this plugin owns. */
|
|
31
|
+
const NS = 'dsh-ssh'
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Family settings namespace the terminal-font preference is addressed by
|
|
35
|
+
* (issue #577); dsh-web-settings maps it to the owning profile entry id.
|
|
36
|
+
*/
|
|
37
|
+
const SETTINGS_NS = 'dsh-ssh'
|
|
38
|
+
|
|
39
|
+
/** The dsh-ssh settings section the browser half reads. */
|
|
40
|
+
interface SshClientSettings {
|
|
41
|
+
/** User-configured xterm fontFamily; empty/undefined means the CSS chain. */
|
|
42
|
+
terminalFontFamily?: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The one field this plugin's own Config schema declares (its entry identity on the shared settings surface). */
|
|
46
|
+
const TERMINAL_FONT_FIELD = 'terminalFontFamily' satisfies keyof SshClientSettings
|
|
47
|
+
|
|
48
|
+
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
49
|
+
interface LocaleNamespaceMap {
|
|
50
|
+
/** dsh-ssh surface copy. */
|
|
51
|
+
'dsh-ssh': SshKey
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Required services (fiber inject waiting — the runtime must be up first). */
|
|
56
|
+
export const inject = ['slots', 'locale', 'configForms', 'layout']
|
|
57
|
+
|
|
58
|
+
/** Type-only surface (export discipline: no value exports beyond the plugin contract). */
|
|
59
|
+
export type { PanelControllerSnapshot } from './panel/controller.ts'
|
|
60
|
+
export type { SshPanelProps } from './panel/SshPanel.tsx'
|
|
61
|
+
export type { HostsTabProps } from './panel/HostsTab.tsx'
|
|
62
|
+
export type { HostFormDialogProps } from './panel/HostFormDialog.tsx'
|
|
63
|
+
export type { TerminalTabProps } from './panel/TerminalTab.tsx'
|
|
64
|
+
export type { TransferTabProps } from './panel/TransferTab.tsx'
|
|
65
|
+
export type { TunnelsTabProps } from './panel/TunnelsTab.tsx'
|
|
66
|
+
export type { ClusterTabProps } from './panel/ClusterTab.tsx'
|
|
67
|
+
export type { SshKey } from './locales.ts'
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Mount the SSH panel.
|
|
71
|
+
* @param ctx - client root context (locale service).
|
|
72
|
+
*/
|
|
73
|
+
export function apply(ctx: ClientContext): void {
|
|
74
|
+
|
|
75
|
+
ctx.effect(() => {
|
|
76
|
+
try {
|
|
77
|
+
return ctx.locale.register(NS, { zh, en })
|
|
78
|
+
} catch {
|
|
79
|
+
return () => {}
|
|
80
|
+
}
|
|
81
|
+
}, 'dsh-ssh: dictionaries')
|
|
82
|
+
|
|
83
|
+
// Wire the SDK translate seat into the module-level tt (sidebar row and
|
|
84
|
+
// other plain-DOM callers): reads the active locale at call time, so they
|
|
85
|
+
// follow the Language setting without a reload.
|
|
86
|
+
try { setRuntimeTranslate(ctx.locale.bind(NS)) } catch { /* locale missing: document-language fallback stays */ }
|
|
87
|
+
|
|
88
|
+
// Panel navigation belongs to the layout service: the panel asks it to
|
|
89
|
+
// select its own panel id (or the conversation) instead of taking over the
|
|
90
|
+
// center column at the DOM level. The lookup stays lazy so a selection
|
|
91
|
+
// issued before the service settles still lands once it does, and the face
|
|
92
|
+
// throws by contract before the layout root entry mounts, which the
|
|
93
|
+
// controller tolerates.
|
|
94
|
+
const controller = new PanelController({
|
|
95
|
+
panel: {
|
|
96
|
+
select: panelId => {
|
|
97
|
+
const layout = (ctx as unknown as { get?(name: string): unknown }).get?.('layout') as { selectPanel?: (id: string | null) => void } | undefined
|
|
98
|
+
layout?.selectPanel?.(panelId)
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
})
|
|
102
|
+
const api = new SshApi()
|
|
103
|
+
// Live terminal-font preference (issue #577): the field lives in this
|
|
104
|
+
// plugin's own profile entry, whose settings page the Host generates from
|
|
105
|
+
// the plugin Config schema; the panel re-applies a change to open terminals
|
|
106
|
+
// without a reconnect.
|
|
107
|
+
const settings = bindSettingsReader<SshClientSettings>(ctx, SETTINGS_NS, TERMINAL_FONT_FIELD)
|
|
108
|
+
const terminalFont: TerminalFontSource = {
|
|
109
|
+
get: () => {
|
|
110
|
+
const snapshot = settings.getSnapshot()
|
|
111
|
+
return snapshot.status === 'ready' ? snapshot.value?.terminalFontFamily : undefined
|
|
112
|
+
},
|
|
113
|
+
subscribe: (listener) => settings.subscribe(listener),
|
|
114
|
+
}
|
|
115
|
+
ctx.effect(() => () => { settings.dispose() }, 'dsh-ssh: settings binding')
|
|
116
|
+
const disposers: Array<() => void> = []
|
|
117
|
+
try {
|
|
118
|
+
disposers.push(registerSshPanel(ctx, controller, api, terminalFont))
|
|
119
|
+
// The layout's panel selection is reconciled back into the controller, so
|
|
120
|
+
// the panel follows the user clicking another panel row.
|
|
121
|
+
const layoutFace = (ctx as unknown as { get?(name: string): unknown }).get?.('layout') as { panelInfo?: { subscribe(listener: () => void): () => void; getSnapshot(): { activePanelId: unknown } } } | undefined
|
|
122
|
+
if (layoutFace?.panelInfo !== undefined) {
|
|
123
|
+
const sync = (): void => {
|
|
124
|
+
const active = layoutFace.panelInfo!.getSnapshot().activePanelId
|
|
125
|
+
controller.syncPanelSelection(active === SSH_PANEL_ID ? SSH_PANEL_ID : null)
|
|
126
|
+
}
|
|
127
|
+
sync()
|
|
128
|
+
disposers.push(layoutFace.panelInfo.subscribe(sync))
|
|
129
|
+
}
|
|
130
|
+
} catch (error) {
|
|
131
|
+
// Registration failures degrade the panel, never the GUI.
|
|
132
|
+
console.warn('[dsh-ssh] panel registration failed:', error)
|
|
133
|
+
}
|
|
134
|
+
ctx.effect(() => () => {
|
|
135
|
+
for (const dispose of disposers.splice(0)) dispose()
|
|
136
|
+
}, 'dsh-ssh: ui mounts')
|
|
137
|
+
}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-ssh surface copy: zh is the key source, en mirrors every key.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export const zh = {
|
|
6
|
+
'entry.label': 'SSH',
|
|
7
|
+
'entry.tooltip': '远程 SSH 运维面板',
|
|
8
|
+
'panel.title': '远程 SSH',
|
|
9
|
+
'panel.backToConversation': '返回会话',
|
|
10
|
+
'tab.hosts': '主机',
|
|
11
|
+
'tab.terminal': '终端',
|
|
12
|
+
'tab.transfer': '传输',
|
|
13
|
+
'tab.tunnels': '隧道',
|
|
14
|
+
'tab.cluster': '集群',
|
|
15
|
+
// hosts
|
|
16
|
+
'hosts.empty': '尚未配置主机。点击「新增主机」添加,或从 ~/.ssh/config 导入。',
|
|
17
|
+
'hosts.add': '新增主机',
|
|
18
|
+
'hosts.import': '导入 ~/.ssh/config',
|
|
19
|
+
'hosts.search': '搜索别名 / 描述 / 标签…',
|
|
20
|
+
'hosts.groupBy.label': '分组方式',
|
|
21
|
+
'hosts.groupBy.none': '不分组',
|
|
22
|
+
'hosts.groupBy.environment': '按环境分组',
|
|
23
|
+
'hosts.groupBy.tags': '按标签分组',
|
|
24
|
+
'hosts.group.ungrouped': '未设置环境',
|
|
25
|
+
'hosts.group.noTags': '无标签',
|
|
26
|
+
'hosts.group.count': '{count} 台',
|
|
27
|
+
'hosts.group.testAll': '测试全部',
|
|
28
|
+
'hosts.col.alias': '别名',
|
|
29
|
+
'hosts.col.host': '主机',
|
|
30
|
+
'hosts.col.user': '用户',
|
|
31
|
+
'hosts.col.auth': '认证',
|
|
32
|
+
'hosts.col.environment': '环境',
|
|
33
|
+
'hosts.col.tags': '标签',
|
|
34
|
+
'hosts.col.description': '备注',
|
|
35
|
+
'hosts.col.actions': '操作',
|
|
36
|
+
'hosts.test': '测试',
|
|
37
|
+
'hosts.edit': '编辑',
|
|
38
|
+
'hosts.delete': '删除',
|
|
39
|
+
'hosts.deleteConfirm': '确定删除主机「{alias}」?将同时停止其隧道。',
|
|
40
|
+
'hosts.imported': '解析 {parsed} 个配置块,新增 {added} 台主机,跳过 {skipped} 个。',
|
|
41
|
+
'hosts.proxyBadge': '代理',
|
|
42
|
+
'import.reason.wildcard': '通配符 pattern,需手动配置',
|
|
43
|
+
'import.reason.existing': '别名已存在',
|
|
44
|
+
'import.reason.match': 'Match 条件块,不支持',
|
|
45
|
+
'import.reason.invalid': '字段不合法,无法导入',
|
|
46
|
+
'import.more': '其余 {count} 个未显示',
|
|
47
|
+
'hosts.testing': '连接测试中…',
|
|
48
|
+
'hosts.testOk': '连接成功({latency} ms)',
|
|
49
|
+
'hosts.testFail': '连接失败:{error}',
|
|
50
|
+
'hosts.connected': '连接',
|
|
51
|
+
'hosts.notConnected': '未连接',
|
|
52
|
+
// host form
|
|
53
|
+
'form.title.create': '新增主机',
|
|
54
|
+
'form.title.edit': '编辑主机 {alias}',
|
|
55
|
+
'form.alias': '别名',
|
|
56
|
+
'form.aliasHint': '小写字母、数字与单连字符,操作时使用',
|
|
57
|
+
'form.host': '主机地址',
|
|
58
|
+
'form.port': '端口',
|
|
59
|
+
'form.user': '用户名',
|
|
60
|
+
'form.auth': '认证方式',
|
|
61
|
+
'form.auth.key': '密钥',
|
|
62
|
+
'form.auth.password': '密码',
|
|
63
|
+
'form.auth.agent': 'SSH Agent',
|
|
64
|
+
'form.agentPath': 'Agent 路径',
|
|
65
|
+
'form.agentPathHint': '留空自动检测(SSH_AUTH_SOCK / Windows Pageant);也可填 socket 路径或 pageant',
|
|
66
|
+
'form.authKeepHint': '编辑时密钥/密码/Agent 留空将保留原认证方式与已存凭据;如需更换认证方式请填写新凭据。',
|
|
67
|
+
'form.keyPath': '私钥路径',
|
|
68
|
+
'form.keyPathHint': '如 ~/.ssh/id_ed25519',
|
|
69
|
+
'form.passphrase': '密钥口令',
|
|
70
|
+
'form.password': '密码',
|
|
71
|
+
'form.passwordHint': '明文保存在 $DSH_HOME/dsh-ssh.json(本机私有文件)',
|
|
72
|
+
'form.passwordRequired': '密码认证需要填写密码。',
|
|
73
|
+
'form.proxyJump': '跳板机别名',
|
|
74
|
+
'form.proxyJumpHint': '逗号分隔的本地主机别名,或 [user@]host[:port] 地址,按顺序连接',
|
|
75
|
+
'form.proxyCommand': 'ProxyCommand',
|
|
76
|
+
'form.proxyCommandHint': 'OpenSSH ProxyCommand:%h 主机、%p 端口、%r 用户、%n 别名;留空或填 none 表示不使用。与跳板机别名互斥。',
|
|
77
|
+
'form.description': '备注',
|
|
78
|
+
'form.environment': '环境',
|
|
79
|
+
'form.environmentHint': '如 development / production',
|
|
80
|
+
'form.tags': '标签',
|
|
81
|
+
'form.tagsHint': '逗号分隔',
|
|
82
|
+
'form.location': '位置',
|
|
83
|
+
'form.save': '保存',
|
|
84
|
+
'form.cancel': '取消',
|
|
85
|
+
'form.required': '请填写必填字段:别名、主机地址、用户名。',
|
|
86
|
+
'form.portInvalid': '端口必须是 1-65535 之间的整数。',
|
|
87
|
+
// terminal
|
|
88
|
+
'terminal.selectHost': '选择主机',
|
|
89
|
+
'terminal.connect': '连接',
|
|
90
|
+
'terminal.disconnect': '断开',
|
|
91
|
+
'terminal.placeholder': '选择主机后点击「连接」打开远程终端。',
|
|
92
|
+
'terminal.connecting': '正在连接…',
|
|
93
|
+
'terminal.ready': '终端已连接({alias})',
|
|
94
|
+
'terminal.exited': '终端已退出({alias})',
|
|
95
|
+
'terminal.error': '终端错误:{error}',
|
|
96
|
+
'terminal.noWebSocket': '当前页面不支持 WebSocket(应用外壳没有可连接的本地主机地址),请改用浏览器打开的 Web 界面使用终端。',
|
|
97
|
+
'terminal.auth.title': '二次身份验证 (2FA / 交互式认证)',
|
|
98
|
+
'terminal.auth.submit': '提交验证码',
|
|
99
|
+
'terminal.auth.cancel': '取消',
|
|
100
|
+
'terminal.auth.placeholder': '请输入验证码或口令',
|
|
101
|
+
'terminal.auth.hint': '服务器请求进行交互式二次验证(输入仅本次生效,不落盘):',
|
|
102
|
+
// transfer
|
|
103
|
+
'transfer.selectHost': '选择主机',
|
|
104
|
+
'transfer.remotePath': '远程路径',
|
|
105
|
+
'transfer.remotePathHint': '如 /tmp/ 或 /home/user/app.tar.gz',
|
|
106
|
+
'transfer.upload': '上传',
|
|
107
|
+
'transfer.uploading': '正在上传 {file}…',
|
|
108
|
+
'transfer.download': '下载',
|
|
109
|
+
'transfer.downloading': '正在下载…',
|
|
110
|
+
'transfer.done': '完成:{bytes} 字节',
|
|
111
|
+
'transfer.failed': '传输失败:{error}',
|
|
112
|
+
'transfer.browseRemote': '浏览远程目录',
|
|
113
|
+
'transfer.refresh': '刷新',
|
|
114
|
+
'transfer.name': '名称',
|
|
115
|
+
'transfer.upLevel': '上级目录',
|
|
116
|
+
'transfer.size': '大小',
|
|
117
|
+
'transfer.modified': '修改时间',
|
|
118
|
+
'transfer.bytes': '{value} B',
|
|
119
|
+
'transfer.kib': '{value} KB',
|
|
120
|
+
'transfer.mib': '{value} MB',
|
|
121
|
+
'transfer.gib': '{value} GB',
|
|
122
|
+
'transfer.percent': '{value}%',
|
|
123
|
+
'transfer.speed': '{value}/s',
|
|
124
|
+
'transfer.dir': '目录',
|
|
125
|
+
'transfer.file': '文件',
|
|
126
|
+
// tunnels
|
|
127
|
+
'tunnel.empty': '没有活跃的隧道。',
|
|
128
|
+
'tunnel.start': '新建隧道',
|
|
129
|
+
'tunnel.alias': '主机别名',
|
|
130
|
+
'tunnel.remotePort': '远程端口',
|
|
131
|
+
'tunnel.remoteHost': '远程主机',
|
|
132
|
+
'tunnel.remoteHostHint': '默认 127.0.0.1(服务器自身)',
|
|
133
|
+
'tunnel.localPort': '本地端口',
|
|
134
|
+
'tunnel.localPortHint': '留空自动分配',
|
|
135
|
+
'tunnel.stop': '停止',
|
|
136
|
+
'tunnel.stopAll': '全部停止',
|
|
137
|
+
'tunnel.stopAllConfirm': '确定停止全部隧道吗?',
|
|
138
|
+
'tunnel.row': '{alias}: 127.0.0.1:{localPort} -> {remoteHost}:{remotePort}',
|
|
139
|
+
'tunnel.started': '隧道已建立:127.0.0.1:{localPort}',
|
|
140
|
+
'tunnel.failed': '隧道启动失败:{error}',
|
|
141
|
+
// cluster
|
|
142
|
+
'cluster.command': '命令',
|
|
143
|
+
'cluster.run': '执行',
|
|
144
|
+
'cluster.confirm': '确定在匹配的主机上执行该命令吗?该操作会真实运行在远程服务器上。',
|
|
145
|
+
'cluster.aliases': '主机别名(逗号分隔,与环境、标签至少填一项)',
|
|
146
|
+
'cluster.environment': '环境过滤',
|
|
147
|
+
'cluster.tags': '标签过滤(逗号分隔)',
|
|
148
|
+
'cluster.results': '执行结果',
|
|
149
|
+
'cluster.empty': '输入命令后点击「执行」。',
|
|
150
|
+
'cluster.noMatch': '没有匹配的主机。',
|
|
151
|
+
'cluster.ok': '成功',
|
|
152
|
+
'cluster.fail': '失败',
|
|
153
|
+
'cluster.timeout': '超时',
|
|
154
|
+
'cluster.col.alias': '主机',
|
|
155
|
+
'cluster.col.status': '状态',
|
|
156
|
+
'cluster.col.exit': '退出码',
|
|
157
|
+
'cluster.col.stdout': '标准输出',
|
|
158
|
+
'cluster.col.stderr': '标准错误',
|
|
159
|
+
'cluster.col.error': '错误',
|
|
160
|
+
'cluster.col.duration': '耗时',
|
|
161
|
+
// common
|
|
162
|
+
'common.loading': '加载中…',
|
|
163
|
+
'common.error': '出错:{error}',
|
|
164
|
+
'common.refresh': '刷新',
|
|
165
|
+
'common.confirm': '确定',
|
|
166
|
+
'error.disabled': 'SSH 插件在宿主端未启用。请前往「设置 → Web 插件 → SSH」打开 enabled 开关。',
|
|
167
|
+
} as const
|
|
168
|
+
|
|
169
|
+
export const en: Record<keyof typeof zh, string> = {
|
|
170
|
+
'entry.label': 'SSH',
|
|
171
|
+
'entry.tooltip': 'Remote SSH operations panel',
|
|
172
|
+
'panel.title': 'Remote SSH',
|
|
173
|
+
'panel.backToConversation': 'Back to chat',
|
|
174
|
+
'tab.hosts': 'Hosts',
|
|
175
|
+
'tab.terminal': 'Terminal',
|
|
176
|
+
'tab.transfer': 'Transfer',
|
|
177
|
+
'tab.tunnels': 'Tunnels',
|
|
178
|
+
'tab.cluster': 'Cluster',
|
|
179
|
+
'hosts.empty': 'No hosts configured. Click "Add host" or import from ~/.ssh/config.',
|
|
180
|
+
'hosts.add': 'Add host',
|
|
181
|
+
'hosts.import': 'Import ~/.ssh/config',
|
|
182
|
+
'hosts.search': 'Search alias / description / tags…',
|
|
183
|
+
'hosts.groupBy.label': 'Group by',
|
|
184
|
+
'hosts.groupBy.none': 'No grouping',
|
|
185
|
+
'hosts.groupBy.environment': 'Group by environment',
|
|
186
|
+
'hosts.groupBy.tags': 'Group by tags',
|
|
187
|
+
'hosts.group.ungrouped': 'No environment',
|
|
188
|
+
'hosts.group.noTags': 'No tags',
|
|
189
|
+
'hosts.group.count': '{count} hosts',
|
|
190
|
+
'hosts.group.testAll': 'Test all',
|
|
191
|
+
'hosts.col.alias': 'Alias',
|
|
192
|
+
'hosts.col.host': 'Host',
|
|
193
|
+
'hosts.col.user': 'User',
|
|
194
|
+
'hosts.col.auth': 'Auth',
|
|
195
|
+
'hosts.col.environment': 'Environment',
|
|
196
|
+
'hosts.col.tags': 'Tags',
|
|
197
|
+
'hosts.col.description': 'Description',
|
|
198
|
+
'hosts.col.actions': 'Actions',
|
|
199
|
+
'hosts.test': 'Test',
|
|
200
|
+
'hosts.edit': 'Edit',
|
|
201
|
+
'hosts.delete': 'Delete',
|
|
202
|
+
'hosts.deleteConfirm': 'Delete host "{alias}"? Its tunnels will be stopped.',
|
|
203
|
+
'hosts.imported': 'Parsed {parsed} blocks, added {added} hosts, skipped {skipped}.',
|
|
204
|
+
'hosts.proxyBadge': 'proxy',
|
|
205
|
+
'import.reason.wildcard': 'wildcard pattern — configure it by hand',
|
|
206
|
+
'import.reason.existing': 'alias already configured',
|
|
207
|
+
'import.reason.match': 'Match block — not supported',
|
|
208
|
+
'import.reason.invalid': 'invalid fields — not imported',
|
|
209
|
+
'import.more': '{count} more not shown',
|
|
210
|
+
'hosts.testing': 'Testing connection…',
|
|
211
|
+
'hosts.testOk': 'Connected ({latency} ms)',
|
|
212
|
+
'hosts.testFail': 'Connection failed: {error}',
|
|
213
|
+
'hosts.connected': 'Connect',
|
|
214
|
+
'hosts.notConnected': 'Not connected',
|
|
215
|
+
'form.title.create': 'Add host',
|
|
216
|
+
'form.title.edit': 'Edit host {alias}',
|
|
217
|
+
'form.alias': 'Alias',
|
|
218
|
+
'form.aliasHint': 'Lowercase letters, digits and single hyphens; used in every operation',
|
|
219
|
+
'form.host': 'Host',
|
|
220
|
+
'form.port': 'Port',
|
|
221
|
+
'form.user': 'User',
|
|
222
|
+
'form.auth': 'Authentication',
|
|
223
|
+
'form.auth.key': 'Key',
|
|
224
|
+
'form.auth.password': 'Password',
|
|
225
|
+
'form.auth.agent': 'SSH Agent',
|
|
226
|
+
'form.agentPath': 'Agent path',
|
|
227
|
+
'form.agentPathHint': 'Leave empty to auto-detect (SSH_AUTH_SOCK / Pageant on Windows), or set a socket path or "pageant"',
|
|
228
|
+
'form.authKeepHint': 'While editing, empty secret fields keep the stored authentication and credentials; enter new values to switch methods.',
|
|
229
|
+
'form.keyPath': 'Private key path',
|
|
230
|
+
'form.keyPathHint': 'e.g. ~/.ssh/id_ed25519',
|
|
231
|
+
'form.passphrase': 'Key passphrase',
|
|
232
|
+
'form.password': 'Password',
|
|
233
|
+
'form.passwordHint': 'Stored in plaintext in $DSH_HOME/dsh-ssh.json (private local file)',
|
|
234
|
+
'form.passwordRequired': 'Password auth requires a password.',
|
|
235
|
+
'form.proxyJump': 'Jump host aliases',
|
|
236
|
+
'form.proxyJumpHint': 'Comma-separated local aliases or [user@]host[:port] addresses, chained in order',
|
|
237
|
+
'form.proxyCommand': 'ProxyCommand',
|
|
238
|
+
'form.proxyCommandHint': 'OpenSSH ProxyCommand: %h host, %p port, %r user, %n alias; empty or none disables it. Mutually exclusive with the jump chain.',
|
|
239
|
+
'form.description': 'Description',
|
|
240
|
+
'form.environment': 'Environment',
|
|
241
|
+
'form.environmentHint': 'e.g. development / production',
|
|
242
|
+
'form.tags': 'Tags',
|
|
243
|
+
'form.tagsHint': 'Comma-separated',
|
|
244
|
+
'form.location': 'Location',
|
|
245
|
+
'form.save': 'Save',
|
|
246
|
+
'form.cancel': 'Cancel',
|
|
247
|
+
'form.required': 'Required fields missing: alias, host, user.',
|
|
248
|
+
'form.portInvalid': 'Port must be an integer between 1 and 65535.',
|
|
249
|
+
'terminal.selectHost': 'Select host',
|
|
250
|
+
'terminal.connect': 'Connect',
|
|
251
|
+
'terminal.disconnect': 'Disconnect',
|
|
252
|
+
'terminal.placeholder': 'Select a host and click "Connect" to open the remote terminal.',
|
|
253
|
+
'terminal.connecting': 'Connecting…',
|
|
254
|
+
'terminal.ready': 'Terminal connected ({alias})',
|
|
255
|
+
'terminal.exited': 'Terminal exited ({alias})',
|
|
256
|
+
'terminal.error': 'Terminal error: {error}',
|
|
257
|
+
'terminal.noWebSocket': 'This page cannot carry a WebSocket (the application shell published no local host address to reach). Open the Web UI in a browser to use the terminal.',
|
|
258
|
+
'terminal.auth.title': 'Two-Factor Authentication (2FA)',
|
|
259
|
+
'terminal.auth.submit': 'Submit Code',
|
|
260
|
+
'terminal.auth.cancel': 'Cancel',
|
|
261
|
+
'terminal.auth.placeholder': 'Enter code or passphrase',
|
|
262
|
+
'terminal.auth.hint': 'The server requested interactive 2FA (session only, never saved):',
|
|
263
|
+
'transfer.selectHost': 'Select host',
|
|
264
|
+
'transfer.remotePath': 'Remote path',
|
|
265
|
+
'transfer.remotePathHint': 'e.g. /tmp/ or /home/user/app.tar.gz',
|
|
266
|
+
'transfer.upload': 'Upload',
|
|
267
|
+
'transfer.uploading': 'Uploading {file}…',
|
|
268
|
+
'transfer.download': 'Download',
|
|
269
|
+
'transfer.downloading': 'Downloading…',
|
|
270
|
+
'transfer.done': 'Done: {bytes} bytes',
|
|
271
|
+
'transfer.failed': 'Transfer failed: {error}',
|
|
272
|
+
'transfer.browseRemote': 'Browse remote',
|
|
273
|
+
'transfer.refresh': 'Refresh',
|
|
274
|
+
'transfer.name': 'Name',
|
|
275
|
+
'transfer.upLevel': 'Parent directory',
|
|
276
|
+
'transfer.size': 'Size',
|
|
277
|
+
'transfer.modified': 'Modified',
|
|
278
|
+
'transfer.bytes': '{value} B',
|
|
279
|
+
'transfer.kib': '{value} KB',
|
|
280
|
+
'transfer.mib': '{value} MB',
|
|
281
|
+
'transfer.gib': '{value} GB',
|
|
282
|
+
'transfer.percent': '{value}%',
|
|
283
|
+
'transfer.speed': '{value}/s',
|
|
284
|
+
'transfer.dir': 'Directory',
|
|
285
|
+
'transfer.file': 'File',
|
|
286
|
+
'tunnel.empty': 'No active tunnels.',
|
|
287
|
+
'tunnel.start': 'New tunnel',
|
|
288
|
+
'tunnel.alias': 'Host alias',
|
|
289
|
+
'tunnel.remotePort': 'Remote port',
|
|
290
|
+
'tunnel.remoteHost': 'Remote host',
|
|
291
|
+
'tunnel.remoteHostHint': 'Default 127.0.0.1 (the server itself)',
|
|
292
|
+
'tunnel.localPort': 'Local port',
|
|
293
|
+
'tunnel.localPortHint': 'Leave empty for auto-assign',
|
|
294
|
+
'tunnel.stop': 'Stop',
|
|
295
|
+
'tunnel.stopAll': 'Stop all',
|
|
296
|
+
'tunnel.stopAllConfirm': 'Stop all tunnels?',
|
|
297
|
+
'tunnel.row': '{alias}: 127.0.0.1:{localPort} -> {remoteHost}:{remotePort}',
|
|
298
|
+
'tunnel.started': 'Tunnel up: 127.0.0.1:{localPort}',
|
|
299
|
+
'tunnel.failed': 'Tunnel failed: {error}',
|
|
300
|
+
'cluster.command': 'Command',
|
|
301
|
+
'cluster.run': 'Run',
|
|
302
|
+
'cluster.confirm': 'Run this command on the matching hosts? It executes for real on the remote servers.',
|
|
303
|
+
'cluster.aliases': 'Host aliases (comma-separated; require at least one filter)',
|
|
304
|
+
'cluster.environment': 'Environment filter',
|
|
305
|
+
'cluster.tags': 'Tag filter (comma-separated)',
|
|
306
|
+
'cluster.results': 'Results',
|
|
307
|
+
'cluster.empty': 'Type a command and click "Run".',
|
|
308
|
+
'cluster.noMatch': 'No hosts matched.',
|
|
309
|
+
'cluster.ok': 'OK',
|
|
310
|
+
'cluster.fail': 'Failed',
|
|
311
|
+
'cluster.timeout': 'Timed out',
|
|
312
|
+
'cluster.col.alias': 'Host',
|
|
313
|
+
'cluster.col.status': 'Status',
|
|
314
|
+
'cluster.col.exit': 'Exit',
|
|
315
|
+
'cluster.col.stdout': 'Stdout',
|
|
316
|
+
'cluster.col.stderr': 'Stderr',
|
|
317
|
+
'cluster.col.error': 'Error',
|
|
318
|
+
'cluster.col.duration': 'Duration',
|
|
319
|
+
'common.loading': 'Loading…',
|
|
320
|
+
'common.error': 'Error: {error}',
|
|
321
|
+
'common.refresh': 'Refresh',
|
|
322
|
+
'common.confirm': 'Confirm',
|
|
323
|
+
'error.disabled': 'The SSH plugin is disabled on the host. Please enable it in Settings → Web Plugins → SSH.',
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** Locale key union. */
|
|
327
|
+
export type SshKey = keyof typeof zh
|
|
328
|
+
|
|
329
|
+
/** Tiny interpolation: {name} -> value. */
|
|
330
|
+
export function t(dictionary: Record<string, string>, key: string, values?: Record<string, string | number>): string {
|
|
331
|
+
let text = dictionary[key] ?? key
|
|
332
|
+
if (values !== undefined) {
|
|
333
|
+
for (const [name, value] of Object.entries(values)) {
|
|
334
|
+
text = text.replaceAll(`{${name}}`, String(value))
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return text
|
|
338
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
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 {} from '@deepseek-ai/dsh-client-ui-slots'
|
|
25
|
+
import type {} from '@deepseek-ai/dsh-client-ui-layout/client'
|
|
26
|
+
import type {} from '@deepseek-ai/dsh-client-ui-sidebar/client'
|
|
27
|
+
import type { SshApi } from './api.ts'
|
|
28
|
+
import { SSH_PANEL_ID, type PanelController } from './panel/controller.ts'
|
|
29
|
+
import { tt, type TerminalFontSource } from './panel/helpers.ts'
|
|
30
|
+
import { SshPanel } from './panel/SshPanel.tsx'
|
|
31
|
+
import css from './panel/panel.module.css'
|
|
32
|
+
|
|
33
|
+
/** The panel id shared by the sidebar row and the main-slot occupant. */
|
|
34
|
+
export { SSH_PANEL_ID }
|
|
35
|
+
|
|
36
|
+
/** Row order among the shell's global panel rows (Plugins 0, Schedule 10, board 20, skill center 30). */
|
|
37
|
+
const PANEL_ORDER = 40
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The sidebar row glyph the shell asks for at its own size and active state.
|
|
41
|
+
* The shell owns the button, label, tooltip and rail geometry; this component
|
|
42
|
+
* draws only the glyph, like every other panel row.
|
|
43
|
+
*
|
|
44
|
+
* The glyph carries `data-dsh-panel-entry` because it is the only DOM this
|
|
45
|
+
* panel's own code owns inside that shell-owned row: the L2 contract (skins)
|
|
46
|
+
* resolves which row belongs to which plugin through it, since the shell
|
|
47
|
+
* stamps no per-entry hook of its own (see contracts/semantic-attrs-v1.md).
|
|
48
|
+
* @param props - the shell's icon share: square edge and selection state.
|
|
49
|
+
* @returns the decorative terminal glyph.
|
|
50
|
+
*/
|
|
51
|
+
export function SshPanelIcon({ size }: { size: number; active: boolean }): React.ReactElement {
|
|
52
|
+
return (
|
|
53
|
+
<svg
|
|
54
|
+
data-dsh-panel-entry={SSH_PANEL_ID}
|
|
55
|
+
viewBox="0 0 16 16"
|
|
56
|
+
width={size}
|
|
57
|
+
height={size}
|
|
58
|
+
fill="none"
|
|
59
|
+
stroke="currentColor"
|
|
60
|
+
strokeWidth="1.5"
|
|
61
|
+
strokeLinecap="round"
|
|
62
|
+
strokeLinejoin="round"
|
|
63
|
+
aria-hidden="true"
|
|
64
|
+
>
|
|
65
|
+
<rect x="1.75" y="2.25" width="12.5" height="11.5" rx="1.75" />
|
|
66
|
+
<path d="M4.25 5.25l2.75 2.75-2.75 2.75" />
|
|
67
|
+
<path d="M8.5 10.75h3.25" />
|
|
68
|
+
</svg>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The main-slot page. The layout mounts it only while this panel is selected;
|
|
74
|
+
* the wrapper carries the pinned `data-dsh-ssh-view` semantic anchor (L2
|
|
75
|
+
* contract, skins) the takeover container used to own.
|
|
76
|
+
* @param props - the framework main-slot share plus this entry's injected face.
|
|
77
|
+
* @returns the SSH panel page.
|
|
78
|
+
*/
|
|
79
|
+
export function SshPanelPage({ controller, api, terminalFont }: {
|
|
80
|
+
controller: PanelController
|
|
81
|
+
api: SshApi
|
|
82
|
+
terminalFont?: TerminalFontSource
|
|
83
|
+
}): React.ReactElement {
|
|
84
|
+
return (
|
|
85
|
+
<div className={css.view} data-dsh-ssh-view="" data-dsh-plugin="ssh">
|
|
86
|
+
<SshPanel controller={controller} api={api} terminalFont={terminalFont} />
|
|
87
|
+
</div>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** The injected face both registrations receive. */
|
|
92
|
+
interface PanelFace {
|
|
93
|
+
controller: PanelController
|
|
94
|
+
api: SshApi
|
|
95
|
+
terminalFont?: TerminalFontSource
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Register the SSH panel's sidebar row and center-column page.
|
|
100
|
+
*
|
|
101
|
+
* Both seats are declared by shell plugins this package does not depend on at
|
|
102
|
+
* runtime, so each registration is wrapped in `ctx.slots.inject`: the callback
|
|
103
|
+
* runs only after the owning entry declares the seat, and a shell that never
|
|
104
|
+
* declares it leaves the panel simply absent instead of failing boot.
|
|
105
|
+
* @param ctx - client root context (services: slots).
|
|
106
|
+
* @param controller - the controller the page and the row drive.
|
|
107
|
+
* @param api - the SSH API client the page operates through.
|
|
108
|
+
* @param terminalFont - live terminal-font setting source (issue #577).
|
|
109
|
+
* @returns disposer releasing both registrations.
|
|
110
|
+
*/
|
|
111
|
+
export function registerSshPanel(
|
|
112
|
+
ctx: ClientContext,
|
|
113
|
+
controller: PanelController,
|
|
114
|
+
api: SshApi,
|
|
115
|
+
terminalFont?: TerminalFontSource,
|
|
116
|
+
): () => void {
|
|
117
|
+
const slots = ctx.slots as {
|
|
118
|
+
inject(key: string, callback: () => () => void): () => void
|
|
119
|
+
register(options: Record<string, unknown>, component: unknown): () => void
|
|
120
|
+
}
|
|
121
|
+
const disposers: Array<() => void> = []
|
|
122
|
+
|
|
123
|
+
disposers.push(slots.inject('sidebar.panellist', () => slots.register({
|
|
124
|
+
name: 'sidebar.panellist',
|
|
125
|
+
id: SSH_PANEL_ID,
|
|
126
|
+
order: PANEL_ORDER,
|
|
127
|
+
// The shell resolves this through resolveSlotLabel on every locale change,
|
|
128
|
+
// so the module-level translate reads the active language at call time.
|
|
129
|
+
label: () => tt('entry.label'),
|
|
130
|
+
}, SshPanelIcon)))
|
|
131
|
+
|
|
132
|
+
disposers.push(slots.inject('main', () => slots.register({
|
|
133
|
+
name: 'main',
|
|
134
|
+
key: SSH_PANEL_ID,
|
|
135
|
+
inject: (): PanelFace => ({ controller, api, terminalFont }),
|
|
136
|
+
}, SshPanelPage as never)))
|
|
137
|
+
|
|
138
|
+
return () => {
|
|
139
|
+
for (const dispose of disposers.splice(0)) dispose()
|
|
140
|
+
}
|
|
141
|
+
}
|