@honor-claw/yoyo 1.2.0-beta.11 → 1.2.0-beta.12

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.2.0-beta.11",
3
+ "version": "1.2.0-beta.12",
4
4
  "description": "OpenClaw Honor Yoyo connection plugin",
5
5
  "keywords": [
6
6
  "ai",
@@ -40,6 +40,31 @@ function getRegistryStringValueAsync(
40
40
  });
41
41
  }
42
42
 
43
+ /**
44
+ * 异步检查注册表键是否存在
45
+ * 使用 winreg 的 values() 方法,键不存在时会报错
46
+ */
47
+ function registryKeyExistsAsync(hive: number, keyPath: string): Promise<boolean> {
48
+ return new Promise((resolve) => {
49
+ try {
50
+ const regKey = new Registry({
51
+ hive,
52
+ key: keyPath,
53
+ });
54
+
55
+ regKey.values((err: Error | null) => {
56
+ if (err) {
57
+ resolve(false);
58
+ } else {
59
+ resolve(true);
60
+ }
61
+ });
62
+ } catch {
63
+ resolve(false);
64
+ }
65
+ });
66
+ }
67
+
43
68
  export class WindowsDeviceInfoProvider implements DeviceInfoProvider {
44
69
  private cache: DeviceInfoCache = {
45
70
  deviceId: "",
@@ -111,11 +136,17 @@ export class WindowsDeviceInfoProvider implements DeviceInfoProvider {
111
136
  systemManufacturer2,
112
137
  ];
113
138
 
114
- const manufacturer = manufacturerSources.find((m) => m && m.trim()) || "";
115
- if (manufacturer.toLowerCase().includes("honor")) {
139
+ const manufacturer = manufacturerSources.find((m) => m && m.toLowerCase().includes("honor"));
140
+ if (manufacturer) {
116
141
  this.cache.deviceBrand = "HONOR";
117
142
  } else {
118
- this.cache.deviceBrand = "";
143
+ // 最后兜底:检查 HKLM:\SOFTWARE\HONOR 注册表键是否存在
144
+ const honorKeyExists = await registryKeyExistsAsync(Registry.HKLM, "\\SOFTWARE\\HONOR");
145
+ if (honorKeyExists) {
146
+ this.cache.deviceBrand = "HONOR";
147
+ } else {
148
+ this.cache.deviceBrand = "";
149
+ }
119
150
  }
120
151
  } catch {
121
152
  // 初始化失败,使用默认值