dsh-remote 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/lib/boot.js +1 -0
- package/lib/client.js +156 -12
- package/lib/detect-platform.js +142 -0
- package/lib/index.js +1 -0
- package/lib/main.js +45 -4
- package/lib/openssh.js +19 -54
- package/lib/pool.js +25 -79
- package/lib/registry.js +4 -0
- package/lib/remote-shell-child.cjs +9 -1
- package/lib/routes-fs.js +137 -1
- package/lib/routes-machines.js +16 -8
- package/lib/web-attach.js +47 -2
- package/package.json +2 -2
package/lib/web-attach.js
CHANGED
|
@@ -294,9 +294,11 @@ export class WebAttach {
|
|
|
294
294
|
this.localPortMax = opts.localPortMax ?? 50
|
|
295
295
|
/** Whether the pool's lifecycle hooks are ours to install. */
|
|
296
296
|
this.trackPool = opts.trackPool !== false
|
|
297
|
-
/** Issue #
|
|
297
|
+
/** Issue #204: discover budgets (injectable so tests need not wait 8s). */
|
|
298
298
|
this.discoverTimeoutMs = opts.discoverTimeoutMs ?? DISCOVER_TIMEOUT_MS
|
|
299
299
|
this.probeTimeoutMs = opts.probeTimeoutMs ?? PROBE_TIMEOUT_MS
|
|
300
|
+
/** Issue #204: the reconnect backoff base (tests inject single-digit ms). */
|
|
301
|
+
this.reconnectBaseDelayMs = opts.reconnectBaseDelayMs ?? 1000
|
|
300
302
|
/** @type {import('node:net').Server|null} */ this.server = null
|
|
301
303
|
/** @type {Set<import('node:net').Socket>} */ this.sockets = new Set()
|
|
302
304
|
/** @type {object|null} */ this.client = null
|
|
@@ -333,6 +335,10 @@ export class WebAttach {
|
|
|
333
335
|
this.omittedNoOpen = false
|
|
334
336
|
/** True while a reconnect-triggered re-resolve is in flight. */
|
|
335
337
|
this._resolving = false
|
|
338
|
+
/** Issue #204: the reconnect-backoff loop's pending timer (null = idle). */
|
|
339
|
+
this._reconnectTimer = null
|
|
340
|
+
/** Issue #204: the current backoff delay (0 = fresh / reset). */
|
|
341
|
+
this._reconnectDelayMs = 0
|
|
336
342
|
/** True once the borrowed connection has been lost (drives recovery). */
|
|
337
343
|
this.connectionLost = false
|
|
338
344
|
/** undefined = "not asked yet"; false = the remote process is provably gone. */
|
|
@@ -683,6 +689,9 @@ export class WebAttach {
|
|
|
683
689
|
*/
|
|
684
690
|
_attach(client) {
|
|
685
691
|
if (!client) return
|
|
692
|
+
// A client is (back) in hand: the issue #204 reconnect loop has done its
|
|
693
|
+
// job (or was never needed) — stop it and reset the backoff.
|
|
694
|
+
this._stopReconnectLoop()
|
|
686
695
|
if (this.attachedClient && this.attachedClient !== client && this.onClientClose) {
|
|
687
696
|
// A different client replaced the one we borrowed (pool reconnect). Stop
|
|
688
697
|
// listening to the old one; its own 'close' has either fired already or
|
|
@@ -703,6 +712,40 @@ export class WebAttach {
|
|
|
703
712
|
this.client = null
|
|
704
713
|
this.connectionLost = true
|
|
705
714
|
this.lastError = String(reason || 'ssh connection closed')
|
|
715
|
+
// Issue #204: without a driver the recovery machinery below never ran —
|
|
716
|
+
// the pool only reconnects when someone CALLS it, so an idle attach stayed
|
|
717
|
+
// a permanent dead end (listener up, every connection RST-ed) until the
|
|
718
|
+
// user manually disconnected.
|
|
719
|
+
this._scheduleReconnect()
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Issue #204: dial the pool with a growing backoff until a client comes
|
|
724
|
+
* back. `pool.connect` memoizes an in-flight dial, so this loop and any
|
|
725
|
+
* other pool activity share one connection attempt; when one succeeds the
|
|
726
|
+
* pool fires onReady, whose hook re-attaches the client and kicks the
|
|
727
|
+
* (existing) re-resolve/restart of the remote `dsh web`. The loop stops on
|
|
728
|
+
* success, on close(), or when the pool goes away.
|
|
729
|
+
*/
|
|
730
|
+
_scheduleReconnect() {
|
|
731
|
+
if (this.closed || !this.trackPool || !this.pool || typeof this.pool.connect !== 'function') return
|
|
732
|
+
if (this._reconnectTimer) return
|
|
733
|
+
const attempt = async () => {
|
|
734
|
+
this._reconnectTimer = null
|
|
735
|
+
if (this.closed || !this.pool || this.client) return
|
|
736
|
+
try { await this.pool.connect() } catch { /* link still down — back off and retry */ }
|
|
737
|
+
if (this.closed || !this.pool) return
|
|
738
|
+
if (this.client) { this._reconnectDelayMs = 0; return }
|
|
739
|
+
this._reconnectDelayMs = Math.min(this._reconnectDelayMs * 2 || this.reconnectBaseDelayMs, 30000)
|
|
740
|
+
this._reconnectTimer = setTimeout(attempt, this._reconnectDelayMs)
|
|
741
|
+
}
|
|
742
|
+
this._reconnectTimer = setTimeout(attempt, 0)
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
/** Stop the issue #204 reconnect loop (success, teardown, or pool change). */
|
|
746
|
+
_stopReconnectLoop() {
|
|
747
|
+
if (this._reconnectTimer) { clearTimeout(this._reconnectTimer); this._reconnectTimer = null }
|
|
748
|
+
this._reconnectDelayMs = 0
|
|
706
749
|
}
|
|
707
750
|
|
|
708
751
|
/**
|
|
@@ -1052,7 +1095,9 @@ export class WebAttach {
|
|
|
1052
1095
|
*/
|
|
1053
1096
|
async close({ stopRemote = false, exec } = {}) {
|
|
1054
1097
|
// Stop following the pool BEFORE any await: a reconnect landing mid-teardown
|
|
1055
|
-
// must not re-arm the tunnel this call is in the middle of closing.
|
|
1098
|
+
// must not re-arm the tunnel this call is in the middle of closing. The
|
|
1099
|
+
// reconnect loop (issue #204) dies with the same stroke.
|
|
1100
|
+
this._stopReconnectLoop()
|
|
1056
1101
|
this._detachPool()
|
|
1057
1102
|
if (this.attachedClient && this.onClientClose) {
|
|
1058
1103
|
try { this.attachedClient.removeListener('close', this.onClientClose) } catch { /* already gone */ }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-remote",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
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>",
|
|
@@ -103,6 +103,6 @@
|
|
|
103
103
|
"test:coverage": "node scripts/coverage-union.mjs",
|
|
104
104
|
"test:coverage:gate": "node scripts/coverage-union.mjs --gate 70 --file-gate 60"
|
|
105
105
|
},
|
|
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.
|
|
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.5.0 更新说明](https://github.com/flymysql/dsh-remote/blob/main/docs/release/1.5.0.md):Web 隧道断链自愈、下载到浏览器所在机器、高 RTT 提速 6 倍、堡垒机终端纯登录模式。\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",
|
|
107
107
|
"readmeFilename": "README.md"
|
|
108
108
|
}
|