@honor-claw/yoyo 1.1.4-beta.2 → 1.1.4-beta.4
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/openclaw.plugin.json +9 -0
- package/package.json +1 -2
- package/src/apis/honor-auth.ts +2 -3
- package/src/cloud-channel/admin-client-manager.ts +5 -3
- package/src/cloud-channel/channel.ts +2 -2
- package/src/cloud-channel/client.ts +14 -9
- package/src/cloud-channel/message-handler.ts +356 -210
- package/src/cloud-channel/session-manager.ts +4 -4
- package/src/cloud-channel/types.ts +17 -10
- package/src/commands/logout/impl.ts +2 -2
- package/src/gateway-client/device/builder.ts +2 -2
- package/src/gateway-client/node-gateway-client.ts +4 -17
- package/src/gateway-client/protocol-client.ts +3 -3
- package/src/honor-auth/browser.ts +4 -5
- package/src/modules/claw-configs/config-manager.ts +9 -26
- package/src/modules/claw-configs/identity-persist.ts +25 -29
- package/src/modules/device/identity.ts +3 -2
- package/src/modules/device/providers/linux.ts +11 -24
- package/src/modules/device/providers/macos.ts +5 -27
- package/src/modules/device/providers/pad.ts +18 -2
- package/src/modules/device/providers/windows.ts +6 -13
- package/src/modules/device/registry.ts +22 -31
- package/src/modules/device/types.ts +10 -10
- package/src/modules/login/impl.ts +110 -110
- package/src/schemas.ts +8 -0
- package/src/services/connection/status-tracker/events.ts +29 -11
- package/src/services/connection/status-tracker/storage.ts +2 -2
- package/src/services/connection/status-tracker/tracker.ts +22 -14
- package/src/services/connection/status-tracker/types.ts +7 -2
- package/src/utils/error.ts +13 -0
package/openclaw.plugin.json
CHANGED
|
@@ -23,6 +23,15 @@
|
|
|
23
23
|
},
|
|
24
24
|
"additionalProperties": false
|
|
25
25
|
},
|
|
26
|
+
"device": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"properties": {
|
|
29
|
+
"deviceType": {
|
|
30
|
+
"type": "string"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"additionalProperties": false
|
|
34
|
+
},
|
|
26
35
|
"env": {
|
|
27
36
|
"type": "string",
|
|
28
37
|
"enum": ["dev", "test", "production"]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@honor-claw/yoyo",
|
|
3
|
-
"version": "1.1.4-beta.
|
|
3
|
+
"version": "1.1.4-beta.4",
|
|
4
4
|
"description": "OpenClaw Honor Yoyo connection plugin",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
"nanoid": "^5.1.6",
|
|
38
38
|
"open": "^11.0.0",
|
|
39
39
|
"undici": "^7.3.0",
|
|
40
|
-
"uuid": "^13.0.0",
|
|
41
40
|
"ws": "^8.18.0",
|
|
42
41
|
"zod": "^4.3.6"
|
|
43
42
|
},
|
package/src/apis/honor-auth.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { createHash, randomBytes } from "crypto";
|
|
7
7
|
import type { TokenResponse, HonorAuthConfig } from "../honor-auth/types.js";
|
|
8
8
|
import { takeApiHost } from "../modules/claw-configs/hosts.js";
|
|
9
|
+
import { wrapError } from "../utils/error.js";
|
|
9
10
|
import { uuid } from "../utils/id.js";
|
|
10
11
|
import { isOKResponse } from "./helpers.js";
|
|
11
12
|
import { HttpClient, type HttpClientOptions } from "./http-client.js";
|
|
@@ -138,9 +139,7 @@ export class HonorAuthClient {
|
|
|
138
139
|
|
|
139
140
|
throw new Error(`failed to get token: ${response.data?.cnMessage}`);
|
|
140
141
|
} catch (error) {
|
|
141
|
-
throw
|
|
142
|
-
`failed to get token: ${error instanceof Error ? error.message : String(error)}`,
|
|
143
|
-
);
|
|
142
|
+
throw wrapError(error, "failed to get token");
|
|
144
143
|
}
|
|
145
144
|
}
|
|
146
145
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { AdminGatewayClient } from "../gateway-client/admin-gateway-client.js";
|
|
2
2
|
import { getConfigManager } from "../modules/claw-configs/config-manager.js";
|
|
3
3
|
import { useClawLogger } from "../utils/logger.js";
|
|
4
|
+
import type { StatusEvent } from "./types.js";
|
|
5
|
+
import { StatusEventType } from "./types.js";
|
|
4
6
|
|
|
5
7
|
export interface AdminClientManagerOptions {
|
|
6
|
-
onStatusEvent?: (event:
|
|
8
|
+
onStatusEvent?: (event: StatusEvent) => void;
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
type PendingReadyRequest = {
|
|
@@ -27,7 +29,7 @@ export class AdminClientManager {
|
|
|
27
29
|
return;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
const token = getConfigManager().getGatewayAuthConfig()
|
|
32
|
+
const token = (getConfigManager().getGatewayAuthConfig()?.token || "") as string;
|
|
31
33
|
this.client = new AdminGatewayClient({
|
|
32
34
|
token,
|
|
33
35
|
onAuthenticated: () => {
|
|
@@ -44,7 +46,7 @@ export class AdminClientManager {
|
|
|
44
46
|
"[yoyoclaw-channel] admin gateway client reconnect failed, notifying status tracker",
|
|
45
47
|
);
|
|
46
48
|
this.options.onStatusEvent?.({
|
|
47
|
-
type:
|
|
49
|
+
type: StatusEventType.ADMIN_CLIENT_RECONNECT_FAILED,
|
|
48
50
|
timestamp: Date.now(),
|
|
49
51
|
data: {},
|
|
50
52
|
});
|
|
@@ -4,7 +4,7 @@ import { AdminClientManager } from "./admin-client-manager.js";
|
|
|
4
4
|
import { ClawCloudSocketClient } from "./client.js";
|
|
5
5
|
import { MessageHandler } from "./message-handler.js";
|
|
6
6
|
import { SessionManager } from "./session-manager.js";
|
|
7
|
-
import type { ClawChannelConfig } from "./types.js";
|
|
7
|
+
import type { ClawChannelConfig, StatusEvent } from "./types.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* 新的Channel实现
|
|
@@ -88,7 +88,7 @@ export class ClawChannel {
|
|
|
88
88
|
/**
|
|
89
89
|
* 统一处理所有状态事件
|
|
90
90
|
*/
|
|
91
|
-
private handleStatusEvent = (event:
|
|
91
|
+
private handleStatusEvent = (event: StatusEvent) => {
|
|
92
92
|
this.config.onStatusEvent?.(event);
|
|
93
93
|
};
|
|
94
94
|
|
|
@@ -8,7 +8,12 @@ import { generateAuthorization } from "../utils/jwt.js";
|
|
|
8
8
|
import { useClawLogger } from "../utils/logger.js";
|
|
9
9
|
import { createWebSocketProxyAgent } from "../utils/proxy.js";
|
|
10
10
|
import { rawDataToString } from "../utils/ws.js";
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
ClawSocketClientOptions,
|
|
13
|
+
YOYOClawServiceEvent,
|
|
14
|
+
YOYOClawSocketMessage,
|
|
15
|
+
} from "./types.js";
|
|
16
|
+
import { StatusEventType } from "./types.js";
|
|
12
17
|
|
|
13
18
|
const PING_INTERVAL = 30000;
|
|
14
19
|
const MAX_RETRIES = 5;
|
|
@@ -49,7 +54,7 @@ export class ClawCloudSocketClient {
|
|
|
49
54
|
|
|
50
55
|
// 通知状态跟踪器:开始连接
|
|
51
56
|
this.options.onStatusEvent?.({
|
|
52
|
-
type:
|
|
57
|
+
type: StatusEventType.CLOUD_SOCKET_CONNECTING,
|
|
53
58
|
timestamp: Date.now(),
|
|
54
59
|
data: {
|
|
55
60
|
url: url,
|
|
@@ -110,7 +115,7 @@ export class ClawCloudSocketClient {
|
|
|
110
115
|
|
|
111
116
|
// 通知状态跟踪器
|
|
112
117
|
this.options.onStatusEvent?.({
|
|
113
|
-
type:
|
|
118
|
+
type: StatusEventType.CLOUD_SOCKET_CONNECTED,
|
|
114
119
|
timestamp: Date.now(),
|
|
115
120
|
data: {
|
|
116
121
|
url: url,
|
|
@@ -141,7 +146,7 @@ export class ClawCloudSocketClient {
|
|
|
141
146
|
|
|
142
147
|
// 通知状态跟踪器
|
|
143
148
|
this.options.onStatusEvent?.({
|
|
144
|
-
type:
|
|
149
|
+
type: StatusEventType.CLOUD_SOCKET_DISCONNECTED,
|
|
145
150
|
timestamp: Date.now(),
|
|
146
151
|
data: {
|
|
147
152
|
reason: reasonText,
|
|
@@ -164,7 +169,7 @@ export class ClawCloudSocketClient {
|
|
|
164
169
|
|
|
165
170
|
// 通知状态跟踪器
|
|
166
171
|
this.options.onStatusEvent?.({
|
|
167
|
-
type:
|
|
172
|
+
type: StatusEventType.CLOUD_SOCKET_ERROR,
|
|
168
173
|
timestamp: Date.now(),
|
|
169
174
|
data: {
|
|
170
175
|
error: error.message,
|
|
@@ -177,7 +182,7 @@ export class ClawCloudSocketClient {
|
|
|
177
182
|
/**
|
|
178
183
|
* 发送消息
|
|
179
184
|
*/
|
|
180
|
-
send(message:
|
|
185
|
+
send(message: YOYOClawServiceEvent, toDeviceId?: string): boolean {
|
|
181
186
|
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
|
182
187
|
useClawLogger().error("[claw-cloud-socket] cannot send message: connection not open");
|
|
183
188
|
return false;
|
|
@@ -226,7 +231,7 @@ export class ClawCloudSocketClient {
|
|
|
226
231
|
private onMessage = async (data: WebSocket.RawData) => {
|
|
227
232
|
try {
|
|
228
233
|
const dataText = rawDataToString(data);
|
|
229
|
-
const message:
|
|
234
|
+
const message: YOYOClawSocketMessage = JSON.parse(dataText);
|
|
230
235
|
|
|
231
236
|
useClawLogger().debug?.(
|
|
232
237
|
`[yoyoclaw-channel] received cloud message from session ${message.wsOutputEvent?.sourceDeviceId}, deviceId ${
|
|
@@ -310,7 +315,7 @@ export class ClawCloudSocketClient {
|
|
|
310
315
|
|
|
311
316
|
// 通知状态跟踪器:重试
|
|
312
317
|
this.options.onStatusEvent?.({
|
|
313
|
-
type:
|
|
318
|
+
type: StatusEventType.CLOUD_SOCKET_RETRY,
|
|
314
319
|
timestamp: Date.now(),
|
|
315
320
|
data: {
|
|
316
321
|
retryCount: this.retryCount,
|
|
@@ -369,7 +374,7 @@ export class ClawCloudSocketClient {
|
|
|
369
374
|
}
|
|
370
375
|
}
|
|
371
376
|
|
|
372
|
-
setMessageHandler(handler: (message:
|
|
377
|
+
setMessageHandler(handler: (message: YOYOClawServiceEvent) => void): void {
|
|
373
378
|
this.options.onMessage = handler;
|
|
374
379
|
}
|
|
375
380
|
|