@honor-claw/yoyo 1.2.1-beta.1 → 1.2.1-beta.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/package.json
CHANGED
|
@@ -26,7 +26,7 @@ export class ClawCloudSocketClient {
|
|
|
26
26
|
private retryTimer: NodeJS.Timeout | null = null;
|
|
27
27
|
private isManualClose = false;
|
|
28
28
|
private isRetryPaused = false; // 重试状态
|
|
29
|
-
// ping
|
|
29
|
+
// ping 定时器(原生 ping + 业务 pingMessage)
|
|
30
30
|
private pingTimer: NodeJS.Timeout | null = null;
|
|
31
31
|
// 当前连接上下文
|
|
32
32
|
private currentTraceId = "";
|
|
@@ -59,7 +59,6 @@ export class ClawCloudSocketClient {
|
|
|
59
59
|
this.ws = new WebSocket(url, wsOptions);
|
|
60
60
|
this.ws.on("open", this.handleOpen.bind(this, url, isRetry));
|
|
61
61
|
this.ws.on("message", this.onMessage);
|
|
62
|
-
this.ws.on("ping", this.handlePing);
|
|
63
62
|
this.ws.on("pong", this.handlePong);
|
|
64
63
|
this.ws.on("close", this.handleClose);
|
|
65
64
|
this.ws.on("error", this.handleError);
|
|
@@ -90,10 +89,6 @@ export class ClawCloudSocketClient {
|
|
|
90
89
|
this.options.onOpen?.();
|
|
91
90
|
};
|
|
92
91
|
|
|
93
|
-
private handlePing = (): void => {
|
|
94
|
-
useClawLogger().debug?.("[claw-cloud-socket] received ping from server");
|
|
95
|
-
};
|
|
96
|
-
|
|
97
92
|
private handlePong = (): void => {
|
|
98
93
|
useClawLogger().debug?.("[claw-cloud-socket] received pong from server");
|
|
99
94
|
};
|
|
@@ -299,7 +294,7 @@ export class ClawCloudSocketClient {
|
|
|
299
294
|
}
|
|
300
295
|
|
|
301
296
|
/**
|
|
302
|
-
* 启动 ping
|
|
297
|
+
* 启动 ping 定时器,同时发送原生 ping 和业务 pingMessage
|
|
303
298
|
*/
|
|
304
299
|
private startPingTimer(): void {
|
|
305
300
|
this.pingTimer = setInterval(() => {
|
|
@@ -308,9 +303,26 @@ export class ClawCloudSocketClient {
|
|
|
308
303
|
return;
|
|
309
304
|
}
|
|
310
305
|
|
|
311
|
-
//
|
|
306
|
+
// 原生 ping
|
|
312
307
|
this.ws.ping();
|
|
313
308
|
useClawLogger().debug?.("[claw-cloud-socket] sent ping to server");
|
|
309
|
+
|
|
310
|
+
// 业务 pingMessage
|
|
311
|
+
const { deviceInfo } = this.options;
|
|
312
|
+
const pingMessage: YOYOClawServiceEvent = {
|
|
313
|
+
msgType: "pingMessage",
|
|
314
|
+
sourceRole: "yoyoclaw",
|
|
315
|
+
sourceDeviceId: deviceInfo.deviceId,
|
|
316
|
+
targetRole: "node",
|
|
317
|
+
port: deviceInfo.port,
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
try {
|
|
321
|
+
this.ws.send(JSON.stringify(pingMessage));
|
|
322
|
+
useClawLogger().debug?.("[claw-cloud-socket] sent pingMessage to server");
|
|
323
|
+
} catch {
|
|
324
|
+
useClawLogger().error("[claw-cloud-socket] failed to send pingMessage");
|
|
325
|
+
}
|
|
314
326
|
}, PING_INTERVAL);
|
|
315
327
|
}
|
|
316
328
|
|
|
@@ -18,8 +18,8 @@ export interface YOYOClawServiceEvent {
|
|
|
18
18
|
sourceDeviceId: string;
|
|
19
19
|
sourceDeviceInfo?: ClawDeviceInfo;
|
|
20
20
|
targetRole?: DeviceRole;
|
|
21
|
-
targetDeviceId
|
|
22
|
-
traceInfo
|
|
21
|
+
targetDeviceId?: string;
|
|
22
|
+
traceInfo?: object;
|
|
23
23
|
port: number | string;
|
|
24
24
|
data?: string; // openclaw原生消息
|
|
25
25
|
msgType:
|
|
@@ -28,7 +28,8 @@ export interface YOYOClawServiceEvent {
|
|
|
28
28
|
| "deviceUnPairMessage"
|
|
29
29
|
| "fetchContexts"
|
|
30
30
|
| "updateContexts"
|
|
31
|
-
| "deviceControl"
|
|
31
|
+
| "deviceControl"
|
|
32
|
+
| "pingMessage";
|
|
32
33
|
/**
|
|
33
34
|
* 会话轮次等追加信息,只有配对消息有
|
|
34
35
|
*/
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export const AUTH_RESULT_HTML = `<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>授权结果</title>
|
|
7
|
+
<style>
|
|
8
|
+
body {
|
|
9
|
+
font-family:
|
|
10
|
+
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
11
|
+
background-color: #f0f2f5;
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
align-items: center;
|
|
15
|
+
height: 100vh;
|
|
16
|
+
margin: 0;
|
|
17
|
+
color: #333;
|
|
18
|
+
}
|
|
19
|
+
.container {
|
|
20
|
+
text-align: center;
|
|
21
|
+
background-color: #ffffff;
|
|
22
|
+
padding: 48px 40px;
|
|
23
|
+
border-radius: 16px;
|
|
24
|
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
|
|
25
|
+
max-width: 380px;
|
|
26
|
+
width: 90%;
|
|
27
|
+
}
|
|
28
|
+
.icon {
|
|
29
|
+
margin-bottom: 24px;
|
|
30
|
+
}
|
|
31
|
+
h1 {
|
|
32
|
+
font-size: 20px;
|
|
33
|
+
font-weight: 600;
|
|
34
|
+
margin: 0 0 12px;
|
|
35
|
+
color: #1a1a1a;
|
|
36
|
+
}
|
|
37
|
+
.hint {
|
|
38
|
+
font-size: 14px;
|
|
39
|
+
color: #999;
|
|
40
|
+
margin: 0;
|
|
41
|
+
}
|
|
42
|
+
</style>
|
|
43
|
+
</head>
|
|
44
|
+
<body>
|
|
45
|
+
<div class="container">
|
|
46
|
+
<div class="icon">{{ICON_SVG}}</div>
|
|
47
|
+
<h1>{{MESSAGE}}</h1>
|
|
48
|
+
<p class="hint">可安全关闭此页面</p>
|
|
49
|
+
</div>
|
|
50
|
+
</body>
|
|
51
|
+
</html>`;
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
* 本地HTTP回调服务器 - 接收OAuth2授权回调
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import * as fs from "fs";
|
|
6
5
|
import { createServer, type IncomingMessage, type ServerResponse } from "http";
|
|
7
|
-
import * as path from "path";
|
|
8
6
|
import { URL } from "url";
|
|
7
|
+
import { AUTH_RESULT_HTML } from "./auth-result-html.js";
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* 回调服务器选项
|
|
@@ -24,16 +23,10 @@ export interface CallbackServerOptions {
|
|
|
24
23
|
const SUCCESS_ICON_SVG = `<svg width="56" height="56" viewBox="0 0 56 56" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M28 56C43.464 56 56 43.464 56 28C56 12.536 43.464 0 28 0C12.536 0 0 12.536 0 28C0 43.464 12.536 56 28 56Z" fill="#28a745"/><path d="M39.6667 20.3333L24.5 35.5L16.3333 27.3333" stroke="white" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
|
|
25
24
|
const FAILURE_ICON_SVG = `<svg width="56" height="56" viewBox="0 0 56 56" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M28 56C43.464 56 56 43.464 56 28C56 12.536 43.464 0 28 0C12.536 0 0 12.536 0 28C0 43.464 12.536 56 28 56Z" fill="#dc3545"/><path d="M35 21L21 35M21 21L35 35" stroke="white" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
|
|
26
25
|
|
|
26
|
+
|
|
27
27
|
function getResultHtml(message: string, success: boolean): string {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const icon = success ? SUCCESS_ICON_SVG : FAILURE_ICON_SVG;
|
|
31
|
-
return template.replace("{{MESSAGE}}", message).replace("{{ICON_SVG}}", icon);
|
|
32
|
-
} catch (error) {
|
|
33
|
-
// Fallback to simple text
|
|
34
|
-
console.error("Failed to read auth-result.html:", error);
|
|
35
|
-
return `<h1>${message}</h1>`;
|
|
36
|
-
}
|
|
28
|
+
const icon = success ? SUCCESS_ICON_SVG : FAILURE_ICON_SVG;
|
|
29
|
+
return AUTH_RESULT_HTML.replace("{{ICON_SVG}}", icon).replace("{{MESSAGE}}", message);
|
|
37
30
|
}
|
|
38
31
|
|
|
39
32
|
/**
|
|
@@ -87,31 +87,30 @@ export class WindowsDeviceInfoProvider implements DeviceInfoProvider {
|
|
|
87
87
|
private async _initializeCache(): Promise<void> {
|
|
88
88
|
try {
|
|
89
89
|
// 并行获取所有注册表值
|
|
90
|
-
const [systemManufacturer, biosVendor, biosVendor2, systemManufacturer2] =
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
]);
|
|
90
|
+
const [systemManufacturer, biosVendor, biosVendor2, systemManufacturer2] = await Promise.all([
|
|
91
|
+
// 原有路径
|
|
92
|
+
getRegistryStringValueAsync(
|
|
93
|
+
Registry.HKLM,
|
|
94
|
+
"\\HARDWARE\\DESCRIPTION\\System",
|
|
95
|
+
"SystemManufacturer",
|
|
96
|
+
),
|
|
97
|
+
getRegistryStringValueAsync(
|
|
98
|
+
Registry.HKLM,
|
|
99
|
+
"\\HARDWARE\\DESCRIPTION\\System",
|
|
100
|
+
"SystemBiosVendor",
|
|
101
|
+
),
|
|
102
|
+
// 新增路径(BIOS 子键)
|
|
103
|
+
getRegistryStringValueAsync(
|
|
104
|
+
Registry.HKLM,
|
|
105
|
+
"\\HARDWARE\\DESCRIPTION\\System\\BIOS",
|
|
106
|
+
"Vendor",
|
|
107
|
+
),
|
|
108
|
+
getRegistryStringValueAsync(
|
|
109
|
+
Registry.HKLM,
|
|
110
|
+
"\\HARDWARE\\DESCRIPTION\\System\\BIOS",
|
|
111
|
+
"SystemManufacturer",
|
|
112
|
+
),
|
|
113
|
+
]);
|
|
115
114
|
|
|
116
115
|
// 缓存 deviceBrand(检查多个来源)
|
|
117
116
|
const manufacturerSources = [
|
|
@@ -126,7 +125,10 @@ export class WindowsDeviceInfoProvider implements DeviceInfoProvider {
|
|
|
126
125
|
this.cache.deviceBrand = "HONOR";
|
|
127
126
|
} else {
|
|
128
127
|
// 最后兜底:检查 HKLM:\SOFTWARE\HONOR 注册表键是否存在
|
|
129
|
-
const honorKeyExists = await registryKeyExistsAsync(
|
|
128
|
+
const honorKeyExists = await registryKeyExistsAsync(
|
|
129
|
+
Registry.HKLM,
|
|
130
|
+
"\\SOFTWARE\\HONOR\\PCManager",
|
|
131
|
+
);
|
|
130
132
|
if (honorKeyExists) {
|
|
131
133
|
this.cache.deviceBrand = "HONOR";
|
|
132
134
|
} else {
|