@lingyao037/openclaw-lingyao-cli 1.1.0 → 1.2.0
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/cli.mjs +13 -39
- package/dist/index.js +35 -3
- package/dist/index.js.map +1 -1
- package/dist/setup-entry.js.map +1 -1
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -37,23 +37,20 @@ const NC = '\x1b[0m';
|
|
|
37
37
|
function getMachineId() {
|
|
38
38
|
try {
|
|
39
39
|
const interfaces = os.networkInterfaces();
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
for (const
|
|
43
|
-
const iface = interfaces[name];
|
|
40
|
+
const macs = [];
|
|
41
|
+
|
|
42
|
+
for (const iface of Object.values(interfaces)) {
|
|
44
43
|
if (!iface) continue;
|
|
45
|
-
|
|
46
44
|
for (const alias of iface) {
|
|
47
45
|
if (!alias.internal && alias.mac && alias.mac !== '00:00:00:00:00:00') {
|
|
48
|
-
|
|
46
|
+
macs.push(alias.mac);
|
|
49
47
|
}
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
50
|
+
|
|
51
|
+
if (macs.length > 0) {
|
|
52
|
+
macs.sort();
|
|
53
|
+
const macStr = macs.join('');
|
|
57
54
|
// fallback to simple hash since we can't use top level await here easily in older nodes
|
|
58
55
|
let hash = 0;
|
|
59
56
|
for (let i = 0; i < macStr.length; i++) {
|
|
@@ -395,11 +392,6 @@ class LingyaoInstaller {
|
|
|
395
392
|
|
|
396
393
|
config.plugins.entries.lingyao = {
|
|
397
394
|
enabled: true,
|
|
398
|
-
config: {
|
|
399
|
-
maxOfflineMessages: 100,
|
|
400
|
-
tokenExpiryDays: 30,
|
|
401
|
-
gatewayId,
|
|
402
|
-
}
|
|
403
395
|
};
|
|
404
396
|
|
|
405
397
|
// 写回配置文件
|
|
@@ -678,29 +670,11 @@ class LingyaoInstaller {
|
|
|
678
670
|
}
|
|
679
671
|
}
|
|
680
672
|
|
|
681
|
-
// Save paired device info to
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
join(this.openclawPath, 'openclaw.json'),
|
|
687
|
-
join(this.openclawPath, 'config.json'),
|
|
688
|
-
];
|
|
689
|
-
|
|
690
|
-
for (const file of configFiles) {
|
|
691
|
-
if (!existsSync(file)) continue;
|
|
692
|
-
try {
|
|
693
|
-
const config = JSON.parse(readFileSync(file, 'utf-8'));
|
|
694
|
-
if (config.plugins?.entries?.lingyao?.config) {
|
|
695
|
-
config.plugins.entries.lingyao.config.pairedDevice = deviceInfo;
|
|
696
|
-
writeFileSync(file, JSON.stringify(config, null, 2), 'utf-8');
|
|
697
|
-
this.success('设备信息已保存到配置');
|
|
698
|
-
}
|
|
699
|
-
} catch {
|
|
700
|
-
// Ignore config write errors
|
|
701
|
-
}
|
|
702
|
-
break; // Only write to first found config file
|
|
703
|
-
}
|
|
673
|
+
// Save paired device info (no longer writes to openclaw.json — device info
|
|
674
|
+
// is managed server-side via the relay, not in plugin config).
|
|
675
|
+
saveDeviceInfo(_deviceInfo) {
|
|
676
|
+
// No-op: pairedDevice was previously written to plugins.entries.lingyao.config
|
|
677
|
+
// which violates OpenClaw's additionalProperties:false constraint.
|
|
704
678
|
}
|
|
705
679
|
|
|
706
680
|
// 主安装流程
|
package/dist/index.js
CHANGED
|
@@ -1433,10 +1433,27 @@ var MessageProcessor = class {
|
|
|
1433
1433
|
*/
|
|
1434
1434
|
async deliverToAgent(message) {
|
|
1435
1435
|
if (!this.messageHandler) {
|
|
1436
|
-
this.runtime.logger.warn("No message handler set, message not delivered to Agent"
|
|
1436
|
+
this.runtime.logger.warn("No message handler set, message not delivered to Agent", {
|
|
1437
|
+
messageId: message.id,
|
|
1438
|
+
type: message.type,
|
|
1439
|
+
deviceId: message.deviceId
|
|
1440
|
+
});
|
|
1437
1441
|
return;
|
|
1438
1442
|
}
|
|
1439
|
-
|
|
1443
|
+
this.runtime.logger.info("Delivering message to Agent", {
|
|
1444
|
+
messageId: message.id,
|
|
1445
|
+
type: message.type,
|
|
1446
|
+
from: message.from,
|
|
1447
|
+
deviceId: message.deviceId,
|
|
1448
|
+
contentLength: message.content?.length ?? 0
|
|
1449
|
+
});
|
|
1450
|
+
try {
|
|
1451
|
+
await this.messageHandler(message);
|
|
1452
|
+
this.runtime.logger.info("Agent handler completed", { messageId: message.id });
|
|
1453
|
+
} catch (error) {
|
|
1454
|
+
this.runtime.logger.error("Agent handler threw error", { messageId: message.id, error });
|
|
1455
|
+
throw error;
|
|
1456
|
+
}
|
|
1440
1457
|
}
|
|
1441
1458
|
};
|
|
1442
1459
|
|
|
@@ -2448,8 +2465,13 @@ var MultiAccountOrchestrator = class {
|
|
|
2448
2465
|
sendNotification(accountId, deviceId, notification) {
|
|
2449
2466
|
const wsClient = this.getWSClient(accountId);
|
|
2450
2467
|
if (!wsClient || !wsClient.isConnected()) {
|
|
2468
|
+
this.runtime.logger.warn(`[${accountId}] Cannot send notification: WS not connected`, { deviceId });
|
|
2451
2469
|
return false;
|
|
2452
2470
|
}
|
|
2471
|
+
this.runtime.logger.info(`[${accountId}] Sending notification to device`, {
|
|
2472
|
+
deviceId,
|
|
2473
|
+
notificationType: notification.type
|
|
2474
|
+
});
|
|
2453
2475
|
wsClient.sendNotification(deviceId, notification);
|
|
2454
2476
|
return true;
|
|
2455
2477
|
}
|
|
@@ -2530,9 +2552,19 @@ var MultiAccountOrchestrator = class {
|
|
|
2530
2552
|
*/
|
|
2531
2553
|
async handleSyncMessage(state, deviceId, message) {
|
|
2532
2554
|
if (!state.messageProcessor) {
|
|
2533
|
-
this.runtime.logger.warn(`[${state.accountId}] Message processor not initialized
|
|
2555
|
+
this.runtime.logger.warn(`[${state.accountId}] Message processor not initialized, dropping message`, {
|
|
2556
|
+
messageId: message.id,
|
|
2557
|
+
messageType: message.type,
|
|
2558
|
+
deviceId
|
|
2559
|
+
});
|
|
2534
2560
|
return;
|
|
2535
2561
|
}
|
|
2562
|
+
this.runtime.logger.info(`[${state.accountId}] Routing sync message to Agent`, {
|
|
2563
|
+
messageId: message.id,
|
|
2564
|
+
messageType: message.type,
|
|
2565
|
+
deviceId,
|
|
2566
|
+
contentLength: message.content?.length ?? 0
|
|
2567
|
+
});
|
|
2536
2568
|
const agentMessage = {
|
|
2537
2569
|
id: message.id,
|
|
2538
2570
|
type: message.type === "sync_diary" ? "diary" : "memory",
|