Merge pull request #328 from SnowLuma/dev

chore: promote dev → main (7eea805)
This commit is contained in:
snowluma-bot[bot] authored and GitHub committed 2026-08-08 11:45:26 +00:00
commit 81a898087c
16 files changed
+163 -37

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{
"license": "SEE LICENSE IN LICENSE",
"name": "snowluma-monorepo",
"version": "1.14.2",
"version": "1.14.3",
"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.2",
"version": "1.14.3",
"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.2",
"version": "1.14.3",
"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.2",
"version": "1.14.3",
"description": "SnowLuma core - NTQQ packet sniffer with Node.js native addon",
"private": true,
"type": "module",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"license": "SEE LICENSE IN LICENSE",
"name": "@snowluma/mcp",
"version": "1.14.2",
"version": "1.14.3",
"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.2",
"version": "1.14.3",
"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>'`.",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"license": "SEE LICENSE IN LICENSE",
"name": "@snowluma/proto-defs",
"version": "1.14.2",
"version": "1.14.3",
"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.2",
"version": "1.14.3",
"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>'`.",
+85 -22
View File
@@ -42,7 +42,8 @@ export interface SysFaceStoreOptions {
interface IndexedCatalog {
packs: SysFacePackEntry[];
byId: Map<string, SysFaceEntry>;
packNameById: Map<string, string>;
entryCount: number;
overlapCount: number;
}
/** Pure classification once an authoritative entry is known. */
@@ -108,16 +109,25 @@ export class SysFaceStore {
if (!needle || !this.catalog) return [];
const matches: SysFaceEntry[] = [];
for (const [id, face] of this.catalog.byId) {
const haystacks = [
id,
face.qDes,
face.emCode,
this.catalog.packNameById.get(id) ?? '',
...face.emojiNameAlias,
];
if (haystacks.some((value) => value.toLocaleLowerCase().includes(needle))) {
matches.push(face);
const matchedIds = new Set<string>();
for (const pack of this.catalog.packs) {
for (const face of pack.emojis) {
if (matchedIds.has(face.qSid)) continue;
const haystacks = [
face.qSid,
face.qDes,
face.emCode,
pack.packName,
...face.emojiNameAlias,
];
if (haystacks.some((value) => value.toLocaleLowerCase().includes(needle))) {
const canonical = this.catalog.byId.get(face.qSid);
if (!canonical) {
throw new Error(`system face index is missing catalog id ${face.qSid}`);
}
matches.push(canonical);
matchedIds.add(face.qSid);
}
}
}
return matches;
@@ -179,8 +189,10 @@ export class SysFaceStore {
this.refreshedInProcess = true;
if (this.storage) await this.storage.save(snapshot);
log.info(
'system face catalog refreshed: faces=%d packs=%d elapsedMs=%d',
'system face catalog refreshed: entries=%d uniqueFaces=%d overlaps=%d packs=%d elapsedMs=%d',
this.catalog.entryCount,
this.catalog.byId.size,
this.catalog.overlapCount,
validated.length,
this.now() - startedAt,
);
@@ -246,8 +258,11 @@ export class SysFaceStore {
validateSnapshot(snapshot);
this.catalog = indexCatalog(snapshot.packs);
log.info(
'system face catalog restored: faces=%d packs=%d fetchedAt=%d elapsedMs=%d',
'system face catalog restored: entries=%d uniqueFaces=%d overlaps=%d packs=%d '
+ 'fetchedAt=%d elapsedMs=%d',
this.catalog.entryCount,
this.catalog.byId.size,
this.catalog.overlapCount,
snapshot.packs.length,
snapshot.fetchedAt,
this.now() - startedAt,
@@ -288,7 +303,12 @@ function validateCatalog(packs: SysFacePackEntry[]): SysFacePackEntry[] {
throw new Error('system face catalog is empty');
}
const seen = new Set<string>();
const seen = new Map<string, {
face: SysFaceEntry;
packIndex: number;
faceIndex: number;
faceIndexByPack: Map<number, number>;
}>();
let faceCount = 0;
for (const [packIndex, pack] of packs.entries()) {
if (!pack || typeof pack.packName !== 'string' || !Array.isArray(pack.emojis)) {
@@ -301,9 +321,6 @@ function validateCatalog(packs: SysFacePackEntry[]): SysFacePackEntry[] {
+ `value=${JSON.stringify(face?.qSid)}`,
);
}
if (seen.has(face.qSid)) {
throw new Error(`duplicate system face id ${face.qSid}`);
}
if (!Array.isArray(face.emojiNameAlias)
|| face.emojiNameAlias.some((alias) => typeof alias !== 'string')) {
throw new Error(`invalid aliases for system face id ${face.qSid}`);
@@ -326,7 +343,31 @@ function validateCatalog(packs: SysFacePackEntry[]): SysFacePackEntry[] {
if (face.url !== null && typeof face.url !== 'string') {
throw new Error(`invalid url for system face id ${face.qSid}`);
}
seen.add(face.qSid);
const previous = seen.get(face.qSid);
if (previous) {
const previousFaceIndex = previous.faceIndexByPack.get(packIndex);
if (previousFaceIndex !== undefined) {
throw new Error(
`duplicate system face id ${face.qSid} within pack ${packIndex}: `
+ `faces ${previousFaceIndex} and ${faceIndex}`,
);
}
if (!hasCompatibleSendMetadata(previous.face, face)) {
throw new Error(
`conflicting system face send metadata for id ${face.qSid}: `
+ `pack ${previous.packIndex}, face ${previous.faceIndex} vs `
+ `pack ${packIndex}, face ${faceIndex}`,
);
}
previous.faceIndexByPack.set(packIndex, faceIndex);
} else {
seen.set(face.qSid, {
face,
packIndex,
faceIndex,
faceIndexByPack: new Map([[packIndex, faceIndex]]),
});
}
faceCount += 1;
}
}
@@ -334,16 +375,38 @@ function validateCatalog(packs: SysFacePackEntry[]): SysFacePackEntry[] {
return packs;
}
function hasCompatibleSendMetadata(left: SysFaceEntry, right: SysFaceEntry): boolean {
if (!isAddressableFaceId(left.qSid)) return true;
const leftIsSuper = isSuperFaceEntry(left);
const rightIsSuper = isSuperFaceEntry(right);
if (leftIsSuper !== rightIsSuper) return false;
if (!leftIsSuper) return true;
return left.aniStickerType === right.aniStickerType
&& left.aniStickerPackId === right.aniStickerPackId
&& left.aniStickerId === right.aniStickerId;
}
function isAddressableFaceId(id: string): boolean {
if (!/^(?:0|[1-9]\d*)$/.test(id)) return false;
const numeric = Number(id);
return Number.isSafeInteger(numeric) && numeric >= 0;
}
function indexCatalog(packs: SysFacePackEntry[]): IndexedCatalog {
const byId = new Map<string, SysFaceEntry>();
const packNameById = new Map<string, string>();
let entryCount = 0;
for (const pack of packs) {
for (const emoji of pack.emojis) {
byId.set(emoji.qSid, emoji);
packNameById.set(emoji.qSid, pack.packName);
entryCount += 1;
if (!byId.has(emoji.qSid)) byId.set(emoji.qSid, emoji);
}
}
return { packs, byId, packNameById };
return {
packs,
byId,
entryCount,
overlapCount: entryCount - byId.size,
};
}
/** Shared, process-wide catalog (the face set is account-independent). */
+64 -1
View File
@@ -232,7 +232,44 @@ describe('SysFaceStore — persistent catalog and query seam', () => {
expect(store.lookup(128522)).toBeNull();
});
it('still rejects empty and duplicate catalog identifiers', () => {
it('preserves one face across multiple catalog packs', async () => {
const commonFace = entry('474', 1, 4, 76, '/给你一拳');
commonFace.emCode = '10474';
const specialFace: SysFaceEntry = {
...commonFace,
qDes: '/给你一拳(黄脸)',
emojiNameAlias: ['punch'],
};
const catalog: SysFacePackEntry[] = [
{ packName: '超级表情', emojis: [commonFace] },
{ packName: 'QQ黄脸', emojis: [specialFace] },
];
const storage = new MemoryCatalogStorage();
const store = new SysFaceStore({
storage,
now: () => 456,
fetchCatalog: async () => catalog,
});
await expect(store.refresh(sender)).resolves.toEqual(catalog);
expect(storage.saved[0]?.packs).toEqual(catalog);
await expect(store.getCatalog(sender)).resolves.toEqual(catalog);
expect(store.lookup(474)).toEqual(commonFace);
expect(store.search('超级表情').map((face) => face.qSid)).toEqual(['474']);
expect(store.search('QQ黄脸').map((face) => face.qSid)).toEqual(['474']);
expect(store.search('punch').map((face) => face.qSid)).toEqual(['474']);
const restored = new SysFaceStore({
storage: new MemoryCatalogStorage(storage.saved[0]!),
fetchCatalog: async () => { throw new Error('network must not be used'); },
});
await restored.ensureReady(sender);
await expect(restored.getCatalog(sender)).resolves.toEqual(catalog);
expect(restored.search('QQ黄脸').map((face) => face.qSid)).toEqual(['474']);
});
it('still rejects empty identifiers and duplicates within one pack', () => {
const store = new SysFaceStore();
expect(() => store.load([{ packName: 'emoji', emojis: [entry('', null, null, null)] }]))
@@ -241,6 +278,32 @@ describe('SysFaceStore — persistent catalog and query seam', () => {
packName: 'emoji',
emojis: [entry('😊', null, null, null), entry('😊', null, null, null)],
}])).toThrow(/duplicate system face id/);
expect(() => store.load([
{ packName: '超级表情', emojis: [entry('474', 1, 4, 76)] },
{
packName: 'QQ黄脸',
emojis: [entry('474', 1, 4, 76), entry('474', 1, 4, 76)],
},
])).toThrow(/duplicate system face id 474 within pack 1/);
});
it('rejects cross-pack copies with conflicting send metadata', () => {
const store = new SysFaceStore();
expect(() => store.load([
{ packName: '超级表情', emojis: [entry('474', 1, 4, 76)] },
{ packName: 'QQ黄脸', emojis: [entry('474', 3, 2, 38)] },
])).toThrow(/conflicting system face send metadata.*pack 0.*pack 1/);
});
it('allows non-addressable Unicode entries to carry panel-specific metadata', () => {
const store = new SysFaceStore();
expect(() => store.load([
{ packName: 'emoji', emojis: [entry('😊', null, null, null, '/微笑')] },
{ packName: '最近使用', emojis: [entry('😊', 3, 2, 38, '/最近使用')] },
])).not.toThrow();
expect(store.search('最近使用').map((face) => face.qSid)).toEqual(['😊']);
});
it('coalesces concurrent refreshes and persists the authoritative result once', async () => {
+1 -1
View File
@@ -1,7 +1,7 @@
{
"license": "SEE LICENSE IN LICENSE",
"name": "@snowluma/proton",
"version": "1.14.2",
"version": "1.14.3",
"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.",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"license": "SEE LICENSE IN LICENSE",
"name": "@snowluma/runtime",
"version": "1.14.2",
"version": "1.14.3",
"private": true,
"type": "module",
"main": "index.mjs",
+1 -1
View File
@@ -4,7 +4,7 @@
"name": "MotricSeven",
"email": "motricseven@gmail.com"
},
"version": "1.14.2",
"version": "1.14.3",
"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.2",
"version": "1.14.3",
"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.2",
"version": "1.14.3",
"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.2",
"version": "1.14.3",
"type": "module",
"scripts": {
"dev": "vite",