@napuketto/adapter 0.18.16 → 0.18.18
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/dist/gray-tip-BL1rhwZK.mjs +619 -0
- package/dist/gray-tip-BL1rhwZK.mjs.map +1 -0
- package/dist/gray-tip-CcpfI1Og.d.mts +1 -0
- package/dist/{index-BlRIp4xi.d.mts → index-CKWWp8-H.d.mts} +3 -1
- package/dist/index-CKWWp8-H.d.mts.map +1 -0
- package/dist/{index-xj5Z4aAN.d.mts → index-DrPCnj64.d.mts} +4 -2
- package/dist/index-DrPCnj64.d.mts.map +1 -0
- package/dist/{index-BcQRoLtj.d.mts → index-tljZ0fmt.d.mts} +6 -2
- package/dist/index-tljZ0fmt.d.mts.map +1 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/media-cache-C_0C9eCV.d.mts +47 -0
- package/dist/media-cache-C_0C9eCV.d.mts.map +1 -0
- package/dist/milky/index.d.mts +1 -1
- package/dist/milky/index.mjs +1 -1
- package/dist/{milky-DsktXHch.mjs → milky-KOD9KyeP.mjs} +34 -22
- package/dist/milky-KOD9KyeP.mjs.map +1 -0
- package/dist/onebot11/index.d.mts +1 -1
- package/dist/onebot11/index.mjs +1 -1
- package/dist/{onebot11-CqHLrn9g.mjs → onebot11-CUK6blMn.mjs} +37 -22
- package/dist/onebot11-CUK6blMn.mjs.map +1 -0
- package/dist/satori/index.d.mts +1 -1
- package/dist/satori/index.mjs +1 -1
- package/dist/{satori-Bx8tkR9X.mjs → satori-Dl9iaDNY.mjs} +28 -19
- package/dist/satori-Dl9iaDNY.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/gray-tip-BwsIxacB.mjs +0 -224
- package/dist/gray-tip-BwsIxacB.mjs.map +0 -1
- package/dist/gray-tip-DNo_Mi4E.d.mts +0 -10
- package/dist/gray-tip-DNo_Mi4E.d.mts.map +0 -1
- package/dist/index-BcQRoLtj.d.mts.map +0 -1
- package/dist/index-BlRIp4xi.d.mts.map +0 -1
- package/dist/index-xj5Z4aAN.d.mts.map +0 -1
- package/dist/milky-DsktXHch.mjs.map +0 -1
- package/dist/onebot11-CqHLrn9g.mjs.map +0 -1
- package/dist/satori-Bx8tkR9X.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gray-tip-BL1rhwZK.mjs","names":[],"sources":["../src/internal/infra/media-cache.ts","../src/internal/qq/media.ts","../src/internal/infra/log.ts","../src/internal/qq/gray-tip.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { randomUUID } from \"node:crypto\";\nimport {\n lstat,\n mkdir,\n readdir,\n readFile,\n realpath,\n rename,\n rmdir,\n unlink,\n writeFile,\n} from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { errorMessage, kernelError } from \"@napuketto/kernel\";\nimport type { AdapterLoggerLike } from \"./log.js\";\n\nconst CACHE_DIR = \".napuketto-media-v1\";\nconst ENTRY_RE = /^entry-(\\d+)-[\\da-f-]{36}$/;\nconst EXTENSION_RE = /^\\.[a-zA-Z0-9]+$/;\nconst OWNED_FILE_RE =\n /^(?:media\\.[a-zA-Z0-9]+(?:\\.part-\\d+-[\\da-f-]{36})?|\\.napuketto-[\\da-f]{16}\\.pcm|\\.owner-next-[\\da-f-]{36}\\.json|\\.lease-\\d+-[\\da-f-]{36})$/;\nconst LEASE_RE = /^\\.lease-(\\d+)-[\\da-f-]{36}$/;\nconst VIDEO_DIR_RE = /^\\.napuketto-video-[a-zA-Z0-9]{6}$/;\nconst DAY = 24 * 60 * 60 * 1000;\nconst META = \".owner.json\";\nexport const MEDIA_TEMP_ROOT = join(tmpdir(), \"napuketto-adapter-media\");\ntype Lifetime = \"temporary\" | \"reference\";\ninterface Owner {\n version: 1;\n lifetime: Lifetime;\n expires: number;\n}\ninterface Entry {\n dir: string;\n owner: Owner;\n bytes: number;\n files: string[];\n directories: string[];\n foreignLive: boolean;\n removable: boolean;\n}\ninterface Contents {\n bytes: number;\n removable: boolean;\n files: string[];\n directories: string[];\n}\ninterface CacheOptions {\n root?: string | undefined;\n logger?: Pick<AdapterLoggerLike, \"warn\"> | undefined;\n ttlMs?: number;\n orphanTtlMs?: number;\n maxBytes?: number;\n now?: () => number;\n}\ninterface Scope {\n cache: MediaCache;\n owned: Map<string, Lifetime>;\n pinned: Map<string, string>;\n failed: boolean;\n}\n\n// Coordination data only: cache services/timers belong to API instances. The locks also\n// serialize separate protocol instances configured with the same root in this process.\nconst locks = new Map<string, Promise<void>>();\nconst active = new Map<string, number>();\nconst scopes = new AsyncLocalStorage<Scope>();\n\nasync function locked<T>(root: string, task: () => Promise<T>): Promise<T> {\n const prior = locks.get(root) ?? Promise.resolve();\n let release = (): void => undefined;\n const next = new Promise<void>((done) => {\n release = done;\n });\n locks.set(root, next);\n await prior;\n try {\n return await task();\n } finally {\n release();\n if (locks.get(root) === next) locks.delete(root);\n }\n}\n\nfunction pin(dir: string): void {\n active.set(dir, (active.get(dir) ?? 0) + 1);\n}\nfunction unpin(dir: string): void {\n const count = active.get(dir) ?? 0;\n if (count <= 1) active.delete(dir);\n else active.set(dir, count - 1);\n}\nfunction missing(err: unknown): boolean {\n return err instanceof Error && \"code\" in err && err.code === \"ENOENT\";\n}\nfunction alive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (err) {\n return !(err instanceof Error && \"code\" in err && err.code === \"ESRCH\");\n }\n}\n\nfunction hasLiveLease(files: string[]): boolean {\n return files.some((name) => {\n const lease = LEASE_RE.exec(name);\n return lease !== null && alive(Number(lease[1]));\n });\n}\n\nfunction parseOwner(value: unknown): Owner | undefined {\n if (\n typeof value !== \"object\" ||\n value === null ||\n !(\"version\" in value) ||\n value.version !== 1 ||\n !(\"lifetime\" in value) ||\n (value.lifetime !== \"temporary\" && value.lifetime !== \"reference\") ||\n !(\"expires\" in value) ||\n typeof value.expires !== \"number\" ||\n !Number.isFinite(value.expires)\n )\n return undefined;\n return { version: 1, lifetime: value.lifetime, expires: value.expires };\n}\n\n/** Private adapter cache. Only its marked, flat entries are candidates for deletion. */\nexport class MediaCache {\n private readonly roots = new Set<string>();\n private timer: NodeJS.Timeout | undefined;\n private starting: Promise<void> | undefined;\n private generation = 0;\n private readonly ttl: number;\n private readonly orphanTtl: number;\n private readonly maxBytes: number;\n private readonly now: () => number;\n private readonly options: CacheOptions;\n\n constructor(options: CacheOptions = {}) {\n this.options = options;\n this.roots.add(resolve(MEDIA_TEMP_ROOT, CACHE_DIR));\n if (options.root) this.roots.add(resolve(options.root, CACHE_DIR));\n this.ttl = options.ttlMs ?? DAY;\n this.orphanTtl = options.orphanTtlMs ?? 60 * 60 * 1000;\n this.maxBytes = options.maxBytes ?? 512 * 1024 * 1024;\n this.now = options.now ?? Date.now;\n }\n\n async start(): Promise<void> {\n if (this.timer !== undefined) return;\n if (this.starting !== undefined) return await this.starting;\n const generation = ++this.generation;\n this.starting = this.sweep().then(() => {\n if (generation !== this.generation) return;\n this.timer = setInterval(() => {\n this.sweep().catch((err: unknown) => {\n this.options.logger?.warn({ error: errorMessage(err) }, \"媒体缓存清理失败\");\n });\n }, 60_000);\n this.timer.unref();\n });\n try {\n await this.starting;\n } finally {\n this.starting = undefined;\n }\n }\n\n stop(): void {\n this.generation++;\n if (this.timer !== undefined) clearInterval(this.timer);\n this.timer = undefined;\n }\n\n /** Nested action helpers reuse the lease until the outer action finishes. */\n async run<T>(task: () => Promise<T>): Promise<T> {\n if (scopes.getStore() !== undefined) return await task();\n const scope: Scope = { cache: this, owned: new Map(), pinned: new Map(), failed: false };\n return await scopes.run(scope, async () => {\n let result: T;\n try {\n result = await task();\n } catch (err) {\n await this.finish(scope, false).catch((cleanup: unknown) => {\n this.options.logger?.warn(\n { error: errorMessage(cleanup) },\n \"媒体动作失败后的清理失败\",\n );\n });\n throw err;\n }\n await this.finish(scope, !scope.failed);\n return result;\n });\n }\n\n private async finish(scope: Scope, success: boolean): Promise<void> {\n const cleaned = await Promise.allSettled(\n [...scope.owned].map(([dir, lifetime]) =>\n locked(dirname(dir), async () => {\n if (success && lifetime === \"reference\") {\n await this.mark(dir, \"reference\", this.now() + this.ttl);\n } else {\n await this.remove(dir);\n }\n }),\n ),\n );\n const released = await Promise.allSettled(\n [...scope.pinned].map(([dir, lease]) =>\n locked(dirname(dir), async () => {\n try {\n await this.checkRoot(dirname(dir));\n if ((await lstat(dir)).isSymbolicLink() || (await realpath(dir)) !== dir) {\n throw kernelError(\"媒体缓存租约边界已改变\", \"INVALID_STATE\");\n }\n await unlink(join(dir, lease));\n } finally {\n unpin(dir);\n }\n }),\n ),\n );\n for (const dir of scope.owned.keys()) unpin(dir);\n const failure = [...cleaned, ...released].find((result) => result.status === \"rejected\");\n if (failure?.status === \"rejected\") throw failure.reason;\n }\n\n /** Allocate before any download/write. Writer may return a renamed output in the same entry. */\n async create(\n base: string,\n extension: string,\n writer: (path: string) => Promise<string> | Promise<void>,\n lifetime: Lifetime = \"temporary\",\n ): Promise<string> {\n if (!EXTENSION_RE.test(extension)) {\n throw kernelError(\"非法媒体缓存扩展名\", \"INVALID_PARAM\");\n }\n // Resolve caller-chosen base once; never sweep the base itself or adopt its contents.\n await mkdir(resolve(base), { recursive: true });\n const root = join(await realpath(resolve(base)), CACHE_DIR);\n this.roots.add(root);\n const dir = await locked(root, async () => {\n await mkdir(root, { recursive: true });\n await this.checkRoot(root);\n await this.collect(root);\n for (let attempt = 0; attempt < 8; attempt++) {\n const candidate = join(root, `entry-${process.pid}-${randomUUID()}`);\n try {\n await mkdir(candidate);\n } catch (err) {\n if (err instanceof Error && \"code\" in err && err.code === \"EEXIST\") continue;\n throw err;\n }\n pin(candidate);\n try {\n await this.mark(candidate, \"temporary\", this.now() + this.orphanTtl);\n } catch (err) {\n unpin(candidate);\n await rmdir(candidate);\n throw err;\n }\n return candidate;\n }\n throw kernelError(\"媒体缓存命名冲突\", \"INVALID_STATE\");\n });\n const scope = scopes.getStore();\n try {\n const path = join(dir, `media${extension}`);\n const output = (await writer(path)) ?? path;\n const info = await lstat(output);\n if (\n dirname(resolve(output)) !== dir ||\n !OWNED_FILE_RE.test(basename(output)) ||\n !info.isFile() ||\n info.isSymbolicLink()\n ) {\n throw kernelError(\"媒体缓存输出超出受控目录\", \"INVALID_STATE\");\n }\n await locked(root, async () => {\n const bytes = await this.collect(root);\n if (bytes > this.maxBytes) {\n throw kernelError(\n \"媒体缓存容量已满(引用期限或使用中租约保护)\",\n \"INVALID_STATE\",\n );\n }\n // Without an action scope, the caller consumes the returned path later.\n if (scope === undefined) await this.mark(dir, \"reference\", this.now() + this.ttl);\n });\n if (scope !== undefined) scope.owned.set(dir, lifetime);\n else unpin(dir);\n return output;\n } catch (err) {\n try {\n await locked(root, () => this.remove(dir));\n } finally {\n unpin(dir);\n }\n throw err;\n }\n }\n\n async sweep(): Promise<void> {\n for (const configuredRoot of this.roots) {\n let root: string;\n try {\n root = join(await realpath(dirname(configuredRoot)), CACHE_DIR);\n } catch (err) {\n if (missing(err)) continue;\n throw err;\n }\n await locked(root, async () => {\n try {\n await this.checkRoot(root);\n } catch (err) {\n if (missing(err)) return;\n throw err;\n }\n await this.collect(root);\n });\n }\n }\n\n private async checkRoot(root: string): Promise<void> {\n const info = await lstat(root);\n if (!info.isDirectory() || info.isSymbolicLink() || (await realpath(root)) !== root) {\n throw kernelError(\"媒体缓存目录不能是符号链接\", \"INVALID_STATE\");\n }\n }\n\n private async mark(dir: string, lifetime: Lifetime, expires: number): Promise<void> {\n await this.checkRoot(dirname(dir));\n const info = await lstat(dir);\n if (!info.isDirectory() || info.isSymbolicLink() || (await realpath(dir)) !== dir) {\n throw kernelError(\"媒体缓存条目边界无效\", \"INVALID_STATE\");\n }\n const metadata = join(dir, META);\n const next = join(dir, `.owner-next-${randomUUID()}.json`);\n try {\n await writeFile(next, JSON.stringify({ version: 1, lifetime, expires }), {\n flag: \"wx\",\n });\n await rename(next, metadata);\n } finally {\n await unlink(next).catch((err: unknown) => {\n if (!missing(err)) throw err;\n });\n }\n }\n\n private async inspect(dir: string): Promise<Entry | undefined> {\n const match = ENTRY_RE.exec(basename(dir));\n if (match === null) return undefined;\n const info = await lstat(dir);\n if (!info.isDirectory() || info.isSymbolicLink()) return undefined;\n const files = await readdir(dir);\n const summary = await this.summarize(dir, files);\n if (summary === undefined) return undefined;\n if (!files.includes(META)) return undefined;\n const parsed = parseOwner(JSON.parse(await readFile(join(dir, META), \"utf8\")));\n if (parsed === undefined) return undefined;\n const pid = Number(match[1]);\n return {\n dir,\n owner: parsed,\n bytes: summary.bytes,\n files: summary.files,\n directories: summary.directories,\n foreignLive: (pid !== process.pid && alive(pid)) || hasLiveLease(files),\n removable: summary.removable,\n };\n }\n\n private async summarize(dir: string, files: string[]): Promise<Contents | undefined> {\n const out: Contents = { bytes: 0, removable: true, files: [], directories: [] };\n for (const file of files) {\n const item = await this.summarizeFile(dir, file);\n if (item === undefined) return undefined;\n out.bytes += item.bytes;\n out.removable &&= item.removable;\n out.files.push(...item.files);\n out.directories.push(...item.directories);\n }\n return out;\n }\n\n private async summarizeFile(dir: string, file: string): Promise<Contents | undefined> {\n const stat = await lstat(join(dir, file));\n if (stat.isDirectory() && VIDEO_DIR_RE.test(file)) {\n const nested = await this.videoOutput(join(dir, file));\n return nested === undefined\n ? { bytes: Number.POSITIVE_INFINITY, removable: false, files: [], directories: [] }\n : {\n bytes: nested.bytes,\n removable: true,\n files: nested.files.map((name) => join(file, name)),\n directories: [file],\n };\n }\n const regular = stat.isFile() && !stat.isSymbolicLink();\n if (file === META && !regular) return undefined;\n return {\n bytes: file === META ? 0 : regular ? stat.size : Number.POSITIVE_INFINITY,\n removable: regular && (file === META || OWNED_FILE_RE.test(file)),\n files: [file],\n directories: [],\n };\n }\n\n private async videoOutput(\n dir: string,\n ): Promise<{ bytes: number; files: string[] } | undefined> {\n const files = await readdir(dir);\n if (files.length === 0) return { bytes: 0, files };\n if (files.length !== 1 || files[0] !== \"output.mp4\") return undefined;\n const info = await lstat(join(dir, \"output.mp4\"));\n return info.isFile() && !info.isSymbolicLink() ? { bytes: info.size, files } : undefined;\n }\n\n private async collect(root: string): Promise<number> {\n let total = 0;\n for (const name of await readdir(root)) {\n const dir = join(root, name);\n let entry: Entry | undefined;\n try {\n entry = await this.inspect(dir);\n } catch (err) {\n if (missing(err) || err instanceof SyntaxError) continue;\n throw err;\n }\n if (entry === undefined) continue;\n if (\n entry.removable &&\n !active.has(dir) &&\n !entry.foreignLive &&\n entry.owner.expires <= this.now()\n ) {\n await this.remove(dir);\n } else {\n total += entry.bytes;\n }\n }\n return total;\n }\n\n private async remove(dir: string): Promise<void> {\n await this.checkRoot(dirname(dir));\n const entry = await this.inspect(dir);\n if (entry === undefined || !entry.removable || hasLiveLease(entry.files)) return;\n for (const file of entry.files.filter((name) => name !== META)) {\n // Revalidate both boundaries and file type immediately before unlink; never recurse.\n await this.checkRoot(dirname(dir));\n if ((await realpath(dir)) !== dir || (await lstat(dir)).isSymbolicLink()) {\n throw kernelError(\"媒体缓存条目边界已改变\", \"INVALID_STATE\");\n }\n const path = join(dir, file);\n if ((await realpath(dirname(path))) !== dirname(path)) return;\n const info = await lstat(path);\n if (!info.isFile() || info.isSymbolicLink()) return;\n await unlink(path);\n }\n for (const name of entry.directories) await rmdir(join(dir, name));\n await unlink(join(dir, META));\n await rmdir(dir);\n }\n}\n\n/** Action factories also work independently of an adapter/registry. */\nexport async function withMediaScope<T>(task: () => Promise<T>): Promise<T> {\n const scope = scopes.getStore();\n if (scope === undefined) return await new MediaCache().run(task);\n try {\n return await task();\n } catch (err) {\n scope.failed = true;\n throw err;\n }\n}\n\nexport async function cacheMediaFile(\n root: string,\n extension: string,\n writer: (path: string) => Promise<string> | Promise<void>,\n lifetime: Lifetime = \"temporary\",\n): Promise<string> {\n return await (scopes.getStore()?.cache ?? new MediaCache()).create(\n root,\n extension,\n writer,\n lifetime,\n );\n}\n\n/** Lease a previously returned cache path; caller/QQ paths are never adopted. */\nexport async function protectMediaPath(path: string): Promise<string> {\n const scope = scopes.getStore();\n const dir = dirname(resolve(path));\n const root = dirname(dir);\n if (\n scope === undefined ||\n basename(root) !== CACHE_DIR ||\n !ENTRY_RE.test(basename(dir)) ||\n scope.pinned.has(dir) ||\n scope.owned.has(dir)\n )\n return path;\n await locked(root, async () => {\n if (\n (await lstat(root)).isSymbolicLink() ||\n (await realpath(root)) !== root ||\n (await lstat(dir)).isSymbolicLink() ||\n (await realpath(dir)) !== dir\n ) {\n throw kernelError(\"媒体缓存引用边界无效\", \"INVALID_STATE\");\n }\n const marker = join(dir, META);\n if (\n (await lstat(marker)).isSymbolicLink() ||\n parseOwner(JSON.parse(await readFile(marker, \"utf8\"))) === undefined\n ) {\n throw kernelError(\"媒体缓存引用缺少所有权标记\", \"INVALID_STATE\");\n }\n const lease = `.lease-${process.pid}-${randomUUID()}`;\n await writeFile(join(dir, lease), \"\", { flag: \"wx\" });\n pin(dir);\n scope.pinned.set(dir, lease);\n });\n return path;\n}\n","/**\n * adapter core 媒体辅助:语音归一化 + 视频缩略图(media 严格解耦的协议层落点)\n *\n * 协议层(onebot11 / satori)发送媒体前统一走这里:\n * - `ensureSilk`:非 silk 音频转 QQ 语音格式(silk v3);\n * - `prepareVideoElements`:视频缺缩略图/时长/尺寸时,用 ffmpeg 抽首帧并探测元数据。\n * 都依赖 @napuketto/media,只发生在 adapter 层;kernel 不 import media(红线),\n * 只接收「文件齐全」的 canonical 元素。\n */\nimport { copyFile, mkdtemp, open, rm, stat } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { extname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { CanonicalElement } from \"@napuketto/kernel\";\nimport { errorMessage, kernelError } from \"@napuketto/kernel\";\nimport { downloadUrl, encodePcmToSilk, extractVideoFrame, getVideoInfo } from \"@napuketto/media\";\nimport type { AdapterLoggerLike } from \"../infra/log.js\";\nimport { cacheMediaFile, MEDIA_TEMP_ROOT, protectMediaPath } from \"../infra/media-cache.js\";\n\n/** file:// 前缀(fileURLToPath 解析失败时的裸剥离兜底)。 */\nexport const FILE_URI_PREFIX_RE = /^file:\\/\\//;\nconst MEDIA_EXTENSION_RE = /^\\.[a-zA-Z0-9]+$/;\n// Match media's audio input bound before creating the owned conversion copy.\nconst MAX_AUDIO_COPY_BYTES = 32 * 1024 * 1024;\n\n/**\n * file:// URI → 平台路径(Windows 盘符 / 百分号编码兼容)。\n * fileURLToPath 解析失败时退化为裸剥离前缀(历史兜底行为,协议侧共用)。\n */\nexport function fileUriToPath(uri: string): string {\n try {\n return fileURLToPath(uri);\n } catch {\n return FILE_URI_PREFIX_RE.test(uri) ? uri.replace(FILE_URI_PREFIX_RE, \"\") : uri;\n }\n}\n\n/**\n * 远程 URL → 本地文件(异步 mkdir + 流式落盘,全仓协议层唯一落盘入口)。\n *\n * - 走 `@napuketto/media` 的 `downloadUrl`:超时、大小上限、流式落盘、协议白名单\n * 与「逐跳复检」的重定向策略都在那里统一(此前这里是裸 `fetch` + `arrayBuffer()`,\n * 无超时无上限:恶意超大响应可直接打爆 Node 堆);\n * - 父目录不存在时自动创建;\n * - 失败统一包成 KernelError SEND_FAILED(`label` 供调用方定制前缀,如「头像下载失败」);\n * - 返回落盘路径(便于调用方直接回传)。\n */\nexport async function downloadBufferToFile(\n url: string,\n filePath: string,\n init?: RequestInit,\n label = \"下载失败\",\n): Promise<string> {\n try {\n const headers = init?.headers === undefined ? undefined : normalizeHeaders(init.headers);\n await downloadUrl(url, filePath, headers === undefined ? {} : { headers });\n } catch (err) {\n throw kernelError(`${label}: ${errorMessage(err)}`, \"SEND_FAILED\", { cause: err });\n }\n return filePath;\n}\n\n/** RequestInit.headers(Headers / 元组数组 / 普通对象)→ 普通字符串对象。 */\nfunction normalizeHeaders(headers: NonNullable<RequestInit[\"headers\"]>): Record<string, string> {\n const out: Record<string, string> = {};\n new Headers(headers).forEach((value, key) => {\n out[key] = value;\n });\n return out;\n}\n\n/** 读文件头 8 字节(判断 silk 魔数)。 */\nasync function readFileHead(path: string): Promise<string> {\n const handle = await open(path, \"r\");\n try {\n const buf = Buffer.alloc(8);\n await handle.read(buf, 0, 8, 0);\n return buf.toString(\"utf8\");\n } finally {\n await handle.close();\n }\n}\n\n/**\n * 语音转码:非 silk 输入(任意音频格式,经 @napuketto/media 归一化)转 silk。\n * 已是 silk(#!SILK_V3 头)原样返回;转码失败原样返回(由 kernel 发送时兜底),\n * 可选 logger 记录降级上下文。\n */\nexport async function ensureSilk(path: string, logger?: AdapterLoggerLike): Promise<string> {\n try {\n await protectMediaPath(path);\n const info = await stat(path);\n if (!info.isFile() || info.size > MAX_AUDIO_COPY_BYTES) {\n throw kernelError(\"语音复制输入必须是 32MiB 以内的普通文件\", \"INVALID_PARAM\");\n }\n const header = await readFileHead(path);\n if (header.startsWith(\"#!SILK\")) {\n return path;\n }\n const ext = extname(path);\n return await cacheMediaFile(\n MEDIA_TEMP_ROOT,\n MEDIA_EXTENSION_RE.test(ext) ? ext : \".bin\",\n async (copy) => {\n await copyFile(path, copy);\n return await encodePcmToSilk(copy);\n },\n );\n } catch (err) {\n logger?.warn({ path, error: errorMessage(err) }, \"语音 silk 转码失败,原样透传\");\n return path;\n }\n}\n\n/** 视频元素准备结果。 */\nexport interface PreparedVideoElements {\n /** 补全后的元素(保持原顺序)。 */\n elements: CanonicalElement[];\n /** 删除临时缩略图目录;没有生成缩略图时是 no-op。发送结束后必须调用。 */\n cleanup: () => Promise<void>;\n}\n\n/** 是否是需要补缩略图的视频元素。 */\nfunction needsVideoThumb(el: CanonicalElement): el is Extract<CanonicalElement, { type: \"video\" }> {\n return el.type === \"video\" && (el.thumbPath === undefined || el.thumbPath === \"\");\n}\n\n/**\n * 视频元素补「首帧缩略图 + 时长 + 尺寸」(QQ 视频消息发送契约)。\n *\n * 为什么必须补:kernel 的 `prepareVideoElement` 只有在 `thumbPath` 存在时才写\n * `thumbMd5 / thumbSize / thumbPath(Map)`,缺失时 native 传输找不到缩略图,\n * `sendMsg` 只回 `sendStatus=0`(无错误信息);`fileTime`(秒)也取自\n * `durationSec`,缺省 0。Linux 原生宿主实测:只给 `file` 的 OB11 `video` 段\n * 必然失败,补上首帧后成功。\n *\n * 缩略图写在系统临时目录(发送时 kernel 会 copyFile 进 QQ 数据目录),\n * 由 `cleanup` 统一删除——不污染用户文件目录。\n *\n * 依赖系统 ffmpeg / ffprobe(@napuketto/media);缺失或抽帧失败时抛\n * `MediaError`,由协议动作层映射成可读错误,而不是让 native 回 `sendStatus=0`。\n */\nexport async function prepareVideoElements(\n elements: readonly CanonicalElement[],\n): Promise<PreparedVideoElements> {\n if (!elements.some(needsVideoThumb)) {\n return { elements: [...elements], cleanup: async () => undefined };\n }\n const dir = await mkdtemp(join(tmpdir(), \"napuketto-video-thumb-\"));\n const cleanup = async (): Promise<void> => {\n await rm(dir, { recursive: true, force: true });\n };\n try {\n const out: CanonicalElement[] = [];\n let index = 0;\n for (const el of elements) {\n if (!needsVideoThumb(el)) {\n out.push(el);\n continue;\n }\n index += 1;\n const thumbPath = join(dir, `thumb-${index}.png`);\n const info = await getVideoInfo(el.path);\n await extractVideoFrame(el.path, thumbPath);\n out.push({\n ...el,\n thumbPath,\n // kernel 把 width/height 写进 thumbWidth/thumbHeight(收向语义是缩略图尺寸;\n // 首帧不缩放 → 与视频宽高一致)\n width: el.width ?? info.width,\n height: el.height ?? info.height,\n durationSec: el.durationSec ?? Math.max(1, Math.round(info.durationMs / 1000)),\n });\n }\n return { elements: out, cleanup };\n } catch (err) {\n await cleanup();\n throw err;\n }\n}\n","/**\n * raw 日志截断与最小 logger 面(协议 adapter 校准日志共用,自\n * onebot11/milky adapter.ts 顶部内联工具收拢)。\n *\n * info/warn 级 raw 字段对运行状态无信息量(输出内容治理):\n * hex/base64/JSON 原文保留前缀定位 + 缺省长度标注;完整值仅在 debug 级\n * 与日志文件中出现。两种截断口径刻意并存——OB11 校准日志带缺省长度标注,\n * Milky 长文本校准日志用固定切片(无标注)。\n */\n\nimport { errorMessage } from \"@napuketto/kernel\";\n\n/** info/warn 级截断缺省上限(OB11 口径)。 */\nconst RAW_INFO_LIMIT = 64;\n\n/** 长文本截断缺省上限(debug / raw 校准日志防刷屏)。 */\nconst RAW_DEBUG_LIMIT = 2000;\n\n/**\n * raw 字段截断:超限截断 + 缺省长度标注(…(+N))。\n * OB11 校准日志(warn 级 64 缺省)口径。\n */\nexport function truncRaw(value: string | undefined, keep = RAW_INFO_LIMIT): string {\n if (value === undefined) {\n return \"\";\n }\n return value.length <= keep ? value : `${value.slice(0, keep)}…(+${value.length - keep})`;\n}\n\n/** 长文本截断:固定上限切片(Milky 校准日志 2000 缺省口径,无长度标注)。 */\nexport function sliceRaw(value: string | undefined, max = RAW_DEBUG_LIMIT): string {\n return value === undefined ? \"\" : value.slice(0, max);\n}\n\n/**\n * 事件链翻译失败留痕(收链路异步 .catch 统一出口:单条/整批丢弃,warn 留痕\n * 不打断订阅;err 规范化为 message 串)。\n */\nexport function logEventFailure(\n logger: AdapterLoggerLike | undefined,\n msg: string,\n err: unknown,\n): void {\n logger?.warn({ err: errorMessage(err) }, msg);\n}\n\n/** 最小 logger 面(校准日志用:未知事件形状打 raw JSON;缺省静默)。 */\nexport interface AdapterLoggerLike {\n warn(obj: unknown, msg?: string): void;\n info(obj: unknown, msg?: string): void;\n /** 校准数据(级别重分配:info → debug;此面必须支持)。 */\n debug(obj: unknown, msg?: string): void;\n}\n","/**\n * grayTip 元素工具(OB11 / Satori 共用,克隆合并)\n *\n * grayTip(系统提示消息)涉及的操作者/成员 uid 需要批量 uid→uin 转换,\n * 两协议翻译层共用同一套收集逻辑。\n */\nimport type { GrayTipElement, RawMessage } from \"@napuketto/kernel\";\n\n/**\n * 消息是否含 grayTip 元素(OB11 / Milky 收链路分流判据,收拢)。\n * `!= null` 空值判定:Linux 原生宿主把未命中的变体字段显式置 null,\n * `!== undefined` 会把普通消息误判成 grayTip 消息(见 OB11 hasFileElement 注)。\n */\nexport function hasGrayTip(msg: RawMessage): boolean {\n return msg.elements.some((el) => el.grayTipElement != null);\n}\n\n/** 非空 uid 才加入集合(Linux 原生对象未命中的字段是显式 null,不只 undefined)。 */\nfunction collectUids(uids: Set<string>, ...candidates: Array<string | null | undefined>): void {\n for (const uid of candidates) {\n if (uid != null && uid !== \"\") {\n uids.add(uid);\n }\n }\n}\n\n/** 收集 grayTip 涉及的 uid(批量 uidToUin 用)。 */\nexport function collectGrayTipUids(msg: RawMessage): string[] {\n const uids = new Set<string>();\n for (const el of msg.elements) {\n const g = el.grayTipElement;\n // Linux 原生对象未命中的变体字段显式置 null(== null 判据,读字段前先挡)\n if (g == null) {\n continue;\n }\n collectUids(uids, g.revokeElement?.operatorUid, g.aioOpGrayTipElement?.peerUid);\n const grp = g.groupElement;\n // Linux 原生对象未命中的变体字段显式置 null(== null 判据)\n if (grp == null) {\n continue;\n }\n collectUids(\n uids,\n grp.memberUid,\n grp.adminUid,\n grp.shutUp?.admin?.uid,\n grp.shutUp?.member?.uid,\n );\n }\n return [...uids];\n}\n\n/**\n * 第一条「已挂载但不可翻译」的 grayTip 元素(校准日志入口)。\n * 与 OB11 / Milky notice 翻译共用:翻译函数返回 null 时用本函数定位元素打 raw\n * 日志,两协议的日志口径一致(跳过 REVOKE——撤回翻译独立成事件)。\n */\nexport function firstUntranslatedGrayTip(msg: RawMessage): GrayTipElement | undefined {\n for (const el of msg.elements) {\n const g = el.grayTipElement;\n // Linux 原生对象未命中的变体字段显式置 null:g/revokeElement 都按空值判\n if (g != null && g.revokeElement == null) {\n return g;\n }\n }\n return undefined;\n}\n\n/**\n * 撤回 grayTip 元素(非撤回消息返回 undefined;Milky 收链路 notice/召回\n * 分流判据,自 milky adapter.ts 收拢)。\n */\nexport function findRevokeElement(\n msg: RawMessage,\n): NonNullable<GrayTipElement[\"revokeElement\"]> | undefined {\n // `?? undefined`:Linux 原生对象显式 null 在类型上不满足 NonNullable 返回;\n // 统一归一成 undefined(调用方只做「是否命中」判定)。\n return (\n msg.elements.find((el) =>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I,SAAS,MAAM,OAAO,GAAG,kBAAkB,IAAI;AAC9D;;AAGA,SAAS,YAAY,MAAmB,GAAG,YAAoD;CAC3F,KAAK,MAAM,OAAO,YACd,IAAI,OAAO,QAAQ,QAAQ,IACvB,KAAK,IAAI,GAAG;AAGxB;;AAGA,SAAgB,mBAAmB,KAA2B;CAC1D,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,MAAM,IAAI,UAAU;EAC3B,MAAM,IAAI,GAAG;EAEb,IAAI,KAAK,MACL;EAEJ,YAAY,MAAM,EAAE,eAAe,aAAa,EAAE,qBAAqB,OAAO;EAC9E,MAAM,MAAM,EAAE;EAEd,IAAI,OAAO,MACP;EAEJ,YACI,MACA,IAAI,WACJ,IAAI,UACJ,IAAI,QAAQ,OAAO,KACnB,IAAI,QAAQ,QAAQ,GACxB;CACJ;CACA,OAAO,CAAC,GAAG,IAAI;AACnB;;;;;;AAOA,SAAgB,yBAAyB,KAA6C;CAClF,KAAK,MAAM,MAAM,IAAI,UAAU;EAC3B,MAAM,IAAI,GAAG;EAEb,IAAI,KAAK,QAAQ,EAAE,iBAAiB,MAChC,OAAO;CAEf;AAEJ;;;;;AAMA,SAAgB,kBACZ,KACwD;CAGxD,OACI,IAAI,SAAS,MAAM,OAAO,GAAG,gBAAgB,iBAAiB,IAAI,CAAC,EAAE,gBAC/D,iBAAiB,KAAA;AAE/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@napuketto/kernel";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { m as ActionRegistry, s as BaseProtocolAdapter, t as ConfigBase$1 } from "./index-BZfGz6FA.mjs";
|
|
2
|
+
import { t as MediaCache } from "./media-cache-C_0C9eCV.mjs";
|
|
2
3
|
import { BuddyEventChannel, ChatType, FlashTransferApi, FriendApi, GroupApi, GroupCache, GroupEventChannel, GroupNotifyApi, KernelErrorCode, LoginEventChannel, MsgApi, MsgEventChannel, Peer, ProfileApi, ProfileLikeApi, RawMessage, RecentContactApi, RecentContactEventChannel, RichMediaApi, TicketApi, WebApi } from "@napuketto/kernel";
|
|
3
4
|
import { EventBroadcaster, TransportAdapter } from "@napuketto/network";
|
|
4
5
|
import { ZodType, z } from "zod";
|
|
@@ -136,6 +137,7 @@ interface MilkyApiOptions {
|
|
|
136
137
|
logger?: MilkyLoggerLike | undefined;
|
|
137
138
|
}
|
|
138
139
|
declare class MilkyApi {
|
|
140
|
+
readonly mediaCache: MediaCache;
|
|
139
141
|
readonly msgApi: MsgApi;
|
|
140
142
|
readonly groupApi: GroupApi;
|
|
141
143
|
readonly friendApi: FriendApi;
|
|
@@ -709,4 +711,4 @@ interface BotOfflineData {
|
|
|
709
711
|
reason: string;
|
|
710
712
|
}
|
|
711
713
|
export { MessageRecallData as A, MilkyApi as B, GroupMuteData as C, IncomingForwardedMessage as D, GroupWholeMuteData as E, PeerPinChangeData as F, MilkyConfig as G, MilkyLoggerLike as H, SendMessageOutput as I, milkyErrorCodeMap as J, milkyConfigSchema as K, MilkyAdapterOptions as L, MilkyEvent as M, OutgoingForwardedMessage as N, IncomingMessage as O, OutgoingSegment as P, NapukettoMilkyAdapter as R, GroupMessageReactionData as S, GroupNotificationEntity as T, MilkyTransportSet as U, MilkyApiOptions as V, assembleMilkyTransports as W, GroupInvitedJoinRequestData as _, FriendRequestEntity as a, GroupMemberEntity as b, GetLoginInfoOutput as c, GroupEntity as d, GroupEssenceMessage as f, GroupInvitationData as g, GroupFolderEntity as h, FriendRequestData as i, MessageScene as j, IncomingSegment as k, GroupAnnouncementEntity as l, GroupFileUploadData as m, FriendCategoryEntity as n, GetCookiesOutput as o, GroupFileEntity as p, MilkyAction as q, FriendEntity as r, GetImplInfoOutput as s, BotOfflineData as t, GroupDisbandData as u, GroupJoinRequestData as v, GroupNameChangeData as w, GroupMemberIncreaseData as x, GroupMemberDecreaseData as y, createMilkyActionRegistry as z };
|
|
712
|
-
//# sourceMappingURL=index-
|
|
714
|
+
//# sourceMappingURL=index-CKWWp8-H.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CKWWp8-H.d.mts","names":["ConfigBase"],"sources":["../src/milky/action/base-action.ts","../src/milky/helper/state/seq-index.ts","../src/milky/config.ts","../src/milky/transport.ts","../src/milky/api.ts","../src/milky/action/index.ts","../src/milky/adapter.ts","../src/milky/types.ts"],"mappings":";;;;;;;;;;;;KAqBY,kBAAkB;EAEpB;EACA;EACA,MAAM;EACN;;EAGA;EACA;EACA;EACA;;;UAIO,YAAY,oBAAoB;WACpC;WACA,QAAQ,QAAQ;;EAEzB,OAAO,mBAAmB,QAAQ,kBAAkB;;;cAI3C,mBAAmB,OAAO;;UCpBtB;EACb,UAAU;EACV;EACA;;cAGS;;mBAEQ;;mBAEA;;mBAEA;;EAGjB,OAAO,KAAK;;EAeZ,aAAa,UAAU,UAAU,iBAAiB;;;;;EAQlD,iBACI,mBACD;IAAc;IAAoB;IAAkB;;;UAgB/C;;;;;EAQR,cAAc,eAAe,OAAO;;EAepC,eAAe,gBAAgB;;UAKvB;;;cCnGC,mBAAiB,EAAA;;;;;;;;;;;GAe5B,EAAA,KAAA;;KAGU,cAAc,EAAE,aAAa;;UCOxB;EACb,MAAM,cAAc;EACpB,KAAK,cAAc;EACnB,KAAK,cAAc;;;UAIN;;EAEb,UAAU;;EAEV,aAAa;;;iBA6FD,wBAAwB;EACpC,QAAQ;EACR,aAAa;EACb,UAAU,eAAe;EACzB,SAAS;IACT;;UChHa;EACb,QAAQ;EACR,UAAU;EACV,WAAW;EACX,YAAY;;EAEZ,gBAAgB;EAChB,WAAW;EACX,QAAQ;EACR,gBAAgB;EAChB,cAAc;;EAEd,kBAAkB;;EAElB,kBAAkB;;EAElB;IAAQ;IAAa;IAAkB;;;EAEvC,aAAa;;EAEb;;EAEA;;EAEA;;EAEA,SAAS;;cAcA;WACA,YAAY;WACZ,QAAQ;WACR,UAAU;WACV,WAAW;WACX,YAAY;WACZ,gBAAgB;WAChB,WAAW;WACX,Q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A;IAAQ;IAAoB;IAAe;IAAmB;;;EAG9D;EACA;IACI;IACA;IACA;IACA;IACA;;;EAGN;EAAmB;IAAQ;IAAkB;;;EAC7C;EAAa;IAAQ;IAAoB;;;EACzC;EAAkB;IAAQ;;;;UAGjB;EACb;EACA;EACA;EACA,UAAU;;;;KAKF;EACJ;EAAc;IAAQ;;;EACtB;EAAiB;IAAQ;;;EACzB;EAAqB,MAAM;;EAC3B;EAAc;IAAQ;IAAiB;;;EACvC;EAAe;IAAQ;;;EAErB;EACA;IAAQ;IAAa;IAAwC;;;EAE/D;EAAgB;IAAQ;;;EACxB;EAAe;IAAQ;IAAa;;;EAElC;EACA;IACI,UAAU;IACV;IACA;IACA;IACA;;;EAGN;EAAmB;IAAQ;;;;KAGvB;EAEF;EACA;EACA;EACA;EACA;EACA,UAAU;EACV,QAAQ;;EAGR;EACA;EACA;EACA;EACA;EACA,UAAU;EACV,OAAO;EACP,cAAc;;EAGd;EACA;EACA;EACA;EACA;EACA,UAAU;EACV,QAAQ;;;UAID,WAAW;EACxB;EACA;EACA;EACA,MAAM;;;UAIO;EACb,eAAe;EACf;EACA;EACA;EACA;EACA;;;;UAMa;EACb;EACA;;;UAIa;EACb;EACA;EACA;EACA;EACA;;;UAIa;EACb;EACA;;;UAsDa;EACb;;;UAqCa;EACb;EACA;EACA;EACA;EACA;EACA;;;;UA+Ca;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;KAIQ;EAEF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAGA;EACA;EACA;EACA;EACA;EACA;;EAGA;EACA;EACA;EACA;EACA;;EAGA;EACA;EACA;EACA;;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;;;UAIO;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;;;UAIG;EACb;EACA;EACA;EACA;EACA,UAAU;;;;UAMG;EACb;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;;;UAIa;EACb;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;;;UAwBa;EACb;EACA;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;;;UAIa;EACb;EACA;;;UAIa;EACb;;EAEA;EACA;;EAEA;EACA;EACA;;;UAIa;EACb;EACA;EACA;;;UAwBa;EACb"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { _ as ErrorCodeMap, m as ActionRegistry, s as BaseProtocolAdapter, t as ConfigBase$1 } from "./index-BZfGz6FA.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { n as AdapterLoggerLike, t as MediaCache } from "./media-cache-C_0C9eCV.mjs";
|
|
3
|
+
import "./gray-tip-CcpfI1Og.mjs";
|
|
3
4
|
import { BuddyCacheEventChannel, BuddyEventChannel, CanonicalElement, FlashTransferApi, FriendApi, GroupApi, GroupCache, GroupEventChannel, GroupNotifyApi, MsgApi, MsgEventChannel, Peer, ProfileApi, ProfileLikeApi, RichMediaApi, TicketApi, WebApi } from "@napuketto/kernel";
|
|
4
5
|
import { EventBroadcaster, TransportAdapter } from "@napuketto/network";
|
|
5
6
|
import { ZodType, z } from "zod";
|
|
@@ -291,6 +292,7 @@ interface OneBotApiOptions {
|
|
|
291
292
|
* 各动作经 `Pick<OneBotApi, ...>` 取所需成员;注册处只构造一次本对象。
|
|
292
293
|
*/
|
|
293
294
|
declare class OneBotApi {
|
|
295
|
+
readonly mediaCache: MediaCache;
|
|
294
296
|
/** kernel 消息 API(send_msg 等消息类动作用)。 */
|
|
295
297
|
readonly msgApi: MsgApi;
|
|
296
298
|
/** kernel 群 API。 */
|
|
@@ -849,4 +851,4 @@ interface AssembleOb11TransportsOptions {
|
|
|
849
851
|
/** 按配置装配 OB11 传输。 */
|
|
850
852
|
declare function assembleOb11Transports(opts: AssembleOb11TransportsOptions): Ob11TransportSet;
|
|
851
853
|
export { OB11MessageInfo as $, serializeCqParts as A, canonicalToCqMessage as B, ob11ConfigSchema as C, escapeCqParam as D, encodeCqCode as E, ob11ErrorCodeMap as F, CurrentTalkative as G, cqMessageToCanonical as H, OneBotApi as I, GroupInfo as J, FriendInfo as K, OneBotApiOptions as L, Ob11ActionDeps as M, createOb11ActionRegistry as N, escapeCqText as O, AtAllRemainInfo as P, OB11Message as Q, OneBotSystemOptions as R, OB11Config as S, CqCode as T, cqMessageToSegments as U, canonicalToSegments as V, segmentsToCanonical as W, HonorMember as X, GroupMemberInfo as Y, LoginInfo as Z, OB11GroupMessageEvent as _, assembleOb11Transports as a, VersionInfo as at, OB11BaseEvent as b, OB11Event as c, OB11RequestEvent as d, OB11MessageSegment as et, OB11NoticeEvent as f, OB11Status as g, OB11MetaEvent as h, Ob11TransportSet as i, StrangerInfo as it, unescapeCqText as j, parseCqMessage as k, OB11FriendRequestEvent as l, OB11LifecycleMetaEvent as m, Ob11OutboundTransport as n, Sender as nt, NapukettoOneBot11Adapter as o, OB11HeartbeatMetaEvent as p, GroupHonorInfo as q, Ob11OutboundWsReconnect as r, Sex as rt, OneBot11AdapterOptions as s, AssembleOb11TransportsOptions as t, OB11Return as tt, OB11GroupRequestEvent as u, OB11MessageEvent as v, segmentsToCqMessage as w, OB11PostType as x, OB11PrivateMessageEvent as y, MessageUnique as z };
|
|
852
|
-
//# sourceMappingURL=index-
|
|
854
|
+
//# sourceMappingURL=index-DrPCnj64.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DrPCnj64.d.mts","names":["MessageEventUnion","NoticeEventUnion","RequestEventUnion","MetaEventUnion","ConfigBase"],"sources":["../src/onebot11/types/index.ts","../src/onebot11/helper/data.ts","../src/onebot11/helper/message-unique.ts","../src/onebot11/api/onebot-api.ts","../src/onebot11/action/base-action.ts","../src/onebot11/action/group/query.ts","../src/onebot11/action/index.ts","../src/onebot11/helper/codec/cqcode.ts","../src/onebot11/helper/codec/segment.ts","../src/onebot11/helper/config.ts","../src/onebot11/event/base.ts","../src/onebot11/event/message.ts","../src/onebot11/event/meta.ts","../src/onebot11/event/notice.ts","../src/onebot11/event/request.ts","../src/onebot11/event/index.ts","../src/onebot11/adapter.ts","../src/onebot11/transport.ts"],"mappings":";;;;;;;;;;;UAMiB,WAAW;EACxB;EACA;EACA,MAAM;EACN;EACA;;;KAIQ;EACJ;EAAc;IAAQ;;;EACtB;EAAY;IAAQ;IAAY;;;EAChC;EAAc;IAAQ;;;EACtB;EAAe;IAAQ;IAAc;;;EACrC;EAAgB;IAAQ;IAAc;;;EACtC;EAAe;IAAQ;IAAc;;;EACrC;EAAc;IAAQ;;;EACtB;EAAe;IAAQ;;;EACvB;EAAiB;IAAQ;;;EACzB;EAAc;IAAQ;;;EACtB;EAAa;IAAQ;;;EACrB;EAAgB;IAAQ;;;;KAGpB,uBAAuB;;UAGlB;EACb;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;EACA;;;UAIa;EACb;EACA;;;UAIa;EACb;EACA;EACA;EACA;IACI;IACA;IACA;IACA;;EAEJ;EACA,SAAS;EACT;EACA;EACA;;;KAIQ;;UAGK;EACb;EACA;EACA;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;;;UAIa;EACb;EACA;EACA,MAAM;EACN;;EAEA;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;;;UAIa;EACb;EACA,oBAAoB;EACpB,gBAAgB;EAChB,gBAAgB;EAChB,aAAa;EACb,oBAAoB;EACpB,cAAc;;;UAID;EACb;EACA;EACA;;EAEA;EACA;EACA;EACA,eAAe;EACf,gBAAgB;EAChB;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AEb,QAAQ;;EAER,aAAa;;EAEb,gBAAgB,cAAc,UAAU;;EAExC;;;iBAiBY,uBAAuB,MAAM,gCAAgC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { m as ActionRegistry, s as BaseProtocolAdapter, t as ConfigBase$1 } from "./index-BZfGz6FA.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { n as AdapterLoggerLike, t as MediaCache } from "./media-cache-C_0C9eCV.mjs";
|
|
3
|
+
import "./gray-tip-CcpfI1Og.mjs";
|
|
3
4
|
import { CanonicalElement, FriendApi, GroupApi, GroupCache, GroupNotifyApi, KernelErrorCode, MsgApi, MsgEventChannel, Peer, ProfileApi } from "@napuketto/kernel";
|
|
4
5
|
import { EventBroadcaster, TransportAdapter } from "@napuketto/network";
|
|
5
6
|
import { ZodType, z } from "zod";
|
|
@@ -42,9 +43,12 @@ interface SatoriApiOptions {
|
|
|
42
43
|
cacheDir?: string | undefined;
|
|
43
44
|
/** 群/成员缓存(guild.member.get / user.get 读缓存用)。 */
|
|
44
45
|
groupCache?: GroupCache | undefined;
|
|
46
|
+
/** 媒体缓存清理失败的可观测出口。 */
|
|
47
|
+
logger?: AdapterLoggerLike | undefined;
|
|
45
48
|
}
|
|
46
49
|
/** Satori 动作统一依赖聚合。 */
|
|
47
50
|
declare class SatoriApi {
|
|
51
|
+
readonly mediaCache: MediaCache;
|
|
48
52
|
readonly msgApi: MsgApi;
|
|
49
53
|
readonly groupApi: GroupApi;
|
|
50
54
|
readonly groupNotifyApi: GroupNotifyApi;
|
|
@@ -436,4 +440,4 @@ declare function toEventSignal(event: Event): {
|
|
|
436
440
|
body: Event;
|
|
437
441
|
};
|
|
438
442
|
export { Message as A, SatoriActionDeps as B, Emoji as C, GuildRole as D, GuildMember as E, Order as F, SatoriToCanonicalDeps as G, SatoriActionError as H, HTTP_STATUS as I, renderElements as J, SatoriElement as K, satoriHttpStatusMap as L, BidiList as M, Direction as N, Login as O, List as P, SatoriConfig as R, ChannelType as S, Guild as T, SatoriApi as U, createSatoriActionRegistry as V, SatoriApiOptions as W, MetaBody as _, parseContentToCanonical as a, Signal as b, canonicalToSatoriElements as c, NapukettoSatoriAdapter as d, SatoriAdapterOptions as f, IdentifyBody as g, Event as h, toEventSignal as i, User as j, LoginStatus as k, SatoriEventContent as l, Button as m, SatoriTransportSet as n, satoriToCanonicalElements as o, Argv as p, parseElements as q, assembleSatoriTransports as r, CanonicalToSatoriDeps as s, AssembleSatoriTransportsOptions as t, SatoriEventDeps as u, Opcode as v, Friend as w, Channel as x, ReadyBody as y, satoriConfigSchema as z };
|
|
439
|
-
//# sourceMappingURL=index-
|
|
443
|
+
//# sourceMappingURL=index-tljZ0fmt.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-tljZ0fmt.d.mts","names":["ConfigBase"],"sources":["../src/satori/helper/element/element.ts","../src/satori/helper/element/media-convert.ts","../src/satori/api/satori-api.ts","../src/satori/action/base-action.ts","../src/satori/action/index.ts","../src/satori/helper/config.ts","../src/satori/helper/error.ts","../src/satori/types/api.ts","../src/satori/types/resource.ts","../src/satori/types/event.ts","../src/satori/helper/translate.ts","../src/satori/adapter.ts","../src/satori/event/translate.ts","../src/satori/helper/element/canonical.ts","../src/satori/helper/element/element-convert.ts","../src/satori/transport.ts"],"mappings":";;;;;;;UAmBiB;EACb;EACA,QAAQ;EACR,WAAW;EACX;;;;;;iBAsJY,cAAc,iBAAiB;;iBA4C/B,eAAe,UAAU;;UCxMxB;;EAEb,WAAW,mBAAmB,QAAQ;;EAEtC;;EAEA,qBAAqB;;;UCER;EACb,QAAQ;EACR,UAAU;EACV,gBAAgB;EAChB,WAAW;EACX,YAAY;;EAEZ;IAAQ;IAAa;;;EAErB;;EAEA,aAAa;;EAEb,SAAS;;;cAIA;WACA,YAAY;WACZ,QAAQ;WACR,UAAU;WACV,gBAAgB;WAChB,WAAW;WACX,YAAY;WACZ;IAAQ;IAAa;;WACrB;WACA;WACA,YAAY;;;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ACJ,OAAO;;;UAIM;EACb;EACA;;;UAIa;EACb,QAAQ;EACR;;;UAIa;EACb;;;UAIa;EACb;EACA;EACA,UAAU;;;UAIG;EACb;;;UAIa;;EAEb;;EAEA;;EAEA;;EAEA,OAAO;;EAEP,OAAO;;EAEP,SAAS;;EAET,UAAU;;EAEV,QAAQ;;EAER,SAAS;;EAET,QAAQ;;EAER,SAAS;;EAET,UAAU;;EAEV,WAAW;;EAEX,OAAO;;EAEP,OAAO;;;UCjFM;;EAEb;;EAEA,YAAY,mBAAmB,QAAQ;;;UCY1B,6BAA6B;;;;EAI1C,SAASA,aAAW,gBAAgB,QAAQ;;EAE5C,cAAc;;EAEd,YAAY;;EAEZ,SAAS;;;cAIA,+BAA+B,oBAAoB;WACnD;mBAEQ;mBACA;mBACA;mBACA;UACT;UACA;UACA;EAER,YAAY,MAAM;;UAuBJ;;UAmBN;;;;;UAQM;;UAMN;;UAaM;;UAWN;;UAwBM;;UAWA;;UAaN;;UAeA;;UAMA;;;UCzLK;EACb;EACA;EACA,UAAU;EACV,QAAQ;EACR,UAAU;EACV,OAAO;EACP,SAAS;EACT,WAAW;;;UAIE,wBAAwB;;UCtBxB;;EAEb,YAAY,mBAAmB,QAAQ;;;;;;iBAgGrB,0BAClB,UAAU,oBACV,OAAM,wBACP,QAAQ;;iBC3FW,0BAClB,UAAU,iBACV,MAAM,wBACP,QAAQ;;iBA2HW,wBAClB,iBACA,MAAM,wBACP,QAAQ;;UCrGM;;EAEb,UAAU;;EAEV,aAAa;;;UAIA;;EAEb,QAAQ;;EAER,aAAa;;EAEb,UAAU;;EAEV,aAAa;;EAEb;;;iBAyJY,yBACZ,MAAM,kCACP;;iBA8Ga,cAAc,OAAO;EAAU;EAAY,MAAM"}
|
package/dist/index.d.mts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { _ as ErrorCodeMap, a as ProtocolConfig, c as ProtocolHooks, g as ActionOutcome, h as ActionKernelSpec, i as ConfigSchema, m as ActionRegistry, n as ConfigFormat, o as createServerSchema, r as ConfigOptions, s as BaseProtocolAdapter, t as ConfigBase, v as runAction } from "./index-BZfGz6FA.mjs";
|
|
19
19
|
import { et as KurobotConfig, l as KurobotAdapterOptions, nt as kurobotConfigSchema, u as NapukettoKurobotAdapter } from "./index-oinf9f75.mjs";
|
|
20
|
-
import { G as MilkyConfig, K as milkyConfigSchema, L as MilkyAdapterOptions, R as NapukettoMilkyAdapter } from "./index-
|
|
21
|
-
import { C as ob11ConfigSchema, S as OB11Config, o as NapukettoOneBot11Adapter, s as OneBot11AdapterOptions } from "./index-
|
|
22
|
-
import { R as SatoriConfig, d as NapukettoSatoriAdapter, f as SatoriAdapterOptions, z as satoriConfigSchema } from "./index-
|
|
20
|
+
import { G as MilkyConfig, K as milkyConfigSchema, L as MilkyAdapterOptions, R as NapukettoMilkyAdapter } from "./index-CKWWp8-H.mjs";
|
|
21
|
+
import { C as ob11ConfigSchema, S as OB11Config, o as NapukettoOneBot11Adapter, s as OneBot11AdapterOptions } from "./index-DrPCnj64.mjs";
|
|
22
|
+
import { R as SatoriConfig, d as NapukettoSatoriAdapter, f as SatoriAdapterOptions, z as satoriConfigSchema } from "./index-tljZ0fmt.mjs";
|
|
23
23
|
export { type ActionKernelSpec, type ActionOutcome, ActionRegistry, BaseProtocolAdapter, ConfigBase, type ConfigFormat, type ConfigOptions, type ConfigSchema, type ErrorCodeMap, type KurobotAdapterOptions, type KurobotConfig, type MilkyAdapterOptions, type MilkyConfig, NapukettoKurobotAdapter, NapukettoMilkyAdapter, NapukettoOneBot11Adapter, NapukettoSatoriAdapter, type OB11Config, type OneBot11AdapterOptions, ProtocolConfig, type ProtocolHooks, type SatoriAdapterOptions, type SatoriConfig, createServerSchema, kurobotConfigSchema, milkyConfigSchema, ob11ConfigSchema, runAction, satoriConfigSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { d as runAction, i as BaseProtocolAdapter, n as ProtocolConfig, r as createServerSchema, t as ConfigBase, u as ActionRegistry } from "./framework-BbtmlUXJ.mjs";
|
|
2
2
|
import { N as kurobotConfigSchema, t as NapukettoKurobotAdapter } from "./kurobot-BUJkleqO.mjs";
|
|
3
|
-
import { r as milkyConfigSchema, t as NapukettoMilkyAdapter } from "./milky-
|
|
4
|
-
import { t as NapukettoOneBot11Adapter, u as ob11ConfigSchema } from "./onebot11-
|
|
5
|
-
import { m as satoriConfigSchema, t as NapukettoSatoriAdapter } from "./satori-
|
|
3
|
+
import { r as milkyConfigSchema, t as NapukettoMilkyAdapter } from "./milky-KOD9KyeP.mjs";
|
|
4
|
+
import { t as NapukettoOneBot11Adapter, u as ob11ConfigSchema } from "./onebot11-CUK6blMn.mjs";
|
|
5
|
+
import { m as satoriConfigSchema, t as NapukettoSatoriAdapter } from "./satori-Dl9iaDNY.mjs";
|
|
6
6
|
export { ActionRegistry, BaseProtocolAdapter, ConfigBase, NapukettoKurobotAdapter, NapukettoMilkyAdapter, NapukettoOneBot11Adapter, NapukettoSatoriAdapter, ProtocolConfig, createServerSchema, kurobotConfigSchema, milkyConfigSchema, ob11ConfigSchema, runAction, satoriConfigSchema };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** 最小 logger 面(校准日志用:未知事件形状打 raw JSON;缺省静默)。 */
|
|
2
|
+
interface AdapterLoggerLike {
|
|
3
|
+
warn(obj: unknown, msg?: string): void;
|
|
4
|
+
info(obj: unknown, msg?: string): void;
|
|
5
|
+
/** 校准数据(级别重分配:info → debug;此面必须支持)。 */
|
|
6
|
+
debug(obj: unknown, msg?: string): void;
|
|
7
|
+
}
|
|
8
|
+
type Lifetime = "temporary" | "reference";
|
|
9
|
+
interface CacheOptions {
|
|
10
|
+
root?: string | undefined;
|
|
11
|
+
logger?: Pick<AdapterLoggerLike, "warn"> | undefined;
|
|
12
|
+
ttlMs?: number;
|
|
13
|
+
orphanTtlMs?: number;
|
|
14
|
+
maxBytes?: number;
|
|
15
|
+
now?: () => number;
|
|
16
|
+
}
|
|
17
|
+
/** Private adapter cache. Only its marked, flat entries are candidates for deletion. */
|
|
18
|
+
declare class MediaCache {
|
|
19
|
+
private readonly roots;
|
|
20
|
+
private timer;
|
|
21
|
+
private starting;
|
|
22
|
+
private generation;
|
|
23
|
+
private readonly ttl;
|
|
24
|
+
private readonly orphanTtl;
|
|
25
|
+
private readonly maxBytes;
|
|
26
|
+
private readonly now;
|
|
27
|
+
private readonly options;
|
|
28
|
+
constructor(options?: CacheOptions);
|
|
29
|
+
start(): Promise<void>;
|
|
30
|
+
stop(): void;
|
|
31
|
+
/** Nested action helpers reuse the lease until the outer action finishes. */
|
|
32
|
+
run<T>(task: () => Promise<T>): Promise<T>;
|
|
33
|
+
private finish;
|
|
34
|
+
/** Allocate before any download/write. Writer may return a renamed output in the same entry. */
|
|
35
|
+
create(base: string, extension: string, writer: (path: string) => Promise<string> | Promise<void>, lifetime?: Lifetime): Promise<string>;
|
|
36
|
+
sweep(): Promise<void>;
|
|
37
|
+
private checkRoot;
|
|
38
|
+
private mark;
|
|
39
|
+
private inspect;
|
|
40
|
+
private summarize;
|
|
41
|
+
private summarizeFile;
|
|
42
|
+
private videoOutput;
|
|
43
|
+
private collect;
|
|
44
|
+
private remove;
|
|
45
|
+
}
|
|
46
|
+
export { AdapterLoggerLike as n, MediaCache as t };
|
|
47
|
+
//# sourceMappingURL=media-cache-C_0C9eCV.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-cache-C_0C9eCV.d.mts","names":[],"sources":["../src/internal/infra/log.ts","../src/internal/infra/media-cache.ts"],"mappings":";UA+CiB;EACb,KAAK,cAAc;EACnB,KAAK,cAAc;;EAEnB,MAAM,cAAc;;KCvBnB;UAqBK;EACN;EACA,SAAS,KAAK;EACd;EACA;EACA;EACA;;;cA2ES;mBACQ;UACT;UACA;UACA;mBACS;mBACA;mBACA;mBACA;mBACA;EAEjB,YAAY,UAAS;EAUf,SAAS;EAoBf;;EAOM,IAAI,GAAG,YAAY,QAAQ,KAAK,QAAQ;UAqBhC;;EAiCR,OACF,cACA,mBACA,SAAS,iBAAiB,kBAAkB,eAC5C,WAAU,WACX;EAqEG,SAAS;UAqBD;UAOA;UAoBA;UAuBA;UAaA;UAuBA;UAUA;UA0BA"}
|
package/dist/milky/index.d.mts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* 对齐 ./onebot11 与 ./satori 的导出口径。装配方(loader assemble-protocols)
|
|
6
6
|
* 动态 import 本入口。
|
|
7
7
|
*/
|
|
8
|
-
import { A as MessageRecallData, B as MilkyApi, C as GroupMuteData, D as IncomingForwardedMessage, E as GroupWholeMuteData, F as PeerPinChangeData, G as MilkyConfig, H as MilkyLoggerLike, I as SendMessageOutput, J as milkyErrorCodeMap, K as milkyConfigSchema, L as MilkyAdapterOptions, M as MilkyEvent, N as OutgoingForwardedMessage, O as IncomingMessage, P as OutgoingSegment, R as NapukettoMilkyAdapter, S as GroupMessageReactionData, T as GroupNotificationEntity, U as MilkyTransportSet, V as MilkyApiOptions, W as assembleMilkyTransports, _ as GroupInvitedJoinRequestData, a as FriendRequestEntity, b as GroupMemberEntity, c as GetLoginInfoOutput, d as GroupEntity, f as GroupEssenceMessage, g as GroupInvitationData, h as GroupFolderEntity, i as FriendRequestData, j as MessageScene, k as IncomingSegment, l as GroupAnnouncementEntity, m as GroupFileUploadData, n as FriendCategoryEntity, o as GetCookiesOutput, p as GroupFileEntity, q as MilkyAction, r as FriendEntity, s as GetImplInfoOutput, t as BotOfflineData, u as GroupDisbandData, v as GroupJoinRequestData, w as GroupNameChangeData, x as GroupMemberIncreaseData, y as GroupMemberDecreaseData, z as createMilkyActionRegistry } from "../index-
|
|
8
|
+
import { A as MessageRecallData, B as MilkyApi, C as GroupMuteData, D as IncomingForwardedMessage, E as GroupWholeMuteData, F as PeerPinChangeData, G as MilkyConfig, H as MilkyLoggerLike, I as SendMessageOutput, J as milkyErrorCodeMap, K as milkyConfigSchema, L as MilkyAdapterOptions, M as MilkyEvent, N as OutgoingForwardedMessage, O as IncomingMessage, P as OutgoingSegment, R as NapukettoMilkyAdapter, S as GroupMessageReactionData, T as GroupNotificationEntity, U as MilkyTransportSet, V as MilkyApiOptions, W as assembleMilkyTransports, _ as GroupInvitedJoinRequestData, a as FriendRequestEntity, b as GroupMemberEntity, c as GetLoginInfoOutput, d as GroupEntity, f as GroupEssenceMessage, g as GroupInvitationData, h as GroupFolderEntity, i as FriendRequestData, j as MessageScene, k as IncomingSegment, l as GroupAnnouncementEntity, m as GroupFileUploadData, n as FriendCategoryEntity, o as GetCookiesOutput, p as GroupFileEntity, q as MilkyAction, r as FriendEntity, s as GetImplInfoOutput, t as BotOfflineData, u as GroupDisbandData, v as GroupJoinRequestData, w as GroupNameChangeData, x as GroupMemberIncreaseData, y as GroupMemberDecreaseData, z as createMilkyActionRegistry } from "../index-CKWWp8-H.mjs";
|
|
9
9
|
export { type BotOfflineData, type FriendCategoryEntity, type FriendEntity, type FriendRequestData, type FriendRequestEntity, type GetCookiesOutput, type GetImplInfoOutput, type GetLoginInfoOutput, type GroupAnnouncementEntity, type GroupDisbandData, type GroupEntity, type GroupEssenceMessage, type GroupFileEntity, type GroupFileUploadData, type GroupFolderEntity, type GroupInvitationData, type GroupInvitedJoinRequestData, type GroupJoinRequestData, type GroupMemberDecreaseData, type GroupMemberEntity, type GroupMemberIncreaseData, type GroupMessageReactionData, type GroupMuteData, type GroupNameChangeData, type GroupNotificationEntity, type GroupWholeMuteData, type IncomingForwardedMessage, type MessageRecallData, type MessageScene, type MilkyAction, type MilkyAdapterOptions, MilkyApi, type MilkyApiOptions, type MilkyConfig, type MilkyEvent, type IncomingMessage as MilkyIncomingMessage, type IncomingSegment as MilkyIncomingSegment, type MilkyLoggerLike, type OutgoingSegment as MilkyOutgoingSegment, type MilkyTransportSet, NapukettoMilkyAdapter, type OutgoingForwardedMessage, type PeerPinChangeData, type SendMessageOutput, assembleMilkyTransports, createMilkyActionRegistry, milkyConfigSchema, milkyErrorCodeMap };
|
package/dist/milky/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { a as MilkyApi, t as NapukettoMilkyAdapter, n as assembleMilkyTransports, i as createMilkyActionRegistry, r as milkyConfigSchema, o as milkyErrorCodeMap } from "../milky-
|
|
1
|
+
export { a as MilkyApi, t as NapukettoMilkyAdapter, n as assembleMilkyTransports, i as createMilkyActionRegistry, r as milkyConfigSchema, o as milkyErrorCodeMap } from "../milky-KOD9KyeP.mjs";
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { a as resolveProtocolConfig, c as matchTokenCredential, d as runAction, i as BaseProtocolAdapter, o as BEARER_PREFIX, s as createTokenAuthorize, u as ActionRegistry } from "./framework-BbtmlUXJ.mjs";
|
|
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-
|
|
2
|
+
import { a as logEventFailure, f as MediaCache, h as withMediaScope, i as hasGrayTip, m as protectMediaPath, n as findRevokeElement, o as sliceRaw, p as cacheMediaFile, r as firstUntranslatedGrayTip, t as collectGrayTipUids, u as fileUriToPath } from "./gray-tip-BL1rhwZK.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-DU8YOhLV.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-Cn1oRaLw.mjs";
|
|
5
5
|
import { ChatType, EssenceListSync, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupMemberRole, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, errorMessage, hasNumberProp, hasStringProp, isRecord, kernelError, narrowEssenceGroupArg, toCanonicalElements } from "@napuketto/kernel";
|
|
6
|
-
import { randomUUID } from "node:crypto";
|
|
7
6
|
import { HttpClient, HttpServer, createSseResponse, isWsOpen } from "@napuketto/network";
|
|
8
7
|
import { z } from "zod";
|
|
9
|
-
import {
|
|
10
|
-
import { join } from "node:path";
|
|
8
|
+
import { rename, writeFile } from "node:fs/promises";
|
|
11
9
|
import { detectFileType, downloadUrl, inferExtension } from "@napuketto/media";
|
|
12
10
|
// src/milky/action/base-action.ts
|
|
13
11
|
/** KernelErrorCode → Milky retcode 映射表(-400/-403 规范语义,其余取常见 HTTP 语义近似负数)。 */
|
|
@@ -35,7 +33,7 @@ function defineMilkyAction(spec) {
|
|
|
35
33
|
handle: async (payload) => {
|
|
36
34
|
const outcome = await runAction({
|
|
37
35
|
schema: spec.schema,
|
|
38
|
-
handle: spec.handle,
|
|
36
|
+
handle: (input) => withMediaScope(() => spec.handle(input)),
|
|
39
37
|
errorCodeMap: milkyErrorCodeMap,
|
|
40
38
|
invalidRetcode: -400,
|
|
41
39
|
invalidMessage: (error) => `参数解析失败: ${zodSummary(error)}`
|
|
@@ -328,13 +326,14 @@ function essenceToEntity(item, groupId) {
|
|
|
328
326
|
* - http(s):// → @napuketto/media downloadUrl 落盘 cacheDir/milky/
|
|
329
327
|
* 未配置 mediaDir 时远程 URI 报错(不发静默空消息)。
|
|
330
328
|
*/
|
|
329
|
+
const DETECTED_EXTENSION_RE = /^[a-zA-Z0-9]+$/;
|
|
331
330
|
/** 解析远程媒体 URI 为本地绝对路径(base64:// / http(s)://;file:// 走同步面)。 */
|
|
332
331
|
async function resolveMediaUri(uri, mediaDir) {
|
|
333
332
|
if (mediaDir === void 0 || mediaDir === "") throw kernelError("远程媒体发送需要配置 [accounts.milky] cacheDir(下载缓存目录)", "INVALID_PARAM");
|
|
334
333
|
if (uri.startsWith("base64://")) return await writeBase64(uri.slice(9), mediaDir);
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
334
|
+
return await cacheMediaFile(mediaDir, inferExtension(null, uri), async (dest) => {
|
|
335
|
+
await downloadUrl(uri, dest);
|
|
336
|
+
});
|
|
338
337
|
}
|
|
339
338
|
/**
|
|
340
339
|
* 动作参数 URI(image_uri / file_uri)→ 本地路径:file:// 同步展开(fileURLToPath
|
|
@@ -342,9 +341,9 @@ async function resolveMediaUri(uri, mediaDir) {
|
|
|
342
341
|
* resolveMediaUri 落盘;裸路径(go-cqhttp 惯例)原样。
|
|
343
342
|
*/
|
|
344
343
|
async function resolveUriToPath(uri, mediaDir) {
|
|
345
|
-
if (uri.startsWith("file://")) return fileUriToPath(uri);
|
|
344
|
+
if (uri.startsWith("file://")) return await protectMediaPath(fileUriToPath(uri));
|
|
346
345
|
if (uri.startsWith("http://") || uri.startsWith("https://") || uri.startsWith("base64://")) return await resolveMediaUri(uri, mediaDir);
|
|
347
|
-
return uri;
|
|
346
|
+
return await protectMediaPath(uri);
|
|
348
347
|
}
|
|
349
348
|
/** base64 载荷 → 落盘(先写 .bin,探测到扩展名再改名)。 */
|
|
350
349
|
async function writeBase64(payload, mediaDir) {
|
|
@@ -355,17 +354,19 @@ async function writeBase64(payload, mediaDir) {
|
|
|
355
354
|
throw kernelError("base64:// 载荷解码失败", "INVALID_PARAM");
|
|
356
355
|
}
|
|
357
356
|
if (bytes.length === 0) throw kernelError("base64:// 载荷为空", "INVALID_PARAM");
|
|
358
|
-
await
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
357
|
+
return await cacheMediaFile(mediaDir, ".bin", async (raw) => {
|
|
358
|
+
await writeFile(raw, bytes, { flag: "wx" });
|
|
359
|
+
let ext;
|
|
360
|
+
try {
|
|
361
|
+
({ext} = await detectFileType(raw));
|
|
362
|
+
} catch {
|
|
363
|
+
return raw;
|
|
364
|
+
}
|
|
365
|
+
if (!DETECTED_EXTENSION_RE.test(ext)) return raw;
|
|
366
|
+
const final = `${raw.slice(0, -4)}.${ext}`;
|
|
367
|
+
if (final !== raw) await rename(raw, final);
|
|
365
368
|
return final;
|
|
366
|
-
}
|
|
367
|
-
return raw;
|
|
368
|
-
}
|
|
369
|
+
});
|
|
369
370
|
}
|
|
370
371
|
// src/milky/action/group-file.ts
|
|
371
372
|
const fileIdField = { file_id: z.string().min(1) };
|
|
@@ -536,6 +537,7 @@ function folderToEntity(info, groupId) {
|
|
|
536
537
|
}
|
|
537
538
|
// src/milky/api.ts
|
|
538
539
|
var MilkyApi = class {
|
|
540
|
+
mediaCache;
|
|
539
541
|
msgApi;
|
|
540
542
|
groupApi;
|
|
541
543
|
friendApi;
|
|
@@ -558,6 +560,10 @@ var MilkyApi = class {
|
|
|
558
560
|
/** message_seq ↔ msgId 双向映射(接收链路 record,动作侧反查)。 */
|
|
559
561
|
seqIndex;
|
|
560
562
|
constructor(opts, seqIndex) {
|
|
563
|
+
this.mediaCache = new MediaCache({
|
|
564
|
+
root: opts.mediaDir,
|
|
565
|
+
logger: opts.logger
|
|
566
|
+
});
|
|
561
567
|
this.msgApi = opts.msgApi;
|
|
562
568
|
this.groupApi = opts.groupApi;
|
|
563
569
|
this.friendApi = opts.friendApi;
|
|
@@ -1913,6 +1919,7 @@ async function resolveElement(el, uinToUid, api) {
|
|
|
1913
1919
|
...el,
|
|
1914
1920
|
path: await resolveMediaUri(el.path, api.mediaDir)
|
|
1915
1921
|
};
|
|
1922
|
+
if ("path" in el) await protectMediaPath(el.path);
|
|
1916
1923
|
return el;
|
|
1917
1924
|
}
|
|
1918
1925
|
/** 远程媒体元素(image/voice/video 且 path 为需落盘的 URI)。 */
|
|
@@ -2228,7 +2235,10 @@ const ACTION_FACTORIES = [
|
|
|
2228
2235
|
/** 构建 Milky 动作注册表(64 个动作,领域工厂遍历注册)。 */
|
|
2229
2236
|
function createMilkyActionRegistry(opts) {
|
|
2230
2237
|
const registry = new ActionRegistry();
|
|
2231
|
-
for (const factory of ACTION_FACTORIES) for (const action of factory(opts.api)) registry.register(
|
|
2238
|
+
for (const factory of ACTION_FACTORIES) for (const action of factory(opts.api)) registry.register({
|
|
2239
|
+
...action,
|
|
2240
|
+
handle: (payload) => opts.api.mediaCache.run(() => action.handle(payload))
|
|
2241
|
+
});
|
|
2232
2242
|
return registry;
|
|
2233
2243
|
}
|
|
2234
2244
|
// src/milky/config.ts
|
|
@@ -3377,6 +3387,7 @@ var NapukettoMilkyAdapter = class extends BaseProtocolAdapter {
|
|
|
3377
3387
|
this.stopTransports = set.close;
|
|
3378
3388
|
await Promise.all(set.adapters.map((a) => a.open()));
|
|
3379
3389
|
}
|
|
3390
|
+
await this.api.mediaCache.start();
|
|
3380
3391
|
this.pipeline.subscribe();
|
|
3381
3392
|
this.calibLogger?.info({
|
|
3382
3393
|
host: config.host,
|
|
@@ -3391,6 +3402,7 @@ var NapukettoMilkyAdapter = class extends BaseProtocolAdapter {
|
|
|
3391
3402
|
}
|
|
3392
3403
|
/** 停止:退订 + 关传输。 */
|
|
3393
3404
|
async stopAll() {
|
|
3405
|
+
this.api.mediaCache.stop();
|
|
3394
3406
|
this.pipeline.unsubscribeAll();
|
|
3395
3407
|
if (this.stopTransports !== null) {
|
|
3396
3408
|
await this.stopTransports();
|
|
@@ -3400,4 +3412,4 @@ var NapukettoMilkyAdapter = class extends BaseProtocolAdapter {
|
|
|
3400
3412
|
};
|
|
3401
3413
|
export { MilkyApi as a, createMilkyActionRegistry as i, assembleMilkyTransports as n, milkyErrorCodeMap as o, milkyConfigSchema as r, NapukettoMilkyAdapter as t };
|
|
3402
3414
|
|
|
3403
|
-
//# sourceMappingURL=milky-
|
|
3415
|
+
//# sourceMappingURL=milky-KOD9KyeP.mjs.map
|