dsh-remote 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +2 -0
- package/README.md +2 -0
- package/lib/client.js +3 -3
- package/lib/deck-bridge.js +17 -0
- package/lib/errors.js +5 -2
- package/lib/pool.js +46 -4
- package/lib/update.js +163 -34
- package/package.json +4 -3
package/README.en.md
CHANGED
|
@@ -18,6 +18,8 @@ Use the normal layout or choose the optional **three-column IDE layout** to view
|
|
|
18
18
|
|
|
19
19
|
<img src="https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-ide.png" alt="DSH remote IDE with file tree, native code editor and agent conversation" width="1200"/>
|
|
20
20
|
|
|
21
|
+
[1.3.1 release notes](https://github.com/flymysql/dsh-remote/blob/main/docs/release/1.3.1.md): SSH recovery, proxy-aware updates and verified official GitHub fallback.
|
|
22
|
+
|
|
21
23
|
## Install
|
|
22
24
|
|
|
23
25
|
```bash
|
package/README.md
CHANGED
|
@@ -26,6 +26,8 @@ dsh plugin --profile web add dsh-remote
|
|
|
26
26
|
|
|
27
27
|
安装或升级后,重启 DSH Web 并刷新页面。自动更新状态在设置 → 远程工作区 → 插件偏好中查看。
|
|
28
28
|
|
|
29
|
+
[1.3.1 更新说明](https://github.com/flymysql/dsh-remote/blob/main/docs/release/1.3.1.md):SSH 连接恢复、代理网络更新与官方 GitHub 下载回退。
|
|
30
|
+
|
|
29
31
|
## 3 步开始
|
|
30
32
|
|
|
31
33
|
1. **配置主机**:设置 → 远程工作区,编辑 SSH 配置或保存主机凭据;直接写在 `~/.ssh/config` 里的 Host 会出现在主机列表中,点该行的「…」菜单 →「编辑」即可保存成机器并填写登录密码(保存前后入口都是同一个「…」菜单)。打开设置会自动检查连通性,无需手动“连接”。
|
package/lib/client.js
CHANGED
|
@@ -27,7 +27,7 @@ window.__ModuleLoader__.load({
|
|
|
27
27
|
|
|
28
28
|
const React = require('react')
|
|
29
29
|
const name = 'dsh-remote'
|
|
30
|
-
const CLIENT_VERSION = '1.3.
|
|
30
|
+
const CLIENT_VERSION = '1.3.1'
|
|
31
31
|
|
|
32
32
|
// ── optional host primitives ────────────────────────────────────────────
|
|
33
33
|
// Issue #74: a remote session's .md link must open over SFTP, NOT via the
|
|
@@ -603,7 +603,7 @@ window.__ModuleLoader__.load({
|
|
|
603
603
|
'settings.updateAppliedNoReload': '✅ 已更新到 v{to}({from} → {to})。重启 Harness 生效。',
|
|
604
604
|
'settings.updatePendingReload': '磁盘已是 v{disk},运行中仍是 v{loaded}。请完全重启 DSH 并刷新页面。',
|
|
605
605
|
'settings.selfUpdateBlocked': 'ℹ️ 当前是 link:/开发模式安装(不在 node_modules 下),已禁止自动更新以免覆盖源码——请在你的源码仓库里更新。',
|
|
606
|
-
'settings.updateRegistryError': '
|
|
606
|
+
'settings.updateRegistryError': '更新来源查询失败:{msg}',
|
|
607
607
|
'settings.updateFailed': '更新失败',
|
|
608
608
|
'settings.updateFailedMsg': '更新失败: {msg}',
|
|
609
609
|
'settings.registryUnreachable': '无法连接 npm registry',
|
|
@@ -1222,7 +1222,7 @@ window.__ModuleLoader__.load({
|
|
|
1222
1222
|
'settings.updateAppliedNoReload': '✅ Updated to v{to} ({from} → {to}). Restart Harness to apply.',
|
|
1223
1223
|
'settings.updatePendingReload': 'v{disk} is on disk; v{loaded} is still running. Restart DSH and refresh this page.',
|
|
1224
1224
|
'settings.selfUpdateBlocked': 'ℹ️ This is a link:/dev install (not under node_modules), so self-update is disabled to avoid overwriting source — update it from its source repo.',
|
|
1225
|
-
'settings.updateRegistryError': '
|
|
1225
|
+
'settings.updateRegistryError': 'Update sources unavailable: {msg}',
|
|
1226
1226
|
'settings.updateFailed': 'Update failed',
|
|
1227
1227
|
'settings.updateFailedMsg': 'Update failed: {msg}',
|
|
1228
1228
|
'settings.registryUnreachable': 'Cannot reach the npm registry',
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// lib/deck-bridge.js —— 给 dsh-mattpocock-skills-deck 的远端工作区适配层用的公开入口。
|
|
2
|
+
//
|
|
3
|
+
// 背景:外挂插件 dsh-deck-remote-exec 让 deck 在 dsh-remote 的远端工作区里工作,
|
|
4
|
+
// 它需要的只是 dsh-remote 已有的几个纯能力(镜像识别、路径翻译、SSH 连接池)。
|
|
5
|
+
// 在此之前它靠「绝对路径动态 import lib/*.js」绕过 package.json 的 exports 限制,
|
|
6
|
+
// 因为那些内部模块没有公开导出。这种做法依赖 dsh-remote 的内部文件布局,
|
|
7
|
+
// 一旦文件改名或 exports 收紧就会失效,而且无法被 Node 的模块解析静态检查。
|
|
8
|
+
//
|
|
9
|
+
// 本文件把这些能力里插件实际用到的符号正式导出,插件改成
|
|
10
|
+
// `import { ... } from 'dsh-remote/deck-bridge'` 即可,不再碰内部路径。
|
|
11
|
+
// 只导出插件真正需要的 6 个符号,不把整个内部模块摊开——公开面越小,
|
|
12
|
+
// 内部实现越能自由演进;要加符号时按插件的实际需要再加。
|
|
13
|
+
//
|
|
14
|
+
// 这些函数/类本身的实现仍在各自原模块里,这里只做转发,零逻辑。
|
|
15
|
+
export { resolveMirror } from './binding.js'
|
|
16
|
+
export { SystemOpenSshPool } from './openssh.js'
|
|
17
|
+
export { resolveRemoteWorkspacePath, relPathUnder, remoteDirname, shq } from './paths.js'
|
package/lib/errors.js
CHANGED
|
@@ -55,10 +55,13 @@ export function classifyError(err, opts = {}) {
|
|
|
55
55
|
// the message a user sees when the port is open but nothing speaks SSH on it,
|
|
56
56
|
// or when a firewall/security group cuts the connection after the TCP accept;
|
|
57
57
|
// it is indistinguishable from "wrong credentials" unless it is classified.
|
|
58
|
-
if (/
|
|
58
|
+
if (/handshake failed|no matching (?:key exchange|host key|cipher|kex|mac)|no matching.*(?:algorithm|cipher)|unsupported.*algorithm/i.test(msg)) {
|
|
59
|
+
return { category: 'network', hint: `SSH 握手未完成${where}:客户端与服务器的 SSH 算法协商失败。若本机 ssh 能连接,请在主机编辑页把「连接后端」改为 openssh 后测试;插件不会自动启用弱算法或跳过主机指纹校验。`, raw: msg }
|
|
60
|
+
}
|
|
61
|
+
if (/connection lost before handshake/i.test(msg)) {
|
|
59
62
|
return {
|
|
60
63
|
category: 'network',
|
|
61
|
-
hint: `SSH 握手未完成${where}
|
|
64
|
+
hint: `SSH 握手未完成${where}:连接在 SSH 认证前断开,当前错误无法确定是服务端限流、网络设备断开还是协议兼容问题,也不能据此判断密码错误。请稍后重试;若同一台电脑的 ssh 可以连接,请在主机编辑页把「连接后端」改为 openssh 后测试。持续失败时再检查 sshd 日志及来源 IP 限制。`,
|
|
62
65
|
raw: msg,
|
|
63
66
|
}
|
|
64
67
|
}
|
package/lib/pool.js
CHANGED
|
@@ -7,6 +7,7 @@ import { truncate } from './paths.js'
|
|
|
7
7
|
import { createHostKeyGuard } from './hostkey.js'
|
|
8
8
|
import { buildSftpSurface } from './sftp-surface.js'
|
|
9
9
|
import { friendlyMessage } from './errors.js'
|
|
10
|
+
import { setTimeout as delay } from 'node:timers/promises'
|
|
10
11
|
import { SystemOpenSshPool, isSystemOpenSshBackend } from './openssh.js'
|
|
11
12
|
|
|
12
13
|
const { Client } = ssh2
|
|
@@ -323,7 +324,7 @@ export class SshPool {
|
|
|
323
324
|
if (this.client) return Promise.resolve(this.client)
|
|
324
325
|
if (this.connecting) return this.connecting
|
|
325
326
|
const epoch = this.epoch
|
|
326
|
-
const pending = this.
|
|
327
|
+
const pending = this._connectWithRetry(epoch)
|
|
327
328
|
this.connecting = pending
|
|
328
329
|
const clear = () => {
|
|
329
330
|
if (this.epoch === epoch && this.connecting === pending) this.connecting = null
|
|
@@ -332,22 +333,48 @@ export class SshPool {
|
|
|
332
333
|
return pending
|
|
333
334
|
}
|
|
334
335
|
|
|
336
|
+
async _connectWithRetry(epoch) {
|
|
337
|
+
try { return await this._doConnect(epoch) }
|
|
338
|
+
catch (error) {
|
|
339
|
+
if (error.code !== 'SSH_HANDSHAKE_CLOSED' || this.epoch !== epoch) throw error
|
|
340
|
+
// MaxStartups / middlebox resets may be transient. Share ONE bounded
|
|
341
|
+
// retry across all callers; never replay an authenticated command.
|
|
342
|
+
await delay(350)
|
|
343
|
+
if (this.epoch !== epoch) throw new Error('ssh target changed during handshake retry')
|
|
344
|
+
return this._doConnect(epoch)
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
335
348
|
async _doConnect(epoch) {
|
|
336
349
|
const isCurrent = () => this.epoch === epoch
|
|
350
|
+
const target = { host: this.config.host, port: this.config.port }
|
|
337
351
|
const knownHostsFile = typeof this._knownHostsFile === 'function' ? this._knownHostsFile() : this._knownHostsFile
|
|
338
352
|
const guard = createHostKeyGuard(this.config, knownHostsFile)
|
|
339
353
|
const client = new Client()
|
|
340
|
-
|
|
354
|
+
this._connectingClient = client
|
|
355
|
+
let settled = false, handshakeCompleted = false
|
|
356
|
+
client.on('handshake', () => { handshakeCompleted = true })
|
|
341
357
|
// Every connect-stage failure is classified HERE, at the layer that knows
|
|
342
358
|
// which machine was being dialed: a bare ssh2 errno ("Timed out while
|
|
343
359
|
// waiting for handshake") names no host, and on a multi-machine plugin the
|
|
344
360
|
// user cannot tell WHICH box failed. friendlyMessage is idempotent, so
|
|
345
361
|
// callers that classify again (rw_connect, routes) do not double-wrap.
|
|
346
|
-
const classify = (err) =>
|
|
362
|
+
const classify = (err) => {
|
|
363
|
+
const error = new Error(friendlyMessage(err, target))
|
|
364
|
+
error.cause = err
|
|
365
|
+
if (!handshakeCompleted && /^(?:Connection lost before handshake|ssh connection closed|read ECONNRESET)$/i.test(String(err.message || err))) error.code = 'SSH_HANDSHAKE_CLOSED'
|
|
366
|
+
return error
|
|
367
|
+
}
|
|
347
368
|
const fail = (err) => {
|
|
348
369
|
if (settled) return
|
|
349
370
|
settled = true
|
|
350
371
|
if (isCurrent() && this.client === client) this.client = null
|
|
372
|
+
if (this._connectingClient === client) this._connectingClient = null
|
|
373
|
+
try { client.destroy() } catch {}
|
|
374
|
+
if (isCurrent() && this.proxyPool) {
|
|
375
|
+
try { this.proxyPool.close() } catch {}
|
|
376
|
+
this.proxyPool = null
|
|
377
|
+
}
|
|
351
378
|
throw classify(guard.lastError ? new Error(guard.lastError) : err)
|
|
352
379
|
}
|
|
353
380
|
|
|
@@ -408,9 +435,17 @@ export class SshPool {
|
|
|
408
435
|
if (settled) return
|
|
409
436
|
settled = true
|
|
410
437
|
if (isCurrent() && this.client === client) this.client = null
|
|
411
|
-
|
|
438
|
+
if (this._connectingClient === client) this._connectingClient = null
|
|
439
|
+
const failure = classify(guard.lastError ? new Error(guard.lastError) : err)
|
|
440
|
+
if (isCurrent() && this.proxyPool) {
|
|
441
|
+
try { this.proxyPool.close() } catch {}
|
|
442
|
+
this.proxyPool = null
|
|
443
|
+
}
|
|
444
|
+
try { client.destroy() } catch {}
|
|
445
|
+
reject(failure)
|
|
412
446
|
}
|
|
413
447
|
client.on('ready', () => {
|
|
448
|
+
if (this._connectingClient === client) this._connectingClient = null
|
|
414
449
|
if (settled) return
|
|
415
450
|
settled = true
|
|
416
451
|
if (!isCurrent()) {
|
|
@@ -521,6 +556,7 @@ export class SshPool {
|
|
|
521
556
|
// Convert it into a normal rejection so every caller's try/catch —
|
|
522
557
|
// boot restore, test-connect, rw_connect — sees a regular failure.
|
|
523
558
|
try {
|
|
559
|
+
if (!isCurrent() || settled) throw new Error('ssh target changed during connect')
|
|
524
560
|
client.connect(opts)
|
|
525
561
|
} catch (err) {
|
|
526
562
|
rejectOnce(err)
|
|
@@ -982,6 +1018,9 @@ export class SshPool {
|
|
|
982
1018
|
const client = this.client
|
|
983
1019
|
this.client = null
|
|
984
1020
|
this._dropSftpSession()
|
|
1021
|
+
const pendingClient = this._connectingClient
|
|
1022
|
+
this._connectingClient = null
|
|
1023
|
+
if (pendingClient) { try { pendingClient.destroy() } catch {} }
|
|
985
1024
|
const pending = this.connecting
|
|
986
1025
|
this.connecting = null
|
|
987
1026
|
if (pending && typeof pending.catch === 'function') {
|
|
@@ -1008,6 +1047,9 @@ export class SshPool {
|
|
|
1008
1047
|
const client = this.client
|
|
1009
1048
|
this.client = null
|
|
1010
1049
|
this._dropSftpSession()
|
|
1050
|
+
const pendingClient = this._connectingClient
|
|
1051
|
+
this._connectingClient = null
|
|
1052
|
+
if (pendingClient) { try { pendingClient.destroy() } catch {} }
|
|
1011
1053
|
const pending = this.connecting
|
|
1012
1054
|
this.connecting = null
|
|
1013
1055
|
if (pending && typeof pending.catch === 'function') {
|
package/lib/update.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// files with the newer npm tarball. This module owns the version check and the
|
|
6
6
|
// tarball apply:
|
|
7
7
|
//
|
|
8
|
-
// •
|
|
8
|
+
// • fetchLatestVersion() — query npm latest, falling back to an official stable GitHub release;
|
|
9
9
|
// • applyUpdate() — download the tarball, extract package/{lib,package.json,
|
|
10
10
|
// cordis.patch.yml} with a minimal tar reader, verify the version, then
|
|
11
11
|
// replace the installed files atomically (temp file + rename, never a
|
|
@@ -27,6 +27,122 @@ import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameS
|
|
|
27
27
|
import { createRequire } from 'node:module'
|
|
28
28
|
import path from 'node:path'
|
|
29
29
|
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
30
|
+
import http from 'node:http'
|
|
31
|
+
import https from 'node:https'
|
|
32
|
+
import tls from 'node:tls'
|
|
33
|
+
import { gunzipSync, inflateSync, brotliDecompressSync } from 'node:zlib'
|
|
34
|
+
// Update-only proxy support uses builtins so partial-install self-healing
|
|
35
|
+
// never needs to import an unavailable package or missing sibling module.
|
|
36
|
+
const CAP = 32 * 1024 * 1024
|
|
37
|
+
|
|
38
|
+
export function updateProxyFor(url, env = process.env) {
|
|
39
|
+
const target = new URL(url)
|
|
40
|
+
const bypass = env.no_proxy ?? env.NO_PROXY ?? ''
|
|
41
|
+
const host = target.hostname.toLowerCase()
|
|
42
|
+
for (const item of bypass.split(',').map(s => s.trim().toLowerCase()).filter(Boolean)) {
|
|
43
|
+
if (item === '*') return ''
|
|
44
|
+
const match = /^(.*?)(?::(\d+))?$/.exec(item)
|
|
45
|
+
if (match[2] && match[2] !== (target.port || '443')) continue
|
|
46
|
+
const domain = match[1].replace(/^\*?\./, '')
|
|
47
|
+
if (host === domain || host.endsWith('.' + domain)) return ''
|
|
48
|
+
}
|
|
49
|
+
return env.https_proxy || env.HTTPS_PROXY || env.http_proxy || env.HTTP_PROXY || ''
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function requestThroughProxy(url, options, proxyUrl) {
|
|
53
|
+
const target = new URL(url), proxy = new URL(proxyUrl)
|
|
54
|
+
if (target.protocol !== 'https:' || !['http:', 'https:'].includes(proxy.protocol)) throw new Error('Update HTTPS proxy must use http:// or https://')
|
|
55
|
+
if (options.signal?.aborted) throw new DOMException('Update request aborted', 'AbortError')
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
let socket, secure, request, agent, done = false
|
|
58
|
+
const cleanup = () => { options.signal?.removeEventListener('abort', abort); agent?.destroy(); request?.destroy(); secure?.destroy(); socket?.destroy(); tunnel.destroy() }
|
|
59
|
+
const fail = error => { if (done) return; done = true; cleanup(); reject(error) }
|
|
60
|
+
const abort = () => fail(new DOMException('Update request aborted', 'AbortError'))
|
|
61
|
+
const headers = { host: target.host }
|
|
62
|
+
if (proxy.username || proxy.password) headers['proxy-authorization'] = 'Basic ' + Buffer.from(decodeURIComponent(proxy.username) + ':' + decodeURIComponent(proxy.password)).toString('base64')
|
|
63
|
+
const transport = proxy.protocol === 'https:' ? https : http
|
|
64
|
+
const tunnel = transport.request({ hostname: proxy.hostname, port: proxy.port || (proxy.protocol === 'https:' ? 443 : 80), method: 'CONNECT', path: target.host.includes(':') ? target.host : target.host + ':443', headers })
|
|
65
|
+
tunnel.on('error', fail)
|
|
66
|
+
tunnel.on('connect', (response, connected, head) => {
|
|
67
|
+
socket = connected
|
|
68
|
+
if (response.statusCode !== 200) { fail(Object.assign(new Error('HTTPS proxy CONNECT returned HTTP ' + response.statusCode), { code: 'PROXY_HTTP_' + response.statusCode })); return }
|
|
69
|
+
if (head.length) socket.unshift(head)
|
|
70
|
+
secure = tls.connect({ socket, servername: target.hostname, ...(options.ca ? { ca: options.ca } : {}) })
|
|
71
|
+
secure.on('error', fail)
|
|
72
|
+
secure.once('secureConnect', () => {
|
|
73
|
+
agent = new https.Agent({ keepAlive: false }); agent.createConnection = () => secure
|
|
74
|
+
request = https.request(target, { method: options.method || 'GET', headers: options.headers, agent }, response => {
|
|
75
|
+
const chunks = []; let size = 0
|
|
76
|
+
response.on('error', fail)
|
|
77
|
+
response.on('aborted', () => fail(new Error('Update response interrupted')))
|
|
78
|
+
response.on('data', chunk => { size += chunk.length; if (size > CAP) fail(new Error('Update response exceeds size limit')); else chunks.push(chunk) })
|
|
79
|
+
response.on('end', () => {
|
|
80
|
+
if (done) return
|
|
81
|
+
try {
|
|
82
|
+
let bytes = Buffer.concat(chunks)
|
|
83
|
+
const encoding = response.headers['content-encoding']
|
|
84
|
+
if (encoding === 'gzip') bytes = gunzipSync(bytes, { maxOutputLength: CAP })
|
|
85
|
+
else if (encoding === 'deflate') bytes = inflateSync(bytes, { maxOutputLength: CAP })
|
|
86
|
+
else if (encoding === 'br') bytes = brotliDecompressSync(bytes, { maxOutputLength: CAP })
|
|
87
|
+
done = true; cleanup()
|
|
88
|
+
resolve({ ok: response.statusCode >= 200 && response.statusCode < 300, status: response.statusCode, headers: new Headers(response.headers), json: async () => JSON.parse(bytes.toString('utf8')), arrayBuffer: async () => bytes })
|
|
89
|
+
} catch (error) { fail(error) }
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
request.on('error', fail); request.end()
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
options.signal?.addEventListener('abort', abort, { once: true })
|
|
96
|
+
if (options.signal?.aborted) abort(); else tunnel.end()
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export async function fetchUpdate(url, options = {}, hops = 0) {
|
|
101
|
+
const proxy = updateProxyFor(url)
|
|
102
|
+
// Unit tests retain their injected global fetch and never contact production.
|
|
103
|
+
if (!proxy || process.env.NODE_TEST_CONTEXT) return fetch(url, options)
|
|
104
|
+
const response = await requestThroughProxy(url, options, proxy)
|
|
105
|
+
if ([301, 302, 303, 307, 308].includes(response.status) && response.headers.get('location')) {
|
|
106
|
+
if (hops >= 5) throw new Error('Too many update redirects')
|
|
107
|
+
const next = new URL(response.headers.get('location'), url)
|
|
108
|
+
if (next.protocol !== 'https:') throw new Error('Update redirect must retain HTTPS')
|
|
109
|
+
const headers = new Headers(options.headers)
|
|
110
|
+
if (next.origin !== new URL(url).origin) { headers.delete('authorization'); headers.delete('cookie') }
|
|
111
|
+
return fetchUpdate(next.href, { ...options, headers: Object.fromEntries(headers) }, hops + 1)
|
|
112
|
+
}
|
|
113
|
+
return response
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Official release fallback only. Never install an unchecked mirror response.
|
|
117
|
+
const REPO = 'https://api.github.com/repos/flymysql/dsh-remote/releases/'
|
|
118
|
+
export const stableVersion = value => typeof value === 'string' && /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(value)
|
|
119
|
+
export async function fetchRelease(version, fetchImpl = fetchUpdate, timeoutMs = 8000) {
|
|
120
|
+
if (version !== undefined && !stableVersion(version)) throw new Error('Invalid stable release version')
|
|
121
|
+
const controller = new AbortController(), timer = setTimeout(() => controller.abort(), timeoutMs)
|
|
122
|
+
timer.unref?.()
|
|
123
|
+
try {
|
|
124
|
+
const response = await fetchImpl(REPO + (version ? 'tags/v' + version : 'latest'), { signal: controller.signal, headers: { accept: 'application/vnd.github+json', 'user-agent': 'dsh-remote-updater' } })
|
|
125
|
+
if (!response.ok) throw new Error('GitHub Release HTTP ' + response.status)
|
|
126
|
+
const release = await response.json()
|
|
127
|
+
const found = String(release?.tag_name || '').replace(/^v/, '')
|
|
128
|
+
if (!stableVersion(found) || version && found !== version || release.draft !== false || release.prerelease !== false) throw new Error('GitHub Release is not the requested stable release')
|
|
129
|
+
const filename = 'dsh-remote-' + found + '.tgz'
|
|
130
|
+
const asset = release.assets?.find(a => a.name === filename && a.state === 'uploaded')
|
|
131
|
+
if (!asset || !/^sha256:[a-f0-9]{64}$/i.test(asset.digest || '') || !Number.isFinite(asset.size) || asset.size <= 0 || asset.size > 32 * 1024 * 1024) throw new Error('GitHub Release has no verified installation archive')
|
|
132
|
+
return { version: found, source: 'github', url: 'https://github.com/flymysql/dsh-remote/releases/download/v' + found + '/' + filename, integrity: 'sha256-' + Buffer.from(asset.digest.slice(7), 'hex').toString('base64') }
|
|
133
|
+
} finally { clearTimeout(timer) }
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export async function downloadReleaseBytes(url, fetchImpl = fetchUpdate, timeoutMs = 60000) {
|
|
137
|
+
const controller = new AbortController(), timer = setTimeout(() => controller.abort(), timeoutMs)
|
|
138
|
+
try {
|
|
139
|
+
const response = await fetchImpl(url, { signal: controller.signal })
|
|
140
|
+
if (!response.ok) throw new Error('download failed (HTTP ' + response.status + ')')
|
|
141
|
+
const bytes = Buffer.from(await response.arrayBuffer())
|
|
142
|
+
if (bytes.length > 32 * 1024 * 1024) throw new Error('Update archive exceeds size limit')
|
|
143
|
+
return bytes
|
|
144
|
+
} finally { clearTimeout(timer) }
|
|
145
|
+
}
|
|
30
146
|
|
|
31
147
|
const NPM_PACKAGE = 'dsh-remote'
|
|
32
148
|
const REGISTRY_URL = 'https://registry.npmjs.org/' + NPM_PACKAGE + '/latest'
|
|
@@ -109,7 +225,7 @@ export function gtVersion(a, b) {
|
|
|
109
225
|
* 三者的处置完全不同,必须让用户看到真实原因。
|
|
110
226
|
* @param timeoutMs - 超时(看门狗只负责中止,不影响进程存活)。
|
|
111
227
|
*/
|
|
112
|
-
|
|
228
|
+
async function fetchNpmLatestVersion(timeoutMs = 8000, fetchImpl = fetchUpdate) {
|
|
113
229
|
try {
|
|
114
230
|
const controller = new AbortController()
|
|
115
231
|
const timer = setTimeout(() => controller.abort(), timeoutMs)
|
|
@@ -118,29 +234,40 @@ export async function fetchLatestVersion(timeoutMs = 8000) {
|
|
|
118
234
|
if (typeof timer.unref === 'function') timer.unref()
|
|
119
235
|
let res
|
|
120
236
|
try {
|
|
121
|
-
res = await
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (!version) return { error: 'npm registry 响应里没有可用的版本号', reason: 'malformed' }
|
|
134
|
-
return { version }
|
|
237
|
+
res = await fetchImpl(REGISTRY_URL, { signal: controller.signal, headers: { accept: 'application/json' } })
|
|
238
|
+
if (res.status === 429) {
|
|
239
|
+
return { error: 'npm registry 限流(HTTP 429)——请求过于频繁,稍后会自动恢复', reason: 'rate-limited', status: 429 }
|
|
240
|
+
}
|
|
241
|
+
if (!res.ok) {
|
|
242
|
+
return { error: `npm registry 返回 HTTP ${res.status}`, reason: 'http', status: res.status }
|
|
243
|
+
}
|
|
244
|
+
const data = await res.json().catch(error => { if (error?.name === 'AbortError') throw error; return null })
|
|
245
|
+
const version = stableVersion(data?.version) ? data.version : null
|
|
246
|
+
if (!version) return { error: 'npm registry 响应里没有可用的版本号', reason: 'malformed' }
|
|
247
|
+
return { version }
|
|
248
|
+
} finally { clearTimeout(timer) }
|
|
135
249
|
} catch (err) {
|
|
136
250
|
const aborted = err?.name === 'AbortError'
|
|
137
251
|
return {
|
|
138
252
|
error: aborted ? `连接 npm registry 超时(${timeoutMs}ms)` : '无法连接 npm registry',
|
|
139
253
|
reason: aborted ? 'timeout' : 'network',
|
|
254
|
+
...((err?.cause?.code || err?.code) ? { networkCode: String(err.cause?.code || err.code) } : {}),
|
|
140
255
|
}
|
|
141
256
|
}
|
|
142
257
|
}
|
|
143
258
|
|
|
259
|
+
/** npm preferred; a registry outage does not disable official GitHub releases. */
|
|
260
|
+
export async function fetchLatestVersion(timeoutMs = 8000, { fetchImpl = fetchUpdate } = {}) {
|
|
261
|
+
const primary = await fetchNpmLatestVersion(timeoutMs, fetchImpl)
|
|
262
|
+
if (!primary.error) return primary
|
|
263
|
+
try {
|
|
264
|
+
const release = await fetchRelease(undefined, fetchImpl, timeoutMs)
|
|
265
|
+
return { version: release.version, source: release.source }
|
|
266
|
+
} catch (error) {
|
|
267
|
+
return { ...primary, error: primary.error + (primary.networkCode ? '(' + primary.networkCode + ')' : '') + ';GitHub 备用来源也不可用', fallbackError: String(error.message || error) }
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
144
271
|
/**
|
|
145
272
|
* Fetch the npm metadata for one exact published version and return its
|
|
146
273
|
* `dist.integrity` (issue #169) — the SRI string the registry itself computed
|
|
@@ -152,7 +279,7 @@ export async function fetchLatestVersion(timeoutMs = 8000) {
|
|
|
152
279
|
* @param {number} [timeoutMs] - watchdog budget; the caller does not await the timer.
|
|
153
280
|
* @returns {Promise<string>} the SRI string ("sha512-…").
|
|
154
281
|
*/
|
|
155
|
-
export async function fetchDistIntegrity(version, fetchImpl =
|
|
282
|
+
export async function fetchDistIntegrity(version, fetchImpl = fetchUpdate, timeoutMs = 15000) {
|
|
156
283
|
const controller = new AbortController()
|
|
157
284
|
const timer = setTimeout(() => controller.abort(), timeoutMs)
|
|
158
285
|
if (typeof timer.unref === 'function') timer.unref()
|
|
@@ -162,7 +289,7 @@ export async function fetchDistIntegrity(version, fetchImpl = fetch, timeoutMs =
|
|
|
162
289
|
headers: { accept: 'application/vnd.npm.install-v1+json' },
|
|
163
290
|
})
|
|
164
291
|
if (!res.ok) throw new Error(`registry metadata returned HTTP ${res.status}`)
|
|
165
|
-
const data = await res.json().catch(()
|
|
292
|
+
const data = await res.json().catch(error => { if (error?.name === 'AbortError') throw error; return null })
|
|
166
293
|
const integrity = data?.dist?.integrity
|
|
167
294
|
if (typeof integrity !== 'string' || !/^(sha512|sha256)-[A-Za-z0-9+/=]+$/.test(integrity)) {
|
|
168
295
|
throw new Error('registry metadata carries no usable dist.integrity')
|
|
@@ -223,7 +350,7 @@ export async function applyUpdate(targetVersion, options = {}) {
|
|
|
223
350
|
}
|
|
224
351
|
const tarballUrl = `https://registry.npmjs.org/${NPM_PACKAGE}/-/${NPM_PACKAGE}-${targetVersion}.tgz`
|
|
225
352
|
const dir = path.resolve(options.dir || selfDir())
|
|
226
|
-
const doFetch = options.fetchImpl ||
|
|
353
|
+
const doFetch = options.fetchImpl || fetchUpdate
|
|
227
354
|
const writeAtomic = options.writeFileAtomic || writeFileAtomic
|
|
228
355
|
const restoreFile = options.restoreFile || copyFileSync
|
|
229
356
|
const tmpRoot = path.join(dir, `.dsh-remote-update-${Date.now()}`)
|
|
@@ -235,23 +362,25 @@ export async function applyUpdate(targetVersion, options = {}) {
|
|
|
235
362
|
// Offline repair must not contact the registry at all.
|
|
236
363
|
buf = readFileSync(options.tarballPath)
|
|
237
364
|
} else {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
// without downloading anything, and the downloaded bytes must match it
|
|
241
|
-
// before a single byte is extracted. The version check further below
|
|
242
|
-
// reads the tarball's own package.json, which an attacker-controlled
|
|
243
|
-
// response can simply echo back; only this hash is external.
|
|
244
|
-
const integrity = options.integrity ?? await fetchDistIntegrity(targetVersion, doFetch)
|
|
245
|
-
const controller = new AbortController()
|
|
246
|
-
const timer = setTimeout(() => controller.abort(), 60000)
|
|
247
|
-
let res
|
|
365
|
+
if (!stableVersion(targetVersion)) throw new Error('Invalid stable update version')
|
|
366
|
+
let integrity, registryFailure
|
|
248
367
|
try {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
368
|
+
integrity = options.integrity ?? await fetchDistIntegrity(targetVersion, doFetch)
|
|
369
|
+
buf = await downloadReleaseBytes(tarballUrl, doFetch)
|
|
370
|
+
} catch (error) { registryFailure = error }
|
|
371
|
+
if (registryFailure) {
|
|
372
|
+
// A malformed integrity response is not a connectivity failure: do not
|
|
373
|
+
// turn a failed trust check into a less strict installation path.
|
|
374
|
+
if (/no usable dist\.integrity|unsupported dist\.integrity/i.test(registryFailure.message)) throw registryFailure
|
|
375
|
+
try {
|
|
376
|
+
const release = await fetchRelease(targetVersion, doFetch)
|
|
377
|
+
integrity = release.integrity
|
|
378
|
+
buf = await downloadReleaseBytes(release.url, doFetch)
|
|
379
|
+
} catch (fallback) {
|
|
380
|
+
throw new Error(String(registryFailure.message) + '; GitHub fallback failed: ' + String(fallback.message))
|
|
381
|
+
}
|
|
252
382
|
}
|
|
253
|
-
|
|
254
|
-
buf = Buffer.from(await res.arrayBuffer())
|
|
383
|
+
// Hash mismatches never trigger source switching and never touch files.
|
|
255
384
|
assertIntegrity(buf, integrity)
|
|
256
385
|
}
|
|
257
386
|
// npm tarballs are gzipped tar; extract the package/ directory.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-remote",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "SSH remote workspaces for DeepSeek Harness: parallel projects across hosts, remote file browsing and editing, recursive search, terminals, Git diffs, and workspace-bound Agent tools to edit, build and test remotely. Optional IDE layout.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "flymysql <flyphp@outlook.com>",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
".": "./lib/boot.js",
|
|
33
33
|
"./client": "./lib/client.js",
|
|
34
34
|
"./package.json": "./package.json",
|
|
35
|
-
"./cordis.patch.yml": "./cordis.patch.yml"
|
|
35
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
36
|
+
"./deck-bridge": "./lib/deck-bridge.js"
|
|
36
37
|
},
|
|
37
38
|
"files": [
|
|
38
39
|
"lib",
|
|
@@ -102,6 +103,6 @@
|
|
|
102
103
|
"test:coverage": "node scripts/coverage-union.mjs",
|
|
103
104
|
"test:coverage:gate": "node scripts/coverage-union.mjs --gate 70 --file-gate 60"
|
|
104
105
|
},
|
|
105
|
-
"readme": "[English](https://github.com/flymysql/dsh-remote/blob/main/README.en.md) · **中文**\n\n# dsh-remote\n\n[](https://www.npmjs.com/package/dsh-remote)\n[](https://www.npmjs.com/package/dsh-remote)\n[](https://www.npmjs.com/package/dsh-remote)\n[](https://github.com/flymysql/dsh-remote/blob/main/LICENSE)\n[](https://github.com/topics/dsh-plugin)\n\n由 [@flymysql](https://github.com/flymysql) 维护 · [主页](https://flymysql.github.io/dsh-remote/) · [用量统计](https://flymysql.github.io/dsh-remote/stats/) · [博客](https://gitpull.cn) · [讨论区](https://github.com/flymysql/dsh-remote/discussions) · [Issue](https://github.com/flymysql/dsh-remote/issues) · [English](https://github.com/flymysql/dsh-remote/blob/main/README.en.md)\n\n\n\n在 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 中,把 SSH 主机变成日常开发工作区:管理多主机项目,浏览和编辑远程文件、递归搜索文件与内容、使用终端、查看 Git 差异、建立本地/反向端口隧道;让 Agent 在所属远程工作区中读写文件、执行命令、构建和测试。多个工作区可独立并行。\n\n可按习惯使用普通布局,或切换 **IDE 三栏布局**,并排查看远程文件、编辑器与原生 Agent 会话;切换时保留任务和未保存编辑。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-ide.png\" alt=\"DSH 远程工作区 IDE 模式:远程文件树、代码编辑器和原生 Agent 会话三栏\" width=\"1200\"/>\n\n## 安装\n\n```bash\ndsh plugin --profile web add dsh-remote\n```\n\n安装或升级后,重启 DSH Web 并刷新页面。自动更新状态在设置 → 远程工作区 → 插件偏好中查看。\n\n## 3 步开始\n\n1. **配置主机**:设置 → 远程工作区,编辑 SSH 配置或保存主机凭据;直接写在 `~/.ssh/config` 里的 Host 会出现在主机列表中,点该行的「…」菜单 →「编辑」即可保存成机器并填写登录密码(保存前后入口都是同一个「…」菜单)。打开设置会自动检查连通性,无需手动“连接”。\n2. **创建工作区**:添加工作区 → 远程,选择主机与目录。每个工作区独立绑定主机,设置页不选目录或“当前远程机”。\n3. **开始开发**:打开工作区文件或切换 IDE 模式,文件打开即可编辑并显示语法高亮,在远端搜索、运行命令并与 Agent 协作。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workspace-picker-browse.png\" alt=\"选择远程目录:固定路径与确认栏,目录列表占据弹窗主要区域\" width=\"720\"/>\n\n## 本地工作区也能用\n\n打开普通本地项目后,点击 **IDE 模式** 或 **工作区文件**,即可使用同一套文件树、高亮编辑、递归搜索、Git 差异与本地终端。无需配置 SSH;Agent 继续使用宿主原生文件和命令工具,多个本地、远程项目可并行工作。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-local.png\" alt=\"本地工作区:文件搜索、高亮编辑和原生 Agent 会话,Agent 已实际完成本地构建\" width=\"1200\"/>\n\n## 日常开发\n\n### 搜索远端文件与内容\n\n文件、目录和内容递归搜索,无需先展开目录或同步镜像。默认界面只显示搜索范围与进度摘要;按需展开搜索选项、扫描详情,支持大小写、忽略项、停止与重试。点击结果进入目录或文件对应行。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-search-results.png\" alt=\"简洁远程搜索:名称搜索结果包含嵌套目录与文件\" width=\"675\"/>\n\n### 查看远端 Git 改动\n\n分别查看工作区和已暂存 diff,筛选文件,点击改动行定位源码。面板只读,不提交或修改暂存区。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-git.png\" alt=\"远端 Git 工作区与已暂存改动、文件列表和源码 diff\" width=\"675\"/>\n\n### 在远端运行终端\n\n终端进入当前会话的远程目录;像素鱼欢迎图后接真实 SSH shell。已保存凭据可自动应答,支持多终端并行。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-terminal.png\" alt=\"DSH 远程终端:像素鱼欢迎图与实际 SSH 命令输出\" width=\"1000\"/>\n\n### 端口转发(SSH 隧道)\n\n谁要发起访问,就在谁那边开监听口:监听口开在本机是本地转发(`ssh -L`),开在远端是远程转发(`ssh -R`)。可同时运行多条;添加转发时可以选择「主机」,每条转发只属于一台机器——给还没连接的主机也能先存下转发,连上后再启动。每条转发都可以点「编辑」调整方向、端口、目标或所属主机,运行中的会先停止、保存后按新配置重新启动。每行能直接勾选「自动重连」——只恢复上次运行中的转发,且按机器隔离,反向转发首次勾选会提示远端监听风险。\n\n从旧版本升级:旧版没有 `lastActive` 的「自动重连」配置会暂停,行上显示「需重新确认」;重新勾选后才会参与自动恢复(反向转发需重新确认远端监听)。\n\n<img src=\"docs/shots/port-forwards.png\" alt=\"端口转发面板:本地/反向方向、自动重连勾选框与添加转发表单\" width=\"900\"/>\n\n### 与 Agent 一起修改和构建\n\n工具卡展示已应用改动、实际退出码和构建输出,编译诊断可跳转源码。编辑器保存会检测远端冲突、保留 CRLF,并保护保存期间继续输入的内容。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-applied-diff.png\" alt=\"Agent 远程编辑成功后的已应用 diff、路径与增删行数\" width=\"485\"/>\n\n## 兼容与边界\n\n- 主要面向 **DSH Web 0.2.x**;0.2.2 需要 **Node.js ≥24.9**。旧版宿主回退、Desktop/TUI 与 Agent diff 差异见[兼容说明](https://github.com/flymysql/dsh-remote/blob/main/docs/reference.zh.md#dsh-版本兼容性)。\n- 文件栏直接访问远端;镜像按需同步。草稿在当前页面内存,崩溃或强制退出仍可能丢失。\n- 不提供远端语言服务、扩展宿主或调试器。Agent 使用配置的 SSH 身份执行命令,请只配置可信主机。\n\n## 文档与社区\n\n[完整工具与配置参考](https://github.com/flymysql/dsh-remote/blob/main/docs/reference.zh.md) · [排障](https://github.com/flymysql/dsh-remote/blob/main/docs/troubleshooting.md) · [自更新修复](https://github.com/flymysql/dsh-remote/blob/main/docs/self-heal.md) · [升级指南](https://github.com/flymysql/dsh-remote/blob/main/docs/migration-1.0.md) · [更新记录](https://github.com/flymysql/dsh-remote/blob/main/CHANGELOG.md)\n\n[主页](https://flymysql.github.io/dsh-remote/) · [讨论区](https://github.com/flymysql/dsh-remote/discussions) · [反馈问题](https://github.com/flymysql/dsh-remote/issues) · [贡献指南](https://github.com/flymysql/dsh-remote/blob/main/CONTRIBUTING.md) · [贡献者与致谢](#贡献者与致谢)\n\n由 [@flymysql](https://github.com/flymysql) 与社区共同维护 · [MIT](https://github.com/flymysql/dsh-remote/blob/main/LICENSE)\n\n### 贡献者与致谢\n\n感谢每一位让这个项目更好的朋友(头像可点进主页;按提交数排序,机器人不计):\n\n<p align=\"left\">\n <a href=\"https://github.com/flymysql\"><img src=\"https://avatars.githubusercontent.com/u/37113068?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@flymysql\" title=\"@flymysql\" /></a>\n <a href=\"https://github.com/baiseraku\"><img src=\"https://avatars.githubusercontent.com/u/139727690?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@baiseraku\" title=\"@baiseraku\" /></a>\n <a href=\"https://github.com/glzhangzhi\"><img src=\"https://avatars.githubusercontent.com/u/36995275?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@glzhangzhi\" title=\"@glzhangzhi\" /></a>\n <a href=\"https://github.com/hjwsm1989\"><img src=\"https://avatars.githubusercontent.com/u/1067541?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@hjwsm1989\" title=\"@hjwsm1989\" /></a>\n <a href=\"https://github.com/j10ha0\"><img src=\"https://avatars.githubusercontent.com/u/72346906?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@j10ha0\" title=\"@j10ha0\" /></a>\n <a href=\"https://github.com/FoolishWiser\"><img src=\"https://avatars.githubusercontent.com/u/104308087?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@FoolishWiser\" title=\"@FoolishWiser\" /></a>\n <a href=\"https://github.com/kakaa-nju\"><img src=\"https://avatars.githubusercontent.com/u/79886619?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@kakaa-nju\" title=\"@kakaa-nju\" /></a>\n <a href=\"https://github.com/4FMTWRV\"><img src=\"https://avatars.githubusercontent.com/u/190457700?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@4FMTWRV\" title=\"@4FMTWRV\" /></a>\n <a href=\"https://github.com/dahaipeng\"><img src=\"https://avatars.githubusercontent.com/u/25660610?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@dahaipeng\" title=\"@dahaipeng\" /></a>\n <a href=\"https://github.com/davidlin2k\"><img src=\"https://avatars.githubusercontent.com/u/17074619?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@davidlin2k\" title=\"@davidlin2k\" /></a>\n <a href=\"https://github.com/FlintyLemming\"><img src=\"https://avatars.githubusercontent.com/u/19165511?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@FlintyLemming\" title=\"@FlintyLemming\" /></a>\n <a href=\"https://github.com/GDWhisper\"><img src=\"https://avatars.githubusercontent.com/u/129148123?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@GDWhisper\" title=\"@GDWhisper\" /></a>\n <a href=\"https://github.com/YiHui-Liu\"><img src=\"https://avatars.githubusercontent.com/u/30190271?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@YiHui-Liu\" title=\"@YiHui-Liu\" /></a>\n <a href=\"https://github.com/Minggle\"><img src=\"https://avatars.githubusercontent.com/u/35053182?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@Minggle\" title=\"@Minggle\" /></a>\n <a href=\"https://github.com/nekomona\"><img src=\"https://avatars.githubusercontent.com/u/25474483?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@nekomona\" title=\"@nekomona\" /></a>\n <a href=\"https://github.com/shis23\"><img src=\"https://avatars.githubusercontent.com/u/189869650?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@shis23\" title=\"@shis23\" /></a>\n</p>\n\n<details>\n<summary>贡献记录与早期贡献者</summary>\n\n近期的亮点贡献(欢迎随时加入这个名单):\n\n| 贡献者 | 做了什么 |\n| --- | --- |\n| [@baiseraku](https://github.com/baiseraku) | 整个 dsh-tui 适配层([#92](https://github.com/flymysql/dsh-remote/pull/92))+ 底栏机器名修正([#98](https://github.com/flymysql/dsh-remote/pull/98)) |\n| [@hjwsm1989](https://github.com/hjwsm1989) | 远程 .md 渲染连环两道:memo 守卫([#102](https://github.com/flymysql/dsh-remote/pull/102))+ labels 契约([#107](https://github.com/flymysql/dsh-remote/pull/107)) |\n| [@shis23](https://github.com/shis23) | rw_sync 路径映射纠偏 + SFTP 超时韧性([#105](https://github.com/flymysql/dsh-remote/pull/105)) |\n| [@davidlin2k](https://github.com/davidlin2k) | 无凭据机器走用户自有 ssh([#100](https://github.com/flymysql/dsh-remote/pull/100)) |\n| [@GDWhisper](https://github.com/GDWhisper) | 目录补全逐字符重连修复([#42](https://github.com/flymysql/dsh-remote/pull/42),issue #41) |\n| [@glzhangzhi](https://github.com/glzhangzhi) | 多远端会话的连接池隔离(issue #25 的主体修复) |\n\n早期已合并 PR 的贡献者(考古名单):\n\n\n\n[@dahaipeng](https://github.com/dahaipeng) (#31) ·\n[@YiHui-Liu](https://github.com/YiHui-Liu) (#28) ·\n[@nekomona](https://github.com/nekomona) (#24) ·\n[@zhz1667](https://github.com/zhz1667) (#43) ·\n[FoolishWiser](https://github.com/FoolishWiser) (#17) ·\n[@jace1cch](https://github.com/jace1cch) (#16) ·\n[@Minggle](https://github.com/Minggle) (#10) ·\n[4FMTWRV](https://github.com/4FMTWRV) (#6) ·\n[glzhangzhi](https://github.com/glzhangzhi)(per-session SSH 连接池修复)\n\n> 名单随版本更新;头像墙之外的每一份 issue 报告、复现步骤、根因线索同样珍贵——\n> 本仓库近半修复的起点都是一条写清楚的 issue。\n\n</details>\n",
|
|
106
|
+
"readme": "[English](https://github.com/flymysql/dsh-remote/blob/main/README.en.md) · **中文**\n\n# dsh-remote\n\n[](https://www.npmjs.com/package/dsh-remote)\n[](https://www.npmjs.com/package/dsh-remote)\n[](https://www.npmjs.com/package/dsh-remote)\n[](https://github.com/flymysql/dsh-remote/blob/main/LICENSE)\n[](https://github.com/topics/dsh-plugin)\n\n由 [@flymysql](https://github.com/flymysql) 维护 · [主页](https://flymysql.github.io/dsh-remote/) · [用量统计](https://flymysql.github.io/dsh-remote/stats/) · [博客](https://gitpull.cn) · [讨论区](https://github.com/flymysql/dsh-remote/discussions) · [Issue](https://github.com/flymysql/dsh-remote/issues) · [English](https://github.com/flymysql/dsh-remote/blob/main/README.en.md)\n\n\n\n在 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 中,把 SSH 主机变成日常开发工作区:管理多主机项目,浏览和编辑远程文件、递归搜索文件与内容、使用终端、查看 Git 差异、建立本地/反向端口隧道;让 Agent 在所属远程工作区中读写文件、执行命令、构建和测试。多个工作区可独立并行。\n\n可按习惯使用普通布局,或切换 **IDE 三栏布局**,并排查看远程文件、编辑器与原生 Agent 会话;切换时保留任务和未保存编辑。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-ide.png\" alt=\"DSH 远程工作区 IDE 模式:远程文件树、代码编辑器和原生 Agent 会话三栏\" width=\"1200\"/>\n\n## 安装\n\n```bash\ndsh plugin --profile web add dsh-remote\n```\n\n安装或升级后,重启 DSH Web 并刷新页面。自动更新状态在设置 → 远程工作区 → 插件偏好中查看。\n\n[1.3.1 更新说明](https://github.com/flymysql/dsh-remote/blob/main/docs/release/1.3.1.md):SSH 连接恢复、代理网络更新与官方 GitHub 下载回退。\n\n## 3 步开始\n\n1. **配置主机**:设置 → 远程工作区,编辑 SSH 配置或保存主机凭据;直接写在 `~/.ssh/config` 里的 Host 会出现在主机列表中,点该行的「…」菜单 →「编辑」即可保存成机器并填写登录密码(保存前后入口都是同一个「…」菜单)。打开设置会自动检查连通性,无需手动“连接”。\n2. **创建工作区**:添加工作区 → 远程,选择主机与目录。每个工作区独立绑定主机,设置页不选目录或“当前远程机”。\n3. **开始开发**:打开工作区文件或切换 IDE 模式,文件打开即可编辑并显示语法高亮,在远端搜索、运行命令并与 Agent 协作。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workspace-picker-browse.png\" alt=\"选择远程目录:固定路径与确认栏,目录列表占据弹窗主要区域\" width=\"720\"/>\n\n## 本地工作区也能用\n\n打开普通本地项目后,点击 **IDE 模式** 或 **工作区文件**,即可使用同一套文件树、高亮编辑、递归搜索、Git 差异与本地终端。无需配置 SSH;Agent 继续使用宿主原生文件和命令工具,多个本地、远程项目可并行工作。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-local.png\" alt=\"本地工作区:文件搜索、高亮编辑和原生 Agent 会话,Agent 已实际完成本地构建\" width=\"1200\"/>\n\n## 日常开发\n\n### 搜索远端文件与内容\n\n文件、目录和内容递归搜索,无需先展开目录或同步镜像。默认界面只显示搜索范围与进度摘要;按需展开搜索选项、扫描详情,支持大小写、忽略项、停止与重试。点击结果进入目录或文件对应行。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-search-results.png\" alt=\"简洁远程搜索:名称搜索结果包含嵌套目录与文件\" width=\"675\"/>\n\n### 查看远端 Git 改动\n\n分别查看工作区和已暂存 diff,筛选文件,点击改动行定位源码。面板只读,不提交或修改暂存区。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-git.png\" alt=\"远端 Git 工作区与已暂存改动、文件列表和源码 diff\" width=\"675\"/>\n\n### 在远端运行终端\n\n终端进入当前会话的远程目录;像素鱼欢迎图后接真实 SSH shell。已保存凭据可自动应答,支持多终端并行。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-terminal.png\" alt=\"DSH 远程终端:像素鱼欢迎图与实际 SSH 命令输出\" width=\"1000\"/>\n\n### 端口转发(SSH 隧道)\n\n谁要发起访问,就在谁那边开监听口:监听口开在本机是本地转发(`ssh -L`),开在远端是远程转发(`ssh -R`)。可同时运行多条;添加转发时可以选择「主机」,每条转发只属于一台机器——给还没连接的主机也能先存下转发,连上后再启动。每条转发都可以点「编辑」调整方向、端口、目标或所属主机,运行中的会先停止、保存后按新配置重新启动。每行能直接勾选「自动重连」——只恢复上次运行中的转发,且按机器隔离,反向转发首次勾选会提示远端监听风险。\n\n从旧版本升级:旧版没有 `lastActive` 的「自动重连」配置会暂停,行上显示「需重新确认」;重新勾选后才会参与自动恢复(反向转发需重新确认远端监听)。\n\n<img src=\"docs/shots/port-forwards.png\" alt=\"端口转发面板:本地/反向方向、自动重连勾选框与添加转发表单\" width=\"900\"/>\n\n### 与 Agent 一起修改和构建\n\n工具卡展示已应用改动、实际退出码和构建输出,编译诊断可跳转源码。编辑器保存会检测远端冲突、保留 CRLF,并保护保存期间继续输入的内容。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-applied-diff.png\" alt=\"Agent 远程编辑成功后的已应用 diff、路径与增删行数\" width=\"485\"/>\n\n## 兼容与边界\n\n- 主要面向 **DSH Web 0.2.x**;0.2.2 需要 **Node.js ≥24.9**。旧版宿主回退、Desktop/TUI 与 Agent diff 差异见[兼容说明](https://github.com/flymysql/dsh-remote/blob/main/docs/reference.zh.md#dsh-版本兼容性)。\n- 文件栏直接访问远端;镜像按需同步。草稿在当前页面内存,崩溃或强制退出仍可能丢失。\n- 不提供远端语言服务、扩展宿主或调试器。Agent 使用配置的 SSH 身份执行命令,请只配置可信主机。\n\n## 文档与社区\n\n[完整工具与配置参考](https://github.com/flymysql/dsh-remote/blob/main/docs/reference.zh.md) · [排障](https://github.com/flymysql/dsh-remote/blob/main/docs/troubleshooting.md) · [自更新修复](https://github.com/flymysql/dsh-remote/blob/main/docs/self-heal.md) · [升级指南](https://github.com/flymysql/dsh-remote/blob/main/docs/migration-1.0.md) · [更新记录](https://github.com/flymysql/dsh-remote/blob/main/CHANGELOG.md)\n\n[主页](https://flymysql.github.io/dsh-remote/) · [讨论区](https://github.com/flymysql/dsh-remote/discussions) · [反馈问题](https://github.com/flymysql/dsh-remote/issues) · [贡献指南](https://github.com/flymysql/dsh-remote/blob/main/CONTRIBUTING.md) · [贡献者与致谢](#贡献者与致谢)\n\n由 [@flymysql](https://github.com/flymysql) 与社区共同维护 · [MIT](https://github.com/flymysql/dsh-remote/blob/main/LICENSE)\n\n### 贡献者与致谢\n\n感谢每一位让这个项目更好的朋友(头像可点进主页;按提交数排序,机器人不计):\n\n<p align=\"left\">\n <a href=\"https://github.com/flymysql\"><img src=\"https://avatars.githubusercontent.com/u/37113068?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@flymysql\" title=\"@flymysql\" /></a>\n <a href=\"https://github.com/baiseraku\"><img src=\"https://avatars.githubusercontent.com/u/139727690?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@baiseraku\" title=\"@baiseraku\" /></a>\n <a href=\"https://github.com/glzhangzhi\"><img src=\"https://avatars.githubusercontent.com/u/36995275?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@glzhangzhi\" title=\"@glzhangzhi\" /></a>\n <a href=\"https://github.com/hjwsm1989\"><img src=\"https://avatars.githubusercontent.com/u/1067541?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@hjwsm1989\" title=\"@hjwsm1989\" /></a>\n <a href=\"https://github.com/j10ha0\"><img src=\"https://avatars.githubusercontent.com/u/72346906?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@j10ha0\" title=\"@j10ha0\" /></a>\n <a href=\"https://github.com/FoolishWiser\"><img src=\"https://avatars.githubusercontent.com/u/104308087?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@FoolishWiser\" title=\"@FoolishWiser\" /></a>\n <a href=\"https://github.com/kakaa-nju\"><img src=\"https://avatars.githubusercontent.com/u/79886619?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@kakaa-nju\" title=\"@kakaa-nju\" /></a>\n <a href=\"https://github.com/4FMTWRV\"><img src=\"https://avatars.githubusercontent.com/u/190457700?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@4FMTWRV\" title=\"@4FMTWRV\" /></a>\n <a href=\"https://github.com/dahaipeng\"><img src=\"https://avatars.githubusercontent.com/u/25660610?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@dahaipeng\" title=\"@dahaipeng\" /></a>\n <a href=\"https://github.com/davidlin2k\"><img src=\"https://avatars.githubusercontent.com/u/17074619?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@davidlin2k\" title=\"@davidlin2k\" /></a>\n <a href=\"https://github.com/FlintyLemming\"><img src=\"https://avatars.githubusercontent.com/u/19165511?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@FlintyLemming\" title=\"@FlintyLemming\" /></a>\n <a href=\"https://github.com/GDWhisper\"><img src=\"https://avatars.githubusercontent.com/u/129148123?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@GDWhisper\" title=\"@GDWhisper\" /></a>\n <a href=\"https://github.com/YiHui-Liu\"><img src=\"https://avatars.githubusercontent.com/u/30190271?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@YiHui-Liu\" title=\"@YiHui-Liu\" /></a>\n <a href=\"https://github.com/Minggle\"><img src=\"https://avatars.githubusercontent.com/u/35053182?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@Minggle\" title=\"@Minggle\" /></a>\n <a href=\"https://github.com/nekomona\"><img src=\"https://avatars.githubusercontent.com/u/25474483?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@nekomona\" title=\"@nekomona\" /></a>\n <a href=\"https://github.com/shis23\"><img src=\"https://avatars.githubusercontent.com/u/189869650?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@shis23\" title=\"@shis23\" /></a>\n</p>\n\n<details>\n<summary>贡献记录与早期贡献者</summary>\n\n近期的亮点贡献(欢迎随时加入这个名单):\n\n| 贡献者 | 做了什么 |\n| --- | --- |\n| [@baiseraku](https://github.com/baiseraku) | 整个 dsh-tui 适配层([#92](https://github.com/flymysql/dsh-remote/pull/92))+ 底栏机器名修正([#98](https://github.com/flymysql/dsh-remote/pull/98)) |\n| [@hjwsm1989](https://github.com/hjwsm1989) | 远程 .md 渲染连环两道:memo 守卫([#102](https://github.com/flymysql/dsh-remote/pull/102))+ labels 契约([#107](https://github.com/flymysql/dsh-remote/pull/107)) |\n| [@shis23](https://github.com/shis23) | rw_sync 路径映射纠偏 + SFTP 超时韧性([#105](https://github.com/flymysql/dsh-remote/pull/105)) |\n| [@davidlin2k](https://github.com/davidlin2k) | 无凭据机器走用户自有 ssh([#100](https://github.com/flymysql/dsh-remote/pull/100)) |\n| [@GDWhisper](https://github.com/GDWhisper) | 目录补全逐字符重连修复([#42](https://github.com/flymysql/dsh-remote/pull/42),issue #41) |\n| [@glzhangzhi](https://github.com/glzhangzhi) | 多远端会话的连接池隔离(issue #25 的主体修复) |\n\n早期已合并 PR 的贡献者(考古名单):\n\n\n\n[@dahaipeng](https://github.com/dahaipeng) (#31) ·\n[@YiHui-Liu](https://github.com/YiHui-Liu) (#28) ·\n[@nekomona](https://github.com/nekomona) (#24) ·\n[@zhz1667](https://github.com/zhz1667) (#43) ·\n[FoolishWiser](https://github.com/FoolishWiser) (#17) ·\n[@jace1cch](https://github.com/jace1cch) (#16) ·\n[@Minggle](https://github.com/Minggle) (#10) ·\n[4FMTWRV](https://github.com/4FMTWRV) (#6) ·\n[glzhangzhi](https://github.com/glzhangzhi)(per-session SSH 连接池修复)\n\n> 名单随版本更新;头像墙之外的每一份 issue 报告、复现步骤、根因线索同样珍贵——\n> 本仓库近半修复的起点都是一条写清楚的 issue。\n\n</details>\n",
|
|
106
107
|
"readmeFilename": "README.md"
|
|
107
108
|
}
|