@napuketto/adapter 0.18.2 → 0.18.3

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.
@@ -1 +1 @@
1
- export { y as MessageUnique, t as NapukettoOneBot11Adapter, r as OneBotApi, n as assembleOb11Transports, a as canonicalToCqMessage, o as canonicalToSegments, s as cqMessageToCanonical, c as cqMessageToSegments, i as createOb11ActionRegistry, f as encodeCqCode, p as escapeCqParam, m as escapeCqText, u as ob11ConfigSchema, v as ob11ErrorCodeMap, h as parseCqMessage, l as segmentsToCanonical, d as segmentsToCqMessage, g as serializeCqParts, _ as unescapeCqText } from "../onebot11-Bypcd8J6.mjs";
1
+ export { y as MessageUnique, t as NapukettoOneBot11Adapter, r as OneBotApi, n as assembleOb11Transports, a as canonicalToCqMessage, o as canonicalToSegments, s as cqMessageToCanonical, c as cqMessageToSegments, i as createOb11ActionRegistry, f as encodeCqCode, p as escapeCqParam, m as escapeCqText, u as ob11ConfigSchema, v as ob11ErrorCodeMap, h as parseCqMessage, l as segmentsToCanonical, d as segmentsToCqMessage, g as serializeCqParts, _ as unescapeCqText } from "../onebot11-BL02tXe_.mjs";
@@ -1,7 +1,7 @@
1
1
  import { a as resolveProtocolConfig, i as BaseProtocolAdapter, l as ActionRegistry, o as BEARER_PREFIX, r as createServerSchema, s as createTokenAuthorize, u as runAction } from "./core-5cq8w_zB.mjs";
2
- import { a as firstNonEmptyString, c as MS_TO_SEC, f as toUin, i as toUnixSeconds, l as NUMERIC_RE, n as senderNickname, o as stringOrUndefined, r as subscribeRawMessages, s as startupBaselineSec, u as numericUin } from "./raw-message-Cs4vDKUU.mjs";
2
+ import { a as firstNonEmptyString, c as MS_TO_SEC, d as numericUin, f as resolveUidToUinWithFallback, i as toUnixSeconds, l as NUMERIC_RE, m as toUin, n as senderNickname, o as stringOrUndefined, r as subscribeRawMessages, s as startupBaselineSec, u as collectGroupNotifyUids } from "./raw-message-CXRlSiNk.mjs";
3
3
  import { a as logEventFailure, c as downloadBufferToFile, d as prepareVideoElements, i as hasGrayTip, l as ensureSilk, o as sliceRaw, r as firstUntranslatedGrayTip, s as truncRaw, t as collectGrayTipUids, u as fileUriToPath } from "./gray-tip-DmZmdtjP.mjs";
4
- import { a as EssenceListSync, c as OBSERVED_UNNAMED_SYSMSG_KEYS, d as processSysMsgBlob, f as recognizeSysMsg, i as narrowBuddyReqs, l as narrowSysMsgBlobs, n as batchUnreadNums, o as extractEssenceSetSysMsg, r as filterBuddyReqs, s as narrowEssenceGroupArg, t as BuddyReqDedup } from "./buddy-req-CN7gzJpq.mjs";
4
+ import { a as narrowEssenceGroupArg, i as extractEssenceSetSysMsg, l as processSysMsgBlob, n as processInboundBuddyReqs, o as OBSERVED_UNNAMED_SYSMSG_KEYS, r as EssenceListSync, s as narrowSysMsgBlobs, t as BuddyReqDedup, u as recognizeSysMsg } from "./buddy-req-BeEl05O8.mjs";
5
5
  import { ChatType, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupMemberRole, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, WebHonorType, errorMessage, hasStringProp, isRecord, kernelError, toCanonicalElements } from "@napuketto/kernel";
6
6
  import { HttpClient, HttpServer, WsClient, WsServer } from "@napuketto/network";
7
7
  import { z } from "zod";
@@ -3040,8 +3040,6 @@ var OneBotApi = class {
3040
3040
  }
3041
3041
  };
3042
3042
  // src/onebot11/enrichment.ts
3043
- /** 资料详情兜底的单批上限(好友申请批通常只有个位数,超限多为历史积压)。 */
3044
- const MAX_PROFILE_LOOKUPS = 10;
3045
3043
  /** OB11 收链路异步回填器。 */
3046
3044
  var Ob11Enrichment = class {
3047
3045
  api;
@@ -3055,39 +3053,17 @@ var Ob11Enrichment = class {
3055
3053
  *
3056
3054
  * 群成员口径(`getUinByUids`)解析不到的 uid 用资料详情兜底(issue #122):
3057
3055
  * 好友申请的申请人通常不在任何群里,群口径必然失败,不回退会让 `user_id` 恒 0。
3056
+ * 批量 / 兜底的 fail-soft 留痕在共享原语内完成。
3058
3057
  */
3059
3058
  async uidToUinMap(uids) {
3060
- if (uids.length === 0) return /* @__PURE__ */ new Map();
3061
- let map;
3062
- try {
3063
- map = await this.api.uidToUin(uids);
3064
- } catch (err) {
3065
- this.calibLogger?.warn({
3066
- count: uids.length,
3067
- error: errorMessage(err)
3068
- }, "ob11: 请求 uid→uin 批量转换失败,退用 uid");
3069
- map = /* @__PURE__ */ new Map();
3070
- }
3071
- await this.fillMissingUins(uids, map);
3072
- return map;
3073
- }
3074
- /**
3075
- * 群口径未命中的 uid 逐个走 `profileApi.getUinByUid` 兜底(原地补 map)。
3076
- * fail-soft:单条失败 / 查不到保持未命中(翻译层退 0);条数设上限,防历史积压
3077
- * 批次把逐条 IPC 打满。
3078
- */
3079
- async fillMissingUins(uids, map) {
3080
- const missing = [...new Set(uids)].filter((uid) => uid !== "" && !map.has(uid));
3081
- for (const uid of missing.slice(0, MAX_PROFILE_LOOKUPS)) try {
3082
- const uin = await this.api.profileApi.getUinByUid(uid);
3083
- if (uin !== null) map.set(uid, uin);
3084
- } catch (err) {
3085
- this.calibLogger?.debug({ error: errorMessage(err) }, "ob11: uid→uin 资料兜底失败(该 uid 退 0)");
3086
- }
3087
- if (missing.length > MAX_PROFILE_LOOKUPS) this.calibLogger?.debug({
3088
- missing: missing.length,
3089
- limit: MAX_PROFILE_LOOKUPS
3090
- }, "ob11: 待兜底 uid 超上限,其余保持未命中");
3059
+ return resolveUidToUinWithFallback(uids, {
3060
+ uidToUin: (batch) => this.api.uidToUin(batch),
3061
+ getUinByUid: (uid) => this.api.profileApi.getUinByUid(uid),
3062
+ logger: this.calibLogger,
3063
+ scope: "ob11",
3064
+ batchWarnMsg: "ob11: 请求 uid→uin 批量转换失败,退用 uid",
3065
+ profileFallback: true
3066
+ });
3091
3067
  }
3092
3068
  /**
3093
3069
  * notice uid 批量转换(空集退空 Map)。失败上抛不吞:grayTip 解析宽容但
@@ -3491,20 +3467,13 @@ var Ob11InboundRequest = class {
3491
3467
  }
3492
3468
  /** 好友申请翻译派发(flag=reqTime;uid→uin 批量失败退空 Map)。 */
3493
3469
  async broadcastBuddyReqs(arg) {
3494
- if (batchUnreadNums(arg) === 0) {
3495
- this.deps.logger?.debug({}, "ob11: onBuddyReqChange unreadNums=0(整批跳过)");
3496
- return;
3497
- }
3498
- const reqs = narrowBuddyReqs(arg);
3499
- if (reqs === null) {
3500
- this.deps.logger?.warn({ raw: truncRaw(JSON.stringify(arg)) }, "ob11: onBuddyReqChange 未知参数形状");
3501
- return;
3502
- }
3503
- const fresh = filterBuddyReqs(reqs, this.baselineSec).filter((req) => this.dedup.claim(req));
3504
- if (fresh.length < reqs.length) this.deps.logger?.debug({
3505
- total: reqs.length,
3506
- kept: fresh.length
3507
- }, "ob11: 好友申请过滤(历史积压 / 已读 / 已处理 / 重复)");
3470
+ const fresh = processInboundBuddyReqs(arg, {
3471
+ baselineSec: this.baselineSec,
3472
+ dedup: this.dedup,
3473
+ scope: "ob11",
3474
+ formatRaw: truncRaw,
3475
+ logger: this.deps.logger
3476
+ });
3508
3477
  if (fresh.length === 0) return;
3509
3478
  const ctx = await this.requestCtx(fresh.map((r) => r.friendUid).filter((uid) => uid !== ""));
3510
3479
  for (const req of fresh) this.deps.broadcast(toOb11FriendRequestEvent(req, ctx));
@@ -3517,12 +3486,6 @@ var Ob11InboundRequest = class {
3517
3486
  };
3518
3487
  }
3519
3488
  };
3520
- /** 收集群系统通知涉及的 uid(user1/user2 双方,空 uid 跳过)。 */
3521
- function collectGroupNotifyUids(notifies) {
3522
- const uids = [];
3523
- for (const notify of notifies) for (const user of [notify.user1, notify.user2]) if (typeof user?.uid === "string" && user.uid !== "") uids.push(user.uid);
3524
- return uids;
3525
- }
3526
3489
  // src/onebot11/helper/sysmsg.ts
3527
3490
  /**
3528
3491
  * OB11 sysmsg 识别表(自 helper/sysmsg.ts 瘦身——解码层上移
@@ -3982,4 +3945,4 @@ function echoFieldOf(req) {
3982
3945
  }
3983
3946
  export { unescapeCqText as _, canonicalToCqMessage as a, cqMessageToSegments as c, segmentsToCqMessage as d, encodeCqCode as f, serializeCqParts as g, parseCqMessage as h, createOb11ActionRegistry as i, segmentsToCanonical as l, escapeCqText as m, assembleOb11Transports as n, canonicalToSegments as o, escapeCqParam as p, OneBotApi as r, cqMessageToCanonical as s, NapukettoOneBot11Adapter as t, ob11ConfigSchema as u, ob11ErrorCodeMap as v, MessageUnique as y };
3984
3947
 
3985
- //# sourceMappingURL=onebot11-Bypcd8J6.mjs.map
3948
+ //# sourceMappingURL=onebot11-BL02tXe_.mjs.map