fix(sdk): catch up SNOWLUMA_ACTIONS with the 14 new core actions
`actions-sync.test.ts` walks every `registerAction(...)` in `@snowluma/core/src/onebot/actions/` and asserts the SDK's exported list matches. The napcat-parity work (Tier 1 + Tier 2 + Tier 3 + AI voice) added 14 actions to core without ever touching the SDK, so the test caught the drift: bot_exit cancel_group_todo complete_group_todo delete_group_folder get_ai_characters get_ai_record get_group_ignore_add_request nc_get_packet_status nc_get_rkey nc_get_user_status send_group_ai_record send_packet set_diy_online_status set_group_todo Added them to `SNOWLUMA_ACTIONS` and gave each one a typed `SnowLumaActionMap` entry. Where the request body shape is non-trivial (AI voice, group todo, DIY status, send_packet, nc_get_user_status), introduced dedicated param types in `types/params.ts`; where the response is structured (AI character list, user-status word), introduced result types in `types/results.ts`. Everything else routes through `JsonObject` / `EmptyData` so the SDK surface stays small. Verified: pnpm --filter @snowluma/sdk typecheck → clean pnpm --filter @snowluma/sdk test → 17/17 pass
This commit is contained in:
@@ -122,6 +122,24 @@ export const SNOWLUMA_ACTIONS = [
|
||||
'rename_group_file',
|
||||
'get_file',
|
||||
'.send_packet',
|
||||
|
||||
// napcat-parity extensions (Tier 1 + Tier 2)
|
||||
'send_packet',
|
||||
'bot_exit',
|
||||
'nc_get_packet_status',
|
||||
'nc_get_rkey',
|
||||
'nc_get_user_status',
|
||||
'get_group_ignore_add_request',
|
||||
'delete_group_folder',
|
||||
'set_group_todo',
|
||||
'complete_group_todo',
|
||||
'cancel_group_todo',
|
||||
// Tier 3: DIY status
|
||||
'set_diy_online_status',
|
||||
// AI voice trio
|
||||
'get_ai_characters',
|
||||
'get_ai_record',
|
||||
'send_group_ai_record',
|
||||
] as const satisfies readonly (keyof SnowLumaActionMap)[];
|
||||
|
||||
export type SnowLumaKnownAction = typeof SNOWLUMA_ACTIONS[number];
|
||||
|
||||
@@ -60,6 +60,13 @@ import type {
|
||||
UploadPrivateFileParams,
|
||||
UserIdParams,
|
||||
QuickOperationParams,
|
||||
SetDiyOnlineStatusParams,
|
||||
NcGetUserStatusParams,
|
||||
GroupTodoParams,
|
||||
GetAiCharactersParams,
|
||||
AiVoiceParams,
|
||||
DeleteGroupFolderParams,
|
||||
SendPacketParams,
|
||||
} from './params';
|
||||
import type {
|
||||
CapabilityInfo,
|
||||
@@ -84,6 +91,9 @@ import type {
|
||||
UploadForwardResult,
|
||||
UrlSafetyInfo,
|
||||
VersionInfo,
|
||||
AiCharacterCategory,
|
||||
UserOnlineStatus,
|
||||
SendGroupAiRecordResult,
|
||||
} from './results';
|
||||
|
||||
export type ActionData = JsonValue;
|
||||
@@ -209,7 +219,27 @@ export interface SnowLumaActionMap {
|
||||
trans_group_file: { params: JsonObject; data: JsonValue };
|
||||
rename_group_file: { params: JsonObject; data: JsonValue };
|
||||
get_file: { params: GetMediaParams; data: JsonValue };
|
||||
'.send_packet': { params: JsonObject; data: JsonValue };
|
||||
'.send_packet': { params: SendPacketParams; data: string };
|
||||
|
||||
// — napcat-parity extensions (Tier 1 + Tier 2) —
|
||||
send_packet: { params: SendPacketParams; data: string };
|
||||
bot_exit: { params: JsonObject; data: EmptyData };
|
||||
nc_get_packet_status: { params: JsonObject; data: JsonValue };
|
||||
nc_get_rkey: { params: JsonObject; data: JsonObject[] };
|
||||
nc_get_user_status: { params: NcGetUserStatusParams; data: UserOnlineStatus };
|
||||
get_group_ignore_add_request: { params: JsonObject; data: JsonArray };
|
||||
delete_group_folder: { params: DeleteGroupFolderParams; data: EmptyData };
|
||||
set_group_todo: { params: GroupTodoParams; data: EmptyData };
|
||||
complete_group_todo: { params: GroupTodoParams; data: EmptyData };
|
||||
cancel_group_todo: { params: GroupTodoParams; data: EmptyData };
|
||||
|
||||
// — Tier 3: DIY status —
|
||||
set_diy_online_status: { params: SetDiyOnlineStatusParams; data: EmptyData };
|
||||
|
||||
// — AI voice trio —
|
||||
get_ai_characters: { params: GetAiCharactersParams; data: AiCharacterCategory[] };
|
||||
get_ai_record: { params: AiVoiceParams; data: string };
|
||||
send_group_ai_record: { params: AiVoiceParams; data: SendGroupAiRecordResult };
|
||||
}
|
||||
|
||||
export type SnowLumaAction = keyof SnowLumaActionMap | (string & {});
|
||||
|
||||
@@ -316,3 +316,47 @@ export interface SetOnlineStatusParams extends JsonObject {
|
||||
ext_status?: number;
|
||||
battery_status?: number;
|
||||
}
|
||||
|
||||
// DIY online status — status/extStatus are forced to 10/2000 server-side,
|
||||
// and these three fields land in the customExt sub-message.
|
||||
export interface SetDiyOnlineStatusParams extends JsonObject {
|
||||
face_id: number | string;
|
||||
wording?: string;
|
||||
face_type?: number | string;
|
||||
}
|
||||
|
||||
// nc_get_user_status — read the QQ-side online/ext-status word for a uin.
|
||||
export interface NcGetUserStatusParams extends UserIdParams {}
|
||||
|
||||
// set_/complete_/cancel_group_todo all share this shape; the action verb
|
||||
// lives in the route, not the body.
|
||||
export interface GroupTodoParams extends GroupIdParams {
|
||||
message_id: number | string;
|
||||
}
|
||||
|
||||
// AI voice — fetch the in-group AI character list.
|
||||
export interface GetAiCharactersParams extends GroupIdParams {
|
||||
chat_type?: number | string;
|
||||
}
|
||||
|
||||
// AI voice — `get_ai_record` and `send_group_ai_record` share params.
|
||||
// The action's verb (read vs send) is the route, not the body.
|
||||
export interface AiVoiceParams extends GroupIdParams {
|
||||
character: string;
|
||||
text: string;
|
||||
chat_type?: number | string;
|
||||
}
|
||||
|
||||
// delete_group_folder — napcat's alias for delete_group_file_folder.
|
||||
// Same body, different action name.
|
||||
export interface DeleteGroupFolderParams extends GroupIdParams {
|
||||
folder_id: string;
|
||||
}
|
||||
|
||||
// send_packet — debug endpoint, sends a hex-encoded raw packet.
|
||||
// `rsp=false` skips waiting for a response.
|
||||
export interface SendPacketParams extends JsonObject {
|
||||
cmd: string;
|
||||
data?: string;
|
||||
rsp?: boolean;
|
||||
}
|
||||
|
||||
@@ -101,3 +101,26 @@ export interface GroupAtAllRemainInfo {
|
||||
}
|
||||
|
||||
export type EmptyData = null;
|
||||
|
||||
// — AI 语音角色:get_ai_characters 返回的分类数组 —
|
||||
export interface AiCharacter {
|
||||
character_id: string;
|
||||
character_name: string;
|
||||
preview_url: string;
|
||||
}
|
||||
|
||||
export interface AiCharacterCategory {
|
||||
type: string;
|
||||
characters: AiCharacter[];
|
||||
}
|
||||
|
||||
// — nc_get_user_status 返回的状态字 —
|
||||
export interface UserOnlineStatus {
|
||||
status: number;
|
||||
ext_status: number;
|
||||
}
|
||||
|
||||
// — send_group_ai_record 返回(合成是异步副作用,message_id 总为 0) —
|
||||
export interface SendGroupAiRecordResult {
|
||||
message_id: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user