Merge pull request #204 from SnowLuma/dev
chore: promote dev → main (d35e276)
This commit is contained in:
22 files changed
+129
-23
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "snowluma-monorepo",
|
||||
"version": "1.11.3",
|
||||
"version": "1.11.4",
|
||||
"description": "SnowLuma monorepo workspace (pnpm)",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/bridge",
|
||||
"version": "1.11.3",
|
||||
"version": "1.11.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "SnowLuma bridge — QQ NT desktop client lifecycle: hook injection (via native addon), per-PID HookSession orchestration, pipe-watcher for process discovery, and the BridgeManagerSink interface that lets the hook layer call back into a UIN-keyed session router without depending on @snowluma/core. Consumed by the top-level app entry (which constructs the BridgeManager from @snowluma/core and injects it as the sink) and by the WebUI server (read-only HookProcessInfo views).",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/common",
|
||||
"version": "1.11.3",
|
||||
"version": "1.11.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "SnowLuma shared infrastructure — leaf-package utilities with zero business dependencies. Logger / hex codec / log file transport / log line summariser / packet sender wire-protocol types / runtime config loader. Consumed by @snowluma/protocol, @snowluma/core, and @snowluma/onebot. Per-file subpath exports keep import sites unambiguous and let the bundler tree-shake aggressively (importing `@snowluma/common/hex` doesn't pull in `node:fs` from the logger transport).",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/core",
|
||||
"version": "1.11.3",
|
||||
"version": "1.11.4",
|
||||
"description": "SnowLuma core - NTQQ packet sniffer with Node.js native addon",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
||||
@@ -123,6 +123,56 @@ describe('video-upload', () => {
|
||||
expect((c2cInfo[0] as any).fileInfo.height).toBe(0);
|
||||
});
|
||||
|
||||
it('[#145] fast-upload with 0x0 dims (e.g. forwarding a dimensionless video) falls back to portrait for group', async () => {
|
||||
// A forwarded video whose cached dims are 0 must NOT ship 0x0 to a group
|
||||
// (→ 文件已过期). videoPayloadFromFingerprint substitutes a neutral 720x1280
|
||||
// portrait; c2c stays 0 (server rejects non-zero there).
|
||||
const noDims = { ...FINGERPRINT, width: 0, height: 0 } as any;
|
||||
await uploadVideoMsgInfo({} as any, true, 12345, noDims);
|
||||
const groupInfo = vi.mocked(pipeline.runNtv2Upload).mock.calls[0]![0].uploadInfo;
|
||||
expect((groupInfo[0] as any).fileInfo.width).toBe(720);
|
||||
expect((groupInfo[0] as any).fileInfo.height).toBe(1280);
|
||||
|
||||
vi.mocked(pipeline.runNtv2Upload).mockClear();
|
||||
await uploadVideoMsgInfo({} as any, false, 'recipient-uid', noDims);
|
||||
const c2cInfo = vi.mocked(pipeline.runNtv2Upload).mock.calls[0]![0].uploadInfo;
|
||||
expect((c2cInfo[0] as any).fileInfo.width).toBe(0);
|
||||
expect((c2cInfo[0] as any).fileInfo.height).toBe(0);
|
||||
});
|
||||
|
||||
it('[#145] zero-trust: fallback cover declared dims equal the video fallback (content == declared)', async () => {
|
||||
// The fast-upload cover is a real 720x1280 image; the thumb sub-file must
|
||||
// declare those same pixels, not a 1x1 lying about its size, and they match
|
||||
// the video fallback so tile + cover agree.
|
||||
const noDims = { ...FINGERPRINT, width: 0, height: 0 } as any;
|
||||
await uploadVideoMsgInfo({} as any, true, 12345, noDims);
|
||||
const info = vi.mocked(pipeline.runNtv2Upload).mock.calls[0]![0].uploadInfo;
|
||||
expect((info[0] as any).fileInfo.width).toBe(720); // video tile
|
||||
expect((info[0] as any).fileInfo.height).toBe(1280);
|
||||
expect((info[1] as any).fileInfo.width).toBe(720); // cover sub-file (subFileType 100)
|
||||
expect((info[1] as any).fileInfo.height).toBe(1280);
|
||||
});
|
||||
|
||||
it('[#145] zero-trust: cached duration 0 → time 1, never 00:00', async () => {
|
||||
const noDur = { ...FINGERPRINT, duration: 0 } as any;
|
||||
await uploadVideoMsgInfo({} as any, true, 12345, noDur);
|
||||
const info = vi.mocked(pipeline.runNtv2Upload).mock.calls[0]![0].uploadInfo;
|
||||
expect((info[0] as any).fileInfo.time).toBe(1);
|
||||
});
|
||||
|
||||
it('[#145] real video dims are preserved on the main file even though the cover is the 720x1280 fallback', async () => {
|
||||
// FINGERPRINT has real 320x240 dims; the fast-upload cover is always the
|
||||
// 720x1280 fallback (no real cover cached on the forward path). The video
|
||||
// tile keeps the real dims — the cover/tile aspect mismatch is tolerated,
|
||||
// only a 0x0 MAIN file triggers 文件已过期.
|
||||
await uploadVideoMsgInfo({} as any, true, 12345, FINGERPRINT);
|
||||
const info = vi.mocked(pipeline.runNtv2Upload).mock.calls[0]![0].uploadInfo;
|
||||
expect((info[0] as any).fileInfo.width).toBe(320); // main video: real dims preserved
|
||||
expect((info[0] as any).fileInfo.height).toBe(240);
|
||||
expect((info[1] as any).fileInfo.width).toBe(720); // cover: fallback
|
||||
expect((info[1] as any).fileInfo.height).toBe(1280);
|
||||
});
|
||||
|
||||
it('main video carries the real `time` (duration in seconds) — regression: was 0', async () => {
|
||||
// NTV2 server bakes the `time` field into the resulting MsgInfo
|
||||
// bytes that ride along as `commonElem.pbElem`; the receiver
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/mcp",
|
||||
"version": "1.11.3",
|
||||
"version": "1.11.4",
|
||||
"description": "MCP server exposing the SnowLuma OneBot action catalog (docs + JSON Schemas) and optional execution to LLM clients.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/onebot",
|
||||
"version": "1.11.3",
|
||||
"version": "1.11.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "SnowLuma OneBot v11 adapter — the protocol translation layer that maps the public OneBot vocabulary (HTTP / WebSocket actions, message segments, post events) onto @snowluma/core's typed Api hub (`bridge.apis.<area>.method()`). Owns network adapters (HTTP server / HTTP client / WS server / WS client), the registered action handlers, the receive-side event→OneBot converter, message-id hashing, message store (SQLite-backed event history), media store, and the OneBot instance + manager that ties one OneBotConfig to one Bridge. Per-file subpath exports mirror the legacy `core/src/onebot/*` layout 1:1 so the previous `import { … } from '../onebot/<x>'` collapses to `import { … } from '@snowluma/onebot/<x>'`.",
|
||||
|
||||
@@ -1193,7 +1193,13 @@ async function parseForwardNodes(
|
||||
continue;
|
||||
}
|
||||
|
||||
const userUin = toPositiveInt(nodeData.user_id ?? nodeData.uin);
|
||||
// [#203] A fake forward node may omit user_id or send "0" — upstream
|
||||
// frameworks (AstrBot, etc.) don't manage QQ uins. The protocol端 is logged
|
||||
// in and the core builder already defaults a zero sender to the bot's own
|
||||
// uin (bridge/apis/forward.ts buildForwardPushBody), so match that leniency
|
||||
// here instead of rejecting. The throw stays as a guard for the not-logged-in
|
||||
// case (selfId 0).
|
||||
const userUin = toPositiveInt(nodeData.user_id ?? nodeData.uin) || ref.selfId;
|
||||
if (userUin <= 0) throw new Error('forward node user_id/uin is required');
|
||||
|
||||
const nickname = String(nodeData.nickname ?? nodeData.name ?? userUin);
|
||||
|
||||
@@ -33,6 +33,7 @@ function fakeBridge(overrides: Partial<BridgeInterface> = {}): BridgeInterface {
|
||||
function makeCtx(bridge: BridgeInterface): OneBotInstanceContext {
|
||||
return {
|
||||
uin: '10001',
|
||||
selfId: 10001,
|
||||
bridge,
|
||||
messageStore: { findEvent: () => null } as any,
|
||||
cacheMessageMeta: vi.fn(),
|
||||
@@ -217,4 +218,27 @@ describe('forward — nested {type:"node"} content', () => {
|
||||
const elements = (nodes as any[])[0]!.elements;
|
||||
expect(elements.some((e: any) => e.type === 'text' && e.text === 'a sibling')).toBe(true);
|
||||
});
|
||||
|
||||
it('[#203] node with user_id "0" or missing falls back to the bot self_id', async () => {
|
||||
// Upstream frameworks (AstrBot etc.) send fake forward nodes with
|
||||
// user_id "0" or omit it; the protocol端 knows self_id, so default to it
|
||||
// instead of rejecting (matches NapCat/LLBot + the core builder).
|
||||
const uploadForwardNodes = vi.fn(async (_nodes: any[]) => 'RESID');
|
||||
const sendGroupMessage = vi.fn(async () => ({
|
||||
messageId: 1, sequence: 100, clientSequence: 0, random: 1, timestamp: 1700000000,
|
||||
}));
|
||||
const bridge = fakeBridge({ apis: { message: { sendGroup: sendGroupMessage }, forward: { upload: uploadForwardNodes } } } as any);
|
||||
const ctx = makeCtx(bridge);
|
||||
|
||||
const messages = [
|
||||
{ type: 'node', data: { user_id: '0', nickname: 'PixivBot', content: [{ type: 'text', data: { text: 'a' } }] } },
|
||||
{ type: 'node', data: { nickname: 'PixivBot', content: [{ type: 'text', data: { text: 'b' } }] } }, // user_id omitted
|
||||
];
|
||||
|
||||
await sendGroupForwardMessage(ctx, 12345, messages as any);
|
||||
const [nodes] = uploadForwardNodes.mock.calls[0]!;
|
||||
expect((nodes as any[])[0].userUin).toBe(10001); // "0" → self_id
|
||||
expect((nodes as any[])[0].nickname).toBe('PixivBot'); // custom nickname preserved
|
||||
expect((nodes as any[])[1].userUin).toBe(10001); // omitted → self_id
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/proto-defs",
|
||||
"version": "1.11.3",
|
||||
"version": "1.11.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "SnowLuma QQ/Lagrange wire-protobuf type definitions. Pure TypeScript interfaces with proton's `pb<N, T>` marker types — `@snowluma/proton`'s vite plugin compiles them into zero-runtime encoder/decoder functions at the call sites in `@snowluma/core` (and any downstream consumer). Exposed as per-file subpaths (`@snowluma/proto-defs/oidb`, `@snowluma/proto-defs/message`, …) so the import-site shape mirrors the legacy `bridge/proto/proton/*` layout and avoids name collisions across files (notably `highway.ts` and `oidb-actions/media.ts` share NTV2-prefixed names).",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/protocol",
|
||||
"version": "1.11.3",
|
||||
"version": "1.11.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "SnowLuma protocol — the protocol-layer between QQ wire bytes and typed events. Owns: identity service (uid↔uin cache with SQLite persistence), event bus, packet pipeline (incoming SSO packet → QQEventVariant), msg-push decoders, element-builder (MessageElement → wire elems[]), highway upload protocol (file/image/video/ptt), OIDB envelope helper, and the event/notice/request type vocabulary. Consumers (@snowluma/core, @snowluma/onebot) talk to this package through `BridgeContext` for runtime calls and the standalone classes (IdentityService, BridgeEventBus, IncomingPacketPipeline) for composition. Per-file subpath exports mirror the legacy `core/src/bridge/*` layout 1:1 so the previous `import { …} from '../bridge/<x>'` collapses to `import { … } from '@snowluma/protocol/<x>'`.",
|
||||
|
||||
@@ -43,6 +43,7 @@ export const GROUP_VIDEO_THUMB_CMD_ID = 1006;
|
||||
// costs ~1.5 GiB+ of process memory.
|
||||
export const MAX_VIDEO_SIZE = 1536 * 1024 * 1024;
|
||||
const SHA1_STREAM_BLOCK_SIZE = 1024 * 1024;
|
||||
|
||||
const SHA1_BLOCK_SIZE = 64;
|
||||
|
||||
export function getVideoSourceSize(element: MessageElement): number | null {
|
||||
@@ -57,10 +58,22 @@ export function getVideoSourceSize(element: MessageElement): number | null {
|
||||
}
|
||||
|
||||
const FALLBACK_THUMB = Buffer.from(
|
||||
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+/p9sAAAAASUVORK5CYII=',
|
||||
'iVBORw0KGgoAAAANSUhEUgAAAtAAAAUACAIAAADhrPJqAAAACXBIWXMAAAABAAAAAQBPJcTWAA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hAAByhgMAyBkOACBnOACAnOEAAHKGAwDIGQ4AIGc4AICc4QAAcoYDAMgZDgAgZzgAgJzhAAByhgMAyBkOACBnOACAnOEAAHKGAwDIGQ4AIGc4AICc4QAAcoYDAMgZDgAgZzgAgJzhAAByhgMAyBkOACBnOACAnOEAAHKGAwDIGQ4AIGc4AICc4QAAcoYDAMgZDgAgZzgAgJzhAAByhgMAyBkOACBnOACAnOEAAHKGAwDIGQ4AIGc4AICc4QAAcoYDAMgZDgAgZzgAgJzhAAByhgMAyBkOACBnOACAnOEAAHKGAwDIGQ4AIGc4AICc4QAAcoYDAMgZDgAgZzgAgJzhAAByhgMAyBkOACBnOACAnOEAAHKGAwDIGQ4AIGc4AICc4QAAcoYDAMgZDgAgZzgAgJzhAAByhgMAyBkOACBnOACAnOEAAHKGAwDIGQ4AIGc4AICc4QAAcoYDAMgZDgAgZzgAgJzhAAByhgMAyBkOACBnOACAnOEAAHKGAwDIGQ4AIGc4AICc4QAAcoYDAMgZDgAgZzgAgJzhAAByhgMAyBkOACBnOACAnOEAAHKGAwDIGQ4AIGc4AICc4QAAcoYDAMgZDgAgZzgAgJzhAAByhgMAyBkOACBnOACAnOEALine truncated
|
||||
'base64',
|
||||
);
|
||||
|
||||
// [#145] The fast-upload (fingerprint / forward) path has no video bytes to
|
||||
// probe, so every field it ships is caller-supplied and untrusted — a video
|
||||
// that arrived on the wire with no metadata caches 0s, and re-forwarding it
|
||||
// with width/height=0 makes QQ-NT receivers render 文件已过期. FALLBACK_THUMB is
|
||||
// a real 720x1280 cover; we derive the fallback video/cover dimensions FROM it
|
||||
// so the declared video size, the declared cover size and the actual cover
|
||||
// pixels are the same numbers by construction — never a 1x1 image lying about
|
||||
// its size. Real cached dimensions always win over these.
|
||||
const FALLBACK_THUMB_FORMAT = detectImageFormat(new Uint8Array(FALLBACK_THUMB));
|
||||
const FAST_UPLOAD_FALLBACK_WIDTH = FALLBACK_THUMB_FORMAT.width || 720;
|
||||
const FAST_UPLOAD_FALLBACK_HEIGHT = FALLBACK_THUMB_FORMAT.height || 1280;
|
||||
|
||||
interface VideoPayload {
|
||||
/** Main-file bytes. Empty on the normal path (streamed from `fileSource`)
|
||||
* and when forwarding from cached fingerprints (fastOnly). */
|
||||
@@ -102,8 +115,10 @@ function makeFallbackThumb(): ThumbPayload {
|
||||
sha1: hashes.sha1,
|
||||
md5Hex: hashes.md5Hex,
|
||||
sha1Hex: hashes.sha1Hex,
|
||||
width: 1,
|
||||
height: 1,
|
||||
// Declared cover dims == FALLBACK_THUMB's real pixels (same source as the
|
||||
// video fallback), so content and declared size always agree.
|
||||
width: FAST_UPLOAD_FALLBACK_WIDTH,
|
||||
height: FAST_UPLOAD_FALLBACK_HEIGHT,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -117,9 +132,12 @@ function videoPayloadFromFingerprint(element: MessageElement): VideoPayload {
|
||||
sha1Hex: element.sha1Hex ?? '',
|
||||
fileName: element.fileName || `${element.md5Hex ?? 'video'}.mp4`,
|
||||
fileSize: element.fileSize ?? 0,
|
||||
width: element.width ?? 0,
|
||||
height: element.height ?? 0,
|
||||
duration: element.duration ?? 1,
|
||||
// Zero-trust on the fast-upload path (no bytes to probe): `|| fallback` not
|
||||
// `??`, so a cached-but-zero value is replaced too. width/height=0 → the
|
||||
// receiver shows 文件已过期; duration=0 → every client renders 00:00 (#145).
|
||||
width: element.width || FAST_UPLOAD_FALLBACK_WIDTH,
|
||||
height: element.height || FAST_UPLOAD_FALLBACK_HEIGHT,
|
||||
duration: element.duration || 1,
|
||||
videoFormat: element.videoFormat ?? 0,
|
||||
thumb: makeFallbackThumb(),
|
||||
fastOnly: true,
|
||||
@@ -206,6 +224,14 @@ async function loadThumb(element: MessageElement, videoPath: string): Promise<{
|
||||
height = height || fmt.height || 1;
|
||||
duration = duration || 1;
|
||||
|
||||
// The cover sub-file must declare its OWN pixel size, which can be smaller
|
||||
// than the video: the ffmpeg addon downscales large frames (4K/8K → ≤1080p)
|
||||
// so the JPEG cover stays under QQ's 1 MiB cover limit. Fall back to the video
|
||||
// dims when the format can't be read. For 1080p and custom-thumb sends the
|
||||
// cover already equals the video size, so this is a no-op there.
|
||||
const thumbWidth = fmt.width || width;
|
||||
const thumbHeight = fmt.height || height;
|
||||
|
||||
const hashes = computeHashes(thumbBytes);
|
||||
return {
|
||||
width,
|
||||
@@ -217,8 +243,8 @@ async function loadThumb(element: MessageElement, videoPath: string): Promise<{
|
||||
sha1: hashes.sha1,
|
||||
md5Hex: hashes.md5Hex,
|
||||
sha1Hex: hashes.sha1Hex,
|
||||
width,
|
||||
height,
|
||||
width: thumbWidth,
|
||||
height: thumbHeight,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/proton",
|
||||
"version": "1.11.3",
|
||||
"version": "1.11.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "Compile-time protobuf encoder/decoder generator for SnowLuma. TypeScript interfaces → fully-inlined, zero-runtime protobuf codec functions. Vendored from SnowLuma/protobuf-dsl (reference copy under dev/protobuf-dsl/) with edge-case fixes applied.",
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/runtime",
|
||||
"version": "1.11.3",
|
||||
"version": "1.11.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "index.mjs",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"name": "MotricSeven",
|
||||
"email": "motricseven@gmail.com"
|
||||
},
|
||||
"version": "1.11.3",
|
||||
"version": "1.11.4",
|
||||
"description": "TypeScript SDK for SnowLuma OneBot HTTP and WebSocket transports",
|
||||
"keywords": [
|
||||
"snowluma",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"name": "MotricSeven",
|
||||
"email": "motricseven@gmail.com"
|
||||
},
|
||||
"version": "1.11.3",
|
||||
"version": "1.11.4",
|
||||
"description": "Shared SnowLuma UI primitives — Tailwind 4 theme tokens + shadcn-style atomic components",
|
||||
"keywords": [
|
||||
"snowluma",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/websocket",
|
||||
"version": "1.11.3",
|
||||
"version": "1.11.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "webui",
|
||||
"private": true,
|
||||
"version": "1.11.3",
|
||||
"version": "1.11.4",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
Reference in new issue
Block a user