@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.
@@ -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.2",
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
  },
@@ -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 new Error(
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: any) => void;
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().token as string;
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: "admin_client_reconnect_failed",
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: any) => {
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 { ClawSocketClientOptions, YoyoClawMessage, YoyoClawSocketMessage } from "./types.js";
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: "cloud_socket_connecting",
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: "cloud_socket_connected",
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: "cloud_socket_disconnected",
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: "cloud_socket_error",
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: YoyoClawMessage, toDeviceId?: string): boolean {
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: YoyoClawSocketMessage = JSON.parse(dataText);
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: "cloud_socket_retry",
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: YoyoClawMessage) => void): void {
377
+ setMessageHandler(handler: (message: YOYOClawServiceEvent) => void): void {
373
378
  this.options.onMessage = handler;
374
379
  }
375
380