@honor-claw/yoyo 1.3.0 → 1.4.0-alpha.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.
@@ -1,23 +1,24 @@
1
1
  import { isBetaVersion as e } from "../../utils/version.mjs";
2
2
  import { getYoyoRuntime as t } from "../../runtime.mjs";
3
- import { getEnvFromProcessEnv as n } from "../../utils/env.mjs";
4
- import { wrapError as r } from "../../utils/error.mjs";
5
- import { useClawLogger as i } from "../../utils/logger.mjs";
6
- import { detectProvidersToRename as a, updateProviderReferences as o } from "./provider.mjs";
3
+ import { areStringArraysEqual as n } from "../../utils/array.mjs";
4
+ import { getEnvFromProcessEnv as r } from "../../utils/env.mjs";
5
+ import { wrapError as i } from "../../utils/error.mjs";
6
+ import { useClawLogger as a } from "../../utils/logger.mjs";
7
+ import { detectProvidersToRename as o, updateProviderReferences as s } from "./provider.mjs";
7
8
  //#region src/modules/configs/config-manager.ts
8
- var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,alarm.enable,alarm.query,alarm.update,app.close,app.open,call.phone,call.search,capture-screenshot,contact.search,file-upload,hotspot,local-search,message.search,message.send,mobile-data,no-disturb,quiet-mode,ringing-mode,schedule.create,schedule.delete,schedule.search,schedule.update,screen-record,vibration-mode,volume.operate,wlan,bluetooth,location-service,nfc,usb-shared-network,eyecomfort,status-bar-show,brightness,autoscreen-onnotice,dark-mode,device-operation,camera,app.uninstall,audio-record,battery,gui.create,gui.pause,gui.terminate,mcp.tool.call".split(","), d = class {
9
+ var c = "yoyo", l = { watch: !0 }, u = 250, d = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,alarm.enable,alarm.query,alarm.update,app.close,app.open,call.phone,call.search,capture-screenshot,contact.search,file-upload,hotspot,local-search,message.search,message.send,mobile-data,no-disturb,quiet-mode,ringing-mode,schedule.create,schedule.delete,schedule.search,schedule.update,screen-record,vibration-mode,volume.operate,wlan,bluetooth,location-service,nfc,usb-shared-network,eyecomfort,status-bar-show,brightness,autoscreen-onnotice,dark-mode,device-operation,camera,app.uninstall,audio-record,battery,gui.create,gui.pause,gui.terminate,mcp.tool.call".split(","), f = class {
9
10
  loadConfig() {
10
11
  try {
11
12
  return t().config.loadConfig();
12
13
  } catch (e) {
13
- throw r(e, "Failed to load config");
14
+ throw i(e, "Failed to load config");
14
15
  }
15
16
  }
16
17
  async saveConfig(e) {
17
18
  try {
18
19
  await t().config.writeConfigFile(e);
19
20
  } catch (e) {
20
- throw r(e, "Failed to save config");
21
+ throw i(e, "Failed to save config");
21
22
  }
22
23
  }
23
24
  getGatewayAuthConfig() {
@@ -43,7 +44,7 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
43
44
  }
44
45
  getUserConfig() {
45
46
  try {
46
- return this.loadConfig().plugins?.entries?.[s]?.config?.user;
47
+ return this.loadConfig().plugins?.entries?.[c]?.config?.user;
47
48
  } catch (e) {
48
49
  console.error(`[claw-configs] Failed to read user config: ${e}`);
49
50
  return;
@@ -51,14 +52,14 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
51
52
  }
52
53
  getEnvInfo() {
53
54
  try {
54
- let e = this.loadConfig().plugins?.entries?.[s]?.config, t = e?.envInfo;
55
+ let e = this.loadConfig().plugins?.entries?.[c]?.config, t = e?.envInfo;
55
56
  if (t?.env) return t;
56
- let r = e?.env;
57
- if (r) return {
58
- env: r,
57
+ let n = e?.env;
58
+ if (n) return {
59
+ env: n,
59
60
  source: "manual"
60
61
  };
61
- let i = n();
62
+ let i = r();
62
63
  return i ? {
63
64
  env: i,
64
65
  source: "env"
@@ -75,7 +76,7 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
75
76
  }
76
77
  getGrayTag() {
77
78
  try {
78
- return this.loadConfig().plugins?.entries?.[s]?.config?.gray;
79
+ return this.loadConfig().plugins?.entries?.[c]?.config?.gray;
79
80
  } catch (e) {
80
81
  console.error(`[claw-configs] Failed to read gray tag config: ${e}`);
81
82
  return;
@@ -83,7 +84,7 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
83
84
  }
84
85
  getDeviceConfig() {
85
86
  try {
86
- return this.loadConfig().plugins?.entries?.[s]?.config?.device;
87
+ return this.loadConfig().plugins?.entries?.[c]?.config?.device;
87
88
  } catch (e) {
88
89
  console.error(`[claw-configs] Failed to read device config: ${e}`);
89
90
  return;
@@ -91,17 +92,17 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
91
92
  }
92
93
  async updateDeviceConfig(e) {
93
94
  try {
94
- let t = this.loadConfig(), n = t.plugins?.entries?.[s]?.config?.device || {}, r = {
95
+ let t = this.loadConfig(), n = t.plugins?.entries?.[c]?.config?.device || {}, r = {
95
96
  ...t,
96
97
  plugins: {
97
98
  ...t.plugins,
98
99
  entries: {
99
100
  ...t.plugins?.entries,
100
- [s]: {
101
- ...t.plugins?.entries?.[s],
101
+ [c]: {
102
+ ...t.plugins?.entries?.[c],
102
103
  enabled: !0,
103
104
  config: {
104
- ...t.plugins?.entries?.[s]?.config,
105
+ ...t.plugins?.entries?.[c]?.config,
105
106
  device: {
106
107
  ...n,
107
108
  ...e
@@ -113,7 +114,7 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
113
114
  };
114
115
  await this.saveConfig(r);
115
116
  } catch (e) {
116
- throw r(e, "Failed to update device config");
117
+ throw i(e, "Failed to update device config");
117
118
  }
118
119
  }
119
120
  async updateEnv(e) {
@@ -124,11 +125,11 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
124
125
  ...t.plugins,
125
126
  entries: {
126
127
  ...t.plugins?.entries,
127
- [s]: {
128
- ...t.plugins?.entries?.[s],
128
+ [c]: {
129
+ ...t.plugins?.entries?.[c],
129
130
  enabled: !0,
130
131
  config: {
131
- ...t.plugins?.entries?.[s]?.config,
132
+ ...t.plugins?.entries?.[c]?.config,
132
133
  envInfo: {
133
134
  env: e,
134
135
  source: "manual"
@@ -141,12 +142,12 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
141
142
  };
142
143
  await this.saveConfig(n);
143
144
  } catch (e) {
144
- throw r(e, "Failed to update env config");
145
+ throw i(e, "Failed to update env config");
145
146
  }
146
147
  }
147
148
  async resetEnv() {
148
149
  try {
149
- let e = this.loadConfig(), t = e.plugins?.entries?.[s]?.config?.envInfo;
150
+ let e = this.loadConfig(), t = e.plugins?.entries?.[c]?.config?.envInfo;
150
151
  if (!t?.env) return;
151
152
  let n = {
152
153
  ...e,
@@ -154,11 +155,11 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
154
155
  ...e.plugins,
155
156
  entries: {
156
157
  ...e.plugins?.entries,
157
- [s]: {
158
- ...e.plugins?.entries?.[s],
158
+ [c]: {
159
+ ...e.plugins?.entries?.[c],
159
160
  enabled: !0,
160
161
  config: {
161
- ...e.plugins?.entries?.[s]?.config,
162
+ ...e.plugins?.entries?.[c]?.config,
162
163
  envInfo: {
163
164
  env: t.env,
164
165
  source: "env"
@@ -170,7 +171,7 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
170
171
  };
171
172
  await this.saveConfig(n);
172
173
  } catch (e) {
173
- throw r(e, "Failed to reset env config");
174
+ throw i(e, "Failed to reset env config");
174
175
  }
175
176
  }
176
177
  async updateGrayTag(e) {
@@ -181,11 +182,11 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
181
182
  ...t.plugins,
182
183
  entries: {
183
184
  ...t.plugins?.entries,
184
- [s]: {
185
- ...t.plugins?.entries?.[s],
185
+ [c]: {
186
+ ...t.plugins?.entries?.[c],
186
187
  enabled: !0,
187
188
  config: {
188
- ...t.plugins?.entries?.[s]?.config,
189
+ ...t.plugins?.entries?.[c]?.config,
189
190
  ...e && { gray: e }
190
191
  }
191
192
  }
@@ -194,7 +195,7 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
194
195
  };
195
196
  await this.saveConfig(n);
196
197
  } catch (e) {
197
- throw r(e, "Failed to update gray tag config");
198
+ throw i(e, "Failed to update gray tag config");
198
199
  }
199
200
  }
200
201
  async updateUserConfig(e) {
@@ -205,11 +206,11 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
205
206
  ...t.plugins,
206
207
  entries: {
207
208
  ...t.plugins?.entries,
208
- [s]: {
209
- ...t.plugins?.entries?.[s],
209
+ [c]: {
210
+ ...t.plugins?.entries?.[c],
210
211
  enabled: !0,
211
212
  config: {
212
- ...t.plugins?.entries?.[s]?.config,
213
+ ...t.plugins?.entries?.[c]?.config,
213
214
  user: e
214
215
  }
215
216
  }
@@ -218,7 +219,7 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
218
219
  };
219
220
  await this.saveConfig(n);
220
221
  } catch (e) {
221
- throw r(e, "Failed to update user config");
222
+ throw i(e, "Failed to update user config");
222
223
  }
223
224
  }
224
225
  async clearUserConfig() {
@@ -229,10 +230,10 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
229
230
  ...e.plugins,
230
231
  entries: {
231
232
  ...e.plugins?.entries,
232
- [s]: {
233
- ...e.plugins?.entries?.[s],
233
+ [c]: {
234
+ ...e.plugins?.entries?.[c],
234
235
  config: {
235
- ...e.plugins?.entries?.[s]?.config,
236
+ ...e.plugins?.entries?.[c]?.config,
236
237
  user: void 0
237
238
  }
238
239
  }
@@ -241,58 +242,58 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
241
242
  };
242
243
  await this.saveConfig(t);
243
244
  } catch (e) {
244
- throw r(e, "Failed to clear user config");
245
+ throw i(e, "Failed to clear user config");
245
246
  }
246
247
  }
247
248
  async initializePluginConfig(t) {
248
249
  try {
249
- let r = this.loadConfig(), s = r.plugins?.allow || [], d = s.includes(t) ? s : [...s, t], f = r.gateway?.nodes?.allowCommands || [], p = Array.from(new Set([...f, ...u])), m = r.skills || {}, h = m.load || {}, g = h.watch === c.watch && h.watchDebounceMs !== void 0 ? h : {
250
- ...h,
251
- ...c,
252
- watchDebounceMs: h.watchDebounceMs ?? l
253
- }, _ = r.plugins?.entries?.[t]?.config?.envInfo, v = r.plugins?.entries?.[t]?.config?.env, y = !!(_?.env || v), b = n(), x = !!_?.env && _.source === "env", S = !_?.env && !!v || x && b && _.env !== b, C = !y || S, w = {
254
- env: b || v || (e() ? "test" : "production"),
250
+ let i = this.loadConfig(), c = i.plugins?.allow || [], f = !c.includes(t), p = c.includes(t) ? c : [...c, t], m = i.gateway?.nodes?.allowCommands || [], h = Array.from(new Set([...m, ...d])), g = !n(m, h), _ = i.skills || {}, v = _.load || {}, y = v.watch !== l.watch || v.watchDebounceMs === void 0, b = y ? {
251
+ ...v,
252
+ ...l,
253
+ watchDebounceMs: v.watchDebounceMs ?? u
254
+ } : v, x = i.plugins?.entries?.[t]?.config?.envInfo, S = i.plugins?.entries?.[t]?.config?.env, C = !!(x?.env || S), w = r(), T = !!x?.env && x.source === "env", E = !x?.env && !!S || T && w && x.env !== w, D = !C || E, O = {
255
+ env: w || S || (e() ? "test" : "production"),
255
256
  source: "env"
256
- }, T = r.plugins?.entries?.[t]?.config || {}, E = C ? {
257
- ...T,
258
- envInfo: w,
257
+ }, k = i.plugins?.entries?.[t]?.config || {}, A = D ? {
258
+ ...k,
259
+ envInfo: O,
259
260
  env: void 0
260
- } : T, D = a(r);
261
- Object.keys(D).length > 0 && i().info(`[claw-configs] Found ${Object.keys(D).length} providers to rename: ${Object.entries(D).map(([e, t]) => `${e} -> ${t}`).join(", ")}`);
262
- let O = {
263
- ...r,
261
+ } : k, j = i.plugins?.entries?.[t]?.enabled !== !0, M = o(i), N = Object.keys(M).length > 0;
262
+ if (N && a().info(`[claw-configs] Found ${Object.keys(M).length} providers to rename: ${Object.entries(M).map(([e, t]) => `${e} -> ${t}`).join(", ")}`), !f && !g && !y && !D && !j && !N) return;
263
+ let P = {
264
+ ...i,
264
265
  plugins: {
265
- ...r.plugins,
266
- allow: d,
266
+ ...i.plugins,
267
+ allow: p,
267
268
  entries: {
268
- ...r.plugins?.entries,
269
+ ...i.plugins?.entries,
269
270
  [t]: {
270
- ...r.plugins?.entries?.[t],
271
+ ...i.plugins?.entries?.[t],
271
272
  enabled: !0,
272
- config: E
273
+ config: A
273
274
  }
274
275
  }
275
276
  },
276
277
  gateway: {
277
- ...r.gateway,
278
+ ...i.gateway,
278
279
  nodes: {
279
- ...r.gateway?.nodes,
280
- allowCommands: p
280
+ ...i.gateway?.nodes,
281
+ allowCommands: h
281
282
  }
282
283
  },
283
284
  skills: {
284
- ...m,
285
- load: g
285
+ ..._,
286
+ load: b
286
287
  }
287
288
  };
288
- Object.keys(D).length > 0 && (O = o(O, D), i().info("[claw-configs] Provider renaming completed")), await this.saveConfig(O);
289
+ N && (P = s(P, M), a().info("[claw-configs] Provider renaming completed")), await this.saveConfig(P);
289
290
  } catch (e) {
290
- throw r(e, "failed to initialize plugin config");
291
+ throw i(e, "failed to initialize plugin config");
291
292
  }
292
293
  }
293
- }, f = null;
294
- function p() {
295
- return f ||= new d(), f;
294
+ }, p = null;
295
+ function m() {
296
+ return p ||= new f(), p;
296
297
  }
297
298
  //#endregion
298
- export { d as ConfigManager, p as getConfigManager };
299
+ export { f as ConfigManager, m as getConfigManager };
@@ -0,0 +1,6 @@
1
+ //#region src/utils/array.ts
2
+ function e(e, t) {
3
+ return e.length === t.length && e.every((e, n) => e === t[n]);
4
+ }
5
+ //#endregion
6
+ export { e as areStringArraysEqual };
@@ -1,7 +1,7 @@
1
1
  //#region src/utils/version.ts
2
2
  var e = null;
3
3
  function t() {
4
- return e === null && (e = "1.3.0".includes("beta") || "1.3.0".includes("alpha")), !!e;
4
+ return e === null && (e = "1.4.0-alpha.2".includes("beta") || "1.4.0-alpha.2".includes("alpha")), !!e;
5
5
  }
6
6
  //#endregion
7
7
  export { t as isBetaVersion };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@honor-claw/yoyo",
3
- "version": "1.3.0",
3
+ "version": "1.4.0-alpha.2",
4
4
  "description": "OpenClaw Honor Yoyo connection plugin",
5
5
  "keywords": [
6
6
  "ai",