@honor-claw/yoyo 1.4.0-beta.3 → 1.4.1-alpha.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.
@@ -1,44 +1,48 @@
1
- import { uuid as e } from "../utils/id.mjs";
2
- import { isOKResponse as t } from "./helpers.mjs";
3
- import { takeApiHost as n } from "./hosts.mjs";
4
- import { HttpClient as r } from "./http-client.mjs";
1
+ import { getYoyoPluginVersionCode as e } from "../utils/version.mjs";
2
+ import { uuid as t } from "../utils/id.mjs";
3
+ import { isOKResponse as n } from "./helpers.mjs";
4
+ import { takeApiHost as r } from "./hosts.mjs";
5
+ import { HttpClient as i } from "./http-client.mjs";
5
6
  //#region src/apis/claw-cloud.ts
6
- var i = class {
7
+ var a = class {
7
8
  httpClient;
8
9
  constructor(e, t) {
9
- this.httpClient = new r(e, t);
10
+ this.httpClient = new i(e, t);
10
11
  }
11
- async registerDevice(t, n, r) {
12
- let i = {
13
- "x-trace-id": e(),
14
- "x-jwt-token": n.token,
15
- "x-device-id": t.deviceId
16
- }, a = {
12
+ async registerDevice(n, r, i) {
13
+ let a = {
14
+ "x-trace-id": t(),
15
+ "x-jwt-token": r.token,
16
+ "x-device-id": n.deviceId
17
+ }, o = {
17
18
  businessTag: "YOYO_CLAW",
18
19
  role: "yoyoclaw",
19
20
  deviceInfo: {
20
- ...t,
21
- manufacture: t.manufacture,
22
- brand: t.brand,
23
- bizExtInfo: r
21
+ ...n,
22
+ manufacture: n.manufacture,
23
+ brand: n.brand,
24
+ bizExtInfo: {
25
+ ...i,
26
+ pluginVersionCode: e()
27
+ }
24
28
  }
25
29
  };
26
30
  return this.httpClient.post("/v1/device/registry", {
27
- headers: i,
28
- body: a
31
+ headers: a,
32
+ body: o
29
33
  });
30
34
  }
31
- async logoutDevice(t, n) {
35
+ async logoutDevice(e, n) {
32
36
  let r = {
33
- "x-trace-id": e(),
37
+ "x-trace-id": t(),
34
38
  "x-jwt-token": n.token,
35
- "x-device-id": t.deviceId
39
+ "x-device-id": e.deviceId
36
40
  }, i = {
37
41
  businessTag: "YOYO_CLAW",
38
42
  deviceInfo: {
39
- ...t,
40
- manufacture: t.manufacture,
41
- brand: t.brand
43
+ ...e,
44
+ manufacture: e.manufacture,
45
+ brand: e.brand
42
46
  }
43
47
  };
44
48
  return this.httpClient.post("/v1/user/logout", {
@@ -46,10 +50,10 @@ var i = class {
46
50
  body: i
47
51
  });
48
52
  }
49
- async exchangeToken(n, r) {
50
- let i = e(), a = {
53
+ async exchangeToken(e, r) {
54
+ let i = t(), a = {
51
55
  "Content-Type": "application/json",
52
- "x-device-id": n.deviceId,
56
+ "x-device-id": e.deviceId,
53
57
  "x-trace-id": i
54
58
  }, o = {};
55
59
  "userId" in r ? a["x-agw-userId"] = r.userId : o = {
@@ -62,13 +66,13 @@ var i = class {
62
66
  headers: a,
63
67
  timeout: 15e3
64
68
  });
65
- if (t(s) && s.data.data) return s.data.data;
69
+ if (n(s) && s.data.data) return s.data.data;
66
70
  throw Error(`failed to get token: ${JSON.stringify(s.data)}, traceId: ${i}`);
67
71
  }
68
72
  };
69
- function a() {
70
- let e = n();
71
- return new i(`https://${e.clawCloud}/aicloud/yoyo-claw-service`, e.grayTag ? { defaultHeaders: { "x-gray": e.grayTag } } : void 0);
73
+ function o() {
74
+ let e = r();
75
+ return new a(`https://${e.clawCloud}/aicloud/yoyo-claw-service`, e.grayTag ? { defaultHeaders: { "x-gray": e.grayTag } } : void 0);
72
76
  }
73
77
  //#endregion
74
- export { i as ClawCloudClient, a as createClawCloudClient };
78
+ export { a as ClawCloudClient, o as createClawCloudClient };
@@ -36,7 +36,7 @@ async function f(t) {
36
36
  ...o,
37
37
  version: o?.version || a.NEW
38
38
  };
39
- return t.legacyDeviceId && (s.legacyDeviceId = t.legacyDeviceId), t.deviceId && (s.deviceId = t.deviceId, s.publicKeyPem = t.publicKeyPem, s.privateKeyPem = t.privateKeyPem, s.createdAtMs = t.createdAtMs), t.version && (s.version = t.version), "gatewayAuthMd5" in t && (s.gatewayAuthMd5 = t.gatewayAuthMd5), await n({
39
+ return t.legacyDeviceId && (s.legacyDeviceId = t.legacyDeviceId), t.deviceId && (s.deviceId = t.deviceId, s.publicKeyPem = t.publicKeyPem, s.privateKeyPem = t.privateKeyPem, s.createdAtMs = t.createdAtMs), t.version && (s.version = t.version), "gatewayAuthMd5" in t && (s.gatewayAuthMd5 = t.gatewayAuthMd5), "pluginVersionCode" in t && (s.pluginVersionCode = t.pluginVersionCode), await n({
40
40
  rootDir: i,
41
41
  relativePath: l(),
42
42
  data: JSON.stringify(s, null, 2),
@@ -49,15 +49,12 @@ async function c() {
49
49
  let r = await s();
50
50
  return await t(r), r;
51
51
  }
52
- async function l() {
53
- return (await e())?.gatewayAuthMd5;
54
- }
55
- function u(e, t) {
52
+ function l(e, t) {
56
53
  let r = n.createPrivateKey(e);
57
54
  return i(n.sign(null, Buffer.from(t, "utf8"), r));
58
55
  }
59
- function d(e) {
56
+ function u(e) {
60
57
  return i(a(e));
61
58
  }
62
59
  //#endregion
63
- export { c as loadOrCreateDeviceIdentity, l as loadPersistedGatewayAuthMd5, d as publicKeyRawBase64UrlFromPem, u as signDevicePayload };
60
+ export { c as loadOrCreateDeviceIdentity, u as publicKeyRawBase64UrlFromPem, l as signDevicePayload };
@@ -1,6 +1,6 @@
1
1
  import "./gateway-auth.mjs";
2
- import "./identity.mjs";
3
2
  import "./registry.mjs";
3
+ import "./identity.mjs";
4
4
  import "./device-info.mjs";
5
5
  import "./helpers.mjs";
6
6
  import "./auth.mjs";
@@ -1,26 +1,37 @@
1
- import { useClawLogger as e } from "../../utils/logger.mjs";
2
- import { getConfigManager as t } from "../configs/config-manager.mjs";
3
- import { isOKResponse as n } from "../../apis/helpers.mjs";
4
- import { createClawCloudClient as r } from "../../apis/claw-cloud.mjs";
5
- import { updatePersistedIdentity as i } from "../configs/identity-persist.mjs";
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";
4
+ import { isOKResponse as r } from "../../apis/helpers.mjs";
5
+ import { createClawCloudClient as i } from "../../apis/claw-cloud.mjs";
6
+ import { getPersistedIdentity as a, updatePersistedIdentity as o } from "../configs/identity-persist.mjs";
6
7
  import "../configs/index.mjs";
7
8
  import "../../apis/index.mjs";
8
- import { formatHashForLog as a } from "../../utils/hash.mjs";
9
- import { createGatewayAuthMd5 as o, isSameGatewayAuthMd5 as s } from "./gateway-auth.mjs";
10
- import { loadPersistedGatewayAuthMd5 as c } from "./identity.mjs";
9
+ import { formatHashForLog as s } from "../../utils/hash.mjs";
10
+ import { createGatewayAuthMd5 as c, isSameGatewayAuthMd5 as l } from "./gateway-auth.mjs";
11
11
  //#region src/modules/device/registry.ts
12
- async function l(e, i) {
13
- if (!e || !i) throw Error("设备信息或用户信息缺失");
14
- let a = t().getGatewayAuthConfig(), o = await r().registerDevice(e, i, a);
15
- if (!n(o)) throw Error(`注册失败:${o.data?.cnMessage}`);
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);
15
+ if (!r(u)) throw Error(`注册失败:${u.data?.cnMessage}`);
16
+ await f(s, l);
16
17
  }
17
- async function u(n, r) {
18
- let u = o(t().getGatewayAuthConfig()), d = await c(), f = e();
19
- if (f.info(`[yoyoclaw-registry] checking gateway auth md5: current=${a(u)}, persisted=${a(d)}`), s(d, u)) {
20
- f.info("[yoyoclaw-registry] gateway auth unchanged, skipping device registration");
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();
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
+ h.info("[yoyoclaw-registry] registration state unchanged, skipping device registration");
21
22
  return;
22
23
  }
23
- f.info("[yoyoclaw-registry] gateway auth changed, registering device"), await l(n, r), await i({ gatewayAuthMd5: u }), f.info("[yoyoclaw-registry] gateway auth md5 persisted after device registration");
24
+ h.info("[yoyoclaw-registry] registration state changed, registering device"), await u(r, i), h.info(`[yoyoclaw-registry] device registration succeeded, pluginVersionCode=${d}`);
25
+ }
26
+ async function f(e, n) {
27
+ try {
28
+ await o({
29
+ gatewayAuthMd5: e,
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)}`);
34
+ }
24
35
  }
25
36
  //#endregion
26
- export { l as registerDevice, u as registerDeviceIfGatewayAuthChanged };
37
+ export { u as registerDevice, d as registerDeviceIfRegistrationStateChanged };
@@ -1,6 +1,6 @@
1
1
  import { useClawLogger as e } from "../../utils/logger.mjs";
2
2
  import { getConfigManager as t } from "../../modules/configs/config-manager.mjs";
3
- import { registerDevice as n, registerDeviceIfGatewayAuthChanged as r } from "../../modules/device/registry.mjs";
3
+ import { registerDevice as n, registerDeviceIfRegistrationStateChanged as r } from "../../modules/device/registry.mjs";
4
4
  import { getDeviceInfo as i } from "../../modules/device/device-info.mjs";
5
5
  import "../../modules/device/index.mjs";
6
6
  import { clearToken as a, loadToken as o } from "../../honor-auth/token-manager.mjs";
@@ -1,7 +1,17 @@
1
1
  //#region src/utils/version.ts
2
- var e = null;
3
- function t() {
4
- return e === null && (e = "1.4.0-beta.3".includes("beta") || "1.4.0-beta.3".includes("alpha")), !!e;
2
+ var e = null, t = null;
3
+ function n() {
4
+ return e === null && (e = "1.4.1-alpha.1".includes("beta") || "1.4.1-alpha.1".includes("alpha")), !!e;
5
+ }
6
+ function r(e) {
7
+ if (!e) return 0;
8
+ let t = Number.parseInt(e, 10);
9
+ return Number.isFinite(t) && t >= 0 ? t : 0;
10
+ }
11
+ function i() {
12
+ if (t !== null) return t;
13
+ let [e, n, i] = "1.4.1-alpha.1".split("-", 1)[0].split("."), a = r(e), o = r(n), s = r(i);
14
+ return t = a * 1e6 + o * 1e3 + s, t;
5
15
  }
6
16
  //#endregion
7
- export { t as isBetaVersion };
17
+ export { i as getYoyoPluginVersionCode, n as isBetaVersion };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@honor-claw/yoyo",
3
- "version": "1.4.0-beta.3",
3
+ "version": "1.4.1-alpha.1",
4
4
  "description": "OpenClaw Honor Yoyo connection plugin",
5
5
  "keywords": [
6
6
  "ai",
@@ -12,8 +12,7 @@
12
12
  "files": [
13
13
  "dist",
14
14
  "skills",
15
- "openclaw.plugin.json",
16
- "src/agent/**/*.md"
15
+ "openclaw.plugin.json"
17
16
  ],
18
17
  "type": "module",
19
18
  "exports": {
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: yoyo_phone_control
3
3
  description: >
4
- 通过 YOYO 控制手机系统功能(应用管理、通话短信、闹钟日程、设备设置等)及在指定 App 内执行 GUI 操作。
4
+ 通过 YOYO 控制手机系统功能(应用管理、通话短信、闹钟日程、设备设置等)。
5
5
  metadata: { "openclaw": { "emoji": "📱", "always": true } }
6
6
  ---
7
7
 
@@ -34,7 +34,6 @@ metadata: { "openclaw": { "emoji": "📱", "always": true } }
34
34
  - 参数必须为合法 JSON,枚举值区分大小写,数值在定义范围内
35
35
  - 当工具执行错误时,必须确认下发的指令是否存在格式问题,尤其是单双引号的使用问题
36
36
  - 如果执行失败,必须重新读取 `SKILL.md` 和对应的工具定义文件,然后重新执行
37
- - 禁止使用GUI工具作为兜底工具,除非用户明确要求在指定 App 内执行指定动作
38
37
  - 绝对不能使用任何其他设备的工具
39
38
  - 不要尝试任何其他方式完成任务,不要提供替代方案
40
39
 
@@ -128,9 +127,6 @@ metadata: { "openclaw": { "emoji": "📱", "always": true } }
128
127
  | `battery` | `references/battery.md` | 电量与省电模式管理 |
129
128
  | `audio-record` | `references/audio-record.md` | 录音管理 |
130
129
  | `camera` | `references/camera.md` | 相机控制(拍照/录像),不支持手电筒相关的操作。 |
131
- | `gui` | `references/gui-task-create.md` | 启动 GUI 操作任务(UI Agent),只有当用户明确要求在指定 App 内执行指定动作时才使用。如果用户没有提供应用名,严禁使用本工具。|
132
- | `gui` | `references/gui-task-terminate.md` | 取消 GUI 任务 |
133
- | `gui` | `references/gui-task-pause.md` | 暂停 GUI 任务 |
134
130
  | `scan-code` | `references/scan-code.md` | 扫码(二维码/条形码) |
135
131
  | `flashlight` | `references/flashlight.md` | 手电筒控制 |
136
132
  | `airplane-mode` | `references/airplane-mode.md` | 飞行模式管理 |
@@ -0,0 +1,166 @@
1
+ ---
2
+ name: yoyo-update
3
+ description: >
4
+ 更新 YOYO 插件到最新版本。当用户要求更新、升级 yoyo 插件,或检查 yoyo 插件版本更新时触发。
5
+ metadata: { "openclaw": { "emoji": "🔄", "always": true } }
6
+ ---
7
+
8
+ # YOYO 插件更新
9
+
10
+ 按照以下 5 步工作流完成 YOYO 插件的版本更新。
11
+
12
+ ## 全局规则
13
+
14
+ - [MANDATORY] **严禁在技能流程内重启网关** — 不得执行 `openclaw gateway stop/start/restart` 或任何网关重启操作
15
+ - [MANDATORY] **严禁卸载插件** — 不得执行 `openclaw plugins uninstall`,否则用户配置将丢失
16
+ - [MANDATORY] 出错时仅汇总错误并给出建议,不得尝试自动修复(尤其是不得通过卸载重装来解决问题)
17
+ - [MANDATORY] 所有面向用户的输出必须使用中文
18
+ - 所有命令在 Windows (bash) 和 Unix (bash) 环境下格式一致,无需区分平台
19
+
20
+ ## 步骤 1:预检查
21
+
22
+ 执行以下命令获取当前插件信息:
23
+
24
+ ```bash
25
+ openclaw plugins info yoyo
26
+ ```
27
+
28
+ **输出字段说明**:
29
+
30
+ | 字段 | 说明 | 示例 |
31
+ | -------------- | ---------------------------- | -------------------------------- |
32
+ | `Status` | 插件加载状态 | `loaded` / `error` / `not found` |
33
+ | `Version` | 当前已安装版本 | `1.3.0-beta.8` |
34
+ | `Spec` | 安装来源标识,含包名和渠道 | `@honor-claw/yoyo@beta` |
35
+ | `Install path` | 插件安装路径 | `~/.openclaw/extensions/yoyo` |
36
+
37
+ **处理规则**:
38
+
39
+ - 若插件未找到(输出为空或提示未安装)→ 告知用户"未检测到 YOYO 插件,请先安装"并停止
40
+ - 若状态非 `loaded`(如 `error`)→ 告知用户插件状态异常并展示具体信息,停止流程
41
+ - 若命令本身执行失败 → 告知用户"无法获取插件信息,请确认 OpenClaw 网关正在运行"并停止
42
+ - 成功获取信息 → 提取 `Version` 和 `Spec` 字段值,进入步骤 2
43
+
44
+ ## 步骤 2:检查最新版本
45
+
46
+ ### 2.1 确定当前发布渠道
47
+
48
+ 根据步骤 1 中 `Spec` 字段判断当前发布渠道:
49
+
50
+ - `Spec` 包含 `@alpha` 后缀 → 渠道为 `alpha`
51
+ - `Spec` 包含 `@beta` 后缀 → 渠道为 `beta`
52
+ - `Spec` 无预发布后缀 → 渠道为 `latest`
53
+
54
+ ### 2.2 查询最新版本
55
+
56
+ 执行以下命令获取所有发布渠道的最新版本:
57
+
58
+ ```bash
59
+ npm view @honor-claw/yoyo dist-tags --json
60
+ ```
61
+
62
+ 从 JSON 输出中提取对应渠道的版本号。示例输出:
63
+
64
+ ```json
65
+ {
66
+ "latest": "1.2.0",
67
+ "beta": "1.3.0-beta.8",
68
+ "alpha": "1.4.0-alpha.3"
69
+ }
70
+ ```
71
+
72
+ 若 `npm view` 命令失败,回退使用以下命令获取 `latest` 版本:
73
+
74
+ ```bash
75
+ npm view @honor-claw/yoyo version
76
+ ```
77
+
78
+ ### 2.3 版本对比
79
+
80
+ 将目标版本(对应渠道最新版)与步骤 1 获取的当前版本进行对比:
81
+
82
+ - **版本相同** → 告知用户"当前已是最新版本(v{version}),无需更新"并停止流程
83
+ - **版本不同** → 记录当前版本和目标版本,进入步骤 3
84
+
85
+ ## 步骤 3:展示版本差异
86
+
87
+ 向用户展示更新摘要后直接进入步骤 4:
88
+
89
+ ```
90
+ 🔄 YOYO 插件更新可用
91
+
92
+ 当前版本:v{当前版本}
93
+ 目标版本:v{目标版本}
94
+ 发布渠道:{渠道名}
95
+ ```
96
+
97
+ ## 步骤 4:执行更新
98
+
99
+ ### 4.1 执行更新命令
100
+
101
+ ```bash
102
+ openclaw plugins update yoyo
103
+ ```
104
+
105
+ 注意:该命令可能需要较长时间执行(下载和安装),请使用足够的超时时间。
106
+
107
+ ### 4.2 监控更新进度
108
+
109
+ 实时监控命令输出,根据不同阶段向用户报告进度:
110
+
111
+ | 输出关键词 | 向用户报告 | 内部处理 |
112
+ | -------------------------------------- | ----------------- | ------------------------------ |
113
+ | `Downloading @honor-claw/yoyo@` | "正在下载插件..." | — |
114
+ | `Extracting` | 不输出 | 静默跟踪 |
115
+ | `Installing to` | "正在更新插件..." | — |
116
+ | `Installing plugin dependencies` | 不输出 | 静默跟踪 |
117
+ | `Updated yoyo:` | 不输出 | 捕获成功版本信息 |
118
+ | `Config overwrite:` / `Config backup:` | 不输出 | 记录配置备份路径 |
119
+ | `Restart the gateway to load plugins` | 不输出 | 更新成功的确认信号,进入步骤 5 |
120
+
121
+ ### 4.3 错误处理
122
+
123
+ 若命令执行过程中出现错误(非零退出码或输出中包含错误信息):
124
+
125
+ - 记录完整错误输出
126
+ - 不尝试重试或替代方案
127
+ - 直接进入步骤 5 的失败处理流程
128
+
129
+ ## 步骤 5:更新后处理
130
+
131
+ ### 更新成功
132
+
133
+ 向用户报告:
134
+
135
+ ```
136
+ ✅ 插件更新完成
137
+
138
+ 更新版本:v{旧版本} → v{新版本}
139
+
140
+ 插件更新完成,重启网关后生效。是否立即重启?
141
+ ```
142
+
143
+ **[MANDATORY] 不得在此步骤中执行网关重启操作。** 仅向用户提问,由用户在下一轮对话中自行决定是否重启。
144
+
145
+ ### 更新失败
146
+
147
+ 向用户报告失败摘要:
148
+
149
+ ```
150
+ ❌ 插件更新失败
151
+
152
+ 失败原因:{简要描述错误}
153
+ ```
154
+
155
+ 并给出以下建议(根据实际错误类型选择):
156
+
157
+ - 网络错误(如 `ECONNREFUSED`、`ETIMEDOUT`)→ "请检查网络连接后重试"
158
+ - 权限错误(如 `EACCES`、`EPERM`)→ "请检查 OpenClaw 安装目录的读写权限"
159
+ - 版本冲突 / 依赖冲突 → "请将以下错误信息反馈给开发团队"
160
+ - 其他未预期错误 → "请将错误信息反馈给开发团队,或稍后重试"
161
+
162
+ **[MANDATORY] 不得尝试以下操作**:
163
+ - 卸载后重装插件(配置会丢失)
164
+ - 手动删除插件目录
165
+ - 修改插件配置文件来绕过错误
166
+ - 重启网关