@linxin666/dsh-ssh 0.2.3 → 0.2.5

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/lib/index.js CHANGED
@@ -2137,11 +2137,11 @@ var SshEngine = class {
2137
2137
  stopAllTunnels(this, alias);
2138
2138
  disposeRecord(this, alias);
2139
2139
  }
2140
- /** Probe connectivity: connect, run `true`, close. */
2140
+ /** Probe connectivity with a cross-platform shell command. */
2141
2141
  async test(alias) {
2142
2142
  const started = Date.now();
2143
2143
  try {
2144
- const result = await this.exec(alias, "true", 1e4);
2144
+ const result = await this.exec(alias, "echo ok", 1e4);
2145
2145
  return result.success ? {
2146
2146
  ok: true,
2147
2147
  latencyMs: result.durationMs
@@ -57,6 +57,7 @@ export declare const zh: {
57
57
  readonly 'form.passphrase': "密钥口令";
58
58
  readonly 'form.password': "密码";
59
59
  readonly 'form.passwordHint': "明文保存在 ~/.dsh/dsh-ssh.json(本机私有文件)";
60
+ readonly 'form.passwordRequired': "密码认证需要填写密码。";
60
61
  readonly 'form.proxyJump': "跳板机别名";
61
62
  readonly 'form.proxyJumpHint': "逗号分隔的本地主机别名,按顺序连接";
62
63
  readonly 'form.description': "备注";
@@ -81,7 +81,7 @@ export declare class SshEngine {
81
81
  * connection — the next operation re-connects from the current config.
82
82
  */
83
83
  dropAlias(alias: string): void;
84
- /** Probe connectivity: connect, run `true`, close. */
84
+ /** Probe connectivity with a cross-platform shell command. */
85
85
  test(alias: string): Promise<TestResult>;
86
86
  /** Close every pooled connection and tunnel. */
87
87
  dispose(): void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-ssh",
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": "0.2.3",
4
+ "version": "0.2.5",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": "^22.19.0 || >=24.0.0"
@@ -49,18 +49,18 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "@deepseek-ai/cordis": "^4.0.1",
52
- "@deepseek-ai/dsh-client-connection": "^0.1.0-rc.7",
53
- "@deepseek-ai/dsh-client-locale": "^0.1.0-rc.7",
54
- "@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.7",
55
- "@deepseek-ai/dsh-client-ui-settings": "^0.1.0-rc.7",
56
- "@deepseek-ai/dsh-client-ui-slots": "^0.1.0-rc.7",
57
- "@deepseek-ai/dsh-host-webserver": "^0.1.0-rc.7",
58
- "@deepseek-ai/dsh-llm": "^0.1.0-rc.7",
59
- "@deepseek-ai/dsh-scope": "^0.1.0-rc.7",
60
- "@deepseek-ai/dsh-settings": "^0.1.0-rc.7",
61
- "@deepseek-ai/dsh-system-prompt": "^0.1.0-rc.7",
62
- "@deepseek-ai/dsh-timeout": "^0.1.0-rc.7",
63
- "@deepseek-ai/dsh-tools": "^0.1.0-rc.7",
52
+ "@deepseek-ai/dsh-client-connection": "^0.1.0-rc.8",
53
+ "@deepseek-ai/dsh-client-locale": "^0.1.0-rc.8",
54
+ "@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.8",
55
+ "@deepseek-ai/dsh-client-ui-settings": "^0.1.0-rc.8",
56
+ "@deepseek-ai/dsh-client-ui-slots": "^0.1.0-rc.8",
57
+ "@deepseek-ai/dsh-host-webserver": "^0.1.0-rc.8",
58
+ "@deepseek-ai/dsh-llm": "^0.1.0-rc.8",
59
+ "@deepseek-ai/dsh-scope": "^0.1.0-rc.8",
60
+ "@deepseek-ai/dsh-settings": "^0.1.0-rc.8",
61
+ "@deepseek-ai/dsh-system-prompt": "^0.1.0-rc.8",
62
+ "@deepseek-ai/dsh-timeout": "^0.1.0-rc.8",
63
+ "@deepseek-ai/dsh-tools": "^0.1.0-rc.8",
64
64
  "@types/node": "^22.20.0",
65
65
  "@types/react": "~18.3.1",
66
66
  "@types/react-dom": "^18.3.5",
package/src/client/api.ts CHANGED
@@ -34,6 +34,17 @@ export class SshApiError extends Error {
34
34
  }
35
35
  }
36
36
 
37
+ /** Extract the `.error` message from a JSON error body; undefined when absent. */
38
+ function extractError(text: string): string | undefined {
39
+ if (text === '') return undefined
40
+ try {
41
+ const parsed = JSON.parse(text) as { error?: unknown } | null
42
+ return typeof parsed?.error === 'string' ? parsed.error : undefined
43
+ } catch {
44
+ return undefined
45
+ }
46
+ }
47
+
37
48
  /** Parse a JSON response or throw an SshApiError. */
38
49
  async function readJson<T>(response: Response): Promise<T> {
39
50
  let body: unknown
@@ -219,7 +230,9 @@ export class SshApi {
219
230
  body: file,
220
231
  })
221
232
  if (!response.ok || response.body === null) {
222
- throw new SshApiError(`upload failed: HTTP ${response.status}`)
233
+ const text = await response.text().catch(() => '')
234
+ const error = extractError(text)
235
+ throw new SshApiError(error ?? `upload failed: HTTP ${response.status}`)
223
236
  }
224
237
  const reader = response.body.getReader()
225
238
  const decoder = new TextDecoder()
@@ -268,7 +281,8 @@ export class SshApi {
268
281
  const response = await fetch(SSH_API.download + query({ alias, remotePath }))
269
282
  if (!response.ok || response.body === null) {
270
283
  const text = await response.text().catch(() => '')
271
- throw new SshApiError(text !== '' && text.startsWith('{') ? text : `download failed: HTTP ${response.status}`)
284
+ const error = extractError(text)
285
+ throw new SshApiError(error ?? `download failed: HTTP ${response.status}`)
272
286
  }
273
287
  const total = Number(response.headers.get('content-length') ?? '0')
274
288
  const disposition = response.headers.get('content-disposition') ?? ''
@@ -60,6 +60,7 @@ export const zh = {
60
60
  'form.passphrase': '密钥口令',
61
61
  'form.password': '密码',
62
62
  'form.passwordHint': '明文保存在 ~/.dsh/dsh-ssh.json(本机私有文件)',
63
+ 'form.passwordRequired': '密码认证需要填写密码。',
63
64
  'form.proxyJump': '跳板机别名',
64
65
  'form.proxyJumpHint': '逗号分隔的本地主机别名,按顺序连接',
65
66
  'form.description': '备注',
@@ -203,6 +204,7 @@ export const en: Record<keyof typeof zh, string> = {
203
204
  'form.passphrase': 'Key passphrase',
204
205
  'form.password': 'Password',
205
206
  'form.passwordHint': 'Stored in plaintext in ~/.dsh/dsh-ssh.json (private local file)',
207
+ 'form.passwordRequired': 'Password auth requires a password.',
206
208
  'form.proxyJump': 'Jump host aliases',
207
209
  'form.proxyJumpHint': 'Comma-separated local aliases, chained in order',
208
210
  'form.description': 'Description',
@@ -92,6 +92,12 @@ export function HostFormDialog({ api, editing, onClose, onSaved }: HostFormDialo
92
92
  setError(tt('form.portInvalid'))
93
93
  return
94
94
  }
95
+ // A password-auth host needs a password on create; when editing, a blank
96
+ // secret field preserves the stored credential instead.
97
+ if (editing == null && form.authKind === 'password' && form.password === '') {
98
+ setError(tt('form.passwordRequired'))
99
+ return
100
+ }
95
101
  // Secrets are never echoed back by the API: when editing and the secret
96
102
  // fields are left empty, the auth block is omitted so the stored
97
103
  // authentication is preserved.
@@ -124,17 +124,38 @@ export function TerminalTab({ api, presetAlias, requestId, terminalFont }: Termi
124
124
  // Unmount cleanup (never touches state on an unmounting component).
125
125
  useEffect(() => () => { teardown() }, [])
126
126
 
127
- // Keep the terminal fitted to its container while connected.
127
+ // Keep the terminal fitted to its container. A window resize is only one
128
+ // trigger: the status banner appearing after connect, panel resizes, and
129
+ // sidebar toggles all change the container without a window resize, so the
130
+ // container itself is observed (otherwise the viewport keeps the pre-banner
131
+ // height and the last line is clipped below the fold). ResizeObserver may
132
+ // be absent (jsdom tests); the window listener then remains the only path.
128
133
  useEffect(() => {
129
- const onResize = (): void => {
134
+ let lastCols = -1
135
+ let lastRows = -1
136
+ const sync = (): void => {
130
137
  const term = termRef.current
131
138
  const fit = fitRef.current
132
139
  if (term === null || fit === null) return
133
140
  fit.fit()
134
- connRef.current?.resize(term.cols, term.rows)
141
+ const conn = connRef.current
142
+ if (conn !== null && (term.cols !== lastCols || term.rows !== lastRows)) {
143
+ lastCols = term.cols
144
+ lastRows = term.rows
145
+ conn.resize(term.cols, term.rows)
146
+ }
147
+ }
148
+ window.addEventListener('resize', sync)
149
+ const container = containerRef.current
150
+ if (container === null || typeof ResizeObserver === 'undefined') {
151
+ return () => { window.removeEventListener('resize', sync) }
152
+ }
153
+ const observer = new ResizeObserver(() => { sync() })
154
+ observer.observe(container)
155
+ return () => {
156
+ observer.disconnect()
157
+ window.removeEventListener('resize', sync)
135
158
  }
136
- window.addEventListener('resize', onResize)
137
- return () => { window.removeEventListener('resize', onResize) }
138
159
  }, [])
139
160
 
140
161
  const connect = (): void => {
@@ -703,8 +703,10 @@ html[data-dsh-ssh-active]:not([data-dsh-taskboard-active]) [class*='centerCol']
703
703
 
704
704
  .termContainer {
705
705
  position: absolute;
706
- inset: 0;
707
- padding: 8px 10px;
706
+ /* Inset offsets, not padding: FitAddon measures this element's height as
707
+ the drawable area, so padding here would be measured as terminal space
708
+ and clip the bottom line under a global border-box reset. */
709
+ inset: 8px 10px;
708
710
  }
709
711
 
710
712
  .termPlaceholder {
package/src/engine.ts CHANGED
@@ -148,11 +148,11 @@ export class SshEngine {
148
148
 
149
149
  // ------------------------------------------------------------- misc
150
150
 
151
- /** Probe connectivity: connect, run `true`, close. */
151
+ /** Probe connectivity with a cross-platform shell command. */
152
152
  async test(alias: string): Promise<TestResult> {
153
153
  const started = Date.now()
154
154
  try {
155
- const result = await this.exec(alias, 'true', 10_000)
155
+ const result = await this.exec(alias, 'echo ok', 10_000)
156
156
  return result.success
157
157
  ? { ok: true, latencyMs: result.durationMs }
158
158
  : { ok: false, latencyMs: result.durationMs, error: 'remote exit code ' + result.exitCode }
@@ -167,4 +167,4 @@ export class SshEngine {
167
167
  for (const id of [...this.tunnels.keys()]) stopTunnel(this, id)
168
168
  for (const alias of [...this.pool.keys()]) disposeRecord(this, alias)
169
169
  }
170
- }
170
+ }