@honor-claw/yoyo 1.6.0-beta.3 → 1.6.0-beta.5
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/authorization-refresh-manager.mjs +21 -6
- 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 +10 -3
- package/skills/yoyo-update/SKILL.md +5 -11
- 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 a = "[yoyoclaw-auth-refresh]", o = .3, s = .1, c = 1e3, l = 6e4, u = class {
|
|
|
9
9
|
scheduleVersion = 0;
|
|
10
10
|
destroyed = !1;
|
|
11
11
|
pausedForExpiredToken = !1;
|
|
12
|
+
pendingConfigTokenRefresh = !1;
|
|
12
13
|
constructor(e) {
|
|
13
14
|
this.config = e;
|
|
14
15
|
}
|
|
@@ -29,15 +30,29 @@ var a = "[yoyoclaw-auth-refresh]", o = .3, s = .1, c = 1e3, l = 6e4, u = class {
|
|
|
29
30
|
}
|
|
30
31
|
this.sendUpdateAuthorizationRequest(), this.scheduleTimer(n.expireMs * s);
|
|
31
32
|
}
|
|
32
|
-
async handleAuthorizationUpdate(
|
|
33
|
-
let
|
|
34
|
-
if (typeof
|
|
33
|
+
async handleAuthorizationUpdate(r) {
|
|
34
|
+
let i = r.bizExtInfo, o = i?.jwtToken;
|
|
35
|
+
if (typeof o != "string" || !o.trim()) {
|
|
35
36
|
e().warn(`${a} updateAuthorization missing valid jwtToken`);
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
38
39
|
try {
|
|
39
|
-
let
|
|
40
|
-
e().info(`${a} cached new token, expireMs: ${
|
|
40
|
+
let s = Date.now(), c = o.trim(), l = (await n(c, i?.expire, s))?.authorizationCache?.expireMs ?? 0;
|
|
41
|
+
if (e().info(`${a} cached new token, expireMs: ${l}, receivedAtMs: ${s}, sourceDeviceId: ${r.sourceDeviceId || "unknown"}, sourceRole: ${r.sourceRole || "unknown"}`), this.pendingConfigTokenRefresh) {
|
|
42
|
+
this.pendingConfigTokenRefresh = !1;
|
|
43
|
+
try {
|
|
44
|
+
let n = t(), r = n.getUserConfig();
|
|
45
|
+
await n.updateUserConfig({
|
|
46
|
+
...r,
|
|
47
|
+
token: c,
|
|
48
|
+
userId: void 0,
|
|
49
|
+
expired: void 0
|
|
50
|
+
}), e().info(`${a} persisted upgraded token to plugin config, expireMs: ${l}`);
|
|
51
|
+
} catch (t) {
|
|
52
|
+
e().error(`${a} failed to persist upgraded token to plugin config: ${String(t)}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
this.pausedForExpiredToken = !1, await this.schedule();
|
|
41
56
|
} catch (t) {
|
|
42
57
|
e().error(`${a} failed to cache new token: ${String(t)}`);
|
|
43
58
|
}
|
|
@@ -54,7 +69,7 @@ var a = "[yoyoclaw-auth-refresh]", o = .3, s = .1, c = 1e3, l = 6e4, u = class {
|
|
|
54
69
|
let s = (await r())?.authorizationCache, c = i(s?.expireMs), u = s?.receivedAtMs ?? 0;
|
|
55
70
|
if (!c || !Number.isFinite(u) || u <= 0) {
|
|
56
71
|
let t = Date.now();
|
|
57
|
-
return await n(o, l, t), e().warn(`${a} missing cached authorization timing, persisted legacy token timing and refreshing immediately`), {
|
|
72
|
+
return this.pendingConfigTokenRefresh = !0, await n(o, l, t), e().warn(`${a} missing cached authorization timing, persisted legacy token timing and refreshing immediately`), {
|
|
58
73
|
receivedAtMs: t,
|
|
59
74
|
expireMs: l,
|
|
60
75
|
refreshImmediately: !0
|
|
@@ -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
|