@honor-claw/yoyo 1.4.1-alpha.1 → 1.4.1-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.
- package/dist/cloud-channel/message-handler.mjs +21 -20
- package/dist/modules/device-toolset/ack.mjs +54 -0
- package/dist/modules/device-toolset/archive.mjs +4 -9
- package/dist/modules/device-toolset/index.mjs +1 -0
- package/dist/modules/device-toolset/normalize.mjs +3 -4
- package/dist/modules/device-toolset/persist.mjs +0 -7
- package/dist/modules/device-toolset/processor.mjs +7 -7
- package/dist/utils/version.mjs +2 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useClawLogger as e } from "../utils/logger.mjs";
|
|
2
2
|
import { StatusEventType as t } from "../services/connection/status-tracker/events.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { createDeviceToolSetUpdateAck as n } from "../modules/device-toolset/ack.mjs";
|
|
4
4
|
import "../modules/device-toolset/index.mjs";
|
|
5
5
|
//#region src/cloud-channel/message-handler.ts
|
|
6
6
|
var r = { style: "SOUL.md" }, i = "[yoyoclaw-channel]", a = class {
|
|
@@ -167,7 +167,7 @@ var r = { style: "SOUL.md" }, i = "[yoyoclaw-channel]", a = class {
|
|
|
167
167
|
this.sendMessage("deviceControl", t, n, "", void 0, o), e().info(`${i} auto pair is completed, requestId: ${r}`);
|
|
168
168
|
return;
|
|
169
169
|
}
|
|
170
|
-
|
|
170
|
+
this.sendMessage("userMessage", t, n, r) || (e().error(`${i} failed to send message, cloud socket closed, session ${t}, device ${s}`), this.sessionManager.closeNodeGatewayClient(t));
|
|
171
171
|
} catch (t) {
|
|
172
172
|
e().error(`${i} failed to handle gateway message: ${String(t)}`);
|
|
173
173
|
}
|
|
@@ -206,10 +206,10 @@ var r = { style: "SOUL.md" }, i = "[yoyoclaw-channel]", a = class {
|
|
|
206
206
|
e().info(`${i} ${o ? "update" : "fetch"} context '${u}' processed (no reply)`);
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
|
-
d.ok ? (e().info(`${i} ${o ? "update" : "fetch"} context successfully`), this.sendContextResponse(a, n, r, s, {
|
|
209
|
+
d.ok ? (e().info(`${i} ${o ? "update" : "fetch"} context successfully`), this.sendContextResponse(a, n, r, s, d.responsePayload ?? {
|
|
210
210
|
ok: !0,
|
|
211
211
|
...d.data
|
|
212
|
-
})) : (e().error(`${i} failed to ${o ? "update" : "fetch"} context: ${d.error}`), this.sendContextResponse(a, n, r, s, {
|
|
212
|
+
})) : (e().error(`${i} failed to ${o ? "update" : "fetch"} context: ${d.error}`), this.sendContextResponse(a, n, r, s, d.responsePayload ?? {
|
|
213
213
|
ok: !1,
|
|
214
214
|
error: d.error,
|
|
215
215
|
...d?.data,
|
|
@@ -220,20 +220,20 @@ var r = { style: "SOUL.md" }, i = "[yoyoclaw-channel]", a = class {
|
|
|
220
220
|
e().error(`${i} error ${o ? "updating" : "fetching"} context '${u}': ${c}`), this.replyContextError(a, n, r, s, c);
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
sendMessage(
|
|
224
|
-
let
|
|
225
|
-
msgType:
|
|
223
|
+
sendMessage(t, n, r, a, o, s) {
|
|
224
|
+
let c = {
|
|
225
|
+
msgType: t,
|
|
226
226
|
sourceRole: "yoyoclaw",
|
|
227
227
|
sourceDeviceId: this.config.deviceInfo.deviceId,
|
|
228
|
-
traceInfo:
|
|
228
|
+
traceInfo: r,
|
|
229
229
|
targetRole: "node",
|
|
230
|
-
targetDeviceId:
|
|
230
|
+
targetDeviceId: n,
|
|
231
231
|
port: this.config.deviceInfo.port,
|
|
232
|
-
data: typeof
|
|
233
|
-
contexts:
|
|
234
|
-
bizExtInfo:
|
|
232
|
+
data: typeof a == "string" ? a : JSON.stringify(a),
|
|
233
|
+
contexts: o,
|
|
234
|
+
bizExtInfo: s
|
|
235
235
|
};
|
|
236
|
-
return this.config.onReply(
|
|
236
|
+
return e().debug?.(`${i} sending message to cloud, msgType: ${c.msgType}, targetDeviceId: ${c.targetDeviceId}, data: ${JSON.stringify(c).slice(0, 3e3)}`), this.config.onReply(c, n);
|
|
237
237
|
}
|
|
238
238
|
validateContext(e) {
|
|
239
239
|
return e?.header?.name ? {
|
|
@@ -367,13 +367,14 @@ var r = { style: "SOUL.md" }, i = "[yoyoclaw-channel]", a = class {
|
|
|
367
367
|
return !e || t !== "DeviceToolSet" && t !== "UniversalToolSet";
|
|
368
368
|
}
|
|
369
369
|
async updateDeviceToolSetContext(e, t, r) {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
ok:
|
|
376
|
-
error:
|
|
370
|
+
let i = await n({
|
|
371
|
+
namespace: r?.header.namespace,
|
|
372
|
+
payload: t
|
|
373
|
+
});
|
|
374
|
+
return {
|
|
375
|
+
ok: i.ok,
|
|
376
|
+
error: i.error,
|
|
377
|
+
responsePayload: i.payload
|
|
377
378
|
};
|
|
378
379
|
}
|
|
379
380
|
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { processDeviceToolSet as e } from "./processor.mjs";
|
|
2
|
+
//#region src/modules/device-toolset/ack.ts
|
|
3
|
+
var t = "200", n = "500", r = "DeviceToolSet payload missing nodeId";
|
|
4
|
+
async function i(t) {
|
|
5
|
+
let n = a(t.payload);
|
|
6
|
+
if (t.namespace !== "yoyoclaw") {
|
|
7
|
+
let e = `Unsupported DeviceToolSet namespace: ${t.namespace ?? "unknown"}`;
|
|
8
|
+
return {
|
|
9
|
+
ok: !1,
|
|
10
|
+
error: e,
|
|
11
|
+
payload: s(n, e)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
if (!n) return {
|
|
15
|
+
ok: !1,
|
|
16
|
+
error: r,
|
|
17
|
+
payload: s("", r)
|
|
18
|
+
};
|
|
19
|
+
try {
|
|
20
|
+
return {
|
|
21
|
+
ok: !0,
|
|
22
|
+
payload: o(await e(t.payload))
|
|
23
|
+
};
|
|
24
|
+
} catch (e) {
|
|
25
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
26
|
+
return {
|
|
27
|
+
ok: !1,
|
|
28
|
+
error: t,
|
|
29
|
+
payload: s(n, t)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function a(e) {
|
|
34
|
+
let t = e?.nodeId;
|
|
35
|
+
return typeof t == "string" && t.trim() ? t : "";
|
|
36
|
+
}
|
|
37
|
+
function o(e) {
|
|
38
|
+
return {
|
|
39
|
+
nodeId: e.nodeId,
|
|
40
|
+
errorCode: t,
|
|
41
|
+
changed: e.changed,
|
|
42
|
+
rawCount: e.rawCount,
|
|
43
|
+
validCount: e.validCount
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function s(e, t) {
|
|
47
|
+
return {
|
|
48
|
+
nodeId: e,
|
|
49
|
+
errorCode: n,
|
|
50
|
+
errorMessage: t
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { i as createDeviceToolSetUpdateAck };
|
|
@@ -3,25 +3,20 @@ import { INVALID_TOOL_FILENAME_CHAR_PATTERN as t, TOOL_ARCHIVE_DIR as n } from "
|
|
|
3
3
|
import r from "node:path";
|
|
4
4
|
//#region src/modules/device-toolset/archive.ts
|
|
5
5
|
async function i(t, i) {
|
|
6
|
-
let s = 0
|
|
6
|
+
let s = 0;
|
|
7
7
|
for (let a of i) {
|
|
8
8
|
let i = o(a.name);
|
|
9
|
-
|
|
10
|
-
c += 1;
|
|
11
|
-
continue;
|
|
12
|
-
}
|
|
13
|
-
await e({
|
|
9
|
+
i && (await e({
|
|
14
10
|
rootDir: t,
|
|
15
11
|
relativePath: r.join(n, i),
|
|
16
12
|
data: JSON.stringify(a, null, 2),
|
|
17
13
|
encoding: "utf8",
|
|
18
14
|
mkdir: !0
|
|
19
|
-
}), s += 1;
|
|
15
|
+
}), s += 1);
|
|
20
16
|
}
|
|
21
17
|
return {
|
|
22
18
|
archiveDir: a(t),
|
|
23
|
-
writtenCount: s
|
|
24
|
-
skippedCount: c
|
|
19
|
+
writtenCount: s
|
|
25
20
|
};
|
|
26
21
|
}
|
|
27
22
|
function a(e) {
|
|
@@ -10,15 +10,14 @@ function t(t) {
|
|
|
10
10
|
return t;
|
|
11
11
|
}
|
|
12
12
|
function n(e) {
|
|
13
|
-
let t = e.nodeId, n = /* @__PURE__ */ new Map()
|
|
13
|
+
let t = e.nodeId, n = /* @__PURE__ */ new Map();
|
|
14
14
|
for (let t of e.toolSet) {
|
|
15
15
|
let e = r(t);
|
|
16
|
-
e
|
|
16
|
+
e && n.set(e.name, e);
|
|
17
17
|
}
|
|
18
18
|
return {
|
|
19
19
|
nodeId: t,
|
|
20
|
-
tools: Array.from(n.values())
|
|
21
|
-
skippedCount: i
|
|
20
|
+
tools: Array.from(n.values())
|
|
22
21
|
};
|
|
23
22
|
}
|
|
24
23
|
function r(t) {
|
|
@@ -36,8 +36,6 @@ async function s(e, t, r) {
|
|
|
36
36
|
mkdir: !0
|
|
37
37
|
}), {
|
|
38
38
|
changed: !0,
|
|
39
|
-
nodeCount: d(a.tools),
|
|
40
|
-
toolCount: Object.keys(a.tools).length,
|
|
41
39
|
cache: a
|
|
42
40
|
};
|
|
43
41
|
}
|
|
@@ -72,10 +70,5 @@ function l(e, t) {
|
|
|
72
70
|
function u(e, t) {
|
|
73
71
|
return [...new Set([...e, t])];
|
|
74
72
|
}
|
|
75
|
-
function d(e) {
|
|
76
|
-
let t = /* @__PURE__ */ new Set();
|
|
77
|
-
for (let n of Object.values(e)) for (let e of n.supportedNodeIds) t.add(e);
|
|
78
|
-
return t.size;
|
|
79
|
-
}
|
|
80
73
|
//#endregion
|
|
81
74
|
export { o as loadDeviceToolSetCache, s as mergeDeviceToolSetCache };
|
|
@@ -14,29 +14,29 @@ async function g(n) {
|
|
|
14
14
|
let g = p(n), _ = t();
|
|
15
15
|
if (!_) throw Error("Unable to resolve home directory for DeviceToolSet persistence");
|
|
16
16
|
let v = m(g);
|
|
17
|
-
e().info(`[yoyoclaw-device-toolset] process start, nodeId: ${v.nodeId},
|
|
17
|
+
e().info(`[yoyoclaw-device-toolset] process start, nodeId: ${v.nodeId}, raw: ${g.toolSet.length}, valid: ${v.tools.length}`);
|
|
18
18
|
let y = u(v.tools);
|
|
19
19
|
if (e().debug?.(`[yoyoclaw-device-toolset] computed md5, nodeId: ${v.nodeId}, md5: ${y}`), !(await d(_, v.nodeId, y)).changed) {
|
|
20
20
|
let t = await l(_, h);
|
|
21
21
|
return e().info(`[yoyoclaw-device-toolset] unchanged, skip refresh, nodeId: ${v.nodeId}, artifactsRestored: ${t.restored}`), {
|
|
22
22
|
changed: !1,
|
|
23
23
|
nodeId: v.nodeId,
|
|
24
|
-
|
|
24
|
+
rawCount: g.toolSet.length,
|
|
25
|
+
validCount: v.tools.length
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
28
|
let b = await s(_, v.nodeId, v.tools);
|
|
28
|
-
e().info(`[yoyoclaw-device-toolset] cache merged, nodeId: ${v.nodeId},
|
|
29
|
+
e().info(`[yoyoclaw-device-toolset] cache merged, nodeId: ${v.nodeId}, processed: ${v.tools.length}`);
|
|
29
30
|
let x = b.cache.tools, S = await i(_, v.tools);
|
|
30
|
-
e().info(`[yoyoclaw-device-toolset] archive refreshed, nodeId: ${v.nodeId}, written: ${S.writtenCount}
|
|
31
|
+
e().info(`[yoyoclaw-device-toolset] archive refreshed, nodeId: ${v.nodeId}, written: ${S.writtenCount}`);
|
|
31
32
|
let C = await c(h, x);
|
|
32
33
|
e().info(`[yoyoclaw-device-toolset] skill refreshed, nodeId: ${v.nodeId}, rows: ${C.rowCount}, updated: ${C.updated}`), C.updated && await r(h, v.nodeId);
|
|
33
34
|
let w = await a(S.archiveDir, o(h));
|
|
34
35
|
return e().info(`[yoyoclaw-device-toolset] mapping ready, nodeId: ${v.nodeId}, mode: ${w.mode}`), await f(_, v.nodeId, y, Date.now()), e().info(`[yoyoclaw-device-toolset] process complete, nodeId: ${v.nodeId}`), {
|
|
35
36
|
changed: !0,
|
|
36
37
|
nodeId: v.nodeId,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
skippedCount: v.skippedCount
|
|
38
|
+
rawCount: g.toolSet.length,
|
|
39
|
+
validCount: v.tools.length
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
//#endregion
|
package/dist/utils/version.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/utils/version.ts
|
|
2
2
|
var e = null, t = null;
|
|
3
3
|
function n() {
|
|
4
|
-
return e === null && (e = "1.4.1-alpha.
|
|
4
|
+
return e === null && (e = "1.4.1-alpha.2".includes("beta") || "1.4.1-alpha.2".includes("alpha")), !!e;
|
|
5
5
|
}
|
|
6
6
|
function r(e) {
|
|
7
7
|
if (!e) return 0;
|
|
@@ -10,7 +10,7 @@ function r(e) {
|
|
|
10
10
|
}
|
|
11
11
|
function i() {
|
|
12
12
|
if (t !== null) return t;
|
|
13
|
-
let [e, n, i] = "1.4.1-alpha.
|
|
13
|
+
let [e, n, i] = "1.4.1-alpha.2".split("-", 1)[0].split("."), a = r(e), o = r(n), s = r(i);
|
|
14
14
|
return t = a * 1e6 + o * 1e3 + s, t;
|
|
15
15
|
}
|
|
16
16
|
//#endregion
|