@openclaw-china/qqbot 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,25 @@
1
+ {
2
+ "id": "qqbot",
3
+ "name": "QQ Bot",
4
+ "description": "QQ 开放平台机器人消息渠道插件",
5
+ "version": "0.1.0",
6
+ "channels": ["qqbot"],
7
+ "configSchema": {
8
+ "type": "object",
9
+ "additionalProperties": false,
10
+ "properties": {
11
+ "enabled": { "type": "boolean" },
12
+ "appId": { "type": "string" },
13
+ "clientSecret": { "type": "string" },
14
+ "markdownSupport": { "type": "boolean" },
15
+ "dmPolicy": { "type": "string", "enum": ["open", "pairing", "allowlist"] },
16
+ "groupPolicy": { "type": "string", "enum": ["open", "allowlist", "disabled"] },
17
+ "requireMention": { "type": "boolean" },
18
+ "allowFrom": { "type": "array", "items": { "type": "string" } },
19
+ "groupAllowFrom": { "type": "array", "items": { "type": "string" } },
20
+ "historyLimit": { "type": "integer", "minimum": 0 },
21
+ "textChunkLimit": { "type": "integer", "minimum": 1 },
22
+ "replyFinalOnly": { "type": "boolean" }
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,438 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const QQBotConfigSchema: z.ZodObject<{
4
+ enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
5
+ appId: z.ZodOptional<z.ZodString>;
6
+ clientSecret: z.ZodOptional<z.ZodString>;
7
+ markdownSupport: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
8
+ dmPolicy: z.ZodDefault<z.ZodOptional<z.ZodEnum<["open", "pairing", "allowlist"]>>>;
9
+ groupPolicy: z.ZodDefault<z.ZodOptional<z.ZodEnum<["open", "allowlist", "disabled"]>>>;
10
+ requireMention: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
11
+ allowFrom: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
12
+ groupAllowFrom: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
13
+ historyLimit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
14
+ textChunkLimit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
15
+ replyFinalOnly: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
16
+ }, "strip", z.ZodTypeAny, {
17
+ enabled: boolean;
18
+ markdownSupport: boolean;
19
+ dmPolicy: "open" | "pairing" | "allowlist";
20
+ groupPolicy: "open" | "allowlist" | "disabled";
21
+ requireMention: boolean;
22
+ historyLimit: number;
23
+ textChunkLimit: number;
24
+ replyFinalOnly: boolean;
25
+ appId?: string | undefined;
26
+ clientSecret?: string | undefined;
27
+ allowFrom?: string[] | undefined;
28
+ groupAllowFrom?: string[] | undefined;
29
+ }, {
30
+ enabled?: boolean | undefined;
31
+ appId?: string | undefined;
32
+ clientSecret?: string | undefined;
33
+ markdownSupport?: boolean | undefined;
34
+ dmPolicy?: "open" | "pairing" | "allowlist" | undefined;
35
+ groupPolicy?: "open" | "allowlist" | "disabled" | undefined;
36
+ requireMention?: boolean | undefined;
37
+ allowFrom?: string[] | undefined;
38
+ groupAllowFrom?: string[] | undefined;
39
+ historyLimit?: number | undefined;
40
+ textChunkLimit?: number | undefined;
41
+ replyFinalOnly?: boolean | undefined;
42
+ }>;
43
+ type QQBotConfig = z.infer<typeof QQBotConfigSchema>;
44
+
45
+ interface ResolvedQQBotAccount {
46
+ accountId: string;
47
+ enabled: boolean;
48
+ configured: boolean;
49
+ appId?: string;
50
+ markdownSupport?: boolean;
51
+ }
52
+ interface QQBotSendResult {
53
+ channel: "qqbot";
54
+ messageId?: string;
55
+ timestamp?: number | string;
56
+ error?: string;
57
+ }
58
+
59
+ /**
60
+ * QQ Bot 出站适配器(仅文本)
61
+ */
62
+
63
+ interface OutboundConfig {
64
+ channels?: {
65
+ qqbot?: QQBotConfig;
66
+ };
67
+ }
68
+
69
+ declare const DEFAULT_ACCOUNT_ID = "default";
70
+ interface PluginConfig {
71
+ channels?: {
72
+ qqbot?: QQBotConfig;
73
+ };
74
+ }
75
+ declare const qqbotPlugin: {
76
+ id: string;
77
+ meta: {
78
+ id: "qqbot";
79
+ label: "QQ Bot";
80
+ selectionLabel: "QQ Bot";
81
+ docsPath: "/channels/qqbot";
82
+ docsLabel: "qqbot";
83
+ blurb: "QQ 开放平台机器人消息";
84
+ aliases: readonly ["qq"];
85
+ order: 72;
86
+ };
87
+ capabilities: {
88
+ chatTypes: readonly ["direct", "channel"];
89
+ media: boolean;
90
+ reactions: boolean;
91
+ threads: boolean;
92
+ edit: boolean;
93
+ reply: boolean;
94
+ polls: boolean;
95
+ blockStreaming: boolean;
96
+ };
97
+ messaging: {
98
+ normalizeTarget: (raw: string) => string | undefined;
99
+ targetResolver: {
100
+ looksLikeId: (raw: string, normalized?: string) => boolean;
101
+ hint: string;
102
+ };
103
+ formatTargetDisplay: (params: {
104
+ target: string;
105
+ display?: string;
106
+ kind?: "user" | "group" | "channel";
107
+ }) => string;
108
+ };
109
+ configSchema: {
110
+ schema: {
111
+ type: string;
112
+ additionalProperties: boolean;
113
+ properties: {
114
+ enabled: {
115
+ type: string;
116
+ };
117
+ appId: {
118
+ type: string;
119
+ };
120
+ clientSecret: {
121
+ type: string;
122
+ };
123
+ markdownSupport: {
124
+ type: string;
125
+ };
126
+ dmPolicy: {
127
+ type: string;
128
+ enum: string[];
129
+ };
130
+ groupPolicy: {
131
+ type: string;
132
+ enum: string[];
133
+ };
134
+ requireMention: {
135
+ type: string;
136
+ };
137
+ allowFrom: {
138
+ type: string;
139
+ items: {
140
+ type: string;
141
+ };
142
+ };
143
+ groupAllowFrom: {
144
+ type: string;
145
+ items: {
146
+ type: string;
147
+ };
148
+ };
149
+ historyLimit: {
150
+ type: string;
151
+ minimum: number;
152
+ };
153
+ textChunkLimit: {
154
+ type: string;
155
+ minimum: number;
156
+ };
157
+ replyFinalOnly: {
158
+ type: string;
159
+ };
160
+ };
161
+ };
162
+ };
163
+ reload: {
164
+ configPrefixes: string[];
165
+ };
166
+ config: {
167
+ listAccountIds: (_cfg: PluginConfig) => string[];
168
+ resolveAccount: (cfg: PluginConfig, accountId?: string) => ResolvedQQBotAccount;
169
+ defaultAccountId: () => string;
170
+ setAccountEnabled: (params: {
171
+ cfg: PluginConfig;
172
+ enabled: boolean;
173
+ }) => PluginConfig;
174
+ deleteAccount: (params: {
175
+ cfg: PluginConfig;
176
+ }) => PluginConfig;
177
+ isConfigured: (_account: ResolvedQQBotAccount, cfg: PluginConfig) => boolean;
178
+ describeAccount: (account: ResolvedQQBotAccount) => {
179
+ accountId: string;
180
+ enabled: boolean;
181
+ configured: boolean;
182
+ };
183
+ resolveAllowFrom: (params: {
184
+ cfg: PluginConfig;
185
+ }) => string[];
186
+ formatAllowFrom: (params: {
187
+ allowFrom: (string | number)[];
188
+ }) => string[];
189
+ };
190
+ security: {
191
+ collectWarnings: (params: {
192
+ cfg: PluginConfig;
193
+ }) => string[];
194
+ };
195
+ setup: {
196
+ resolveAccountId: () => string;
197
+ applyAccountConfig: (params: {
198
+ cfg: PluginConfig;
199
+ }) => PluginConfig;
200
+ };
201
+ outbound: {
202
+ deliveryMode: "direct";
203
+ textChunkLimit: number;
204
+ chunkerMode: "markdown";
205
+ sendText: (params: {
206
+ cfg: OutboundConfig;
207
+ to: string;
208
+ text: string;
209
+ replyToId?: string;
210
+ }) => Promise<QQBotSendResult>;
211
+ sendMedia: (params: {
212
+ cfg: OutboundConfig;
213
+ to: string;
214
+ text?: string;
215
+ mediaUrl?: string;
216
+ }) => Promise<QQBotSendResult>;
217
+ };
218
+ gateway: {
219
+ startAccount: (ctx: {
220
+ cfg: PluginConfig;
221
+ runtime?: unknown;
222
+ abortSignal?: AbortSignal;
223
+ accountId: string;
224
+ setStatus?: (status: Record<string, unknown>) => void;
225
+ log?: {
226
+ info: (msg: string) => void;
227
+ error: (msg: string) => void;
228
+ };
229
+ }) => Promise<void>;
230
+ stopAccount: (_ctx: {
231
+ accountId: string;
232
+ }) => Promise<void>;
233
+ getStatus: () => {
234
+ connected: boolean;
235
+ };
236
+ };
237
+ };
238
+
239
+ interface PluginRuntime {
240
+ log?: (msg: string) => void;
241
+ error?: (msg: string) => void;
242
+ channel?: {
243
+ routing?: {
244
+ resolveAgentRoute?: (params: {
245
+ cfg: unknown;
246
+ channel: string;
247
+ accountId?: string;
248
+ peer: {
249
+ kind: string;
250
+ id: string;
251
+ };
252
+ }) => {
253
+ sessionKey: string;
254
+ accountId: string;
255
+ agentId?: string;
256
+ };
257
+ };
258
+ session?: {
259
+ resolveStorePath?: (store: unknown, params: {
260
+ agentId?: string;
261
+ }) => string | undefined;
262
+ readSessionUpdatedAt?: (params: {
263
+ storePath: string;
264
+ sessionKey: string;
265
+ }) => number | null;
266
+ recordSessionMetaFromInbound?: (params: {
267
+ storePath: string;
268
+ sessionKey: string;
269
+ ctx: unknown;
270
+ groupResolution?: unknown;
271
+ createIfMissing?: boolean;
272
+ }) => Promise<unknown>;
273
+ updateLastRoute?: (params: {
274
+ storePath: string;
275
+ sessionKey: string;
276
+ channel?: string;
277
+ to?: string;
278
+ accountId?: string;
279
+ threadId?: string | number;
280
+ deliveryContext?: unknown;
281
+ ctx?: unknown;
282
+ groupResolution?: unknown;
283
+ }) => Promise<unknown>;
284
+ recordInboundSession?: (params: {
285
+ storePath: string;
286
+ sessionKey: string;
287
+ ctx: unknown;
288
+ updateLastRoute?: {
289
+ sessionKey: string;
290
+ channel: string;
291
+ to: string;
292
+ accountId?: string;
293
+ threadId?: string | number;
294
+ };
295
+ onRecordError?: (err: unknown) => void;
296
+ }) => Promise<void>;
297
+ };
298
+ reply?: {
299
+ dispatchReplyFromConfig?: (params: {
300
+ ctx: unknown;
301
+ cfg: unknown;
302
+ dispatcher?: unknown;
303
+ replyOptions?: unknown;
304
+ }) => Promise<{
305
+ queuedFinal: boolean;
306
+ counts: {
307
+ final: number;
308
+ };
309
+ }>;
310
+ dispatchReplyWithBufferedBlockDispatcher?: (params: {
311
+ ctx: unknown;
312
+ cfg: unknown;
313
+ dispatcherOptions: {
314
+ deliver: (payload: unknown, info?: {
315
+ kind?: string;
316
+ }) => Promise<void> | void;
317
+ onError?: (err: unknown, info: {
318
+ kind: string;
319
+ }) => void;
320
+ onSkip?: (payload: unknown, info: {
321
+ kind: string;
322
+ reason: string;
323
+ }) => void;
324
+ onReplyStart?: () => Promise<void> | void;
325
+ humanDelay?: unknown;
326
+ };
327
+ replyOptions?: unknown;
328
+ }) => Promise<unknown>;
329
+ finalizeInboundContext?: (ctx: unknown) => unknown;
330
+ createReplyDispatcher?: (params: unknown) => unknown;
331
+ createReplyDispatcherWithTyping?: (params: unknown) => {
332
+ dispatcher: unknown;
333
+ replyOptions?: unknown;
334
+ markDispatchIdle?: () => void;
335
+ };
336
+ resolveHumanDelayConfig?: (cfg: unknown, agentId?: string) => unknown;
337
+ resolveEffectiveMessagesConfig?: (cfg: unknown) => unknown;
338
+ resolveEnvelopeFormatOptions?: (cfg: unknown) => unknown;
339
+ formatAgentEnvelope?: (params: unknown) => string;
340
+ formatInboundEnvelope?: (params: unknown) => string;
341
+ };
342
+ text?: {
343
+ resolveTextChunkLimit?: (params: {
344
+ cfg: unknown;
345
+ channel: string;
346
+ defaultLimit?: number;
347
+ }) => number;
348
+ resolveChunkMode?: (cfg: unknown, channel: string) => unknown;
349
+ resolveMarkdownTableMode?: (params: {
350
+ cfg: unknown;
351
+ channel: string;
352
+ accountId?: string;
353
+ }) => unknown;
354
+ convertMarkdownTables?: (text: string, mode: unknown) => string;
355
+ chunkTextWithMode?: (text: string, limit: number, mode: unknown) => string[];
356
+ chunkMarkdownText?: (text: string, limit: number) => string[];
357
+ };
358
+ };
359
+ system?: {
360
+ enqueueSystemEvent?: (message: string, options?: unknown) => void;
361
+ };
362
+ [key: string]: unknown;
363
+ }
364
+ declare function setQQBotRuntime(next: PluginRuntime): void;
365
+ declare function getQQBotRuntime(): PluginRuntime;
366
+
367
+ /**
368
+ * @openclaw-china/qqbot
369
+ * QQ Bot 渠道插件入口
370
+ */
371
+ interface MoltbotPluginApi {
372
+ registerChannel: (opts: {
373
+ plugin: unknown;
374
+ }) => void;
375
+ runtime?: unknown;
376
+ [key: string]: unknown;
377
+ }
378
+
379
+ declare const plugin: {
380
+ id: string;
381
+ name: string;
382
+ description: string;
383
+ configSchema: {
384
+ type: string;
385
+ additionalProperties: boolean;
386
+ properties: {
387
+ enabled: {
388
+ type: string;
389
+ };
390
+ appId: {
391
+ type: string;
392
+ };
393
+ clientSecret: {
394
+ type: string;
395
+ };
396
+ markdownSupport: {
397
+ type: string;
398
+ };
399
+ dmPolicy: {
400
+ type: string;
401
+ enum: string[];
402
+ };
403
+ groupPolicy: {
404
+ type: string;
405
+ enum: string[];
406
+ };
407
+ requireMention: {
408
+ type: string;
409
+ };
410
+ allowFrom: {
411
+ type: string;
412
+ items: {
413
+ type: string;
414
+ };
415
+ };
416
+ groupAllowFrom: {
417
+ type: string;
418
+ items: {
419
+ type: string;
420
+ };
421
+ };
422
+ historyLimit: {
423
+ type: string;
424
+ minimum: number;
425
+ };
426
+ textChunkLimit: {
427
+ type: string;
428
+ minimum: number;
429
+ };
430
+ replyFinalOnly: {
431
+ type: string;
432
+ };
433
+ };
434
+ };
435
+ register(api: MoltbotPluginApi): void;
436
+ };
437
+
438
+ export { DEFAULT_ACCOUNT_ID, type MoltbotPluginApi, type QQBotConfig, type QQBotSendResult, type ResolvedQQBotAccount, plugin as default, getQQBotRuntime, qqbotPlugin, setQQBotRuntime };