agentdev 0.1.8 → 0.1.9
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/BasicAgent-UWXLSZP2.js +13 -0
- package/dist/ExplorerAgent-LCM3JQS4.js +13 -0
- package/dist/{chunk-LQTEETML.js → chunk-5T4C2XRT.js} +12 -7
- package/dist/chunk-5T4C2XRT.js.map +1 -0
- package/dist/{chunk-OBOU27DM.js → chunk-A354ZCZF.js} +6735 -1822
- package/dist/chunk-A354ZCZF.js.map +1 -0
- package/dist/{chunk-TSASFMRF.js → chunk-BAP2GCYH.js} +1 -1
- package/dist/chunk-BAP2GCYH.js.map +1 -0
- package/dist/{chunk-3BPSNNK3.js → chunk-EECW6PYP.js} +11 -9
- package/dist/chunk-EECW6PYP.js.map +1 -0
- package/dist/chunk-G5ECPY4K.js +551 -0
- package/dist/chunk-G5ECPY4K.js.map +1 -0
- package/dist/{chunk-LLV3W326.js → chunk-NORTAQIL.js} +67 -20
- package/dist/chunk-NORTAQIL.js.map +1 -0
- package/dist/{chunk-F3PR7UTL.js → chunk-QFHPUAUQ.js} +5 -3
- package/dist/{chunk-F3PR7UTL.js.map → chunk-QFHPUAUQ.js.map} +1 -1
- package/dist/cli/server.js +2 -2
- package/dist/cli/viewer.js +2 -2
- package/dist/features/shell/templates/bash.render.d.ts +1 -1
- package/dist/features/websearch/templates/web-fetch.render.d.ts +1 -1
- package/dist/index.d.ts +1733 -500
- package/dist/index.js +30 -8
- package/dist/index.js.map +1 -1
- package/dist/{notification-3VEAP7YF.js → notification-NWVOS2WR.js} +3 -3
- package/dist/tools-LDR3LIJP.js +14 -0
- package/dist/tools-LDR3LIJP.js.map +1 -0
- package/dist/{types-DUKIIntb.d.ts → types-CF5UsxD9.d.ts} +3 -0
- package/node_modules/@sliverp/qqbot/LICENSE +21 -0
- package/node_modules/@sliverp/qqbot/README.md +427 -0
- package/node_modules/@sliverp/qqbot/README.standalone.zh.md +77 -0
- package/node_modules/@sliverp/qqbot/README.zh.md +423 -0
- package/node_modules/@sliverp/qqbot/bin/qqbot-cli.js +227 -0
- package/node_modules/@sliverp/qqbot/clawdbot.plugin.json +16 -0
- package/node_modules/@sliverp/qqbot/dist/index.d.ts +20 -0
- package/node_modules/@sliverp/qqbot/dist/index.js +25 -0
- package/node_modules/@sliverp/qqbot/dist/src/agent.d.ts +76 -0
- package/node_modules/@sliverp/qqbot/dist/src/agent.js +36 -0
- package/node_modules/@sliverp/qqbot/dist/src/api.d.ts +138 -0
- package/node_modules/@sliverp/qqbot/dist/src/api.js +523 -0
- package/node_modules/@sliverp/qqbot/dist/src/channel.d.ts +3 -0
- package/node_modules/@sliverp/qqbot/dist/src/channel.js +349 -0
- package/node_modules/@sliverp/qqbot/dist/src/config.d.ts +25 -0
- package/node_modules/@sliverp/qqbot/dist/src/config.js +156 -0
- package/node_modules/@sliverp/qqbot/dist/src/demo-standalone.d.ts +1 -0
- package/node_modules/@sliverp/qqbot/dist/src/demo-standalone.js +125 -0
- package/node_modules/@sliverp/qqbot/dist/src/gateway.d.ts +20 -0
- package/node_modules/@sliverp/qqbot/dist/src/gateway.js +2156 -0
- package/node_modules/@sliverp/qqbot/dist/src/image-server.d.ts +62 -0
- package/node_modules/@sliverp/qqbot/dist/src/image-server.js +401 -0
- package/node_modules/@sliverp/qqbot/dist/src/known-users.d.ts +100 -0
- package/node_modules/@sliverp/qqbot/dist/src/known-users.js +263 -0
- package/node_modules/@sliverp/qqbot/dist/src/onboarding.d.ts +10 -0
- package/node_modules/@sliverp/qqbot/dist/src/onboarding.js +203 -0
- package/node_modules/@sliverp/qqbot/dist/src/openclaw-agent-adapter.d.ts +2 -0
- package/node_modules/@sliverp/qqbot/dist/src/openclaw-agent-adapter.js +155 -0
- package/node_modules/@sliverp/qqbot/dist/src/outbound.d.ts +150 -0
- package/node_modules/@sliverp/qqbot/dist/src/outbound.js +1175 -0
- package/node_modules/@sliverp/qqbot/dist/src/proactive.d.ts +170 -0
- package/node_modules/@sliverp/qqbot/dist/src/proactive.js +399 -0
- package/node_modules/@sliverp/qqbot/dist/src/runtime.d.ts +5 -0
- package/node_modules/@sliverp/qqbot/dist/src/runtime.js +16 -0
- package/node_modules/@sliverp/qqbot/dist/src/session-store.d.ts +52 -0
- package/node_modules/@sliverp/qqbot/dist/src/session-store.js +254 -0
- package/node_modules/@sliverp/qqbot/dist/src/types.d.ts +145 -0
- package/node_modules/@sliverp/qqbot/dist/src/types.js +1 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/audio-convert.d.ts +73 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/audio-convert.js +645 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/file-utils.d.ts +46 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/file-utils.js +107 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/image-size.d.ts +51 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/image-size.js +234 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/media-tags.d.ts +14 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/media-tags.js +120 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/payload.d.ts +112 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/payload.js +186 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/platform.d.ts +126 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/platform.js +358 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/upload-cache.d.ts +34 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/upload-cache.js +93 -0
- package/node_modules/@sliverp/qqbot/dist/standalone.d.ts +6 -0
- package/node_modules/@sliverp/qqbot/dist/standalone.js +6 -0
- package/node_modules/@sliverp/qqbot/index.ts +30 -0
- package/node_modules/@sliverp/qqbot/moltbot.plugin.json +16 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/LICENSE +201 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/README.md +134 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/browser.js +17 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/cjs/browser.js +16 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/cjs/node.js +219 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/index.d.ts +4 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/node.js +223 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/package.json +54 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/index.js +5 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/package.json +36 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/WASMAudioDecoderCommon.js +231 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/WASMAudioDecoderWorker.js +129 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/README +67 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/build_puff.js +31 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/puff.c +863 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/puff.h +35 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/utilities.js +3 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/types.d.ts +7 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/README.md +265 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/dist/mpg123-decoder.min.js +185 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/dist/mpg123-decoder.min.js.map +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/index.js +8 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/package.json +58 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/src/EmscriptenWasm.js +464 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/src/MPEGDecoder.js +200 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/src/MPEGDecoderWebWorker.js +21 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/types.d.ts +30 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/LICENSE +21 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/README.md +85 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/index.cjs +16 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/index.d.ts +70 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/index.mjs +16 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/silk.wasm +0 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/utils.d.ts +4 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/package.json +39 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/.github/FUNDING.yml +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/.prettierignore +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/LICENSE +7 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/README.md +163 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/dist/esm.js +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/dist/index.js +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/package.json +50 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/rollup.config.js +27 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/src/simple-yenc.js +302 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/LICENSE +20 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/README.md +548 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/browser.js +8 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/index.js +13 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/buffer-util.js +131 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/constants.js +19 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/receiver.js +706 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/sender.js +602 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/stream.js +161 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/websocket-server.js +554 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/websocket.js +1393 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/package.json +69 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/wrapper.mjs +8 -0
- package/node_modules/@sliverp/qqbot/openclaw.plugin.json +16 -0
- package/node_modules/@sliverp/qqbot/package.json +81 -0
- package/node_modules/@sliverp/qqbot/skills/qqbot-cron/SKILL.md +513 -0
- package/node_modules/@sliverp/qqbot/skills/qqbot-media/SKILL.md +194 -0
- package/node_modules/@sliverp/qqbot/src/agent.ts +133 -0
- package/node_modules/@sliverp/qqbot/src/api.ts +704 -0
- package/node_modules/@sliverp/qqbot/src/channel.ts +380 -0
- package/node_modules/@sliverp/qqbot/src/config.ts +182 -0
- package/node_modules/@sliverp/qqbot/src/demo-standalone.ts +144 -0
- package/node_modules/@sliverp/qqbot/src/gateway.ts +2285 -0
- package/node_modules/@sliverp/qqbot/src/image-server.ts +474 -0
- package/node_modules/@sliverp/qqbot/src/known-users.ts +353 -0
- package/node_modules/@sliverp/qqbot/src/onboarding.ts +274 -0
- package/node_modules/@sliverp/qqbot/src/openclaw-agent-adapter.ts +168 -0
- package/node_modules/@sliverp/qqbot/src/openclaw-plugin-sdk.d.ts +483 -0
- package/node_modules/@sliverp/qqbot/src/outbound.ts +1301 -0
- package/node_modules/@sliverp/qqbot/src/proactive.ts +530 -0
- package/node_modules/@sliverp/qqbot/src/runtime.ts +22 -0
- package/node_modules/@sliverp/qqbot/src/session-store.ts +303 -0
- package/node_modules/@sliverp/qqbot/src/types.ts +153 -0
- package/node_modules/@sliverp/qqbot/src/utils/audio-convert.ts +738 -0
- package/node_modules/@sliverp/qqbot/src/utils/file-utils.ts +122 -0
- package/node_modules/@sliverp/qqbot/src/utils/image-size.ts +266 -0
- package/node_modules/@sliverp/qqbot/src/utils/media-tags.ts +134 -0
- package/node_modules/@sliverp/qqbot/src/utils/payload.ts +265 -0
- package/node_modules/@sliverp/qqbot/src/utils/platform.ts +404 -0
- package/node_modules/@sliverp/qqbot/src/utils/upload-cache.ts +128 -0
- package/node_modules/@sliverp/qqbot/standalone.ts +6 -0
- package/node_modules/@sliverp/qqbot/tsconfig.json +16 -0
- package/package.json +9 -1
- package/dist/BasicAgent-QWEYCLV5.js +0 -12
- package/dist/ExplorerAgent-4IT22VB7.js +0 -12
- package/dist/chunk-3BPSNNK3.js.map +0 -1
- package/dist/chunk-LLV3W326.js.map +0 -1
- package/dist/chunk-LQTEETML.js.map +0 -1
- package/dist/chunk-OBOU27DM.js.map +0 -1
- package/dist/chunk-TSASFMRF.js.map +0 -1
- /package/dist/{BasicAgent-QWEYCLV5.js.map → BasicAgent-UWXLSZP2.js.map} +0 -0
- /package/dist/{ExplorerAgent-4IT22VB7.js.map → ExplorerAgent-LCM3JQS4.js.map} +0 -0
- /package/dist/{notification-3VEAP7YF.js.map → notification-NWVOS2WR.js.map} +0 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* QQBot CLI - 用于升级和管理 QQBot 插件
|
|
5
|
+
*
|
|
6
|
+
* 用法:
|
|
7
|
+
* npx @sliverp/qqbot upgrade # 升级插件
|
|
8
|
+
* npx @sliverp/qqbot install # 安装插件
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { execSync } from 'child_process';
|
|
12
|
+
import { existsSync, readFileSync, writeFileSync, rmSync } from 'fs';
|
|
13
|
+
import { homedir } from 'os';
|
|
14
|
+
import { join, dirname } from 'path';
|
|
15
|
+
import { fileURLToPath } from 'url';
|
|
16
|
+
|
|
17
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
+
const __dirname = dirname(__filename);
|
|
19
|
+
|
|
20
|
+
// 获取包的根目录
|
|
21
|
+
const PKG_ROOT = join(__dirname, '..');
|
|
22
|
+
|
|
23
|
+
const args = process.argv.slice(2);
|
|
24
|
+
const command = args[0];
|
|
25
|
+
|
|
26
|
+
// 检测使用的是 clawdbot 还是 openclaw
|
|
27
|
+
function detectInstallation() {
|
|
28
|
+
const home = homedir();
|
|
29
|
+
if (existsSync(join(home, '.openclaw'))) {
|
|
30
|
+
return 'openclaw';
|
|
31
|
+
}
|
|
32
|
+
if (existsSync(join(home, '.clawdbot'))) {
|
|
33
|
+
return 'clawdbot';
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 清理旧版本插件,返回旧的 qqbot 配置
|
|
39
|
+
function cleanupInstallation(appName) {
|
|
40
|
+
const home = homedir();
|
|
41
|
+
const appDir = join(home, `.${appName}`);
|
|
42
|
+
const configFile = join(appDir, `${appName}.json`);
|
|
43
|
+
const extensionDir = join(appDir, 'extensions', 'qqbot');
|
|
44
|
+
|
|
45
|
+
let oldQqbotConfig = null;
|
|
46
|
+
|
|
47
|
+
console.log(`\n>>> 处理 ${appName} 安装...`);
|
|
48
|
+
|
|
49
|
+
// 1. 先读取旧的 qqbot 配置
|
|
50
|
+
if (existsSync(configFile)) {
|
|
51
|
+
try {
|
|
52
|
+
const config = JSON.parse(readFileSync(configFile, 'utf8'));
|
|
53
|
+
if (config.channels?.qqbot) {
|
|
54
|
+
oldQqbotConfig = { ...config.channels.qqbot };
|
|
55
|
+
console.log('已保存旧的 qqbot 配置');
|
|
56
|
+
}
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.error('读取配置文件失败:', err.message);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 2. 删除旧的扩展目录
|
|
63
|
+
if (existsSync(extensionDir)) {
|
|
64
|
+
console.log(`删除旧版本插件: ${extensionDir}`);
|
|
65
|
+
rmSync(extensionDir, { recursive: true, force: true });
|
|
66
|
+
} else {
|
|
67
|
+
console.log('未找到旧版本插件目录,跳过删除');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 3. 清理配置文件中的 qqbot 相关字段
|
|
71
|
+
if (existsSync(configFile)) {
|
|
72
|
+
console.log('清理配置文件中的 qqbot 字段...');
|
|
73
|
+
try {
|
|
74
|
+
const config = JSON.parse(readFileSync(configFile, 'utf8'));
|
|
75
|
+
|
|
76
|
+
// 删除 channels.qqbot
|
|
77
|
+
if (config.channels?.qqbot) {
|
|
78
|
+
delete config.channels.qqbot;
|
|
79
|
+
console.log(' - 已删除 channels.qqbot');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 删除 plugins.entries.qqbot
|
|
83
|
+
if (config.plugins?.entries?.qqbot) {
|
|
84
|
+
delete config.plugins.entries.qqbot;
|
|
85
|
+
console.log(' - 已删除 plugins.entries.qqbot');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// 删除 plugins.installs.qqbot
|
|
89
|
+
if (config.plugins?.installs?.qqbot) {
|
|
90
|
+
delete config.plugins.installs.qqbot;
|
|
91
|
+
console.log(' - 已删除 plugins.installs.qqbot');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
writeFileSync(configFile, JSON.stringify(config, null, 2));
|
|
95
|
+
console.log('配置文件已更新');
|
|
96
|
+
} catch (err) {
|
|
97
|
+
console.error('清理配置文件失败:', err.message);
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
console.log(`未找到配置文件: ${configFile}`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return oldQqbotConfig;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// 执行命令并继承 stdio
|
|
107
|
+
function runCommand(cmd, args = []) {
|
|
108
|
+
try {
|
|
109
|
+
execSync([cmd, ...args].join(' '), { stdio: 'inherit' });
|
|
110
|
+
return true;
|
|
111
|
+
} catch (err) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// 升级命令
|
|
117
|
+
function upgrade() {
|
|
118
|
+
console.log('=== QQBot 插件升级脚本 ===');
|
|
119
|
+
|
|
120
|
+
let foundInstallation = null;
|
|
121
|
+
let savedConfig = null;
|
|
122
|
+
const home = homedir();
|
|
123
|
+
|
|
124
|
+
// 检查 openclaw
|
|
125
|
+
if (existsSync(join(home, '.openclaw'))) {
|
|
126
|
+
savedConfig = cleanupInstallation('openclaw');
|
|
127
|
+
foundInstallation = 'openclaw';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// 检查 clawdbot
|
|
131
|
+
if (existsSync(join(home, '.clawdbot'))) {
|
|
132
|
+
const clawdbotConfig = cleanupInstallation('clawdbot');
|
|
133
|
+
if (!savedConfig) savedConfig = clawdbotConfig;
|
|
134
|
+
foundInstallation = 'clawdbot';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (!foundInstallation) {
|
|
138
|
+
console.log('\n未找到 clawdbot 或 openclaw 安装目录');
|
|
139
|
+
console.log('请确认已安装 clawdbot 或 openclaw');
|
|
140
|
+
process.exit(1);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
console.log('\n=== 清理完成 ===');
|
|
144
|
+
|
|
145
|
+
// 自动安装插件
|
|
146
|
+
console.log('\n[1/2] 安装新版本插件...');
|
|
147
|
+
runCommand(foundInstallation, ['plugins', 'install', '@sliverp/qqbot']);
|
|
148
|
+
|
|
149
|
+
// 自动配置通道(使用保存的 appId 和 clientSecret)
|
|
150
|
+
console.log('\n[2/2] 配置机器人通道...');
|
|
151
|
+
if (savedConfig?.appId && savedConfig?.clientSecret) {
|
|
152
|
+
const token = `${savedConfig.appId}:${savedConfig.clientSecret}`;
|
|
153
|
+
console.log(`使用已保存的配置: appId=${savedConfig.appId}`);
|
|
154
|
+
runCommand(foundInstallation, ['channels', 'add', '--channel', 'qqbot', '--token', `"${token}"`]);
|
|
155
|
+
|
|
156
|
+
// 恢复其他配置项(如 markdownSupport)
|
|
157
|
+
if (savedConfig.markdownSupport !== undefined) {
|
|
158
|
+
runCommand(foundInstallation, ['config', 'set', 'channels.qqbot.markdownSupport', String(savedConfig.markdownSupport)]);
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
console.log('未找到已保存的 qqbot 配置,请手动配置:');
|
|
162
|
+
console.log(` ${foundInstallation} channels add --channel qqbot --token "AppID:AppSecret"`);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
console.log('\n=== 升级完成 ===');
|
|
167
|
+
console.log(`\n可以运行以下命令前台运行启动机器人:`);
|
|
168
|
+
console.log(` ${foundInstallation} gateway stop && ${foundInstallation} gateway --port 18789 --verbose`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// 安装命令
|
|
172
|
+
function install() {
|
|
173
|
+
console.log('=== QQBot 插件安装 ===');
|
|
174
|
+
|
|
175
|
+
const cmd = detectInstallation();
|
|
176
|
+
if (!cmd) {
|
|
177
|
+
console.log('未找到 clawdbot 或 openclaw 安装');
|
|
178
|
+
console.log('请先安装 openclaw 或 clawdbot');
|
|
179
|
+
process.exit(1);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
console.log(`\n使用 ${cmd} 安装插件...`);
|
|
183
|
+
runCommand(cmd, ['plugins', 'install', '@sliverp/qqbot']);
|
|
184
|
+
|
|
185
|
+
console.log('\n=== 安装完成 ===');
|
|
186
|
+
console.log('\n请配置机器人通道:');
|
|
187
|
+
console.log(` ${cmd} channels add --channel qqbot --token "AppID:AppSecret"`);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// 显示帮助
|
|
191
|
+
function showHelp() {
|
|
192
|
+
console.log(`
|
|
193
|
+
QQBot CLI - QQ机器人插件管理工具
|
|
194
|
+
|
|
195
|
+
用法:
|
|
196
|
+
npx @sliverp/qqbot <命令>
|
|
197
|
+
|
|
198
|
+
命令:
|
|
199
|
+
upgrade 清理旧版本插件(升级前执行)
|
|
200
|
+
install 安装插件到 openclaw/clawdbot
|
|
201
|
+
|
|
202
|
+
示例:
|
|
203
|
+
npx @sliverp/qqbot upgrade
|
|
204
|
+
npx @sliverp/qqbot install
|
|
205
|
+
`);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// 主入口
|
|
209
|
+
switch (command) {
|
|
210
|
+
case 'upgrade':
|
|
211
|
+
upgrade();
|
|
212
|
+
break;
|
|
213
|
+
case 'install':
|
|
214
|
+
install();
|
|
215
|
+
break;
|
|
216
|
+
case '-h':
|
|
217
|
+
case '--help':
|
|
218
|
+
case 'help':
|
|
219
|
+
showHelp();
|
|
220
|
+
break;
|
|
221
|
+
default:
|
|
222
|
+
if (command) {
|
|
223
|
+
console.log(`未知命令: ${command}`);
|
|
224
|
+
}
|
|
225
|
+
showHelp();
|
|
226
|
+
process.exit(command ? 1 : 0);
|
|
227
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "qqbot",
|
|
3
|
+
"name": "QQ Bot Channel",
|
|
4
|
+
"description": "QQ Bot channel plugin with message support, cron jobs, and proactive messaging",
|
|
5
|
+
"channels": ["qqbot"],
|
|
6
|
+
"skills": ["skills/qqbot-cron", "skills/qqbot-media"],
|
|
7
|
+
"capabilities": {
|
|
8
|
+
"proactiveMessaging": true,
|
|
9
|
+
"cronJobs": true
|
|
10
|
+
},
|
|
11
|
+
"configSchema": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"additionalProperties": false,
|
|
14
|
+
"properties": {}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
2
|
+
declare const plugin: {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
configSchema: unknown;
|
|
7
|
+
register(api: OpenClawPluginApi): void;
|
|
8
|
+
};
|
|
9
|
+
export default plugin;
|
|
10
|
+
export { qqbotPlugin } from "./src/channel.js";
|
|
11
|
+
export { setQQBotRuntime, getQQBotRuntime, hasQQBotRuntime, tryGetQQBotRuntime } from "./src/runtime.js";
|
|
12
|
+
export { setQQBotAgentAdapter, getQQBotAgentAdapter } from "./src/agent.js";
|
|
13
|
+
export { createOpenClawAgentAdapter } from "./src/openclaw-agent-adapter.js";
|
|
14
|
+
export { qqbotOnboardingAdapter } from "./src/onboarding.js";
|
|
15
|
+
export * from "./src/types.js";
|
|
16
|
+
export * from "./src/agent.js";
|
|
17
|
+
export * from "./src/api.js";
|
|
18
|
+
export * from "./src/config.js";
|
|
19
|
+
export * from "./src/gateway.js";
|
|
20
|
+
export * from "./src/outbound.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { emptyPluginConfigSchema } from "openclaw/plugin-sdk";
|
|
2
|
+
import { qqbotPlugin } from "./src/channel.js";
|
|
3
|
+
import { setQQBotRuntime } from "./src/runtime.js";
|
|
4
|
+
const plugin = {
|
|
5
|
+
id: "qqbot",
|
|
6
|
+
name: "QQ Bot",
|
|
7
|
+
description: "QQ Bot channel plugin",
|
|
8
|
+
configSchema: emptyPluginConfigSchema(),
|
|
9
|
+
register(api) {
|
|
10
|
+
setQQBotRuntime(api.runtime);
|
|
11
|
+
api.registerChannel({ plugin: qqbotPlugin });
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default plugin;
|
|
15
|
+
export { qqbotPlugin } from "./src/channel.js";
|
|
16
|
+
export { setQQBotRuntime, getQQBotRuntime, hasQQBotRuntime, tryGetQQBotRuntime } from "./src/runtime.js";
|
|
17
|
+
export { setQQBotAgentAdapter, getQQBotAgentAdapter } from "./src/agent.js";
|
|
18
|
+
export { createOpenClawAgentAdapter } from "./src/openclaw-agent-adapter.js";
|
|
19
|
+
export { qqbotOnboardingAdapter } from "./src/onboarding.js";
|
|
20
|
+
export * from "./src/types.js";
|
|
21
|
+
export * from "./src/agent.js";
|
|
22
|
+
export * from "./src/api.js";
|
|
23
|
+
export * from "./src/config.js";
|
|
24
|
+
export * from "./src/gateway.js";
|
|
25
|
+
export * from "./src/outbound.js";
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { ResolvedQQBotAccount } from "./types.js";
|
|
2
|
+
export interface QQBotAgentLog {
|
|
3
|
+
info: (msg: string) => void;
|
|
4
|
+
error: (msg: string) => void;
|
|
5
|
+
debug?: (msg: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export interface QQBotInboundAttachment {
|
|
8
|
+
kind: "image" | "voice" | "file";
|
|
9
|
+
contentType?: string;
|
|
10
|
+
fileName?: string;
|
|
11
|
+
originalUrl?: string;
|
|
12
|
+
localPath?: string;
|
|
13
|
+
transcript?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface QQBotInboundRequest {
|
|
16
|
+
channel: "qqbot";
|
|
17
|
+
accountId: string;
|
|
18
|
+
eventType: "c2c" | "guild" | "dm" | "group";
|
|
19
|
+
chatType: "direct" | "group";
|
|
20
|
+
senderId: string;
|
|
21
|
+
senderName?: string;
|
|
22
|
+
messageId: string;
|
|
23
|
+
timestamp: number;
|
|
24
|
+
rawText: string;
|
|
25
|
+
text: string;
|
|
26
|
+
from: string;
|
|
27
|
+
to: string;
|
|
28
|
+
qualifiedTarget: string;
|
|
29
|
+
commandAuthorized: boolean;
|
|
30
|
+
channelId?: string;
|
|
31
|
+
guildId?: string;
|
|
32
|
+
groupOpenid?: string;
|
|
33
|
+
imageUrls: string[];
|
|
34
|
+
localMediaPaths: string[];
|
|
35
|
+
localMediaTypes: string[];
|
|
36
|
+
remoteMediaUrls: string[];
|
|
37
|
+
remoteMediaTypes: string[];
|
|
38
|
+
attachments: QQBotInboundAttachment[];
|
|
39
|
+
}
|
|
40
|
+
export interface QQBotAgentOutput {
|
|
41
|
+
text?: string;
|
|
42
|
+
mediaUrl?: string;
|
|
43
|
+
mediaUrls?: string[];
|
|
44
|
+
}
|
|
45
|
+
export interface QQBotAgentDeliverInfo {
|
|
46
|
+
kind: string;
|
|
47
|
+
}
|
|
48
|
+
export interface QQBotAgentActivityRecord {
|
|
49
|
+
channel: "qqbot";
|
|
50
|
+
accountId: string;
|
|
51
|
+
direction: "inbound" | "outbound";
|
|
52
|
+
}
|
|
53
|
+
export interface QQBotAgentHandleMessageContext {
|
|
54
|
+
request: QQBotInboundRequest;
|
|
55
|
+
account: ResolvedQQBotAccount;
|
|
56
|
+
cfg: unknown;
|
|
57
|
+
abortSignal: AbortSignal;
|
|
58
|
+
log?: QQBotAgentLog;
|
|
59
|
+
deliver: (payload: QQBotAgentOutput, info: QQBotAgentDeliverInfo) => Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
export interface QQBotAgentAdapter {
|
|
62
|
+
name?: string;
|
|
63
|
+
recordActivity?: (record: QQBotAgentActivityRecord) => void;
|
|
64
|
+
handleMessage: (ctx: QQBotAgentHandleMessageContext) => Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
export interface QQBotSimpleAgentContext {
|
|
67
|
+
account: ResolvedQQBotAccount;
|
|
68
|
+
cfg: unknown;
|
|
69
|
+
abortSignal: AbortSignal;
|
|
70
|
+
log?: QQBotAgentLog;
|
|
71
|
+
}
|
|
72
|
+
export type QQBotSimpleAgentResult = string | QQBotAgentOutput | Array<string | QQBotAgentOutput> | null | undefined;
|
|
73
|
+
export type QQBotSimpleAgentHandler = (request: QQBotInboundRequest, ctx: QQBotSimpleAgentContext) => Promise<QQBotSimpleAgentResult> | QQBotSimpleAgentResult;
|
|
74
|
+
export declare function createQQBotAgentAdapter(handler: QQBotSimpleAgentHandler): QQBotAgentAdapter;
|
|
75
|
+
export declare function setQQBotAgentAdapter(adapter: QQBotAgentAdapter | null): void;
|
|
76
|
+
export declare function getQQBotAgentAdapter(): QQBotAgentAdapter | null;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
function normalizeSimpleResult(result) {
|
|
2
|
+
if (result === null || result === undefined) {
|
|
3
|
+
return [];
|
|
4
|
+
}
|
|
5
|
+
if (typeof result === "string") {
|
|
6
|
+
return [{ text: result }];
|
|
7
|
+
}
|
|
8
|
+
if (Array.isArray(result)) {
|
|
9
|
+
return result.flatMap((item) => normalizeSimpleResult(item));
|
|
10
|
+
}
|
|
11
|
+
return [result];
|
|
12
|
+
}
|
|
13
|
+
export function createQQBotAgentAdapter(handler) {
|
|
14
|
+
return {
|
|
15
|
+
name: "custom",
|
|
16
|
+
async handleMessage(ctx) {
|
|
17
|
+
const result = await handler(ctx.request, {
|
|
18
|
+
account: ctx.account,
|
|
19
|
+
cfg: ctx.cfg,
|
|
20
|
+
abortSignal: ctx.abortSignal,
|
|
21
|
+
log: ctx.log,
|
|
22
|
+
});
|
|
23
|
+
const outputs = normalizeSimpleResult(result);
|
|
24
|
+
for (const output of outputs) {
|
|
25
|
+
await ctx.deliver(output, { kind: "message" });
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
let currentAgentAdapter = null;
|
|
31
|
+
export function setQQBotAgentAdapter(adapter) {
|
|
32
|
+
currentAgentAdapter = adapter;
|
|
33
|
+
}
|
|
34
|
+
export function getQQBotAgentAdapter() {
|
|
35
|
+
return currentAgentAdapter;
|
|
36
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QQ Bot API 鉴权和请求封装
|
|
3
|
+
* [修复版] 已重构为支持多实例并发,消除全局变量冲突
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 初始化 API 配置
|
|
7
|
+
* @param options.markdownSupport - 是否支持 markdown 消息(默认 false,需要机器人具备该权限才能启用)
|
|
8
|
+
*/
|
|
9
|
+
export declare function initApiConfig(options: {
|
|
10
|
+
markdownSupport?: boolean;
|
|
11
|
+
}): void;
|
|
12
|
+
/**
|
|
13
|
+
* 获取当前是否支持 markdown
|
|
14
|
+
*/
|
|
15
|
+
export declare function isMarkdownSupport(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* 获取 AccessToken(带缓存 + singleflight 并发安全)
|
|
18
|
+
*
|
|
19
|
+
* 使用 singleflight 模式:当多个请求同时发现 Token 过期时,
|
|
20
|
+
* 只有第一个请求会真正去获取新 Token,其他请求复用同一个 Promise。
|
|
21
|
+
*
|
|
22
|
+
* 按 appId 隔离,支持多机器人并发请求。
|
|
23
|
+
*/
|
|
24
|
+
export declare function getAccessToken(appId: string, clientSecret: string): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* 清除 Token 缓存
|
|
27
|
+
* @param appId 选填。如果有,只清空特定账号的缓存;如果没有,清空所有账号。
|
|
28
|
+
*/
|
|
29
|
+
export declare function clearTokenCache(appId?: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* 获取 Token 缓存状态(用于监控)
|
|
32
|
+
*/
|
|
33
|
+
export declare function getTokenStatus(appId: string): {
|
|
34
|
+
status: "valid" | "expired" | "refreshing" | "none";
|
|
35
|
+
expiresAt: number | null;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* 获取全局唯一的消息序号(范围 0 ~ 65535)
|
|
39
|
+
* 使用毫秒级时间戳低位 + 随机数异或混合,无状态,避免碰撞
|
|
40
|
+
*/
|
|
41
|
+
export declare function getNextMsgSeq(_msgId: string): number;
|
|
42
|
+
/**
|
|
43
|
+
* API 请求封装
|
|
44
|
+
*/
|
|
45
|
+
export declare function apiRequest<T = unknown>(accessToken: string, method: string, path: string, body?: unknown, timeoutMs?: number): Promise<T>;
|
|
46
|
+
export declare function getGatewayUrl(accessToken: string): Promise<string>;
|
|
47
|
+
export interface MessageResponse {
|
|
48
|
+
id: string;
|
|
49
|
+
timestamp: number | string;
|
|
50
|
+
}
|
|
51
|
+
export declare function sendC2CMessage(accessToken: string, openid: string, content: string, msgId?: string): Promise<MessageResponse>;
|
|
52
|
+
export declare function sendC2CInputNotify(accessToken: string, openid: string, msgId?: string, inputSecond?: number): Promise<void>;
|
|
53
|
+
export declare function sendChannelMessage(accessToken: string, channelId: string, content: string, msgId?: string): Promise<{
|
|
54
|
+
id: string;
|
|
55
|
+
timestamp: string;
|
|
56
|
+
}>;
|
|
57
|
+
export declare function sendGroupMessage(accessToken: string, groupOpenid: string, content: string, msgId?: string): Promise<MessageResponse>;
|
|
58
|
+
export declare function sendProactiveC2CMessage(accessToken: string, openid: string, content: string): Promise<{
|
|
59
|
+
id: string;
|
|
60
|
+
timestamp: number;
|
|
61
|
+
}>;
|
|
62
|
+
export declare function sendProactiveGroupMessage(accessToken: string, groupOpenid: string, content: string): Promise<{
|
|
63
|
+
id: string;
|
|
64
|
+
timestamp: string;
|
|
65
|
+
}>;
|
|
66
|
+
export declare enum MediaFileType {
|
|
67
|
+
IMAGE = 1,
|
|
68
|
+
VIDEO = 2,
|
|
69
|
+
VOICE = 3,
|
|
70
|
+
FILE = 4
|
|
71
|
+
}
|
|
72
|
+
export interface UploadMediaResponse {
|
|
73
|
+
file_uuid: string;
|
|
74
|
+
file_info: string;
|
|
75
|
+
ttl: number;
|
|
76
|
+
id?: string;
|
|
77
|
+
}
|
|
78
|
+
export declare function uploadC2CMedia(accessToken: string, openid: string, fileType: MediaFileType, url?: string, fileData?: string, srvSendMsg?: boolean, fileName?: string): Promise<UploadMediaResponse>;
|
|
79
|
+
export declare function uploadGroupMedia(accessToken: string, groupOpenid: string, fileType: MediaFileType, url?: string, fileData?: string, srvSendMsg?: boolean, fileName?: string): Promise<UploadMediaResponse>;
|
|
80
|
+
export declare function sendC2CMediaMessage(accessToken: string, openid: string, fileInfo: string, msgId?: string, content?: string): Promise<{
|
|
81
|
+
id: string;
|
|
82
|
+
timestamp: number;
|
|
83
|
+
}>;
|
|
84
|
+
export declare function sendGroupMediaMessage(accessToken: string, groupOpenid: string, fileInfo: string, msgId?: string, content?: string): Promise<{
|
|
85
|
+
id: string;
|
|
86
|
+
timestamp: string;
|
|
87
|
+
}>;
|
|
88
|
+
export declare function sendC2CImageMessage(accessToken: string, openid: string, imageUrl: string, msgId?: string, content?: string): Promise<{
|
|
89
|
+
id: string;
|
|
90
|
+
timestamp: number;
|
|
91
|
+
}>;
|
|
92
|
+
export declare function sendGroupImageMessage(accessToken: string, groupOpenid: string, imageUrl: string, msgId?: string, content?: string): Promise<{
|
|
93
|
+
id: string;
|
|
94
|
+
timestamp: string;
|
|
95
|
+
}>;
|
|
96
|
+
export declare function sendC2CVoiceMessage(accessToken: string, openid: string, voiceBase64: string, msgId?: string): Promise<{
|
|
97
|
+
id: string;
|
|
98
|
+
timestamp: number;
|
|
99
|
+
}>;
|
|
100
|
+
export declare function sendGroupVoiceMessage(accessToken: string, groupOpenid: string, voiceBase64: string, msgId?: string): Promise<{
|
|
101
|
+
id: string;
|
|
102
|
+
timestamp: string;
|
|
103
|
+
}>;
|
|
104
|
+
export declare function sendC2CFileMessage(accessToken: string, openid: string, fileBase64?: string, fileUrl?: string, msgId?: string, fileName?: string): Promise<{
|
|
105
|
+
id: string;
|
|
106
|
+
timestamp: number;
|
|
107
|
+
}>;
|
|
108
|
+
export declare function sendGroupFileMessage(accessToken: string, groupOpenid: string, fileBase64?: string, fileUrl?: string, msgId?: string, fileName?: string): Promise<{
|
|
109
|
+
id: string;
|
|
110
|
+
timestamp: string;
|
|
111
|
+
}>;
|
|
112
|
+
export declare function sendC2CVideoMessage(accessToken: string, openid: string, videoUrl?: string, videoBase64?: string, msgId?: string, content?: string): Promise<{
|
|
113
|
+
id: string;
|
|
114
|
+
timestamp: number;
|
|
115
|
+
}>;
|
|
116
|
+
export declare function sendGroupVideoMessage(accessToken: string, groupOpenid: string, videoUrl?: string, videoBase64?: string, msgId?: string, content?: string): Promise<{
|
|
117
|
+
id: string;
|
|
118
|
+
timestamp: string;
|
|
119
|
+
}>;
|
|
120
|
+
interface BackgroundTokenRefreshOptions {
|
|
121
|
+
refreshAheadMs?: number;
|
|
122
|
+
randomOffsetMs?: number;
|
|
123
|
+
minRefreshIntervalMs?: number;
|
|
124
|
+
retryDelayMs?: number;
|
|
125
|
+
log?: {
|
|
126
|
+
info: (msg: string) => void;
|
|
127
|
+
error: (msg: string) => void;
|
|
128
|
+
debug?: (msg: string) => void;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export declare function startBackgroundTokenRefresh(appId: string, clientSecret: string, options?: BackgroundTokenRefreshOptions): void;
|
|
132
|
+
/**
|
|
133
|
+
* 停止后台 Token 刷新
|
|
134
|
+
* @param appId 选填。如果有,仅停止该账号的定时刷新。
|
|
135
|
+
*/
|
|
136
|
+
export declare function stopBackgroundTokenRefresh(appId?: string): void;
|
|
137
|
+
export declare function isBackgroundTokenRefreshRunning(appId?: string): boolean;
|
|
138
|
+
export {};
|