@honor-claw/yoyo 1.6.0-beta.4 → 1.6.0
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/dist/apis/http-client.mjs +2 -0
- package/dist/cloud-channel/message-handler.mjs +39 -2
- package/dist/gateway-client/admin-client.mjs +19 -8
- package/dist/gateway-client/protocol-client.mjs +38 -37
- package/dist/hooks/index.mjs +9 -3
- package/dist/index.mjs +3 -3
- package/dist/modules/configs/config-manager.mjs +85 -77
- package/dist/modules/configs/identity-persist.mjs +28 -30
- package/dist/modules/configs/index.mjs +1 -1
- package/dist/modules/configs/state-flags.mjs +3 -66
- package/dist/modules/device/providers/windows.mjs +1 -1
- package/dist/modules/device/registry.mjs +12 -12
- package/dist/utils/version.mjs +45 -13
- package/openclaw.plugin.json +4 -0
- package/package.json +7 -1
- package/skills/yoyo-control/SKILL.md +0 -2
- package/skills/yoyo-control/configs/sub-skills.json +0 -2
- package/skills/yoyo-control/references/flight-monitor-create.md +0 -233
- package/skills/yoyo-control/references/flight-monitor-search.md +0 -229
- package/skills/yoyo-control/scripts/time_infer.py +0 -99
|
@@ -3,6 +3,8 @@ import { getProxyUrl as t, shouldUseProxy as n } from "../utils/proxy.mjs";
|
|
|
3
3
|
import { ProxyAgent as r, request as i } from "undici";
|
|
4
4
|
//#region src/apis/http-client.ts
|
|
5
5
|
var a = class extends Error {
|
|
6
|
+
status;
|
|
7
|
+
data;
|
|
6
8
|
constructor(e, t, n) {
|
|
7
9
|
super(n), this.status = e, this.data = t, this.name = "HttpError";
|
|
8
10
|
}
|
|
@@ -9,6 +9,7 @@ var r = { style: "SOUL.md" }, i = "[yoyoclaw-channel]", a = class {
|
|
|
9
9
|
config;
|
|
10
10
|
pendingFirstMessages = /* @__PURE__ */ new Map();
|
|
11
11
|
initializedDeviceIds = /* @__PURE__ */ new Set();
|
|
12
|
+
pendingNodeConnects = /* @__PURE__ */ new Map();
|
|
12
13
|
contextUpdateHandlers = {
|
|
13
14
|
style: this.updateStyleContext.bind(this),
|
|
14
15
|
"model.primary": this.updatePrimaryModel.bind(this),
|
|
@@ -116,7 +117,43 @@ var r = { style: "SOUL.md" }, i = "[yoyoclaw-channel]", a = class {
|
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
forwardToNodeGateway(t, n, r, a) {
|
|
119
|
-
e().info(`${i} forwarding user message to node gateway from ${n}, session: ${t}`)
|
|
120
|
+
e().info(`${i} forwarding user message to node gateway from ${n}, session: ${t}`);
|
|
121
|
+
let o = this.readNodeConnectRequest(a);
|
|
122
|
+
o && this.pendingNodeConnects.set(o.requestId, o.nodeId);
|
|
123
|
+
try {
|
|
124
|
+
r.send(a);
|
|
125
|
+
} catch (e) {
|
|
126
|
+
throw o && this.pendingNodeConnects.delete(o.requestId), e;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
readNodeConnectRequest(e) {
|
|
130
|
+
let t;
|
|
131
|
+
try {
|
|
132
|
+
t = JSON.parse(e);
|
|
133
|
+
} catch {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (t.type !== "req" || t.method !== "connect" || typeof t.id != "string" || !t.params || typeof t.params != "object") return;
|
|
137
|
+
let n = t.params;
|
|
138
|
+
if (n.role !== "node" || !n.device || typeof n.device != "object") return;
|
|
139
|
+
let r = n.device;
|
|
140
|
+
if (!(typeof r.id != "string" || !r.id.trim())) return {
|
|
141
|
+
requestId: t.id,
|
|
142
|
+
nodeId: r.id
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
handleNodeConnectResponse(e) {
|
|
146
|
+
let t = e;
|
|
147
|
+
if (t.type !== "res" || typeof t.id != "string") return;
|
|
148
|
+
let n = this.pendingNodeConnects.get(t.id);
|
|
149
|
+
n && (this.pendingNodeConnects.delete(t.id), !(t.ok !== !0 || !t.payload || typeof t.payload != "object") && t.payload.type === "hello-ok" && this.armNodePairingAutoApproval(n));
|
|
150
|
+
}
|
|
151
|
+
async armNodePairingAutoApproval(t) {
|
|
152
|
+
if (!await this.adminClientManager.waitForReady()) {
|
|
153
|
+
e().warn(`${i} admin client not available for node pairing auto approval, nodeId: ${t}`);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
await this.adminClientManager.getClient()?.approvePendingNodePairing(t);
|
|
120
157
|
}
|
|
121
158
|
processMessageBuffer(e, t, n, r) {
|
|
122
159
|
let i = this.pendingFirstMessages.get(t);
|
|
@@ -156,7 +193,7 @@ var r = { style: "SOUL.md" }, i = "[yoyoclaw-channel]", a = class {
|
|
|
156
193
|
e().warn(`${i} gateway message is not valid JSON`);
|
|
157
194
|
return;
|
|
158
195
|
}
|
|
159
|
-
if (!a.ok && a.error?.code === "NOT_PAIRED") {
|
|
196
|
+
if (this.handleNodeConnectResponse(a), !a.ok && a.error?.code === "NOT_PAIRED") {
|
|
160
197
|
let r = a.error?.details?.requestId;
|
|
161
198
|
if (!r) {
|
|
162
199
|
e().warn(`${i} NOT_PAIRED without requestId, ignoring...`);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useClawLogger as e } from "../utils/logger.mjs";
|
|
2
|
+
import { GATEWAY_CLIENT_IDS as t, GATEWAY_CLIENT_MODES as n } from "./types/client.mjs";
|
|
3
|
+
import { ProtocolGatewayClient as r } from "./protocol-client.mjs";
|
|
3
4
|
//#region src/gateway-client/admin-client.ts
|
|
4
|
-
var
|
|
5
|
+
var i = {
|
|
5
6
|
role: "operator",
|
|
6
7
|
scopes: [
|
|
7
8
|
"operator.admin",
|
|
@@ -11,12 +12,12 @@ var r = {
|
|
|
11
12
|
"operator.approvals",
|
|
12
13
|
"operator.pairing"
|
|
13
14
|
],
|
|
14
|
-
clientId:
|
|
15
|
+
clientId: t.CLI,
|
|
15
16
|
displayName: "YOYO-Control",
|
|
16
|
-
clientMode:
|
|
17
|
-
},
|
|
17
|
+
clientMode: n.BACKEND
|
|
18
|
+
}, a = "[yoyoclaw-adminGatewayClient]", o = class extends r {
|
|
18
19
|
constructor(e = {}) {
|
|
19
|
-
super(e,
|
|
20
|
+
super(e, i);
|
|
20
21
|
}
|
|
21
22
|
async setAgentFile(e, t, n = "main") {
|
|
22
23
|
return this.sendRequest("agents.files.set", {
|
|
@@ -49,6 +50,16 @@ var r = {
|
|
|
49
50
|
async devicePairApprove(e) {
|
|
50
51
|
return this.sendRequest("device.pair.approve", { requestId: e });
|
|
51
52
|
}
|
|
53
|
+
async approvePendingNodePairing(t) {
|
|
54
|
+
let n = t.trim();
|
|
55
|
+
if (!n) return !1;
|
|
56
|
+
try {
|
|
57
|
+
let t = (await this.sendRequest("node.pair.list", {})).pending?.find((e) => e.nodeId === n);
|
|
58
|
+
return t ? (e().info(`${a} auto approving node pairing, nodeId: ${n}, requestId: ${t.requestId}`), await this.sendRequest("node.pair.approve", { requestId: t.requestId }), !0) : !1;
|
|
59
|
+
} catch (t) {
|
|
60
|
+
return e().error(`${a} node pairing auto approve failed, nodeId: ${n}, error: ${String(t)}`), !1;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
52
63
|
};
|
|
53
64
|
//#endregion
|
|
54
|
-
export {
|
|
65
|
+
export { o as default };
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { useClawLogger as e } from "../utils/logger.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { getProtocolVersion as t } from "../utils/version.mjs";
|
|
3
|
+
import { loadOrCreateDeviceIdentity as n } from "../modules/device/identity.mjs";
|
|
4
|
+
import { buildDeviceAuthCredential as r } from "../modules/device/credential-builder.mjs";
|
|
5
|
+
import { GatewayClient as i } from "./client.mjs";
|
|
6
|
+
import { ErrorCodes as a, GATEWAY_CLIENT_IDS as o, GATEWAY_CLIENT_MODES as s, WebSocketClientError as c } from "./types/client.mjs";
|
|
7
|
+
import { randomUUID as l } from "node:crypto";
|
|
7
8
|
//#region src/gateway-client/protocol-client.ts
|
|
8
|
-
var
|
|
9
|
+
var u = {
|
|
9
10
|
role: "operator",
|
|
10
11
|
scopes: [],
|
|
11
|
-
clientId:
|
|
12
|
+
clientId: o.CLI,
|
|
12
13
|
displayName: "Protocol Client",
|
|
13
|
-
clientMode:
|
|
14
|
-
},
|
|
14
|
+
clientMode: s.CLI
|
|
15
|
+
}, d = 3e4, f = "1.0.0", p = "server", m = 2, h = 1e3, g = class extends i {
|
|
15
16
|
protocolOpts;
|
|
16
17
|
config;
|
|
17
18
|
pendingRequests = /* @__PURE__ */ new Map();
|
|
@@ -27,7 +28,7 @@ var l = {
|
|
|
27
28
|
isReconnecting = !1;
|
|
28
29
|
constructor(e = {}, t = {}) {
|
|
29
30
|
super(e), this.protocolOpts = e, this.config = {
|
|
30
|
-
...
|
|
31
|
+
...u,
|
|
31
32
|
...t
|
|
32
33
|
}, this.debug = process.env.DEBUG_GATEWAY === "true";
|
|
33
34
|
}
|
|
@@ -67,15 +68,15 @@ var l = {
|
|
|
67
68
|
if (t) if (this.logDebug("response", e), this.pendingRequests.delete(e.id), this.clearTimer(e.id), e.ok) t.resolve(e.payload);
|
|
68
69
|
else {
|
|
69
70
|
let n = e.error || {
|
|
70
|
-
code:
|
|
71
|
+
code: a.UNKNOWN,
|
|
71
72
|
message: "Unknown error"
|
|
72
73
|
};
|
|
73
|
-
t.reject(new
|
|
74
|
+
t.reject(new c(this.toErrorCode(n.code), n.message, n.details, n.retryable));
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
async sendConnect() {
|
|
77
|
-
let e = this.config.clientMode ??
|
|
78
|
-
deviceIdentity:
|
|
78
|
+
let e = this.config.clientMode ?? s.CLI, i = await n(), a = this.connectNonce ? r({
|
|
79
|
+
deviceIdentity: i,
|
|
79
80
|
clientName: this.config.clientId,
|
|
80
81
|
clientMode: e,
|
|
81
82
|
role: this.config.role,
|
|
@@ -83,16 +84,16 @@ var l = {
|
|
|
83
84
|
authToken: this.protocolOpts.token,
|
|
84
85
|
nonce: this.connectNonce,
|
|
85
86
|
platform: process.platform,
|
|
86
|
-
deviceFamily:
|
|
87
|
-
}) : void 0,
|
|
88
|
-
minProtocol:
|
|
89
|
-
maxProtocol:
|
|
87
|
+
deviceFamily: p
|
|
88
|
+
}) : void 0, o = {
|
|
89
|
+
minProtocol: t(),
|
|
90
|
+
maxProtocol: t(),
|
|
90
91
|
client: {
|
|
91
92
|
id: this.config.clientId,
|
|
92
93
|
displayName: this.config.displayName,
|
|
93
|
-
version:
|
|
94
|
+
version: f,
|
|
94
95
|
platform: process.platform,
|
|
95
|
-
deviceFamily:
|
|
96
|
+
deviceFamily: p,
|
|
96
97
|
mode: e
|
|
97
98
|
},
|
|
98
99
|
role: this.config.role,
|
|
@@ -101,21 +102,21 @@ var l = {
|
|
|
101
102
|
token: this.protocolOpts.token,
|
|
102
103
|
password: this.protocolOpts.password
|
|
103
104
|
},
|
|
104
|
-
device:
|
|
105
|
+
device: a
|
|
105
106
|
};
|
|
106
|
-
this.sendRequest("connect",
|
|
107
|
+
this.sendRequest("connect", o).then((e) => {
|
|
107
108
|
this.helloOk = e, this.connected = !0, this.authenticated = !0, this.protocolOpts.onAuthenticated?.();
|
|
108
109
|
}).catch((e) => {
|
|
109
|
-
this.authenticated = !1, e instanceof
|
|
110
|
+
this.authenticated = !1, e instanceof c ? this.protocolOpts.onClose?.(`auth failed: [${e.code}] ${e.message}`) : this.protocolOpts.onClose?.(`auth failed: ${e.message}`);
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
113
|
async sendRequest(e, t) {
|
|
113
|
-
let n =
|
|
114
|
+
let n = l();
|
|
114
115
|
return this.logDebug("request", {
|
|
115
116
|
id: n,
|
|
116
117
|
method: e,
|
|
117
118
|
params: t
|
|
118
|
-
}), new Promise((r,
|
|
119
|
+
}), new Promise((r, i) => {
|
|
119
120
|
let o = {
|
|
120
121
|
type: "req",
|
|
121
122
|
id: n,
|
|
@@ -124,22 +125,22 @@ var l = {
|
|
|
124
125
|
};
|
|
125
126
|
this.pendingRequests.set(n, {
|
|
126
127
|
resolve: r,
|
|
127
|
-
reject:
|
|
128
|
+
reject: i
|
|
128
129
|
});
|
|
129
130
|
try {
|
|
130
131
|
this.send(JSON.stringify(o));
|
|
131
132
|
} catch (e) {
|
|
132
|
-
this.pendingRequests.delete(n),
|
|
133
|
+
this.pendingRequests.delete(n), i(new c(a.CONNECTION_FAILED, `WebSocket is not connected, ${JSON.stringify(e)}`));
|
|
133
134
|
return;
|
|
134
135
|
}
|
|
135
|
-
let
|
|
136
|
+
let s = setTimeout(() => {
|
|
136
137
|
if (this.pendingRequests.has(n)) {
|
|
137
138
|
this.pendingRequests.delete(n);
|
|
138
139
|
let t = this.pendingTimers.get(n);
|
|
139
|
-
t && clearTimeout(t), this.pendingTimers.delete(n),
|
|
140
|
+
t && clearTimeout(t), this.pendingTimers.delete(n), i(new c(a.TIMEOUT, `Request timeout: ${e}`));
|
|
140
141
|
}
|
|
141
|
-
},
|
|
142
|
-
this.pendingTimers.set(n,
|
|
142
|
+
}, d);
|
|
143
|
+
this.pendingTimers.set(n, s);
|
|
143
144
|
});
|
|
144
145
|
}
|
|
145
146
|
isAuthenticated() {
|
|
@@ -149,7 +150,7 @@ var l = {
|
|
|
149
150
|
return this.connected;
|
|
150
151
|
}
|
|
151
152
|
toErrorCode(e) {
|
|
152
|
-
return Object.values(
|
|
153
|
+
return Object.values(a).includes(e) ? e : a.UNKNOWN;
|
|
153
154
|
}
|
|
154
155
|
clearTimer(e) {
|
|
155
156
|
let t = this.pendingTimers.get(e);
|
|
@@ -170,15 +171,15 @@ var l = {
|
|
|
170
171
|
}
|
|
171
172
|
scheduleReconnect() {
|
|
172
173
|
if (!(this.closed || this.isReconnecting)) {
|
|
173
|
-
if (this.reconnectAttempts >=
|
|
174
|
-
e().error(`[protocol-gateway] max reconnect attempts (${
|
|
174
|
+
if (this.reconnectAttempts >= m) {
|
|
175
|
+
e().error(`[protocol-gateway] max reconnect attempts (${m}) reached, giving up`), this.protocolOpts.onReconnectFailed?.();
|
|
175
176
|
return;
|
|
176
177
|
}
|
|
177
|
-
this.reconnectAttempts++, this.isReconnecting = !0, e().info(`[protocol-gateway] attempting to reconnect (attempt ${this.reconnectAttempts}/${
|
|
178
|
+
this.reconnectAttempts++, this.isReconnecting = !0, e().info(`[protocol-gateway] attempting to reconnect (attempt ${this.reconnectAttempts}/${m})`), this.reconnectTimer = setTimeout(() => {
|
|
178
179
|
this.isReconnecting = !1, this.closed || super.connect();
|
|
179
|
-
},
|
|
180
|
+
}, h);
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
183
|
};
|
|
183
184
|
//#endregion
|
|
184
|
-
export {
|
|
185
|
+
export { g as ProtocolGatewayClient };
|
package/dist/hooks/index.mjs
CHANGED
|
@@ -22,15 +22,21 @@ function c(e) {
|
|
|
22
22
|
}
|
|
23
23
|
function l(e) {
|
|
24
24
|
e.on("after_tool_call", async (t) => {
|
|
25
|
-
if (!(t.toolName !== "read" || t.error || !
|
|
25
|
+
if (!(t.toolName !== "read" || t.error || !d(t.params))) try {
|
|
26
26
|
await r(o, "after_tool_call:read_yoyo_control_skill"), e.logger.info("[yoyoclaw-skill-refresh] yoyo-control skill read marker updated");
|
|
27
27
|
} catch (t) {
|
|
28
28
|
e.logger.warn(`[yoyoclaw-skill-refresh] failed to update skill read marker: ${String(t)}`);
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
var u = [
|
|
33
|
+
"path",
|
|
34
|
+
"file_path",
|
|
35
|
+
"filePath",
|
|
36
|
+
"file"
|
|
37
|
+
];
|
|
38
|
+
function d(e) {
|
|
39
|
+
return u.some((t) => n(e[t]));
|
|
34
40
|
}
|
|
35
41
|
//#endregion
|
|
36
42
|
export { s as registerHooks };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { setClawLogger as e } from "./utils/logger.mjs";
|
|
2
|
+
import { setYoyoRuntime as t } from "./runtime.mjs";
|
|
3
3
|
import { registerCommands as n } from "./commands/index.mjs";
|
|
4
4
|
import { registerHooks as r } from "./hooks/index.mjs";
|
|
5
5
|
import { YoyoPluginConfigSchema as i } from "./schemas.mjs";
|
|
@@ -12,7 +12,7 @@ var o = {
|
|
|
12
12
|
description: "OpenClaw Honor Yoyo connection plugin",
|
|
13
13
|
configSchema: i,
|
|
14
14
|
register(i) {
|
|
15
|
-
|
|
15
|
+
t(i.runtime), e(i.logger), i.registerService(a(i)), r(i), n(i);
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
//#endregion
|
|
@@ -1,25 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { STATE_FLAG as c, hasPersistedStateFlag as l, markPersistedStateFlag as u } from "./state-flags.mjs";
|
|
1
|
+
import { areStringArraysEqual as e } from "../../utils/array.mjs";
|
|
2
|
+
import { getEnvFromProcessEnv as t } from "../../utils/env.mjs";
|
|
3
|
+
import { wrapError as n } from "../../utils/error.mjs";
|
|
4
|
+
import { useClawLogger as r } from "../../utils/logger.mjs";
|
|
5
|
+
import { detectProvidersToRename as i, updateProviderReferences as a } from "./provider.mjs";
|
|
6
|
+
import { getYoyoRuntime as o } from "../../runtime.mjs";
|
|
7
|
+
import { isBetaVersion as s } from "../../utils/version.mjs";
|
|
9
8
|
//#region src/modules/configs/config-manager.ts
|
|
10
|
-
var
|
|
9
|
+
var c = "yoyo", l = /* @__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,task_result_query".split(","), u = class {
|
|
11
10
|
loadConfig() {
|
|
12
11
|
try {
|
|
13
|
-
|
|
12
|
+
let e = o().config, t = e.current;
|
|
13
|
+
return typeof t == "function" ? structuredClone(t()) : structuredClone(e.loadConfig());
|
|
14
14
|
} catch (e) {
|
|
15
|
-
throw
|
|
15
|
+
throw n(e, "Failed to load config");
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
async saveConfig(e) {
|
|
19
19
|
try {
|
|
20
|
-
|
|
20
|
+
let t = o().config, n = t.replaceConfigFile;
|
|
21
|
+
if (typeof n == "function") {
|
|
22
|
+
await n({
|
|
23
|
+
nextConfig: e,
|
|
24
|
+
afterWrite: { mode: "auto" }
|
|
25
|
+
});
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
await t.writeConfigFile(e);
|
|
21
29
|
} catch (e) {
|
|
22
|
-
throw
|
|
30
|
+
throw n(e, "Failed to save config");
|
|
23
31
|
}
|
|
24
32
|
}
|
|
25
33
|
getGatewayAuthConfig() {
|
|
@@ -45,7 +53,7 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
|
|
|
45
53
|
}
|
|
46
54
|
getUserConfig() {
|
|
47
55
|
try {
|
|
48
|
-
return this.loadConfig().plugins?.entries?.[
|
|
56
|
+
return this.loadConfig().plugins?.entries?.[c]?.config?.user;
|
|
49
57
|
} catch (e) {
|
|
50
58
|
console.error(`[claw-configs] Failed to read user config: ${e}`);
|
|
51
59
|
return;
|
|
@@ -53,14 +61,14 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
|
|
|
53
61
|
}
|
|
54
62
|
getEnvInfo() {
|
|
55
63
|
try {
|
|
56
|
-
let e = this.loadConfig().plugins?.entries?.[
|
|
57
|
-
if (
|
|
58
|
-
let
|
|
59
|
-
if (
|
|
60
|
-
env:
|
|
64
|
+
let e = this.loadConfig().plugins?.entries?.[c]?.config, n = e?.envInfo;
|
|
65
|
+
if (n?.env) return n;
|
|
66
|
+
let r = e?.env;
|
|
67
|
+
if (r) return {
|
|
68
|
+
env: r,
|
|
61
69
|
source: "manual"
|
|
62
70
|
};
|
|
63
|
-
let i =
|
|
71
|
+
let i = t();
|
|
64
72
|
return i ? {
|
|
65
73
|
env: i,
|
|
66
74
|
source: "env"
|
|
@@ -77,7 +85,7 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
|
|
|
77
85
|
}
|
|
78
86
|
getGrayTag() {
|
|
79
87
|
try {
|
|
80
|
-
return this.loadConfig().plugins?.entries?.[
|
|
88
|
+
return this.loadConfig().plugins?.entries?.[c]?.config?.gray;
|
|
81
89
|
} catch (e) {
|
|
82
90
|
console.error(`[claw-configs] Failed to read gray tag config: ${e}`);
|
|
83
91
|
return;
|
|
@@ -85,7 +93,7 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
|
|
|
85
93
|
}
|
|
86
94
|
getDeviceConfig() {
|
|
87
95
|
try {
|
|
88
|
-
return this.loadConfig().plugins?.entries?.[
|
|
96
|
+
return this.loadConfig().plugins?.entries?.[c]?.config?.device;
|
|
89
97
|
} catch (e) {
|
|
90
98
|
console.error(`[claw-configs] Failed to read device config: ${e}`);
|
|
91
99
|
return;
|
|
@@ -93,17 +101,17 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
|
|
|
93
101
|
}
|
|
94
102
|
async updateDeviceConfig(e) {
|
|
95
103
|
try {
|
|
96
|
-
let t = this.loadConfig(), n = t.plugins?.entries?.[
|
|
104
|
+
let t = this.loadConfig(), n = t.plugins?.entries?.[c]?.config?.device || {}, r = {
|
|
97
105
|
...t,
|
|
98
106
|
plugins: {
|
|
99
107
|
...t.plugins,
|
|
100
108
|
entries: {
|
|
101
109
|
...t.plugins?.entries,
|
|
102
|
-
[
|
|
103
|
-
...t.plugins?.entries?.[
|
|
110
|
+
[c]: {
|
|
111
|
+
...t.plugins?.entries?.[c],
|
|
104
112
|
enabled: !0,
|
|
105
113
|
config: {
|
|
106
|
-
...t.plugins?.entries?.[
|
|
114
|
+
...t.plugins?.entries?.[c]?.config,
|
|
107
115
|
device: {
|
|
108
116
|
...n,
|
|
109
117
|
...e
|
|
@@ -115,7 +123,7 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
|
|
|
115
123
|
};
|
|
116
124
|
await this.saveConfig(r);
|
|
117
125
|
} catch (e) {
|
|
118
|
-
throw
|
|
126
|
+
throw n(e, "Failed to update device config");
|
|
119
127
|
}
|
|
120
128
|
}
|
|
121
129
|
async updateEnv(e) {
|
|
@@ -126,11 +134,11 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
|
|
|
126
134
|
...t.plugins,
|
|
127
135
|
entries: {
|
|
128
136
|
...t.plugins?.entries,
|
|
129
|
-
[
|
|
130
|
-
...t.plugins?.entries?.[
|
|
137
|
+
[c]: {
|
|
138
|
+
...t.plugins?.entries?.[c],
|
|
131
139
|
enabled: !0,
|
|
132
140
|
config: {
|
|
133
|
-
...t.plugins?.entries?.[
|
|
141
|
+
...t.plugins?.entries?.[c]?.config,
|
|
134
142
|
envInfo: {
|
|
135
143
|
env: e,
|
|
136
144
|
source: "manual"
|
|
@@ -143,12 +151,12 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
|
|
|
143
151
|
};
|
|
144
152
|
await this.saveConfig(n);
|
|
145
153
|
} catch (e) {
|
|
146
|
-
throw
|
|
154
|
+
throw n(e, "Failed to update env config");
|
|
147
155
|
}
|
|
148
156
|
}
|
|
149
157
|
async resetEnv() {
|
|
150
158
|
try {
|
|
151
|
-
let e = this.loadConfig(), t = e.plugins?.entries?.[
|
|
159
|
+
let e = this.loadConfig(), t = e.plugins?.entries?.[c]?.config?.envInfo;
|
|
152
160
|
if (!t?.env) return;
|
|
153
161
|
let n = {
|
|
154
162
|
...e,
|
|
@@ -156,11 +164,11 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
|
|
|
156
164
|
...e.plugins,
|
|
157
165
|
entries: {
|
|
158
166
|
...e.plugins?.entries,
|
|
159
|
-
[
|
|
160
|
-
...e.plugins?.entries?.[
|
|
167
|
+
[c]: {
|
|
168
|
+
...e.plugins?.entries?.[c],
|
|
161
169
|
enabled: !0,
|
|
162
170
|
config: {
|
|
163
|
-
...e.plugins?.entries?.[
|
|
171
|
+
...e.plugins?.entries?.[c]?.config,
|
|
164
172
|
envInfo: {
|
|
165
173
|
env: t.env,
|
|
166
174
|
source: "env"
|
|
@@ -172,7 +180,7 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
|
|
|
172
180
|
};
|
|
173
181
|
await this.saveConfig(n);
|
|
174
182
|
} catch (e) {
|
|
175
|
-
throw
|
|
183
|
+
throw n(e, "Failed to reset env config");
|
|
176
184
|
}
|
|
177
185
|
}
|
|
178
186
|
async updateGrayTag(e) {
|
|
@@ -183,11 +191,11 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
|
|
|
183
191
|
...t.plugins,
|
|
184
192
|
entries: {
|
|
185
193
|
...t.plugins?.entries,
|
|
186
|
-
[
|
|
187
|
-
...t.plugins?.entries?.[
|
|
194
|
+
[c]: {
|
|
195
|
+
...t.plugins?.entries?.[c],
|
|
188
196
|
enabled: !0,
|
|
189
197
|
config: {
|
|
190
|
-
...t.plugins?.entries?.[
|
|
198
|
+
...t.plugins?.entries?.[c]?.config,
|
|
191
199
|
...e && { gray: e }
|
|
192
200
|
}
|
|
193
201
|
}
|
|
@@ -196,7 +204,7 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
|
|
|
196
204
|
};
|
|
197
205
|
await this.saveConfig(n);
|
|
198
206
|
} catch (e) {
|
|
199
|
-
throw
|
|
207
|
+
throw n(e, "Failed to update gray tag config");
|
|
200
208
|
}
|
|
201
209
|
}
|
|
202
210
|
async updateUserConfig(e) {
|
|
@@ -207,11 +215,11 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
|
|
|
207
215
|
...t.plugins,
|
|
208
216
|
entries: {
|
|
209
217
|
...t.plugins?.entries,
|
|
210
|
-
[
|
|
211
|
-
...t.plugins?.entries?.[
|
|
218
|
+
[c]: {
|
|
219
|
+
...t.plugins?.entries?.[c],
|
|
212
220
|
enabled: !0,
|
|
213
221
|
config: {
|
|
214
|
-
...t.plugins?.entries?.[
|
|
222
|
+
...t.plugins?.entries?.[c]?.config,
|
|
215
223
|
user: e
|
|
216
224
|
}
|
|
217
225
|
}
|
|
@@ -220,7 +228,7 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
|
|
|
220
228
|
};
|
|
221
229
|
await this.saveConfig(n);
|
|
222
230
|
} catch (e) {
|
|
223
|
-
throw
|
|
231
|
+
throw n(e, "Failed to update user config");
|
|
224
232
|
}
|
|
225
233
|
}
|
|
226
234
|
async clearUserConfig() {
|
|
@@ -231,10 +239,10 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
|
|
|
231
239
|
...e.plugins,
|
|
232
240
|
entries: {
|
|
233
241
|
...e.plugins?.entries,
|
|
234
|
-
[
|
|
235
|
-
...e.plugins?.entries?.[
|
|
242
|
+
[c]: {
|
|
243
|
+
...e.plugins?.entries?.[c],
|
|
236
244
|
config: {
|
|
237
|
-
...e.plugins?.entries?.[
|
|
245
|
+
...e.plugins?.entries?.[c]?.config,
|
|
238
246
|
user: void 0
|
|
239
247
|
}
|
|
240
248
|
}
|
|
@@ -243,59 +251,59 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
|
|
|
243
251
|
};
|
|
244
252
|
await this.saveConfig(t);
|
|
245
253
|
} catch (e) {
|
|
246
|
-
throw
|
|
254
|
+
throw n(e, "Failed to clear user config");
|
|
247
255
|
}
|
|
248
256
|
}
|
|
249
|
-
async initializePluginConfig(
|
|
257
|
+
async initializePluginConfig(o) {
|
|
250
258
|
try {
|
|
251
|
-
let
|
|
252
|
-
env:
|
|
259
|
+
let n = this.loadConfig(), c = n.skills || {}, u = c.load || {}, d = u.watch === !1, f = n.plugins?.allow || [], p = !f.includes(o), m = f.includes(o) ? f : [...f, o], h = n.gateway?.nodes?.allowCommands || [], g = Array.from(new Set([...h, ...l])), _ = !e(h, g), v = !d, y = n.plugins?.entries?.[o]?.config?.envInfo, b = n.plugins?.entries?.[o]?.config?.env, x = !!(y?.env || b), S = t(), C = !!y?.env && y.source === "env", w = !y?.env && !!b || C && S && y.env !== S, T = !x || w, E = {
|
|
260
|
+
env: S || b || (s() ? "test" : "production"),
|
|
253
261
|
source: "env"
|
|
254
|
-
},
|
|
255
|
-
...
|
|
256
|
-
envInfo:
|
|
262
|
+
}, D = n.plugins?.entries?.[o]?.config || {}, O = T ? {
|
|
263
|
+
...D,
|
|
264
|
+
envInfo: E,
|
|
257
265
|
env: void 0
|
|
258
|
-
} :
|
|
259
|
-
if (
|
|
260
|
-
let
|
|
261
|
-
...
|
|
266
|
+
} : D, k = n.plugins?.entries?.[o]?.enabled !== !0, A = i(n), j = Object.keys(A).length > 0;
|
|
267
|
+
if (j && r().info(`[claw-configs] Found ${Object.keys(A).length} providers to rename: ${Object.entries(A).map(([e, t]) => `${e} -> ${t}`).join(", ")}`), !p && !_ && !v && !T && !k && !j) return;
|
|
268
|
+
let M = {
|
|
269
|
+
...n,
|
|
262
270
|
plugins: {
|
|
263
|
-
...
|
|
264
|
-
allow:
|
|
271
|
+
...n.plugins,
|
|
272
|
+
allow: m,
|
|
265
273
|
entries: {
|
|
266
|
-
...
|
|
267
|
-
[
|
|
268
|
-
...
|
|
274
|
+
...n.plugins?.entries,
|
|
275
|
+
[o]: {
|
|
276
|
+
...n.plugins?.entries?.[o],
|
|
269
277
|
enabled: !0,
|
|
270
|
-
config:
|
|
278
|
+
config: O
|
|
271
279
|
}
|
|
272
280
|
}
|
|
273
281
|
},
|
|
274
282
|
gateway: {
|
|
275
|
-
...
|
|
283
|
+
...n.gateway,
|
|
276
284
|
nodes: {
|
|
277
|
-
...
|
|
278
|
-
allowCommands:
|
|
285
|
+
...n.gateway?.nodes,
|
|
286
|
+
allowCommands: g
|
|
279
287
|
}
|
|
280
288
|
}
|
|
281
289
|
};
|
|
282
|
-
|
|
283
|
-
...
|
|
290
|
+
v && (M = {
|
|
291
|
+
...M,
|
|
284
292
|
skills: {
|
|
285
|
-
...
|
|
293
|
+
...c,
|
|
286
294
|
load: {
|
|
287
|
-
...
|
|
295
|
+
...u,
|
|
288
296
|
watch: !1
|
|
289
297
|
}
|
|
290
298
|
}
|
|
291
|
-
},
|
|
299
|
+
}, r().info("[claw-configs] Disabled skills.load.watch for yoyo")), j && (M = a(M, A), r().info("[claw-configs] Provider renaming completed")), await this.saveConfig(M);
|
|
292
300
|
} catch (e) {
|
|
293
|
-
throw
|
|
301
|
+
throw n(e, "failed to initialize plugin config");
|
|
294
302
|
}
|
|
295
303
|
}
|
|
296
|
-
},
|
|
297
|
-
function
|
|
298
|
-
return
|
|
304
|
+
}, d = null;
|
|
305
|
+
function f() {
|
|
306
|
+
return d ||= new u(), d;
|
|
299
307
|
}
|
|
300
308
|
//#endregion
|
|
301
|
-
export {
|
|
309
|
+
export { u as ConfigManager, f as getConfigManager };
|