diff --git a/packages/core/package.json b/packages/core/package.json index e3ff10a0..23eac82e 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -14,6 +14,7 @@ "typecheck": "tsc --noEmit" }, "dependencies": { + "@snowluma/proto-defs": "workspace:*", "@snowluma/proton": "workspace:*", "@snowluma/websocket": "workspace:*" }, diff --git a/packages/core/src/bridge/actions/extras.ts b/packages/core/src/bridge/actions/extras.ts index e6d514c0..fd8c1391 100644 --- a/packages/core/src/bridge/actions/extras.ts +++ b/packages/core/src/bridge/actions/extras.ts @@ -1,18 +1,18 @@ import { protobuf_decode, protobuf_encode } from '@snowluma/proton'; import type { Bridge } from '../bridge'; import { makeOidbEnvelope, runOidb } from '../bridge-oidb'; -import { OidbBase } from '../proto/proton/oidb'; +import { OidbBase } from '@snowluma/proto-defs/oidb'; import type { OidbGroupTodo, OidbStrangerStatusReq, OidbStrangerStatusResp, -} from '../proto/proton/oidb-actions/base'; +} from '@snowluma/proto-defs/oidb-actions/base'; import type { OidbAiVoiceListReq, OidbAiVoiceListResp, OidbAiVoiceReq, OidbAiVoiceResp, -} from '../proto/proton/oidb-actions/media'; +} from '@snowluma/proto-defs/oidb-actions/media'; import type { MediaIndexNode } from './shared'; // ─────────────── Group todo (0xF90) ─────────────── diff --git a/packages/core/src/bridge/actions/forward.ts b/packages/core/src/bridge/actions/forward.ts index f78f2462..2299f53c 100644 --- a/packages/core/src/bridge/actions/forward.ts +++ b/packages/core/src/bridge/actions/forward.ts @@ -12,8 +12,8 @@ import type { RecvLongMsgResp, SendLongMsgReq, SendLongMsgResp, -} from '../proto/proton/longmsg'; -import type { FileExtra, PushMsg, PushMsgBody } from '../proto/proton/message'; +} from '@snowluma/proto-defs/longmsg'; +import type { FileExtra, PushMsg, PushMsgBody } from '@snowluma/proto-defs/message'; import { resolveSelfUid, toInt } from './shared'; // Module-scoped cache, keyed by res_id. Survives only for the lifetime diff --git a/packages/core/src/bridge/actions/friend.ts b/packages/core/src/bridge/actions/friend.ts index 2fd8088b..722e300f 100644 --- a/packages/core/src/bridge/actions/friend.ts +++ b/packages/core/src/bridge/actions/friend.ts @@ -1,12 +1,12 @@ import { protobuf_encode } from '@snowluma/proton'; import type { Bridge } from '../bridge'; import { makeOidbEnvelope, runOidb } from '../bridge-oidb'; -import { OidbBase } from '../proto/proton/oidb'; +import { OidbBase } from '@snowluma/proto-defs/oidb'; import type { OidbDeleteFriend, OidbFriendRequestAction, OidbSetFriendRemark, -} from '../proto/proton/oidb-actions/base'; +} from '@snowluma/proto-defs/oidb-actions/base'; export async function setFriendAddRequest(bridge: Bridge, uidOrFlag: string, approve: boolean): Promise { let targetUid = uidOrFlag; diff --git a/packages/core/src/bridge/actions/group-admin.ts b/packages/core/src/bridge/actions/group-admin.ts index 8b4c4949..59886231 100644 --- a/packages/core/src/bridge/actions/group-admin.ts +++ b/packages/core/src/bridge/actions/group-admin.ts @@ -1,7 +1,7 @@ import { protobuf_decode, protobuf_encode } from '@snowluma/proton'; import type { Bridge } from '../bridge'; import { makeOidbEnvelope, runOidb } from '../bridge-oidb'; -import { OidbBase } from '../proto/proton/oidb'; +import { OidbBase } from '@snowluma/proto-defs/oidb'; import type { Oidb0x89a_0AddOption, Oidb0x89a_0Search, @@ -18,7 +18,7 @@ import type { OidbRenameMember, OidbSetAdmin, OidbSpecialTitle, -} from '../proto/proton/oidb-actions/base'; +} from '@snowluma/proto-defs/oidb-actions/base'; // ─────────────── mute / un-mute ─────────────── diff --git a/packages/core/src/bridge/actions/group-album.ts b/packages/core/src/bridge/actions/group-album.ts index d582d2e1..dbccbdb2 100644 --- a/packages/core/src/bridge/actions/group-album.ts +++ b/packages/core/src/bridge/actions/group-album.ts @@ -9,7 +9,7 @@ import type { DoQunLikeResponse, GetMediaListRequest, GetMediaListResponse, -} from '../proto/proton/oidb-actions/group-album'; +} from '@snowluma/proto-defs/oidb-actions/group-album'; export interface GroupAlbumMediaResult { mediaList: any[]; diff --git a/packages/core/src/bridge/actions/group-file.ts b/packages/core/src/bridge/actions/group-file.ts index 0c0e5ec1..fc51a037 100644 --- a/packages/core/src/bridge/actions/group-file.ts +++ b/packages/core/src/bridge/actions/group-file.ts @@ -5,8 +5,8 @@ import type { Bridge } from '../bridge'; import { makeOidbEnvelope, runOidb } from '../bridge-oidb'; import { fetchHighwaySession, uploadHighwayHttp } from '../highway/highway-client'; import { computeHashes, computeMd5, FILE_UPLOAD_MAX_BYTES, loadBinarySource } from '../highway/utils'; -import type { FileUploadExt } from '../proto/proton/highway'; -import { OidbBase } from '../proto/proton/oidb'; +import type { FileUploadExt } from '@snowluma/proto-defs/highway'; +import { OidbBase } from '@snowluma/proto-defs/oidb'; import type { OidbGroupFileCountViewReq, OidbGroupFileCountViewResp, @@ -17,7 +17,7 @@ import type { OidbGroupFileViewReq, OidbGroupFileViewResp, OidbGroupSendFileReq, -} from '../proto/proton/oidb-actions/group-file'; +} from '@snowluma/proto-defs/oidb-actions/group-file'; import type { NTV2RichMediaReq, NTV2RichMediaResp, @@ -25,7 +25,7 @@ import type { OidbPrivateFileDownloadResp, OidbPrivateFileUploadReq, OidbPrivateFileUploadResp, -} from '../proto/proton/oidb-actions/media'; +} from '@snowluma/proto-defs/oidb-actions/media'; import { ensureRetCodeZero, resolveSelfUid, toInt, type MediaIndexNode } from './shared'; const log = createLogger('GroupFile'); diff --git a/packages/core/src/bridge/actions/group-message.ts b/packages/core/src/bridge/actions/group-message.ts index a355c8cd..0ea8b9ea 100644 --- a/packages/core/src/bridge/actions/group-message.ts +++ b/packages/core/src/bridge/actions/group-message.ts @@ -1,8 +1,8 @@ import { protobuf_encode } from '@snowluma/proton'; import type { Bridge } from '../bridge'; import { makeOidbEnvelope, runOidb } from '../bridge-oidb'; -import { OidbBase } from '../proto/proton/oidb'; -import type { C2CRecallRequest, GroupRecallRequest, OidbEssence, SsoReadedReportReq } from '../proto/proton/oidb-actions/base'; +import { OidbBase } from '@snowluma/proto-defs/oidb'; +import type { C2CRecallRequest, GroupRecallRequest, OidbEssence, SsoReadedReportReq } from '@snowluma/proto-defs/oidb-actions/base'; export async function recallGroupMessage(bridge: Bridge, groupId: number, sequence: number): Promise { const request = protobuf_encode({ diff --git a/packages/core/src/bridge/actions/interaction.ts b/packages/core/src/bridge/actions/interaction.ts index 4589bb68..28642b0d 100644 --- a/packages/core/src/bridge/actions/interaction.ts +++ b/packages/core/src/bridge/actions/interaction.ts @@ -1,14 +1,14 @@ import { protobuf_decode, protobuf_encode } from '@snowluma/proton'; import type { Bridge } from '../bridge'; import { makeOidbEnvelope, runOidb } from '../bridge-oidb'; -import { OidbBase } from '../proto/proton/oidb'; +import { OidbBase } from '@snowluma/proto-defs/oidb'; import type { Oidb0x9083Req, Oidb0x9083Resp, OidbGroupReaction, OidbLike, OidbPoke, -} from '../proto/proton/oidb-actions/base'; +} from '@snowluma/proto-defs/oidb-actions/base'; export async function sendPoke(bridge: Bridge, isGroup: boolean, peerUin: number, targetUin?: number): Promise { const env = makeOidbEnvelope(0xED3, 1, { diff --git a/packages/core/src/bridge/actions/misc.ts b/packages/core/src/bridge/actions/misc.ts index 21ad7319..0ca4a9bc 100644 --- a/packages/core/src/bridge/actions/misc.ts +++ b/packages/core/src/bridge/actions/misc.ts @@ -1,7 +1,7 @@ import { protobuf_decode, protobuf_encode } from '@snowluma/proton'; import type { Bridge } from '../bridge'; import { makeOidbEnvelope, runOidb } from '../bridge-oidb'; -import { OidbBase } from '../proto/proton/oidb'; +import { OidbBase } from '@snowluma/proto-defs/oidb'; import type { MiniAppShareReq, MiniAppShareResp, @@ -11,7 +11,7 @@ import type { Oidb0x990Resp, Oidb0xeb7Req, Oidb0xeb7Resp, -} from '../proto/proton/oidb-actions/base'; +} from '@snowluma/proto-defs/oidb-actions/base'; export async function translateEn2Zh( bridge: Bridge, diff --git a/packages/core/src/bridge/actions/profile.ts b/packages/core/src/bridge/actions/profile.ts index 2bf05dd1..2c3cd7d6 100644 --- a/packages/core/src/bridge/actions/profile.ts +++ b/packages/core/src/bridge/actions/profile.ts @@ -3,7 +3,7 @@ import type { Bridge } from '../bridge'; import { makeOidbEnvelope, runOidb } from '../bridge-oidb'; import { fetchHighwaySession, uploadHighwayHttp } from '../highway/highway-client'; import { computeHashes, loadBinarySource } from '../highway/utils'; -import { OidbBase } from '../proto/proton/oidb'; +import { OidbBase } from '@snowluma/proto-defs/oidb'; import type { FaceroamOpReq, FaceroamOpResp, @@ -19,7 +19,7 @@ import type { OidbSetProfile, SetStatusReq, SetStatusResp, -} from '../proto/proton/oidb-actions/base'; +} from '@snowluma/proto-defs/oidb-actions/base'; import { resolveSelfUid } from './shared'; // ─────────────── status / profile setters ─────────────── diff --git a/packages/core/src/bridge/bridge-contacts.ts b/packages/core/src/bridge/bridge-contacts.ts index 0b5035e9..3c3a4149 100644 --- a/packages/core/src/bridge/bridge-contacts.ts +++ b/packages/core/src/bridge/bridge-contacts.ts @@ -7,7 +7,7 @@ import type { OidbSvcTrpcTcp0xFD4_1Response, OidbSvcTrpcTcp0xFE5_2Response, OidbSvcTrpcTcp0xFE7_3Response, -} from './proto/proton/oidb'; +} from '@snowluma/proto-defs/oidb'; import type { AvatarInfo, OidbFriendListRequest, @@ -16,11 +16,11 @@ import type { OidbGroupRequestList, OidbUserInfoRequest, OidbUserInfoResponse, -} from './proto/proton/oidb-actions/base'; +} from '@snowluma/proto-defs/oidb-actions/base'; import type { NTV2RichMediaReq, NTV2RichMediaResp, -} from './proto/proton/oidb-actions/media'; +} from '@snowluma/proto-defs/oidb-actions/media'; import type { FriendInfo, GroupMemberInfo, GroupRequestInfo, QQGroupInfo, UserProfileInfo } from './qq-info'; // --------------------------------------------------------------------------- diff --git a/packages/core/src/bridge/bridge-oidb.ts b/packages/core/src/bridge/bridge-oidb.ts index 0f24a970..e1895bfd 100644 --- a/packages/core/src/bridge/bridge-oidb.ts +++ b/packages/core/src/bridge/bridge-oidb.ts @@ -1,6 +1,6 @@ import { protobuf_decode } from '@snowluma/proton'; import type { Bridge } from './bridge'; -import type { OidbBase, OidbBaseMeta } from './proto/proton/oidb'; +import type { OidbBase, OidbBaseMeta } from '@snowluma/proto-defs/oidb'; /** * Build the OidbBase-shaped TS value. Pure helper, no protobuf diff --git a/packages/core/src/bridge/bridge.ts b/packages/core/src/bridge/bridge.ts index 897936f0..6fe43827 100644 --- a/packages/core/src/bridge/bridge.ts +++ b/packages/core/src/bridge/bridge.ts @@ -10,8 +10,8 @@ import { IncomingPacketPipeline, type CmdParser } from './packet-pipeline'; import type { SendMessageRequest, SendMessageResponse, -} from './proto/proton/action'; -import type { FileExtra } from './proto/proton/message'; +} from '@snowluma/proto-defs/action'; +import type { FileExtra } from '@snowluma/proto-defs/message'; import type { FriendInfo, GroupMemberInfo, GroupRequestInfo, QQGroupInfo, UserProfileInfo } from './qq-info'; // Delegated modules diff --git a/packages/core/src/bridge/element-builder.ts b/packages/core/src/bridge/element-builder.ts index 35459951..6469adaf 100644 --- a/packages/core/src/bridge/element-builder.ts +++ b/packages/core/src/bridge/element-builder.ts @@ -8,8 +8,8 @@ import { uploadVideoMsgInfo } from './highway/video-upload'; import type { MarkdownData, MentionExtraSend, -} from './proto/proton/action'; -import type { Elem, GroupFileExtra } from './proto/proton/element'; +} from '@snowluma/proto-defs/action'; +import type { Elem, GroupFileExtra } from '@snowluma/proto-defs/element'; type ProtoElem = Partial; diff --git a/packages/core/src/bridge/highway/highway-client.ts b/packages/core/src/bridge/highway/highway-client.ts index b73a88b2..30cb6dd8 100644 --- a/packages/core/src/bridge/highway/highway-client.ts +++ b/packages/core/src/bridge/highway/highway-client.ts @@ -7,7 +7,7 @@ import type { NTV2RichMediaHighwayExt, ReqDataHighwayHead, RespDataHighwayHead, -} from '../proto/proton/highway'; +} from '@snowluma/proto-defs/highway'; import { computeMd5, packHighwayFrame, unpackHighwayFrame } from './utils'; const HIGHWAY_APP_ID = 1600001604; diff --git a/packages/core/src/bridge/highway/pipeline.ts b/packages/core/src/bridge/highway/pipeline.ts index 93bb86a8..814f11cd 100644 --- a/packages/core/src/bridge/highway/pipeline.ts +++ b/packages/core/src/bridge/highway/pipeline.ts @@ -7,8 +7,8 @@ import type { EncodableMediaMsgInfo, NTV2UploadRichMediaReq, NTV2UploadRichMediaResp, -} from '../proto/proton/highway'; -import { OidbBase } from '../proto/proton/oidb'; +} from '@snowluma/proto-defs/highway'; +import { OidbBase } from '@snowluma/proto-defs/oidb'; import { buildHighwayExtend, fetchHighwaySession, uploadHighwayHttp } from './highway-client'; const moduleLog = createLogger('Highway'); diff --git a/packages/core/src/bridge/msg-push/context.ts b/packages/core/src/bridge/msg-push/context.ts index 3ccfe463..9d78413a 100644 --- a/packages/core/src/bridge/msg-push/context.ts +++ b/packages/core/src/bridge/msg-push/context.ts @@ -1,7 +1,7 @@ import { protobuf_decode } from '@snowluma/proton'; import type { PacketInfo } from '../../protocol/types'; import type { IdentityService } from '../identity-service'; -import type { ContentHead, MessageBody, PushMsg, ResponseHead } from '../proto/proton/message'; +import type { ContentHead, MessageBody, PushMsg, ResponseHead } from '@snowluma/proto-defs/message'; export type PushMsgBody = MessageBody; export type PushMsgResponseHead = ResponseHead; diff --git a/packages/core/src/bridge/msg-push/decoders/event-0x210.ts b/packages/core/src/bridge/msg-push/decoders/event-0x210.ts index 999d271a..da5493fc 100644 --- a/packages/core/src/bridge/msg-push/decoders/event-0x210.ts +++ b/packages/core/src/bridge/msg-push/decoders/event-0x210.ts @@ -11,7 +11,7 @@ import type { FriendRequest, GeneralGrayTipInfo, NewFriend, -} from '../../proto/proton/notify'; +} from '@snowluma/proto-defs/notify'; import type { MsgPushContext } from '../context'; import { Event0x210SubType } from '../enums'; import { diff --git a/packages/core/src/bridge/msg-push/decoders/event-0x2dc.ts b/packages/core/src/bridge/msg-push/decoders/event-0x2dc.ts index f8fcdf2c..84961539 100644 --- a/packages/core/src/bridge/msg-push/decoders/event-0x2dc.ts +++ b/packages/core/src/bridge/msg-push/decoders/event-0x2dc.ts @@ -12,7 +12,7 @@ import type { GroupMute, GroupReactNotify, NotifyMessageBody, -} from '../../proto/proton/notify'; +} from '@snowluma/proto-defs/notify'; import type { MsgPushContext } from '../context'; import { Event0x2DCSubType } from '../enums'; import { diff --git a/packages/core/src/bridge/msg-push/decoders/group-admin.ts b/packages/core/src/bridge/msg-push/decoders/group-admin.ts index 803f6689..b82a80cc 100644 --- a/packages/core/src/bridge/msg-push/decoders/group-admin.ts +++ b/packages/core/src/bridge/msg-push/decoders/group-admin.ts @@ -1,6 +1,6 @@ import { protobuf_decode } from '@snowluma/proton'; import type { GroupAdminEvent } from '../../events'; -import type { GroupAdmin } from '../../proto/proton/notify'; +import type { GroupAdmin } from '@snowluma/proto-defs/notify'; import { resolveUidToUin } from '../helpers'; import type { MsgPushDecoder } from '../registry'; diff --git a/packages/core/src/bridge/msg-push/decoders/group-join-request.ts b/packages/core/src/bridge/msg-push/decoders/group-join-request.ts index e2d85d76..67d87aea 100644 --- a/packages/core/src/bridge/msg-push/decoders/group-join-request.ts +++ b/packages/core/src/bridge/msg-push/decoders/group-join-request.ts @@ -3,7 +3,7 @@ import type { GroupInviteEvent } from '../../events'; import type { GroupInvitation, GroupInvite, GroupJoin, -} from '../../proto/proton/notify'; +} from '@snowluma/proto-defs/notify'; import { resolveUidToUin } from '../helpers'; import type { MsgPushDecoder } from '../registry'; diff --git a/packages/core/src/bridge/msg-push/decoders/group-member-change.ts b/packages/core/src/bridge/msg-push/decoders/group-member-change.ts index 2b3b2108..e9aa3736 100644 --- a/packages/core/src/bridge/msg-push/decoders/group-member-change.ts +++ b/packages/core/src/bridge/msg-push/decoders/group-member-change.ts @@ -1,6 +1,6 @@ import { protobuf_decode } from '@snowluma/proton'; import type { GroupMemberJoin, GroupMemberLeave } from '../../events'; -import type { GroupChange, SelfJoinInGroup } from '../../proto/proton/notify'; +import type { GroupChange, SelfJoinInGroup } from '@snowluma/proto-defs/notify'; import { decodeOperatorUid, resolveUidToUin } from '../helpers'; import type { MsgPushDecoder } from '../registry'; diff --git a/packages/core/src/bridge/msg-push/helpers.ts b/packages/core/src/bridge/msg-push/helpers.ts index e905e997..200d1abe 100644 --- a/packages/core/src/bridge/msg-push/helpers.ts +++ b/packages/core/src/bridge/msg-push/helpers.ts @@ -1,7 +1,7 @@ import { protobuf_decode } from '@snowluma/proton'; import { inflateSync } from 'zlib'; import type { IdentityService } from '../identity-service'; -import type { OperatorInfo } from '../proto/proton/notify'; +import type { OperatorInfo } from '@snowluma/proto-defs/notify'; export function makeImageUrl(origUrl: string): string { if (!origUrl) return ''; diff --git a/packages/core/src/bridge/msg-push/rich-body-decoder.ts b/packages/core/src/bridge/msg-push/rich-body-decoder.ts index 9d7a0f0d..6246140f 100644 --- a/packages/core/src/bridge/msg-push/rich-body-decoder.ts +++ b/packages/core/src/bridge/msg-push/rich-body-decoder.ts @@ -9,8 +9,8 @@ import type { NotOnlineImage, QFaceExtra, QSmallFaceExtra, -} from '../proto/proton/element'; -import type { FileExtra, MessageBody, RichText } from '../proto/proton/message'; +} from '@snowluma/proto-defs/element'; +import type { FileExtra, MessageBody, RichText } from '@snowluma/proto-defs/message'; import { decompressData, makeImageUrl } from './helpers'; type ElemDecoded = Elem; diff --git a/packages/core/src/bridge/web-actions/cookies.ts b/packages/core/src/bridge/web-actions/cookies.ts index 70d5f45b..ba6c6ac9 100644 --- a/packages/core/src/bridge/web-actions/cookies.ts +++ b/packages/core/src/bridge/web-actions/cookies.ts @@ -1,13 +1,13 @@ import { protobuf_decode, protobuf_encode } from '@snowluma/proton'; import type { Bridge } from '../bridge'; import { makeOidbEnvelope, runOidb } from '../bridge-oidb'; -import { OidbBase } from '../proto/proton/oidb'; +import { OidbBase } from '@snowluma/proto-defs/oidb'; import type { OidbClientKeyReq, OidbClientKeyResp, OidbGetPskeyReq, OidbGetPskeyResp, -} from '../proto/proton/oidb-actions/base'; +} from '@snowluma/proto-defs/oidb-actions/base'; import { RequestUtil } from '../web/request-util'; export async function forceFetchClientKey(bridge: Bridge) { diff --git a/packages/core/src/onebot/modules/message-actions.ts b/packages/core/src/onebot/modules/message-actions.ts index c2589e79..7eb74764 100644 --- a/packages/core/src/onebot/modules/message-actions.ts +++ b/packages/core/src/onebot/modules/message-actions.ts @@ -138,7 +138,7 @@ export async function sendPrivateMessage( // C2C `{type:'file'}` segments can't ride on the elems[] pipeline — // c2c files live on `RichText.notOnlineFile`, parallel to elems - // (see `proto/proton/message.ts:notOnlineFile`). The element-builder + // (see `@snowluma/proto-defs/message:notOnlineFile`). The element-builder // explicitly drops them with a warn ("file send via elems[] is // group-only"), so a private message that bundled a file alongside // anything else used to either ship as "[空消息]" (only-file case, diff --git a/packages/core/tests/actions/extras.test.ts b/packages/core/tests/actions/extras.test.ts index e6c69b07..4d77aee9 100644 --- a/packages/core/tests/actions/extras.test.ts +++ b/packages/core/tests/actions/extras.test.ts @@ -1,13 +1,13 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'; import { protobuf_encode } from '@snowluma/proton'; -import type { OidbBase } from '../../src/bridge/proto/proton/oidb'; +import type { OidbBase } from '@snowluma/proto-defs/oidb'; import type { OidbStrangerStatusResp, -} from '../../src/bridge/proto/proton/oidb-actions/base'; +} from '@snowluma/proto-defs/oidb-actions/base'; import type { OidbAiVoiceListResp, OidbAiVoiceResp, -} from '../../src/bridge/proto/proton/oidb-actions/media'; +} from '@snowluma/proto-defs/oidb-actions/media'; // `encodeOidbEnv` / `decodeOidbEnv` are proton-bound pass-through wrappers // that the plugin substitutes at the call site with the inlined codec, so diff --git a/packages/core/tests/actions/forward-file.test.ts b/packages/core/tests/actions/forward-file.test.ts index a6a0e900..e10cbdba 100644 --- a/packages/core/tests/actions/forward-file.test.ts +++ b/packages/core/tests/actions/forward-file.test.ts @@ -45,7 +45,7 @@ vi.mock('../../src/bridge/element-builder', () => ({ })); import { protobuf_encode } from '@snowluma/proton'; -import type { SendLongMsgResp } from '../../src/bridge/proto/proton/longmsg'; +import type { SendLongMsgResp } from '@snowluma/proto-defs/longmsg'; import * as forward from '../../src/bridge/actions/forward'; import { mockBridge } from './_helpers'; diff --git a/packages/core/tests/actions/forward.test.ts b/packages/core/tests/actions/forward.test.ts index db1ea831..3eecf540 100644 --- a/packages/core/tests/actions/forward.test.ts +++ b/packages/core/tests/actions/forward.test.ts @@ -15,7 +15,7 @@ vi.mock('../../src/bridge/element-builder', () => ({ })); import { protobuf_encode } from '@snowluma/proton'; -import type { SendLongMsgResp } from '../../src/bridge/proto/proton/longmsg'; +import type { SendLongMsgResp } from '@snowluma/proto-defs/longmsg'; import * as forward from '../../src/bridge/actions/forward'; import { mockBridge } from './_helpers'; diff --git a/packages/core/tests/actions/group-admin.test.ts b/packages/core/tests/actions/group-admin.test.ts index 90bb9672..28b1ce7f 100644 --- a/packages/core/tests/actions/group-admin.test.ts +++ b/packages/core/tests/actions/group-admin.test.ts @@ -1,7 +1,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'; import { protobuf_encode } from '@snowluma/proton'; -import type { OidbBase } from '../../src/bridge/proto/proton/oidb'; -import type { Oidb0x8a7Resp } from '../../src/bridge/proto/proton/oidb-actions/base'; +import type { OidbBase } from '@snowluma/proto-defs/oidb'; +import type { Oidb0x8a7Resp } from '@snowluma/proto-defs/oidb-actions/base'; // `encodeOidbEnv` / `decodeOidbEnv` are proton-bound pass-through wrappers // that the plugin substitutes at the call site with the inlined codec, so diff --git a/packages/core/tests/actions/group-file.test.ts b/packages/core/tests/actions/group-file.test.ts index 64935916..61df590b 100644 --- a/packages/core/tests/actions/group-file.test.ts +++ b/packages/core/tests/actions/group-file.test.ts @@ -1,16 +1,16 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'; import { protobuf_encode } from '@snowluma/proton'; -import type { OidbBase } from '../../src/bridge/proto/proton/oidb'; +import type { OidbBase } from '@snowluma/proto-defs/oidb'; import type { OidbGroupFileCountViewResp, OidbGroupFileResp, OidbGroupFileViewResp, OidbGroupFileFolderResp, -} from '../../src/bridge/proto/proton/oidb-actions/group-file'; +} from '@snowluma/proto-defs/oidb-actions/group-file'; import type { OidbPrivateFileUploadResp, NTV2RichMediaResp, -} from '../../src/bridge/proto/proton/oidb-actions/media'; +} from '@snowluma/proto-defs/oidb-actions/media'; // `encodeOidbEnv` / `decodeOidbEnv` are proton-bound pass-through wrappers // (substituted at the call site with the inlined codec). Mocking them on diff --git a/packages/core/tests/actions/interaction.test.ts b/packages/core/tests/actions/interaction.test.ts index 88570593..93ac5e49 100644 --- a/packages/core/tests/actions/interaction.test.ts +++ b/packages/core/tests/actions/interaction.test.ts @@ -1,7 +1,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'; import { protobuf_encode } from '@snowluma/proton'; -import type { OidbBase } from '../../src/bridge/proto/proton/oidb'; -import type { Oidb0x9083Resp } from '../../src/bridge/proto/proton/oidb-actions/base'; +import type { OidbBase } from '@snowluma/proto-defs/oidb'; +import type { Oidb0x9083Resp } from '@snowluma/proto-defs/oidb-actions/base'; // `encodeOidbEnv` / `decodeOidbEnv` are proton-bound pass-through wrappers // that the plugin substitutes at the call site for the inlined codec. diff --git a/packages/core/tests/actions/misc.test.ts b/packages/core/tests/actions/misc.test.ts index 7f7f7dd5..adc9ff38 100644 --- a/packages/core/tests/actions/misc.test.ts +++ b/packages/core/tests/actions/misc.test.ts @@ -1,10 +1,10 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'; import { protobuf_encode } from '@snowluma/proton'; -import type { OidbBase } from '../../src/bridge/proto/proton/oidb'; +import type { OidbBase } from '@snowluma/proto-defs/oidb'; import type { Oidb0x990Resp, Oidb0x112eResp, -} from '../../src/bridge/proto/proton/oidb-actions/base'; +} from '@snowluma/proto-defs/oidb-actions/base'; // `encodeOidbEnv` / `decodeOidbEnv` are proton-bound pass-through wrappers // — the plugin substitutes them at the call site with the inlined codec, diff --git a/packages/core/tests/actions/profile.test.ts b/packages/core/tests/actions/profile.test.ts index bf5aa37c..e96d88bc 100644 --- a/packages/core/tests/actions/profile.test.ts +++ b/packages/core/tests/actions/profile.test.ts @@ -1,13 +1,13 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'; import { protobuf_decode, protobuf_encode } from '@snowluma/proton'; -import type { OidbBase } from '../../src/bridge/proto/proton/oidb'; +import type { OidbBase } from '@snowluma/proto-defs/oidb'; import type { GroupAvatarExtra, Oidb0x7edResp, Oidb0xe17Resp, SetStatusReq, SetStatusResp, -} from '../../src/bridge/proto/proton/oidb-actions/base'; +} from '@snowluma/proto-defs/oidb-actions/base'; // `encodeOidbEnv` / `decodeOidbEnv` are proton-bound pass-through wrappers // (substituted at the call site with the inlined codec). Mocking them on diff --git a/packages/core/tests/bridge-private-routing.test.ts b/packages/core/tests/bridge-private-routing.test.ts index 96c56008..fdb75a3a 100644 --- a/packages/core/tests/bridge-private-routing.test.ts +++ b/packages/core/tests/bridge-private-routing.test.ts @@ -1,8 +1,8 @@ import { describe, expect, it, vi } from 'vitest'; import { protobuf_decode, protobuf_encode } from '@snowluma/proton'; import type { SendPacketResult } from '../src/protocol/packet-sender'; -import type { SendMessageRequest, SendMessageResponse } from '../src/bridge/proto/proton/action'; -import type { FileExtra } from '../src/bridge/proto/proton/message'; +import type { SendMessageRequest, SendMessageResponse } from '@snowluma/proto-defs/action'; +import type { FileExtra } from '@snowluma/proto-defs/message'; vi.mock('../src/bridge/element-builder', () => ({ buildSendElems: vi.fn(async () => [{ text: { str: 'stub media elem' } }]), diff --git a/packages/core/tests/group-msg-emoji-like.test.ts b/packages/core/tests/group-msg-emoji-like.test.ts index b2187bcf..66daafd1 100644 --- a/packages/core/tests/group-msg-emoji-like.test.ts +++ b/packages/core/tests/group-msg-emoji-like.test.ts @@ -7,7 +7,7 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest'; import { protobuf_encode } from '@snowluma/proton'; -import type { GroupReactNotify } from '../src/bridge/proto/proton/notify'; +import type { GroupReactNotify } from '@snowluma/proto-defs/notify'; import { decodeEvent0x2DC } from '../src/bridge/msg-push/decoders/event-0x2dc'; import type { MsgPushContext } from '../src/bridge/msg-push/context'; import { IdentityService } from '../src/bridge/identity-service'; diff --git a/packages/core/tests/highway/pipeline.test.ts b/packages/core/tests/highway/pipeline.test.ts index 06ade675..f4abb7aa 100644 --- a/packages/core/tests/highway/pipeline.test.ts +++ b/packages/core/tests/highway/pipeline.test.ts @@ -24,8 +24,8 @@ import { runNtv2Upload, type MediaSubFileUpload, } from '../../src/bridge/highway/pipeline'; -import type { OidbBase } from '../../src/bridge/proto/proton/oidb'; -import type { EncodableMediaMsgInfo, NTV2UploadRichMediaReq, NTV2UploadRichMediaResp } from '../../src/bridge/proto/proton/highway'; +import type { OidbBase } from '@snowluma/proto-defs/oidb'; +import type { EncodableMediaMsgInfo, NTV2UploadRichMediaReq, NTV2UploadRichMediaResp } from '@snowluma/proto-defs/highway'; interface FakeUploadResponse { upload?: { diff --git a/packages/core/tests/message-parser.test.ts b/packages/core/tests/message-parser.test.ts index fabec744..ab222560 100644 --- a/packages/core/tests/message-parser.test.ts +++ b/packages/core/tests/message-parser.test.ts @@ -5,9 +5,9 @@ import { describe, it, expect, vi } from 'vitest'; import { protobuf_decode, protobuf_encode } from '@snowluma/proton'; import { parseMessage } from '../src/onebot/message-parser'; import { buildSendElems } from '../src/bridge/element-builder'; -import type { MentionExtraSend } from '../src/bridge/proto/proton/action'; -import type { OidbBase } from '../src/bridge/proto/proton/oidb'; -import type { NTV2UploadRichMediaResp } from '../src/bridge/proto/proton/highway'; +import type { MentionExtraSend } from '@snowluma/proto-defs/action'; +import type { OidbBase } from '@snowluma/proto-defs/oidb'; +import type { NTV2UploadRichMediaResp } from '@snowluma/proto-defs/highway'; describe('parseMessage', () => { describe('plain text', () => { diff --git a/packages/core/tests/msg-push-handler.test.ts b/packages/core/tests/msg-push-handler.test.ts index 851439d2..87241ea0 100644 --- a/packages/core/tests/msg-push-handler.test.ts +++ b/packages/core/tests/msg-push-handler.test.ts @@ -14,8 +14,8 @@ import type { GroupMemberInfo, QQGroupInfo } from '../src/bridge/qq-info'; // inline-extract the kind. import type { GroupChange, NewFriend, FriendRecall, OperatorInfo, SelfJoinInGroup, -} from '../src/bridge/proto/proton/notify'; -import type { PushMsg } from '../src/bridge/proto/proton/message'; +} from '@snowluma/proto-defs/notify'; +import type { PushMsg } from '@snowluma/proto-defs/message'; import type { GroupMemberJoin, FriendAddEvent, QQEventVariant, } from '../src/bridge/events'; diff --git a/packages/core/tests/observability-logs.test.ts b/packages/core/tests/observability-logs.test.ts index b09b7208..220b2f19 100644 --- a/packages/core/tests/observability-logs.test.ts +++ b/packages/core/tests/observability-logs.test.ts @@ -25,8 +25,8 @@ import { runNtv2Upload, type MediaSubFileUpload, } from '../src/bridge/highway/pipeline'; -import type { OidbBase } from '../src/bridge/proto/proton/oidb'; -import type { NTV2UploadRichMediaResp } from '../src/bridge/proto/proton/highway'; +import type { OidbBase } from '@snowluma/proto-defs/oidb'; +import type { NTV2UploadRichMediaResp } from '@snowluma/proto-defs/highway'; import { MsgPushRegistry } from '../src/bridge/msg-push/registry'; import type { MsgPushContext } from '../src/bridge/msg-push/context'; import { decodeEvent0x2DC } from '../src/bridge/msg-push/decoders/event-0x2dc'; diff --git a/packages/core/tests/web-actions/cookies.test.ts b/packages/core/tests/web-actions/cookies.test.ts index e585ac9d..9ee80fcf 100644 --- a/packages/core/tests/web-actions/cookies.test.ts +++ b/packages/core/tests/web-actions/cookies.test.ts @@ -1,10 +1,10 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'; import { protobuf_encode } from '@snowluma/proton'; -import type { OidbBase } from '../../src/bridge/proto/proton/oidb'; +import type { OidbBase } from '@snowluma/proto-defs/oidb'; import type { OidbClientKeyResp, OidbGetPskeyResp, -} from '../../src/bridge/proto/proton/oidb-actions/base'; +} from '@snowluma/proto-defs/oidb-actions/base'; // `encodeOidbEnv` / `decodeOidbEnv` are proton-bound pass-through wrappers // — the plugin substitutes them at the call site with the inlined codec, diff --git a/packages/proto-defs/package.json b/packages/proto-defs/package.json new file mode 100644 index 00000000..3ccd8a00 --- /dev/null +++ b/packages/proto-defs/package.json @@ -0,0 +1,73 @@ +{ + "name": "@snowluma/proto-defs", + "version": "1.9.0", + "private": true, + "type": "module", + "description": "SnowLuma QQ/Lagrange wire-protobuf type definitions. Pure TypeScript interfaces with proton's `pb` 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).", + "main": "./src/index.ts", + "types": "./src/index.ts", + "exports": { + ".": { + "types": "./src/index.ts", + "default": "./src/index.ts" + }, + "./action": { + "types": "./src/action.ts", + "default": "./src/action.ts" + }, + "./element": { + "types": "./src/element.ts", + "default": "./src/element.ts" + }, + "./highway": { + "types": "./src/highway.ts", + "default": "./src/highway.ts" + }, + "./longmsg": { + "types": "./src/longmsg.ts", + "default": "./src/longmsg.ts" + }, + "./message": { + "types": "./src/message.ts", + "default": "./src/message.ts" + }, + "./notify": { + "types": "./src/notify.ts", + "default": "./src/notify.ts" + }, + "./oidb": { + "types": "./src/oidb.ts", + "default": "./src/oidb.ts" + }, + "./oidb-action": { + "types": "./src/oidb-action.ts", + "default": "./src/oidb-action.ts" + }, + "./oidb-actions/base": { + "types": "./src/oidb-actions/base.ts", + "default": "./src/oidb-actions/base.ts" + }, + "./oidb-actions/group-album": { + "types": "./src/oidb-actions/group-album.ts", + "default": "./src/oidb-actions/group-album.ts" + }, + "./oidb-actions/group-file": { + "types": "./src/oidb-actions/group-file.ts", + "default": "./src/oidb-actions/group-file.ts" + }, + "./oidb-actions/media": { + "types": "./src/oidb-actions/media.ts", + "default": "./src/oidb-actions/media.ts" + } + }, + "scripts": { + "typecheck": "tsc --noEmit" + }, + "dependencies": { + "@snowluma/proton": "workspace:*" + }, + "devDependencies": { + "@types/node": "^24.12.2", + "typescript": "catalog:" + } +} diff --git a/packages/core/src/bridge/proto/proton/action.ts b/packages/proto-defs/src/action.ts similarity index 100% rename from packages/core/src/bridge/proto/proton/action.ts rename to packages/proto-defs/src/action.ts diff --git a/packages/core/src/bridge/proto/proton/element.ts b/packages/proto-defs/src/element.ts similarity index 100% rename from packages/core/src/bridge/proto/proton/element.ts rename to packages/proto-defs/src/element.ts diff --git a/packages/core/src/bridge/proto/proton/highway.ts b/packages/proto-defs/src/highway.ts similarity index 100% rename from packages/core/src/bridge/proto/proton/highway.ts rename to packages/proto-defs/src/highway.ts diff --git a/packages/proto-defs/src/index.ts b/packages/proto-defs/src/index.ts new file mode 100644 index 00000000..614f5e73 --- /dev/null +++ b/packages/proto-defs/src/index.ts @@ -0,0 +1,34 @@ +// SnowLuma wire-protobuf type definitions. +// +// This barrel exists so `@snowluma/proto-defs` can be resolved by a +// plain `import {} from '@snowluma/proto-defs'` (consumers that don't +// know which sub-namespace they want, or just want to see what's +// available). The package itself is otherwise consumed via the +// per-file subpath exports declared in package.json — that's the +// recommended import shape because it mirrors the legacy +// `bridge/proto/proton/` paths 1:1 and avoids name collisions. +// +// ─── Collision note ─── +// +// `highway.ts` and `oidb-actions/media.ts` each define their own +// `NTV2*` types (NTV2CommonHead, NTV2ClientMeta, NTV2C2CUserInfo, +// NTV2FileInfo, NTV2FileType, NTV2GroupInfo). The two definitions +// are NOT compatible — they describe different wire shapes for +// different protocol surfaces and happen to share the same name in +// the upstream Lagrange schema. `export *` silently drops one side +// when names collide, so a consumer that grabs an `NTV2CommonHead` +// off the barrel might end up with the wrong one. Prefer the subpath +// imports below for any NTV2-named type. + +export type * from './action.js'; +export type * from './element.js'; +// NOTE: `highway.ts` intentionally NOT re-exported here — see note above. +export type * from './longmsg.js'; +export type * from './message.js'; +export type * from './notify.js'; +export type * from './oidb.js'; +export type * from './oidb-action.js'; +export type * from './oidb-actions/base.js'; +export type * from './oidb-actions/group-album.js'; +export type * from './oidb-actions/group-file.js'; +// NOTE: `oidb-actions/media.ts` intentionally NOT re-exported — see note above. diff --git a/packages/core/src/bridge/proto/proton/longmsg.ts b/packages/proto-defs/src/longmsg.ts similarity index 100% rename from packages/core/src/bridge/proto/proton/longmsg.ts rename to packages/proto-defs/src/longmsg.ts diff --git a/packages/core/src/bridge/proto/proton/message.ts b/packages/proto-defs/src/message.ts similarity index 100% rename from packages/core/src/bridge/proto/proton/message.ts rename to packages/proto-defs/src/message.ts diff --git a/packages/core/src/bridge/proto/proton/notify.ts b/packages/proto-defs/src/notify.ts similarity index 100% rename from packages/core/src/bridge/proto/proton/notify.ts rename to packages/proto-defs/src/notify.ts diff --git a/packages/core/src/bridge/proto/proton/oidb-action.ts b/packages/proto-defs/src/oidb-action.ts similarity index 100% rename from packages/core/src/bridge/proto/proton/oidb-action.ts rename to packages/proto-defs/src/oidb-action.ts diff --git a/packages/core/src/bridge/proto/proton/oidb-actions/base.ts b/packages/proto-defs/src/oidb-actions/base.ts similarity index 100% rename from packages/core/src/bridge/proto/proton/oidb-actions/base.ts rename to packages/proto-defs/src/oidb-actions/base.ts diff --git a/packages/core/src/bridge/proto/proton/oidb-actions/group-album.ts b/packages/proto-defs/src/oidb-actions/group-album.ts similarity index 100% rename from packages/core/src/bridge/proto/proton/oidb-actions/group-album.ts rename to packages/proto-defs/src/oidb-actions/group-album.ts diff --git a/packages/core/src/bridge/proto/proton/oidb-actions/group-file.ts b/packages/proto-defs/src/oidb-actions/group-file.ts similarity index 100% rename from packages/core/src/bridge/proto/proton/oidb-actions/group-file.ts rename to packages/proto-defs/src/oidb-actions/group-file.ts diff --git a/packages/core/src/bridge/proto/proton/oidb-actions/index.ts b/packages/proto-defs/src/oidb-actions/index.ts similarity index 100% rename from packages/core/src/bridge/proto/proton/oidb-actions/index.ts rename to packages/proto-defs/src/oidb-actions/index.ts diff --git a/packages/core/src/bridge/proto/proton/oidb-actions/media.ts b/packages/proto-defs/src/oidb-actions/media.ts similarity index 100% rename from packages/core/src/bridge/proto/proton/oidb-actions/media.ts rename to packages/proto-defs/src/oidb-actions/media.ts diff --git a/packages/core/src/bridge/proto/proton/oidb.ts b/packages/proto-defs/src/oidb.ts similarity index 100% rename from packages/core/src/bridge/proto/proton/oidb.ts rename to packages/proto-defs/src/oidb.ts diff --git a/packages/proto-defs/tsconfig.json b/packages/proto-defs/tsconfig.json new file mode 100644 index 00000000..4cd329d7 --- /dev/null +++ b/packages/proto-defs/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "types": ["node"], + "noEmit": true + }, + "include": [ + "src/**/*" + ], + "exclude": [ + "node_modules" + ] +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index da2257c5..1de46d31 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -50,6 +50,9 @@ importers: packages/core: dependencies: + '@snowluma/proto-defs': + specifier: workspace:* + version: link:../proto-defs '@snowluma/proton': specifier: workspace:* version: link:../proton @@ -88,6 +91,19 @@ importers: specifier: ^4.1.4 version: 4.1.4(@types/node@24.12.2)(vite@8.0.8(@types/node@24.12.2)(esbuild@0.27.7)(jiti@2.6.1)(sass@1.99.0)(tsx@4.21.0)) + packages/proto-defs: + dependencies: + '@snowluma/proton': + specifier: workspace:* + version: link:../proton + devDependencies: + '@types/node': + specifier: ^24.12.2 + version: 24.12.2 + typescript: + specifier: 'catalog:' + version: 6.0.2 + packages/proton: dependencies: typescript: