@goodandready/dsh-remote-workspace 0.2.0 → 0.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.md +17 -0
- package/README.ru.md +17 -0
- package/README.zh.md +17 -0
- package/docs/plans/task_plan.md +18 -20
- package/lib/alert-service.js +109 -0
- package/lib/client.js +490 -77
- package/lib/diagnose-service.js +57 -0
- package/lib/docker-service.js +93 -0
- package/lib/env-service.js +122 -0
- package/lib/health-service.js +117 -0
- package/lib/index.js +94 -7
- package/lib/routes.js +627 -398
- package/lib/ssh-config-parser.js +89 -0
- package/lib/ssh-service.js +59 -20
- package/lib/tar-sync-service.js +85 -0
- package/lib/tools.js +175 -2
- package/lib/watcher-service.js +111 -0
- package/package.json +1 -1
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/plans/task_plan.md
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
# task_plan.md — dsh-remote-workspace
|
|
1
|
+
# task_plan.md — dsh-remote-workspace (v0.3.1)
|
|
2
2
|
|
|
3
3
|
## Цель
|
|
4
|
-
|
|
4
|
+
Реализовать 5 ключевых возможностей в рамках релиза v0.3.1:
|
|
5
|
+
1. Smart Tarball Sync (пакетное ускорение передачи каталогов).
|
|
6
|
+
2. remote_diagnose (комплексный агентский инструмент диагностики сервера).
|
|
7
|
+
3. Import from ~/.ssh/config (парсинг хостов в .env vault).
|
|
8
|
+
4. remote_env & Remote Environment Manager (безопасный редактор .env).
|
|
9
|
+
5. AlertService (фоновый мониторинг аномалий и события Cordis).
|
|
5
10
|
|
|
6
|
-
##
|
|
7
|
-
- [
|
|
8
|
-
- [
|
|
9
|
-
- [
|
|
10
|
-
- [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
- [x] **Фаза 7**: Дополнительные ручные сценарии и документация (Docs standard EN/RU/ZH).
|
|
18
|
-
- [/] **Фаза 8**: Стабильность, аудит багов, расширение тестов и дизайн в едином стиле dsh-clinebot:
|
|
19
|
-
- [ ] 8.1. Исправление стабильности: безопасный доступ к Cordis сервисам (ctx.get), сброс соединений при смене реквизитов профиля, нормализация полей в estConnection (latencyMs / remoteOs).
|
|
20
|
-
- [ ] 8.2. Безопасность и отказоустойчивость: фильтрация isTrustedSettingsRequest на API маршрутах, обработка ошибок стримов в TunnelService, автосоздание папок в MirrorSyncService.
|
|
21
|
-
- [ ] 8.3. Редизайн UI в едином стиле dsh-clinebot: модульные карточки, статусные бейджи в шапке, добавление поля localMirrorPath, секция управления туннелями в интерфейсе.
|
|
22
|
-
- [ ] 8.4. Расширение набора тестов (тесты API routes, tools, store/apply, client registration).
|
|
23
|
-
- [ ] 8.5. Тестирование на изолированном MiniPC сервере (dsh-test-plugin).
|
|
11
|
+
## Статус фаз
|
|
12
|
+
- [ ] **Фаза 1**: Backend-сервисы (lib/tar-sync-service.js, lib/diagnose-service.js, lib/ssh-config-parser.js, lib/env-service.js, lib/alert-service.js)
|
|
13
|
+
- [ ] **Фаза 2**: Интеграция в инструменты модели (remote_diagnose, remote_env, smart sync) и API маршруты
|
|
14
|
+
- [ ] **Фаза 3**: Обновление клиентского интерфейса (кнопка импорта SSH, вкладка/модалка .env, индикатор алертов)
|
|
15
|
+
- [ ] **Фаза 4**: Модульные и интеграционные тесты (test/phase4.test.mjs)
|
|
16
|
+
- [ ] **Фаза 5**: Документация (README EN/RU/ZH, DESIGN.md) и проверка лимитов размера (<250 KiB)
|
|
17
|
+
- [ ] **Фаза 6**: Тестовый гейт на MiniPC (dsh-test-plugin) и боевая верификация на MiniAI
|
|
18
|
+
|
|
19
|
+
## Next Step
|
|
20
|
+
Создание backend-сервисов в lib/.
|
|
21
|
+
EOF
|
|
@@ -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
|
+
}
|