@cxyhhhhh/openclaw-qqbot 2.0.0-dev.202607101541 → 2.0.0-dev.202607131536

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.
Files changed (62) hide show
  1. package/README.md +188 -3
  2. package/README.zh.md +190 -3
  3. package/dist/index.cjs +1995 -921
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +6 -0
  6. package/openclaw.plugin.json +1 -1
  7. package/package.json +1 -1
  8. package/scripts/postinstall-link-sdk.js +170 -0
  9. package/skills/qqbot-media/SKILL.md +60 -0
  10. package/src/adapter/contract.ts +1 -1
  11. package/src/adapter/resolve.ts +38 -0
  12. package/src/admin-resolver.ts +181 -0
  13. package/src/api.ts +1333 -0
  14. package/src/approval-handler.ts +505 -0
  15. package/src/channel.ts +15 -0
  16. package/src/credential-backup.ts +72 -0
  17. package/src/deliver-debounce.ts +229 -0
  18. package/src/dispatch/dispatch.ts +95 -75
  19. package/src/features/approval-utils.ts +0 -4
  20. package/src/gateway.ts +2272 -0
  21. package/src/group-history.ts +328 -0
  22. package/src/image-server.ts +675 -0
  23. package/src/inbound-attachments.ts +321 -0
  24. package/src/known-users.ts +353 -0
  25. package/src/message-gating.ts +190 -0
  26. package/src/message-queue.ts +354 -0
  27. package/src/onboarding.ts +282 -0
  28. package/src/openclaw-plugin-sdk.d.ts +16 -0
  29. package/src/outbound/media-send.ts +48 -9
  30. package/src/outbound/streaming-controller.ts +12 -0
  31. package/src/outbound-deliver.ts +486 -0
  32. package/src/outbound.ts +1179 -0
  33. package/src/proactive.ts +530 -0
  34. package/src/ref-index-store.ts +412 -0
  35. package/src/reply-dispatcher.ts +334 -0
  36. package/src/session-store.ts +303 -0
  37. package/src/setup/account-key.ts +41 -0
  38. package/src/setup/finalize.ts +16 -15
  39. package/src/setup/login.ts +197 -0
  40. package/src/setup/surface.ts +9 -1
  41. package/src/slash-commands.ts +2431 -0
  42. package/src/startup-greeting.ts +120 -0
  43. package/src/streaming.ts +1077 -0
  44. package/src/stt.ts +86 -0
  45. package/src/tools/channel.ts +275 -0
  46. package/src/transport/index.ts +11 -0
  47. package/src/transport/webhook-transport.ts +332 -0
  48. package/src/transport/webhook-verify.ts +119 -0
  49. package/src/typing-keepalive.ts +59 -0
  50. package/src/typings/openclaw-webhook-ingress.d.ts +66 -0
  51. package/src/update-checker.ts +186 -0
  52. package/src/utils/audio-convert.ts +887 -0
  53. package/src/utils/chunked-upload.ts +483 -0
  54. package/src/utils/file-utils.ts +193 -0
  55. package/src/utils/image-size.ts +266 -0
  56. package/src/utils/media-send.ts +636 -0
  57. package/src/utils/media-tags.ts +183 -0
  58. package/src/utils/payload.ts +265 -0
  59. package/src/utils/text-parsing.ts +85 -0
  60. package/src/utils/upload-cache.ts +128 -0
  61. package/skills/qqbot-group/SKILL.md +0 -75
  62. package/skills/qqbot-group/references/api_reference.md +0 -94
package/dist/index.cjs CHANGED
@@ -6,6 +6,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __esm = (fn, res) => function __init() {
10
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
+ };
9
12
  var __commonJS = (cb, mod) => function __require() {
10
13
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
14
  };
@@ -31,6 +34,272 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
31
34
  ));
32
35
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
36
 
37
+ // src/config.ts
38
+ var config_exports = {};
39
+ __export(config_exports, {
40
+ DEFAULT_ACCOUNT_ID: () => DEFAULT_ACCOUNT_ID,
41
+ applyQQBotAccountConfig: () => applyQQBotAccountConfig,
42
+ isGroupAllowed: () => isGroupAllowed,
43
+ listQQBotAccountIds: () => listQQBotAccountIds,
44
+ resolveDefaultQQBotAccountId: () => resolveDefaultQQBotAccountId,
45
+ resolveGroupAllowFrom: () => resolveGroupAllowFrom,
46
+ resolveGroupConfig: () => resolveGroupConfig,
47
+ resolveGroupConfigFromAccount: () => resolveGroupConfigFromAccount,
48
+ resolveGroupName: () => resolveGroupName,
49
+ resolveGroupPolicy: () => resolveGroupPolicy,
50
+ resolveGroupPrompt: () => resolveGroupPrompt,
51
+ resolveHistoryLimit: () => resolveHistoryLimit,
52
+ resolveIgnoreOtherMentions: () => resolveIgnoreOtherMentions,
53
+ resolveMentionPatterns: () => resolveMentionPatterns,
54
+ resolveProcessingTimeoutMs: () => resolveProcessingTimeoutMs,
55
+ resolveQQBotAccount: () => resolveQQBotAccount,
56
+ resolveRequireMention: () => resolveRequireMention,
57
+ resolveToolPolicy: () => resolveToolPolicy,
58
+ resolveUserAgentSuffix: () => resolveUserAgentSuffix
59
+ });
60
+ function resolveMentionPatterns(cfg, agentId) {
61
+ if (agentId) {
62
+ const agents = cfg.agents;
63
+ const entry = agents?.list?.find((a) => a.id?.trim().toLowerCase() === agentId.trim().toLowerCase());
64
+ const agentGroupChat = entry?.groupChat;
65
+ if (agentGroupChat && Object.hasOwn(agentGroupChat, "mentionPatterns")) {
66
+ return agentGroupChat.mentionPatterns ?? [];
67
+ }
68
+ }
69
+ const globalGroupChat = cfg?.messages?.groupChat;
70
+ if (globalGroupChat && typeof globalGroupChat === "object" && Object.hasOwn(globalGroupChat, "mentionPatterns")) {
71
+ return globalGroupChat.mentionPatterns ?? [];
72
+ }
73
+ return [];
74
+ }
75
+ function evaluateMatchedGroupAccessForPolicy(params) {
76
+ if (params.groupPolicy === "disabled") {
77
+ return { allowed: false, groupPolicy: params.groupPolicy, reason: "disabled" };
78
+ }
79
+ if (params.groupPolicy === "allowlist") {
80
+ if (params.requireMatchInput && !params.hasMatchInput) {
81
+ return { allowed: false, groupPolicy: params.groupPolicy, reason: "missing_match_input" };
82
+ }
83
+ if (!params.allowlistConfigured) {
84
+ return { allowed: false, groupPolicy: params.groupPolicy, reason: "empty_allowlist" };
85
+ }
86
+ if (!params.allowlistMatched) {
87
+ return { allowed: false, groupPolicy: params.groupPolicy, reason: "not_allowlisted" };
88
+ }
89
+ }
90
+ return { allowed: true, groupPolicy: params.groupPolicy, reason: "allowed" };
91
+ }
92
+ function resolveGroupPolicy(cfg, accountId) {
93
+ const account = resolveQQBotAccount(cfg, accountId);
94
+ return account.config?.groupPolicy ?? DEFAULT_GROUP_POLICY;
95
+ }
96
+ function resolveGroupAllowFrom(cfg, accountId) {
97
+ const account = resolveQQBotAccount(cfg, accountId);
98
+ return (account.config?.groupAllowFrom ?? []).map((id) => String(id).trim().toUpperCase());
99
+ }
100
+ function isGroupAllowed(cfg, groupOpenid, accountId) {
101
+ const account = resolveQQBotAccount(cfg, accountId);
102
+ const policy = account.config?.groupPolicy ?? DEFAULT_GROUP_POLICY;
103
+ const allowList = (account.config?.groupAllowFrom ?? []).map((id) => String(id).trim().toUpperCase());
104
+ const allowlistConfigured = allowList.length > 0;
105
+ const allowlistMatched = allowList.some((id) => id === "*" || id === groupOpenid.toUpperCase());
106
+ return evaluateMatchedGroupAccessForPolicy({
107
+ groupPolicy: policy,
108
+ allowlistConfigured,
109
+ allowlistMatched
110
+ }).allowed;
111
+ }
112
+ function resolveGroupConfigFromAccount(account, groupOpenid) {
113
+ const groups = account.config?.groups ?? {};
114
+ const wildcardCfg = groups["*"] ?? {};
115
+ const specificCfg = groups[groupOpenid] ?? {};
116
+ const accountDefaultRequireMention = account.config?.defaultRequireMention ?? DEFAULT_GROUP_CONFIG.requireMention;
117
+ return {
118
+ requireMention: specificCfg.requireMention ?? wildcardCfg.requireMention ?? accountDefaultRequireMention,
119
+ ignoreOtherMentions: specificCfg.ignoreOtherMentions ?? wildcardCfg.ignoreOtherMentions ?? DEFAULT_GROUP_CONFIG.ignoreOtherMentions,
120
+ toolPolicy: specificCfg.toolPolicy ?? wildcardCfg.toolPolicy ?? DEFAULT_GROUP_CONFIG.toolPolicy,
121
+ name: specificCfg.name ?? wildcardCfg.name ?? DEFAULT_GROUP_CONFIG.name,
122
+ prompt: specificCfg.prompt ?? wildcardCfg.prompt ?? DEFAULT_GROUP_PROMPT,
123
+ historyLimit: specificCfg.historyLimit ?? wildcardCfg.historyLimit ?? DEFAULT_GROUP_CONFIG.historyLimit
124
+ };
125
+ }
126
+ function resolveGroupConfig(cfg, groupOpenid, accountId) {
127
+ return resolveGroupConfigFromAccount(resolveQQBotAccount(cfg, accountId), groupOpenid);
128
+ }
129
+ function resolveHistoryLimit(cfg, groupOpenid, accountId) {
130
+ return Math.max(0, resolveGroupConfig(cfg, groupOpenid, accountId).historyLimit);
131
+ }
132
+ function resolveGroupPrompt(cfg, groupOpenid, accountId) {
133
+ return resolveGroupConfig(cfg, groupOpenid, accountId).prompt;
134
+ }
135
+ function resolveRequireMention(cfg, groupOpenid, accountId) {
136
+ return resolveGroupConfig(cfg, groupOpenid, accountId).requireMention;
137
+ }
138
+ function resolveIgnoreOtherMentions(cfg, groupOpenid, accountId) {
139
+ return resolveGroupConfig(cfg, groupOpenid, accountId).ignoreOtherMentions;
140
+ }
141
+ function resolveToolPolicy(cfg, groupOpenid, accountId) {
142
+ return resolveGroupConfig(cfg, groupOpenid, accountId).toolPolicy;
143
+ }
144
+ function resolveGroupName(cfg, groupOpenid, accountId) {
145
+ const name = resolveGroupConfig(cfg, groupOpenid, accountId).name;
146
+ return name || groupOpenid.slice(0, 8);
147
+ }
148
+ function normalizeAppId(raw) {
149
+ if (raw === null || raw === void 0) return "";
150
+ return String(raw).trim();
151
+ }
152
+ function listQQBotAccountIds(cfg) {
153
+ const ids = /* @__PURE__ */ new Set();
154
+ const qqbot = cfg.channels?.qqbot;
155
+ if (qqbot?.appId) {
156
+ ids.add(DEFAULT_ACCOUNT_ID);
157
+ }
158
+ if (qqbot?.accounts) {
159
+ for (const accountId of Object.keys(qqbot.accounts)) {
160
+ if (qqbot.accounts[accountId]?.appId) {
161
+ ids.add(accountId);
162
+ }
163
+ }
164
+ }
165
+ return Array.from(ids);
166
+ }
167
+ function resolveDefaultQQBotAccountId(cfg) {
168
+ const qqbot = cfg.channels?.qqbot;
169
+ if (qqbot?.appId) {
170
+ return DEFAULT_ACCOUNT_ID;
171
+ }
172
+ if (qqbot?.accounts) {
173
+ const ids = Object.keys(qqbot.accounts);
174
+ if (ids.length > 0) {
175
+ return ids[0];
176
+ }
177
+ }
178
+ return DEFAULT_ACCOUNT_ID;
179
+ }
180
+ function resolveUserAgentSuffix(cfg) {
181
+ const qqbot = cfg.channels?.qqbot;
182
+ return qqbot?.userAgentSuffix ? String(qqbot.userAgentSuffix).trim() : "";
183
+ }
184
+ function resolveProcessingTimeoutMs(accountConfig) {
185
+ if (accountConfig?.processingTimeoutMs !== void 0) {
186
+ return accountConfig.processingTimeoutMs;
187
+ }
188
+ const env = process.env.OPENCLAW_PROCESSING_TIMEOUT_MS;
189
+ if (env) {
190
+ const v = Number(env);
191
+ if (!Number.isNaN(v) && v >= 0) return v;
192
+ }
193
+ return DEFAULT_PROCESSING_TIMEOUT_MS;
194
+ }
195
+ function resolveQQBotAccount(cfg, accountId) {
196
+ const resolvedAccountId = accountId ?? resolveDefaultQQBotAccountId(cfg);
197
+ const qqbot = cfg.channels?.qqbot;
198
+ let accountConfig = {};
199
+ let appId = "";
200
+ let clientSecret = "";
201
+ let secretSource = "none";
202
+ if (resolvedAccountId === DEFAULT_ACCOUNT_ID) {
203
+ const { accounts: _accounts, ...topLevelConfig } = qqbot ?? {};
204
+ accountConfig = {
205
+ ...topLevelConfig,
206
+ markdownSupport: qqbot?.markdownSupport ?? true
207
+ };
208
+ appId = normalizeAppId(qqbot?.appId);
209
+ } else {
210
+ const account = qqbot?.accounts?.[resolvedAccountId];
211
+ accountConfig = account ?? {};
212
+ appId = normalizeAppId(account?.appId);
213
+ }
214
+ if (accountConfig.clientSecret) {
215
+ clientSecret = accountConfig.clientSecret;
216
+ secretSource = "config";
217
+ } else if (accountConfig.clientSecretFile) {
218
+ secretSource = "file";
219
+ } else if (process.env.QQBOT_CLIENT_SECRET && resolvedAccountId === DEFAULT_ACCOUNT_ID) {
220
+ clientSecret = process.env.QQBOT_CLIENT_SECRET;
221
+ secretSource = "env";
222
+ }
223
+ if (!appId && process.env.QQBOT_APP_ID && resolvedAccountId === DEFAULT_ACCOUNT_ID) {
224
+ appId = normalizeAppId(process.env.QQBOT_APP_ID);
225
+ }
226
+ return {
227
+ accountId: resolvedAccountId,
228
+ name: accountConfig.name,
229
+ enabled: accountConfig.enabled !== false,
230
+ appId,
231
+ clientSecret,
232
+ secretSource,
233
+ systemPrompt: accountConfig.systemPrompt,
234
+ markdownSupport: accountConfig.markdownSupport !== false,
235
+ userAgentSuffix: resolveUserAgentSuffix(cfg),
236
+ processingTimeoutMs: resolveProcessingTimeoutMs(accountConfig),
237
+ config: accountConfig
238
+ };
239
+ }
240
+ function applyQQBotAccountConfig(cfg, accountId, input) {
241
+ const next = { ...cfg };
242
+ if (accountId === DEFAULT_ACCOUNT_ID) {
243
+ const existingConfig = next.channels?.qqbot || {};
244
+ const allowFrom = existingConfig.allowFrom ?? ["*"];
245
+ next.channels = {
246
+ ...next.channels,
247
+ qqbot: {
248
+ ...next.channels?.qqbot || {},
249
+ enabled: true,
250
+ allowFrom,
251
+ ...input.appId ? { appId: input.appId } : {},
252
+ ...input.clientSecret ? { clientSecret: input.clientSecret } : input.clientSecretFile ? { clientSecretFile: input.clientSecretFile } : {},
253
+ ...input.name ? { name: input.name } : {}
254
+ }
255
+ };
256
+ } else {
257
+ const existingAccountConfig = next.channels?.qqbot?.accounts?.[accountId] || {};
258
+ const allowFrom = existingAccountConfig.allowFrom ?? ["*"];
259
+ next.channels = {
260
+ ...next.channels,
261
+ qqbot: {
262
+ ...next.channels?.qqbot || {},
263
+ enabled: true,
264
+ accounts: {
265
+ ...next.channels?.qqbot?.accounts || {},
266
+ [accountId]: {
267
+ ...next.channels?.qqbot?.accounts?.[accountId] || {},
268
+ enabled: true,
269
+ allowFrom,
270
+ ...input.appId ? { appId: input.appId } : {},
271
+ ...input.clientSecret ? { clientSecret: input.clientSecret } : input.clientSecretFile ? { clientSecretFile: input.clientSecretFile } : {},
272
+ ...input.name ? { name: input.name } : {}
273
+ }
274
+ }
275
+ }
276
+ };
277
+ }
278
+ return next;
279
+ }
280
+ var DEFAULT_ACCOUNT_ID, DEFAULT_GROUP_POLICY, DEFAULT_GROUP_HISTORY_LIMIT, DEFAULT_PROCESSING_TIMEOUT_MS, DEFAULT_GROUP_CONFIG, DEFAULT_GROUP_PROMPT;
281
+ var init_config = __esm({
282
+ "src/config.ts"() {
283
+ "use strict";
284
+ DEFAULT_ACCOUNT_ID = "default";
285
+ DEFAULT_GROUP_POLICY = "open";
286
+ DEFAULT_GROUP_HISTORY_LIMIT = 20;
287
+ DEFAULT_PROCESSING_TIMEOUT_MS = 0;
288
+ DEFAULT_GROUP_CONFIG = {
289
+ requireMention: true,
290
+ ignoreOtherMentions: false,
291
+ toolPolicy: "restricted",
292
+ name: "",
293
+ historyLimit: DEFAULT_GROUP_HISTORY_LIMIT
294
+ };
295
+ DEFAULT_GROUP_PROMPT = [
296
+ "\u82E5\u53D1\u9001\u8005\u4E3A\u673A\u5668\u4EBA\uFF0C\u4EC5\u5728\u5BF9\u65B9\u660E\u786E@\u4F60\u63D0\u95EE\u6216\u8BF7\u6C42\u534F\u52A9\u5177\u4F53\u4EFB\u52A1\u65F6\uFF0C\u4EE5\u7B80\u6D01\u660E\u4E86\u7684\u5185\u5BB9\u56DE\u590D\uFF0C",
297
+ "\u907F\u514D\u4E0E\u5176\u4ED6\u673A\u5668\u4EBA\u4EA7\u751F\u62A2\u7B54\u6216\u591A\u8F6E\u65E0\u610F\u4E49\u5BF9\u8BDD\u3002",
298
+ "\u5728\u7FA4\u804A\u4E2D\u4F18\u5148\u8BA9\u4EBA\u7C7B\u7528\u6237\u7684\u6D88\u606F\u5F97\u5230\u54CD\u5E94\uFF0C\u673A\u5668\u4EBA\u4E4B\u95F4\u4FDD\u6301\u534F\u4F5C\u800C\u975E\u7ADE\u4E89\uFF0C\u786E\u4FDD\u5BF9\u8BDD\u6709\u5E8F\u4E0D\u5237\u5C4F\u3002"
299
+ ].join("");
300
+ }
301
+ });
302
+
34
303
  // node_modules/.pnpm/ws@8.21.0/node_modules/ws/lib/constants.js
35
304
  var require_constants = __commonJS({
36
305
  "node_modules/.pnpm/ws@8.21.0/node_modules/ws/lib/constants.js"(exports2, module2) {
@@ -3710,16 +3979,248 @@ var require_websocket_server = __commonJS({
3710
3979
  }
3711
3980
  });
3712
3981
 
3713
- // node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMode.js
3714
- var require_QRMode = __commonJS({
3715
- "node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMode.js"(exports2, module2) {
3716
- "use strict";
3717
- module2.exports = {
3718
- MODE_NUMBER: 1 << 0,
3719
- MODE_ALPHA_NUM: 1 << 1,
3720
- MODE_8BIT_BYTE: 1 << 2,
3721
- MODE_KANJI: 1 << 3
3722
- };
3982
+ // src/adapter/resolve.ts
3983
+ var resolve_exports = {};
3984
+ __export(resolve_exports, {
3985
+ _resetAdaptersCache: () => _resetAdaptersCache,
3986
+ getAdapters: () => getAdapters,
3987
+ persistAuthConfig: () => persistAuthConfig,
3988
+ resolveRuntimeAdapters: () => resolveRuntimeAdapters
3989
+ });
3990
+ function probeFunction(rt, paths) {
3991
+ for (const path22 of paths) {
3992
+ let target = rt;
3993
+ let parent = rt;
3994
+ for (let i = 0; i < path22.length; i++) {
3995
+ parent = target;
3996
+ target = target?.[path22[i]];
3997
+ if (target === void 0 || target === null) break;
3998
+ }
3999
+ if (typeof target === "function") {
4000
+ return target.bind(parent);
4001
+ }
4002
+ }
4003
+ return null;
4004
+ }
4005
+ function resolveRuntimeAdapters(rt, log4) {
4006
+ const version = rt.version ?? "unknown";
4007
+ const inboundRun = probeFunction(rt, [
4008
+ ["channel", "inbound", "run"],
4009
+ // current (2026-05+)
4010
+ ["channel", "turn", "run"]
4011
+ // legacy (removed 2026-05-27)
4012
+ ]);
4013
+ const dispatchReply = probeFunction(rt, [
4014
+ ["channel", "reply", "dispatchReplyWithBufferedBlockDispatcher"]
4015
+ ]);
4016
+ const resolveAgentRoute = probeFunction(rt, [
4017
+ ["channel", "routing", "resolveAgentRoute"]
4018
+ ]);
4019
+ const rawBuildContext = probeFunction(rt, [
4020
+ ["channel", "inbound", "buildContext"]
4021
+ ]);
4022
+ const rawFinalizeContext = !rawBuildContext ? probeFunction(rt, [["channel", "reply", "finalizeInboundContext"]]) : null;
4023
+ const buildInboundContext = rawBuildContext ? (params) => rawBuildContext(params) : rawFinalizeContext ? (params) => {
4024
+ const isCommand = params.access?.commands?.authorized ?? false;
4025
+ const rawCtx = {
4026
+ Body: params.message.body,
4027
+ BodyForAgent: params.message.bodyForAgent,
4028
+ RawBody: params.message.rawBody,
4029
+ CommandBody: params.message.commandBody ?? params.message.rawBody,
4030
+ CommandSource: isCommand ? "text" : void 0,
4031
+ CommandTurn: params.command ?? void 0,
4032
+ CommandAuthorized: isCommand,
4033
+ From: params.from,
4034
+ To: params.reply.to,
4035
+ SessionKey: params.route.routeSessionKey,
4036
+ AccountId: params.route.accountId ?? params.accountId,
4037
+ ChatType: params.conversation.kind,
4038
+ GroupSystemPrompt: params.conversation.label,
4039
+ SenderId: params.sender.id,
4040
+ SenderName: params.sender.name,
4041
+ Provider: params.provider ?? params.channel,
4042
+ Surface: params.surface ?? params.channel,
4043
+ MessageSid: params.messageId,
4044
+ Timestamp: params.timestamp ?? Date.now(),
4045
+ OriginatingChannel: params.channel,
4046
+ OriginatingTo: params.reply.originatingTo ?? params.reply.to,
4047
+ ...params.extra
4048
+ };
4049
+ return rawFinalizeContext(rawCtx);
4050
+ } : null;
4051
+ const resolveStorePath = probeFunction(rt, [
4052
+ ["channel", "session", "resolveStorePath"]
4053
+ ]);
4054
+ const recordInboundSession = probeFunction(rt, [
4055
+ ["channel", "session", "recordInboundSession"]
4056
+ ]);
4057
+ const formatEnvelope = probeFunction(rt, [
4058
+ ["channel", "reply", "formatAgentEnvelope"],
4059
+ // current (2026-06+)
4060
+ ["channel", "reply", "formatInboundEnvelope"]
4061
+ // deprecated,低版本兼容
4062
+ ]);
4063
+ const resolveEnvelopeFormatOptions = probeFunction(rt, [
4064
+ ["channel", "reply", "resolveEnvelopeFormatOptions"]
4065
+ ]);
4066
+ const chunkMarkdownText = probeFunction(rt, [
4067
+ ["channel", "text", "chunkMarkdownText"]
4068
+ ]);
4069
+ const saveRemoteMedia = probeFunction(rt, [
4070
+ ["channel", "media", "saveRemoteMedia"]
4071
+ ]);
4072
+ const getConfig = probeFunction(rt, [
4073
+ ["config", "current"]
4074
+ ]) ?? probeFunction(rt, [
4075
+ ["getConfig"]
4076
+ ]) ?? probeFunction(rt, [
4077
+ ["config", "loadConfig"]
4078
+ ]);
4079
+ const rawMutateConfig = probeFunction(rt, [["config", "mutateConfigFile"]]);
4080
+ const rawWriteConfig = probeFunction(rt, [["config", "writeConfigFile"]]);
4081
+ const persistConfig = rawMutateConfig ? async (mutator) => {
4082
+ await rawMutateConfig({
4083
+ afterWrite: "hot-reload",
4084
+ mutate: mutator
4085
+ });
4086
+ } : rawWriteConfig && getConfig ? async (mutator) => {
4087
+ const current = JSON.parse(JSON.stringify(getConfig()));
4088
+ mutator(current);
4089
+ await rawWriteConfig(current);
4090
+ } : null;
4091
+ const resolved = [
4092
+ inboundRun && "inboundRun",
4093
+ dispatchReply && "dispatchReply",
4094
+ resolveAgentRoute && "resolveAgentRoute",
4095
+ buildInboundContext && "buildInboundContext",
4096
+ resolveStorePath && "resolveStorePath",
4097
+ recordInboundSession && "recordInboundSession",
4098
+ formatEnvelope && "formatEnvelope",
4099
+ chunkMarkdownText && "chunkMarkdownText",
4100
+ saveRemoteMedia && "saveRemoteMedia",
4101
+ getConfig && "getConfig",
4102
+ persistConfig && `persistConfig(${rawMutateConfig ? "mutate" : "write"})`
4103
+ ].filter(Boolean);
4104
+ log4?.info(
4105
+ `[qqbot:adapter] openclaw=${version} resolved ${resolved.length} adapters: ${resolved.join(", ")}`
4106
+ );
4107
+ return {
4108
+ inboundRun,
4109
+ dispatchReply,
4110
+ resolveAgentRoute,
4111
+ buildInboundContext,
4112
+ resolveStorePath,
4113
+ recordInboundSession,
4114
+ formatEnvelope,
4115
+ resolveEnvelopeFormatOptions,
4116
+ chunkMarkdownText,
4117
+ saveRemoteMedia,
4118
+ getConfig,
4119
+ persistConfig,
4120
+ version
4121
+ };
4122
+ }
4123
+ function getAdapters(rt, log4) {
4124
+ const cached = _cachedRuntimeRef?.deref();
4125
+ if (cached === rt && _cachedAdapters) {
4126
+ return _cachedAdapters;
4127
+ }
4128
+ _cachedAdapters = resolveRuntimeAdapters(rt, log4);
4129
+ _cachedRuntimeRef = new WeakRef(rt);
4130
+ return _cachedAdapters;
4131
+ }
4132
+ async function persistAuthConfig(runtime2, cfg, afterWrite = "restart") {
4133
+ const config = runtime2.config;
4134
+ if (typeof config?.mutateConfigFile === "function") {
4135
+ await config.mutateConfigFile({
4136
+ mutate: () => cfg,
4137
+ afterWrite
4138
+ });
4139
+ return;
4140
+ }
4141
+ if (typeof config?.writeConfigFile === "function") {
4142
+ await config.writeConfigFile(cfg);
4143
+ return;
4144
+ }
4145
+ if (typeof runtime2.writeConfigFile === "function") {
4146
+ await runtime2.writeConfigFile(cfg);
4147
+ return;
4148
+ }
4149
+ const { homedir: homedir5 } = await import("os");
4150
+ const { join: join8 } = await import("path");
4151
+ const { writeFileSync: writeFileSync5 } = await import("fs");
4152
+ writeFileSync5(join8(homedir5(), ".openclaw", "openclaw.json"), JSON.stringify(cfg, null, 2) + "\n", "utf-8");
4153
+ }
4154
+ function _resetAdaptersCache() {
4155
+ _cachedAdapters = null;
4156
+ _cachedRuntimeRef = null;
4157
+ }
4158
+ var _cachedAdapters, _cachedRuntimeRef;
4159
+ var init_resolve = __esm({
4160
+ "src/adapter/resolve.ts"() {
4161
+ "use strict";
4162
+ _cachedAdapters = null;
4163
+ _cachedRuntimeRef = null;
4164
+ }
4165
+ });
4166
+
4167
+ // src/adapter/setup.ts
4168
+ function loadSetup() {
4169
+ if (_setup !== void 0) return _setup;
4170
+ try {
4171
+ _setup = req2("openclaw/plugin-sdk/setup");
4172
+ } catch {
4173
+ _setup = null;
4174
+ }
4175
+ return _setup;
4176
+ }
4177
+ function loadTools() {
4178
+ if (_tools !== void 0) return _tools;
4179
+ try {
4180
+ _tools = req2("openclaw/plugin-sdk/setup-tools");
4181
+ } catch {
4182
+ _tools = null;
4183
+ }
4184
+ return _tools;
4185
+ }
4186
+ function createStandardChannelSetupStatus(...args) {
4187
+ const mod = loadSetup();
4188
+ if (mod) return mod.createStandardChannelSetupStatus(...args);
4189
+ return {
4190
+ channelLabel: args[0]?.channelLabel ?? "QQ Bot",
4191
+ configuredLabel: "Configured",
4192
+ unconfiguredLabel: "Not configured",
4193
+ resolveConfigured: () => false
4194
+ };
4195
+ }
4196
+ function setSetupChannelEnabled(...args) {
4197
+ loadSetup()?.setSetupChannelEnabled?.(...args);
4198
+ }
4199
+ function formatDocsLink(...args) {
4200
+ const mod = loadTools();
4201
+ if (mod) return mod.formatDocsLink(...args);
4202
+ return args[1] ? `${args[1]}: ${args[0]}` : args[0];
4203
+ }
4204
+ var import_node_module2, req2, _setup, _tools, DEFAULT_ACCOUNT_ID2;
4205
+ var init_setup = __esm({
4206
+ "src/adapter/setup.ts"() {
4207
+ "use strict";
4208
+ import_node_module2 = require("module");
4209
+ req2 = (0, import_node_module2.createRequire)(__filename);
4210
+ DEFAULT_ACCOUNT_ID2 = "default";
4211
+ }
4212
+ });
4213
+
4214
+ // node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMode.js
4215
+ var require_QRMode = __commonJS({
4216
+ "node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMode.js"(exports2, module2) {
4217
+ "use strict";
4218
+ module2.exports = {
4219
+ MODE_NUMBER: 1 << 0,
4220
+ MODE_ALPHA_NUM: 1 << 1,
4221
+ MODE_8BIT_BYTE: 1 << 2,
4222
+ MODE_KANJI: 1 << 3
4223
+ };
3723
4224
  }
3724
4225
  });
3725
4226
 
@@ -4791,295 +5292,1081 @@ var require_main = __commonJS({
4791
5292
  }
4792
5293
  });
4793
5294
 
4794
- // index.ts
4795
- var index_exports = {};
4796
- __export(index_exports, {
4797
- DEFAULT_ACCOUNT_ID: () => DEFAULT_ACCOUNT_ID,
4798
- MSG_TYPE_QUOTE: () => MSG_TYPE_QUOTE2,
4799
- MSG_TYPE_TEXT: () => MSG_TYPE_TEXT,
4800
- PersistedRefIndexStore: () => PersistedRefIndexStore,
4801
- QQBotGateway: () => QQBotGateway,
4802
- StreamContentType: () => StreamContentType2,
4803
- StreamInputMode: () => StreamInputMode2,
4804
- StreamInputState: () => StreamInputState2,
4805
- StreamingController: () => StreamingController,
4806
- applyQQBotAccountConfig: () => applyQQBotAccountConfig,
4807
- buildUserAgent: () => buildUserAgent,
4808
- default: () => index_default,
4809
- dispatchToOpenClaw: () => dispatchToOpenClaw,
4810
- flushAllRefIndexStores: () => flushAllRefIndexStores,
4811
- getBotForAccount: () => getBotForAccount,
4812
- getPersistedRefIndexStore: () => getPersistedRefIndexStore,
4813
- getQQBotRuntime: () => getQQBotRuntime,
4814
- isGroupAllowed: () => isGroupAllowed,
4815
- listQQBotAccountIds: () => listQQBotAccountIds,
4816
- parseTarget: () => parseTarget,
4817
- qqbotOnboardingAdapter: () => qqbotOnboardingAdapter,
4818
- qqbotPlugin: () => qqbotPlugin,
4819
- resolveDefaultQQBotAccountId: () => resolveDefaultQQBotAccountId,
4820
- resolveGroupAllowFrom: () => resolveGroupAllowFrom,
4821
- resolveGroupConfig: () => resolveGroupConfig,
4822
- resolveGroupConfigFromAccount: () => resolveGroupConfigFromAccount,
4823
- resolveGroupName: () => resolveGroupName,
4824
- resolveGroupPolicy: () => resolveGroupPolicy,
4825
- resolveGroupPrompt: () => resolveGroupPrompt,
4826
- resolveHistoryLimit: () => resolveHistoryLimit,
4827
- resolveIgnoreOtherMentions: () => resolveIgnoreOtherMentions,
4828
- resolveMentionPatterns: () => resolveMentionPatterns,
4829
- resolveProcessingTimeoutMs: () => resolveProcessingTimeoutMs,
4830
- resolveQQBotAccount: () => resolveQQBotAccount,
4831
- resolveRequireMention: () => resolveRequireMention,
4832
- resolveToolPolicy: () => resolveToolPolicy,
4833
- resolveUserAgentSuffix: () => resolveUserAgentSuffix,
4834
- sendMedia: () => sendMedia,
4835
- sendText: () => sendText,
4836
- setQQBotRuntime: () => setQQBotRuntime,
4837
- shouldUseStreaming: () => shouldUseStreaming,
4838
- tryGetBotForAccount: () => tryGetBotForAccount
4839
- });
4840
- module.exports = __toCommonJS(index_exports);
4841
- var import_plugin_sdk = require("openclaw/plugin-sdk");
4842
-
4843
- // src/channel.ts
4844
- var import_core = require("openclaw/plugin-sdk/core");
5295
+ // node_modules/.pnpm/@tencent-connect+qqbot-connector@1.2.0/node_modules/@tencent-connect/qqbot-connector/dist/esm/qqbot-session.js
5296
+ function d(t = "production") {
5297
+ return E[t];
5298
+ }
5299
+ function l() {
5300
+ return import_node_crypto.default.randomBytes(32).toString("base64");
5301
+ }
5302
+ function b(t, r) {
5303
+ const a = Buffer.from(r, "base64"), n = Buffer.from(t, "base64"), e = n.subarray(0, 12), c = n.subarray(n.length - 16), s = n.subarray(12, n.length - 16), o = import_node_crypto.default.createDecipheriv("aes-256-gcm", a, e);
5304
+ return o.setAuthTag(c), Buffer.concat([o.update(s), o.final()]).toString("utf8");
5305
+ }
5306
+ function h(t, r, a) {
5307
+ return new Promise((n, e) => {
5308
+ const c = JSON.stringify(r), s = new URL(t), o = import_node_https.default.request({ hostname: s.hostname, path: s.pathname + s.search, method: "POST", timeout: a, headers: { "Content-Type": "application/json", Accept: "application/json", "Content-Length": Buffer.byteLength(c) } }, (i) => {
5309
+ if (i.statusCode !== 200) {
5310
+ i.resume(), e(new Error(`HTTP ${i.statusCode} from ${t}`));
5311
+ return;
5312
+ }
5313
+ let f = "";
5314
+ i.on("data", (p2) => {
5315
+ f += p2;
5316
+ }), i.on("end", () => {
5317
+ try {
5318
+ n(JSON.parse(f));
5319
+ } catch (p2) {
5320
+ e(p2);
5321
+ }
5322
+ });
5323
+ });
5324
+ o.on("error", e), o.on("timeout", () => {
5325
+ o.destroy(), e(new Error(`timeout fetching ${t}`));
5326
+ }), o.end(c);
5327
+ });
5328
+ }
5329
+ async function y(t = "production", r = 1e4) {
5330
+ const a = `https://${d(t)}/lite/create_bind_task`, n = l(), e = await h(a, { key: n }, r);
5331
+ if (e.retcode !== 0) throw new Error(e.msg ?? "create_bind_task failed");
5332
+ if (!e.data?.task_id) throw new Error("create_bind_task: missing task_id");
5333
+ return { taskId: e.data.task_id, key: n };
5334
+ }
5335
+ async function g(t, r = "production", a = 1e4) {
5336
+ const n = `https://${d(r)}/lite/poll_bind_result`, e = await h(n, { task_id: t }, a);
5337
+ if (e.retcode !== 0) throw new Error(e.msg ?? "poll_bind_result failed");
5338
+ return { status: e.data?.status ?? u.NONE, botAppId: String(e.data?.bot_appid ?? ""), botEncryptSecret: e.data?.bot_encrypt_secret ?? "", userOpenid: e.data?.user_openid || void 0 };
5339
+ }
5340
+ function w(t, r = "") {
5341
+ return `https://${d("production")}/qqbot/openclaw/connect.html?task_id=${encodeURIComponent(t)}&source=${encodeURIComponent(r)}&_wv=2`;
5342
+ }
5343
+ var import_node_crypto, import_node_https, E, u;
5344
+ var init_qqbot_session = __esm({
5345
+ "node_modules/.pnpm/@tencent-connect+qqbot-connector@1.2.0/node_modules/@tencent-connect/qqbot-connector/dist/esm/qqbot-session.js"() {
5346
+ "use strict";
5347
+ import_node_crypto = __toESM(require("crypto"), 1);
5348
+ import_node_https = __toESM(require("https"), 1);
5349
+ E = { production: "q.qq.com", test: "test.q.qq.com" };
5350
+ (function(t) {
5351
+ t[t.NONE = 0] = "NONE", t[t.PENDING = 1] = "PENDING", t[t.COMPLETED = 2] = "COMPLETED", t[t.EXPIRED = 3] = "EXPIRED";
5352
+ })(u || (u = {}));
5353
+ }
5354
+ });
4845
5355
 
4846
- // src/config.ts
4847
- function resolveMentionPatterns(cfg, agentId) {
4848
- if (agentId) {
4849
- const agents = cfg.agents;
4850
- const entry = agents?.list?.find((a) => a.id?.trim().toLowerCase() === agentId.trim().toLowerCase());
4851
- const agentGroupChat = entry?.groupChat;
4852
- if (agentGroupChat && Object.hasOwn(agentGroupChat, "mentionPatterns")) {
4853
- return agentGroupChat.mentionPatterns ?? [];
5356
+ // node_modules/.pnpm/@tencent-connect+qqbot-connector@1.2.0/node_modules/@tencent-connect/qqbot-connector/dist/esm/qr-connect.js
5357
+ function F(r) {
5358
+ return new Promise((o) => {
5359
+ import_qrcode_terminal.default.generate(r, { small: true }, (e) => {
5360
+ o(e);
5361
+ });
5362
+ });
5363
+ }
5364
+ function d2(r, o) {
5365
+ return new Promise((e, t) => {
5366
+ if (o?.aborted) {
5367
+ t(new DOMException("Aborted", "AbortError"));
5368
+ return;
4854
5369
  }
5370
+ const n = setTimeout(e, r);
5371
+ o?.addEventListener("abort", () => {
5372
+ clearTimeout(n), t(new DOMException("Aborted", "AbortError"));
5373
+ }, { once: true });
5374
+ });
5375
+ }
5376
+ async function C(r, o, e) {
5377
+ for (; !e?.aborted; ) {
5378
+ let t;
5379
+ try {
5380
+ t = await g(r);
5381
+ } catch {
5382
+ await d2(p, e);
5383
+ continue;
5384
+ }
5385
+ if (t.status === u.COMPLETED) {
5386
+ const n = b(t.botEncryptSecret, o);
5387
+ return { outcome: "scanned", appId: t.botAppId, appSecret: n, userOpenid: t.userOpenid };
5388
+ }
5389
+ if (t.status === u.EXPIRED) return { outcome: "expired" };
5390
+ await d2(p, e);
4855
5391
  }
4856
- const globalGroupChat = cfg?.messages?.groupChat;
4857
- if (globalGroupChat && typeof globalGroupChat === "object" && Object.hasOwn(globalGroupChat, "mentionPatterns")) {
4858
- return globalGroupChat.mentionPatterns ?? [];
5392
+ throw new DOMException("Aborted", "AbortError");
5393
+ }
5394
+ function l2(r, o) {
5395
+ const e = new AbortController(), t = o?.signal ? AbortSignal.any([e.signal, o.signal]) : e.signal;
5396
+ return (async () => {
5397
+ const n = o?.displayQrCodeToConsole ?? true;
5398
+ for (; ; ) {
5399
+ if (t.aborted) throw new DOMException("Aborted", "AbortError");
5400
+ let a;
5401
+ try {
5402
+ a = await y();
5403
+ } catch (u2) {
5404
+ throw new Error(`\u83B7\u53D6\u7ED1\u5B9A\u4EFB\u52A1\u5931\u8D25: ${u2 instanceof Error ? u2.message : String(u2)}`, { cause: u2 });
5405
+ }
5406
+ const i = w(a.taskId, o?.source);
5407
+ if (n) {
5408
+ const u2 = await F(i);
5409
+ console.log(u2), console.log(`\u8BF7\u4F7F\u7528\u624B\u673A QQ \u626B\u63CF\u4E0A\u65B9\u4E8C\u7EF4\u7801\uFF0C\u5B8C\u6210\u673A\u5668\u4EBA\u7ED1\u5B9A\u3002
5410
+ `);
5411
+ }
5412
+ r.onQrDisplayed?.(i);
5413
+ const s = await C(a.taskId, a.key, t);
5414
+ if (s.outcome === "scanned") {
5415
+ r.onSuccess([{ appId: s.appId, appSecret: s.appSecret, userOpenid: s.userOpenid }]);
5416
+ return;
5417
+ }
5418
+ r.onQrExpired?.(), n && console.log(`\u4E8C\u7EF4\u7801\u5DF2\u8FC7\u671F\uFF0C\u6B63\u5728\u5237\u65B0\u2026
5419
+ `);
5420
+ }
5421
+ })().catch((n) => {
5422
+ if (n instanceof DOMException && n.name === "AbortError") {
5423
+ r.onFailure(new Error("\u5DF2\u53D6\u6D88"));
5424
+ return;
5425
+ }
5426
+ r.onFailure(n instanceof Error ? n : new Error(String(n)));
5427
+ }), () => e.abort();
5428
+ }
5429
+ function m2(r) {
5430
+ return new Promise((o, e) => {
5431
+ l2({ onSuccess: o, onFailure: e }, { ...r, displayQrCodeToConsole: true });
5432
+ });
5433
+ }
5434
+ var import_qrcode_terminal, p;
5435
+ var init_qr_connect = __esm({
5436
+ "node_modules/.pnpm/@tencent-connect+qqbot-connector@1.2.0/node_modules/@tencent-connect/qqbot-connector/dist/esm/qr-connect.js"() {
5437
+ "use strict";
5438
+ import_qrcode_terminal = __toESM(require_main(), 1);
5439
+ init_qqbot_session();
5440
+ p = 2e3;
4859
5441
  }
4860
- return [];
5442
+ });
5443
+
5444
+ // node_modules/.pnpm/@tencent-connect+qqbot-connector@1.2.0/node_modules/@tencent-connect/qqbot-connector/dist/esm/index.js
5445
+ var init_esm = __esm({
5446
+ "node_modules/.pnpm/@tencent-connect+qqbot-connector@1.2.0/node_modules/@tencent-connect/qqbot-connector/dist/esm/index.js"() {
5447
+ "use strict";
5448
+ init_qr_connect();
5449
+ }
5450
+ });
5451
+
5452
+ // src/setup/account-key.ts
5453
+ var account_key_exports = {};
5454
+ __export(account_key_exports, {
5455
+ resolveAccountKey: () => resolveAccountKey
5456
+ });
5457
+ function resolveAccountKey(cfg, appId, resolvedId) {
5458
+ if (resolvedId) return resolvedId;
5459
+ for (const id of listQQBotAccountIds(cfg)) {
5460
+ if (resolveQQBotAccount(cfg, id).appId === appId) return id;
5461
+ }
5462
+ if (listQQBotAccountIds(cfg).length === 0) return "default";
5463
+ return appId;
4861
5464
  }
4862
- var DEFAULT_ACCOUNT_ID = "default";
4863
- function evaluateMatchedGroupAccessForPolicy(params) {
4864
- if (params.groupPolicy === "disabled") {
4865
- return { allowed: false, groupPolicy: params.groupPolicy, reason: "disabled" };
5465
+ var init_account_key = __esm({
5466
+ "src/setup/account-key.ts"() {
5467
+ "use strict";
5468
+ init_config();
4866
5469
  }
4867
- if (params.groupPolicy === "allowlist") {
4868
- if (params.requireMatchInput && !params.hasMatchInput) {
4869
- return { allowed: false, groupPolicy: params.groupPolicy, reason: "missing_match_input" };
4870
- }
4871
- if (!params.allowlistConfigured) {
4872
- return { allowed: false, groupPolicy: params.groupPolicy, reason: "empty_allowlist" };
5470
+ });
5471
+
5472
+ // src/setup/finalize.ts
5473
+ var finalize_exports = {};
5474
+ __export(finalize_exports, {
5475
+ applyAccountDefaults: () => applyAccountDefaults,
5476
+ finalizeQQBotSetup: () => finalizeQQBotSetup
5477
+ });
5478
+ function isConfigured(cfg, accountId) {
5479
+ const account = resolveQQBotAccount(cfg, accountId);
5480
+ return Boolean(account.appId && account.clientSecret);
5481
+ }
5482
+ async function linkViaQrCode(cfg, _accountId, prompter, rt) {
5483
+ try {
5484
+ const accounts = await m2({ source: "openclaw" });
5485
+ if (accounts.length === 0) {
5486
+ await prompter.note("\u672A\u83B7\u53D6\u5230\u4EFB\u4F55 QQ Bot \u8D26\u53F7\u4FE1\u606F\u3002", "QQ Bot");
5487
+ return cfg;
4873
5488
  }
4874
- if (!params.allowlistMatched) {
4875
- return { allowed: false, groupPolicy: params.groupPolicy, reason: "not_allowlisted" };
5489
+ let next = cfg;
5490
+ for (const { appId, appSecret, userOpenid } of accounts) {
5491
+ const key = resolveAccountKey(cfg, appId);
5492
+ next = applyQQBotAccountConfig(next, key, { appId, clientSecret: appSecret });
5493
+ next = applyAccountDefaults(next, key, userOpenid);
5494
+ rt.log(`\u7ED1\u5B9A\u6210\u529F\uFF01\u8D26\u6237: ${key} (AppID: ${appId})`);
4876
5495
  }
5496
+ return next;
5497
+ } catch (err) {
5498
+ rt.error(`QQ Bot \u7ED1\u5B9A\u5931\u8D25: ${String(err)}`);
5499
+ await prompter.note(`\u7ED1\u5B9A\u5931\u8D25\uFF0C\u60A8\u53EF\u4EE5\u7A0D\u540E\u624B\u52A8\u914D\u7F6E\u3002
5500
+ \u6587\u6863: ${formatDocsLink("/channels/qqbot", "qqbot")}`, "QQ Bot");
5501
+ return cfg;
4877
5502
  }
4878
- return { allowed: true, groupPolicy: params.groupPolicy, reason: "allowed" };
4879
5503
  }
4880
- var DEFAULT_GROUP_POLICY = "open";
4881
- var DEFAULT_GROUP_HISTORY_LIMIT = 20;
4882
- var DEFAULT_PROCESSING_TIMEOUT_MS = 0;
4883
- var DEFAULT_GROUP_CONFIG = {
4884
- requireMention: true,
4885
- ignoreOtherMentions: false,
4886
- toolPolicy: "restricted",
4887
- name: "",
4888
- historyLimit: DEFAULT_GROUP_HISTORY_LIMIT
4889
- };
4890
- var DEFAULT_GROUP_PROMPT = [
4891
- "\u82E5\u53D1\u9001\u8005\u4E3A\u673A\u5668\u4EBA\uFF0C\u4EC5\u5728\u5BF9\u65B9\u660E\u786E@\u4F60\u63D0\u95EE\u6216\u8BF7\u6C42\u534F\u52A9\u5177\u4F53\u4EFB\u52A1\u65F6\uFF0C\u4EE5\u7B80\u6D01\u660E\u4E86\u7684\u5185\u5BB9\u56DE\u590D\uFF0C",
4892
- "\u907F\u514D\u4E0E\u5176\u4ED6\u673A\u5668\u4EBA\u4EA7\u751F\u62A2\u7B54\u6216\u591A\u8F6E\u65E0\u610F\u4E49\u5BF9\u8BDD\u3002",
4893
- "\u5728\u7FA4\u804A\u4E2D\u4F18\u5148\u8BA9\u4EBA\u7C7B\u7528\u6237\u7684\u6D88\u606F\u5F97\u5230\u54CD\u5E94\uFF0C\u673A\u5668\u4EBA\u4E4B\u95F4\u4FDD\u6301\u534F\u4F5C\u800C\u975E\u7ADE\u4E89\uFF0C\u786E\u4FDD\u5BF9\u8BDD\u6709\u5E8F\u4E0D\u5237\u5C4F\u3002"
4894
- ].join("");
4895
- function resolveGroupPolicy(cfg, accountId) {
4896
- const account = resolveQQBotAccount(cfg, accountId);
4897
- return account.config?.groupPolicy ?? DEFAULT_GROUP_POLICY;
5504
+ async function linkViaManual(cfg, _accountId, prompter) {
5505
+ const appIdInput = await prompter.text({ message: "\u8BF7\u8F93\u5165 QQ Bot AppID", validate: (v) => v.trim() ? void 0 : "AppID \u4E0D\u80FD\u4E3A\u7A7A" });
5506
+ const secret = await prompter.text({ message: "\u8BF7\u8F93\u5165 QQ Bot AppSecret", validate: (v) => v.trim() ? void 0 : "AppSecret \u4E0D\u80FD\u4E3A\u7A7A" });
5507
+ const appId = appIdInput.trim();
5508
+ const key = resolveAccountKey(cfg, appId);
5509
+ let next = applyQQBotAccountConfig(cfg, key, { appId, clientSecret: secret.trim() });
5510
+ next = applyAccountDefaults(next, key);
5511
+ await prompter.note("\u2714 QQ Bot \u914D\u7F6E\u5B8C\u6210\uFF01", "QQ Bot");
5512
+ return next;
4898
5513
  }
4899
- function resolveGroupAllowFrom(cfg, accountId) {
4900
- const account = resolveQQBotAccount(cfg, accountId);
4901
- return (account.config?.groupAllowFrom ?? []).map((id) => String(id).trim().toUpperCase());
5514
+ async function finalizeQQBotSetup(params) {
5515
+ const accountId = params.accountId.trim() || DEFAULT_ACCOUNT_ID2;
5516
+ const configured = isConfigured(params.cfg, accountId);
5517
+ const mode = await params.prompter.select({
5518
+ message: configured ? "QQ \u5DF2\u7ED1\u5B9A\uFF0C\u9009\u62E9\u64CD\u4F5C" : "\u9009\u62E9 QQ \u7ED1\u5B9A\u65B9\u5F0F",
5519
+ options: [
5520
+ { value: "qr", label: "\u626B\u7801\u7ED1\u5B9A\uFF08\u63A8\u8350\uFF09", hint: "\u4F7F\u7528 QQ \u626B\u63CF\u4E8C\u7EF4\u7801\u81EA\u52A8\u5B8C\u6210\u7ED1\u5B9A" },
5521
+ { value: "manual", label: "\u624B\u52A8\u8F93\u5165 QQ Bot AppID \u548C AppSecret", hint: "\u9700\u5230 QQ \u5F00\u653E\u5E73\u53F0 q.qq.com \u67E5\u770B" },
5522
+ { value: "skip", label: configured ? "\u4FDD\u6301\u5F53\u524D\u914D\u7F6E" : "\u7A0D\u540E\u914D\u7F6E" }
5523
+ ]
5524
+ });
5525
+ let next = params.cfg;
5526
+ if (mode === "qr") {
5527
+ next = await linkViaQrCode(next, accountId, params.prompter, params.runtime);
5528
+ } else if (mode === "manual") {
5529
+ next = await linkViaManual(next, accountId, params.prompter);
5530
+ } else if (!configured) {
5531
+ await params.prompter.note("\u60A8\u53EF\u4EE5\u7A0D\u540E\u8FD0\u884C\u4EE5\u4E0B\u547D\u4EE4\u91CD\u65B0\u914D\u7F6E\uFF1A\n openclaw channels add", "QQ Bot");
5532
+ }
5533
+ return { cfg: next };
4902
5534
  }
4903
- function isGroupAllowed(cfg, groupOpenid, accountId) {
4904
- const account = resolveQQBotAccount(cfg, accountId);
4905
- const policy = account.config?.groupPolicy ?? DEFAULT_GROUP_POLICY;
4906
- const allowList = (account.config?.groupAllowFrom ?? []).map((id) => String(id).trim().toUpperCase());
4907
- const allowlistConfigured = allowList.length > 0;
4908
- const allowlistMatched = allowList.some((id) => id === "*" || id === groupOpenid.toUpperCase());
4909
- return evaluateMatchedGroupAccessForPolicy({
4910
- groupPolicy: policy,
4911
- allowlistConfigured,
4912
- allowlistMatched
4913
- }).allowed;
5535
+ function applyAccountDefaults(cfg, accountId, userOpenid) {
5536
+ const next = { ...cfg, channels: { ...cfg.channels } };
5537
+ const qqbot = { ...next.channels?.qqbot ?? {} };
5538
+ const defaults = { streaming: true, dmPolicy: "allowlist", mediaMaxMb: 200 };
5539
+ if (userOpenid) defaults.allowFrom = [userOpenid];
5540
+ if (accountId === DEFAULT_ACCOUNT_ID2) {
5541
+ Object.assign(qqbot, defaults);
5542
+ } else {
5543
+ const accounts = { ...qqbot.accounts ?? {} };
5544
+ accounts[accountId] = { ...accounts[accountId] ?? {}, ...defaults };
5545
+ qqbot.accounts = accounts;
5546
+ }
5547
+ next.channels = { ...next.channels, qqbot };
5548
+ return next;
4914
5549
  }
4915
- function resolveGroupConfigFromAccount(account, groupOpenid) {
4916
- const groups = account.config?.groups ?? {};
4917
- const wildcardCfg = groups["*"] ?? {};
4918
- const specificCfg = groups[groupOpenid] ?? {};
4919
- const accountDefaultRequireMention = account.config?.defaultRequireMention ?? DEFAULT_GROUP_CONFIG.requireMention;
4920
- return {
4921
- requireMention: specificCfg.requireMention ?? wildcardCfg.requireMention ?? accountDefaultRequireMention,
4922
- ignoreOtherMentions: specificCfg.ignoreOtherMentions ?? wildcardCfg.ignoreOtherMentions ?? DEFAULT_GROUP_CONFIG.ignoreOtherMentions,
4923
- toolPolicy: specificCfg.toolPolicy ?? wildcardCfg.toolPolicy ?? DEFAULT_GROUP_CONFIG.toolPolicy,
4924
- name: specificCfg.name ?? wildcardCfg.name ?? DEFAULT_GROUP_CONFIG.name,
4925
- prompt: specificCfg.prompt ?? wildcardCfg.prompt ?? DEFAULT_GROUP_PROMPT,
4926
- historyLimit: specificCfg.historyLimit ?? wildcardCfg.historyLimit ?? DEFAULT_GROUP_CONFIG.historyLimit
4927
- };
5550
+ var init_finalize = __esm({
5551
+ "src/setup/finalize.ts"() {
5552
+ "use strict";
5553
+ init_setup();
5554
+ init_esm();
5555
+ init_config();
5556
+ init_account_key();
5557
+ }
5558
+ });
5559
+
5560
+ // node_modules/.pnpm/silk-wasm@3.7.1/node_modules/silk-wasm/lib/index.mjs
5561
+ var lib_exports = {};
5562
+ __export(lib_exports, {
5563
+ decode: () => decode,
5564
+ encode: () => encode,
5565
+ getDuration: () => getDuration,
5566
+ getWavFileInfo: () => getWavFileInfo2,
5567
+ isSilk: () => isSilk,
5568
+ isWav: () => isWav
5569
+ });
5570
+ function isWavFile(fileData) {
5571
+ try {
5572
+ let chunks = unpackWavFileChunks(fileData), fmt = decodeFormatChunk(chunks.get("fmt")), data = chunks.get("data");
5573
+ return getWavFileType(fmt), verifyDataChunkLength(data, fmt), true;
5574
+ } catch {
5575
+ return false;
5576
+ }
4928
5577
  }
4929
- function resolveGroupConfig(cfg, groupOpenid, accountId) {
4930
- return resolveGroupConfigFromAccount(resolveQQBotAccount(cfg, accountId), groupOpenid);
5578
+ function decodeWavFile(fileData) {
5579
+ let chunks = unpackWavFileChunks(fileData), fmt = decodeFormatChunk(chunks.get("fmt")), data = chunks.get("data"), wavFileType = getWavFileType(fmt), audioEncoding = wavFileTypeAudioEncodings[wavFileType], wavFileTypeName = audioEncodingNames[audioEncoding] + fmt.bitsPerSample;
5580
+ return verifyDataChunkLength(data, fmt), { channelData: decodeDataChunk(data, fmt, wavFileType), sampleRate: fmt.sampleRate, numberOfChannels: fmt.numberOfChannels, audioEncoding, bitsPerSample: fmt.bitsPerSample, wavFileTypeName };
5581
+ }
5582
+ function unpackWavFileChunks(fileData) {
5583
+ let dataView;
5584
+ fileData instanceof ArrayBuffer ? dataView = new DataView(fileData) : dataView = new DataView(fileData.buffer, fileData.byteOffset, fileData.byteLength);
5585
+ let fileLength = dataView.byteLength;
5586
+ if (fileLength < 20) throw new Error("WAV file is too short.");
5587
+ if (getString(dataView, 0, 4) != "RIFF") throw new Error("Not a valid WAV file (no RIFF header).");
5588
+ let mainChunkLength = dataView.getUint32(4, true);
5589
+ if (8 + mainChunkLength != fileLength) throw new Error(`Main chunk length of WAV file (${8 + mainChunkLength}) does not match file size (${fileLength}).`);
5590
+ if (getString(dataView, 8, 4) != "WAVE") throw new Error("RIFF file is not a WAV file.");
5591
+ let chunks = /* @__PURE__ */ new Map(), fileOffset = 12;
5592
+ for (; fileOffset < fileLength; ) {
5593
+ if (fileOffset + 8 > fileLength) throw new Error(`Incomplete chunk prefix in WAV file at offset ${fileOffset}.`);
5594
+ let chunkId = getString(dataView, fileOffset, 4).trim(), chunkLength = dataView.getUint32(fileOffset + 4, true);
5595
+ if (fileOffset + 8 + chunkLength > fileLength) throw new Error(`Incomplete chunk data in WAV file at offset ${fileOffset}.`);
5596
+ let chunkData = new DataView(dataView.buffer, dataView.byteOffset + fileOffset + 8, chunkLength);
5597
+ chunks.set(chunkId, chunkData);
5598
+ let padLength = chunkLength % 2;
5599
+ fileOffset += 8 + chunkLength + padLength;
5600
+ }
5601
+ return chunks;
5602
+ }
5603
+ function getString(dataView, offset, length) {
5604
+ let a = new Uint8Array(dataView.buffer, dataView.byteOffset + offset, length);
5605
+ return String.fromCharCode.apply(null, a);
5606
+ }
5607
+ function getInt24(dataView, offset) {
5608
+ let b0 = dataView.getInt8(offset + 2) * 65536, b12 = dataView.getUint16(offset, true);
5609
+ return b0 + b12;
5610
+ }
5611
+ function decodeFormatChunk(dataView) {
5612
+ if (!dataView) throw new Error("No format chunk found in WAV file.");
5613
+ if (dataView.byteLength < 16) throw new Error("Format chunk of WAV file is too short.");
5614
+ let fmt = {};
5615
+ return fmt.formatCode = dataView.getUint16(0, true), fmt.numberOfChannels = dataView.getUint16(2, true), fmt.sampleRate = dataView.getUint32(4, true), fmt.bytesPerSec = dataView.getUint32(8, true), fmt.bytesPerFrame = dataView.getUint16(12, true), fmt.bitsPerSample = dataView.getUint16(14, true), fmt;
5616
+ }
5617
+ function getWavFileType(fmt) {
5618
+ if (fmt.numberOfChannels < 1 || fmt.numberOfChannels > 999) throw new Error("Invalid number of channels in WAV file.");
5619
+ let bytesPerSample = Math.ceil(fmt.bitsPerSample / 8), expectedBytesPerFrame = fmt.numberOfChannels * bytesPerSample;
5620
+ if (fmt.formatCode == 1 && fmt.bitsPerSample >= 1 && fmt.bitsPerSample <= 8 && fmt.bytesPerFrame == expectedBytesPerFrame) return 0;
5621
+ if (fmt.formatCode == 1 && fmt.bitsPerSample >= 9 && fmt.bitsPerSample <= 16 && fmt.bytesPerFrame == expectedBytesPerFrame) return 1;
5622
+ if (fmt.formatCode == 1 && fmt.bitsPerSample >= 17 && fmt.bitsPerSample <= 24 && fmt.bytesPerFrame == expectedBytesPerFrame) return 2;
5623
+ if (fmt.formatCode == 3 && fmt.bitsPerSample == 32 && fmt.bytesPerFrame == expectedBytesPerFrame) return 3;
5624
+ throw new Error(`Unsupported WAV file type, formatCode=${fmt.formatCode}, bitsPerSample=${fmt.bitsPerSample}, bytesPerFrame=${fmt.bytesPerFrame}, numberOfChannels=${fmt.numberOfChannels}.`);
5625
+ }
5626
+ function decodeDataChunk(data, fmt, wavFileType) {
5627
+ switch (wavFileType) {
5628
+ case 0:
5629
+ return decodeDataChunk_uint8(data, fmt);
5630
+ case 1:
5631
+ return decodeDataChunk_int16(data, fmt);
5632
+ case 2:
5633
+ return decodeDataChunk_int24(data, fmt);
5634
+ case 3:
5635
+ return decodeDataChunk_float32(data, fmt);
5636
+ default:
5637
+ throw new Error("No decoder.");
5638
+ }
4931
5639
  }
4932
- function resolveHistoryLimit(cfg, groupOpenid, accountId) {
4933
- return Math.max(0, resolveGroupConfig(cfg, groupOpenid, accountId).historyLimit);
5640
+ function decodeDataChunk_int16(data, fmt) {
5641
+ let channelData = allocateChannelDataArrays(data.byteLength, fmt), numberOfChannels = fmt.numberOfChannels, numberOfFrames = channelData[0].length, offs = 0;
5642
+ for (let frameNo = 0; frameNo < numberOfFrames; frameNo++) for (let channelNo = 0; channelNo < numberOfChannels; channelNo++) {
5643
+ let sampleValueFloat = data.getInt16(offs, true) / 32768;
5644
+ channelData[channelNo][frameNo] = sampleValueFloat, offs += 2;
5645
+ }
5646
+ return channelData;
4934
5647
  }
4935
- function resolveGroupPrompt(cfg, groupOpenid, accountId) {
4936
- return resolveGroupConfig(cfg, groupOpenid, accountId).prompt;
5648
+ function decodeDataChunk_uint8(data, fmt) {
5649
+ let channelData = allocateChannelDataArrays(data.byteLength, fmt), numberOfChannels = fmt.numberOfChannels, numberOfFrames = channelData[0].length, offs = 0;
5650
+ for (let frameNo = 0; frameNo < numberOfFrames; frameNo++) for (let channelNo = 0; channelNo < numberOfChannels; channelNo++) {
5651
+ let sampleValueFloat = (data.getUint8(offs) - 128) / 128;
5652
+ channelData[channelNo][frameNo] = sampleValueFloat, offs += 1;
5653
+ }
5654
+ return channelData;
4937
5655
  }
4938
- function resolveRequireMention(cfg, groupOpenid, accountId) {
4939
- return resolveGroupConfig(cfg, groupOpenid, accountId).requireMention;
5656
+ function decodeDataChunk_int24(data, fmt) {
5657
+ let channelData = allocateChannelDataArrays(data.byteLength, fmt), numberOfChannels = fmt.numberOfChannels, numberOfFrames = channelData[0].length, offs = 0;
5658
+ for (let frameNo = 0; frameNo < numberOfFrames; frameNo++) for (let channelNo = 0; channelNo < numberOfChannels; channelNo++) {
5659
+ let sampleValueFloat = getInt24(data, offs) / 8388608;
5660
+ channelData[channelNo][frameNo] = sampleValueFloat, offs += 3;
5661
+ }
5662
+ return channelData;
4940
5663
  }
4941
- function resolveIgnoreOtherMentions(cfg, groupOpenid, accountId) {
4942
- return resolveGroupConfig(cfg, groupOpenid, accountId).ignoreOtherMentions;
5664
+ function decodeDataChunk_float32(data, fmt) {
5665
+ let channelData = allocateChannelDataArrays(data.byteLength, fmt), numberOfChannels = fmt.numberOfChannels, numberOfFrames = channelData[0].length, offs = 0;
5666
+ for (let frameNo = 0; frameNo < numberOfFrames; frameNo++) for (let channelNo = 0; channelNo < numberOfChannels; channelNo++) {
5667
+ let sampleValueFloat = data.getFloat32(offs, true);
5668
+ channelData[channelNo][frameNo] = sampleValueFloat, offs += 4;
5669
+ }
5670
+ return channelData;
4943
5671
  }
4944
- function resolveToolPolicy(cfg, groupOpenid, accountId) {
4945
- return resolveGroupConfig(cfg, groupOpenid, accountId).toolPolicy;
5672
+ function allocateChannelDataArrays(dataLength, fmt) {
5673
+ let numberOfFrames = Math.floor(dataLength / fmt.bytesPerFrame), channelData = new Array(fmt.numberOfChannels);
5674
+ for (let channelNo = 0; channelNo < fmt.numberOfChannels; channelNo++) channelData[channelNo] = new Float32Array(numberOfFrames);
5675
+ return channelData;
4946
5676
  }
4947
- function resolveGroupName(cfg, groupOpenid, accountId) {
4948
- const name = resolveGroupConfig(cfg, groupOpenid, accountId).name;
4949
- return name || groupOpenid.slice(0, 8);
5677
+ function verifyDataChunkLength(data, fmt) {
5678
+ if (!data) throw new Error("No data chunk found in WAV file.");
5679
+ if (data.byteLength % fmt.bytesPerFrame != 0) throw new Error("WAV file data chunk length is not a multiple of frame size.");
4950
5680
  }
4951
- function normalizeAppId(raw) {
4952
- if (raw === null || raw === void 0) return "";
4953
- return String(raw).trim();
5681
+ function getWavFileInfo(fileData) {
5682
+ let chunks = unpackWavFileChunks(fileData), chunkInfo = getChunkInfo(chunks), fmt = decodeFormatChunk(chunks.get("fmt"));
5683
+ return { chunkInfo, fmt };
4954
5684
  }
4955
- function listQQBotAccountIds(cfg) {
4956
- const ids = /* @__PURE__ */ new Set();
4957
- const qqbot = cfg.channels?.qqbot;
4958
- if (qqbot?.appId) {
4959
- ids.add(DEFAULT_ACCOUNT_ID);
5685
+ function getChunkInfo(chunks) {
5686
+ let chunkInfo = [];
5687
+ for (let e of chunks) {
5688
+ let ci = {};
5689
+ ci.chunkId = e[0], ci.dataOffset = e[1].byteOffset, ci.dataLength = e[1].byteLength, chunkInfo.push(ci);
4960
5690
  }
4961
- if (qqbot?.accounts) {
4962
- for (const accountId of Object.keys(qqbot.accounts)) {
4963
- if (qqbot.accounts[accountId]?.appId) {
4964
- ids.add(accountId);
4965
- }
4966
- }
4967
- }
4968
- return Array.from(ids);
5691
+ return chunkInfo.sort((e1, e2) => e1.dataOffset - e2.dataOffset), chunkInfo;
4969
5692
  }
4970
- function resolveDefaultQQBotAccountId(cfg) {
4971
- const qqbot = cfg.channels?.qqbot;
4972
- if (qqbot?.appId) {
4973
- return DEFAULT_ACCOUNT_ID;
5693
+ function ensureMonoPcm(channelData) {
5694
+ let { length: numberOfChannels } = channelData;
5695
+ if (numberOfChannels === 1) return channelData[0];
5696
+ let monoData = new Float32Array(channelData[0].length);
5697
+ for (let i = 0; i < monoData.length; i++) {
5698
+ let sum = 0;
5699
+ for (let j = 0; j < numberOfChannels; j++) sum += channelData[j][i];
5700
+ monoData[i] = sum / numberOfChannels;
4974
5701
  }
4975
- if (qqbot?.accounts) {
4976
- const ids = Object.keys(qqbot.accounts);
4977
- if (ids.length > 0) {
4978
- return ids[0];
4979
- }
5702
+ return monoData;
5703
+ }
5704
+ function ensureS16lePcm(input) {
5705
+ let int16Array = new Int16Array(input.length);
5706
+ for (let offset = 0; offset < input.length; offset++) {
5707
+ let x = ~~(input[offset] * 32768);
5708
+ int16Array[offset] = x > 32767 ? 32767 : x;
4980
5709
  }
4981
- return DEFAULT_ACCOUNT_ID;
5710
+ return int16Array.buffer;
4982
5711
  }
4983
- function resolveUserAgentSuffix(cfg) {
4984
- const qqbot = cfg.channels?.qqbot;
4985
- return qqbot?.userAgentSuffix ? String(qqbot.userAgentSuffix).trim() : "";
5712
+ function toUTF8String(input, start = 0, end = input.byteLength) {
5713
+ return new TextDecoder().decode(input.slice(start, end));
4986
5714
  }
4987
- function resolveProcessingTimeoutMs(accountConfig) {
4988
- if (accountConfig?.processingTimeoutMs !== void 0) {
4989
- return accountConfig.processingTimeoutMs;
4990
- }
4991
- const env = process.env.OPENCLAW_PROCESSING_TIMEOUT_MS;
4992
- if (env) {
4993
- const v = Number(env);
4994
- if (!Number.isNaN(v) && v >= 0) return v;
4995
- }
4996
- return DEFAULT_PROCESSING_TIMEOUT_MS;
5715
+ function binaryFromSource(source) {
5716
+ return ArrayBuffer.isView(source) ? source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength) : source;
4997
5717
  }
4998
- function resolveQQBotAccount(cfg, accountId) {
4999
- const resolvedAccountId = accountId ?? resolveDefaultQQBotAccountId(cfg);
5000
- const qqbot = cfg.channels?.qqbot;
5001
- let accountConfig = {};
5002
- let appId = "";
5003
- let clientSecret = "";
5004
- let secretSource = "none";
5005
- if (resolvedAccountId === DEFAULT_ACCOUNT_ID) {
5006
- const { accounts: _accounts, ...topLevelConfig } = qqbot ?? {};
5007
- accountConfig = {
5008
- ...topLevelConfig,
5009
- markdownSupport: qqbot?.markdownSupport ?? true
5010
- };
5011
- appId = normalizeAppId(qqbot?.appId);
5012
- } else {
5013
- const account = qqbot?.accounts?.[resolvedAccountId];
5014
- accountConfig = account ?? {};
5015
- appId = normalizeAppId(account?.appId);
5718
+ async function encode(input, sampleRate) {
5719
+ let instance = await silk_default(), buffer = binaryFromSource(input);
5720
+ if (!buffer?.byteLength) throw new Error("input data length is 0");
5721
+ if (isWavFile(input)) {
5722
+ let { channelData, sampleRate: wavSampleRate } = decodeWavFile(input);
5723
+ sampleRate ||= wavSampleRate, buffer = ensureS16lePcm(ensureMonoPcm(channelData));
5016
5724
  }
5017
- if (accountConfig.clientSecret) {
5018
- clientSecret = accountConfig.clientSecret;
5019
- secretSource = "config";
5020
- } else if (accountConfig.clientSecretFile) {
5021
- secretSource = "file";
5022
- } else if (process.env.QQBOT_CLIENT_SECRET && resolvedAccountId === DEFAULT_ACCOUNT_ID) {
5023
- clientSecret = process.env.QQBOT_CLIENT_SECRET;
5024
- secretSource = "env";
5025
- }
5026
- if (!appId && process.env.QQBOT_APP_ID && resolvedAccountId === DEFAULT_ACCOUNT_ID) {
5027
- appId = normalizeAppId(process.env.QQBOT_APP_ID);
5725
+ let data = new Uint8Array(), duration = instance.silk_encode(buffer, sampleRate, (output) => {
5726
+ data = output.slice();
5727
+ });
5728
+ if (duration === 0) throw new Error("silk encoding failure");
5729
+ return { data, duration };
5730
+ }
5731
+ async function decode(input, sampleRate) {
5732
+ let instance = await silk_default(), buffer = binaryFromSource(input);
5733
+ if (!buffer?.byteLength) throw new Error("input data length is 0");
5734
+ let data = new Uint8Array(), duration = instance.silk_decode(buffer, sampleRate, (output) => {
5735
+ output.length > 0 && (data = output.slice());
5736
+ });
5737
+ if (duration === 0) throw new Error("silk decoding failure");
5738
+ return { data, duration };
5739
+ }
5740
+ function getDuration(data, frameMs = 20) {
5741
+ let buffer = binaryFromSource(data), view = new DataView(buffer), byteLength = view.byteLength, offset = view.getUint8(0) === 2 ? 10 : 9, blocks = 0;
5742
+ for (; offset < byteLength; ) {
5743
+ let size = view.getUint16(offset, true);
5744
+ blocks += 1, offset += size + 2;
5028
5745
  }
5029
- return {
5030
- accountId: resolvedAccountId,
5031
- name: accountConfig.name,
5032
- enabled: accountConfig.enabled !== false,
5033
- appId,
5034
- clientSecret,
5035
- secretSource,
5036
- systemPrompt: accountConfig.systemPrompt,
5037
- markdownSupport: accountConfig.markdownSupport !== false,
5038
- userAgentSuffix: resolveUserAgentSuffix(cfg),
5039
- processingTimeoutMs: resolveProcessingTimeoutMs(accountConfig),
5040
- config: accountConfig
5041
- };
5746
+ return blocks * frameMs;
5042
5747
  }
5043
- function applyQQBotAccountConfig(cfg, accountId, input) {
5044
- const next = { ...cfg };
5045
- if (accountId === DEFAULT_ACCOUNT_ID) {
5046
- const existingConfig = next.channels?.qqbot || {};
5047
- const allowFrom = existingConfig.allowFrom ?? ["*"];
5048
- next.channels = {
5049
- ...next.channels,
5050
- qqbot: {
5051
- ...next.channels?.qqbot || {},
5052
- enabled: true,
5053
- allowFrom,
5054
- ...input.appId ? { appId: input.appId } : {},
5055
- ...input.clientSecret ? { clientSecret: input.clientSecret } : input.clientSecretFile ? { clientSecretFile: input.clientSecretFile } : {},
5056
- ...input.name ? { name: input.name } : {}
5748
+ function isWav(data) {
5749
+ return isWavFile(data);
5750
+ }
5751
+ function getWavFileInfo2(data) {
5752
+ return getWavFileInfo(data);
5753
+ }
5754
+ function isSilk(data) {
5755
+ let buffer = binaryFromSource(data);
5756
+ return buffer.byteLength < 7 ? false : toUTF8String(buffer, 0, 7).includes("#!SILK");
5757
+ }
5758
+ var import_meta, Module, silk_default, audioEncodingNames, wavFileTypeAudioEncodings;
5759
+ var init_lib = __esm({
5760
+ "node_modules/.pnpm/silk-wasm@3.7.1/node_modules/silk-wasm/lib/index.mjs"() {
5761
+ "use strict";
5762
+ import_meta = {};
5763
+ Module = async function(moduleArg = {}) {
5764
+ var moduleRtn, g2 = moduleArg, aa, q, ba = new Promise((a, b2) => {
5765
+ aa = a, q = b2;
5766
+ }), ca = typeof window == "object", da = typeof WorkerGlobalScope < "u", t = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string" && process.type != "renderer";
5767
+ if (t) {
5768
+ let { createRequire: a } = await import("module");
5769
+ var require2 = a(import_meta.url);
5770
+ }
5771
+ var u2 = (a, b2) => {
5772
+ throw b2;
5773
+ }, ea = import_meta.url, v = "", fa, w2;
5774
+ if (t) {
5775
+ var fs21 = require2("fs"), ha = require2("path");
5776
+ ea.startsWith("file:") && (v = ha.dirname(require2("url").fileURLToPath(ea)) + "/"), w2 = (a) => (a = y2(a) ? new URL(a) : a, fs21.readFileSync(a)), fa = async (a) => (a = y2(a) ? new URL(a) : a, fs21.readFileSync(a, void 0)), process.argv.slice(2), u2 = (a, b2) => {
5777
+ throw process.exitCode = a, b2;
5778
+ };
5779
+ } else if (ca || da) {
5780
+ try {
5781
+ v = new URL(".", ea).href;
5782
+ } catch {
5783
+ }
5784
+ da && (w2 = (a) => {
5785
+ var b2 = new XMLHttpRequest();
5786
+ return b2.open("GET", a, false), b2.responseType = "arraybuffer", b2.send(null), new Uint8Array(b2.response);
5787
+ }), fa = async (a) => {
5788
+ if (y2(a)) return new Promise((d3, c) => {
5789
+ var e = new XMLHttpRequest();
5790
+ e.open("GET", a, true), e.responseType = "arraybuffer", e.onload = () => {
5791
+ e.status == 200 || e.status == 0 && e.response ? d3(e.response) : c(e.status);
5792
+ }, e.onerror = c, e.send(null);
5793
+ });
5794
+ var b2 = await fetch(a, { credentials: "same-origin" });
5795
+ if (b2.ok) return b2.arrayBuffer();
5796
+ throw Error(b2.status + " : " + b2.url);
5797
+ };
5057
5798
  }
5058
- };
5059
- } else {
5060
- const existingAccountConfig = next.channels?.qqbot?.accounts?.[accountId] || {};
5061
- const allowFrom = existingAccountConfig.allowFrom ?? ["*"];
5062
- next.channels = {
5063
- ...next.channels,
5064
- qqbot: {
5065
- ...next.channels?.qqbot || {},
5066
- enabled: true,
5067
- accounts: {
5068
- ...next.channels?.qqbot?.accounts || {},
5069
- [accountId]: {
5070
- ...next.channels?.qqbot?.accounts?.[accountId] || {},
5071
- enabled: true,
5072
- allowFrom,
5073
- ...input.appId ? { appId: input.appId } : {},
5074
- ...input.clientSecret ? { clientSecret: input.clientSecret } : input.clientSecretFile ? { clientSecretFile: input.clientSecretFile } : {},
5075
- ...input.name ? { name: input.name } : {}
5799
+ console.log.bind(console);
5800
+ var A = console.error.bind(console), C2, D, E3 = false, ia, ja, F2, G, H, I, J, ka, la, ma, na, y2 = (a) => a.startsWith("file://");
5801
+ function pa() {
5802
+ var a = D.buffer;
5803
+ ja = new Int8Array(a), G = new Int16Array(a), F2 = new Uint8Array(a), H = new Uint16Array(a), I = new Int32Array(a), J = new Uint32Array(a), ka = new Float32Array(a), na = new Float64Array(a), la = new BigInt64Array(a), ma = new BigUint64Array(a);
5804
+ }
5805
+ var K = 0, L = null;
5806
+ function qa(a) {
5807
+ throw g2.onAbort?.(a), a = "Aborted(" + a + ")", A(a), E3 = true, a = new WebAssembly.RuntimeError(a + ". Build with -sASSERTIONS for more info."), q(a), a;
5808
+ }
5809
+ var ra;
5810
+ async function sa(a) {
5811
+ if (!C2) try {
5812
+ var b2 = await fa(a);
5813
+ return new Uint8Array(b2);
5814
+ } catch {
5815
+ }
5816
+ if (a == ra && C2) a = new Uint8Array(C2);
5817
+ else if (w2) a = w2(a);
5818
+ else throw "both async and sync fetching of the wasm failed";
5819
+ return a;
5820
+ }
5821
+ async function ta(a, b2) {
5822
+ try {
5823
+ var d3 = await sa(a);
5824
+ return await WebAssembly.instantiate(d3, b2);
5825
+ } catch (c) {
5826
+ A(`failed to asynchronously prepare wasm: ${c}`), qa(c);
5827
+ }
5828
+ }
5829
+ async function ua(a) {
5830
+ var b2 = ra;
5831
+ if (!C2 && typeof WebAssembly.instantiateStreaming == "function" && !y2(b2) && !t) try {
5832
+ var d3 = fetch(b2, { credentials: "same-origin" });
5833
+ return await WebAssembly.instantiateStreaming(d3, a);
5834
+ } catch (c) {
5835
+ A(`wasm streaming compile failed: ${c}`), A("falling back to ArrayBuffer instantiation");
5836
+ }
5837
+ return ta(b2, a);
5838
+ }
5839
+ class va {
5840
+ name = "ExitStatus";
5841
+ constructor(a) {
5842
+ this.message = `Program terminated with exit(${a})`, this.status = a;
5843
+ }
5844
+ }
5845
+ var wa = (a) => {
5846
+ for (; 0 < a.length; ) a.shift()(g2);
5847
+ }, xa = [], ya = [], za = () => {
5848
+ var a = g2.preRun.shift();
5849
+ ya.push(a);
5850
+ }, O = true;
5851
+ class Aa {
5852
+ constructor(a) {
5853
+ this.I = a - 24;
5854
+ }
5855
+ }
5856
+ var Ba = 0, Ca = 0, Da, P = (a) => {
5857
+ for (var b2 = ""; F2[a]; ) b2 += Da[F2[a++]];
5858
+ return b2;
5859
+ }, Q = {}, R = {}, S = {}, T = g2.BindingError = class extends Error {
5860
+ constructor(a) {
5861
+ super(a), this.name = "BindingError";
5862
+ }
5863
+ }, Ea = (a) => {
5864
+ throw new T(a);
5865
+ };
5866
+ function Fa(a, b2, d3 = {}) {
5867
+ var c = b2.name;
5868
+ if (!a) throw new T(`type "${c}" must have a positive integer typeid pointer`);
5869
+ if (R.hasOwnProperty(a)) {
5870
+ if (d3.K) return;
5871
+ throw new T(`Cannot register type '${c}' twice`);
5872
+ }
5873
+ R[a] = b2, delete S[a], Q.hasOwnProperty(a) && (b2 = Q[a], delete Q[a], b2.forEach((e) => e()));
5874
+ }
5875
+ function U(a, b2, d3 = {}) {
5876
+ return Fa(a, b2, d3);
5877
+ }
5878
+ var Ga = (a, b2, d3) => {
5879
+ switch (b2) {
5880
+ case 1:
5881
+ return d3 ? (c) => ja[c] : (c) => F2[c];
5882
+ case 2:
5883
+ return d3 ? (c) => G[c >> 1] : (c) => H[c >> 1];
5884
+ case 4:
5885
+ return d3 ? (c) => I[c >> 2] : (c) => J[c >> 2];
5886
+ case 8:
5887
+ return d3 ? (c) => la[c >> 3] : (c) => ma[c >> 3];
5888
+ default:
5889
+ throw new TypeError(`invalid integer width (${b2}): ${a}`);
5890
+ }
5891
+ }, Ha = [], V = [], Ia = (a) => {
5892
+ 9 < a && --V[a + 1] === 0 && (V[a] = void 0, Ha.push(a));
5893
+ }, Ja = (a) => {
5894
+ if (!a) throw new T(`Cannot use deleted val. handle = ${a}`);
5895
+ return V[a];
5896
+ }, Ka = (a) => {
5897
+ switch (a) {
5898
+ case void 0:
5899
+ return 2;
5900
+ case null:
5901
+ return 4;
5902
+ case true:
5903
+ return 6;
5904
+ case false:
5905
+ return 8;
5906
+ default:
5907
+ let b2 = Ha.pop() || V.length;
5908
+ return V[b2] = a, V[b2 + 1] = 1, b2;
5909
+ }
5910
+ };
5911
+ function La(a) {
5912
+ return this.fromWireType(J[a >> 2]);
5913
+ }
5914
+ var Ma = { name: "emscripten::val", fromWireType: (a) => {
5915
+ var b2 = Ja(a);
5916
+ return Ia(a), b2;
5917
+ }, toWireType: (a, b2) => Ka(b2), H: 8, readValueFromPointer: La, G: null }, Na = (a, b2) => {
5918
+ switch (b2) {
5919
+ case 4:
5920
+ return function(d3) {
5921
+ return this.fromWireType(ka[d3 >> 2]);
5922
+ };
5923
+ case 8:
5924
+ return function(d3) {
5925
+ return this.fromWireType(na[d3 >> 3]);
5926
+ };
5927
+ default:
5928
+ throw new TypeError(`invalid float width (${b2}): ${a}`);
5929
+ }
5930
+ }, Oa = (a) => {
5931
+ for (; a.length; ) {
5932
+ var b2 = a.pop();
5933
+ a.pop()(b2);
5934
+ }
5935
+ };
5936
+ function Pa(a) {
5937
+ for (var b2 = 1; b2 < a.length; ++b2) if (a[b2] !== null && a[b2].G === void 0) return true;
5938
+ return false;
5939
+ }
5940
+ var Sa = (a, b2) => {
5941
+ if (g2[a].F === void 0) {
5942
+ var d3 = g2[a];
5943
+ g2[a] = function(...c) {
5944
+ if (!g2[a].F.hasOwnProperty(c.length)) throw new T(`Function '${b2}' called with an invalid number of arguments (${c.length}) - expects one of (${g2[a].F})!`);
5945
+ return g2[a].F[c.length].apply(this, c);
5946
+ }, g2[a].F = [], g2[a].F[d3.J] = d3;
5947
+ }
5948
+ }, Ta = (a, b2, d3) => {
5949
+ if (g2.hasOwnProperty(a)) {
5950
+ if (d3 === void 0 || g2[a].F !== void 0 && g2[a].F[d3] !== void 0) throw new T(`Cannot register public name '${a}' twice`);
5951
+ if (Sa(a, a), g2[a].F.hasOwnProperty(d3)) throw new T(`Cannot register multiple overloads of a function with the same number of arguments (${d3})!`);
5952
+ g2[a].F[d3] = b2;
5953
+ } else g2[a] = b2, g2[a].J = d3;
5954
+ }, Ua = (a, b2) => {
5955
+ for (var d3 = [], c = 0; c < a; c++) d3.push(J[b2 + 4 * c >> 2]);
5956
+ return d3;
5957
+ }, Va = g2.InternalError = class extends Error {
5958
+ constructor(a) {
5959
+ super(a), this.name = "InternalError";
5960
+ }
5961
+ }, Wa = [], Xa, Ya = (a, b2) => {
5962
+ a = P(a);
5963
+ var d3;
5964
+ if ((d3 = Wa[b2]) || (Wa[b2] = d3 = Xa.get(b2)), typeof d3 != "function") throw new T(`unknown function pointer with signature ${a}: ${b2}`);
5965
+ return d3;
5966
+ };
5967
+ class Za extends Error {
5968
+ }
5969
+ for (var ab = (a) => {
5970
+ a = $a(a);
5971
+ var b2 = P(a);
5972
+ return W(a), b2;
5973
+ }, bb = (a, b2) => {
5974
+ function d3(f) {
5975
+ e[f] || R[f] || (S[f] ? S[f].forEach(d3) : (c.push(f), e[f] = true));
5976
+ }
5977
+ var c = [], e = {};
5978
+ throw b2.forEach(d3), new Za(`${a}: ` + c.map(ab).join([", "]));
5979
+ }, cb = (a, b2) => {
5980
+ function d3(h2) {
5981
+ if (h2 = b2(h2), h2.length !== c.length) throw new Va("Mismatched type converter count");
5982
+ for (var l3 = 0; l3 < c.length; ++l3) U(c[l3], h2[l3]);
5983
+ }
5984
+ var c = [];
5985
+ c.forEach((h2) => S[h2] = a);
5986
+ var e = Array(a.length), f = [], m3 = 0;
5987
+ a.forEach((h2, l3) => {
5988
+ R.hasOwnProperty(h2) ? e[l3] = R[h2] : (f.push(h2), Q.hasOwnProperty(h2) || (Q[h2] = []), Q[h2].push(() => {
5989
+ e[l3] = R[h2], ++m3, m3 === f.length && d3(e);
5990
+ }));
5991
+ }), f.length === 0 && d3(e);
5992
+ }, db = (a) => {
5993
+ a = a.trim();
5994
+ let b2 = a.indexOf("(");
5995
+ return b2 === -1 ? a : a.slice(0, b2);
5996
+ }, eb = typeof TextDecoder < "u" ? new TextDecoder() : void 0, fb = (a = 0, b2 = NaN) => {
5997
+ var d3 = F2, c = a + b2;
5998
+ for (b2 = a; d3[b2] && !(b2 >= c); ) ++b2;
5999
+ if (16 < b2 - a && d3.buffer && eb) return eb.decode(d3.subarray(a, b2));
6000
+ for (c = ""; a < b2; ) {
6001
+ var e = d3[a++];
6002
+ if (e & 128) {
6003
+ var f = d3[a++] & 63;
6004
+ if ((e & 224) == 192) c += String.fromCharCode((e & 31) << 6 | f);
6005
+ else {
6006
+ var m3 = d3[a++] & 63;
6007
+ e = (e & 240) == 224 ? (e & 15) << 12 | f << 6 | m3 : (e & 7) << 18 | f << 12 | m3 << 6 | d3[a++] & 63, 65536 > e ? c += String.fromCharCode(e) : (e -= 65536, c += String.fromCharCode(55296 | e >> 10, 56320 | e & 1023));
6008
+ }
6009
+ } else c += String.fromCharCode(e);
6010
+ }
6011
+ return c;
6012
+ }, gb = typeof TextDecoder < "u" ? new TextDecoder("utf-16le") : void 0, hb = (a, b2) => {
6013
+ for (var d3 = a >> 1, c = d3 + b2 / 2; !(d3 >= c) && H[d3]; ) ++d3;
6014
+ if (d3 <<= 1, 32 < d3 - a && gb) return gb.decode(F2.subarray(a, d3));
6015
+ for (d3 = "", c = 0; !(c >= b2 / 2); ++c) {
6016
+ var e = G[a + 2 * c >> 1];
6017
+ if (e == 0) break;
6018
+ d3 += String.fromCharCode(e);
6019
+ }
6020
+ return d3;
6021
+ }, ib = (a, b2, d3) => {
6022
+ if (d3 ??= 2147483647, 2 > d3) return 0;
6023
+ d3 -= 2;
6024
+ var c = b2;
6025
+ d3 = d3 < 2 * a.length ? d3 / 2 : a.length;
6026
+ for (var e = 0; e < d3; ++e) G[b2 >> 1] = a.charCodeAt(e), b2 += 2;
6027
+ return G[b2 >> 1] = 0, b2 - c;
6028
+ }, jb = (a) => 2 * a.length, kb = (a, b2) => {
6029
+ for (var d3 = 0, c = ""; !(d3 >= b2 / 4); ) {
6030
+ var e = I[a + 4 * d3 >> 2];
6031
+ if (e == 0) break;
6032
+ ++d3, 65536 <= e ? (e -= 65536, c += String.fromCharCode(55296 | e >> 10, 56320 | e & 1023)) : c += String.fromCharCode(e);
6033
+ }
6034
+ return c;
6035
+ }, lb = (a, b2, d3) => {
6036
+ if (d3 ??= 2147483647, 4 > d3) return 0;
6037
+ var c = b2;
6038
+ d3 = c + d3 - 4;
6039
+ for (var e = 0; e < a.length; ++e) {
6040
+ var f = a.charCodeAt(e);
6041
+ if (55296 <= f && 57343 >= f) {
6042
+ var m3 = a.charCodeAt(++e);
6043
+ f = 65536 + ((f & 1023) << 10) | m3 & 1023;
6044
+ }
6045
+ if (I[b2 >> 2] = f, b2 += 4, b2 + 4 > d3) break;
6046
+ }
6047
+ return I[b2 >> 2] = 0, b2 - c;
6048
+ }, mb = (a) => {
6049
+ for (var b2 = 0, d3 = 0; d3 < a.length; ++d3) {
6050
+ var c = a.charCodeAt(d3);
6051
+ 55296 <= c && 57343 >= c && ++d3, b2 += 4;
6052
+ }
6053
+ return b2;
6054
+ }, nb = 0, ob = [], pb = (a) => {
6055
+ var b2 = ob.length;
6056
+ return ob.push(a), b2;
6057
+ }, qb = (a, b2) => {
6058
+ var d3 = R[a];
6059
+ if (d3 === void 0) throw a = `${b2} has unknown type ${ab(a)}`, new T(a);
6060
+ return d3;
6061
+ }, rb = (a, b2) => {
6062
+ for (var d3 = Array(a), c = 0; c < a; ++c) d3[c] = qb(J[b2 + 4 * c >> 2], `parameter ${c}`);
6063
+ return d3;
6064
+ }, sb = (a, b2, d3) => {
6065
+ var c = [];
6066
+ return a = a.toWireType(c, d3), c.length && (J[b2 >> 2] = Ka(c)), a;
6067
+ }, X = {}, tb = (a) => {
6068
+ ia = a, O || 0 < nb || (g2.onExit?.(a), E3 = true), u2(a, new va(a));
6069
+ }, ub = (a) => {
6070
+ if (!E3) try {
6071
+ if (a(), !(O || 0 < nb)) try {
6072
+ ia = a = ia, tb(a);
6073
+ } catch (b2) {
6074
+ b2 instanceof va || b2 == "unwind" || u2(1, b2);
5076
6075
  }
6076
+ } catch (b2) {
6077
+ b2 instanceof va || b2 == "unwind" || u2(1, b2);
6078
+ }
6079
+ }, vb = Array(256), Y = 0; 256 > Y; ++Y) vb[Y] = String.fromCharCode(Y);
6080
+ Da = vb, V.push(0, 1, void 0, 1, null, 1, true, 1, false, 1), g2.count_emval_handles = () => V.length / 2 - 5 - Ha.length, g2.noExitRuntime && (O = g2.noExitRuntime), g2.printErr && (A = g2.printErr), g2.wasmBinary && (C2 = g2.wasmBinary);
6081
+ var Ab = { u: (a, b2, d3) => {
6082
+ var c = new Aa(a);
6083
+ throw J[c.I + 16 >> 2] = 0, J[c.I + 4 >> 2] = b2, J[c.I + 8 >> 2] = d3, Ba = a, Ca++, Ba;
6084
+ }, v: () => qa(""), l: (a, b2, d3) => {
6085
+ b2 = P(b2), U(a, { name: b2, fromWireType: (c) => c, toWireType: function(c, e) {
6086
+ if (typeof e != "bigint" && typeof e != "number") throw e === null ? e = "null" : (c = typeof e, e = c === "object" || c === "array" || c === "function" ? e.toString() : "" + e), new TypeError(`Cannot convert "${e}" to ${this.name}`);
6087
+ return typeof e == "number" && (e = BigInt(e)), e;
6088
+ }, H: 8, readValueFromPointer: Ga(b2, d3, b2.indexOf("u") == -1), G: null });
6089
+ }, o: (a, b2, d3, c) => {
6090
+ b2 = P(b2), U(a, { name: b2, fromWireType: function(e) {
6091
+ return !!e;
6092
+ }, toWireType: function(e, f) {
6093
+ return f ? d3 : c;
6094
+ }, H: 8, readValueFromPointer: function(e) {
6095
+ return this.fromWireType(F2[e]);
6096
+ }, G: null });
6097
+ }, m: (a) => U(a, Ma), k: (a, b2, d3) => {
6098
+ b2 = P(b2), U(a, { name: b2, fromWireType: (c) => c, toWireType: (c, e) => e, H: 8, readValueFromPointer: Na(b2, d3), G: null });
6099
+ }, c: (a, b2, d3, c, e, f, m3) => {
6100
+ var h2 = Ua(b2, d3);
6101
+ a = P(a), a = db(a), e = Ya(c, e), Ta(a, function() {
6102
+ bb(`Cannot call ${a} due to unbound types`, h2);
6103
+ }, b2 - 1), cb(h2, (l3) => {
6104
+ var k = [l3[0], null].concat(l3.slice(1));
6105
+ l3 = a;
6106
+ var p2 = a, z = e, n = k.length;
6107
+ if (2 > n) throw new T("argTypes array size mismatch! Must at least get return value and 'this' types!");
6108
+ var B = k[1] !== null && false, M = Pa(k), Qa = k[0].name !== "void";
6109
+ z = [p2, Ea, z, f, Oa, k[0], k[1]];
6110
+ for (var x = 0; x < n - 2; ++x) z.push(k[x + 2]);
6111
+ if (!M) for (x = B ? 1 : 2; x < k.length; ++x) k[x].G !== null && z.push(k[x].G);
6112
+ M = Pa(k), x = k.length - 2;
6113
+ var r = [], N = ["fn"];
6114
+ for (B && N.push("thisWired"), n = 0; n < x; ++n) r.push(`arg${n}`), N.push(`arg${n}Wired`);
6115
+ r = r.join(","), N = N.join(","), r = `return function (${r}) {
6116
+ `, M && (r += `var destructors = [];
6117
+ `);
6118
+ var Ra = M ? "destructors" : "null", oa = "humanName throwBindingError invoker fn runDestructors retType classParam".split(" ");
6119
+ for (B && (r += `var thisWired = classParam['toWireType'](${Ra}, this);
6120
+ `), n = 0; n < x; ++n) r += `var arg${n}Wired = argType${n}['toWireType'](${Ra}, arg${n});
6121
+ `, oa.push(`argType${n}`);
6122
+ if (r += (Qa || m3 ? "var rv = " : "") + `invoker(${N});
6123
+ `, M) r += `runDestructors(destructors);
6124
+ `;
6125
+ else for (n = B ? 1 : 2; n < k.length; ++n) B = n === 1 ? "thisWired" : "arg" + (n - 2) + "Wired", k[n].G !== null && (r += `${B}_dtor(${B});
6126
+ `, oa.push(`${B}_dtor`));
6127
+ Qa && (r += `var ret = retType['fromWireType'](rv);
6128
+ return ret;
6129
+ `);
6130
+ let [yb, zb] = [oa, r + `}
6131
+ `];
6132
+ if (k = new _F(...yb, zb)(...z), p2 = Object.defineProperty(k, "name", { value: p2 }), k = b2 - 1, !g2.hasOwnProperty(l3)) throw new Va("Replacing nonexistent public symbol");
6133
+ return g2[l3].F !== void 0 && k !== void 0 ? g2[l3].F[k] = p2 : (g2[l3] = p2, g2[l3].J = k), [];
6134
+ });
6135
+ }, b: (a, b2, d3, c, e) => {
6136
+ if (b2 = P(b2), e === -1 && (e = 4294967295), e = (h2) => h2, c === 0) {
6137
+ var f = 32 - 8 * d3;
6138
+ e = (h2) => h2 << f >>> f;
6139
+ }
6140
+ var m3 = b2.includes("unsigned") ? function(h2, l3) {
6141
+ return l3 >>> 0;
6142
+ } : function(h2, l3) {
6143
+ return l3;
6144
+ };
6145
+ U(a, { name: b2, fromWireType: e, toWireType: m3, H: 8, readValueFromPointer: Ga(b2, d3, c !== 0), G: null });
6146
+ }, a: (a, b2, d3) => {
6147
+ function c(f) {
6148
+ return new e(ja.buffer, J[f + 4 >> 2], J[f >> 2]);
6149
+ }
6150
+ var e = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, BigInt64Array, BigUint64Array][b2];
6151
+ d3 = P(d3), U(a, { name: d3, fromWireType: c, H: 8, readValueFromPointer: c }, { K: true });
6152
+ }, n: (a, b2) => {
6153
+ b2 = P(b2), U(a, { name: b2, fromWireType: function(d3) {
6154
+ for (var c = J[d3 >> 2], e = d3 + 4, f, m3 = e, h2 = 0; h2 <= c; ++h2) {
6155
+ var l3 = e + h2;
6156
+ (h2 == c || F2[l3] == 0) && (m3 = m3 ? fb(m3, l3 - m3) : "", f === void 0 ? f = m3 : (f += "\0", f += m3), m3 = l3 + 1);
6157
+ }
6158
+ return W(d3), f;
6159
+ }, toWireType: function(d3, c) {
6160
+ c instanceof ArrayBuffer && (c = new Uint8Array(c));
6161
+ var e, f = typeof c == "string";
6162
+ if (!(f || ArrayBuffer.isView(c) && c.BYTES_PER_ELEMENT == 1)) throw new T("Cannot pass non-string to std::string");
6163
+ var m3;
6164
+ if (f) for (e = m3 = 0; e < c.length; ++e) {
6165
+ var h2 = c.charCodeAt(e);
6166
+ 127 >= h2 ? m3++ : 2047 >= h2 ? m3 += 2 : 55296 <= h2 && 57343 >= h2 ? (m3 += 4, ++e) : m3 += 3;
6167
+ }
6168
+ else m3 = c.length;
6169
+ if (e = m3, m3 = wb(4 + e + 1), h2 = m3 + 4, J[m3 >> 2] = e, f) {
6170
+ if (f = h2, h2 = e + 1, e = F2, 0 < h2) {
6171
+ h2 = f + h2 - 1;
6172
+ for (var l3 = 0; l3 < c.length; ++l3) {
6173
+ var k = c.charCodeAt(l3);
6174
+ if (55296 <= k && 57343 >= k) {
6175
+ var p2 = c.charCodeAt(++l3);
6176
+ k = 65536 + ((k & 1023) << 10) | p2 & 1023;
6177
+ }
6178
+ if (127 >= k) {
6179
+ if (f >= h2) break;
6180
+ e[f++] = k;
6181
+ } else {
6182
+ if (2047 >= k) {
6183
+ if (f + 1 >= h2) break;
6184
+ e[f++] = 192 | k >> 6;
6185
+ } else {
6186
+ if (65535 >= k) {
6187
+ if (f + 2 >= h2) break;
6188
+ e[f++] = 224 | k >> 12;
6189
+ } else {
6190
+ if (f + 3 >= h2) break;
6191
+ e[f++] = 240 | k >> 18, e[f++] = 128 | k >> 12 & 63;
6192
+ }
6193
+ e[f++] = 128 | k >> 6 & 63;
6194
+ }
6195
+ e[f++] = 128 | k & 63;
6196
+ }
6197
+ }
6198
+ e[f] = 0;
6199
+ }
6200
+ } else F2.set(c, h2);
6201
+ return d3 !== null && d3.push(W, m3), m3;
6202
+ }, H: 8, readValueFromPointer: La, G(d3) {
6203
+ W(d3);
6204
+ } });
6205
+ }, e: (a, b2, d3) => {
6206
+ if (d3 = P(d3), b2 === 2) var c = hb, e = ib, f = jb, m3 = (h2) => H[h2 >> 1];
6207
+ else b2 === 4 && (c = kb, e = lb, f = mb, m3 = (h2) => J[h2 >> 2]);
6208
+ U(a, { name: d3, fromWireType: (h2) => {
6209
+ for (var l3 = J[h2 >> 2], k, p2 = h2 + 4, z = 0; z <= l3; ++z) {
6210
+ var n = h2 + 4 + z * b2;
6211
+ (z == l3 || m3(n) == 0) && (p2 = c(p2, n - p2), k === void 0 ? k = p2 : (k += "\0", k += p2), p2 = n + b2);
6212
+ }
6213
+ return W(h2), k;
6214
+ }, toWireType: (h2, l3) => {
6215
+ if (typeof l3 != "string") throw new T(`Cannot pass non-string to C++ string type ${d3}`);
6216
+ var k = f(l3), p2 = wb(4 + k + b2);
6217
+ return J[p2 >> 2] = k / b2, e(l3, p2 + 4, k + b2), h2 !== null && h2.push(W, p2), p2;
6218
+ }, H: 8, readValueFromPointer: La, G(h2) {
6219
+ W(h2);
6220
+ } });
6221
+ }, f: (a) => {
6222
+ U(a, Ma);
6223
+ }, p: (a, b2) => {
6224
+ b2 = P(b2), U(a, { L: true, name: b2, H: 0, fromWireType: () => {
6225
+ }, toWireType: () => {
6226
+ } });
6227
+ }, s: () => {
6228
+ O = false, nb = 0;
6229
+ }, i: (a, b2, d3, c) => (a = ob[a], b2 = Ja(b2), a(null, b2, d3, c)), d: Ia, h: (a, b2, d3) => {
6230
+ b2 = rb(a, b2);
6231
+ var c = b2.shift();
6232
+ a--;
6233
+ var e = `return function (obj, func, destructorsRef, args) {
6234
+ `, f = 0, m3 = [];
6235
+ d3 === 0 && m3.push("obj");
6236
+ for (var h2 = ["retType"], l3 = [c], k = 0; k < a; ++k) m3.push(`arg${k}`), h2.push(`argType${k}`), l3.push(b2[k]), e += ` var arg${k} = argType${k}.readValueFromPointer(args${f ? "+" + f : ""});
6237
+ `, f += b2[k].H;
6238
+ return e += ` var rv = ${d3 === 1 ? "new func" : "func.call"}(${m3.join(", ")});
6239
+ `, c.L || (h2.push("emval_returnValue"), l3.push(sb), e += ` return emval_returnValue(retType, destructorsRef, rv);
6240
+ `), a = new _F(...h2, e + `};
6241
+ `)(...l3), d3 = `methodCaller<(${b2.map((p2) => p2.name).join(", ")}) => ${c.name}>`, pb(Object.defineProperty(a, "name", { value: d3 }));
6242
+ }, q: (a) => {
6243
+ 9 < a && (V[a + 1] += 1);
6244
+ }, g: (a) => {
6245
+ var b2 = Ja(a);
6246
+ Oa(b2), Ia(a);
6247
+ }, j: (a, b2) => (a = qb(a, "_emval_take_value"), a = a.readValueFromPointer(b2), Ka(a)), t: (a, b2) => {
6248
+ if (X[a] && (clearTimeout(X[a].id), delete X[a]), !b2) return 0;
6249
+ var d3 = setTimeout(() => {
6250
+ delete X[a], ub(() => xb(a, performance.now()));
6251
+ }, b2);
6252
+ return X[a] = { id: d3, M: b2 }, 0;
6253
+ }, w: (a) => {
6254
+ var b2 = F2.length;
6255
+ if (a >>>= 0, 2147483648 < a) return false;
6256
+ for (var d3 = 1; 4 >= d3; d3 *= 2) {
6257
+ var c = b2 * (1 + 0.2 / d3);
6258
+ c = Math.min(c, a + 100663296);
6259
+ a: {
6260
+ c = (Math.min(2147483648, 65536 * Math.ceil(Math.max(a, c) / 65536)) - D.buffer.byteLength + 65535) / 65536 | 0;
6261
+ try {
6262
+ D.grow(c), pa();
6263
+ var e = 1;
6264
+ break a;
6265
+ } catch {
6266
+ }
6267
+ e = void 0;
6268
+ }
6269
+ if (e) return true;
6270
+ }
6271
+ return false;
6272
+ }, r: tb }, Z = await (async function() {
6273
+ function a(c) {
6274
+ return Z = c.exports, D = Z.x, pa(), Xa = Z.D, K--, g2.monitorRunDependencies?.(K), K == 0 && L && (c = L, L = null, c()), Z;
6275
+ }
6276
+ K++, g2.monitorRunDependencies?.(K);
6277
+ var b2 = { a: Ab };
6278
+ if (g2.instantiateWasm) return new Promise((c) => {
6279
+ g2.instantiateWasm(b2, (e, f) => {
6280
+ c(a(e, f));
6281
+ });
6282
+ });
6283
+ ra ??= g2.locateFile ? g2.locateFile ? g2.locateFile("silk.wasm", v) : v + "silk.wasm" : new URL("silk.wasm", import_meta.url).href;
6284
+ try {
6285
+ var d3 = await ua(b2);
6286
+ return a(d3.instance);
6287
+ } catch (c) {
6288
+ return q(c), Promise.reject(c);
6289
+ }
6290
+ })(), $a = Z.z, wb = Z.A, W = Z.B, xb = Z.C;
6291
+ function Bb() {
6292
+ function a() {
6293
+ if (g2.calledRun = true, !E3) {
6294
+ if (Z.y(), aa(g2), g2.onRuntimeInitialized?.(), g2.postRun) for (typeof g2.postRun == "function" && (g2.postRun = [g2.postRun]); g2.postRun.length; ) {
6295
+ var b2 = g2.postRun.shift();
6296
+ xa.push(b2);
6297
+ }
6298
+ wa(xa);
6299
+ }
6300
+ }
6301
+ if (0 < K) L = Bb;
6302
+ else {
6303
+ if (g2.preRun) for (typeof g2.preRun == "function" && (g2.preRun = [g2.preRun]); g2.preRun.length; ) za();
6304
+ wa(ya), 0 < K ? L = Bb : g2.setStatus ? (g2.setStatus("Running..."), setTimeout(() => {
6305
+ setTimeout(() => g2.setStatus(""), 1), a();
6306
+ }, 1)) : a();
5077
6307
  }
5078
6308
  }
6309
+ if (g2.preInit) for (typeof g2.preInit == "function" && (g2.preInit = [g2.preInit]); 0 < g2.preInit.length; ) g2.preInit.shift()();
6310
+ return Bb(), moduleRtn = ba, moduleRtn;
5079
6311
  };
6312
+ silk_default = Module;
6313
+ audioEncodingNames = ["int", "float"];
6314
+ wavFileTypeAudioEncodings = [0, 0, 0, 1];
5080
6315
  }
5081
- return next;
5082
- }
6316
+ });
6317
+
6318
+ // index.ts
6319
+ var index_exports = {};
6320
+ __export(index_exports, {
6321
+ DEFAULT_ACCOUNT_ID: () => DEFAULT_ACCOUNT_ID,
6322
+ MSG_TYPE_QUOTE: () => MSG_TYPE_QUOTE2,
6323
+ MSG_TYPE_TEXT: () => MSG_TYPE_TEXT,
6324
+ PersistedRefIndexStore: () => PersistedRefIndexStore,
6325
+ QQBotGateway: () => QQBotGateway,
6326
+ StreamContentType: () => StreamContentType2,
6327
+ StreamInputMode: () => StreamInputMode2,
6328
+ StreamInputState: () => StreamInputState2,
6329
+ StreamingController: () => StreamingController,
6330
+ applyQQBotAccountConfig: () => applyQQBotAccountConfig,
6331
+ buildUserAgent: () => buildUserAgent,
6332
+ default: () => index_default,
6333
+ dispatchToOpenClaw: () => dispatchToOpenClaw,
6334
+ flushAllRefIndexStores: () => flushAllRefIndexStores,
6335
+ getBotForAccount: () => getBotForAccount,
6336
+ getPersistedRefIndexStore: () => getPersistedRefIndexStore,
6337
+ getQQBotRuntime: () => getQQBotRuntime,
6338
+ isGroupAllowed: () => isGroupAllowed,
6339
+ listQQBotAccountIds: () => listQQBotAccountIds,
6340
+ parseTarget: () => parseTarget,
6341
+ qqbotOnboardingAdapter: () => qqbotOnboardingAdapter,
6342
+ qqbotPlugin: () => qqbotPlugin,
6343
+ resolveDefaultQQBotAccountId: () => resolveDefaultQQBotAccountId,
6344
+ resolveGroupAllowFrom: () => resolveGroupAllowFrom,
6345
+ resolveGroupConfig: () => resolveGroupConfig,
6346
+ resolveGroupConfigFromAccount: () => resolveGroupConfigFromAccount,
6347
+ resolveGroupName: () => resolveGroupName,
6348
+ resolveGroupPolicy: () => resolveGroupPolicy,
6349
+ resolveGroupPrompt: () => resolveGroupPrompt,
6350
+ resolveHistoryLimit: () => resolveHistoryLimit,
6351
+ resolveIgnoreOtherMentions: () => resolveIgnoreOtherMentions,
6352
+ resolveMentionPatterns: () => resolveMentionPatterns,
6353
+ resolveProcessingTimeoutMs: () => resolveProcessingTimeoutMs,
6354
+ resolveQQBotAccount: () => resolveQQBotAccount,
6355
+ resolveRequireMention: () => resolveRequireMention,
6356
+ resolveToolPolicy: () => resolveToolPolicy,
6357
+ resolveUserAgentSuffix: () => resolveUserAgentSuffix,
6358
+ sendMedia: () => sendMedia,
6359
+ sendText: () => sendText,
6360
+ setQQBotRuntime: () => setQQBotRuntime,
6361
+ shouldUseStreaming: () => shouldUseStreaming,
6362
+ tryGetBotForAccount: () => tryGetBotForAccount
6363
+ });
6364
+ module.exports = __toCommonJS(index_exports);
6365
+ var import_plugin_sdk = require("openclaw/plugin-sdk");
6366
+
6367
+ // src/channel.ts
6368
+ var import_core = require("openclaw/plugin-sdk/core");
6369
+ init_config();
5083
6370
 
5084
6371
  // src/bot-instance.ts
5085
6372
  var import_node_os = __toESM(require("os"), 1);
@@ -5087,11 +6374,11 @@ var import_node_os = __toESM(require("os"), 1);
5087
6374
  // src/outbound/outbound-service.ts
5088
6375
  var path3 = __toESM(require("path"), 1);
5089
6376
 
5090
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/QQBot.js
6377
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/QQBot.js
5091
6378
  var fs3 = __toESM(require("fs"), 1);
5092
6379
  var path = __toESM(require("path"), 1);
5093
6380
 
5094
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/types.js
6381
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/types.js
5095
6382
  function resolvePolicy(ctx, path22, explicit, defaultValue) {
5096
6383
  if (explicit !== void 0 && explicit !== null) {
5097
6384
  return explicit;
@@ -5167,7 +6454,7 @@ function createMiddlewareContext(params) {
5167
6454
  return ctx;
5168
6455
  }
5169
6456
 
5170
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/types.js
6457
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/types.js
5171
6458
  var ApiError = class extends Error {
5172
6459
  httpStatus;
5173
6460
  path;
@@ -5200,7 +6487,7 @@ var StreamContentType = {
5200
6487
  MARKDOWN: "markdown"
5201
6488
  };
5202
6489
 
5203
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/format.js
6490
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/format.js
5204
6491
  function formatErrorMessage(err) {
5205
6492
  if (err instanceof Error) {
5206
6493
  let formatted = err.message || err.name || "Error";
@@ -5247,7 +6534,7 @@ function formatFileSize(bytes) {
5247
6534
  return `${(bytes / 1024 / 1024 / 1024).toFixed(2)} GB`;
5248
6535
  }
5249
6536
 
5250
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/api-client.js
6537
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/api-client.js
5251
6538
  var DEFAULT_BASE_URL = "https://api.sgroup.qq.com";
5252
6539
  var DEFAULT_TIMEOUT_MS = 3e4;
5253
6540
  var FILE_UPLOAD_TIMEOUT_MS = 12e4;
@@ -5342,12 +6629,12 @@ var ApiClient = class {
5342
6629
  }
5343
6630
  };
5344
6631
 
5345
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/media-chunked.js
6632
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/media-chunked.js
5346
6633
  var crypto = __toESM(require("crypto"), 1);
5347
6634
  var fs = __toESM(require("fs"), 1);
5348
6635
  var https = __toESM(require("https"), 1);
5349
6636
 
5350
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/retry.js
6637
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/retry.js
5351
6638
  async function withRetry(fn, policy, persistentPolicy, logger) {
5352
6639
  let lastError = null;
5353
6640
  for (let attempt = 0; attempt <= policy.maxRetries; attempt++) {
@@ -5439,7 +6726,7 @@ function buildPartFinishPersistentPolicy(retryTimeoutMs, retryableCodes = PART_F
5439
6726
  var PART_FINISH_RETRYABLE_CODES = /* @__PURE__ */ new Set([40093001]);
5440
6727
  var UPLOAD_PREPARE_FALLBACK_CODE = 40093002;
5441
6728
 
5442
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/routes.js
6729
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/routes.js
5443
6730
  function messagePath(scope, targetId) {
5444
6731
  return scope === "c2c" ? `/v2/users/${targetId}/messages` : `/v2/groups/${targetId}/messages`;
5445
6732
  }
@@ -5476,7 +6763,7 @@ function getNextMsgSeq(_msgId) {
5476
6763
  return (timePart ^ random) % 65536;
5477
6764
  }
5478
6765
 
5479
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/media-chunked.js
6766
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/media-chunked.js
5480
6767
  var UploadDailyLimitExceededError = class extends Error {
5481
6768
  filePath;
5482
6769
  fileSize;
@@ -5738,10 +7025,10 @@ function sleep2(ms) {
5738
7025
  return new Promise((resolve2) => setTimeout(resolve2, ms));
5739
7026
  }
5740
7027
 
5741
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/media.js
7028
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/media.js
5742
7029
  var fs2 = __toESM(require("fs"), 1);
5743
7030
 
5744
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/file-utils.js
7031
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/file-utils.js
5745
7032
  var MAX_UPLOAD_SIZE = 20 * 1024 * 1024;
5746
7033
  var CHUNKED_UPLOAD_MAX_SIZE = 100 * 1024 * 1024;
5747
7034
  var LARGE_FILE_THRESHOLD = 5 * 1024 * 1024;
@@ -5759,7 +7046,7 @@ function sanitizeFileName(name) {
5759
7046
  return cleaned || "file";
5760
7047
  }
5761
7048
 
5762
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/media.js
7049
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/media.js
5763
7050
  var MAX_BASE64_CHECK_SIZE = Math.ceil(MAX_UPLOAD_SIZE * 1.4);
5764
7051
  function formatUploadSize() {
5765
7052
  return formatFileSize(MAX_UPLOAD_SIZE);
@@ -5847,7 +7134,7 @@ var MediaApi = class {
5847
7134
  }
5848
7135
  };
5849
7136
 
5850
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/messages.js
7137
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/messages.js
5851
7138
  var MessageApi = class {
5852
7139
  client;
5853
7140
  tokenManager;
@@ -6035,7 +7322,7 @@ var MessageApi = class {
6035
7322
  }
6036
7323
  };
6037
7324
 
6038
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/token.js
7325
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/token.js
6039
7326
  var DEFAULT_TOKEN_BASE_URL = "https://bots.qq.com";
6040
7327
  var TOKEN_PATH = "/app/getAppAccessToken";
6041
7328
  var TokenManager = class {
@@ -6222,7 +7509,7 @@ var import_websocket = __toESM(require_websocket(), 1);
6222
7509
  var import_websocket_server = __toESM(require_websocket_server(), 1);
6223
7510
  var wrapper_default = import_websocket.default;
6224
7511
 
6225
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/codec.js
7512
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/codec.js
6226
7513
  function decodeGatewayMessageData(data) {
6227
7514
  if (typeof data === "string") {
6228
7515
  return data;
@@ -6249,7 +7536,7 @@ function readOptionalMessageSceneExt(event) {
6249
7536
  return scene?.ext;
6250
7537
  }
6251
7538
 
6252
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/constants.js
7539
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/constants.js
6253
7540
  var INTENTS = {
6254
7541
  GUILDS: 1 << 0,
6255
7542
  GUILD_MEMBERS: 1 << 1,
@@ -6322,7 +7609,7 @@ var GatewayEvent = {
6322
7609
  MESSAGE_REACTION_REMOVE: "MESSAGE_REACTION_REMOVE"
6323
7610
  };
6324
7611
 
6325
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/event-dispatcher.js
7612
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/event-dispatcher.js
6326
7613
  var REF_INDEX_KEY = "msg_idx";
6327
7614
  function parseRefIndices(ext, msgType, msgElements) {
6328
7615
  let refMsgIdx;
@@ -6463,7 +7750,7 @@ function dispatchEvent(eventType, data, _accountId, _log) {
6463
7750
  return { action: "raw", type: eventType, data };
6464
7751
  }
6465
7752
 
6466
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/reconnect.js
7753
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/reconnect.js
6467
7754
  var ReconnectState = class {
6468
7755
  accountId;
6469
7756
  log;
@@ -6574,7 +7861,7 @@ var ReconnectState = class {
6574
7861
  }
6575
7862
  };
6576
7863
 
6577
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/gateway-connection.js
7864
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/gateway-connection.js
6578
7865
  var GatewayConnection = class {
6579
7866
  isAborted = false;
6580
7867
  currentWs = null;
@@ -6832,7 +8119,7 @@ function previewPayload(data) {
6832
8119
  }
6833
8120
  }
6834
8121
 
6835
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/transport/webhook-verify.js
8122
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/transport/webhook-verify.js
6836
8123
  var crypto2 = __toESM(require("crypto"), 1);
6837
8124
  function deriveSeed(botSecret) {
6838
8125
  let seed = botSecret;
@@ -6884,7 +8171,7 @@ function signValidationResponse(params) {
6884
8171
  };
6885
8172
  }
6886
8173
 
6887
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/transport/webhook-server-node.js
8174
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/transport/webhook-server-node.js
6888
8175
  var http = __toESM(require("http"), 1);
6889
8176
  var NodeHttpWebhookServer = class {
6890
8177
  server = null;
@@ -6932,7 +8219,7 @@ var NodeHttpWebhookServer = class {
6932
8219
  }
6933
8220
  };
6934
8221
 
6935
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/transport/webhook.js
8222
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/transport/webhook.js
6936
8223
  var OP_DISPATCH = 0;
6937
8224
  var OP_HTTP_CALLBACK_ACK = 12;
6938
8225
  var OP_VALIDATION = 13;
@@ -7076,7 +8363,7 @@ function getHeader(headers, key) {
7076
8363
  return val;
7077
8364
  }
7078
8365
 
7079
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/upload-cache.js
8366
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/upload-cache.js
7080
8367
  var crypto3 = __toESM(require("crypto"), 1);
7081
8368
  var MAX_CACHE_SIZE = 500;
7082
8369
  function computeFileHash(data) {
@@ -7141,7 +8428,7 @@ var UploadCache = class {
7141
8428
  }
7142
8429
  };
7143
8430
 
7144
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/streaming.js
8431
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/streaming.js
7145
8432
  var DEFAULT_THROTTLE_MS = 500;
7146
8433
  var MIN_THROTTLE_MS = 300;
7147
8434
  var MAX_FLUSH_RETRIES = 3;
@@ -7309,7 +8596,7 @@ var StreamSession = class {
7309
8596
  }
7310
8597
  };
7311
8598
 
7312
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/QQBot.js
8599
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/QQBot.js
7313
8600
  var MsgType = {
7314
8601
  /** Plain text. */
7315
8602
  TEXT: 0,
@@ -7997,7 +9284,7 @@ var QQBot = class {
7997
9284
  }
7998
9285
  };
7999
9286
 
8000
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/message-filter.js
9287
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/message-filter.js
8001
9288
  function messageFilter(options = {}) {
8002
9289
  const skipSelfEcho = options.skipSelfEcho ?? true;
8003
9290
  const dedupOpts = options.dedup !== false ? { windowMs: 5e3, maxSize: 1e3, ...options.dedup ?? {} } : null;
@@ -8035,7 +9322,7 @@ function messageFilter(options = {}) {
8035
9322
  };
8036
9323
  }
8037
9324
 
8038
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/content-sanitizer.js
9325
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/content-sanitizer.js
8039
9326
  function contentSanitizer(options = {}) {
8040
9327
  const { stripBotMention = true, stripAllMentions = false, collapseWhitespace = false, parseFaceTags: parseFaceTags2 = false, transform } = options;
8041
9328
  return async (ctx, next) => {
@@ -8130,7 +9417,7 @@ function faceToEmoji(id) {
8130
9417
  return map[id];
8131
9418
  }
8132
9419
 
8133
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/rate-limiter.js
9420
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/rate-limiter.js
8134
9421
  var SlidingWindow = class {
8135
9422
  buckets = /* @__PURE__ */ new Map();
8136
9423
  max;
@@ -8184,7 +9471,7 @@ function rateLimiter(options = {}) {
8184
9471
  };
8185
9472
  }
8186
9473
 
8187
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/concurrency-guard.js
9474
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/concurrency-guard.js
8188
9475
  function concurrencyGuard(options = {}) {
8189
9476
  const strategy = options.strategy ?? "queue";
8190
9477
  const maxQueue = options.maxQueue ?? 3;
@@ -8419,7 +9706,7 @@ function concurrencyGuard(options = {}) {
8419
9706
  return guard;
8420
9707
  }
8421
9708
 
8422
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/mention-gate.js
9709
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/mention-gate.js
8423
9710
  function detectMentionInContent(content, appId) {
8424
9711
  if (!content || !appId)
8425
9712
  return false;
@@ -8475,7 +9762,7 @@ function mentionGate(options = {}) {
8475
9762
  };
8476
9763
  }
8477
9764
 
8478
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/quote-ref.js
9765
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/quote-ref.js
8479
9766
  var MemoryRefIndexStore = class {
8480
9767
  map = /* @__PURE__ */ new Map();
8481
9768
  maxSize;
@@ -8593,7 +9880,7 @@ function buildText(content, attachments) {
8593
9880
  return parts.join("\n") || "[empty message]";
8594
9881
  }
8595
9882
 
8596
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/envelope-formatter.js
9883
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/envelope-formatter.js
8597
9884
  function envelopeFormatter(options = {}) {
8598
9885
  const { historyLimit = 5, includeQuote = true, includeSender = true, format } = options;
8599
9886
  return async (ctx, next) => {
@@ -8665,7 +9952,7 @@ ${parts.join("\n")}
8665
9952
  return sections.join("\n\n");
8666
9953
  }
8667
9954
 
8668
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/slash-command.js
9955
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/slash-command.js
8669
9956
  function slashCommand(options = {}) {
8670
9957
  const prefixes = options.prefixes ?? ["/"];
8671
9958
  const catchErrors = options.catchErrors ?? true;
@@ -8818,7 +10105,7 @@ async function sendCommandResult(ctx, result) {
8818
10105
  }
8819
10106
  }
8820
10107
 
8821
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/history-buffer.js
10108
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/history-buffer.js
8822
10109
  var MemoryHistoryStore = class {
8823
10110
  buffers = /* @__PURE__ */ new Map();
8824
10111
  append(groupKey, entry, limit) {
@@ -8883,7 +10170,7 @@ function historyBuffer(options = {}) {
8883
10170
  return m3;
8884
10171
  }
8885
10172
 
8886
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/typing-indicator.js
10173
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/typing-indicator.js
8887
10174
  var DEFAULT_DURATION_SEC = 60;
8888
10175
  var DEFAULT_KEEPALIVE_INTERVAL_MS = 5e4;
8889
10176
  function typingIndicator(options = {}) {
@@ -8920,7 +10207,7 @@ function typingIndicator(options = {}) {
8920
10207
  };
8921
10208
  }
8922
10209
 
8923
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/error-handler.js
10210
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/error-handler.js
8924
10211
  var DEFAULT_FORMAT = (err) => {
8925
10212
  if (err instanceof ApiError) {
8926
10213
  if (err.bizMessage)
@@ -8958,7 +10245,7 @@ function errorHandler(options = {}) {
8958
10245
  };
8959
10246
  }
8960
10247
 
8961
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/storage/kv-store.js
10248
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/storage/kv-store.js
8962
10249
  var import_node_fs = __toESM(require("fs"), 1);
8963
10250
  var import_node_path = __toESM(require("path"), 1);
8964
10251
  var FileKVStore = class {
@@ -9068,7 +10355,7 @@ var FileKVStore = class {
9068
10355
  }
9069
10356
  };
9070
10357
 
9071
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/storage/session-adapter.js
10358
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/storage/session-adapter.js
9072
10359
  function kvSessionPersistence(opts) {
9073
10360
  const prefix = opts.prefix ?? "qqbot:session:";
9074
10361
  const key = `${prefix}${opts.accountId}`;
@@ -9295,7 +10582,7 @@ var import_node_path2 = __toESM(require("path"), 1);
9295
10582
  var import_node_fs2 = __toESM(require("fs"), 1);
9296
10583
  var _cachedOpenclawVersion;
9297
10584
  function getPackageVersion() {
9298
- return true ? "2.0.0-dev.202607101541" : "unknown";
10585
+ return true ? "2.0.0-dev.202607131536" : "unknown";
9299
10586
  }
9300
10587
  function getOpenclawVersion(runtimeVersion) {
9301
10588
  if (_cachedOpenclawVersion) return _cachedOpenclawVersion;
@@ -9637,223 +10924,80 @@ var PersistedRefIndexStore = class {
9637
10924
  return this.memory.size;
9638
10925
  }
9639
10926
  /** 是否已完成初始化(磁盘回放) */
9640
- get isInitialized() {
9641
- return this.initialized;
9642
- }
9643
- /** 诊断快照 */
9644
- stats() {
9645
- return {
9646
- memoryEntries: this.memory.size,
9647
- diskLines: this.diskLineCount,
9648
- maxEntries: this.maxEntries,
9649
- filePath: this.filePath
9650
- };
9651
- }
9652
- /**
9653
- * 强制将当前内存状态持久化到磁盘(进程退出前调用)
9654
- */
9655
- flush() {
9656
- this.compactSync();
9657
- }
9658
- };
9659
- var stores = /* @__PURE__ */ new Map();
9660
- function getPersistedRefIndexStore(accountId) {
9661
- let store = stores.get(accountId);
9662
- if (!store) {
9663
- const filePath = import_node_path3.default.join(getQQBotDataDir("data", accountId), DEFAULT_FILENAME);
9664
- store = new PersistedRefIndexStore({ filePath });
9665
- stores.set(accountId, store);
9666
- }
9667
- return store;
9668
- }
9669
- function flushAllRefIndexStores() {
9670
- for (const store of stores.values()) {
9671
- store.flush();
9672
- }
9673
- }
9674
-
9675
- // src/runtime.ts
9676
- var runtime = null;
9677
- var exitHooksInstalled = false;
9678
- function setQQBotRuntime(next) {
9679
- runtime = next;
9680
- const version = getOpenclawVersion(next.version);
9681
- setOpenClawVersion(version);
9682
- installExitHooksOnce();
9683
- }
9684
- function installExitHooksOnce() {
9685
- if (exitHooksInstalled) return;
9686
- exitHooksInstalled = true;
9687
- const flush = () => {
9688
- try {
9689
- flushAllRefIndexStores();
9690
- } catch {
9691
- }
9692
- };
9693
- process.on("beforeExit", flush);
9694
- process.on("SIGINT", () => {
9695
- flush();
9696
- process.exit(0);
9697
- });
9698
- process.on("SIGTERM", () => {
9699
- flush();
9700
- process.exit(0);
9701
- });
9702
- }
9703
- function getQQBotRuntime() {
9704
- if (!runtime) throw new Error("QQBot runtime not initialized");
9705
- return runtime;
9706
- }
9707
- function tryGetQQBotRuntime() {
9708
- return runtime;
9709
- }
9710
-
9711
- // src/adapter/resolve.ts
9712
- function probeFunction(rt, paths) {
9713
- for (const path22 of paths) {
9714
- let target = rt;
9715
- let parent = rt;
9716
- for (let i = 0; i < path22.length; i++) {
9717
- parent = target;
9718
- target = target?.[path22[i]];
9719
- if (target === void 0 || target === null) break;
9720
- }
9721
- if (typeof target === "function") {
9722
- return target.bind(parent);
9723
- }
9724
- }
9725
- return null;
9726
- }
9727
- function resolveRuntimeAdapters(rt, log4) {
9728
- const version = rt.version ?? "unknown";
9729
- const inboundRun = probeFunction(rt, [
9730
- ["channel", "inbound", "run"],
9731
- // current (2026-05+)
9732
- ["channel", "turn", "run"]
9733
- // legacy (removed 2026-05-27)
9734
- ]);
9735
- const dispatchReply = probeFunction(rt, [
9736
- ["channel", "reply", "dispatchReplyWithBufferedBlockDispatcher"]
9737
- ]);
9738
- const resolveAgentRoute = probeFunction(rt, [
9739
- ["channel", "routing", "resolveAgentRoute"]
9740
- ]);
9741
- const rawBuildContext = probeFunction(rt, [
9742
- ["channel", "inbound", "buildContext"]
9743
- ]);
9744
- const rawFinalizeContext = !rawBuildContext ? probeFunction(rt, [["channel", "reply", "finalizeInboundContext"]]) : null;
9745
- const buildInboundContext = rawBuildContext ? (params) => rawBuildContext(params) : rawFinalizeContext ? (params) => {
9746
- const isCommand = params.access?.commands?.authorized ?? false;
9747
- const rawCtx = {
9748
- Body: params.message.body,
9749
- BodyForAgent: params.message.bodyForAgent,
9750
- RawBody: params.message.rawBody,
9751
- CommandBody: params.message.commandBody ?? params.message.rawBody,
9752
- CommandSource: isCommand ? "text" : void 0,
9753
- CommandTurn: params.command ?? void 0,
9754
- CommandAuthorized: isCommand,
9755
- From: params.from,
9756
- To: params.reply.to,
9757
- SessionKey: params.route.routeSessionKey,
9758
- AccountId: params.route.accountId ?? params.accountId,
9759
- ChatType: params.conversation.kind,
9760
- GroupSystemPrompt: params.conversation.label,
9761
- SenderId: params.sender.id,
9762
- SenderName: params.sender.name,
9763
- Provider: params.provider ?? params.channel,
9764
- Surface: params.surface ?? params.channel,
9765
- MessageSid: params.messageId,
9766
- Timestamp: params.timestamp ?? Date.now(),
9767
- OriginatingChannel: params.channel,
9768
- OriginatingTo: params.reply.originatingTo ?? params.reply.to,
9769
- ...params.extra
9770
- };
9771
- return rawFinalizeContext(rawCtx);
9772
- } : null;
9773
- const resolveStorePath = probeFunction(rt, [
9774
- ["channel", "session", "resolveStorePath"]
9775
- ]);
9776
- const recordInboundSession = probeFunction(rt, [
9777
- ["channel", "session", "recordInboundSession"]
9778
- ]);
9779
- const formatEnvelope = probeFunction(rt, [
9780
- ["channel", "reply", "formatAgentEnvelope"],
9781
- // current (2026-06+)
9782
- ["channel", "reply", "formatInboundEnvelope"]
9783
- // deprecated,低版本兼容
9784
- ]);
9785
- const resolveEnvelopeFormatOptions = probeFunction(rt, [
9786
- ["channel", "reply", "resolveEnvelopeFormatOptions"]
9787
- ]);
9788
- const chunkMarkdownText = probeFunction(rt, [
9789
- ["channel", "text", "chunkMarkdownText"]
9790
- ]);
9791
- const saveRemoteMedia = probeFunction(rt, [
9792
- ["channel", "media", "saveRemoteMedia"]
9793
- ]);
9794
- const getConfig = probeFunction(rt, [
9795
- ["config", "current"]
9796
- ]) ?? probeFunction(rt, [
9797
- ["getConfig"]
9798
- ]) ?? probeFunction(rt, [
9799
- ["config", "loadConfig"]
9800
- ]);
9801
- const rawMutateConfig = probeFunction(rt, [["config", "mutateConfigFile"]]);
9802
- const rawWriteConfig = probeFunction(rt, [["config", "writeConfigFile"]]);
9803
- const persistConfig = rawMutateConfig ? async (mutator) => {
9804
- await rawMutateConfig({
9805
- afterWrite: "hot-reload",
9806
- mutate: mutator
9807
- });
9808
- } : rawWriteConfig && getConfig ? async (mutator) => {
9809
- const current = JSON.parse(JSON.stringify(getConfig()));
9810
- mutator(current);
9811
- await rawWriteConfig(current);
9812
- } : null;
9813
- const resolved = [
9814
- inboundRun && "inboundRun",
9815
- dispatchReply && "dispatchReply",
9816
- resolveAgentRoute && "resolveAgentRoute",
9817
- buildInboundContext && "buildInboundContext",
9818
- resolveStorePath && "resolveStorePath",
9819
- recordInboundSession && "recordInboundSession",
9820
- formatEnvelope && "formatEnvelope",
9821
- chunkMarkdownText && "chunkMarkdownText",
9822
- saveRemoteMedia && "saveRemoteMedia",
9823
- getConfig && "getConfig",
9824
- persistConfig && `persistConfig(${rawMutateConfig ? "mutate" : "write"})`
9825
- ].filter(Boolean);
9826
- log4?.info(
9827
- `[qqbot:adapter] openclaw=${version} resolved ${resolved.length} adapters: ${resolved.join(", ")}`
9828
- );
9829
- return {
9830
- inboundRun,
9831
- dispatchReply,
9832
- resolveAgentRoute,
9833
- buildInboundContext,
9834
- resolveStorePath,
9835
- recordInboundSession,
9836
- formatEnvelope,
9837
- resolveEnvelopeFormatOptions,
9838
- chunkMarkdownText,
9839
- saveRemoteMedia,
9840
- getConfig,
9841
- persistConfig,
9842
- version
9843
- };
10927
+ get isInitialized() {
10928
+ return this.initialized;
10929
+ }
10930
+ /** 诊断快照 */
10931
+ stats() {
10932
+ return {
10933
+ memoryEntries: this.memory.size,
10934
+ diskLines: this.diskLineCount,
10935
+ maxEntries: this.maxEntries,
10936
+ filePath: this.filePath
10937
+ };
10938
+ }
10939
+ /**
10940
+ * 强制将当前内存状态持久化到磁盘(进程退出前调用)
10941
+ */
10942
+ flush() {
10943
+ this.compactSync();
10944
+ }
10945
+ };
10946
+ var stores = /* @__PURE__ */ new Map();
10947
+ function getPersistedRefIndexStore(accountId) {
10948
+ let store = stores.get(accountId);
10949
+ if (!store) {
10950
+ const filePath = import_node_path3.default.join(getQQBotDataDir("data", accountId), DEFAULT_FILENAME);
10951
+ store = new PersistedRefIndexStore({ filePath });
10952
+ stores.set(accountId, store);
10953
+ }
10954
+ return store;
9844
10955
  }
9845
- var _cachedAdapters = null;
9846
- var _cachedRuntimeRef = null;
9847
- function getAdapters(rt, log4) {
9848
- const cached = _cachedRuntimeRef?.deref();
9849
- if (cached === rt && _cachedAdapters) {
9850
- return _cachedAdapters;
10956
+ function flushAllRefIndexStores() {
10957
+ for (const store of stores.values()) {
10958
+ store.flush();
9851
10959
  }
9852
- _cachedAdapters = resolveRuntimeAdapters(rt, log4);
9853
- _cachedRuntimeRef = new WeakRef(rt);
9854
- return _cachedAdapters;
9855
10960
  }
9856
10961
 
10962
+ // src/runtime.ts
10963
+ var runtime = null;
10964
+ var exitHooksInstalled = false;
10965
+ function setQQBotRuntime(next) {
10966
+ runtime = next;
10967
+ const version = getOpenclawVersion(next.version);
10968
+ setOpenClawVersion(version);
10969
+ installExitHooksOnce();
10970
+ }
10971
+ function installExitHooksOnce() {
10972
+ if (exitHooksInstalled) return;
10973
+ exitHooksInstalled = true;
10974
+ const flush = () => {
10975
+ try {
10976
+ flushAllRefIndexStores();
10977
+ } catch {
10978
+ }
10979
+ };
10980
+ process.on("beforeExit", flush);
10981
+ process.on("SIGINT", () => {
10982
+ flush();
10983
+ process.exit(0);
10984
+ });
10985
+ process.on("SIGTERM", () => {
10986
+ flush();
10987
+ process.exit(0);
10988
+ });
10989
+ }
10990
+ function getQQBotRuntime() {
10991
+ if (!runtime) throw new Error("QQBot runtime not initialized");
10992
+ return runtime;
10993
+ }
10994
+ function tryGetQQBotRuntime() {
10995
+ return runtime;
10996
+ }
10997
+
10998
+ // src/channel.ts
10999
+ init_resolve();
11000
+
9857
11001
  // src/outbound/media-send.ts
9858
11002
  var path8 = __toESM(require("path"), 1);
9859
11003
  var fs9 = __toESM(require("fs"), 1);
@@ -9877,6 +11021,9 @@ function resolveAgentWorkspace(cfg, agentId) {
9877
11021
  return getQQBotMediaDir();
9878
11022
  }
9879
11023
 
11024
+ // src/outbound/media-send.ts
11025
+ init_resolve();
11026
+
9880
11027
  // src/utils/ssrf-guard.ts
9881
11028
  var import_node_net = __toESM(require("net"), 1);
9882
11029
  var import_promises = __toESM(require("dns/promises"), 1);
@@ -10043,14 +11190,36 @@ function resolveTempRoots() {
10043
11190
  }
10044
11191
  return [...roots];
10045
11192
  }
10046
- var ALLOWED_MEDIA_ROOTS = [
10047
- path8.join(os4.homedir(), ".openclaw", "media"),
10048
- path8.join(os4.homedir(), ".openclaw", "workspace"),
10049
- // 框架 outbound 目录(saveMediaBuffer 写入)
10050
- path8.join(os4.homedir(), ".openclaw", "outbound"),
10051
- // TTS 语音临时目录(deliver-pipeline 已通过 isTtsPathSafe 预检)
10052
- ...resolveTempRoots()
10053
- ];
11193
+ function buildDynamicAllowedRoots(workspaceDir) {
11194
+ const home = os4.homedir();
11195
+ const derivedBase = workspaceDir ? path8.dirname(workspaceDir) : path8.join(home, ".openclaw");
11196
+ const roots = [];
11197
+ const added = /* @__PURE__ */ new Set();
11198
+ const addRoot = (p2) => {
11199
+ try {
11200
+ const real = fs9.existsSync(p2) ? fs9.realpathSync(p2) : p2;
11201
+ if (!added.has(real)) {
11202
+ added.add(real);
11203
+ roots.push(real);
11204
+ }
11205
+ } catch {
11206
+ }
11207
+ };
11208
+ const knownBases = [path8.join(home, ".openclaw"), path8.join(home, ".openclaw-dev")];
11209
+ if (workspaceDir) {
11210
+ addRoot(path8.join(derivedBase, "media"));
11211
+ addRoot(path8.join(derivedBase, "workspace"));
11212
+ addRoot(path8.join(derivedBase, "outbound"));
11213
+ addRoot(workspaceDir);
11214
+ }
11215
+ for (const base of knownBases) {
11216
+ addRoot(path8.join(base, "media"));
11217
+ addRoot(path8.join(base, "workspace"));
11218
+ addRoot(path8.join(base, "outbound"));
11219
+ }
11220
+ for (const t of resolveTempRoots()) addRoot(t);
11221
+ return roots;
11222
+ }
10054
11223
  var MAX_DATA_URL_BYTES = 10 * 1024 * 1024;
10055
11224
  async function sendMedia2(params) {
10056
11225
  const { source, accountId, log: log4 } = params;
@@ -10119,7 +11288,8 @@ async function resolveMediaPath(source, log4, workspaceDir) {
10119
11288
  } catch {
10120
11289
  return { ok: false, error: `Cannot resolve path: ${resolved}` };
10121
11290
  }
10122
- const allowed = isPathInAllowedRoots(real, ALLOWED_MEDIA_ROOTS);
11291
+ const dynamicRoots = buildDynamicAllowedRoots(workspaceDir);
11292
+ const allowed = isPathInAllowedRoots(real, dynamicRoots);
10123
11293
  if (!allowed) {
10124
11294
  log4?.warn(`path blocked \u2014 not in allowed directory: ${real}`);
10125
11295
  return { ok: false, error: `\u6587\u4EF6\u8DEF\u5F84\u4E0D\u5728\u5141\u8BB8\u7684\u76EE\u5F55\u4E2D` };
@@ -10134,348 +11304,94 @@ function resolveWorkspaceFromAgent(agentId) {
10134
11304
  function resolveConfigViaAdapter() {
10135
11305
  try {
10136
11306
  const rt = tryGetQQBotRuntime();
10137
- if (!rt) return void 0;
10138
- return getAdapters(rt).getConfig?.();
10139
- } catch {
10140
- return void 0;
10141
- }
10142
- }
10143
- function resolveWorkingFile(name, workspaceDir) {
10144
- for (const p2 of [path8.resolve(name), workspaceDir ? path8.join(workspaceDir, name) : null]) {
10145
- if (p2 && fs9.existsSync(p2)) return p2;
10146
- }
10147
- return null;
10148
- }
10149
- async function sendImageMedia(gw, target, source, params) {
10150
- try {
10151
- const result = await gw.sendMedia(target, source, {
10152
- text: params.text,
10153
- msgId: params.replyToId
10154
- });
10155
- return { messageId: result.id };
10156
- } catch (err) {
10157
- return { error: formatErr(err) };
10158
- }
10159
- }
10160
- async function sendVoiceMedia(gw, target, source, params) {
10161
- const voiceSource = resolveVoiceSource2(source);
10162
- try {
10163
- const result = await gw.sendVoice(target, voiceSource, {
10164
- msgId: params.replyToId
10165
- });
10166
- return { messageId: result.id };
10167
- } catch (err) {
10168
- params.log?.child("media")?.warn(`sendVoice failed (${formatErr(err)}), falling back to sendFile`);
10169
- try {
10170
- const fileName = path8.basename(source);
10171
- const fallback = await gw.sendFile(target, source, {
10172
- text: params.text,
10173
- msgId: params.replyToId,
10174
- fileName
10175
- });
10176
- return { messageId: fallback.id, fallback: true };
10177
- } catch (fallbackErr) {
10178
- return { error: `voice: ${formatErr(err)} | fallback file: ${formatErr(fallbackErr)}` };
10179
- }
10180
- }
10181
- }
10182
- async function sendVideoMedia(gw, target, source, params) {
10183
- try {
10184
- const result = await gw.sendVideo(target, source, {
10185
- text: params.text,
10186
- msgId: params.replyToId
10187
- });
10188
- return { messageId: result.id };
10189
- } catch (err) {
10190
- return { error: formatErr(err) };
10191
- }
10192
- }
10193
- async function sendFileMedia(gw, target, source, params) {
10194
- try {
10195
- const fileName = path8.basename(source);
10196
- const result = await gw.sendFile(target, source, {
10197
- text: params.text,
10198
- msgId: params.replyToId,
10199
- fileName
10200
- });
10201
- return { messageId: result.id };
10202
- } catch (err) {
10203
- return { error: formatErr(err) };
10204
- }
10205
- }
10206
- function resolveVoiceSource2(source) {
10207
- if (source.startsWith("http://") || source.startsWith("https://")) {
10208
- return { url: source };
10209
- }
10210
- if (source.startsWith("data:") || !source.startsWith("/") && !source.startsWith("./") && !source.startsWith("../") && !source.startsWith("~")) {
10211
- const commaIdx = source.indexOf(",");
10212
- return { base64: commaIdx > 0 ? source.slice(commaIdx + 1) : source };
10213
- }
10214
- return { localPath: source };
10215
- }
10216
- function formatErr(err) {
10217
- if (err instanceof Error) return err.message;
10218
- return String(err);
10219
- }
10220
-
10221
- // src/adapter/setup.ts
10222
- var import_node_module2 = require("module");
10223
- var req2 = (0, import_node_module2.createRequire)(__filename);
10224
- var _setup;
10225
- var _tools;
10226
- function loadSetup() {
10227
- if (_setup !== void 0) return _setup;
10228
- try {
10229
- _setup = req2("openclaw/plugin-sdk/setup");
10230
- } catch {
10231
- _setup = null;
10232
- }
10233
- return _setup;
10234
- }
10235
- function loadTools() {
10236
- if (_tools !== void 0) return _tools;
10237
- try {
10238
- _tools = req2("openclaw/plugin-sdk/setup-tools");
10239
- } catch {
10240
- _tools = null;
10241
- }
10242
- return _tools;
10243
- }
10244
- var DEFAULT_ACCOUNT_ID2 = "default";
10245
- function createStandardChannelSetupStatus(...args) {
10246
- const mod = loadSetup();
10247
- if (mod) return mod.createStandardChannelSetupStatus(...args);
10248
- return {
10249
- channelLabel: args[0]?.channelLabel ?? "QQ Bot",
10250
- configuredLabel: "Configured",
10251
- unconfiguredLabel: "Not configured",
10252
- resolveConfigured: () => false
10253
- };
10254
- }
10255
- function setSetupChannelEnabled(...args) {
10256
- loadSetup()?.setSetupChannelEnabled?.(...args);
10257
- }
10258
- function formatDocsLink(...args) {
10259
- const mod = loadTools();
10260
- if (mod) return mod.formatDocsLink(...args);
10261
- return args[1] ? `${args[1]}: ${args[0]}` : args[0];
10262
- }
10263
-
10264
- // node_modules/.pnpm/@tencent-connect+qqbot-connector@1.2.0/node_modules/@tencent-connect/qqbot-connector/dist/esm/qr-connect.js
10265
- var import_qrcode_terminal = __toESM(require_main(), 1);
10266
-
10267
- // node_modules/.pnpm/@tencent-connect+qqbot-connector@1.2.0/node_modules/@tencent-connect/qqbot-connector/dist/esm/qqbot-session.js
10268
- var import_node_crypto = __toESM(require("crypto"), 1);
10269
- var import_node_https = __toESM(require("https"), 1);
10270
- var E = { production: "q.qq.com", test: "test.q.qq.com" };
10271
- function d(t = "production") {
10272
- return E[t];
10273
- }
10274
- function l() {
10275
- return import_node_crypto.default.randomBytes(32).toString("base64");
10276
- }
10277
- var u;
10278
- (function(t) {
10279
- t[t.NONE = 0] = "NONE", t[t.PENDING = 1] = "PENDING", t[t.COMPLETED = 2] = "COMPLETED", t[t.EXPIRED = 3] = "EXPIRED";
10280
- })(u || (u = {}));
10281
- function b(t, r) {
10282
- const a = Buffer.from(r, "base64"), n = Buffer.from(t, "base64"), e = n.subarray(0, 12), c = n.subarray(n.length - 16), s = n.subarray(12, n.length - 16), o = import_node_crypto.default.createDecipheriv("aes-256-gcm", a, e);
10283
- return o.setAuthTag(c), Buffer.concat([o.update(s), o.final()]).toString("utf8");
10284
- }
10285
- function h(t, r, a) {
10286
- return new Promise((n, e) => {
10287
- const c = JSON.stringify(r), s = new URL(t), o = import_node_https.default.request({ hostname: s.hostname, path: s.pathname + s.search, method: "POST", timeout: a, headers: { "Content-Type": "application/json", Accept: "application/json", "Content-Length": Buffer.byteLength(c) } }, (i) => {
10288
- if (i.statusCode !== 200) {
10289
- i.resume(), e(new Error(`HTTP ${i.statusCode} from ${t}`));
10290
- return;
10291
- }
10292
- let f = "";
10293
- i.on("data", (p2) => {
10294
- f += p2;
10295
- }), i.on("end", () => {
10296
- try {
10297
- n(JSON.parse(f));
10298
- } catch (p2) {
10299
- e(p2);
10300
- }
10301
- });
10302
- });
10303
- o.on("error", e), o.on("timeout", () => {
10304
- o.destroy(), e(new Error(`timeout fetching ${t}`));
10305
- }), o.end(c);
10306
- });
10307
- }
10308
- async function y(t = "production", r = 1e4) {
10309
- const a = `https://${d(t)}/lite/create_bind_task`, n = l(), e = await h(a, { key: n }, r);
10310
- if (e.retcode !== 0) throw new Error(e.msg ?? "create_bind_task failed");
10311
- if (!e.data?.task_id) throw new Error("create_bind_task: missing task_id");
10312
- return { taskId: e.data.task_id, key: n };
10313
- }
10314
- async function g(t, r = "production", a = 1e4) {
10315
- const n = `https://${d(r)}/lite/poll_bind_result`, e = await h(n, { task_id: t }, a);
10316
- if (e.retcode !== 0) throw new Error(e.msg ?? "poll_bind_result failed");
10317
- return { status: e.data?.status ?? u.NONE, botAppId: String(e.data?.bot_appid ?? ""), botEncryptSecret: e.data?.bot_encrypt_secret ?? "", userOpenid: e.data?.user_openid || void 0 };
11307
+ if (!rt) return void 0;
11308
+ return getAdapters(rt).getConfig?.();
11309
+ } catch {
11310
+ return void 0;
11311
+ }
10318
11312
  }
10319
- function w(t, r = "") {
10320
- return `https://${d("production")}/qqbot/openclaw/connect.html?task_id=${encodeURIComponent(t)}&source=${encodeURIComponent(r)}&_wv=2`;
11313
+ function resolveWorkingFile(name, workspaceDir) {
11314
+ for (const p2 of [path8.resolve(name), workspaceDir ? path8.join(workspaceDir, name) : null]) {
11315
+ if (p2 && fs9.existsSync(p2)) return p2;
11316
+ }
11317
+ return null;
10321
11318
  }
10322
-
10323
- // node_modules/.pnpm/@tencent-connect+qqbot-connector@1.2.0/node_modules/@tencent-connect/qqbot-connector/dist/esm/qr-connect.js
10324
- var p = 2e3;
10325
- function F(r) {
10326
- return new Promise((o) => {
10327
- import_qrcode_terminal.default.generate(r, { small: true }, (e) => {
10328
- o(e);
11319
+ async function sendImageMedia(gw, target, source, params) {
11320
+ try {
11321
+ const result = await gw.sendMedia(target, source, {
11322
+ text: params.text,
11323
+ msgId: params.replyToId
10329
11324
  });
10330
- });
10331
- }
10332
- function d2(r, o) {
10333
- return new Promise((e, t) => {
10334
- if (o?.aborted) {
10335
- t(new DOMException("Aborted", "AbortError"));
10336
- return;
10337
- }
10338
- const n = setTimeout(e, r);
10339
- o?.addEventListener("abort", () => {
10340
- clearTimeout(n), t(new DOMException("Aborted", "AbortError"));
10341
- }, { once: true });
10342
- });
11325
+ return { messageId: result.id };
11326
+ } catch (err) {
11327
+ return { error: formatErr(err) };
11328
+ }
10343
11329
  }
10344
- async function C(r, o, e) {
10345
- for (; !e?.aborted; ) {
10346
- let t;
11330
+ async function sendVoiceMedia(gw, target, source, params) {
11331
+ const voiceSource = resolveVoiceSource2(source);
11332
+ try {
11333
+ const result = await gw.sendVoice(target, voiceSource, {
11334
+ msgId: params.replyToId
11335
+ });
11336
+ return { messageId: result.id };
11337
+ } catch (err) {
11338
+ params.log?.child("media")?.warn(`sendVoice failed (${formatErr(err)}), falling back to sendFile`);
10347
11339
  try {
10348
- t = await g(r);
10349
- } catch {
10350
- await d2(p, e);
10351
- continue;
10352
- }
10353
- if (t.status === u.COMPLETED) {
10354
- const n = b(t.botEncryptSecret, o);
10355
- return { outcome: "scanned", appId: t.botAppId, appSecret: n, userOpenid: t.userOpenid };
11340
+ const fileName = path8.basename(source);
11341
+ const fallback = await gw.sendFile(target, source, {
11342
+ text: params.text,
11343
+ msgId: params.replyToId,
11344
+ fileName
11345
+ });
11346
+ return { messageId: fallback.id, fallback: true };
11347
+ } catch (fallbackErr) {
11348
+ return { error: `voice: ${formatErr(err)} | fallback file: ${formatErr(fallbackErr)}` };
10356
11349
  }
10357
- if (t.status === u.EXPIRED) return { outcome: "expired" };
10358
- await d2(p, e);
10359
11350
  }
10360
- throw new DOMException("Aborted", "AbortError");
10361
- }
10362
- function l2(r, o) {
10363
- const e = new AbortController(), t = o?.signal ? AbortSignal.any([e.signal, o.signal]) : e.signal;
10364
- return (async () => {
10365
- const n = o?.displayQrCodeToConsole ?? true;
10366
- for (; ; ) {
10367
- if (t.aborted) throw new DOMException("Aborted", "AbortError");
10368
- let a;
10369
- try {
10370
- a = await y();
10371
- } catch (u2) {
10372
- throw new Error(`\u83B7\u53D6\u7ED1\u5B9A\u4EFB\u52A1\u5931\u8D25: ${u2 instanceof Error ? u2.message : String(u2)}`, { cause: u2 });
10373
- }
10374
- const i = w(a.taskId, o?.source);
10375
- if (n) {
10376
- const u2 = await F(i);
10377
- console.log(u2), console.log(`\u8BF7\u4F7F\u7528\u624B\u673A QQ \u626B\u63CF\u4E0A\u65B9\u4E8C\u7EF4\u7801\uFF0C\u5B8C\u6210\u673A\u5668\u4EBA\u7ED1\u5B9A\u3002
10378
- `);
10379
- }
10380
- r.onQrDisplayed?.(i);
10381
- const s = await C(a.taskId, a.key, t);
10382
- if (s.outcome === "scanned") {
10383
- r.onSuccess([{ appId: s.appId, appSecret: s.appSecret, userOpenid: s.userOpenid }]);
10384
- return;
10385
- }
10386
- r.onQrExpired?.(), n && console.log(`\u4E8C\u7EF4\u7801\u5DF2\u8FC7\u671F\uFF0C\u6B63\u5728\u5237\u65B0\u2026
10387
- `);
10388
- }
10389
- })().catch((n) => {
10390
- if (n instanceof DOMException && n.name === "AbortError") {
10391
- r.onFailure(new Error("\u5DF2\u53D6\u6D88"));
10392
- return;
10393
- }
10394
- r.onFailure(n instanceof Error ? n : new Error(String(n)));
10395
- }), () => e.abort();
10396
- }
10397
- function m2(r) {
10398
- return new Promise((o, e) => {
10399
- l2({ onSuccess: o, onFailure: e }, { ...r, displayQrCodeToConsole: true });
10400
- });
10401
11351
  }
10402
-
10403
- // src/setup/finalize.ts
10404
- function isConfigured(cfg, accountId) {
10405
- const account = resolveQQBotAccount(cfg, accountId);
10406
- return Boolean(account.appId && account.clientSecret);
10407
- }
10408
- async function linkViaQrCode(cfg, accountId, prompter, rt) {
11352
+ async function sendVideoMedia(gw, target, source, params) {
10409
11353
  try {
10410
- const accounts = await m2({ source: "openclaw" });
10411
- if (accounts.length === 0) {
10412
- await prompter.note("\u672A\u83B7\u53D6\u5230\u4EFB\u4F55 QQ Bot \u8D26\u53F7\u4FE1\u606F\u3002", "QQ Bot");
10413
- return cfg;
10414
- }
10415
- let next = cfg;
10416
- for (const { appId, appSecret, userOpenid } of accounts) {
10417
- next = applyQQBotAccountConfig(next, appId, { appId, clientSecret: appSecret });
10418
- next = applyAccountDefaults(next, appId, userOpenid);
10419
- }
10420
- if (accounts.length === 1) {
10421
- rt.log(`\u2714 QQ Bot \u7ED1\u5B9A\u6210\u529F\uFF01(AppID: ${accounts[0].appId})`);
10422
- } else {
10423
- rt.log(`\u2714 ${accounts.length} \u4E2A QQ Bot \u7ED1\u5B9A\u6210\u529F\uFF01(AppID: ${accounts.map((a) => a.appId).join(", ")})`);
10424
- }
10425
- return next;
11354
+ const result = await gw.sendVideo(target, source, {
11355
+ text: params.text,
11356
+ msgId: params.replyToId
11357
+ });
11358
+ return { messageId: result.id };
10426
11359
  } catch (err) {
10427
- rt.error(`QQ Bot \u7ED1\u5B9A\u5931\u8D25: ${String(err)}`);
10428
- await prompter.note(`\u7ED1\u5B9A\u5931\u8D25\uFF0C\u60A8\u53EF\u4EE5\u7A0D\u540E\u624B\u52A8\u914D\u7F6E\u3002
10429
- \u6587\u6863: ${formatDocsLink("/channels/qqbot", "qqbot")}`, "QQ Bot");
10430
- return cfg;
11360
+ return { error: formatErr(err) };
10431
11361
  }
10432
11362
  }
10433
- async function linkViaManual(cfg, prompter) {
10434
- const appId = await prompter.text({ message: "\u8BF7\u8F93\u5165 QQ Bot AppID", validate: (v) => v.trim() ? void 0 : "AppID \u4E0D\u80FD\u4E3A\u7A7A" });
10435
- const secret = await prompter.text({ message: "\u8BF7\u8F93\u5165 QQ Bot AppSecret", validate: (v) => v.trim() ? void 0 : "AppSecret \u4E0D\u80FD\u4E3A\u7A7A" });
10436
- let next = applyQQBotAccountConfig(cfg, appId.trim(), { appId: appId.trim(), clientSecret: secret.trim() });
10437
- next = applyAccountDefaults(next, appId.trim());
10438
- await prompter.note("\u2714 QQ Bot \u914D\u7F6E\u5B8C\u6210\uFF01", "QQ Bot");
10439
- return next;
10440
- }
10441
- async function finalizeQQBotSetup(params) {
10442
- const accountId = params.accountId.trim() || DEFAULT_ACCOUNT_ID2;
10443
- const configured = isConfigured(params.cfg, accountId);
10444
- const mode = await params.prompter.select({
10445
- message: configured ? "QQ \u5DF2\u7ED1\u5B9A\uFF0C\u9009\u62E9\u64CD\u4F5C" : "\u9009\u62E9 QQ \u7ED1\u5B9A\u65B9\u5F0F",
10446
- options: [
10447
- { value: "qr", label: "\u626B\u7801\u7ED1\u5B9A\uFF08\u63A8\u8350\uFF09", hint: "\u4F7F\u7528 QQ \u626B\u63CF\u4E8C\u7EF4\u7801\u81EA\u52A8\u5B8C\u6210\u7ED1\u5B9A" },
10448
- { value: "manual", label: "\u624B\u52A8\u8F93\u5165 QQ Bot AppID \u548C AppSecret", hint: "\u9700\u5230 QQ \u5F00\u653E\u5E73\u53F0 q.qq.com \u67E5\u770B" },
10449
- { value: "skip", label: configured ? "\u4FDD\u6301\u5F53\u524D\u914D\u7F6E" : "\u7A0D\u540E\u914D\u7F6E" }
10450
- ]
10451
- });
10452
- let next = params.cfg;
10453
- if (mode === "qr") {
10454
- next = await linkViaQrCode(next, accountId, params.prompter, params.runtime);
10455
- } else if (mode === "manual") {
10456
- next = await linkViaManual(next, params.prompter);
10457
- } else if (!configured) {
10458
- await params.prompter.note("\u60A8\u53EF\u4EE5\u7A0D\u540E\u8FD0\u884C\u4EE5\u4E0B\u547D\u4EE4\u91CD\u65B0\u914D\u7F6E\uFF1A\n openclaw channels add", "QQ Bot");
11363
+ async function sendFileMedia(gw, target, source, params) {
11364
+ try {
11365
+ const fileName = path8.basename(source);
11366
+ const result = await gw.sendFile(target, source, {
11367
+ text: params.text,
11368
+ msgId: params.replyToId,
11369
+ fileName
11370
+ });
11371
+ return { messageId: result.id };
11372
+ } catch (err) {
11373
+ return { error: formatErr(err) };
10459
11374
  }
10460
- return { cfg: next };
10461
11375
  }
10462
- function applyAccountDefaults(cfg, accountId, userOpenid) {
10463
- const next = { ...cfg, channels: { ...cfg.channels } };
10464
- const qqbot = { ...next.channels?.qqbot ?? {} };
10465
- const defaults = { streaming: true, dmPolicy: "allowlist" };
10466
- if (userOpenid) defaults.allowFrom = [userOpenid];
10467
- if (accountId === DEFAULT_ACCOUNT_ID2) {
10468
- Object.assign(qqbot, defaults);
10469
- } else {
10470
- const accounts = { ...qqbot.accounts ?? {} };
10471
- accounts[accountId] = { ...accounts[accountId] ?? {}, ...defaults };
10472
- qqbot.accounts = accounts;
11376
+ function resolveVoiceSource2(source) {
11377
+ if (source.startsWith("http://") || source.startsWith("https://")) {
11378
+ return { url: source };
10473
11379
  }
10474
- next.channels = { ...next.channels, qqbot };
10475
- return next;
11380
+ if (source.startsWith("data:") || !source.startsWith("/") && !source.startsWith("./") && !source.startsWith("../") && !source.startsWith("~")) {
11381
+ const commaIdx = source.indexOf(",");
11382
+ return { base64: commaIdx > 0 ? source.slice(commaIdx + 1) : source };
11383
+ }
11384
+ return { localPath: source };
11385
+ }
11386
+ function formatErr(err) {
11387
+ if (err instanceof Error) return err.message;
11388
+ return String(err);
10476
11389
  }
10477
11390
 
10478
11391
  // src/setup/surface.ts
11392
+ init_setup();
11393
+ init_config();
11394
+ init_finalize();
10479
11395
  var CHANNEL = "qqbot";
10480
11396
  var qqbotSetupWizard = {
10481
11397
  channel: CHANNEL,
@@ -10492,6 +11408,14 @@ var qqbotSetupWizard = {
10492
11408
  return Boolean(account.appId && account.clientSecret);
10493
11409
  })
10494
11410
  }),
11411
+ // 未配置时默认使用 default 账号,有账户时框架会提示选择
11412
+ resolveAccountIdForConfigure: async ({ cfg, shouldPromptAccountIds, accountOverride, defaultAccountId }) => {
11413
+ if (accountOverride) return accountOverride;
11414
+ const ids = listQQBotAccountIds(cfg);
11415
+ if (ids.length === 0) return "default";
11416
+ if (!shouldPromptAccountIds) return ids[0];
11417
+ return defaultAccountId || resolveDefaultQQBotAccountId(cfg);
11418
+ },
10495
11419
  credentials: [],
10496
11420
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10497
11421
  finalize: (async ({ cfg, accountId, prompter, runtime: runtime2 }) => finalizeQQBotSetup({ cfg, accountId, prompter, runtime: runtime2 })),
@@ -10501,6 +11425,118 @@ var qqbotSetupWizard = {
10501
11425
  }
10502
11426
  };
10503
11427
 
11428
+ // src/setup/login.ts
11429
+ init_esm();
11430
+ var pendingSessions = /* @__PURE__ */ new Map();
11431
+ function startQrLogin(accountId, source = "openclaw") {
11432
+ const key = accountId ?? "default";
11433
+ pendingSessions.get(key)?.dispose();
11434
+ pendingSessions.delete(key);
11435
+ return new Promise((resolve2) => {
11436
+ let credentialsResolve;
11437
+ let credentialsReject;
11438
+ const credentialsPromise = new Promise((res, rej) => {
11439
+ credentialsResolve = res;
11440
+ credentialsReject = rej;
11441
+ });
11442
+ const dispose = l2(
11443
+ {
11444
+ onQrDisplayed(url) {
11445
+ resolve2({
11446
+ qrDataUrl: url,
11447
+ message: "\u8BF7\u4F7F\u7528\u624B\u673A QQ \u626B\u63CF\u4E8C\u7EF4\u7801\u5B8C\u6210\u7ED1\u5B9A"
11448
+ });
11449
+ },
11450
+ onSuccess: (creds) => credentialsResolve(creds),
11451
+ onFailure: (err) => credentialsReject(err)
11452
+ },
11453
+ { displayQrCodeToConsole: true, source }
11454
+ );
11455
+ pendingSessions.set(key, { dispose, credentialsPromise });
11456
+ });
11457
+ }
11458
+ async function waitQrLogin(accountId) {
11459
+ const key = accountId ?? "default";
11460
+ const session = pendingSessions.get(key);
11461
+ if (!session) {
11462
+ return { connected: false, message: "\u6CA1\u6709\u6B63\u5728\u8FDB\u884C\u7684\u767B\u5F55\u4F1A\u8BDD\uFF0C\u8BF7\u5148\u8FD0\u884C login \u547D\u4EE4\u3002" };
11463
+ }
11464
+ try {
11465
+ const credentials = await session.credentialsPromise;
11466
+ pendingSessions.delete(key);
11467
+ if (credentials.length === 0) {
11468
+ return { connected: false, message: "\u672A\u83B7\u53D6\u5230 QQ Bot \u51ED\u636E\u3002" };
11469
+ }
11470
+ return {
11471
+ connected: true,
11472
+ message: `\u7ED1\u5B9A\u6210\u529F\uFF01AppID: ${credentials.map((c) => c.appId).join(", ")}`,
11473
+ credentials
11474
+ };
11475
+ } catch (err) {
11476
+ pendingSessions.delete(key);
11477
+ return {
11478
+ connected: false,
11479
+ message: `\u7ED1\u5B9A\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`
11480
+ };
11481
+ }
11482
+ }
11483
+ function parseChannelInput(channelInput) {
11484
+ if (!channelInput) return null;
11485
+ const parts = channelInput.trim().split(":");
11486
+ if (parts.length === 2 && parts[0] && parts[1]) {
11487
+ return { appId: parts[0], clientSecret: parts[1] };
11488
+ }
11489
+ return null;
11490
+ }
11491
+ async function qqbotLogin({
11492
+ cfg,
11493
+ accountId,
11494
+ channelInput,
11495
+ verbose,
11496
+ ...rest
11497
+ }) {
11498
+ const { applyQQBotAccountConfig: applyQQBotAccountConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
11499
+ const { persistAuthConfig: persistAuthConfig2 } = await Promise.resolve().then(() => (init_resolve(), resolve_exports));
11500
+ const { applyAccountDefaults: applyAccountDefaults2 } = await Promise.resolve().then(() => (init_finalize(), finalize_exports));
11501
+ const { resolveAccountKey: resolveAccountKey2 } = await Promise.resolve().then(() => (init_account_key(), account_key_exports));
11502
+ const runtime2 = rest;
11503
+ const resolvedId = accountId ? accountId.trim().toLowerCase() : null;
11504
+ const parsed = parseChannelInput(channelInput);
11505
+ if (parsed) {
11506
+ const key = resolveAccountKey2(cfg, parsed.appId, resolvedId);
11507
+ const result2 = applyQQBotAccountConfig2(cfg, key, {
11508
+ appId: parsed.appId,
11509
+ clientSecret: parsed.clientSecret
11510
+ });
11511
+ Object.assign(cfg, result2);
11512
+ const withDefaults = applyAccountDefaults2(cfg, key);
11513
+ Object.assign(cfg, withDefaults);
11514
+ await persistAuthConfig2(runtime2, cfg, "restart");
11515
+ if (verbose) console.log(`QQ Bot \u5DF2\u914D\u7F6E (${key}) AppID: ${parsed.appId}`);
11516
+ return;
11517
+ }
11518
+ const { qrDataUrl, message } = await startQrLogin(resolvedId || "pending");
11519
+ console.log(`
11520
+ ${message}`);
11521
+ if (qrDataUrl) console.log(`QR \u94FE\u63A5: ${qrDataUrl}`);
11522
+ const result = await waitQrLogin(resolvedId || "pending");
11523
+ if (!result.connected || !result.credentials) {
11524
+ throw new Error(result.message);
11525
+ }
11526
+ for (const cred of result.credentials) {
11527
+ const key = resolveAccountKey2(cfg, cred.appId, resolvedId);
11528
+ const next = applyQQBotAccountConfig2(cfg, key, {
11529
+ appId: cred.appId,
11530
+ clientSecret: cred.appSecret
11531
+ });
11532
+ Object.assign(cfg, next);
11533
+ const withDefaults = applyAccountDefaults2(cfg, key, cred.userOpenid);
11534
+ Object.assign(cfg, withDefaults);
11535
+ }
11536
+ await persistAuthConfig2(runtime2, cfg, "restart");
11537
+ console.log(`QQ Bot \u767B\u5F55\u6210\u529F\uFF01`);
11538
+ }
11539
+
10504
11540
  // src/outbound/sanitize.ts
10505
11541
  var INTERNAL_TAGS = [
10506
11542
  // 框架脚手架标签
@@ -10526,6 +11562,10 @@ function sanitizeQQBotText(text) {
10526
11562
  return result.trim();
10527
11563
  }
10528
11564
 
11565
+ // src/gateway/lifecycle.ts
11566
+ init_config();
11567
+ init_resolve();
11568
+
10529
11569
  // src/gateway/qqbot-gateway.ts
10530
11570
  var import_node_os4 = __toESM(require("os"), 1);
10531
11571
 
@@ -10762,6 +11802,7 @@ function botMe() {
10762
11802
  }
10763
11803
 
10764
11804
  // src/commands/config-util.ts
11805
+ init_resolve();
10765
11806
  function checkCommandAuth(ctx) {
10766
11807
  const p2 = ctx.state.policy;
10767
11808
  const mode = p2?.c2cMode ?? "allowlist";
@@ -11009,6 +12050,7 @@ var import_node_fs5 = __toESM(require("fs"), 1);
11009
12050
  var import_node_path5 = __toESM(require("path"), 1);
11010
12051
  var import_node_os3 = __toESM(require("os"), 1);
11011
12052
  var import_node_crypto2 = __toESM(require("crypto"), 1);
12053
+ init_resolve();
11012
12054
  var MAX_LINES_PER_FILE = 1e3;
11013
12055
  var MAX_FILES = 4;
11014
12056
  var LOG_KEYWORDS = ["gateway", "openclaw", "clawdbot", "moltbot"];
@@ -11213,6 +12255,7 @@ function botLogs(runtime2) {
11213
12255
  }
11214
12256
 
11215
12257
  // src/commands/bot-approve.ts
12258
+ init_resolve();
11216
12259
  var PRESETS = {
11217
12260
  on: { security: "allowlist", ask: "on-miss", desc: "\u5F00\u542F\u5BA1\u6279\uFF08\u767D\u540D\u5355\u6A21\u5F0F\uFF09" },
11218
12261
  off: { security: "full", ask: "off", desc: "\u5173\u95ED\u5BA1\u6279" },
@@ -11516,10 +12559,10 @@ function buildCommandList(account, opts) {
11516
12559
  // src/middleware/attachment.ts
11517
12560
  var path17 = __toESM(require("path"), 1);
11518
12561
 
11519
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/reply-limiter.js
12562
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/reply-limiter.js
11520
12563
  var DEFAULT_TTL_MS = 60 * 60 * 1e3;
11521
12564
 
11522
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/media-tags.js
12565
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/media-tags.js
11523
12566
  var VALID_TAGS = ["qqimg", "qqvoice", "qqvideo", "qqfile", "qqmedia"];
11524
12567
  var TAG_ALIASES = {
11525
12568
  qq_img: "qqimg",
@@ -11568,30 +12611,30 @@ var SELF_CLOSING_TAG_REGEX = new RegExp("`?" + LEFT_BRACKET + "\\s*(" + TAG_NAME
11568
12611
  var FUZZY_MEDIA_TAG_REGEX = new RegExp("`?" + LEFT_BRACKET + "\\s*(" + TAG_NAME_PATTERN + ")\\s*" + RIGHT_BRACKET + `["']?\\s*([^<\uFF1C<\uFF1E>"'\`]+?)\\s*["']?` + LEFT_BRACKET + "\\s*/?\\s*(?:" + TAG_NAME_PATTERN + ")\\s*" + RIGHT_BRACKET + "`?", "gi");
11569
12612
  var MULTILINE_TAG_CLEANUP = new RegExp("(" + LEFT_BRACKET + "\\s*(?:" + TAG_NAME_PATTERN + ")\\s*" + RIGHT_BRACKET + ")([\\s\\S]*?)(" + LEFT_BRACKET + "\\s*/?\\s*(?:" + TAG_NAME_PATTERN + ")\\s*" + RIGHT_BRACKET + ")", "gi");
11570
12613
 
11571
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/ref-index-store.js
12614
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/ref-index-store.js
11572
12615
  var import_node_fs6 = __toESM(require("fs"), 1);
11573
12616
  var DEFAULT_TTL_MS2 = 7 * 24 * 60 * 60 * 1e3;
11574
12617
 
11575
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/session-store.js
12618
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/session-store.js
11576
12619
  var import_node_fs7 = __toESM(require("fs"), 1);
11577
12620
  var import_node_path7 = __toESM(require("path"), 1);
11578
12621
  var DEFAULT_EXPIRE_MS = 5 * 60 * 1e3;
11579
12622
 
11580
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/text-parsing.js
12623
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/text-parsing.js
11581
12624
  var MAX_FACE_EXT_BYTES = 64 * 1024;
11582
12625
 
11583
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/media-source.js
12626
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/media-source.js
11584
12627
  var fs14 = __toESM(require("fs"), 1);
11585
12628
 
11586
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/image-size.js
12629
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/image-size.js
11587
12630
  var import_node_buffer = require("buffer");
11588
12631
 
11589
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/ffmpeg.js
12632
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/ffmpeg.js
11590
12633
  var import_node_child_process = require("child_process");
11591
12634
  var fs15 = __toESM(require("fs"), 1);
11592
12635
  var path13 = __toESM(require("path"), 1);
11593
12636
 
11594
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/audio.js
12637
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/audio.js
11595
12638
  var import_node_child_process2 = require("child_process");
11596
12639
  var fs16 = __toESM(require("fs"), 1);
11597
12640
  var path14 = __toESM(require("path"), 1);
@@ -11602,7 +12645,7 @@ function loadSilkWasm() {
11602
12645
  }
11603
12646
  _silkWasmPromise = (async () => {
11604
12647
  try {
11605
- const mod = await import("silk-wasm");
12648
+ const mod = await Promise.resolve().then(() => (init_lib(), lib_exports));
11606
12649
  return mod;
11607
12650
  } catch {
11608
12651
  return null;
@@ -11865,6 +12908,7 @@ async function downloadViaFetch(opts) {
11865
12908
  }
11866
12909
 
11867
12910
  // src/middleware/attachment.ts
12911
+ init_resolve();
11868
12912
  function attachmentProcessor(opts) {
11869
12913
  return async (ctx, next) => {
11870
12914
  const msg = ctx.message;
@@ -12068,6 +13112,7 @@ async function downloadMediaFile(url, filename, log4) {
12068
13112
  }
12069
13113
 
12070
13114
  // src/dispatch/body-assembler.ts
13115
+ init_resolve();
12071
13116
  var QUOTE_BEGIN = "[Quoted message begins]";
12072
13117
  var QUOTE_END = "[Quoted message ends]";
12073
13118
  var REF_BEGIN = "[Reference message begins]";
@@ -12271,6 +13316,7 @@ function normalizeTimestamp(ts) {
12271
13316
  }
12272
13317
 
12273
13318
  // src/middleware/policy-injector.ts
13319
+ init_config();
12274
13320
  function createPolicyInjector(account) {
12275
13321
  return async (ctx, next) => {
12276
13322
  const msg = ctx.message;
@@ -12809,12 +13855,22 @@ var StreamingController = class {
12809
13855
  lastAcceptedFull = "";
12810
13856
  /** 已成功发送的分片数(降级:=0 则走静态消息兜底) */
12811
13857
  sentChunkCount = 0;
13858
+ /** 同步标志:收到第一个 onPartialReply 即置 true(不等 async 完成) */
13859
+ _hasStarted = false;
12812
13860
  /** 串行队列 */
12813
13861
  chain = Promise.resolve();
12814
13862
  // ── 公共访问器 ──
12815
13863
  get currentPhase() {
12816
13864
  return this.phase;
12817
13865
  }
13866
+ /** 是否已成功发送至少一个流式分片 */
13867
+ get hasSentChunks() {
13868
+ return this.sentChunkCount > 0;
13869
+ }
13870
+ /** 同步标志:流式已启动(不等异步完成),用于 final 去重 */
13871
+ get hasStarted() {
13872
+ return this._hasStarted;
13873
+ }
12818
13874
  get isTerminal() {
12819
13875
  return this.phase === "done" || this.phase === "failed";
12820
13876
  }
@@ -12823,14 +13879,17 @@ var StreamingController = class {
12823
13879
  }
12824
13880
  // ── 入口 ──
12825
13881
  onPartialReply(text) {
13882
+ this._hasStarted = true;
12826
13883
  this.chain = this.chain.then(() => this.handleChunk(text)).catch((err) => {
12827
13884
  this.deps.log?.error(`onPartialReply error: ${err instanceof Error ? err.message : String(err)}`);
13885
+ this.transition("failed", "chunk_error");
12828
13886
  });
12829
13887
  return this.chain;
12830
13888
  }
12831
13889
  finalize() {
12832
13890
  this.chain = this.chain.then(() => this.handleFinalize()).catch((err) => {
12833
13891
  this.deps.log?.error(`finalize error: ${err instanceof Error ? err.message : String(err)}`);
13892
+ this.transition("failed", "finalize_error");
12834
13893
  });
12835
13894
  return this.chain;
12836
13895
  }
@@ -12941,6 +14000,7 @@ function shouldUseStreaming(account, targetScope) {
12941
14000
  }
12942
14001
 
12943
14002
  // src/dispatch/dispatch.ts
14003
+ init_resolve();
12944
14004
  async function dispatchToOpenClaw(ctx, msg, account, runtime2, log4) {
12945
14005
  const dlog = log4?.child("dispatch");
12946
14006
  const adapters = getAdapters(runtime2, dlog);
@@ -13002,6 +14062,8 @@ async function dispatchToOpenClaw(ctx, msg, account, runtime2, log4) {
13002
14062
  if (streamingController) {
13003
14063
  dlog?.debug(`streaming enabled for ${envelope.senderId}`);
13004
14064
  }
14065
+ const deliveredMediaUrls = /* @__PURE__ */ new Set();
14066
+ const deliveredTexts = /* @__PURE__ */ new Set();
13005
14067
  if (!adapters.inboundRun) {
13006
14068
  if (adapters.recordInboundSession) {
13007
14069
  try {
@@ -13018,11 +14080,24 @@ async function dispatchToOpenClaw(ctx, msg, account, runtime2, log4) {
13018
14080
  cfg,
13019
14081
  dispatcherOptions: {
13020
14082
  deliver: async (payload, info) => {
13021
- await deliverReply(payload, info, deliverCtx);
14083
+ const text = payload.text?.trim() ?? "";
14084
+ if (!payload.mediaUrl && !payload.mediaUrls?.length && text && (deliveredTexts.has(text) || streamingController?.hasStarted && !streamingController?.shouldFallbackToStatic)) {
14085
+ return;
14086
+ }
14087
+ const filteredPayload = deliveredMediaUrls.size > 0 ? {
14088
+ ...payload,
14089
+ mediaUrl: payload.mediaUrl && !deliveredMediaUrls.has(payload.mediaUrl) ? payload.mediaUrl : void 0,
14090
+ mediaUrls: payload.mediaUrls?.filter((u2) => !deliveredMediaUrls.has(u2))
14091
+ } : payload;
14092
+ await deliverReply(filteredPayload, info, deliverCtx);
14093
+ if (text) deliveredTexts.add(text);
14094
+ for (const u2 of filteredPayload.mediaUrls ?? []) deliveredMediaUrls.add(u2);
14095
+ if (filteredPayload.mediaUrl) deliveredMediaUrls.add(filteredPayload.mediaUrl);
13022
14096
  }
13023
14097
  },
13024
14098
  replyOptions: {
13025
14099
  abortSignal: ctx.signal,
14100
+ runId: envelope.messageId,
13026
14101
  ...streamingController ? {
13027
14102
  onPartialReply: async (p2) => {
13028
14103
  if (p2.text) await streamingController.onPartialReply(p2.text);
@@ -13060,8 +14135,6 @@ async function dispatchToOpenClaw(ctx, msg, account, runtime2, log4) {
13060
14135
  }
13061
14136
  },
13062
14137
  runDispatch: () => {
13063
- let blockDelivered = false;
13064
- const deliveredMediaUrls = /* @__PURE__ */ new Set();
13065
14138
  return adapters.dispatchReply({
13066
14139
  ctx: ctxPayload,
13067
14140
  cfg,
@@ -13069,77 +14142,33 @@ async function dispatchToOpenClaw(ctx, msg, account, runtime2, log4) {
13069
14142
  deliver: async (payload, info) => {
13070
14143
  try {
13071
14144
  const kind = info?.kind;
13072
- dlog?.debug(`deliver kind=${kind ?? "none"} textLen=${payload.text?.length ?? 0} audioAsVoice=${payload.audioAsVoice ?? false} mediaUrl=${payload.mediaUrl?.slice(0, 60) ?? "none"} mediaUrls=${payload.mediaUrls?.length ?? 0}`);
14145
+ const text = payload.text?.trim() ?? "";
14146
+ const hasMedia = !!(payload.mediaUrl || payload.mediaUrls?.length);
14147
+ dlog?.debug(`deliver kind=${kind ?? "none"} textLen=${text.length} voice=${!!payload.audioAsVoice} media=${hasMedia}`);
13073
14148
  if (kind === "block") {
13074
14149
  if (payload.audioAsVoice) {
13075
14150
  await deliverReply(payload, info, deliverCtx);
13076
14151
  } else {
13077
- const urls = payload.mediaUrls?.length ? payload.mediaUrls : payload.mediaUrl ? [payload.mediaUrl] : [];
13078
- for (const url of urls) {
13079
- try {
13080
- await sendMedia2({
13081
- to: deliverCtx.qualifiedTarget,
13082
- source: url,
13083
- text: "",
13084
- replyToId: deliverCtx.replyToId,
13085
- accountId: deliverCtx.accountId,
13086
- log: deliverCtx.log,
13087
- agentId: deliverCtx.agentId
13088
- });
13089
- deliveredMediaUrls.add(url);
13090
- } catch (err) {
13091
- dlog?.error(`block media failed: ${err instanceof Error ? err.message : String(err)}`);
13092
- }
13093
- }
14152
+ await forwardMediaUrls(payload, deliverCtx, deliveredMediaUrls, dlog);
13094
14153
  }
13095
14154
  }
13096
- if (streamingController && !streamingController.shouldFallbackToStatic) {
13097
- if (kind !== "block") {
13098
- await streamingController.finalize();
13099
- }
13100
- if (!streamingController.shouldFallbackToStatic) {
13101
- if (kind === "block") return;
13102
- return;
13103
- }
14155
+ if (streamingController?.hasStarted && !streamingController.shouldFallbackToStatic) {
14156
+ if (kind !== "block") await streamingController.finalize();
14157
+ if (!streamingController.shouldFallbackToStatic) return;
13104
14158
  dlog?.warn(`streaming fallback to static`);
13105
14159
  }
13106
- if (kind === "block") {
13107
- blockDelivered = true;
13108
- } else if (kind === "final" && blockDelivered) {
14160
+ if (kind === "final" && !hasMedia && text && deliveredTexts.has(text)) {
13109
14161
  return;
13110
14162
  }
13111
14163
  if (kind === "tool") {
13112
- const toolMediaUrls = [];
13113
- if (payload.mediaUrls?.length) toolMediaUrls.push(...payload.mediaUrls);
13114
- if (payload.mediaUrl && !toolMediaUrls.includes(payload.mediaUrl)) toolMediaUrls.push(payload.mediaUrl);
13115
- const newUrls = toolMediaUrls.filter((u2) => !deliveredMediaUrls.has(u2));
13116
- for (const mediaUrl of newUrls) {
13117
- try {
13118
- await sendMedia2({
13119
- to: deliverCtx.qualifiedTarget,
13120
- source: mediaUrl,
13121
- text: "",
13122
- replyToId: deliverCtx.replyToId,
13123
- accountId: deliverCtx.accountId,
13124
- log: deliverCtx.log,
13125
- agentId: deliverCtx.agentId
13126
- });
13127
- deliveredMediaUrls.add(mediaUrl);
13128
- dlog?.info(`tool media forwarded url=${mediaUrl.slice(0, 60)}`);
13129
- } catch (err) {
13130
- dlog?.error(`tool media forward failed: ${err instanceof Error ? err.message : String(err)}`);
13131
- }
13132
- }
14164
+ await forwardMediaUrls(payload, deliverCtx, deliveredMediaUrls, dlog);
13133
14165
  return;
13134
14166
  }
13135
- const filteredPayload = deliveredMediaUrls.size > 0 ? {
13136
- ...payload,
13137
- mediaUrl: payload.mediaUrl && !deliveredMediaUrls.has(payload.mediaUrl) ? payload.mediaUrl : void 0,
13138
- mediaUrls: payload.mediaUrls?.filter((u2) => !deliveredMediaUrls.has(u2))
13139
- } : payload;
14167
+ const filteredPayload = filterDeliveredMedia(payload, deliveredMediaUrls);
13140
14168
  await deliverReply(filteredPayload, info, deliverCtx);
14169
+ if (text) deliveredTexts.add(text);
13141
14170
  } catch (err) {
13142
- dlog?.error(`error: ${err instanceof Error ? err.message : String(err)}`);
14171
+ dlog?.error(`deliver error: ${err instanceof Error ? err.message : String(err)}`);
13143
14172
  }
13144
14173
  }
13145
14174
  },
@@ -13187,6 +14216,36 @@ function createStreamingController(envelope, account, log4) {
13187
14216
  log: log4
13188
14217
  });
13189
14218
  }
14219
+ async function forwardMediaUrls(payload, ctx, delivered, log4) {
14220
+ const urls = [];
14221
+ if (payload.mediaUrls?.length) urls.push(...payload.mediaUrls);
14222
+ if (payload.mediaUrl && !urls.includes(payload.mediaUrl)) urls.push(payload.mediaUrl);
14223
+ const newUrls = urls.filter((u2) => !delivered.has(u2));
14224
+ for (const url of newUrls) {
14225
+ try {
14226
+ await sendMedia2({
14227
+ to: ctx.qualifiedTarget,
14228
+ source: url,
14229
+ text: "",
14230
+ replyToId: ctx.replyToId,
14231
+ accountId: ctx.accountId,
14232
+ log: ctx.log,
14233
+ agentId: ctx.agentId
14234
+ });
14235
+ delivered.add(url);
14236
+ } catch (err) {
14237
+ log4?.error(`media forward failed: ${err instanceof Error ? err.message : String(err)}`);
14238
+ }
14239
+ }
14240
+ }
14241
+ function filterDeliveredMedia(payload, delivered) {
14242
+ if (delivered.size === 0) return payload;
14243
+ return {
14244
+ ...payload,
14245
+ mediaUrl: payload.mediaUrl && !delivered.has(payload.mediaUrl) ? payload.mediaUrl : void 0,
14246
+ mediaUrls: payload.mediaUrls?.filter((u2) => !delivered.has(u2))
14247
+ };
14248
+ }
13190
14249
 
13191
14250
  // src/adapter/gateway.ts
13192
14251
  var import_node_module5 = require("module");
@@ -13502,6 +14561,7 @@ function getApprovalHandler(accountId) {
13502
14561
  // src/features/proactive.ts
13503
14562
  var fs19 = __toESM(require("fs"), 1);
13504
14563
  var path20 = __toESM(require("path"), 1);
14564
+ init_config();
13505
14565
  var log2 = createPluginLogger({ prefix: "[proactive]" });
13506
14566
  var STORAGE_DIR = getQQBotDataDir("data");
13507
14567
  var KNOWN_USERS_FILE = path20.join(STORAGE_DIR, "known-users.json");
@@ -13608,6 +14668,8 @@ function getCachedMsgId(scope, targetId) {
13608
14668
  }
13609
14669
 
13610
14670
  // src/gateway/event-handlers.ts
14671
+ init_resolve();
14672
+ init_config();
13611
14673
  async function handleMessage(ctx, msg, account, runtime2, log4) {
13612
14674
  const hlog = log4.child("handle");
13613
14675
  const scope = msg.replyTarget.scope;
@@ -14452,10 +15514,6 @@ var approvalStubs = {
14452
15514
  buildPendingPayload: () => null,
14453
15515
  buildResolvedPayload: () => null
14454
15516
  },
14455
- auth: {
14456
- authorizeActorAction: () => ({ authorized: true }),
14457
- getActionAvailabilityState: () => ({ kind: "enabled" })
14458
- },
14459
15517
  approvals: {
14460
15518
  delivery: {
14461
15519
  hasConfiguredDmRoute: () => true,
@@ -14469,6 +15527,7 @@ var approvalStubs = {
14469
15527
  };
14470
15528
 
14471
15529
  // src/features/onboarding.ts
15530
+ init_config();
14472
15531
  var qqbotOnboardingAdapter = {
14473
15532
  getStatus: (ctx) => {
14474
15533
  const cfg = ctx.config;
@@ -14512,6 +15571,7 @@ var qqbotPlugin = {
14512
15571
  threads: false,
14513
15572
  blockStreaming: false
14514
15573
  },
15574
+ gatewayMethods: ["web.login.start", "web.login.wait"],
14515
15575
  reload: { configPrefixes: ["channels.qqbot"] },
14516
15576
  // ── 群消息策略 ──
14517
15577
  groups: {
@@ -14690,7 +15750,19 @@ ${line}` : line;
14690
15750
  log: ctx.log
14691
15751
  });
14692
15752
  },
14693
- logoutAccount: (params) => logoutAndClearCredentials(params)
15753
+ logoutAccount: (params) => logoutAndClearCredentials(params),
15754
+ loginWithQrStart: async ({ accountId }) => startQrLogin(accountId),
15755
+ loginWithQrWait: async ({ accountId }) => {
15756
+ const result = await waitQrLogin(accountId);
15757
+ return { connected: result.connected, message: result.message };
15758
+ }
15759
+ },
15760
+ // ── 登录认证 ──
15761
+ auth: {
15762
+ login: qqbotLogin,
15763
+ // 审批权限(从 approvalStubs 迁移)
15764
+ authorizeActorAction: () => ({ authorized: true }),
15765
+ getActionAvailabilityState: () => ({ kind: "enabled" })
14694
15766
  },
14695
15767
  // ── 状态 ──
14696
15768
  status: {
@@ -14754,6 +15826,7 @@ function createOutLog(accountId) {
14754
15826
  }
14755
15827
 
14756
15828
  // src/tools/platform.ts
15829
+ init_config();
14757
15830
  var PlatformApiSchema = {
14758
15831
  type: "object",
14759
15832
  properties: {
@@ -15063,7 +16136,7 @@ function registerRemindTool(api) {
15063
16136
  }
15064
16137
 
15065
16138
  // src/adapter/contract.ts
15066
- var log3 = createPluginLogger({ prefix: "[contract]", forceConsole: true });
16139
+ var log3 = createPluginLogger({ prefix: "[contract]", forceConsole: false });
15067
16140
  var REQUIRED = [
15068
16141
  {
15069
16142
  name: "channel.reply.dispatchReplyWithBufferedBlockDispatcher",
@@ -15123,6 +16196,7 @@ var StreamContentType2 = {
15123
16196
  };
15124
16197
 
15125
16198
  // index.ts
16199
+ init_config();
15126
16200
  var registered = false;
15127
16201
  var plugin = {
15128
16202
  id: "openclaw-qqbot",