@napuketto/adapter 0.23.1 → 0.24.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @napuketto/adapter
2
2
 
3
- NapukettoQQ 协议适配器容器:core 框架 + OneBot 11 / Satori / KuroBot / Milky。
3
+ Napuketto 协议适配器容器:core 框架 + OneBot 11 / Satori / KuroBot / Milky。
4
4
 
5
5
  - **core**:协议适配器生命周期框架(`BaseProtocolAdapter` / 动作执行内核 `runAction` / 动作注册表 / `ConfigBase`)
6
6
  - **onebot11**:动作注册表与 HTTP / WebSocket / 反向 WebSocket 多实例传输,鉴权 + 心跳
@@ -6,7 +6,7 @@ import { AsyncLocalStorage } from "node:async_hooks";
6
6
  import { copyFile, lstat, mkdir, mkdtemp, open, readFile, readdir, readlink, realpath, rename, rm, rmdir, stat, unlink, writeFile } from "node:fs/promises";
7
7
  import { tmpdir } from "node:os";
8
8
  import { basename, dirname, extname, isAbsolute, join, resolve, sep } from "node:path";
9
- import { MAX_AUDIO_INPUT_BYTES, downloadPublicUrl, downloadUrl, encodePcmToSilk, extractVideoFrame, getVideoInfo } from "@napuketto/media";
9
+ import { MAX_AUDIO_INPUT_BYTES, detectFileType, downloadPublicUrl, downloadUrl, encodePcmToSilk, extractVideoFrame, getImageSize, getVideoInfo } from "@napuketto/media";
10
10
  import { pipeline } from "node:stream/promises";
11
11
  import { fileURLToPath } from "node:url";
12
12
  // src/internal/infra/media-cache.ts
@@ -716,11 +716,13 @@ async function exportQqMedia(source, qqRoot, cacheDir) {
716
716
  }
717
717
  // src/internal/qq/media.ts
718
718
  /**
719
- * adapter core 媒体辅助:语音归一化 + 视频缩略图(media 严格解耦的协议层落点)
719
+ * adapter core 媒体辅助:语音归一化 + 视频缩略图 + 图片元数据
720
+ * (media 严格解耦的协议层落点)
720
721
  *
721
- * 协议层(onebot11 / satori)发送媒体前统一走这里:
722
+ * 协议层(onebot11 / milky / satori)发送媒体前统一走这里:
722
723
  * - `ensureSilk`:非 silk 音频转 QQ 语音格式(silk v3);
723
- * - `prepareVideoElements`:视频缺缩略图/时长/尺寸时,用 ffmpeg 抽首帧并探测元数据。
724
+ * - `prepareVideoElements`:视频缺缩略图/时长/尺寸时,用 ffmpeg 抽首帧并探测元数据;
725
+ * - `prepareImageElements`:图片缺尺寸/MIME 时用 image-size / file-type 补齐。
724
726
  * 都依赖 @napuketto/media,只发生在 adapter 层;kernel 不 import media(红线),
725
727
  * 只接收「文件齐全」的 canonical 元素。
726
728
  */
@@ -771,6 +773,49 @@ async function ensureSilk(path, logger) {
771
773
  return path;
772
774
  }
773
775
  }
776
+ /** 清洗 canonical MIME:IPC / 第三方可能传非字符串脏值,统一按缺失处理。 */
777
+ function imageMime(value) {
778
+ return typeof value === "string" && value.trim() !== "" ? value : void 0;
779
+ }
780
+ /** 是否需要补图片尺寸/MIME(任一缺失)。 */
781
+ function needsImageMeta(el) {
782
+ return el.type === "image" && (el.size === void 0 || imageMime(el.mime) === void 0);
783
+ }
784
+ /**
785
+ * 图片元素补「像素尺寸 + MIME」(QQ PIC 发送契约的 picWidth / picHeight / picType)。
786
+ *
787
+ * 为什么必须补:kernel 的 `prepareImageElement` 会把 canonical `size` / `mime`
788
+ * 写进 picElement;缺失时它只能退到零依赖文件头解析。协议层先用
789
+ * `@napuketto/media`(image-size / file-type,覆盖格式更全)补齐,kernel 不必
790
+ * 依赖媒体库(解耦红线)。单项探测失败只 warn 并保留原元素——发送链不能因为
791
+ * 元数据失败而中断,kernel 仍有零依赖兜底。
792
+ */
793
+ async function prepareImageElements(elements, logger) {
794
+ if (!elements.some(needsImageMeta)) return [...elements];
795
+ const out = [];
796
+ for (const el of elements) {
797
+ if (!needsImageMeta(el)) {
798
+ out.push(el);
799
+ continue;
800
+ }
801
+ try {
802
+ const size = el.size ?? await getImageSize(el.path);
803
+ const mime = imageMime(el.mime) ?? (await detectFileType(el.path)).mime;
804
+ out.push({
805
+ ...el,
806
+ size,
807
+ mime
808
+ });
809
+ } catch (err) {
810
+ logger?.warn({
811
+ path: el.path,
812
+ error: errorMessage(err)
813
+ }, "图片元数据探测失败,交由 kernel 零依赖兜底");
814
+ out.push(el);
815
+ }
816
+ }
817
+ return out;
818
+ }
774
819
  /** 是否是需要补缩略图的视频元素。 */
775
820
  function needsVideoThumb(el) {
776
821
  return el.type === "video" && (el.thumbPath === void 0 || el.thumbPath === "");
@@ -913,4 +958,4 @@ function firstUntranslatedGrayTip(msg) {
913
958
  function findRevokeElement(msg) {
914
959
  return msg.elements.find((el) => el.grayTipElement?.revokeElement != null)?.grayTipElement?.revokeElement ?? void 0;
915
960
  }
916
- export { cacheMediaFile as _, logEventFailure as a, protocolMediaSchema as c, mediaDownloader as d, prepareVideoElements as f, MediaCache as g, resolveLocalMedia as h, hasGrayTip as i, downloadProtocolMedia as l, exportQqMedia as m, findRevokeElement as n, sliceRaw as o, bindLocalMediaRoots as p, firstUntranslatedGrayTip as r, truncRaw as s, collectGrayTipUids as t, ensureSilk as u, leaseInternalMedia as v, withMediaScope as y };
961
+ export { MediaCache as _, logEventFailure as a, withMediaScope as b, protocolMediaSchema as c, mediaDownloader as d, prepareImageElements as f, resolveLocalMedia as g, exportQqMedia as h, hasGrayTip as i, downloadProtocolMedia as l, bindLocalMediaRoots as m, findRevokeElement as n, sliceRaw as o, prepareVideoElements as p, firstUntranslatedGrayTip as r, truncRaw as s, collectGrayTipUids as t, ensureSilk as u, cacheMediaFile as v, leaseInternalMedia as y };
@@ -70,6 +70,8 @@ declare class SatoriApi {
70
70
  readonly cacheDir: string;
71
71
  readonly publishLocalAsset?: ((path: string) => Promise<string | undefined>) | undefined;
72
72
  readonly groupCache: GroupCache | undefined;
73
+ /** 动作层可观测出口(媒体缓存/图片元数据探测降级留痕;缺省静默)。 */
74
+ readonly logger: AdapterLoggerLike | undefined;
73
75
  /**
74
76
  * 频道类型缓存:channel_id → isGroup(群聊频道 id 与私聊 uin 无法从数字
75
77
  * 规则区分,需从事件/查询回填——QQ 平台群号与用户 uin 同为数字)。
package/dist/index.d.mts CHANGED
@@ -19,7 +19,7 @@ import { _ as ErrorCodeMap, a as ProtocolConfig, c as ProtocolHooks, g as Action
19
19
  import { et as KurobotConfig, l as KurobotAdapterOptions, nt as kurobotConfigSchema, u as NapukettoKurobotAdapter } from "./index-tW3a05Du.mjs";
20
20
  import { G as MilkyConfig, K as milkyConfigSchema, L as MilkyAdapterOptions, R as NapukettoMilkyAdapter } from "./index-CWUA38Aw.mjs";
21
21
  import { C as ob11ConfigSchema, S as OB11Config, o as NapukettoOneBot11Adapter, s as OneBot11AdapterOptions } from "./index-Beq1S5ad.mjs";
22
- import { R as SatoriConfig, d as NapukettoSatoriAdapter, f as SatoriAdapterOptions, z as satoriConfigSchema } from "./index-DAoLsewN.mjs";
22
+ import { R as SatoriConfig, d as NapukettoSatoriAdapter, f as SatoriAdapterOptions, z as satoriConfigSchema } from "./index-DNuLYcSP.mjs";
23
23
  import { z } from "zod";
24
24
  declare const protocolMediaSchema: z.ZodObject<{
25
25
  localMediaRoots: z.ZodOptional<z.ZodArray<z.ZodString>>;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { f as ActionRegistry, n as ProtocolConfig, o as BaseProtocolAdapter, p as runAction, r as createServerSchema, t as ConfigBase } from "./framework-CA3087JP.mjs";
2
- import { N as kurobotConfigSchema, t as NapukettoKurobotAdapter } from "./kurobot-BrKT5cJA.mjs";
3
- import { r as milkyConfigSchema, t as NapukettoMilkyAdapter } from "./milky-6O1JM1A9.mjs";
4
- import { t as NapukettoOneBot11Adapter, u as ob11ConfigSchema } from "./onebot11-CgylJN92.mjs";
5
- import { m as satoriConfigSchema, t as NapukettoSatoriAdapter } from "./satori-DdcfE1nh.mjs";
2
+ import { N as kurobotConfigSchema, t as NapukettoKurobotAdapter } from "./kurobot-3nvb4oqh.mjs";
3
+ import { r as milkyConfigSchema, t as NapukettoMilkyAdapter } from "./milky-BWLRoCdN.mjs";
4
+ import { t as NapukettoOneBot11Adapter, u as ob11ConfigSchema } from "./onebot11-Eh6OEQ10.mjs";
5
+ import { m as satoriConfigSchema, t as NapukettoSatoriAdapter } from "./satori-CgaSIlQs.mjs";
6
6
  export { ActionRegistry, BaseProtocolAdapter, ConfigBase, NapukettoKurobotAdapter, NapukettoMilkyAdapter, NapukettoOneBot11Adapter, NapukettoSatoriAdapter, ProtocolConfig, createServerSchema, kurobotConfigSchema, milkyConfigSchema, ob11ConfigSchema, runAction, satoriConfigSchema };
@@ -1 +1 @@
1
- export { u as KurobotConnection, n as MAX_GROUP_TEXT_LENGTH, t as NapukettoKurobotAdapter, d as PROTOCOL_NAME, f as PROTOCOL_VERSION, p as WS_SUBPROTOCOL, m as bindingsUpdatedFrame, h as commandFrame, g as commandResultFrame, _ as deathFrame, r as degradeElements, i as degradeMessage, v as encodeFrame, y as gameChatFrame, b as helloAckFrame, x as helloFrame, S as isProtocolVersionCompatible, C as joinFrame, M as kurobotConfigDefaults, N as kurobotConfigSchema, w as leaveFrame, T as pingFrame, E as platformChatFrame, D as pongFrame, O as queryFrame, k as queryResultFrame, a as renderCommandResult, o as renderDeathText, s as renderTemplate, c as resolveSenderName, A as statusFrame, l as truncateForGroup, j as wireFrameSchema } from "../kurobot-BrKT5cJA.mjs";
1
+ export { u as KurobotConnection, n as MAX_GROUP_TEXT_LENGTH, t as NapukettoKurobotAdapter, d as PROTOCOL_NAME, f as PROTOCOL_VERSION, p as WS_SUBPROTOCOL, m as bindingsUpdatedFrame, h as commandFrame, g as commandResultFrame, _ as deathFrame, r as degradeElements, i as degradeMessage, v as encodeFrame, y as gameChatFrame, b as helloAckFrame, x as helloFrame, S as isProtocolVersionCompatible, C as joinFrame, M as kurobotConfigDefaults, N as kurobotConfigSchema, w as leaveFrame, T as pingFrame, E as platformChatFrame, D as pongFrame, O as queryFrame, k as queryResultFrame, a as renderCommandResult, o as renderDeathText, s as renderTemplate, c as resolveSenderName, A as statusFrame, l as truncateForGroup, j as wireFrameSchema } from "../kurobot-3nvb4oqh.mjs";
@@ -17,7 +17,7 @@ const kurobotConfigSchema = z.object({
17
17
  url: z.url().refine((u) => u.startsWith("ws://") || u.startsWith("wss://"), { message: "url 必须是 ws:// 或 wss:// 地址" }),
18
18
  /** 鉴权 token(缺省空 = 不带;服务端配置了非空 token 则必须一致,否则 close 1008)。 */
19
19
  token: z.string().default(""),
20
- /** 自报身份(缺省 napukettoqq,能取到 adapter 包版本则 napukettoqq/<版本>)。 */
20
+ /** 自报身份(缺省 napuketto,能取到 adapter 包版本则 napuketto/<版本>)。 */
21
21
  client: z.string().min(1).optional(),
22
22
  /** 群命令前缀(前缀开头 → command 帧,不再作为 chat 发送)。 */
23
23
  commandPrefix: z.string().min(1).default("/"),
@@ -1112,13 +1112,13 @@ function resolvePackageVersion(log) {
1112
1112
  if (isRecord(parsed) && typeof parsed["version"] === "string" && parsed["version"] !== "") return parsed["version"];
1113
1113
  return null;
1114
1114
  } catch (err) {
1115
- log?.debug({ error: errorMessage(err) }, "kurobot: package.json 版本探测失败,hello 降级 unknown/napukettoqq");
1115
+ log?.debug({ error: errorMessage(err) }, "kurobot: package.json 版本探测失败,hello.client 降级为 napuketto(不带版本)");
1116
1116
  return null;
1117
1117
  }
1118
1118
  }
1119
- /** hello.client 缺省身份:napukettoqq/<版本>(取不到版本则 napukettoqq)。 */
1119
+ /** hello.client 缺省身份:napuketto/<版本>(取不到版本则 napuketto)。 */
1120
1120
  function resolveDefaultClient(log) {
1121
1121
  const version = resolvePackageVersion(log);
1122
- return version === null ? "napukettoqq" : `napukettoqq/${version}`;
1122
+ return version === null ? "napuketto" : `napuketto/${version}`;
1123
1123
  }
1124
1124
  export { statusFrame as A, joinFrame as C, pongFrame as D, platformChatFrame as E, kurobotConfigDefaults as M, kurobotConfigSchema as N, queryFrame as O, isProtocolVersionCompatible as S, pingFrame as T, deathFrame as _, renderCommandResult as a, helloAckFrame as b, resolveSenderName as c, PROTOCOL_NAME as d, PROTOCOL_VERSION as f, commandResultFrame as g, commandFrame as h, degradeMessage as i, wireFrameSchema as j, queryResultFrame as k, truncateForGroup as l, bindingsUpdatedFrame as m, MAX_GROUP_TEXT_LENGTH as n, renderDeathText as o, WS_SUBPROTOCOL as p, degradeElements as r, renderTemplate as s, NapukettoKurobotAdapter as t, KurobotConnection as u, encodeFrame as v, leaveFrame as w, helloFrame as x, gameChatFrame as y };
@@ -1 +1 @@
1
- export { a as MilkyApi, t as NapukettoMilkyAdapter, n as assembleMilkyTransports, i as createMilkyActionRegistry, r as milkyConfigSchema, o as milkyErrorCodeMap } from "../milky-6O1JM1A9.mjs";
1
+ export { a as MilkyApi, t as NapukettoMilkyAdapter, n as assembleMilkyTransports, i as createMilkyActionRegistry, r as milkyConfigSchema, o as milkyErrorCodeMap } from "../milky-BWLRoCdN.mjs";
@@ -1,5 +1,5 @@
1
1
  import { c as BEARER_PREFIX, f as ActionRegistry, i as validateListenerToken, l as createTokenAuthorize, o as BaseProtocolAdapter, p as runAction, s as resolveProtocolConfig } from "./framework-CA3087JP.mjs";
2
- import { _ as cacheMediaFile, a as logEventFailure, c as protocolMediaSchema, d as mediaDownloader, g as MediaCache, h as resolveLocalMedia, i as hasGrayTip, n as findRevokeElement, o as sliceRaw, p as bindLocalMediaRoots, r as firstUntranslatedGrayTip, t as collectGrayTipUids, y as withMediaScope } from "./gray-tip-CiZ6OxlQ.mjs";
2
+ import { _ as MediaCache, a as logEventFailure, b as withMediaScope, c as protocolMediaSchema, d as mediaDownloader, f as prepareImageElements, g as resolveLocalMedia, i as hasGrayTip, m as bindLocalMediaRoots, n as findRevokeElement, o as sliceRaw, r as firstUntranslatedGrayTip, t as collectGrayTipUids, v as cacheMediaFile } from "./gray-tip-DlxDI1YV.mjs";
3
3
  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, o as stringOrUndefined, p as resolveUin, r as subscribeRawMessages, s as startupBaselineSec, t as forEachRawMessage } from "./raw-message-B0kwCfKE.mjs";
4
4
  import { a as processSysMsgBlob, c as varintAt, d as processInboundBuddyReqs, i as nodeAt, l as varintOf, n as OBSERVED_UNNAMED_SYSMSG_KEYS, o as recognizeSysMsg, r as narrowSysMsgBlobs, s as textOf, t as extractEssenceSetSysMsg, u as BuddyReqDedup } from "./essence-ChxJJipr.mjs";
5
5
  import { ChatType, EssenceListSync, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupMemberRole, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, errorMessage, findPendingGroupRequest, hasNumberProp, hasStringProp, isRecord, kernelError, narrowEssenceGroupArg, toCanonicalElements } from "@napuketto/kernel";
@@ -1910,12 +1910,13 @@ async function recallTempMessages(peer, msgIds, api) {
1910
1910
  }
1911
1911
  }
1912
1912
  /** ---------- 元素二次解析 ---------- */
1913
- /** 元素二次解析:at uin→uid + 远程媒体 URI 落盘(reply seq 已在映射层兜底原样)。 */
1913
+ /** 元素二次解析:at uin→uid + 远程媒体 URI 落盘 + 图片尺寸/MIME 补齐
1914
+ * (reply seq 已在映射层兜底原样)。 */
1914
1915
  async function resolveElements(elements, atUins, api) {
1915
1916
  const uinToUid = await resolveAtUins(atUins, api);
1916
1917
  const out = [];
1917
1918
  for (const el of elements) out.push(await resolveElement(el, uinToUid, api));
1918
- return out;
1919
+ return await prepareImageElements(out, api.logger);
1919
1920
  }
1920
1921
  /** at uin→uid 批量转换(失败返回 undefined:at 原样 uin,交 QQ 端判断)。 */
1921
1922
  async function resolveAtUins(atUins, api) {
@@ -2219,7 +2220,7 @@ function createSystemActions(api) {
2219
2220
  name: "get_impl_info",
2220
2221
  schema: z.object({}).strict(),
2221
2222
  handle: async () => ({
2222
- impl_name: "napukettoqq",
2223
+ impl_name: "napuketto",
2223
2224
  impl_version: api.implVersion,
2224
2225
  qq_protocol_version: api.qqVersion,
2225
2226
  qq_protocol_type: "windows",
@@ -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-CgylJN92.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-Eh6OEQ10.mjs";
@@ -1,5 +1,5 @@
1
1
  import { a as validateServerTokens, c as BEARER_PREFIX, f as ActionRegistry, l as createTokenAuthorize, o as BaseProtocolAdapter, p as runAction, r as createServerSchema, s as resolveProtocolConfig } from "./framework-CA3087JP.mjs";
2
- import { _ as cacheMediaFile, a as logEventFailure, c as protocolMediaSchema, d as mediaDownloader, f as prepareVideoElements, g as MediaCache, h as resolveLocalMedia, i as hasGrayTip, l as downloadProtocolMedia, m as exportQqMedia, o as sliceRaw, p as bindLocalMediaRoots, r as firstUntranslatedGrayTip, s as truncRaw, t as collectGrayTipUids, u as ensureSilk, y as withMediaScope } from "./gray-tip-CiZ6OxlQ.mjs";
2
+ import { _ as MediaCache, a as logEventFailure, b as withMediaScope, c as protocolMediaSchema, d as mediaDownloader, f as prepareImageElements, g as resolveLocalMedia, h as exportQqMedia, i as hasGrayTip, l as downloadProtocolMedia, m as bindLocalMediaRoots, o as sliceRaw, p as prepareVideoElements, r as firstUntranslatedGrayTip, s as truncRaw, t as collectGrayTipUids, u as ensureSilk, v as cacheMediaFile } from "./gray-tip-DlxDI1YV.mjs";
3
3
  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, p as resolveUin, r as subscribeRawMessages, s as startupBaselineSec, u as collectGroupNotifyUids } from "./raw-message-B0kwCfKE.mjs";
4
4
  import { a as processSysMsgBlob, d as processInboundBuddyReqs, n as OBSERVED_UNNAMED_SYSMSG_KEYS, o as recognizeSysMsg, r as narrowSysMsgBlobs, t as extractEssenceSetSysMsg, u as BuddyReqDedup } from "./essence-ChxJJipr.mjs";
5
5
  import { ChatType, EssenceListSync, GrayTipSubType, GroupApi, GroupNotifyMsgType, NTGroupMemberRole, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, WebHonorType, errorMessage, findPendingGroupRequest, hasStringProp, isRecord, kernelError, narrowEssenceGroupArg, toCanonicalElements, toPendingGroupRequest } from "@napuketto/kernel";
@@ -2407,7 +2407,8 @@ async function sendOb11Message(payload, deps) {
2407
2407
  return el;
2408
2408
  });
2409
2409
  canonical = await ensureVoiceSilk(canonical, deps.logger);
2410
- const prepared = await prepareVideoElements(canonical);
2410
+ const withImageMeta = await prepareImageElements(canonical, deps.logger);
2411
+ const prepared = await prepareVideoElements(withImageMeta);
2411
2412
  try {
2412
2413
  const { msgId } = await deps.msgApi.sendMessage(peer, prepared.elements);
2413
2414
  return { message_id: deps.messageUnique.alloc(msgId, peer) };
@@ -2708,7 +2709,7 @@ function createSystemInfoActions(api) {
2708
2709
  name: "get_version_info",
2709
2710
  schema: getVersionInfoSchema,
2710
2711
  handle: () => Promise.resolve({
2711
- app_name: "napuketto-qq",
2712
+ app_name: "napuketto",
2712
2713
  app_version: api.appVersion,
2713
2714
  protocol_version: "v11"
2714
2715
  })
@@ -2,5 +2,5 @@
2
2
  * Satori 协议适配器
3
3
  * 公共面:类型 + 动作注册表 + 配置 schema + 传输装配 + 适配器。
4
4
  */
5
- import { A as Message, B as SatoriActionDeps, C as Emoji, D as GuildRole, E as GuildMember, F as Order, G as SatoriToCanonicalDeps, H as SatoriActionError, I as HTTP_STATUS, J as renderElements, K as SatoriElement, L as satoriHttpStatusMap, M as BidiList, N as Direction, O as Login, P as List, R as SatoriConfig, S as ChannelType, T as Guild, U as SatoriApi, V as createSatoriActionRegistry, W as SatoriApiOptions, _ as MetaBody, a as parseContentToCanonical, b as Signal, c as canonicalToSatoriElements, d as NapukettoSatoriAdapter, f as SatoriAdapterOptions, g as IdentifyBody, h as Event, i as toEventSignal, j as User, k as LoginStatus, l as SatoriEventContent, m as Button, n as SatoriTransportSet, o as satoriToCanonicalElements, p as Argv, q as parseElements, r as assembleSatoriTransports, s as CanonicalToSatoriDeps, t as AssembleSatoriTransportsOptions, u as SatoriEventDeps, v as Opcode, w as Friend, x as Channel, y as ReadyBody, z as satoriConfigSchema } from "../index-DAoLsewN.mjs";
5
+ import { A as Message, B as SatoriActionDeps, C as Emoji, D as GuildRole, E as GuildMember, F as Order, G as SatoriToCanonicalDeps, H as SatoriActionError, I as HTTP_STATUS, J as renderElements, K as SatoriElement, L as satoriHttpStatusMap, M as BidiList, N as Direction, O as Login, P as List, R as SatoriConfig, S as ChannelType, T as Guild, U as SatoriApi, V as createSatoriActionRegistry, W as SatoriApiOptions, _ as MetaBody, a as parseContentToCanonical, b as Signal, c as canonicalToSatoriElements, d as NapukettoSatoriAdapter, f as SatoriAdapterOptions, g as IdentifyBody, h as Event, i as toEventSignal, j as User, k as LoginStatus, l as SatoriEventContent, m as Button, n as SatoriTransportSet, o as satoriToCanonicalElements, p as Argv, q as parseElements, r as assembleSatoriTransports, s as CanonicalToSatoriDeps, t as AssembleSatoriTransportsOptions, u as SatoriEventDeps, v as Opcode, w as Friend, x as Channel, y as ReadyBody, z as satoriConfigSchema } from "../index-DNuLYcSP.mjs";
6
6
  export { type Argv, type AssembleSatoriTransportsOptions, type BidiList, type Button, type CanonicalToSatoriDeps, type Channel, type ChannelType, type Direction, type Emoji, type Event, type Friend, type Guild, type GuildMember, type GuildRole, HTTP_STATUS, type IdentifyBody, type List, type Login, type LoginStatus, type Message, type MetaBody, NapukettoSatoriAdapter, type Opcode, type Order, type ReadyBody, type SatoriActionDeps, SatoriActionError, type SatoriAdapterOptions, SatoriApi, type SatoriApiOptions, type SatoriConfig, type SatoriElement, type SatoriEventContent, type SatoriEventDeps, type SatoriToCanonicalDeps, type SatoriTransportSet, type Signal, type User, assembleSatoriTransports, canonicalToSatoriElements, createSatoriActionRegistry, parseContentToCanonical, parseElements, renderElements, satoriConfigSchema, satoriHttpStatusMap, satoriToCanonicalElements, toEventSignal };
@@ -1 +1 @@
1
- export { f as HTTP_STATUS, t as NapukettoSatoriAdapter, c as SatoriActionError, i as SatoriApi, n as assembleSatoriTransports, d as canonicalToSatoriElements, a as createSatoriActionRegistry, o as parseContentToCanonical, l as parseElements, u as renderElements, m as satoriConfigSchema, p as satoriHttpStatusMap, s as satoriToCanonicalElements, r as toEventSignal } from "../satori-DdcfE1nh.mjs";
1
+ export { f as HTTP_STATUS, t as NapukettoSatoriAdapter, c as SatoriActionError, i as SatoriApi, n as assembleSatoriTransports, d as canonicalToSatoriElements, a as createSatoriActionRegistry, o as parseContentToCanonical, l as parseElements, u as renderElements, m as satoriConfigSchema, p as satoriHttpStatusMap, s as satoriToCanonicalElements, r as toEventSignal } from "../satori-CgaSIlQs.mjs";
@@ -1,5 +1,5 @@
1
1
  import { a as validateServerTokens, d as tokenEquals, f as ActionRegistry, l as createTokenAuthorize, o as BaseProtocolAdapter, p as runAction, r as createServerSchema, s as resolveProtocolConfig } from "./framework-CA3087JP.mjs";
2
- import { _ as cacheMediaFile, a as logEventFailure, c as protocolMediaSchema, g as MediaCache, h as resolveLocalMedia, l as downloadProtocolMedia, m as exportQqMedia, p as bindLocalMediaRoots, t as collectGrayTipUids, u as ensureSilk, v as leaseInternalMedia, y as withMediaScope } from "./gray-tip-CiZ6OxlQ.mjs";
2
+ import { _ as MediaCache, a as logEventFailure, b as withMediaScope, c as protocolMediaSchema, f as prepareImageElements, g as resolveLocalMedia, h as exportQqMedia, l as downloadProtocolMedia, m as bindLocalMediaRoots, t as collectGrayTipUids, u as ensureSilk, v as cacheMediaFile, y as leaseInternalMedia } from "./gray-tip-DlxDI1YV.mjs";
3
3
  import { c as MS_TO_SEC, h as toUinString, i as toUnixSeconds, r as subscribeRawMessages } from "./raw-message-B0kwCfKE.mjs";
4
4
  import { ChatType, GrayTipSubType, NTGroupRequestOperateTypes, TipGroupElementType, errorMessage, findPendingGroupRequest, isRecord, kernelError, toCanonicalElements } from "@napuketto/kernel";
5
5
  import { HttpServer, WsServer, isWsOpen, sendWsText } from "@napuketto/network";
@@ -1100,10 +1100,10 @@ function createMessageActions(deps) {
1100
1100
  const ownedOutputs = /* @__PURE__ */ new Set();
1101
1101
  let msgId;
1102
1102
  try {
1103
- const elements = await parseContentToCanonical(content, {
1103
+ const elements = await prepareImageElements(await parseContentToCanonical(content, {
1104
1104
  ...deps.toCanonicalDeps(),
1105
1105
  onVideoTranscoded: (path) => ownedOutputs.add(path)
1106
- });
1106
+ }), deps.logger);
1107
1107
  ({msgId} = await deps.msgApi.sendMessage(peer, elements));
1108
1108
  } finally {
1109
1109
  await Promise.all([...ownedOutputs].map(async (path) => {
@@ -1363,6 +1363,8 @@ var SatoriApi = class {
1363
1363
  cacheDir;
1364
1364
  publishLocalAsset;
1365
1365
  groupCache;
1366
+ /** 动作层可观测出口(媒体缓存/图片元数据探测降级留痕;缺省静默)。 */
1367
+ logger;
1366
1368
  /**
1367
1369
  * 频道类型缓存:channel_id → isGroup(群聊频道 id 与私聊 uin 无法从数字
1368
1370
  * 规则区分,需从事件/查询回填——QQ 平台群号与用户 uin 同为数字)。
@@ -1380,6 +1382,7 @@ var SatoriApi = class {
1380
1382
  this.self = opts.self;
1381
1383
  this.selfUin = opts.self.uin;
1382
1384
  this.cacheDir = opts.cacheDir ?? join(tmpdir(), "napuketto-satori-cache");
1385
+ this.logger = opts.logger;
1383
1386
  this.mediaCache = new MediaCache({
1384
1387
  root: this.cacheDir,
1385
1388
  logger: opts.logger,
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@napuketto/adapter",
4
- "version": "0.23.1",
4
+ "version": "0.24.1",
5
5
  "type": "module",
6
- "description": "Protocol adapters (OneBot11 / Satori / KuroBot / Milky) for NapukettoQQ",
6
+ "description": "Protocol adapters (OneBot11 / Satori / KuroBot / Milky) for Napuketto",
7
7
  "keywords": [
8
- "qq",
9
8
  "bot",
10
9
  "napuketto",
11
10
  "adapter",
@@ -14,13 +13,13 @@
14
13
  "kurobot",
15
14
  "milky"
16
15
  ],
17
- "homepage": "https://github.com/NapukettoDev/NapukettoQQ/tree/main/packages/adapter#readme",
16
+ "homepage": "https://github.com/NapukettoDev/Napuketto/tree/main/packages/adapter#readme",
18
17
  "bugs": {
19
- "url": "https://github.com/NapukettoDev/NapukettoQQ/issues"
18
+ "url": "https://github.com/NapukettoDev/Napuketto/issues"
20
19
  },
21
20
  "repository": {
22
21
  "type": "git",
23
- "url": "git+https://github.com/NapukettoDev/NapukettoQQ.git",
22
+ "url": "git+https://github.com/NapukettoDev/Napuketto.git",
24
23
  "directory": "packages/adapter"
25
24
  },
26
25
  "license": "MIT",
@@ -83,9 +82,9 @@
83
82
  "dev": "tsdown --watch"
84
83
  },
85
84
  "dependencies": {
86
- "@napuketto/kernel": "^0.19.0",
87
- "@napuketto/media": "^0.4.0",
88
- "@napuketto/network": "^0.5.0",
85
+ "@napuketto/kernel": "^0.19.2",
86
+ "@napuketto/media": "^0.4.1",
87
+ "@napuketto/network": "^0.5.1",
89
88
  "zod": "^4.6.7"
90
89
  },
91
90
  "devDependencies": {