@napuketto/adapter 0.3.5 → 0.4.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.
@@ -4095,6 +4095,17 @@ function authorizeHeader(token) {
4095
4095
  //#region src/onebot11/adapter.ts
4096
4096
  /** 毫秒 → 秒(Unix 时间戳)。 */
4097
4097
  const MS_TO_SEC = 1e3;
4098
+ /**
4099
+ * info/warn 级 raw 字段截断上限(2026-10-25 输出内容治理):hex/base64/JSON
4100
+ * 原文对运行状态无信息量,保留前缀定位 + 缺省长度;完整值仅在 debug 级
4101
+ * ([log.levels].ob11 = "debug")与日志文件中出现。
4102
+ */
4103
+ const RAW_INFO_LIMIT = 64;
4104
+ /** raw 字段截断:超限截断 + 缺省长度标注(…(+N))。 */
4105
+ function truncRaw(value, keep = RAW_INFO_LIMIT) {
4106
+ if (value === void 0) return "";
4107
+ return value.length <= keep ? value : `${value.slice(0, keep)}…(+${value.length - keep})`;
4108
+ }
4098
4109
  /** OneBot 11 协议适配器。 */
4099
4110
  var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
4100
4111
  protocol = "onebot11";
@@ -4239,7 +4250,7 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
4239
4250
  this.unsubscribes.push(this.msgChannel.on("Msg/onRecvOfflineFileMsg", (arg) => {
4240
4251
  const items = narrowOfflineFiles(arg);
4241
4252
  if (items === null) {
4242
- this.calibLogger?.warn({ raw: JSON.stringify(arg)?.slice(0, 2e3) }, "ob11: onRecvOfflineFileMsg 未知参数形状");
4253
+ this.calibLogger?.warn({ raw: truncRaw(JSON.stringify(arg)) }, "ob11: onRecvOfflineFileMsg 未知参数形状");
4243
4254
  return;
4244
4255
  }
4245
4256
  for (const item of items) this.broadcastEvent(toOfflineFileNotice(item, this.selfUin));
@@ -4247,13 +4258,13 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
4247
4258
  this.unsubscribes.push(this.msgChannel.on("Msg/onRecvSysMsg", (arg) => {
4248
4259
  const blobs = narrowSysMsgBlobs(arg);
4249
4260
  if (blobs === null) {
4250
- this.calibLogger?.warn({ raw: JSON.stringify(arg)?.slice(0, 2e3) }, "ob11: onRecvSysMsg 未知参数形状");
4261
+ this.calibLogger?.warn({ raw: truncRaw(JSON.stringify(arg)) }, "ob11: onRecvSysMsg 未知参数形状");
4251
4262
  return;
4252
4263
  }
4253
4264
  for (const blob of blobs) this.handleSysMsgBlob(blob);
4254
4265
  }));
4255
4266
  this.unsubscribes.push(this.msgChannel.on("Msg/onRecvOnlineFileMsg", (arg) => {
4256
- this.calibLogger?.info({ raw: JSON.stringify(arg)?.slice(0, 2e3) }, "ob11: onRecvOnlineFileMsg raw(校准数据)");
4267
+ this.calibLogger?.debug({ raw: JSON.stringify(arg)?.slice(0, 2e3) }, "ob11: onRecvOnlineFileMsg raw(校准数据)");
4257
4268
  }));
4258
4269
  if (this.groupChannel !== void 0) {
4259
4270
  this.unsubscribes.push(this.groupChannel.on("Group/onGroupNotifiesUpdated", (doubt, notifies) => {
@@ -4261,20 +4272,20 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
4261
4272
  this.broadcastGroupRequests(notifies);
4262
4273
  }));
4263
4274
  this.unsubscribes.push(this.groupChannel.on("Group/onGroupEssenceListChange", (arg) => {
4264
- this.calibLogger?.info({ raw: JSON.stringify(arg)?.slice(0, 2e3) }, "ob11: onGroupEssenceListChange raw(group_essence 校准数据)");
4275
+ this.calibLogger?.debug({ raw: truncRaw(JSON.stringify(arg)) }, "ob11: onGroupEssenceListChange raw(group_essence 校准数据)");
4265
4276
  }));
4266
4277
  }
4267
4278
  if (this.friendChannel !== void 0) {
4268
4279
  this.unsubscribes.push(this.friendChannel.on("Buddy/onBuddyReqChange", (arg) => {
4269
4280
  const reqs = narrowBuddyReqs(arg);
4270
4281
  if (reqs === null) {
4271
- this.calibLogger?.warn({ raw: JSON.stringify(arg)?.slice(0, 2e3) }, "ob11: onBuddyReqChange 未知参数形状");
4282
+ this.calibLogger?.warn({ raw: truncRaw(JSON.stringify(arg)) }, "ob11: onBuddyReqChange 未知参数形状");
4272
4283
  return;
4273
4284
  }
4274
4285
  this.broadcastFriendRequests(reqs);
4275
4286
  }));
4276
4287
  for (const evt of ["Buddy/onBuddyListChange", "Buddy/onBuddyListChangedV2"]) this.unsubscribes.push(this.friendChannel.on(evt, (arg) => {
4277
- this.calibLogger?.info({ raw: JSON.stringify(arg)?.slice(0, 2e3) }, `ob11: ${evt} raw(friend_add 校准数据)`);
4288
+ this.calibLogger?.info({ raw: truncRaw(JSON.stringify(arg)) }, `ob11: ${evt} raw(friend_add 校准数据)`);
4278
4289
  }));
4279
4290
  }
4280
4291
  if (this.buddyCacheEvents !== void 0) this.unsubscribes.push(this.buddyCacheEvents.on("BuddyCache/onBuddyAdded", (entry) => {
@@ -4306,7 +4317,7 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
4306
4317
  handleSysMsgBlob(blob) {
4307
4318
  const tree = decodeProtoTree(blob);
4308
4319
  if (tree === null) {
4309
- this.calibLogger?.warn({ raw: toHex(blob).slice(0, 1024) }, "ob11: onRecvSysMsg protobuf 解码失败");
4320
+ this.calibLogger?.warn({ raw: truncRaw(toHex(blob).slice(0, 1024)) }, "ob11: onRecvSysMsg protobuf 解码失败");
4310
4321
  return;
4311
4322
  }
4312
4323
  const env = extractSysMsgEnvelope(tree);
@@ -4318,7 +4329,7 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
4318
4329
  return;
4319
4330
  }
4320
4331
  }
4321
- this.calibLogger?.info({
4332
+ this.calibLogger?.debug({
4322
4333
  verdict: rec.kind,
4323
4334
  msgType: env.msgType,
4324
4335
  subType: env.subType,