@honor-claw/yoyo 1.3.0-beta.3 → 1.3.0-beta.4
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/index.mjs +55 -44
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -23,7 +23,7 @@ import { Buffer as ie } from "node:buffer";
|
|
|
23
23
|
//#region src/utils/version.ts
|
|
24
24
|
var ae = null;
|
|
25
25
|
function oe() {
|
|
26
|
-
return ae === null && (ae = "1.3.0-beta.
|
|
26
|
+
return ae === null && (ae = "1.3.0-beta.4".includes("beta") || "1.3.0-beta.4".includes("alpha")), !!ae;
|
|
27
27
|
}
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/runtime.ts
|
|
@@ -2951,7 +2951,7 @@ function Cr(e) {
|
|
|
2951
2951
|
return JSON.stringify(Or(e));
|
|
2952
2952
|
}
|
|
2953
2953
|
function wr(e) {
|
|
2954
|
-
return g("md5").update(Cr(e)).digest("hex");
|
|
2954
|
+
return e.length === 0 ? "" : g("md5").update(Cr(e)).digest("hex");
|
|
2955
2955
|
}
|
|
2956
2956
|
async function Tr(e) {
|
|
2957
2957
|
try {
|
|
@@ -3016,7 +3016,7 @@ function kr(e) {
|
|
|
3016
3016
|
let t = e;
|
|
3017
3017
|
if (!Y(t.nodeId)) throw Error("DeviceToolSet payload missing nodeId");
|
|
3018
3018
|
if (!Array.isArray(t.toolSet)) throw Error("DeviceToolSet payload toolSet must be an array");
|
|
3019
|
-
return e;
|
|
3019
|
+
return O().debug?.(`DeviceToolSet payload received: ${JSON.stringify(t, null, 2)}`), e;
|
|
3020
3020
|
}
|
|
3021
3021
|
function Ar(e) {
|
|
3022
3022
|
let t = e.nodeId, n = [], r = 0;
|
|
@@ -3081,83 +3081,94 @@ async function Ir(e, t, n) {
|
|
|
3081
3081
|
mkdir: !0
|
|
3082
3082
|
}), {
|
|
3083
3083
|
changed: !0,
|
|
3084
|
-
nodeCount:
|
|
3084
|
+
nodeCount: Br(r.tools),
|
|
3085
3085
|
toolCount: Object.keys(r.tools).length,
|
|
3086
3086
|
cache: r
|
|
3087
3087
|
};
|
|
3088
3088
|
}
|
|
3089
3089
|
function Lr(e, t, n) {
|
|
3090
|
-
let r =
|
|
3090
|
+
let r = Rr(e, t);
|
|
3091
3091
|
for (let e of n) {
|
|
3092
3092
|
let n = r[e.id];
|
|
3093
3093
|
r[e.id] = {
|
|
3094
3094
|
id: e.id,
|
|
3095
3095
|
name: e.name,
|
|
3096
3096
|
description: e.description,
|
|
3097
|
-
supportedNodeIds:
|
|
3097
|
+
supportedNodeIds: zr(n?.supportedNodeIds ?? [], t)
|
|
3098
3098
|
};
|
|
3099
3099
|
}
|
|
3100
3100
|
return r;
|
|
3101
3101
|
}
|
|
3102
3102
|
function Rr(e, t) {
|
|
3103
|
+
let n = {};
|
|
3104
|
+
for (let [r, i] of Object.entries(e)) {
|
|
3105
|
+
let e = i.supportedNodeIds.filter((e) => e !== t);
|
|
3106
|
+
e.length > 0 && (n[r] = {
|
|
3107
|
+
...i,
|
|
3108
|
+
supportedNodeIds: e
|
|
3109
|
+
});
|
|
3110
|
+
}
|
|
3111
|
+
return n;
|
|
3112
|
+
}
|
|
3113
|
+
function zr(e, t) {
|
|
3103
3114
|
return [...new Set([...e, t])];
|
|
3104
3115
|
}
|
|
3105
|
-
function
|
|
3116
|
+
function Br(e) {
|
|
3106
3117
|
let t = /* @__PURE__ */ new Set();
|
|
3107
3118
|
for (let n of Object.values(e)) for (let e of n.supportedNodeIds) t.add(e);
|
|
3108
3119
|
return t.size;
|
|
3109
3120
|
}
|
|
3110
3121
|
//#endregion
|
|
3111
3122
|
//#region src/modules/device-toolset/skill-inject.ts
|
|
3112
|
-
var
|
|
3113
|
-
async function
|
|
3114
|
-
let n = r.join(e,
|
|
3123
|
+
var Vr = r.join("skills", "yoyo-control", "SKILL.md"), Hr = r.join("skills", "yoyo-control", "configs", "sub-skills.json"), Ur = "{{full-mcp-tool-list}}", Wr = "<!-- yoyo-mcp-tools:start -->", Gr = "<!-- yoyo-mcp-tools:end -->";
|
|
3124
|
+
async function Kr(e, t) {
|
|
3125
|
+
let n = r.join(e, Vr), i = await v.readFile(n, "utf8"), a = Jr(t, await qr(e)), o = Xr(i, Yr(a));
|
|
3115
3126
|
return o !== i && await v.writeFile(n, o, "utf8"), {
|
|
3116
3127
|
skillPath: n,
|
|
3117
3128
|
rowCount: Object.keys(a).length
|
|
3118
3129
|
};
|
|
3119
3130
|
}
|
|
3120
|
-
async function
|
|
3121
|
-
let t = r.join(e,
|
|
3131
|
+
async function qr(e) {
|
|
3132
|
+
let t = r.join(e, Hr), n;
|
|
3122
3133
|
try {
|
|
3123
3134
|
n = await v.readFile(t, "utf8");
|
|
3124
3135
|
} catch (e) {
|
|
3125
|
-
if (
|
|
3136
|
+
if ($r(e) && e.code === "ENOENT") return /* @__PURE__ */ new Set();
|
|
3126
3137
|
throw e;
|
|
3127
3138
|
}
|
|
3128
3139
|
let i = JSON.parse(n);
|
|
3129
3140
|
if (!Array.isArray(i) || i.some((e) => typeof e != "string")) throw Error("sub-skills config must be a JSON array of tool names");
|
|
3130
3141
|
return new Set(i.map((e) => e.trim()).filter(Boolean));
|
|
3131
3142
|
}
|
|
3132
|
-
function
|
|
3143
|
+
function Jr(e, t) {
|
|
3133
3144
|
return t.size === 0 ? e : Object.fromEntries(Object.entries(e).filter(([e, n]) => !t.has(e) && !t.has(n.name)));
|
|
3134
3145
|
}
|
|
3135
|
-
function
|
|
3146
|
+
function Yr(e) {
|
|
3136
3147
|
return [
|
|
3137
|
-
|
|
3138
|
-
...Object.values(e).toSorted((e, t) => e.name.localeCompare(t.name)).map((e) => `| ${
|
|
3139
|
-
|
|
3148
|
+
Wr,
|
|
3149
|
+
...Object.values(e).toSorted((e, t) => e.name.localeCompare(t.name)).map((e) => `| ${Zr(e.name)} | ${Zr(e.description)} | ${Zr(e.supportedNodeIds.join(", "))} |`),
|
|
3150
|
+
Gr
|
|
3140
3151
|
].join("\n");
|
|
3141
3152
|
}
|
|
3142
|
-
function
|
|
3143
|
-
let n = RegExp(`${
|
|
3153
|
+
function Xr(e, t) {
|
|
3154
|
+
let n = RegExp(`${Qr(Wr)}[\\s\\S]*?${Qr(Gr)}`);
|
|
3144
3155
|
if (n.test(e)) return e.replace(n, t);
|
|
3145
|
-
if (e.includes(
|
|
3156
|
+
if (e.includes(Ur)) return e.replace(Ur, t);
|
|
3146
3157
|
throw Error("Unable to find MCP tools placeholder or generated block in yoyo-control skill");
|
|
3147
3158
|
}
|
|
3148
|
-
function
|
|
3159
|
+
function Zr(e) {
|
|
3149
3160
|
return e.replaceAll("|", "\\|").replace(/\r?\n/g, " ");
|
|
3150
3161
|
}
|
|
3151
|
-
function
|
|
3162
|
+
function Qr(e) {
|
|
3152
3163
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3153
3164
|
}
|
|
3154
|
-
function
|
|
3165
|
+
function $r(e) {
|
|
3155
3166
|
return e instanceof Error && "code" in e;
|
|
3156
3167
|
}
|
|
3157
3168
|
//#endregion
|
|
3158
3169
|
//#region src/modules/device-toolset/processor.ts
|
|
3159
|
-
var
|
|
3160
|
-
async function
|
|
3170
|
+
var ei = Ct();
|
|
3171
|
+
async function ti(e) {
|
|
3161
3172
|
let t = kr(e), n = wt();
|
|
3162
3173
|
if (!n) throw Error("Unable to resolve home directory for DeviceToolSet persistence");
|
|
3163
3174
|
let i = Ar(t);
|
|
@@ -3172,9 +3183,9 @@ async function ei(e) {
|
|
|
3172
3183
|
O().info(`[yoyoclaw-device-toolset] cache merged, nodeId: ${i.nodeId}, supportedNodes: ${o.nodeCount}, tools: ${o.toolCount}`);
|
|
3173
3184
|
let s = o.cache.tools, c = await ar(n, i.tools);
|
|
3174
3185
|
O().info(`[yoyoclaw-device-toolset] archive refreshed, nodeId: ${i.nodeId}, written: ${c.writtenCount}, skipped: ${c.skippedCount}`);
|
|
3175
|
-
let l = await
|
|
3186
|
+
let l = await Kr(ei, s);
|
|
3176
3187
|
O().info(`[yoyoclaw-device-toolset] skill refreshed, nodeId: ${i.nodeId}, rows: ${l.rowCount}`);
|
|
3177
|
-
let u = await mr(c.archiveDir, r.join(
|
|
3188
|
+
let u = await mr(c.archiveDir, r.join(ei, "skills", "yoyo-control", "mcptools"));
|
|
3178
3189
|
return O().info(`[yoyoclaw-device-toolset] mapping ready, nodeId: ${i.nodeId}, mode: ${u.mode}`), await Dr(n, i.nodeId, a, Date.now()), O().info(`[yoyoclaw-device-toolset] process complete, nodeId: ${i.nodeId}`), {
|
|
3179
3190
|
changed: !0,
|
|
3180
3191
|
nodeId: i.nodeId,
|
|
@@ -3185,7 +3196,7 @@ async function ei(e) {
|
|
|
3185
3196
|
}
|
|
3186
3197
|
//#endregion
|
|
3187
3198
|
//#region src/cloud-channel/message-handler.ts
|
|
3188
|
-
var
|
|
3199
|
+
var ni = { style: "SOUL.md" }, X = "[yoyoclaw-channel]", ri = class {
|
|
3189
3200
|
sessionManager;
|
|
3190
3201
|
adminClientManager;
|
|
3191
3202
|
config;
|
|
@@ -3462,7 +3473,7 @@ var ti = { style: "SOUL.md" }, X = "[yoyoclaw-channel]", ni = class {
|
|
|
3462
3473
|
ok: !1,
|
|
3463
3474
|
error: "Missing content in context payload"
|
|
3464
3475
|
};
|
|
3465
|
-
let r =
|
|
3476
|
+
let r = ni.style, i = await e.setAgentFile(r, n);
|
|
3466
3477
|
return i.ok ? {
|
|
3467
3478
|
ok: !0,
|
|
3468
3479
|
data: { name: "style" }
|
|
@@ -3551,14 +3562,14 @@ var ti = { style: "SOUL.md" }, X = "[yoyoclaw-channel]", ni = class {
|
|
|
3551
3562
|
async updateDeviceToolSetContext(e, t, n) {
|
|
3552
3563
|
return n?.header.namespace === "yoyoclaw" ? {
|
|
3553
3564
|
ok: !0,
|
|
3554
|
-
data: await
|
|
3565
|
+
data: await ti(t),
|
|
3555
3566
|
noReply: !0
|
|
3556
3567
|
} : {
|
|
3557
3568
|
ok: !1,
|
|
3558
3569
|
error: `Unsupported DeviceToolSet namespace: ${n?.header.namespace ?? "unknown"}`
|
|
3559
3570
|
};
|
|
3560
3571
|
}
|
|
3561
|
-
},
|
|
3572
|
+
}, ii = class extends Pn {
|
|
3562
3573
|
nodeOpts;
|
|
3563
3574
|
sessionId;
|
|
3564
3575
|
hardwareDeviceId;
|
|
@@ -3600,7 +3611,7 @@ var ti = { style: "SOUL.md" }, X = "[yoyoclaw-channel]", ni = class {
|
|
|
3600
3611
|
onError(e) {
|
|
3601
3612
|
O().error(`[yoyoclaw-nodeGatewayClient] error for session: ${this.sessionId}, device: ${this.hardwareDeviceId}: ${e.message}`);
|
|
3602
3613
|
}
|
|
3603
|
-
},
|
|
3614
|
+
}, ai = class {
|
|
3604
3615
|
nodeGatewayClientsMap = /* @__PURE__ */ new Map();
|
|
3605
3616
|
deviceSessionsMap = /* @__PURE__ */ new Map();
|
|
3606
3617
|
sessionIdToHardwareDeviceMap = /* @__PURE__ */ new Map();
|
|
@@ -3633,7 +3644,7 @@ var ti = { style: "SOUL.md" }, X = "[yoyoclaw-channel]", ni = class {
|
|
|
3633
3644
|
this.nodeGatewayClientsMap.set(e, t);
|
|
3634
3645
|
}
|
|
3635
3646
|
createNodeGatewayClient(e) {
|
|
3636
|
-
let t = new
|
|
3647
|
+
let t = new ii({
|
|
3637
3648
|
sessionId: e.sessionId,
|
|
3638
3649
|
hardwareDeviceId: e.hardwareDeviceId,
|
|
3639
3650
|
deviceInfo: e.deviceInfo,
|
|
@@ -3665,14 +3676,14 @@ var ti = { style: "SOUL.md" }, X = "[yoyoclaw-channel]", ni = class {
|
|
|
3665
3676
|
getSessionCount() {
|
|
3666
3677
|
return this.sessionIdToHardwareDeviceMap.size;
|
|
3667
3678
|
}
|
|
3668
|
-
},
|
|
3679
|
+
}, oi = class {
|
|
3669
3680
|
cloudClient;
|
|
3670
3681
|
sessionManager;
|
|
3671
3682
|
adminClientManager;
|
|
3672
3683
|
messageHandler;
|
|
3673
3684
|
config;
|
|
3674
3685
|
constructor(e) {
|
|
3675
|
-
this.config = e, this.sessionManager = new
|
|
3686
|
+
this.config = e, this.sessionManager = new ai(), this.adminClientManager = new Kn({ onStatusEvent: this.handleStatusEvent }), this.messageHandler = new ri({
|
|
3676
3687
|
sessionManager: this.sessionManager,
|
|
3677
3688
|
adminClientManager: this.adminClientManager,
|
|
3678
3689
|
config: {
|
|
@@ -3719,7 +3730,7 @@ var ti = { style: "SOUL.md" }, X = "[yoyoclaw-channel]", ni = class {
|
|
|
3719
3730
|
}, Z = {
|
|
3720
3731
|
channel: null,
|
|
3721
3732
|
status: "idle"
|
|
3722
|
-
}, Q = null,
|
|
3733
|
+
}, Q = null, si = (e) => ({
|
|
3723
3734
|
id: "yoyoclaw-connection",
|
|
3724
3735
|
async start() {
|
|
3725
3736
|
O().info("[yoyoclaw] plugin service enabled"), Q = new Cn(!0);
|
|
@@ -3736,7 +3747,7 @@ var ti = { style: "SOUL.md" }, X = "[yoyoclaw-channel]", ni = class {
|
|
|
3736
3747
|
}
|
|
3737
3748
|
try {
|
|
3738
3749
|
let e = await mn();
|
|
3739
|
-
e?.token ? (O().info("[yoyoclaw-conn] token found, creating channel"), await
|
|
3750
|
+
e?.token ? (O().info("[yoyoclaw-conn] token found, creating channel"), await ci(await W(), e)) : O().info("[yoyoclaw-conn] no token found, skipping channel creation");
|
|
3740
3751
|
} catch (e) {
|
|
3741
3752
|
O().error(`[yoyoclaw-conn] failed to initialize connection: ${String(e)}`);
|
|
3742
3753
|
}
|
|
@@ -3745,7 +3756,7 @@ var ti = { style: "SOUL.md" }, X = "[yoyoclaw-channel]", ni = class {
|
|
|
3745
3756
|
$(), O().info("[yoyoclaw-conn] stopping connection service"), Q &&= (await Q.destroy(), null);
|
|
3746
3757
|
}
|
|
3747
3758
|
});
|
|
3748
|
-
async function
|
|
3759
|
+
async function ci(e, t) {
|
|
3749
3760
|
O().info(`[yoyoclaw-conn] creating new channel for device: ${e.deviceId}`), await Xt(e, t);
|
|
3750
3761
|
let n = Z.status;
|
|
3751
3762
|
return Z.status = "connecting", Q && await Q.handleEvent({
|
|
@@ -3756,7 +3767,7 @@ async function si(e, t) {
|
|
|
3756
3767
|
previousStatus: n
|
|
3757
3768
|
}
|
|
3758
3769
|
}), new Promise((n, r) => {
|
|
3759
|
-
Z.channel = new
|
|
3770
|
+
Z.channel = new oi({
|
|
3760
3771
|
deviceInfo: e,
|
|
3761
3772
|
userInfo: t,
|
|
3762
3773
|
onOpen: () => {
|
|
@@ -3787,7 +3798,7 @@ async function si(e, t) {
|
|
|
3787
3798
|
return;
|
|
3788
3799
|
}
|
|
3789
3800
|
try {
|
|
3790
|
-
O().info("[yoyoclaw-conn] attempting to register device"), await Yt(e, t), O().info("[yoyoclaw-conn] device registered successfully, reconnecting..."), $(), await
|
|
3801
|
+
O().info("[yoyoclaw-conn] attempting to register device"), await Yt(e, t), O().info("[yoyoclaw-conn] device registered successfully, reconnecting..."), $(), await ci(e, t);
|
|
3791
3802
|
} catch (e) {
|
|
3792
3803
|
O().error(`[yoyoclaw-conn] device registration failed: ${String(e)}`), O().info("[yoyoclaw-conn] clearing token and destroying channel");
|
|
3793
3804
|
try {
|
|
@@ -3831,14 +3842,14 @@ function $() {
|
|
|
3831
3842
|
}
|
|
3832
3843
|
//#endregion
|
|
3833
3844
|
//#region index.ts
|
|
3834
|
-
var
|
|
3845
|
+
var li = {
|
|
3835
3846
|
id: "yoyo",
|
|
3836
3847
|
name: "YOYOClaw",
|
|
3837
3848
|
description: "OpenClaw Honor Yoyo connection plugin",
|
|
3838
3849
|
configSchema: Mn,
|
|
3839
3850
|
register(e) {
|
|
3840
|
-
ce(e.runtime), _e(e.logger), e.registerService(
|
|
3851
|
+
ce(e.runtime), _e(e.logger), e.registerService(si(e)), e.on("before_prompt_build", async () => ({ prependSystemContext: kn })), On(e);
|
|
3841
3852
|
}
|
|
3842
3853
|
};
|
|
3843
3854
|
//#endregion
|
|
3844
|
-
export {
|
|
3855
|
+
export { li as default };
|