claw-subagent-service 0.0.161 → 0.0.163
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
|
@@ -385,7 +385,7 @@ class RongyunMessageHandler {
|
|
|
385
385
|
|
|
386
386
|
this.logInfo(`[RongyunMessageHandler] 收到设备控制命令: command=${command}, from=${targetId}`);
|
|
387
387
|
|
|
388
|
-
const validCommands = ['disable', 'enable', 'delete', 'status'];
|
|
388
|
+
const validCommands = ['disable', 'enable', 'delete', 'status', 'rename_device'];
|
|
389
389
|
if (!validCommands.includes(command)) {
|
|
390
390
|
await this.sendDeviceControlResult(targetId, requestId, command, 'error', `未知命令: ${command}`);
|
|
391
391
|
return;
|
|
@@ -394,6 +394,42 @@ class RongyunMessageHandler {
|
|
|
394
394
|
try {
|
|
395
395
|
let result;
|
|
396
396
|
switch (command) {
|
|
397
|
+
case 'rename_device': {
|
|
398
|
+
const newName = data.name || data.nickname;
|
|
399
|
+
if (!newName) {
|
|
400
|
+
result = { status: 'error', message: '缺少新名称参数' };
|
|
401
|
+
break;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// 更新本地配置文件
|
|
405
|
+
try {
|
|
406
|
+
const homeDir = os.homedir();
|
|
407
|
+
const configPaths = [
|
|
408
|
+
path.join(homeDir, '.claw-bridge', 'config.json'),
|
|
409
|
+
path.join(__dirname, '..', '..', 'rongcloud-config.json')
|
|
410
|
+
];
|
|
411
|
+
|
|
412
|
+
for (const configPath of configPaths) {
|
|
413
|
+
if (fs.existsSync(configPath)) {
|
|
414
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
415
|
+
config.nodeName = newName;
|
|
416
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
417
|
+
this.logInfo(`[RongyunMessageHandler] 已更新本地配置名称: ${configPath} -> ${newName}`);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// 更新内存中的配置
|
|
422
|
+
if (this.config) {
|
|
423
|
+
this.config.nodeName = newName;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
result = { status: 'success', message: `设备名称已更新为: ${newName}` };
|
|
427
|
+
} catch (err) {
|
|
428
|
+
this.logError(`[RongyunMessageHandler] 更新本地配置失败: ${err.message}`);
|
|
429
|
+
result = { status: 'error', message: `更新本地配置失败: ${err.message}` };
|
|
430
|
+
}
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
397
433
|
case 'disable': {
|
|
398
434
|
// 先发送响应,再停止服务
|
|
399
435
|
result = { status: 'success', message: '设备服务已禁用' };
|