dsh-ssh-hub 0.0.0-stage → 0.1.9

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.
Files changed (129) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +255 -2
  3. package/cordis.patch.yml +16 -0
  4. package/icon.svg +3 -0
  5. package/lib/client.js +13766 -0
  6. package/lib/index.js +6727 -0
  7. package/lib/types/activity/history.d.ts +50 -0
  8. package/lib/types/alerting/notify.d.ts +89 -0
  9. package/lib/types/alerting/prompt-summary.d.ts +28 -0
  10. package/lib/types/alerting/rules.d.ts +135 -0
  11. package/lib/types/alerting/tools.d.ts +30 -0
  12. package/lib/types/audit/audit-log.d.ts +84 -0
  13. package/lib/types/audit/recorder.d.ts +50 -0
  14. package/lib/types/client/api.d.ts +199 -0
  15. package/lib/types/client/index.d.ts +45 -0
  16. package/lib/types/client/locales.d.ts +309 -0
  17. package/lib/types/client/native-panel.d.ts +70 -0
  18. package/lib/types/client/panel/ClusterTab.d.ts +7 -0
  19. package/lib/types/client/panel/DeployTab.d.ts +10 -0
  20. package/lib/types/client/panel/FleetTab.d.ts +10 -0
  21. package/lib/types/client/panel/HostFormDialog.d.ts +12 -0
  22. package/lib/types/client/panel/HostsTab.d.ts +25 -0
  23. package/lib/types/client/panel/LogsTab.d.ts +10 -0
  24. package/lib/types/client/panel/SshPanel.d.ts +14 -0
  25. package/lib/types/client/panel/TerminalTab.d.ts +27 -0
  26. package/lib/types/client/panel/TransferTab.d.ts +7 -0
  27. package/lib/types/client/panel/TunnelsTab.d.ts +27 -0
  28. package/lib/types/client/panel/controller.d.ts +253 -0
  29. package/lib/types/client/panel/helpers.d.ts +45 -0
  30. package/lib/types/client/panel/tabs.d.ts +62 -0
  31. package/lib/types/client/panel/xterm.css.d.ts +2 -0
  32. package/lib/types/client/settings-binding.d.ts +71 -0
  33. package/lib/types/deploy/orchestrator.d.ts +158 -0
  34. package/lib/types/deploy/tools.d.ts +14 -0
  35. package/lib/types/dsh-home.d.ts +16 -0
  36. package/lib/types/engine/cluster.d.ts +19 -0
  37. package/lib/types/engine/connection-pool.d.ts +183 -0
  38. package/lib/types/engine/proxy-command.d.ts +36 -0
  39. package/lib/types/engine/pty.d.ts +32 -0
  40. package/lib/types/engine/sftp.d.ts +20 -0
  41. package/lib/types/engine/terminal-sessions.d.ts +67 -0
  42. package/lib/types/engine/tunnel-discovery.d.ts +89 -0
  43. package/lib/types/engine/tunnel.d.ts +38 -0
  44. package/lib/types/engine.d.ts +98 -0
  45. package/lib/types/http.d.ts +59 -0
  46. package/lib/types/index.d.ts +128 -0
  47. package/lib/types/inspect/checks.d.ts +118 -0
  48. package/lib/types/inspect/inspection.d.ts +111 -0
  49. package/lib/types/inspect/tools.d.ts +50 -0
  50. package/lib/types/logs/search.d.ts +131 -0
  51. package/lib/types/logs/tools.d.ts +6 -0
  52. package/lib/types/loopback.d.ts +64 -0
  53. package/lib/types/monitor/loop.d.ts +133 -0
  54. package/lib/types/monitor/metrics.d.ts +151 -0
  55. package/lib/types/mount-once.d.ts +55 -0
  56. package/lib/types/protocol.d.ts +518 -0
  57. package/lib/types/routes.d.ts +82 -0
  58. package/lib/types/security/known-hosts.d.ts +153 -0
  59. package/lib/types/security/master-secret.d.ts +157 -0
  60. package/lib/types/security/redact.d.ts +44 -0
  61. package/lib/types/security/secrets.d.ts +70 -0
  62. package/lib/types/ssh-config.d.ts +42 -0
  63. package/lib/types/store.d.ts +183 -0
  64. package/lib/types/tool-surface.d.ts +72 -0
  65. package/lib/types/tools.d.ts +56 -0
  66. package/locale/en.json +6 -0
  67. package/locale/zh.json +6 -0
  68. package/package.json +126 -6
  69. package/src/activity/history.ts +117 -0
  70. package/src/alerting/notify.ts +212 -0
  71. package/src/alerting/prompt-summary.ts +71 -0
  72. package/src/alerting/rules.ts +281 -0
  73. package/src/alerting/tools.ts +263 -0
  74. package/src/audit/audit-log.ts +198 -0
  75. package/src/audit/recorder.ts +73 -0
  76. package/src/client/api.ts +752 -0
  77. package/src/client/css-modules.d.ts +5 -0
  78. package/src/client/index.ts +150 -0
  79. package/src/client/locales.ts +634 -0
  80. package/src/client/native-panel.tsx +141 -0
  81. package/src/client/panel/ClusterTab.tsx +141 -0
  82. package/src/client/panel/DeployTab.tsx +314 -0
  83. package/src/client/panel/FleetTab.tsx +494 -0
  84. package/src/client/panel/HostFormDialog.tsx +289 -0
  85. package/src/client/panel/HostsTab.tsx +395 -0
  86. package/src/client/panel/LogsTab.tsx +208 -0
  87. package/src/client/panel/SshPanel.tsx +105 -0
  88. package/src/client/panel/TerminalTab.tsx +550 -0
  89. package/src/client/panel/TransferTab.tsx +238 -0
  90. package/src/client/panel/TunnelsTab.tsx +306 -0
  91. package/src/client/panel/controller.ts +507 -0
  92. package/src/client/panel/helpers.ts +84 -0
  93. package/src/client/panel/panel.module.css +1712 -0
  94. package/src/client/panel/tabs.ts +52 -0
  95. package/src/client/panel/xterm.css.ts +2 -0
  96. package/src/client/settings-binding.ts +184 -0
  97. package/src/deploy/orchestrator.ts +326 -0
  98. package/src/deploy/tools.ts +225 -0
  99. package/src/dsh-home.ts +42 -0
  100. package/src/engine/cluster.ts +60 -0
  101. package/src/engine/connection-pool.ts +721 -0
  102. package/src/engine/proxy-command.ts +248 -0
  103. package/src/engine/pty.ts +78 -0
  104. package/src/engine/sftp.ts +229 -0
  105. package/src/engine/terminal-sessions.ts +280 -0
  106. package/src/engine/tunnel-discovery.ts +352 -0
  107. package/src/engine/tunnel.ts +205 -0
  108. package/src/engine.ts +187 -0
  109. package/src/http.ts +127 -0
  110. package/src/index.ts +690 -0
  111. package/src/inspect/checks.ts +251 -0
  112. package/src/inspect/inspection.ts +321 -0
  113. package/src/inspect/tools.ts +366 -0
  114. package/src/logs/search.ts +251 -0
  115. package/src/logs/tools.ts +160 -0
  116. package/src/loopback.ts +119 -0
  117. package/src/monitor/loop.ts +265 -0
  118. package/src/monitor/metrics.ts +333 -0
  119. package/src/mount-once.ts +142 -0
  120. package/src/protocol.ts +528 -0
  121. package/src/routes.ts +953 -0
  122. package/src/security/known-hosts.ts +342 -0
  123. package/src/security/master-secret.ts +334 -0
  124. package/src/security/redact.ts +119 -0
  125. package/src/security/secrets.ts +152 -0
  126. package/src/ssh-config.ts +182 -0
  127. package/src/store.ts +757 -0
  128. package/src/tool-surface.ts +96 -0
  129. package/src/tools.ts +517 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,256 @@
1
- # Temporary Holding Version
1
+ # dsh-ssh-hub
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 面向 **DSH(DeepSeek Harness)** 的服务器车队运维插件。
4
+
5
+ 以 [`@linxin666/dsh-ssh`](https://www.npmjs.com/package/@linxin666/dsh-ssh) 为基座(Apache-2.0,10.4k★),在其之上补齐了运维场景中真正缺失的四块能力:**巡检、告警、部署发布、跨机日志**,同时收紧了安全面。
6
+
7
+ 适用于 **10–50 台纯 Linux 云服务器** 的 agentless 运维:远端不安装任何 agent,全部能力通过 SSH 实现。
8
+
9
+ ---
10
+
11
+ ## 能力
12
+
13
+ ### 继承自基座(6 个工具)
14
+
15
+ | 工具 | 用途 |
16
+ | --- | --- |
17
+ | `ssh_list` | 列出主机(按环境 / 标签分组) |
18
+ | `ssh_exec` | 在单台远程主机执行命令 |
19
+ | `ssh_upload` / `ssh_download` | 与远程主机互传文件 |
20
+ | `ssh_tunnel` | 本地端口转发(访问远程内网服务) |
21
+ | `ssh_cluster` | 按 aliases / environment / tags 集群并发执行 |
22
+
23
+ 基座还提供:持久连接池(空闲 30 分钟断开)、`~/.ssh/config` 导入、ProxyJump / ProxyCommand 跳板、PTY Web 终端(多标签 / 分离重连 / 2FA)、SFTP。
24
+
25
+ ### 本插件新增(9 个工具)
26
+
27
+ | 工具 | 用途 |
28
+ | --- | --- |
29
+ | `hub_inspect` | 运行内置巡检项并留存本轮结果 |
30
+ | `hub_inspect_catalog` | 列出可用巡检项与阈值 |
31
+ | `hub_inspect_diff` | 对比上一轮:值漂移 / 新增超限 / 已恢复 |
32
+ | `hub_monitor` | 报告定时监控是否在跑、间隔、覆盖台数、上一轮与下一轮时间 |
33
+ | `hub_alerts` | 查看告警状态与最近事件 |
34
+ | `hub_alert_rules` | 列出 / 调整告警规则 |
35
+ | `hub_alert_test` | 测试通知渠道(区分"规则没触发"与"渠道坏了") |
36
+ | `hub_deploy` | 分批部署 + 健康检查 + 自动回滚 |
37
+ | `hub_log_search` | 跨机检索 journald / 日志目录 |
38
+
39
+ > `hub_monitor` 存在的原因:监控**未启动**和机群**全部健康**都会表现为"告警列表为空",
40
+ > 而这两件事的含义相反。问一句"有没有东西在看"要先于"有没有问题"。
41
+
42
+ ### 内置巡检项
43
+
44
+ 全部为只读 POSIX 命令,**不在远端安装任何东西**:
45
+
46
+ | id | 检查 | 触发条件 |
47
+ | --- | --- | --- |
48
+ | `disk-usage` | 磁盘使用率 | > 85% |
49
+ | `disk-inodes` | inode 使用率 | > 85% |
50
+ | `memory-used` | 内存使用率 | > 90% |
51
+ | `load-average` | 5 分钟负载 | > 4 |
52
+ | `uptime` | 运行时长 | < 1 小时(疑似重启循环) |
53
+ | `sshd-running` | sshd 运行中 | 停止 |
54
+ | `failed-units` | 失败的 systemd 单元 | > 0 |
55
+ | `kernel` | 内核版本 | 仅记录 |
56
+
57
+ ---
58
+
59
+ ## 三个关键设计决策
60
+
61
+ ### 1. 告警的 `null` 冻结语义
62
+
63
+ 探针读不到值(SSH 超时、命令失败)时,告警状态被**冻结**——既不算恢复,也不推进计数。
64
+
65
+ 一个瞎掉的探针如果上报"已恢复",机器宕机会被显示成健康。所以状态冻结时保持原状,恢复通知在黑屏后依然照常发出。
66
+
67
+ ### 2. 冷却只挡重复触发,不挡恢复
68
+
69
+ 告警在冷却期内持续越界时不再重复通知;但**恢复通知永远发送**。运维人员被告知"磁盘满了"却从未被告知"磁盘好了",页面会一直开着。
70
+
71
+ ### 3. 回滚是一等公民
72
+
73
+ `hub_deploy` 的每个步骤都可以带 `rollbackCommand`:
74
+
75
+ - 健康检查失败 → 整批回滚(不是逐台,因为"一半回滚一半没回滚"是最糟的状态)
76
+ - 缺少回滚命令 → **如实报告"无法回滚"**,不假装这批没问题
77
+ - 部分步骤缺回滚命令 → 拒绝执行部分回滚(半应用状态比不应用更危险)
78
+ - 回滚命令按**逆序**执行
79
+
80
+ 被前序失败批次跳过的主机,会明确列为"未部署",不会被算作已部署。
81
+
82
+ ---
83
+
84
+ ## 安全
85
+
86
+ | 项 | 行为 |
87
+ | --- | --- |
88
+ | 凭据加密 | 配置 `DSH_SSH_HUB_SECRET` 且 `encryptCredentials=true` 时,凭据以 scrypt + AES-GCM 信封加密落盘。**没有默认密钥**——默认密钥等于后门。旧版明文库可正常加载,并在下次更新时自动重新加密 |
89
+ | 主机指纹 | `hostKeyPolicy` = `off` / `tofu` / `strict`,对照 `~/.ssh/known_hosts` 校验。密钥变更或吊销在任何策略下都被拒绝 |
90
+ | 输出脱敏 | 命令输出返回前脱敏(密码赋值、私钥块、Bearer token、AWS key、JWT、连接串)。**这是安全网不是保证**——远端可能有本模块不认识的秘密形态 |
91
+ | 审计日志 | `$DSH_HOME/dsh-ssh-hub/audit.log`(JSON Lines,0600)。exec / cluster / upload / download / tunnel / deploy 全部记录,actor 区分 user / agent |
92
+ | 遥测 | **已移除**。基座每个浏览器每天向 `dsh-market.com` 发一次匿名心跳;一个掌握凭据和服务器清单的工具不该向第三方报告自己的存在 |
93
+
94
+ ---
95
+
96
+ ## 安装
97
+
98
+ ```bash
99
+ npm install dsh-ssh-hub
100
+ dsh plugin --profile desktop add dsh-ssh-hub
101
+ ```
102
+
103
+ 本项目为独立开发(非 monorepo),自建构建链:
104
+
105
+ ```bash
106
+ npm install --ignore-scripts # 沙箱下会阻止子进程 spawn,必须加 --ignore-scripts
107
+ npm run check # typecheck + test + build + pack 校验
108
+ ```
109
+
110
+ `npm run build` **不等于**可安装件:安装器复制的是 tgz。`npm run pack:check` 会解包 tgz 并逐文件比对 SHA-256,产物与磁盘不一致即失败。
111
+
112
+ ---
113
+
114
+ ## 配置
115
+
116
+ | 字段 | 默认 | 说明 |
117
+ | --- | --- | --- |
118
+ | `enabled` | `true` | 总开关 |
119
+ | `announceToAgent` | `false` | 是否向模型播报本插件存在 |
120
+ | `connectTimeoutMs` | `30000` | 连接与认证超时(1–600000) |
121
+ | `hostKeyPolicy` | `off` | `off` / `tofu` / `strict` |
122
+ | `knownHostsPath` | `""` | 空 = `~/.ssh/known_hosts` |
123
+ | `encryptCredentials` | `false` | 是否加密凭据落盘 |
124
+ | `auditEnabled` | `true` | 是否写审计日志 |
125
+ | `monitorEnabled` | `false` | 是否启动定时监控循环 |
126
+ | `monitorIntervalMs` | `60000` | 监控间隔(10000–3600000) |
127
+ | `monitorChecks` | `""` | 逗号分隔的巡检项;空 = 全部 |
128
+
129
+ > **`monitorEnabled` 默认关闭**。一个插件刚加载就自主探测你所有服务器的定时器是个惊喜,
130
+ > 不是功能。开启是显式决策。未开启时面板与 `hub_monitor` 都会明说"没有东西在检查",
131
+ > 以免"安静的告警列表"被误读成"机群健康"。
132
+
133
+ 主密钥来自 `DSH_SSH_HUB_SECRET`(环境变量)或 `DSH_SSH_HUB_SECRET_FILE`(文件路径,
134
+ 读取后去掉一个结尾换行)。**没有默认值**——一个内置的默认主密钥等于没有加密。
135
+ 加密需要 `encryptCredentials` 与主密钥**同时**具备:只给密钥不改开关,不会悄悄改写
136
+ 一个操作者没选择加密的存储;只改开关不给密钥,就不能加密。
137
+
138
+ ---
139
+
140
+ ## 监控与面板
141
+
142
+ 定时循环由 DSH 的 `timer` 服务驱动(`inject` 里是**硬依赖**:若允许 `setInterval` 兜底,
143
+ 插件卸载后探针定时器会泄漏)。
144
+
145
+ 一轮的行为边界:
146
+
147
+ - 上一轮未结束 → 下一轮跳过,并记录跳过原因(不是静默丢弃)
148
+ - 没有需要巡检的主机 → 跳过,原因如实记录
149
+ - 某台主机连不上 → 该台记为**盲探针**(`value: null` + `error`),其余照跑;
150
+ 一台机器重启不会让整个机群失去监控
151
+ - 通知渠道抛错 → 吞掉,循环存活(通知失败不该等于监控停摆)
152
+
153
+ 指标分级落盘:`raw`(24h) → `1m`(30d) → `15m`(90d) → `1h`(永久)。滚动聚合按
154
+ `metric|at` 键合并,重复聚合不会产生重复桶;盲探针不进均值,只有盲探针的桶
155
+ `value: null` 但样本数照记。删主机时它的指标历史一并清掉——历史只按别名索引,
156
+ 留着会让后来同名的主机继承别人的数字,而那些数字看起来是真的。
157
+
158
+ 面板新增第 6 个页签「机群」:监控武装状态 → 上一轮超限/盲探针 → 与上一轮的变化集 →
159
+ 告警状态与事件 → 磁盘趋势迷你图 → 安全态势。页签里**没有**启停监控的按钮:
160
+ 那是带审计痕迹的配置决策,不该由一个面板按钮代劳。唯一的动作是「立即巡检」,
161
+ 它走的路径和定时器完全相同。
162
+
163
+ 7 条新路由(均只应答本机回环,非回环 403):
164
+
165
+ ```
166
+ GET /api/dsh-ssh/monitor 监控状态
167
+ POST /api/dsh-ssh/monitor/tick 手动触发一轮(与定时器同一条路径)
168
+ GET /api/dsh-ssh/inspection 最近轮次(limit 1–50,最新在前)
169
+ GET /api/dsh-ssh/inspection/diff 与上一轮的变化
170
+ GET /api/dsh-ssh/alerts 告警状态与最近 50 条事件
171
+ GET /api/dsh-ssh/metrics 某主机的指标序列(需 alias,tier 校验,limit 1–2000)
172
+ GET /api/dsh-ssh/security 加密/指纹策略/审计的当前态势
173
+ ```
174
+
175
+ ---
176
+
177
+ ## 文件布局
178
+
179
+ ```
180
+ src/
181
+ index.ts 插件入口:配置、引擎、路由、工具注册、提示词
182
+ engine.ts SSH 引擎(连接池 / exec / cluster / 隧道 / SFTP)
183
+ store.ts 主机存储(凭据加解密)
184
+ tools.ts 基座 6 个工具(+ 脱敏 + 审计)
185
+ routes.ts /api/dsh-ssh 路由族(含监控 7 条)
186
+ security/
187
+ known-hosts.ts known_hosts 解析、指纹、校验策略
188
+ secrets.ts 凭据加密信封
189
+ redact.ts 输出脱敏
190
+ audit/
191
+ audit-log.ts JSON Lines 审计日志
192
+ recorder.ts 审计记录器
193
+ inspect/
194
+ checks.ts 巡检项定义与判定
195
+ inspection.ts 巡检执行与结果留存(单台失败不拖垮整轮)
196
+ tools.ts 巡检工具
197
+ monitor/
198
+ loop.ts 定时监控循环(重叠保护 / 幂等启停 / 有界事件流)
199
+ metrics.ts raw/1m/15m/1h 四级指标落盘与滚动聚合
200
+ alerting/
201
+ rules.ts 告警状态机
202
+ notify.ts 模板化通知(Bark / Telegram / 飞书 / 企微)
203
+ tools.ts 告警工具
204
+ deploy/
205
+ orchestrator.ts 部署编排(分批 / 健康检查 / 回滚)
206
+ tools.ts 部署工具
207
+ logs/
208
+ search.ts 跨机日志检索
209
+ tools.ts 日志工具
210
+ client/panel/
211
+ HostsTab.tsx 主机管理与 SSH 配置导入
212
+ TerminalTab.tsx Web 终端
213
+ TransferTab.tsx SFTP 文件传输
214
+ TunnelsTab.tsx 隧道管理(外部隧道探测与 forwards.conf 映射)
215
+ ClusterTab.tsx 集群并发执行
216
+ DeployTab.tsx 分批部署与回滚
217
+ LogsTab.tsx 跨机日志检索
218
+ FleetTab.tsx 机群状态与巡检监控
219
+ scripts/
220
+ verify-monitor.mjs 装好后对运行中的插件做端到端验收
221
+ verify-ssh2-import.mjs 独立证明 ssh2 的 CJS 导入形式在真实 node 里可用
222
+ verify-contrast.mjs 双皮肤色彩对比度合规性检测
223
+ render-preview.mjs 全视图端到端预览渲染与无盲区截图
224
+ tests/ 313 个测试(20 个套件)
225
+ ```
226
+
227
+ ---
228
+
229
+ ## 测试
230
+
231
+ ```
232
+ Test Files 20 passed (20)
233
+ Tests 313 passed (313)
234
+ ```
235
+
236
+ 其中 `tests/ssh-e2e.test.ts` 会起一个**真实的 ssh2 服务端**(自签 RSA 主机密钥、
237
+ 口令认证、exec 通道),验证连接/认证/执行/连接池复用/集群顺序/完整一轮巡检/
238
+ 主机指纹三策略。它不是 mock 掉传输层,而是真的过一遍 SSH 握手——
239
+ "命令字符串拼对了"和"远程真的收到这条命令"是两件事。
240
+
241
+ 两个脚本是可执行的验收门,不是文档示例:
242
+
243
+ ```
244
+ node scripts/verify-ssh2-import.mjs # 证明 CJS 导入形式在真实 node 进程里能构造并连接
245
+ node scripts/verify-monitor.mjs # 对运行中的插件跑完整监控链路(需 DSH 在跑)
246
+ ```
247
+
248
+ `verify-ssh2-import.mjs` 有必要单独存在:vitest 走 Vite 的 CJS 互操作,
249
+ 所以测试全绿**不能**证明 esbuild 的 ESM 产物里能拿到 `ssh2.Client`。
250
+ 这个区别是实测踩出来的(见 DESIGN.md 风险表)。
251
+
252
+ ---
253
+
254
+ ## 许可证
255
+
256
+ Apache-2.0。基座 [`@linxin666/dsh-ssh`](https://github.com/zhu1090093659/dsh-web) 同为 Apache-2.0。
@@ -0,0 +1,16 @@
1
+ # dsh-ssh-hub bundle patch: inserts the dual-face plugin row into the web
2
+ # profile roster. Applied as a profile bundle layer (the `dsh.bundle.patch`
3
+ # manifest field) over dsh-base.
4
+ #
5
+ # The row is a bare plugin by package name: the node half (exports ".") runs
6
+ # in the host process (SSH engine, /api/dsh-ssh routes, agent tools), and the
7
+ # `dsh.client` declaration in package.json makes the browser half
8
+ # (exports "./client", served at /plugins/<id>/client.js) load in the web GUI.
9
+ #
10
+ # The row id is `ssh-hub` rather than the upstream `ssh`, so that a profile
11
+ # holding both plugins has two distinct rows instead of one silently
12
+ # replacing the other. The two share the /api/dsh-ssh route prefix, so only
13
+ # one of them may be enabled at a time.
14
+ - insert:
15
+ - id: ssh-hub
16
+ name: 'dsh-ssh-hub'
package/icon.svg ADDED
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
2
+ <path fill="#4d6bfe" fill-rule="evenodd" d="M 67.5 120 L 70.5 120 L 72.5 121 L 80.5 129 L 81.5 129 L 84.5 132 L 85.5 132 L 90.5 136 L 93.5 137 L 95.5 139 L 101.5 142 L 103.5 142 L 106.5 144 L 111.5 145 L 112.5 146 L 115.5 146 L 119.5 148 Q 122.75 147.25 123.5 149 L 127.5 149 L 128.5 150 L 133.5 150 L 134.5 151 L 140.5 151 L 141.5 152 L 150.5 152 L 151.5 153 L 160.5 153 L 161.5 154 L 171.5 154 L 172.5 155 L 178.5 155 L 179.5 156 Q 183.5 155 184.5 157 L 189.5 157 Q 190.5 159 194.5 158 L 195.5 159 L 197.5 159 L 198.5 160 L 200.5 160 L 201.5 161 L 206.5 162 L 209.5 164 L 211.5 164 L 219.5 168 L 224.5 172 L 227.5 173 L 247 191.5 L 247 192.5 L 253 199.5 L 255.5 204 L 258 201.5 L 263 193.5 L 272.5 183 L 273.5 183 L 280.5 176 L 281.5 176 L 292.5 168 L 300.5 164 L 302.5 164 L 305.5 162 L 307.5 162 L 308.5 161 L 310.5 161 L 314.5 159 L 317.5 159 L 318.5 158 Q 321.75 158.75 322.5 157 L 326.5 157 L 327.5 156 L 331.5 156 L 332.5 155 L 337.5 155 L 338.5 154 L 348.5 154 L 349.5 153 L 358.5 153 L 359.5 152 L 368.5 152 L 369.5 151 L 376.5 151 L 377.5 150 L 383.5 150 L 384.5 149 L 388.5 149 L 389.5 148 L 392.5 148 L 393.5 147 L 396.5 147 L 397.5 146 L 399.5 146 L 400.5 145 L 405.5 144 L 423.5 135 L 426.5 132 L 431.5 129 L 439.5 121 L 441.5 120 L 444.5 120 L 448 123.5 L 448 140.5 L 447 141.5 L 447 149.5 L 446 150.5 L 446 154.5 L 445 155.5 Q 445.75 158.75 444 159.5 L 444 163.5 Q 442.25 164.25 443 167.5 L 440 173.5 L 439 178.5 L 435 185.5 L 435 187.5 L 432 193.5 L 430 195.5 L 429 198.5 L 427 200.5 L 425 204.5 L 419 211.5 L 419 212.5 L 402.5 229 L 401.5 229 L 394.5 235 L 393.5 235 L 388.5 239 L 385.5 240 L 383.5 242 L 371.5 248 L 369.5 248 L 364.5 251 L 362.5 251 L 361.5 252 L 359.5 252 L 358.5 253 L 356.5 253 L 355.5 254 L 353.5 254 L 349.5 256 L 342.5 257 L 338.5 259 L 335.5 259 L 334.5 260 L 327.5 261 L 326.5 262 L 324.5 262 L 323.5 263 L 321.5 263 L 320.5 264 L 318.5 264 L 317.5 265 L 312.5 266 L 309.5 268 L 307.5 268 L 295.5 275 L 288 282.5 Q 287.5 286 285 287.5 Q 285.5 290 284 290.5 L 284 293.5 L 283 294.5 L 283 311.5 L 284 312.5 L 284 318.5 L 285 319.5 L 285 323.5 L 286 324.5 L 286 328.5 Q 288 329.5 287 333.5 L 288 334.5 L 288 337.5 L 289 338.5 L 289 341.5 L 290 342.5 L 290 345.5 L 291 346.5 L 292 353.5 L 293 354.5 L 293 356.5 L 295 360.5 L 295 363.5 L 296 364.5 L 296 367.5 L 297 368.5 L 297 370.5 L 298 371.5 L 298 373.5 L 299 374.5 L 299 376.5 L 301 380.5 L 301 386.5 L 298.5 389 L 294.5 391 Q 292 390.5 291.5 392 L 286.5 392 L 285.5 393 L 272.5 393 L 271.5 394 L 240.5 394 L 239.5 393 L 227.5 393 L 226.5 392 L 221.5 392 Q 220.75 390.25 217.5 391 L 212 387.5 L 211 385.5 L 211 381.5 L 212 380.5 Q 211.5 378 213 377.5 L 213 374.5 L 214 373.5 L 214 371.5 L 216 367.5 L 216 364.5 L 217 363.5 L 217 361.5 L 219 357.5 L 219 354.5 L 221 350.5 L 221 347.5 L 222 346.5 L 222 343.5 L 223 342.5 L 223 339.5 L 224 338.5 L 224 335.5 L 225 334.5 Q 224.25 331.25 226 330.5 L 226 326.5 L 227 325.5 Q 226 321.5 228 320.5 L 228 315.5 L 229 314.5 L 229 292.5 L 228 291.5 L 227 286.5 L 225 284.5 L 223 280.5 L 219.5 277 L 218.5 277 L 212.5 272 L 202.5 267 L 200.5 267 L 197.5 265 L 194.5 265 L 193.5 264 L 191.5 264 L 190.5 263 L 188.5 263 L 184.5 261 L 181.5 261 L 180.5 260 L 173.5 259 L 172.5 258 L 170.5 258 L 166.5 256 L 159.5 255 L 158.5 254 L 156.5 254 L 155.5 253 L 150.5 252 L 147.5 250 L 145.5 250 L 142.5 248 L 140.5 248 L 128.5 242 L 123.5 238 L 120.5 237 L 109.5 228 L 108.5 228 L 95 214.5 L 95 213.5 L 87 204.5 L 84 198.5 L 82 196.5 L 80 191.5 L 77 187.5 L 77 185.5 L 72 175.5 L 72 173.5 L 71 172.5 L 71 170.5 L 69 166.5 L 69 163.5 L 68 162.5 Q 68.75 159.25 67 158.5 L 67 154.5 L 66 153.5 L 66 148.5 L 65 147.5 L 65 139.5 L 64 138.5 L 64 124.5 L 67.5 120 Z"/>
3
+ </svg>