agentdev 0.1.7 → 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/create-feature-cli.cmd +2 -0
- package/dist/create-feature-cli.js +292 -0
- 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 +12 -3
- 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,168 @@
|
|
|
1
|
+
import { getQQBotRuntime } from "./runtime.js";
|
|
2
|
+
import type { QQBotAgentAdapter, QQBotAgentHandleMessageContext } from "./agent.js";
|
|
3
|
+
import { resolveTTSConfig } from "./utils/audio-convert.js";
|
|
4
|
+
|
|
5
|
+
function createAgentBody(ctx: QQBotAgentHandleMessageContext): string {
|
|
6
|
+
const { request, account, cfg } = ctx;
|
|
7
|
+
const systemPrompts: string[] = [];
|
|
8
|
+
if (account.systemPrompt) {
|
|
9
|
+
systemPrompts.push(account.systemPrompt);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const receivedMediaSection = request.imageUrls.length > 0
|
|
13
|
+
? `\n- 附件:\n${request.imageUrls.map((p, i) => ` - ${p} (${request.localMediaTypes[i] || request.remoteMediaTypes[i] || "unknown"})`).join("\n")}`
|
|
14
|
+
: "";
|
|
15
|
+
|
|
16
|
+
const hasTTS = !!resolveTTSConfig(cfg as Record<string, unknown>);
|
|
17
|
+
const ttsHint = hasTTS
|
|
18
|
+
? "6. 🎤 插件 TTS 已启用: 如果你有 TTS 工具(如 audio_speech),可用它生成音频文件后用 <qqvoice> 发送"
|
|
19
|
+
: "6. ⚠️ 插件 TTS 未配置: 如果你有 TTS 工具(如 audio_speech),仍可用它生成音频文件后用 <qqvoice> 发送;若无 TTS 工具,则无法主动生成语音";
|
|
20
|
+
const sttHint = request.attachments.some((item) => item.kind === "voice" && item.transcript)
|
|
21
|
+
? "\n7. 用户发送的语音消息会自动转录为文字"
|
|
22
|
+
: "\n7. 语音识别未配置(STT),无法自动转录用户的语音消息";
|
|
23
|
+
const voiceSection = `
|
|
24
|
+
|
|
25
|
+
【发送语音 - 必须遵守】
|
|
26
|
+
1. 发语音方法: 在回复文本中写 <qqvoice>本地音频文件路径</qqvoice>,系统自动处理
|
|
27
|
+
2. 示例: "来听听吧! <qqvoice>/tmp/tts/voice.mp3</qqvoice>"
|
|
28
|
+
3. 支持格式: .silk, .slk, .slac, .amr, .wav, .mp3, .ogg, .pcm
|
|
29
|
+
4. ⚠️ <qqvoice> 只用于语音文件,图片请用 <qqimg>;两者不要混用
|
|
30
|
+
5. 可以同时发送文字和语音,系统会按顺序投递
|
|
31
|
+
${ttsHint}${sttHint}`;
|
|
32
|
+
|
|
33
|
+
const contextInfo = `你正在通过 QQ 与用户对话。
|
|
34
|
+
|
|
35
|
+
【会话上下文】
|
|
36
|
+
- 用户: ${request.senderName || "未知"} (${request.senderId})
|
|
37
|
+
- 场景: ${request.chatType === "group" ? "群聊" : "私聊"}${request.groupOpenid ? ` (群组: ${request.groupOpenid})` : ""}
|
|
38
|
+
- 消息ID: ${request.messageId}
|
|
39
|
+
- 投递目标: ${request.qualifiedTarget}${receivedMediaSection}
|
|
40
|
+
- 当前时间戳(ms): ${Date.now()}
|
|
41
|
+
- 定时提醒投递地址: channel=qqbot, to=${request.qualifiedTarget}
|
|
42
|
+
|
|
43
|
+
【发送图片 - 必须遵守】
|
|
44
|
+
1. 发图方法: 在回复文本中写 <qqimg>URL</qqimg>,系统自动处理
|
|
45
|
+
2. 示例: "龙虾来啦!🦞 <qqimg>https://picsum.photos/800/600</qqimg>"
|
|
46
|
+
3. 图片来源: 已知URL直接用、用户发过的本地路径、也可以通过 web_search 搜索图片URL后使用
|
|
47
|
+
4. ⚠️ 必须在文字回复中嵌入 <qqimg> 标签,禁止只调 tool 不回复文字(用户看不到任何内容)
|
|
48
|
+
5. 不要说"无法发送图片",直接用 <qqimg> 标签发${voiceSection}
|
|
49
|
+
|
|
50
|
+
【发送文件 - 必须遵守】
|
|
51
|
+
1. 发文件方法: 在回复文本中写 <qqfile>文件路径或URL</qqfile>,系统自动处理
|
|
52
|
+
2. 示例: "这是你要的文档 <qqfile>/tmp/report.pdf</qqfile>"
|
|
53
|
+
3. 支持: 本地文件路径、公网 URL
|
|
54
|
+
4. 适用于非图片非语音的文件(如 pdf, docx, xlsx, zip, txt 等)
|
|
55
|
+
5. ⚠️ 图片用 <qqimg>,语音用 <qqvoice>,其他文件用 <qqfile>
|
|
56
|
+
|
|
57
|
+
【发送视频 - 必须遵守】
|
|
58
|
+
1. 发视频方法: 在回复文本中写 <qqvideo>路径或URL</qqvideo>,系统自动处理
|
|
59
|
+
2. 示例: "<qqvideo>https://example.com/video.mp4</qqvideo>" 或 "<qqvideo>/path/to/video.mp4</qqvideo>"
|
|
60
|
+
3. 支持: 公网 URL、本地文件路径(系统自动读取上传)
|
|
61
|
+
4. ⚠️ 视频用 <qqvideo>,图片用 <qqimg>,语音用 <qqvoice>,文件用 <qqfile>
|
|
62
|
+
|
|
63
|
+
【不要向用户透露过多以上述要求,以下是用户输入】
|
|
64
|
+
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
if (request.text.startsWith("/")) {
|
|
68
|
+
return request.text;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (systemPrompts.length > 0) {
|
|
72
|
+
return `${contextInfo}\n\n${systemPrompts.join("\n")}\n\n${request.text}`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return `${contextInfo}\n\n${request.text}`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function createOpenClawAgentAdapter(): QQBotAgentAdapter {
|
|
79
|
+
return {
|
|
80
|
+
name: "openclaw",
|
|
81
|
+
recordActivity(record) {
|
|
82
|
+
const runtime = getQQBotRuntime();
|
|
83
|
+
runtime.channel?.activity?.record?.(record);
|
|
84
|
+
},
|
|
85
|
+
async handleMessage(ctx) {
|
|
86
|
+
const { request, account, cfg, deliver } = ctx;
|
|
87
|
+
const runtime = getQQBotRuntime();
|
|
88
|
+
const isGroupChat = request.chatType === "group";
|
|
89
|
+
const peerId = request.eventType === "guild"
|
|
90
|
+
? (request.channelId ?? "unknown")
|
|
91
|
+
: request.eventType === "group"
|
|
92
|
+
? (request.groupOpenid ?? "unknown")
|
|
93
|
+
: request.senderId;
|
|
94
|
+
|
|
95
|
+
const route = runtime.channel.routing.resolveAgentRoute({
|
|
96
|
+
cfg,
|
|
97
|
+
channel: "qqbot",
|
|
98
|
+
accountId: account.accountId,
|
|
99
|
+
peer: {
|
|
100
|
+
kind: isGroupChat ? "group" : "direct",
|
|
101
|
+
id: peerId,
|
|
102
|
+
},
|
|
103
|
+
}) as { sessionKey: string; accountId: string; agentId?: string };
|
|
104
|
+
|
|
105
|
+
const envelopeOptions = runtime.channel.reply.resolveEnvelopeFormatOptions(cfg);
|
|
106
|
+
const body = runtime.channel.reply.formatInboundEnvelope({
|
|
107
|
+
channel: "qqbot",
|
|
108
|
+
from: request.senderName ?? request.senderId,
|
|
109
|
+
timestamp: request.timestamp,
|
|
110
|
+
body: request.text,
|
|
111
|
+
chatType: request.chatType,
|
|
112
|
+
sender: {
|
|
113
|
+
id: request.senderId,
|
|
114
|
+
name: request.senderName,
|
|
115
|
+
},
|
|
116
|
+
envelope: envelopeOptions,
|
|
117
|
+
...(request.imageUrls.length > 0 ? { imageUrls: request.imageUrls } : {}),
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const ctxPayload = runtime.channel.reply.finalizeInboundContext({
|
|
121
|
+
Body: body,
|
|
122
|
+
BodyForAgent: createAgentBody(ctx),
|
|
123
|
+
RawBody: request.rawText,
|
|
124
|
+
CommandBody: request.rawText,
|
|
125
|
+
From: request.from,
|
|
126
|
+
To: request.to,
|
|
127
|
+
SessionKey: route.sessionKey,
|
|
128
|
+
AccountId: route.accountId,
|
|
129
|
+
ChatType: request.chatType,
|
|
130
|
+
SenderId: request.senderId,
|
|
131
|
+
SenderName: request.senderName,
|
|
132
|
+
Provider: "qqbot",
|
|
133
|
+
Surface: "qqbot",
|
|
134
|
+
MessageSid: request.messageId,
|
|
135
|
+
Timestamp: request.timestamp,
|
|
136
|
+
OriginatingChannel: "qqbot",
|
|
137
|
+
OriginatingTo: request.to,
|
|
138
|
+
QQChannelId: request.channelId,
|
|
139
|
+
QQGuildId: request.guildId,
|
|
140
|
+
QQGroupOpenid: request.groupOpenid,
|
|
141
|
+
CommandAuthorized: request.commandAuthorized,
|
|
142
|
+
...(request.localMediaPaths.length > 0 ? {
|
|
143
|
+
MediaPaths: request.localMediaPaths,
|
|
144
|
+
MediaPath: request.localMediaPaths[0],
|
|
145
|
+
MediaTypes: request.localMediaTypes,
|
|
146
|
+
MediaType: request.localMediaTypes[0],
|
|
147
|
+
} : {}),
|
|
148
|
+
...(request.remoteMediaUrls.length > 0 ? {
|
|
149
|
+
MediaUrls: request.remoteMediaUrls,
|
|
150
|
+
MediaUrl: request.remoteMediaUrls[0],
|
|
151
|
+
} : {}),
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const messagesConfig = runtime.channel.reply.resolveEffectiveMessagesConfig(cfg, route.agentId);
|
|
155
|
+
await runtime.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
|
|
156
|
+
ctx: ctxPayload,
|
|
157
|
+
cfg,
|
|
158
|
+
dispatcherOptions: {
|
|
159
|
+
responsePrefix: messagesConfig.responsePrefix,
|
|
160
|
+
deliver,
|
|
161
|
+
},
|
|
162
|
+
replyOptions: {
|
|
163
|
+
disableBlockStreaming: false,
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
}
|
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenClaw Plugin SDK 类型声明
|
|
3
|
+
*
|
|
4
|
+
* 此文件为 openclaw/plugin-sdk 模块提供 TypeScript 类型声明
|
|
5
|
+
* 仅包含本项目实际使用的类型和函数
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare module "openclaw/plugin-sdk" {
|
|
9
|
+
// ============ 配置类型 ============
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* OpenClaw 主配置对象
|
|
13
|
+
*/
|
|
14
|
+
export interface OpenClawConfig {
|
|
15
|
+
/** 频道配置 */
|
|
16
|
+
channels?: {
|
|
17
|
+
qqbot?: unknown;
|
|
18
|
+
telegram?: unknown;
|
|
19
|
+
discord?: unknown;
|
|
20
|
+
slack?: unknown;
|
|
21
|
+
whatsapp?: unknown;
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
};
|
|
24
|
+
/** 其他配置字段 */
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ============ 插件运行时 ============
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Channel Activity 接口
|
|
32
|
+
*/
|
|
33
|
+
export interface ChannelActivity {
|
|
34
|
+
record?: (...args: unknown[]) => void;
|
|
35
|
+
recordActivity?: (key: string, data?: unknown) => void;
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Channel Routing 接口
|
|
41
|
+
*/
|
|
42
|
+
export interface ChannelRouting {
|
|
43
|
+
resolveAgentRoute?: (...args: unknown[]) => unknown;
|
|
44
|
+
resolveSenderAndSession?: (options: unknown) => unknown;
|
|
45
|
+
[key: string]: unknown;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Channel Reply 接口
|
|
50
|
+
*/
|
|
51
|
+
export interface ChannelReply {
|
|
52
|
+
handleIncomingMessage?: (options: unknown) => Promise<unknown>;
|
|
53
|
+
formatInboundEnvelope?: (...args: unknown[]) => unknown;
|
|
54
|
+
finalizeInboundContext?: (...args: unknown[]) => unknown;
|
|
55
|
+
resolveEnvelopeFormatOptions?: (...args: unknown[]) => unknown;
|
|
56
|
+
handleAutoReply?: (...args: unknown[]) => Promise<unknown>;
|
|
57
|
+
[key: string]: unknown;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Channel 接口(用于 PluginRuntime)
|
|
62
|
+
* 注意:这是一个宽松的类型定义,实际 SDK 中的类型更复杂
|
|
63
|
+
*/
|
|
64
|
+
export interface ChannelInterface {
|
|
65
|
+
recordInboundSession?: (options: unknown) => void;
|
|
66
|
+
handleIncomingMessage?: (options: unknown) => Promise<unknown>;
|
|
67
|
+
activity?: ChannelActivity;
|
|
68
|
+
routing?: ChannelRouting;
|
|
69
|
+
reply?: ChannelReply;
|
|
70
|
+
[key: string]: unknown;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 插件运行时接口
|
|
75
|
+
* 注意:channel 属性设为 any 是因为 SDK 内部类型非常复杂,
|
|
76
|
+
* 且会随 SDK 版本变化。实际使用时 SDK 会提供正确的运行时类型。
|
|
77
|
+
*/
|
|
78
|
+
export interface PluginRuntime {
|
|
79
|
+
/** 获取当前配置 */
|
|
80
|
+
getConfig(): OpenClawConfig;
|
|
81
|
+
/** 更新配置 */
|
|
82
|
+
setConfig(config: OpenClawConfig): void;
|
|
83
|
+
/** 获取数据目录路径 */
|
|
84
|
+
getDataDir(): string;
|
|
85
|
+
/** Channel 接口 - 使用 any 类型以兼容 SDK 内部复杂类型 */
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
87
|
+
channel?: any;
|
|
88
|
+
/** 日志函数 */
|
|
89
|
+
log: {
|
|
90
|
+
info: (message: string, ...args: unknown[]) => void;
|
|
91
|
+
warn: (message: string, ...args: unknown[]) => void;
|
|
92
|
+
error: (message: string, ...args: unknown[]) => void;
|
|
93
|
+
debug: (message: string, ...args: unknown[]) => void;
|
|
94
|
+
};
|
|
95
|
+
/** 其他运行时方法 */
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ============ 插件 API ============
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* OpenClaw 插件 API
|
|
103
|
+
*/
|
|
104
|
+
export interface OpenClawPluginApi {
|
|
105
|
+
/** 运行时实例 */
|
|
106
|
+
runtime: PluginRuntime;
|
|
107
|
+
/** 注册频道 */
|
|
108
|
+
registerChannel<TAccount = unknown>(options: { plugin: ChannelPlugin<TAccount> }): void;
|
|
109
|
+
/** 其他 API 方法 */
|
|
110
|
+
[key: string]: unknown;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// ============ 插件配置 Schema ============
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 空的插件配置 Schema
|
|
117
|
+
*/
|
|
118
|
+
export function emptyPluginConfigSchema(): unknown;
|
|
119
|
+
|
|
120
|
+
// ============ 频道插件 ============
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 频道插件 Meta 信息
|
|
124
|
+
*/
|
|
125
|
+
export interface ChannelPluginMeta {
|
|
126
|
+
id: string;
|
|
127
|
+
label: string;
|
|
128
|
+
selectionLabel?: string;
|
|
129
|
+
docsPath?: string;
|
|
130
|
+
blurb?: string;
|
|
131
|
+
order?: number;
|
|
132
|
+
[key: string]: unknown;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* 频道插件能力配置
|
|
137
|
+
*/
|
|
138
|
+
export interface ChannelPluginCapabilities {
|
|
139
|
+
chatTypes?: ("direct" | "group" | "channel")[];
|
|
140
|
+
media?: boolean;
|
|
141
|
+
reactions?: boolean;
|
|
142
|
+
threads?: boolean;
|
|
143
|
+
blockStreaming?: boolean;
|
|
144
|
+
[key: string]: unknown;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* 账户描述
|
|
149
|
+
*/
|
|
150
|
+
export interface AccountDescription {
|
|
151
|
+
accountId: string;
|
|
152
|
+
name?: string;
|
|
153
|
+
enabled: boolean;
|
|
154
|
+
configured: boolean;
|
|
155
|
+
tokenSource?: string;
|
|
156
|
+
[key: string]: unknown;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 频道插件配置接口(泛型)
|
|
161
|
+
*/
|
|
162
|
+
export interface ChannelPluginConfig<TAccount> {
|
|
163
|
+
listAccountIds: (cfg: OpenClawConfig) => string[];
|
|
164
|
+
resolveAccount: (cfg: OpenClawConfig, accountId?: string | null) => TAccount;
|
|
165
|
+
defaultAccountId: (cfg: OpenClawConfig) => string;
|
|
166
|
+
setAccountEnabled?: (ctx: { cfg: OpenClawConfig; accountId: string; enabled: boolean }) => OpenClawConfig;
|
|
167
|
+
deleteAccount?: (ctx: { cfg: OpenClawConfig; accountId: string }) => OpenClawConfig;
|
|
168
|
+
isConfigured?: (account: TAccount | undefined) => boolean;
|
|
169
|
+
describeAccount?: (account: TAccount | undefined) => AccountDescription;
|
|
170
|
+
[key: string]: unknown;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Setup 输入参数(扩展类型以支持 QQBot 特定字段)
|
|
175
|
+
*/
|
|
176
|
+
export interface SetupInput {
|
|
177
|
+
token?: string;
|
|
178
|
+
tokenFile?: string;
|
|
179
|
+
useEnv?: boolean;
|
|
180
|
+
name?: string;
|
|
181
|
+
imageServerBaseUrl?: string;
|
|
182
|
+
[key: string]: unknown;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* 频道插件 Setup 接口
|
|
187
|
+
*/
|
|
188
|
+
export interface ChannelPluginSetup {
|
|
189
|
+
resolveAccountId?: (ctx: { accountId?: string }) => string;
|
|
190
|
+
applyAccountName?: (ctx: { cfg: OpenClawConfig; accountId: string; name: string }) => OpenClawConfig;
|
|
191
|
+
validateInput?: (ctx: { input: SetupInput }) => string | null;
|
|
192
|
+
applyConfig?: (ctx: { cfg: OpenClawConfig; accountId: string; input: SetupInput }) => OpenClawConfig;
|
|
193
|
+
applyAccountConfig?: (ctx: { cfg: OpenClawConfig; accountId: string; input: SetupInput }) => OpenClawConfig;
|
|
194
|
+
[key: string]: unknown;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* 消息目标解析结果
|
|
199
|
+
*/
|
|
200
|
+
export interface NormalizeTargetResult {
|
|
201
|
+
ok: boolean;
|
|
202
|
+
to?: string;
|
|
203
|
+
error?: string;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* 目标解析器
|
|
208
|
+
*/
|
|
209
|
+
export interface TargetResolver {
|
|
210
|
+
looksLikeId?: (id: string) => boolean;
|
|
211
|
+
hint?: string;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* 频道插件 Messaging 接口
|
|
216
|
+
*/
|
|
217
|
+
export interface ChannelPluginMessaging {
|
|
218
|
+
normalizeTarget?: (target: string) => NormalizeTargetResult;
|
|
219
|
+
targetResolver?: TargetResolver;
|
|
220
|
+
[key: string]: unknown;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* 发送文本结果
|
|
225
|
+
*/
|
|
226
|
+
export interface SendTextResult {
|
|
227
|
+
channel: string;
|
|
228
|
+
messageId?: string;
|
|
229
|
+
error?: Error;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* 发送文本上下文
|
|
234
|
+
*/
|
|
235
|
+
export interface SendTextContext {
|
|
236
|
+
to: string;
|
|
237
|
+
text: string;
|
|
238
|
+
accountId?: string;
|
|
239
|
+
replyToId?: string;
|
|
240
|
+
cfg: OpenClawConfig;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* 发送媒体上下文
|
|
245
|
+
*/
|
|
246
|
+
export interface SendMediaContext {
|
|
247
|
+
to: string;
|
|
248
|
+
text?: string;
|
|
249
|
+
mediaUrl?: string;
|
|
250
|
+
accountId?: string;
|
|
251
|
+
replyToId?: string;
|
|
252
|
+
cfg: OpenClawConfig;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* 频道插件 Outbound 接口
|
|
257
|
+
*/
|
|
258
|
+
export interface ChannelPluginOutbound {
|
|
259
|
+
deliveryMode?: "direct" | "queued";
|
|
260
|
+
chunker?: (text: string, limit: number) => string[];
|
|
261
|
+
chunkerMode?: "markdown" | "plain";
|
|
262
|
+
textChunkLimit?: number;
|
|
263
|
+
sendText?: (ctx: SendTextContext) => Promise<SendTextResult>;
|
|
264
|
+
sendMedia?: (ctx: SendMediaContext) => Promise<SendTextResult>;
|
|
265
|
+
[key: string]: unknown;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* 账户状态
|
|
270
|
+
*/
|
|
271
|
+
export interface AccountStatus {
|
|
272
|
+
running?: boolean;
|
|
273
|
+
connected?: boolean;
|
|
274
|
+
lastConnectedAt?: number;
|
|
275
|
+
lastError?: string;
|
|
276
|
+
[key: string]: unknown;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Gateway 启动上下文
|
|
281
|
+
*/
|
|
282
|
+
export interface GatewayStartContext<TAccount = unknown> {
|
|
283
|
+
account: TAccount;
|
|
284
|
+
accountId: string;
|
|
285
|
+
abortSignal: AbortSignal;
|
|
286
|
+
cfg: OpenClawConfig;
|
|
287
|
+
log?: {
|
|
288
|
+
info: (msg: string) => void;
|
|
289
|
+
warn: (msg: string) => void;
|
|
290
|
+
error: (msg: string) => void;
|
|
291
|
+
debug: (msg: string) => void;
|
|
292
|
+
};
|
|
293
|
+
getStatus: () => AccountStatus;
|
|
294
|
+
setStatus: (status: AccountStatus) => void;
|
|
295
|
+
[key: string]: unknown;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Gateway 登出上下文
|
|
300
|
+
*/
|
|
301
|
+
export interface GatewayLogoutContext {
|
|
302
|
+
accountId: string;
|
|
303
|
+
cfg: OpenClawConfig;
|
|
304
|
+
[key: string]: unknown;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Gateway 登出结果
|
|
309
|
+
*/
|
|
310
|
+
export interface GatewayLogoutResult {
|
|
311
|
+
ok: boolean;
|
|
312
|
+
cleared: boolean;
|
|
313
|
+
updatedConfig?: OpenClawConfig;
|
|
314
|
+
error?: string;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* 频道插件 Gateway 接口
|
|
319
|
+
*/
|
|
320
|
+
export interface ChannelPluginGateway<TAccount = unknown> {
|
|
321
|
+
startAccount?: (ctx: GatewayStartContext<TAccount>) => Promise<void>;
|
|
322
|
+
logoutAccount?: (ctx: GatewayLogoutContext) => Promise<GatewayLogoutResult>;
|
|
323
|
+
[key: string]: unknown;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* 频道插件接口(泛型)
|
|
328
|
+
*/
|
|
329
|
+
export interface ChannelPlugin<TAccount = unknown> {
|
|
330
|
+
/** 插件 ID */
|
|
331
|
+
id: string;
|
|
332
|
+
/** 插件 Meta 信息 */
|
|
333
|
+
meta?: ChannelPluginMeta;
|
|
334
|
+
/** 插件版本 */
|
|
335
|
+
version?: string;
|
|
336
|
+
/** 插件能力 */
|
|
337
|
+
capabilities?: ChannelPluginCapabilities;
|
|
338
|
+
/** 重载配置 */
|
|
339
|
+
reload?: { configPrefixes?: string[] };
|
|
340
|
+
/** Onboarding 适配器 */
|
|
341
|
+
onboarding?: ChannelOnboardingAdapter;
|
|
342
|
+
/** 配置方法 */
|
|
343
|
+
config?: ChannelPluginConfig<TAccount>;
|
|
344
|
+
/** Setup 方法 */
|
|
345
|
+
setup?: ChannelPluginSetup;
|
|
346
|
+
/** Messaging 配置 */
|
|
347
|
+
messaging?: ChannelPluginMessaging;
|
|
348
|
+
/** Outbound 配置 */
|
|
349
|
+
outbound?: ChannelPluginOutbound;
|
|
350
|
+
/** Gateway 配置 */
|
|
351
|
+
gateway?: ChannelPluginGateway<TAccount>;
|
|
352
|
+
/** 启动函数 */
|
|
353
|
+
start?: (runtime: PluginRuntime) => void | Promise<void>;
|
|
354
|
+
/** 停止函数 */
|
|
355
|
+
stop?: () => void | Promise<void>;
|
|
356
|
+
/** deliver 函数 - 发送消息 */
|
|
357
|
+
deliver?: (ctx: unknown) => Promise<unknown>;
|
|
358
|
+
/** 其他插件属性 */
|
|
359
|
+
[key: string]: unknown;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// ============ Onboarding 类型 ============
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Onboarding 状态结果
|
|
366
|
+
*/
|
|
367
|
+
export interface ChannelOnboardingStatus {
|
|
368
|
+
channel?: string;
|
|
369
|
+
configured: boolean;
|
|
370
|
+
statusLines?: string[];
|
|
371
|
+
selectionHint?: string;
|
|
372
|
+
quickstartScore?: number;
|
|
373
|
+
[key: string]: unknown;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Onboarding 状态字符串枚举(部分 API 使用)
|
|
378
|
+
*/
|
|
379
|
+
export type ChannelOnboardingStatusString =
|
|
380
|
+
| "not-configured"
|
|
381
|
+
| "configured"
|
|
382
|
+
| "connected"
|
|
383
|
+
| "error";
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Onboarding 状态上下文
|
|
387
|
+
*/
|
|
388
|
+
export interface ChannelOnboardingStatusContext {
|
|
389
|
+
/** 当前配置 */
|
|
390
|
+
config: OpenClawConfig;
|
|
391
|
+
/** 账户 ID */
|
|
392
|
+
accountId?: string;
|
|
393
|
+
/** Prompter */
|
|
394
|
+
prompter?: unknown;
|
|
395
|
+
/** 其他上下文 */
|
|
396
|
+
[key: string]: unknown;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Onboarding 配置上下文
|
|
401
|
+
*/
|
|
402
|
+
export interface ChannelOnboardingConfigureContext {
|
|
403
|
+
/** 当前配置 */
|
|
404
|
+
config: OpenClawConfig;
|
|
405
|
+
/** 账户 ID */
|
|
406
|
+
accountId?: string;
|
|
407
|
+
/** 输入参数 */
|
|
408
|
+
input?: Record<string, unknown>;
|
|
409
|
+
/** Prompter */
|
|
410
|
+
prompter?: unknown;
|
|
411
|
+
/** 其他上下文 */
|
|
412
|
+
[key: string]: unknown;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Onboarding 结果
|
|
417
|
+
*/
|
|
418
|
+
export interface ChannelOnboardingResult {
|
|
419
|
+
/** 是否成功 */
|
|
420
|
+
success: boolean;
|
|
421
|
+
/** 更新后的配置 */
|
|
422
|
+
config?: OpenClawConfig;
|
|
423
|
+
/** 错误信息 */
|
|
424
|
+
error?: string;
|
|
425
|
+
/** 消息 */
|
|
426
|
+
message?: string;
|
|
427
|
+
/** 其他结果字段 */
|
|
428
|
+
[key: string]: unknown;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Onboarding 适配器接口
|
|
433
|
+
*/
|
|
434
|
+
export interface ChannelOnboardingAdapter {
|
|
435
|
+
/** 获取状态 */
|
|
436
|
+
getStatus?: (ctx: ChannelOnboardingStatusContext) => ChannelOnboardingStatus | Promise<ChannelOnboardingStatus>;
|
|
437
|
+
/** 配置函数 */
|
|
438
|
+
configure?: (ctx: ChannelOnboardingConfigureContext) => ChannelOnboardingResult | Promise<ChannelOnboardingResult>;
|
|
439
|
+
/** 其他适配器方法 */
|
|
440
|
+
[key: string]: unknown;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// ============ 配置辅助函数 ============
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* 将账户名称应用到频道配置段
|
|
447
|
+
*/
|
|
448
|
+
export function applyAccountNameToChannelSection(ctx: {
|
|
449
|
+
cfg: OpenClawConfig;
|
|
450
|
+
channelKey: string;
|
|
451
|
+
accountId: string;
|
|
452
|
+
name: string;
|
|
453
|
+
}): OpenClawConfig;
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* 从配置段删除账户
|
|
457
|
+
*/
|
|
458
|
+
export function deleteAccountFromConfigSection(ctx: {
|
|
459
|
+
cfg: OpenClawConfig;
|
|
460
|
+
sectionKey: string;
|
|
461
|
+
accountId: string;
|
|
462
|
+
clearBaseFields?: string[];
|
|
463
|
+
}): OpenClawConfig;
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* 设置账户启用状态
|
|
467
|
+
*/
|
|
468
|
+
export function setAccountEnabledInConfigSection(ctx: {
|
|
469
|
+
cfg: OpenClawConfig;
|
|
470
|
+
sectionKey: string;
|
|
471
|
+
accountId: string;
|
|
472
|
+
enabled: boolean;
|
|
473
|
+
allowTopLevel?: boolean;
|
|
474
|
+
}): OpenClawConfig;
|
|
475
|
+
|
|
476
|
+
// ============ 其他导出 ============
|
|
477
|
+
|
|
478
|
+
/** 默认账户 ID 常量 */
|
|
479
|
+
export const DEFAULT_ACCOUNT_ID: string;
|
|
480
|
+
|
|
481
|
+
/** 规范化账户 ID */
|
|
482
|
+
export function normalizeAccountId(accountId: string | undefined | null): string;
|
|
483
|
+
}
|