@napuketto/adapter 0.15.0 → 0.15.2

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.
@@ -1,7 +1,7 @@
1
- import { _ as prepareVideoElements, a as extractSysMsgEnvelope, b as BaseAction, c as narrowSysMsgBlobs, f as toHex, g as ensureSilk, r as decodeProtoTree, t as toUnixSeconds, u as recognizeSysMsg, x as ActionRegistry, y as BaseProtocolAdapter } from "../core-Be1hDKmc.mjs";
1
+ import { S as ActionRegistry, _ as ensureSilk, b as BaseProtocolAdapter, c as narrowSysMsgBlobs, d as recognizeSysMsg, t as toUnixSeconds, u as processSysMsgBlob, v as prepareVideoElements, x as BaseAction } from "../core-CxDffqmA.mjs";
2
2
  import { n as senderNickname, r as subscribeRawMessages } from "../raw-message-D2vA27kj.mjs";
3
- import { i as narrowBuddyReqs, n as extractEssenceSetSysMsg, r as narrowEssenceGroupArg, t as EssenceListSync } from "../essence-BP3LE1Bm.mjs";
4
- import { i as MS_TO_SEC$3, n as firstUntranslatedGrayTip, o as toUin, r as hasGrayTip, t as collectGrayTipUids } from "../gray-tip-CitrbUCZ.mjs";
3
+ import { a as MS_TO_SEC$2, c as toUin, i as hasGrayTip, o as numericUin, r as firstUntranslatedGrayTip, t as collectGrayTipUids } from "../gray-tip-C0pnbB__.mjs";
4
+ import { a as narrowEssenceGroupArg, i as extractEssenceSetSysMsg, n as truncRaw, o as narrowBuddyReqs, r as EssenceListSync, t as sliceRaw } from "../log-DiPRjA5P.mjs";
5
5
  import { n as createWsServerSchema, t as createHttpServerSchema } from "../transport-schema-BEzr06W3.mjs";
6
6
  import { ChatType, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupMemberRole, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, WebHonorType, kernelError, toCanonicalElements } from "@napuketto/kernel";
7
7
  import { basename, join } from "node:path";
@@ -33,10 +33,79 @@ async function resolveUid(uin, uinToUid) {
33
33
  if (uid === void 0) throw kernelError(`用户 ${uin} 的 uid 解析失败`, "INVALID_PARAM");
34
34
  return uid;
35
35
  }
36
- // src/onebot11/action/friend/delete-friend.ts
36
+ // src/onebot11/action/friend/manage.ts
37
37
  /**
38
- * delete_friend 动作:删除好友(P2-11 接 kernel FriendApi.deleteFriend)
38
+ * 好友管理域动作(2026-11-14 自 friend/ 微文件合并)
39
+ *
40
+ * - set_friend_add_request(P2-11):flag=reqTime(NapCat 约定,需从好友请求事件
41
+ * 上报中获取)→ getBuddyReqList 匹配 → handleFriendRequest + optional remark
42
+ * - set_friend_remark / delete_friend(P2-11):user_id 经 uin→uid
43
+ * - set_doubt_friends_add_request(P2-11 可疑好友申请处理,NapCat 扩展;
44
+ * approve 字段 NapCat 强制为 true,该接口无语义仅保留)
45
+ * - send_like(P2-14):ProfileLikeApi.sendLike
39
46
  */
47
+ const setDoubtFriendsAddRequestSchema = z.object({
48
+ flag: z.string(),
49
+ approve: z.boolean().optional()
50
+ });
51
+ /** 处理可疑好友申请(P2-11 接 kernel handleDoubtFriendRequest)。 */
52
+ var SetDoubtFriendsAddRequestAction = class extends BaseAction {
53
+ name = "set_doubt_friends_add_request";
54
+ schema = setDoubtFriendsAddRequestSchema;
55
+ errorCodeMap = ob11ErrorCodeMap;
56
+ friendApi;
57
+ constructor(friendApi) {
58
+ super();
59
+ this.friendApi = friendApi;
60
+ }
61
+ _handle(payload) {
62
+ this.friendApi.handleDoubtFriendRequest(payload.flag);
63
+ return Promise.resolve(null);
64
+ }
65
+ };
66
+ const setFriendAddRequestSchema = z.object({
67
+ flag: z.string(),
68
+ approve: z.boolean().optional(),
69
+ remark: z.string().optional()
70
+ });
71
+ /** 处理加好友请求(P2-11 接 kernel FriendApi)。 */
72
+ var SetFriendAddRequestAction = class extends BaseAction {
73
+ name = "set_friend_add_request";
74
+ schema = setFriendAddRequestSchema;
75
+ errorCodeMap = ob11ErrorCodeMap;
76
+ friendApi;
77
+ constructor(friendApi) {
78
+ super();
79
+ this.friendApi = friendApi;
80
+ }
81
+ async _handle(payload) {
82
+ const notify = (await this.friendApi.getBuddyReqList()).find((req) => req.reqTime === payload.flag);
83
+ if (notify === void 0) throw kernelError("未找到对应的好友请求(flag 无效或已过期)", "NOT_FOUND");
84
+ await this.friendApi.handleFriendRequest(notify, payload.approve !== false);
85
+ if (payload.remark !== void 0) this.friendApi.setFriendRemark(notify.friendUid, payload.remark);
86
+ return null;
87
+ }
88
+ };
89
+ const setFriendRemarkSchema = z.object({
90
+ user_id: z.number(),
91
+ remark: z.string()
92
+ });
93
+ /** 设置好友备注(P2-11 接 kernel setFriendRemark)。 */
94
+ var SetFriendRemarkAction = class extends BaseAction {
95
+ name = "set_friend_remark";
96
+ schema = setFriendRemarkSchema;
97
+ errorCodeMap = ob11ErrorCodeMap;
98
+ deps;
99
+ constructor(deps) {
100
+ super();
101
+ this.deps = deps;
102
+ }
103
+ async _handle(payload) {
104
+ const uid = await resolveUid(String(payload.user_id), this.deps.uinToUid);
105
+ this.deps.friendApi.setFriendRemark(uid, payload.remark);
106
+ return null;
107
+ }
108
+ };
40
109
  const deleteFriendSchema = z.object({ user_id: z.number() });
41
110
  /** 删除好友(P2-11 接 kernel deleteFriend)。 */
42
111
  var DeleteFriendAction = class extends BaseAction {
@@ -54,25 +123,38 @@ var DeleteFriendAction = class extends BaseAction {
54
123
  return null;
55
124
  }
56
125
  };
57
- // src/onebot11/action/friend/get-doubt-friends-add-request.ts
58
- const getDoubtFriendsAddRequestSchema = z.object({ count: z.number().optional() });
59
- /** 默认获取数量。 */
60
- const DEFAULT_COUNT$3 = 50;
61
- /** 获取可疑好友申请(P2-11 接 kernel getDoubtFriendRequest)。 */
62
- var GetDoubtFriendsAddRequestAction = class extends BaseAction {
63
- name = "get_doubt_friends_add_request";
64
- schema = getDoubtFriendsAddRequestSchema;
126
+ const sendLikeSchema = z.object({
127
+ user_id: z.number(),
128
+ times: z.number().optional()
129
+ });
130
+ /** 点赞(P2-14 接 kernel ProfileLikeApi)。 */
131
+ var SendLikeAction = class extends BaseAction {
132
+ name = "send_like";
133
+ schema = sendLikeSchema;
65
134
  errorCodeMap = ob11ErrorCodeMap;
66
- friendApi;
67
- constructor(friendApi) {
135
+ deps;
136
+ constructor(deps) {
68
137
  super();
69
- this.friendApi = friendApi;
138
+ this.deps = deps;
70
139
  }
71
- _handle(payload) {
72
- return this.friendApi.getDoubtFriendRequest(payload.count ?? DEFAULT_COUNT$3);
140
+ async _handle(payload) {
141
+ const uid = await resolveUid(String(payload.user_id), this.deps.uinToUid);
142
+ await this.deps.profileLikeApi.sendLike(uid, payload.times ?? 1);
143
+ return null;
73
144
  }
74
145
  };
75
- // src/onebot11/action/friend/get-friend-list.ts
146
+ /** 好友管理域动作工厂(friend_add_request / friend_remark / delete_friend /
147
+ * doubt 申请处理 / send_like)。 */
148
+ function createFriendManageActions(api) {
149
+ return [
150
+ new SetFriendAddRequestAction(api.friendApi),
151
+ new SetFriendRemarkAction(api),
152
+ new DeleteFriendAction(api),
153
+ new SetDoubtFriendsAddRequestAction(api.friendApi),
154
+ new SendLikeAction(api)
155
+ ];
156
+ }
157
+ // src/onebot11/action/friend/query.ts
76
158
  const getFriendListSchema = z.object({
77
159
  /** 是否忽略缓存(go-cqhttp 扩展)。 */
78
160
  no_cache: z.boolean().optional() });
@@ -97,7 +179,6 @@ var GetFriendListAction = class extends BaseAction {
97
179
  });
98
180
  }
99
181
  };
100
- // src/onebot11/action/friend/get-friends-with-category.ts
101
182
  const getFriendsWithCategorySchema = z.object({});
102
183
  /** 获取好友列表(含分类,P2-11 接 kernel getFriendCategories)。 */
103
184
  var GetFriendsWithCategoryAction = class extends BaseAction {
@@ -113,7 +194,6 @@ var GetFriendsWithCategoryAction = class extends BaseAction {
113
194
  return this.friendApi.getFriendCategories();
114
195
  }
115
196
  };
116
- // src/onebot11/action/friend/get-stranger-info.ts
117
197
  const getStrangerInfoSchema = z.object({
118
198
  user_id: z.number(),
119
199
  no_cache: z.boolean().optional()
@@ -135,39 +215,13 @@ var GetStrangerInfoAction = class extends BaseAction {
135
215
  };
136
216
  }
137
217
  };
138
- // src/onebot11/action/friend/send-like.ts
139
- /**
140
- * send_like 动作:点赞(P2-14 接 kernel ProfileLikeApi.sendLike)
141
- */
142
- const sendLikeSchema = z.object({
143
- user_id: z.number(),
144
- times: z.number().optional()
145
- });
146
- /** 点赞(P2-14 接 kernel ProfileLikeApi)。 */
147
- var SendLikeAction = class extends BaseAction {
148
- name = "send_like";
149
- schema = sendLikeSchema;
150
- errorCodeMap = ob11ErrorCodeMap;
151
- deps;
152
- constructor(deps) {
153
- super();
154
- this.deps = deps;
155
- }
156
- async _handle(payload) {
157
- const uid = await resolveUid(String(payload.user_id), this.deps.uinToUid);
158
- await this.deps.profileLikeApi.sendLike(uid, payload.times ?? 1);
159
- return null;
160
- }
161
- };
162
- // src/onebot11/action/friend/set-doubt-friends-add-request.ts
163
- const setDoubtFriendsAddRequestSchema = z.object({
164
- flag: z.string(),
165
- approve: z.boolean().optional()
166
- });
167
- /** 处理可疑好友申请(P2-11 接 kernel handleDoubtFriendRequest)。 */
168
- var SetDoubtFriendsAddRequestAction = class extends BaseAction {
169
- name = "set_doubt_friends_add_request";
170
- schema = setDoubtFriendsAddRequestSchema;
218
+ const getDoubtFriendsAddRequestSchema = z.object({ count: z.number().optional() });
219
+ /** 默认获取数量。 */
220
+ const DEFAULT_COUNT$2 = 50;
221
+ /** 获取可疑好友申请(P2-11 接 kernel getDoubtFriendRequest)。 */
222
+ var GetDoubtFriendsAddRequestAction = class extends BaseAction {
223
+ name = "get_doubt_friends_add_request";
224
+ schema = getDoubtFriendsAddRequestSchema;
171
225
  errorCodeMap = ob11ErrorCodeMap;
172
226
  friendApi;
173
227
  constructor(friendApi) {
@@ -175,64 +229,19 @@ var SetDoubtFriendsAddRequestAction = class extends BaseAction {
175
229
  this.friendApi = friendApi;
176
230
  }
177
231
  _handle(payload) {
178
- this.friendApi.handleDoubtFriendRequest(payload.flag);
179
- return Promise.resolve(null);
180
- }
181
- };
182
- // src/onebot11/action/friend/set-friend-add-request.ts
183
- /**
184
- * set_friend_add_request 动作:处理加好友请求(P2-11)
185
- *
186
- * flag=reqTime(NapCat 约定,需从好友请求事件上报中获取)→ getBuddyReqList
187
- * 匹配 → handleFriendRequest(notify, approve) + optional remark。
188
- */
189
- const setFriendAddRequestSchema = z.object({
190
- flag: z.string(),
191
- approve: z.boolean().optional(),
192
- remark: z.string().optional()
193
- });
194
- /** 处理加好友请求(P2-11 接 kernel FriendApi)。 */
195
- var SetFriendAddRequestAction = class extends BaseAction {
196
- name = "set_friend_add_request";
197
- schema = setFriendAddRequestSchema;
198
- errorCodeMap = ob11ErrorCodeMap;
199
- friendApi;
200
- constructor(friendApi) {
201
- super();
202
- this.friendApi = friendApi;
203
- }
204
- async _handle(payload) {
205
- const notify = (await this.friendApi.getBuddyReqList()).find((req) => req.reqTime === payload.flag);
206
- if (notify === void 0) throw kernelError("未找到对应的好友请求(flag 无效或已过期)", "NOT_FOUND");
207
- await this.friendApi.handleFriendRequest(notify, payload.approve !== false);
208
- if (payload.remark !== void 0) this.friendApi.setFriendRemark(notify.friendUid, payload.remark);
209
- return null;
210
- }
211
- };
212
- // src/onebot11/action/friend/set-friend-remark.ts
213
- /**
214
- * set_friend_remark 动作:设置好友备注(P2-11 接 kernel FriendApi.setFriendRemark)
215
- */
216
- const setFriendRemarkSchema = z.object({
217
- user_id: z.number(),
218
- remark: z.string()
219
- });
220
- /** 设置好友备注(P2-11 接 kernel setFriendRemark)。 */
221
- var SetFriendRemarkAction = class extends BaseAction {
222
- name = "set_friend_remark";
223
- schema = setFriendRemarkSchema;
224
- errorCodeMap = ob11ErrorCodeMap;
225
- deps;
226
- constructor(deps) {
227
- super();
228
- this.deps = deps;
229
- }
230
- async _handle(payload) {
231
- const uid = await resolveUid(String(payload.user_id), this.deps.uinToUid);
232
- this.deps.friendApi.setFriendRemark(uid, payload.remark);
233
- return null;
232
+ return this.friendApi.getDoubtFriendRequest(payload.count ?? DEFAULT_COUNT$2);
234
233
  }
235
234
  };
235
+ /** 好友查询域动作工厂(friend_list / friends_with_category / stranger_info /
236
+ * doubt_friends_add_request)。 */
237
+ function createFriendQueryActions(api) {
238
+ return [
239
+ new GetFriendListAction(api.friendApi),
240
+ new GetFriendsWithCategoryAction(api.friendApi),
241
+ new GetStrangerInfoAction(api.profileApi),
242
+ new GetDoubtFriendsAddRequestAction(api.friendApi)
243
+ ];
244
+ }
236
245
  // src/onebot11/helper/message-unique.ts
237
246
  /** OB11 message_id 上限(int32 max = 0x7FFF_FFFF)。 */
238
247
  const INT32_MAX = 2147483647;
@@ -320,11 +329,16 @@ function resolveMsgIdAndPeer(messageId, unique) {
320
329
  peer
321
330
  };
322
331
  }
323
- // src/onebot11/action/group/set-essence-msg.ts
332
+ // src/onebot11/action/group/essence.ts
324
333
  /**
325
- * set_essence_msg 动作:设置精华消息(P2-10 接 kernel GroupApi.addGroupEssence)
334
+ * 群精华/荣誉域动作(2026-11-14 自 set-essence-msg / delete-essence-msg /
335
+ * get-essence-msg-list / get-group-honor-info 合并)
326
336
  *
327
- * message_id → msgId + peer(MessageUnique 反查,需群消息)→ addGroupEssence。
337
+ * - set/delete_essence_msg(P2-10):message_id → msgId + peer(MessageUnique 反查,
338
+ * 需群消息)→ GroupApi.addGroupEssence / removeGroupEssence(共用 EssenceMsgBase)
339
+ * - get_essence_msg_list(P2-15):qun.qq.com digest_list web 接口 → msg_list,
340
+ * msg_content 映射 text/image 段
341
+ * - get_group_honor_info(P2-15):qun.qq.com honorlist web 接口;type 缺省 all
328
342
  */
329
343
  const setEssenceMsgSchema = z.object({ message_id: z.union([z.number(), z.string()]) });
330
344
  /** 精华消息基类(set/delete 共用实现,2026-08-08 克隆合并)。 */
@@ -350,10 +364,6 @@ var SetEssenceMsgAction = class extends EssenceMsgBase {
350
364
  await this.deps.groupApi.addGroupEssence(groupCode, msgId);
351
365
  }
352
366
  };
353
- // src/onebot11/action/group/delete-essence-msg.ts
354
- /**
355
- * delete_essence_msg 动作:取消精华消息(P2-10 接 kernel GroupApi.removeGroupEssence)
356
- */
357
367
  const deleteEssenceMsgSchema = z.object({ message_id: z.union([z.number(), z.string()]) });
358
368
  /** 取消精华消息(P2-10 接 kernel removeGroupEssence)。 */
359
369
  var DeleteEssenceMsgAction = class extends EssenceMsgBase {
@@ -363,7 +373,6 @@ var DeleteEssenceMsgAction = class extends EssenceMsgBase {
363
373
  await this.deps.groupApi.removeGroupEssence(groupCode, msgId);
364
374
  }
365
375
  };
366
- // src/onebot11/action/group/get-essence-msg-list.ts
367
376
  const getEssenceMsgListSchema = z.object({ group_id: z.number() });
368
377
  /** 文本段类型(msg_content.msg_type)。 */
369
378
  const MSG_TYPE_TEXT = 1;
@@ -415,88 +424,6 @@ function toSegment(part) {
415
424
  };
416
425
  return null;
417
426
  }
418
- // src/onebot11/action/group/get-group-add-request.ts
419
- const getGroupAddRequestSchema = z.object({ count: z.number().optional() });
420
- /** 默认获取数量。 */
421
- const DEFAULT_COUNT$2 = 100;
422
- /** 获取未处理群申请(P2-15)。 */
423
- var GetGroupAddRequestAction = class extends BaseAction {
424
- name = "get_group_add_request";
425
- schema = getGroupAddRequestSchema;
426
- errorCodeMap = ob11ErrorCodeMap;
427
- groupNotifyApi;
428
- constructor(groupNotifyApi) {
429
- super();
430
- this.groupNotifyApi = groupNotifyApi;
431
- }
432
- async _handle(payload) {
433
- return (await this.groupNotifyApi.getSingleScreenNotifies(false, payload.count ?? DEFAULT_COUNT$2)).map(toGroupAddRequestItem);
434
- }
435
- };
436
- /** 获取被忽略群申请(P2-15)。 */
437
- var GetGroupIgnoredNotifiesAction = class extends BaseAction {
438
- name = "get_group_ignored_notifies";
439
- schema = getGroupAddRequestSchema;
440
- errorCodeMap = ob11ErrorCodeMap;
441
- groupNotifyApi;
442
- constructor(groupNotifyApi) {
443
- super();
444
- this.groupNotifyApi = groupNotifyApi;
445
- }
446
- async _handle(payload) {
447
- return (await this.groupNotifyApi.getSingleScreenNotifies(true, payload.count ?? DEFAULT_COUNT$2)).map(toGroupAddRequestItem);
448
- }
449
- };
450
- /** GroupNotify → OB11 群请求项(纯函数)。 */
451
- function toGroupAddRequestItem(notify) {
452
- const { seq, type, status, postscript, user1, group } = notify;
453
- let groupCode = 0;
454
- let groupName = "";
455
- if (group !== void 0) {
456
- const { groupCode: code, groupName: name } = group;
457
- groupCode = Number(code);
458
- groupName = name;
459
- }
460
- let userId = 0;
461
- let userNick = "";
462
- if (user1 !== void 0) {
463
- const { uid, nickName } = user1;
464
- userId = Number(uid);
465
- userNick = nickName;
466
- }
467
- return {
468
- flag: seq,
469
- group_id: groupCode,
470
- group_name: groupName,
471
- user_id: userId,
472
- user_nick: userNick,
473
- type,
474
- checked: status !== 1,
475
- postscript: postscript ?? ""
476
- };
477
- }
478
- // src/onebot11/action/group/get-group-at-all-remain.ts
479
- const getGroupAtAllRemainSchema = z.object({ group_id: z.number() });
480
- /** 获取群 @全体成员 剩余次数(P2-10 接 kernel getGroupRemainAtTimes)。 */
481
- var GetGroupAtAllRemainAction = class extends BaseAction {
482
- name = "get_group_at_all_remain";
483
- schema = getGroupAtAllRemainSchema;
484
- errorCodeMap = ob11ErrorCodeMap;
485
- groupApi;
486
- constructor(groupApi) {
487
- super();
488
- this.groupApi = groupApi;
489
- }
490
- async _handle(payload) {
491
- const remain = await this.groupApi.getGroupRemainAtTimes(String(payload.group_id));
492
- return {
493
- can_at_all: remain.canAtAll,
494
- remain_at_all_count_for_uin: remain.remainAtAllCountForUin,
495
- remain_at_all_count_for_group: remain.remainAtAllCountForGroup
496
- };
497
- }
498
- };
499
- // src/onebot11/action/group/get-group-honor-info.ts
500
427
  const getGroupHonorInfoSchema = z.object({
501
428
  group_id: z.number(),
502
429
  type: z.string().optional()
@@ -524,200 +451,15 @@ function mapHonorType(raw) {
524
451
  if (raw === "emotion") return WebHonorType.EMOTION;
525
452
  return WebHonorType.ALL;
526
453
  }
527
- // src/onebot11/helper/translate.ts
528
- /**
529
- * OB11 翻译辅助(NT 实体 → OB11 结构,P2-4)
530
- *
531
- * 纯函数(ADR-008):只读入参,不调 API、不读缓存。
532
- * 群成员/群信息等 NT 实体 → OB11 返回结构的薄映射。
533
- */
534
- /** NT Group → OB11 GroupInfo。 */
535
- function toOb11GroupInfo(group) {
536
- const info = {
537
- group_id: Number(group.groupCode),
538
- group_name: group.groupName
539
- };
540
- if (typeof group.memberCount === "number") info.member_count = group.memberCount;
541
- if (typeof group.maxMember === "number") info.max_member_count = group.maxMember;
542
- return info;
543
- }
544
- /** NT GroupDetailInfo → OB11 GroupInfo(getGroupDetailInfo / GroupCache 用)。 */
545
- function toOb11GroupInfoDetail(detail) {
546
- const info = {
547
- group_id: Number(detail.groupCode),
548
- group_name: detail.groupName
549
- };
550
- if (typeof detail.memberNum === "number") info.member_count = detail.memberNum;
551
- if (typeof detail.maxMemberNum === "number") info.max_member_count = detail.maxMemberNum;
552
- return info;
553
- }
554
- /** 禁言秒 → 毫秒(shut_up_timestamp 单位)。 */
555
- const SEC_TO_MS = 1e3;
556
- /** NT GroupMember → OB11 GroupMemberInfo(uin 由 uidToUin 映射补全)。 */
557
- function toOb11GroupMemberInfo(groupCode, member, uidToUin) {
558
- let uinStr = member.uin;
559
- if (uinStr === "") uinStr = uidToUin.get(member.uid) ?? member.uid;
560
- const info = {
561
- group_id: Number(groupCode),
562
- user_id: Number(uinStr),
563
- nickname: member.nick,
564
- role: GroupApi.roleToString(member.role)
565
- };
566
- if (member.cardName !== "") info.card = member.cardName;
567
- if (member.memberSpecialTitle !== void 0 && member.memberSpecialTitle !== "") {
568
- info.title = member.memberSpecialTitle;
569
- info.special_title = member.memberSpecialTitle;
570
- }
571
- if (member.shutUpTime > 0) info.shut_up_timestamp = member.shutUpTime * SEC_TO_MS;
572
- if (member.joinTime !== "" && member.joinTime !== "0") info.join_time = Number(member.joinTime);
573
- if (member.lastSpeakTime !== "" && member.lastSpeakTime !== "0") info.last_sent_time = Number(member.lastSpeakTime);
574
- if (typeof member.age === "number") info.age = member.age;
575
- return info;
454
+ /** 群精华/荣誉域动作工厂(set/delete_essence_msg / essence_msg_list / honor_info)。 */
455
+ function createGroupEssenceActions(api) {
456
+ return [
457
+ new SetEssenceMsgAction(api),
458
+ new DeleteEssenceMsgAction(api),
459
+ new GetEssenceMsgListAction(api.webApi),
460
+ new GetGroupHonorInfoAction(api.webApi)
461
+ ];
576
462
  }
577
- // src/onebot11/action/group/get-group-info.ts
578
- /**
579
- * get_group_info 动作:获取群信息(P2-4 接 kernel GroupApi;P2-17 读缓存)
580
- */
581
- const getGroupInfoSchema = z.object({
582
- group_id: z.number(),
583
- /** 是否忽略缓存(go-cqhttp 扩展)。 */
584
- no_cache: z.boolean().optional()
585
- });
586
- /** 获取群信息(P2-4 接 kernel apis/group;P2-17 优先读 GroupCache)。 */
587
- var GetGroupInfoAction = class extends BaseAction {
588
- name = "get_group_info";
589
- schema = getGroupInfoSchema;
590
- errorCodeMap = ob11ErrorCodeMap;
591
- deps;
592
- constructor(deps) {
593
- super();
594
- this.deps = deps;
595
- }
596
- async _handle(payload) {
597
- const groupCode = String(payload.group_id);
598
- if (payload.no_cache !== true && this.deps.groupCache !== void 0) return toOb11GroupInfoDetail(await this.deps.groupCache.getGroupDetail(groupCode));
599
- return toOb11GroupInfoDetail(await this.deps.groupApi.getGroupInfo(groupCode));
600
- }
601
- };
602
- // src/onebot11/action/group/get-group-list.ts
603
- /**
604
- * get_group_list 动作:获取群列表(P2-4 接 kernel GroupApi + GroupCache)
605
- *
606
- * ⚠️ 实测校准(2026-08-08 端到端联调):原生 getGroupList 返回值无数据
607
- * (仅 { result, errMsg }),列表经 onGroupListUpdate 事件推送 → GroupCache
608
- * 维护——列表一律从缓存读,no_cache=true 仅触发原生刷新。
609
- */
610
- const getGroupListSchema = z.object({
611
- /** 是否忽略缓存(go-cqhttp 扩展)。 */
612
- no_cache: z.boolean().optional() });
613
- /** 获取群列表(P2-4 接 kernel apis/group;群列表数据经事件推送,从 GroupCache 读)。 */
614
- var GetGroupListAction = class extends BaseAction {
615
- name = "get_group_list";
616
- schema = getGroupListSchema;
617
- errorCodeMap = ob11ErrorCodeMap;
618
- deps;
619
- constructor(deps) {
620
- super();
621
- this.deps = deps;
622
- }
623
- async _handle(payload) {
624
- return (this.deps.groupCache === void 0 ? await this.deps.groupApi.getGroupList(true) : payload.no_cache === true ? await this.deps.groupCache.listGroupsRefreshed() : this.deps.groupCache.listGroups()).map(toOb11GroupInfo);
625
- }
626
- };
627
- // src/onebot11/action/group/get-group-member-info.ts
628
- /**
629
- * get_group_member_info 动作:获取群成员信息(P2-4 接 kernel GroupApi;P2-17 读缓存)
630
- */
631
- const getGroupMemberInfoSchema = z.object({
632
- group_id: z.number(),
633
- user_id: z.number(),
634
- /** 是否忽略缓存(go-cqhttp 扩展)。 */
635
- no_cache: z.boolean().optional()
636
- });
637
- /** 获取群成员信息(P2-4 接 kernel apis/group;P2-17 优先读 GroupCache)。 */
638
- var GetGroupMemberInfoAction = class extends BaseAction {
639
- name = "get_group_member_info";
640
- schema = getGroupMemberInfoSchema;
641
- errorCodeMap = ob11ErrorCodeMap;
642
- deps;
643
- constructor(deps) {
644
- super();
645
- this.deps = deps;
646
- }
647
- async _handle(payload) {
648
- const groupCode = String(payload.group_id);
649
- const uid = (await this.deps.groupApi.uinToUid([String(payload.user_id)])).get(String(payload.user_id));
650
- if (uid === void 0) throw kernelError(`成员 ${payload.user_id} 不在群 ${payload.group_id}`, "NOT_FOUND");
651
- const member = await this.resolveMember(groupCode, uid, payload.no_cache === true);
652
- if (member === void 0) throw kernelError(`成员 ${payload.user_id} 不在群 ${payload.group_id}`, "NOT_FOUND");
653
- return toOb11GroupMemberInfo(groupCode, member, await this.deps.groupApi.uidToUin([uid]));
654
- }
655
- /** 读缓存(缺省)或直查 api(no_cache=true / 未装配缓存)。 */
656
- async resolveMember(groupCode, uid, noCache) {
657
- if (noCache || this.deps.groupCache === void 0) {
658
- const [member] = await this.deps.groupApi.getGroupMemberInfo(groupCode, [uid]);
659
- return member;
660
- }
661
- return await this.deps.groupCache.getMember(groupCode, uid);
662
- }
663
- };
664
- // src/onebot11/action/group/get-group-member-list.ts
665
- const getGroupMemberListSchema = z.object({
666
- group_id: z.number(),
667
- /** 是否忽略缓存(go-cqhttp 扩展)。 */
668
- no_cache: z.boolean().optional()
669
- });
670
- /** 获取群成员列表(P2-4 接 kernel apis/group;P2-17 优先读 GroupCache)。 */
671
- var GetGroupMemberListAction = class extends BaseAction {
672
- name = "get_group_member_list";
673
- schema = getGroupMemberListSchema;
674
- errorCodeMap = ob11ErrorCodeMap;
675
- deps;
676
- constructor(deps) {
677
- super();
678
- this.deps = deps;
679
- }
680
- async _handle(payload) {
681
- const groupCode = String(payload.group_id);
682
- const noCache = payload.no_cache === true;
683
- let members;
684
- if (noCache || this.deps.groupCache === void 0) members = await this.deps.groupApi.getGroupMemberList(groupCode, noCache);
685
- else members = await this.deps.groupCache.getMembers(groupCode);
686
- const uinMap = await this.deps.groupApi.uidToUin(members.map((m) => m.uid));
687
- return members.map((m) => toOb11GroupMemberInfo(groupCode, m, uinMap));
688
- }
689
- };
690
- // src/onebot11/action/group/get-group-shut-list.ts
691
- /**
692
- * get_group_shut_list 动作:获取群禁言列表(P2-13 接 kernel GroupNotifyApi)
693
- *
694
- * getGroupShutUpMemberList → [{ user_id, nickname, shut_up_time }](uin 经 uidToUin)。
695
- */
696
- const getGroupShutListSchema = z.object({ group_id: z.number() });
697
- /** 获取群禁言列表(P2-13 接 kernel GroupNotifyApi)。 */
698
- var GetGroupShutListAction = class extends BaseAction {
699
- name = "get_group_shut_list";
700
- schema = getGroupShutListSchema;
701
- errorCodeMap = ob11ErrorCodeMap;
702
- deps;
703
- constructor(deps) {
704
- super();
705
- this.deps = deps;
706
- }
707
- async _handle(payload) {
708
- const members = await this.deps.groupNotifyApi.getGroupShutUpMemberList(String(payload.group_id));
709
- const uids = members.map((m) => m.uid);
710
- let uinMap = /* @__PURE__ */ new Map();
711
- if (uids.length > 0) uinMap = await this.deps.uidToUin(uids);
712
- const out = [];
713
- for (const member of members) out.push({
714
- user_id: Number(uinMap.get(member.uid) ?? member.uin ?? member.uid),
715
- nickname: member.nick,
716
- shut_up_time: member.shutUpTime
717
- });
718
- return out;
719
- }
720
- };
721
463
  // src/onebot11/action/group/get-group-system-msg.ts
722
464
  const getGroupSystemMsgSchema = z.object({ count: z.number().optional() });
723
465
  /** 默认获取数量。 */
@@ -811,6 +553,10 @@ function toMessageInfo(notify, uinMap) {
811
553
  requester_nick: invitorNick
812
554
  };
813
555
  }
556
+ /** 群系统消息动作工厂(get_group_system_msg)。 */
557
+ function createGroupSystemMsgActions(api) {
558
+ return [new GetGroupSystemMsgAction(api)];
559
+ }
814
560
  // src/onebot11/action/limits.ts
815
561
  /** 批量翻译的词条上限(translate_en2zh)。 */
816
562
  const MAX_TRANSLATE_WORDS = 2e3;
@@ -936,6 +682,17 @@ var TransGroupFileAction = class extends BaseAction {
936
682
  return null;
937
683
  }
938
684
  };
685
+ /** 群文件操作域动作工厂(create/delete folder、delete/rename/move/trans file)。 */
686
+ function createGroupFileOpActions(api) {
687
+ return [
688
+ new CreateGroupFileFolderAction(api.richMediaApi),
689
+ new DeleteGroupFileAction(api.richMediaApi),
690
+ new DeleteGroupFolderAction(api.richMediaApi),
691
+ new RenameGroupFileAction(api.richMediaApi),
692
+ new MoveGroupFileAction(api.richMediaApi),
693
+ new TransGroupFileAction(api.richMediaApi)
694
+ ];
695
+ }
939
696
  // src/onebot11/action/group/group-files-query.ts
940
697
  const getGroupRootFilesSchema = z.object({
941
698
  group_id: z.number(),
@@ -1035,63 +792,34 @@ function toGroupFolderInfo(folder) {
1035
792
  folder_name: folder.folderName
1036
793
  };
1037
794
  }
1038
- // src/onebot11/action/group/set-group-add-request.ts
1039
- /**
1040
- * set_group_add_request 动作:处理加群请求(P2-13 接 kernel GroupNotifyApi)
1041
- *
1042
- * flag=seq(群请求事件上报的 flag)→ getSingleScreenNotifies(doubt, count)
1043
- * 匹配 → handleGroupRequest(approve=true→同意 / false→拒绝,reason 默认空格)。
1044
- */
1045
- const setGroupAddRequestSchema = z.object({
1046
- flag: z.string(),
1047
- approve: z.boolean().optional(),
1048
- reason: z.string().optional(),
1049
- count: z.number().optional()
1050
- });
1051
- /** 默认搜索通知数量。 */
1052
- const DEFAULT_COUNT = 100;
1053
- /** 处理加群请求(P2-13 接 kernel GroupNotifyApi)。 */
1054
- var SetGroupAddRequestAction = class extends BaseAction {
1055
- name = "set_group_add_request";
1056
- schema = setGroupAddRequestSchema;
1057
- errorCodeMap = ob11ErrorCodeMap;
1058
- groupNotifyApi;
1059
- constructor(groupNotifyApi) {
1060
- super();
1061
- this.groupNotifyApi = groupNotifyApi;
1062
- }
1063
- async _handle(payload) {
1064
- const count = payload.count ?? DEFAULT_COUNT;
1065
- const notify = await this.findNotify(payload.flag, count);
1066
- if (notify === null) throw kernelError("未找到对应的群请求(flag 无效或已过期)", "NOT_FOUND");
1067
- let operateType = NTGroupRequestOperateTypes.KREFUSE;
1068
- if (payload.approve !== false) operateType = NTGroupRequestOperateTypes.KAGREE;
1069
- await this.groupNotifyApi.handleGroupRequest(false, notify, operateType, payload.reason ?? " ");
1070
- return null;
1071
- }
1072
- /** 按 seq 匹配通知(先非可疑,后可疑)。 */
1073
- async findNotify(flag, count) {
1074
- const hit = (await this.groupNotifyApi.getSingleScreenNotifies(false, count)).find((item) => item.seq === flag);
1075
- if (hit !== void 0) return hit;
1076
- return (await this.groupNotifyApi.getSingleScreenNotifies(true, count)).find((item) => item.seq === flag) ?? null;
1077
- }
1078
- };
1079
- // src/onebot11/action/group/set-group-admin.ts
795
+ /** 群文件查询域动作工厂(root files / by folder / system info)。 */
796
+ function createGroupFileQueryActions(api) {
797
+ return [
798
+ new GetGroupRootFilesAction(api.richMediaApi),
799
+ new GetGroupFilesByFolderAction(api.richMediaApi),
800
+ new GetGroupFileSystemInfoAction(api.richMediaApi)
801
+ ];
802
+ }
803
+ // src/onebot11/action/group/manage.ts
1080
804
  /**
1081
- * set_group_admin 动作:设置群管理员(P2-10 接 kernel GroupApi.setMemberRole)
805
+ * 群管理域动作(2026-11-14 自 set-group-kick / set-group-ban / set-group-whole-ban /
806
+ * set-group-admin / set-group-card / set-group-name / set-group-leave 合并)
1082
807
  *
1083
- * enable=true 设为管理员,false 取消;user_id → uinToUid。
808
+ * 踢人 / 单人与全员禁言 / 管理员 / 名片 / 群名 / 退群,均接 kernel GroupApi;
809
+ * user_id(uin)→ uid 经 resolveUid。
1084
810
  */
1085
- const setGroupAdminSchema = z.object({
811
+ const setGroupKickSchema = z.object({
1086
812
  group_id: z.number(),
1087
813
  user_id: z.number(),
1088
- /** 是否设为管理员。 */
1089
- enable: z.boolean().default(true)
814
+ /** 是否拒绝加群请求(拉黑)。 */
815
+ reject_add_request: z.boolean().optional(),
816
+ /** 踢人理由。 */
817
+ kick_reason: z.string().optional()
1090
818
  });
1091
- /** 设置群管理员(P2-10 接 kernel setMemberRole)。 */
1092
- var SetGroupAdminAction = class extends BaseAction {
1093
- name = "set_group_admin";
1094
- schema = setGroupAdminSchema;
819
+ /** 群组踢人(P2-10 接 kernel kickMember)。 */
820
+ var SetGroupKickAction = class extends BaseAction {
821
+ name = "set_group_kick";
822
+ schema = setGroupKickSchema;
1095
823
  errorCodeMap = ob11ErrorCodeMap;
1096
824
  groupApi;
1097
825
  constructor(groupApi) {
@@ -1099,14 +827,17 @@ var SetGroupAdminAction = class extends BaseAction {
1099
827
  this.groupApi = groupApi;
1100
828
  }
1101
829
  async _handle(payload) {
1102
- const uid = await resolveUid(String(payload.user_id), (uins) => this.groupApi.uinToUid(uins));
1103
- let role = NTGroupMemberRole.MEMBER;
1104
- if (payload.enable) role = NTGroupMemberRole.ADMIN;
1105
- this.groupApi.setMemberRole(String(payload.group_id), uid, role);
830
+ const uid = await this.resolveUid(payload.user_id);
831
+ await this.groupApi.kickMember(String(payload.group_id), [uid], payload.reject_add_request === true, payload.kick_reason ?? "");
1106
832
  return null;
1107
833
  }
834
+ /** user_id(uin)→ uid。 */
835
+ async resolveUid(userId) {
836
+ const uid = (await this.groupApi.uinToUid([String(userId)])).get(String(userId));
837
+ if (uid === void 0) throw kernelError(`用户 ${userId} 的 uid 解析失败`, "INVALID_PARAM");
838
+ return uid;
839
+ }
1108
840
  };
1109
- // src/onebot11/action/group/set-group-ban.ts
1110
841
  const setGroupBanSchema = z.object({
1111
842
  group_id: z.number(),
1112
843
  user_id: z.number(),
@@ -1132,17 +863,15 @@ var SetGroupBanAction = class extends BaseAction {
1132
863
  return null;
1133
864
  }
1134
865
  };
1135
- // src/onebot11/action/group/set-group-card.ts
1136
- const setGroupCardSchema = z.object({
866
+ const setGroupWholeBanSchema = z.object({
1137
867
  group_id: z.number(),
1138
- user_id: z.number(),
1139
- /** 群名片(空串清除)。 */
1140
- card: z.string().optional().default("")
868
+ /** 是否开启全员禁言。 */
869
+ enable: z.boolean().default(true)
1141
870
  });
1142
- /** 设置群名片(P2-10 接 kernel setMemberCardName)。 */
1143
- var SetGroupCardAction = class extends BaseAction {
1144
- name = "set_group_card";
1145
- schema = setGroupCardSchema;
871
+ /** 群组全员禁言(P2-10 接 kernel setGroupShutUp)。 */
872
+ var SetGroupWholeBanAction = class extends BaseAction {
873
+ name = "set_group_whole_ban";
874
+ schema = setGroupWholeBanSchema;
1146
875
  errorCodeMap = ob11ErrorCodeMap;
1147
876
  groupApi;
1148
877
  constructor(groupApi) {
@@ -1150,29 +879,20 @@ var SetGroupCardAction = class extends BaseAction {
1150
879
  this.groupApi = groupApi;
1151
880
  }
1152
881
  async _handle(payload) {
1153
- const uid = await resolveUid(String(payload.user_id), (uins) => this.groupApi.uinToUid(uins));
1154
- this.groupApi.setMemberCardName(String(payload.group_id), uid, payload.card);
882
+ await this.groupApi.setGroupShutUp(String(payload.group_id), payload.enable);
1155
883
  return null;
1156
884
  }
1157
885
  };
1158
- // src/onebot11/action/group/set-group-kick.ts
1159
- /**
1160
- * set_group_kick 动作:群组踢人(P2-10 接 kernel GroupApi.kickMember)
1161
- *
1162
- * user_id(uin)→ uinToUid → kickMember(kickMemberV2)。
1163
- */
1164
- const setGroupKickSchema = z.object({
886
+ const setGroupAdminSchema = z.object({
1165
887
  group_id: z.number(),
1166
888
  user_id: z.number(),
1167
- /** 是否拒绝加群请求(拉黑)。 */
1168
- reject_add_request: z.boolean().optional(),
1169
- /** 踢人理由。 */
1170
- kick_reason: z.string().optional()
889
+ /** 是否设为管理员。 */
890
+ enable: z.boolean().default(true)
1171
891
  });
1172
- /** 群组踢人(P2-10 接 kernel kickMember)。 */
1173
- var SetGroupKickAction = class extends BaseAction {
1174
- name = "set_group_kick";
1175
- schema = setGroupKickSchema;
892
+ /** 设置群管理员(P2-10 接 kernel setMemberRole)。 */
893
+ var SetGroupAdminAction = class extends BaseAction {
894
+ name = "set_group_admin";
895
+ schema = setGroupAdminSchema;
1176
896
  errorCodeMap = ob11ErrorCodeMap;
1177
897
  groupApi;
1178
898
  constructor(groupApi) {
@@ -1180,27 +900,23 @@ var SetGroupKickAction = class extends BaseAction {
1180
900
  this.groupApi = groupApi;
1181
901
  }
1182
902
  async _handle(payload) {
1183
- const uid = await this.resolveUid(payload.user_id);
1184
- await this.groupApi.kickMember(String(payload.group_id), [uid], payload.reject_add_request === true, payload.kick_reason ?? "");
903
+ const uid = await resolveUid(String(payload.user_id), (uins) => this.groupApi.uinToUid(uins));
904
+ let role = NTGroupMemberRole.MEMBER;
905
+ if (payload.enable) role = NTGroupMemberRole.ADMIN;
906
+ this.groupApi.setMemberRole(String(payload.group_id), uid, role);
1185
907
  return null;
1186
908
  }
1187
- /** user_id(uin)→ uid。 */
1188
- async resolveUid(userId) {
1189
- const uid = (await this.groupApi.uinToUid([String(userId)])).get(String(userId));
1190
- if (uid === void 0) throw kernelError(`用户 ${userId} 的 uid 解析失败`, "INVALID_PARAM");
1191
- return uid;
1192
- }
1193
909
  };
1194
- // src/onebot11/action/group/set-group-leave.ts
1195
- const setGroupLeaveSchema = z.object({
910
+ const setGroupCardSchema = z.object({
1196
911
  group_id: z.number(),
1197
- /** 是否解散群(仅群主可用)。 */
1198
- is_dismiss: z.boolean().optional().default(false)
912
+ user_id: z.number(),
913
+ /** 群名片(空串清除)。 */
914
+ card: z.string().optional().default("")
1199
915
  });
1200
- /** 退出群聊(P2-10 接 kernel quitGroup)。 */
1201
- var SetGroupLeaveAction = class extends BaseAction {
1202
- name = "set_group_leave";
1203
- schema = setGroupLeaveSchema;
916
+ /** 设置群名片(P2-10 接 kernel setMemberCardName)。 */
917
+ var SetGroupCardAction = class extends BaseAction {
918
+ name = "set_group_card";
919
+ schema = setGroupCardSchema;
1204
920
  errorCodeMap = ob11ErrorCodeMap;
1205
921
  groupApi;
1206
922
  constructor(groupApi) {
@@ -1208,11 +924,11 @@ var SetGroupLeaveAction = class extends BaseAction {
1208
924
  this.groupApi = groupApi;
1209
925
  }
1210
926
  async _handle(payload) {
1211
- await this.groupApi.quitGroup(String(payload.group_id), payload.is_dismiss);
927
+ const uid = await resolveUid(String(payload.user_id), (uins) => this.groupApi.uinToUid(uins));
928
+ this.groupApi.setMemberCardName(String(payload.group_id), uid, payload.card);
1212
929
  return null;
1213
930
  }
1214
931
  };
1215
- // src/onebot11/action/group/set-group-name.ts
1216
932
  const setGroupNameSchema = z.object({
1217
933
  group_id: z.number(),
1218
934
  group_name: z.string()
@@ -1232,16 +948,15 @@ var SetGroupNameAction = class extends BaseAction {
1232
948
  return null;
1233
949
  }
1234
950
  };
1235
- // src/onebot11/action/group/set-group-whole-ban.ts
1236
- const setGroupWholeBanSchema = z.object({
951
+ const setGroupLeaveSchema = z.object({
1237
952
  group_id: z.number(),
1238
- /** 是否开启全员禁言。 */
1239
- enable: z.boolean().default(true)
953
+ /** 是否解散群(仅群主可用)。 */
954
+ is_dismiss: z.boolean().optional().default(false)
1240
955
  });
1241
- /** 群组全员禁言(P2-10 接 kernel setGroupShutUp)。 */
1242
- var SetGroupWholeBanAction = class extends BaseAction {
1243
- name = "set_group_whole_ban";
1244
- schema = setGroupWholeBanSchema;
956
+ /** 退出群聊(P2-10 接 kernel quitGroup)。 */
957
+ var SetGroupLeaveAction = class extends BaseAction {
958
+ name = "set_group_leave";
959
+ schema = setGroupLeaveSchema;
1245
960
  errorCodeMap = ob11ErrorCodeMap;
1246
961
  groupApi;
1247
962
  constructor(groupApi) {
@@ -1249,107 +964,132 @@ var SetGroupWholeBanAction = class extends BaseAction {
1249
964
  this.groupApi = groupApi;
1250
965
  }
1251
966
  async _handle(payload) {
1252
- await this.groupApi.setGroupShutUp(String(payload.group_id), payload.enable);
967
+ await this.groupApi.quitGroup(String(payload.group_id), payload.is_dismiss);
1253
968
  return null;
1254
969
  }
1255
970
  };
1256
- // src/onebot11/action/message/delete-msg.ts
1257
971
  /**
1258
- * delete_msg 动作:撤回消息(P2-10 接 kernel MsgApi.recallMessage)
972
+ * 群管理域动作工厂(kick / ban / whole_ban / admin / card / name / leave)。
973
+ */
974
+ function createGroupManageActions(api) {
975
+ return [
976
+ new SetGroupKickAction(api.groupApi),
977
+ new SetGroupBanAction(api.groupApi),
978
+ new SetGroupWholeBanAction(api.groupApi),
979
+ new SetGroupAdminAction(api.groupApi),
980
+ new SetGroupCardAction(api.groupApi),
981
+ new SetGroupNameAction(api.groupApi),
982
+ new SetGroupLeaveAction(api.groupApi)
983
+ ];
984
+ }
985
+ // src/onebot11/action/group/notify.ts
986
+ /**
987
+ * 群通知域动作(2026-11-14 自 get-group-add-request / set-group-add-request /
988
+ * get-group-shut-list 合并,均接 kernel GroupNotifyApi)
1259
989
  *
1260
- * OB11 标准 delete_msg 只有 message_id;peer 经 MessageUnique 反查。
1261
- * 群聊管理员 / 私聊 2 分钟内可撤回。
990
+ * - get_group_add_request / get_group_ignored_notifies(P2-15):未处理申请列表 /
991
+ * 可疑忽略列表(getSingleScreenNotifies(false|true));flag=seq 用于应答
992
+ * - set_group_add_request(P2-13):flag=seq 匹配 → handleGroupRequest
993
+ * (approve=true→同意 / false→拒绝,reason 默认空格)
994
+ * - get_group_shut_list(P2-13):getGroupShutUpMemberList → 禁言成员列表
995
+ * (uin 经 uidToUin 批量转换)
1262
996
  */
1263
- const deleteMsgSchema = z.object({ message_id: z.union([z.number(), z.string()]) });
1264
- /** 撤回消息(P2-10 接 kernel recallMessage)。 */
1265
- var DeleteMsgAction = class extends BaseAction {
1266
- name = "delete_msg";
1267
- schema = deleteMsgSchema;
997
+ const getGroupAddRequestSchema = z.object({ count: z.number().optional() });
998
+ /** 默认获取数量。 */
999
+ const DEFAULT_COUNT = 100;
1000
+ /** 获取未处理群申请(P2-15)。 */
1001
+ var GetGroupAddRequestAction = class extends BaseAction {
1002
+ name = "get_group_add_request";
1003
+ schema = getGroupAddRequestSchema;
1268
1004
  errorCodeMap = ob11ErrorCodeMap;
1269
- deps;
1270
- constructor(deps) {
1005
+ groupNotifyApi;
1006
+ constructor(groupNotifyApi) {
1271
1007
  super();
1272
- this.deps = deps;
1008
+ this.groupNotifyApi = groupNotifyApi;
1273
1009
  }
1274
1010
  async _handle(payload) {
1275
- const { msgId, peer } = resolveMsgIdAndPeer(payload.message_id, this.deps.messageUnique);
1276
- await this.deps.msgApi.recallMessage(peer, [msgId]);
1277
- return null;
1011
+ return (await this.groupNotifyApi.getSingleScreenNotifies(false, payload.count ?? DEFAULT_COUNT)).map(toGroupAddRequestItem);
1278
1012
  }
1279
1013
  };
1280
- // src/onebot11/action/message/fetch-ptt-text.ts
1281
- /**
1282
- * fetch_ptt_text 动作:获取语音转文字结果(NapCat 扩展,P2-10)
1283
- *
1284
- * message_id → msgId + peer → MsgApi.fetchPttText(内部:拉消息 → 找 PTT 元素
1285
- * → translatePtt2Text → 再拉取读 pttElement.text)。
1286
- */
1287
- const fetchPttTextSchema = z.object({ message_id: z.union([z.number(), z.string()]) });
1288
- /** 获取语音转文字结果(P2-10 接 kernel fetchPttText)。 */
1289
- var FetchPttTextAction = class extends BaseAction {
1290
- name = "fetch_ptt_text";
1291
- schema = fetchPttTextSchema;
1014
+ /** 获取被忽略群申请(P2-15)。 */
1015
+ var GetGroupIgnoredNotifiesAction = class extends BaseAction {
1016
+ name = "get_group_ignored_notifies";
1017
+ schema = getGroupAddRequestSchema;
1292
1018
  errorCodeMap = ob11ErrorCodeMap;
1293
- deps;
1294
- constructor(deps) {
1019
+ groupNotifyApi;
1020
+ constructor(groupNotifyApi) {
1295
1021
  super();
1296
- this.deps = deps;
1022
+ this.groupNotifyApi = groupNotifyApi;
1297
1023
  }
1298
1024
  async _handle(payload) {
1299
- const { msgId, peer } = resolveMsgIdAndPeer(payload.message_id, this.deps.messageUnique);
1300
- return { text: await this.deps.msgApi.fetchPttText(msgId, peer) };
1025
+ return (await this.groupNotifyApi.getSingleScreenNotifies(true, payload.count ?? DEFAULT_COUNT)).map(toGroupAddRequestItem);
1301
1026
  }
1302
1027
  };
1303
- // src/onebot11/action/message/resolve-peer.ts
1304
- /**
1305
- * OB11 目标 Peer 解析 / 单条消息拉取(多个动作共用,2026-08-08 克隆合并)
1306
- *
1307
- * group_id 直通(群消息 peerUid = 群号);user_id 经 uin→uid 解析。
1308
- */
1309
- /** 解析目标 Peer(group_id 直通;user_id 经 uin→uid)。 */
1310
- async function resolveTargetPeer(payload, deps, missingHint) {
1311
- if (payload.group_id !== void 0) return {
1312
- chatType: ChatType.GROUP,
1313
- peerUid: String(payload.group_id)
1314
- };
1315
- if (payload.user_id !== void 0) {
1316
- const uid = (await deps.uinToUid([String(payload.user_id)])).get(String(payload.user_id));
1317
- if (uid === void 0) throw kernelError(`用户 ${payload.user_id} 的 uid 解析失败`, "INVALID_PARAM");
1318
- return {
1319
- chatType: ChatType.C2C,
1320
- peerUid: uid
1321
- };
1028
+ /** GroupNotify → OB11 群请求项(纯函数)。 */
1029
+ function toGroupAddRequestItem(notify) {
1030
+ const { seq, type, status, postscript, user1, group } = notify;
1031
+ let groupCode = 0;
1032
+ let groupName = "";
1033
+ if (group !== void 0) {
1034
+ const { groupCode: code, groupName: name } = group;
1035
+ groupCode = Number(code);
1036
+ groupName = name;
1037
+ }
1038
+ let userId = 0;
1039
+ let userNick = "";
1040
+ if (user1 !== void 0) {
1041
+ const { uid, nickName } = user1;
1042
+ userId = Number(uid);
1043
+ userNick = nickName;
1322
1044
  }
1323
- throw kernelError(missingHint, "INVALID_PARAM");
1324
- }
1325
- /**
1326
- * 按 message_id(OB11 int32 或 NT msgId)拉取单条消息。
1327
- * 消息不存在/已被撤回 → 抛 KernelError NOT_FOUND。
1328
- */
1329
- async function fetchMsgById(messageId, messageUnique, msgApi) {
1330
- const { msgId, peer } = resolveMsgIdAndPeer(messageId, messageUnique);
1331
- const [msg] = await msgApi.fetchMsgsByMsgId(peer, [msgId]);
1332
- if (msg === void 0) throw kernelError(`消息 ${messageId} 不存在或已被撤回`, "NOT_FOUND");
1333
1045
  return {
1334
- msg,
1335
- peer,
1336
- msgId
1046
+ flag: seq,
1047
+ group_id: groupCode,
1048
+ group_name: groupName,
1049
+ user_id: userId,
1050
+ user_nick: userNick,
1051
+ type,
1052
+ checked: status !== 1,
1053
+ postscript: postscript ?? ""
1337
1054
  };
1338
1055
  }
1339
- // src/onebot11/action/message/forward-single-msg.ts
1340
- /**
1341
- * forward_group_single_msg / forward_friend_single_msg 动作:单条转发(P2-12)
1342
- *
1343
- * message_id 反查源 msgId + peer;group_id/user_id 为目标 →
1344
- * MsgApi.forwardSingleMessage(srcPeer, [msgId], dstPeer)。
1345
- */
1346
- const forwardSingleMsgSchema = z.object({
1347
- message_id: z.union([z.number(), z.string()]),
1348
- group_id: z.number().optional(),
1349
- user_id: z.number().optional()
1056
+ const setGroupAddRequestSchema = z.object({
1057
+ flag: z.string(),
1058
+ approve: z.boolean().optional(),
1059
+ reason: z.string().optional(),
1060
+ count: z.number().optional()
1350
1061
  });
1351
- /** 单条转发基类(两个动作共用实现)。 */
1352
- var ForwardSingleMsgBase = class extends BaseAction {
1062
+ /** 处理加群请求(P2-13 接 kernel GroupNotifyApi)。 */
1063
+ var SetGroupAddRequestAction = class extends BaseAction {
1064
+ name = "set_group_add_request";
1065
+ schema = setGroupAddRequestSchema;
1066
+ errorCodeMap = ob11ErrorCodeMap;
1067
+ groupNotifyApi;
1068
+ constructor(groupNotifyApi) {
1069
+ super();
1070
+ this.groupNotifyApi = groupNotifyApi;
1071
+ }
1072
+ async _handle(payload) {
1073
+ const count = payload.count ?? DEFAULT_COUNT;
1074
+ const notify = await this.findNotify(payload.flag, count);
1075
+ if (notify === null) throw kernelError("未找到对应的群请求(flag 无效或已过期)", "NOT_FOUND");
1076
+ let operateType = NTGroupRequestOperateTypes.KREFUSE;
1077
+ if (payload.approve !== false) operateType = NTGroupRequestOperateTypes.KAGREE;
1078
+ await this.groupNotifyApi.handleGroupRequest(false, notify, operateType, payload.reason ?? " ");
1079
+ return null;
1080
+ }
1081
+ /** 按 seq 匹配通知(先非可疑,后可疑)。 */
1082
+ async findNotify(flag, count) {
1083
+ const hit = (await this.groupNotifyApi.getSingleScreenNotifies(false, count)).find((item) => item.seq === flag);
1084
+ if (hit !== void 0) return hit;
1085
+ return (await this.groupNotifyApi.getSingleScreenNotifies(true, count)).find((item) => item.seq === flag) ?? null;
1086
+ }
1087
+ };
1088
+ const getGroupShutListSchema = z.object({ group_id: z.number() });
1089
+ /** 获取群禁言列表(P2-13 接 kernel GroupNotifyApi)。 */
1090
+ var GetGroupShutListAction = class extends BaseAction {
1091
+ name = "get_group_shut_list";
1092
+ schema = getGroupShutListSchema;
1353
1093
  errorCodeMap = ob11ErrorCodeMap;
1354
1094
  deps;
1355
1095
  constructor(deps) {
@@ -1357,38 +1097,232 @@ var ForwardSingleMsgBase = class extends BaseAction {
1357
1097
  this.deps = deps;
1358
1098
  }
1359
1099
  async _handle(payload) {
1360
- const { msgId, peer: sourcePeer } = resolveMsgIdAndPeer(payload.message_id, this.deps.messageUnique);
1361
- const dstPeer = await resolveTargetPeer(payload, this.deps, "单条转发需要 group_id 或 user_id");
1362
- await this.deps.msgApi.forwardSingleMessage(sourcePeer, [msgId], dstPeer);
1363
- return null;
1100
+ const members = await this.deps.groupNotifyApi.getGroupShutUpMemberList(String(payload.group_id));
1101
+ const uids = members.map((m) => m.uid);
1102
+ let uinMap = /* @__PURE__ */ new Map();
1103
+ if (uids.length > 0) uinMap = await this.deps.uidToUin(uids);
1104
+ const out = [];
1105
+ for (const member of members) out.push({
1106
+ user_id: Number(uinMap.get(member.uid) ?? member.uin ?? member.uid),
1107
+ nickname: member.nick,
1108
+ shut_up_time: member.shutUpTime
1109
+ });
1110
+ return out;
1364
1111
  }
1365
1112
  };
1366
- /** 转发单条消息到群(P2-12)。 */
1367
- var ForwardGroupSingleMsgAction = class extends ForwardSingleMsgBase {
1368
- name = "forward_group_single_msg";
1369
- schema = forwardSingleMsgSchema;
1370
- };
1371
- /** 转发单条消息到好友(P2-12)。 */
1372
- var ForwardFriendSingleMsgAction = class extends ForwardSingleMsgBase {
1373
- name = "forward_friend_single_msg";
1374
- schema = forwardSingleMsgSchema;
1375
- };
1376
- // src/onebot11/helper/codec/cqcode.ts
1377
1113
  /**
1378
- * CQ 码编解码(OneBot 11 消息段序列化格式)
1379
- *
1380
- * 纯函数、无 OB11 类型依赖:本文件只处理「文本 ↔ CQ 码片段」的通用编解码,
1381
- * segment 级别的映射在 data.ts(OB11Constructor)。
1382
- *
1383
- * 转义规则(OneBot 11 规范):
1384
- * - 纯文本:& → &,[ → [,] → ]
1385
- * - 参数值:额外 , → ,
1114
+ * 群通知域动作工厂(get_group_add_request / get_group_ignored_notifies /
1115
+ * set_group_add_request / get_group_shut_list)。
1386
1116
  */
1387
- /** 解析单个 CQ 码文本 → 结构化 CqCode。 */
1388
- function parseCqCode(raw) {
1389
- const body = raw.slice(4, -1);
1390
- const firstComma = body.indexOf(",");
1391
- let type = body;
1117
+ function createGroupNotifyActions(api) {
1118
+ return [
1119
+ new GetGroupAddRequestAction(api.groupNotifyApi),
1120
+ new GetGroupIgnoredNotifiesAction(api.groupNotifyApi),
1121
+ new SetGroupAddRequestAction(api.groupNotifyApi),
1122
+ new GetGroupShutListAction(api)
1123
+ ];
1124
+ }
1125
+ // src/onebot11/helper/translate.ts
1126
+ /**
1127
+ * OB11 翻译辅助(NT 实体 → OB11 结构,P2-4)
1128
+ *
1129
+ * 纯函数(ADR-008):只读入参,不调 API、不读缓存。
1130
+ * 群成员/群信息等 NT 实体 → OB11 返回结构的薄映射。
1131
+ */
1132
+ /** NT Group → OB11 GroupInfo。 */
1133
+ function toOb11GroupInfo(group) {
1134
+ const info = {
1135
+ group_id: Number(group.groupCode),
1136
+ group_name: group.groupName
1137
+ };
1138
+ if (typeof group.memberCount === "number") info.member_count = group.memberCount;
1139
+ if (typeof group.maxMember === "number") info.max_member_count = group.maxMember;
1140
+ return info;
1141
+ }
1142
+ /** NT GroupDetailInfo → OB11 GroupInfo(getGroupDetailInfo / GroupCache 用)。 */
1143
+ function toOb11GroupInfoDetail(detail) {
1144
+ const info = {
1145
+ group_id: Number(detail.groupCode),
1146
+ group_name: detail.groupName
1147
+ };
1148
+ if (typeof detail.memberNum === "number") info.member_count = detail.memberNum;
1149
+ if (typeof detail.maxMemberNum === "number") info.max_member_count = detail.maxMemberNum;
1150
+ return info;
1151
+ }
1152
+ /** 禁言秒 → 毫秒(shut_up_timestamp 单位)。 */
1153
+ const SEC_TO_MS = 1e3;
1154
+ /** NT GroupMember → OB11 GroupMemberInfo(uin 由 uidToUin 映射补全)。 */
1155
+ function toOb11GroupMemberInfo(groupCode, member, uidToUin) {
1156
+ let uinStr = member.uin;
1157
+ if (uinStr === "") uinStr = uidToUin.get(member.uid) ?? member.uid;
1158
+ const info = {
1159
+ group_id: Number(groupCode),
1160
+ user_id: Number(uinStr),
1161
+ nickname: member.nick,
1162
+ role: GroupApi.roleToString(member.role)
1163
+ };
1164
+ if (member.cardName !== "") info.card = member.cardName;
1165
+ if (member.memberSpecialTitle !== void 0 && member.memberSpecialTitle !== "") {
1166
+ info.title = member.memberSpecialTitle;
1167
+ info.special_title = member.memberSpecialTitle;
1168
+ }
1169
+ if (member.shutUpTime > 0) info.shut_up_timestamp = member.shutUpTime * SEC_TO_MS;
1170
+ if (member.joinTime !== "" && member.joinTime !== "0") info.join_time = Number(member.joinTime);
1171
+ if (member.lastSpeakTime !== "" && member.lastSpeakTime !== "0") info.last_sent_time = Number(member.lastSpeakTime);
1172
+ if (typeof member.age === "number") info.age = member.age;
1173
+ return info;
1174
+ }
1175
+ // src/onebot11/action/group/query.ts
1176
+ /**
1177
+ * 群查询域动作(2026-11-14 自 get-group-info / get-group-list / get-group-member-info /
1178
+ * get-group-member-list / get-group-at-all-remain 合并)
1179
+ *
1180
+ * P2-4 接 kernel GroupApi;P2-17 群信息/成员动作优先读 GroupCache,no_cache=true
1181
+ * 直查 api。get_group_list 有实测校准:原生 getGroupList 返回值无数据(仅
1182
+ * { result, errMsg }),列表经 onGroupListUpdate 事件推送 → GroupCache 维护。
1183
+ */
1184
+ const getGroupInfoSchema = z.object({
1185
+ group_id: z.number(),
1186
+ /** 是否忽略缓存(go-cqhttp 扩展)。 */
1187
+ no_cache: z.boolean().optional()
1188
+ });
1189
+ /** 获取群信息(P2-4 接 kernel apis/group;P2-17 优先读 GroupCache)。 */
1190
+ var GetGroupInfoAction = class extends BaseAction {
1191
+ name = "get_group_info";
1192
+ schema = getGroupInfoSchema;
1193
+ errorCodeMap = ob11ErrorCodeMap;
1194
+ deps;
1195
+ constructor(deps) {
1196
+ super();
1197
+ this.deps = deps;
1198
+ }
1199
+ async _handle(payload) {
1200
+ const groupCode = String(payload.group_id);
1201
+ if (payload.no_cache !== true && this.deps.groupCache !== void 0) return toOb11GroupInfoDetail(await this.deps.groupCache.getGroupDetail(groupCode));
1202
+ return toOb11GroupInfoDetail(await this.deps.groupApi.getGroupInfo(groupCode));
1203
+ }
1204
+ };
1205
+ const getGroupListSchema = z.object({
1206
+ /** 是否忽略缓存(go-cqhttp 扩展)。 */
1207
+ no_cache: z.boolean().optional() });
1208
+ /** 获取群列表(P2-4 接 kernel apis/group;群列表数据经事件推送,从 GroupCache 读)。 */
1209
+ var GetGroupListAction = class extends BaseAction {
1210
+ name = "get_group_list";
1211
+ schema = getGroupListSchema;
1212
+ errorCodeMap = ob11ErrorCodeMap;
1213
+ deps;
1214
+ constructor(deps) {
1215
+ super();
1216
+ this.deps = deps;
1217
+ }
1218
+ async _handle(payload) {
1219
+ return (this.deps.groupCache === void 0 ? await this.deps.groupApi.getGroupList(true) : payload.no_cache === true ? await this.deps.groupCache.listGroupsRefreshed() : this.deps.groupCache.listGroups()).map(toOb11GroupInfo);
1220
+ }
1221
+ };
1222
+ const getGroupMemberInfoSchema = z.object({
1223
+ group_id: z.number(),
1224
+ user_id: z.number(),
1225
+ /** 是否忽略缓存(go-cqhttp 扩展)。 */
1226
+ no_cache: z.boolean().optional()
1227
+ });
1228
+ /** 获取群成员信息(P2-4 接 kernel apis/group;P2-17 优先读 GroupCache)。 */
1229
+ var GetGroupMemberInfoAction = class extends BaseAction {
1230
+ name = "get_group_member_info";
1231
+ schema = getGroupMemberInfoSchema;
1232
+ errorCodeMap = ob11ErrorCodeMap;
1233
+ deps;
1234
+ constructor(deps) {
1235
+ super();
1236
+ this.deps = deps;
1237
+ }
1238
+ async _handle(payload) {
1239
+ const groupCode = String(payload.group_id);
1240
+ const uid = (await this.deps.groupApi.uinToUid([String(payload.user_id)])).get(String(payload.user_id));
1241
+ if (uid === void 0) throw kernelError(`成员 ${payload.user_id} 不在群 ${payload.group_id}`, "NOT_FOUND");
1242
+ const member = await this.resolveMember(groupCode, uid, payload.no_cache === true);
1243
+ if (member === void 0) throw kernelError(`成员 ${payload.user_id} 不在群 ${payload.group_id}`, "NOT_FOUND");
1244
+ return toOb11GroupMemberInfo(groupCode, member, await this.deps.groupApi.uidToUin([uid]));
1245
+ }
1246
+ /** 读缓存(缺省)或直查 api(no_cache=true / 未装配缓存)。 */
1247
+ async resolveMember(groupCode, uid, noCache) {
1248
+ if (noCache || this.deps.groupCache === void 0) {
1249
+ const [member] = await this.deps.groupApi.getGroupMemberInfo(groupCode, [uid]);
1250
+ return member;
1251
+ }
1252
+ return await this.deps.groupCache.getMember(groupCode, uid);
1253
+ }
1254
+ };
1255
+ const getGroupMemberListSchema = z.object({
1256
+ group_id: z.number(),
1257
+ /** 是否忽略缓存(go-cqhttp 扩展)。 */
1258
+ no_cache: z.boolean().optional()
1259
+ });
1260
+ /** 获取群成员列表(P2-4 接 kernel apis/group;P2-17 优先读 GroupCache)。 */
1261
+ var GetGroupMemberListAction = class extends BaseAction {
1262
+ name = "get_group_member_list";
1263
+ schema = getGroupMemberListSchema;
1264
+ errorCodeMap = ob11ErrorCodeMap;
1265
+ deps;
1266
+ constructor(deps) {
1267
+ super();
1268
+ this.deps = deps;
1269
+ }
1270
+ async _handle(payload) {
1271
+ const groupCode = String(payload.group_id);
1272
+ const noCache = payload.no_cache === true;
1273
+ let members;
1274
+ if (noCache || this.deps.groupCache === void 0) members = await this.deps.groupApi.getGroupMemberList(groupCode, noCache);
1275
+ else members = await this.deps.groupCache.getMembers(groupCode);
1276
+ const uinMap = await this.deps.groupApi.uidToUin(members.map((m) => m.uid));
1277
+ return members.map((m) => toOb11GroupMemberInfo(groupCode, m, uinMap));
1278
+ }
1279
+ };
1280
+ const getGroupAtAllRemainSchema = z.object({ group_id: z.number() });
1281
+ /** 获取群 @全体成员 剩余次数(P2-10 接 kernel getGroupRemainAtTimes)。 */
1282
+ var GetGroupAtAllRemainAction = class extends BaseAction {
1283
+ name = "get_group_at_all_remain";
1284
+ schema = getGroupAtAllRemainSchema;
1285
+ errorCodeMap = ob11ErrorCodeMap;
1286
+ groupApi;
1287
+ constructor(groupApi) {
1288
+ super();
1289
+ this.groupApi = groupApi;
1290
+ }
1291
+ async _handle(payload) {
1292
+ const remain = await this.groupApi.getGroupRemainAtTimes(String(payload.group_id));
1293
+ return {
1294
+ can_at_all: remain.canAtAll,
1295
+ remain_at_all_count_for_uin: remain.remainAtAllCountForUin,
1296
+ remain_at_all_count_for_group: remain.remainAtAllCountForGroup
1297
+ };
1298
+ }
1299
+ };
1300
+ /** 群查询域动作工厂(group_info / group_list / member_info / member_list / at_all_remain)。 */
1301
+ function createGroupQueryActions(api) {
1302
+ return [
1303
+ new GetGroupInfoAction(api),
1304
+ new GetGroupListAction(api),
1305
+ new GetGroupMemberInfoAction(api),
1306
+ new GetGroupMemberListAction(api),
1307
+ new GetGroupAtAllRemainAction(api.groupApi)
1308
+ ];
1309
+ }
1310
+ // src/onebot11/helper/codec/cqcode.ts
1311
+ /**
1312
+ * CQ 码编解码(OneBot 11 消息段序列化格式)
1313
+ *
1314
+ * 纯函数、无 OB11 类型依赖:本文件只处理「文本 ↔ CQ 码片段」的通用编解码,
1315
+ * segment 级别的映射在 data.ts(OB11Constructor)。
1316
+ *
1317
+ * 转义规则(OneBot 11 规范):
1318
+ * - 纯文本:& → &,[ → [,] → ]
1319
+ * - 参数值:额外 , → ,
1320
+ */
1321
+ /** 解析单个 CQ 码文本 → 结构化 CqCode。 */
1322
+ function parseCqCode(raw) {
1323
+ const body = raw.slice(4, -1);
1324
+ const firstComma = body.indexOf(",");
1325
+ let type = body;
1392
1326
  if (firstComma !== -1) type = body.slice(0, firstComma);
1393
1327
  const params = {};
1394
1328
  if (firstComma !== -1) for (const pair of body.slice(firstComma + 1).split(",")) {
@@ -1869,7 +1803,7 @@ function toOb11MessageInfo(msg, unique, ctx = {}) {
1869
1803
  }
1870
1804
  // src/onebot11/helper/notice.ts
1871
1805
  /** 毫秒 → 秒(Unix 时间戳)。 */
1872
- const MS_TO_SEC$2 = 1e3;
1806
+ const MS_TO_SEC$1 = 1e3;
1873
1807
  /** 群文件业务类型(group_upload 的 file.busid,与 kernel 群文件系列同源语义)。 */
1874
1808
  const GROUP_FILE_BUS_ID = 102;
1875
1809
  /**
@@ -2023,7 +1957,7 @@ function toBan(common, grp, ctx) {
2023
1957
  function toFriendAdd(entry, selfUin) {
2024
1958
  const uin = entry.coreInfo?.uin ?? entry.uin ?? "";
2025
1959
  return {
2026
- time: Math.floor(Date.now() / MS_TO_SEC$2),
1960
+ time: Math.floor(Date.now() / MS_TO_SEC$1),
2027
1961
  self_id: Number(selfUin),
2028
1962
  post_type: "notice",
2029
1963
  notice_type: "friend_add",
@@ -2118,7 +2052,7 @@ function toOb11GroupRequestEvent(notify, ctx) {
2118
2052
  default: return null;
2119
2053
  }
2120
2054
  return {
2121
- time: Math.floor(Date.now() / MS_TO_SEC$3),
2055
+ time: Math.floor(Date.now() / MS_TO_SEC$2),
2122
2056
  self_id: Number(ctx.selfUin),
2123
2057
  post_type: "request",
2124
2058
  request_type: "group",
@@ -2136,7 +2070,7 @@ function toOb11GroupRequestEvent(notify, ctx) {
2136
2070
  function toOb11FriendRequestEvent(req, ctx) {
2137
2071
  const words = req["words"];
2138
2072
  return {
2139
- time: Math.floor(Date.now() / MS_TO_SEC$3),
2073
+ time: Math.floor(Date.now() / MS_TO_SEC$2),
2140
2074
  self_id: Number(ctx.selfUin),
2141
2075
  post_type: "request",
2142
2076
  request_type: "friend",
@@ -2145,62 +2079,259 @@ function toOb11FriendRequestEvent(req, ctx) {
2145
2079
  flag: req.reqTime
2146
2080
  };
2147
2081
  }
2148
- // src/onebot11/action/message/get-forward-msg.ts
2082
+ // src/onebot11/action/message/resolve-peer.ts
2149
2083
  /**
2150
- * get_forward_msg 动作:获取合并转发内容(P2-12 接 kernel MsgApi.fetchForwardMessage)
2084
+ * OB11 目标 Peer 解析 / 单条消息拉取(多个动作共用,2026-08-08 克隆合并)
2151
2085
  *
2152
- * message_id / id → 反查 msgId + peer → fetchForwardMessage(getMultiMsg)→
2153
- * 每条 toOb11MessageInfo → { messages }。
2086
+ * group_id 直通(群消息 peerUid = 群号);user_id 经 uin→uid 解析。
2154
2087
  */
2155
- const getForwardMsgSchema = z.object({
2156
- message_id: z.union([z.number(), z.string()]).optional(),
2157
- id: z.union([z.number(), z.string()]).optional()
2158
- });
2159
- /** 获取合并转发内容(P2-12 接 kernel fetchForwardMessage)。 */
2160
- var GetForwardMsgAction = class extends BaseAction {
2161
- name = "get_forward_msg";
2162
- schema = getForwardMsgSchema;
2163
- errorCodeMap = ob11ErrorCodeMap;
2164
- deps;
2165
- constructor(deps) {
2166
- super();
2167
- this.deps = deps;
2168
- }
2169
- async _handle(payload) {
2170
- const id = payload.message_id ?? payload.id;
2171
- if (id === void 0) throw kernelError("get_forward_msg 需要 message_id 或 id", "INVALID_PARAM");
2172
- const { msgId, peer } = resolveMsgIdAndPeer(id, this.deps.messageUnique);
2173
- return { messages: (await this.deps.msgApi.fetchForwardMessage(peer, msgId)).map((msg) => toOb11MessageInfo(msg, this.deps.messageUnique)) };
2088
+ /** 解析目标 Peer(group_id 直通;user_id 经 uin→uid)。 */
2089
+ async function resolveTargetPeer(payload, deps, missingHint) {
2090
+ if (payload.group_id !== void 0) return {
2091
+ chatType: ChatType.GROUP,
2092
+ peerUid: String(payload.group_id)
2093
+ };
2094
+ if (payload.user_id !== void 0) {
2095
+ const uid = (await deps.uinToUid([String(payload.user_id)])).get(String(payload.user_id));
2096
+ if (uid === void 0) throw kernelError(`用户 ${payload.user_id} 的 uid 解析失败`, "INVALID_PARAM");
2097
+ return {
2098
+ chatType: ChatType.C2C,
2099
+ peerUid: uid
2100
+ };
2174
2101
  }
2175
- };
2176
- /** 历史消息公共参数(message_seq / count / 反向排序)。 */
2177
- const msgHistoryParamsSchema = {
2178
- /** 起始消息序号(message_seq,缺省从最新拉)。 */
2179
- message_seq: z.union([z.number(), z.string()]).optional(),
2180
- count: z.number().default(20),
2181
- /** 是否反向排序(NapCat 扩展)。 */
2182
- reverse_order: z.boolean().optional(),
2183
- reverseOrder: z.boolean().optional()
2184
- };
2185
- /** 解析 message_seq → 起始 msgId(int32 经 MessageUnique 反查,否则原样透传)。 */
2186
- function resolveStartMsgId(messageSeq, messageUnique) {
2187
- if (messageSeq === void 0) return;
2188
- const raw = String(messageSeq);
2189
- const shortId = Number(raw);
2190
- if (Number.isFinite(shortId)) return messageUnique.getMsgId(shortId) ?? raw;
2191
- return raw;
2102
+ throw kernelError(missingHint, "INVALID_PARAM");
2192
2103
  }
2193
2104
  /**
2194
- * 拉取历史消息并翻译为 OB11 消息信息数组。
2195
- * 收集全部消息 at uid → 一次批量 uidToUin → 上下文注入(P2-19)。
2196
- * 群聊另取发送者角色表(GroupCache 一次整表读取,失败回退缺省 member)。
2105
+ * 按 message_id(OB11 int32 或 NT msgId)拉取单条消息。
2106
+ * 消息不存在/已被撤回 → 抛 KernelError NOT_FOUND。
2197
2107
  */
2198
- async function fetchAndTranslateHistory(peer, messageSeq, count, deps) {
2199
- const startMsgId = resolveStartMsgId(messageSeq, deps.messageUnique);
2200
- const opts = { count };
2201
- if (startMsgId !== void 0) opts.msgId = startMsgId;
2202
- const msgs = await deps.msgApi.fetchMessages(peer, opts);
2203
- if (msgs.length === 0) throw kernelError(`消息 ${messageSeq ?? "0"} 不存在`, "NOT_FOUND");
2108
+ async function fetchMsgById(messageId, messageUnique, msgApi) {
2109
+ const { msgId, peer } = resolveMsgIdAndPeer(messageId, messageUnique);
2110
+ const [msg] = await msgApi.fetchMsgsByMsgId(peer, [msgId]);
2111
+ if (msg === void 0) throw kernelError(`消息 ${messageId} 不存在或已被撤回`, "NOT_FOUND");
2112
+ return {
2113
+ msg,
2114
+ peer,
2115
+ msgId
2116
+ };
2117
+ }
2118
+ // src/onebot11/action/message/forward.ts
2119
+ /**
2120
+ * 消息转发域动作(2026-11-14 自 send-forward-msg / forward-single-msg /
2121
+ * get-forward-msg 合并)
2122
+ *
2123
+ * - send_group_forward_msg / send_private_forward_msg(P2-12):messages 每项为
2124
+ * node 元素 `{ type: "node", data: { id } }`——id 是此前 send_msg 返回的 OB11
2125
+ * message_id。经 MessageUnique 反查源 msgId + peer,组装到目标 peer(群直通 /
2126
+ * 私聊 uinToUid)→ MsgApi.sendForwardMessage
2127
+ * - forward_group_single_msg / forward_friend_single_msg(P2-12):message_id 反查
2128
+ * 源 msgId + peer;group_id/user_id 为目标 → MsgApi.forwardSingleMessage
2129
+ * - get_forward_msg(P2-12):message_id / id → fetchForwardMessage(getMultiMsg)
2130
+ * → 每条 toOb11MessageInfo → { messages }
2131
+ */
2132
+ const forwardNodeSchema = z.object({
2133
+ type: z.literal("node").optional(),
2134
+ data: z.object({ id: z.union([z.number(), z.string()]) }).optional()
2135
+ });
2136
+ const sendGroupForwardMsgSchema = z.object({
2137
+ group_id: z.number(),
2138
+ messages: z.array(z.unknown()).max(500).default([])
2139
+ });
2140
+ const sendPrivateForwardMsgSchema = z.object({
2141
+ user_id: z.number(),
2142
+ messages: z.array(z.unknown()).max(500).default([])
2143
+ });
2144
+ /** 解析 node 元素列表 → 源消息 (msgId, peer) 列表(id 反查,跳过无法解析的项)。 */
2145
+ function resolveSourceMessages(messages, unique) {
2146
+ const out = [];
2147
+ for (const raw of messages) {
2148
+ const parsed = forwardNodeSchema.safeParse(raw);
2149
+ if (parsed.success) {
2150
+ const id = parsed.data.data?.id;
2151
+ if (id !== void 0) {
2152
+ const msgId = unique.getMsgId(Number(id));
2153
+ if (msgId !== void 0) {
2154
+ const peer = unique.getPeer(msgId);
2155
+ if (peer !== void 0) out.push({
2156
+ msgId,
2157
+ peer
2158
+ });
2159
+ }
2160
+ }
2161
+ }
2162
+ }
2163
+ return out;
2164
+ }
2165
+ /** 合并转发发送(群/私聊共用:解析源消息 → 发送 → 映射 message_id)。 */
2166
+ async function sendForward(messages, target, deps) {
2167
+ const sources = resolveSourceMessages(messages, deps.messageUnique);
2168
+ const [firstSource] = sources;
2169
+ if (firstSource === void 0) throw kernelError("合并转发需要至少一条可解析的源消息(node.id)", "INVALID_PARAM");
2170
+ const { msgId } = await deps.msgApi.sendForwardMessage(target, firstSource.peer, sources.map((s) => s.msgId));
2171
+ return { message_id: deps.messageUnique.alloc(msgId, target) };
2172
+ }
2173
+ /** 发送群合并转发(P2-12 接 kernel sendForwardMessage)。 */
2174
+ var SendGroupForwardMsgAction = class extends BaseAction {
2175
+ name = "send_group_forward_msg";
2176
+ schema = sendGroupForwardMsgSchema;
2177
+ errorCodeMap = ob11ErrorCodeMap;
2178
+ deps;
2179
+ constructor(deps) {
2180
+ super();
2181
+ this.deps = deps;
2182
+ }
2183
+ async _handle(payload) {
2184
+ const target = {
2185
+ chatType: ChatType.GROUP,
2186
+ peerUid: String(payload.group_id)
2187
+ };
2188
+ return await sendForward(payload.messages, target, this.deps);
2189
+ }
2190
+ };
2191
+ /** 发送私聊合并转发(P2-12)。 */
2192
+ var SendPrivateForwardMsgAction = class extends BaseAction {
2193
+ name = "send_private_forward_msg";
2194
+ schema = sendPrivateForwardMsgSchema;
2195
+ errorCodeMap = ob11ErrorCodeMap;
2196
+ deps;
2197
+ constructor(deps) {
2198
+ super();
2199
+ this.deps = deps;
2200
+ }
2201
+ async _handle(payload) {
2202
+ const uid = await resolveUid(String(payload.user_id), this.deps.uinToUid);
2203
+ const target = {
2204
+ chatType: ChatType.C2C,
2205
+ peerUid: uid
2206
+ };
2207
+ return await sendForward(payload.messages, target, this.deps);
2208
+ }
2209
+ };
2210
+ const forwardSingleMsgSchema = z.object({
2211
+ message_id: z.union([z.number(), z.string()]),
2212
+ group_id: z.number().optional(),
2213
+ user_id: z.number().optional()
2214
+ });
2215
+ /** 单条转发基类(两个动作共用实现)。 */
2216
+ var ForwardSingleMsgBase = class extends BaseAction {
2217
+ errorCodeMap = ob11ErrorCodeMap;
2218
+ deps;
2219
+ constructor(deps) {
2220
+ super();
2221
+ this.deps = deps;
2222
+ }
2223
+ async _handle(payload) {
2224
+ const { msgId, peer: sourcePeer } = resolveMsgIdAndPeer(payload.message_id, this.deps.messageUnique);
2225
+ const dstPeer = await resolveTargetPeer(payload, this.deps, "单条转发需要 group_id 或 user_id");
2226
+ await this.deps.msgApi.forwardSingleMessage(sourcePeer, [msgId], dstPeer);
2227
+ return null;
2228
+ }
2229
+ };
2230
+ /** 转发单条消息到群(P2-12)。 */
2231
+ var ForwardGroupSingleMsgAction = class extends ForwardSingleMsgBase {
2232
+ name = "forward_group_single_msg";
2233
+ schema = forwardSingleMsgSchema;
2234
+ };
2235
+ /** 转发单条消息到好友(P2-12)。 */
2236
+ var ForwardFriendSingleMsgAction = class extends ForwardSingleMsgBase {
2237
+ name = "forward_friend_single_msg";
2238
+ schema = forwardSingleMsgSchema;
2239
+ };
2240
+ const getForwardMsgSchema = z.object({
2241
+ message_id: z.union([z.number(), z.string()]).optional(),
2242
+ id: z.union([z.number(), z.string()]).optional()
2243
+ });
2244
+ /** 获取合并转发内容(P2-12 接 kernel fetchForwardMessage)。 */
2245
+ var GetForwardMsgAction = class extends BaseAction {
2246
+ name = "get_forward_msg";
2247
+ schema = getForwardMsgSchema;
2248
+ errorCodeMap = ob11ErrorCodeMap;
2249
+ deps;
2250
+ constructor(deps) {
2251
+ super();
2252
+ this.deps = deps;
2253
+ }
2254
+ async _handle(payload) {
2255
+ const id = payload.message_id ?? payload.id;
2256
+ if (id === void 0) throw kernelError("get_forward_msg 需要 message_id 或 id", "INVALID_PARAM");
2257
+ const { msgId, peer } = resolveMsgIdAndPeer(id, this.deps.messageUnique);
2258
+ return { messages: (await this.deps.msgApi.fetchForwardMessage(peer, msgId)).map((msg) => toOb11MessageInfo(msg, this.deps.messageUnique)) };
2259
+ }
2260
+ };
2261
+ /** 消息转发域动作工厂(合并转发 ×2 / 单条转发 ×2 / get_forward_msg)。 */
2262
+ function createForwardActions(api) {
2263
+ return [
2264
+ new SendGroupForwardMsgAction(api),
2265
+ new SendPrivateForwardMsgAction(api),
2266
+ new GetForwardMsgAction(api),
2267
+ new ForwardGroupSingleMsgAction(api),
2268
+ new ForwardFriendSingleMsgAction(api)
2269
+ ];
2270
+ }
2271
+ // src/onebot11/action/message/history.ts
2272
+ /**
2273
+ * 消息读取域动作(2026-11-14 自 get-msg / msg-history / get-group-msg-history /
2274
+ * get-friend-msg-history 合并)
2275
+ *
2276
+ * - get_msg:message_id → msgId + peer(MessageUnique 反查)→ 拉消息 → OB11 消息信息
2277
+ * - get_group_msg_history(go-cqhttp 扩展)/ get_friend_msg_history(NapCat 扩展):
2278
+ * 拉取历史消息 → at uid 批量转换 → OB11 消息信息数组(共享 fetchAndTranslateHistory)
2279
+ */
2280
+ const getMsgSchema = z.object({ message_id: z.union([z.number(), z.string()]) });
2281
+ /** 获取消息详情(P2-10 接 kernel fetchMsgsByMsgId)。 */
2282
+ var GetMsgAction = class extends BaseAction {
2283
+ name = "get_msg";
2284
+ schema = getMsgSchema;
2285
+ errorCodeMap = ob11ErrorCodeMap;
2286
+ deps;
2287
+ constructor(deps) {
2288
+ super();
2289
+ this.deps = deps;
2290
+ }
2291
+ async _handle(payload) {
2292
+ const { msg } = await fetchMsgById(payload.message_id, this.deps.messageUnique, this.deps.msgApi);
2293
+ const { atUids } = collectReceiveNeeds(toCanonicalElements(msg));
2294
+ let uidToUin;
2295
+ if (atUids.length > 0) try {
2296
+ uidToUin = await this.deps.uidToUin(atUids);
2297
+ } catch {}
2298
+ const senderRole = msg.chatType === ChatType.GROUP ? await this.deps.groupMemberRole(msg.peerUid, msg.senderUid) : void 0;
2299
+ const ctx = {
2300
+ ...uidToUin !== void 0 ? { uidToUin } : {},
2301
+ ...senderRole !== void 0 ? { senderRole } : {},
2302
+ msgIdToOb11Id: (m) => this.deps.messageUnique.getMessageId(m)
2303
+ };
2304
+ return toOb11MessageInfo(msg, this.deps.messageUnique, ctx);
2305
+ }
2306
+ };
2307
+ /** 历史消息公共参数(message_seq / count / 反向排序)。 */
2308
+ const msgHistoryParamsSchema = {
2309
+ /** 起始消息序号(message_seq,缺省从最新拉)。 */
2310
+ message_seq: z.union([z.number(), z.string()]).optional(),
2311
+ count: z.number().default(20),
2312
+ /** 是否反向排序(NapCat 扩展)。 */
2313
+ reverse_order: z.boolean().optional(),
2314
+ reverseOrder: z.boolean().optional()
2315
+ };
2316
+ /** 解析 message_seq → 起始 msgId(int32 经 MessageUnique 反查,否则原样透传)。 */
2317
+ function resolveStartMsgId(messageSeq, messageUnique) {
2318
+ if (messageSeq === void 0) return;
2319
+ const raw = String(messageSeq);
2320
+ const shortId = Number(raw);
2321
+ if (Number.isFinite(shortId)) return messageUnique.getMsgId(shortId) ?? raw;
2322
+ return raw;
2323
+ }
2324
+ /**
2325
+ * 拉取历史消息并翻译为 OB11 消息信息数组。
2326
+ * 收集全部消息 at uid → 一次批量 uidToUin → 上下文注入(P2-19)。
2327
+ * 群聊另取发送者角色表(GroupCache 一次整表读取,失败回退缺省 member)。
2328
+ */
2329
+ async function fetchAndTranslateHistory(peer, messageSeq, count, deps) {
2330
+ const startMsgId = resolveStartMsgId(messageSeq, deps.messageUnique);
2331
+ const opts = { count };
2332
+ if (startMsgId !== void 0) opts.msgId = startMsgId;
2333
+ const msgs = await deps.msgApi.fetchMessages(peer, opts);
2334
+ if (msgs.length === 0) throw kernelError(`消息 ${messageSeq ?? "0"} 不存在`, "NOT_FOUND");
2204
2335
  const atUids = /* @__PURE__ */ new Set();
2205
2336
  for (const m of msgs) {
2206
2337
  const { atUids: uids } = collectReceiveNeeds(toCanonicalElements(m));
@@ -2224,20 +2355,14 @@ async function fetchAndTranslateHistory(peer, messageSeq, count, deps) {
2224
2355
  });
2225
2356
  }) };
2226
2357
  }
2227
- // src/onebot11/action/message/get-friend-msg-history.ts
2228
- /**
2229
- * get_friend_msg_history 动作:获取私聊历史消息(NapCat 扩展,P2-10)
2230
- *
2231
- * user_id → uin→uid → Peer{ C2C } → fetchMessages → 数组翻译。
2232
- */
2233
- const getFriendMsgHistorySchema = z.object({
2234
- user_id: z.number(),
2358
+ const getGroupMsgHistorySchema = z.object({
2359
+ group_id: z.number(),
2235
2360
  ...msgHistoryParamsSchema
2236
2361
  });
2237
- /** 获取私聊历史消息(P2-10 接 kernel fetchMessages)。 */
2238
- var GetFriendMsgHistoryAction = class extends BaseAction {
2239
- name = "get_friend_msg_history";
2240
- schema = getFriendMsgHistorySchema;
2362
+ /** 获取群历史消息(P2-10 接 kernel fetchMessages)。 */
2363
+ var GetGroupMsgHistoryAction = class extends BaseAction {
2364
+ name = "get_group_msg_history";
2365
+ schema = getGroupMsgHistorySchema;
2241
2366
  errorCodeMap = ob11ErrorCodeMap;
2242
2367
  deps;
2243
2368
  constructor(deps) {
@@ -2245,28 +2370,20 @@ var GetFriendMsgHistoryAction = class extends BaseAction {
2245
2370
  this.deps = deps;
2246
2371
  }
2247
2372
  async _handle(payload) {
2248
- const uid = await resolveUid(String(payload.user_id), this.deps.uinToUid);
2249
2373
  return await fetchAndTranslateHistory({
2250
- chatType: ChatType.C2C,
2251
- peerUid: uid
2374
+ chatType: ChatType.GROUP,
2375
+ peerUid: String(payload.group_id)
2252
2376
  }, payload.message_seq, payload.count, this.deps);
2253
2377
  }
2254
2378
  };
2255
- // src/onebot11/action/message/get-group-msg-history.ts
2256
- /**
2257
- * get_group_msg_history 动作:获取群历史消息(go-cqhttp 扩展,P2-10)
2258
- *
2259
- * group_id → Peer{ GROUP } → MsgApi.fetchMessages(message_seq 起,count 条)
2260
- * → 数组翻译为 OB11 消息信息。
2261
- */
2262
- const getGroupMsgHistorySchema = z.object({
2263
- group_id: z.number(),
2379
+ const getFriendMsgHistorySchema = z.object({
2380
+ user_id: z.number(),
2264
2381
  ...msgHistoryParamsSchema
2265
2382
  });
2266
- /** 获取群历史消息(P2-10 接 kernel fetchMessages)。 */
2267
- var GetGroupMsgHistoryAction = class extends BaseAction {
2268
- name = "get_group_msg_history";
2269
- schema = getGroupMsgHistorySchema;
2383
+ /** 获取私聊历史消息(P2-10 接 kernel fetchMessages)。 */
2384
+ var GetFriendMsgHistoryAction = class extends BaseAction {
2385
+ name = "get_friend_msg_history";
2386
+ schema = getFriendMsgHistorySchema;
2270
2387
  errorCodeMap = ob11ErrorCodeMap;
2271
2388
  deps;
2272
2389
  constructor(deps) {
@@ -2274,25 +2391,37 @@ var GetGroupMsgHistoryAction = class extends BaseAction {
2274
2391
  this.deps = deps;
2275
2392
  }
2276
2393
  async _handle(payload) {
2394
+ const uid = await resolveUid(String(payload.user_id), this.deps.uinToUid);
2277
2395
  return await fetchAndTranslateHistory({
2278
- chatType: ChatType.GROUP,
2279
- peerUid: String(payload.group_id)
2396
+ chatType: ChatType.C2C,
2397
+ peerUid: uid
2280
2398
  }, payload.message_seq, payload.count, this.deps);
2281
2399
  }
2282
2400
  };
2283
- // src/onebot11/action/message/get-media.ts
2401
+ /** 消息读取域动作工厂(get_msg / get_group_msg_history / get_friend_msg_history)。 */
2402
+ function createHistoryActions(api) {
2403
+ return [
2404
+ new GetMsgAction(api),
2405
+ new GetGroupMsgHistoryAction(api),
2406
+ new GetFriendMsgHistoryAction(api)
2407
+ ];
2408
+ }
2409
+ // src/onebot11/action/message/media.ts
2284
2410
  /**
2285
- * get_image / get_record 动作:获取图片/语音文件(P2-14;2026-09-08 T5 接主动下载;
2286
- * 2026-09-08 B1 语音接原生 downloadRichMedia)
2411
+ * 消息媒体域动作(2026-11-14 自 get-media / fetch-ptt-text 合并)
2287
2412
  *
2288
- * message_id 反查 → fetchMsgsByMsgId → 找 PIC/PTT 元素:
2289
- * - 本地文件解析:NT 相对路径(sourcePath/filePath)按 mediaBaseDir(QQ NT
2290
- * global 目录)解析为绝对路径,命中磁盘即返回 file
2291
- * - 图片主动下载:本地未命中且有 picUrl → @napuketto/media downloadUrl 落
2292
- * cacheDir/media/,返回 file(绝对路径)+ url + file_size/file_name
2293
- * - 语音主动下载(B1):本地未命中 → kernel MsgApi.downloadPtt(原生
2294
- * downloadRichMedia + 轮询元素回查)→ filePath 落盘后返回绝对路径;
2295
- * 失败回退原始 filePath(NT 相对/绝对)+ 元数据,不抛错
2413
+ * - get_image / get_record:获取图片/语音文件(P2-14;2026-09-08 T5 接主动下载;
2414
+ * 2026-09-08 B1 语音接原生 downloadRichMedia)。message_id 反查 → fetchMsgsByMsgId
2415
+ * → 找 PIC/PTT 元素:
2416
+ * - 本地文件解析:NT 相对路径(sourcePath/filePath)按 mediaBaseDir(QQ NT
2417
+ * global 目录)解析为绝对路径,命中磁盘即返回 file
2418
+ * - 图片主动下载:本地未命中且有 picUrl → @napuketto/media downloadUrl 落
2419
+ * cacheDir/media/,返回 file(绝对路径)+ url + file_size/file_name
2420
+ * - 语音主动下载(B1):本地未命中 → kernel MsgApi.downloadPtt(原生
2421
+ * downloadRichMedia + 轮询元素回查)→ filePath 落盘后返回绝对路径;
2422
+ * 失败回退原始 filePath(NT 相对/绝对)+ 元数据,不抛错
2423
+ * - fetch_ptt_text:message_id → MsgApi.fetchPttText(内部:拉消息 → 找 PTT 元素
2424
+ * → translatePtt2Text → 再拉取读 pttElement.text)
2296
2425
  */
2297
2426
  const getMediaSchema = z.object({
2298
2427
  /** CQ 码 file 字段或 message_id(简化:message_id 反查)。 */
@@ -2424,17 +2553,11 @@ var GetRecordAction = class extends BaseAction {
2424
2553
  };
2425
2554
  }
2426
2555
  };
2427
- // src/onebot11/action/message/get-msg.ts
2428
- /**
2429
- * get_msg 动作:获取消息详情(P2-10 接 kernel MsgApi.fetchMsgsByMsgId)
2430
- *
2431
- * message_id → msgId + peer(MessageUnique 反查)→ 拉消息 → OB11 消息信息结构。
2432
- */
2433
- const getMsgSchema = z.object({ message_id: z.union([z.number(), z.string()]) });
2434
- /** 获取消息详情(P2-10 接 kernel fetchMsgsByMsgId)。 */
2435
- var GetMsgAction = class extends BaseAction {
2436
- name = "get_msg";
2437
- schema = getMsgSchema;
2556
+ const fetchPttTextSchema = z.object({ message_id: z.union([z.number(), z.string()]) });
2557
+ /** 获取语音转文字结果(P2-10 接 kernel fetchPttText)。 */
2558
+ var FetchPttTextAction = class extends BaseAction {
2559
+ name = "fetch_ptt_text";
2560
+ schema = fetchPttTextSchema;
2438
2561
  errorCodeMap = ob11ErrorCodeMap;
2439
2562
  deps;
2440
2563
  constructor(deps) {
@@ -2442,29 +2565,47 @@ var GetMsgAction = class extends BaseAction {
2442
2565
  this.deps = deps;
2443
2566
  }
2444
2567
  async _handle(payload) {
2445
- const { msg } = await fetchMsgById(payload.message_id, this.deps.messageUnique, this.deps.msgApi);
2446
- const { atUids } = collectReceiveNeeds(toCanonicalElements(msg));
2447
- let uidToUin;
2448
- if (atUids.length > 0) try {
2449
- uidToUin = await this.deps.uidToUin(atUids);
2450
- } catch {}
2451
- const senderRole = msg.chatType === ChatType.GROUP ? await this.deps.groupMemberRole(msg.peerUid, msg.senderUid) : void 0;
2452
- const ctx = {
2453
- ...uidToUin !== void 0 ? { uidToUin } : {},
2454
- ...senderRole !== void 0 ? { senderRole } : {},
2455
- msgIdToOb11Id: (m) => this.deps.messageUnique.getMessageId(m)
2456
- };
2457
- return toOb11MessageInfo(msg, this.deps.messageUnique, ctx);
2568
+ const { msgId, peer } = resolveMsgIdAndPeer(payload.message_id, this.deps.messageUnique);
2569
+ return { text: await this.deps.msgApi.fetchPttText(msgId, peer) };
2458
2570
  }
2459
2571
  };
2460
- // src/onebot11/action/message/mark-msg-as-read.ts
2572
+ /** 消息媒体域动作工厂(get_image / get_record / fetch_ptt_text)。 */
2573
+ function createMediaActions(api) {
2574
+ return [
2575
+ new GetImageAction(api),
2576
+ new GetRecordAction(api),
2577
+ new FetchPttTextAction(api)
2578
+ ];
2579
+ }
2580
+ // src/onebot11/action/message/ops.ts
2461
2581
  /**
2462
- * mark_msg_as_read 动作:标记消息已读(P2-10 接 kernel MsgApi.markRead)
2582
+ * 消息操作域动作(2026-11-14 自 delete-msg / mark-msg-as-read(-aliases) /
2583
+ * set-msg-emoji-like / set-input-status 合并)
2463
2584
  *
2464
- * OB11 标准 mark_msg_as_read 以 user_id 为参数;NapCat 扩展同时支持 group_id
2465
- * (mark_private_msg_as_read / mark_group_msg_as_read 由 adapter 层同名动作或
2466
- * 语义别名处理)。user_id → C2C peer;group_id → GROUP peer。
2585
+ * - delete_msg:撤回消息(OB11 标准只有 message_id,peer 经 MessageUnique 反查;
2586
+ * 群聊管理员 / 私聊 2 分钟内可撤回)
2587
+ * - mark_msg_as_read:OB11 标准以 user_id 为参数,NapCat 扩展同时支持 group_id;
2588
+ * mark_private_msg_as_read / mark_group_msg_as_read 为细分同名动作
2589
+ * - set_msg_emoji_like:message_id → 拉消息取 msgSeq → MsgApi.setMsgEmojiLike
2590
+ * - set_input_status:user_id → uinToUid → MsgApi.setInputStatus(1=输入中,0=停止)
2467
2591
  */
2592
+ const deleteMsgSchema = z.object({ message_id: z.union([z.number(), z.string()]) });
2593
+ /** 撤回消息(P2-10 接 kernel recallMessage)。 */
2594
+ var DeleteMsgAction = class extends BaseAction {
2595
+ name = "delete_msg";
2596
+ schema = deleteMsgSchema;
2597
+ errorCodeMap = ob11ErrorCodeMap;
2598
+ deps;
2599
+ constructor(deps) {
2600
+ super();
2601
+ this.deps = deps;
2602
+ }
2603
+ async _handle(payload) {
2604
+ const { msgId, peer } = resolveMsgIdAndPeer(payload.message_id, this.deps.messageUnique);
2605
+ await this.deps.msgApi.recallMessage(peer, [msgId]);
2606
+ return null;
2607
+ }
2608
+ };
2468
2609
  const markMsgAsReadSchema = z.object({
2469
2610
  user_id: z.number().optional(),
2470
2611
  group_id: z.number().optional()
@@ -2497,14 +2638,6 @@ var MarkMsgAsReadAction = class extends BaseAction {
2497
2638
  return null;
2498
2639
  }
2499
2640
  };
2500
- // src/onebot11/action/message/mark-msg-as-read-aliases.ts
2501
- /**
2502
- * mark_private_msg_as_read / mark_group_msg_as_read 动作:标记会话已读(P2-13)
2503
- *
2504
- * mark_msg_as_read 的细分别名(NapCat 扩展):
2505
- * - mark_private_msg_as_read:user_id → C2C markRead
2506
- * - mark_group_msg_as_read:group_id → GROUP markRead
2507
- */
2508
2641
  const markPrivateMsgAsReadSchema = z.object({ user_id: z.number() });
2509
2642
  const markGroupMsgAsReadSchema = z.object({ group_id: z.number() });
2510
2643
  /** 标记私聊已读(P2-13)。 */
@@ -2544,59 +2677,19 @@ var MarkGroupMsgAsReadAction = class extends BaseAction {
2544
2677
  return null;
2545
2678
  }
2546
2679
  };
2547
- // src/onebot11/action/message/send-forward-msg.ts
2548
- /**
2549
- * send_group_forward_msg / send_private_forward_msg 动作:发送合并转发(P2-12)
2550
- *
2551
- * messages 每项为 node 元素 `{ type: "node", data: { id } }`——id 是此前
2552
- * send_msg 返回的 OB11 message_id。经 MessageUnique 反查源 msgId + peer,
2553
- * 组装到目标 peer(群直通 / 私聊 uinToUid)→ MsgApi.sendForwardMessage。
2554
- */
2555
- const forwardNodeSchema = z.object({
2556
- type: z.literal("node").optional(),
2557
- data: z.object({ id: z.union([z.number(), z.string()]) }).optional()
2558
- });
2559
- const sendGroupForwardMsgSchema = z.object({
2560
- group_id: z.number(),
2561
- messages: z.array(z.unknown()).max(500).default([])
2562
- });
2563
- const sendPrivateForwardMsgSchema = z.object({
2564
- user_id: z.number(),
2565
- messages: z.array(z.unknown()).max(500).default([])
2680
+ const setMsgEmojiLikeSchema = z.object({
2681
+ message_id: z.union([z.number(), z.string()]),
2682
+ /** 表情 ID(如 105 点赞)。 */
2683
+ emoji_id: z.number(),
2684
+ /** 表情类型(默认 1)。 */
2685
+ emoji_type: z.number().optional(),
2686
+ /** 是否点赞(false 取消)。 */
2687
+ like: z.boolean().optional()
2566
2688
  });
2567
- /** 解析 node 元素列表 → 源消息 (msgId, peer) 列表(id 反查,跳过无法解析的项)。 */
2568
- function resolveSourceMessages(messages, unique) {
2569
- const out = [];
2570
- for (const raw of messages) {
2571
- const parsed = forwardNodeSchema.safeParse(raw);
2572
- if (parsed.success) {
2573
- const id = parsed.data.data?.id;
2574
- if (id !== void 0) {
2575
- const msgId = unique.getMsgId(Number(id));
2576
- if (msgId !== void 0) {
2577
- const peer = unique.getPeer(msgId);
2578
- if (peer !== void 0) out.push({
2579
- msgId,
2580
- peer
2581
- });
2582
- }
2583
- }
2584
- }
2585
- }
2586
- return out;
2587
- }
2588
- /** 合并转发发送(群/私聊共用:解析源消息 → 发送 → 映射 message_id)。 */
2589
- async function sendForward(messages, target, deps) {
2590
- const sources = resolveSourceMessages(messages, deps.messageUnique);
2591
- const [firstSource] = sources;
2592
- if (firstSource === void 0) throw kernelError("合并转发需要至少一条可解析的源消息(node.id)", "INVALID_PARAM");
2593
- const { msgId } = await deps.msgApi.sendForwardMessage(target, firstSource.peer, sources.map((s) => s.msgId));
2594
- return { message_id: deps.messageUnique.alloc(msgId, target) };
2595
- }
2596
- /** 发送群合并转发(P2-12 接 kernel sendForwardMessage)。 */
2597
- var SendGroupForwardMsgAction = class extends BaseAction {
2598
- name = "send_group_forward_msg";
2599
- schema = sendGroupForwardMsgSchema;
2689
+ /** 消息表情表态(P2-10 接 kernel setMsgEmojiLike)。 */
2690
+ var SetMsgEmojiLikeAction = class extends BaseAction {
2691
+ name = "set_msg_emoji_like";
2692
+ schema = setMsgEmojiLikeSchema;
2600
2693
  errorCodeMap = ob11ErrorCodeMap;
2601
2694
  deps;
2602
2695
  constructor(deps) {
@@ -2604,17 +2697,27 @@ var SendGroupForwardMsgAction = class extends BaseAction {
2604
2697
  this.deps = deps;
2605
2698
  }
2606
2699
  async _handle(payload) {
2607
- const target = {
2608
- chatType: ChatType.GROUP,
2609
- peerUid: String(payload.group_id)
2610
- };
2611
- return await sendForward(payload.messages, target, this.deps);
2700
+ const { msg, peer } = await fetchMsgById(payload.message_id, this.deps.messageUnique, this.deps.msgApi);
2701
+ await this.deps.msgApi.setMsgEmojiLike(peer, {
2702
+ msgSeq: msg.msgSeq,
2703
+ emojiId: String(payload.emoji_id),
2704
+ emojiType: String(payload.emoji_type ?? 1),
2705
+ like: payload.like ?? true
2706
+ });
2707
+ return null;
2612
2708
  }
2613
2709
  };
2614
- /** 发送私聊合并转发(P2-12)。 */
2615
- var SendPrivateForwardMsgAction = class extends BaseAction {
2616
- name = "send_private_forward_msg";
2617
- schema = sendPrivateForwardMsgSchema;
2710
+ const setInputStatusSchema = z.object({
2711
+ user_id: z.number(),
2712
+ /** 输入事件类型:1=输入中,0=停止。 */
2713
+ event_type: z.number().optional()
2714
+ });
2715
+ /** 输入中事件类型。 */
2716
+ const EVENT_TYPE_TYPING = 1;
2717
+ /** 发送输入状态(P2-11 接 kernel setInputStatus)。 */
2718
+ var SetInputStatusAction = class extends BaseAction {
2719
+ name = "set_input_status";
2720
+ schema = setInputStatusSchema;
2618
2721
  errorCodeMap = ob11ErrorCodeMap;
2619
2722
  deps;
2620
2723
  constructor(deps) {
@@ -2623,14 +2726,28 @@ var SendPrivateForwardMsgAction = class extends BaseAction {
2623
2726
  }
2624
2727
  async _handle(payload) {
2625
2728
  const uid = await resolveUid(String(payload.user_id), this.deps.uinToUid);
2626
- const target = {
2729
+ await this.deps.msgApi.setInputStatus({
2627
2730
  chatType: ChatType.C2C,
2628
2731
  peerUid: uid
2629
- };
2630
- return await sendForward(payload.messages, target, this.deps);
2732
+ }, payload.event_type ?? EVENT_TYPE_TYPING);
2733
+ return null;
2631
2734
  }
2632
2735
  };
2633
- // src/onebot11/action/message/send-msg.ts
2736
+ /**
2737
+ * 消息操作域动作工厂(delete_msg / mark_msg_as_read 系列 / set_msg_emoji_like /
2738
+ * set_input_status)。
2739
+ */
2740
+ function createMsgOpsActions(api) {
2741
+ return [
2742
+ new DeleteMsgAction(api),
2743
+ new MarkMsgAsReadAction(api),
2744
+ new MarkPrivateMsgAsReadAction(api),
2745
+ new MarkGroupMsgAsReadAction(api),
2746
+ new SetMsgEmojiLikeAction(api),
2747
+ new SetInputStatusAction(api)
2748
+ ];
2749
+ }
2750
+ // src/onebot11/action/message/send.ts
2634
2751
  const sendMsgSchema = z.object({
2635
2752
  message_type: z.enum(["group", "private"]).optional(),
2636
2753
  user_id: z.number().optional(),
@@ -2684,33 +2801,15 @@ var SendMsgAction = class extends BaseAction {
2684
2801
  return sendOb11Message(payload, this.deps);
2685
2802
  }
2686
2803
  };
2687
- /** CQ 特殊字符转义(auto_escape,&、[、]、, 前置 &)。 */
2688
- function escapeText(text) {
2689
- return text.replaceAll("&", "&").replaceAll("[", "[").replaceAll("]", "]").replaceAll(",", ",");
2690
- }
2691
- /** 语音元素统一转 silk:非 silk 自动转码(QQ 语音格式),已是 silk 原样。 */
2692
- async function ensureVoiceSilk(elements) {
2693
- const out = [];
2694
- for (const el of elements) if (el.type === "voice") out.push({
2695
- ...el,
2696
- path: await ensureSilk(el.path)
2697
- });
2698
- else out.push(el);
2699
- return out;
2700
- }
2701
- // src/onebot11/action/message/send-group-msg.ts
2702
- /**
2703
- * send_group_msg 动作:发送群聊消息(复用 sendOb11Message 核心)
2704
- */
2705
- const sendGroupMsgSchema = z.object({
2706
- group_id: z.number(),
2804
+ const sendPrivateMsgSchema = z.object({
2805
+ user_id: z.number(),
2707
2806
  message: z.union([z.string(), z.array(z.unknown()).max(200)]),
2708
2807
  auto_escape: z.boolean().optional()
2709
2808
  });
2710
- /** 发送群聊消息(P2-10 复用 sendOb11Message)。 */
2711
- var SendGroupMsgAction = class extends BaseAction {
2712
- name = "send_group_msg";
2713
- schema = sendGroupMsgSchema;
2809
+ /** 发送私聊消息(P2-10 复用 sendOb11Message)。 */
2810
+ var SendPrivateMsgAction = class extends BaseAction {
2811
+ name = "send_private_msg";
2812
+ schema = sendPrivateMsgSchema;
2714
2813
  errorCodeMap = ob11ErrorCodeMap;
2715
2814
  deps;
2716
2815
  constructor(deps) {
@@ -2721,19 +2820,15 @@ var SendGroupMsgAction = class extends BaseAction {
2721
2820
  return sendOb11Message(payload, this.deps);
2722
2821
  }
2723
2822
  };
2724
- // src/onebot11/action/message/send-private-msg.ts
2725
- /**
2726
- * send_private_msg 动作:发送私聊消息(复用 sendOb11Message 核心)
2727
- */
2728
- const sendPrivateMsgSchema = z.object({
2729
- user_id: z.number(),
2823
+ const sendGroupMsgSchema = z.object({
2824
+ group_id: z.number(),
2730
2825
  message: z.union([z.string(), z.array(z.unknown()).max(200)]),
2731
2826
  auto_escape: z.boolean().optional()
2732
2827
  });
2733
- /** 发送私聊消息(P2-10 复用 sendOb11Message)。 */
2734
- var SendPrivateMsgAction = class extends BaseAction {
2735
- name = "send_private_msg";
2736
- schema = sendPrivateMsgSchema;
2828
+ /** 发送群聊消息(P2-10 复用 sendOb11Message)。 */
2829
+ var SendGroupMsgAction = class extends BaseAction {
2830
+ name = "send_group_msg";
2831
+ schema = sendGroupMsgSchema;
2737
2832
  errorCodeMap = ob11ErrorCodeMap;
2738
2833
  deps;
2739
2834
  constructor(deps) {
@@ -2744,175 +2839,76 @@ var SendPrivateMsgAction = class extends BaseAction {
2744
2839
  return sendOb11Message(payload, this.deps);
2745
2840
  }
2746
2841
  };
2747
- // src/onebot11/action/message/set-input-status.ts
2842
+ /** CQ 特殊字符转义(auto_escape,&、[、]、, 前置 &)。 */
2843
+ function escapeText(text) {
2844
+ return text.replaceAll("&", "&").replaceAll("[", "[").replaceAll("]", "]").replaceAll(",", ",");
2845
+ }
2846
+ /** 语音元素统一转 silk:非 silk 自动转码(QQ 语音格式),已是 silk 原样。 */
2847
+ async function ensureVoiceSilk(elements) {
2848
+ const out = [];
2849
+ for (const el of elements) if (el.type === "voice") out.push({
2850
+ ...el,
2851
+ path: await ensureSilk(el.path)
2852
+ });
2853
+ else out.push(el);
2854
+ return out;
2855
+ }
2856
+ /** 消息发送域动作工厂(send_msg / send_private_msg / send_group_msg)。 */
2857
+ function createSendActions(api) {
2858
+ return [
2859
+ new SendMsgAction(api),
2860
+ new SendPrivateMsgAction(api),
2861
+ new SendGroupMsgAction(api)
2862
+ ];
2863
+ }
2864
+ // src/onebot11/action/system/account.ts
2748
2865
  /**
2749
- * set_input_status 动作:发送输入状态(NapCat 扩展,P2-11)
2866
+ * 账号票据与资料域动作(2026-11-14 自 get-cookies / get-clientkey /
2867
+ * get-credentials / profile-actions 合并)
2750
2868
  *
2751
- * user_id → uinToUid → MsgApi.setInputStatus(peer, eventType)。
2752
- * eventType:1=输入中,0=停止输入。
2869
+ * - get_cookies(P2-13):kernel TicketApi.getCookies,domain 缺省 v2.qq.com
2870
+ * (NapCat 行为);user_id 缺省用机器人自身 uin
2871
+ * - get_clientkey(P2-13):kernel TicketApi.getClientKey
2872
+ * - get_csrf_token / get_credentials(P2-15):qun.qq.com cookies 的 skey → bkn
2873
+ * (csrf 等价物);get_credentials 返回指定域名 cookies + bkn
2874
+ * - set_self_longnick / set_qq_profile / set_qq_avatar(P2-14):kernel ProfileApi;
2875
+ * set_qq_profile 的 sex 忽略,头像 URL 需先经 cacheDir 下载
2753
2876
  */
2754
- const setInputStatusSchema = z.object({
2755
- user_id: z.number(),
2756
- /** 输入事件类型:1=输入中,0=停止。 */
2757
- event_type: z.number().optional()
2877
+ /** URL 前缀(头像在线文件识别)。 */
2878
+ const URL_PREFIX = /^https?:\/\//;
2879
+ const getCookiesSchema = z.object({
2880
+ domain: z.string().optional(),
2881
+ user_id: z.number().optional()
2758
2882
  });
2759
- /** 输入中事件类型。 */
2760
- const EVENT_TYPE_TYPING = 1;
2761
- /** 发送输入状态(P2-11 接 kernel setInputStatus)。 */
2762
- var SetInputStatusAction = class extends BaseAction {
2763
- name = "set_input_status";
2764
- schema = setInputStatusSchema;
2883
+ /** 默认域名。 */
2884
+ const DEFAULT_DOMAIN = "v2.qq.com";
2885
+ /** 获取 cookies(P2-13 接 kernel TicketApi.getCookies)。 */
2886
+ var GetCookiesAction = class extends BaseAction {
2887
+ name = "get_cookies";
2888
+ schema = getCookiesSchema;
2765
2889
  errorCodeMap = ob11ErrorCodeMap;
2766
2890
  deps;
2767
2891
  constructor(deps) {
2768
2892
  super();
2769
2893
  this.deps = deps;
2770
2894
  }
2771
- async _handle(payload) {
2772
- const uid = await resolveUid(String(payload.user_id), this.deps.uinToUid);
2773
- await this.deps.msgApi.setInputStatus({
2774
- chatType: ChatType.C2C,
2775
- peerUid: uid
2776
- }, payload.event_type ?? EVENT_TYPE_TYPING);
2777
- return null;
2895
+ _handle(payload) {
2896
+ const domain = payload.domain ?? DEFAULT_DOMAIN;
2897
+ let uin = this.deps.selfUin;
2898
+ if (payload.user_id !== void 0) uin = String(payload.user_id);
2899
+ return this.deps.ticketApi.getCookies(domain, uin);
2778
2900
  }
2779
2901
  };
2780
- // src/onebot11/action/message/set-msg-emoji-like.ts
2781
- /**
2782
- * set_msg_emoji_like 动作:消息表情表态(NapCat 扩展,P2-10)
2783
- *
2784
- * message_id → msgId + peer → 拉消息取 msgSeq → MsgApi.setMsgEmojiLike。
2785
- */
2786
- const setMsgEmojiLikeSchema = z.object({
2787
- message_id: z.union([z.number(), z.string()]),
2788
- /** 表情 ID(如 105 点赞)。 */
2789
- emoji_id: z.number(),
2790
- /** 表情类型(默认 1)。 */
2791
- emoji_type: z.number().optional(),
2792
- /** 是否点赞(false 取消)。 */
2793
- like: z.boolean().optional()
2794
- });
2795
- /** 消息表情表态(P2-10 接 kernel setMsgEmojiLike)。 */
2796
- var SetMsgEmojiLikeAction = class extends BaseAction {
2797
- name = "set_msg_emoji_like";
2798
- schema = setMsgEmojiLikeSchema;
2902
+ const getClientkeySchema = z.object({});
2903
+ /** 获取 clientKey(P2-13 接 kernel TicketApi)。 */
2904
+ var GetClientkeyAction = class extends BaseAction {
2905
+ name = "get_clientkey";
2906
+ schema = getClientkeySchema;
2799
2907
  errorCodeMap = ob11ErrorCodeMap;
2800
- deps;
2801
- constructor(deps) {
2908
+ ticketApi;
2909
+ constructor(ticketApi) {
2802
2910
  super();
2803
- this.deps = deps;
2804
- }
2805
- async _handle(payload) {
2806
- const { msg, peer } = await fetchMsgById(payload.message_id, this.deps.messageUnique, this.deps.msgApi);
2807
- await this.deps.msgApi.setMsgEmojiLike(peer, {
2808
- msgSeq: msg.msgSeq,
2809
- emojiId: String(payload.emoji_id),
2810
- emojiType: String(payload.emoji_type ?? 1),
2811
- like: payload.like ?? true
2812
- });
2813
- return null;
2814
- }
2815
- };
2816
- // src/onebot11/action/system/can-send-image.ts
2817
- /**
2818
- * can_send_image 动作:是否可以发送图片(本地 true,P2-11)
2819
- */
2820
- const canSendImageSchema = z.object({});
2821
- /** 是否可以发送图片(本地 true,P2-11)。 */
2822
- var CanSendImageAction = class extends BaseAction {
2823
- name = "can_send_image";
2824
- schema = canSendImageSchema;
2825
- errorCodeMap = ob11ErrorCodeMap;
2826
- _handle(_payload) {
2827
- return Promise.resolve({ yes: true });
2828
- }
2829
- };
2830
- // src/onebot11/action/system/can-send-record.ts
2831
- /**
2832
- * can_send_record 动作:是否可以发送语音(本地 true,P2-11)
2833
- */
2834
- const canSendRecordSchema = z.object({});
2835
- /** 是否可以发送语音(本地 true,P2-11)。 */
2836
- var CanSendRecordAction = class extends BaseAction {
2837
- name = "can_send_record";
2838
- schema = canSendRecordSchema;
2839
- errorCodeMap = ob11ErrorCodeMap;
2840
- _handle(_payload) {
2841
- return Promise.resolve({ yes: true });
2842
- }
2843
- };
2844
- // src/onebot11/action/system/clean-cache.ts
2845
- /**
2846
- * clean_cache 动作:清理缓存(本地组装,P2-11)
2847
- *
2848
- * cleanCache 回调由装配方注入(boot.cjs 接 kernel PathWrapper.clearCache)。
2849
- * 未配置时明确报错(不静默)。
2850
- */
2851
- const cleanCacheSchema = z.object({});
2852
- /** 清理缓存(P2-11)。 */
2853
- var CleanCacheAction = class extends BaseAction {
2854
- name = "clean_cache";
2855
- schema = cleanCacheSchema;
2856
- errorCodeMap = ob11ErrorCodeMap;
2857
- deps;
2858
- constructor(deps) {
2859
- super();
2860
- this.deps = deps;
2861
- }
2862
- async _handle(_payload) {
2863
- if (this.deps.cleanCache === void 0) throw kernelError("clean_cache 未配置(装配方未注入清理回调)", "INVALID_STATE");
2864
- await this.deps.cleanCache();
2865
- return null;
2866
- }
2867
- };
2868
- // src/onebot11/action/system/download-file.ts
2869
- /**
2870
- * download_file 动作:下载文件到缓存目录(P2-12)
2871
- *
2872
- * url → fetch 下载 → 存 deps.system.cacheDir(缺省抛错)→ 返回 { file }。
2873
- * 文件名:download-<timestamp>-<basename>(headers 等扩展字段忽略)。
2874
- */
2875
- const downloadFileSchema = z.object({
2876
- url: z.string(),
2877
- thread_count: z.number().optional(),
2878
- headers: z.record(z.string(), z.string()).optional()
2879
- });
2880
- /** 下载文件到缓存目录(P2-12)。 */
2881
- var DownloadFileAction = class extends BaseAction {
2882
- name = "download_file";
2883
- schema = downloadFileSchema;
2884
- errorCodeMap = ob11ErrorCodeMap;
2885
- deps;
2886
- constructor(deps) {
2887
- super();
2888
- this.deps = deps;
2889
- }
2890
- async _handle(payload) {
2891
- const { cacheDir } = this.deps;
2892
- if (cacheDir === void 0 || cacheDir === "") throw kernelError("download_file 未配置缓存目录(装配方未注入)", "INVALID_STATE");
2893
- const safeName = basename(new URL(payload.url).pathname) || "download.bin";
2894
- const filePath = join(cacheDir, `download-${Date.now()}-${safeName}`);
2895
- mkdirSync(cacheDir, { recursive: true });
2896
- const init = {};
2897
- if (payload.headers !== void 0) init.headers = payload.headers;
2898
- const res = await fetch(payload.url, init);
2899
- if (!res.ok) throw new Error(`下载失败: ${res.status} ${res.statusText}`);
2900
- const buf = new Uint8Array(await res.arrayBuffer());
2901
- writeFileSync(filePath, buf);
2902
- return { file: filePath };
2903
- }
2904
- };
2905
- // src/onebot11/action/system/get-clientkey.ts
2906
- const getClientkeySchema = z.object({});
2907
- /** 获取 clientKey(P2-13 接 kernel TicketApi)。 */
2908
- var GetClientkeyAction = class extends BaseAction {
2909
- name = "get_clientkey";
2910
- schema = getClientkeySchema;
2911
- errorCodeMap = ob11ErrorCodeMap;
2912
- ticketApi;
2913
- constructor(ticketApi) {
2914
- super();
2915
- this.ticketApi = ticketApi;
2911
+ this.ticketApi = ticketApi;
2916
2912
  }
2917
2913
  async _handle(_payload) {
2918
2914
  const raw = await this.ticketApi.getClientKey();
@@ -2924,45 +2920,9 @@ var GetClientkeyAction = class extends BaseAction {
2924
2920
  };
2925
2921
  }
2926
2922
  };
2927
- // src/onebot11/action/system/get-cookies.ts
2928
- /**
2929
- * get_cookies 动作:获取 cookies(P2-13 接 kernel TicketApi.getCookies)
2930
- *
2931
- * domain 缺省 v2.qq.com(NapCat 行为);user_id 缺省用机器人自身 uin。
2932
- */
2933
- const getCookiesSchema = z.object({
2934
- domain: z.string().optional(),
2935
- user_id: z.number().optional()
2936
- });
2937
- /** 默认域名。 */
2938
- const DEFAULT_DOMAIN$1 = "v2.qq.com";
2939
- /** 获取 cookies(P2-13 接 kernel TicketApi.getCookies)。 */
2940
- var GetCookiesAction = class extends BaseAction {
2941
- name = "get_cookies";
2942
- schema = getCookiesSchema;
2943
- errorCodeMap = ob11ErrorCodeMap;
2944
- deps;
2945
- constructor(deps) {
2946
- super();
2947
- this.deps = deps;
2948
- }
2949
- _handle(payload) {
2950
- const domain = payload.domain ?? DEFAULT_DOMAIN$1;
2951
- let uin = this.deps.selfUin;
2952
- if (payload.user_id !== void 0) uin = String(payload.user_id);
2953
- return this.deps.ticketApi.getCookies(domain, uin);
2954
- }
2955
- };
2956
- // src/onebot11/action/system/get-credentials.ts
2957
- /**
2958
- * get_csrf_token / get_credentials 动作(P2-15 接 kernel TicketApi)
2959
- *
2960
- * - get_csrf_token:qun.qq.com cookies 的 skey → bkn(csrf 等价物)
2961
- * - get_credentials:指定域名 cookies + bkn → { cookies, csrf_token }
2962
- */
2963
2923
  const getCsrfTokenSchema = z.object({});
2964
2924
  /** 默认域名(bkn 计算用)。 */
2965
- const DEFAULT_DOMAIN = "qun.qq.com";
2925
+ const BKN_DOMAIN = "qun.qq.com";
2966
2926
  /** 获取 csrf_token(bkn,P2-15)。 */
2967
2927
  var GetCsrfTokenAction = class extends BaseAction {
2968
2928
  name = "get_csrf_token";
@@ -2974,7 +2934,7 @@ var GetCsrfTokenAction = class extends BaseAction {
2974
2934
  this.deps = deps;
2975
2935
  }
2976
2936
  async _handle(_payload) {
2977
- const skey = (await this.deps.ticketApi.getCookies(DEFAULT_DOMAIN, this.deps.selfUin))["skey"] ?? "";
2937
+ const skey = (await this.deps.ticketApi.getCookies(BKN_DOMAIN, this.deps.selfUin))["skey"] ?? "";
2978
2938
  return { token: Number(TicketApi.getBkn(skey)) };
2979
2939
  }
2980
2940
  };
@@ -2990,7 +2950,7 @@ var GetCredentialsAction = class extends BaseAction {
2990
2950
  this.deps = deps;
2991
2951
  }
2992
2952
  async _handle(payload) {
2993
- const domain = payload.domain ?? DEFAULT_DOMAIN;
2953
+ const domain = payload.domain ?? BKN_DOMAIN;
2994
2954
  const cookies = await this.deps.ticketApi.getCookies(domain, this.deps.selfUin);
2995
2955
  return {
2996
2956
  cookies,
@@ -2998,140 +2958,6 @@ var GetCredentialsAction = class extends BaseAction {
2998
2958
  };
2999
2959
  }
3000
2960
  };
3001
- // src/onebot11/action/system/get-login-info.ts
3002
- /**
3003
- * get_login_info 动作:获取登录信息(P2-4 注入 self)
3004
- */
3005
- const getLoginInfoSchema = z.object({});
3006
- /** 获取登录信息(self 由装配方注入,P2-5 接 kernel selfInfo 维护后取真实昵称)。 */
3007
- var GetLoginInfoAction = class extends BaseAction {
3008
- name = "get_login_info";
3009
- schema = getLoginInfoSchema;
3010
- errorCodeMap = ob11ErrorCodeMap;
3011
- self;
3012
- constructor(self) {
3013
- super();
3014
- this.self = self;
3015
- }
3016
- _handle(_payload) {
3017
- return Promise.resolve({
3018
- user_id: Number(this.self.uin),
3019
- nickname: this.self.nickname
3020
- });
3021
- }
3022
- };
3023
- // src/onebot11/action/system/get-robot-uin-range.ts
3024
- /**
3025
- * get_robot_uin_range 动作:获取机器人 QQ 号范围(本地组装,P2-11)
3026
- *
3027
- * NapCat 从配置返回;我们给通用范围(min/max)。
3028
- */
3029
- const getRobotUinRangeSchema = z.object({});
3030
- /** QQ 号下限。 */
3031
- const UIN_MIN = 10001;
3032
- /** QQ 号上限。 */
3033
- const UIN_MAX = 4294967295;
3034
- /** 获取机器人 QQ 号范围(P2-11 本地组装)。 */
3035
- var GetRobotUinRangeAction = class extends BaseAction {
3036
- name = "get_robot_uin_range";
3037
- schema = getRobotUinRangeSchema;
3038
- errorCodeMap = ob11ErrorCodeMap;
3039
- _handle(_payload) {
3040
- return Promise.resolve({
3041
- min: UIN_MIN,
3042
- max: UIN_MAX
3043
- });
3044
- }
3045
- };
3046
- // src/onebot11/action/system/get-status.ts
3047
- /**
3048
- * get_status 动作:获取运行状态(本地组装,P2-11)
3049
- *
3050
- * 返回与心跳 status 同构的 OB11Status(online/good + 扩展字段)。
3051
- */
3052
- const getStatusSchema = z.object({});
3053
- /** 获取运行状态(本地组装,P2-11)。 */
3054
- var GetStatusAction = class extends BaseAction {
3055
- name = "get_status";
3056
- schema = getStatusSchema;
3057
- errorCodeMap = ob11ErrorCodeMap;
3058
- _handle(_payload) {
3059
- return Promise.resolve({
3060
- online: true,
3061
- good: true
3062
- });
3063
- }
3064
- };
3065
- // src/onebot11/action/system/get-version-info.ts
3066
- /**
3067
- * get_version_info 动作:获取版本信息(本地组装,P2-11)
3068
- *
3069
- * appVersion 由装配方注入(kernel wrapper 版本或 NAPUTO_QQ_VERSION)。
3070
- */
3071
- const getVersionInfoSchema = z.object({});
3072
- /** 获取版本信息(本地组装,P2-11)。 */
3073
- var GetVersionInfoAction = class extends BaseAction {
3074
- name = "get_version_info";
3075
- schema = getVersionInfoSchema;
3076
- errorCodeMap = ob11ErrorCodeMap;
3077
- deps;
3078
- constructor(deps) {
3079
- super();
3080
- this.deps = deps;
3081
- }
3082
- _handle(_payload) {
3083
- return Promise.resolve({
3084
- app_name: "napuketto-qq",
3085
- app_version: this.deps.appVersion,
3086
- protocol_version: "v11"
3087
- });
3088
- }
3089
- };
3090
- // src/onebot11/action/system/process-control.ts
3091
- /**
3092
- * bot_exit / set_restart 动作:退出 / 重启(P2-12)
3093
- *
3094
- * exit/restart 回调由装配方注入(boot.cjs 接进程控制)。未配置时明确报错。
3095
- */
3096
- const botExitSchema = z.object({});
3097
- /** 退出机器人进程(P2-12)。 */
3098
- var BotExitAction = class extends BaseAction {
3099
- name = "bot_exit";
3100
- schema = botExitSchema;
3101
- errorCodeMap = ob11ErrorCodeMap;
3102
- deps;
3103
- constructor(deps) {
3104
- super();
3105
- this.deps = deps;
3106
- }
3107
- async _handle(_payload) {
3108
- if (this.deps.exit === void 0) throw kernelError("bot_exit 未配置(装配方未注入退出回调)", "INVALID_STATE");
3109
- await this.deps.exit();
3110
- return null;
3111
- }
3112
- };
3113
- /** 重启机器人(P2-12;重启交给装配方,缺省退化为退出)。 */
3114
- var SetRestartAction = class extends BaseAction {
3115
- name = "set_restart";
3116
- schema = botExitSchema;
3117
- errorCodeMap = ob11ErrorCodeMap;
3118
- deps;
3119
- constructor(deps) {
3120
- super();
3121
- this.deps = deps;
3122
- }
3123
- async _handle(_payload) {
3124
- const restart = this.deps.restart ?? this.deps.exit;
3125
- if (restart === void 0) throw kernelError("set_restart 未配置(装配方未注入重启回调)", "INVALID_STATE");
3126
- await restart();
3127
- return null;
3128
- }
3129
- };
3130
- // src/onebot11/action/system/profile-actions.ts
3131
- /** 资料类动作(P2-14):set_self_longnick / set_qq_profile / set_qq_avatar
3132
- */
3133
- /** URL 前缀(头像在线文件识别)。 */
3134
- const URL_PREFIX = /^https?:\/\//;
3135
2961
  const setSelfLongnickSchema = z.object({ longNick: z.string() });
3136
2962
  /** 设置个性签名(P2-14 接 kernel ProfileApi.setLongNick)。 */
3137
2963
  var SetSelfLongnickAction = class extends BaseAction {
@@ -3202,89 +3028,28 @@ var SetQQAvatarAction = class extends BaseAction {
3202
3028
  return filePath;
3203
3029
  }
3204
3030
  };
3205
- // src/onebot11/action/system/set-diy-online-status.ts
3206
- const setDiyOnlineStatusSchema = z.object({
3207
- status: z.number().optional(),
3208
- /** 自定义状态文案。 */
3209
- wording: z.string(),
3210
- /** 表情 ID。 */
3211
- face_id: z.string().optional(),
3212
- /** 表情类型。 */
3213
- face_type: z.string().optional()
3214
- });
3215
- /** 默认在线状态值。 */
3216
- const STATUS_ONLINE$1 = 10;
3217
- /** 设置自定义在线状态(P2-12 接 kernel setOnlineStatus customStatus)。 */
3218
- var SetDiyOnlineStatusAction = class extends BaseAction {
3219
- name = "set_diy_online_status";
3220
- schema = setDiyOnlineStatusSchema;
3221
- errorCodeMap = ob11ErrorCodeMap;
3222
- msgApi;
3223
- constructor(msgApi) {
3224
- super();
3225
- this.msgApi = msgApi;
3226
- }
3227
- async _handle(payload) {
3228
- const customStatus = {
3229
- faceId: payload.face_id ?? "",
3230
- wording: payload.wording,
3231
- faceType: payload.face_type ?? "1"
3232
- };
3233
- await this.msgApi.setOnlineStatus({
3234
- status: payload.status ?? STATUS_ONLINE$1,
3235
- extStatus: 0,
3236
- batteryStatus: 0,
3237
- customStatus
3238
- });
3239
- return null;
3240
- }
3241
- };
3242
- // src/onebot11/action/system/set-online-status.ts
3243
- const setOnlineStatusSchema = z.object({
3244
- status: z.number().optional(),
3245
- ext_status: z.number().optional(),
3246
- battery_status: z.number().optional()
3247
- });
3248
- /** 默认在线状态值。 */
3249
- const STATUS_ONLINE = 10;
3250
- /** 设置在线状态(P2-12 接 kernel setOnlineStatus)。 */
3251
- var SetOnlineStatusAction = class extends BaseAction {
3252
- name = "set_online_status";
3253
- schema = setOnlineStatusSchema;
3254
- errorCodeMap = ob11ErrorCodeMap;
3255
- msgApi;
3256
- constructor(msgApi) {
3257
- super();
3258
- this.msgApi = msgApi;
3259
- }
3260
- async _handle(payload) {
3261
- await this.msgApi.setOnlineStatus({
3262
- status: payload.status ?? STATUS_ONLINE,
3263
- extStatus: payload.ext_status ?? 0,
3264
- batteryStatus: payload.battery_status ?? 0
3265
- });
3266
- return null;
3267
- }
3268
- };
3269
- // src/onebot11/action/system/translate-en2zh.ts
3270
- const translateEn2ZhSchema = z.object({ words: z.array(z.string()).max(MAX_TRANSLATE_WORDS) });
3271
- /** 英文单词翻译(P2-14)。 */
3272
- var TranslateEn2ZhAction = class extends BaseAction {
3273
- name = "translate_en2zh";
3274
- schema = translateEn2ZhSchema;
3275
- errorCodeMap = ob11ErrorCodeMap;
3276
- richMediaApi;
3277
- constructor(richMediaApi) {
3278
- super();
3279
- this.richMediaApi = richMediaApi;
3280
- }
3281
- async _handle(payload) {
3282
- return { words: await this.richMediaApi.translateWords(payload.words) };
3283
- }
3284
- };
3285
- // src/onebot11/action/upload-file.ts
3286
3031
  /**
3287
- * 文件投递动作(upload_group_file / upload_private_file)——**闪传通道**
3032
+ * 账号票据与资料域动作工厂(cookies / clientkey / csrf_token / credentials /
3033
+ * self_longnick / qq_profile / qq_avatar)。
3034
+ */
3035
+ function createSystemAccountActions(api) {
3036
+ return [
3037
+ new GetClientkeyAction(api.ticketApi),
3038
+ new GetCookiesAction(api),
3039
+ new GetCsrfTokenAction(api),
3040
+ new GetCredentialsAction(api),
3041
+ new SetSelfLongnickAction(api.profileApi),
3042
+ new SetQQProfileAction(api.profileApi),
3043
+ new SetQQAvatarAction(api)
3044
+ ];
3045
+ }
3046
+ // src/onebot11/action/system/file.ts
3047
+ /**
3048
+ * 文件收发域动作(2026-11-14 自 system/download-file 与根部 upload-file 合并)
3049
+ *
3050
+ * - download_file(P2-12):url → fetch 下载 → 存 cacheDir(缺省抛错)→ 返回
3051
+ * { file }。文件名:download-<timestamp>-<basename>(headers 等扩展字段忽略)
3052
+ * - upload_group_file / upload_private_file——**闪传通道**
3288
3053
  *
3289
3054
  * ⚠️ 语义降级(2026-11-11 决定,探测依据见 kernel design §15):
3290
3055
  * QQ NT 没有任何「把文件传进群文件列表」的 NAPI,`sendMsg` 带 fileElement 时原生走的
@@ -3299,6 +3064,36 @@ var TranslateEn2ZhAction = class extends BaseAction {
3299
3064
  * 输入只接受本地路径与 `file://` URI:远程 `http(s)://` / `base64://` 需要下载缓存与媒体
3300
3065
  * 依赖,当前未接(明确报错,不静默失败)。
3301
3066
  */
3067
+ const downloadFileSchema = z.object({
3068
+ url: z.string(),
3069
+ thread_count: z.number().optional(),
3070
+ headers: z.record(z.string(), z.string()).optional()
3071
+ });
3072
+ /** 下载文件到缓存目录(P2-12)。 */
3073
+ var DownloadFileAction = class extends BaseAction {
3074
+ name = "download_file";
3075
+ schema = downloadFileSchema;
3076
+ errorCodeMap = ob11ErrorCodeMap;
3077
+ deps;
3078
+ constructor(deps) {
3079
+ super();
3080
+ this.deps = deps;
3081
+ }
3082
+ async _handle(payload) {
3083
+ const { cacheDir } = this.deps;
3084
+ if (cacheDir === void 0 || cacheDir === "") throw kernelError("download_file 未配置缓存目录(装配方未注入)", "INVALID_STATE");
3085
+ const safeName = basename(new URL(payload.url).pathname) || "download.bin";
3086
+ const filePath = join(cacheDir, `download-${Date.now()}-${safeName}`);
3087
+ mkdirSync(cacheDir, { recursive: true });
3088
+ const init = {};
3089
+ if (payload.headers !== void 0) init.headers = payload.headers;
3090
+ const res = await fetch(payload.url, init);
3091
+ if (!res.ok) throw new Error(`下载失败: ${res.status} ${res.statusText}`);
3092
+ const buf = new Uint8Array(await res.arrayBuffer());
3093
+ writeFileSync(filePath, buf);
3094
+ return { file: filePath };
3095
+ }
3096
+ };
3302
3097
  /** file:// 前缀(fileURLToPath 失败时的裸剥离兜底)。 */
3303
3098
  const FILE_URI_PREFIX_RE = /^file:\/\//;
3304
3099
  /** 路径分隔符(取文件名用)。 */
@@ -3366,151 +3161,308 @@ function basename$1(path) {
3366
3161
  const last = parts[parts.length - 1] ?? "";
3367
3162
  return last === "" ? "文件" : last;
3368
3163
  }
3369
- // src/onebot11/action/index.ts
3164
+ /** 文件收发域动作工厂(download_file / upload_group_file / upload_private_file)。 */
3165
+ function createSystemFileActions(api) {
3166
+ return [
3167
+ new DownloadFileAction(api),
3168
+ new UploadGroupFileAction(api),
3169
+ new UploadPrivateFileAction(api)
3170
+ ];
3171
+ }
3172
+ // src/onebot11/action/system/info.ts
3173
+ const getLoginInfoSchema = z.object({});
3174
+ /** 获取登录信息(self 由装配方注入,P2-5 接 kernel selfInfo 维护后取真实昵称)。 */
3175
+ var GetLoginInfoAction = class extends BaseAction {
3176
+ name = "get_login_info";
3177
+ schema = getLoginInfoSchema;
3178
+ errorCodeMap = ob11ErrorCodeMap;
3179
+ self;
3180
+ constructor(self) {
3181
+ super();
3182
+ this.self = self;
3183
+ }
3184
+ _handle(_payload) {
3185
+ return Promise.resolve({
3186
+ user_id: Number(this.self.uin),
3187
+ nickname: this.self.nickname
3188
+ });
3189
+ }
3190
+ };
3191
+ const getVersionInfoSchema = z.object({});
3192
+ /** 获取版本信息(本地组装,P2-11)。 */
3193
+ var GetVersionInfoAction = class extends BaseAction {
3194
+ name = "get_version_info";
3195
+ schema = getVersionInfoSchema;
3196
+ errorCodeMap = ob11ErrorCodeMap;
3197
+ deps;
3198
+ constructor(deps) {
3199
+ super();
3200
+ this.deps = deps;
3201
+ }
3202
+ _handle(_payload) {
3203
+ return Promise.resolve({
3204
+ app_name: "napuketto-qq",
3205
+ app_version: this.deps.appVersion,
3206
+ protocol_version: "v11"
3207
+ });
3208
+ }
3209
+ };
3210
+ const getStatusSchema = z.object({});
3211
+ /** 获取运行状态(本地组装,P2-11)。 */
3212
+ var GetStatusAction = class extends BaseAction {
3213
+ name = "get_status";
3214
+ schema = getStatusSchema;
3215
+ errorCodeMap = ob11ErrorCodeMap;
3216
+ _handle(_payload) {
3217
+ return Promise.resolve({
3218
+ online: true,
3219
+ good: true
3220
+ });
3221
+ }
3222
+ };
3223
+ const getRobotUinRangeSchema = z.object({});
3224
+ /** QQ 号下限。 */
3225
+ const UIN_MIN = 10001;
3226
+ /** QQ 号上限。 */
3227
+ const UIN_MAX = 4294967295;
3228
+ /** 获取机器人 QQ 号范围(P2-11 本地组装)。 */
3229
+ var GetRobotUinRangeAction = class extends BaseAction {
3230
+ name = "get_robot_uin_range";
3231
+ schema = getRobotUinRangeSchema;
3232
+ errorCodeMap = ob11ErrorCodeMap;
3233
+ _handle(_payload) {
3234
+ return Promise.resolve({
3235
+ min: UIN_MIN,
3236
+ max: UIN_MAX
3237
+ });
3238
+ }
3239
+ };
3240
+ const translateEn2ZhSchema = z.object({ words: z.array(z.string()).max(MAX_TRANSLATE_WORDS) });
3241
+ /** 英文单词翻译(P2-14)。 */
3242
+ var TranslateEn2ZhAction = class extends BaseAction {
3243
+ name = "translate_en2zh";
3244
+ schema = translateEn2ZhSchema;
3245
+ errorCodeMap = ob11ErrorCodeMap;
3246
+ richMediaApi;
3247
+ constructor(richMediaApi) {
3248
+ super();
3249
+ this.richMediaApi = richMediaApi;
3250
+ }
3251
+ async _handle(payload) {
3252
+ return { words: await this.richMediaApi.translateWords(payload.words) };
3253
+ }
3254
+ };
3370
3255
  /**
3371
- * OneBot 11 动作注册表(ADR-013 延伸)
3372
- * 各协议维护自己的 ActionRegistry,由协议 adapter 挂到请求分发。
3373
- * P2-16:deps 收敛为 { api: OneBotApi } 单聚合对象(基础设施第一项)。
3374
- *
3375
- * 同时是 action 域 barrel:re-export 全部动作类 + error-map + resolve-uid,
3376
- * 协议外部只从本入口消费动作面。
3256
+ * 系统信息域动作工厂(login_info / version_info / status / robot_uin_range /
3257
+ * translate_en2zh)。
3377
3258
  */
3378
- /** 构建 OB11 动作注册表(所有 OB11 动作在此注册,按组拆分控制行数)。 */
3379
- function createOb11ActionRegistry(deps) {
3380
- const registry = new ActionRegistry();
3381
- registerMsgActions(registry, deps);
3382
- registerForwardActions(registry, deps);
3383
- registerQueryActions(registry, deps);
3384
- registerGroupActions(registry, deps);
3385
- registerFriendActions(registry, deps);
3386
- registerSystemActions(registry, deps);
3387
- registerGroupNotifyActions(registry, deps);
3388
- registerTicketActions(registry, deps);
3389
- registerProfileActions(registry, deps);
3390
- registerGroupFileActions(registry, deps);
3391
- registerFileUploadActions(registry, deps);
3392
- registerWebActions(registry, deps);
3393
- return registry;
3259
+ function createSystemInfoActions(api) {
3260
+ return [
3261
+ new GetLoginInfoAction(api.self),
3262
+ new GetVersionInfoAction(api),
3263
+ new GetStatusAction(),
3264
+ new GetRobotUinRangeAction(),
3265
+ new TranslateEn2ZhAction(api.richMediaApi)
3266
+ ];
3394
3267
  }
3268
+ // src/onebot11/action/system/status.ts
3395
3269
  /**
3396
- * 文件投递动作(upload_group_file / upload_private_file):**闪传通道**。
3397
- * 语义降级说明见 ./upload-file.ts 文件头(分享卡片,非群文件条目)。
3270
+ * 系统状态与维护域动作(2026-11-14 自 set-online-status / set-diy-online-status /
3271
+ * can-send-image / can-send-record / clean-cache / process-control 合并)
3272
+ *
3273
+ * - set_online_status(P2-12):status/ext_status/battery_status 见 NapCat 状态表
3274
+ * (在线 10 / 离开 30 / 隐身 40 / 忙碌 50 / Q我吧 60 / 请勿打扰 70 等)
3275
+ * - set_diy_online_status(P2-12):customStatus(faceId/wording/faceType)随
3276
+ * setStatus 一并提交;status 缺省 10(在线)
3277
+ * - can_send_image / can_send_record(P2-11):本地恒 true
3278
+ * - clean_cache(P2-11):cleanCache 回调由装配方注入(boot.cjs 接 kernel
3279
+ * PathWrapper.clearCache),未配置时明确报错(不静默)
3280
+ * - bot_exit / set_restart(P2-12):exit/restart 回调由装配方注入(boot.cjs 接
3281
+ * 进程控制),未配置时明确报错;重启缺省退化为退出
3398
3282
  */
3399
- function registerFileUploadActions(registry, deps) {
3400
- registry.register(new UploadGroupFileAction(deps.api));
3401
- registry.register(new UploadPrivateFileAction(deps.api));
3402
- }
3403
- /** 群空间 web / csrf / 陌生人 / 群请求动作(P2-15)。 */
3404
- function registerWebActions(registry, deps) {
3405
- registry.register(new GetStrangerInfoAction(deps.api.profileApi));
3406
- registry.register(new GetCsrfTokenAction(deps.api));
3407
- registry.register(new GetCredentialsAction(deps.api));
3408
- registry.register(new GetGroupAddRequestAction(deps.api.groupNotifyApi));
3409
- registry.register(new GetGroupIgnoredNotifiesAction(deps.api.groupNotifyApi));
3410
- registry.register(new GetEssenceMsgListAction(deps.api.webApi));
3411
- registry.register(new GetGroupHonorInfoAction(deps.api.webApi));
3412
- }
3413
- /** 资料/点赞/翻译动作(P2-14)。 */
3414
- function registerProfileActions(registry, deps) {
3415
- registry.register(new SetSelfLongnickAction(deps.api.profileApi));
3416
- registry.register(new SetQQProfileAction(deps.api.profileApi));
3417
- registry.register(new SetQQAvatarAction(deps.api));
3418
- registry.register(new TranslateEn2ZhAction(deps.api.richMediaApi));
3419
- registry.register(new SendLikeAction(deps.api));
3420
- }
3421
- /** 群文件动作(P2-14)。 */
3422
- function registerGroupFileActions(registry, deps) {
3423
- registry.register(new GetGroupRootFilesAction(deps.api.richMediaApi));
3424
- registry.register(new GetGroupFilesByFolderAction(deps.api.richMediaApi));
3425
- registry.register(new GetGroupFileSystemInfoAction(deps.api.richMediaApi));
3426
- registry.register(new CreateGroupFileFolderAction(deps.api.richMediaApi));
3427
- registry.register(new DeleteGroupFileAction(deps.api.richMediaApi));
3428
- registry.register(new DeleteGroupFolderAction(deps.api.richMediaApi));
3429
- registry.register(new RenameGroupFileAction(deps.api.richMediaApi));
3430
- registry.register(new MoveGroupFileAction(deps.api.richMediaApi));
3431
- registry.register(new TransGroupFileAction(deps.api.richMediaApi));
3432
- }
3433
- /** 群通知/禁言列表动作(P2-13)。 */
3434
- function registerGroupNotifyActions(registry, deps) {
3435
- registry.register(new SetGroupAddRequestAction(deps.api.groupNotifyApi));
3436
- registry.register(new GetGroupSystemMsgAction(deps.api));
3437
- registry.register(new GetGroupShutListAction(deps.api));
3438
- }
3439
- /** 票据动作(P2-13)。 */
3440
- function registerTicketActions(registry, deps) {
3441
- registry.register(new GetClientkeyAction(deps.api.ticketApi));
3442
- registry.register(new GetCookiesAction(deps.api));
3443
- }
3444
- /** 合并转发 / 单条转发 / 在线状态(P2-12)。 */
3445
- function registerForwardActions(registry, deps) {
3446
- registry.register(new SendGroupForwardMsgAction(deps.api));
3447
- registry.register(new SendPrivateForwardMsgAction(deps.api));
3448
- registry.register(new GetForwardMsgAction(deps.api));
3449
- registry.register(new ForwardGroupSingleMsgAction(deps.api));
3450
- registry.register(new ForwardFriendSingleMsgAction(deps.api));
3451
- registry.register(new SetOnlineStatusAction(deps.api.msgApi));
3452
- registry.register(new SetDiyOnlineStatusAction(deps.api.msgApi));
3453
- }
3454
- /** 消息类动作(P2-3 / P2-10 / P2-11)。 */
3455
- function registerMsgActions(registry, deps) {
3456
- registry.register(new SendMsgAction(deps.api));
3457
- registry.register(new SendPrivateMsgAction(deps.api));
3458
- registry.register(new SendGroupMsgAction(deps.api));
3459
- registry.register(new DeleteMsgAction(deps.api));
3460
- registry.register(new GetMsgAction(deps.api));
3461
- registry.register(new GetGroupMsgHistoryAction(deps.api));
3462
- registry.register(new GetFriendMsgHistoryAction(deps.api));
3463
- registry.register(new MarkMsgAsReadAction(deps.api));
3464
- registry.register(new MarkPrivateMsgAsReadAction(deps.api));
3465
- registry.register(new MarkGroupMsgAsReadAction(deps.api));
3466
- registry.register(new SetMsgEmojiLikeAction(deps.api));
3467
- registry.register(new FetchPttTextAction(deps.api));
3468
- registry.register(new SetInputStatusAction(deps.api));
3469
- registry.register(new GetImageAction(deps.api));
3470
- registry.register(new GetRecordAction(deps.api));
3471
- }
3472
- /** 查询类动作(P2-4;P2-17 群信息/成员动作读 GroupCache)。 */
3473
- function registerQueryActions(registry, deps) {
3474
- registry.register(new GetLoginInfoAction(deps.api.self));
3475
- registry.register(new GetGroupInfoAction(deps.api));
3476
- registry.register(new GetGroupListAction(deps.api));
3477
- registry.register(new GetGroupMemberInfoAction(deps.api));
3478
- registry.register(new GetGroupMemberListAction(deps.api));
3479
- registry.register(new GetFriendListAction(deps.api.friendApi));
3480
- }
3481
- /** 群管类动作(P2-10)。 */
3482
- function registerGroupActions(registry, deps) {
3483
- registry.register(new SetGroupKickAction(deps.api.groupApi));
3484
- registry.register(new SetGroupBanAction(deps.api.groupApi));
3485
- registry.register(new SetGroupWholeBanAction(deps.api.groupApi));
3486
- registry.register(new SetGroupAdminAction(deps.api.groupApi));
3487
- registry.register(new SetGroupCardAction(deps.api.groupApi));
3488
- registry.register(new SetGroupNameAction(deps.api.groupApi));
3489
- registry.register(new SetGroupLeaveAction(deps.api.groupApi));
3490
- registry.register(new SetEssenceMsgAction(deps.api));
3491
- registry.register(new DeleteEssenceMsgAction(deps.api));
3492
- registry.register(new GetGroupAtAllRemainAction(deps.api.groupApi));
3493
- }
3494
- /** 好友类动作(P2-11)。 */
3495
- function registerFriendActions(registry, deps) {
3496
- registry.register(new SetFriendAddRequestAction(deps.api.friendApi));
3497
- registry.register(new SetFriendRemarkAction(deps.api));
3498
- registry.register(new DeleteFriendAction(deps.api));
3499
- registry.register(new GetFriendsWithCategoryAction(deps.api.friendApi));
3500
- registry.register(new GetDoubtFriendsAddRequestAction(deps.api.friendApi));
3501
- registry.register(new SetDoubtFriendsAddRequestAction(deps.api.friendApi));
3283
+ const setOnlineStatusSchema = z.object({
3284
+ status: z.number().optional(),
3285
+ ext_status: z.number().optional(),
3286
+ battery_status: z.number().optional()
3287
+ });
3288
+ /** 默认在线状态值。 */
3289
+ const STATUS_ONLINE = 10;
3290
+ /** 设置在线状态(P2-12 接 kernel setOnlineStatus)。 */
3291
+ var SetOnlineStatusAction = class extends BaseAction {
3292
+ name = "set_online_status";
3293
+ schema = setOnlineStatusSchema;
3294
+ errorCodeMap = ob11ErrorCodeMap;
3295
+ msgApi;
3296
+ constructor(msgApi) {
3297
+ super();
3298
+ this.msgApi = msgApi;
3299
+ }
3300
+ async _handle(payload) {
3301
+ await this.msgApi.setOnlineStatus({
3302
+ status: payload.status ?? STATUS_ONLINE,
3303
+ extStatus: payload.ext_status ?? 0,
3304
+ batteryStatus: payload.battery_status ?? 0
3305
+ });
3306
+ return null;
3307
+ }
3308
+ };
3309
+ const setDiyOnlineStatusSchema = z.object({
3310
+ status: z.number().optional(),
3311
+ /** 自定义状态文案。 */
3312
+ wording: z.string(),
3313
+ /** 表情 ID。 */
3314
+ face_id: z.string().optional(),
3315
+ /** 表情类型。 */
3316
+ face_type: z.string().optional()
3317
+ });
3318
+ /** 设置自定义在线状态(P2-12 接 kernel setOnlineStatus customStatus)。 */
3319
+ var SetDiyOnlineStatusAction = class extends BaseAction {
3320
+ name = "set_diy_online_status";
3321
+ schema = setDiyOnlineStatusSchema;
3322
+ errorCodeMap = ob11ErrorCodeMap;
3323
+ msgApi;
3324
+ constructor(msgApi) {
3325
+ super();
3326
+ this.msgApi = msgApi;
3327
+ }
3328
+ async _handle(payload) {
3329
+ const customStatus = {
3330
+ faceId: payload.face_id ?? "",
3331
+ wording: payload.wording,
3332
+ faceType: payload.face_type ?? "1"
3333
+ };
3334
+ await this.msgApi.setOnlineStatus({
3335
+ status: payload.status ?? STATUS_ONLINE,
3336
+ extStatus: 0,
3337
+ batteryStatus: 0,
3338
+ customStatus
3339
+ });
3340
+ return null;
3341
+ }
3342
+ };
3343
+ const canSendImageSchema = z.object({});
3344
+ /** 是否可以发送图片(本地 true,P2-11)。 */
3345
+ var CanSendImageAction = class extends BaseAction {
3346
+ name = "can_send_image";
3347
+ schema = canSendImageSchema;
3348
+ errorCodeMap = ob11ErrorCodeMap;
3349
+ _handle(_payload) {
3350
+ return Promise.resolve({ yes: true });
3351
+ }
3352
+ };
3353
+ const canSendRecordSchema = z.object({});
3354
+ /** 是否可以发送语音(本地 true,P2-11)。 */
3355
+ var CanSendRecordAction = class extends BaseAction {
3356
+ name = "can_send_record";
3357
+ schema = canSendRecordSchema;
3358
+ errorCodeMap = ob11ErrorCodeMap;
3359
+ _handle(_payload) {
3360
+ return Promise.resolve({ yes: true });
3361
+ }
3362
+ };
3363
+ const cleanCacheSchema = z.object({});
3364
+ /** 清理缓存(P2-11)。 */
3365
+ var CleanCacheAction = class extends BaseAction {
3366
+ name = "clean_cache";
3367
+ schema = cleanCacheSchema;
3368
+ errorCodeMap = ob11ErrorCodeMap;
3369
+ deps;
3370
+ constructor(deps) {
3371
+ super();
3372
+ this.deps = deps;
3373
+ }
3374
+ async _handle(_payload) {
3375
+ if (this.deps.cleanCache === void 0) throw kernelError("clean_cache 未配置(装配方未注入清理回调)", "INVALID_STATE");
3376
+ await this.deps.cleanCache();
3377
+ return null;
3378
+ }
3379
+ };
3380
+ const botExitSchema = z.object({});
3381
+ /** 退出机器人进程(P2-12)。 */
3382
+ var BotExitAction = class extends BaseAction {
3383
+ name = "bot_exit";
3384
+ schema = botExitSchema;
3385
+ errorCodeMap = ob11ErrorCodeMap;
3386
+ deps;
3387
+ constructor(deps) {
3388
+ super();
3389
+ this.deps = deps;
3390
+ }
3391
+ async _handle(_payload) {
3392
+ if (this.deps.exit === void 0) throw kernelError("bot_exit 未配置(装配方未注入退出回调)", "INVALID_STATE");
3393
+ await this.deps.exit();
3394
+ return null;
3395
+ }
3396
+ };
3397
+ /** 重启机器人(P2-12;重启交给装配方,缺省退化为退出)。 */
3398
+ var SetRestartAction = class extends BaseAction {
3399
+ name = "set_restart";
3400
+ schema = botExitSchema;
3401
+ errorCodeMap = ob11ErrorCodeMap;
3402
+ deps;
3403
+ constructor(deps) {
3404
+ super();
3405
+ this.deps = deps;
3406
+ }
3407
+ async _handle(_payload) {
3408
+ const restart = this.deps.restart ?? this.deps.exit;
3409
+ if (restart === void 0) throw kernelError("set_restart 未配置(装配方未注入重启回调)", "INVALID_STATE");
3410
+ await restart();
3411
+ return null;
3412
+ }
3413
+ };
3414
+ /**
3415
+ * 系统状态与维护域动作工厂(set_online_status ×2 / can_send ×2 / clean_cache /
3416
+ * bot_exit / set_restart)。
3417
+ */
3418
+ function createSystemStatusActions(api) {
3419
+ return [
3420
+ new SetOnlineStatusAction(api.msgApi),
3421
+ new SetDiyOnlineStatusAction(api.msgApi),
3422
+ new CanSendImageAction(),
3423
+ new CanSendRecordAction(),
3424
+ new CleanCacheAction(api),
3425
+ new BotExitAction(api),
3426
+ new SetRestartAction(api)
3427
+ ];
3502
3428
  }
3503
- /** 系统类动作(P2-11 / P2-12)。 */
3504
- function registerSystemActions(registry, deps) {
3505
- registry.register(new GetStatusAction());
3506
- registry.register(new GetVersionInfoAction(deps.api));
3507
- registry.register(new CleanCacheAction(deps.api));
3508
- registry.register(new CanSendImageAction());
3509
- registry.register(new CanSendRecordAction());
3510
- registry.register(new GetRobotUinRangeAction());
3511
- registry.register(new DownloadFileAction(deps.api));
3512
- registry.register(new BotExitAction(deps.api));
3513
- registry.register(new SetRestartAction(deps.api));
3429
+ // src/onebot11/action/index.ts
3430
+ /**
3431
+ * OneBot 11 动作注册表(ADR-013 延伸)
3432
+ * 各协议维护自己的 ActionRegistry,由协议 adapter 挂到请求分发。
3433
+ * P2-16:deps 收敛为 { api: OneBotApi } 单聚合对象(基础设施第一项)。
3434
+ *
3435
+ * 同时是 action 域 barrel:re-export error-map / resolve-uid / AtAllRemainInfo,
3436
+ * 协议外部只从本入口消费动作面。动作类按领域分文件(message/ group/ friend/
3437
+ * system/),各领域文件导出 create*Actions 工厂,此处遍历注册——新增动作在
3438
+ * 领域文件的工厂里登记即可。
3439
+ */
3440
+ /** 全部领域工厂(18 个:message×5 + group×7 + friend×2 + system×4)。 */
3441
+ const ACTION_FACTORIES = [
3442
+ createSendActions,
3443
+ createHistoryActions,
3444
+ createMsgOpsActions,
3445
+ createMediaActions,
3446
+ createForwardActions,
3447
+ createGroupManageActions,
3448
+ createGroupQueryActions,
3449
+ createGroupEssenceActions,
3450
+ createGroupNotifyActions,
3451
+ createGroupSystemMsgActions,
3452
+ createGroupFileQueryActions,
3453
+ createGroupFileOpActions,
3454
+ createFriendQueryActions,
3455
+ createFriendManageActions,
3456
+ createSystemInfoActions,
3457
+ createSystemStatusActions,
3458
+ createSystemAccountActions,
3459
+ createSystemFileActions
3460
+ ];
3461
+ /** 构建 OB11 动作注册表(81 个动作,领域工厂遍历注册)。 */
3462
+ function createOb11ActionRegistry(deps) {
3463
+ const registry = new ActionRegistry();
3464
+ for (const factory of ACTION_FACTORIES) for (const action of factory(deps.api)) registry.register(action);
3465
+ return registry;
3514
3466
  }
3515
3467
  // src/onebot11/api/one-bot-api.ts
3516
3468
  /**
@@ -3621,6 +3573,256 @@ var OneBotApi = class {
3621
3573
  }
3622
3574
  }
3623
3575
  };
3576
+ // src/onebot11/enrichment.ts
3577
+ /** OB11 收链路异步回填器。 */
3578
+ var Ob11Enrichment = class {
3579
+ api;
3580
+ calibLogger;
3581
+ constructor(deps) {
3582
+ this.api = deps.api;
3583
+ this.calibLogger = deps.logger;
3584
+ }
3585
+ /** uid 批量 → uin(失败退空 Map:翻译层退化为 uid 数值,不阻塞请求上报)。 */
3586
+ async uidToUinMap(uids) {
3587
+ if (uids.length === 0) return /* @__PURE__ */ new Map();
3588
+ try {
3589
+ return await this.api.uidToUin(uids);
3590
+ } catch {
3591
+ return /* @__PURE__ */ new Map();
3592
+ }
3593
+ }
3594
+ /**
3595
+ * notice uid 批量转换(空集退空 Map)。失败上抛不吞:grayTip 解析宽容但
3596
+ * uid 查询炸掉时整个 notice 丢弃(与原 adapter 行为一致,调用方 catch)。
3597
+ */
3598
+ async noticeUidMap(uids) {
3599
+ if (uids.length === 0) return /* @__PURE__ */ new Map();
3600
+ return this.api.uidToUin(uids);
3601
+ }
3602
+ /**
3603
+ * 消息事件翻译上下文(P2-19:接收方向 ID 转换)。
3604
+ * at uid → 一次批量 uidToUin;群消息另查发送者角色(GroupCache 缓存优先,
3605
+ * 失败回退缺省 member);msgId → OB11 id 经 messageUnique 反查。
3606
+ */
3607
+ async messageContext(msg) {
3608
+ const { atUids } = collectReceiveNeeds(toCanonicalElements(msg));
3609
+ let uidToUin;
3610
+ if (atUids.length > 0) try {
3611
+ uidToUin = await this.api.uidToUin(atUids);
3612
+ } catch {}
3613
+ const senderRole = msg.chatType === ChatType.GROUP ? await this.api.groupMemberRole(msg.peerUid, msg.senderUid) : void 0;
3614
+ return {
3615
+ ...uidToUin !== void 0 ? { uidToUin } : {},
3616
+ ...senderRole !== void 0 ? { senderRole } : {},
3617
+ msgIdToOb11Id: (msgId) => this.api.messageUnique.getMessageId(msgId)
3618
+ };
3619
+ }
3620
+ /** sysmsg 规则的 uid→uin 解析器(collectUids 声明才批量转换;失败/缺省恒 0)。 */
3621
+ async sysMsgUinResolver(rule, tree, env) {
3622
+ if (rule.collectUids === void 0) return () => 0;
3623
+ const uids = rule.collectUids(tree, env).filter((uid) => uid !== "");
3624
+ if (uids.length === 0) return () => 0;
3625
+ try {
3626
+ const map = await this.api.uidToUin(uids);
3627
+ return (uid) => Number(map.get(uid) ?? 0);
3628
+ } catch {
3629
+ return () => 0;
3630
+ }
3631
+ }
3632
+ /**
3633
+ * 精华 message_id 反查:msgSeq → 近段历史扫描(60 条,对齐 milky
3634
+ * resolveMsgIdBySeq fallback 层)→ MessageUnique.alloc 幂等分配(可被 get_msg
3635
+ * 反查的正确空间,对照 recall 的 msgSeq 错位)。未命中返回 null(跳过事件)。
3636
+ */
3637
+ async resolveEssenceMsgId(groupCode, seq) {
3638
+ const peer = {
3639
+ chatType: ChatType.GROUP,
3640
+ peerUid: groupCode
3641
+ };
3642
+ const hit = (await this.api.msgApi.fetchMessages(peer, { count: 60 }).catch(() => [])).find((m) => Number(m.msgSeq) === seq);
3643
+ if (hit === void 0) {
3644
+ this.calibLogger?.warn({
3645
+ group: groupCode,
3646
+ seq
3647
+ }, "ob11: 精华 message_id 反查未命中(跳过事件)");
3648
+ return null;
3649
+ }
3650
+ return this.api.messageUnique.alloc(hit.msgId, peer);
3651
+ }
3652
+ };
3653
+ // src/onebot11/inbound/essence.ts
3654
+ /** OB11 精华域处理器(串行 diff 同步 + group_essence notice 广播)。 */
3655
+ var Ob11InboundEssence = class {
3656
+ deps;
3657
+ essenceSync;
3658
+ constructor(deps) {
3659
+ this.deps = deps;
3660
+ this.essenceSync = new EssenceListSync({
3661
+ fetchList: (groupCode) => deps.api.webApi.getEssenceMsgList(groupCode),
3662
+ onAdded: (groupCode, added) => this.broadcastDiff(groupCode, added, "add"),
3663
+ onRemoved: (groupCode, removed, prev) => this.broadcastDiff(groupCode, removed.map((seq) => ({
3664
+ messageSeq: seq,
3665
+ senderUin: prev.get(seq)?.senderUin ?? null,
3666
+ operatorUin: null,
3667
+ addDigestTime: null
3668
+ })), "delete"),
3669
+ onFetchError: (g, err) => deps.logger?.warn({
3670
+ group: g,
3671
+ err: String(err)
3672
+ }, "ob11: 精华列表拉取失败(diff 跳过)")
3673
+ });
3674
+ }
3675
+ /** sysmsg 732:1 加速触发器:抽取群号踢入串行链(抽取失败 → false 落校准路径)。 */
3676
+ triggerFromSysMsg(tree) {
3677
+ const hit = extractEssenceSetSysMsg(tree);
3678
+ if (hit === null) return false;
3679
+ this.essenceSync.enqueue(String(hit.groupCode));
3680
+ return true;
3681
+ }
3682
+ /** 精华列表变更:拉全量列表 diff(唯一发射路径;参数收窄失败走校准日志)。 */
3683
+ change(arg) {
3684
+ const groupCode = narrowEssenceGroupArg(arg);
3685
+ if (groupCode === null) {
3686
+ this.deps.logger?.warn({ raw: truncRaw(JSON.stringify(arg)) }, "ob11: onGroupEssenceListChange 未知参数形状");
3687
+ return;
3688
+ }
3689
+ this.essenceSync.enqueue(groupCode);
3690
+ }
3691
+ /** diff 逐条广播(add/delete 共用):sender 必填 → message_id 反查 → notice 装配。 */
3692
+ async broadcastDiff(groupCode, items, subType) {
3693
+ const { enrich, broadcast, selfUin } = this.deps;
3694
+ for (const item of items) {
3695
+ const senderId = numericUin(item.senderUin);
3696
+ if (senderId === null) {
3697
+ const detail = subType === "add" ? "新增 sender_uin 缺失" : "移除 sender 不可得";
3698
+ this.deps.logger?.warn({
3699
+ group: groupCode,
3700
+ seq: item.messageSeq
3701
+ }, `ob11: 精华${detail}(跳过事件)`);
3702
+ continue;
3703
+ }
3704
+ const messageId = await enrich.resolveEssenceMsgId(groupCode, item.messageSeq);
3705
+ if (messageId === null) continue;
3706
+ const operatorId = numericUin(item.operatorUin);
3707
+ broadcast({
3708
+ time: item.addDigestTime ?? Math.floor(Date.now() / 1e3),
3709
+ self_id: Number(selfUin),
3710
+ post_type: "notice",
3711
+ notice_type: "group_essence",
3712
+ sub_type: subType,
3713
+ group_id: Number(groupCode),
3714
+ sender_id: senderId,
3715
+ ...operatorId !== null ? { operator_id: operatorId } : {},
3716
+ message_id: messageId
3717
+ });
3718
+ }
3719
+ }
3720
+ };
3721
+ // src/onebot11/helper/notice-extra.ts
3722
+ /** 毫秒 → 秒(Unix 时间戳)。 */
3723
+ const MS_TO_SEC = 1e3;
3724
+ /** 候选 uin 字段(按优先级取第一个数字串;uid 串不硬转——待校准)。 */
3725
+ function pickUin(item) {
3726
+ for (const key of [
3727
+ "senderUin",
3728
+ "fromUin",
3729
+ "peerUin"
3730
+ ]) {
3731
+ const v = item[key];
3732
+ if (typeof v === "string" && v !== "" && Number.isFinite(Number(v))) return v;
3733
+ }
3734
+ return "0";
3735
+ }
3736
+ /** 候选 url 字段(fileUrl / url;未知为空串)。 */
3737
+ function pickUrl(item) {
3738
+ for (const key of ["fileUrl", "url"]) {
3739
+ const v = item[key];
3740
+ if (typeof v === "string" && v !== "") return v;
3741
+ }
3742
+ return "";
3743
+ }
3744
+ /** 单个候选对象 → 归一化项(不可识别返回 null)。接受两类形状:
3745
+ * ① RawMessage 型(elements[].fileElement——离线文件以消息推送到达的假设,
3746
+ * 与 onRecvOfflineFileMsg 挂在 MsgService、UpdateC2CFileMsg 字符串一致)
3747
+ * ② 专用实体型(顶层 fileName 或 fileInfo.fileName——getNewOfflineFileList 族) */
3748
+ function narrowItem(item) {
3749
+ if (typeof item !== "object" || item === null) return null;
3750
+ const obj = item;
3751
+ if (Array.isArray(obj["elements"])) {
3752
+ const file = obj["elements"].find((e) => typeof e === "object" && e !== null && "fileElement" in e)?.fileElement;
3753
+ if (file === void 0) return null;
3754
+ return {
3755
+ senderUin: pickUin(obj),
3756
+ name: typeof file["fileName"] === "string" ? file["fileName"] : "",
3757
+ size: Number(file["fileSize"] ?? 0),
3758
+ url: pickUrl(file)
3759
+ };
3760
+ }
3761
+ const file = obj["fileInfo"] ?? obj;
3762
+ if (typeof file["fileName"] !== "string") return null;
3763
+ return {
3764
+ senderUin: pickUin(obj),
3765
+ name: file["fileName"],
3766
+ size: Number(file["fileSize"] ?? 0),
3767
+ url: pickUrl(file)
3768
+ };
3769
+ }
3770
+ /**
3771
+ * onRecvOfflineFileMsg 参数 → 归一化项列表(防御性收窄)。
3772
+ * 接受数组 / 单对象;全部不可识别返回 null(调用方打 raw 日志)。
3773
+ * 空数组同样返回 null(无文件可翻译,与未知形状同走日志路径无害)。
3774
+ */
3775
+ function narrowOfflineFiles(arg) {
3776
+ const narrowed = (Array.isArray(arg) ? arg : [arg]).map(narrowItem).filter((v) => v !== null);
3777
+ return narrowed.length > 0 ? narrowed : null;
3778
+ }
3779
+ /** 归一化项 → OB11 offline_file notice(time 取当前时刻,friend_add 同款)。 */
3780
+ function toOfflineFileNotice(item, selfUin) {
3781
+ return {
3782
+ time: Math.floor(Date.now() / MS_TO_SEC),
3783
+ self_id: Number(selfUin),
3784
+ post_type: "notice",
3785
+ notice_type: "offline_file",
3786
+ user_id: Number(item.senderUin),
3787
+ file: {
3788
+ name: item.name,
3789
+ size: item.size,
3790
+ url: item.url
3791
+ }
3792
+ };
3793
+ }
3794
+ // src/onebot11/inbound/file-notice.ts
3795
+ /** OB11 轻量通知域处理器(文件 / 好友新增等无独立翻译链的通知)。 */
3796
+ var Ob11InboundFileNotice = class {
3797
+ deps;
3798
+ constructor(deps) {
3799
+ this.deps = deps;
3800
+ }
3801
+ /**
3802
+ * 离线文件(c3,2026-09-10):Msg/onRecvOfflineFileMsg → OB11 offline_file
3803
+ * notice(payload 形状待校准:防御性收窄,未知形状 raw 日志积累)。
3804
+ */
3805
+ offlineFile(arg) {
3806
+ const items = narrowOfflineFiles(arg);
3807
+ if (items === null) {
3808
+ this.deps.logger?.warn({ raw: truncRaw(JSON.stringify(arg)) }, "ob11: onRecvOfflineFileMsg 未知参数形状");
3809
+ return;
3810
+ }
3811
+ for (const item of items) this.deps.broadcast(toOfflineFileNotice(item, this.deps.selfUin));
3812
+ }
3813
+ /** 在线文件:OB11 无对应通知类型;debug 级 raw 校准日志(2026-10-25)。 */
3814
+ onlineFile(arg) {
3815
+ this.deps.logger?.debug({ raw: sliceRaw(JSON.stringify(arg)) }, "ob11: onRecvOnlineFileMsg raw(校准数据)");
3816
+ }
3817
+ /** 好友列表变化:快照字段较多,raw 日志保留积累校准数据(翻译走 friendAdd)。 */
3818
+ buddyList(evt, arg) {
3819
+ this.deps.logger?.info({ raw: truncRaw(JSON.stringify(arg)) }, `ob11: ${evt} raw(friend_add 校准数据)`);
3820
+ }
3821
+ /** 好友缓存 diff 新增(B2,2026-09-08)→ friend_add notice(翻译纯函数)。 */
3822
+ friendAdd(entry) {
3823
+ this.deps.broadcast(toFriendAdd(entry, this.deps.selfUin));
3824
+ }
3825
+ };
3624
3826
  // src/onebot11/helper/message-event.ts
3625
3827
  /** RawMessage → OB11 消息事件(message_id 经 MessageUnique 映射并记录 peer)。
3626
3828
  * messageFormat 决定 message 字段格式:array = 消息段数组(标准),string = CQ 码字符串。
@@ -3673,78 +3875,102 @@ function toOb11MessageEvent(msg, selfUin, unique, messageFormat = "array", ctx =
3673
3875
  sender
3674
3876
  };
3675
3877
  }
3676
- // src/onebot11/helper/notice-extra.ts
3677
- /** 毫秒 → 秒(Unix 时间戳)。 */
3678
- const MS_TO_SEC$1 = 1e3;
3679
- /** 候选 uin 字段(按优先级取第一个数字串;uid 串不硬转——待校准)。 */
3680
- function pickUin(item) {
3681
- for (const key of [
3682
- "senderUin",
3683
- "fromUin",
3684
- "peerUin"
3685
- ]) {
3686
- const v = item[key];
3687
- if (typeof v === "string" && v !== "" && Number.isFinite(Number(v))) return v;
3878
+ // src/onebot11/inbound/message.ts
3879
+ /** OB11 消息域处理器(Msg/onRecvMsg 分流与翻译派发)。 */
3880
+ var Ob11InboundMessage = class {
3881
+ deps;
3882
+ reportSelfMessage = false;
3883
+ messageFormat = "array";
3884
+ /** 群文件报形式(B4):true = fileElement 群消息报 group_upload notice 替代 message。 */
3885
+ groupUploadAsNotice = false;
3886
+ constructor(deps) {
3887
+ this.deps = deps;
3688
3888
  }
3689
- return "0";
3690
- }
3691
- /** 候选 url 字段(fileUrl / url;未知为空串)。 */
3692
- function pickUrl(item) {
3693
- for (const key of ["fileUrl", "url"]) {
3694
- const v = item[key];
3695
- if (typeof v === "string" && v !== "") return v;
3889
+ /** 刷新收链路开关(start / subscribeOnly / reload 共用)。 */
3890
+ applyConfig(config) {
3891
+ this.reportSelfMessage = config.reportSelfMessage;
3892
+ this.messageFormat = config.messagePostFormat;
3893
+ this.groupUploadAsNotice = config.groupUploadAsNotice;
3696
3894
  }
3697
- return "";
3698
- }
3699
- /** 单个候选对象 → 归一化项(不可识别返回 null)。接受两类形状:
3700
- * ① RawMessage 型(elements[].fileElement——离线文件以消息推送到达的假设,
3701
- * 与 onRecvOfflineFileMsg 挂在 MsgService、UpdateC2CFileMsg 字符串一致)
3702
- * ② 专用实体型(顶层 fileName 或 fileInfo.fileName——getNewOfflineFileList 族) */
3703
- function narrowItem(item) {
3704
- if (typeof item !== "object" || item === null) return null;
3705
- const obj = item;
3706
- if (Array.isArray(obj["elements"])) {
3707
- const file = obj["elements"].find((e) => typeof e === "object" && e !== null && "fileElement" in e)?.fileElement;
3708
- if (file === void 0) return null;
3895
+ /** 单条收向消息:grayTip→notice / 自消息过滤 / 群文件开关 / message 事件。 */
3896
+ handleRawMessage(msg) {
3897
+ if (hasGrayTip(msg)) {
3898
+ this.broadcastNotice(msg).catch((err) => {
3899
+ this.deps.logger?.debug({ err: err instanceof Error ? err.message : String(err) }, "ob11: notice 翻译失败(整个事件丢弃)");
3900
+ });
3901
+ return;
3902
+ }
3903
+ if (!this.reportSelfMessage && String(msg.senderUin) === this.deps.selfUin) return;
3904
+ if (this.groupUploadAsNotice && msg.chatType === ChatType.GROUP && hasFileElement(msg)) {
3905
+ const notice = toGroupUpload(msg, this.deps.selfUin);
3906
+ if (notice !== null) {
3907
+ this.deps.broadcast(notice);
3908
+ return;
3909
+ }
3910
+ }
3911
+ this.broadcastMessageEvent(msg);
3912
+ }
3913
+ /**
3914
+ * 广播消息事件(P2-19):回填 ctx 后交纯函数翻译;ID 转换在 enrichment 批量完成。
3915
+ */
3916
+ async broadcastMessageEvent(msg) {
3917
+ const ctx = await this.deps.enrich.messageContext(msg);
3918
+ this.deps.broadcast(toOb11MessageEvent(msg, this.deps.selfUin, this.deps.api.messageUnique, this.messageFormat, ctx));
3919
+ }
3920
+ /** 广播 grayTip → notice 事件(批量 uidToUin 后翻译,纯函数)。 */
3921
+ async broadcastNotice(msg) {
3922
+ const uidToUin = await this.deps.enrich.noticeUidMap(collectGrayTipUids(msg));
3923
+ const notice = toOb11NoticeEvent(msg, {
3924
+ selfUin: this.deps.selfUin,
3925
+ uidToUin,
3926
+ ...this.deps.logger !== void 0 ? { logger: this.deps.logger } : {}
3927
+ });
3928
+ if (notice !== null) this.deps.broadcast(notice);
3929
+ }
3930
+ };
3931
+ // src/onebot11/inbound/request.ts
3932
+ /** OB11 请求域处理器(群通知 / 好友申请的 uid 回填与广播)。 */
3933
+ var Ob11InboundRequest = class {
3934
+ deps;
3935
+ constructor(deps) {
3936
+ this.deps = deps;
3937
+ }
3938
+ /** 群系统通知 → group request 事件(批量 uidToUin 后翻译,纯函数)。 */
3939
+ async groupNotifies(doubt, notifies) {
3940
+ if (doubt || !Array.isArray(notifies)) return;
3941
+ const ctx = await this.requestCtx(collectGroupNotifyUids(notifies));
3942
+ for (const notify of notifies) {
3943
+ const event = toOb11GroupRequestEvent(notify, ctx);
3944
+ if (event !== null) this.deps.broadcast(event);
3945
+ }
3946
+ }
3947
+ /** 好友申请 → friend request 事件(防御收窄;未知形状 raw warn 校准)。 */
3948
+ buddyReqs(arg) {
3949
+ this.broadcastBuddyReqs(arg);
3950
+ }
3951
+ /** 好友申请翻译派发(flag=reqTime;uid→uin 批量失败退空 Map)。 */
3952
+ async broadcastBuddyReqs(arg) {
3953
+ const reqs = narrowBuddyReqs(arg);
3954
+ if (reqs === null) {
3955
+ this.deps.logger?.warn({ raw: truncRaw(JSON.stringify(arg)) }, "ob11: onBuddyReqChange 未知参数形状");
3956
+ return;
3957
+ }
3958
+ const ctx = await this.requestCtx(reqs.map((r) => r.friendUid).filter((uid) => uid !== ""));
3959
+ for (const req of reqs) this.deps.broadcast(toOb11FriendRequestEvent(req, ctx));
3960
+ }
3961
+ /** request 翻译上下文(uid→uin 批量;失败退空 Map 不阻塞上报)。 */
3962
+ async requestCtx(uids) {
3709
3963
  return {
3710
- senderUin: pickUin(obj),
3711
- name: typeof file["fileName"] === "string" ? file["fileName"] : "",
3712
- size: Number(file["fileSize"] ?? 0),
3713
- url: pickUrl(file)
3964
+ selfUin: this.deps.selfUin,
3965
+ uidToUin: await this.deps.enrich.uidToUinMap(uids)
3714
3966
  };
3715
3967
  }
3716
- const file = obj["fileInfo"] ?? obj;
3717
- if (typeof file["fileName"] !== "string") return null;
3718
- return {
3719
- senderUin: pickUin(obj),
3720
- name: file["fileName"],
3721
- size: Number(file["fileSize"] ?? 0),
3722
- url: pickUrl(file)
3723
- };
3724
- }
3725
- /**
3726
- * onRecvOfflineFileMsg 参数 → 归一化项列表(防御性收窄)。
3727
- * 接受数组 / 单对象;全部不可识别返回 null(调用方打 raw 日志)。
3728
- * 空数组同样返回 null(无文件可翻译,与未知形状同走日志路径无害)。
3729
- */
3730
- function narrowOfflineFiles(arg) {
3731
- const narrowed = (Array.isArray(arg) ? arg : [arg]).map(narrowItem).filter((v) => v !== null);
3732
- return narrowed.length > 0 ? narrowed : null;
3733
- }
3734
- /** 归一化项 → OB11 offline_file notice(time 取当前时刻,friend_add 同款)。 */
3735
- function toOfflineFileNotice(item, selfUin) {
3736
- return {
3737
- time: Math.floor(Date.now() / MS_TO_SEC$1),
3738
- self_id: Number(selfUin),
3739
- post_type: "notice",
3740
- notice_type: "offline_file",
3741
- user_id: Number(item.senderUin),
3742
- file: {
3743
- name: item.name,
3744
- size: item.size,
3745
- url: item.url
3746
- }
3747
- };
3968
+ };
3969
+ /** 收集群系统通知涉及的 uid(user1/user2 双方,空 uid 跳过)。 */
3970
+ function collectGroupNotifyUids(notifies) {
3971
+ const uids = [];
3972
+ for (const notify of notifies) for (const user of [notify.user1, notify.user2]) if (typeof user?.uid === "string" && user.uid !== "") uids.push(user.uid);
3973
+ return uids;
3748
3974
  }
3749
3975
  // src/onebot11/helper/sysmsg.ts
3750
3976
  /**
@@ -3761,7 +3987,7 @@ function toOfflineFileNotice(item, selfUin) {
3761
3987
  * 从 `core/shared/sysmsg.js` 导入使用。
3762
3988
  */
3763
3989
  /** 群号判别(strings[0] 必须是数字串)。 */
3764
- const NUMERIC_RE$1 = /^\d+$/;
3990
+ const NUMERIC_RE = /^\d+$/;
3765
3991
  /**
3766
3992
  * (msgType, subType) → 规则表(键 = 原生分发键,design.md §7.1)。
3767
3993
  *
@@ -3777,7 +4003,7 @@ const KIND_TABLE = /* @__PURE__ */ new Map([["732:21", {
3777
4003
  },
3778
4004
  extract: (_tree, env, uinOf, ctx) => {
3779
4005
  const [groupCode, subject, cardNew, cardOld] = env.strings;
3780
- if (groupCode === void 0 || subject === void 0 || !NUMERIC_RE$1.test(groupCode) || !subject.startsWith("u_")) return null;
4006
+ if (groupCode === void 0 || subject === void 0 || !NUMERIC_RE.test(groupCode) || !subject.startsWith("u_")) return null;
3781
4007
  return {
3782
4008
  time: ctx.time,
3783
4009
  self_id: ctx.selfUin,
@@ -3800,6 +4026,111 @@ const OBSERVED_UNNAMED = /* @__PURE__ */ new Set([
3800
4026
  function recognizeOb11SysMsg(msgType, subType, table = KIND_TABLE) {
3801
4027
  return recognizeSysMsg(msgType, subType, table, OBSERVED_UNNAMED);
3802
4028
  }
4029
+ // src/onebot11/inbound/sysmsg.ts
4030
+ /**
4031
+ * OB11 inbound sysmsg 域(2026-11-14 自 event-pipeline.ts 拆出)
4032
+ *
4033
+ * Msg/onRecvSysMsg 总闸:参数收窄(未知形状 raw warn)→ 单条字节块走
4034
+ * core/shared/sysmsg.ts 的 processSysMsgBlob 通用管线(解码 → 信封 → 识别 →
4035
+ * 分流)。表命中做两件事:732:1 精华加速触发器(表外,踢入 essence 域的串行
4036
+ * diff 链)与识别表规则广播(uid→uin 经 enrichment 批量回填后 extract);
4037
+ * 未识别 / 提取失败落校准路径,不广播半成品。
4038
+ */
4039
+ /** OB11 sysmsg 域处理器(解码识别分流 + 精华触发器)。 */
4040
+ var Ob11InboundSysMsg = class {
4041
+ deps;
4042
+ constructor(deps) {
4043
+ this.deps = deps;
4044
+ }
4045
+ /** onRecvSysMsg 总闸:参数收窄(未知形状 raw warn)→ 逐块走通用管线。 */
4046
+ handleRawArg(arg) {
4047
+ const blobs = narrowSysMsgBlobs(arg);
4048
+ if (blobs === null) {
4049
+ this.deps.logger?.warn({ raw: truncRaw(JSON.stringify(arg)) }, "ob11: onRecvSysMsg 未知参数形状");
4050
+ return;
4051
+ }
4052
+ for (const blob of blobs) processSysMsgBlob(blob, {
4053
+ scope: "ob11",
4054
+ logger: this.deps.logger,
4055
+ decodeFailLevel: "warn",
4056
+ recognize: (msgType, subType) => recognizeOb11SysMsg(msgType, subType),
4057
+ onNotice: (tree, env, rec) => this.handleRecognized(tree, env, rec)
4058
+ });
4059
+ }
4060
+ /**
4061
+ * 已解码 sysmsg 分流(732:1 精华触发器 / 识别表规则广播);返回 true =
4062
+ * 已消费。提取失败返回 false 落入校准路径(不硬广播半成品事件)。
4063
+ */
4064
+ async handleRecognized(tree, env, rec) {
4065
+ if (env.msgType === 732 && env.subType === 1 && this.deps.essence.triggerFromSysMsg(tree)) return true;
4066
+ if (rec.kind !== "notice") return false;
4067
+ const uinOf = await this.deps.enrich.sysMsgUinResolver(rec.rule, tree, env);
4068
+ const ctx = {
4069
+ selfUin: Number(this.deps.selfUin),
4070
+ time: env.time ?? Math.floor(Date.now() / 1e3)
4071
+ };
4072
+ const event = rec.rule.extract(tree, env, uinOf, ctx);
4073
+ if (event === null) return false;
4074
+ this.deps.broadcast(event);
4075
+ return true;
4076
+ }
4077
+ };
4078
+ // src/onebot11/event-pipeline.ts
4079
+ var Ob11EventPipeline = class {
4080
+ deps;
4081
+ essence;
4082
+ message;
4083
+ sysMsg;
4084
+ request;
4085
+ fileNotice;
4086
+ unsubscribes = [];
4087
+ constructor(deps) {
4088
+ this.deps = deps;
4089
+ const enrich = new Ob11Enrichment({
4090
+ api: deps.api,
4091
+ logger: deps.logger
4092
+ });
4093
+ this.essence = new Ob11InboundEssence({
4094
+ ...deps,
4095
+ enrich
4096
+ });
4097
+ this.message = new Ob11InboundMessage({
4098
+ ...deps,
4099
+ enrich
4100
+ });
4101
+ this.sysMsg = new Ob11InboundSysMsg({
4102
+ ...deps,
4103
+ enrich,
4104
+ essence: this.essence
4105
+ });
4106
+ this.request = new Ob11InboundRequest({
4107
+ ...deps,
4108
+ enrich
4109
+ });
4110
+ this.fileNotice = new Ob11InboundFileNotice(deps);
4111
+ }
4112
+ applyConfig(config) {
4113
+ this.message.applyConfig(config);
4114
+ }
4115
+ /** 订阅 kernel 事件(消息 + 群 + 好友 + 好友缓存,幂等;路由到 inbound/)。 */
4116
+ subscribe() {
4117
+ if (this.unsubscribes.length > 0) return;
4118
+ const { msgChannel, groupChannel, friendChannel, buddyCacheEvents } = this.deps;
4119
+ this.unsubscribes.push(subscribeRawMessages(msgChannel, (msg) => this.message.handleRawMessage(msg)), msgChannel.on("Msg/onRecvOfflineFileMsg", (a) => this.fileNotice.offlineFile(a)), msgChannel.on("Msg/onRecvSysMsg", (a) => this.sysMsg.handleRawArg(a)), msgChannel.on("Msg/onRecvOnlineFileMsg", (a) => this.fileNotice.onlineFile(a)));
4120
+ if (groupChannel !== void 0) this.unsubscribes.push(groupChannel.on("Group/onGroupNotifiesUpdated", (doubt, notifies) => {
4121
+ this.request.groupNotifies(doubt, notifies);
4122
+ }), groupChannel.on("Group/onGroupEssenceListChange", (a) => this.essence.change(a)));
4123
+ if (friendChannel !== void 0) {
4124
+ this.unsubscribes.push(friendChannel.on("Buddy/onBuddyReqChange", (a) => this.request.buddyReqs(a)));
4125
+ for (const evt of ["Buddy/onBuddyListChange", "Buddy/onBuddyListChangedV2"]) this.unsubscribes.push(friendChannel.on(evt, (a) => this.fileNotice.buddyList(evt, a)));
4126
+ }
4127
+ if (buddyCacheEvents !== void 0) this.unsubscribes.push(buddyCacheEvents.on("BuddyCache/onBuddyAdded", (e) => this.fileNotice.friendAdd(e)));
4128
+ }
4129
+ unsubscribeAll() {
4130
+ for (const off of this.unsubscribes) off();
4131
+ this.unsubscribes = [];
4132
+ }
4133
+ };
3803
4134
  // src/onebot11/transport.ts
3804
4135
  /**
3805
4136
  * OB11 传输装配(P2-5,2026-08-05)
@@ -3945,48 +4276,19 @@ function authorizeHeader(token) {
3945
4276
  return { authorization: `${BEARER_PREFIX}${token}` };
3946
4277
  }
3947
4278
  // src/onebot11/adapter.ts
3948
- /** 毫秒 → 秒(Unix 时间戳)。 */
3949
- const MS_TO_SEC = 1e3;
3950
- /**
3951
- * info/warn 级 raw 字段截断上限(2026-10-25 输出内容治理):hex/base64/JSON
3952
- * 原文对运行状态无信息量,保留前缀定位 + 缺省长度;完整值仅在 debug 级
3953
- * ([log.levels].ob11 = "debug")与日志文件中出现。
3954
- */
3955
- const RAW_INFO_LIMIT = 64;
3956
- /** raw 字段截断:超限截断 + 缺省长度标注(…(+N))。 */
3957
- function truncRaw(value, keep = RAW_INFO_LIMIT) {
3958
- if (value === void 0) return "";
3959
- return value.length <= keep ? value : `${value.slice(0, keep)}…(+${value.length - keep})`;
3960
- }
3961
- /** 数字串判别(uin)。 */
3962
- const NUMERIC_RE = /^\d+$/;
3963
- /** 数字串 uin → number(缺失/非法 → null,调用方按口径省略或跳过)。 */
3964
- function numericUin(value) {
3965
- return value !== null && NUMERIC_RE.test(value) ? Number(value) : null;
3966
- }
3967
4279
  /** OneBot 11 协议适配器。 */
3968
4280
  var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
3969
4281
  protocol = "onebot11";
3970
- msgChannel;
3971
- groupChannel;
3972
- friendChannel;
3973
- buddyCacheEvents;
3974
- calibLogger;
3975
4282
  selfUin;
3976
4283
  oneBotApi;
3977
4284
  /** 动作注册表(公共只读:IPC 桥等装配方枚举动作名直接挂载)。 */
3978
4285
  registry;
3979
- unsubscribes = [];
4286
+ /** 收链路事件管道(订阅 / 过滤 / 翻译派发,2026-11-14 拆出)。 */
4287
+ pipeline;
3980
4288
  transports = null;
3981
4289
  heartbeatTimer = null;
3982
- reportSelfMessage = false;
3983
- messageFormat = "array";
3984
- /** 群文件报形式(B4):true = fileElement 群消息报 group_upload notice 替代 message。 */
3985
- groupUploadAsNotice = false;
3986
4290
  /** IPC 桥模式标记(subscribeOnly 启动;reload 时跳过传输重建)。 */
3987
4291
  subscribedOnly = false;
3988
- /** 精华列表串行同步(core 共享组件:缓存 + 串行链 + diff;732:1 触发器与列表回调共用)。 */
3989
- essenceSync;
3990
4292
  constructor(opts) {
3991
4293
  super({
3992
4294
  config: opts.config,
@@ -3997,23 +4299,17 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
3997
4299
  onReload: (config) => this.reloadTransports(config)
3998
4300
  }
3999
4301
  });
4000
- this.msgChannel = opts.msgChannel;
4001
- this.groupChannel = opts.groupChannel;
4002
- this.friendChannel = opts.friendChannel;
4003
- this.buddyCacheEvents = opts.buddyCacheEvents;
4004
- this.calibLogger = opts.logger;
4005
4302
  this.selfUin = opts.self.uin;
4006
4303
  this.oneBotApi = new OneBotApi(opts);
4007
- this.essenceSync = new EssenceListSync({
4008
- fetchList: (groupCode) => this.oneBotApi.webApi.getEssenceMsgList(groupCode),
4009
- onAdded: (groupCode, added) => this.broadcastEssenceAdded(groupCode, added),
4010
- onRemoved: (groupCode, removed, prev) => this.broadcastEssenceRemoved(groupCode, removed, prev),
4011
- onFetchError: (groupCode, err) => {
4012
- this.calibLogger?.warn({
4013
- group: groupCode,
4014
- err: String(err)
4015
- }, "ob11: 精华列表拉取失败(diff 跳过)");
4016
- }
4304
+ this.pipeline = new Ob11EventPipeline({
4305
+ selfUin: this.selfUin,
4306
+ api: this.oneBotApi,
4307
+ broadcast: (event) => this.broadcastEvent(event),
4308
+ ...opts.logger !== void 0 ? { logger: opts.logger } : {},
4309
+ msgChannel: opts.msgChannel,
4310
+ ...opts.groupChannel !== void 0 ? { groupChannel: opts.groupChannel } : {},
4311
+ ...opts.friendChannel !== void 0 ? { friendChannel: opts.friendChannel } : {},
4312
+ ...opts.buddyCacheEvents !== void 0 ? { buddyCacheEvents: opts.buddyCacheEvents } : {}
4017
4313
  });
4018
4314
  this.registry = createOb11ActionRegistry({ api: this.oneBotApi });
4019
4315
  }
@@ -4023,9 +4319,7 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
4023
4319
  */
4024
4320
  async reloadTransports(config) {
4025
4321
  if (this.subscribedOnly) {
4026
- this.reportSelfMessage = config.reportSelfMessage;
4027
- this.messageFormat = config.messagePostFormat;
4028
- this.groupUploadAsNotice = config.groupUploadAsNotice;
4322
+ this.pipeline.applyConfig(config);
4029
4323
  return;
4030
4324
  }
4031
4325
  await this.stopAll();
@@ -4034,9 +4328,7 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
4034
4328
  /** 启动传输:装配(HTTP/WS)+ 打开 server/client + 广播 lifecycle enable + 起心跳。 */
4035
4329
  async startTransports(config) {
4036
4330
  this.subscribedOnly = false;
4037
- this.reportSelfMessage = config.reportSelfMessage;
4038
- this.messageFormat = config.messagePostFormat;
4039
- this.groupUploadAsNotice = config.groupUploadAsNotice;
4331
+ this.pipeline.applyConfig(config);
4040
4332
  const broadcaster = this.getBroadcaster();
4041
4333
  if (broadcaster !== void 0) {
4042
4334
  this.transports = assembleOb11Transports({
@@ -4059,9 +4351,9 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
4059
4351
  await Promise.all(this.transports.servers.map((s) => s.open()));
4060
4352
  await Promise.all(this.transports.transports.map((t) => t.open()));
4061
4353
  }
4062
- this.subscribe();
4354
+ this.pipeline.subscribe();
4063
4355
  this.broadcastEvent({
4064
- time: Math.floor(Date.now() / MS_TO_SEC),
4356
+ time: Math.floor(Date.now() / MS_TO_SEC$2),
4065
4357
  self_id: Number(this.selfUin),
4066
4358
  post_type: "meta_event",
4067
4359
  meta_event_type: "lifecycle",
@@ -4074,7 +4366,7 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
4074
4366
  if (intervalMs <= 0) return;
4075
4367
  this.heartbeatTimer = setInterval(() => {
4076
4368
  this.broadcastEvent({
4077
- time: Math.floor(Date.now() / MS_TO_SEC),
4369
+ time: Math.floor(Date.now() / MS_TO_SEC$2),
4078
4370
  self_id: Number(this.selfUin),
4079
4371
  post_type: "meta_event",
4080
4372
  meta_event_type: "heartbeat",
@@ -4092,306 +4384,29 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
4092
4384
  clearInterval(this.heartbeatTimer);
4093
4385
  this.heartbeatTimer = null;
4094
4386
  }
4095
- this.unsubscribeAll();
4387
+ this.pipeline.unsubscribeAll();
4096
4388
  if (this.transports !== null) {
4097
4389
  await this.transports.close();
4098
4390
  this.transports = null;
4099
4391
  }
4100
4392
  }
4101
- /** 订阅 kernel 事件(消息 + 群通知 + 好友请求,幂等)。 */
4102
- subscribe() {
4103
- if (this.unsubscribes.length > 0) return;
4104
- this.unsubscribes.push(subscribeRawMessages(this.msgChannel, (msg) => {
4105
- if (hasGrayTip(msg)) {
4106
- this.broadcastNotice(msg).catch(() => {});
4107
- return;
4108
- }
4109
- if (!this.reportSelfMessage && String(msg.senderUin) === this.selfUin) return;
4110
- if (this.groupUploadAsNotice && msg.chatType === ChatType.GROUP && hasFileElement(msg)) {
4111
- const notice = toGroupUpload(msg, this.selfUin);
4112
- if (notice !== null) {
4113
- this.broadcastEvent(notice);
4114
- return;
4115
- }
4116
- }
4117
- this.broadcastMessageEvent(msg);
4118
- }));
4119
- this.unsubscribes.push(this.msgChannel.on("Msg/onRecvOfflineFileMsg", (arg) => {
4120
- const items = narrowOfflineFiles(arg);
4121
- if (items === null) {
4122
- this.calibLogger?.warn({ raw: truncRaw(JSON.stringify(arg)) }, "ob11: onRecvOfflineFileMsg 未知参数形状");
4123
- return;
4124
- }
4125
- for (const item of items) this.broadcastEvent(toOfflineFileNotice(item, this.selfUin));
4126
- }));
4127
- this.unsubscribes.push(this.msgChannel.on("Msg/onRecvSysMsg", (arg) => {
4128
- const blobs = narrowSysMsgBlobs(arg);
4129
- if (blobs === null) {
4130
- this.calibLogger?.warn({ raw: truncRaw(JSON.stringify(arg)) }, "ob11: onRecvSysMsg 未知参数形状");
4131
- return;
4132
- }
4133
- for (const blob of blobs) this.handleSysMsgBlob(blob);
4134
- }));
4135
- this.unsubscribes.push(this.msgChannel.on("Msg/onRecvOnlineFileMsg", (arg) => {
4136
- this.calibLogger?.debug({ raw: JSON.stringify(arg)?.slice(0, 2e3) }, "ob11: onRecvOnlineFileMsg raw(校准数据)");
4137
- }));
4138
- if (this.groupChannel !== void 0) {
4139
- this.unsubscribes.push(this.groupChannel.on("Group/onGroupNotifiesUpdated", (doubt, notifies) => {
4140
- if (doubt || !Array.isArray(notifies)) return;
4141
- this.broadcastGroupRequests(notifies);
4142
- }));
4143
- this.unsubscribes.push(this.groupChannel.on("Group/onGroupEssenceListChange", (arg) => {
4144
- this.handleEssenceChange(arg);
4145
- }));
4146
- }
4147
- if (this.friendChannel !== void 0) {
4148
- this.unsubscribes.push(this.friendChannel.on("Buddy/onBuddyReqChange", (arg) => {
4149
- const reqs = narrowBuddyReqs(arg);
4150
- if (reqs === null) {
4151
- this.calibLogger?.warn({ raw: truncRaw(JSON.stringify(arg)) }, "ob11: onBuddyReqChange 未知参数形状");
4152
- return;
4153
- }
4154
- this.broadcastFriendRequests(reqs);
4155
- }));
4156
- for (const evt of ["Buddy/onBuddyListChange", "Buddy/onBuddyListChangedV2"]) this.unsubscribes.push(this.friendChannel.on(evt, (arg) => {
4157
- this.calibLogger?.info({ raw: truncRaw(JSON.stringify(arg)) }, `ob11: ${evt} raw(friend_add 校准数据)`);
4158
- }));
4159
- }
4160
- if (this.buddyCacheEvents !== void 0) this.unsubscribes.push(this.buddyCacheEvents.on("BuddyCache/onBuddyAdded", (entry) => {
4161
- this.broadcastEvent(toFriendAdd(entry, this.selfUin));
4162
- }));
4163
- }
4164
4393
  /**
4165
4394
  * 仅启动接收链路(IPC 桥模式,2026-08-27):订阅消息通道维护 messageUnique +
4166
- * 灰色通知翻译,与 start() 的差别仅在传输层——不装配 HTTP/WS、不起心跳、
4167
- * 不广播 lifecycle。配置经 seed 装配(load() 返回内存初值)。
4395
+ * 灰色通知翻译;与 start() 的差别仅在传输层(无 HTTP/WS、无心跳、无 lifecycle)。
4396
+ * 配置经 seed 装配(load() 返回内存初值)。
4168
4397
  */
4169
4398
  async subscribeOnly() {
4170
4399
  const config = await this.config.load();
4171
- this.reportSelfMessage = config.reportSelfMessage;
4172
- this.messageFormat = config.messagePostFormat;
4173
- this.groupUploadAsNotice = config.groupUploadAsNotice;
4400
+ this.pipeline.applyConfig(config);
4174
4401
  this.subscribedOnly = true;
4175
- this.subscribe();
4402
+ this.pipeline.subscribe();
4176
4403
  }
4177
4404
  /** 仅退订(与 subscribeOnly 配对的进程级清理;传输关闭仍走 stop())。 */
4178
4405
  unsubscribeOnly() {
4179
4406
  this.subscribedOnly = false;
4180
- this.unsubscribeAll();
4181
- }
4182
- /** sysmsg 规则的 uid→uin 解析器(collectUids 声明才批量转换;失败/缺省恒 0)。 */
4183
- async sysMsgUinResolver(rule, tree, env) {
4184
- if (rule.collectUids === void 0) return () => 0;
4185
- const uids = rule.collectUids(tree, env).filter((uid) => uid !== "");
4186
- if (uids.length === 0) return () => 0;
4187
- try {
4188
- const map = await this.oneBotApi.uidToUin(uids);
4189
- return (uid) => Number(map.get(uid) ?? 0);
4190
- } catch {
4191
- return () => 0;
4192
- }
4193
- }
4194
- /**
4195
- * 单条 sysmsg 字节块:解码 → 识别 → 命中才广播,未识别打结构化校准日志
4196
- * (识别表 2026-11-01 起含 732:21 group_card;732:1 精华为加速触发器,
4197
- * design.md §1/§7.5)。规则声明 collectUids 时先批量 uid→uin 再提取。
4198
- */
4199
- async handleSysMsgBlob(blob) {
4200
- const tree = decodeProtoTree(blob);
4201
- if (tree === null) {
4202
- this.calibLogger?.warn({ raw: truncRaw(toHex(blob).slice(0, 1024)) }, "ob11: onRecvSysMsg protobuf 解码失败");
4203
- return;
4204
- }
4205
- const env = extractSysMsgEnvelope(tree);
4206
- const rec = recognizeOb11SysMsg(env.msgType, env.subType);
4207
- if (await this.handleRecognizedSysMsg(tree, env, rec)) return;
4208
- this.calibLogger?.debug({
4209
- verdict: rec.kind,
4210
- msgType: env.msgType,
4211
- subType: env.subType,
4212
- subTypeAlt: env.subTypeAlt,
4213
- groupCodes: env.groupCodes,
4214
- time: env.time,
4215
- actorUin: env.actorUin,
4216
- actorUid: env.actorUid,
4217
- strings: env.strings,
4218
- raw: toHex(blob).slice(0, 1024)
4219
- }, "ob11: onRecvSysMsg 校准数据(未识别,不广播)");
4220
- }
4221
- /**
4222
- * 已识别 sysmsg 处理(732:1 精华触发器 / 识别表规则广播);命中返回 true。
4223
- * 提取失败返回 false 落入校准路径(不硬广播半成品事件)。
4224
- */
4225
- async handleRecognizedSysMsg(tree, env, rec) {
4226
- if (env.msgType === 732 && env.subType === 1 && this.triggerEssenceSync(tree)) return true;
4227
- if (rec.kind !== "notice") return false;
4228
- const uinOf = await this.sysMsgUinResolver(rec.rule, tree, env);
4229
- const ctx = {
4230
- selfUin: Number(this.selfUin),
4231
- time: env.time ?? Math.floor(Date.now() / 1e3)
4232
- };
4233
- const event = rec.rule.extract(tree, env, uinOf, ctx);
4234
- if (event === null) return false;
4235
- this.broadcastEvent(event);
4236
- return true;
4237
- }
4238
- /** sysmsg 732:1 → 加速触发器:抽取群号踢入串行 sync 链(抽取失败走校准路径)。 */
4239
- triggerEssenceSync(tree) {
4240
- const hit = extractEssenceSetSysMsg(tree);
4241
- if (hit === null) return false;
4242
- this.essenceSync.enqueue(String(hit.groupCode));
4243
- return true;
4244
- }
4245
- /** 精华列表变更:拉全量列表 diff(唯一发射路径;参数收窄失败走校准日志)。 */
4246
- handleEssenceChange(arg) {
4247
- const groupCode = narrowEssenceGroupArg(arg);
4248
- if (groupCode === null) {
4249
- this.calibLogger?.warn({ raw: truncRaw(JSON.stringify(arg)) }, "ob11: onGroupEssenceListChange 未知参数形状");
4250
- return;
4251
- }
4252
- this.essenceSync.enqueue(groupCode);
4253
- }
4254
- /** diff 新增项 → group_essence add(sender 必填,operator 回填,message_id 反查)。 */
4255
- async broadcastEssenceAdded(groupCode, added) {
4256
- for (const item of added) {
4257
- const senderId = numericUin(item.senderUin);
4258
- if (senderId === null) {
4259
- this.calibLogger?.warn({
4260
- group: groupCode,
4261
- seq: item.messageSeq
4262
- }, "ob11: 精华新增 sender_uin 缺失(跳过事件)");
4263
- continue;
4264
- }
4265
- const messageId = await this.resolveEssenceMsgId(groupCode, item.messageSeq);
4266
- if (messageId === null) continue;
4267
- const operatorId = numericUin(item.operatorUin);
4268
- this.broadcastEvent({
4269
- time: item.addDigestTime ?? Math.floor(Date.now() / MS_TO_SEC),
4270
- self_id: Number(this.selfUin),
4271
- post_type: "notice",
4272
- notice_type: "group_essence",
4273
- sub_type: "add",
4274
- group_id: Number(groupCode),
4275
- sender_id: senderId,
4276
- ...operatorId !== null ? { operator_id: operatorId } : {},
4277
- message_id: messageId
4278
- });
4279
- }
4280
- }
4281
- /** diff 移除项 → group_essence delete(sender 从 prev 缓存回填;operator 无数据源省略)。 */
4282
- async broadcastEssenceRemoved(groupCode, removed, prev) {
4283
- for (const seq of removed) {
4284
- const senderId = numericUin(prev.get(seq)?.senderUin ?? null);
4285
- if (senderId === null) {
4286
- this.calibLogger?.warn({
4287
- group: groupCode,
4288
- seq
4289
- }, "ob11: 精华移除 sender 不可得(跳过事件)");
4290
- continue;
4291
- }
4292
- const messageId = await this.resolveEssenceMsgId(groupCode, seq);
4293
- if (messageId === null) continue;
4294
- this.broadcastEvent({
4295
- time: Math.floor(Date.now() / MS_TO_SEC),
4296
- self_id: Number(this.selfUin),
4297
- post_type: "notice",
4298
- notice_type: "group_essence",
4299
- sub_type: "delete",
4300
- group_id: Number(groupCode),
4301
- sender_id: senderId,
4302
- message_id: messageId
4303
- });
4304
- }
4305
- }
4306
- /**
4307
- * 精华 message_id 反查:msgSeq → 近段历史扫描(60 条,对齐 milky
4308
- * resolveMsgIdBySeq fallback 层)→ MessageUnique.alloc 幂等分配(可被 get_msg
4309
- * 反查的正确空间,对照 recall 的 msgSeq 错位)。未命中返回 null(跳过事件)。
4310
- */
4311
- async resolveEssenceMsgId(groupCode, seq) {
4312
- const peer = {
4313
- chatType: ChatType.GROUP,
4314
- peerUid: groupCode
4315
- };
4316
- const hit = (await this.oneBotApi.msgApi.fetchMessages(peer, { count: 60 }).catch(() => [])).find((m) => Number(m.msgSeq) === seq);
4317
- if (hit === void 0) {
4318
- this.calibLogger?.warn({
4319
- group: groupCode,
4320
- seq
4321
- }, "ob11: 精华 message_id 反查未命中(跳过事件)");
4322
- return null;
4323
- }
4324
- return this.oneBotApi.messageUnique.alloc(hit.msgId, peer);
4325
- }
4326
- /**
4327
- * 广播消息事件(P2-19:接收方向 ID 转换)。
4328
- * 收集 at uid → 一次批量 uidToUin → 构造上下文 → 翻译广播。
4329
- * 群消息另查发送者角色(GroupCache 缓存优先,失败回退缺省 member)。
4330
- * 翻译失败退化为原样(不阻塞上报)。
4331
- */
4332
- async broadcastMessageEvent(msg) {
4333
- const { atUids } = collectReceiveNeeds(toCanonicalElements(msg));
4334
- let uidToUin;
4335
- if (atUids.length > 0) try {
4336
- uidToUin = await this.oneBotApi.uidToUin(atUids);
4337
- } catch {}
4338
- const senderRole = msg.chatType === ChatType.GROUP ? await this.oneBotApi.groupMemberRole(msg.peerUid, msg.senderUid) : void 0;
4339
- const ctx = {
4340
- ...uidToUin !== void 0 ? { uidToUin } : {},
4341
- ...senderRole !== void 0 ? { senderRole } : {},
4342
- msgIdToOb11Id: (msgId) => this.oneBotApi.messageUnique.getMessageId(msgId)
4343
- };
4344
- this.broadcastEvent(toOb11MessageEvent(msg, this.selfUin, this.oneBotApi.messageUnique, this.messageFormat, ctx));
4345
- }
4346
- /** 广播 grayTip → notice 事件(批量 uidToUin 后翻译,纯函数)。 */
4347
- async broadcastNotice(msg) {
4348
- const uids = collectGrayTipUids(msg);
4349
- let uidToUin = /* @__PURE__ */ new Map();
4350
- if (uids.length > 0) uidToUin = await this.oneBotApi.uidToUin(uids);
4351
- const notice = toOb11NoticeEvent(msg, {
4352
- selfUin: this.selfUin,
4353
- uidToUin,
4354
- ...this.calibLogger !== void 0 ? { logger: this.calibLogger } : {}
4355
- });
4356
- if (notice !== null) this.broadcastEvent(notice);
4357
- }
4358
- /** 广播群系统通知 → OB11 group request 事件(批量 uidToUin 后翻译,纯函数)。 */
4359
- async broadcastGroupRequests(notifies) {
4360
- const ctx = {
4361
- selfUin: this.selfUin,
4362
- uidToUin: await this.uidToUinMap(collectGroupNotifyUids(notifies))
4363
- };
4364
- for (const n of notifies) {
4365
- const event = toOb11GroupRequestEvent(n, ctx);
4366
- if (event !== null) this.broadcastEvent(event);
4367
- }
4368
- }
4369
- /** 广播好友申请 → OB11 friend request 事件(批量 uidToUin 后翻译,纯函数)。 */
4370
- async broadcastFriendRequests(reqs) {
4371
- const ctx = {
4372
- selfUin: this.selfUin,
4373
- uidToUin: await this.uidToUinMap(reqs.map((r) => r.friendUid).filter((uid) => uid !== ""))
4374
- };
4375
- for (const req of reqs) this.broadcastEvent(toOb11FriendRequestEvent(req, ctx));
4376
- }
4377
- /** uid 批量 → uin(失败退空 Map:翻译层退化为 uid 数值,不阻塞请求上报)。 */
4378
- async uidToUinMap(uids) {
4379
- if (uids.length === 0) return /* @__PURE__ */ new Map();
4380
- try {
4381
- return await this.oneBotApi.uidToUin(uids);
4382
- } catch {
4383
- return /* @__PURE__ */ new Map();
4384
- }
4385
- }
4386
- /** 退订(幂等)。 */
4387
- unsubscribeAll() {
4388
- for (const off of this.unsubscribes) off();
4389
- this.unsubscribes = [];
4407
+ this.pipeline.unsubscribeAll();
4390
4408
  }
4391
- /**
4392
- * 请求分发(挂到 network transport 的 onRequest):
4393
- * OB11 标准请求 { action, params, echo } → 动作注册表 → handle(HTTP)/websocketHandle(WS)。
4394
- */
4409
+ /** 请求分发(挂到 transport 的 onRequest):{ action, params, echo } → 注册表分发。 */
4395
4410
  async handleRequest(req, respond) {
4396
4411
  const parsed = req ?? {};
4397
4412
  const { action: rawAction, echo } = parsed;
@@ -4423,15 +4438,6 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
4423
4438
  respond(result);
4424
4439
  }
4425
4440
  };
4426
- /** 收集群系统通知涉及的 uid(user1/user2 双方,空 uid 跳过)。 */
4427
- function collectGroupNotifyUids(notifies) {
4428
- const uids = [];
4429
- for (const n of notifies) {
4430
- const notify = n;
4431
- for (const u of [notify.user1, notify.user2]) if (typeof u?.uid === "string" && u.uid !== "") uids.push(u.uid);
4432
- }
4433
- return uids;
4434
- }
4435
4441
  export { MessageUnique, NapukettoOneBot11Adapter, OneBotApi, assembleOb11Transports, canonicalToCqMessage, canonicalToSegments, cqMessageToCanonical, cqMessageToSegments, createOb11ActionRegistry, encodeCqCode, escapeCqParam, escapeCqText, ob11ConfigSchema, ob11ErrorCodeMap, parseCqMessage, segmentsToCanonical, segmentsToCqMessage, serializeCqParts, unescapeCqText };
4436
4442
 
4437
4443
  //# sourceMappingURL=index.mjs.map