@honor-claw/yoyo 1.1.0 → 1.1.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@honor-claw/yoyo",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "OpenClaw Honor Yoyo connection plugin",
5
5
  "keywords": [
6
6
  "ai",
@@ -116,8 +116,9 @@ volume.operate
116
116
 
117
117
  1. **设值与调大/调小的区别**: `设值`为绝对值设定("调到50"),`调大`/`调小`为相对值调整("调大20")
118
118
  2. **numberType 匹配**: `number` 需与 `numberType` 配合使用——"50"对应数字、"50%"对应百分比、"最大/最小"对应极值、"3格/3档"对应级别、"1/3/三分之一"对应分数
119
- 3. **音量类型缺省**: 未指定 `volumeType` 时,默认操作系统主音量
120
- 4. **同义词映射**: "静音"→关闭、"取消静音"→打开、"声音设为零"→设值(number=零)
119
+ 3. **number取值规则**:如果numberType为“百分比”,该值必须为小数!!!如:用户说“调节音量到30%”,number取值为0.3"
120
+ 4. **音量类型缺省**: 未指定 `volumeType` 时,默认操作系统主音量
121
+ 5. **同义词映射**: "静音"→关闭、"取消静音"→打开、"声音设为零"→设值(number=零)
121
122
 
122
123
  ## Query 示例及输出
123
124
 
@@ -5,12 +5,11 @@
5
5
 
6
6
  import { createHash, randomBytes } from 'crypto';
7
7
  import { HttpClient, type HttpClientOptions } from './http-client.js';
8
- import type { TokenResponseV2, HonorAuthConfig } from '../honor-auth/types.js';
8
+ import type { TokenResponse, HonorAuthConfig } from '../honor-auth/types.js';
9
9
  import { uuid } from '../utils/id.js';
10
10
  import { isOKResponse } from './helpers.js';
11
11
  import type { HttpApiWrapper } from './types.js';
12
12
  import { takeApiHost } from '../modules/claw-configs/hosts.js';
13
- import type { DeviceInfo } from '../types.js';
14
13
 
15
14
  /**
16
15
  * PKCE参数
@@ -102,9 +101,9 @@ export class HonorAuthClient {
102
101
  /**
103
102
  * 使用授权码换取Token
104
103
  */
105
- async exchangeToken(code: string, deviceInfo: DeviceInfo) {
104
+ async exchangeToken(code: string) {
106
105
  const hosts = takeApiHost();
107
- const tokenUrl = `https://${hosts.clawCloud}/aicloud/yoyo-claw-service/v1/user/jwtToken`;
106
+ const tokenUrl = `https://${hosts.ics}/honorboard/auth/v1/oauth/jwtToken`;
108
107
 
109
108
  const data = {
110
109
  clientId: this.config.clientId,
@@ -116,9 +115,10 @@ export class HonorAuthClient {
116
115
  // 构建请求头,包含灰度标签(如果有)
117
116
  const headers: Record<string, string> = {
118
117
  'Content-Type': 'application/json',
119
- 'x-device-id': deviceInfo.deviceId,
120
- // 'x-sys-version': '1.0.0',
121
- 'x-trace-id': uuid(),
118
+ 'x-origin-udid': this.config.clientId,
119
+ 'x-app-pkg': 'com.hihonor.pc.openclaw',
120
+ 'x-request-nonce': uuid(),
121
+ 'x-timestamp': String(Date.now()),
122
122
  };
123
123
 
124
124
  // 添加灰度标签
@@ -126,7 +126,7 @@ export class HonorAuthClient {
126
126
  headers['x-gray'] = hosts.grayTag;
127
127
  }
128
128
 
129
- const response = await this.httpClient.post<HttpApiWrapper<TokenResponseV2>>(tokenUrl, {
129
+ const response = await this.httpClient.post<HttpApiWrapper<TokenResponse>>(tokenUrl, {
130
130
  body: data,
131
131
  headers,
132
132
  timeout: 15000,
@@ -10,10 +10,10 @@ import open from 'open';
10
10
  /**
11
11
  * 执行OAuth2授权流程(自动打开浏览器)
12
12
  */
13
- export async function performOAuth2AuthWithBrowser(deviceInfo: DeviceInfo, configOverrides?: Partial<HonorAuthConfig>) {
13
+ export async function performOAuth2AuthWithBrowser(_: DeviceInfo, configOverrides?: Partial<HonorAuthConfig>) {
14
14
  const config = getConfig(configOverrides);
15
15
  const logger = useClawLogger();
16
-
16
+
17
17
  logger.debug('Starting Honor login flow...');
18
18
 
19
19
  // 创建认证客户端
@@ -59,17 +59,19 @@ export async function performOAuth2AuthWithBrowser(deviceInfo: DeviceInfo, confi
59
59
 
60
60
  // 使用授权码换取Token
61
61
  try {
62
- const tokenInfo = await authClient.exchangeToken(receivedCode, deviceInfo);
62
+ const tokenInfo = await authClient.exchangeToken(receivedCode);
63
63
 
64
- if (!tokenInfo.jwtToken) {
65
- throw new Error('failed to get jwt token');
64
+ if (!tokenInfo.token || !tokenInfo.userInfo?.userId) {
65
+ throw new Error('failed to get user info');
66
66
  }
67
67
 
68
68
  // 保存Token
69
- await saveToken({ token: tokenInfo.jwtToken }, config.saveToFile !== false);
69
+ await saveToken(tokenInfo, config.saveToFile !== false);
70
70
 
71
71
  return {
72
- token: tokenInfo.jwtToken,
72
+ userId: tokenInfo.userInfo.userId,
73
+ token: tokenInfo.token,
74
+ userName: tokenInfo.userInfo.displayName,
73
75
  } as HonorUserInfo;
74
76
  } catch (error) {
75
77
  throw new Error(`get token failed: ${error instanceof Error ? error.message : String(error)}`);