@napuketto/adapter 0.15.1 → 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.
@@ -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(",")) {
@@ -2145,67 +2079,264 @@ 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");
2204
- const atUids = /* @__PURE__ */ new Set();
2205
- for (const m of msgs) {
2206
- const { atUids: uids } = collectReceiveNeeds(toCanonicalElements(m));
2207
- for (const u of uids) atUids.add(u);
2208
- }
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");
2335
+ const atUids = /* @__PURE__ */ new Set();
2336
+ for (const m of msgs) {
2337
+ const { atUids: uids } = collectReceiveNeeds(toCanonicalElements(m));
2338
+ for (const u of uids) atUids.add(u);
2339
+ }
2209
2340
  let uidToUin;
2210
2341
  if (atUids.size > 0) try {
2211
2342
  uidToUin = await deps.uidToUin([...atUids]);
@@ -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,47 +2553,59 @@ 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;
2438
- errorCodeMap = ob11ErrorCodeMap;
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;
2561
+ errorCodeMap = ob11ErrorCodeMap;
2439
2562
  deps;
2440
2563
  constructor(deps) {
2441
2564
  super();
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,152 +3161,309 @@ function basename$1(path) {
3366
3161
  const last = parts[parts.length - 1] ?? "";
3367
3162
  return last === "" ? "文件" : last;
3368
3163
  }
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
+ };
3255
+ /**
3256
+ * 系统信息域动作工厂(login_info / version_info / status / robot_uin_range /
3257
+ * translate_en2zh)。
3258
+ */
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
+ ];
3267
+ }
3268
+ // src/onebot11/action/system/status.ts
3269
+ /**
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
+ * 进程控制),未配置时明确报错;重启缺省退化为退出
3282
+ */
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
+ ];
3428
+ }
3369
3429
  // src/onebot11/action/index.ts
3370
3430
  /**
3371
3431
  * OneBot 11 动作注册表(ADR-013 延伸)
3372
3432
  * 各协议维护自己的 ActionRegistry,由协议 adapter 挂到请求分发。
3373
3433
  * P2-16:deps 收敛为 { api: OneBotApi } 单聚合对象(基础设施第一项)。
3374
3434
  *
3375
- * 同时是 action 域 barrel:re-export 全部动作类 + error-map + resolve-uid,
3376
- * 协议外部只从本入口消费动作面。
3435
+ * 同时是 action 域 barrel:re-export error-map / resolve-uid / AtAllRemainInfo,
3436
+ * 协议外部只从本入口消费动作面。动作类按领域分文件(message/ group/ friend/
3437
+ * system/),各领域文件导出 create*Actions 工厂,此处遍历注册——新增动作在
3438
+ * 领域文件的工厂里登记即可。
3377
3439
  */
3378
- /** 构建 OB11 动作注册表(所有 OB11 动作在此注册,按组拆分控制行数)。 */
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 个动作,领域工厂遍历注册)。 */
3379
3462
  function createOb11ActionRegistry(deps) {
3380
3463
  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);
3464
+ for (const factory of ACTION_FACTORIES) for (const action of factory(deps.api)) registry.register(action);
3393
3465
  return registry;
3394
3466
  }
3395
- /**
3396
- * 文件投递动作(upload_group_file / upload_private_file):**闪传通道**。
3397
- * 语义降级说明见 ./upload-file.ts 文件头(分享卡片,非群文件条目)。
3398
- */
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));
3502
- }
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));
3514
- }
3515
3467
  // src/onebot11/api/one-bot-api.ts
3516
3468
  /**
3517
3469
  * OneBot 11 动作统一依赖聚合(P2-16)。