@honor-claw/yoyo 0.0.1-alpha.1 → 0.0.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@honor-claw/yoyo",
3
- "version": "0.0.1-alpha.1",
3
+ "version": "0.0.1-beta.2",
4
4
  "type": "module",
5
5
  "description": "OpenClaw Honor Yoyo connection plugin",
6
6
  "scripts": {
@@ -36,7 +36,6 @@
36
36
  "jsonwebtoken": "^9.0.3",
37
37
  "nanoid": "^5.1.6",
38
38
  "open": "^11.0.0",
39
- "registry-js": "^1.16.1",
40
39
  "undici": "^7.3.0",
41
40
  "uuid": "^13.0.0",
42
41
  "ws": "^8.18.0",
@@ -2,20 +2,31 @@
2
2
  * Windows 设备信息提供者
3
3
  */
4
4
  import { v4 as uuidv4 } from 'uuid';
5
- import { enumerateValues, HKEY } from 'registry-js';
6
5
  import os from 'os';
6
+ import { execSync } from 'child_process';
7
7
  import type { DeviceInfoProvider } from './base.js';
8
8
  import type { DeviceType } from '../../../types.js';
9
9
 
10
10
  export class WindowsDeviceInfoProvider implements DeviceInfoProvider {
11
+ /**
12
+ * 执行 PowerShell 命令并获取输出
13
+ */
14
+ private execPowerShell(command: string): string {
15
+ try {
16
+ return execSync(`powershell -Command "${command}"`, { encoding: 'utf-8' }).trim();
17
+ } catch {
18
+ return '';
19
+ }
20
+ }
21
+
11
22
  /**
12
23
  * 获取 Windows 设备型号
13
24
  */
14
25
  private getWindowsDeviceModel(): string {
15
26
  try {
16
- const values = enumerateValues(HKEY.HKEY_LOCAL_MACHINE, 'HARDWARE\\DESCRIPTION\\System\\BIOS');
17
- const modelValue = values.find(v => v.name === 'SystemProductName');
18
- const model = String(modelValue?.data || '').trim();
27
+ const model = this.execPowerShell(
28
+ "(Get-CimInstance -ClassName Win32_ComputerSystem).Model"
29
+ );
19
30
  return model || 'Windows PC';
20
31
  } catch {
21
32
  return 'Windows PC';
@@ -36,9 +47,24 @@ export class WindowsDeviceInfoProvider implements DeviceInfoProvider {
36
47
  */
37
48
  getDeviceId(): string {
38
49
  try {
39
- const values = enumerateValues(HKEY.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Microsoft\\Cryptography');
40
- const machineGuid = values.find(v => v.name === 'MachineGuid');
41
- return String(machineGuid?.data || uuidv4());
50
+ // 优先使用 MachineGuid
51
+ const machineGuid = this.execPowerShell(
52
+ '(Get-ItemProperty "HKLM:\\SOFTWARE\\Microsoft\\Cryptography").MachineGuid'
53
+ );
54
+ if (machineGuid) {
55
+ return machineGuid;
56
+ }
57
+
58
+ // 备用方案:使用主板序列号
59
+ const serial = this.execPowerShell(
60
+ '(Get-CimInstance -ClassName Win32_BIOS).SerialNumber'
61
+ );
62
+ if (serial) {
63
+ return serial;
64
+ }
65
+
66
+ // 最后备用方案:使用 UUID
67
+ return uuidv4();
42
68
  } catch {
43
69
  return uuidv4();
44
70
  }