@napuketto/adapter 0.15.4 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +1 -1
  2. package/dist/core/index.d.mts +8 -3
  3. package/dist/core/index.mjs +1 -1
  4. package/dist/core-Byoso-c3.mjs +108 -0
  5. package/dist/core-Byoso-c3.mjs.map +1 -0
  6. package/dist/{core-DOyFBFOW.mjs → essence-CYb60NC6.mjs} +164 -260
  7. package/dist/essence-CYb60NC6.mjs.map +1 -0
  8. package/dist/{gray-tip-C0pnbB__.mjs → gray-tip-C7lAbfOf.mjs} +10 -10
  9. package/dist/gray-tip-C7lAbfOf.mjs.map +1 -0
  10. package/dist/index-RMEWjNfV.d.mts +91 -0
  11. package/dist/index-RMEWjNfV.d.mts.map +1 -0
  12. package/dist/kurobot/index.d.mts +6 -6
  13. package/dist/kurobot/index.d.mts.map +1 -1
  14. package/dist/kurobot/index.mjs +10 -10
  15. package/dist/kurobot/index.mjs.map +1 -1
  16. package/dist/media-DMMn74TC.mjs +126 -0
  17. package/dist/media-DMMn74TC.mjs.map +1 -0
  18. package/dist/milky/index.d.mts +19 -22
  19. package/dist/milky/index.d.mts.map +1 -1
  20. package/dist/milky/index.mjs +1240 -1357
  21. package/dist/milky/index.mjs.map +1 -1
  22. package/dist/onebot11/index.d.mts +45 -21
  23. package/dist/onebot11/index.d.mts.map +1 -1
  24. package/dist/onebot11/index.mjs +1221 -1865
  25. package/dist/onebot11/index.mjs.map +1 -1
  26. package/dist/{raw-message-D2vA27kj.mjs → raw-message-DE3sdJg8.mjs} +18 -4
  27. package/dist/raw-message-DE3sdJg8.mjs.map +1 -0
  28. package/dist/satori/index.d.mts +24 -37
  29. package/dist/satori/index.d.mts.map +1 -1
  30. package/dist/satori/index.mjs +396 -564
  31. package/dist/satori/index.mjs.map +1 -1
  32. package/package.json +1 -1
  33. package/dist/core-DOyFBFOW.mjs.map +0 -1
  34. package/dist/gray-tip-C0pnbB__.mjs.map +0 -1
  35. package/dist/index-BbHwULNm.d.mts +0 -269
  36. package/dist/index-BbHwULNm.d.mts.map +0 -1
  37. package/dist/log-DYEB3Eto.mjs +0 -176
  38. package/dist/log-DYEB3Eto.mjs.map +0 -1
  39. package/dist/lookup-Dw0W04Ng.mjs +0 -22
  40. package/dist/lookup-Dw0W04Ng.mjs.map +0 -1
  41. package/dist/raw-message-D2vA27kj.mjs.map +0 -1
  42. package/dist/transport-schema-BEzr06W3.mjs +0 -29
  43. package/dist/transport-schema-BEzr06W3.mjs.map +0 -1
@@ -1,18 +1,30 @@
1
- import { S as ActionRegistry, _ as ensureSilk, b as BaseProtocolAdapter, c as narrowSysMsgBlobs, d as recognizeSysMsg, t as toUnixSeconds, u as processSysMsgBlob, v as prepareVideoElements, x as BaseAction } from "../core-DOyFBFOW.mjs";
2
- import { n as senderNickname, r as subscribeRawMessages } from "../raw-message-D2vA27kj.mjs";
3
- import { a as MS_TO_SEC$2, c as toUin, i as hasGrayTip, o as numericUin, r as firstUntranslatedGrayTip, t as collectGrayTipUids } from "../gray-tip-C0pnbB__.mjs";
4
- import { a as narrowEssenceGroupArg, i as extractEssenceSetSysMsg, n as truncRaw, o as narrowBuddyReqs, r as EssenceListSync, t as sliceRaw } from "../log-DYEB3Eto.mjs";
5
- import { n as createWsServerSchema, t as createHttpServerSchema } from "../transport-schema-BEzr06W3.mjs";
1
+ import { i as runAction, n as BaseProtocolAdapter, r as ActionRegistry } from "../core-Byoso-c3.mjs";
2
+ import { i as toUnixSeconds, n as senderNickname, r as subscribeRawMessages } from "../raw-message-DE3sdJg8.mjs";
3
+ import { n as prepareVideoElements, r as createServerSchema, t as ensureSilk } from "../media-DMMn74TC.mjs";
4
+ import { a as MS_TO_SEC$2, c as toUin, i as hasGrayTip, o as numericUin, r as firstUntranslatedGrayTip, t as collectGrayTipUids } from "../gray-tip-C7lAbfOf.mjs";
5
+ import { d as logEventFailure, f as sliceRaw, i as narrowSysMsgBlobs, m as narrowBuddyReqs, n as extractEssenceSetSysMsg, o as processSysMsgBlob, p as truncRaw, r as narrowEssenceGroupArg, s as recognizeSysMsg, t as EssenceListSync } from "../essence-CYb60NC6.mjs";
6
6
  import { ChatType, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupMemberRole, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, WebHonorType, kernelError, toCanonicalElements } from "@napuketto/kernel";
7
- import { basename, join } from "node:path";
8
- import { downloadUrl, inferExtension } from "@napuketto/media";
9
7
  import { z } from "zod";
10
8
  import { randomUUID } from "node:crypto";
11
9
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
10
+ import { basename, join } from "node:path";
11
+ import { downloadUrl, inferExtension } from "@napuketto/media";
12
12
  import { fileURLToPath } from "node:url";
13
13
  import { HttpClient, HttpServer, WsClient, WsServer } from "@napuketto/network";
14
- // src/onebot11/action/error-map.ts
15
- /** OB11 错误码映射表(send_msg 等所有 OB11 动作共用)。 */
14
+ // src/onebot11/action/base-action.ts
15
+ /**
16
+ * OB11 动作运行时:声明式动作工厂 + 响应信封 + 错误码映射 + 共享解析助手。
17
+ *
18
+ * 动作 = `{ name, schema, handle }` 声明对象,经 defineOb11Action 组装出
19
+ * HTTP `handle`(校验失败 retcode=400)与 WS `websocketHandle`(1400 +
20
+ * echo 透传)两个入口;执行骨架走 core runAction(zod safeParse → 执行 →
21
+ * isKernelError 统一映射,映射表收拢为本文件 ob11ErrorCodeMap)。
22
+ */
23
+ /** 校验失败 retcode:HTTP 入口。 */
24
+ const INVALID_RETCODE_HTTP = 400;
25
+ /** 校验失败 retcode:WS 入口。 */
26
+ const INVALID_RETCODE_WS = 1400;
27
+ /** OB11 错误码映射表(kernel KernelErrorCode → retcode;全部 OB11 动作共用)。 */
16
28
  const ob11ErrorCodeMap = {
17
29
  SEND_FAILED: 100,
18
30
  PERMISSION_DENIED: 101,
@@ -23,11 +35,37 @@ const ob11ErrorCodeMap = {
23
35
  INVALID_STATE: 106,
24
36
  UNKNOWN: 999
25
37
  };
26
- // src/onebot11/action/resolve-uid.ts
27
- /**
28
- * OB11 用户 ID 解析(uin → uid,多个动作共用,2026-08-08 克隆合并)
29
- */
30
- /** 解析单个 uin → uid(失败抛 KernelError INVALID_PARAM)。 */
38
+ /** 声明式动作工厂:闭包依赖 + 统一信封与错误映射。 */
39
+ function defineOb11Action(spec) {
40
+ const run = async (payload, invalidRetcode, echo) => {
41
+ const outcome = await runAction({
42
+ schema: spec.schema,
43
+ handle: spec.handle,
44
+ errorCodeMap: ob11ErrorCodeMap,
45
+ invalidRetcode
46
+ }, payload);
47
+ const result = outcome.ok ? {
48
+ retcode: 0,
49
+ status: "ok",
50
+ data: outcome.data,
51
+ message: ""
52
+ } : {
53
+ retcode: outcome.retcode,
54
+ status: "failed",
55
+ data: null,
56
+ message: outcome.message
57
+ };
58
+ if (echo !== void 0) result.echo = echo;
59
+ return result;
60
+ };
61
+ return {
62
+ name: spec.name,
63
+ schema: spec.schema,
64
+ handle: (payload) => run(payload, INVALID_RETCODE_HTTP),
65
+ websocketHandle: (payload, echo) => run(payload, INVALID_RETCODE_WS, echo)
66
+ };
67
+ }
68
+ /** 解析单个 uin → uid(失败抛 KernelError INVALID_PARAM;多动作共用)。 */
31
69
  async function resolveUid(uin, uinToUid) {
32
70
  const uid = (await uinToUid([uin])).get(uin);
33
71
  if (uid === void 0) throw kernelError(`用户 ${uin} 的 uid 解析失败`, "INVALID_PARAM");
@@ -35,211 +73,126 @@ async function resolveUid(uin, uinToUid) {
35
73
  }
36
74
  // src/onebot11/action/friend/manage.ts
37
75
  /**
38
- * 好友管理域动作(2026-11-14 自 friend/ 微文件合并)
76
+ * 好友管理域动作
39
77
  *
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
78
+ * - set_friend_add_request:flag=reqTime(NapCat 约定,需从好友请求事件上报中
79
+ * 获取)→ getBuddyReqList 匹配 → handleFriendRequest + optional remark
80
+ * - set_friend_remark / delete_friend:user_id 经 uin→uid
81
+ * - set_doubt_friends_add_request(可疑好友申请处理,NapCat 扩展;approve 字段
82
+ * NapCat 强制为 true,该接口无语义仅保留)
83
+ * - send_like:ProfileLikeApi.sendLike
46
84
  */
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
- };
109
- const deleteFriendSchema = z.object({ user_id: z.number() });
110
- /** 删除好友(P2-11 接 kernel deleteFriend)。 */
111
- var DeleteFriendAction = class extends BaseAction {
112
- name = "delete_friend";
113
- schema = deleteFriendSchema;
114
- errorCodeMap = ob11ErrorCodeMap;
115
- deps;
116
- constructor(deps) {
117
- super();
118
- this.deps = deps;
119
- }
120
- async _handle(payload) {
121
- const uid = await resolveUid(String(payload.user_id), this.deps.uinToUid);
122
- await this.deps.friendApi.deleteFriend(uid);
123
- return null;
124
- }
125
- };
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;
134
- errorCodeMap = ob11ErrorCodeMap;
135
- deps;
136
- constructor(deps) {
137
- super();
138
- this.deps = deps;
139
- }
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;
144
- }
145
- };
146
85
  /** 好友管理域动作工厂(friend_add_request / friend_remark / delete_friend /
147
86
  * doubt 申请处理 / send_like)。 */
148
87
  function createFriendManageActions(api) {
149
88
  return [
150
- new SetFriendAddRequestAction(api.friendApi),
151
- new SetFriendRemarkAction(api),
152
- new DeleteFriendAction(api),
153
- new SetDoubtFriendsAddRequestAction(api.friendApi),
154
- new SendLikeAction(api)
89
+ defineOb11Action({
90
+ name: "set_friend_add_request",
91
+ schema: z.object({
92
+ flag: z.string(),
93
+ approve: z.boolean().optional(),
94
+ remark: z.string().optional()
95
+ }),
96
+ handle: async (payload) => {
97
+ const notify = (await api.friendApi.getBuddyReqList()).find((req) => req.reqTime === payload.flag);
98
+ if (notify === void 0) throw kernelError("未找到对应的好友请求(flag 无效或已过期)", "NOT_FOUND");
99
+ await api.friendApi.handleFriendRequest(notify, payload.approve !== false);
100
+ if (payload.remark !== void 0) api.friendApi.setFriendRemark(notify.friendUid, payload.remark);
101
+ return null;
102
+ }
103
+ }),
104
+ defineOb11Action({
105
+ name: "set_friend_remark",
106
+ schema: z.object({
107
+ user_id: z.number(),
108
+ remark: z.string()
109
+ }),
110
+ handle: async (payload) => {
111
+ const uid = await resolveUid(String(payload.user_id), api.uinToUid);
112
+ api.friendApi.setFriendRemark(uid, payload.remark);
113
+ return null;
114
+ }
115
+ }),
116
+ defineOb11Action({
117
+ name: "delete_friend",
118
+ schema: z.object({ user_id: z.number() }),
119
+ handle: async (payload) => {
120
+ const uid = await resolveUid(String(payload.user_id), api.uinToUid);
121
+ await api.friendApi.deleteFriend(uid);
122
+ return null;
123
+ }
124
+ }),
125
+ defineOb11Action({
126
+ name: "set_doubt_friends_add_request",
127
+ schema: z.object({
128
+ flag: z.string(),
129
+ approve: z.boolean().optional()
130
+ }),
131
+ handle: async (payload) => {
132
+ api.friendApi.handleDoubtFriendRequest(payload.flag);
133
+ return null;
134
+ }
135
+ }),
136
+ defineOb11Action({
137
+ name: "send_like",
138
+ schema: z.object({
139
+ user_id: z.number(),
140
+ times: z.number().optional()
141
+ }),
142
+ handle: async (payload) => {
143
+ const uid = await resolveUid(String(payload.user_id), api.uinToUid);
144
+ await api.profileLikeApi.sendLike(uid, payload.times ?? 1);
145
+ return null;
146
+ }
147
+ })
155
148
  ];
156
149
  }
157
150
  // src/onebot11/action/friend/query.ts
158
- const getFriendListSchema = z.object({
159
- /** 是否忽略缓存(go-cqhttp 扩展)。 */
160
- no_cache: z.boolean().optional() });
161
- /** 获取好友列表(P2-4 接 kernel apis/friend)。 */
162
- var GetFriendListAction = class extends BaseAction {
163
- name = "get_friend_list";
164
- schema = getFriendListSchema;
165
- errorCodeMap = ob11ErrorCodeMap;
166
- friendApi;
167
- constructor(friendApi) {
168
- super();
169
- this.friendApi = friendApi;
170
- }
171
- async _handle(_payload) {
172
- return (await this.friendApi.getFriendList()).map((f) => {
173
- const info = {
174
- user_id: Number(f.uin),
175
- nickname: f.nickname
176
- };
177
- if (f.remark !== "") info.remark = f.remark;
178
- return info;
179
- });
180
- }
181
- };
182
- const getFriendsWithCategorySchema = z.object({});
183
- /** 获取好友列表(含分类,P2-11 接 kernel getFriendCategories)。 */
184
- var GetFriendsWithCategoryAction = class extends BaseAction {
185
- name = "get_friends_with_category";
186
- schema = getFriendsWithCategorySchema;
187
- errorCodeMap = ob11ErrorCodeMap;
188
- friendApi;
189
- constructor(friendApi) {
190
- super();
191
- this.friendApi = friendApi;
192
- }
193
- _handle(_payload) {
194
- return this.friendApi.getFriendCategories();
195
- }
196
- };
197
- const getStrangerInfoSchema = z.object({
198
- user_id: z.number(),
199
- no_cache: z.boolean().optional()
200
- });
201
- /** 获取陌生人信息(P2-15 接 kernel ProfileApi)。 */
202
- var GetStrangerInfoAction = class extends BaseAction {
203
- name = "get_stranger_info";
204
- schema = getStrangerInfoSchema;
205
- errorCodeMap = ob11ErrorCodeMap;
206
- profileApi;
207
- constructor(profileApi) {
208
- super();
209
- this.profileApi = profileApi;
210
- }
211
- async _handle(payload) {
212
- return {
213
- ...await this.profileApi.getStrangerInfo(String(payload.user_id)),
214
- user_id: payload.user_id
215
- };
216
- }
217
- };
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;
225
- errorCodeMap = ob11ErrorCodeMap;
226
- friendApi;
227
- constructor(friendApi) {
228
- super();
229
- this.friendApi = friendApi;
230
- }
231
- _handle(payload) {
232
- return this.friendApi.getDoubtFriendRequest(payload.count ?? DEFAULT_COUNT$2);
233
- }
234
- };
151
+ /** 可疑好友申请默认获取数量。 */
152
+ const DEFAULT_DOUBT_COUNT = 50;
235
153
  /** 好友查询域动作工厂(friend_list / friends_with_category / stranger_info /
236
154
  * doubt_friends_add_request)。 */
237
155
  function createFriendQueryActions(api) {
238
156
  return [
239
- new GetFriendListAction(api.friendApi),
240
- new GetFriendsWithCategoryAction(api.friendApi),
241
- new GetStrangerInfoAction(api.profileApi),
242
- new GetDoubtFriendsAddRequestAction(api.friendApi)
157
+ defineOb11Action({
158
+ name: "get_friend_list",
159
+ schema: z.object({
160
+ /** 是否忽略缓存(go-cqhttp 扩展)。 */
161
+ no_cache: z.boolean().optional() }),
162
+ handle: async () => {
163
+ return (await api.friendApi.getFriendList()).map((f) => {
164
+ const info = {
165
+ user_id: Number(f.uin),
166
+ nickname: f.nickname
167
+ };
168
+ if (f.remark !== "") info.remark = f.remark;
169
+ return info;
170
+ });
171
+ }
172
+ }),
173
+ defineOb11Action({
174
+ name: "get_friends_with_category",
175
+ schema: z.object({}),
176
+ handle: () => api.friendApi.getFriendCategories()
177
+ }),
178
+ defineOb11Action({
179
+ name: "get_stranger_info",
180
+ schema: z.object({
181
+ user_id: z.number(),
182
+ no_cache: z.boolean().optional()
183
+ }),
184
+ handle: async (payload) => {
185
+ return {
186
+ ...await api.profileApi.getStrangerInfo(String(payload.user_id)),
187
+ user_id: payload.user_id
188
+ };
189
+ }
190
+ }),
191
+ defineOb11Action({
192
+ name: "get_doubt_friends_add_request",
193
+ schema: z.object({ count: z.number().optional() }),
194
+ handle: (payload) => api.friendApi.getDoubtFriendRequest(payload.count ?? DEFAULT_DOUBT_COUNT)
195
+ })
243
196
  ];
244
197
  }
245
198
  // src/onebot11/helper/message-unique.ts
@@ -331,87 +284,25 @@ function resolveMsgIdAndPeer(messageId, unique) {
331
284
  }
332
285
  // src/onebot11/action/group/essence.ts
333
286
  /**
334
- * 群精华/荣誉域动作(2026-11-14 自 set-essence-msg / delete-essence-msg /
335
- * get-essence-msg-list / get-group-honor-info 合并)
287
+ * 群精华/荣誉域动作
336
288
  *
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,
289
+ * - set/delete_essence_msg:message_id → msgId + peer(MessageUnique 反查,
290
+ * 需群消息)→ GroupApi.addGroupEssence / removeGroupEssence(共用实现)
291
+ * - get_essence_msg_list:qun.qq.com digest_list web 接口 → msg_list,
340
292
  * msg_content 映射 text/image 段
341
- * - get_group_honor_info(P2-15):qun.qq.com honorlist web 接口;type 缺省 all
293
+ * - get_group_honor_info:qun.qq.com honorlist web 接口;type 缺省 all
342
294
  */
343
- const setEssenceMsgSchema = z.object({ message_id: z.union([z.number(), z.string()]) });
344
- /** 精华消息基类(set/delete 共用实现,2026-08-08 克隆合并)。 */
345
- var EssenceMsgBase = class extends BaseAction {
346
- errorCodeMap = ob11ErrorCodeMap;
347
- deps;
348
- constructor(deps) {
349
- super();
350
- this.deps = deps;
351
- }
352
- async _handle(payload) {
353
- const { msgId, peer } = resolveMsgIdAndPeer(payload.message_id, this.deps.messageUnique);
354
- if (peer.chatType !== ChatType.GROUP) throw kernelError("精华消息仅支持群聊消息", "INVALID_PARAM");
355
- await this.operate(peer.peerUid, msgId);
356
- return null;
357
- }
358
- };
359
- /** 设置精华消息(P2-10 接 kernel addGroupEssence)。 */
360
- var SetEssenceMsgAction = class extends EssenceMsgBase {
361
- name = "set_essence_msg";
362
- schema = setEssenceMsgSchema;
363
- async operate(groupCode, msgId) {
364
- await this.deps.groupApi.addGroupEssence(groupCode, msgId);
365
- }
366
- };
367
- const deleteEssenceMsgSchema = z.object({ message_id: z.union([z.number(), z.string()]) });
368
- /** 取消精华消息(P2-10 接 kernel removeGroupEssence)。 */
369
- var DeleteEssenceMsgAction = class extends EssenceMsgBase {
370
- name = "delete_essence_msg";
371
- schema = deleteEssenceMsgSchema;
372
- async operate(groupCode, msgId) {
373
- await this.deps.groupApi.removeGroupEssence(groupCode, msgId);
374
- }
375
- };
376
- const getEssenceMsgListSchema = z.object({ group_id: z.number() });
377
295
  /** 文本段类型(msg_content.msg_type)。 */
378
296
  const MSG_TYPE_TEXT = 1;
379
297
  /** 图片段类型(msg_content.msg_type)。 */
380
298
  const MSG_TYPE_IMAGE = 3;
381
- /** 获取群精华消息列表(P2-15 接 kernel WebApi)。 */
382
- var GetEssenceMsgListAction = class extends BaseAction {
383
- name = "get_essence_msg_list";
384
- schema = getEssenceMsgListSchema;
385
- errorCodeMap = ob11ErrorCodeMap;
386
- webApi;
387
- constructor(webApi) {
388
- super();
389
- this.webApi = webApi;
390
- }
391
- async _handle(payload) {
392
- const list = await this.webApi.getEssenceMsgList(String(payload.group_id));
393
- const out = [];
394
- for (const item of list) {
395
- const content = [];
396
- for (const part of item.msg_content ?? []) {
397
- const seg = toSegment(part);
398
- if (seg !== null) content.push(seg);
399
- }
400
- out.push({
401
- msg_seq: item.msg_seq,
402
- msg_random: item.msg_random,
403
- sender_id: Number(item.sender_uin),
404
- sender_nick: item.sender_nick,
405
- operator_id: Number(item.add_digest_uin),
406
- operator_nick: item.add_digest_nick,
407
- operator_time: item.add_digest_time,
408
- message_id: 0,
409
- content
410
- });
411
- }
412
- return out;
413
- }
414
- };
299
+ /** set/delete 精华共用实现:message_id 反查 + 群聊校验 + 具体精华操作。 */
300
+ async function operateEssence(api, messageId, operate) {
301
+ const { msgId, peer } = resolveMsgIdAndPeer(messageId, api.messageUnique);
302
+ if (peer.chatType !== ChatType.GROUP) throw kernelError("精华消息仅支持群聊消息", "INVALID_PARAM");
303
+ await operate(peer.peerUid, msgId);
304
+ return null;
305
+ }
415
306
  /** msg_content 项 → OB11 段(1=text 3=image,纯函数)。 */
416
307
  function toSegment(part) {
417
308
  if (part.msg_type === MSG_TYPE_TEXT) return {
@@ -424,25 +315,6 @@ function toSegment(part) {
424
315
  };
425
316
  return null;
426
317
  }
427
- const getGroupHonorInfoSchema = z.object({
428
- group_id: z.number(),
429
- type: z.string().optional()
430
- });
431
- /** 获取群荣誉信息(P2-15 接 kernel WebApi)。 */
432
- var GetGroupHonorInfoAction = class extends BaseAction {
433
- name = "get_group_honor_info";
434
- schema = getGroupHonorInfoSchema;
435
- errorCodeMap = ob11ErrorCodeMap;
436
- webApi;
437
- constructor(webApi) {
438
- super();
439
- this.webApi = webApi;
440
- }
441
- _handle(payload) {
442
- const type = mapHonorType(payload.type);
443
- return this.webApi.getGroupHonorInfo(String(payload.group_id), type);
444
- }
445
- };
446
318
  /** type 字符串 → WebHonorType(talkative/performer/legend/emotion/all,纯函数)。 */
447
319
  function mapHonorType(raw) {
448
320
  if (raw === "talkative") return WebHonorType.TALKATIVE;
@@ -454,62 +326,73 @@ function mapHonorType(raw) {
454
326
  /** 群精华/荣誉域动作工厂(set/delete_essence_msg / essence_msg_list / honor_info)。 */
455
327
  function createGroupEssenceActions(api) {
456
328
  return [
457
- new SetEssenceMsgAction(api),
458
- new DeleteEssenceMsgAction(api),
459
- new GetEssenceMsgListAction(api.webApi),
460
- new GetGroupHonorInfoAction(api.webApi)
329
+ defineOb11Action({
330
+ name: "set_essence_msg",
331
+ schema: z.object({ message_id: z.union([z.number(), z.string()]) }),
332
+ handle: (payload) => operateEssence(api, payload.message_id, (groupCode, msgId) => api.groupApi.addGroupEssence(groupCode, msgId))
333
+ }),
334
+ defineOb11Action({
335
+ name: "delete_essence_msg",
336
+ schema: z.object({ message_id: z.union([z.number(), z.string()]) }),
337
+ handle: (payload) => operateEssence(api, payload.message_id, (groupCode, msgId) => api.groupApi.removeGroupEssence(groupCode, msgId))
338
+ }),
339
+ defineOb11Action({
340
+ name: "get_essence_msg_list",
341
+ schema: z.object({ group_id: z.number() }),
342
+ handle: async (payload) => {
343
+ const list = await api.webApi.getEssenceMsgList(String(payload.group_id));
344
+ const out = [];
345
+ for (const item of list) {
346
+ const content = [];
347
+ for (const part of item.msg_content ?? []) {
348
+ const seg = toSegment(part);
349
+ if (seg !== null) content.push(seg);
350
+ }
351
+ out.push({
352
+ msg_seq: item.msg_seq,
353
+ msg_random: item.msg_random,
354
+ sender_id: Number(item.sender_uin),
355
+ sender_nick: item.sender_nick,
356
+ operator_id: Number(item.add_digest_uin),
357
+ operator_nick: item.add_digest_nick,
358
+ operator_time: item.add_digest_time,
359
+ message_id: 0,
360
+ content
361
+ });
362
+ }
363
+ return out;
364
+ }
365
+ }),
366
+ defineOb11Action({
367
+ name: "get_group_honor_info",
368
+ schema: z.object({
369
+ group_id: z.number(),
370
+ type: z.string().optional()
371
+ }),
372
+ handle: (payload) => api.webApi.getGroupHonorInfo(String(payload.group_id), mapHonorType(payload.type))
373
+ })
461
374
  ];
462
375
  }
463
376
  // src/onebot11/action/group/get-group-system-msg.ts
464
- const getGroupSystemMsgSchema = z.object({ count: z.number().optional() });
465
377
  /** 默认获取数量。 */
466
378
  const DEFAULT_COUNT$1 = 50;
467
- /** 获取群系统消息(P2-13 接 kernel GroupNotifyApi)。 */
468
- var GetGroupSystemMsgAction = class extends BaseAction {
469
- name = "get_group_system_msg";
470
- schema = getGroupSystemMsgSchema;
471
- errorCodeMap = ob11ErrorCodeMap;
472
- deps;
473
- constructor(deps) {
474
- super();
475
- this.deps = deps;
476
- }
477
- async _handle(payload) {
478
- const count = payload.count ?? DEFAULT_COUNT$1;
479
- const notifies = await this.deps.groupNotifyApi.getSingleScreenNotifies(false, count);
480
- const uinMap = await this.collectUinMap(notifies);
481
- const invited = [];
482
- const joined = [];
483
- for (const notify of notifies) {
484
- const info = toMessageInfo(notify, uinMap);
485
- if (notify.type === GroupNotifyMsgType.INVITED_BY_MEMBER) invited.push(info);
486
- else if (notify.type === GroupNotifyMsgType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS) joined.push(info);
379
+ /** 收集全部涉及的 uid 批量转 uin(循环外一次请求)。 */
380
+ async function collectUinMap(api, notifies) {
381
+ const uids = [];
382
+ for (const notify of notifies) {
383
+ const { user1, user2 } = notify;
384
+ if (user1 !== void 0) {
385
+ const { uid } = user1;
386
+ if (uid !== "") uids.push(uid);
487
387
  }
488
- const result = {
489
- invited_requests: invited,
490
- join_requests: joined
491
- };
492
- result["InvitedRequest"] = invited;
493
- return result;
494
- }
495
- /** 收集全部涉及的 uid 批量转 uin(循环外一次请求)。 */
496
- async collectUinMap(notifies) {
497
- const uids = [];
498
- for (const notify of notifies) {
499
- const { user1, user2 } = notify;
500
- if (user1 !== void 0) {
501
- const { uid } = user1;
502
- if (uid !== "") uids.push(uid);
503
- }
504
- if (user2 !== void 0) {
505
- const { uid } = user2;
506
- if (uid !== "") uids.push(uid);
507
- }
388
+ if (user2 !== void 0) {
389
+ const { uid } = user2;
390
+ if (uid !== "") uids.push(uid);
508
391
  }
509
- if (uids.length === 0) return /* @__PURE__ */ new Map();
510
- return await this.deps.uidToUin(uids);
511
392
  }
512
- };
393
+ if (uids.length === 0) return /* @__PURE__ */ new Map();
394
+ return await api.uidToUin(uids);
395
+ }
513
396
  /** GroupNotify → OB11 群系统消息结构(纯函数,uin 已批量转换)。 */
514
397
  function toMessageInfo(notify, uinMap) {
515
398
  const { seq, status, postscript, user1, user2, group } = notify;
@@ -555,205 +438,118 @@ function toMessageInfo(notify, uinMap) {
555
438
  }
556
439
  /** 群系统消息动作工厂(get_group_system_msg)。 */
557
440
  function createGroupSystemMsgActions(api) {
558
- return [new GetGroupSystemMsgAction(api)];
441
+ return [defineOb11Action({
442
+ name: "get_group_system_msg",
443
+ schema: z.object({ count: z.number().optional() }),
444
+ handle: async (payload) => {
445
+ const count = payload.count ?? DEFAULT_COUNT$1;
446
+ const notifies = await api.groupNotifyApi.getSingleScreenNotifies(false, count);
447
+ const uinMap = await collectUinMap(api, notifies);
448
+ const invited = [];
449
+ const joined = [];
450
+ for (const notify of notifies) {
451
+ const info = toMessageInfo(notify, uinMap);
452
+ if (notify.type === GroupNotifyMsgType.INVITED_BY_MEMBER) invited.push(info);
453
+ else if (notify.type === GroupNotifyMsgType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS) joined.push(info);
454
+ }
455
+ const result = {
456
+ invited_requests: invited,
457
+ join_requests: joined
458
+ };
459
+ result["InvitedRequest"] = invited;
460
+ return result;
461
+ }
462
+ })];
559
463
  }
560
464
  // src/onebot11/action/limits.ts
561
465
  /** 批量翻译的词条上限(translate_en2zh)。 */
562
466
  const MAX_TRANSLATE_WORDS = 2e3;
563
467
  // src/onebot11/action/group/group-files-op.ts
564
- const createGroupFileFolderSchema = z.object({
565
- group_id: z.number(),
566
- folder_name: z.string()
567
- });
568
- /** 创建群文件夹(P2-14)。 */
569
- var CreateGroupFileFolderAction = class extends BaseAction {
570
- name = "create_group_file_folder";
571
- schema = createGroupFileFolderSchema;
572
- errorCodeMap = ob11ErrorCodeMap;
573
- richMediaApi;
574
- constructor(richMediaApi) {
575
- super();
576
- this.richMediaApi = richMediaApi;
577
- }
578
- async _handle(payload) {
579
- return { folder_id: await this.richMediaApi.createGroupFolder(String(payload.group_id), payload.folder_name) };
580
- }
581
- };
582
- const deleteGroupFileSchema = z.object({
583
- group_id: z.number(),
584
- file_id: z.string(),
585
- /** 兼容 go-cqhttp 的 file_ids 数组(取第一个)。 */
586
- file_ids: z.array(z.string()).max(100).optional()
587
- });
588
- /** 删除群文件(P2-14)。 */
589
- var DeleteGroupFileAction = class extends BaseAction {
590
- name = "delete_group_file";
591
- schema = deleteGroupFileSchema;
592
- errorCodeMap = ob11ErrorCodeMap;
593
- richMediaApi;
594
- constructor(richMediaApi) {
595
- super();
596
- this.richMediaApi = richMediaApi;
597
- }
598
- async _handle(payload) {
599
- const ids = payload.file_ids ?? [payload.file_id];
600
- await this.richMediaApi.deleteGroupFile(String(payload.group_id), ids);
601
- return null;
602
- }
603
- };
604
- const deleteGroupFolderSchema = z.object({
605
- group_id: z.number(),
606
- folder_id: z.string()
607
- });
608
- /** 删除群文件夹(P2-14)。 */
609
- var DeleteGroupFolderAction = class extends BaseAction {
610
- name = "delete_group_folder";
611
- schema = deleteGroupFolderSchema;
612
- errorCodeMap = ob11ErrorCodeMap;
613
- richMediaApi;
614
- constructor(richMediaApi) {
615
- super();
616
- this.richMediaApi = richMediaApi;
617
- }
618
- async _handle(payload) {
619
- await this.richMediaApi.deleteGroupFolder(String(payload.group_id), payload.folder_id);
620
- return null;
621
- }
622
- };
623
- const renameGroupFileSchema = z.object({
624
- group_id: z.number(),
625
- file_id: z.string(),
626
- new_name: z.string()
627
- });
628
- /** 重命名群文件(P2-14)。 */
629
- var RenameGroupFileAction = class extends BaseAction {
630
- name = "rename_group_file";
631
- schema = renameGroupFileSchema;
632
- errorCodeMap = ob11ErrorCodeMap;
633
- richMediaApi;
634
- constructor(richMediaApi) {
635
- super();
636
- this.richMediaApi = richMediaApi;
637
- }
638
- async _handle(payload) {
639
- await this.richMediaApi.renameGroupFile(String(payload.group_id), payload.file_id, payload.new_name);
640
- return null;
641
- }
642
- };
643
- const moveGroupFileSchema = z.object({
644
- group_id: z.number(),
645
- file_id: z.string(),
646
- file_ids: z.array(z.string()).max(100).optional(),
647
- /** 目标文件夹 ID(空为根目录)。 */
648
- folder_id: z.string().optional()
649
- });
650
- /** 移动群文件(P2-14)。 */
651
- var MoveGroupFileAction = class extends BaseAction {
652
- name = "move_group_file";
653
- schema = moveGroupFileSchema;
654
- errorCodeMap = ob11ErrorCodeMap;
655
- richMediaApi;
656
- constructor(richMediaApi) {
657
- super();
658
- this.richMediaApi = richMediaApi;
659
- }
660
- async _handle(payload) {
661
- const ids = payload.file_ids ?? [payload.file_id];
662
- await this.richMediaApi.moveGroupFile(String(payload.group_id), ids, payload.folder_id ?? "");
663
- return null;
664
- }
665
- };
666
- const transGroupFileSchema = z.object({
667
- group_id: z.number(),
668
- file_id: z.string()
669
- });
670
- /** 转存群文件(P2-14)。 */
671
- var TransGroupFileAction = class extends BaseAction {
672
- name = "trans_group_file";
673
- schema = transGroupFileSchema;
674
- errorCodeMap = ob11ErrorCodeMap;
675
- richMediaApi;
676
- constructor(richMediaApi) {
677
- super();
678
- this.richMediaApi = richMediaApi;
679
- }
680
- async _handle(payload) {
681
- await this.richMediaApi.transGroupFile(String(payload.group_id), payload.file_id);
682
- return null;
683
- }
684
- };
468
+ /**
469
+ * 群文件操作动作:create_group_file_folder / delete_group_file /
470
+ * delete_group_folder / rename_group_file / move_group_file / trans_group_file
471
+ */
685
472
  /** 群文件操作域动作工厂(create/delete folder、delete/rename/move/trans file)。 */
686
473
  function createGroupFileOpActions(api) {
687
474
  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)
475
+ defineOb11Action({
476
+ name: "create_group_file_folder",
477
+ schema: z.object({
478
+ group_id: z.number(),
479
+ folder_name: z.string()
480
+ }),
481
+ handle: async (payload) => {
482
+ return { folder_id: await api.richMediaApi.createGroupFolder(String(payload.group_id), payload.folder_name) };
483
+ }
484
+ }),
485
+ defineOb11Action({
486
+ name: "delete_group_file",
487
+ schema: z.object({
488
+ group_id: z.number(),
489
+ file_id: z.string(),
490
+ /** 兼容 go-cqhttp 的 file_ids 数组(取第一个)。 */
491
+ file_ids: z.array(z.string()).max(100).optional()
492
+ }),
493
+ handle: async (payload) => {
494
+ const ids = payload.file_ids ?? [payload.file_id];
495
+ await api.richMediaApi.deleteGroupFile(String(payload.group_id), ids);
496
+ return null;
497
+ }
498
+ }),
499
+ defineOb11Action({
500
+ name: "delete_group_folder",
501
+ schema: z.object({
502
+ group_id: z.number(),
503
+ folder_id: z.string()
504
+ }),
505
+ handle: async (payload) => {
506
+ await api.richMediaApi.deleteGroupFolder(String(payload.group_id), payload.folder_id);
507
+ return null;
508
+ }
509
+ }),
510
+ defineOb11Action({
511
+ name: "rename_group_file",
512
+ schema: z.object({
513
+ group_id: z.number(),
514
+ file_id: z.string(),
515
+ new_name: z.string()
516
+ }),
517
+ handle: async (payload) => {
518
+ await api.richMediaApi.renameGroupFile(String(payload.group_id), payload.file_id, payload.new_name);
519
+ return null;
520
+ }
521
+ }),
522
+ defineOb11Action({
523
+ name: "move_group_file",
524
+ schema: z.object({
525
+ group_id: z.number(),
526
+ file_id: z.string(),
527
+ file_ids: z.array(z.string()).max(100).optional(),
528
+ /** 目标文件夹 ID(空为根目录)。 */
529
+ folder_id: z.string().optional()
530
+ }),
531
+ handle: async (payload) => {
532
+ const ids = payload.file_ids ?? [payload.file_id];
533
+ await api.richMediaApi.moveGroupFile(String(payload.group_id), ids, payload.folder_id ?? "");
534
+ return null;
535
+ }
536
+ }),
537
+ defineOb11Action({
538
+ name: "trans_group_file",
539
+ schema: z.object({
540
+ group_id: z.number(),
541
+ file_id: z.string()
542
+ }),
543
+ handle: async (payload) => {
544
+ await api.richMediaApi.transGroupFile(String(payload.group_id), payload.file_id);
545
+ return null;
546
+ }
547
+ })
694
548
  ];
695
549
  }
696
550
  // src/onebot11/action/group/group-files-query.ts
697
- const getGroupRootFilesSchema = z.object({
698
- group_id: z.number(),
699
- file_count: z.number().optional()
700
- });
701
551
  /** 默认文件数量。 */
702
552
  const DEFAULT_FILE_COUNT = 50;
703
- /** 获取群根目录文件列表(P2-14 接 kernel RichMediaApi)。 */
704
- var GetGroupRootFilesAction = class extends BaseAction {
705
- name = "get_group_root_files";
706
- schema = getGroupRootFilesSchema;
707
- errorCodeMap = ob11ErrorCodeMap;
708
- richMediaApi;
709
- constructor(richMediaApi) {
710
- super();
711
- this.richMediaApi = richMediaApi;
712
- }
713
- async _handle(payload) {
714
- return splitFilesAndFolders(await this.richMediaApi.getGroupFileList(String(payload.group_id), "", payload.file_count ?? DEFAULT_FILE_COUNT));
715
- }
716
- };
717
- const getGroupFilesByFolderSchema = z.object({
718
- group_id: z.number(),
719
- folder_id: z.string(),
720
- file_count: z.number().optional()
721
- });
722
- /** 获取群指定文件夹文件列表(P2-14)。 */
723
- var GetGroupFilesByFolderAction = class extends BaseAction {
724
- name = "get_group_files_by_folder";
725
- schema = getGroupFilesByFolderSchema;
726
- errorCodeMap = ob11ErrorCodeMap;
727
- richMediaApi;
728
- constructor(richMediaApi) {
729
- super();
730
- this.richMediaApi = richMediaApi;
731
- }
732
- async _handle(payload) {
733
- return splitFilesAndFolders(await this.richMediaApi.getGroupFileList(String(payload.group_id), payload.folder_id, payload.file_count ?? DEFAULT_FILE_COUNT));
734
- }
735
- };
736
- const getGroupFileSystemInfoSchema = z.object({ group_id: z.number() });
737
- /** 群文件系统信息(P2-14)。 */
738
- var GetGroupFileSystemInfoAction = class extends BaseAction {
739
- name = "get_group_file_system_info";
740
- schema = getGroupFileSystemInfoSchema;
741
- errorCodeMap = ob11ErrorCodeMap;
742
- richMediaApi;
743
- constructor(richMediaApi) {
744
- super();
745
- this.richMediaApi = richMediaApi;
746
- }
747
- async _handle(payload) {
748
- const info = await this.richMediaApi.getGroupFileSystemInfo(String(payload.group_id));
749
- return {
750
- file_count: info.fileCount,
751
- limit_count: info.limitCount,
752
- used_space: info.usedSpace,
753
- total_space: info.totalSpace
754
- };
755
- }
756
- };
757
553
  /** 列表拆分 files/folders(fileInfo/folderInfo 取其一,纯函数)。 */
758
554
  function splitFilesAndFolders(list) {
759
555
  const files = [];
@@ -795,236 +591,172 @@ function toGroupFolderInfo(folder) {
795
591
  /** 群文件查询域动作工厂(root files / by folder / system info)。 */
796
592
  function createGroupFileQueryActions(api) {
797
593
  return [
798
- new GetGroupRootFilesAction(api.richMediaApi),
799
- new GetGroupFilesByFolderAction(api.richMediaApi),
800
- new GetGroupFileSystemInfoAction(api.richMediaApi)
594
+ defineOb11Action({
595
+ name: "get_group_root_files",
596
+ schema: z.object({
597
+ group_id: z.number(),
598
+ file_count: z.number().optional()
599
+ }),
600
+ handle: async (payload) => {
601
+ return splitFilesAndFolders(await api.richMediaApi.getGroupFileList(String(payload.group_id), "", payload.file_count ?? DEFAULT_FILE_COUNT));
602
+ }
603
+ }),
604
+ defineOb11Action({
605
+ name: "get_group_files_by_folder",
606
+ schema: z.object({
607
+ group_id: z.number(),
608
+ folder_id: z.string(),
609
+ file_count: z.number().optional()
610
+ }),
611
+ handle: async (payload) => {
612
+ return splitFilesAndFolders(await api.richMediaApi.getGroupFileList(String(payload.group_id), payload.folder_id, payload.file_count ?? DEFAULT_FILE_COUNT));
613
+ }
614
+ }),
615
+ defineOb11Action({
616
+ name: "get_group_file_system_info",
617
+ schema: z.object({ group_id: z.number() }),
618
+ handle: async (payload) => {
619
+ const info = await api.richMediaApi.getGroupFileSystemInfo(String(payload.group_id));
620
+ return {
621
+ file_count: info.fileCount,
622
+ limit_count: info.limitCount,
623
+ used_space: info.usedSpace,
624
+ total_space: info.totalSpace
625
+ };
626
+ }
627
+ })
801
628
  ];
802
629
  }
803
630
  // src/onebot11/action/group/manage.ts
804
631
  /**
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 合并)
632
+ * 群管理域动作
807
633
  *
808
634
  * 踢人 / 单人与全员禁言 / 管理员 / 名片 / 群名 / 退群,均接 kernel GroupApi;
809
635
  * user_id(uin)→ uid 经 resolveUid。
810
636
  */
811
- const setGroupKickSchema = z.object({
812
- group_id: z.number(),
813
- user_id: z.number(),
814
- /** 是否拒绝加群请求(拉黑)。 */
815
- reject_add_request: z.boolean().optional(),
816
- /** 踢人理由。 */
817
- kick_reason: z.string().optional()
818
- });
819
- /** 群组踢人(P2-10 接 kernel kickMember)。 */
820
- var SetGroupKickAction = class extends BaseAction {
821
- name = "set_group_kick";
822
- schema = setGroupKickSchema;
823
- errorCodeMap = ob11ErrorCodeMap;
824
- groupApi;
825
- constructor(groupApi) {
826
- super();
827
- this.groupApi = groupApi;
828
- }
829
- async _handle(payload) {
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 ?? "");
832
- return null;
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
- }
840
- };
841
- const setGroupBanSchema = z.object({
842
- group_id: z.number(),
843
- user_id: z.number(),
844
- /** 禁言时长(秒),0 解除。 */
845
- duration: z.number().default(30)
846
- });
847
- /** 群组单人禁言(P2-10 接 kernel setMemberShutUp)。 */
848
- var SetGroupBanAction = class extends BaseAction {
849
- name = "set_group_ban";
850
- schema = setGroupBanSchema;
851
- errorCodeMap = ob11ErrorCodeMap;
852
- groupApi;
853
- constructor(groupApi) {
854
- super();
855
- this.groupApi = groupApi;
856
- }
857
- async _handle(payload) {
858
- const uid = await resolveUid(String(payload.user_id), (uins) => this.groupApi.uinToUid(uins));
859
- await this.groupApi.setMemberShutUp(String(payload.group_id), [{
860
- uid,
861
- duration: payload.duration
862
- }]);
863
- return null;
864
- }
865
- };
866
- const setGroupWholeBanSchema = z.object({
867
- group_id: z.number(),
868
- /** 是否开启全员禁言。 */
869
- enable: z.boolean().default(true)
870
- });
871
- /** 群组全员禁言(P2-10 接 kernel setGroupShutUp)。 */
872
- var SetGroupWholeBanAction = class extends BaseAction {
873
- name = "set_group_whole_ban";
874
- schema = setGroupWholeBanSchema;
875
- errorCodeMap = ob11ErrorCodeMap;
876
- groupApi;
877
- constructor(groupApi) {
878
- super();
879
- this.groupApi = groupApi;
880
- }
881
- async _handle(payload) {
882
- await this.groupApi.setGroupShutUp(String(payload.group_id), payload.enable);
883
- return null;
884
- }
885
- };
886
- const setGroupAdminSchema = z.object({
887
- group_id: z.number(),
888
- user_id: z.number(),
889
- /** 是否设为管理员。 */
890
- enable: z.boolean().default(true)
891
- });
892
- /** 设置群管理员(P2-10 接 kernel setMemberRole)。 */
893
- var SetGroupAdminAction = class extends BaseAction {
894
- name = "set_group_admin";
895
- schema = setGroupAdminSchema;
896
- errorCodeMap = ob11ErrorCodeMap;
897
- groupApi;
898
- constructor(groupApi) {
899
- super();
900
- this.groupApi = groupApi;
901
- }
902
- async _handle(payload) {
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);
907
- return null;
908
- }
909
- };
910
- const setGroupCardSchema = z.object({
911
- group_id: z.number(),
912
- user_id: z.number(),
913
- /** 群名片(空串清除)。 */
914
- card: z.string().optional().default("")
915
- });
916
- /** 设置群名片(P2-10 接 kernel setMemberCardName)。 */
917
- var SetGroupCardAction = class extends BaseAction {
918
- name = "set_group_card";
919
- schema = setGroupCardSchema;
920
- errorCodeMap = ob11ErrorCodeMap;
921
- groupApi;
922
- constructor(groupApi) {
923
- super();
924
- this.groupApi = groupApi;
925
- }
926
- async _handle(payload) {
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);
929
- return null;
930
- }
931
- };
932
- const setGroupNameSchema = z.object({
933
- group_id: z.number(),
934
- group_name: z.string()
935
- });
936
- /** 修改群名(P2-10 接 kernel modifyGroupName)。 */
937
- var SetGroupNameAction = class extends BaseAction {
938
- name = "set_group_name";
939
- schema = setGroupNameSchema;
940
- errorCodeMap = ob11ErrorCodeMap;
941
- groupApi;
942
- constructor(groupApi) {
943
- super();
944
- this.groupApi = groupApi;
945
- }
946
- async _handle(payload) {
947
- await this.groupApi.modifyGroupName(String(payload.group_id), payload.group_name);
948
- return null;
949
- }
950
- };
951
- const setGroupLeaveSchema = z.object({
952
- group_id: z.number(),
953
- /** 是否解散群(仅群主可用)。 */
954
- is_dismiss: z.boolean().optional().default(false)
955
- });
956
- /** 退出群聊(P2-10 接 kernel quitGroup)。 */
957
- var SetGroupLeaveAction = class extends BaseAction {
958
- name = "set_group_leave";
959
- schema = setGroupLeaveSchema;
960
- errorCodeMap = ob11ErrorCodeMap;
961
- groupApi;
962
- constructor(groupApi) {
963
- super();
964
- this.groupApi = groupApi;
965
- }
966
- async _handle(payload) {
967
- await this.groupApi.quitGroup(String(payload.group_id), payload.is_dismiss);
968
- return null;
969
- }
970
- };
971
- /**
972
- * 群管理域动作工厂(kick / ban / whole_ban / admin / card / name / leave)。
973
- */
637
+ /** 默认禁言时长(秒)。 */
638
+ const DEFAULT_BAN_DURATION = 30;
639
+ /** 群管理域动作工厂(kick / ban / whole_ban / admin / card / name / leave)。 */
640
+ /** uin → uid(groupApi.uinToUid 绑定视图;kernel 方法非箭头绑定)。 */
641
+ function memberUidOf(api, uin) {
642
+ return resolveUid(String(uin), (uins) => api.groupApi.uinToUid(uins));
643
+ }
974
644
  function createGroupManageActions(api) {
975
645
  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)
646
+ defineOb11Action({
647
+ name: "set_group_kick",
648
+ schema: z.object({
649
+ group_id: z.number(),
650
+ user_id: z.number(),
651
+ /** 是否拒绝加群请求(拉黑)。 */
652
+ reject_add_request: z.boolean().optional(),
653
+ /** 踢人理由。 */
654
+ kick_reason: z.string().optional()
655
+ }),
656
+ handle: async (payload) => {
657
+ const uid = await memberUidOf(api, payload.user_id);
658
+ await api.groupApi.kickMember(String(payload.group_id), [uid], payload.reject_add_request === true, payload.kick_reason ?? "");
659
+ return null;
660
+ }
661
+ }),
662
+ defineOb11Action({
663
+ name: "set_group_ban",
664
+ schema: z.object({
665
+ group_id: z.number(),
666
+ user_id: z.number(),
667
+ /** 禁言时长(秒),0 解除。 */
668
+ duration: z.number().default(DEFAULT_BAN_DURATION)
669
+ }),
670
+ handle: async (payload) => {
671
+ const uid = await memberUidOf(api, payload.user_id);
672
+ await api.groupApi.setMemberShutUp(String(payload.group_id), [{
673
+ uid,
674
+ duration: payload.duration
675
+ }]);
676
+ return null;
677
+ }
678
+ }),
679
+ defineOb11Action({
680
+ name: "set_group_whole_ban",
681
+ schema: z.object({
682
+ group_id: z.number(),
683
+ /** 是否开启全员禁言。 */
684
+ enable: z.boolean().default(true)
685
+ }),
686
+ handle: async (payload) => {
687
+ await api.groupApi.setGroupShutUp(String(payload.group_id), payload.enable);
688
+ return null;
689
+ }
690
+ }),
691
+ defineOb11Action({
692
+ name: "set_group_admin",
693
+ schema: z.object({
694
+ group_id: z.number(),
695
+ user_id: z.number(),
696
+ /** 是否设为管理员。 */
697
+ enable: z.boolean().default(true)
698
+ }),
699
+ handle: async (payload) => {
700
+ const uid = await memberUidOf(api, payload.user_id);
701
+ let role = NTGroupMemberRole.MEMBER;
702
+ if (payload.enable) role = NTGroupMemberRole.ADMIN;
703
+ api.groupApi.setMemberRole(String(payload.group_id), uid, role);
704
+ return null;
705
+ }
706
+ }),
707
+ defineOb11Action({
708
+ name: "set_group_card",
709
+ schema: z.object({
710
+ group_id: z.number(),
711
+ user_id: z.number(),
712
+ /** 群名片(空串清除)。 */
713
+ card: z.string().optional().default("")
714
+ }),
715
+ handle: async (payload) => {
716
+ const uid = await memberUidOf(api, payload.user_id);
717
+ api.groupApi.setMemberCardName(String(payload.group_id), uid, payload.card);
718
+ return null;
719
+ }
720
+ }),
721
+ defineOb11Action({
722
+ name: "set_group_name",
723
+ schema: z.object({
724
+ group_id: z.number(),
725
+ group_name: z.string()
726
+ }),
727
+ handle: async (payload) => {
728
+ await api.groupApi.modifyGroupName(String(payload.group_id), payload.group_name);
729
+ return null;
730
+ }
731
+ }),
732
+ defineOb11Action({
733
+ name: "set_group_leave",
734
+ schema: z.object({
735
+ group_id: z.number(),
736
+ /** 是否解散群(仅群主可用)。 */
737
+ is_dismiss: z.boolean().optional().default(false)
738
+ }),
739
+ handle: async (payload) => {
740
+ await api.groupApi.quitGroup(String(payload.group_id), payload.is_dismiss);
741
+ return null;
742
+ }
743
+ })
983
744
  ];
984
745
  }
985
746
  // src/onebot11/action/group/notify.ts
986
747
  /**
987
- * 群通知域动作(2026-11-14 自 get-group-add-request / set-group-add-request /
988
- * get-group-shut-list 合并,均接 kernel GroupNotifyApi)
748
+ * 群通知域动作(均接 kernel GroupNotifyApi)
989
749
  *
990
- * - get_group_add_request / get_group_ignored_notifies(P2-15):未处理申请列表 /
750
+ * - get_group_add_request / get_group_ignored_notifies:未处理申请列表 /
991
751
  * 可疑忽略列表(getSingleScreenNotifies(false|true));flag=seq 用于应答
992
- * - set_group_add_request(P2-13):flag=seq 匹配 → handleGroupRequest
752
+ * - set_group_add_request:flag=seq 匹配 → handleGroupRequest
993
753
  * (approve=true→同意 / false→拒绝,reason 默认空格)
994
- * - get_group_shut_list(P2-13):getGroupShutUpMemberList → 禁言成员列表
754
+ * - get_group_shut_list:getGroupShutUpMemberList → 禁言成员列表
995
755
  * (uin 经 uidToUin 批量转换)
996
756
  */
997
757
  const getGroupAddRequestSchema = z.object({ count: z.number().optional() });
998
758
  /** 默认获取数量。 */
999
759
  const DEFAULT_COUNT = 100;
1000
- /** 获取未处理群申请(P2-15)。 */
1001
- var GetGroupAddRequestAction = class extends BaseAction {
1002
- name = "get_group_add_request";
1003
- schema = getGroupAddRequestSchema;
1004
- errorCodeMap = ob11ErrorCodeMap;
1005
- groupNotifyApi;
1006
- constructor(groupNotifyApi) {
1007
- super();
1008
- this.groupNotifyApi = groupNotifyApi;
1009
- }
1010
- async _handle(payload) {
1011
- return (await this.groupNotifyApi.getSingleScreenNotifies(false, payload.count ?? DEFAULT_COUNT)).map(toGroupAddRequestItem);
1012
- }
1013
- };
1014
- /** 获取被忽略群申请(P2-15)。 */
1015
- var GetGroupIgnoredNotifiesAction = class extends BaseAction {
1016
- name = "get_group_ignored_notifies";
1017
- schema = getGroupAddRequestSchema;
1018
- errorCodeMap = ob11ErrorCodeMap;
1019
- groupNotifyApi;
1020
- constructor(groupNotifyApi) {
1021
- super();
1022
- this.groupNotifyApi = groupNotifyApi;
1023
- }
1024
- async _handle(payload) {
1025
- return (await this.groupNotifyApi.getSingleScreenNotifies(true, payload.count ?? DEFAULT_COUNT)).map(toGroupAddRequestItem);
1026
- }
1027
- };
1028
760
  /** GroupNotify → OB11 群请求项(纯函数)。 */
1029
761
  function toGroupAddRequestItem(notify) {
1030
762
  const { seq, type, status, postscript, user1, group } = notify;
@@ -1053,80 +785,72 @@ function toGroupAddRequestItem(notify) {
1053
785
  postscript: postscript ?? ""
1054
786
  };
1055
787
  }
1056
- const setGroupAddRequestSchema = z.object({
1057
- flag: z.string(),
1058
- approve: z.boolean().optional(),
1059
- reason: z.string().optional(),
1060
- count: z.number().optional()
1061
- });
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;
1093
- errorCodeMap = ob11ErrorCodeMap;
1094
- deps;
1095
- constructor(deps) {
1096
- super();
1097
- this.deps = deps;
1098
- }
1099
- async _handle(payload) {
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;
1111
- }
1112
- };
1113
- /**
1114
- * 群通知域动作工厂(get_group_add_request / get_group_ignored_notifies /
1115
- * set_group_add_request / get_group_shut_list)。
1116
- */
788
+ /** 按 seq 匹配通知(先非可疑,后可疑)。 */
789
+ async function findGroupNotify(groupNotifyApi, flag, count) {
790
+ const hit = (await groupNotifyApi.getSingleScreenNotifies(false, count)).find((item) => item.seq === flag);
791
+ if (hit !== void 0) return hit;
792
+ return (await groupNotifyApi.getSingleScreenNotifies(true, count)).find((item) => item.seq === flag) ?? null;
793
+ }
794
+ /** 群通知域动作工厂(get_group_add_request / get_group_ignored_notifies /
795
+ * set_group_add_request / get_group_shut_list)。 */
1117
796
  function createGroupNotifyActions(api) {
1118
797
  return [
1119
- new GetGroupAddRequestAction(api.groupNotifyApi),
1120
- new GetGroupIgnoredNotifiesAction(api.groupNotifyApi),
1121
- new SetGroupAddRequestAction(api.groupNotifyApi),
1122
- new GetGroupShutListAction(api)
798
+ defineOb11Action({
799
+ name: "get_group_add_request",
800
+ schema: getGroupAddRequestSchema,
801
+ handle: async (payload) => {
802
+ return (await api.groupNotifyApi.getSingleScreenNotifies(false, payload.count ?? DEFAULT_COUNT)).map(toGroupAddRequestItem);
803
+ }
804
+ }),
805
+ defineOb11Action({
806
+ name: "get_group_ignored_notifies",
807
+ schema: getGroupAddRequestSchema,
808
+ handle: async (payload) => {
809
+ return (await api.groupNotifyApi.getSingleScreenNotifies(true, payload.count ?? DEFAULT_COUNT)).map(toGroupAddRequestItem);
810
+ }
811
+ }),
812
+ defineOb11Action({
813
+ name: "set_group_add_request",
814
+ schema: z.object({
815
+ flag: z.string(),
816
+ approve: z.boolean().optional(),
817
+ reason: z.string().optional(),
818
+ count: z.number().optional()
819
+ }),
820
+ handle: async (payload) => {
821
+ const count = payload.count ?? DEFAULT_COUNT;
822
+ const notify = await findGroupNotify(api.groupNotifyApi, payload.flag, count);
823
+ if (notify === null) throw kernelError("未找到对应的群请求(flag 无效或已过期)", "NOT_FOUND");
824
+ let operateType = NTGroupRequestOperateTypes.KREFUSE;
825
+ if (payload.approve !== false) operateType = NTGroupRequestOperateTypes.KAGREE;
826
+ await api.groupNotifyApi.handleGroupRequest(false, notify, operateType, payload.reason ?? " ");
827
+ return null;
828
+ }
829
+ }),
830
+ defineOb11Action({
831
+ name: "get_group_shut_list",
832
+ schema: z.object({ group_id: z.number() }),
833
+ handle: async (payload) => {
834
+ const members = await api.groupNotifyApi.getGroupShutUpMemberList(String(payload.group_id));
835
+ const uids = members.map((m) => m.uid);
836
+ let uinMap = /* @__PURE__ */ new Map();
837
+ if (uids.length > 0) uinMap = await api.uidToUin(uids);
838
+ const out = [];
839
+ for (const member of members) out.push({
840
+ user_id: Number(uinMap.get(member.uid) ?? member.uin ?? member.uid),
841
+ nickname: member.nick,
842
+ shut_up_time: member.shutUpTime
843
+ });
844
+ return out;
845
+ }
846
+ })
1123
847
  ];
1124
848
  }
1125
849
  // src/onebot11/helper/translate.ts
1126
850
  /**
1127
- * OB11 翻译辅助(NT 实体 → OB11 结构,P2-4)
851
+ * OB11 翻译辅助(NT 实体 → OB11 结构)
1128
852
  *
1129
- * 纯函数(ADR-008):只读入参,不调 API、不读缓存。
853
+ * 纯函数:只读入参,不调 API、不读缓存。
1130
854
  * 群成员/群信息等 NT 实体 → OB11 返回结构的薄映射。
1131
855
  */
1132
856
  /** NT Group → OB11 GroupInfo。 */
@@ -1174,137 +898,88 @@ function toOb11GroupMemberInfo(groupCode, member, uidToUin) {
1174
898
  }
1175
899
  // src/onebot11/action/group/query.ts
1176
900
  /**
1177
- * 群查询域动作(2026-11-14 自 get-group-info / get-group-list / get-group-member-info /
1178
- * get-group-member-list / get-group-at-all-remain 合并)
901
+ * 群查询域动作
1179
902
  *
1180
- * P2-4 接 kernel GroupApi;P2-17 群信息/成员动作优先读 GroupCache,no_cache=true
903
+ * 接 kernel GroupApi;群信息/成员动作优先读 GroupCache,no_cache=true
1181
904
  * 直查 api。get_group_list 有实测校准:原生 getGroupList 返回值无数据(仅
1182
905
  * { result, errMsg }),列表经 onGroupListUpdate 事件推送 → GroupCache 维护。
1183
906
  */
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
907
  /** 群查询域动作工厂(group_info / group_list / member_info / member_list / at_all_remain)。 */
1301
908
  function createGroupQueryActions(api) {
1302
909
  return [
1303
- new GetGroupInfoAction(api),
1304
- new GetGroupListAction(api),
1305
- new GetGroupMemberInfoAction(api),
1306
- new GetGroupMemberListAction(api),
1307
- new GetGroupAtAllRemainAction(api.groupApi)
910
+ defineOb11Action({
911
+ name: "get_group_info",
912
+ schema: z.object({
913
+ group_id: z.number(),
914
+ /** 是否忽略缓存(go-cqhttp 扩展)。 */
915
+ no_cache: z.boolean().optional()
916
+ }),
917
+ handle: async (payload) => {
918
+ const groupCode = String(payload.group_id);
919
+ if (payload.no_cache !== true && api.groupCache !== void 0) return toOb11GroupInfoDetail(await api.groupCache.getGroupDetail(groupCode));
920
+ return toOb11GroupInfoDetail(await api.groupApi.getGroupInfo(groupCode));
921
+ }
922
+ }),
923
+ defineOb11Action({
924
+ name: "get_group_list",
925
+ schema: z.object({
926
+ /** 是否忽略缓存(go-cqhttp 扩展)。 */
927
+ no_cache: z.boolean().optional() }),
928
+ handle: async (payload) => {
929
+ return (api.groupCache === void 0 ? await api.groupApi.getGroupList(true) : payload.no_cache === true ? await api.groupCache.listGroupsRefreshed() : api.groupCache.listGroups()).map(toOb11GroupInfo);
930
+ }
931
+ }),
932
+ defineOb11Action({
933
+ name: "get_group_member_info",
934
+ schema: z.object({
935
+ group_id: z.number(),
936
+ user_id: z.number(),
937
+ /** 是否忽略缓存(go-cqhttp 扩展)。 */
938
+ no_cache: z.boolean().optional()
939
+ }),
940
+ handle: async (payload) => {
941
+ const groupCode = String(payload.group_id);
942
+ const uid = (await api.groupApi.uinToUid([String(payload.user_id)])).get(String(payload.user_id));
943
+ if (uid === void 0) throw kernelError(`成员 ${payload.user_id} 不在群 ${payload.group_id}`, "NOT_FOUND");
944
+ let member;
945
+ if (payload.no_cache === true || api.groupCache === void 0) {
946
+ const [first] = await api.groupApi.getGroupMemberInfo(groupCode, [uid]);
947
+ member = first;
948
+ } else member = await api.groupCache.getMember(groupCode, uid);
949
+ if (member === void 0) throw kernelError(`成员 ${payload.user_id} 不在群 ${payload.group_id}`, "NOT_FOUND");
950
+ const uinMap = await api.groupApi.uidToUin([uid]);
951
+ return toOb11GroupMemberInfo(groupCode, member, uinMap);
952
+ }
953
+ }),
954
+ defineOb11Action({
955
+ name: "get_group_member_list",
956
+ schema: z.object({
957
+ group_id: z.number(),
958
+ /** 是否忽略缓存(go-cqhttp 扩展)。 */
959
+ no_cache: z.boolean().optional()
960
+ }),
961
+ handle: async (payload) => {
962
+ const groupCode = String(payload.group_id);
963
+ const noCache = payload.no_cache === true;
964
+ let members;
965
+ if (noCache || api.groupCache === void 0) members = await api.groupApi.getGroupMemberList(groupCode, noCache);
966
+ else members = await api.groupCache.getMembers(groupCode);
967
+ const uinMap = await api.groupApi.uidToUin(members.map((m) => m.uid));
968
+ return members.map((m) => toOb11GroupMemberInfo(groupCode, m, uinMap));
969
+ }
970
+ }),
971
+ defineOb11Action({
972
+ name: "get_group_at_all_remain",
973
+ schema: z.object({ group_id: z.number() }),
974
+ handle: async (payload) => {
975
+ const remain = await api.groupApi.getGroupRemainAtTimes(String(payload.group_id));
976
+ return {
977
+ can_at_all: remain.canAtAll,
978
+ remain_at_all_count_for_uin: remain.remainAtAllCountForUin,
979
+ remain_at_all_count_for_group: remain.remainAtAllCountForGroup
980
+ };
981
+ }
982
+ })
1308
983
  ];
1309
984
  }
1310
985
  // src/onebot11/helper/codec/cqcode.ts
@@ -1577,10 +1252,10 @@ function segmentsToCqMessage(segments) {
1577
1252
  }
1578
1253
  // src/onebot11/helper/config.ts
1579
1254
  /**
1580
- * OneBot 11 协议配置(zod schema,归属本包,ADR-012)
1255
+ * OneBot 11 协议配置(zod schema,归属本包)
1581
1256
  * 协议配置 schema 在各自协议包,kernel 只提供 ConfigBase 基类。
1582
1257
  *
1583
- * 2026-08-07 多实例化(P2-18):对齐 NapCat——httpServers / httpPostUrls / wsServers /
1258
+ * 多实例化:对齐 NapCat——httpServers / httpPostUrls / wsServers /
1584
1259
  * wsReverseUrls 四个数组实例(每实例可覆盖全局 token);旧单对象字段 http/httpPost/ws/
1585
1260
  * wsReverse 废弃(zod strip 静默忽略,不兼容迁移)。
1586
1261
  */
@@ -1597,7 +1272,7 @@ const DEFAULT_RECONNECT_DELAY_MS = 5e3;
1597
1272
  /** 消息内容格式(NapCat messagePostFormat)。 */
1598
1273
  const MESSAGE_FORMATS = ["array", "string"];
1599
1274
  /** HTTP 反向服务器实例(第三方 POST 指令入口)。 */
1600
- const httpServerSchema = createHttpServerSchema(DEFAULT_HTTP_PORT);
1275
+ const httpServerSchema = createServerSchema(DEFAULT_HTTP_PORT);
1601
1276
  /** HTTP 正向上报实例(Webhook 事件推送)。 */
1602
1277
  const httpPostSchema = z.object({
1603
1278
  enabled: z.boolean().default(false),
@@ -1608,7 +1283,7 @@ const httpPostSchema = z.object({
1608
1283
  timeoutMs: z.number().int().optional()
1609
1284
  });
1610
1285
  /** 反向 WS server 实例(第三方 WS 连入,带 WS ping 间隔扩展字段)。 */
1611
- const wsServerSchema = createWsServerSchema(DEFAULT_WS_PORT).extend({
1286
+ const wsServerSchema = createServerSchema(DEFAULT_WS_PORT).extend({
1612
1287
  /** WS ping 间隔(毫秒)。 */
1613
1288
  heartbeatInterval: z.number().int().default(DEFAULT_WS_HEARTBEAT_MS) });
1614
1289
  /** 正向 WS client 实例(主动连接第三方,双向)。 */
@@ -1637,7 +1312,7 @@ const ob11ConfigSchema = z.object({
1637
1312
  /** 消息内容格式:array = 消息段数组(标准),string = CQ 码字符串。 */
1638
1313
  messagePostFormat: z.enum(MESSAGE_FORMATS).default("array"),
1639
1314
  /**
1640
- * 群文件报形式(B4,2026-09-08):false(缺省)= message 事件 + file 段
1315
+ * 群文件报形式():false(缺省)= message 事件 + file 段
1641
1316
  * (go-cqhttp 兼容;此前 file 元素被静默丢弃,本版本起透出);true = 含
1642
1317
  * fileElement 的群消息改报 group_upload notice 事件(替代 message 事件)。
1643
1318
  */
@@ -1774,7 +1449,7 @@ function cqMessageToCanonical(text) {
1774
1449
  }
1775
1450
  // src/onebot11/helper/message-info.ts
1776
1451
  /** RawMessage → OB11 消息信息(message_id 经 MessageUnique 映射)。
1777
- * ctx(可选):接收方向 ID 转换上下文(at uid→uin、reply NT msgId→OB11 id,P2-19)。 */
1452
+ * ctx(可选):接收方向 ID 转换上下文(at uid→uin、reply NT msgId→OB11 id)。 */
1778
1453
  function toOb11MessageInfo(msg, unique, ctx = {}) {
1779
1454
  const elements = applyReceiveContext(toCanonicalElements(msg), ctx);
1780
1455
  let messageType = "private";
@@ -1809,7 +1484,7 @@ const GROUP_FILE_BUS_ID = 102;
1809
1484
  /**
1810
1485
  * 检查消息是否含文件元素(group_upload 开关分支判定)。
1811
1486
  *
1812
- * ⚠️ 用空值判定(`!= null`)而非 `!== undefined`(2026-11-10,Linux 原生宿主):
1487
+ * ⚠️ 用空值判定(`!= null`)而非 `!== undefined`(Linux 原生宿主):
1813
1488
  * Windows 原生对象省略未命中的元素变体字段,Linux 3.2.x 原生对象则把**全部**
1814
1489
  * 变体字段显式置 `null`(`"grayTipElement":null` 等)。用 `!== undefined`
1815
1490
  * 会把每条普通消息都判成「含该元素」——OB11 入站消息因此全部被误路由到
@@ -1827,7 +1502,7 @@ function base(msg, ctx) {
1827
1502
  group_id: Number(msg.peerUid)
1828
1503
  };
1829
1504
  }
1830
- /** 撤回事件(chatType 分流:GROUP→group_recall / C2C→friend_recall,2026-09-08)。 */
1505
+ /** 撤回事件(chatType 分流:GROUP→group_recall / C2C→friend_recall)。 */
1831
1506
  function toRecall(msg, g, ctx) {
1832
1507
  if (g?.revokeElement === void 0) return null;
1833
1508
  const revoke = g.revokeElement;
@@ -1848,7 +1523,7 @@ function toRecall(msg, g, ctx) {
1848
1523
  };
1849
1524
  }
1850
1525
  /**
1851
- * 戳一戳(notify.poke,aioOpGrayTipElement,2026-09-08)。
1526
+ * 戳一戳(notify.poke,aioOpGrayTipElement)。
1852
1527
  *
1853
1528
  * ⚠️ 待真实 poke 事件验证:aioOp 载荷的完整字段形状未经实测(实体类型仅有
1854
1529
  * operateType/peerUid 两个已证字段)。当前口径:user_id = 消息发送者,
@@ -1950,7 +1625,7 @@ function toBan(common, grp, ctx) {
1950
1625
  };
1951
1626
  }
1952
1627
  /**
1953
- * 好友添加(friend_add,B2,2026-09-08)。
1628
+ * 好友添加(friend_add,)。
1954
1629
  * 数据源 = kernel BuddyCache 快照 diff(Buddy/onBuddyListChange 全量快照对比,
1955
1630
  * 首帧 baseline 不发)——非 grayTip 路径。user_id 取 coreInfo.uin(顶层 uin 兜底)。
1956
1631
  */
@@ -1965,7 +1640,7 @@ function toFriendAdd(entry, selfUin) {
1965
1640
  };
1966
1641
  }
1967
1642
  /**
1968
- * 群文件上传(group_upload,B4,2026-09-08)。
1643
+ * 群文件上传(group_upload,)。
1969
1644
  * 数据源 = 含 fileElement 的群消息(开关 groupUploadAsNotice=true 时替代
1970
1645
  * message 事件报出)。file.id 取 fileUuid(缺省文件名)、size 取 fileSize、
1971
1646
  * busid 固定 102(群文件业务类型,与 kernel GROUP_FILE_BIZ_TYPE 同源语义)。
@@ -2005,7 +1680,7 @@ function logUntranslatedGrayTip(msg, ctx) {
2005
1680
  }, "ob11: 未翻译的 grayTip 子类型(raw 校准数据)");
2006
1681
  }
2007
1682
  /** RawMessage → OB11 notice 事件(无 grayTip 返回 null)。
2008
- * 未知/未翻译子类型打 raw JSON 日志(校准数据积累,2026-09-08)。 */
1683
+ * 未知/未翻译子类型打 raw JSON 日志(校准数据积累)。 */
2009
1684
  function toOb11NoticeEvent(msg, ctx) {
2010
1685
  for (const el of msg.elements) {
2011
1686
  const g = el.grayTipElement;
@@ -2017,7 +1692,7 @@ function toOb11NoticeEvent(msg, ctx) {
2017
1692
  }
2018
1693
  // src/onebot11/helper/request.ts
2019
1694
  /**
2020
- * OB11 request 事件翻译(2026-09-08)
1695
+ * OB11 request 事件翻译
2021
1696
  *
2022
1697
  * 事件源(kernel 事件通道,本次接线):
2023
1698
  * - `Group/onGroupNotifiesUpdated`(GroupBridge,群系统通知推送)→ group_add / group_invite
@@ -2027,7 +1702,7 @@ function toOb11NoticeEvent(msg, ctx) {
2027
1702
  * - 群请求 flag = GroupNotify.seq(set_group_add_request 按 `item.seq === flag` 匹配)
2028
1703
  * - 好友请求 flag = BuddyReq.reqTime(set_friend_add_request 按 `reqTime === flag` 匹配)
2029
1704
  *
2030
- * 纯函数(ADR-008):uid→uin 由调用方批量转换后传入。
1705
+ * 纯函数:uid→uin 由调用方批量转换后传入。
2031
1706
  * ⚠️ onBuddyReqChange 回调参数形状未经真实事件校准(wrapper 字符串证据仅有方法名),
2032
1707
  * narrowBuddyReqs 防御性收窄,未知形状返回 null 由调用方打 raw 日志积累校准数据。
2033
1708
  */
@@ -2081,7 +1756,7 @@ function toOb11FriendRequestEvent(req, ctx) {
2081
1756
  }
2082
1757
  // src/onebot11/action/message/resolve-peer.ts
2083
1758
  /**
2084
- * OB11 目标 Peer 解析 / 单条消息拉取(多个动作共用,2026-08-08 克隆合并)
1759
+ * OB11 目标 Peer 解析 / 单条消息拉取(多个动作共用)
2085
1760
  *
2086
1761
  * group_id 直通(群消息 peerUid = 群号);user_id 经 uin→uid 解析。
2087
1762
  */
@@ -2117,16 +1792,15 @@ async function fetchMsgById(messageId, messageUnique, msgApi) {
2117
1792
  }
2118
1793
  // src/onebot11/action/message/forward.ts
2119
1794
  /**
2120
- * 消息转发域动作(2026-11-14 自 send-forward-msg / forward-single-msg /
2121
- * get-forward-msg 合并)
1795
+ * 消息转发域动作
2122
1796
  *
2123
- * - send_group_forward_msg / send_private_forward_msg(P2-12):messages 每项为
1797
+ * - send_group_forward_msg / send_private_forward_msg:messages 每项为
2124
1798
  * node 元素 `{ type: "node", data: { id } }`——id 是此前 send_msg 返回的 OB11
2125
1799
  * message_id。经 MessageUnique 反查源 msgId + peer,组装到目标 peer(群直通 /
2126
1800
  * 私聊 uinToUid)→ MsgApi.sendForwardMessage
2127
- * - forward_group_single_msg / forward_friend_single_msg(P2-12):message_id 反查
1801
+ * - forward_group_single_msg / forward_friend_single_msg:message_id 反查
2128
1802
  * 源 msgId + peer;group_id/user_id 为目标 → MsgApi.forwardSingleMessage
2129
- * - get_forward_msg(P2-12):message_id / id → fetchForwardMessage(getMultiMsg)
1803
+ * - get_forward_msg:message_id / id → fetchForwardMessage(getMultiMsg)
2130
1804
  * → 每条 toOb11MessageInfo → { messages }
2131
1805
  */
2132
1806
  const forwardNodeSchema = z.object({
@@ -2141,6 +1815,15 @@ const sendPrivateForwardMsgSchema = z.object({
2141
1815
  user_id: z.number(),
2142
1816
  messages: z.array(z.unknown()).max(500).default([])
2143
1817
  });
1818
+ const forwardSingleMsgSchema = z.object({
1819
+ message_id: z.union([z.number(), z.string()]),
1820
+ group_id: z.number().optional(),
1821
+ user_id: z.number().optional()
1822
+ });
1823
+ const getForwardMsgSchema = z.object({
1824
+ message_id: z.union([z.number(), z.string()]).optional(),
1825
+ id: z.union([z.number(), z.string()]).optional()
1826
+ });
2144
1827
  /** 解析 node 元素列表 → 源消息 (msgId, peer) 列表(id 反查,跳过无法解析的项)。 */
2145
1828
  function resolveSourceMessages(messages, unique) {
2146
1829
  const out = [];
@@ -2170,145 +1853,70 @@ async function sendForward(messages, target, deps) {
2170
1853
  const { msgId } = await deps.msgApi.sendForwardMessage(target, firstSource.peer, sources.map((s) => s.msgId));
2171
1854
  return { message_id: deps.messageUnique.alloc(msgId, target) };
2172
1855
  }
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)。 */
1856
+ /** 单条转发共用实现:message_id 反查源消息 + 目标 Peer 解析 → forwardSingleMessage。 */
1857
+ async function forwardSingleMsg(payload, deps) {
1858
+ const { msgId, peer: sourcePeer } = resolveMsgIdAndPeer(payload.message_id, deps.messageUnique);
1859
+ const dstPeer = await resolveTargetPeer(payload, deps, "单条转发需要 group_id 或 user_id");
1860
+ await deps.msgApi.forwardSingleMessage(sourcePeer, [msgId], dstPeer);
1861
+ return null;
1862
+ }
1863
+ /** 消息转发域动作工厂(合并转发 ×2 / get_forward_msg / 单条转发 ×2)。 */
2262
1864
  function createForwardActions(api) {
2263
1865
  return [
2264
- new SendGroupForwardMsgAction(api),
2265
- new SendPrivateForwardMsgAction(api),
2266
- new GetForwardMsgAction(api),
2267
- new ForwardGroupSingleMsgAction(api),
2268
- new ForwardFriendSingleMsgAction(api)
1866
+ defineOb11Action({
1867
+ name: "send_group_forward_msg",
1868
+ schema: sendGroupForwardMsgSchema,
1869
+ handle: async (payload) => {
1870
+ const target = {
1871
+ chatType: ChatType.GROUP,
1872
+ peerUid: String(payload.group_id)
1873
+ };
1874
+ return await sendForward(payload.messages, target, api);
1875
+ }
1876
+ }),
1877
+ defineOb11Action({
1878
+ name: "send_private_forward_msg",
1879
+ schema: sendPrivateForwardMsgSchema,
1880
+ handle: async (payload) => {
1881
+ const uid = await resolveUid(String(payload.user_id), api.uinToUid);
1882
+ const target = {
1883
+ chatType: ChatType.C2C,
1884
+ peerUid: uid
1885
+ };
1886
+ return await sendForward(payload.messages, target, api);
1887
+ }
1888
+ }),
1889
+ defineOb11Action({
1890
+ name: "get_forward_msg",
1891
+ schema: getForwardMsgSchema,
1892
+ handle: async (payload) => {
1893
+ const id = payload.message_id ?? payload.id;
1894
+ if (id === void 0) throw kernelError("get_forward_msg 需要 message_id 或 id", "INVALID_PARAM");
1895
+ const { msgId, peer } = resolveMsgIdAndPeer(id, api.messageUnique);
1896
+ return { messages: (await api.msgApi.fetchForwardMessage(peer, msgId)).map((msg) => toOb11MessageInfo(msg, api.messageUnique)) };
1897
+ }
1898
+ }),
1899
+ defineOb11Action({
1900
+ name: "forward_group_single_msg",
1901
+ schema: forwardSingleMsgSchema,
1902
+ handle: (payload) => forwardSingleMsg(payload, api)
1903
+ }),
1904
+ defineOb11Action({
1905
+ name: "forward_friend_single_msg",
1906
+ schema: forwardSingleMsgSchema,
1907
+ handle: (payload) => forwardSingleMsg(payload, api)
1908
+ })
2269
1909
  ];
2270
1910
  }
2271
1911
  // src/onebot11/action/message/history.ts
2272
1912
  /**
2273
- * 消息读取域动作(2026-11-14 自 get-msg / msg-history / get-group-msg-history /
2274
- * get-friend-msg-history 合并)
1913
+ * 消息读取域动作
2275
1914
  *
2276
1915
  * - get_msg:message_id → msgId + peer(MessageUnique 反查)→ 拉消息 → OB11 消息信息
2277
1916
  * - get_group_msg_history(go-cqhttp 扩展)/ get_friend_msg_history(NapCat 扩展):
2278
1917
  * 拉取历史消息 → at uid 批量转换 → OB11 消息信息数组(共享 fetchAndTranslateHistory)
2279
1918
  */
2280
1919
  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 (err) {
2298
- this.deps.logger?.warn({
2299
- count: atUids.length,
2300
- error: err instanceof Error ? err.message : String(err)
2301
- }, "ob11: get_msg at uid→uin 失败,at 原样");
2302
- }
2303
- const senderRole = msg.chatType === ChatType.GROUP ? await this.deps.groupMemberRole(msg.peerUid, msg.senderUid) : void 0;
2304
- const ctx = {
2305
- ...uidToUin !== void 0 ? { uidToUin } : {},
2306
- ...senderRole !== void 0 ? { senderRole } : {},
2307
- msgIdToOb11Id: (m) => this.deps.messageUnique.getMessageId(m)
2308
- };
2309
- return toOb11MessageInfo(msg, this.deps.messageUnique, ctx);
2310
- }
2311
- };
2312
1920
  /** 历史消息公共参数(message_seq / count / 反向排序)。 */
2313
1921
  const msgHistoryParamsSchema = {
2314
1922
  /** 起始消息序号(message_seq,缺省从最新拉)。 */
@@ -2328,7 +1936,7 @@ function resolveStartMsgId(messageSeq, messageUnique) {
2328
1936
  }
2329
1937
  /**
2330
1938
  * 拉取历史消息并翻译为 OB11 消息信息数组。
2331
- * 收集全部消息 at uid → 一次批量 uidToUin → 上下文注入(P2-19)。
1939
+ * 收集全部消息 at uid → 一次批量 uidToUin → 上下文注入。
2332
1940
  * 群聊另取发送者角色表(GroupCache 一次整表读取,失败回退缺省 member)。
2333
1941
  */
2334
1942
  async function fetchAndTranslateHistory(peer, messageSeq, count, deps) {
@@ -2369,65 +1977,71 @@ const getGroupMsgHistorySchema = z.object({
2369
1977
  group_id: z.number(),
2370
1978
  ...msgHistoryParamsSchema
2371
1979
  });
2372
- /** 获取群历史消息(P2-10 接 kernel fetchMessages)。 */
2373
- var GetGroupMsgHistoryAction = class extends BaseAction {
2374
- name = "get_group_msg_history";
2375
- schema = getGroupMsgHistorySchema;
2376
- errorCodeMap = ob11ErrorCodeMap;
2377
- deps;
2378
- constructor(deps) {
2379
- super();
2380
- this.deps = deps;
2381
- }
2382
- async _handle(payload) {
2383
- return await fetchAndTranslateHistory({
2384
- chatType: ChatType.GROUP,
2385
- peerUid: String(payload.group_id)
2386
- }, payload.message_seq, payload.count, this.deps);
2387
- }
2388
- };
2389
1980
  const getFriendMsgHistorySchema = z.object({
2390
1981
  user_id: z.number(),
2391
1982
  ...msgHistoryParamsSchema
2392
1983
  });
2393
- /** 获取私聊历史消息(P2-10 接 kernel fetchMessages)。 */
2394
- var GetFriendMsgHistoryAction = class extends BaseAction {
2395
- name = "get_friend_msg_history";
2396
- schema = getFriendMsgHistorySchema;
2397
- errorCodeMap = ob11ErrorCodeMap;
2398
- deps;
2399
- constructor(deps) {
2400
- super();
2401
- this.deps = deps;
2402
- }
2403
- async _handle(payload) {
2404
- const uid = await resolveUid(String(payload.user_id), this.deps.uinToUid);
2405
- return await fetchAndTranslateHistory({
2406
- chatType: ChatType.C2C,
2407
- peerUid: uid
2408
- }, payload.message_seq, payload.count, this.deps);
2409
- }
2410
- };
2411
1984
  /** 消息读取域动作工厂(get_msg / get_group_msg_history / get_friend_msg_history)。 */
2412
1985
  function createHistoryActions(api) {
2413
1986
  return [
2414
- new GetMsgAction(api),
2415
- new GetGroupMsgHistoryAction(api),
2416
- new GetFriendMsgHistoryAction(api)
1987
+ defineOb11Action({
1988
+ name: "get_msg",
1989
+ schema: getMsgSchema,
1990
+ handle: async (payload) => {
1991
+ const { msg } = await fetchMsgById(payload.message_id, api.messageUnique, api.msgApi);
1992
+ const { atUids } = collectReceiveNeeds(toCanonicalElements(msg));
1993
+ let uidToUin;
1994
+ if (atUids.length > 0) try {
1995
+ uidToUin = await api.uidToUin(atUids);
1996
+ } catch (err) {
1997
+ api.logger?.warn({
1998
+ count: atUids.length,
1999
+ error: err instanceof Error ? err.message : String(err)
2000
+ }, "ob11: get_msg at uid→uin 失败,at 原样");
2001
+ }
2002
+ const senderRole = msg.chatType === ChatType.GROUP ? await api.groupMemberRole(msg.peerUid, msg.senderUid) : void 0;
2003
+ const ctx = {
2004
+ ...uidToUin !== void 0 ? { uidToUin } : {},
2005
+ ...senderRole !== void 0 ? { senderRole } : {},
2006
+ msgIdToOb11Id: (m) => api.messageUnique.getMessageId(m)
2007
+ };
2008
+ return toOb11MessageInfo(msg, api.messageUnique, ctx);
2009
+ }
2010
+ }),
2011
+ defineOb11Action({
2012
+ name: "get_group_msg_history",
2013
+ schema: getGroupMsgHistorySchema,
2014
+ handle: async (payload) => {
2015
+ return await fetchAndTranslateHistory({
2016
+ chatType: ChatType.GROUP,
2017
+ peerUid: String(payload.group_id)
2018
+ }, payload.message_seq, payload.count, api);
2019
+ }
2020
+ }),
2021
+ defineOb11Action({
2022
+ name: "get_friend_msg_history",
2023
+ schema: getFriendMsgHistorySchema,
2024
+ handle: async (payload) => {
2025
+ const uid = await resolveUid(String(payload.user_id), api.uinToUid);
2026
+ return await fetchAndTranslateHistory({
2027
+ chatType: ChatType.C2C,
2028
+ peerUid: uid
2029
+ }, payload.message_seq, payload.count, api);
2030
+ }
2031
+ })
2417
2032
  ];
2418
2033
  }
2419
2034
  // src/onebot11/action/message/media.ts
2420
2035
  /**
2421
- * 消息媒体域动作(2026-11-14 自 get-media / fetch-ptt-text 合并)
2036
+ * 消息媒体域动作
2422
2037
  *
2423
- * - get_image / get_record:获取图片/语音文件(P2-14;2026-09-08 T5 接主动下载;
2424
- * 2026-09-08 B1 语音接原生 downloadRichMedia)。message_id 反查 → fetchMsgsByMsgId
2425
- * → 找 PIC/PTT 元素:
2038
+ * - get_image / get_record:获取图片/语音文件(图片接主动下载;语音接原生
2039
+ * downloadRichMedia)。message_id 反查 → fetchMsgsByMsgId → 找 PIC/PTT 元素:
2426
2040
  * - 本地文件解析:NT 相对路径(sourcePath/filePath)按 mediaBaseDir(QQ NT
2427
2041
  * global 目录)解析为绝对路径,命中磁盘即返回 file
2428
2042
  * - 图片主动下载:本地未命中且有 picUrl → @napuketto/media downloadUrl 落
2429
2043
  * cacheDir/media/,返回 file(绝对路径)+ url + file_size/file_name
2430
- * - 语音主动下载(B1):本地未命中 → kernel MsgApi.downloadPtt(原生
2044
+ * - 语音主动下载:本地未命中 → kernel MsgApi.downloadPtt(原生
2431
2045
  * downloadRichMedia + 轮询元素回查)→ filePath 落盘后返回绝对路径;
2432
2046
  * 失败回退原始 filePath(NT 相对/绝对)+ 元数据,不抛错
2433
2047
  * - fetch_ptt_text:message_id → MsgApi.fetchPttText(内部:拉消息 → 找 PTT 元素
@@ -2438,6 +2052,7 @@ const getMediaSchema = z.object({
2438
2052
  file: z.string().optional(),
2439
2053
  message_id: z.union([z.number(), z.string()]).optional()
2440
2054
  });
2055
+ const fetchPttTextSchema = z.object({ message_id: z.union([z.number(), z.string()]) });
2441
2056
  /**
2442
2057
  * NT 相对路径 → 本地绝对路径(存在才返回)。
2443
2058
  * 候选:原样绝对路径 / mediaBaseDir 下相对路径(反斜杠归一化)。
@@ -2491,119 +2106,95 @@ function takeId(payload, actionName) {
2491
2106
  if (id === void 0) throw kernelError(`${actionName} 需要 message_id 或 file`, "INVALID_PARAM");
2492
2107
  return id;
2493
2108
  }
2494
- /** 获取图片信息(本地优先,picUrl 主动下载兜底)。 */
2495
- var GetImageAction = class extends BaseAction {
2496
- name = "get_image";
2497
- schema = getMediaSchema;
2498
- errorCodeMap = ob11ErrorCodeMap;
2499
- deps;
2500
- constructor(deps) {
2501
- super();
2502
- this.deps = deps;
2503
- }
2504
- async _handle(payload) {
2505
- const base = await resolveMedia(takeId(payload, "get_image"), "图片", this.deps, (el) => {
2506
- const pic = el.picElement;
2507
- if (pic === void 0) return;
2508
- const out = {};
2509
- if (pic.fileSize !== void 0) out.file_size = pic.fileSize;
2510
- if (pic.fileName !== void 0) out.file_name = pic.fileName;
2511
- if (pic.picUrl !== void 0) out.url = pic.picUrl;
2512
- const rel = pic.sourcePath ?? pic.picPath;
2513
- if (rel !== void 0) {
2514
- const local = resolveLocalMediaFile(rel, this.deps);
2515
- if (local !== null) out.file = local;
2516
- }
2517
- return out;
2518
- });
2519
- if (base.file === void 0 && base.url !== void 0) {
2520
- const downloaded = await downloadImageToCache(base.url, this.deps);
2521
- if (downloaded !== null) base.file = downloaded;
2522
- }
2523
- return base;
2524
- }
2525
- };
2526
- /** 获取语音信息(本地优先;未命中走原生 downloadRichMedia,失败回退原始路径)。 */
2527
- var GetRecordAction = class extends BaseAction {
2528
- name = "get_record";
2529
- schema = getMediaSchema;
2530
- errorCodeMap = ob11ErrorCodeMap;
2531
- deps;
2532
- constructor(deps) {
2533
- super();
2534
- this.deps = deps;
2535
- }
2536
- async _handle(payload) {
2537
- const id = takeId(payload, "get_record");
2538
- const { msgId, peer } = resolveMsgIdAndPeer(id, this.deps.messageUnique);
2539
- const [first] = await this.deps.msgApi.fetchMsgsByMsgId(peer, [msgId]);
2540
- if (first === void 0) throw kernelError(`消息 ${id} 不存在或已被撤回`, "NOT_FOUND");
2541
- const ptt = first.elements.find((e) => e.pttElement !== void 0)?.pttElement;
2542
- if (ptt === void 0 || ptt.filePath === void 0) throw kernelError(`消息 ${id} 不包含语音`, "NOT_FOUND");
2543
- const meta = () => ({
2544
- ...ptt.fileSize !== void 0 ? { file_size: ptt.fileSize } : {},
2545
- ...ptt.fileName !== void 0 ? { file_name: ptt.fileName } : {}
2546
- });
2547
- const local = resolveLocalMediaFile(ptt.filePath, this.deps);
2548
- if (local !== null) return {
2549
- ...meta(),
2550
- file: local
2551
- };
2552
- return await this.downloadPttFallback(msgId, peer, id) ?? {
2553
- ...meta(),
2554
- file: ptt.filePath
2555
- };
2109
+ /** 提取 pic 元素 → 媒体信息(url / 本地 file / 元数据;非 pic 元素返回 undefined)。 */
2110
+ function extractPicElement(el, deps) {
2111
+ const pic = el.picElement;
2112
+ if (pic === void 0) return;
2113
+ const out = {};
2114
+ if (pic.fileSize !== void 0) out.file_size = pic.fileSize;
2115
+ if (pic.fileName !== void 0) out.file_name = pic.fileName;
2116
+ if (pic.picUrl !== void 0) out.url = pic.picUrl;
2117
+ const rel = pic.sourcePath ?? pic.picPath;
2118
+ if (rel !== void 0) {
2119
+ const local = resolveLocalMediaFile(rel, deps);
2120
+ if (local !== null) out.file = local;
2556
2121
  }
2557
- /** 原生下载语音 → 元素回查本地路径;下载失败/未命中 null(warn 留痕,不抛错)。 */
2558
- async downloadPttFallback(msgId, peer, id) {
2559
- try {
2560
- const downloaded = await this.deps.msgApi.downloadPtt(msgId, peer);
2561
- const rel = downloaded.filePath;
2562
- if (rel !== void 0 && rel !== "") {
2563
- const localAfter = resolveLocalMediaFile(rel, this.deps);
2564
- if (localAfter !== null) return {
2565
- ...downloaded.fileSize !== void 0 ? { file_size: downloaded.fileSize } : {},
2566
- ...downloaded.fileName !== void 0 ? { file_name: downloaded.fileName } : {},
2567
- file: localAfter
2568
- };
2569
- }
2570
- } catch (err) {
2571
- this.deps.logger?.warn({
2572
- message_id: id,
2573
- error: err instanceof Error ? err.message : String(err)
2574
- }, "ob11: 语音原生下载失败,get_record 回退原始路径");
2122
+ return out;
2123
+ }
2124
+ /** 原生下载语音 → 元素回查本地路径;下载失败/未命中 null(warn 留痕,不抛错)。 */
2125
+ async function downloadPttFallback(msgId, peer, id, deps) {
2126
+ try {
2127
+ const downloaded = await deps.msgApi.downloadPtt(msgId, peer);
2128
+ const rel = downloaded.filePath;
2129
+ if (rel !== void 0 && rel !== "") {
2130
+ const localAfter = resolveLocalMediaFile(rel, deps);
2131
+ if (localAfter !== null) return {
2132
+ ...downloaded.fileSize !== void 0 ? { file_size: downloaded.fileSize } : {},
2133
+ ...downloaded.fileName !== void 0 ? { file_name: downloaded.fileName } : {},
2134
+ file: localAfter
2135
+ };
2575
2136
  }
2576
- return null;
2577
- }
2578
- };
2579
- const fetchPttTextSchema = z.object({ message_id: z.union([z.number(), z.string()]) });
2580
- /** 获取语音转文字结果(P2-10 接 kernel fetchPttText)。 */
2581
- var FetchPttTextAction = class extends BaseAction {
2582
- name = "fetch_ptt_text";
2583
- schema = fetchPttTextSchema;
2584
- errorCodeMap = ob11ErrorCodeMap;
2585
- deps;
2586
- constructor(deps) {
2587
- super();
2588
- this.deps = deps;
2589
- }
2590
- async _handle(payload) {
2591
- const { msgId, peer } = resolveMsgIdAndPeer(payload.message_id, this.deps.messageUnique);
2592
- return { text: await this.deps.msgApi.fetchPttText(msgId, peer) };
2137
+ } catch (err) {
2138
+ deps.logger?.warn({
2139
+ message_id: id,
2140
+ error: err instanceof Error ? err.message : String(err)
2141
+ }, "ob11: 语音原生下载失败,get_record 回退原始路径");
2593
2142
  }
2594
- };
2143
+ return null;
2144
+ }
2595
2145
  /** 消息媒体域动作工厂(get_image / get_record / fetch_ptt_text)。 */
2596
2146
  function createMediaActions(api) {
2597
2147
  return [
2598
- new GetImageAction(api),
2599
- new GetRecordAction(api),
2600
- new FetchPttTextAction(api)
2601
- ];
2602
- }
2603
- // src/onebot11/action/message/ops.ts
2148
+ defineOb11Action({
2149
+ name: "get_image",
2150
+ schema: getMediaSchema,
2151
+ handle: async (payload) => {
2152
+ const base = await resolveMedia(takeId(payload, "get_image"), "图片", api, (el) => extractPicElement(el, api));
2153
+ if (base.file === void 0 && base.url !== void 0) {
2154
+ const downloaded = await downloadImageToCache(base.url, api);
2155
+ if (downloaded !== null) base.file = downloaded;
2156
+ }
2157
+ return base;
2158
+ }
2159
+ }),
2160
+ defineOb11Action({
2161
+ name: "get_record",
2162
+ schema: getMediaSchema,
2163
+ handle: async (payload) => {
2164
+ const id = takeId(payload, "get_record");
2165
+ const { msgId, peer } = resolveMsgIdAndPeer(id, api.messageUnique);
2166
+ const [first] = await api.msgApi.fetchMsgsByMsgId(peer, [msgId]);
2167
+ if (first === void 0) throw kernelError(`消息 ${id} 不存在或已被撤回`, "NOT_FOUND");
2168
+ const ptt = first.elements.find((e) => e.pttElement !== void 0)?.pttElement;
2169
+ if (ptt === void 0 || ptt.filePath === void 0) throw kernelError(`消息 ${id} 不包含语音`, "NOT_FOUND");
2170
+ const meta = () => ({
2171
+ ...ptt.fileSize !== void 0 ? { file_size: ptt.fileSize } : {},
2172
+ ...ptt.fileName !== void 0 ? { file_name: ptt.fileName } : {}
2173
+ });
2174
+ const local = resolveLocalMediaFile(ptt.filePath, api);
2175
+ if (local !== null) return {
2176
+ ...meta(),
2177
+ file: local
2178
+ };
2179
+ return await downloadPttFallback(msgId, peer, id, api) ?? {
2180
+ ...meta(),
2181
+ file: ptt.filePath
2182
+ };
2183
+ }
2184
+ }),
2185
+ defineOb11Action({
2186
+ name: "fetch_ptt_text",
2187
+ schema: fetchPttTextSchema,
2188
+ handle: async (payload) => {
2189
+ const { msgId, peer } = resolveMsgIdAndPeer(payload.message_id, api.messageUnique);
2190
+ return { text: await api.msgApi.fetchPttText(msgId, peer) };
2191
+ }
2192
+ })
2193
+ ];
2194
+ }
2195
+ // src/onebot11/action/message/ops.ts
2604
2196
  /**
2605
- * 消息操作域动作(2026-11-14 自 delete-msg / mark-msg-as-read(-aliases) /
2606
- * set-msg-emoji-like / set-input-status 合并)
2197
+ * 消息操作域动作
2607
2198
  *
2608
2199
  * - delete_msg:撤回消息(OB11 标准只有 message_id,peer 经 MessageUnique 反查;
2609
2200
  * 群聊管理员 / 私聊 2 分钟内可撤回)
@@ -2613,93 +2204,12 @@ function createMediaActions(api) {
2613
2204
  * - set_input_status:user_id → uinToUid → MsgApi.setInputStatus(1=输入中,0=停止)
2614
2205
  */
2615
2206
  const deleteMsgSchema = z.object({ message_id: z.union([z.number(), z.string()]) });
2616
- /** 撤回消息(P2-10 接 kernel recallMessage)。 */
2617
- var DeleteMsgAction = class extends BaseAction {
2618
- name = "delete_msg";
2619
- schema = deleteMsgSchema;
2620
- errorCodeMap = ob11ErrorCodeMap;
2621
- deps;
2622
- constructor(deps) {
2623
- super();
2624
- this.deps = deps;
2625
- }
2626
- async _handle(payload) {
2627
- const { msgId, peer } = resolveMsgIdAndPeer(payload.message_id, this.deps.messageUnique);
2628
- await this.deps.msgApi.recallMessage(peer, [msgId]);
2629
- return null;
2630
- }
2631
- };
2632
2207
  const markMsgAsReadSchema = z.object({
2633
2208
  user_id: z.number().optional(),
2634
2209
  group_id: z.number().optional()
2635
2210
  }).refine((v) => v.user_id !== void 0 || v.group_id !== void 0, { message: "mark_msg_as_read 需要 user_id 或 group_id" });
2636
- /** 标记消息已读(P2-10 接 kernel markRead)。 */
2637
- var MarkMsgAsReadAction = class extends BaseAction {
2638
- name = "mark_msg_as_read";
2639
- schema = markMsgAsReadSchema;
2640
- errorCodeMap = ob11ErrorCodeMap;
2641
- deps;
2642
- constructor(deps) {
2643
- super();
2644
- this.deps = deps;
2645
- }
2646
- async _handle(payload) {
2647
- if (payload.group_id !== void 0) {
2648
- await this.deps.msgApi.markRead({
2649
- chatType: ChatType.GROUP,
2650
- peerUid: String(payload.group_id)
2651
- });
2652
- return null;
2653
- }
2654
- if (payload.user_id !== void 0) {
2655
- const uid = await resolveUid(String(payload.user_id), this.deps.uinToUid);
2656
- await this.deps.msgApi.markRead({
2657
- chatType: ChatType.C2C,
2658
- peerUid: uid
2659
- });
2660
- }
2661
- return null;
2662
- }
2663
- };
2664
2211
  const markPrivateMsgAsReadSchema = z.object({ user_id: z.number() });
2665
2212
  const markGroupMsgAsReadSchema = z.object({ group_id: z.number() });
2666
- /** 标记私聊已读(P2-13)。 */
2667
- var MarkPrivateMsgAsReadAction = class extends BaseAction {
2668
- name = "mark_private_msg_as_read";
2669
- schema = markPrivateMsgAsReadSchema;
2670
- errorCodeMap = ob11ErrorCodeMap;
2671
- deps;
2672
- constructor(deps) {
2673
- super();
2674
- this.deps = deps;
2675
- }
2676
- async _handle(payload) {
2677
- const uid = await resolveUid(String(payload.user_id), this.deps.uinToUid);
2678
- await this.deps.msgApi.markRead({
2679
- chatType: ChatType.C2C,
2680
- peerUid: uid
2681
- });
2682
- return null;
2683
- }
2684
- };
2685
- /** 标记群聊已读(P2-13)。 */
2686
- var MarkGroupMsgAsReadAction = class extends BaseAction {
2687
- name = "mark_group_msg_as_read";
2688
- schema = markGroupMsgAsReadSchema;
2689
- errorCodeMap = ob11ErrorCodeMap;
2690
- deps;
2691
- constructor(deps) {
2692
- super();
2693
- this.deps = deps;
2694
- }
2695
- async _handle(payload) {
2696
- await this.deps.msgApi.markRead({
2697
- chatType: ChatType.GROUP,
2698
- peerUid: String(payload.group_id)
2699
- });
2700
- return null;
2701
- }
2702
- };
2703
2213
  const setMsgEmojiLikeSchema = z.object({
2704
2214
  message_id: z.union([z.number(), z.string()]),
2705
2215
  /** 表情 ID(如 105 点赞)。 */
@@ -2709,27 +2219,6 @@ const setMsgEmojiLikeSchema = z.object({
2709
2219
  /** 是否点赞(false 取消)。 */
2710
2220
  like: z.boolean().optional()
2711
2221
  });
2712
- /** 消息表情表态(P2-10 接 kernel setMsgEmojiLike)。 */
2713
- var SetMsgEmojiLikeAction = class extends BaseAction {
2714
- name = "set_msg_emoji_like";
2715
- schema = setMsgEmojiLikeSchema;
2716
- errorCodeMap = ob11ErrorCodeMap;
2717
- deps;
2718
- constructor(deps) {
2719
- super();
2720
- this.deps = deps;
2721
- }
2722
- async _handle(payload) {
2723
- const { msg, peer } = await fetchMsgById(payload.message_id, this.deps.messageUnique, this.deps.msgApi);
2724
- await this.deps.msgApi.setMsgEmojiLike(peer, {
2725
- msgSeq: msg.msgSeq,
2726
- emojiId: String(payload.emoji_id),
2727
- emojiType: String(payload.emoji_type ?? 1),
2728
- like: payload.like ?? true
2729
- });
2730
- return null;
2731
- }
2732
- };
2733
2222
  const setInputStatusSchema = z.object({
2734
2223
  user_id: z.number(),
2735
2224
  /** 输入事件类型:1=输入中,0=停止。 */
@@ -2737,37 +2226,91 @@ const setInputStatusSchema = z.object({
2737
2226
  });
2738
2227
  /** 输入中事件类型。 */
2739
2228
  const EVENT_TYPE_TYPING = 1;
2740
- /** 发送输入状态(P2-11 接 kernel setInputStatus)。 */
2741
- var SetInputStatusAction = class extends BaseAction {
2742
- name = "set_input_status";
2743
- schema = setInputStatusSchema;
2744
- errorCodeMap = ob11ErrorCodeMap;
2745
- deps;
2746
- constructor(deps) {
2747
- super();
2748
- this.deps = deps;
2749
- }
2750
- async _handle(payload) {
2751
- const uid = await resolveUid(String(payload.user_id), this.deps.uinToUid);
2752
- await this.deps.msgApi.setInputStatus({
2753
- chatType: ChatType.C2C,
2754
- peerUid: uid
2755
- }, payload.event_type ?? EVENT_TYPE_TYPING);
2756
- return null;
2757
- }
2758
- };
2759
2229
  /**
2760
2230
  * 消息操作域动作工厂(delete_msg / mark_msg_as_read 系列 / set_msg_emoji_like /
2761
2231
  * set_input_status)。
2762
2232
  */
2763
2233
  function createMsgOpsActions(api) {
2764
2234
  return [
2765
- new DeleteMsgAction(api),
2766
- new MarkMsgAsReadAction(api),
2767
- new MarkPrivateMsgAsReadAction(api),
2768
- new MarkGroupMsgAsReadAction(api),
2769
- new SetMsgEmojiLikeAction(api),
2770
- new SetInputStatusAction(api)
2235
+ defineOb11Action({
2236
+ name: "delete_msg",
2237
+ schema: deleteMsgSchema,
2238
+ handle: async (payload) => {
2239
+ const { msgId, peer } = resolveMsgIdAndPeer(payload.message_id, api.messageUnique);
2240
+ await api.msgApi.recallMessage(peer, [msgId]);
2241
+ return null;
2242
+ }
2243
+ }),
2244
+ defineOb11Action({
2245
+ name: "mark_msg_as_read",
2246
+ schema: markMsgAsReadSchema,
2247
+ handle: async (payload) => {
2248
+ if (payload.group_id !== void 0) {
2249
+ await api.msgApi.markRead({
2250
+ chatType: ChatType.GROUP,
2251
+ peerUid: String(payload.group_id)
2252
+ });
2253
+ return null;
2254
+ }
2255
+ if (payload.user_id !== void 0) {
2256
+ const uid = await resolveUid(String(payload.user_id), api.uinToUid);
2257
+ await api.msgApi.markRead({
2258
+ chatType: ChatType.C2C,
2259
+ peerUid: uid
2260
+ });
2261
+ }
2262
+ return null;
2263
+ }
2264
+ }),
2265
+ defineOb11Action({
2266
+ name: "mark_private_msg_as_read",
2267
+ schema: markPrivateMsgAsReadSchema,
2268
+ handle: async (payload) => {
2269
+ const uid = await resolveUid(String(payload.user_id), api.uinToUid);
2270
+ await api.msgApi.markRead({
2271
+ chatType: ChatType.C2C,
2272
+ peerUid: uid
2273
+ });
2274
+ return null;
2275
+ }
2276
+ }),
2277
+ defineOb11Action({
2278
+ name: "mark_group_msg_as_read",
2279
+ schema: markGroupMsgAsReadSchema,
2280
+ handle: async (payload) => {
2281
+ await api.msgApi.markRead({
2282
+ chatType: ChatType.GROUP,
2283
+ peerUid: String(payload.group_id)
2284
+ });
2285
+ return null;
2286
+ }
2287
+ }),
2288
+ defineOb11Action({
2289
+ name: "set_msg_emoji_like",
2290
+ schema: setMsgEmojiLikeSchema,
2291
+ handle: async (payload) => {
2292
+ const { msg, peer } = await fetchMsgById(payload.message_id, api.messageUnique, api.msgApi);
2293
+ await api.msgApi.setMsgEmojiLike(peer, {
2294
+ msgSeq: msg.msgSeq,
2295
+ emojiId: String(payload.emoji_id),
2296
+ emojiType: String(payload.emoji_type ?? 1),
2297
+ like: payload.like ?? true
2298
+ });
2299
+ return null;
2300
+ }
2301
+ }),
2302
+ defineOb11Action({
2303
+ name: "set_input_status",
2304
+ schema: setInputStatusSchema,
2305
+ handle: async (payload) => {
2306
+ const uid = await resolveUid(String(payload.user_id), api.uinToUid);
2307
+ await api.msgApi.setInputStatus({
2308
+ chatType: ChatType.C2C,
2309
+ peerUid: uid
2310
+ }, payload.event_type ?? EVENT_TYPE_TYPING);
2311
+ return null;
2312
+ }
2313
+ })
2771
2314
  ];
2772
2315
  }
2773
2316
  // src/onebot11/action/message/send.ts
@@ -2778,6 +2321,19 @@ const sendMsgSchema = z.object({
2778
2321
  message: z.union([z.string(), z.array(z.unknown()).max(200)]),
2779
2322
  auto_escape: z.boolean().optional()
2780
2323
  });
2324
+ /** send_private / send_group 共用的消息与转义字段(上界见 action/limits.ts)。 */
2325
+ const sendMsgBodyFields = {
2326
+ message: z.union([z.string(), z.array(z.unknown()).max(200)]),
2327
+ auto_escape: z.boolean().optional()
2328
+ };
2329
+ const sendPrivateMsgSchema = z.object({
2330
+ user_id: z.number(),
2331
+ ...sendMsgBodyFields
2332
+ });
2333
+ const sendGroupMsgSchema = z.object({
2334
+ group_id: z.number(),
2335
+ ...sendMsgBodyFields
2336
+ });
2781
2337
  /** 共享发送核心:解析 Peer → canonical 翻译(含 auto_escape)→ sendMessage → 映射 message_id。 */
2782
2338
  async function sendOb11Message(payload, deps) {
2783
2339
  const peer = await resolveTargetPeer(payload, deps, "send_msg 需要 group_id 或 user_id");
@@ -2815,58 +2371,6 @@ async function sendOb11Message(payload, deps) {
2815
2371
  await prepared.cleanup();
2816
2372
  }
2817
2373
  }
2818
- /** 发送消息(P2-3 接 kernel apis/msg,返回真实 message_id)。 */
2819
- var SendMsgAction = class extends BaseAction {
2820
- name = "send_msg";
2821
- schema = sendMsgSchema;
2822
- errorCodeMap = ob11ErrorCodeMap;
2823
- deps;
2824
- constructor(deps) {
2825
- super();
2826
- this.deps = deps;
2827
- }
2828
- _handle(payload) {
2829
- return sendOb11Message(payload, this.deps);
2830
- }
2831
- };
2832
- const sendPrivateMsgSchema = z.object({
2833
- user_id: z.number(),
2834
- message: z.union([z.string(), z.array(z.unknown()).max(200)]),
2835
- auto_escape: z.boolean().optional()
2836
- });
2837
- /** 发送私聊消息(P2-10 复用 sendOb11Message)。 */
2838
- var SendPrivateMsgAction = class extends BaseAction {
2839
- name = "send_private_msg";
2840
- schema = sendPrivateMsgSchema;
2841
- errorCodeMap = ob11ErrorCodeMap;
2842
- deps;
2843
- constructor(deps) {
2844
- super();
2845
- this.deps = deps;
2846
- }
2847
- _handle(payload) {
2848
- return sendOb11Message(payload, this.deps);
2849
- }
2850
- };
2851
- const sendGroupMsgSchema = z.object({
2852
- group_id: z.number(),
2853
- message: z.union([z.string(), z.array(z.unknown()).max(200)]),
2854
- auto_escape: z.boolean().optional()
2855
- });
2856
- /** 发送群聊消息(P2-10 复用 sendOb11Message)。 */
2857
- var SendGroupMsgAction = class extends BaseAction {
2858
- name = "send_group_msg";
2859
- schema = sendGroupMsgSchema;
2860
- errorCodeMap = ob11ErrorCodeMap;
2861
- deps;
2862
- constructor(deps) {
2863
- super();
2864
- this.deps = deps;
2865
- }
2866
- _handle(payload) {
2867
- return sendOb11Message(payload, this.deps);
2868
- }
2869
- };
2870
2374
  /** CQ 特殊字符转义(auto_escape,&、[、]、, 前置 &)。 */
2871
2375
  function escapeText(text) {
2872
2376
  return text.replaceAll("&", "&").replaceAll("[", "[").replaceAll("]", "]").replaceAll(",", ",");
@@ -2883,203 +2387,158 @@ async function ensureVoiceSilk(elements, logger) {
2883
2387
  }
2884
2388
  /** 消息发送域动作工厂(send_msg / send_private_msg / send_group_msg)。 */
2885
2389
  function createSendActions(api) {
2390
+ const deps = api;
2886
2391
  return [
2887
- new SendMsgAction(api),
2888
- new SendPrivateMsgAction(api),
2889
- new SendGroupMsgAction(api)
2392
+ defineOb11Action({
2393
+ name: "send_msg",
2394
+ schema: sendMsgSchema,
2395
+ handle: (payload) => sendOb11Message(payload, deps)
2396
+ }),
2397
+ defineOb11Action({
2398
+ name: "send_private_msg",
2399
+ schema: sendPrivateMsgSchema,
2400
+ handle: (payload) => sendOb11Message(payload, deps)
2401
+ }),
2402
+ defineOb11Action({
2403
+ name: "send_group_msg",
2404
+ schema: sendGroupMsgSchema,
2405
+ handle: (payload) => sendOb11Message(payload, deps)
2406
+ })
2890
2407
  ];
2891
2408
  }
2892
2409
  // src/onebot11/action/system/account.ts
2893
2410
  /**
2894
- * 账号票据与资料域动作(2026-11-14 自 get-cookies / get-clientkey /
2895
- * get-credentials / profile-actions 合并)
2411
+ * 账号票据与资料域动作
2896
2412
  *
2897
- * - get_cookies(P2-13):kernel TicketApi.getCookies,domain 缺省 v2.qq.com
2413
+ * - get_cookies:kernel TicketApi.getCookies,domain 缺省 v2.qq.com
2898
2414
  * (NapCat 行为);user_id 缺省用机器人自身 uin
2899
- * - get_clientkey(P2-13):kernel TicketApi.getClientKey
2900
- * - get_csrf_token / get_credentials(P2-15):qun.qq.com cookies 的 skey → bkn
2415
+ * - get_clientkey:kernel TicketApi.getClientKey
2416
+ * - get_csrf_token / get_credentials:qun.qq.com cookies 的 skey → bkn
2901
2417
  * (csrf 等价物);get_credentials 返回指定域名 cookies + bkn
2902
- * - set_self_longnick / set_qq_profile / set_qq_avatar(P2-14):kernel ProfileApi;
2418
+ * - set_self_longnick / set_qq_profile / set_qq_avatar:kernel ProfileApi;
2903
2419
  * set_qq_profile 的 sex 忽略,头像 URL 需先经 cacheDir 下载
2904
2420
  */
2905
2421
  /** URL 前缀(头像在线文件识别)。 */
2906
2422
  const URL_PREFIX = /^https?:\/\//;
2423
+ /** 默认域名。 */
2424
+ const DEFAULT_DOMAIN = "v2.qq.com";
2425
+ /** 默认域名(bkn 计算用)。 */
2426
+ const BKN_DOMAIN = "qun.qq.com";
2907
2427
  const getCookiesSchema = z.object({
2908
2428
  domain: z.string().optional(),
2909
2429
  user_id: z.number().optional()
2910
2430
  });
2911
- /** 默认域名。 */
2912
- const DEFAULT_DOMAIN = "v2.qq.com";
2913
- /** 获取 cookies(P2-13 接 kernel TicketApi.getCookies)。 */
2914
- var GetCookiesAction = class extends BaseAction {
2915
- name = "get_cookies";
2916
- schema = getCookiesSchema;
2917
- errorCodeMap = ob11ErrorCodeMap;
2918
- deps;
2919
- constructor(deps) {
2920
- super();
2921
- this.deps = deps;
2922
- }
2923
- _handle(payload) {
2924
- const domain = payload.domain ?? DEFAULT_DOMAIN;
2925
- let uin = this.deps.selfUin;
2926
- if (payload.user_id !== void 0) uin = String(payload.user_id);
2927
- return this.deps.ticketApi.getCookies(domain, uin);
2928
- }
2929
- };
2930
2431
  const getClientkeySchema = z.object({});
2931
- /** 获取 clientKey(P2-13 接 kernel TicketApi)。 */
2932
- var GetClientkeyAction = class extends BaseAction {
2933
- name = "get_clientkey";
2934
- schema = getClientkeySchema;
2935
- errorCodeMap = ob11ErrorCodeMap;
2936
- ticketApi;
2937
- constructor(ticketApi) {
2938
- super();
2939
- this.ticketApi = ticketApi;
2940
- }
2941
- async _handle(_payload) {
2942
- const raw = await this.ticketApi.getClientKey();
2943
- return {
2944
- clientKey: raw.clientKey,
2945
- keyIndex: raw.keyIndex,
2946
- expireTime: raw.expireTime,
2947
- url: raw.url
2948
- };
2949
- }
2950
- };
2951
2432
  const getCsrfTokenSchema = z.object({});
2952
- /** 默认域名(bkn 计算用)。 */
2953
- const BKN_DOMAIN = "qun.qq.com";
2954
- /** 获取 csrf_token(bkn,P2-15)。 */
2955
- var GetCsrfTokenAction = class extends BaseAction {
2956
- name = "get_csrf_token";
2957
- schema = getCsrfTokenSchema;
2958
- errorCodeMap = ob11ErrorCodeMap;
2959
- deps;
2960
- constructor(deps) {
2961
- super();
2962
- this.deps = deps;
2963
- }
2964
- async _handle(_payload) {
2965
- const skey = (await this.deps.ticketApi.getCookies(BKN_DOMAIN, this.deps.selfUin))["skey"] ?? "";
2966
- return { token: Number(TicketApi.getBkn(skey)) };
2967
- }
2968
- };
2969
2433
  const getCredentialsSchema = z.object({ domain: z.string().optional() });
2970
- /** 获取凭据(cookies + csrf_token,P2-15)。 */
2971
- var GetCredentialsAction = class extends BaseAction {
2972
- name = "get_credentials";
2973
- schema = getCredentialsSchema;
2974
- errorCodeMap = ob11ErrorCodeMap;
2975
- deps;
2976
- constructor(deps) {
2977
- super();
2978
- this.deps = deps;
2979
- }
2980
- async _handle(payload) {
2981
- const domain = payload.domain ?? BKN_DOMAIN;
2982
- const cookies = await this.deps.ticketApi.getCookies(domain, this.deps.selfUin);
2983
- return {
2984
- cookies,
2985
- csrf_token: Number(TicketApi.getBkn(cookies["skey"] ?? ""))
2986
- };
2987
- }
2988
- };
2989
2434
  const setSelfLongnickSchema = z.object({ longNick: z.string() });
2990
- /** 设置个性签名(P2-14 接 kernel ProfileApi.setLongNick)。 */
2991
- var SetSelfLongnickAction = class extends BaseAction {
2992
- name = "set_self_longnick";
2993
- schema = setSelfLongnickSchema;
2994
- errorCodeMap = ob11ErrorCodeMap;
2995
- profileApi;
2996
- constructor(profileApi) {
2997
- super();
2998
- this.profileApi = profileApi;
2999
- }
3000
- async _handle(payload) {
3001
- await this.profileApi.setLongNick(payload.longNick);
3002
- return null;
3003
- }
3004
- };
3005
2435
  const setQQProfileSchema = z.object({
3006
2436
  nickname: z.string(),
3007
2437
  personal_note: z.string().optional(),
3008
2438
  sex: z.union([z.number(), z.string()]).optional()
3009
2439
  });
3010
- /** 设置 QQ 资料(P2-14;nickname → setNickName,personal_note → setLongNick,sex 忽略)。 */
3011
- var SetQQProfileAction = class extends BaseAction {
3012
- name = "set_qq_profile";
3013
- schema = setQQProfileSchema;
3014
- errorCodeMap = ob11ErrorCodeMap;
3015
- profileApi;
3016
- constructor(profileApi) {
3017
- super();
3018
- this.profileApi = profileApi;
3019
- }
3020
- async _handle(payload) {
3021
- await this.profileApi.setNickName(payload.nickname);
3022
- if (payload.personal_note !== void 0) await this.profileApi.setLongNick(payload.personal_note);
3023
- return null;
3024
- }
3025
- };
3026
2440
  const setQQAvatarSchema = z.object({
3027
2441
  /** 本地路径(URL 需先下载,由装配方 cacheDir 支持)。 */
3028
2442
  file: z.string() });
3029
- /** 设置 QQ 头像(P2-14 接 kernel ProfileApi.setHeader)。 */
3030
- var SetQQAvatarAction = class extends BaseAction {
3031
- name = "set_qq_avatar";
3032
- schema = setQQAvatarSchema;
3033
- errorCodeMap = ob11ErrorCodeMap;
3034
- deps;
3035
- constructor(deps) {
3036
- super();
3037
- this.deps = deps;
3038
- }
3039
- async _handle(payload) {
3040
- let filePath = payload.file;
3041
- if (URL_PREFIX.test(filePath)) filePath = await this.downloadToCache(filePath);
3042
- if (!existsSync(filePath)) throw kernelError(`头像文件不存在: ${filePath}`, "NOT_FOUND");
3043
- await this.deps.profileApi.setHeader(filePath);
3044
- return null;
3045
- }
3046
- /** URL 下载到缓存目录(cacheDir 缺省抛错)。 */
3047
- async downloadToCache(url) {
3048
- const { cacheDir } = this.deps;
3049
- if (cacheDir === void 0 || cacheDir === "") throw kernelError("set_qq_avatar 处理 URL 需要缓存目录(装配方未注入)", "INVALID_STATE");
3050
- const safeName = basename(new URL(url).pathname) || "avatar.bin";
3051
- const filePath = join(cacheDir, `avatar-${Date.now()}-${safeName}`);
3052
- const res = await fetch(url);
3053
- if (!res.ok) throw new Error(`头像下载失败: ${res.status} ${res.statusText}`);
3054
- const buf = new Uint8Array(await res.arrayBuffer());
3055
- writeFileSync(filePath, buf);
3056
- return filePath;
3057
- }
3058
- };
2443
+ /** URL 头像下载到缓存目录(cacheDir 缺省抛错)。 */
2444
+ async function downloadAvatarToCache(url, cacheDir) {
2445
+ if (cacheDir === void 0 || cacheDir === "") throw kernelError("set_qq_avatar 处理 URL 需要缓存目录(装配方未注入)", "INVALID_STATE");
2446
+ const safeName = basename(new URL(url).pathname) || "avatar.bin";
2447
+ const filePath = join(cacheDir, `avatar-${Date.now()}-${safeName}`);
2448
+ const res = await fetch(url);
2449
+ if (!res.ok) throw new Error(`头像下载失败: ${res.status} ${res.statusText}`);
2450
+ const buf = new Uint8Array(await res.arrayBuffer());
2451
+ writeFileSync(filePath, buf);
2452
+ return filePath;
2453
+ }
3059
2454
  /**
3060
2455
  * 账号票据与资料域动作工厂(cookies / clientkey / csrf_token / credentials /
3061
2456
  * self_longnick / qq_profile / qq_avatar)。
3062
2457
  */
3063
2458
  function createSystemAccountActions(api) {
3064
2459
  return [
3065
- new GetClientkeyAction(api.ticketApi),
3066
- new GetCookiesAction(api),
3067
- new GetCsrfTokenAction(api),
3068
- new GetCredentialsAction(api),
3069
- new SetSelfLongnickAction(api.profileApi),
3070
- new SetQQProfileAction(api.profileApi),
3071
- new SetQQAvatarAction(api)
2460
+ defineOb11Action({
2461
+ name: "get_clientkey",
2462
+ schema: getClientkeySchema,
2463
+ handle: async () => {
2464
+ const raw = await api.ticketApi.getClientKey();
2465
+ return {
2466
+ clientKey: raw.clientKey,
2467
+ keyIndex: raw.keyIndex,
2468
+ expireTime: raw.expireTime,
2469
+ url: raw.url
2470
+ };
2471
+ }
2472
+ }),
2473
+ defineOb11Action({
2474
+ name: "get_cookies",
2475
+ schema: getCookiesSchema,
2476
+ handle: (payload) => {
2477
+ const domain = payload.domain ?? DEFAULT_DOMAIN;
2478
+ let uin = api.selfUin;
2479
+ if (payload.user_id !== void 0) uin = String(payload.user_id);
2480
+ return api.ticketApi.getCookies(domain, uin);
2481
+ }
2482
+ }),
2483
+ defineOb11Action({
2484
+ name: "get_csrf_token",
2485
+ schema: getCsrfTokenSchema,
2486
+ handle: async () => {
2487
+ const skey = (await api.ticketApi.getCookies(BKN_DOMAIN, api.selfUin))["skey"] ?? "";
2488
+ return { token: Number(TicketApi.getBkn(skey)) };
2489
+ }
2490
+ }),
2491
+ defineOb11Action({
2492
+ name: "get_credentials",
2493
+ schema: getCredentialsSchema,
2494
+ handle: async (payload) => {
2495
+ const domain = payload.domain ?? BKN_DOMAIN;
2496
+ const cookies = await api.ticketApi.getCookies(domain, api.selfUin);
2497
+ return {
2498
+ cookies,
2499
+ csrf_token: Number(TicketApi.getBkn(cookies["skey"] ?? ""))
2500
+ };
2501
+ }
2502
+ }),
2503
+ defineOb11Action({
2504
+ name: "set_self_longnick",
2505
+ schema: setSelfLongnickSchema,
2506
+ handle: async (payload) => {
2507
+ await api.profileApi.setLongNick(payload.longNick);
2508
+ return null;
2509
+ }
2510
+ }),
2511
+ defineOb11Action({
2512
+ name: "set_qq_profile",
2513
+ schema: setQQProfileSchema,
2514
+ handle: async (payload) => {
2515
+ await api.profileApi.setNickName(payload.nickname);
2516
+ if (payload.personal_note !== void 0) await api.profileApi.setLongNick(payload.personal_note);
2517
+ return null;
2518
+ }
2519
+ }),
2520
+ defineOb11Action({
2521
+ name: "set_qq_avatar",
2522
+ schema: setQQAvatarSchema,
2523
+ handle: async (payload) => {
2524
+ let filePath = payload.file;
2525
+ if (URL_PREFIX.test(filePath)) filePath = await downloadAvatarToCache(filePath, api.cacheDir);
2526
+ if (!existsSync(filePath)) throw kernelError(`头像文件不存在: ${filePath}`, "NOT_FOUND");
2527
+ await api.profileApi.setHeader(filePath);
2528
+ return null;
2529
+ }
2530
+ })
3072
2531
  ];
3073
2532
  }
3074
2533
  // src/onebot11/action/system/file.ts
3075
2534
  /**
3076
- * 文件收发域动作(2026-11-14 自 system/download-file 与根部 upload-file 合并)
2535
+ * 文件收发域动作
3077
2536
  *
3078
- * - download_file(P2-12):url → fetch 下载 → 存 cacheDir(缺省抛错)→ 返回
2537
+ * - download_file:url → fetch 下载 → 存 cacheDir(缺省抛错)→ 返回
3079
2538
  * { file }。文件名:download-<timestamp>-<basename>(headers 等扩展字段忽略)
3080
2539
  * - upload_group_file / upload_private_file——**闪传通道**
3081
2540
  *
3082
- * ⚠️ 语义降级(2026-11-11 决定,探测依据见 kernel design §15):
2541
+ * ⚠️ 语义降级(探测依据见 kernel design §15):
3083
2542
  * QQ NT 没有任何「把文件传进群文件列表」的 NAPI,`sendMsg` 带 fileElement 时原生走的
3084
2543
  * 文件传输命令被服务端拒绝(`170019002`,逐维扫参无效),`fileUuid` 永远拿不到。唯一实测
3085
2544
  * 可用的投递通道是闪传:上传文件集 → 发分享卡片。因此本动作:
@@ -3092,40 +2551,15 @@ function createSystemAccountActions(api) {
3092
2551
  * 输入只接受本地路径与 `file://` URI:远程 `http(s)://` / `base64://` 需要下载缓存与媒体
3093
2552
  * 依赖,当前未接(明确报错,不静默失败)。
3094
2553
  */
2554
+ /** file:// 前缀(fileURLToPath 失败时的裸剥离兜底)。 */
2555
+ const FILE_URI_PREFIX_RE = /^file:\/\//;
2556
+ /** 路径分隔符(取文件名用)。 */
2557
+ const PATH_SEPARATORS = /[\\/]/;
3095
2558
  const downloadFileSchema = z.object({
3096
2559
  url: z.string(),
3097
2560
  thread_count: z.number().optional(),
3098
2561
  headers: z.record(z.string(), z.string()).optional()
3099
2562
  });
3100
- /** 下载文件到缓存目录(P2-12)。 */
3101
- var DownloadFileAction = class extends BaseAction {
3102
- name = "download_file";
3103
- schema = downloadFileSchema;
3104
- errorCodeMap = ob11ErrorCodeMap;
3105
- deps;
3106
- constructor(deps) {
3107
- super();
3108
- this.deps = deps;
3109
- }
3110
- async _handle(payload) {
3111
- const { cacheDir } = this.deps;
3112
- if (cacheDir === void 0 || cacheDir === "") throw kernelError("download_file 未配置缓存目录(装配方未注入)", "INVALID_STATE");
3113
- const safeName = basename(new URL(payload.url).pathname) || "download.bin";
3114
- const filePath = join(cacheDir, `download-${Date.now()}-${safeName}`);
3115
- mkdirSync(cacheDir, { recursive: true });
3116
- const init = {};
3117
- if (payload.headers !== void 0) init.headers = payload.headers;
3118
- const res = await fetch(payload.url, init);
3119
- if (!res.ok) throw new Error(`下载失败: ${res.status} ${res.statusText}`);
3120
- const buf = new Uint8Array(await res.arrayBuffer());
3121
- writeFileSync(filePath, buf);
3122
- return { file: filePath };
3123
- }
3124
- };
3125
- /** file:// 前缀(fileURLToPath 失败时的裸剥离兜底)。 */
3126
- const FILE_URI_PREFIX_RE = /^file:\/\//;
3127
- /** 路径分隔符(取文件名用)。 */
3128
- const PATH_SEPARATORS = /[\\/]/;
3129
2563
  const uploadGroupFileSchema = z.object({
3130
2564
  group_id: z.number(),
3131
2565
  file: z.string().min(1),
@@ -3138,41 +2572,6 @@ const uploadPrivateFileSchema = z.object({
3138
2572
  file: z.string().min(1),
3139
2573
  name: z.string().optional()
3140
2574
  });
3141
- /** upload_group_file:上传文件并投递到群(闪传卡片;语义降级见文件头)。 */
3142
- var UploadGroupFileAction = class extends BaseAction {
3143
- name = "upload_group_file";
3144
- schema = uploadGroupFileSchema;
3145
- errorCodeMap = ob11ErrorCodeMap;
3146
- deps;
3147
- constructor(deps) {
3148
- super();
3149
- this.deps = deps;
3150
- }
3151
- async _handle(payload) {
3152
- const path = resolveLocalFile(payload.file);
3153
- const peer = {
3154
- chatType: ChatType.GROUP,
3155
- peerUid: String(payload.group_id)
3156
- };
3157
- return { file_id: (await this.deps.flashTransferApi.sendFile(peer, [path], { name: payload.name ?? basename$1(path) })).fileSetId };
3158
- }
3159
- };
3160
- /** upload_private_file:上传文件并投递到私聊(闪传卡片;语义降级见文件头)。 */
3161
- var UploadPrivateFileAction = class extends BaseAction {
3162
- name = "upload_private_file";
3163
- schema = uploadPrivateFileSchema;
3164
- errorCodeMap = ob11ErrorCodeMap;
3165
- deps;
3166
- constructor(deps) {
3167
- super();
3168
- this.deps = deps;
3169
- }
3170
- async _handle(payload) {
3171
- const path = resolveLocalFile(payload.file);
3172
- const peer = await resolveTargetPeer({ user_id: payload.user_id }, this.deps, "upload_private_file 需要 user_id");
3173
- return { file_id: (await this.deps.flashTransferApi.sendFile(peer, [path], { name: payload.name ?? basename$1(path) })).fileSetId };
3174
- }
3175
- };
3176
2575
  /** 本地路径 / file:// 展开;远程 URI 明确拒绝(未接下载缓存)。 */
3177
2576
  function resolveLocalFile(file) {
3178
2577
  if (file.startsWith("http://") || file.startsWith("https://") || file.startsWith("base64://")) throw kernelError("upload_group_file/upload_private_file 目前只支持本地路径与 file:// URI(远程 URI 需要下载缓存,未接入)", "INVALID_PARAM");
@@ -3192,148 +2591,136 @@ function basename$1(path) {
3192
2591
  /** 文件收发域动作工厂(download_file / upload_group_file / upload_private_file)。 */
3193
2592
  function createSystemFileActions(api) {
3194
2593
  return [
3195
- new DownloadFileAction(api),
3196
- new UploadGroupFileAction(api),
3197
- new UploadPrivateFileAction(api)
2594
+ defineOb11Action({
2595
+ name: "download_file",
2596
+ schema: downloadFileSchema,
2597
+ handle: async (payload) => {
2598
+ const { cacheDir } = api;
2599
+ if (cacheDir === void 0 || cacheDir === "") throw kernelError("download_file 未配置缓存目录(装配方未注入)", "INVALID_STATE");
2600
+ const safeName = basename(new URL(payload.url).pathname) || "download.bin";
2601
+ const filePath = join(cacheDir, `download-${Date.now()}-${safeName}`);
2602
+ mkdirSync(cacheDir, { recursive: true });
2603
+ const init = {};
2604
+ if (payload.headers !== void 0) init.headers = payload.headers;
2605
+ const res = await fetch(payload.url, init);
2606
+ if (!res.ok) throw new Error(`下载失败: ${res.status} ${res.statusText}`);
2607
+ const buf = new Uint8Array(await res.arrayBuffer());
2608
+ writeFileSync(filePath, buf);
2609
+ return { file: filePath };
2610
+ }
2611
+ }),
2612
+ defineOb11Action({
2613
+ name: "upload_group_file",
2614
+ schema: uploadGroupFileSchema,
2615
+ handle: async (payload) => {
2616
+ const path = resolveLocalFile(payload.file);
2617
+ const peer = {
2618
+ chatType: ChatType.GROUP,
2619
+ peerUid: String(payload.group_id)
2620
+ };
2621
+ return { file_id: (await api.flashTransferApi.sendFile(peer, [path], { name: payload.name ?? basename$1(path) })).fileSetId };
2622
+ }
2623
+ }),
2624
+ defineOb11Action({
2625
+ name: "upload_private_file",
2626
+ schema: uploadPrivateFileSchema,
2627
+ handle: async (payload) => {
2628
+ const path = resolveLocalFile(payload.file);
2629
+ const peer = await resolveTargetPeer({ user_id: payload.user_id }, api, "upload_private_file 需要 user_id");
2630
+ return { file_id: (await api.flashTransferApi.sendFile(peer, [path], { name: payload.name ?? basename$1(path) })).fileSetId };
2631
+ }
2632
+ })
3198
2633
  ];
3199
2634
  }
3200
2635
  // src/onebot11/action/system/info.ts
3201
- const getLoginInfoSchema = z.object({});
3202
- /** 获取登录信息(self 由装配方注入,P2-5 接 kernel selfInfo 维护后取真实昵称)。 */
3203
- var GetLoginInfoAction = class extends BaseAction {
3204
- name = "get_login_info";
3205
- schema = getLoginInfoSchema;
3206
- errorCodeMap = ob11ErrorCodeMap;
3207
- self;
3208
- constructor(self) {
3209
- super();
3210
- this.self = self;
3211
- }
3212
- _handle(_payload) {
3213
- return Promise.resolve({
3214
- user_id: Number(this.self.uin),
3215
- nickname: this.self.nickname
3216
- });
3217
- }
3218
- };
3219
- const getVersionInfoSchema = z.object({});
3220
- /** 获取版本信息(本地组装,P2-11)。 */
3221
- var GetVersionInfoAction = class extends BaseAction {
3222
- name = "get_version_info";
3223
- schema = getVersionInfoSchema;
3224
- errorCodeMap = ob11ErrorCodeMap;
3225
- deps;
3226
- constructor(deps) {
3227
- super();
3228
- this.deps = deps;
3229
- }
3230
- _handle(_payload) {
3231
- return Promise.resolve({
3232
- app_name: "napuketto-qq",
3233
- app_version: this.deps.appVersion,
3234
- protocol_version: "v11"
3235
- });
3236
- }
3237
- };
3238
- const getStatusSchema = z.object({});
3239
- /** 获取运行状态(本地组装,P2-11)。 */
3240
- var GetStatusAction = class extends BaseAction {
3241
- name = "get_status";
3242
- schema = getStatusSchema;
3243
- errorCodeMap = ob11ErrorCodeMap;
3244
- _handle(_payload) {
3245
- return Promise.resolve({
3246
- online: true,
3247
- good: true
3248
- });
3249
- }
3250
- };
3251
- const getRobotUinRangeSchema = z.object({});
2636
+ /**
2637
+ * 系统信息域动作——只读信息查询,多为本地组装。
2638
+ *
2639
+ * - get_login_info:self 由装配方注入(接 kernel selfInfo 取真实昵称)
2640
+ * - get_version_info:appVersion 由装配方注入(kernel wrapper 版本或
2641
+ * NAPUTO_QQ_VERSION)
2642
+ * - get_status:返回与心跳 status 同构的 OB11Status(online/good)
2643
+ * - get_robot_uin_range:NapCat 从配置返回;这里给通用范围(min/max)
2644
+ * - translate_en2zh:kernel RichMediaApi.translateWords(词条数组限长)
2645
+ */
3252
2646
  /** QQ 号下限。 */
3253
2647
  const UIN_MIN = 10001;
3254
2648
  /** QQ 号上限。 */
3255
2649
  const UIN_MAX = 4294967295;
3256
- /** 获取机器人 QQ 号范围(P2-11 本地组装)。 */
3257
- var GetRobotUinRangeAction = class extends BaseAction {
3258
- name = "get_robot_uin_range";
3259
- schema = getRobotUinRangeSchema;
3260
- errorCodeMap = ob11ErrorCodeMap;
3261
- _handle(_payload) {
3262
- return Promise.resolve({
3263
- min: UIN_MIN,
3264
- max: UIN_MAX
3265
- });
3266
- }
3267
- };
2650
+ const getLoginInfoSchema = z.object({});
2651
+ const getVersionInfoSchema = z.object({});
2652
+ const getStatusSchema = z.object({});
2653
+ const getRobotUinRangeSchema = z.object({});
3268
2654
  const translateEn2ZhSchema = z.object({ words: z.array(z.string()).max(MAX_TRANSLATE_WORDS) });
3269
- /** 英文单词翻译(P2-14)。 */
3270
- var TranslateEn2ZhAction = class extends BaseAction {
3271
- name = "translate_en2zh";
3272
- schema = translateEn2ZhSchema;
3273
- errorCodeMap = ob11ErrorCodeMap;
3274
- richMediaApi;
3275
- constructor(richMediaApi) {
3276
- super();
3277
- this.richMediaApi = richMediaApi;
3278
- }
3279
- async _handle(payload) {
3280
- return { words: await this.richMediaApi.translateWords(payload.words) };
3281
- }
3282
- };
3283
2655
  /**
3284
2656
  * 系统信息域动作工厂(login_info / version_info / status / robot_uin_range /
3285
2657
  * translate_en2zh)。
3286
2658
  */
3287
2659
  function createSystemInfoActions(api) {
3288
2660
  return [
3289
- new GetLoginInfoAction(api.self),
3290
- new GetVersionInfoAction(api),
3291
- new GetStatusAction(),
3292
- new GetRobotUinRangeAction(),
3293
- new TranslateEn2ZhAction(api.richMediaApi)
2661
+ defineOb11Action({
2662
+ name: "get_login_info",
2663
+ schema: getLoginInfoSchema,
2664
+ handle: () => Promise.resolve({
2665
+ user_id: Number(api.self.uin),
2666
+ nickname: api.self.nickname
2667
+ })
2668
+ }),
2669
+ defineOb11Action({
2670
+ name: "get_version_info",
2671
+ schema: getVersionInfoSchema,
2672
+ handle: () => Promise.resolve({
2673
+ app_name: "napuketto-qq",
2674
+ app_version: api.appVersion,
2675
+ protocol_version: "v11"
2676
+ })
2677
+ }),
2678
+ defineOb11Action({
2679
+ name: "get_status",
2680
+ schema: getStatusSchema,
2681
+ handle: () => Promise.resolve({
2682
+ online: true,
2683
+ good: true
2684
+ })
2685
+ }),
2686
+ defineOb11Action({
2687
+ name: "get_robot_uin_range",
2688
+ schema: getRobotUinRangeSchema,
2689
+ handle: () => Promise.resolve({
2690
+ min: UIN_MIN,
2691
+ max: UIN_MAX
2692
+ })
2693
+ }),
2694
+ defineOb11Action({
2695
+ name: "translate_en2zh",
2696
+ schema: translateEn2ZhSchema,
2697
+ handle: async (payload) => {
2698
+ return { words: await api.richMediaApi.translateWords(payload.words) };
2699
+ }
2700
+ })
3294
2701
  ];
3295
2702
  }
3296
2703
  // src/onebot11/action/system/status.ts
3297
2704
  /**
3298
- * 系统状态与维护域动作(2026-11-14 自 set-online-status / set-diy-online-status /
3299
- * can-send-image / can-send-record / clean-cache / process-control 合并)
2705
+ * 系统状态与维护域动作
3300
2706
  *
3301
- * - set_online_status(P2-12):status/ext_status/battery_status 见 NapCat 状态表
2707
+ * - set_online_status:status/ext_status/battery_status 见 NapCat 状态表
3302
2708
  * (在线 10 / 离开 30 / 隐身 40 / 忙碌 50 / Q我吧 60 / 请勿打扰 70 等)
3303
- * - set_diy_online_status(P2-12):customStatus(faceId/wording/faceType)随
2709
+ * - set_diy_online_status:customStatus(faceId/wording/faceType)随
3304
2710
  * setStatus 一并提交;status 缺省 10(在线)
3305
- * - can_send_image / can_send_record(P2-11):本地恒 true
3306
- * - clean_cache(P2-11):cleanCache 回调由装配方注入(boot.cjs 接 kernel
2711
+ * - can_send_image / can_send_record:本地恒 true
2712
+ * - clean_cache:cleanCache 回调由装配方注入(boot.cjs 接 kernel
3307
2713
  * PathWrapper.clearCache),未配置时明确报错(不静默)
3308
- * - bot_exit / set_restart(P2-12):exit/restart 回调由装配方注入(boot.cjs 接
2714
+ * - bot_exit / set_restart:exit/restart 回调由装配方注入(boot.cjs 接
3309
2715
  * 进程控制),未配置时明确报错;重启缺省退化为退出
3310
2716
  */
2717
+ /** 默认在线状态值。 */
2718
+ const STATUS_ONLINE = 10;
3311
2719
  const setOnlineStatusSchema = z.object({
3312
2720
  status: z.number().optional(),
3313
2721
  ext_status: z.number().optional(),
3314
2722
  battery_status: z.number().optional()
3315
2723
  });
3316
- /** 默认在线状态值。 */
3317
- const STATUS_ONLINE = 10;
3318
- /** 设置在线状态(P2-12 接 kernel setOnlineStatus)。 */
3319
- var SetOnlineStatusAction = class extends BaseAction {
3320
- name = "set_online_status";
3321
- schema = setOnlineStatusSchema;
3322
- errorCodeMap = ob11ErrorCodeMap;
3323
- msgApi;
3324
- constructor(msgApi) {
3325
- super();
3326
- this.msgApi = msgApi;
3327
- }
3328
- async _handle(payload) {
3329
- await this.msgApi.setOnlineStatus({
3330
- status: payload.status ?? STATUS_ONLINE,
3331
- extStatus: payload.ext_status ?? 0,
3332
- batteryStatus: payload.battery_status ?? 0
3333
- });
3334
- return null;
3335
- }
3336
- };
3337
2724
  const setDiyOnlineStatusSchema = z.object({
3338
2725
  status: z.number().optional(),
3339
2726
  /** 自定义状态文案。 */
@@ -3343,126 +2730,95 @@ const setDiyOnlineStatusSchema = z.object({
3343
2730
  /** 表情类型。 */
3344
2731
  face_type: z.string().optional()
3345
2732
  });
3346
- /** 设置自定义在线状态(P2-12 接 kernel setOnlineStatus customStatus)。 */
3347
- var SetDiyOnlineStatusAction = class extends BaseAction {
3348
- name = "set_diy_online_status";
3349
- schema = setDiyOnlineStatusSchema;
3350
- errorCodeMap = ob11ErrorCodeMap;
3351
- msgApi;
3352
- constructor(msgApi) {
3353
- super();
3354
- this.msgApi = msgApi;
3355
- }
3356
- async _handle(payload) {
3357
- const customStatus = {
3358
- faceId: payload.face_id ?? "",
3359
- wording: payload.wording,
3360
- faceType: payload.face_type ?? "1"
3361
- };
3362
- await this.msgApi.setOnlineStatus({
3363
- status: payload.status ?? STATUS_ONLINE,
3364
- extStatus: 0,
3365
- batteryStatus: 0,
3366
- customStatus
3367
- });
3368
- return null;
3369
- }
3370
- };
3371
2733
  const canSendImageSchema = z.object({});
3372
- /** 是否可以发送图片(本地 true,P2-11)。 */
3373
- var CanSendImageAction = class extends BaseAction {
3374
- name = "can_send_image";
3375
- schema = canSendImageSchema;
3376
- errorCodeMap = ob11ErrorCodeMap;
3377
- _handle(_payload) {
3378
- return Promise.resolve({ yes: true });
3379
- }
3380
- };
3381
2734
  const canSendRecordSchema = z.object({});
3382
- /** 是否可以发送语音(本地 true,P2-11)。 */
3383
- var CanSendRecordAction = class extends BaseAction {
3384
- name = "can_send_record";
3385
- schema = canSendRecordSchema;
3386
- errorCodeMap = ob11ErrorCodeMap;
3387
- _handle(_payload) {
3388
- return Promise.resolve({ yes: true });
3389
- }
3390
- };
3391
2735
  const cleanCacheSchema = z.object({});
3392
- /** 清理缓存(P2-11)。 */
3393
- var CleanCacheAction = class extends BaseAction {
3394
- name = "clean_cache";
3395
- schema = cleanCacheSchema;
3396
- errorCodeMap = ob11ErrorCodeMap;
3397
- deps;
3398
- constructor(deps) {
3399
- super();
3400
- this.deps = deps;
3401
- }
3402
- async _handle(_payload) {
3403
- if (this.deps.cleanCache === void 0) throw kernelError("clean_cache 未配置(装配方未注入清理回调)", "INVALID_STATE");
3404
- await this.deps.cleanCache();
3405
- return null;
3406
- }
3407
- };
3408
2736
  const botExitSchema = z.object({});
3409
- /** 退出机器人进程(P2-12)。 */
3410
- var BotExitAction = class extends BaseAction {
3411
- name = "bot_exit";
3412
- schema = botExitSchema;
3413
- errorCodeMap = ob11ErrorCodeMap;
3414
- deps;
3415
- constructor(deps) {
3416
- super();
3417
- this.deps = deps;
3418
- }
3419
- async _handle(_payload) {
3420
- if (this.deps.exit === void 0) throw kernelError("bot_exit 未配置(装配方未注入退出回调)", "INVALID_STATE");
3421
- await this.deps.exit();
3422
- return null;
3423
- }
3424
- };
3425
- /** 重启机器人(P2-12;重启交给装配方,缺省退化为退出)。 */
3426
- var SetRestartAction = class extends BaseAction {
3427
- name = "set_restart";
3428
- schema = botExitSchema;
3429
- errorCodeMap = ob11ErrorCodeMap;
3430
- deps;
3431
- constructor(deps) {
3432
- super();
3433
- this.deps = deps;
3434
- }
3435
- async _handle(_payload) {
3436
- const restart = this.deps.restart ?? this.deps.exit;
3437
- if (restart === void 0) throw kernelError("set_restart 未配置(装配方未注入重启回调)", "INVALID_STATE");
3438
- await restart();
3439
- return null;
3440
- }
3441
- };
3442
2737
  /**
3443
2738
  * 系统状态与维护域动作工厂(set_online_status ×2 / can_send ×2 / clean_cache /
3444
2739
  * bot_exit / set_restart)。
3445
2740
  */
3446
2741
  function createSystemStatusActions(api) {
3447
2742
  return [
3448
- new SetOnlineStatusAction(api.msgApi),
3449
- new SetDiyOnlineStatusAction(api.msgApi),
3450
- new CanSendImageAction(),
3451
- new CanSendRecordAction(),
3452
- new CleanCacheAction(api),
3453
- new BotExitAction(api),
3454
- new SetRestartAction(api)
2743
+ defineOb11Action({
2744
+ name: "set_online_status",
2745
+ schema: setOnlineStatusSchema,
2746
+ handle: async (payload) => {
2747
+ await api.msgApi.setOnlineStatus({
2748
+ status: payload.status ?? STATUS_ONLINE,
2749
+ extStatus: payload.ext_status ?? 0,
2750
+ batteryStatus: payload.battery_status ?? 0
2751
+ });
2752
+ return null;
2753
+ }
2754
+ }),
2755
+ defineOb11Action({
2756
+ name: "set_diy_online_status",
2757
+ schema: setDiyOnlineStatusSchema,
2758
+ handle: async (payload) => {
2759
+ const customStatus = {
2760
+ faceId: payload.face_id ?? "",
2761
+ wording: payload.wording,
2762
+ faceType: payload.face_type ?? "1"
2763
+ };
2764
+ await api.msgApi.setOnlineStatus({
2765
+ status: payload.status ?? STATUS_ONLINE,
2766
+ extStatus: 0,
2767
+ batteryStatus: 0,
2768
+ customStatus
2769
+ });
2770
+ return null;
2771
+ }
2772
+ }),
2773
+ defineOb11Action({
2774
+ name: "can_send_image",
2775
+ schema: canSendImageSchema,
2776
+ handle: async () => ({ yes: true })
2777
+ }),
2778
+ defineOb11Action({
2779
+ name: "can_send_record",
2780
+ schema: canSendRecordSchema,
2781
+ handle: async () => ({ yes: true })
2782
+ }),
2783
+ defineOb11Action({
2784
+ name: "clean_cache",
2785
+ schema: cleanCacheSchema,
2786
+ handle: async () => {
2787
+ if (api.cleanCache === void 0) throw kernelError("clean_cache 未配置(装配方未注入清理回调)", "INVALID_STATE");
2788
+ await api.cleanCache();
2789
+ return null;
2790
+ }
2791
+ }),
2792
+ defineOb11Action({
2793
+ name: "bot_exit",
2794
+ schema: botExitSchema,
2795
+ handle: async () => {
2796
+ if (api.exit === void 0) throw kernelError("bot_exit 未配置(装配方未注入退出回调)", "INVALID_STATE");
2797
+ await api.exit();
2798
+ return null;
2799
+ }
2800
+ }),
2801
+ defineOb11Action({
2802
+ name: "set_restart",
2803
+ schema: botExitSchema,
2804
+ handle: async () => {
2805
+ const restart = api.restart ?? api.exit;
2806
+ if (restart === void 0) throw kernelError("set_restart 未配置(装配方未注入重启回调)", "INVALID_STATE");
2807
+ await restart();
2808
+ return null;
2809
+ }
2810
+ })
3455
2811
  ];
3456
2812
  }
3457
2813
  // src/onebot11/action/index.ts
3458
2814
  /**
3459
- * OneBot 11 动作注册表(ADR-013 延伸)
2815
+ * OneBot 11 动作注册表
3460
2816
  * 各协议维护自己的 ActionRegistry,由协议 adapter 挂到请求分发。
3461
- * P2-16:deps 收敛为 { api: OneBotApi } 单聚合对象(基础设施第一项)。
2817
+ * deps 收敛为 { api: OneBotApi } 单聚合对象。
3462
2818
  *
3463
- * 同时是 action 域 barrel:re-export error-map / resolve-uid / AtAllRemainInfo,
3464
- * 协议外部只从本入口消费动作面。动作类按领域分文件(message/ group/ friend/
3465
- * system/),各领域文件导出 create*Actions 工厂,此处遍历注册——新增动作在
2819
+ * 同时是 action 域 barrel:re-export ob11ErrorCodeMap / resolveUid(base-action)/
2820
+ * AtAllRemainInfo,协议外部只从本入口消费动作面。动作按领域分文件(message/ group/
2821
+ * friend/ system/),各领域文件导出 create*Actions 工厂,此处遍历注册——新增动作在
3466
2822
  * 领域文件的工厂里登记即可。
3467
2823
  */
3468
2824
  /** 全部领域工厂(18 个:message×5 + group×7 + friend×2 + system×4)。 */
@@ -3494,7 +2850,7 @@ function createOb11ActionRegistry(deps) {
3494
2850
  }
3495
2851
  // src/onebot11/api/one-bot-api.ts
3496
2852
  /**
3497
- * OneBot 11 动作统一依赖聚合(P2-16)。
2853
+ * OneBot 11 动作统一依赖聚合。
3498
2854
  * 各动作经 `Pick<OneBotApi, ...>` 取所需成员;注册处只构造一次本对象。
3499
2855
  */
3500
2856
  var OneBotApi = class {
@@ -3518,7 +2874,7 @@ var OneBotApi = class {
3518
2874
  profileLikeApi;
3519
2875
  /** kernel 群空间 web API(精华/荣誉用)。 */
3520
2876
  webApi;
3521
- /** 群/成员缓存(ADR-008;翻译层只读消费,缺失惰性回填)。 */
2877
+ /** 群/成员缓存(翻译层只读消费,缺失惰性回填)。 */
3522
2878
  groupCache;
3523
2879
  /** OB11 message_id ↔ NT msgId 双向映射(收链路与动作共用同一映射空间)。 */
3524
2880
  messageUnique;
@@ -3644,7 +3000,7 @@ var Ob11Enrichment = class {
3644
3000
  return this.api.uidToUin(uids);
3645
3001
  }
3646
3002
  /**
3647
- * 消息事件翻译上下文(P2-19:接收方向 ID 转换)。
3003
+ * 消息事件翻译上下文(接收方向 ID 转换)。
3648
3004
  * at uid → 一次批量 uidToUin;群消息另查发送者角色(GroupCache 缓存优先,
3649
3005
  * 失败回退缺省 member);msgId → OB11 id 经 messageUnique 反查。
3650
3006
  */
@@ -3860,7 +3216,7 @@ var Ob11InboundFileNotice = class {
3860
3216
  this.deps = deps;
3861
3217
  }
3862
3218
  /**
3863
- * 离线文件(c3,2026-09-10):Msg/onRecvOfflineFileMsg → OB11 offline_file
3219
+ * 离线文件(c3):Msg/onRecvOfflineFileMsg → OB11 offline_file
3864
3220
  * notice(payload 形状待校准:防御性收窄,未知形状 raw 日志积累)。
3865
3221
  */
3866
3222
  offlineFile(arg) {
@@ -3871,7 +3227,7 @@ var Ob11InboundFileNotice = class {
3871
3227
  }
3872
3228
  for (const item of items) this.deps.broadcast(toOfflineFileNotice(item, this.deps.selfUin));
3873
3229
  }
3874
- /** 在线文件:OB11 无对应通知类型;debug 级 raw 校准日志(2026-10-25)。 */
3230
+ /** 在线文件:OB11 无对应通知类型;debug 级 raw 校准日志。 */
3875
3231
  onlineFile(arg) {
3876
3232
  this.deps.logger?.debug({ raw: sliceRaw(JSON.stringify(arg)) }, "ob11: onRecvOnlineFileMsg raw(校准数据)");
3877
3233
  }
@@ -3879,7 +3235,7 @@ var Ob11InboundFileNotice = class {
3879
3235
  buddyList(evt, arg) {
3880
3236
  this.deps.logger?.info({ raw: truncRaw(JSON.stringify(arg)) }, `ob11: ${evt} raw(friend_add 校准数据)`);
3881
3237
  }
3882
- /** 好友缓存 diff 新增(B2,2026-09-08)→ friend_add notice(翻译纯函数)。 */
3238
+ /** 好友缓存 diff 新增()→ friend_add notice(翻译纯函数)。 */
3883
3239
  friendAdd(entry) {
3884
3240
  this.deps.broadcast(toFriendAdd(entry, this.deps.selfUin));
3885
3241
  }
@@ -3887,7 +3243,7 @@ var Ob11InboundFileNotice = class {
3887
3243
  // src/onebot11/helper/message-event.ts
3888
3244
  /** RawMessage → OB11 消息事件(message_id 经 MessageUnique 映射并记录 peer)。
3889
3245
  * messageFormat 决定 message 字段格式:array = 消息段数组(标准),string = CQ 码字符串。
3890
- * ctx(可选):接收方向 ID 转换上下文(at uid→uin、reply NT msgId→OB11 id,P2-19)。 */
3246
+ * ctx(可选):接收方向 ID 转换上下文(at uid→uin、reply NT msgId→OB11 id)。 */
3891
3247
  function toOb11MessageEvent(msg, selfUin, unique, messageFormat = "array", ctx = {}) {
3892
3248
  const elements = applyReceiveContext(toCanonicalElements(msg), ctx);
3893
3249
  const segments = canonicalToSegments(elements);
@@ -3942,7 +3298,7 @@ var Ob11InboundMessage = class {
3942
3298
  deps;
3943
3299
  reportSelfMessage = false;
3944
3300
  messageFormat = "array";
3945
- /** 群文件报形式(B4):true = fileElement 群消息报 group_upload notice 替代 message。 */
3301
+ /** 群文件报形式():true = fileElement 群消息报 group_upload notice 替代 message。 */
3946
3302
  groupUploadAsNotice = false;
3947
3303
  constructor(deps) {
3948
3304
  this.deps = deps;
@@ -3969,10 +3325,10 @@ var Ob11InboundMessage = class {
3969
3325
  return;
3970
3326
  }
3971
3327
  }
3972
- this.broadcastMessageEvent(msg);
3328
+ this.broadcastMessageEvent(msg).catch((err) => logEventFailure(this.deps.logger, "ob11: message 事件翻译失败(单条丢弃)", err));
3973
3329
  }
3974
3330
  /**
3975
- * 广播消息事件(P2-19):回填 ctx 后交纯函数翻译;ID 转换在 enrichment 批量完成。
3331
+ * 广播消息事件:回填 ctx 后交纯函数翻译;ID 转换在 enrichment 批量完成。
3976
3332
  */
3977
3333
  async broadcastMessageEvent(msg) {
3978
3334
  const ctx = await this.deps.enrich.messageContext(msg);
@@ -4007,7 +3363,7 @@ var Ob11InboundRequest = class {
4007
3363
  }
4008
3364
  /** 好友申请 → friend request 事件(防御收窄;未知形状 raw warn 校准)。 */
4009
3365
  buddyReqs(arg) {
4010
- this.broadcastBuddyReqs(arg);
3366
+ this.broadcastBuddyReqs(arg).catch((err) => logEventFailure(this.deps.logger, "ob11: friend request 翻译失败(整批丢弃)", err));
4011
3367
  }
4012
3368
  /** 好友申请翻译派发(flag=reqTime;uid→uin 批量失败退空 Map)。 */
4013
3369
  async broadcastBuddyReqs(arg) {
@@ -4035,7 +3391,7 @@ function collectGroupNotifyUids(notifies) {
4035
3391
  }
4036
3392
  // src/onebot11/helper/sysmsg.ts
4037
3393
  /**
4038
- * OB11 sysmsg 识别表(2026-11-01 自 helper/sysmsg.ts 瘦身——解码层上移
3394
+ * OB11 sysmsg 识别表(自 helper/sysmsg.ts 瘦身——解码层上移
4039
3395
  * core/sysmsg.ts 共享,milky.md §0.8.3/§0.8.6)
4040
3396
  *
4041
3397
  * 本模块只保留 OB11 侧内容:
@@ -4052,7 +3408,7 @@ const NUMERIC_RE = /^\d+$/;
4052
3408
  /**
4053
3409
  * (msgType, subType) → 规则表(键 = 原生分发键,design.md §7.1)。
4054
3410
  *
4055
- * 2026-11-01 起不再是空表:732:21(群名片变更)为批次三轮录制取得的首个
3411
+ * 不再是空表:732:21(群名片变更)为轮录制取得的首个
4056
3412
  * 实证条目。card/title 等其余判别值仍无样本支撑,宁可漏报不错报;未识别
4057
3413
  * 一律走结构化校准日志,不广播。
4058
3414
  */
@@ -4089,7 +3445,7 @@ function recognizeOb11SysMsg(msgType, subType, table = KIND_TABLE) {
4089
3445
  }
4090
3446
  // src/onebot11/inbound/sysmsg.ts
4091
3447
  /**
4092
- * OB11 inbound sysmsg 域(2026-11-14 自 event-pipeline.ts 拆出)
3448
+ * OB11 inbound sysmsg 域(自 event-pipeline.ts 拆出)
4093
3449
  *
4094
3450
  * Msg/onRecvSysMsg 总闸:参数收窄(未知形状 raw warn)→ 单条字节块走
4095
3451
  * core/shared/sysmsg.ts 的 processSysMsgBlob 通用管线(解码 → 信封 → 识别 →
@@ -4179,7 +3535,7 @@ var Ob11EventPipeline = class {
4179
3535
  const { msgChannel, groupChannel, friendChannel, buddyCacheEvents } = this.deps;
4180
3536
  this.unsubscribes.push(subscribeRawMessages(msgChannel, (msg) => this.message.handleRawMessage(msg)), msgChannel.on("Msg/onRecvOfflineFileMsg", (a) => this.fileNotice.offlineFile(a)), msgChannel.on("Msg/onRecvSysMsg", (a) => this.sysMsg.handleRawArg(a)), msgChannel.on("Msg/onRecvOnlineFileMsg", (a) => this.fileNotice.onlineFile(a)));
4181
3537
  if (groupChannel !== void 0) this.unsubscribes.push(groupChannel.on("Group/onGroupNotifiesUpdated", (doubt, notifies) => {
4182
- this.request.groupNotifies(doubt, notifies);
3538
+ this.request.groupNotifies(doubt, notifies).catch((err) => logEventFailure(this.deps.logger, "ob11: group request 翻译失败(整批丢弃)", err));
4183
3539
  }), groupChannel.on("Group/onGroupEssenceListChange", (a) => this.essence.change(a)));
4184
3540
  if (friendChannel !== void 0) {
4185
3541
  this.unsubscribes.push(friendChannel.on("Buddy/onBuddyReqChange", (a) => this.request.buddyReqs(a)));
@@ -4194,7 +3550,7 @@ var Ob11EventPipeline = class {
4194
3550
  };
4195
3551
  // src/onebot11/transport.ts
4196
3552
  /**
4197
- * OB11 传输装配(P2-5,2026-08-05)
3553
+ * OB11 传输装配
4198
3554
  *
4199
3555
  * 按 OB11Config 创建/装配 network 传输适配器:
4200
3556
  * - HTTP 反向(http.enabled):HttpServer 接收第三方调用 → handleRequest → 响应
@@ -4208,8 +3564,8 @@ var Ob11EventPipeline = class {
4208
3564
  /** Authorization 头前缀。 */
4209
3565
  const BEARER_PREFIX = "Bearer ";
4210
3566
  /** 校验 URL 查询参数里的 access_token(WS client 连接 URL 可能带)。
4211
- * ⚠️ req.url 是纯路径(无 origin),new URL(相对路径) 必抛——2026-09-08
4212
- * T10 E2E 实测抓到的 bug(查询参数鉴权从未生效,WS 全被 4401 关闭),
3567
+ * ⚠️ req.url 是纯路径(无 origin),new URL(相对路径) 必抛——
3568
+ * E2E 实测抓到的 bug(查询参数鉴权从未生效,WS 全被 4401 关闭),
4213
3569
  * 用 dummy base 解析。 */
4214
3570
  function hasAccessTokenQuery(url, token) {
4215
3571
  try {
@@ -4344,7 +3700,7 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
4344
3700
  oneBotApi;
4345
3701
  /** 动作注册表(公共只读:IPC 桥等装配方枚举动作名直接挂载)。 */
4346
3702
  registry;
4347
- /** 收链路事件管道(订阅 / 过滤 / 翻译派发,2026-11-14 拆出)。 */
3703
+ /** 收链路事件管道(订阅 / 过滤 / 翻译派发,拆出)。 */
4348
3704
  pipeline;
4349
3705
  transports = null;
4350
3706
  heartbeatTimer = null;
@@ -4375,7 +3731,7 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
4375
3731
  this.registry = createOb11ActionRegistry({ api: this.oneBotApi });
4376
3732
  }
4377
3733
  /**
4378
- * 配置热更新(P2-6,2026-09-08 实现):stop 旧传输/心跳/退订 → 按新配置重建。
3734
+ * 配置热更新(实现):stop 旧传输/心跳/退订 → 按新配置重建。
4379
3735
  * IPC 桥模式(subscribeOnly,无传输)只刷新上报开关字段,不重建。
4380
3736
  */
4381
3737
  async reloadTransports(config) {
@@ -4452,7 +3808,7 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
4452
3808
  }
4453
3809
  }
4454
3810
  /**
4455
- * 仅启动接收链路(IPC 桥模式,2026-08-27):订阅消息通道维护 messageUnique +
3811
+ * 仅启动接收链路(IPC 桥模式):订阅消息通道维护 messageUnique +
4456
3812
  * 灰色通知翻译;与 start() 的差别仅在传输层(无 HTTP/WS、无心跳、无 lifecycle)。
4457
3813
  * 配置经 seed 装配(load() 返回内存初值)。
4458
3814
  */