claw-subagent-service 0.0.157 → 0.0.160
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/package.json
CHANGED
|
@@ -3,7 +3,7 @@ const axios = require('axios');
|
|
|
3
3
|
const GATEWAY_URL = 'http://127.0.0.1:4096';
|
|
4
4
|
|
|
5
5
|
// 系统提示词 - OpenClaw 运维助手智能体
|
|
6
|
-
const SYSTEM_PROMPT = `你是
|
|
6
|
+
const SYSTEM_PROMPT = `你是 虾说智能助手的 openclaw 运维助手智能体,职责有:保活、修配置、做备份 等运维工作。
|
|
7
7
|
|
|
8
8
|
## 核心职责
|
|
9
9
|
1. **保活**:openclaw 挂了自动拉起来
|
|
@@ -23,10 +23,10 @@ const os = require('os');
|
|
|
23
23
|
const serviceSessions = new Map();
|
|
24
24
|
|
|
25
25
|
// 客服系统提示词
|
|
26
|
-
const SERVICE_SYSTEM_PROMPT =
|
|
26
|
+
const SERVICE_SYSTEM_PROMPT = `你是虾说智能助手的客服助手,专门帮助用户解答使用问题。
|
|
27
27
|
|
|
28
28
|
## 核心职责
|
|
29
|
-
1.
|
|
29
|
+
1. **解答产品使用问题**:帮助用户了解如何使用虾说智能助手的各项功能
|
|
30
30
|
2. **故障排查**:协助用户解决常见的技术问题
|
|
31
31
|
3. **功能介绍**:介绍App的新功能和更新内容
|
|
32
32
|
|
|
@@ -188,7 +188,7 @@ class RongyunMessageHandler {
|
|
|
188
188
|
// 先发送响应,再执行命令(避免前端超时)
|
|
189
189
|
// 启动/停止/重启命令是异步的,前端只需要知道命令已接收
|
|
190
190
|
const isAsyncCommand = [OpenClawCommandEnum.START, OpenClawCommandEnum.STOP, OpenClawCommandEnum.RESTART].includes(command);
|
|
191
|
-
|
|
191
|
+
|
|
192
192
|
if (isAsyncCommand) {
|
|
193
193
|
// 立即响应,告知前端命令已接收
|
|
194
194
|
const actionName = force ? '强制' + getCommandName(command) : getCommandName(command);
|
|
@@ -199,7 +199,7 @@ class RongyunMessageHandler {
|
|
|
199
199
|
message: `${actionName}命令已接收,正在执行...`
|
|
200
200
|
}, requestId, sourceId);
|
|
201
201
|
}
|
|
202
|
-
|
|
202
|
+
|
|
203
203
|
// 执行命令(在后台异步执行,不阻塞响应)
|
|
204
204
|
// 使用 Promise 避免阻塞,让命令在后台执行
|
|
205
205
|
executeCommand(command, null, async (response) => {
|
|
@@ -229,7 +229,7 @@ class RongyunMessageHandler {
|
|
|
229
229
|
this.commandLockTimer = null;
|
|
230
230
|
}
|
|
231
231
|
});
|
|
232
|
-
|
|
232
|
+
|
|
233
233
|
// 异步命令立即返回,不等待执行完成
|
|
234
234
|
if (isAsyncCommand) {
|
|
235
235
|
return;
|
|
@@ -369,13 +369,13 @@ class RongyunMessageHandler {
|
|
|
369
369
|
// 先发送响应,再停止服务
|
|
370
370
|
result = { status: 'success', message: '设备服务已禁用' };
|
|
371
371
|
await this.sendDeviceControlResult(targetId, requestId, command, result.status, result.message, result.data);
|
|
372
|
-
|
|
372
|
+
|
|
373
373
|
setTimeout(async () => {
|
|
374
374
|
const svcMgr = new ServiceManager('claw-subagent-service', 'OpenClaw Guard CLI Client', process.argv[1], this.log);
|
|
375
|
-
try { await svcMgr.stop(); } catch (e) {}
|
|
376
|
-
try { await svcMgr.uninstall(); } catch (e) {}
|
|
375
|
+
try { await svcMgr.stop(); } catch (e) { }
|
|
376
|
+
try { await svcMgr.uninstall(); } catch (e) { }
|
|
377
377
|
}, 2000);
|
|
378
|
-
|
|
378
|
+
|
|
379
379
|
return;
|
|
380
380
|
}
|
|
381
381
|
case 'enable': {
|
|
@@ -388,12 +388,12 @@ class RongyunMessageHandler {
|
|
|
388
388
|
// 先发送响应,再停止服务(否则服务停止后无法发送响应)
|
|
389
389
|
result = { status: 'success', message: '设备已删除,本地配置已清除' };
|
|
390
390
|
await this.sendDeviceControlResult(targetId, requestId, command, result.status, result.message, result.data);
|
|
391
|
-
|
|
391
|
+
|
|
392
392
|
// 延迟执行实际的删除操作
|
|
393
393
|
setTimeout(async () => {
|
|
394
394
|
const svcMgr = new ServiceManager('claw-subagent-service', 'OpenClaw Guard CLI Client', process.argv[1], this.log);
|
|
395
|
-
try { await svcMgr.stop(); } catch (e) {}
|
|
396
|
-
try { await svcMgr.uninstall(); } catch (e) {}
|
|
395
|
+
try { await svcMgr.stop(); } catch (e) { }
|
|
396
|
+
try { await svcMgr.uninstall(); } catch (e) { }
|
|
397
397
|
const homeDir = os.homedir();
|
|
398
398
|
const configPaths = [
|
|
399
399
|
path.join(homeDir, '.claw-bridge', 'config.json'),
|
|
@@ -405,7 +405,7 @@ class RongyunMessageHandler {
|
|
|
405
405
|
}
|
|
406
406
|
}
|
|
407
407
|
}, 2000);
|
|
408
|
-
|
|
408
|
+
|
|
409
409
|
return; // 已经发送了响应,直接返回
|
|
410
410
|
}
|
|
411
411
|
case 'status': {
|
|
@@ -432,7 +432,7 @@ class RongyunMessageHandler {
|
|
|
432
432
|
try {
|
|
433
433
|
// 获取 OpenClaw 真实运行状态(检查端口 18789)
|
|
434
434
|
const openClawStatus = await getOpenClawStatus();
|
|
435
|
-
|
|
435
|
+
|
|
436
436
|
// 获取真实的版本信息(如果可能)
|
|
437
437
|
let version = 'unknown';
|
|
438
438
|
try {
|
|
@@ -445,11 +445,11 @@ class RongyunMessageHandler {
|
|
|
445
445
|
} catch (e) {
|
|
446
446
|
// 忽略版本获取失败
|
|
447
447
|
}
|
|
448
|
-
|
|
448
|
+
|
|
449
449
|
// 构建真实状态数据
|
|
450
450
|
// openClawStatus: 1=端口监听正常(服务可用), 0=未运行(端口未监听)
|
|
451
451
|
const statusMessage = openClawStatus === 1 ? '运行中' : '未运行';
|
|
452
|
-
|
|
452
|
+
|
|
453
453
|
const statusData = {
|
|
454
454
|
open_claw_status: openClawStatus, // 1=运行中, 0=未运行
|
|
455
455
|
status_message: statusMessage,
|
|
@@ -457,7 +457,7 @@ class RongyunMessageHandler {
|
|
|
457
457
|
version: version,
|
|
458
458
|
timestamp: Date.now(),
|
|
459
459
|
};
|
|
460
|
-
|
|
460
|
+
|
|
461
461
|
this.logInfo(`[RongyunMessageHandler] 设备真实状态: openClawStatus=${openClawStatus}, version=${version}`);
|
|
462
462
|
await this.sendDeviceStatusReport(targetId, requestId, statusData);
|
|
463
463
|
} catch (e) {
|