Merge pull request #378 from SnowLuma/dev

chore: promote dev → main (fea1996)
This commit is contained in:
snowluma-bot[bot]
2026-08-16 07:18:55 +00:00
committed by GitHub
26 changed files with 215 additions and 28 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"license": "SEE LICENSE IN LICENSE",
"name": "snowluma-monorepo",
"version": "1.14.8",
"version": "1.14.9",
"description": "SnowLuma monorepo workspace (pnpm)",
"private": true,
"type": "module",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"license": "SEE LICENSE IN LICENSE",
"name": "@snowluma/bridge",
"version": "1.14.8",
"version": "1.14.9",
"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 -1
View File
@@ -1,7 +1,7 @@
{
"license": "SEE LICENSE IN LICENSE",
"name": "@snowluma/common",
"version": "1.14.8",
"version": "1.14.9",
"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 -1
View File
@@ -1,7 +1,7 @@
{
"license": "SEE LICENSE IN LICENSE",
"name": "@snowluma/core",
"version": "1.14.8",
"version": "1.14.9",
"description": "SnowLuma core - NTQQ packet sniffer with Node.js native addon",
"private": true,
"type": "module",
+24 -11
View File
@@ -35,6 +35,10 @@ import { deflateSync } from 'node:zlib';
const FLASH_SLICE_SIZE = 1024 * 1024;
/** After create returns, 0x93d4 can still omit the main-file fileId for a
* few seconds (#364). Re-query on this schedule (first lookup is immediate). */
const FLASH_FILE_ID_RETRY_DELAYS_MS = [1000, 2000, 4000, 4000] as const;
/** Fail cleanly if the staged file changed since the streaming hash pass. */
async function assertUnchanged(filePath: string, baseline: { size: number; mtimeMs: number }): Promise<void> {
const now = await fsp.stat(filePath);
@@ -267,21 +271,30 @@ export class FlashTransferApi {
* 多文件时每条 f6=序号、f14=主文件 fileId),按 fileIndex 选中后走 0x12a9 sub=200
* 拿主文件直链。0x93d3/0x93d4 的 downloadUrl 字段是缩略图(appid=14903/14902),
* 主文件必须走 0x12a9 sub=200。
*
* create 刚返回时 f14 可能还是空的(#364)。fileId 空则按
* FLASH_FILE_ID_RETRY_DELAYS_MS 再问 0x93d4;已经有 fileId 后 0x12a9 只打一枪。
*/
private async getFileDownload(
filesetUuid: string, fileIndex: number = 1,
): Promise<{ url: string; fileName: string; fileSize: number } | null> {
const metas = await GetDownloadUrl.invoke(this.ctx, { filesetUuid });
const meta = metas.find((m) => m.fileIndex === fileIndex);
if (!meta || !meta.fileId) return null;
const url = await GetFlashDownload.invoke(this.ctx, {
filesetUuid: meta.filesetUuid,
fileUuid: meta.fileUuid,
fileId: meta.fileId,
fileName: meta.fileName,
});
if (!url) return null;
return { url, fileName: meta.fileName, fileSize: meta.fileSize };
for (let attempt = 0; ; attempt++) {
const metas = await GetDownloadUrl.invoke(this.ctx, { filesetUuid });
const meta = metas.find((m) => m.fileIndex === fileIndex);
if (meta?.fileId) {
const url = await GetFlashDownload.invoke(this.ctx, {
filesetUuid: meta.filesetUuid,
fileUuid: meta.fileUuid,
fileId: meta.fileId,
fileName: meta.fileName,
});
if (!url) return null;
return { url, fileName: meta.fileName, fileSize: meta.fileSize };
}
const delay = FLASH_FILE_ID_RETRY_DELAYS_MS[attempt];
if (delay === undefined) return null;
await new Promise<void>((resolve) => setTimeout(resolve, delay));
}
}
/**
@@ -0,0 +1,99 @@
// Regression for #364: create_flash_task can return before 0x93d4 fills
// the main-file fileId. get_flash_file_url / download_fileset poll 0x93d4
// while that field is empty, then take the normal 0x12a9 sub=200 path.
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { GetDownloadUrl } from '@snowluma/protocol/oidb-services/flash-transfer/get-download-url';
import { GetFlashDownload } from '@snowluma/protocol/oidb-services/flash-transfer/get-flash-download';
import { FlashTransferApi } from '../src/bridge/apis/flash-transfer';
const FILESET = '8982c4b5-195c-49e2-a3ab-478b32af234c';
const FILE_ID = 'main-file-id';
const URL = 'https://multimedia.qfile.qq.com/download?appid=14901&fileid=main-file-id';
function meta(fileId: string, fileIndex = 1): GetDownloadUrl.FileMeta {
return {
fileIndex,
fileId,
filesetUuid: FILESET,
fileUuid: 'file-uuid',
fileName: 'sl364-hitpass.txt',
fileSize: 41,
};
}
function api(): FlashTransferApi {
return new FlashTransferApi({} as never);
}
describe('FlashTransferApi.getFlashFileUrl — empty fileId poll (#364)', () => {
beforeEach(() => {
vi.useFakeTimers();
});
afterEach(() => {
vi.useRealTimers();
vi.restoreAllMocks();
});
it('does not wait when 0x93d4 already has the main-file fileId', async () => {
const lookup = vi.spyOn(GetDownloadUrl, 'invoke').mockResolvedValue([meta(FILE_ID)]);
const download = vi.spyOn(GetFlashDownload, 'invoke').mockResolvedValue(URL);
await expect(api().getFlashFileUrl(FILESET)).resolves.toBe(URL);
expect(lookup).toHaveBeenCalledOnce();
expect(download).toHaveBeenCalledOnce();
expect(download.mock.calls[0]![1]).toMatchObject({ fileId: FILE_ID, filesetUuid: FILESET });
});
it('re-queries 0x93d4 after an empty fileId and then takes the download path', async () => {
const lookup = vi.spyOn(GetDownloadUrl, 'invoke')
.mockResolvedValueOnce([meta('')])
.mockResolvedValueOnce([meta(FILE_ID)]);
const download = vi.spyOn(GetFlashDownload, 'invoke').mockResolvedValue(URL);
const pending = api().getFlashFileUrl(FILESET);
await vi.advanceTimersByTimeAsync(1000);
await expect(pending).resolves.toBe(URL);
expect(lookup).toHaveBeenCalledTimes(2);
expect(download).toHaveBeenCalledOnce();
expect(download.mock.calls[0]![1]).toMatchObject({ fileId: FILE_ID });
});
it('shares the same poll for download_fileset', async () => {
vi.spyOn(GetDownloadUrl, 'invoke')
.mockResolvedValueOnce([meta('')])
.mockResolvedValueOnce([meta(FILE_ID)]);
vi.spyOn(GetFlashDownload, 'invoke').mockResolvedValue(URL);
const pending = api().downloadFileset(FILESET);
await vi.advanceTimersByTimeAsync(1000);
await expect(pending).resolves.toEqual({
url: URL,
fileName: 'sl364-hitpass.txt',
fileSize: 41,
});
});
it('keeps the original error when fileId stays empty through the budget', async () => {
const lookup = vi.spyOn(GetDownloadUrl, 'invoke').mockResolvedValue([meta('')]);
const download = vi.spyOn(GetFlashDownload, 'invoke').mockResolvedValue(URL);
const pending = api().getFlashFileUrl(FILESET);
const expectFailed = expect(pending).rejects.toThrow('get_flash_file_url: no download url available');
await vi.advanceTimersByTimeAsync(20_000);
await expectFailed;
expect(lookup.mock.calls.length).toBeGreaterThan(1);
expect(download).not.toHaveBeenCalled();
});
it('does not re-query 0x93d4 when fileId is present but 0x12a9 returns no url', async () => {
const lookup = vi.spyOn(GetDownloadUrl, 'invoke').mockResolvedValue([meta(FILE_ID)]);
vi.spyOn(GetFlashDownload, 'invoke').mockResolvedValue(null);
await expect(api().getFlashFileUrl(FILESET)).rejects.toThrow('get_flash_file_url: no download url available');
expect(lookup).toHaveBeenCalledOnce();
});
});
+1 -1
View File
@@ -1,7 +1,7 @@
{
"license": "SEE LICENSE IN LICENSE",
"name": "@snowluma/mcp",
"version": "1.14.8",
"version": "1.14.9",
"description": "MCP server exposing the SnowLuma OneBot action catalog (docs + JSON Schemas) and optional execution to LLM clients.",
"repository": {
"type": "git",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"license": "SEE LICENSE IN LICENSE",
"name": "@snowluma/onebot",
"version": "1.14.8",
"version": "1.14.9",
"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>'`.",
@@ -211,7 +211,8 @@ export const ELEMENT_CODECS = {
log.warn('could not quote the target message');
return null;
}
if (id <= 0) {
// message_id is a signed int32 hash; only 0 is invalid (#371).
if (id === 0) {
log.warn('could not quote the target message');
return null;
}
@@ -246,7 +247,10 @@ export const ELEMENT_CODECS = {
}
// Backward-compatible path: allow direct seq reply IDs.
return id > 0 ? { type: 'reply', replySeq: id } : null;
// A negative OneBot id is never a QQ sequence.
if (id > 0) return { type: 'reply', replySeq: id };
log.warn('could not quote the target message');
return null;
},
},
@@ -1679,7 +1679,7 @@ async function parseForwardNodes(
const eventSender = asJsonObject(event.sender) ?? {};
const senderCard = eventSender.card !== undefined ? String(eventSender.card) : undefined;
const nickname = String(eventSender.card ?? eventSender.nickname ?? nodeData.nickname ?? nodeData.name ?? '');
const nickname = String(eventSender.card || eventSender.nickname || nodeData.nickname || nodeData.name || '');
const userUin = toPositiveInt(event.user_id);
if (userUin <= 0) {
throw new MessageElementValidationError(
@@ -375,6 +375,50 @@ describe('forward — nested {type:"node"} content', () => {
});
});
it('[#372] empty group card does not replace a cached sender nickname with the QQ number', async () => {
// Group events always store sender.card as "" when the member has no
// card. `??` treats that empty string as present and then
// `nickname || String(userUin)` collapses the display name to the QQ
// number — the get_forward_msg symptom in #372.
const uploadForwardNodes = vi.fn(async () => 'RES');
const sendGroupMessage = vi.fn(async () => ({
messageId: 1, sequence: 1, clientSequence: 0, random: 1, timestamp: 1,
}));
const findEvent = vi.fn((id: number) => id === 7 ? ({
user_id: 22222,
message_id: 7,
message_seq: 42,
message_type: 'group',
group_id: 12345,
time: 1700000000,
message: [{ type: 'text', data: { text: 'cached' } }],
sender: { user_id: 22222, nickname: 'alice', card: '' },
}) : id === 8 ? ({
user_id: 33333,
message_id: 8,
message_seq: 43,
message_type: 'group',
group_id: 12345,
time: 1700000000,
message: [{ type: 'text', data: { text: 'nameless' } }],
sender: { user_id: 33333, nickname: '', card: '' },
}) : null);
const bridge = fakeBridge({
apis: { message: { sendGroup: sendGroupMessage }, forward: { upload: uploadForwardNodes } },
} as any);
const ctx = makeCtx(bridge);
(ctx as any).messageStore = { findEvent };
await sendGroupForwardMessage(ctx, 12345, [
{ type: 'node', data: { id: 7, nickname: 'node-override' } },
{ type: 'node', data: { id: 8, nickname: 'node-fallback' } },
] as any);
const [nodes] = uploadForwardNodes.mock.calls[0]!;
expect((nodes as any[])[0]).toMatchObject({ userUin: 22222, nickname: 'alice' });
expect((nodes as any[])[1]).toMatchObject({ userUin: 33333, nickname: 'node-fallback' });
});
it('reports a missing cached message_id as caller-invalid before upload', async () => {
const uploadForwardNodes = vi.fn(async () => 'RES');
const sendGroupMessage = vi.fn();
@@ -666,6 +666,33 @@ describe('parseMessage', () => {
expect(result[0].replySeq).toBe(100);
});
it('resolves a signed-int32 message_id to the stored reply sequence (#371)', async () => {
const result = await parseMessage(
[
{ type: 'reply', data: { id: -188861750 } },
{ type: 'text', data: { text: '测试成功' } },
] as any,
false,
{ resolveReplySequence: (id) => id === -188861750 ? 4242 : null },
);
expect(result).toEqual([
{ type: 'reply', replySeq: 4242, replyMessageId: -188861750 },
{ type: 'text', text: '测试成功' },
]);
});
it('does not treat an unresolved negative message_id as a QQ sequence (#371)', async () => {
const result = await parseMessage(
[
{ type: 'reply', data: { id: -188861750 } },
{ type: 'text', data: { text: '测试成功' } },
] as any,
false,
{ resolveReplySequence: () => null },
);
expect(result).toEqual([{ type: 'text', text: '测试成功' }]);
});
it('parses share as json card', async () => {
const result = await parseMessage(
[{ type: 'share', data: { url: 'https://example.com', title: 'Test' } }] as any,
+1 -1
View File
@@ -1,7 +1,7 @@
{
"license": "SEE LICENSE IN LICENSE",
"name": "@snowluma/proto-defs",
"version": "1.14.8",
"version": "1.14.9",
"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 -1
View File
@@ -1,7 +1,7 @@
{
"license": "SEE LICENSE IN LICENSE",
"name": "@snowluma/protocol",
"version": "1.14.8",
"version": "1.14.9",
"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>'`.",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"license": "SEE LICENSE IN LICENSE",
"name": "@snowluma/proton",
"version": "1.14.8",
"version": "1.14.9",
"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.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -1,7 +1,7 @@
{
"license": "SEE LICENSE IN LICENSE",
"name": "@snowluma/runtime",
"version": "1.14.8",
"version": "1.14.9",
"private": true,
"type": "module",
"main": "index.mjs",
+1 -1
View File
@@ -4,7 +4,7 @@
"name": "MotricSeven",
"email": "motricseven@gmail.com"
},
"version": "1.14.8",
"version": "1.14.9",
"description": "TypeScript SDK for SnowLuma OneBot HTTP and WebSocket transports",
"keywords": [
"snowluma",
+1 -1
View File
@@ -4,7 +4,7 @@
"name": "MotricSeven",
"email": "motricseven@gmail.com"
},
"version": "1.14.8",
"version": "1.14.9",
"description": "Shared SnowLuma UI primitives — Tailwind 4 theme tokens + shadcn-style atomic components",
"keywords": [
"snowluma",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"license": "SEE LICENSE IN LICENSE",
"name": "@snowluma/websocket",
"version": "1.14.8",
"version": "1.14.9",
"private": true,
"type": "module",
"main": "./src/index.ts",
+1 -1
View File
@@ -2,7 +2,7 @@
"license": "SEE LICENSE IN LICENSE",
"name": "webui",
"private": true,
"version": "1.14.8",
"version": "1.14.9",
"type": "module",
"scripts": {
"dev": "vite",