@fraqjs/plugin-ai 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2833 -6
- package/dist/index.mjs +1364 -3
- package/package.json +13 -9
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { definePlugin } from "@fraqjs/fraq";
|
|
2
|
+
import { tool } from "ai";
|
|
3
|
+
import { z } from "zod";
|
|
2
4
|
//#region src/provider.ts
|
|
3
|
-
async function resolveLanguageModels(config) {
|
|
5
|
+
async function resolveLanguageModels(name, config) {
|
|
4
6
|
const { sdk, options, models } = config;
|
|
5
7
|
let provider;
|
|
6
8
|
switch (sdk) {
|
|
@@ -16,6 +18,14 @@ async function resolveLanguageModels(config) {
|
|
|
16
18
|
case "@ai-sdk/openai":
|
|
17
19
|
provider = (await import("@ai-sdk/openai")).createOpenAI(options);
|
|
18
20
|
break;
|
|
21
|
+
case "@ai-sdk/openai-compatible":
|
|
22
|
+
if (!options.baseURL) throw new Error("`baseURL` is required for OpenAI Compatible SDK");
|
|
23
|
+
provider = (await import("@ai-sdk/openai-compatible")).createOpenAICompatible({
|
|
24
|
+
...options,
|
|
25
|
+
baseURL: options.baseURL,
|
|
26
|
+
name
|
|
27
|
+
});
|
|
28
|
+
break;
|
|
19
29
|
default: throw new Error(`Unsupported AI SDK: ${sdk}`);
|
|
20
30
|
}
|
|
21
31
|
return models.map((model) => provider.languageModel(model));
|
|
@@ -48,6 +58,1357 @@ var AiService = class {
|
|
|
48
58
|
}
|
|
49
59
|
};
|
|
50
60
|
//#endregion
|
|
61
|
+
//#region src/protocol/types-zod.ts
|
|
62
|
+
const zUin = z.number().int().min(10001).max(4294967295);
|
|
63
|
+
function zDropBadElementArray(element) {
|
|
64
|
+
return z.array(element.catch(null)).transform((val) => val.filter((item) => item !== null));
|
|
65
|
+
}
|
|
66
|
+
const BotOfflineEvent = z.object({
|
|
67
|
+
event_type: z.literal("bot_offline"),
|
|
68
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
69
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
70
|
+
data: z.object({ reason: z.string().describe("下线原因") })
|
|
71
|
+
}).describe("机器人离线事件");
|
|
72
|
+
const MessageReceiveEvent = z.object({
|
|
73
|
+
event_type: z.literal("message_receive"),
|
|
74
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
75
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
76
|
+
data: z.lazy(() => IncomingMessage).describe("消息接收事件")
|
|
77
|
+
}).describe("消息接收事件");
|
|
78
|
+
const MessageRecallEvent = z.object({
|
|
79
|
+
event_type: z.literal("message_recall"),
|
|
80
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
81
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
82
|
+
data: z.object({
|
|
83
|
+
message_scene: z.enum([
|
|
84
|
+
"friend",
|
|
85
|
+
"group",
|
|
86
|
+
"temp"
|
|
87
|
+
]).describe("消息场景"),
|
|
88
|
+
peer_id: zUin.describe("好友 QQ 号或群号"),
|
|
89
|
+
message_seq: z.number().int().nonnegative().describe("消息序列号"),
|
|
90
|
+
sender_id: zUin.describe("被撤回的消息的发送者 QQ 号"),
|
|
91
|
+
operator_id: zUin.describe("操作者 QQ 号"),
|
|
92
|
+
display_suffix: z.string().describe("撤回提示的后缀文本")
|
|
93
|
+
})
|
|
94
|
+
}).describe("消息撤回事件");
|
|
95
|
+
const PeerPinChangeEvent = z.object({
|
|
96
|
+
event_type: z.literal("peer_pin_change"),
|
|
97
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
98
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
99
|
+
data: z.object({
|
|
100
|
+
message_scene: z.enum([
|
|
101
|
+
"friend",
|
|
102
|
+
"group",
|
|
103
|
+
"temp"
|
|
104
|
+
]).describe("发生改变的会话的消息场景"),
|
|
105
|
+
peer_id: zUin.describe("发生改变的好友 QQ 号或群号"),
|
|
106
|
+
is_pinned: z.boolean().describe("是否被置顶, `false` 表示取消置顶")
|
|
107
|
+
})
|
|
108
|
+
}).describe("会话置顶变更事件");
|
|
109
|
+
const FriendRequestEvent = z.object({
|
|
110
|
+
event_type: z.literal("friend_request"),
|
|
111
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
112
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
113
|
+
data: z.object({
|
|
114
|
+
initiator_id: zUin.describe("申请好友的用户 QQ 号"),
|
|
115
|
+
initiator_uid: z.string().describe("用户 UID"),
|
|
116
|
+
comment: z.string().describe("申请附加信息"),
|
|
117
|
+
via: z.string().describe("申请来源")
|
|
118
|
+
})
|
|
119
|
+
}).describe("好友请求事件");
|
|
120
|
+
const GroupJoinRequestEvent = z.object({
|
|
121
|
+
event_type: z.literal("group_join_request"),
|
|
122
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
123
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
124
|
+
data: z.object({
|
|
125
|
+
group_id: zUin.describe("群号"),
|
|
126
|
+
notification_seq: z.number().int().nonnegative().describe("请求对应的通知序列号"),
|
|
127
|
+
is_filtered: z.boolean().describe("请求是否被过滤(发起自风险账户)"),
|
|
128
|
+
initiator_id: zUin.describe("申请入群的用户 QQ 号"),
|
|
129
|
+
comment: z.string().describe("申请附加信息")
|
|
130
|
+
})
|
|
131
|
+
}).describe("入群请求事件");
|
|
132
|
+
const GroupInvitedJoinRequestEvent = z.object({
|
|
133
|
+
event_type: z.literal("group_invited_join_request"),
|
|
134
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
135
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
136
|
+
data: z.object({
|
|
137
|
+
group_id: zUin.describe("群号"),
|
|
138
|
+
notification_seq: z.number().int().nonnegative().describe("请求对应的通知序列号"),
|
|
139
|
+
initiator_id: zUin.describe("邀请者 QQ 号"),
|
|
140
|
+
target_user_id: zUin.describe("被邀请者 QQ 号")
|
|
141
|
+
})
|
|
142
|
+
}).describe("群成员邀请他人入群请求事件");
|
|
143
|
+
const GroupInvitationEvent = z.object({
|
|
144
|
+
event_type: z.literal("group_invitation"),
|
|
145
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
146
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
147
|
+
data: z.object({
|
|
148
|
+
group_id: zUin.describe("群号"),
|
|
149
|
+
invitation_seq: z.number().int().nonnegative().describe("邀请序列号"),
|
|
150
|
+
initiator_id: zUin.describe("邀请者 QQ 号"),
|
|
151
|
+
source_group_id: z.number().int().nonnegative().nullish().describe("来源群号,如果是通过 QQ 群邀请")
|
|
152
|
+
})
|
|
153
|
+
}).describe("他人邀请自身入群事件");
|
|
154
|
+
const FriendNudgeEvent = z.object({
|
|
155
|
+
event_type: z.literal("friend_nudge"),
|
|
156
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
157
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
158
|
+
data: z.object({
|
|
159
|
+
user_id: zUin.describe("好友 QQ 号"),
|
|
160
|
+
is_self_send: z.boolean().describe("是否是自己发送的戳一戳"),
|
|
161
|
+
is_self_receive: z.boolean().describe("是否是自己接收的戳一戳"),
|
|
162
|
+
display_action: z.string().describe("戳一戳提示的动作文本"),
|
|
163
|
+
display_suffix: z.string().describe("戳一戳提示的后缀文本"),
|
|
164
|
+
display_action_img_url: z.string().describe("戳一戳提示的动作图片 URL,用于取代动作提示文本")
|
|
165
|
+
})
|
|
166
|
+
}).describe("好友戳一戳事件");
|
|
167
|
+
const FriendFileUploadEvent = z.object({
|
|
168
|
+
event_type: z.literal("friend_file_upload"),
|
|
169
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
170
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
171
|
+
data: z.object({
|
|
172
|
+
user_id: zUin.describe("好友 QQ 号"),
|
|
173
|
+
file_id: z.string().describe("文件 ID"),
|
|
174
|
+
file_name: z.string().describe("文件名称"),
|
|
175
|
+
file_size: z.number().int().nonnegative().describe("文件大小(字节)"),
|
|
176
|
+
file_hash: z.string().describe("文件的 TriSHA1 哈希值"),
|
|
177
|
+
is_self: z.boolean().describe("是否是自己发送的文件")
|
|
178
|
+
})
|
|
179
|
+
}).describe("好友文件上传事件");
|
|
180
|
+
const GroupAdminChangeEvent = z.object({
|
|
181
|
+
event_type: z.literal("group_admin_change"),
|
|
182
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
183
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
184
|
+
data: z.object({
|
|
185
|
+
group_id: zUin.describe("群号"),
|
|
186
|
+
user_id: zUin.describe("发生变更的用户 QQ 号"),
|
|
187
|
+
operator_id: zUin.describe("操作者 QQ 号"),
|
|
188
|
+
is_set: z.boolean().describe("是否被设置为管理员,`false` 表示被取消管理员")
|
|
189
|
+
})
|
|
190
|
+
}).describe("群管理员变更事件");
|
|
191
|
+
const GroupEssenceMessageChangeEvent = z.object({
|
|
192
|
+
event_type: z.literal("group_essence_message_change"),
|
|
193
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
194
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
195
|
+
data: z.object({
|
|
196
|
+
group_id: zUin.describe("群号"),
|
|
197
|
+
message_seq: z.number().int().nonnegative().describe("发生变更的消息序列号"),
|
|
198
|
+
operator_id: zUin.describe("操作者 QQ 号"),
|
|
199
|
+
is_set: z.boolean().describe("是否被设置为精华,`false` 表示被取消精华")
|
|
200
|
+
})
|
|
201
|
+
}).describe("群精华消息变更事件");
|
|
202
|
+
const GroupMemberIncreaseEvent = z.object({
|
|
203
|
+
event_type: z.literal("group_member_increase"),
|
|
204
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
205
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
206
|
+
data: z.object({
|
|
207
|
+
group_id: zUin.describe("群号"),
|
|
208
|
+
user_id: zUin.describe("发生变更的用户 QQ 号"),
|
|
209
|
+
operator_id: z.number().int().nonnegative().nullish().describe("管理员 QQ 号,如果是管理员同意入群"),
|
|
210
|
+
invitor_id: z.number().int().nonnegative().nullish().describe("邀请者 QQ 号,如果是邀请入群")
|
|
211
|
+
})
|
|
212
|
+
}).describe("群成员增加事件");
|
|
213
|
+
const GroupMemberDecreaseEvent = z.object({
|
|
214
|
+
event_type: z.literal("group_member_decrease"),
|
|
215
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
216
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
217
|
+
data: z.object({
|
|
218
|
+
group_id: zUin.describe("群号"),
|
|
219
|
+
user_id: zUin.describe("发生变更的用户 QQ 号"),
|
|
220
|
+
operator_id: z.number().int().nonnegative().nullish().describe("管理员 QQ 号,如果是管理员踢出")
|
|
221
|
+
})
|
|
222
|
+
}).describe("群成员减少事件");
|
|
223
|
+
const GroupDisbandEvent = z.object({
|
|
224
|
+
event_type: z.literal("group_disband"),
|
|
225
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
226
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
227
|
+
data: z.object({
|
|
228
|
+
group_id: zUin.describe("群号"),
|
|
229
|
+
operator_id: zUin.describe("操作者 QQ 号")
|
|
230
|
+
})
|
|
231
|
+
}).describe("群解散事件");
|
|
232
|
+
const GroupNameChangeEvent = z.object({
|
|
233
|
+
event_type: z.literal("group_name_change"),
|
|
234
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
235
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
236
|
+
data: z.object({
|
|
237
|
+
group_id: zUin.describe("群号"),
|
|
238
|
+
new_group_name: z.string().describe("新的群名称"),
|
|
239
|
+
operator_id: zUin.describe("操作者 QQ 号")
|
|
240
|
+
})
|
|
241
|
+
}).describe("群名称变更事件");
|
|
242
|
+
const GroupMessageReactionEvent = z.object({
|
|
243
|
+
event_type: z.literal("group_message_reaction"),
|
|
244
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
245
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
246
|
+
data: z.object({
|
|
247
|
+
group_id: zUin.describe("群号"),
|
|
248
|
+
user_id: zUin.describe("发送回应者 QQ 号"),
|
|
249
|
+
message_seq: z.number().int().nonnegative().describe("消息序列号"),
|
|
250
|
+
face_id: z.string().describe("表情 ID"),
|
|
251
|
+
reaction_type: z.enum(["face", "emoji"]).describe("收到的回应类型"),
|
|
252
|
+
is_add: z.boolean().describe("是否为添加,`false` 表示取消回应")
|
|
253
|
+
})
|
|
254
|
+
}).describe("群消息表情回应事件");
|
|
255
|
+
const GroupMuteEvent = z.object({
|
|
256
|
+
event_type: z.literal("group_mute"),
|
|
257
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
258
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
259
|
+
data: z.object({
|
|
260
|
+
group_id: zUin.describe("群号"),
|
|
261
|
+
user_id: zUin.describe("发生变更的用户 QQ 号"),
|
|
262
|
+
operator_id: zUin.describe("操作者 QQ 号"),
|
|
263
|
+
duration: z.number().int().nonnegative().describe("禁言时长(秒),为 0 表示取消禁言")
|
|
264
|
+
})
|
|
265
|
+
}).describe("群禁言事件");
|
|
266
|
+
const GroupWholeMuteEvent = z.object({
|
|
267
|
+
event_type: z.literal("group_whole_mute"),
|
|
268
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
269
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
270
|
+
data: z.object({
|
|
271
|
+
group_id: zUin.describe("群号"),
|
|
272
|
+
operator_id: zUin.describe("操作者 QQ 号"),
|
|
273
|
+
is_mute: z.boolean().describe("是否全员禁言,`false` 表示取消全员禁言")
|
|
274
|
+
})
|
|
275
|
+
}).describe("群全体禁言事件");
|
|
276
|
+
const GroupNudgeEvent = z.object({
|
|
277
|
+
event_type: z.literal("group_nudge"),
|
|
278
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
279
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
280
|
+
data: z.object({
|
|
281
|
+
group_id: zUin.describe("群号"),
|
|
282
|
+
sender_id: zUin.describe("发送者 QQ 号"),
|
|
283
|
+
receiver_id: zUin.describe("接收者 QQ 号"),
|
|
284
|
+
display_action: z.string().describe("戳一戳提示的动作文本"),
|
|
285
|
+
display_suffix: z.string().describe("戳一戳提示的后缀文本"),
|
|
286
|
+
display_action_img_url: z.string().describe("戳一戳提示的动作图片 URL,用于取代动作提示文本")
|
|
287
|
+
})
|
|
288
|
+
}).describe("群戳一戳事件");
|
|
289
|
+
const GroupFileUploadEvent = z.object({
|
|
290
|
+
event_type: z.literal("group_file_upload"),
|
|
291
|
+
time: z.number().int().nonnegative().describe("事件 Unix 时间戳(秒)"),
|
|
292
|
+
self_id: zUin.describe("机器人 QQ 号"),
|
|
293
|
+
data: z.object({
|
|
294
|
+
group_id: zUin.describe("群号"),
|
|
295
|
+
user_id: zUin.describe("发送者 QQ 号"),
|
|
296
|
+
file_id: z.string().describe("文件 ID"),
|
|
297
|
+
file_name: z.string().describe("文件名称"),
|
|
298
|
+
file_size: z.number().int().nonnegative().describe("文件大小(字节)")
|
|
299
|
+
})
|
|
300
|
+
}).describe("群文件上传事件");
|
|
301
|
+
z.discriminatedUnion("event_type", [
|
|
302
|
+
BotOfflineEvent,
|
|
303
|
+
MessageReceiveEvent,
|
|
304
|
+
MessageRecallEvent,
|
|
305
|
+
PeerPinChangeEvent,
|
|
306
|
+
FriendRequestEvent,
|
|
307
|
+
GroupJoinRequestEvent,
|
|
308
|
+
GroupInvitedJoinRequestEvent,
|
|
309
|
+
GroupInvitationEvent,
|
|
310
|
+
FriendNudgeEvent,
|
|
311
|
+
FriendFileUploadEvent,
|
|
312
|
+
GroupAdminChangeEvent,
|
|
313
|
+
GroupEssenceMessageChangeEvent,
|
|
314
|
+
GroupMemberIncreaseEvent,
|
|
315
|
+
GroupMemberDecreaseEvent,
|
|
316
|
+
GroupDisbandEvent,
|
|
317
|
+
GroupNameChangeEvent,
|
|
318
|
+
GroupMessageReactionEvent,
|
|
319
|
+
GroupMuteEvent,
|
|
320
|
+
GroupWholeMuteEvent,
|
|
321
|
+
GroupNudgeEvent,
|
|
322
|
+
GroupFileUploadEvent
|
|
323
|
+
]).describe("事件");
|
|
324
|
+
const FriendEntity = z.object({
|
|
325
|
+
user_id: zUin.describe("用户 QQ 号"),
|
|
326
|
+
nickname: z.string().describe("用户昵称"),
|
|
327
|
+
sex: z.enum([
|
|
328
|
+
"male",
|
|
329
|
+
"female",
|
|
330
|
+
"unknown"
|
|
331
|
+
]).describe("用户性别"),
|
|
332
|
+
qid: z.string().describe("用户 QID"),
|
|
333
|
+
remark: z.string().describe("好友备注"),
|
|
334
|
+
category: z.lazy(() => FriendCategoryEntity).describe("好友分组")
|
|
335
|
+
}).describe("好友实体");
|
|
336
|
+
const FriendCategoryEntity = z.object({
|
|
337
|
+
category_id: z.number().int().nonnegative().describe("好友分组 ID"),
|
|
338
|
+
category_name: z.string().describe("好友分组名称")
|
|
339
|
+
}).describe("好友分组实体");
|
|
340
|
+
const GroupEntity = z.object({
|
|
341
|
+
group_id: zUin.describe("群号"),
|
|
342
|
+
group_name: z.string().describe("群名称"),
|
|
343
|
+
member_count: z.number().int().nonnegative().describe("群成员数量"),
|
|
344
|
+
max_member_count: z.number().int().nonnegative().describe("群容量"),
|
|
345
|
+
remark: z.string().describe("群备注"),
|
|
346
|
+
created_time: z.number().int().nonnegative().describe("群创建时间,Unix 时间戳(秒)"),
|
|
347
|
+
description: z.string().describe("群简介"),
|
|
348
|
+
question: z.string().describe("加群验证问题"),
|
|
349
|
+
announcement: z.string().describe("群公告预览")
|
|
350
|
+
}).describe("群实体");
|
|
351
|
+
const GroupMemberEntity = z.object({
|
|
352
|
+
user_id: zUin.describe("用户 QQ 号"),
|
|
353
|
+
nickname: z.string().describe("用户昵称"),
|
|
354
|
+
sex: z.enum([
|
|
355
|
+
"male",
|
|
356
|
+
"female",
|
|
357
|
+
"unknown"
|
|
358
|
+
]).describe("用户性别"),
|
|
359
|
+
group_id: zUin.describe("群号"),
|
|
360
|
+
card: z.string().describe("成员备注"),
|
|
361
|
+
title: z.string().describe("专属头衔"),
|
|
362
|
+
level: z.number().int().nonnegative().describe("群等级,注意和 QQ 等级区分"),
|
|
363
|
+
role: z.enum([
|
|
364
|
+
"owner",
|
|
365
|
+
"admin",
|
|
366
|
+
"member"
|
|
367
|
+
]).describe("权限等级"),
|
|
368
|
+
join_time: z.number().int().nonnegative().describe("入群时间,Unix 时间戳(秒)"),
|
|
369
|
+
last_sent_time: z.number().int().nonnegative().describe("最后发言时间,Unix 时间戳(秒)"),
|
|
370
|
+
shut_up_end_time: z.number().int().nonnegative().nullish().describe("禁言结束时间,Unix 时间戳(秒)")
|
|
371
|
+
}).describe("群成员实体");
|
|
372
|
+
const GroupAnnouncementEntity = z.object({
|
|
373
|
+
group_id: zUin.describe("群号"),
|
|
374
|
+
announcement_id: z.string().describe("公告 ID"),
|
|
375
|
+
user_id: zUin.describe("发送者 QQ 号"),
|
|
376
|
+
time: z.number().int().nonnegative().describe("Unix 时间戳(秒)"),
|
|
377
|
+
content: z.string().describe("公告内容"),
|
|
378
|
+
image_url: z.string().nullish().describe("公告图片 URL")
|
|
379
|
+
}).describe("群公告实体");
|
|
380
|
+
const GroupFileEntity = z.object({
|
|
381
|
+
group_id: zUin.describe("群号"),
|
|
382
|
+
file_id: z.string().describe("文件 ID"),
|
|
383
|
+
file_name: z.string().describe("文件名称"),
|
|
384
|
+
parent_folder_id: z.string().describe("父文件夹 ID"),
|
|
385
|
+
file_size: z.number().int().nonnegative().describe("文件大小(字节)"),
|
|
386
|
+
uploaded_time: z.number().int().nonnegative().describe("上传时的 Unix 时间戳(秒)"),
|
|
387
|
+
expire_time: z.number().int().nonnegative().nullish().describe("过期时的 Unix 时间戳(秒)"),
|
|
388
|
+
uploader_id: zUin.describe("上传者 QQ 号"),
|
|
389
|
+
downloaded_times: z.number().int().nonnegative().describe("下载次数")
|
|
390
|
+
}).describe("群文件实体");
|
|
391
|
+
const GroupFolderEntity = z.object({
|
|
392
|
+
group_id: zUin.describe("群号"),
|
|
393
|
+
folder_id: z.string().describe("文件夹 ID"),
|
|
394
|
+
parent_folder_id: z.string().describe("父文件夹 ID"),
|
|
395
|
+
folder_name: z.string().describe("文件夹名称"),
|
|
396
|
+
created_time: z.number().int().nonnegative().describe("创建时的 Unix 时间戳(秒)"),
|
|
397
|
+
last_modified_time: z.number().int().nonnegative().describe("最后修改时的 Unix 时间戳(秒)"),
|
|
398
|
+
creator_id: zUin.describe("创建者 QQ 号"),
|
|
399
|
+
file_count: z.number().int().nonnegative().describe("文件数量")
|
|
400
|
+
}).describe("群文件夹实体");
|
|
401
|
+
const FriendRequest = z.object({
|
|
402
|
+
time: z.number().int().nonnegative().describe("请求发起时的 Unix 时间戳(秒)"),
|
|
403
|
+
initiator_id: zUin.describe("请求发起者 QQ 号"),
|
|
404
|
+
initiator_uid: z.string().describe("请求发起者 UID"),
|
|
405
|
+
target_user_id: zUin.describe("目标用户 QQ 号"),
|
|
406
|
+
target_user_uid: z.string().describe("目标用户 UID"),
|
|
407
|
+
state: z.enum([
|
|
408
|
+
"pending",
|
|
409
|
+
"accepted",
|
|
410
|
+
"rejected",
|
|
411
|
+
"ignored"
|
|
412
|
+
]).describe("请求状态"),
|
|
413
|
+
comment: z.string().describe("申请附加信息"),
|
|
414
|
+
via: z.string().describe("申请来源"),
|
|
415
|
+
is_filtered: z.boolean().describe("请求是否被过滤(发起自风险账户)")
|
|
416
|
+
}).describe("好友请求实体");
|
|
417
|
+
const GroupJoinRequestNotification = z.object({
|
|
418
|
+
type: z.literal("join_request"),
|
|
419
|
+
group_id: zUin.describe("群号"),
|
|
420
|
+
notification_seq: z.number().int().nonnegative().describe("通知序列号"),
|
|
421
|
+
is_filtered: z.boolean().describe("请求是否被过滤(发起自风险账户)"),
|
|
422
|
+
initiator_id: zUin.describe("发起者 QQ 号"),
|
|
423
|
+
state: z.enum([
|
|
424
|
+
"pending",
|
|
425
|
+
"accepted",
|
|
426
|
+
"rejected",
|
|
427
|
+
"ignored"
|
|
428
|
+
]).describe("请求状态"),
|
|
429
|
+
operator_id: z.number().int().nonnegative().nullish().describe("处理请求的管理员 QQ 号"),
|
|
430
|
+
comment: z.string().describe("入群请求附加信息")
|
|
431
|
+
}).describe("用户入群请求");
|
|
432
|
+
const GroupAdminChangeNotification = z.object({
|
|
433
|
+
type: z.literal("admin_change"),
|
|
434
|
+
group_id: zUin.describe("群号"),
|
|
435
|
+
notification_seq: z.number().int().nonnegative().describe("通知序列号"),
|
|
436
|
+
target_user_id: zUin.describe("被设置/取消用户 QQ 号"),
|
|
437
|
+
is_set: z.boolean().describe("是否被设置为管理员,`false` 表示被取消管理员"),
|
|
438
|
+
operator_id: zUin.describe("操作者(群主)QQ 号")
|
|
439
|
+
}).describe("群管理员变更通知");
|
|
440
|
+
const GroupKickNotification = z.object({
|
|
441
|
+
type: z.literal("kick"),
|
|
442
|
+
group_id: zUin.describe("群号"),
|
|
443
|
+
notification_seq: z.number().int().nonnegative().describe("通知序列号"),
|
|
444
|
+
target_user_id: zUin.describe("被移除用户 QQ 号"),
|
|
445
|
+
operator_id: zUin.describe("移除用户的管理员 QQ 号")
|
|
446
|
+
}).describe("群成员被移除通知");
|
|
447
|
+
const GroupQuitNotification = z.object({
|
|
448
|
+
type: z.literal("quit"),
|
|
449
|
+
group_id: zUin.describe("群号"),
|
|
450
|
+
notification_seq: z.number().int().nonnegative().describe("通知序列号"),
|
|
451
|
+
target_user_id: zUin.describe("退群用户 QQ 号")
|
|
452
|
+
}).describe("群成员退群通知");
|
|
453
|
+
const GroupInvitedJoinRequestNotification = z.object({
|
|
454
|
+
type: z.literal("invited_join_request"),
|
|
455
|
+
group_id: zUin.describe("群号"),
|
|
456
|
+
notification_seq: z.number().int().nonnegative().describe("通知序列号"),
|
|
457
|
+
initiator_id: zUin.describe("邀请者 QQ 号"),
|
|
458
|
+
target_user_id: zUin.describe("被邀请用户 QQ 号"),
|
|
459
|
+
state: z.enum([
|
|
460
|
+
"pending",
|
|
461
|
+
"accepted",
|
|
462
|
+
"rejected",
|
|
463
|
+
"ignored"
|
|
464
|
+
]).describe("请求状态"),
|
|
465
|
+
operator_id: z.number().int().nonnegative().nullish().describe("处理请求的管理员 QQ 号")
|
|
466
|
+
}).describe("群成员邀请他人入群请求");
|
|
467
|
+
const GroupNotification = z.discriminatedUnion("type", [
|
|
468
|
+
GroupJoinRequestNotification,
|
|
469
|
+
GroupAdminChangeNotification,
|
|
470
|
+
GroupKickNotification,
|
|
471
|
+
GroupQuitNotification,
|
|
472
|
+
GroupInvitedJoinRequestNotification
|
|
473
|
+
]).describe("群通知实体");
|
|
474
|
+
const IncomingFriendMessage = z.object({
|
|
475
|
+
message_scene: z.literal("friend"),
|
|
476
|
+
peer_id: zUin.describe("好友 QQ 号或群号"),
|
|
477
|
+
message_seq: z.number().int().nonnegative().describe("消息序列号"),
|
|
478
|
+
sender_id: zUin.describe("发送者 QQ 号"),
|
|
479
|
+
time: z.number().int().nonnegative().describe("消息 Unix 时间戳(秒)"),
|
|
480
|
+
segments: z.array(z.lazy(() => IncomingSegment)).describe("消息段列表"),
|
|
481
|
+
friend: z.lazy(() => FriendEntity).describe("好友信息")
|
|
482
|
+
}).describe("好友消息");
|
|
483
|
+
const IncomingGroupMessage = z.object({
|
|
484
|
+
message_scene: z.literal("group"),
|
|
485
|
+
peer_id: zUin.describe("好友 QQ 号或群号"),
|
|
486
|
+
message_seq: z.number().int().nonnegative().describe("消息序列号"),
|
|
487
|
+
sender_id: zUin.describe("发送者 QQ 号"),
|
|
488
|
+
time: z.number().int().nonnegative().describe("消息 Unix 时间戳(秒)"),
|
|
489
|
+
segments: z.array(z.lazy(() => IncomingSegment)).describe("消息段列表"),
|
|
490
|
+
group: z.lazy(() => GroupEntity).describe("群信息"),
|
|
491
|
+
group_member: z.lazy(() => GroupMemberEntity).describe("群成员信息")
|
|
492
|
+
}).describe("群消息");
|
|
493
|
+
const IncomingTempMessage = z.object({
|
|
494
|
+
message_scene: z.literal("temp"),
|
|
495
|
+
peer_id: zUin.describe("好友 QQ 号或群号"),
|
|
496
|
+
message_seq: z.number().int().nonnegative().describe("消息序列号"),
|
|
497
|
+
sender_id: zUin.describe("发送者 QQ 号"),
|
|
498
|
+
time: z.number().int().nonnegative().describe("消息 Unix 时间戳(秒)"),
|
|
499
|
+
segments: z.array(z.lazy(() => IncomingSegment)).describe("消息段列表"),
|
|
500
|
+
group: z.lazy(() => GroupEntity).nullish().describe("临时会话发送者的所在的群信息")
|
|
501
|
+
}).describe("临时会话消息");
|
|
502
|
+
const IncomingMessage = z.discriminatedUnion("message_scene", [
|
|
503
|
+
IncomingFriendMessage,
|
|
504
|
+
IncomingGroupMessage,
|
|
505
|
+
IncomingTempMessage
|
|
506
|
+
]).describe("接收消息");
|
|
507
|
+
const IncomingForwardedMessage = z.object({
|
|
508
|
+
message_seq: z.number().int().nonnegative().describe("消息序列号"),
|
|
509
|
+
sender_name: z.string().describe("发送者名称"),
|
|
510
|
+
avatar_url: z.string().describe("发送者头像 URL"),
|
|
511
|
+
time: z.number().int().nonnegative().describe("消息 Unix 时间戳(秒)"),
|
|
512
|
+
segments: z.array(z.lazy(() => IncomingSegment)).describe("消息段列表")
|
|
513
|
+
}).describe("接收转发消息");
|
|
514
|
+
const GroupEssenceMessage = z.object({
|
|
515
|
+
group_id: zUin.describe("群号"),
|
|
516
|
+
message_seq: z.number().int().nonnegative().describe("消息序列号"),
|
|
517
|
+
message_time: z.number().int().nonnegative().describe("消息发送时的 Unix 时间戳(秒)"),
|
|
518
|
+
sender_id: zUin.describe("发送者 QQ 号"),
|
|
519
|
+
sender_name: z.string().describe("发送者名称"),
|
|
520
|
+
operator_id: zUin.describe("设置精华的操作者 QQ 号"),
|
|
521
|
+
operator_name: z.string().describe("设置精华的操作者名称"),
|
|
522
|
+
operation_time: z.number().int().nonnegative().describe("消息被设置精华时的 Unix 时间戳(秒)"),
|
|
523
|
+
segments: z.array(z.lazy(() => IncomingSegment)).describe("消息段列表")
|
|
524
|
+
}).describe("群精华消息");
|
|
525
|
+
const IncomingTextSegment = z.object({
|
|
526
|
+
type: z.literal("text"),
|
|
527
|
+
data: z.object({ text: z.string().describe("文本内容") })
|
|
528
|
+
}).describe("文本消息段");
|
|
529
|
+
const IncomingMentionSegment = z.object({
|
|
530
|
+
type: z.literal("mention"),
|
|
531
|
+
data: z.object({
|
|
532
|
+
user_id: zUin.describe("提及的 QQ 号"),
|
|
533
|
+
name: z.string().describe("去掉 `@` 前缀的提及的名称")
|
|
534
|
+
})
|
|
535
|
+
}).describe("提及消息段");
|
|
536
|
+
const IncomingMentionAllSegment = z.object({
|
|
537
|
+
type: z.literal("mention_all"),
|
|
538
|
+
data: z.object({})
|
|
539
|
+
}).describe("提及全体消息段");
|
|
540
|
+
const IncomingFaceSegment = z.object({
|
|
541
|
+
type: z.literal("face"),
|
|
542
|
+
data: z.object({
|
|
543
|
+
face_id: z.string().describe("表情 ID"),
|
|
544
|
+
is_large: z.boolean().describe("是否为超级表情")
|
|
545
|
+
})
|
|
546
|
+
}).describe("表情消息段");
|
|
547
|
+
const IncomingReplySegment = z.object({
|
|
548
|
+
type: z.literal("reply"),
|
|
549
|
+
data: z.object({
|
|
550
|
+
message_seq: z.number().int().nonnegative().describe("被引用的消息序列号"),
|
|
551
|
+
sender_id: zUin.describe("被引用的消息发送者 QQ 号"),
|
|
552
|
+
sender_name: z.string().nullish().describe("被引用的消息发送者名称,仅在合并转发中能够获取"),
|
|
553
|
+
time: z.number().int().nonnegative().describe("被引用的消息的 Unix 时间戳(秒)"),
|
|
554
|
+
get segments() {
|
|
555
|
+
return z.array(IncomingSegment).describe("回复消息内容");
|
|
556
|
+
}
|
|
557
|
+
})
|
|
558
|
+
}).describe("回复消息段");
|
|
559
|
+
const IncomingImageSegment = z.object({
|
|
560
|
+
type: z.literal("image"),
|
|
561
|
+
data: z.object({
|
|
562
|
+
resource_id: z.string().describe("资源 ID"),
|
|
563
|
+
temp_url: z.string().describe("临时 URL"),
|
|
564
|
+
width: z.number().int().nonnegative().describe("图片宽度"),
|
|
565
|
+
height: z.number().int().nonnegative().describe("图片高度"),
|
|
566
|
+
summary: z.string().describe("图片预览文本"),
|
|
567
|
+
sub_type: z.enum(["normal", "sticker"]).describe("图片类型")
|
|
568
|
+
})
|
|
569
|
+
}).describe("图片消息段");
|
|
570
|
+
const IncomingRecordSegment = z.object({
|
|
571
|
+
type: z.literal("record"),
|
|
572
|
+
data: z.object({
|
|
573
|
+
resource_id: z.string().describe("资源 ID"),
|
|
574
|
+
temp_url: z.string().describe("临时 URL"),
|
|
575
|
+
duration: z.number().int().nonnegative().describe("语音时长(秒)")
|
|
576
|
+
})
|
|
577
|
+
}).describe("语音消息段");
|
|
578
|
+
const IncomingVideoSegment = z.object({
|
|
579
|
+
type: z.literal("video"),
|
|
580
|
+
data: z.object({
|
|
581
|
+
resource_id: z.string().describe("资源 ID"),
|
|
582
|
+
temp_url: z.string().describe("临时 URL"),
|
|
583
|
+
width: z.number().int().nonnegative().describe("视频宽度"),
|
|
584
|
+
height: z.number().int().nonnegative().describe("视频高度"),
|
|
585
|
+
duration: z.number().int().nonnegative().describe("视频时长(秒)")
|
|
586
|
+
})
|
|
587
|
+
}).describe("视频消息段");
|
|
588
|
+
const IncomingFileSegment = z.object({
|
|
589
|
+
type: z.literal("file"),
|
|
590
|
+
data: z.object({
|
|
591
|
+
file_id: z.string().describe("文件 ID"),
|
|
592
|
+
file_name: z.string().describe("文件名称"),
|
|
593
|
+
file_size: z.number().int().nonnegative().describe("文件大小(字节)"),
|
|
594
|
+
file_hash: z.string().nullish().describe("文件的 TriSHA1 哈希值,仅在私聊文件中存在")
|
|
595
|
+
})
|
|
596
|
+
}).describe("文件消息段");
|
|
597
|
+
const IncomingForwardSegment = z.object({
|
|
598
|
+
type: z.literal("forward"),
|
|
599
|
+
data: z.object({
|
|
600
|
+
forward_id: z.string().describe("合并转发 ID"),
|
|
601
|
+
title: z.string().describe("合并转发标题"),
|
|
602
|
+
preview: z.array(z.string()).describe("合并转发预览文本"),
|
|
603
|
+
summary: z.string().describe("合并转发摘要")
|
|
604
|
+
})
|
|
605
|
+
}).describe("合并转发消息段");
|
|
606
|
+
const IncomingMarketFaceSegment = z.object({
|
|
607
|
+
type: z.literal("market_face"),
|
|
608
|
+
data: z.object({
|
|
609
|
+
emoji_package_id: z.number().int().nonnegative().describe("市场表情包 ID"),
|
|
610
|
+
emoji_id: z.string().describe("市场表情 ID"),
|
|
611
|
+
key: z.string().describe("市场表情 Key"),
|
|
612
|
+
summary: z.string().describe("市场表情预览文本"),
|
|
613
|
+
url: z.string().describe("市场表情 URL")
|
|
614
|
+
})
|
|
615
|
+
}).describe("市场表情消息段");
|
|
616
|
+
const IncomingLightAppSegment = z.object({
|
|
617
|
+
type: z.literal("light_app"),
|
|
618
|
+
data: z.object({
|
|
619
|
+
app_name: z.string().describe("小程序名称"),
|
|
620
|
+
json_payload: z.string().describe("小程序 JSON 数据")
|
|
621
|
+
})
|
|
622
|
+
}).describe("小程序消息段");
|
|
623
|
+
const IncomingXmlSegment = z.object({
|
|
624
|
+
type: z.literal("xml"),
|
|
625
|
+
data: z.object({
|
|
626
|
+
service_id: z.number().int().nonnegative().describe("服务 ID"),
|
|
627
|
+
xml_payload: z.string().describe("XML 数据")
|
|
628
|
+
})
|
|
629
|
+
}).describe("XML 消息段");
|
|
630
|
+
const IncomingMarkdownSegment = z.object({
|
|
631
|
+
type: z.literal("markdown"),
|
|
632
|
+
data: z.object({ content: z.string().describe("Markdown 内容") })
|
|
633
|
+
}).describe("Markdown 消息段");
|
|
634
|
+
const IncomingSegment = z.discriminatedUnion("type", [
|
|
635
|
+
IncomingTextSegment,
|
|
636
|
+
IncomingMentionSegment,
|
|
637
|
+
IncomingMentionAllSegment,
|
|
638
|
+
IncomingFaceSegment,
|
|
639
|
+
IncomingReplySegment,
|
|
640
|
+
IncomingImageSegment,
|
|
641
|
+
IncomingRecordSegment,
|
|
642
|
+
IncomingVideoSegment,
|
|
643
|
+
IncomingFileSegment,
|
|
644
|
+
IncomingForwardSegment,
|
|
645
|
+
IncomingMarketFaceSegment,
|
|
646
|
+
IncomingLightAppSegment,
|
|
647
|
+
IncomingXmlSegment,
|
|
648
|
+
IncomingMarkdownSegment
|
|
649
|
+
]).catch({
|
|
650
|
+
type: "text",
|
|
651
|
+
data: { text: "[unknown]" }
|
|
652
|
+
}).describe("接收消息段");
|
|
653
|
+
const OutgoingForwardedMessage = z.object({
|
|
654
|
+
user_id: zUin.describe("发送者 QQ 号"),
|
|
655
|
+
sender_name: z.string().describe("发送者名称"),
|
|
656
|
+
time: z.number().int().nonnegative().nullish().describe("消息 Unix 时间戳(秒)"),
|
|
657
|
+
segments: z.array(z.lazy(() => OutgoingSegment)).describe("消息段列表")
|
|
658
|
+
}).describe("发送转发消息");
|
|
659
|
+
const OutgoingTextSegment = z.object({
|
|
660
|
+
type: z.literal("text"),
|
|
661
|
+
data: z.object({ text: z.string().describe("文本内容") })
|
|
662
|
+
}).describe("文本消息段");
|
|
663
|
+
const OutgoingMentionSegment = z.object({
|
|
664
|
+
type: z.literal("mention"),
|
|
665
|
+
data: z.object({ user_id: zUin.describe("提及的 QQ 号") })
|
|
666
|
+
}).describe("提及消息段");
|
|
667
|
+
const OutgoingMentionAllSegment = z.object({
|
|
668
|
+
type: z.literal("mention_all"),
|
|
669
|
+
data: z.object({})
|
|
670
|
+
}).describe("提及全体消息段");
|
|
671
|
+
const OutgoingFaceSegment = z.object({
|
|
672
|
+
type: z.literal("face"),
|
|
673
|
+
data: z.object({
|
|
674
|
+
face_id: z.string().describe("表情 ID"),
|
|
675
|
+
is_large: z.boolean().nullish().default(false).transform((val) => val ?? false).describe("是否为超级表情")
|
|
676
|
+
})
|
|
677
|
+
}).describe("表情消息段");
|
|
678
|
+
const OutgoingReplySegment = z.object({
|
|
679
|
+
type: z.literal("reply"),
|
|
680
|
+
data: z.object({ message_seq: z.number().int().nonnegative().describe("被引用的消息序列号") })
|
|
681
|
+
}).describe("回复消息段");
|
|
682
|
+
const OutgoingImageSegment = z.object({
|
|
683
|
+
type: z.literal("image"),
|
|
684
|
+
data: z.object({
|
|
685
|
+
uri: z.string().describe("文件 URI,支持 `file://` `http(s)://` `base64://` 三种格式"),
|
|
686
|
+
sub_type: z.enum(["normal", "sticker"]).nullish().default("normal").transform((val) => val ?? "normal").describe("图片类型"),
|
|
687
|
+
summary: z.string().nullish().describe("图片预览文本")
|
|
688
|
+
})
|
|
689
|
+
}).describe("图片消息段");
|
|
690
|
+
const OutgoingRecordSegment = z.object({
|
|
691
|
+
type: z.literal("record"),
|
|
692
|
+
data: z.object({ uri: z.string().describe("文件 URI,支持 `file://` `http(s)://` `base64://` 三种格式") })
|
|
693
|
+
}).describe("语音消息段");
|
|
694
|
+
const OutgoingVideoSegment = z.object({
|
|
695
|
+
type: z.literal("video"),
|
|
696
|
+
data: z.object({
|
|
697
|
+
uri: z.string().describe("文件 URI,支持 `file://` `http(s)://` `base64://` 三种格式"),
|
|
698
|
+
thumb_uri: z.string().nullish().describe("封面图片 URI")
|
|
699
|
+
})
|
|
700
|
+
}).describe("视频消息段");
|
|
701
|
+
const OutgoingForwardSegment = z.object({
|
|
702
|
+
type: z.literal("forward"),
|
|
703
|
+
data: z.object({
|
|
704
|
+
get messages() {
|
|
705
|
+
return z.array(OutgoingForwardedMessage).describe("转发消息内容");
|
|
706
|
+
},
|
|
707
|
+
title: z.string().nullish().describe("合并转发标题"),
|
|
708
|
+
preview: z.array(z.string()).nullish().describe("合并转发预览文本,若提供,至少 1 条,至多 4 条"),
|
|
709
|
+
summary: z.string().nullish().describe("合并转发摘要"),
|
|
710
|
+
prompt: z.string().nullish().describe("合并转发的预览外显文本,仅对移动端 QQ 有效")
|
|
711
|
+
})
|
|
712
|
+
}).describe("合并转发消息段");
|
|
713
|
+
const OutgoingLightAppSegment = z.object({
|
|
714
|
+
type: z.literal("light_app"),
|
|
715
|
+
data: z.object({ json_payload: z.string().describe("小程序 JSON 数据") })
|
|
716
|
+
}).describe("小程序消息段");
|
|
717
|
+
const OutgoingSegment = z.discriminatedUnion("type", [
|
|
718
|
+
OutgoingTextSegment,
|
|
719
|
+
OutgoingMentionSegment,
|
|
720
|
+
OutgoingMentionAllSegment,
|
|
721
|
+
OutgoingFaceSegment,
|
|
722
|
+
OutgoingReplySegment,
|
|
723
|
+
OutgoingImageSegment,
|
|
724
|
+
OutgoingRecordSegment,
|
|
725
|
+
OutgoingVideoSegment,
|
|
726
|
+
OutgoingForwardSegment,
|
|
727
|
+
OutgoingLightAppSegment
|
|
728
|
+
]).describe("发送消息段");
|
|
729
|
+
const GetLoginInfoOutput = z.object({
|
|
730
|
+
uin: zUin.describe("登录 QQ 号"),
|
|
731
|
+
nickname: z.string().describe("登录昵称")
|
|
732
|
+
}).describe("get_login_info 响应数据");
|
|
733
|
+
const GetImplInfoOutput = z.object({
|
|
734
|
+
impl_name: z.string().describe("协议端名称"),
|
|
735
|
+
impl_version: z.string().describe("协议端版本"),
|
|
736
|
+
qq_protocol_version: z.string().describe("协议端使用的 QQ 协议版本"),
|
|
737
|
+
qq_protocol_type: z.enum([
|
|
738
|
+
"windows",
|
|
739
|
+
"linux",
|
|
740
|
+
"macos",
|
|
741
|
+
"android_pad",
|
|
742
|
+
"android_phone",
|
|
743
|
+
"ipad",
|
|
744
|
+
"iphone",
|
|
745
|
+
"harmony",
|
|
746
|
+
"watch"
|
|
747
|
+
]).describe("协议端使用的 QQ 协议平台"),
|
|
748
|
+
milky_version: z.string().describe("协议端实现的 Milky 协议版本,目前为 \"1.3\"")
|
|
749
|
+
}).describe("get_impl_info 响应数据");
|
|
750
|
+
const GetUserProfileInput = z.object({ user_id: zUin.describe("用户 QQ 号") }).describe("get_user_profile 请求参数");
|
|
751
|
+
const GetUserProfileOutput = z.object({
|
|
752
|
+
nickname: z.string().describe("昵称"),
|
|
753
|
+
qid: z.string().describe("QID"),
|
|
754
|
+
age: z.number().int().nonnegative().describe("年龄"),
|
|
755
|
+
sex: z.enum([
|
|
756
|
+
"male",
|
|
757
|
+
"female",
|
|
758
|
+
"unknown"
|
|
759
|
+
]).describe("性别"),
|
|
760
|
+
remark: z.string().describe("备注"),
|
|
761
|
+
bio: z.string().describe("个性签名"),
|
|
762
|
+
level: z.number().int().nonnegative().describe("QQ 等级"),
|
|
763
|
+
country: z.string().describe("国家或地区"),
|
|
764
|
+
city: z.string().describe("城市"),
|
|
765
|
+
school: z.string().describe("学校")
|
|
766
|
+
}).describe("get_user_profile 响应数据");
|
|
767
|
+
const GetFriendListInput = z.object({ no_cache: z.boolean().nullish().default(false).transform((val) => val ?? false).describe("是否强制不使用缓存") }).describe("get_friend_list 请求参数");
|
|
768
|
+
const GetFriendListOutput = z.object({ friends: z.array(z.lazy(() => FriendEntity)).describe("好友列表") }).describe("get_friend_list 响应数据");
|
|
769
|
+
const GetFriendInfoInput = z.object({
|
|
770
|
+
user_id: zUin.describe("好友 QQ 号"),
|
|
771
|
+
no_cache: z.boolean().nullish().default(false).transform((val) => val ?? false).describe("是否强制不使用缓存")
|
|
772
|
+
}).describe("get_friend_info 请求参数");
|
|
773
|
+
const GetFriendInfoOutput = z.object({ friend: z.lazy(() => FriendEntity).describe("好友信息") }).describe("get_friend_info 响应数据");
|
|
774
|
+
const GetGroupListInput = z.object({ no_cache: z.boolean().nullish().default(false).transform((val) => val ?? false).describe("是否强制不使用缓存") }).describe("get_group_list 请求参数");
|
|
775
|
+
const GetGroupListOutput = z.object({ groups: z.array(z.lazy(() => GroupEntity)).describe("群列表") }).describe("get_group_list 响应数据");
|
|
776
|
+
const GetGroupInfoInput = z.object({
|
|
777
|
+
group_id: zUin.describe("群号"),
|
|
778
|
+
no_cache: z.boolean().nullish().default(false).transform((val) => val ?? false).describe("是否强制不使用缓存")
|
|
779
|
+
}).describe("get_group_info 请求参数");
|
|
780
|
+
const GetGroupInfoOutput = z.object({ group: z.lazy(() => GroupEntity).describe("群信息") }).describe("get_group_info 响应数据");
|
|
781
|
+
const GetGroupMemberListInput = z.object({
|
|
782
|
+
group_id: zUin.describe("群号"),
|
|
783
|
+
no_cache: z.boolean().nullish().default(false).transform((val) => val ?? false).describe("是否强制不使用缓存")
|
|
784
|
+
}).describe("get_group_member_list 请求参数");
|
|
785
|
+
const GetGroupMemberListOutput = z.object({ members: z.array(z.lazy(() => GroupMemberEntity)).describe("群成员列表") }).describe("get_group_member_list 响应数据");
|
|
786
|
+
const GetGroupMemberInfoInput = z.object({
|
|
787
|
+
group_id: zUin.describe("群号"),
|
|
788
|
+
user_id: zUin.describe("群成员 QQ 号"),
|
|
789
|
+
no_cache: z.boolean().nullish().default(false).transform((val) => val ?? false).describe("是否强制不使用缓存")
|
|
790
|
+
}).describe("get_group_member_info 请求参数");
|
|
791
|
+
const GetGroupMemberInfoOutput = z.object({ member: z.lazy(() => GroupMemberEntity).describe("群成员信息") }).describe("get_group_member_info 响应数据");
|
|
792
|
+
const GetPeerPinsOutput = z.object({
|
|
793
|
+
friends: z.array(z.lazy(() => FriendEntity)).describe("置顶的好友列表"),
|
|
794
|
+
groups: z.array(z.lazy(() => GroupEntity)).describe("置顶的群列表")
|
|
795
|
+
}).describe("get_peer_pins 响应数据");
|
|
796
|
+
const SetPeerPinInput = z.object({
|
|
797
|
+
message_scene: z.enum([
|
|
798
|
+
"friend",
|
|
799
|
+
"group",
|
|
800
|
+
"temp"
|
|
801
|
+
]).describe("要设置的会话的消息场景"),
|
|
802
|
+
peer_id: zUin.describe("要设置的好友 QQ 号或群号"),
|
|
803
|
+
is_pinned: z.boolean().nullish().default(true).transform((val) => val ?? true).describe("是否置顶, `false` 表示取消置顶")
|
|
804
|
+
}).describe("set_peer_pin 请求参数");
|
|
805
|
+
const SetAvatarInput = z.object({ uri: z.string().describe("头像文件 URI,支持 `file://` `http(s)://` `base64://` 三种格式") }).describe("set_avatar 请求参数");
|
|
806
|
+
const SetNicknameInput = z.object({ new_nickname: z.string().describe("新昵称") }).describe("set_nickname 请求参数");
|
|
807
|
+
const SetBioInput = z.object({ new_bio: z.string().describe("新个性签名") }).describe("set_bio 请求参数");
|
|
808
|
+
const GetCustomFaceUrlListOutput = z.object({ urls: z.array(z.string()).describe("自定义表情 URL 列表") }).describe("get_custom_face_url_list 响应数据");
|
|
809
|
+
const GetCookiesInput = z.object({ domain: z.string().describe("需要获取 Cookies 的域名") }).describe("get_cookies 请求参数");
|
|
810
|
+
const GetCookiesOutput = z.object({ cookies: z.string().describe("域名对应的 Cookies 字符串") }).describe("get_cookies 响应数据");
|
|
811
|
+
const GetCSRFTokenOutput = z.object({ csrf_token: z.string().describe("CSRF Token") }).describe("get_csrf_token 响应数据");
|
|
812
|
+
const SendPrivateMessageInput = z.object({
|
|
813
|
+
user_id: zUin.describe("好友 QQ 号"),
|
|
814
|
+
message: z.array(z.lazy(() => OutgoingSegment)).describe("消息内容")
|
|
815
|
+
}).describe("send_private_message 请求参数");
|
|
816
|
+
const SendPrivateMessageOutput = z.object({
|
|
817
|
+
message_seq: z.number().int().nonnegative().describe("消息序列号"),
|
|
818
|
+
time: z.number().int().nonnegative().describe("消息发送时间")
|
|
819
|
+
}).describe("send_private_message 响应数据");
|
|
820
|
+
const SendGroupMessageInput = z.object({
|
|
821
|
+
group_id: zUin.describe("群号"),
|
|
822
|
+
message: z.array(z.lazy(() => OutgoingSegment)).describe("消息内容")
|
|
823
|
+
}).describe("send_group_message 请求参数");
|
|
824
|
+
const SendGroupMessageOutput = z.object({
|
|
825
|
+
message_seq: z.number().int().nonnegative().describe("消息序列号"),
|
|
826
|
+
time: z.number().int().nonnegative().describe("消息发送时间")
|
|
827
|
+
}).describe("send_group_message 响应数据");
|
|
828
|
+
const RecallPrivateMessageInput = z.object({
|
|
829
|
+
user_id: zUin.describe("好友 QQ 号"),
|
|
830
|
+
message_seq: z.number().int().nonnegative().describe("消息序列号")
|
|
831
|
+
}).describe("recall_private_message 请求参数");
|
|
832
|
+
const RecallGroupMessageInput = z.object({
|
|
833
|
+
group_id: zUin.describe("群号"),
|
|
834
|
+
message_seq: z.number().int().nonnegative().describe("消息序列号")
|
|
835
|
+
}).describe("recall_group_message 请求参数");
|
|
836
|
+
const GetMessageInput = z.object({
|
|
837
|
+
message_scene: z.enum([
|
|
838
|
+
"friend",
|
|
839
|
+
"group",
|
|
840
|
+
"temp"
|
|
841
|
+
]).describe("消息场景"),
|
|
842
|
+
peer_id: zUin.describe("好友 QQ 号或群号"),
|
|
843
|
+
message_seq: z.number().int().nonnegative().describe("消息序列号")
|
|
844
|
+
}).describe("get_message 请求参数");
|
|
845
|
+
const GetMessageOutput = z.object({ message: z.lazy(() => IncomingMessage).describe("消息内容") }).describe("get_message 响应数据");
|
|
846
|
+
const GetHistoryMessagesInput = z.object({
|
|
847
|
+
message_scene: z.enum([
|
|
848
|
+
"friend",
|
|
849
|
+
"group",
|
|
850
|
+
"temp"
|
|
851
|
+
]).describe("消息场景"),
|
|
852
|
+
peer_id: zUin.describe("好友 QQ 号或群号"),
|
|
853
|
+
start_message_seq: z.number().int().nonnegative().nullish().describe("起始消息序列号,由此开始从新到旧查询,不提供则从最新消息开始"),
|
|
854
|
+
limit: z.number().int().nonnegative().nullish().default(20).transform((val) => val ?? 20).describe("期望获取到的消息数量,最多 30 条")
|
|
855
|
+
}).describe("get_history_messages 请求参数");
|
|
856
|
+
const GetHistoryMessagesOutput = z.object({
|
|
857
|
+
messages: z.array(z.lazy(() => IncomingMessage)).describe("获取到的消息(message_seq 升序排列),部分消息可能不存在,如撤回的消息"),
|
|
858
|
+
next_message_seq: z.number().int().nonnegative().nullish().describe("下一页起始消息序列号")
|
|
859
|
+
}).describe("get_history_messages 响应数据");
|
|
860
|
+
const GetResourceTempUrlInput = z.object({ resource_id: z.string().describe("资源 ID") }).describe("get_resource_temp_url 请求参数");
|
|
861
|
+
const GetResourceTempUrlOutput = z.object({ url: z.string().describe("临时资源链接") }).describe("get_resource_temp_url 响应数据");
|
|
862
|
+
const GetForwardedMessagesInput = z.object({ forward_id: z.string().describe("转发消息 ID") }).describe("get_forwarded_messages 请求参数");
|
|
863
|
+
const GetForwardedMessagesOutput = z.object({ messages: z.array(z.lazy(() => IncomingForwardedMessage)).describe("转发消息内容") }).describe("get_forwarded_messages 响应数据");
|
|
864
|
+
const MarkMessageAsReadInput = z.object({
|
|
865
|
+
message_scene: z.enum([
|
|
866
|
+
"friend",
|
|
867
|
+
"group",
|
|
868
|
+
"temp"
|
|
869
|
+
]).describe("消息场景"),
|
|
870
|
+
peer_id: zUin.describe("好友 QQ 号或群号"),
|
|
871
|
+
message_seq: z.number().int().nonnegative().describe("标为已读的消息序列号,该消息及更早的消息将被标记为已读")
|
|
872
|
+
}).describe("mark_message_as_read 请求参数");
|
|
873
|
+
const SendFriendNudgeInput = z.object({
|
|
874
|
+
user_id: zUin.describe("好友 QQ 号"),
|
|
875
|
+
is_self: z.boolean().nullish().default(false).transform((val) => val ?? false).describe("是否戳自己")
|
|
876
|
+
}).describe("send_friend_nudge 请求参数");
|
|
877
|
+
const SendProfileLikeInput = z.object({
|
|
878
|
+
user_id: zUin.describe("好友 QQ 号"),
|
|
879
|
+
count: z.number().int().nonnegative().nullish().default(1).transform((val) => val ?? 1).describe("点赞数量")
|
|
880
|
+
}).describe("send_profile_like 请求参数");
|
|
881
|
+
const DeleteFriendInput = z.object({ user_id: zUin.describe("好友 QQ 号") }).describe("delete_friend 请求参数");
|
|
882
|
+
const GetFriendRequestsInput = z.object({
|
|
883
|
+
limit: z.number().int().nonnegative().nullish().default(20).transform((val) => val ?? 20).describe("获取的最大请求数量"),
|
|
884
|
+
is_filtered: z.boolean().nullish().default(false).transform((val) => val ?? false).describe("`true` 表示只获取被过滤(由风险账号发起)的通知,`false` 表示只获取未被过滤的通知")
|
|
885
|
+
}).describe("get_friend_requests 请求参数");
|
|
886
|
+
const GetFriendRequestsOutput = z.object({ requests: z.array(z.lazy(() => FriendRequest)).describe("好友请求列表") }).describe("get_friend_requests 响应数据");
|
|
887
|
+
const AcceptFriendRequestInput = z.object({
|
|
888
|
+
initiator_uid: z.string().describe("请求发起者 UID"),
|
|
889
|
+
is_filtered: z.boolean().nullish().default(false).transform((val) => val ?? false).describe("是否是被过滤的请求")
|
|
890
|
+
}).describe("accept_friend_request 请求参数");
|
|
891
|
+
const RejectFriendRequestInput = z.object({
|
|
892
|
+
initiator_uid: z.string().describe("请求发起者 UID"),
|
|
893
|
+
is_filtered: z.boolean().nullish().default(false).transform((val) => val ?? false).describe("是否是被过滤的请求"),
|
|
894
|
+
reason: z.string().nullish().describe("拒绝理由")
|
|
895
|
+
}).describe("reject_friend_request 请求参数");
|
|
896
|
+
const SetGroupNameInput = z.object({
|
|
897
|
+
group_id: zUin.describe("群号"),
|
|
898
|
+
new_group_name: z.string().describe("新群名称")
|
|
899
|
+
}).describe("set_group_name 请求参数");
|
|
900
|
+
const SetGroupAvatarInput = z.object({
|
|
901
|
+
group_id: zUin.describe("群号"),
|
|
902
|
+
image_uri: z.string().describe("头像文件 URI,支持 `file://` `http(s)://` `base64://` 三种格式")
|
|
903
|
+
}).describe("set_group_avatar 请求参数");
|
|
904
|
+
const SetGroupMemberCardInput = z.object({
|
|
905
|
+
group_id: zUin.describe("群号"),
|
|
906
|
+
user_id: zUin.describe("被设置的群成员 QQ 号"),
|
|
907
|
+
card: z.string().describe("新群名片")
|
|
908
|
+
}).describe("set_group_member_card 请求参数");
|
|
909
|
+
const SetGroupMemberSpecialTitleInput = z.object({
|
|
910
|
+
group_id: zUin.describe("群号"),
|
|
911
|
+
user_id: zUin.describe("被设置的群成员 QQ 号"),
|
|
912
|
+
special_title: z.string().describe("新专属头衔")
|
|
913
|
+
}).describe("set_group_member_special_title 请求参数");
|
|
914
|
+
const SetGroupMemberAdminInput = z.object({
|
|
915
|
+
group_id: zUin.describe("群号"),
|
|
916
|
+
user_id: zUin.describe("被设置的 QQ 号"),
|
|
917
|
+
is_set: z.boolean().nullish().default(true).transform((val) => val ?? true).describe("是否设置为管理员,`false` 表示取消管理员")
|
|
918
|
+
}).describe("set_group_member_admin 请求参数");
|
|
919
|
+
const SetGroupMemberMuteInput = z.object({
|
|
920
|
+
group_id: zUin.describe("群号"),
|
|
921
|
+
user_id: zUin.describe("被设置的 QQ 号"),
|
|
922
|
+
duration: z.number().int().nonnegative().nullish().default(0).transform((val) => val ?? 0).describe("禁言持续时间(秒),设为 `0` 为取消禁言")
|
|
923
|
+
}).describe("set_group_member_mute 请求参数");
|
|
924
|
+
const SetGroupWholeMuteInput = z.object({
|
|
925
|
+
group_id: zUin.describe("群号"),
|
|
926
|
+
is_mute: z.boolean().nullish().default(true).transform((val) => val ?? true).describe("是否开启全员禁言,`false` 表示取消全员禁言")
|
|
927
|
+
}).describe("set_group_whole_mute 请求参数");
|
|
928
|
+
const KickGroupMemberInput = z.object({
|
|
929
|
+
group_id: zUin.describe("群号"),
|
|
930
|
+
user_id: zUin.describe("被踢的 QQ 号"),
|
|
931
|
+
reject_add_request: z.boolean().nullish().default(false).transform((val) => val ?? false).describe("是否拒绝加群申请,`false` 表示不拒绝")
|
|
932
|
+
}).describe("kick_group_member 请求参数");
|
|
933
|
+
const GetGroupAnnouncementsInput = z.object({ group_id: zUin.describe("群号") }).describe("get_group_announcements 请求参数");
|
|
934
|
+
const GetGroupAnnouncementsOutput = z.object({ announcements: z.array(z.lazy(() => GroupAnnouncementEntity)).describe("群公告列表") }).describe("get_group_announcements 响应数据");
|
|
935
|
+
const SendGroupAnnouncementInput = z.object({
|
|
936
|
+
group_id: zUin.describe("群号"),
|
|
937
|
+
content: z.string().describe("公告内容"),
|
|
938
|
+
image_uri: z.string().nullish().describe("公告附带图像文件 URI,支持 `file://` `http(s)://` `base64://` 三种格式")
|
|
939
|
+
}).describe("send_group_announcement 请求参数");
|
|
940
|
+
const DeleteGroupAnnouncementInput = z.object({
|
|
941
|
+
group_id: zUin.describe("群号"),
|
|
942
|
+
announcement_id: z.string().describe("公告 ID")
|
|
943
|
+
}).describe("delete_group_announcement 请求参数");
|
|
944
|
+
const GetGroupEssenceMessagesInput = z.object({
|
|
945
|
+
group_id: zUin.describe("群号"),
|
|
946
|
+
page_index: z.number().int().nonnegative().describe("页码索引,从 0 开始"),
|
|
947
|
+
page_size: z.number().int().nonnegative().describe("每页包含的精华消息数量")
|
|
948
|
+
}).describe("get_group_essence_messages 请求参数");
|
|
949
|
+
const GetGroupEssenceMessagesOutput = z.object({
|
|
950
|
+
messages: z.array(z.lazy(() => GroupEssenceMessage)).describe("精华消息列表"),
|
|
951
|
+
is_end: z.boolean().describe("是否已到最后一页")
|
|
952
|
+
}).describe("get_group_essence_messages 响应数据");
|
|
953
|
+
const SetGroupEssenceMessageInput = z.object({
|
|
954
|
+
group_id: zUin.describe("群号"),
|
|
955
|
+
message_seq: z.number().int().nonnegative().describe("消息序列号"),
|
|
956
|
+
is_set: z.boolean().nullish().default(true).transform((val) => val ?? true).describe("是否设置为精华消息,`false` 表示取消精华")
|
|
957
|
+
}).describe("set_group_essence_message 请求参数");
|
|
958
|
+
const QuitGroupInput = z.object({ group_id: zUin.describe("群号") }).describe("quit_group 请求参数");
|
|
959
|
+
const SendGroupMessageReactionInput = z.object({
|
|
960
|
+
group_id: zUin.describe("群号"),
|
|
961
|
+
message_seq: z.number().int().nonnegative().describe("要回应的消息序列号"),
|
|
962
|
+
reaction: z.string().describe("发送的回应的表情 ID"),
|
|
963
|
+
reaction_type: z.enum(["face", "emoji"]).nullish().default("face").transform((val) => val ?? "face").describe("发送的回应类型"),
|
|
964
|
+
is_add: z.boolean().nullish().default(true).transform((val) => val ?? true).describe("是否添加表情,`false` 表示取消")
|
|
965
|
+
}).describe("send_group_message_reaction 请求参数");
|
|
966
|
+
const SendGroupNudgeInput = z.object({
|
|
967
|
+
group_id: zUin.describe("群号"),
|
|
968
|
+
user_id: zUin.describe("被戳的群成员 QQ 号")
|
|
969
|
+
}).describe("send_group_nudge 请求参数");
|
|
970
|
+
const GetGroupNotificationsInput = z.object({
|
|
971
|
+
start_notification_seq: z.number().int().nonnegative().nullish().describe("起始通知序列号"),
|
|
972
|
+
is_filtered: z.boolean().nullish().default(false).transform((val) => val ?? false).describe("`true` 表示只获取被过滤(由风险账号发起)的通知,`false` 表示只获取未被过滤的通知"),
|
|
973
|
+
limit: z.number().int().nonnegative().nullish().default(20).transform((val) => val ?? 20).describe("获取的最大通知数量")
|
|
974
|
+
}).describe("get_group_notifications 请求参数");
|
|
975
|
+
const GetGroupNotificationsOutput = z.object({
|
|
976
|
+
notifications: zDropBadElementArray(GroupNotification).describe("获取到的群通知(notification_seq 降序排列),序列号不一定连续"),
|
|
977
|
+
next_notification_seq: z.number().int().nonnegative().nullish().describe("下一页起始通知序列号")
|
|
978
|
+
}).describe("get_group_notifications 响应数据");
|
|
979
|
+
const AcceptGroupRequestInput = z.object({
|
|
980
|
+
notification_seq: z.number().int().nonnegative().describe("请求对应的通知序列号"),
|
|
981
|
+
notification_type: z.enum(["join_request", "invited_join_request"]).describe("请求对应的通知类型"),
|
|
982
|
+
group_id: zUin.describe("请求所在的群号"),
|
|
983
|
+
is_filtered: z.boolean().nullish().default(false).transform((val) => val ?? false).describe("是否是被过滤的请求")
|
|
984
|
+
}).describe("accept_group_request 请求参数");
|
|
985
|
+
const RejectGroupRequestInput = z.object({
|
|
986
|
+
notification_seq: z.number().int().nonnegative().describe("请求对应的通知序列号"),
|
|
987
|
+
notification_type: z.enum(["join_request", "invited_join_request"]).describe("请求对应的通知类型"),
|
|
988
|
+
group_id: zUin.describe("请求所在的群号"),
|
|
989
|
+
is_filtered: z.boolean().nullish().default(false).transform((val) => val ?? false).describe("是否是被过滤的请求"),
|
|
990
|
+
reason: z.string().nullish().describe("拒绝理由")
|
|
991
|
+
}).describe("reject_group_request 请求参数");
|
|
992
|
+
const AcceptGroupInvitationInput = z.object({
|
|
993
|
+
group_id: zUin.describe("群号"),
|
|
994
|
+
invitation_seq: z.number().int().nonnegative().describe("邀请序列号")
|
|
995
|
+
}).describe("accept_group_invitation 请求参数");
|
|
996
|
+
const RejectGroupInvitationInput = z.object({
|
|
997
|
+
group_id: zUin.describe("群号"),
|
|
998
|
+
invitation_seq: z.number().int().nonnegative().describe("邀请序列号")
|
|
999
|
+
}).describe("reject_group_invitation 请求参数");
|
|
1000
|
+
const UploadPrivateFileInput = z.object({
|
|
1001
|
+
user_id: zUin.describe("好友 QQ 号"),
|
|
1002
|
+
file_uri: z.string().describe("文件 URI,支持 `file://` `http(s)://` `base64://` 三种格式"),
|
|
1003
|
+
file_name: z.string().describe("文件名称")
|
|
1004
|
+
}).describe("upload_private_file 请求参数");
|
|
1005
|
+
const UploadPrivateFileOutput = z.object({ file_id: z.string().describe("文件 ID") }).describe("upload_private_file 响应数据");
|
|
1006
|
+
const UploadGroupFileInput = z.object({
|
|
1007
|
+
group_id: zUin.describe("群号"),
|
|
1008
|
+
parent_folder_id: z.string().nullish().default("/").transform((val) => val ?? "/").describe("目标文件夹 ID"),
|
|
1009
|
+
file_uri: z.string().describe("文件 URI,支持 `file://` `http(s)://` `base64://` 三种格式"),
|
|
1010
|
+
file_name: z.string().describe("文件名称")
|
|
1011
|
+
}).describe("upload_group_file 请求参数");
|
|
1012
|
+
const UploadGroupFileOutput = z.object({ file_id: z.string().describe("文件 ID") }).describe("upload_group_file 响应数据");
|
|
1013
|
+
const GetPrivateFileDownloadUrlInput = z.object({
|
|
1014
|
+
user_id: zUin.describe("好友 QQ 号"),
|
|
1015
|
+
file_id: z.string().describe("文件 ID"),
|
|
1016
|
+
file_hash: z.string().describe("文件的 TriSHA1 哈希值"),
|
|
1017
|
+
is_self_send: z.boolean().nullish().default(false).transform((val) => val ?? false).describe("是否为自己发送的文件")
|
|
1018
|
+
}).describe("get_private_file_download_url 请求参数");
|
|
1019
|
+
const GetPrivateFileDownloadUrlOutput = z.object({ download_url: z.string().describe("文件下载链接") }).describe("get_private_file_download_url 响应数据");
|
|
1020
|
+
const GetGroupFileDownloadUrlInput = z.object({
|
|
1021
|
+
group_id: zUin.describe("群号"),
|
|
1022
|
+
file_id: z.string().describe("文件 ID")
|
|
1023
|
+
}).describe("get_group_file_download_url 请求参数");
|
|
1024
|
+
const GetGroupFileDownloadUrlOutput = z.object({ download_url: z.string().describe("文件下载链接") }).describe("get_group_file_download_url 响应数据");
|
|
1025
|
+
const GetGroupFilesInput = z.object({
|
|
1026
|
+
group_id: zUin.describe("群号"),
|
|
1027
|
+
parent_folder_id: z.string().nullish().default("/").transform((val) => val ?? "/").describe("父文件夹 ID")
|
|
1028
|
+
}).describe("get_group_files 请求参数");
|
|
1029
|
+
const GetGroupFilesOutput = z.object({
|
|
1030
|
+
files: z.array(z.lazy(() => GroupFileEntity)).describe("文件列表"),
|
|
1031
|
+
folders: z.array(z.lazy(() => GroupFolderEntity)).describe("文件夹列表")
|
|
1032
|
+
}).describe("get_group_files 响应数据");
|
|
1033
|
+
const MoveGroupFileInput = z.object({
|
|
1034
|
+
group_id: zUin.describe("群号"),
|
|
1035
|
+
file_id: z.string().describe("文件 ID"),
|
|
1036
|
+
parent_folder_id: z.string().nullish().default("/").transform((val) => val ?? "/").describe("文件所在的文件夹 ID"),
|
|
1037
|
+
target_folder_id: z.string().nullish().default("/").transform((val) => val ?? "/").describe("目标文件夹 ID")
|
|
1038
|
+
}).describe("move_group_file 请求参数");
|
|
1039
|
+
const RenameGroupFileInput = z.object({
|
|
1040
|
+
group_id: zUin.describe("群号"),
|
|
1041
|
+
file_id: z.string().describe("文件 ID"),
|
|
1042
|
+
parent_folder_id: z.string().nullish().default("/").transform((val) => val ?? "/").describe("文件所在的文件夹 ID"),
|
|
1043
|
+
new_file_name: z.string().describe("新文件名称")
|
|
1044
|
+
}).describe("rename_group_file 请求参数");
|
|
1045
|
+
const DeleteGroupFileInput = z.object({
|
|
1046
|
+
group_id: zUin.describe("群号"),
|
|
1047
|
+
file_id: z.string().describe("文件 ID")
|
|
1048
|
+
}).describe("delete_group_file 请求参数");
|
|
1049
|
+
const PersistGroupFileInput = z.object({
|
|
1050
|
+
group_id: zUin.describe("群号"),
|
|
1051
|
+
file_id: z.string().describe("文件 ID")
|
|
1052
|
+
}).describe("persist_group_file 请求参数");
|
|
1053
|
+
const CreateGroupFolderInput = z.object({
|
|
1054
|
+
group_id: zUin.describe("群号"),
|
|
1055
|
+
folder_name: z.string().describe("文件夹名称")
|
|
1056
|
+
}).describe("create_group_folder 请求参数");
|
|
1057
|
+
const CreateGroupFolderOutput = z.object({ folder_id: z.string().describe("文件夹 ID") }).describe("create_group_folder 响应数据");
|
|
1058
|
+
const RenameGroupFolderInput = z.object({
|
|
1059
|
+
group_id: zUin.describe("群号"),
|
|
1060
|
+
folder_id: z.string().describe("文件夹 ID"),
|
|
1061
|
+
new_folder_name: z.string().describe("新文件夹名")
|
|
1062
|
+
}).describe("rename_group_folder 请求参数");
|
|
1063
|
+
const DeleteGroupFolderInput = z.object({
|
|
1064
|
+
group_id: zUin.describe("群号"),
|
|
1065
|
+
folder_id: z.string().describe("文件夹 ID")
|
|
1066
|
+
}).describe("delete_group_folder 请求参数");
|
|
1067
|
+
const zodApiEndpoints = {
|
|
1068
|
+
get_login_info: {
|
|
1069
|
+
description: "获取登录信息",
|
|
1070
|
+
requestSchema: null,
|
|
1071
|
+
responseSchema: GetLoginInfoOutput
|
|
1072
|
+
},
|
|
1073
|
+
get_impl_info: {
|
|
1074
|
+
description: "获取协议端信息",
|
|
1075
|
+
requestSchema: null,
|
|
1076
|
+
responseSchema: GetImplInfoOutput
|
|
1077
|
+
},
|
|
1078
|
+
get_user_profile: {
|
|
1079
|
+
description: "获取用户个人信息",
|
|
1080
|
+
requestSchema: GetUserProfileInput,
|
|
1081
|
+
responseSchema: GetUserProfileOutput
|
|
1082
|
+
},
|
|
1083
|
+
get_friend_list: {
|
|
1084
|
+
description: "获取好友列表",
|
|
1085
|
+
requestSchema: GetFriendListInput,
|
|
1086
|
+
responseSchema: GetFriendListOutput
|
|
1087
|
+
},
|
|
1088
|
+
get_friend_info: {
|
|
1089
|
+
description: "获取好友信息",
|
|
1090
|
+
requestSchema: GetFriendInfoInput,
|
|
1091
|
+
responseSchema: GetFriendInfoOutput
|
|
1092
|
+
},
|
|
1093
|
+
get_group_list: {
|
|
1094
|
+
description: "获取群列表",
|
|
1095
|
+
requestSchema: GetGroupListInput,
|
|
1096
|
+
responseSchema: GetGroupListOutput
|
|
1097
|
+
},
|
|
1098
|
+
get_group_info: {
|
|
1099
|
+
description: "获取群信息",
|
|
1100
|
+
requestSchema: GetGroupInfoInput,
|
|
1101
|
+
responseSchema: GetGroupInfoOutput
|
|
1102
|
+
},
|
|
1103
|
+
get_group_member_list: {
|
|
1104
|
+
description: "获取群成员列表",
|
|
1105
|
+
requestSchema: GetGroupMemberListInput,
|
|
1106
|
+
responseSchema: GetGroupMemberListOutput
|
|
1107
|
+
},
|
|
1108
|
+
get_group_member_info: {
|
|
1109
|
+
description: "获取群成员信息",
|
|
1110
|
+
requestSchema: GetGroupMemberInfoInput,
|
|
1111
|
+
responseSchema: GetGroupMemberInfoOutput
|
|
1112
|
+
},
|
|
1113
|
+
get_peer_pins: {
|
|
1114
|
+
description: "获取置顶的好友和群列表",
|
|
1115
|
+
requestSchema: null,
|
|
1116
|
+
responseSchema: GetPeerPinsOutput
|
|
1117
|
+
},
|
|
1118
|
+
set_peer_pin: {
|
|
1119
|
+
description: "设置好友或群的置顶状态",
|
|
1120
|
+
requestSchema: SetPeerPinInput,
|
|
1121
|
+
responseSchema: null
|
|
1122
|
+
},
|
|
1123
|
+
set_avatar: {
|
|
1124
|
+
description: "设置 QQ 账号头像",
|
|
1125
|
+
requestSchema: SetAvatarInput,
|
|
1126
|
+
responseSchema: null
|
|
1127
|
+
},
|
|
1128
|
+
set_nickname: {
|
|
1129
|
+
description: "设置 QQ 账号昵称",
|
|
1130
|
+
requestSchema: SetNicknameInput,
|
|
1131
|
+
responseSchema: null
|
|
1132
|
+
},
|
|
1133
|
+
set_bio: {
|
|
1134
|
+
description: "设置 QQ 账号个性签名",
|
|
1135
|
+
requestSchema: SetBioInput,
|
|
1136
|
+
responseSchema: null
|
|
1137
|
+
},
|
|
1138
|
+
get_custom_face_url_list: {
|
|
1139
|
+
description: "获取自定义表情 URL 列表",
|
|
1140
|
+
requestSchema: null,
|
|
1141
|
+
responseSchema: GetCustomFaceUrlListOutput
|
|
1142
|
+
},
|
|
1143
|
+
get_cookies: {
|
|
1144
|
+
description: "获取 Cookies",
|
|
1145
|
+
requestSchema: GetCookiesInput,
|
|
1146
|
+
responseSchema: GetCookiesOutput
|
|
1147
|
+
},
|
|
1148
|
+
get_csrf_token: {
|
|
1149
|
+
description: "获取 CSRF Token",
|
|
1150
|
+
requestSchema: null,
|
|
1151
|
+
responseSchema: GetCSRFTokenOutput
|
|
1152
|
+
},
|
|
1153
|
+
send_private_message: {
|
|
1154
|
+
description: "发送私聊消息",
|
|
1155
|
+
requestSchema: SendPrivateMessageInput,
|
|
1156
|
+
responseSchema: SendPrivateMessageOutput
|
|
1157
|
+
},
|
|
1158
|
+
send_group_message: {
|
|
1159
|
+
description: "发送群聊消息",
|
|
1160
|
+
requestSchema: SendGroupMessageInput,
|
|
1161
|
+
responseSchema: SendGroupMessageOutput
|
|
1162
|
+
},
|
|
1163
|
+
recall_private_message: {
|
|
1164
|
+
description: "撤回私聊消息",
|
|
1165
|
+
requestSchema: RecallPrivateMessageInput,
|
|
1166
|
+
responseSchema: null
|
|
1167
|
+
},
|
|
1168
|
+
recall_group_message: {
|
|
1169
|
+
description: "撤回群聊消息",
|
|
1170
|
+
requestSchema: RecallGroupMessageInput,
|
|
1171
|
+
responseSchema: null
|
|
1172
|
+
},
|
|
1173
|
+
get_message: {
|
|
1174
|
+
description: "获取消息",
|
|
1175
|
+
requestSchema: GetMessageInput,
|
|
1176
|
+
responseSchema: GetMessageOutput
|
|
1177
|
+
},
|
|
1178
|
+
get_history_messages: {
|
|
1179
|
+
description: "获取历史消息列表",
|
|
1180
|
+
requestSchema: GetHistoryMessagesInput,
|
|
1181
|
+
responseSchema: GetHistoryMessagesOutput
|
|
1182
|
+
},
|
|
1183
|
+
get_resource_temp_url: {
|
|
1184
|
+
description: "获取临时资源链接",
|
|
1185
|
+
requestSchema: GetResourceTempUrlInput,
|
|
1186
|
+
responseSchema: GetResourceTempUrlOutput
|
|
1187
|
+
},
|
|
1188
|
+
get_forwarded_messages: {
|
|
1189
|
+
description: "获取合并转发消息内容",
|
|
1190
|
+
requestSchema: GetForwardedMessagesInput,
|
|
1191
|
+
responseSchema: GetForwardedMessagesOutput
|
|
1192
|
+
},
|
|
1193
|
+
mark_message_as_read: {
|
|
1194
|
+
description: "标记消息为已读",
|
|
1195
|
+
requestSchema: MarkMessageAsReadInput,
|
|
1196
|
+
responseSchema: null
|
|
1197
|
+
},
|
|
1198
|
+
send_friend_nudge: {
|
|
1199
|
+
description: "发送好友戳一戳",
|
|
1200
|
+
requestSchema: SendFriendNudgeInput,
|
|
1201
|
+
responseSchema: null
|
|
1202
|
+
},
|
|
1203
|
+
send_profile_like: {
|
|
1204
|
+
description: "发送名片点赞",
|
|
1205
|
+
requestSchema: SendProfileLikeInput,
|
|
1206
|
+
responseSchema: null
|
|
1207
|
+
},
|
|
1208
|
+
delete_friend: {
|
|
1209
|
+
description: "删除好友",
|
|
1210
|
+
requestSchema: DeleteFriendInput,
|
|
1211
|
+
responseSchema: null
|
|
1212
|
+
},
|
|
1213
|
+
get_friend_requests: {
|
|
1214
|
+
description: "获取好友请求列表",
|
|
1215
|
+
requestSchema: GetFriendRequestsInput,
|
|
1216
|
+
responseSchema: GetFriendRequestsOutput
|
|
1217
|
+
},
|
|
1218
|
+
accept_friend_request: {
|
|
1219
|
+
description: "同意好友请求",
|
|
1220
|
+
requestSchema: AcceptFriendRequestInput,
|
|
1221
|
+
responseSchema: null
|
|
1222
|
+
},
|
|
1223
|
+
reject_friend_request: {
|
|
1224
|
+
description: "拒绝好友请求",
|
|
1225
|
+
requestSchema: RejectFriendRequestInput,
|
|
1226
|
+
responseSchema: null
|
|
1227
|
+
},
|
|
1228
|
+
set_group_name: {
|
|
1229
|
+
description: "设置群名称",
|
|
1230
|
+
requestSchema: SetGroupNameInput,
|
|
1231
|
+
responseSchema: null
|
|
1232
|
+
},
|
|
1233
|
+
set_group_avatar: {
|
|
1234
|
+
description: "设置群头像",
|
|
1235
|
+
requestSchema: SetGroupAvatarInput,
|
|
1236
|
+
responseSchema: null
|
|
1237
|
+
},
|
|
1238
|
+
set_group_member_card: {
|
|
1239
|
+
description: "设置群名片",
|
|
1240
|
+
requestSchema: SetGroupMemberCardInput,
|
|
1241
|
+
responseSchema: null
|
|
1242
|
+
},
|
|
1243
|
+
set_group_member_special_title: {
|
|
1244
|
+
description: "设置群成员专属头衔",
|
|
1245
|
+
requestSchema: SetGroupMemberSpecialTitleInput,
|
|
1246
|
+
responseSchema: null
|
|
1247
|
+
},
|
|
1248
|
+
set_group_member_admin: {
|
|
1249
|
+
description: "设置群管理员",
|
|
1250
|
+
requestSchema: SetGroupMemberAdminInput,
|
|
1251
|
+
responseSchema: null
|
|
1252
|
+
},
|
|
1253
|
+
set_group_member_mute: {
|
|
1254
|
+
description: "设置群成员禁言",
|
|
1255
|
+
requestSchema: SetGroupMemberMuteInput,
|
|
1256
|
+
responseSchema: null
|
|
1257
|
+
},
|
|
1258
|
+
set_group_whole_mute: {
|
|
1259
|
+
description: "设置群全员禁言",
|
|
1260
|
+
requestSchema: SetGroupWholeMuteInput,
|
|
1261
|
+
responseSchema: null
|
|
1262
|
+
},
|
|
1263
|
+
kick_group_member: {
|
|
1264
|
+
description: "踢出群成员",
|
|
1265
|
+
requestSchema: KickGroupMemberInput,
|
|
1266
|
+
responseSchema: null
|
|
1267
|
+
},
|
|
1268
|
+
get_group_announcements: {
|
|
1269
|
+
description: "获取群公告列表",
|
|
1270
|
+
requestSchema: GetGroupAnnouncementsInput,
|
|
1271
|
+
responseSchema: GetGroupAnnouncementsOutput
|
|
1272
|
+
},
|
|
1273
|
+
send_group_announcement: {
|
|
1274
|
+
description: "发送群公告",
|
|
1275
|
+
requestSchema: SendGroupAnnouncementInput,
|
|
1276
|
+
responseSchema: null
|
|
1277
|
+
},
|
|
1278
|
+
delete_group_announcement: {
|
|
1279
|
+
description: "删除群公告",
|
|
1280
|
+
requestSchema: DeleteGroupAnnouncementInput,
|
|
1281
|
+
responseSchema: null
|
|
1282
|
+
},
|
|
1283
|
+
get_group_essence_messages: {
|
|
1284
|
+
description: "获取群精华消息列表",
|
|
1285
|
+
requestSchema: GetGroupEssenceMessagesInput,
|
|
1286
|
+
responseSchema: GetGroupEssenceMessagesOutput
|
|
1287
|
+
},
|
|
1288
|
+
set_group_essence_message: {
|
|
1289
|
+
description: "设置群精华消息",
|
|
1290
|
+
requestSchema: SetGroupEssenceMessageInput,
|
|
1291
|
+
responseSchema: null
|
|
1292
|
+
},
|
|
1293
|
+
quit_group: {
|
|
1294
|
+
description: "退出群",
|
|
1295
|
+
requestSchema: QuitGroupInput,
|
|
1296
|
+
responseSchema: null
|
|
1297
|
+
},
|
|
1298
|
+
send_group_message_reaction: {
|
|
1299
|
+
description: "发送群消息表情回应",
|
|
1300
|
+
requestSchema: SendGroupMessageReactionInput,
|
|
1301
|
+
responseSchema: null
|
|
1302
|
+
},
|
|
1303
|
+
send_group_nudge: {
|
|
1304
|
+
description: "发送群戳一戳",
|
|
1305
|
+
requestSchema: SendGroupNudgeInput,
|
|
1306
|
+
responseSchema: null
|
|
1307
|
+
},
|
|
1308
|
+
get_group_notifications: {
|
|
1309
|
+
description: "获取群通知列表",
|
|
1310
|
+
requestSchema: GetGroupNotificationsInput,
|
|
1311
|
+
responseSchema: GetGroupNotificationsOutput
|
|
1312
|
+
},
|
|
1313
|
+
accept_group_request: {
|
|
1314
|
+
description: "同意入群/邀请他人入群请求",
|
|
1315
|
+
requestSchema: AcceptGroupRequestInput,
|
|
1316
|
+
responseSchema: null
|
|
1317
|
+
},
|
|
1318
|
+
reject_group_request: {
|
|
1319
|
+
description: "拒绝入群/邀请他人入群请求",
|
|
1320
|
+
requestSchema: RejectGroupRequestInput,
|
|
1321
|
+
responseSchema: null
|
|
1322
|
+
},
|
|
1323
|
+
accept_group_invitation: {
|
|
1324
|
+
description: "同意他人邀请自身入群",
|
|
1325
|
+
requestSchema: AcceptGroupInvitationInput,
|
|
1326
|
+
responseSchema: null
|
|
1327
|
+
},
|
|
1328
|
+
reject_group_invitation: {
|
|
1329
|
+
description: "拒绝他人邀请自身入群",
|
|
1330
|
+
requestSchema: RejectGroupInvitationInput,
|
|
1331
|
+
responseSchema: null
|
|
1332
|
+
},
|
|
1333
|
+
upload_private_file: {
|
|
1334
|
+
description: "上传私聊文件",
|
|
1335
|
+
requestSchema: UploadPrivateFileInput,
|
|
1336
|
+
responseSchema: UploadPrivateFileOutput
|
|
1337
|
+
},
|
|
1338
|
+
upload_group_file: {
|
|
1339
|
+
description: "上传群文件",
|
|
1340
|
+
requestSchema: UploadGroupFileInput,
|
|
1341
|
+
responseSchema: UploadGroupFileOutput
|
|
1342
|
+
},
|
|
1343
|
+
get_private_file_download_url: {
|
|
1344
|
+
description: "获取私聊文件下载链接",
|
|
1345
|
+
requestSchema: GetPrivateFileDownloadUrlInput,
|
|
1346
|
+
responseSchema: GetPrivateFileDownloadUrlOutput
|
|
1347
|
+
},
|
|
1348
|
+
get_group_file_download_url: {
|
|
1349
|
+
description: "获取群文件下载链接",
|
|
1350
|
+
requestSchema: GetGroupFileDownloadUrlInput,
|
|
1351
|
+
responseSchema: GetGroupFileDownloadUrlOutput
|
|
1352
|
+
},
|
|
1353
|
+
get_group_files: {
|
|
1354
|
+
description: "获取群文件列表",
|
|
1355
|
+
requestSchema: GetGroupFilesInput,
|
|
1356
|
+
responseSchema: GetGroupFilesOutput
|
|
1357
|
+
},
|
|
1358
|
+
move_group_file: {
|
|
1359
|
+
description: "移动群文件",
|
|
1360
|
+
requestSchema: MoveGroupFileInput,
|
|
1361
|
+
responseSchema: null
|
|
1362
|
+
},
|
|
1363
|
+
rename_group_file: {
|
|
1364
|
+
description: "重命名群文件",
|
|
1365
|
+
requestSchema: RenameGroupFileInput,
|
|
1366
|
+
responseSchema: null
|
|
1367
|
+
},
|
|
1368
|
+
delete_group_file: {
|
|
1369
|
+
description: "删除群文件",
|
|
1370
|
+
requestSchema: DeleteGroupFileInput,
|
|
1371
|
+
responseSchema: null
|
|
1372
|
+
},
|
|
1373
|
+
persist_group_file: {
|
|
1374
|
+
description: "转存群文件为永久文件",
|
|
1375
|
+
requestSchema: PersistGroupFileInput,
|
|
1376
|
+
responseSchema: null
|
|
1377
|
+
},
|
|
1378
|
+
create_group_folder: {
|
|
1379
|
+
description: "创建群文件夹",
|
|
1380
|
+
requestSchema: CreateGroupFolderInput,
|
|
1381
|
+
responseSchema: CreateGroupFolderOutput
|
|
1382
|
+
},
|
|
1383
|
+
rename_group_folder: {
|
|
1384
|
+
description: "重命名群文件夹",
|
|
1385
|
+
requestSchema: RenameGroupFolderInput,
|
|
1386
|
+
responseSchema: null
|
|
1387
|
+
},
|
|
1388
|
+
delete_group_folder: {
|
|
1389
|
+
description: "删除群文件夹",
|
|
1390
|
+
requestSchema: DeleteGroupFolderInput,
|
|
1391
|
+
responseSchema: null
|
|
1392
|
+
}
|
|
1393
|
+
};
|
|
1394
|
+
//#endregion
|
|
1395
|
+
//#region src/protocol/toolset.ts
|
|
1396
|
+
function milkyToolset(ctx, endpoints) {
|
|
1397
|
+
const tools = {};
|
|
1398
|
+
for (const endpoint of endpoints) {
|
|
1399
|
+
const endpointDesc = zodApiEndpoints[endpoint];
|
|
1400
|
+
tools[endpoint] = tool({
|
|
1401
|
+
description: endpointDesc.description,
|
|
1402
|
+
inputSchema: endpointDesc.requestSchema ?? z.object({}),
|
|
1403
|
+
outputSchema: endpointDesc.responseSchema ?? z.object({}),
|
|
1404
|
+
execute: async (input) => {
|
|
1405
|
+
return await ctx.client[endpoint](input) ?? {};
|
|
1406
|
+
}
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
return tools;
|
|
1410
|
+
}
|
|
1411
|
+
//#endregion
|
|
51
1412
|
//#region src/index.ts
|
|
52
1413
|
function isProviderConfig(config) {
|
|
53
1414
|
return "sdk" in config && typeof config.sdk === "string";
|
|
@@ -57,7 +1418,7 @@ const AiPlugin = definePlugin({
|
|
|
57
1418
|
provides: [AiService],
|
|
58
1419
|
async apply(ctx, options) {
|
|
59
1420
|
const models = {};
|
|
60
|
-
for (const [name, config] of Object.entries(options.providers)) if (isProviderConfig(config)) (await resolveLanguageModels(config)).forEach((model, idx) => {
|
|
1421
|
+
for (const [name, config] of Object.entries(options.providers)) if (isProviderConfig(config)) (await resolveLanguageModels(name, config)).forEach((model, idx) => {
|
|
61
1422
|
const modelName = `${name}/${config.models[idx]}`;
|
|
62
1423
|
models[modelName] = model;
|
|
63
1424
|
});
|
|
@@ -73,4 +1434,4 @@ const AiPlugin = definePlugin({
|
|
|
73
1434
|
}
|
|
74
1435
|
});
|
|
75
1436
|
//#endregion
|
|
76
|
-
export { AiPlugin, AiPlugin as default, AiService, resolveLanguageModels };
|
|
1437
|
+
export { AiPlugin, AiPlugin as default, AiService, milkyToolset, resolveLanguageModels };
|