@napuketto/adapter 0.9.0 → 0.11.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 (39) 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-BRbsj_Vv.mjs +135 -0
  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 +5 -21
  18. package/dist/milky/index.d.mts.map +1 -1
  19. package/dist/milky/index.mjs +193 -290
  20. package/dist/milky/index.mjs.map +1 -1
  21. package/dist/onebot11/index.d.mts +58 -63
  22. package/dist/onebot11/index.d.mts.map +1 -1
  23. package/dist/onebot11/index.mjs +246 -198
  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/buddy-req-Q7Q4bVuz.mjs +0 -43
  35. package/dist/buddy-req-Q7Q4bVuz.mjs.map +0 -1
  36. package/dist/gray-tip-LwBee5mo.mjs.map +0 -1
  37. package/dist/index-h-tsUu0j.d.mts.map +0 -1
  38. package/dist/raw-message-D_ecJy4C.mjs.map +0 -1
  39. 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 { n as MS_TO_SEC$2, r as resolveUin, t as narrowBuddyReqs } from "../buddy-req-Q7Q4bVuz.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,76 +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/essence.ts
2254
- /** 单个候选值 → 群号字符串(非空字符串 / 正整数)。 */
2255
- function toGroupCode(value) {
2256
- if (typeof value === "string" && value !== "") return value;
2257
- if (typeof value === "number" && Number.isInteger(value) && value > 0) return String(value);
2258
- return null;
2259
- }
2260
- /** onGroupEssenceListChange 参数 → 群号(录制实证首项字符串;防御收窄)。 */
2261
- function narrowEssenceGroupArg(arg) {
2262
- const first = Array.isArray(arg) ? arg[0] : arg;
2263
- if (first !== null && typeof first === "object") {
2264
- const rec = first;
2265
- for (const key of [
2266
- "groupCode",
2267
- "group_code",
2268
- "groupId",
2269
- "peerUid"
2270
- ]) {
2271
- const code = toGroupCode(rec[key]);
2272
- if (code !== null) return code;
2273
- }
2274
- return null;
2275
- }
2276
- return toGroupCode(first);
2277
- }
2278
- /** 精华列表项 → 缓存操作者(add_digest_uin 缺失/空 → 空串 = 未知)。 */
2279
- function essenceOperator(item) {
2280
- return typeof item.add_digest_uin === "string" && item.add_digest_uin !== "" ? item.add_digest_uin : "";
2281
- }
2282
- /** 列表 → 缓存 map(seq → 操作者)。 */
2283
- function buildEssenceCache(items) {
2284
- const cache = /* @__PURE__ */ new Map();
2285
- for (const item of items) if (typeof item.msg_seq === "number") cache.set(item.msg_seq, essenceOperator(item));
2286
- return cache;
2287
- }
2288
- /** 新增项收集(cache 新键即新增)。 */
2289
- function collectAdded(prev, cache) {
2290
- const added = [];
2291
- for (const [seq, operator] of cache) if (!prev.has(seq)) added.push({
2292
- messageSeq: seq,
2293
- operatorUin: operator === "" ? null : operator
2294
- });
2295
- return added;
2296
- }
2297
- /** 移除项收集(cache 无即移除;移除者不可知)。 */
2298
- function collectRemoved(prev, cache) {
2299
- const removed = [];
2300
- for (const seq of prev.keys()) if (!cache.has(seq)) removed.push(seq);
2301
- return removed;
2302
- }
2303
- /**
2304
- * 精华列表 diff:prev 缺省(基线未建立)时只建缓存不产出事件——
2305
- * 首个变更事件只做基线,避免全量首推被误报为「逐条加精」。
2306
- */
2307
- function diffEssenceList(prev, items) {
2308
- const cache = buildEssenceCache(items);
2309
- if (prev === void 0) return {
2310
- cache,
2311
- added: [],
2312
- removed: []
2313
- };
2314
- return {
2315
- cache,
2316
- added: collectAdded(prev, cache),
2317
- removed: collectRemoved(prev, cache)
2318
- };
2319
- }
2320
- //#endregion
2321
- //#region src/milky/helper/file-upload.ts
2238
+ // src/milky/helper/event/file-upload.ts
2322
2239
  /**
2323
2240
  * friend_file_upload 翻译(Milky 批次三,2026-11-01 录制定型)
2324
2241
  *
@@ -2346,8 +2263,7 @@ function toFriendFileUploadData(msg, selfUin, uidToUin) {
2346
2263
  is_self: isSelf
2347
2264
  };
2348
2265
  }
2349
- //#endregion
2350
- //#region src/milky/helper/notice.ts
2266
+ // src/milky/helper/event/notice.ts
2351
2267
  /** 毫秒 → 秒(Unix 时间戳)。 */
2352
2268
  const MS_TO_SEC = 1e3;
2353
2269
  /** uid → uin(core 共享解析;ctx 携带映射)。 */
@@ -2492,8 +2408,7 @@ function toMilkyNoticeEvent(msg, ctx) {
2492
2408
  }, "milky: 未翻译的 grayTip 子类型(raw 校准数据)");
2493
2409
  return null;
2494
2410
  }
2495
- //#endregion
2496
- //#region src/milky/helper/peer-pin.ts
2411
+ // src/milky/helper/event/peer-pin.ts
2497
2412
  /**
2498
2413
  * peer_pin_change 翻译(Milky 批次三,RecentContact/onRecentContactListChangedVer2)
2499
2414
  *
@@ -2551,8 +2466,97 @@ function toPeerPinChangeData(entry) {
2551
2466
  peerUin
2552
2467
  };
2553
2468
  }
2554
- //#endregion
2555
- //#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
2556
2560
  /**
2557
2561
  * 带过期去重键缓存(Milky 批次三)
2558
2562
  *
@@ -2580,8 +2584,7 @@ var RecentKeyCache = class {
2580
2584
  for (const [key, expiry] of this.entries) if (expiry <= now) this.entries.delete(key);
2581
2585
  }
2582
2586
  };
2583
- //#endregion
2584
- //#region src/milky/helper/seq-index.ts
2587
+ // src/milky/helper/state/seq-index.ts
2585
2588
  /** 单方向最大条目数(测试用例引用容量语义)。 */
2586
2589
  const MAX_ENTRIES = 4096;
2587
2590
  var MessageSeqIndex = class {
@@ -2658,104 +2661,7 @@ var MessageSeqIndex = class {
2658
2661
  }
2659
2662
  }
2660
2663
  };
2661
- //#endregion
2662
- //#region src/milky/helper/sysmsg.ts
2663
- /**
2664
- * Milky sysmsg 识别表(批次三,2026-11-01;识别机制共享自 core/sysmsg.ts)
2665
- *
2666
- * 键 = 原生分发键 "msgType:subType",规则产出事件 data 体(信封 time/self_id/
2667
- * event_type 由适配器统一包装)。路径依据 = 三轮录制 wire bytes 全量解码
2668
- * (milky.md §0.8.6 识别表;临时解码脚本 .napuketto/decode-sysmsg*.mjs 不入库)。
2669
- *
2670
- * - 732:16 群消息表情回应:f1.f1=群号;f3.f2.f44.f1.f1={f1 变动值, f2.f1=msgSeq,
2671
- * f3={f1 faceId 字符串, f5: 1=添加/2=撤销, f3:1 仅添加时存在}}。
2672
- * operator 不在 push(f4=bot 自身 uid 占位)——user_id 省略。
2673
- * - 732:1 群精华设置:f1.f1=群号, f1.f8.f8.f1=msgSeq;取消精华无独立 sysmsg
2674
- * (remove 走 onGroupEssenceListChange 列表 diff,helper/essence.ts)。
2675
- * - 528:349/381/382 多端设备同步族:不广播。
2676
- */
2677
- /** 数字串判别(faceId 实证为数字字符串)。 */
2678
- const NUMERIC_RE$1 = /^\d+$/;
2679
- /** 732:16 → group_message_reaction。 */
2680
- const REACTION_RULE = {
2681
- kind: "group_message_reaction",
2682
- extract: (tree) => reactionData(tree)
2683
- };
2684
- /** 路径提取:f1.f1=群号 + f3.f2.f44.f1.f1=回应明细(任一缺失 → null)。 */
2685
- function reactionData(tree) {
2686
- const groupId = varintAt(tree, [1, 1]);
2687
- const detail = nodeAt(tree, [
2688
- 3,
2689
- 2,
2690
- 44,
2691
- 1,
2692
- 1
2693
- ]);
2694
- if (groupId === null || detail === null) return null;
2695
- return reactionDetail(groupId, detail);
2696
- }
2697
- /** 明细提取:f2.f1=msgSeq + f3=face 块(任一缺失 → null)。 */
2698
- function reactionDetail(groupId, detail) {
2699
- const msgSeq = varintAt(detail, [2, 1]);
2700
- const face = nodeAt(detail, [3]);
2701
- if (msgSeq === null || face === null) return null;
2702
- return reactionFace(groupId, msgSeq, face);
2703
- }
2704
- /** face 块提取:faceId 实证为数字字符串("76"/"124"…);f5 双判据(f3 仅添加时存在)。 */
2705
- function reactionFace(groupId, msgSeq, face) {
2706
- const isAdd = reactionIsAdd(face);
2707
- const faceId = reactionFaceId(face);
2708
- if (isAdd === null || faceId === null) return null;
2709
- return {
2710
- group_id: groupId,
2711
- message_seq: msgSeq,
2712
- face_id: faceId,
2713
- reaction_type: "face",
2714
- is_add: isAdd
2715
- };
2716
- }
2717
- /** faceId 字段(数字字符串 → number;缺失/非数字 → null)。 */
2718
- function reactionFaceId(face) {
2719
- const faceIdText = textOf(face, 1);
2720
- return faceIdText !== null && NUMERIC_RE$1.test(faceIdText) ? Number(faceIdText) : null;
2721
- }
2722
- /** is_add 判定:f5=1 添加 / 2 撤销(f3=1 仅添加时存在,双判据);非法 → null。 */
2723
- function reactionIsAdd(face) {
2724
- const op = varintOf(face, 5);
2725
- if (op === 1) return true;
2726
- return op === 2 ? false : null;
2727
- }
2728
- /** (msgType, subType) → 规则表(键 = 原生分发键)。 */
2729
- const KIND_TABLE = /* @__PURE__ */ new Map([["732:16", REACTION_RULE], ["732:1", {
2730
- kind: "group_essence_message_change",
2731
- extract: (tree) => {
2732
- const groupId = varintAt(tree, [1, 1]);
2733
- const msgSeq = varintAt(tree, [
2734
- 1,
2735
- 8,
2736
- 8,
2737
- 1
2738
- ]);
2739
- if (groupId === null || msgSeq === null) return null;
2740
- return {
2741
- group_id: groupId,
2742
- message_seq: msgSeq,
2743
- is_set: true
2744
- };
2745
- }
2746
- }]]);
2747
- /** 已观测但未命名的键(多端设备同步族等,不广播只走校准日志)。 */
2748
- const OBSERVED_UNNAMED = /* @__PURE__ */ new Set([
2749
- "528:382",
2750
- "528:349",
2751
- "528:381"
2752
- ]);
2753
- /** (msgType, subType) → 识别结果(绑定 Milky 表;table 参数供单测注入)。 */
2754
- function recognizeMilkySysMsg(msgType, subType, table = KIND_TABLE) {
2755
- return recognizeSysMsg(msgType, subType, table, OBSERVED_UNNAMED);
2756
- }
2757
- //#endregion
2758
- //#region src/milky/transport.ts
2664
+ // src/milky/transport.ts
2759
2665
  /** /event 路径(规范固定)。 */
2760
2666
  const EVENT_PATH = "/event";
2761
2667
  /** /api/ 前缀 + 动作名(小写字母开头,小写/数字/下划线)。 */
@@ -2922,8 +2828,7 @@ function pathnameOf(url) {
2922
2828
  return url.split("?")[0] ?? "";
2923
2829
  }
2924
2830
  }
2925
- //#endregion
2926
- //#region src/milky/adapter.ts
2831
+ // src/milky/adapter.ts
2927
2832
  var NapukettoMilkyAdapter = class extends BaseProtocolAdapter {
2928
2833
  protocol = "milky";
2929
2834
  msgChannel;
@@ -2937,7 +2842,7 @@ var NapukettoMilkyAdapter = class extends BaseProtocolAdapter {
2937
2842
  fileKeys = new RecentKeyCache(6e5);
2938
2843
  /** essence 双路径去重(732:1 快路径 vs 列表 diff,键 群:seq:方向)。 */
2939
2844
  essenceKeys = new RecentKeyCache(3e5);
2940
- /** 精华列表缓存(群号 → seq → 操作者 uin,空串 = 未知)。 */
2845
+ /** 精华列表缓存(群号 → seq → 条目{操作者/发送者})。 */
2941
2846
  essenceCaches = /* @__PURE__ */ new Map();
2942
2847
  /** 精华列表拉取串行链(并发回写乱序会把新列表覆盖成旧列表)。 */
2943
2848
  essenceChain = Promise.resolve();
@@ -3426,8 +3331,7 @@ function secondsOf(raw) {
3426
3331
  if (raw !== void 0 && NUMERIC_RE.test(raw)) return Number(raw);
3427
3332
  return Math.floor(Date.now() / 1e3);
3428
3333
  }
3429
- //#endregion
3430
- //#region src/milky/config.ts
3334
+ // src/milky/config.ts
3431
3335
  /**
3432
3336
  * Milky 协议配置(zod schema,归属本包,ADR-012)
3433
3337
  *
@@ -3451,7 +3355,6 @@ const milkyConfigSchema = z.object({
3451
3355
  /** 发送媒体 http(s) URI 下载缓存目录(缺省不下载 = http(s) 发送媒体不可用)。 */
3452
3356
  cacheDir: z.string().optional()
3453
3357
  });
3454
- //#endregion
3455
3358
  export { NapukettoMilkyAdapter, milkyConfigSchema };
3456
3359
 
3457
3360
  //# sourceMappingURL=index.mjs.map