@honor-claw/yoyo 1.4.0-alpha.1 → 1.4.0-beta.1
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,28 +1,24 @@
|
|
|
1
1
|
import { isBetaVersion as e } from "../../utils/version.mjs";
|
|
2
2
|
import { getYoyoRuntime as t } from "../../runtime.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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
|
|
9
|
-
input: 0,
|
|
10
|
-
output: 0,
|
|
11
|
-
cacheRead: 0,
|
|
12
|
-
cacheWrite: 0
|
|
13
|
-
}, f = 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 {
|
|
14
10
|
loadConfig() {
|
|
15
11
|
try {
|
|
16
12
|
return t().config.loadConfig();
|
|
17
13
|
} catch (e) {
|
|
18
|
-
throw
|
|
14
|
+
throw i(e, "Failed to load config");
|
|
19
15
|
}
|
|
20
16
|
}
|
|
21
17
|
async saveConfig(e) {
|
|
22
18
|
try {
|
|
23
19
|
await t().config.writeConfigFile(e);
|
|
24
20
|
} catch (e) {
|
|
25
|
-
throw
|
|
21
|
+
throw i(e, "Failed to save config");
|
|
26
22
|
}
|
|
27
23
|
}
|
|
28
24
|
getGatewayAuthConfig() {
|
|
@@ -48,7 +44,7 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
|
|
|
48
44
|
}
|
|
49
45
|
getUserConfig() {
|
|
50
46
|
try {
|
|
51
|
-
return this.loadConfig().plugins?.entries?.[
|
|
47
|
+
return this.loadConfig().plugins?.entries?.[c]?.config?.user;
|
|
52
48
|
} catch (e) {
|
|
53
49
|
console.error(`[claw-configs] Failed to read user config: ${e}`);
|
|
54
50
|
return;
|
|
@@ -56,14 +52,14 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
|
|
|
56
52
|
}
|
|
57
53
|
getEnvInfo() {
|
|
58
54
|
try {
|
|
59
|
-
let e = this.loadConfig().plugins?.entries?.[
|
|
55
|
+
let e = this.loadConfig().plugins?.entries?.[c]?.config, t = e?.envInfo;
|
|
60
56
|
if (t?.env) return t;
|
|
61
|
-
let
|
|
62
|
-
if (
|
|
63
|
-
env:
|
|
57
|
+
let n = e?.env;
|
|
58
|
+
if (n) return {
|
|
59
|
+
env: n,
|
|
64
60
|
source: "manual"
|
|
65
61
|
};
|
|
66
|
-
let i =
|
|
62
|
+
let i = r();
|
|
67
63
|
return i ? {
|
|
68
64
|
env: i,
|
|
69
65
|
source: "env"
|
|
@@ -80,7 +76,7 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
|
|
|
80
76
|
}
|
|
81
77
|
getGrayTag() {
|
|
82
78
|
try {
|
|
83
|
-
return this.loadConfig().plugins?.entries?.[
|
|
79
|
+
return this.loadConfig().plugins?.entries?.[c]?.config?.gray;
|
|
84
80
|
} catch (e) {
|
|
85
81
|
console.error(`[claw-configs] Failed to read gray tag config: ${e}`);
|
|
86
82
|
return;
|
|
@@ -88,7 +84,7 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
|
|
|
88
84
|
}
|
|
89
85
|
getDeviceConfig() {
|
|
90
86
|
try {
|
|
91
|
-
return this.loadConfig().plugins?.entries?.[
|
|
87
|
+
return this.loadConfig().plugins?.entries?.[c]?.config?.device;
|
|
92
88
|
} catch (e) {
|
|
93
89
|
console.error(`[claw-configs] Failed to read device config: ${e}`);
|
|
94
90
|
return;
|
|
@@ -96,17 +92,17 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
|
|
|
96
92
|
}
|
|
97
93
|
async updateDeviceConfig(e) {
|
|
98
94
|
try {
|
|
99
|
-
let t = this.loadConfig(), n = t.plugins?.entries?.[
|
|
95
|
+
let t = this.loadConfig(), n = t.plugins?.entries?.[c]?.config?.device || {}, r = {
|
|
100
96
|
...t,
|
|
101
97
|
plugins: {
|
|
102
98
|
...t.plugins,
|
|
103
99
|
entries: {
|
|
104
100
|
...t.plugins?.entries,
|
|
105
|
-
[
|
|
106
|
-
...t.plugins?.entries?.[
|
|
101
|
+
[c]: {
|
|
102
|
+
...t.plugins?.entries?.[c],
|
|
107
103
|
enabled: !0,
|
|
108
104
|
config: {
|
|
109
|
-
...t.plugins?.entries?.[
|
|
105
|
+
...t.plugins?.entries?.[c]?.config,
|
|
110
106
|
device: {
|
|
111
107
|
...n,
|
|
112
108
|
...e
|
|
@@ -118,7 +114,7 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
|
|
|
118
114
|
};
|
|
119
115
|
await this.saveConfig(r);
|
|
120
116
|
} catch (e) {
|
|
121
|
-
throw
|
|
117
|
+
throw i(e, "Failed to update device config");
|
|
122
118
|
}
|
|
123
119
|
}
|
|
124
120
|
async updateEnv(e) {
|
|
@@ -129,11 +125,11 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
|
|
|
129
125
|
...t.plugins,
|
|
130
126
|
entries: {
|
|
131
127
|
...t.plugins?.entries,
|
|
132
|
-
[
|
|
133
|
-
...t.plugins?.entries?.[
|
|
128
|
+
[c]: {
|
|
129
|
+
...t.plugins?.entries?.[c],
|
|
134
130
|
enabled: !0,
|
|
135
131
|
config: {
|
|
136
|
-
...t.plugins?.entries?.[
|
|
132
|
+
...t.plugins?.entries?.[c]?.config,
|
|
137
133
|
envInfo: {
|
|
138
134
|
env: e,
|
|
139
135
|
source: "manual"
|
|
@@ -146,12 +142,12 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
|
|
|
146
142
|
};
|
|
147
143
|
await this.saveConfig(n);
|
|
148
144
|
} catch (e) {
|
|
149
|
-
throw
|
|
145
|
+
throw i(e, "Failed to update env config");
|
|
150
146
|
}
|
|
151
147
|
}
|
|
152
148
|
async resetEnv() {
|
|
153
149
|
try {
|
|
154
|
-
let e = this.loadConfig(), t = e.plugins?.entries?.[
|
|
150
|
+
let e = this.loadConfig(), t = e.plugins?.entries?.[c]?.config?.envInfo;
|
|
155
151
|
if (!t?.env) return;
|
|
156
152
|
let n = {
|
|
157
153
|
...e,
|
|
@@ -159,11 +155,11 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
|
|
|
159
155
|
...e.plugins,
|
|
160
156
|
entries: {
|
|
161
157
|
...e.plugins?.entries,
|
|
162
|
-
[
|
|
163
|
-
...e.plugins?.entries?.[
|
|
158
|
+
[c]: {
|
|
159
|
+
...e.plugins?.entries?.[c],
|
|
164
160
|
enabled: !0,
|
|
165
161
|
config: {
|
|
166
|
-
...e.plugins?.entries?.[
|
|
162
|
+
...e.plugins?.entries?.[c]?.config,
|
|
167
163
|
envInfo: {
|
|
168
164
|
env: t.env,
|
|
169
165
|
source: "env"
|
|
@@ -175,7 +171,7 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
|
|
|
175
171
|
};
|
|
176
172
|
await this.saveConfig(n);
|
|
177
173
|
} catch (e) {
|
|
178
|
-
throw
|
|
174
|
+
throw i(e, "Failed to reset env config");
|
|
179
175
|
}
|
|
180
176
|
}
|
|
181
177
|
async updateGrayTag(e) {
|
|
@@ -186,11 +182,11 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
|
|
|
186
182
|
...t.plugins,
|
|
187
183
|
entries: {
|
|
188
184
|
...t.plugins?.entries,
|
|
189
|
-
[
|
|
190
|
-
...t.plugins?.entries?.[
|
|
185
|
+
[c]: {
|
|
186
|
+
...t.plugins?.entries?.[c],
|
|
191
187
|
enabled: !0,
|
|
192
188
|
config: {
|
|
193
|
-
...t.plugins?.entries?.[
|
|
189
|
+
...t.plugins?.entries?.[c]?.config,
|
|
194
190
|
...e && { gray: e }
|
|
195
191
|
}
|
|
196
192
|
}
|
|
@@ -199,7 +195,7 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
|
|
|
199
195
|
};
|
|
200
196
|
await this.saveConfig(n);
|
|
201
197
|
} catch (e) {
|
|
202
|
-
throw
|
|
198
|
+
throw i(e, "Failed to update gray tag config");
|
|
203
199
|
}
|
|
204
200
|
}
|
|
205
201
|
async updateUserConfig(e) {
|
|
@@ -210,11 +206,11 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
|
|
|
210
206
|
...t.plugins,
|
|
211
207
|
entries: {
|
|
212
208
|
...t.plugins?.entries,
|
|
213
|
-
[
|
|
214
|
-
...t.plugins?.entries?.[
|
|
209
|
+
[c]: {
|
|
210
|
+
...t.plugins?.entries?.[c],
|
|
215
211
|
enabled: !0,
|
|
216
212
|
config: {
|
|
217
|
-
...t.plugins?.entries?.[
|
|
213
|
+
...t.plugins?.entries?.[c]?.config,
|
|
218
214
|
user: e
|
|
219
215
|
}
|
|
220
216
|
}
|
|
@@ -223,7 +219,7 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
|
|
|
223
219
|
};
|
|
224
220
|
await this.saveConfig(n);
|
|
225
221
|
} catch (e) {
|
|
226
|
-
throw
|
|
222
|
+
throw i(e, "Failed to update user config");
|
|
227
223
|
}
|
|
228
224
|
}
|
|
229
225
|
async clearUserConfig() {
|
|
@@ -234,10 +230,10 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
|
|
|
234
230
|
...e.plugins,
|
|
235
231
|
entries: {
|
|
236
232
|
...e.plugins?.entries,
|
|
237
|
-
[
|
|
238
|
-
...e.plugins?.entries?.[
|
|
233
|
+
[c]: {
|
|
234
|
+
...e.plugins?.entries?.[c],
|
|
239
235
|
config: {
|
|
240
|
-
...e.plugins?.entries?.[
|
|
236
|
+
...e.plugins?.entries?.[c]?.config,
|
|
241
237
|
user: void 0
|
|
242
238
|
}
|
|
243
239
|
}
|
|
@@ -246,56 +242,53 @@ var s = "yoyo", c = { watch: !0 }, l = 250, u = /* @__PURE__ */ "alarm.create,al
|
|
|
246
242
|
};
|
|
247
243
|
await this.saveConfig(t);
|
|
248
244
|
} catch (e) {
|
|
249
|
-
throw
|
|
245
|
+
throw i(e, "Failed to clear user config");
|
|
250
246
|
}
|
|
251
247
|
}
|
|
252
248
|
async initializePluginConfig(t) {
|
|
253
249
|
try {
|
|
254
|
-
let
|
|
255
|
-
...
|
|
256
|
-
...
|
|
257
|
-
watchDebounceMs:
|
|
258
|
-
}
|
|
259
|
-
env:
|
|
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"),
|
|
260
256
|
source: "env"
|
|
261
|
-
},
|
|
262
|
-
...
|
|
263
|
-
envInfo:
|
|
257
|
+
}, k = i.plugins?.entries?.[t]?.config || {}, A = D ? {
|
|
258
|
+
...k,
|
|
259
|
+
envInfo: O,
|
|
264
260
|
env: void 0
|
|
265
|
-
} :
|
|
266
|
-
|
|
267
|
-
let
|
|
268
|
-
...
|
|
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,
|
|
269
265
|
plugins: {
|
|
270
|
-
...
|
|
271
|
-
allow:
|
|
266
|
+
...i.plugins,
|
|
267
|
+
allow: p,
|
|
272
268
|
entries: {
|
|
273
|
-
...
|
|
269
|
+
...i.plugins?.entries,
|
|
274
270
|
[t]: {
|
|
275
|
-
...
|
|
271
|
+
...i.plugins?.entries?.[t],
|
|
276
272
|
enabled: !0,
|
|
277
|
-
config:
|
|
273
|
+
config: A
|
|
278
274
|
}
|
|
279
275
|
}
|
|
280
276
|
},
|
|
281
277
|
gateway: {
|
|
282
|
-
...
|
|
278
|
+
...i.gateway,
|
|
283
279
|
nodes: {
|
|
284
|
-
...
|
|
285
|
-
allowCommands:
|
|
280
|
+
...i.gateway?.nodes,
|
|
281
|
+
allowCommands: h
|
|
286
282
|
}
|
|
287
283
|
},
|
|
288
284
|
skills: {
|
|
289
|
-
...
|
|
290
|
-
load:
|
|
285
|
+
..._,
|
|
286
|
+
load: b
|
|
291
287
|
}
|
|
292
288
|
};
|
|
293
|
-
|
|
294
|
-
for (let e of Object.values(k.models.providers)) if (Array.isArray(e.models)) for (let t of e.models) t.cost ||= d;
|
|
295
|
-
}
|
|
296
|
-
await this.saveConfig(k);
|
|
289
|
+
N && (P = s(P, M), a().info("[claw-configs] Provider renaming completed")), await this.saveConfig(P);
|
|
297
290
|
} catch (e) {
|
|
298
|
-
throw
|
|
291
|
+
throw i(e, "failed to initialize plugin config");
|
|
299
292
|
}
|
|
300
293
|
}
|
|
301
294
|
}, p = null;
|
package/dist/utils/version.mjs
CHANGED
|
@@ -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.4.0-
|
|
4
|
+
return e === null && (e = "1.4.0-beta.1".includes("beta") || "1.4.0-beta.1".includes("alpha")), !!e;
|
|
5
5
|
}
|
|
6
6
|
//#endregion
|
|
7
7
|
export { t as isBetaVersion };
|