@napuketto/adapter 0.10.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/core/index.d.mts +1 -1
  2. package/dist/core/index.mjs +1 -2
  3. package/dist/{core-DW5i42XH.mjs → core-BNOfqnV-.mjs} +8 -15
  4. package/dist/{core-DW5i42XH.mjs.map → core-BNOfqnV-.mjs.map} +1 -1
  5. package/dist/{essence-DSSyWl36.mjs → essence-BRbsj_Vv.mjs} +5 -8
  6. package/dist/essence-BRbsj_Vv.mjs.map +1 -0
  7. package/dist/{gray-tip-LwBee5mo.mjs → gray-tip-ByF-MKeV.mjs} +2 -3
  8. package/dist/gray-tip-ByF-MKeV.mjs.map +1 -0
  9. package/dist/{index-h-tsUu0j.d.mts → index-DNvM3A-1.d.mts} +1 -15
  10. package/dist/index-DNvM3A-1.d.mts.map +1 -0
  11. package/dist/index.d.mts +1 -4
  12. package/dist/index.d.mts.map +1 -1
  13. package/dist/kurobot/index.d.mts +35 -45
  14. package/dist/kurobot/index.d.mts.map +1 -1
  15. package/dist/kurobot/index.mjs +7 -12
  16. package/dist/kurobot/index.mjs.map +1 -1
  17. package/dist/milky/index.d.mts +4 -20
  18. package/dist/milky/index.d.mts.map +1 -1
  19. package/dist/milky/index.mjs +192 -216
  20. package/dist/milky/index.mjs.map +1 -1
  21. package/dist/onebot11/index.d.mts +21 -57
  22. package/dist/onebot11/index.d.mts.map +1 -1
  23. package/dist/onebot11/index.mjs +99 -178
  24. package/dist/onebot11/index.mjs.map +1 -1
  25. package/dist/{raw-message-D_ecJy4C.mjs → raw-message-C1E7jbjl.mjs} +2 -3
  26. package/dist/raw-message-C1E7jbjl.mjs.map +1 -0
  27. package/dist/satori/index.d.mts +16 -50
  28. package/dist/satori/index.d.mts.map +1 -1
  29. package/dist/satori/index.mjs +28 -52
  30. package/dist/satori/index.mjs.map +1 -1
  31. package/dist/{transport-schema-CpPxyRK0.mjs → transport-schema-BEzr06W3.mjs} +2 -3
  32. package/dist/transport-schema-BEzr06W3.mjs.map +1 -0
  33. package/package.json +21 -16
  34. package/dist/essence-DSSyWl36.mjs.map +0 -1
  35. package/dist/gray-tip-LwBee5mo.mjs.map +0 -1
  36. package/dist/index-h-tsUu0j.d.mts.map +0 -1
  37. package/dist/raw-message-D_ecJy4C.mjs.map +0 -1
  38. package/dist/transport-schema-CpPxyRK0.mjs.map +0 -1
@@ -1,7 +1,7 @@
1
- import { _ as BaseProtocolAdapter, b as ActionRegistry, c as nodeAt, d as toHex, f as varintAt, i as extractSysMsgEnvelope, l as recognizeSysMsg, n as decodeProtoTree, p as varintOf, s as narrowSysMsgBlobs, u as textOf } from "../core-DW5i42XH.mjs";
2
- import { n as firstUntranslatedGrayTip, t as collectGrayTipUids } from "../gray-tip-LwBee5mo.mjs";
3
- import { a as MS_TO_SEC$2, i as narrowBuddyReqs, n as extractEssenceSetSysMsg, o as resolveUin, r as narrowEssenceGroupArg, t as diffEssenceList } from "../essence-DSSyWl36.mjs";
4
- import { n as subscribeRawMessages, t as forEachRawMessage } from "../raw-message-D_ecJy4C.mjs";
1
+ import { _ as BaseProtocolAdapter, b as ActionRegistry, c as nodeAt, d as toHex, f as varintAt, i as extractSysMsgEnvelope, l as recognizeSysMsg, n as decodeProtoTree, p as varintOf, s as narrowSysMsgBlobs, u as textOf } from "../core-BNOfqnV-.mjs";
2
+ import { a as MS_TO_SEC$2, i as narrowBuddyReqs, n as extractEssenceSetSysMsg, o as resolveUin, r as narrowEssenceGroupArg, t as diffEssenceList } from "../essence-BRbsj_Vv.mjs";
3
+ import { n as firstUntranslatedGrayTip, t as collectGrayTipUids } from "../gray-tip-ByF-MKeV.mjs";
4
+ import { n as subscribeRawMessages, t as forEachRawMessage } from "../raw-message-C1E7jbjl.mjs";
5
5
  import { ChatType, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, isKernelError, kernelError, toCanonicalElements } from "@napuketto/kernel";
6
6
  import { mkdir, rename, writeFile } from "node:fs/promises";
7
7
  import { detectFileType, downloadUrl, inferExtension } from "@napuketto/media";
@@ -11,7 +11,7 @@ import { join } from "node:path";
11
11
  import { HttpClient, HttpServer, createSseResponse } from "@napuketto/network";
12
12
  import { WebSocket } from "ws";
13
13
  import { fileURLToPath } from "node:url";
14
- //#region src/milky/api.ts
14
+ // src/milky/api.ts
15
15
  var MilkyApi = class {
16
16
  msgApi;
17
17
  groupApi;
@@ -133,8 +133,82 @@ async function findBuddyReq(api, initiatorUid) {
133
133
  if (hit === void 0) throw kernelError(`未找到来自 ${initiatorUid} 的好友申请`, "NOT_FOUND");
134
134
  return hit;
135
135
  }
136
- //#endregion
137
- //#region src/milky/helper/entities.ts
136
+ // src/milky/helper/event/request.ts
137
+ /** uid → uin(core 共享解析;ctx 携带映射)。 */
138
+ function toUin$1(uid, ctx) {
139
+ return resolveUin(uid, ctx.uidToUin);
140
+ }
141
+ /** BuddyReq → friend_request 事件(comment 取 words 字段,形状待校准,缺省空串)。 */
142
+ function toFriendRequestEvent(req, ctx) {
143
+ const words = req["words"];
144
+ return {
145
+ time: Math.floor(Date.now() / MS_TO_SEC$2),
146
+ self_id: Number(ctx.selfUin),
147
+ event_type: "friend_request",
148
+ data: {
149
+ initiator_id: toUin$1(req.friendUid, ctx),
150
+ initiator_uid: req.friendUid,
151
+ comment: typeof words === "string" ? words : "",
152
+ via: req.sourceName ?? ""
153
+ }
154
+ };
155
+ }
156
+ /** GroupNotify → Milky 群请求事件(非未处理状态 / 非请求类返回 null)。 */
157
+ function toGroupRequestEvent(notify, doubt, ctx) {
158
+ if (notify.status !== GroupNotifyMsgStatus.KUNHANDLE) return null;
159
+ const groupId = Number(notify.group?.groupCode ?? 0);
160
+ const seq = Number(notify.seq);
161
+ const time = Math.floor(Date.now() / MS_TO_SEC$2);
162
+ const selfId = Number(ctx.selfUin);
163
+ switch (notify.type) {
164
+ case GroupNotifyMsgType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS: return {
165
+ time,
166
+ self_id: selfId,
167
+ event_type: "group_join_request",
168
+ data: {
169
+ group_id: groupId,
170
+ notification_seq: seq,
171
+ is_filtered: doubt,
172
+ initiator_id: toUin$1(notify.user1?.uid, ctx),
173
+ comment: notify.postscript ?? ""
174
+ }
175
+ };
176
+ case GroupNotifyMsgType.INVITED_NEED_ADMINI_STRATOR_PASS: return {
177
+ time,
178
+ self_id: selfId,
179
+ event_type: "group_invited_join_request",
180
+ data: {
181
+ group_id: groupId,
182
+ notification_seq: seq,
183
+ initiator_id: toUin$1(notify.user1?.uid, ctx),
184
+ target_user_id: toUin$1(notify.user2?.uid, ctx)
185
+ }
186
+ };
187
+ case GroupNotifyMsgType.INVITED_BY_MEMBER: return {
188
+ time,
189
+ self_id: selfId,
190
+ event_type: "group_invitation",
191
+ data: {
192
+ group_id: groupId,
193
+ invitation_seq: seq,
194
+ initiator_id: toUin$1(notify.user1?.uid, ctx),
195
+ source_group_id: null
196
+ }
197
+ };
198
+ default: return null;
199
+ }
200
+ }
201
+ /**
202
+ * 群通知涉及的 uid 集合(去重;get_group_notifications 与事件广播共用)。
203
+ * kernel GroupEventChannel 的 onGroupNotifiesUpdated 回调参数已类型化
204
+ * (GroupNotify[]),无需防御收窄。
205
+ */
206
+ function collectNotifyUids(notifies) {
207
+ const uids = /* @__PURE__ */ new Set();
208
+ for (const n of notifies) for (const uid of [n.user1?.uid, n.user2?.uid]) if (uid !== void 0 && uid !== "") uids.add(uid);
209
+ return [...uids];
210
+ }
211
+ // src/milky/helper/message/entities.ts
138
212
  /** GroupDetailInfo / Group → GroupEntity(detail 缺失时全兜底)。 */
139
213
  function toGroupEntity(detail, groupCode) {
140
214
  return {
@@ -194,8 +268,7 @@ function toFriendEntity(friend, uin, nick) {
194
268
  }
195
269
  };
196
270
  }
197
- //#endregion
198
- //#region src/milky/helper/media-uri.ts
271
+ // src/milky/helper/message/media-uri.ts
199
272
  /**
200
273
  * 发送媒体 URI 解析(Milky OutgoingSegment uri → 本地路径)
201
274
  *
@@ -250,84 +323,7 @@ async function writeBase64(payload, mediaDir) {
250
323
  return raw;
251
324
  }
252
325
  }
253
- //#endregion
254
- //#region src/milky/helper/request.ts
255
- /** uid → uin(core 共享解析;ctx 携带映射)。 */
256
- function toUin$1(uid, ctx) {
257
- return resolveUin(uid, ctx.uidToUin);
258
- }
259
- /** BuddyReq → friend_request 事件(comment 取 words 字段,形状待校准,缺省空串)。 */
260
- function toFriendRequestEvent(req, ctx) {
261
- const words = req["words"];
262
- return {
263
- time: Math.floor(Date.now() / MS_TO_SEC$2),
264
- self_id: Number(ctx.selfUin),
265
- event_type: "friend_request",
266
- data: {
267
- initiator_id: toUin$1(req.friendUid, ctx),
268
- initiator_uid: req.friendUid,
269
- comment: typeof words === "string" ? words : "",
270
- via: req.sourceName ?? ""
271
- }
272
- };
273
- }
274
- /** GroupNotify → Milky 群请求事件(非未处理状态 / 非请求类返回 null)。 */
275
- function toGroupRequestEvent(notify, doubt, ctx) {
276
- if (notify.status !== GroupNotifyMsgStatus.KUNHANDLE) return null;
277
- const groupId = Number(notify.group?.groupCode ?? 0);
278
- const seq = Number(notify.seq);
279
- const time = Math.floor(Date.now() / MS_TO_SEC$2);
280
- const selfId = Number(ctx.selfUin);
281
- switch (notify.type) {
282
- case GroupNotifyMsgType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS: return {
283
- time,
284
- self_id: selfId,
285
- event_type: "group_join_request",
286
- data: {
287
- group_id: groupId,
288
- notification_seq: seq,
289
- is_filtered: doubt,
290
- initiator_id: toUin$1(notify.user1?.uid, ctx),
291
- comment: notify.postscript ?? ""
292
- }
293
- };
294
- case GroupNotifyMsgType.INVITED_NEED_ADMINI_STRATOR_PASS: return {
295
- time,
296
- self_id: selfId,
297
- event_type: "group_invited_join_request",
298
- data: {
299
- group_id: groupId,
300
- notification_seq: seq,
301
- initiator_id: toUin$1(notify.user1?.uid, ctx),
302
- target_user_id: toUin$1(notify.user2?.uid, ctx)
303
- }
304
- };
305
- case GroupNotifyMsgType.INVITED_BY_MEMBER: return {
306
- time,
307
- self_id: selfId,
308
- event_type: "group_invitation",
309
- data: {
310
- group_id: groupId,
311
- invitation_seq: seq,
312
- initiator_id: toUin$1(notify.user1?.uid, ctx),
313
- source_group_id: null
314
- }
315
- };
316
- default: return null;
317
- }
318
- }
319
- /**
320
- * 群通知涉及的 uid 集合(去重;get_group_notifications 与事件广播共用)。
321
- * kernel GroupEventChannel 的 onGroupNotifiesUpdated 回调参数已类型化
322
- * (GroupNotify[]),无需防御收窄。
323
- */
324
- function collectNotifyUids(notifies) {
325
- const uids = /* @__PURE__ */ new Set();
326
- for (const n of notifies) for (const uid of [n.user1?.uid, n.user2?.uid]) if (uid !== void 0 && uid !== "") uids.add(uid);
327
- return [...uids];
328
- }
329
- //#endregion
330
- //#region src/milky/action/error-map.ts
326
+ // src/milky/action/error-map.ts
331
327
  const milkyErrorCodeMap = {
332
328
  SEND_FAILED: -500,
333
329
  PERMISSION_DENIED: -405,
@@ -338,8 +334,7 @@ const milkyErrorCodeMap = {
338
334
  INVALID_STATE: -409,
339
335
  UNKNOWN: -500
340
336
  };
341
- //#endregion
342
- //#region src/milky/action/base-action.ts
337
+ // src/milky/action/base-action.ts
343
338
  /**
344
339
  * MilkyAction:Milky 动作基类(zod 校验 + KernelError → 负数 retcode)
345
340
  *
@@ -398,8 +393,7 @@ var MilkyApiAction = class extends MilkyAction {
398
393
  this.api = api;
399
394
  }
400
395
  };
401
- //#endregion
402
- //#region src/milky/action/group.ts
396
+ // src/milky/action/group.ts
403
397
  const groupIdField$1 = { group_id: z.number().int().min(10001) };
404
398
  const userIdField = { user_id: z.number().int().min(10001) };
405
399
  const optBool = z.boolean().nullable().optional();
@@ -927,8 +921,7 @@ function picUrlOf(b) {
927
921
  const url = b.pic?.url;
928
922
  return typeof url === "string" && url !== "" ? url : null;
929
923
  }
930
- //#endregion
931
- //#region src/milky/helper/segments.ts
924
+ // src/milky/helper/message/segments.ts
932
925
  /**
933
926
  * Milky 消息段 ↔ canonical 元素转换(纯函数,ADR-008)
934
927
  *
@@ -1207,8 +1200,7 @@ function fileUriToPath(uri) {
1207
1200
  return uri.replace(FILE_URI_PREFIX_RE, "");
1208
1201
  }
1209
1202
  }
1210
- //#endregion
1211
- //#region src/milky/helper/translate.ts
1203
+ // src/milky/helper/event/translate.ts
1212
1204
  /**
1213
1205
  * Milky 事件翻译(RawMessage → Milky 事件,纯函数,ADR-008)
1214
1206
  *
@@ -1313,8 +1305,7 @@ function toGroupFileUploadEvent(msg, selfUin) {
1313
1305
  }
1314
1306
  };
1315
1307
  }
1316
- //#endregion
1317
- //#region src/milky/action/message.ts
1308
+ // src/milky/action/message.ts
1318
1309
  /**
1319
1310
  * OutgoingSegment 宽松校验:入口只保证「{type, data}」形状,字段级转换在
1320
1311
  * outgoingSegmentsToCanonical 内做(未知段跳过 = 规范兼容性要求)。
@@ -1323,7 +1314,7 @@ const outgoingSegmentSchema = z.object({
1323
1314
  type: z.string(),
1324
1315
  data: z.record(z.string(), z.unknown())
1325
1316
  }).loose();
1326
- const sendMessageFields = { message: z.array(outgoingSegmentSchema).min(1) };
1317
+ const sendMessageFields = { message: z.array(outgoingSegmentSchema).min(1).max(200) };
1327
1318
  const recallFields = { message_seq: z.number().int().min(0) };
1328
1319
  /** send_private_message:发送私聊消息。 */
1329
1320
  var SendPrivateMessageAction = class extends MilkyApiAction {
@@ -1687,8 +1678,7 @@ async function sendFileMessage(api, peer, path, fileName) {
1687
1678
  const uuid = (sent?.elements.find((e) => e.fileElement !== void 0))?.fileElement?.fileUuid;
1688
1679
  return uuid !== void 0 && uuid !== "" ? uuid : msgId;
1689
1680
  }
1690
- //#endregion
1691
- //#region src/milky/action/group-file.ts
1681
+ // src/milky/action/group-file.ts
1692
1682
  const groupIdField = { group_id: z.number().int().min(10001) };
1693
1683
  const fileIdField = { file_id: z.string().min(1) };
1694
1684
  const optStr = z.string().nullable().optional();
@@ -1863,8 +1853,7 @@ var RenameGroupFolderAction = class extends MilkyApiAction {
1863
1853
  return {};
1864
1854
  }
1865
1855
  };
1866
- //#endregion
1867
- //#region src/milky/action/profile.ts
1856
+ // src/milky/action/profile.ts
1868
1857
  /**
1869
1858
  * Milky 资料类动作(P1):get_user_profile / get_friend_info / set_avatar /
1870
1859
  * set_nickname / set_bio / get_cookies / get_csrf_token
@@ -1955,8 +1944,7 @@ var GetCSRFTokenAction = class extends MilkyApiAction {
1955
1944
  return { csrf_token: TicketApi.getBkn(cookies["skey"] ?? "") };
1956
1945
  }
1957
1946
  };
1958
- //#endregion
1959
- //#region src/milky/action/social.ts
1947
+ // src/milky/action/social.ts
1960
1948
  const emptySchema$1 = z.object({}).strict();
1961
1949
  /** get_friend_list:获取好友列表。 */
1962
1950
  var GetFriendListAction = class extends MilkyApiAction {
@@ -2134,8 +2122,7 @@ function requireSelfUid(api) {
2134
2122
  }
2135
2123
  /** 可选布尔(social.ts 本文件原无 optBool,本地定义避免全局重名)。 */
2136
2124
  const optBoolNudge = z.boolean().nullable().optional();
2137
- //#endregion
2138
- //#region src/milky/action/system.ts
2125
+ // src/milky/action/system.ts
2139
2126
  /**
2140
2127
  * Milky 系统类动作(P0):get_login_info / get_impl_info
2141
2128
  *
@@ -2170,8 +2157,7 @@ var GetImplInfoAction = class extends MilkyApiAction {
2170
2157
  };
2171
2158
  }
2172
2159
  };
2173
- //#endregion
2174
- //#region src/milky/action/index.ts
2160
+ // src/milky/action/index.ts
2175
2161
  /**
2176
2162
  * Milky 动作注册表(P0 9 + P1 40 + P2 批次二 15 = 64 个)
2177
2163
  *
@@ -2249,8 +2235,7 @@ function createMilkyActionRegistry(opts) {
2249
2235
  registry.register(new RenameGroupFolderAction(api));
2250
2236
  return registry;
2251
2237
  }
2252
- //#endregion
2253
- //#region src/milky/helper/file-upload.ts
2238
+ // src/milky/helper/event/file-upload.ts
2254
2239
  /**
2255
2240
  * friend_file_upload 翻译(Milky 批次三,2026-11-01 录制定型)
2256
2241
  *
@@ -2278,8 +2263,7 @@ function toFriendFileUploadData(msg, selfUin, uidToUin) {
2278
2263
  is_self: isSelf
2279
2264
  };
2280
2265
  }
2281
- //#endregion
2282
- //#region src/milky/helper/notice.ts
2266
+ // src/milky/helper/event/notice.ts
2283
2267
  /** 毫秒 → 秒(Unix 时间戳)。 */
2284
2268
  const MS_TO_SEC = 1e3;
2285
2269
  /** uid → uin(core 共享解析;ctx 携带映射)。 */
@@ -2424,8 +2408,7 @@ function toMilkyNoticeEvent(msg, ctx) {
2424
2408
  }, "milky: 未翻译的 grayTip 子类型(raw 校准数据)");
2425
2409
  return null;
2426
2410
  }
2427
- //#endregion
2428
- //#region src/milky/helper/peer-pin.ts
2411
+ // src/milky/helper/event/peer-pin.ts
2429
2412
  /**
2430
2413
  * peer_pin_change 翻译(Milky 批次三,RecentContact/onRecentContactListChangedVer2)
2431
2414
  *
@@ -2483,8 +2466,97 @@ function toPeerPinChangeData(entry) {
2483
2466
  peerUin
2484
2467
  };
2485
2468
  }
2486
- //#endregion
2487
- //#region src/milky/helper/recent-keys.ts
2469
+ // src/milky/helper/event/sysmsg.ts
2470
+ /**
2471
+ * Milky sysmsg 识别表(批次三,2026-11-01;识别机制共享自 core/sysmsg.ts)
2472
+ *
2473
+ * 键 = 原生分发键 "msgType:subType",规则产出事件 data 体(信封 time/self_id/
2474
+ * event_type 由适配器统一包装)。路径依据 = 三轮录制 wire bytes 全量解码
2475
+ * (milky.md §0.8.6 识别表;临时解码脚本 .napuketto/decode-sysmsg*.mjs 不入库)。
2476
+ *
2477
+ * - 732:16 群消息表情回应:f1.f1=群号;f3.f2.f44.f1.f1={f1 变动值, f2.f1=msgSeq,
2478
+ * f3={f1 faceId 字符串, f5: 1=添加/2=撤销, f3:1 仅添加时存在}}。
2479
+ * operator 不在 push(f4=bot 自身 uid 占位)——user_id 省略。
2480
+ * - 732:1 群精华设置:f1.f1=群号, f1.f8.f8.f1=msgSeq(路径提取共享自
2481
+ * core/shared/essence.ts extractEssenceSetSysMsg);取消精华无独立 sysmsg
2482
+ * (remove 走 onGroupEssenceListChange 列表 diff,core/shared/essence.ts)。
2483
+ * - 528:349/381/382 多端设备同步族:不广播。
2484
+ */
2485
+ /** 数字串判别(faceId 实证为数字字符串)。 */
2486
+ const NUMERIC_RE$1 = /^\d+$/;
2487
+ /** 732:16 → group_message_reaction。 */
2488
+ const REACTION_RULE = {
2489
+ kind: "group_message_reaction",
2490
+ extract: (tree) => reactionData(tree)
2491
+ };
2492
+ /** 路径提取:f1.f1=群号 + f3.f2.f44.f1.f1=回应明细(任一缺失 → null)。 */
2493
+ function reactionData(tree) {
2494
+ const groupId = varintAt(tree, [1, 1]);
2495
+ const detail = nodeAt(tree, [
2496
+ 3,
2497
+ 2,
2498
+ 44,
2499
+ 1,
2500
+ 1
2501
+ ]);
2502
+ if (groupId === null || detail === null) return null;
2503
+ return reactionDetail(groupId, detail);
2504
+ }
2505
+ /** 明细提取:f2.f1=msgSeq + f3=face 块(任一缺失 → null)。 */
2506
+ function reactionDetail(groupId, detail) {
2507
+ const msgSeq = varintAt(detail, [2, 1]);
2508
+ const face = nodeAt(detail, [3]);
2509
+ if (msgSeq === null || face === null) return null;
2510
+ return reactionFace(groupId, msgSeq, face);
2511
+ }
2512
+ /** face 块提取:faceId 实证为数字字符串("76"/"124"…);f5 双判据(f3 仅添加时存在)。 */
2513
+ function reactionFace(groupId, msgSeq, face) {
2514
+ const isAdd = reactionIsAdd(face);
2515
+ const faceId = reactionFaceId(face);
2516
+ if (isAdd === null || faceId === null) return null;
2517
+ return {
2518
+ group_id: groupId,
2519
+ message_seq: msgSeq,
2520
+ face_id: faceId,
2521
+ reaction_type: "face",
2522
+ is_add: isAdd
2523
+ };
2524
+ }
2525
+ /** faceId 字段(数字字符串 → number;缺失/非数字 → null)。 */
2526
+ function reactionFaceId(face) {
2527
+ const faceIdText = textOf(face, 1);
2528
+ return faceIdText !== null && NUMERIC_RE$1.test(faceIdText) ? Number(faceIdText) : null;
2529
+ }
2530
+ /** is_add 判定:f5=1 添加 / 2 撤销(f3=1 仅添加时存在,双判据);非法 → null。 */
2531
+ function reactionIsAdd(face) {
2532
+ const op = varintOf(face, 5);
2533
+ if (op === 1) return true;
2534
+ return op === 2 ? false : null;
2535
+ }
2536
+ /** (msgType, subType) → 规则表(键 = 原生分发键)。 */
2537
+ const KIND_TABLE = /* @__PURE__ */ new Map([["732:16", REACTION_RULE], ["732:1", {
2538
+ kind: "group_essence_message_change",
2539
+ extract: (tree) => {
2540
+ const hit = extractEssenceSetSysMsg(tree);
2541
+ if (hit === null) return null;
2542
+ return {
2543
+ group_id: hit.groupCode,
2544
+ message_seq: hit.messageSeq,
2545
+ is_set: true
2546
+ };
2547
+ }
2548
+ }]]);
2549
+ /** 已观测但未命名的键(多端设备同步族等,不广播只走校准日志)。 */
2550
+ const OBSERVED_UNNAMED = /* @__PURE__ */ new Set([
2551
+ "528:382",
2552
+ "528:349",
2553
+ "528:381"
2554
+ ]);
2555
+ /** (msgType, subType) → 识别结果(绑定 Milky 表;table 参数供单测注入)。 */
2556
+ function recognizeMilkySysMsg(msgType, subType, table = KIND_TABLE) {
2557
+ return recognizeSysMsg(msgType, subType, table, OBSERVED_UNNAMED);
2558
+ }
2559
+ // src/milky/helper/state/recent-keys.ts
2488
2560
  /**
2489
2561
  * 带过期去重键缓存(Milky 批次三)
2490
2562
  *
@@ -2512,8 +2584,7 @@ var RecentKeyCache = class {
2512
2584
  for (const [key, expiry] of this.entries) if (expiry <= now) this.entries.delete(key);
2513
2585
  }
2514
2586
  };
2515
- //#endregion
2516
- //#region src/milky/helper/seq-index.ts
2587
+ // src/milky/helper/state/seq-index.ts
2517
2588
  /** 单方向最大条目数(测试用例引用容量语义)。 */
2518
2589
  const MAX_ENTRIES = 4096;
2519
2590
  var MessageSeqIndex = class {
@@ -2590,99 +2661,7 @@ var MessageSeqIndex = class {
2590
2661
  }
2591
2662
  }
2592
2663
  };
2593
- //#endregion
2594
- //#region src/milky/helper/sysmsg.ts
2595
- /**
2596
- * Milky sysmsg 识别表(批次三,2026-11-01;识别机制共享自 core/sysmsg.ts)
2597
- *
2598
- * 键 = 原生分发键 "msgType:subType",规则产出事件 data 体(信封 time/self_id/
2599
- * event_type 由适配器统一包装)。路径依据 = 三轮录制 wire bytes 全量解码
2600
- * (milky.md §0.8.6 识别表;临时解码脚本 .napuketto/decode-sysmsg*.mjs 不入库)。
2601
- *
2602
- * - 732:16 群消息表情回应:f1.f1=群号;f3.f2.f44.f1.f1={f1 变动值, f2.f1=msgSeq,
2603
- * f3={f1 faceId 字符串, f5: 1=添加/2=撤销, f3:1 仅添加时存在}}。
2604
- * operator 不在 push(f4=bot 自身 uid 占位)——user_id 省略。
2605
- * - 732:1 群精华设置:f1.f1=群号, f1.f8.f8.f1=msgSeq(路径提取共享自
2606
- * core/essence.ts extractEssenceSetSysMsg);取消精华无独立 sysmsg
2607
- * (remove 走 onGroupEssenceListChange 列表 diff,core/essence.ts)。
2608
- * - 528:349/381/382 多端设备同步族:不广播。
2609
- */
2610
- /** 数字串判别(faceId 实证为数字字符串)。 */
2611
- const NUMERIC_RE$1 = /^\d+$/;
2612
- /** 732:16 → group_message_reaction。 */
2613
- const REACTION_RULE = {
2614
- kind: "group_message_reaction",
2615
- extract: (tree) => reactionData(tree)
2616
- };
2617
- /** 路径提取:f1.f1=群号 + f3.f2.f44.f1.f1=回应明细(任一缺失 → null)。 */
2618
- function reactionData(tree) {
2619
- const groupId = varintAt(tree, [1, 1]);
2620
- const detail = nodeAt(tree, [
2621
- 3,
2622
- 2,
2623
- 44,
2624
- 1,
2625
- 1
2626
- ]);
2627
- if (groupId === null || detail === null) return null;
2628
- return reactionDetail(groupId, detail);
2629
- }
2630
- /** 明细提取:f2.f1=msgSeq + f3=face 块(任一缺失 → null)。 */
2631
- function reactionDetail(groupId, detail) {
2632
- const msgSeq = varintAt(detail, [2, 1]);
2633
- const face = nodeAt(detail, [3]);
2634
- if (msgSeq === null || face === null) return null;
2635
- return reactionFace(groupId, msgSeq, face);
2636
- }
2637
- /** face 块提取:faceId 实证为数字字符串("76"/"124"…);f5 双判据(f3 仅添加时存在)。 */
2638
- function reactionFace(groupId, msgSeq, face) {
2639
- const isAdd = reactionIsAdd(face);
2640
- const faceId = reactionFaceId(face);
2641
- if (isAdd === null || faceId === null) return null;
2642
- return {
2643
- group_id: groupId,
2644
- message_seq: msgSeq,
2645
- face_id: faceId,
2646
- reaction_type: "face",
2647
- is_add: isAdd
2648
- };
2649
- }
2650
- /** faceId 字段(数字字符串 → number;缺失/非数字 → null)。 */
2651
- function reactionFaceId(face) {
2652
- const faceIdText = textOf(face, 1);
2653
- return faceIdText !== null && NUMERIC_RE$1.test(faceIdText) ? Number(faceIdText) : null;
2654
- }
2655
- /** is_add 判定:f5=1 添加 / 2 撤销(f3=1 仅添加时存在,双判据);非法 → null。 */
2656
- function reactionIsAdd(face) {
2657
- const op = varintOf(face, 5);
2658
- if (op === 1) return true;
2659
- return op === 2 ? false : null;
2660
- }
2661
- /** (msgType, subType) → 规则表(键 = 原生分发键)。 */
2662
- const KIND_TABLE = /* @__PURE__ */ new Map([["732:16", REACTION_RULE], ["732:1", {
2663
- kind: "group_essence_message_change",
2664
- extract: (tree) => {
2665
- const hit = extractEssenceSetSysMsg(tree);
2666
- if (hit === null) return null;
2667
- return {
2668
- group_id: hit.groupCode,
2669
- message_seq: hit.messageSeq,
2670
- is_set: true
2671
- };
2672
- }
2673
- }]]);
2674
- /** 已观测但未命名的键(多端设备同步族等,不广播只走校准日志)。 */
2675
- const OBSERVED_UNNAMED = /* @__PURE__ */ new Set([
2676
- "528:382",
2677
- "528:349",
2678
- "528:381"
2679
- ]);
2680
- /** (msgType, subType) → 识别结果(绑定 Milky 表;table 参数供单测注入)。 */
2681
- function recognizeMilkySysMsg(msgType, subType, table = KIND_TABLE) {
2682
- return recognizeSysMsg(msgType, subType, table, OBSERVED_UNNAMED);
2683
- }
2684
- //#endregion
2685
- //#region src/milky/transport.ts
2664
+ // src/milky/transport.ts
2686
2665
  /** /event 路径(规范固定)。 */
2687
2666
  const EVENT_PATH = "/event";
2688
2667
  /** /api/ 前缀 + 动作名(小写字母开头,小写/数字/下划线)。 */
@@ -2849,8 +2828,7 @@ function pathnameOf(url) {
2849
2828
  return url.split("?")[0] ?? "";
2850
2829
  }
2851
2830
  }
2852
- //#endregion
2853
- //#region src/milky/adapter.ts
2831
+ // src/milky/adapter.ts
2854
2832
  var NapukettoMilkyAdapter = class extends BaseProtocolAdapter {
2855
2833
  protocol = "milky";
2856
2834
  msgChannel;
@@ -3353,8 +3331,7 @@ function secondsOf(raw) {
3353
3331
  if (raw !== void 0 && NUMERIC_RE.test(raw)) return Number(raw);
3354
3332
  return Math.floor(Date.now() / 1e3);
3355
3333
  }
3356
- //#endregion
3357
- //#region src/milky/config.ts
3334
+ // src/milky/config.ts
3358
3335
  /**
3359
3336
  * Milky 协议配置(zod schema,归属本包,ADR-012)
3360
3337
  *
@@ -3378,7 +3355,6 @@ const milkyConfigSchema = z.object({
3378
3355
  /** 发送媒体 http(s) URI 下载缓存目录(缺省不下载 = http(s) 发送媒体不可用)。 */
3379
3356
  cacheDir: z.string().optional()
3380
3357
  });
3381
- //#endregion
3382
3358
  export { NapukettoMilkyAdapter, milkyConfigSchema };
3383
3359
 
3384
3360
  //# sourceMappingURL=index.mjs.map