@goodandready/dsh-remote-workspace 0.3.0 → 0.3.2
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.md +17 -0
- package/README.ru.md +17 -0
- package/README.zh.md +17 -0
- package/docs/design/DESIGN.md +1 -1
- package/lib/alert-service.js +109 -0
- package/lib/client.js +2316 -1991
- package/lib/diagnose-service.js +57 -0
- package/lib/docker-service.js +1 -1
- package/lib/env-service.js +122 -0
- package/lib/index.js +83 -16
- package/lib/mirror-sync-service.js +2 -2
- package/lib/routes/docker.js +85 -0
- package/lib/routes/env.js +60 -0
- package/lib/routes/files.js +88 -0
- package/lib/routes/helpers.js +40 -0
- package/lib/routes/profiles.js +141 -0
- package/lib/routes/sync.js +52 -0
- package/lib/routes/terminal.js +103 -0
- package/lib/routes/tunnels.js +59 -0
- package/lib/routes.js +47 -516
- package/lib/ssh-config-parser.js +89 -0
- package/lib/ssh-service.js +24 -9
- package/lib/tar-sync-service.js +85 -0
- package/lib/tools.js +78 -3
- package/lib/tunnel-service.js +2 -2
- package/lib/updater-service.js +338 -0
- package/lib/vault-service.js +29 -5
- package/lib/watcher-service.js +3 -3
- package/package.json +6 -3
- package/docs/plans/findings.md +0 -19
- package/docs/plans/progress.md +0 -15
- package/docs/plans/task_plan.md +0 -23
package/README.md
CHANGED
|
@@ -22,6 +22,16 @@
|
|
|
22
22
|
<a href="README.zh.md"><b>🇨🇳 中文说明</b></a>
|
|
23
23
|
</p>
|
|
24
24
|
|
|
25
|
+
<table align="center">
|
|
26
|
+
<tr>
|
|
27
|
+
<td align="center">
|
|
28
|
+
⭐ <strong>If you like this plugin, please star it on GitHub</strong> — it shows me that the plugin is useful to you and motivates me to keep developing it.
|
|
29
|
+
<br><br>
|
|
30
|
+
🐛 <strong>If you find a bug or would like to request a feature</strong>, open a GitHub issue in any language — I will review your proposal and implement useful suggestions in a future plugin version.
|
|
31
|
+
</td>
|
|
32
|
+
</tr>
|
|
33
|
+
</table>
|
|
34
|
+
|
|
25
35
|
</div>
|
|
26
36
|
|
|
27
37
|
---
|
|
@@ -236,3 +246,10 @@ All endpoints are hosted under `/dsh-remote-workspace`:
|
|
|
236
246
|
## 📄 License
|
|
237
247
|
|
|
238
248
|
MIT © [GooDAnDReaDY](https://github.com/GooDAnDReaDY)
|
|
249
|
+
|
|
250
|
+
### 13. Smart Tarball Sync & Diagnostics (v0.3.1)
|
|
251
|
+
- **`🚀 Fast Tarball Stream`**: High-throughput directory sync via on-the-fly streaming `tar -czf` bypassing per-file roundtrips.
|
|
252
|
+
- **`🩺 Remote Diagnostics (remote_diagnose)`**: Instant one-shot checks for occupied ports (`ports`), OOM killer events (`oom_killer`), disk consumption (`disk`), and service crash-logs (`service_logs`).
|
|
253
|
+
- **`📥 Import from ~/.ssh/config`**: One-click import of hosts, keys, and ProxyJump configurations directly into the encrypted `.env` vault.
|
|
254
|
+
- **`🗃️ Remote Environment Manager (remote_env)`**: Inspect and atomically modify remote `.env` key-values with password masking and structural preservation.
|
|
255
|
+
- **`📡 Background Anomaly Alerts`**: Proactive monitoring of disk (<10% free), memory (<5%), and restarting Docker containers via Cordis event bus (`remote-workspace/alert`).
|
package/README.ru.md
CHANGED
|
@@ -22,6 +22,16 @@
|
|
|
22
22
|
<a href="README.zh.md"><b>🇨🇳 中文说明</b></a>
|
|
23
23
|
</p>
|
|
24
24
|
|
|
25
|
+
<table align="center">
|
|
26
|
+
<tr>
|
|
27
|
+
<td align="center">
|
|
28
|
+
⭐ <strong>Если вам нравится этот плагин, поставьте ему звезду на GitHub</strong> — это покажет мне, что плагин вам полезен, и будет мотивировать меня развивать его дальше.
|
|
29
|
+
<br><br>
|
|
30
|
+
🐛 <strong>Если вы нашли баг или хотите предложить новый функционал</strong>, создайте issue на GitHub на любом языке — я рассмотрю ваше предложение и реализую полезные идеи в одной из следующих версий плагина.
|
|
31
|
+
</td>
|
|
32
|
+
</tr>
|
|
33
|
+
</table>
|
|
34
|
+
|
|
25
35
|
</div>
|
|
26
36
|
|
|
27
37
|
---
|
|
@@ -236,3 +246,10 @@ dsh-remote-workspace:
|
|
|
236
246
|
## 📄 Лицензия
|
|
237
247
|
|
|
238
248
|
MIT © [GooDAnDReaDY](https://github.com/GooDAnDReaDY)
|
|
249
|
+
|
|
250
|
+
### 13. Пакетная синхронизация и диагностика (v0.3.1)
|
|
251
|
+
- **`🚀 Быстрый Tarball поток`**: Высокоскоростная передача структуры каталогов через потоковый `tar -czf` без задержек пофайлового обхода.
|
|
252
|
+
- **`🩺 Диагностика сервера (remote_diagnose)`**: Мгновенный аудит занятых портов (`ports`), срабатываний OOM Killer (`oom_killer`), дискового пространства (`disk`) и crash-логов служб.
|
|
253
|
+
- **`📥 Импорт из ~/.ssh/config`**: Автоматическое добавление хостов, ключей и bastion-узлов в зашифрованный `.env` vault.
|
|
254
|
+
- **`🗃️ Менеджер переменных окружения (remote_env)`**: Атомарное изменение и безопасный просмотр удалённых `.env` файлов с маскированием паролей.
|
|
255
|
+
- **`📡 Мониторинг аномалий`**: Оповещение о переполнении диска (<10%), дефиците ОЗУ (<5%) и циклических перезапусках контейнеров через шину событий Cordis (`remote-workspace/alert`).
|
package/README.zh.md
CHANGED
|
@@ -22,6 +22,16 @@
|
|
|
22
22
|
<a href="README.zh.md"><b>🇨🇳 中文说明</b></a>
|
|
23
23
|
</p>
|
|
24
24
|
|
|
25
|
+
<table align="center">
|
|
26
|
+
<tr>
|
|
27
|
+
<td align="center">
|
|
28
|
+
⭐ <strong>如果您喜欢这个插件,请在 GitHub 上为它点亮 Star</strong> — 这能让我知道插件对您有用,并鼓励我继续开发和维护它。
|
|
29
|
+
<br><br>
|
|
30
|
+
🐛 <strong>如果您发现 Bug 或希望增加功能</strong>,请使用任意语言在 GitHub 上提交 Issue — 我会评估您的建议,并在后续版本中实现有价值的改进。
|
|
31
|
+
</td>
|
|
32
|
+
</tr>
|
|
33
|
+
</table>
|
|
34
|
+
|
|
25
35
|
</div>
|
|
26
36
|
|
|
27
37
|
---
|
|
@@ -236,3 +246,10 @@ dsh-remote-workspace:
|
|
|
236
246
|
## 📄 开源许可证
|
|
237
247
|
|
|
238
248
|
MIT © [GooDAnDReaDY](https://github.com/GooDAnDReaDY)
|
|
249
|
+
|
|
250
|
+
### 13. 归档流同步与综合诊断 (v0.3.1)
|
|
251
|
+
- **`🚀 快速 Tarball 流式同步`**:利用实时 `tar -czf` 数据流传输整个目录,彻底消除小文件频繁往返的延迟。
|
|
252
|
+
- **`🩺 远程系统诊断 (remote_diagnose)`**:一键检测端口占用 (`ports`)、OOM 终止记录 (`oom_killer`)、磁盘分布 (`disk`) 与服务崩溃日志。
|
|
253
|
+
- **`📥 导入 ~/.ssh/config`**:快速解析本机已有主机、私钥及跳板机配置至加密 `.env` 保管库。
|
|
254
|
+
- **`🗃️ 远程环境变量管理 (remote_env)`**:支持远程 `.env` 的安全预览与原子化变量修改,自动遮蔽敏感密码。
|
|
255
|
+
- **`📡 异常告警监控`**:当磁盘低于 10%、内存不足 5% 或容器异常重启时,主动触发 Cordis 事件总线 (`remote-workspace/alert`) 告警。
|
package/docs/design/DESIGN.md
CHANGED
|
@@ -7,7 +7,7 @@ emote_fs,
|
|
|
7
7
|
emote_sync,
|
|
8
8
|
emote_tunnel).
|
|
9
9
|
- **Аудитория**: Разработчики и инженеры, использующие DSH для работы с проектами на VPS, удаленных серверах, облачных инстансах и MiniPC.
|
|
10
|
-
- **Статус**:
|
|
10
|
+
- **Статус**: Стабильный релиз v0.3.2 (One-Click Updater, Cross-Plugin API, Clean Tokens, Modular Routes).
|
|
11
11
|
|
|
12
12
|
## User Surfaces
|
|
13
13
|
- **Web/UI**: Нативная карточка настроек профилей хостов (settings.plugin.item), удаленный SFTP браузер каталогов, чип статуса подключения в шапке сессии (conversation.session.header.utilities).
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export class AlertService {
|
|
2
|
+
/**
|
|
3
|
+
* @param {any} ctx
|
|
4
|
+
* @param {import('./health-service.js').HealthService} healthService
|
|
5
|
+
* @param {import('./docker-service.js').DockerService} dockerService
|
|
6
|
+
*/
|
|
7
|
+
constructor(ctx, healthService, dockerService) {
|
|
8
|
+
this.ctx = ctx;
|
|
9
|
+
this.healthService = healthService;
|
|
10
|
+
this.dockerService = dockerService;
|
|
11
|
+
/** @type {NodeJS.Timeout|null} */
|
|
12
|
+
this.timer = null;
|
|
13
|
+
/** @type {Array<any>} */
|
|
14
|
+
this.activeAlerts = [];
|
|
15
|
+
this.checkIntervalMs = 5 * 60 * 1000; // 5 mins
|
|
16
|
+
this.enabled = false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
start(intervalMs = 300000) {
|
|
20
|
+
this.stop();
|
|
21
|
+
this.checkIntervalMs = intervalMs;
|
|
22
|
+
this.enabled = true;
|
|
23
|
+
this.timer = setInterval(() => this.check(), this.checkIntervalMs);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
stop() {
|
|
27
|
+
if (this.timer) {
|
|
28
|
+
clearInterval(this.timer);
|
|
29
|
+
this.timer = null;
|
|
30
|
+
}
|
|
31
|
+
this.enabled = false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Run single alert check across active profile
|
|
36
|
+
*/
|
|
37
|
+
async check(profile) {
|
|
38
|
+
if (!profile) return [];
|
|
39
|
+
|
|
40
|
+
const alerts = [];
|
|
41
|
+
try {
|
|
42
|
+
// 1. Health check
|
|
43
|
+
const health = await this.healthService.getHealth(profile, true);
|
|
44
|
+
if (health.disk && health.disk.percent >= 90) {
|
|
45
|
+
alerts.push({
|
|
46
|
+
id: `disk-${Date.now()}`,
|
|
47
|
+
level: health.disk.percent >= 95 ? 'critical' : 'warning',
|
|
48
|
+
type: 'disk_full',
|
|
49
|
+
message: `Disk usage on ${profile.name || profile.host} is ${health.disk.percent}%`,
|
|
50
|
+
timestamp: Date.now()
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (health.memory && health.memory.percent >= 95) {
|
|
55
|
+
alerts.push({
|
|
56
|
+
id: `mem-${Date.now()}`,
|
|
57
|
+
level: 'warning',
|
|
58
|
+
type: 'memory_high',
|
|
59
|
+
message: `Memory usage on ${profile.name || profile.host} is ${health.memory.percent}%`,
|
|
60
|
+
timestamp: Date.now()
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 2. Docker check
|
|
65
|
+
if (this.dockerService) {
|
|
66
|
+
try {
|
|
67
|
+
const containers = await this.dockerService.listContainers(profile);
|
|
68
|
+
for (const c of containers) {
|
|
69
|
+
if (c.State === 'restarting' || (c.Status && c.Status.includes('Restarting'))) {
|
|
70
|
+
alerts.push({
|
|
71
|
+
id: `docker-${c.ID || c.Names}`,
|
|
72
|
+
level: 'warning',
|
|
73
|
+
type: 'container_restarting',
|
|
74
|
+
message: `Container ${c.Names || c.ID} is restarting repeatedly`,
|
|
75
|
+
timestamp: Date.now()
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
} catch {
|
|
80
|
+
// Docker might not be installed or active, non-blocking
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
} catch (err) {
|
|
84
|
+
// If host unreachable
|
|
85
|
+
alerts.push({
|
|
86
|
+
id: `host-unreachable-${Date.now()}`,
|
|
87
|
+
level: 'critical',
|
|
88
|
+
type: 'host_unreachable',
|
|
89
|
+
message: `Host ${profile.name || profile.host} unreachable: ${err.message}`,
|
|
90
|
+
timestamp: Date.now()
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
this.activeAlerts = alerts;
|
|
95
|
+
|
|
96
|
+
// Emit Cordis event if ctx is present
|
|
97
|
+
if (this.ctx && typeof this.ctx.emit === 'function' && alerts.length > 0) {
|
|
98
|
+
for (const alert of alerts) {
|
|
99
|
+
this.ctx.emit('remote-workspace/alert', alert);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return alerts;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
getAlerts() {
|
|
107
|
+
return this.activeAlerts;
|
|
108
|
+
}
|
|
109
|
+
}
|