@honor-claw/yoyo 1.4.2-alpha.1 → 1.5.1-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.
@@ -97,7 +97,7 @@ var r = { style: "SOUL.md" }, i = "[yoyoclaw-channel]", a = class {
97
97
  return;
98
98
  }
99
99
  let r = this.sessionManager.getHardwareDeviceId(n);
100
- if (!r) {
100
+ if (e().info(`${i} received user message, session: ${n}, hardware device: ${r}`), !r) {
101
101
  e().warn(`${i} user message missing hardwareDeviceId, session: ${n}`);
102
102
  return;
103
103
  }
@@ -1,7 +1,7 @@
1
1
  import e from "./assets/favicon.mjs";
2
2
  import { ASSET_URLS as t, getResultHtml as n } from "./auth-result-html.mjs";
3
- import { createServer as r } from "http";
4
- import { URL as i } from "node:url";
3
+ import { URL as r } from "node:url";
4
+ import { createServer as i } from "http";
5
5
  //#region src/honor-auth/callback-server.ts
6
6
  var a = { "favicon.png": e };
7
7
  function o(e, t) {
@@ -26,11 +26,11 @@ function s(e) {
26
26
  setTimeout(() => {
27
27
  g();
28
28
  }, e);
29
- }, y = r((e, r) => {
29
+ }, y = i((e, i) => {
30
30
  try {
31
- let a = new i(e.url || "", `http://localhost:${c}`);
31
+ let a = new r(e.url || "", `http://localhost:${c}`);
32
32
  if (e.method !== "GET") {
33
- r.writeHead(405, { "Content-Type": "text/html; charset=utf-8" }), r.end(n({
33
+ i.writeHead(405, { "Content-Type": "text/html; charset=utf-8" }), i.end(n({
34
34
  pageTitle: "请求方式不支持",
35
35
  statusClass: "error",
36
36
  title: "不支持的请求方式",
@@ -39,16 +39,16 @@ function s(e) {
39
39
  return;
40
40
  }
41
41
  if (a.pathname === "/favicon.ico" || a.pathname === t.favicon) {
42
- o(r, "favicon.png");
42
+ o(i, "favicon.png");
43
43
  return;
44
44
  }
45
45
  let s = a.searchParams.get("code") || "", l = a.searchParams.get("error") || "", d = a.searchParams.get("error_description") || a.searchParams.get("error_message") || "";
46
- s && !m ? (m = !0, r.writeHead(200, { "Content-Type": "text/html; charset=utf-8" }), r.end(n({
46
+ s && !m ? (m = !0, i.writeHead(200, { "Content-Type": "text/html; charset=utf-8" }), i.end(n({
47
47
  pageTitle: "授权成功",
48
48
  statusClass: "success",
49
49
  title: "登录已完成",
50
50
  hintText: "请返回 OpenClaw,登录流程会继续完成。"
51
- })), v(), u(s)) : l && !m ? (r.writeHead(400, { "Content-Type": "text/html; charset=utf-8" }), r.end(n({
51
+ })), v(), u(s)) : l && !m ? (i.writeHead(400, { "Content-Type": "text/html; charset=utf-8" }), i.end(n({
52
52
  pageTitle: "授权失败",
53
53
  statusClass: "error",
54
54
  title: "未能完成授权",
@@ -62,12 +62,12 @@ function s(e) {
62
62
  }] : []]
63
63
  })), setTimeout(() => {
64
64
  _(/* @__PURE__ */ Error(d ? `authorization failed: ${l} (${d})` : `authorization failed: ${l}`));
65
- }, 120)) : m ? (r.writeHead(200, { "Content-Type": "text/html; charset=utf-8" }), r.end(n({
65
+ }, 120)) : m ? (i.writeHead(200, { "Content-Type": "text/html; charset=utf-8" }), i.end(n({
66
66
  pageTitle: "登录已完成",
67
67
  statusClass: "success",
68
68
  title: "授权已经处理完成",
69
69
  hintText: "请返回 OpenClaw,登录流程会继续完成。"
70
- }))) : (r.writeHead(400, { "Content-Type": "text/html; charset=utf-8" }), r.end(n({
70
+ }))) : (i.writeHead(400, { "Content-Type": "text/html; charset=utf-8" }), i.end(n({
71
71
  pageTitle: "授权失败",
72
72
  statusClass: "error",
73
73
  title: "回调参数不完整",
@@ -76,7 +76,7 @@ function s(e) {
76
76
  _(/* @__PURE__ */ Error("authorization failed: no code in callback"));
77
77
  }, 120));
78
78
  } catch (e) {
79
- console.error("authorize callback error:", e), r.writeHead(500, { "Content-Type": "text/html; charset=utf-8" }), r.end(n({
79
+ console.error("authorize callback error:", e), i.writeHead(500, { "Content-Type": "text/html; charset=utf-8" }), i.end(n({
80
80
  pageTitle: "服务异常",
81
81
  statusClass: "error",
82
82
  title: "回调服务出现异常",
@@ -22,12 +22,15 @@ 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 || !n(t.params.path))) try {
25
+ if (!(t.toolName !== "read" || t.error || !u(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
+ function u(e) {
33
+ return n(e.path) || n(e.file_path);
34
+ }
32
35
  //#endregion
33
36
  export { s as registerHooks };
@@ -5,8 +5,9 @@ import { getEnvFromProcessEnv as r } from "../../utils/env.mjs";
5
5
  import { wrapError as i } from "../../utils/error.mjs";
6
6
  import { useClawLogger as a } from "../../utils/logger.mjs";
7
7
  import { detectProvidersToRename as o, updateProviderReferences as s } from "./provider.mjs";
8
+ import { STATE_FLAG as c, hasPersistedStateFlag as l, markPersistedStateFlag as u } from "./state-flags.mjs";
8
9
  //#region src/modules/configs/config-manager.ts
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 {
10
+ var d = "yoyo", f = /* @__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(","), p = class {
10
11
  loadConfig() {
11
12
  try {
12
13
  return t().config.loadConfig();
@@ -44,7 +45,7 @@ var c = "yoyo", l = { watch: !0 }, u = 250, d = /* @__PURE__ */ "alarm.create,al
44
45
  }
45
46
  getUserConfig() {
46
47
  try {
47
- return this.loadConfig().plugins?.entries?.[c]?.config?.user;
48
+ return this.loadConfig().plugins?.entries?.[d]?.config?.user;
48
49
  } catch (e) {
49
50
  console.error(`[claw-configs] Failed to read user config: ${e}`);
50
51
  return;
@@ -52,7 +53,7 @@ var c = "yoyo", l = { watch: !0 }, u = 250, d = /* @__PURE__ */ "alarm.create,al
52
53
  }
53
54
  getEnvInfo() {
54
55
  try {
55
- let e = this.loadConfig().plugins?.entries?.[c]?.config, t = e?.envInfo;
56
+ let e = this.loadConfig().plugins?.entries?.[d]?.config, t = e?.envInfo;
56
57
  if (t?.env) return t;
57
58
  let n = e?.env;
58
59
  if (n) return {
@@ -76,7 +77,7 @@ var c = "yoyo", l = { watch: !0 }, u = 250, d = /* @__PURE__ */ "alarm.create,al
76
77
  }
77
78
  getGrayTag() {
78
79
  try {
79
- return this.loadConfig().plugins?.entries?.[c]?.config?.gray;
80
+ return this.loadConfig().plugins?.entries?.[d]?.config?.gray;
80
81
  } catch (e) {
81
82
  console.error(`[claw-configs] Failed to read gray tag config: ${e}`);
82
83
  return;
@@ -84,7 +85,7 @@ var c = "yoyo", l = { watch: !0 }, u = 250, d = /* @__PURE__ */ "alarm.create,al
84
85
  }
85
86
  getDeviceConfig() {
86
87
  try {
87
- return this.loadConfig().plugins?.entries?.[c]?.config?.device;
88
+ return this.loadConfig().plugins?.entries?.[d]?.config?.device;
88
89
  } catch (e) {
89
90
  console.error(`[claw-configs] Failed to read device config: ${e}`);
90
91
  return;
@@ -92,17 +93,17 @@ var c = "yoyo", l = { watch: !0 }, u = 250, d = /* @__PURE__ */ "alarm.create,al
92
93
  }
93
94
  async updateDeviceConfig(e) {
94
95
  try {
95
- let t = this.loadConfig(), n = t.plugins?.entries?.[c]?.config?.device || {}, r = {
96
+ let t = this.loadConfig(), n = t.plugins?.entries?.[d]?.config?.device || {}, r = {
96
97
  ...t,
97
98
  plugins: {
98
99
  ...t.plugins,
99
100
  entries: {
100
101
  ...t.plugins?.entries,
101
- [c]: {
102
- ...t.plugins?.entries?.[c],
102
+ [d]: {
103
+ ...t.plugins?.entries?.[d],
103
104
  enabled: !0,
104
105
  config: {
105
- ...t.plugins?.entries?.[c]?.config,
106
+ ...t.plugins?.entries?.[d]?.config,
106
107
  device: {
107
108
  ...n,
108
109
  ...e
@@ -125,11 +126,11 @@ var c = "yoyo", l = { watch: !0 }, u = 250, d = /* @__PURE__ */ "alarm.create,al
125
126
  ...t.plugins,
126
127
  entries: {
127
128
  ...t.plugins?.entries,
128
- [c]: {
129
- ...t.plugins?.entries?.[c],
129
+ [d]: {
130
+ ...t.plugins?.entries?.[d],
130
131
  enabled: !0,
131
132
  config: {
132
- ...t.plugins?.entries?.[c]?.config,
133
+ ...t.plugins?.entries?.[d]?.config,
133
134
  envInfo: {
134
135
  env: e,
135
136
  source: "manual"
@@ -147,7 +148,7 @@ var c = "yoyo", l = { watch: !0 }, u = 250, d = /* @__PURE__ */ "alarm.create,al
147
148
  }
148
149
  async resetEnv() {
149
150
  try {
150
- let e = this.loadConfig(), t = e.plugins?.entries?.[c]?.config?.envInfo;
151
+ let e = this.loadConfig(), t = e.plugins?.entries?.[d]?.config?.envInfo;
151
152
  if (!t?.env) return;
152
153
  let n = {
153
154
  ...e,
@@ -155,11 +156,11 @@ var c = "yoyo", l = { watch: !0 }, u = 250, d = /* @__PURE__ */ "alarm.create,al
155
156
  ...e.plugins,
156
157
  entries: {
157
158
  ...e.plugins?.entries,
158
- [c]: {
159
- ...e.plugins?.entries?.[c],
159
+ [d]: {
160
+ ...e.plugins?.entries?.[d],
160
161
  enabled: !0,
161
162
  config: {
162
- ...e.plugins?.entries?.[c]?.config,
163
+ ...e.plugins?.entries?.[d]?.config,
163
164
  envInfo: {
164
165
  env: t.env,
165
166
  source: "env"
@@ -182,11 +183,11 @@ var c = "yoyo", l = { watch: !0 }, u = 250, d = /* @__PURE__ */ "alarm.create,al
182
183
  ...t.plugins,
183
184
  entries: {
184
185
  ...t.plugins?.entries,
185
- [c]: {
186
- ...t.plugins?.entries?.[c],
186
+ [d]: {
187
+ ...t.plugins?.entries?.[d],
187
188
  enabled: !0,
188
189
  config: {
189
- ...t.plugins?.entries?.[c]?.config,
190
+ ...t.plugins?.entries?.[d]?.config,
190
191
  ...e && { gray: e }
191
192
  }
192
193
  }
@@ -206,11 +207,11 @@ var c = "yoyo", l = { watch: !0 }, u = 250, d = /* @__PURE__ */ "alarm.create,al
206
207
  ...t.plugins,
207
208
  entries: {
208
209
  ...t.plugins?.entries,
209
- [c]: {
210
- ...t.plugins?.entries?.[c],
210
+ [d]: {
211
+ ...t.plugins?.entries?.[d],
211
212
  enabled: !0,
212
213
  config: {
213
- ...t.plugins?.entries?.[c]?.config,
214
+ ...t.plugins?.entries?.[d]?.config,
214
215
  user: e
215
216
  }
216
217
  }
@@ -230,10 +231,10 @@ var c = "yoyo", l = { watch: !0 }, u = 250, d = /* @__PURE__ */ "alarm.create,al
230
231
  ...e.plugins,
231
232
  entries: {
232
233
  ...e.plugins?.entries,
233
- [c]: {
234
- ...e.plugins?.entries?.[c],
234
+ [d]: {
235
+ ...e.plugins?.entries?.[d],
235
236
  config: {
236
- ...e.plugins?.entries?.[c]?.config,
237
+ ...e.plugins?.entries?.[d]?.config,
237
238
  user: void 0
238
239
  }
239
240
  }
@@ -247,30 +248,26 @@ var c = "yoyo", l = { watch: !0 }, u = 250, d = /* @__PURE__ */ "alarm.create,al
247
248
  }
248
249
  async initializePluginConfig(t) {
249
250
  try {
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"),
251
+ let i = this.loadConfig(), d = i.skills || {}, p = d.load || {}, m = p.watch === !0, h = !m || await l(c.DISABLE_SKILLS_LOAD_WATCH_MIGRATION_DONE), g = i.plugins?.allow || [], _ = !g.includes(t), v = g.includes(t) ? g : [...g, t], y = i.gateway?.nodes?.allowCommands || [], b = Array.from(new Set([...y, ...f])), x = !n(y, b), S = m && !h, C = i.plugins?.entries?.[t]?.config?.envInfo, w = i.plugins?.entries?.[t]?.config?.env, T = !!(C?.env || w), E = r(), D = !!C?.env && C.source === "env", O = !C?.env && !!w || D && E && C.env !== E, k = !T || O, A = {
252
+ env: E || w || (e() ? "test" : "production"),
256
253
  source: "env"
257
- }, k = i.plugins?.entries?.[t]?.config || {}, A = D ? {
258
- ...k,
259
- envInfo: O,
254
+ }, j = i.plugins?.entries?.[t]?.config || {}, M = k ? {
255
+ ...j,
256
+ envInfo: A,
260
257
  env: void 0
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 = {
258
+ } : j, N = i.plugins?.entries?.[t]?.enabled !== !0, P = o(i), F = Object.keys(P).length > 0;
259
+ if (F && a().info(`[claw-configs] Found ${Object.keys(P).length} providers to rename: ${Object.entries(P).map(([e, t]) => `${e} -> ${t}`).join(", ")}`), !_ && !x && !S && !k && !N && !F) return;
260
+ let I = {
264
261
  ...i,
265
262
  plugins: {
266
263
  ...i.plugins,
267
- allow: p,
264
+ allow: v,
268
265
  entries: {
269
266
  ...i.plugins?.entries,
270
267
  [t]: {
271
268
  ...i.plugins?.entries?.[t],
272
269
  enabled: !0,
273
- config: A
270
+ config: M
274
271
  }
275
272
  }
276
273
  },
@@ -278,22 +275,27 @@ var c = "yoyo", l = { watch: !0 }, u = 250, d = /* @__PURE__ */ "alarm.create,al
278
275
  ...i.gateway,
279
276
  nodes: {
280
277
  ...i.gateway?.nodes,
281
- allowCommands: h
278
+ allowCommands: b
282
279
  }
283
- },
284
- skills: {
285
- ..._,
286
- load: b
287
280
  }
288
281
  };
289
- N && (P = s(P, M), a().info("[claw-configs] Provider renaming completed")), await this.saveConfig(P);
282
+ S && (I = {
283
+ ...I,
284
+ skills: {
285
+ ...d,
286
+ load: {
287
+ ...p,
288
+ watch: !1
289
+ }
290
+ }
291
+ }, a().info("[claw-configs] Disabled skills.load.watch for yoyo migration")), F && (I = s(I, P), a().info("[claw-configs] Provider renaming completed")), await this.saveConfig(I), S && await u(c.DISABLE_SKILLS_LOAD_WATCH_MIGRATION_DONE);
290
292
  } catch (e) {
291
293
  throw i(e, "failed to initialize plugin config");
292
294
  }
293
295
  }
294
- }, p = null;
295
- function m() {
296
- return p ||= new f(), p;
296
+ }, m = null;
297
+ function h() {
298
+ return m ||= new p(), m;
297
299
  }
298
300
  //#endregion
299
- export { f as ConfigManager, m as getConfigManager };
301
+ export { p as ConfigManager, h as getConfigManager };
@@ -1,2 +1,3 @@
1
+ import "./state-flags.mjs";
1
2
  import "./config-manager.mjs";
2
3
  import "./identity-persist.mjs";
@@ -0,0 +1,66 @@
1
+ import { useClawLogger as e } from "../../utils/logger.mjs";
2
+ import { SafeFsError as t, safeReadFile as n, safeWriteFile as r } from "../../utils/fs-safe.mjs";
3
+ import { resolveEffectiveHomeDir as i } from "../../utils/home-dir.mjs";
4
+ import a from "node:path";
5
+ //#region src/modules/configs/state-flags.ts
6
+ var o = { DISABLE_SKILLS_LOAD_WATCH_MIGRATION_DONE: "disableSkillsLoadWatchMigrationDone" }, s = ".openclaw", c = "yoyo", l = "state.json", u = 64 * 1024;
7
+ function d() {
8
+ return a.join(s, c, l);
9
+ }
10
+ async function f(r) {
11
+ try {
12
+ let e = await n({
13
+ rootDir: r,
14
+ relativePath: d(),
15
+ maxBytes: u
16
+ });
17
+ return v(JSON.parse(e.buffer.toString("utf8")));
18
+ } catch (n) {
19
+ return n instanceof t && n.code === "not-found" || e().warn(`[yoyo-state] failed to read state: ${String(n)}`), null;
20
+ }
21
+ }
22
+ async function p() {
23
+ let t = i();
24
+ return t ? f(t) : (e().warn("[yoyo-state] failed to find home dir"), null);
25
+ }
26
+ async function m(t) {
27
+ let n = i();
28
+ if (!n) return e().warn("[yoyo-state] failed to find home dir"), null;
29
+ let a = {
30
+ ...await f(n) ?? _(),
31
+ version: 1
32
+ };
33
+ return t.flags && (a.flags = {
34
+ ...a.flags,
35
+ ...y(t.flags)
36
+ }), await r({
37
+ rootDir: n,
38
+ relativePath: d(),
39
+ data: JSON.stringify(a, null, 2),
40
+ encoding: "utf8",
41
+ mkdir: !0
42
+ }), a;
43
+ }
44
+ async function h(e) {
45
+ return (await p())?.flags?.[e] === !0;
46
+ }
47
+ async function g(e) {
48
+ return m({ flags: { [e]: !0 } });
49
+ }
50
+ function _() {
51
+ return { version: 1 };
52
+ }
53
+ function v(e) {
54
+ return !e || typeof e != "object" || Array.isArray(e) ? _() : {
55
+ ..._(),
56
+ flags: y(e.flags)
57
+ };
58
+ }
59
+ function y(e) {
60
+ if (!e || typeof e != "object" || Array.isArray(e)) return;
61
+ let t = {};
62
+ for (let [n, r] of Object.entries(e)) typeof r == "boolean" && (t[n] = r);
63
+ return Object.keys(t).length > 0 ? t : void 0;
64
+ }
65
+ //#endregion
66
+ export { o as STATE_FLAG, p as getPersistedPluginState, h as hasPersistedStateFlag, g as markPersistedStateFlag, m as updatePersistedPluginState };
@@ -1,34 +1,45 @@
1
- import { safeWriteFile as e } from "../../utils/fs-safe.mjs";
2
- import { INVALID_TOOL_FILENAME_CHAR_PATTERN as t, TOOL_ARCHIVE_DIR as n } from "./consts.mjs";
3
- import r from "node:path";
1
+ import { hasNodeErrorCode as e } from "../../utils/error.mjs";
2
+ import { safeWriteFile as t } from "../../utils/fs-safe.mjs";
3
+ import { INVALID_TOOL_FILENAME_CHAR_PATTERN as n, TOOL_ARCHIVE_DIR as r } from "./consts.mjs";
4
+ import i from "node:path";
5
+ import a from "node:fs/promises";
4
6
  //#region src/modules/device-toolset/archive.ts
5
- async function i(t, i) {
6
- let s = 0;
7
- for (let a of i) {
8
- let i = o(a.name);
9
- i && (await e({
10
- rootDir: t,
11
- relativePath: r.join(n, i),
12
- data: JSON.stringify(a, null, 2),
7
+ async function o(e, n) {
8
+ let a = 0, o = await c(e);
9
+ for (let o of n) {
10
+ let n = l(o.name);
11
+ n && (await t({
12
+ rootDir: e,
13
+ relativePath: i.join(r, n),
14
+ data: JSON.stringify(o, null, 2),
13
15
  encoding: "utf8",
14
16
  mkdir: !0
15
- }), s += 1);
17
+ }), a += 1);
16
18
  }
17
19
  return {
18
- archiveDir: a(t),
19
- writtenCount: s
20
+ archiveDir: s(e),
21
+ writtenCount: a,
22
+ createdArchiveDir: !o && a > 0
20
23
  };
21
24
  }
22
- function a(e) {
23
- return r.join(e, n);
25
+ function s(e) {
26
+ return i.join(e, r);
27
+ }
28
+ async function c(t) {
29
+ try {
30
+ return (await a.stat(s(t))).isDirectory();
31
+ } catch (t) {
32
+ if (e(t, "ENOENT", "ENOTDIR")) return !1;
33
+ throw t;
34
+ }
24
35
  }
25
- function o(e) {
26
- let n = e.trim();
27
- if (!(!n || t.test(n) || s(n))) return `${n}.json`;
36
+ function l(e) {
37
+ let t = e.trim();
38
+ if (!(!t || n.test(t) || u(t))) return `${t}.json`;
28
39
  }
29
- function s(e) {
40
+ function u(e) {
30
41
  for (let t of e) if (t.codePointAt(0) < 32) return !0;
31
42
  return !1;
32
43
  }
33
44
  //#endregion
34
- export { i as refreshToolArchive, a as resolveToolArchiveDir };
45
+ export { o as refreshToolArchive, s as resolveToolArchiveDir };
@@ -1,43 +1,43 @@
1
1
  import { useClawLogger as e } from "../../utils/logger.mjs";
2
2
  import { resolveEffectiveHomeDir as t, resolveExtensionRoot as n } from "../../utils/home-dir.mjs";
3
- import { clearYoyoControlSkillReadMarker as r } from "./skill-refresh-marker.mjs";
4
- import { refreshToolArchive as i } from "./archive.mjs";
5
- import { ensureMcpToolsMapping as a, resolveMcpToolsTargetDir as o } from "./link.mjs";
6
- import { mergeDeviceToolSetCache as s } from "./persist.mjs";
7
- import { refreshYoyoControlSkill as c } from "./skill-inject.mjs";
8
- import { ensureDeviceToolSetArtifacts as l } from "./artifacts.mjs";
9
- import { computeDeviceToolSetMd5 as u, getDeviceToolSetChangeState as d, writeToolSetMd5Entry as f } from "./md5-index.mjs";
10
- import { assertDeviceToolSetPayload as p, normalizeDeviceToolSet as m } from "./normalize.mjs";
3
+ import { clearYoyoControlSkillReadMarker as r, markYoyoControlSkillRead as i } from "./skill-refresh-marker.mjs";
4
+ import { refreshToolArchive as a } from "./archive.mjs";
5
+ import { ensureMcpToolsMapping as o, resolveMcpToolsTargetDir as s } from "./link.mjs";
6
+ import { mergeDeviceToolSetCache as c } from "./persist.mjs";
7
+ import { refreshYoyoControlSkill as l } from "./skill-inject.mjs";
8
+ import { ensureDeviceToolSetArtifacts as u } from "./artifacts.mjs";
9
+ import { computeDeviceToolSetMd5 as d, getDeviceToolSetChangeState as f, writeToolSetMd5Entry as p } from "./md5-index.mjs";
10
+ import { assertDeviceToolSetPayload as m, normalizeDeviceToolSet as h } from "./normalize.mjs";
11
11
  //#region src/modules/device-toolset/processor.ts
12
- var h = n();
13
- async function g(n) {
14
- let g = p(n), _ = t();
15
- if (!_) throw Error("Unable to resolve home directory for DeviceToolSet persistence");
16
- let v = m(g);
17
- e().info(`[yoyoclaw-device-toolset] process start, nodeId: ${v.nodeId}, raw: ${g.toolSet.length}, valid: ${v.tools.length}`);
18
- let y = u(v.tools);
19
- if (e().debug?.(`[yoyoclaw-device-toolset] computed md5, nodeId: ${v.nodeId}, md5: ${y}`), !(await d(_, v.nodeId, y)).changed) {
20
- let t = await l(_, h);
21
- return e().info(`[yoyoclaw-device-toolset] unchanged, skip refresh, nodeId: ${v.nodeId}, artifactsRestored: ${t.restored}`), {
12
+ var g = n();
13
+ async function _(n) {
14
+ let _ = m(n), v = t();
15
+ if (!v) throw Error("Unable to resolve home directory for DeviceToolSet persistence");
16
+ let y = h(_);
17
+ e().info(`[yoyoclaw-device-toolset] process start, nodeId: ${y.nodeId}, raw: ${_.toolSet.length}, valid: ${y.tools.length}`);
18
+ let b = d(y.tools);
19
+ if (e().debug?.(`[yoyoclaw-device-toolset] computed md5, nodeId: ${y.nodeId}, md5: ${b}`), !(await f(v, y.nodeId, b)).changed) {
20
+ let t = await u(v, g);
21
+ return e().info(`[yoyoclaw-device-toolset] unchanged, skip refresh, nodeId: ${y.nodeId}, artifactsRestored: ${t.restored}`), {
22
22
  changed: !1,
23
- nodeId: v.nodeId,
24
- rawCount: g.toolSet.length,
25
- validCount: v.tools.length
23
+ nodeId: y.nodeId,
24
+ rawCount: _.toolSet.length,
25
+ validCount: y.tools.length
26
26
  };
27
27
  }
28
- let b = await s(_, v.nodeId, v.tools);
29
- e().info(`[yoyoclaw-device-toolset] cache merged, nodeId: ${v.nodeId}, processed: ${v.tools.length}`);
30
- let x = b.cache.tools, S = await i(_, v.tools);
31
- e().info(`[yoyoclaw-device-toolset] archive refreshed, nodeId: ${v.nodeId}, written: ${S.writtenCount}`);
32
- let C = await c(h, x);
33
- e().info(`[yoyoclaw-device-toolset] skill refreshed, nodeId: ${v.nodeId}, rows: ${C.rowCount}, updated: ${C.updated}`), C.updated && await r(h, v.nodeId);
34
- let w = await a(S.archiveDir, o(h));
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}`), {
28
+ let x = await c(v, y.nodeId, y.tools);
29
+ e().info(`[yoyoclaw-device-toolset] cache merged, nodeId: ${y.nodeId}, processed: ${y.tools.length}`);
30
+ let S = x.cache.tools, C = await a(v, y.tools);
31
+ e().info(`[yoyoclaw-device-toolset] archive refreshed, nodeId: ${y.nodeId}, written: ${C.writtenCount}, createdArchiveDir: ${C.createdArchiveDir}`);
32
+ let w = await l(g, S);
33
+ e().info(`[yoyoclaw-device-toolset] skill refreshed, nodeId: ${y.nodeId}, rows: ${w.rowCount}, updated: ${w.updated}`), C.createdArchiveDir ? await i(g, "clean_install") : w.updated && await r(g, y.nodeId);
34
+ let T = await o(C.archiveDir, s(g));
35
+ return e().info(`[yoyoclaw-device-toolset] mapping ready, nodeId: ${y.nodeId}, mode: ${T.mode}`), await p(v, y.nodeId, b, Date.now()), e().info(`[yoyoclaw-device-toolset] process complete, nodeId: ${y.nodeId}`), {
36
36
  changed: !0,
37
- nodeId: v.nodeId,
38
- rawCount: g.toolSet.length,
39
- validCount: v.tools.length
37
+ nodeId: y.nodeId,
38
+ rawCount: _.toolSet.length,
39
+ validCount: y.tools.length
40
40
  };
41
41
  }
42
42
  //#endregion
43
- export { g as processDeviceToolSet };
43
+ export { _ as processDeviceToolSet };
@@ -1,38 +1,39 @@
1
- import { MCP_TOOLS_END_MARKER as e, MCP_TOOLS_PLACEHOLDER as t, MCP_TOOLS_START_MARKER as n, YOYO_CONTROL_SKILL_RELATIVE_PATH as r, YOYO_CONTROL_SUB_SKILLS_RELATIVE_PATH as i } from "./consts.mjs";
2
- import a from "node:path";
3
- import o from "node:fs/promises";
1
+ import { hasNodeErrorCode as e } from "../../utils/error.mjs";
2
+ import { MCP_TOOLS_END_MARKER as t, MCP_TOOLS_PLACEHOLDER as n, MCP_TOOLS_START_MARKER as r, YOYO_CONTROL_SKILL_RELATIVE_PATH as i, YOYO_CONTROL_SUB_SKILLS_RELATIVE_PATH as a } from "./consts.mjs";
3
+ import o from "node:path";
4
+ import s from "node:fs/promises";
4
5
  //#region src/modules/device-toolset/skill-inject.ts
5
- async function s(e, t) {
6
- let n = a.join(e, r), i = await o.readFile(n, "utf8"), s = l(t, await c(e)), p = f(i, u(s));
7
- return p !== i && await o.writeFile(n, p, "utf8"), {
6
+ async function c(e, t) {
7
+ let n = o.join(e, i), r = await s.readFile(n, "utf8"), a = u(t, await l(e)), c = p(r, d(a));
8
+ return c !== r && await s.writeFile(n, c, "utf8"), {
8
9
  skillPath: n,
9
- rowCount: d(s).length,
10
- updated: p !== i
10
+ rowCount: f(a).length,
11
+ updated: c !== r
11
12
  };
12
13
  }
13
- async function c(e) {
14
- let t = a.join(e, i), n;
14
+ async function l(t) {
15
+ let n = o.join(t, a), r;
15
16
  try {
16
- n = await o.readFile(t, "utf8");
17
- } catch (e) {
18
- if (h(e) && e.code === "ENOENT") return /* @__PURE__ */ new Set();
19
- throw e;
17
+ r = await s.readFile(n, "utf8");
18
+ } catch (t) {
19
+ if (e(t, "ENOENT")) return /* @__PURE__ */ new Set();
20
+ throw t;
20
21
  }
21
- let r = JSON.parse(n);
22
- if (!Array.isArray(r) || r.some((e) => typeof e != "string")) throw Error("sub-skills config must be a JSON array of tool names");
23
- return new Set(r.map((e) => e.trim()).filter(Boolean));
22
+ let i = JSON.parse(r);
23
+ if (!Array.isArray(i) || i.some((e) => typeof e != "string")) throw Error("sub-skills config must be a JSON array of tool names");
24
+ return new Set(i.map((e) => e.trim()).filter(Boolean));
24
25
  }
25
- function l(e, t) {
26
+ function u(e, t) {
26
27
  return t.size === 0 ? e : Object.fromEntries(Object.entries(e).filter(([e, n]) => !t.has(e) && !t.has(n.name)));
27
28
  }
28
- function u(t) {
29
+ function d(e) {
29
30
  return [
30
- n,
31
- ...d(t).map((e) => `| ${p(e.name)} | ${p(e.description)} | ${p(e.nodeId)} |`),
32
- e
31
+ r,
32
+ ...f(e).map((e) => `| ${m(e.name)} | ${m(e.description)} | ${m(e.nodeId)} |`),
33
+ t
33
34
  ].join("\n");
34
35
  }
35
- function d(e) {
36
+ function f(e) {
36
37
  return Object.values(e).flatMap((e) => e.supportedNodeIds.map((t) => ({
37
38
  name: e.name,
38
39
  description: e.description,
@@ -42,20 +43,17 @@ function d(e) {
42
43
  return n === 0 ? e.nodeId.localeCompare(t.nodeId) : n;
43
44
  });
44
45
  }
45
- function f(r, i) {
46
- let a = RegExp(`${m(n)}[\\s\\S]*?${m(e)}`);
47
- if (a.test(r)) return r.replace(a, i);
48
- if (r.includes("{{full-mcp-tool-list}}")) return r.replace(t, i);
46
+ function p(e, i) {
47
+ let a = RegExp(`${h(r)}[\\s\\S]*?${h(t)}`);
48
+ if (a.test(e)) return e.replace(a, i);
49
+ if (e.includes("{{full-mcp-tool-list}}")) return e.replace(n, i);
49
50
  throw Error("Unable to find MCP tools placeholder or generated block in yoyo-control skill");
50
51
  }
51
- function p(e) {
52
- return e.replaceAll("|", "\\|").replace(/\r?\n/g, " ");
53
- }
54
52
  function m(e) {
55
- return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
53
+ return e.replaceAll("|", "\\|").replace(/\r?\n/g, " ");
56
54
  }
57
55
  function h(e) {
58
- return e instanceof Error && "code" in e;
56
+ return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
59
57
  }
60
58
  //#endregion
61
- export { s as refreshYoyoControlSkill };
59
+ export { c as refreshYoyoControlSkill };