@napuketto/adapter 0.17.0 → 0.18.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/{buddy-req-BvAxJo6d.mjs → buddy-req-CN7gzJpq.mjs} +51 -14
  2. package/dist/buddy-req-CN7gzJpq.mjs.map +1 -0
  3. package/dist/core/index.mjs +1 -1
  4. package/dist/{core-D8sq68iP.mjs → core-C7Nnl45P.mjs} +3 -3
  5. package/dist/core-C7Nnl45P.mjs.map +1 -0
  6. package/dist/index-B-HpCes-.d.mts.map +1 -1
  7. package/dist/{index-DBD-IZKn.d.mts → index-B2Hf9yzT.d.mts} +18 -6
  8. package/dist/{index-DBD-IZKn.d.mts.map → index-B2Hf9yzT.d.mts.map} +1 -1
  9. package/dist/index-DBjlR2dn.d.mts.map +1 -1
  10. package/dist/{index-CepyMhuM.d.mts → index-d_RSpWyb.d.mts} +17 -6
  11. package/dist/index-d_RSpWyb.d.mts.map +1 -0
  12. package/dist/index-dsurF2t_.d.mts.map +1 -1
  13. package/dist/index.d.mts +2 -2
  14. package/dist/index.mjs +5 -5
  15. package/dist/kurobot/index.mjs +1 -1
  16. package/dist/{kurobot-cMBAVX3L.mjs → kurobot-B3por6f4.mjs} +19 -19
  17. package/dist/kurobot-B3por6f4.mjs.map +1 -0
  18. package/dist/milky/index.d.mts +1 -1
  19. package/dist/milky/index.mjs +1 -1
  20. package/dist/{milky-CYAOJLv_.mjs → milky-Dpk2r5RV.mjs} +261 -145
  21. package/dist/milky-Dpk2r5RV.mjs.map +1 -0
  22. package/dist/onebot11/index.d.mts +1 -1
  23. package/dist/onebot11/index.mjs +1 -1
  24. package/dist/{onebot11-BikYDo3k.mjs → onebot11-D_JlAsjy.mjs} +254 -150
  25. package/dist/onebot11-D_JlAsjy.mjs.map +1 -0
  26. package/dist/{raw-message-D5nMIebz.mjs → raw-message-Cs4vDKUU.mjs} +11 -3
  27. package/dist/raw-message-Cs4vDKUU.mjs.map +1 -0
  28. package/dist/satori/index.mjs +1 -1
  29. package/dist/{satori-Cb2uM3PY.mjs → satori-Deamai7y.mjs} +47 -22
  30. package/dist/satori-Deamai7y.mjs.map +1 -0
  31. package/package.json +4 -4
  32. package/dist/buddy-req-BvAxJo6d.mjs.map +0 -1
  33. package/dist/core-D8sq68iP.mjs.map +0 -1
  34. package/dist/index-CepyMhuM.d.mts.map +0 -1
  35. package/dist/kurobot-cMBAVX3L.mjs.map +0 -1
  36. package/dist/milky-CYAOJLv_.mjs.map +0 -1
  37. package/dist/onebot11-BikYDo3k.mjs.map +0 -1
  38. package/dist/raw-message-D5nMIebz.mjs.map +0 -1
  39. package/dist/satori-Cb2uM3PY.mjs.map +0 -1
@@ -1,8 +1,8 @@
1
- import { a as resolveProtocolConfig, i as BaseProtocolAdapter, o as ActionRegistry, s as runAction } from "./core-D8sq68iP.mjs";
1
+ import { a as resolveProtocolConfig, i as BaseProtocolAdapter, o as ActionRegistry, s as runAction } from "./core-C7Nnl45P.mjs";
2
2
  import { a as logEventFailure, i as hasGrayTip, n as findRevokeElement, o as sliceRaw, r as firstUntranslatedGrayTip, t as collectGrayTipUids, u as fileUriToPath } from "./gray-tip-DmZmdtjP.mjs";
3
- import { a as firstNonEmptyString, c as MS_TO_SEC, d as resolveUin, f as toUin, i as toUnixSeconds, l as NUMERIC_RE, o as stringOrUndefined, r as subscribeRawMessages, s as startupBaselineSec, t as forEachRawMessage, u as numericUin } from "./raw-message-D5nMIebz.mjs";
4
- import { a as EssenceListSync, c as OBSERVED_UNNAMED_SYSMSG_KEYS, d as processSysMsgBlob, f as recognizeSysMsg, h as varintOf, i as narrowBuddyReqs, l as narrowSysMsgBlobs, m as varintAt, n as batchUnreadNums, o as extractEssenceSetSysMsg, p as textOf, r as filterBuddyReqs, s as narrowEssenceGroupArg, t as BuddyReqDedup, u as nodeAt } from "./buddy-req-BvAxJo6d.mjs";
5
- import { ChatType, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupMemberRole, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, errorMessage, kernelError, toCanonicalElements } from "@napuketto/kernel";
3
+ import { a as firstNonEmptyString, c as MS_TO_SEC, d as resolveUin, f as toUin, i as toUnixSeconds, l as NUMERIC_RE, o as stringOrUndefined, r as subscribeRawMessages, s as startupBaselineSec, t as forEachRawMessage, u as numericUin } from "./raw-message-Cs4vDKUU.mjs";
4
+ import { a as EssenceListSync, c as OBSERVED_UNNAMED_SYSMSG_KEYS, d as processSysMsgBlob, f as recognizeSysMsg, h as varintOf, i as narrowBuddyReqs, l as narrowSysMsgBlobs, m as varintAt, n as batchUnreadNums, o as extractEssenceSetSysMsg, p as textOf, r as filterBuddyReqs, s as narrowEssenceGroupArg, t as BuddyReqDedup, u as nodeAt } from "./buddy-req-CN7gzJpq.mjs";
5
+ import { ChatType, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupMemberRole, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, errorMessage, hasNumberProp, hasStringProp, isRecord, kernelError, toCanonicalElements } from "@napuketto/kernel";
6
6
  import { HttpClient, HttpServer, createSseResponse, isWsOpen } from "@napuketto/network";
7
7
  import { z } from "zod";
8
8
  import { randomUUID } from "node:crypto";
@@ -308,13 +308,13 @@ function essenceToEntity(item, groupId) {
308
308
  });
309
309
  return {
310
310
  group_id: groupId,
311
- message_seq: item.msg_seq,
312
- message_time: item.add_digest_time,
311
+ message_seq: item.msg_seq ?? 0,
312
+ message_time: item.add_digest_time ?? 0,
313
313
  sender_id: Number(item.sender_uin) || 0,
314
- sender_name: item.sender_nick,
314
+ sender_name: item.sender_nick ?? "",
315
315
  operator_id: Number(item.add_digest_uin) || 0,
316
- operator_name: item.add_digest_nick,
317
- operation_time: item.add_digest_time,
316
+ operator_name: item.add_digest_nick ?? "",
317
+ operation_time: item.add_digest_time ?? 0,
318
318
  segments
319
319
  };
320
320
  }
@@ -1076,6 +1076,10 @@ function notifyToEntity(notify, isFiltered, uidToUin) {
1076
1076
  return entity;
1077
1077
  }
1078
1078
  // src/milky/helper/message/segments.ts
1079
+ /** 发送段最小形状守卫(type + data 对象)。 */
1080
+ function isRawOutgoingSegment(val) {
1081
+ return isRecord(val) && hasStringProp(val, "type") && isRecord(val["data"]);
1082
+ }
1079
1083
  /** uin 字符串 → Milky user_id(非有限正数 = 转换失败)。 */
1080
1084
  function toUserId(uin) {
1081
1085
  const n = Number(uin);
@@ -1128,43 +1132,62 @@ function videoToIncoming(el) {
1128
1132
  }
1129
1133
  };
1130
1134
  }
1131
- /** 按类型分发的段映射器表(键 = canonical type;缺项 = 跳过)。 */
1132
- const INCOMING_MAPPERS = {
1133
- text: (el) => ({
1134
- type: "text",
1135
- data: { text: el.text }
1136
- }),
1137
- at: atToIncoming,
1138
- face: (el) => ({
1139
- type: "face",
1140
- data: {
1141
- face_id: el.id,
1142
- is_large: false
1143
- }
1144
- }),
1145
- reply: replyToIncoming,
1146
- image: imageToIncoming,
1147
- voice: voiceToIncoming,
1148
- video: videoToIncoming,
1149
- file: fileToIncoming,
1150
- json: (el) => ({
1151
- type: "light_app",
1152
- data: {
1153
- app_name: parseAppName(el.raw),
1154
- json_payload: rawToPayload(el.raw)
1155
- }
1156
- }),
1157
- xml: (el) => ({
1158
- type: "xml",
1159
- data: {
1160
- service_id: 0,
1161
- xml_payload: rawToPayload(el.raw)
1162
- }
1163
- })
1164
- };
1135
+ /**
1136
+ * canonical → IncomingSegment 单元素分发(可辨识联合 switch)。
1137
+ * 未映射类型(unknown / forward / 规范无对应)→ null(规范兼容性要求跳过)。
1138
+ *
1139
+ * 按「简单段 / 媒体与载荷段」拆两级:一级 switch 只分派,二级各管一类,
1140
+ * 单函数分支数保持低位(fallow 复杂度门禁)。
1141
+ */
1165
1142
  function canonicalToIncomingSegment(el, ctx) {
1166
- const mapper = INCOMING_MAPPERS[el.type];
1167
- return mapper === void 0 ? null : mapper(el, ctx);
1143
+ switch (el.type) {
1144
+ case "at": return atToIncoming(el, ctx);
1145
+ case "reply": return replyToIncoming(el, ctx);
1146
+ case "text":
1147
+ case "face":
1148
+ case "file": return simpleIncoming(el);
1149
+ default: return mediaOrPayloadIncoming(el);
1150
+ }
1151
+ }
1152
+ /** text / face / file 直映射。 */
1153
+ function simpleIncoming(el) {
1154
+ switch (el.type) {
1155
+ case "text": return {
1156
+ type: "text",
1157
+ data: { text: el.text }
1158
+ };
1159
+ case "face": return {
1160
+ type: "face",
1161
+ data: {
1162
+ face_id: el.id,
1163
+ is_large: false
1164
+ }
1165
+ };
1166
+ case "file": return fileToIncoming(el);
1167
+ }
1168
+ }
1169
+ /** 媒体段(image / voice / video)与载荷段(json / xml)映射;其余返回 null。 */
1170
+ function mediaOrPayloadIncoming(el) {
1171
+ switch (el.type) {
1172
+ case "image": return imageToIncoming(el);
1173
+ case "voice": return voiceToIncoming(el);
1174
+ case "video": return videoToIncoming(el);
1175
+ case "json": return {
1176
+ type: "light_app",
1177
+ data: {
1178
+ app_name: parseAppName(el.raw),
1179
+ json_payload: rawToPayload(el.raw)
1180
+ }
1181
+ };
1182
+ case "xml": return {
1183
+ type: "xml",
1184
+ data: {
1185
+ service_id: 0,
1186
+ xml_payload: rawToPayload(el.raw)
1187
+ }
1188
+ };
1189
+ default: return null;
1190
+ }
1168
1191
  }
1169
1192
  /** canonical at → mention / mention_all(uid→uin 失败跳过该段)。 */
1170
1193
  function atToIncoming(el, ctx) {
@@ -1232,7 +1255,7 @@ function parseAppName(raw) {
1232
1255
  } catch {
1233
1256
  return "";
1234
1257
  }
1235
- if (typeof obj !== "object" || obj === null || !("app" in obj)) return "";
1258
+ if (!isRecord(obj)) return "";
1236
1259
  const app = obj["app"];
1237
1260
  return typeof app === "string" ? app : "";
1238
1261
  }
@@ -1248,74 +1271,23 @@ function rawToPayload(raw) {
1248
1271
  /**
1249
1272
  * OutgoingSegment 数组 → canonical 元素(同步映射;媒体 URI 解析与 at uin→uid
1250
1273
  * 由调用方在返回值上继续处理)。
1251
- * forward 在此报错:顶层 forward 已由 sendMilkyMessage 分流到组装链(message.ts,
1252
- *),命中本分支 = forward 与其他段混发漏网或嵌套 forward(组装链内逐项
1253
- * 转换经过此处)——均显式拒绝。
1274
+ *
1275
+ * 入参兼容 `RawOutgoingSegment`(HTTP 载荷只保证 {type,data} 形状):已知类型的
1276
+ * 必填字段逐项守卫,缺失/类型错误立即抛 INVALID_PARAM;未知 type 按协议跳过。
1277
+ * forward 在此报错:顶层 forward 已由 sendMilkyMessage 分流到组装链(message.ts),
1278
+ * 命中本分支 = forward 与其他段混发漏网或嵌套 forward(组装链内逐项转换经过此处)
1279
+ * ——均显式拒绝。
1254
1280
  */
1255
1281
  function outgoingSegmentsToCanonical(segments) {
1256
1282
  const elements = [];
1257
1283
  const atUins = [];
1258
1284
  const replySeqs = [];
1259
- for (const seg of segments) switch (seg.type) {
1260
- case "text":
1261
- elements.push({
1262
- type: "text",
1263
- text: seg.data.text
1264
- });
1265
- break;
1266
- case "mention": {
1267
- const uin = String(seg.data.user_id);
1268
- atUins.push(uin);
1269
- elements.push({
1270
- type: "at",
1271
- target: uin
1272
- });
1273
- break;
1274
- }
1275
- case "mention_all":
1276
- elements.push({
1277
- type: "at",
1278
- target: "all"
1279
- });
1280
- break;
1281
- case "face":
1282
- elements.push({
1283
- type: "face",
1284
- id: seg.data.face_id
1285
- });
1286
- break;
1287
- case "reply":
1288
- replySeqs.push(seg.data.message_seq);
1289
- elements.push({
1290
- type: "reply",
1291
- messageId: String(seg.data.message_seq)
1292
- });
1293
- break;
1294
- case "image":
1295
- elements.push({
1296
- type: "image",
1297
- path: resolveUriToPathPlaceholder(seg.data.uri)
1298
- });
1299
- break;
1300
- case "record":
1301
- elements.push({
1302
- type: "voice",
1303
- path: resolveUriToPathPlaceholder(seg.data.uri)
1304
- });
1305
- break;
1306
- case "video":
1307
- elements.push({
1308
- type: "video",
1309
- path: resolveUriToPathPlaceholder(seg.data.uri)
1310
- });
1311
- break;
1312
- case "light_app":
1313
- elements.push({
1314
- type: "json",
1315
- raw: seg.data.json_payload
1316
- });
1317
- break;
1318
- case "forward": throw kernelError("forward 段不可与其他消息段混发或嵌套(顶层 forward 须单独发送)", "INVALID_PARAM");
1285
+ for (const seg of segments) {
1286
+ const converted = outgoingSegmentToCanonical(seg);
1287
+ if (converted === null) continue;
1288
+ elements.push(converted.element);
1289
+ if (converted.atUin !== void 0) atUins.push(converted.atUin);
1290
+ if (converted.replySeq !== void 0) replySeqs.push(converted.replySeq);
1319
1291
  }
1320
1292
  return {
1321
1293
  elements,
@@ -1323,6 +1295,115 @@ function outgoingSegmentsToCanonical(segments) {
1323
1295
  replySeqs
1324
1296
  };
1325
1297
  }
1298
+ /** 段 data 收窄(非对象按空对象处理,字段守卫会立即拒绝)。 */
1299
+ function segmentData(seg) {
1300
+ return isRecord(seg.data) ? seg.data : {};
1301
+ }
1302
+ /** 已知段缺必填字段 / 类型错误 → INVALID_PARAM。 */
1303
+ function invalidSegment(type) {
1304
+ throw kernelError(`Milky 消息段 ${type} 参数不合法`, "INVALID_PARAM");
1305
+ }
1306
+ /** text 段(必填 text: string)。 */
1307
+ function textSegment(data) {
1308
+ if (!hasStringProp(data, "text")) return invalidSegment("text");
1309
+ return { element: {
1310
+ type: "text",
1311
+ text: data["text"]
1312
+ } };
1313
+ }
1314
+ /** mention 段(必填 user_id: number)。 */
1315
+ function mentionSegment(data) {
1316
+ if (!hasNumberProp(data, "user_id")) return invalidSegment("mention");
1317
+ const uin = String(data["user_id"]);
1318
+ return {
1319
+ element: {
1320
+ type: "at",
1321
+ target: uin
1322
+ },
1323
+ atUin: uin
1324
+ };
1325
+ }
1326
+ /** face 段(必填 face_id: string)。 */
1327
+ function faceSegment(data) {
1328
+ if (!hasStringProp(data, "face_id")) return invalidSegment("face");
1329
+ return { element: {
1330
+ type: "face",
1331
+ id: data["face_id"]
1332
+ } };
1333
+ }
1334
+ /** reply 段(必填 message_seq: number)。 */
1335
+ function replySegment(data) {
1336
+ if (!hasNumberProp(data, "message_seq")) return invalidSegment("reply");
1337
+ return {
1338
+ element: {
1339
+ type: "reply",
1340
+ messageId: String(data["message_seq"])
1341
+ },
1342
+ replySeq: data["message_seq"]
1343
+ };
1344
+ }
1345
+ /** 媒体段(image/record/video,必填 uri: string)。 */
1346
+ function mediaSegment(type, data) {
1347
+ if (!hasStringProp(data, "uri")) return invalidSegment(type);
1348
+ const path = resolveUriToPathPlaceholder(data["uri"]);
1349
+ if (type === "record") return { element: {
1350
+ type: "voice",
1351
+ path
1352
+ } };
1353
+ return { element: {
1354
+ type: type === "image" ? "image" : "video",
1355
+ path
1356
+ } };
1357
+ }
1358
+ /** light_app 段(json_payload 缺省按空串,保持容忍)。 */
1359
+ function lightAppSegment(data) {
1360
+ const payload = data["json_payload"];
1361
+ return { element: {
1362
+ type: "json",
1363
+ raw: typeof payload === "string" ? payload : ""
1364
+ } };
1365
+ }
1366
+ /** 简单段类型判定(字面量联合收窄)。 */
1367
+ function isSimpleOutgoingType(type) {
1368
+ switch (type) {
1369
+ case "text":
1370
+ case "mention":
1371
+ case "mention_all":
1372
+ case "face":
1373
+ case "reply": return true;
1374
+ default: return false;
1375
+ }
1376
+ }
1377
+ /** 简单段分发。 */
1378
+ function simpleOutgoingSegment(type, data) {
1379
+ switch (type) {
1380
+ case "text": return textSegment(data);
1381
+ case "mention": return mentionSegment(data);
1382
+ case "mention_all": return { element: {
1383
+ type: "at",
1384
+ target: "all"
1385
+ } };
1386
+ case "face": return faceSegment(data);
1387
+ case "reply": return replySegment(data);
1388
+ }
1389
+ }
1390
+ /** 复杂段分发(媒体 / light_app / forward / 未知)。 */
1391
+ function complexOutgoingSegment(type, data) {
1392
+ switch (type) {
1393
+ case "image": return mediaSegment("image", data);
1394
+ case "record": return mediaSegment("record", data);
1395
+ case "video": return mediaSegment("video", data);
1396
+ case "light_app": return lightAppSegment(data);
1397
+ case "forward": throw kernelError("forward 段不可与其他消息段混发或嵌套(顶层 forward 须单独发送)", "INVALID_PARAM");
1398
+ default: return null;
1399
+ }
1400
+ }
1401
+ /** 单段分派入口(简单段 / 复杂段两级,避免单函数分支过多)。 */
1402
+ function outgoingSegmentToCanonical(seg) {
1403
+ const data = segmentData(seg);
1404
+ if (isSimpleOutgoingType(seg.type)) return simpleOutgoingSegment(seg.type, data);
1405
+ return complexOutgoingSegment(seg.type, data);
1406
+ }
1326
1407
  /**
1327
1408
  * 媒体 URI → 本地路径(同步面:file:// / 裸路径直接给 canonical;base64:// 与
1328
1409
  * http(s):// 需要异步落盘,由 send 核心在 canonical 上二次解析——此处先放原始
@@ -1699,7 +1780,9 @@ async function recallBySeq(peer, seq, api) {
1699
1780
  // src/milky/action/message-send.ts
1700
1781
  /**
1701
1782
  * OutgoingSegment 宽松校验:入口只保证「{type, data}」形状,字段级转换在
1702
- * outgoingSegmentsToCanonical 内做(未知段跳过 = 规范兼容性要求)。
1783
+ * outgoingSegmentsToCanonical 内做(已知段缺字段抛 INVALID_PARAM,未知段跳过)。
1784
+ * 类型标注直接写 RawOutgoingSegment——不再把「只保证 {type,data} 的入口值」
1785
+ * 谎称成完整的 OutgoingSegment:入口本就不保证字段,校验后的形状必须诚实。
1703
1786
  */
1704
1787
  const outgoingSegmentSchema = z.object({
1705
1788
  type: z.string(),
@@ -1751,7 +1834,7 @@ async function sendForwardComposition(peer, segments, api) {
1751
1834
  if (segments.length !== 1) throw kernelError("forward 段必须单独发送(不支持与其他消息段混发)", "INVALID_PARAM");
1752
1835
  const [forward] = segments;
1753
1836
  if (forward === void 0 || forward.type !== "forward") throw kernelError("forward 组装链收到非 forward 段", "UNKNOWN");
1754
- const messages = narrowForwardMessages(forward);
1837
+ const messages = narrowForwardMessages(forward.data);
1755
1838
  const srcMsgIds = [];
1756
1839
  for (const [i, item] of messages.entries()) {
1757
1840
  const { elements, atUins } = outgoingSegmentsToCanonical(item.segments);
@@ -1766,18 +1849,24 @@ async function sendForwardComposition(peer, segments, api) {
1766
1849
  }
1767
1850
  /**
1768
1851
  * forward 段载荷收窄(入口 schema 只保证 data 为 record):messages 非空数组,
1769
- * 项内 segments 非空数组。user_id / sender_name / time 不参与组装不校验
1770
- * (丢弃字段不设门槛);title / preview / summary / prompt 忽略。
1852
+ * 项内 segments 非空数组且**每个元素**都是 {type, data} 对象。user_id /
1853
+ * sender_name / time 不参与组装不校验(丢弃字段不设门槛);title / preview /
1854
+ * summary / prompt 忽略。
1771
1855
  */
1772
- function narrowForwardMessages(forward) {
1773
- const raw = forward.data.messages;
1856
+ function narrowForwardMessages(data) {
1857
+ const raw = data["messages"];
1774
1858
  if (!Array.isArray(raw) || raw.length === 0) throw kernelError("forward 段 messages 必须是非空数组", "INVALID_PARAM");
1775
1859
  const out = [];
1776
1860
  for (const item of raw) {
1777
- if (typeof item !== "object" || item === null) throw kernelError("forward 段 messages 项必须是对象", "INVALID_PARAM");
1778
- const segments = item.segments;
1861
+ if (!isRecord(item)) throw kernelError("forward 段 messages 项必须是对象", "INVALID_PARAM");
1862
+ const segments = item["segments"];
1779
1863
  if (!Array.isArray(segments) || segments.length === 0) throw kernelError("forward 段 messages 项的 segments 必须是非空数组", "INVALID_PARAM");
1780
- out.push(item);
1864
+ const narrowed = [];
1865
+ for (const segment of segments) {
1866
+ if (!isRawOutgoingSegment(segment)) throw kernelError("forward 段内嵌 segment 必须是包含 type 与 data 的对象", "INVALID_PARAM");
1867
+ narrowed.push(segment);
1868
+ }
1869
+ out.push({ segments: narrowed });
1781
1870
  }
1782
1871
  return out;
1783
1872
  }
@@ -1820,18 +1909,15 @@ async function resolveElement(el, uinToUid, api) {
1820
1909
  ...el,
1821
1910
  target: uinToUid?.get(el.target) ?? el.target
1822
1911
  };
1823
- if (isRemoteMediaUri(el)) {
1824
- const media = el;
1825
- return {
1826
- ...media,
1827
- path: await resolveMediaUri(media.path, api.mediaDir)
1828
- };
1829
- }
1912
+ if ((el.type === "image" || el.type === "voice" || el.type === "video") && isRemoteMediaUri(el)) return {
1913
+ ...el,
1914
+ path: await resolveMediaUri(el.path, api.mediaDir)
1915
+ };
1830
1916
  return el;
1831
1917
  }
1832
1918
  /** 远程媒体元素(image/voice/video 且 path 为需落盘的 URI)。 */
1833
1919
  function isRemoteMediaUri(el) {
1834
- return (el.type === "image" || el.type === "voice" || el.type === "video") && (el.path.startsWith("http://") || el.path.startsWith("https://") || el.path.startsWith("base64://"));
1920
+ return el.path.startsWith("http://") || el.path.startsWith("https://") || el.path.startsWith("base64://");
1835
1921
  }
1836
1922
  // src/milky/action/profile.ts
1837
1923
  /**
@@ -1977,17 +2063,20 @@ function createSocialActions(api) {
1977
2063
  }, "milky: 好友申请 uid→uin 失败,initiator_id 兜底 0");
1978
2064
  return /* @__PURE__ */ new Map();
1979
2065
  });
1980
- const requests = reqs.map((req) => ({
1981
- time: Number(req.reqTime) || 0,
1982
- initiator_id: Number(uidToUin.get(req.friendUid)) || 0,
1983
- initiator_uid: req.friendUid,
1984
- target_user_id: Number(api.self.uin),
1985
- target_user_uid: api.self.uid ?? "",
1986
- state: "pending",
1987
- comment: typeof req["words"] === "string" ? req["words"] : "",
1988
- via: req.sourceName ?? "",
1989
- is_filtered: false
1990
- }));
2066
+ const requests = reqs.map((req) => {
2067
+ const words = req["words"];
2068
+ return {
2069
+ time: Number(req.reqTime) || 0,
2070
+ initiator_id: Number(uidToUin.get(req.friendUid)) || 0,
2071
+ initiator_uid: req.friendUid,
2072
+ target_user_id: Number(api.self.uin),
2073
+ target_user_uid: api.self.uid ?? "",
2074
+ state: "pending",
2075
+ comment: typeof words === "string" ? words : "",
2076
+ via: req.sourceName ?? "",
2077
+ is_filtered: false
2078
+ };
2079
+ });
1991
2080
  const limit = payload.limit ?? requests.length;
1992
2081
  return { requests: requests.slice(0, limit) };
1993
2082
  }
@@ -2394,6 +2483,10 @@ var RecentKeyCache = class {
2394
2483
  }
2395
2484
  };
2396
2485
  // src/milky/inbound/essence.ts
2486
+ /**
2487
+ * Milky inbound 精华域:双路径发射——732:1 快路径(sysmsg 域 claim 后即时广播)
2488
+ * 与列表 diff(remove 路径 + operator 回填),essenceKeys 按 群:seq:方向 去重。
2489
+ */
2397
2490
  /** Milky 精华域处理器(双路径去重 + 串行 diff 同步 + group_essence 事件广播)。 */
2398
2491
  var MilkyInboundEssence = class {
2399
2492
  deps;
@@ -2414,9 +2507,11 @@ var MilkyInboundEssence = class {
2414
2507
  /** sysmsg 732:1 快路径去重守卫:非精华恒 true;精华 claim 失败(diff 已抢发)→ false。 */
2415
2508
  claimFastPath(ruleKind, data) {
2416
2509
  if (ruleKind !== "group_essence_message_change") return true;
2417
- const rec = data;
2418
- if (typeof rec.group_id !== "number" || typeof rec.message_seq !== "number") return true;
2419
- return this.claimChange(rec.group_id, rec.message_seq, true);
2510
+ if (!isRecord(data)) return true;
2511
+ const groupId = data["group_id"];
2512
+ const seq = data["message_seq"];
2513
+ if (typeof groupId !== "number" || typeof seq !== "number") return true;
2514
+ return this.claimChange(groupId, seq, true);
2420
2515
  }
2421
2516
  /** 精华列表变更:拉全量列表 diff(remove 路径 + operator 回填;串行防乱序)。 */
2422
2517
  change(arg) {
@@ -2789,6 +2884,11 @@ function toPeerPinChangeData(entry) {
2789
2884
  };
2790
2885
  }
2791
2886
  // src/milky/inbound/pin.ts
2887
+ /**
2888
+ * Milky inbound 置顶域:RecentContact/onRecentContactListChangedVer2 →
2889
+ * peer_pin_change(topFlag 翻转检测,条目自带 chatType 判场景);启动期
2890
+ * getPinnedContacts 播种基线(重启后首个取消置顶也能观测到翻转)。
2891
+ */
2792
2892
  /** Milky 置顶域处理器(翻转检测 + 播种基线 + peer_pin_change 广播)。 */
2793
2893
  var MilkyInboundPin = class {
2794
2894
  deps;
@@ -2825,14 +2925,30 @@ var MilkyInboundPin = class {
2825
2925
  };
2826
2926
  /** 变更列表 → changedList 条目数组(形状不符 → 空)。 */
2827
2927
  function changedListOf(list) {
2828
- if (list === null || typeof list !== "object") return [];
2829
- const changed = list.changedList;
2928
+ if (!isRecord(list)) return [];
2929
+ const changed = list["changedList"];
2830
2930
  return Array.isArray(changed) ? changed : [];
2831
2931
  }
2932
+ /** 变更条目 → RecentContact 安全构造(peerUid 缺失时回退 peerUin;场景由 chatType 判定)。 */
2933
+ function toRecentContact(val) {
2934
+ if (!isRecord(val) || typeof val["chatType"] !== "number") return null;
2935
+ const peerUid = typeof val["peerUid"] === "string" ? val["peerUid"] : void 0;
2936
+ const peerUin = typeof val["peerUin"] === "string" ? val["peerUin"] : void 0;
2937
+ const resolvedPeerUid = peerUid ?? peerUin;
2938
+ if (resolvedPeerUid === void 0) return null;
2939
+ return {
2940
+ chatType: val["chatType"],
2941
+ peerUid: resolvedPeerUid,
2942
+ ...peerUin !== void 0 ? { peerUin } : {},
2943
+ ...typeof val["topFlag"] === "number" ? { topFlag: val["topFlag"] } : {},
2944
+ ...typeof val["topFlagTime"] === "string" ? { topFlagTime: val["topFlagTime"] } : {},
2945
+ ...typeof val["isTop"] === "boolean" ? { isTop: val["isTop"] } : {}
2946
+ };
2947
+ }
2832
2948
  /** 变更条目 → 翻转检测输入(null = 条目不支持/缺置顶字段)。 */
2833
2949
  function pinPayloadOf(entry) {
2834
- if (entry === null || typeof entry !== "object") return null;
2835
- return pinPayloadFrom(entry);
2950
+ const contact = toRecentContact(entry);
2951
+ return contact === null ? null : pinPayloadFrom(contact);
2836
2952
  }
2837
2953
  function pinPayloadFrom(contact) {
2838
2954
  const topFlag = contact.topFlag;
@@ -3320,4 +3436,4 @@ var NapukettoMilkyAdapter = class extends BaseProtocolAdapter {
3320
3436
  };
3321
3437
  export { MilkyApi as a, createMilkyActionRegistry as i, assembleMilkyTransports as n, milkyErrorCodeMap as o, milkyConfigSchema as r, NapukettoMilkyAdapter as t };
3322
3438
 
3323
- //# sourceMappingURL=milky-CYAOJLv_.mjs.map
3439
+ //# sourceMappingURL=milky-Dpk2r5RV.mjs.map