@honor-claw/yoyo 1.6.1-beta.2 → 1.6.1-beta.3

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.
@@ -1,17 +1,18 @@
1
1
  import { useClawLogger as e } from "../utils/logger.mjs";
2
- import { loadOrCreateDeviceIdentity as t } from "../modules/device/identity.mjs";
3
- import { buildDeviceAuthCredential as n } from "../modules/device/credential-builder.mjs";
4
- import { GatewayClient as r } from "./client.mjs";
5
- import { ErrorCodes as i, GATEWAY_CLIENT_IDS as a, GATEWAY_CLIENT_MODES as o, WebSocketClientError as s } from "./types/client.mjs";
6
- import { randomUUID as c } from "node:crypto";
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 l = {
9
+ var u = {
9
10
  role: "operator",
10
11
  scopes: [],
11
- clientId: a.CLI,
12
+ clientId: o.CLI,
12
13
  displayName: "Protocol Client",
13
- clientMode: o.CLI
14
- }, u = 3e4, d = "1.0.0", f = "server", p = 2, m = 1e3, h = class extends r {
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
- ...l,
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: i.UNKNOWN,
71
+ code: a.UNKNOWN,
71
72
  message: "Unknown error"
72
73
  };
73
- t.reject(new s(this.toErrorCode(n.code), n.message, n.details, n.retryable));
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 ?? o.CLI, r = await t(), i = this.connectNonce ? n({
78
- deviceIdentity: r,
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: f
87
- }) : void 0, a = {
88
- minProtocol: 4,
89
- maxProtocol: 4,
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: d,
94
+ version: f,
94
95
  platform: process.platform,
95
- deviceFamily: f,
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: i
105
+ device: a
105
106
  };
106
- this.sendRequest("connect", a).then((e) => {
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 s ? this.protocolOpts.onClose?.(`auth failed: [${e.code}] ${e.message}`) : this.protocolOpts.onClose?.(`auth failed: ${e.message}`);
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 = c();
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, a) => {
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: a
128
+ reject: i
128
129
  });
129
130
  try {
130
131
  this.send(JSON.stringify(o));
131
132
  } catch (e) {
132
- this.pendingRequests.delete(n), a(new s(i.CONNECTION_FAILED, `WebSocket is not connected, ${JSON.stringify(e)}`));
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 c = setTimeout(() => {
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), a(new s(i.TIMEOUT, `Request timeout: ${e}`));
140
+ t && clearTimeout(t), this.pendingTimers.delete(n), i(new c(a.TIMEOUT, `Request timeout: ${e}`));
140
141
  }
141
- }, u);
142
- this.pendingTimers.set(n, c);
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(i).includes(e) ? e : i.UNKNOWN;
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 >= p) {
174
- e().error(`[protocol-gateway] max reconnect attempts (${p}) reached, giving up`), this.protocolOpts.onReconnectFailed?.();
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}/${p})`), this.reconnectTimer = setTimeout(() => {
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
- }, m);
180
+ }, h);
180
181
  }
181
182
  }
182
183
  };
183
184
  //#endregion
184
- export { h as ProtocolGatewayClient };
185
+ export { g as ProtocolGatewayClient };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { setYoyoRuntime as e } from "./runtime.mjs";
2
- import { setClawLogger as t } from "./utils/logger.mjs";
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
- e(i.runtime), t(i.logger), i.registerService(a(i)), r(i), n(i);
15
+ t(i.runtime), e(i.logger), i.registerService(a(i)), r(i), n(i);
16
16
  }
17
17
  };
18
18
  //#endregion
@@ -1,34 +1,34 @@
1
- import { isBetaVersion as e } from "../../utils/version.mjs";
2
- import { getYoyoRuntime as t } from "../../runtime.mjs";
3
- import { areStringArraysEqual as n } from "../../utils/array.mjs";
4
- import { getEnvFromProcessEnv as r } from "../../utils/env.mjs";
5
- import { wrapError as i } from "../../utils/error.mjs";
6
- import { useClawLogger as a } from "../../utils/logger.mjs";
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";
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 { STATE_FLAG as o, hasPersistedStateFlag as s, markPersistedStateFlag as c } from "./state-flags.mjs";
7
+ import { getYoyoRuntime as l } from "../../runtime.mjs";
8
+ import { isBetaVersion as u } from "../../utils/version.mjs";
9
9
  //#region src/modules/configs/config-manager.ts
10
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,task_result_query".split(","), p = class {
11
11
  loadConfig() {
12
12
  try {
13
- let e = t().config, n = e.current;
14
- return typeof n == "function" ? structuredClone(n()) : structuredClone(e.loadConfig());
13
+ let e = l().config, t = e.current;
14
+ return typeof t == "function" ? structuredClone(t()) : structuredClone(e.loadConfig());
15
15
  } catch (e) {
16
- throw i(e, "Failed to load config");
16
+ throw n(e, "Failed to load config");
17
17
  }
18
18
  }
19
19
  async saveConfig(e) {
20
20
  try {
21
- let n = t().config, r = n.replaceConfigFile;
22
- if (typeof r == "function") {
23
- await r({
21
+ let t = l().config, n = t.replaceConfigFile;
22
+ if (typeof n == "function") {
23
+ await n({
24
24
  nextConfig: e,
25
25
  afterWrite: { mode: "auto" }
26
26
  });
27
27
  return;
28
28
  }
29
- await n.writeConfigFile(e);
29
+ await t.writeConfigFile(e);
30
30
  } catch (e) {
31
- throw i(e, "Failed to save config");
31
+ throw n(e, "Failed to save config");
32
32
  }
33
33
  }
34
34
  getGatewayAuthConfig() {
@@ -62,14 +62,14 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
62
62
  }
63
63
  getEnvInfo() {
64
64
  try {
65
- let e = this.loadConfig().plugins?.entries?.[d]?.config, t = e?.envInfo;
66
- if (t?.env) return t;
67
- let n = e?.env;
68
- if (n) return {
69
- env: n,
65
+ let e = this.loadConfig().plugins?.entries?.[d]?.config, n = e?.envInfo;
66
+ if (n?.env) return n;
67
+ let r = e?.env;
68
+ if (r) return {
69
+ env: r,
70
70
  source: "manual"
71
71
  };
72
- let i = r();
72
+ let i = t();
73
73
  return i ? {
74
74
  env: i,
75
75
  source: "env"
@@ -124,7 +124,7 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
124
124
  };
125
125
  await this.saveConfig(r);
126
126
  } catch (e) {
127
- throw i(e, "Failed to update device config");
127
+ throw n(e, "Failed to update device config");
128
128
  }
129
129
  }
130
130
  async updateEnv(e) {
@@ -152,7 +152,7 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
152
152
  };
153
153
  await this.saveConfig(n);
154
154
  } catch (e) {
155
- throw i(e, "Failed to update env config");
155
+ throw n(e, "Failed to update env config");
156
156
  }
157
157
  }
158
158
  async resetEnv() {
@@ -181,7 +181,7 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
181
181
  };
182
182
  await this.saveConfig(n);
183
183
  } catch (e) {
184
- throw i(e, "Failed to reset env config");
184
+ throw n(e, "Failed to reset env config");
185
185
  }
186
186
  }
187
187
  async updateGrayTag(e) {
@@ -205,7 +205,7 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
205
205
  };
206
206
  await this.saveConfig(n);
207
207
  } catch (e) {
208
- throw i(e, "Failed to update gray tag config");
208
+ throw n(e, "Failed to update gray tag config");
209
209
  }
210
210
  }
211
211
  async updateUserConfig(e) {
@@ -229,7 +229,7 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
229
229
  };
230
230
  await this.saveConfig(n);
231
231
  } catch (e) {
232
- throw i(e, "Failed to update user config");
232
+ throw n(e, "Failed to update user config");
233
233
  }
234
234
  }
235
235
  async clearUserConfig() {
@@ -252,38 +252,38 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
252
252
  };
253
253
  await this.saveConfig(t);
254
254
  } catch (e) {
255
- throw i(e, "Failed to clear user config");
255
+ throw n(e, "Failed to clear user config");
256
256
  }
257
257
  }
258
- async initializePluginConfig(t) {
258
+ async initializePluginConfig(l) {
259
259
  try {
260
- 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 = {
261
- env: E || w || (e() ? "test" : "production"),
260
+ let n = this.loadConfig(), d = n.skills || {}, p = d.load || {}, m = p.watch === !0, h = !m || await s(o.DISABLE_SKILLS_LOAD_WATCH_MIGRATION_DONE), g = n.plugins?.allow || [], _ = !g.includes(l), v = g.includes(l) ? g : [...g, l], y = n.gateway?.nodes?.allowCommands || [], b = Array.from(new Set([...y, ...f])), x = !e(y, b), S = m && !h, C = n.plugins?.entries?.[l]?.config?.envInfo, w = n.plugins?.entries?.[l]?.config?.env, T = !!(C?.env || w), E = t(), D = !!C?.env && C.source === "env", O = !C?.env && !!w || D && E && C.env !== E, k = !T || O, A = {
261
+ env: E || w || (u() ? "test" : "production"),
262
262
  source: "env"
263
- }, j = i.plugins?.entries?.[t]?.config || {}, M = k ? {
263
+ }, j = n.plugins?.entries?.[l]?.config || {}, M = k ? {
264
264
  ...j,
265
265
  envInfo: A,
266
266
  env: void 0
267
- } : j, N = i.plugins?.entries?.[t]?.enabled !== !0, P = o(i), F = Object.keys(P).length > 0;
268
- 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;
267
+ } : j, N = n.plugins?.entries?.[l]?.enabled !== !0, P = i(n), F = Object.keys(P).length > 0;
268
+ if (F && r().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;
269
269
  let I = {
270
- ...i,
270
+ ...n,
271
271
  plugins: {
272
- ...i.plugins,
272
+ ...n.plugins,
273
273
  allow: v,
274
274
  entries: {
275
- ...i.plugins?.entries,
276
- [t]: {
277
- ...i.plugins?.entries?.[t],
275
+ ...n.plugins?.entries,
276
+ [l]: {
277
+ ...n.plugins?.entries?.[l],
278
278
  enabled: !0,
279
279
  config: M
280
280
  }
281
281
  }
282
282
  },
283
283
  gateway: {
284
- ...i.gateway,
284
+ ...n.gateway,
285
285
  nodes: {
286
- ...i.gateway?.nodes,
286
+ ...n.gateway?.nodes,
287
287
  allowCommands: b
288
288
  }
289
289
  }
@@ -297,9 +297,9 @@ var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,ala
297
297
  watch: !1
298
298
  }
299
299
  }
300
- }, 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);
300
+ }, r().info("[claw-configs] Disabled skills.load.watch for yoyo migration")), F && (I = a(I, P), r().info("[claw-configs] Provider renaming completed")), await this.saveConfig(I), S && await c(o.DISABLE_SKILLS_LOAD_WATCH_MIGRATION_DONE);
301
301
  } catch (e) {
302
- throw i(e, "failed to initialize plugin config");
302
+ throw n(e, "failed to initialize plugin config");
303
303
  }
304
304
  }
305
305
  }, m = null;
@@ -1,6 +1,6 @@
1
- import { getYoyoPluginVersionCode as e } from "../../utils/version.mjs";
2
- import { useClawLogger as t } from "../../utils/logger.mjs";
3
- import { getConfigManager as n } from "../configs/config-manager.mjs";
1
+ import { useClawLogger as e } from "../../utils/logger.mjs";
2
+ import { getConfigManager as t } from "../configs/config-manager.mjs";
3
+ import { getYoyoPluginVersionCode as n } from "../../utils/version.mjs";
4
4
  import { isOKResponse as r } from "../../apis/helpers.mjs";
5
5
  import { createClawCloudClient as i } from "../../apis/claw-cloud.mjs";
6
6
  import { getPersistedIdentity as a, updatePersistedIdentity as o } from "../configs/identity-persist.mjs";
@@ -9,28 +9,28 @@ import "../../apis/index.mjs";
9
9
  import { formatHashForLog as s } from "../../utils/hash.mjs";
10
10
  import { createGatewayAuthMd5 as c, isSameGatewayAuthMd5 as l } from "./gateway-auth.mjs";
11
11
  //#region src/modules/device/registry.ts
12
- async function u(t, a) {
13
- if (!t || !a) throw Error("设备信息或用户信息缺失");
14
- let o = n().getGatewayAuthConfig(), s = c(o), l = e(), u = await i().registerDevice(t, a, o);
12
+ async function u(e, a) {
13
+ if (!e || !a) throw Error("设备信息或用户信息缺失");
14
+ let o = t().getGatewayAuthConfig(), s = c(o), l = n(), u = await i().registerDevice(e, a, o);
15
15
  if (!r(u)) throw Error(`注册失败:${u.data?.cnMessage}`);
16
16
  await f(s, l);
17
17
  }
18
18
  async function d(r, i) {
19
- let o = c(n().getGatewayAuthConfig()), d = e(), f = await a(), p = f?.gatewayAuthMd5, m = f?.pluginVersionCode, h = t();
19
+ let o = c(t().getGatewayAuthConfig()), d = n(), f = await a(), p = f?.gatewayAuthMd5, m = f?.pluginVersionCode, h = e();
20
20
  if (h.info(`[yoyoclaw-registry] checking registration state: gatewayAuth current=${s(o)}, persisted=${s(p)}; pluginVersionCode current=${d}, persisted=${m ?? "none"}`), l(p, o) && m === d) {
21
21
  h.info("[yoyoclaw-registry] registration state unchanged, skipping device registration");
22
22
  return;
23
23
  }
24
24
  h.info("[yoyoclaw-registry] registration state changed, registering device"), await u(r, i), h.info(`[yoyoclaw-registry] device registration succeeded, pluginVersionCode=${d}`);
25
25
  }
26
- async function f(e, n) {
26
+ async function f(t, n) {
27
27
  try {
28
28
  await o({
29
- gatewayAuthMd5: e,
29
+ gatewayAuthMd5: t,
30
30
  pluginVersionCode: n
31
- }), t().info("[yoyoclaw-registry] registration state persisted after device registration");
32
- } catch (e) {
33
- t().warn(`[yoyoclaw-registry] failed to persist registration state: ${String(e)}`);
31
+ }), e().info("[yoyoclaw-registry] registration state persisted after device registration");
32
+ } catch (t) {
33
+ e().warn(`[yoyoclaw-registry] failed to persist registration state: ${String(t)}`);
34
34
  }
35
35
  }
36
36
  //#endregion
@@ -1,16 +1,16 @@
1
1
  import { findPackageRoot as e } from "./package-json.mjs";
2
2
  import t from "node:path";
3
- import { fileURLToPath as n } from "node:url";
4
- import r from "node:os";
3
+ import n from "node:os";
4
+ import { fileURLToPath as r } from "node:url";
5
5
  //#region src/utils/home-dir.ts
6
6
  function i(e) {
7
7
  return e?.trim() || void 0;
8
8
  }
9
- function a(r = import.meta.url) {
10
- return e(r) ?? t.parse(n(r)).root;
9
+ function a(n = import.meta.url) {
10
+ return e(n) ?? t.parse(r(n)).root;
11
11
  }
12
- function o(e = process.env, n = r.homedir) {
13
- let i = s(e, n);
12
+ function o(e = process.env, r = n.homedir) {
13
+ let i = s(e, r);
14
14
  return i ? t.resolve(i) : void 0;
15
15
  }
16
16
  function s(e, t) {
@@ -1,27 +1,59 @@
1
1
  import { findPackageRoot as e, readPackageJson as t } from "./package-json.mjs";
2
+ import { getYoyoRuntime as n } from "../runtime.mjs";
2
3
  //#region src/utils/version.ts
3
- var n = "@honor-claw/yoyo";
4
- function r() {
5
- let e = o();
4
+ var r = "@honor-claw/yoyo", i = 3;
5
+ function a() {
6
+ try {
7
+ let e = n().version;
8
+ return o(e);
9
+ } catch {
10
+ return i;
11
+ }
12
+ }
13
+ function o(e) {
14
+ let t = s(e);
15
+ return t && c(t, [
16
+ 2026,
17
+ 5,
18
+ 12
19
+ ]) >= 0 ? 4 : i;
20
+ }
21
+ function s(e) {
22
+ if (!e) return null;
23
+ let t = e.split("-", 1)[0].split(".");
24
+ if (t.length === 0) return null;
25
+ let n = t.map((e) => Number.parseInt(e, 10));
26
+ return n.some((e) => !Number.isFinite(e) || e < 0) ? null : n;
27
+ }
28
+ function c(e, t) {
29
+ let n = Math.max(e.length, t.length);
30
+ for (let r = 0; r < n; r += 1) {
31
+ let n = e[r] ?? 0, i = t[r] ?? 0;
32
+ if (n !== i) return n - i;
33
+ }
34
+ return 0;
35
+ }
36
+ function l() {
37
+ let e = f();
6
38
  return e.includes("beta") || e.includes("alpha");
7
39
  }
8
- function i(e) {
40
+ function u(e) {
9
41
  if (!e) return 0;
10
42
  let t = Number.parseInt(e, 10);
11
43
  return Number.isFinite(t) && t >= 0 ? t : 0;
12
44
  }
13
- function a() {
14
- let [e, t, n] = o().split("-", 1)[0].split("."), r = i(e), a = i(t), s = i(n);
15
- return r * 1e6 + a * 1e3 + s;
45
+ function d() {
46
+ let [e, t, n] = f().split("-", 1)[0].split("."), r = u(e), i = u(t), a = u(n);
47
+ return r * 1e6 + i * 1e3 + a;
16
48
  }
17
- function o() {
49
+ function f() {
18
50
  try {
19
- let r = e(import.meta.url, n);
20
- if (!r) return "0.0.0";
21
- let i = t(r)?.version;
51
+ let n = e(import.meta.url, r);
52
+ if (!n) return "0.0.0";
53
+ let i = t(n)?.version;
22
54
  if (typeof i == "string") return i;
23
55
  } catch {}
24
56
  return "0.0.0";
25
57
  }
26
58
  //#endregion
27
- export { a as getYoyoPluginVersionCode, r as isBetaVersion };
59
+ export { a as getProtocolVersion, d as getYoyoPluginVersionCode, l as isBetaVersion };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@honor-claw/yoyo",
3
- "version": "1.6.1-beta.2",
3
+ "version": "1.6.1-beta.3",
4
4
  "description": "OpenClaw Honor Yoyo connection plugin",
5
5
  "keywords": [
6
6
  "ai",