@ryantest/openclaw-qqbot 1.6.7-beta.7 → 1.6.7-beta.8
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/src/slash-commands.d.ts +6 -21
- package/dist/src/slash-commands.js +1532 -35
- package/package.json +1 -1
- package/src/slash-commands.ts +1599 -33
- package/dist/src/commands/bot-clear-storage.d.ts +0 -1
- package/dist/src/commands/bot-clear-storage.js +0 -157
- package/dist/src/commands/bot-help.d.ts +0 -1
- package/dist/src/commands/bot-help.js +0 -24
- package/dist/src/commands/bot-logs.d.ts +0 -1
- package/dist/src/commands/bot-logs.js +0 -232
- package/dist/src/commands/bot-ping.d.ts +0 -1
- package/dist/src/commands/bot-ping.js +0 -29
- package/dist/src/commands/bot-upgrade.d.ts +0 -1
- package/dist/src/commands/bot-upgrade.js +0 -252
- package/dist/src/commands/bot-version.d.ts +0 -1
- package/dist/src/commands/bot-version.js +0 -33
- package/dist/src/upgrade-utils.d.ts +0 -74
- package/dist/src/upgrade-utils.js +0 -634
- package/src/commands/bot-clear-storage.ts +0 -176
- package/src/commands/bot-help.ts +0 -26
- package/src/commands/bot-logs.ts +0 -234
- package/src/commands/bot-ping.ts +0 -31
- package/src/commands/bot-upgrade.ts +0 -281
- package/src/commands/bot-version.ts +0 -32
- package/src/upgrade-utils.ts +0 -673
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import { registerCommand, getPluginVersion } from "../slash-commands.js";
|
|
2
|
-
import { getUpdateInfo, checkVersionExists } from "../update-checker.js";
|
|
3
|
-
import { checkUpgradeCompatibility, fireHotUpgrade, isUpgrading, setUpgrading, preUpgradeCredentialBackup, saveUpgradeGreetingTarget, } from "../upgrade-utils.js";
|
|
4
|
-
const DEFAULT_UPGRADE_URL = "https://docs.qq.com/doc/DSGxOZk1oVnVKVkpq";
|
|
5
|
-
registerCommand({
|
|
6
|
-
name: "bot-upgrade",
|
|
7
|
-
description: "检查更新并查看升级指引",
|
|
8
|
-
usage: [
|
|
9
|
-
`/bot-upgrade 检查是否有新版本`,
|
|
10
|
-
`/bot-upgrade --latest 确认升级到最新版本(需 upgradeMode=hot-reload)`,
|
|
11
|
-
`/bot-upgrade --version X 升级到指定版本(需 upgradeMode=hot-reload)`,
|
|
12
|
-
`/bot-upgrade --pkg scope/name 指定 npm 包(如 ryantest/openclaw-qqbot)`,
|
|
13
|
-
`/bot-upgrade --force 强制重新安装当前版本(需 upgradeMode=hot-reload)`,
|
|
14
|
-
`/bot-upgrade --local 使用本地升级脚本(跳过远端下载)`,
|
|
15
|
-
].join("\n"),
|
|
16
|
-
handler: async (ctx) => {
|
|
17
|
-
const PLUGIN_VERSION = getPluginVersion();
|
|
18
|
-
const url = ctx.accountConfig?.upgradeUrl || DEFAULT_UPGRADE_URL;
|
|
19
|
-
const upgradeMode = ctx.accountConfig?.upgradeMode || "hot-reload";
|
|
20
|
-
const args = ctx.args.trim();
|
|
21
|
-
const info = await getUpdateInfo();
|
|
22
|
-
const GITHUB_URL = "https://github.com/tencent-connect/openclaw-qqbot/";
|
|
23
|
-
// ── doc 模式(默认):只展示升级指引,不执行热更新 ──
|
|
24
|
-
if (upgradeMode !== "hot-reload") {
|
|
25
|
-
if (info.checkedAt === 0) {
|
|
26
|
-
return `⏳ 版本检查中,请稍后再试`;
|
|
27
|
-
}
|
|
28
|
-
if (info.error) {
|
|
29
|
-
return [
|
|
30
|
-
`❌ 主机网络访问异常,无法检查更新`,
|
|
31
|
-
``,
|
|
32
|
-
`查看升级指引:[点击查看](${url})`,
|
|
33
|
-
].join("\n");
|
|
34
|
-
}
|
|
35
|
-
if (!info.hasUpdate) {
|
|
36
|
-
return [
|
|
37
|
-
`✅ 当前已是最新版本 v${PLUGIN_VERSION}`,
|
|
38
|
-
``,
|
|
39
|
-
`项目地址:[GitHub](${GITHUB_URL})`,
|
|
40
|
-
].join("\n");
|
|
41
|
-
}
|
|
42
|
-
return [
|
|
43
|
-
`🆕 发现新版本`,
|
|
44
|
-
``,
|
|
45
|
-
`当前版本:**v${PLUGIN_VERSION}**`,
|
|
46
|
-
`最新版本:**v${info.latest}**`,
|
|
47
|
-
``,
|
|
48
|
-
`📖 升级指引:[点击查看](${url})`,
|
|
49
|
-
`🌟 官方 GitHub 仓库:[点击前往](${GITHUB_URL})`,
|
|
50
|
-
].join("\n");
|
|
51
|
-
}
|
|
52
|
-
// ── hot-reload 模式:执行热更新 ──
|
|
53
|
-
if (ctx.type !== "c2c") {
|
|
54
|
-
return `💡 请在私聊中使用此指令`;
|
|
55
|
-
}
|
|
56
|
-
if (isUpgrading()) {
|
|
57
|
-
return `⏳ 正在升级中,请稍候...`;
|
|
58
|
-
}
|
|
59
|
-
let isForce = false;
|
|
60
|
-
let isLatest = false;
|
|
61
|
-
let isLocal = false;
|
|
62
|
-
let versionArg;
|
|
63
|
-
let pkgArg;
|
|
64
|
-
const tokens = args ? args.split(/\s+/).filter(Boolean) : [];
|
|
65
|
-
for (let i = 0; i < tokens.length; i += 1) {
|
|
66
|
-
const t = tokens[i];
|
|
67
|
-
if (t === "--force") {
|
|
68
|
-
isForce = true;
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
if (t === "--latest") {
|
|
72
|
-
isLatest = true;
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
if (t === "--local") {
|
|
76
|
-
isLocal = true;
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
if (t === "--pkg") {
|
|
80
|
-
const next = tokens[i + 1];
|
|
81
|
-
if (!next || next.startsWith("--")) {
|
|
82
|
-
return `❌ 参数错误:--pkg 需要包名\n\n示例:/bot-upgrade --pkg ryantest/openclaw-qqbot`;
|
|
83
|
-
}
|
|
84
|
-
pkgArg = next;
|
|
85
|
-
i += 1;
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
if (t.startsWith("--pkg=")) {
|
|
89
|
-
const v = t.slice("--pkg=".length).trim();
|
|
90
|
-
if (!v) {
|
|
91
|
-
return `❌ 参数错误:--pkg 需要包名\n\n示例:/bot-upgrade --pkg ryantest/openclaw-qqbot`;
|
|
92
|
-
}
|
|
93
|
-
pkgArg = v;
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
if (t === "--version") {
|
|
97
|
-
const next = tokens[i + 1];
|
|
98
|
-
if (!next || next.startsWith("--")) {
|
|
99
|
-
return `❌ 参数错误:--version 需要版本号\n\n示例:/bot-upgrade --version 1.6.5`;
|
|
100
|
-
}
|
|
101
|
-
versionArg = next.replace(/^v/, "");
|
|
102
|
-
i += 1;
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
if (t.startsWith("--version=")) {
|
|
106
|
-
const v = t.slice("--version=".length).trim();
|
|
107
|
-
if (!v) {
|
|
108
|
-
return `❌ 参数错误:--version 需要版本号\n\n示例:/bot-upgrade --version 1.6.5`;
|
|
109
|
-
}
|
|
110
|
-
versionArg = v.replace(/^v/, "");
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
if (!t.startsWith("--") && !versionArg) {
|
|
114
|
-
versionArg = t.replace(/^v/, "");
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
// ── 无参数:只展示信息+确认按钮 ──
|
|
119
|
-
if (!versionArg && !isLatest && !isForce) {
|
|
120
|
-
if (info.checkedAt === 0) {
|
|
121
|
-
return `⏳ 版本检查中,请稍后再试`;
|
|
122
|
-
}
|
|
123
|
-
if (info.error) {
|
|
124
|
-
return [
|
|
125
|
-
`❌ 主机网络访问异常,无法检查更新`,
|
|
126
|
-
``,
|
|
127
|
-
`查看手动升级指引:[点击查看](${url})`,
|
|
128
|
-
].join("\n");
|
|
129
|
-
}
|
|
130
|
-
if (!info.hasUpdate) {
|
|
131
|
-
const lines = [
|
|
132
|
-
`✅ 当前已是最新版本 v${PLUGIN_VERSION}`,
|
|
133
|
-
``,
|
|
134
|
-
`项目地址:[GitHub](${GITHUB_URL})`,
|
|
135
|
-
];
|
|
136
|
-
return lines.join("\n");
|
|
137
|
-
}
|
|
138
|
-
return [
|
|
139
|
-
`🆕 发现新版本`,
|
|
140
|
-
``,
|
|
141
|
-
`当前版本:**v${PLUGIN_VERSION}**`,
|
|
142
|
-
`最新版本:**v${info.latest}**`,
|
|
143
|
-
``,
|
|
144
|
-
`升级将重启 Gateway 服务,期间短暂不可用。`,
|
|
145
|
-
`请确认主机网络可正常访问 npm 仓库。`,
|
|
146
|
-
``,
|
|
147
|
-
`**点击确认升级** <qqbot-cmd-enter text="/bot-upgrade --latest" />`,
|
|
148
|
-
``,
|
|
149
|
-
`手动升级指引:[点击查看](${url})`,
|
|
150
|
-
`🌟官方 GitHub 仓库:[点击前往](${GITHUB_URL})`,
|
|
151
|
-
].join("\n");
|
|
152
|
-
}
|
|
153
|
-
let upgradePkg = pkgArg || ctx.accountConfig?.upgradePkg;
|
|
154
|
-
if (upgradePkg) {
|
|
155
|
-
upgradePkg = upgradePkg.trim();
|
|
156
|
-
if (!upgradePkg.startsWith("@"))
|
|
157
|
-
upgradePkg = `@${upgradePkg}`;
|
|
158
|
-
}
|
|
159
|
-
// ── --version 指定版本:先校验版本号是否存在 ──
|
|
160
|
-
if (versionArg) {
|
|
161
|
-
const exists = await checkVersionExists(versionArg, upgradePkg);
|
|
162
|
-
if (!exists) {
|
|
163
|
-
return `❌ 版本 ${versionArg} 不存在,请检查版本号`;
|
|
164
|
-
}
|
|
165
|
-
if (versionArg === PLUGIN_VERSION && !isForce) {
|
|
166
|
-
return `✅ 当前已是 v${PLUGIN_VERSION},无需升级`;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
// ── --latest:检查是否需要升级 ──
|
|
170
|
-
if (isLatest && !versionArg) {
|
|
171
|
-
if (info.checkedAt === 0) {
|
|
172
|
-
return `⏳ 版本检查中,请稍后再试`;
|
|
173
|
-
}
|
|
174
|
-
if (info.error) {
|
|
175
|
-
return [
|
|
176
|
-
`❌ 主机网络访问异常,无法检查更新`,
|
|
177
|
-
``,
|
|
178
|
-
`查看手动升级指引:[点击查看](${url})`,
|
|
179
|
-
].join("\n");
|
|
180
|
-
}
|
|
181
|
-
if (!info.hasUpdate && !isForce) {
|
|
182
|
-
return `✅ 当前已是 v${PLUGIN_VERSION},无需升级`;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
const targetVersion = versionArg || info.latest || undefined;
|
|
186
|
-
const isReinstall = isForce && targetVersion === PLUGIN_VERSION;
|
|
187
|
-
// ── 环境兼容性检查 ──
|
|
188
|
-
const compat = checkUpgradeCompatibility();
|
|
189
|
-
if (!compat.ok) {
|
|
190
|
-
return [
|
|
191
|
-
`🚫 当前环境不满足热更新要求:`,
|
|
192
|
-
``,
|
|
193
|
-
...compat.errors,
|
|
194
|
-
...(compat.warnings.length ? [``, ...compat.warnings] : []),
|
|
195
|
-
``,
|
|
196
|
-
`查看手动升级指引:[点击查看](${url})`,
|
|
197
|
-
].join("\n");
|
|
198
|
-
}
|
|
199
|
-
setUpgrading(true);
|
|
200
|
-
preUpgradeCredentialBackup(ctx.accountId, ctx.appId);
|
|
201
|
-
const startResult = fireHotUpgrade(targetVersion, upgradePkg, isLocal);
|
|
202
|
-
if (!startResult.ok) {
|
|
203
|
-
setUpgrading(false);
|
|
204
|
-
if (startResult.reason === "no-script") {
|
|
205
|
-
return [
|
|
206
|
-
`❌ 未找到升级脚本,无法执行热更新`,
|
|
207
|
-
``,
|
|
208
|
-
`可能原因:升级后脚本目录被清理,或远端下载失败(查看日志了解详情)`,
|
|
209
|
-
`💡 可尝试不带 \`--local\` 重试,或手动升级`,
|
|
210
|
-
``,
|
|
211
|
-
`查看手动升级指引:[点击查看](${url})`,
|
|
212
|
-
].join("\n");
|
|
213
|
-
}
|
|
214
|
-
if (startResult.reason === "no-cli") {
|
|
215
|
-
return [
|
|
216
|
-
`❌ 未找到 CLI 工具,无法执行热更新`,
|
|
217
|
-
``,
|
|
218
|
-
`查看手动升级指引:[点击查看](${url})`,
|
|
219
|
-
].join("\n");
|
|
220
|
-
}
|
|
221
|
-
if (startResult.reason === "no-powershell") {
|
|
222
|
-
return [
|
|
223
|
-
`❌ 未找到 PowerShell,无法执行热更新`,
|
|
224
|
-
``,
|
|
225
|
-
`请确认系统中已安装 PowerShell(Windows 10+ 自带)`,
|
|
226
|
-
`查看手动升级指引:[点击查看](${url})`,
|
|
227
|
-
].join("\n");
|
|
228
|
-
}
|
|
229
|
-
return [
|
|
230
|
-
`❌ 当前环境不支持热更新(需要 bash)`,
|
|
231
|
-
``,
|
|
232
|
-
`查看手动升级指引:[点击查看](${url})`,
|
|
233
|
-
].join("\n");
|
|
234
|
-
}
|
|
235
|
-
saveUpgradeGreetingTarget(ctx.accountId, ctx.appId, ctx.senderId);
|
|
236
|
-
const resultLines = isReinstall
|
|
237
|
-
? [
|
|
238
|
-
`🔄 正在重新安装 v${PLUGIN_VERSION}...`,
|
|
239
|
-
``,
|
|
240
|
-
`预计 30~60 秒完成,届时会自动通知您`,
|
|
241
|
-
]
|
|
242
|
-
: [
|
|
243
|
-
`🔄 正在升级...`,
|
|
244
|
-
``,
|
|
245
|
-
`当前版本:v${PLUGIN_VERSION}`,
|
|
246
|
-
...(targetVersion ? [`目标版本:v${targetVersion}`] : []),
|
|
247
|
-
``,
|
|
248
|
-
`预计 30~60 秒完成,届时会自动通知您`,
|
|
249
|
-
];
|
|
250
|
-
return resultLines.join("\n");
|
|
251
|
-
},
|
|
252
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { getUpdateInfo } from "../update-checker.js";
|
|
2
|
-
import { getFrameworkVersion } from "../upgrade-utils.js";
|
|
3
|
-
import { registerCommand, getPluginVersion } from "../slash-commands.js";
|
|
4
|
-
registerCommand({
|
|
5
|
-
name: "bot-version",
|
|
6
|
-
description: "查看插件版本号",
|
|
7
|
-
usage: [
|
|
8
|
-
`/bot-version`,
|
|
9
|
-
``,
|
|
10
|
-
`查看当前 QQBot 插件版本和 OpenClaw 框架版本。`,
|
|
11
|
-
`同时检查是否有新版本可用。`,
|
|
12
|
-
].join("\n"),
|
|
13
|
-
handler: async () => {
|
|
14
|
-
const PLUGIN_VERSION = getPluginVersion();
|
|
15
|
-
const frameworkVersion = getFrameworkVersion();
|
|
16
|
-
const lines = [
|
|
17
|
-
`🦞框架版本:${frameworkVersion}`,
|
|
18
|
-
`🤖QQBot 插件版本:v${PLUGIN_VERSION}`,
|
|
19
|
-
];
|
|
20
|
-
const info = await getUpdateInfo();
|
|
21
|
-
if (info.checkedAt === 0) {
|
|
22
|
-
lines.push(`⏳ 版本检查中...`);
|
|
23
|
-
}
|
|
24
|
-
else if (info.error) {
|
|
25
|
-
lines.push(`⚠️ 版本检查失败`);
|
|
26
|
-
}
|
|
27
|
-
else if (info.hasUpdate && info.latest) {
|
|
28
|
-
lines.push(`🆕最新可用版本:v${info.latest},点击 <qqbot-cmd-input text="/bot-upgrade" show="/bot-upgrade"/> 查看升级指引`);
|
|
29
|
-
}
|
|
30
|
-
lines.push(`🌟官方 GitHub 仓库:[点击前往](https://github.com/tencent-connect/openclaw-qqbot/)`);
|
|
31
|
-
return lines.join("\n");
|
|
32
|
-
},
|
|
33
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 热更新相关工具函数
|
|
3
|
-
*
|
|
4
|
-
* 包含:框架版本检测、CLI 查找、升级脚本查找/下载/复制、
|
|
5
|
-
* 环境兼容性检查、配置操作、热更新执行引擎
|
|
6
|
-
*/
|
|
7
|
-
export declare function getFrameworkVersion(): string;
|
|
8
|
-
/**
|
|
9
|
-
* 解析框架版本字符串中的日期版本号
|
|
10
|
-
* 输入示例: "OpenClaw 2026.3.13 (61d171a)" → "2026.3.13"
|
|
11
|
-
*/
|
|
12
|
-
export declare function parseFrameworkDateVersion(versionStr: string): string | null;
|
|
13
|
-
/**
|
|
14
|
-
* 找到 CLI 命令名或完整路径(openclaw / clawdbot / moltbot)
|
|
15
|
-
*/
|
|
16
|
-
export declare function findCli(): string | null;
|
|
17
|
-
/**
|
|
18
|
-
* 同步执行 CLI 命令。
|
|
19
|
-
*/
|
|
20
|
-
export declare function execCliSync(cliPath: string, args: string[]): string | null;
|
|
21
|
-
/**
|
|
22
|
-
* 异步执行 CLI 命令。
|
|
23
|
-
*/
|
|
24
|
-
export declare function execCliAsync(cliPath: string, args: string[], opts: {
|
|
25
|
-
timeout?: number;
|
|
26
|
-
env?: NodeJS.ProcessEnv;
|
|
27
|
-
windowsHide?: boolean;
|
|
28
|
-
}, cb: (error: Error | null, stdout: string, stderr: string) => void): void;
|
|
29
|
-
/**
|
|
30
|
-
* 找到升级脚本路径(兼容源码运行、dist 运行、已安装扩展目录、pnpm 全局、打包环境)
|
|
31
|
-
*/
|
|
32
|
-
export declare function getUpgradeScriptPath(): string | null;
|
|
33
|
-
/**
|
|
34
|
-
* 将升级脚本复制到临时位置
|
|
35
|
-
*/
|
|
36
|
-
export declare function copyScriptToTemp(scriptPath: string): string | null;
|
|
37
|
-
/**
|
|
38
|
-
* 从远端下载升级脚本到临时目录,返回临时脚本路径,失败返回 null。
|
|
39
|
-
*/
|
|
40
|
-
export declare function downloadRemoteUpgradeScript(): string | null;
|
|
41
|
-
/**
|
|
42
|
-
* 清理临时升级脚本目录
|
|
43
|
-
*/
|
|
44
|
-
export declare function cleanupTempScript(): void;
|
|
45
|
-
export interface UpgradeCompatResult {
|
|
46
|
-
ok: boolean;
|
|
47
|
-
errors: string[];
|
|
48
|
-
warnings: string[];
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* 检查当前环境是否满足热更新要求
|
|
52
|
-
*/
|
|
53
|
-
export declare function checkUpgradeCompatibility(): UpgradeCompatResult;
|
|
54
|
-
export declare function findBash(): string | null;
|
|
55
|
-
export declare function findPowerShell(): string | null;
|
|
56
|
-
/**
|
|
57
|
-
* 将 openclaw.json 中的 qqbot 插件 source 从 "path" 切换为 "npm"。
|
|
58
|
-
*/
|
|
59
|
-
export declare function switchPluginSourceToNpm(): void;
|
|
60
|
-
/**
|
|
61
|
-
* 热更新前保存当前账户的 appId/secret 到暂存文件。
|
|
62
|
-
*/
|
|
63
|
-
export declare function preUpgradeCredentialBackup(accountId: string, appId: string): void;
|
|
64
|
-
export declare function saveUpgradeGreetingTarget(accountId: string, appId: string, openid: string): void;
|
|
65
|
-
export declare function isUpgrading(): boolean;
|
|
66
|
-
export declare function setUpgrading(v: boolean): void;
|
|
67
|
-
export type HotUpgradeStartResult = {
|
|
68
|
-
ok: boolean;
|
|
69
|
-
reason?: "no-script" | "no-cli" | "no-bash" | "no-powershell";
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* 执行热更新:执行脚本(--no-restart) → 立即触发 gateway restart
|
|
73
|
-
*/
|
|
74
|
-
export declare function fireHotUpgrade(targetVersion?: string, pkg?: string, useLocal?: boolean): HotUpgradeStartResult;
|