fix(sdk): restore native ESM imports and action exports

This commit is contained in:
DrSmoothl committed 2026-10-23 13:04:33 +08:00
1 parent f8cb15c27b
commit b997de44a2
33 files changed
+482 -81

No files matched your search

+222
View File
@@ -0,0 +1,222 @@
/**
* Action names shipped with this SDK version, including compatibility aliases.
* This is a local catalog, not a capability check against a connected server.
*/
export const SNOWLUMA_ACTIONS = [
'get_login_info',
'get_status',
'get_version_info',
'can_send_image',
'can_send_record',
'send_msg',
'send_private_msg',
'send_group_msg',
'get_msg',
'delete_msg',
'get_friend_list',
'get_stranger_info',
'delete_friend',
'get_group_list',
'get_group_info',
'get_group_member_list',
'get_group_member_info',
'get_group_honor_info',
'get_group_system_msg',
'set_group_kick',
'set_group_kick_members',
'set_group_ban',
'set_group_whole_ban',
'set_group_add_option',
'set_group_search',
'set_group_admin',
'set_group_card',
'set_group_name',
'set_group_leave',
'set_group_special_title',
'set_group_anonymous',
'set_group_anonymous_ban',
'set_group_portrait',
'upload_group_file',
'upload_private_file',
'get_group_file_url',
'get_group_root_files',
'get_group_files_by_folder',
'delete_group_file',
'move_group_file',
'create_group_file_folder',
'delete_group_file_folder',
'rename_group_file_folder',
'get_private_file_url',
'set_friend_add_request',
'set_group_add_request',
'send_like',
'friend_poke',
'group_poke',
'send_poke',
'set_essence_msg',
'delete_essence_msg',
'get_essence_msg_list',
'set_group_reaction',
'get_group_msg_history',
'get_friend_msg_history',
'mark_group_msg_as_read',
'mark_private_msg_as_read',
'mark_msg_as_read',
'get_rkey',
'ocr_image',
'.ocr_image',
'_send_group_notice',
'_get_group_notice',
'_del_group_notice',
'upload_forward_msg',
'upload_foward_msg',
'send_forward_msg',
'send_group_forward_msg',
'send_private_forward_msg',
'get_forward_msg',
'get_image',
'get_record',
'get_cookies',
'get_csrf_token',
'get_credentials',
'set_restart',
'clean_cache',
'.handle_quick_operation',
'set_friend_remark',
'set_group_remark',
'set_msg_emoji_like',
'_mark_all_as_read',
'get_group_file_system_info',
'check_url_safely',
'download_file',
'set_qq_profile',
'set_online_status',
'get_group_ignored_notifies',
'get_group_shut_list',
'forward_friend_single_msg',
'forward_group_single_msg',
'get_recent_contact',
'get_profile_like',
'fetch_custom_face',
'get_emoji_likes',
'fetch_emoji_like',
'get_friends_with_category',
'get_online_clients',
'_get_model_show',
'_set_model_show',
'.get_word_slices',
'get_group_at_all_remain',
'get_unidirectional_friend_list',
'set_self_longnick',
'get_collection_list',
'create_collection',
'set_qq_avatar',
'set_input_status',
'translate_en2zh',
'get_clientkey',
'get_mini_app_ark',
'click_inline_keyboard_button',
'set_group_sign',
'send_group_sign',
'get_group_info_ex',
'get_group_detail_info',
'trans_group_file',
'rename_group_file',
'get_file',
'.send_packet',
'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',
'set_diy_online_status',
'get_ai_characters',
'get_ai_record',
'send_group_ai_record',
'_get_friend_dress',
'add_custom_face',
'add_group_tag',
'cancel_group_album_media_like',
'clean_stream_temp_file',
'comment_qzone',
'create_flash_task',
'del_group_album_media',
'delete_custom_face',
'delete_flash_file',
'delete_group_tag',
'delete_qzone_msg',
'do_group_album_comment',
'download_file_image_stream',
'download_file_record_stream',
'download_file_stream',
'download_fileset',
'fetch_custom_face_detail',
'fetch_face_entity',
'fetch_ptt_text',
'get_ptt_text',
'get_record_text',
'fetch_super_face_id',
'fetch_sys_faces',
'get_doubt_friends_add_request',
'get_fileset_id',
'get_fileset_info',
'get_flash_file_list',
'get_flash_file_url',
'get_group_admin_settings',
'get_group_album_list',
'get_group_album_media_list',
'get_group_share_link',
'get_group_signed_list',
'get_group_tags',
'get_group_todo_list',
'get_msg_emoji_likes',
'get_qun_album_list',
'get_qzone_feeds',
'get_qzone_msg_detail',
'get_qzone_msg_list',
'get_rkey_server',
'get_share_link',
'like_qzone',
'list_filesets',
'modify_custom_face',
'move_custom_face_to_front',
'rename_flash_file',
'request_decrypt_key',
'search_sys_faces',
'send_ark_share',
'send_custom_face',
'send_flash_msg',
'send_group_ark_share',
'send_qzone_msg',
'send_tuwen_ark',
'set_doubt_friends_add_request',
'set_friends_category',
'set_group_album_media_like',
'set_group_member_invite_policy',
'set_group_member_permissions',
'set_group_new_member_history_visibility',
'set_group_robot_add_option',
'set_qzone_ban',
'set_qzone_msg_right',
'share_group_ex',
'share_peer',
'test_download_stream',
'unlike_qzone',
'upload_file_stream',
'upload_image_to_qun_album',
'upload_video_to_qun_album',
'.handle_quick_operation_async',
] as const;
export type SnowLumaKnownAction = (typeof SNOWLUMA_ACTIONS)[number];
const ACTION_SET = new Set<string>(SNOWLUMA_ACTIONS);
export function isSnowLumaAction(action: string): action is SnowLumaKnownAction {
return ACTION_SET.has(action);
}
+3 -3
View File
@@ -1,5 +1,5 @@
import { createSnowLumaApiError } from '../errors';
import { normalizeMessage } from '../messages/index';
import { createSnowLumaApiError } from '../errors.js';
import { normalizeMessage } from '../messages/index.js';
import type {
ActionParams,
ActionResult,
@@ -19,7 +19,7 @@ import type {
SendMsgParams,
SetGroupReactionParams,
SnowLumaAction,
} from '../types/index';
} from '../types/index.js';
/**
* Base class for SnowLuma API clients.
+5 -5
View File
@@ -4,10 +4,10 @@ import {
SnowLumaParseError,
SnowLumaTimeoutError,
SnowLumaTransportError,
} from '../errors';
import { SnowLumaApiClient, toJsonObject } from './api-client';
import { createRequestAbortState, isAbortError } from '../internal/abort';
import { assertApiResponse } from '../internal/json';
} from '../errors.js';
import { SnowLumaApiClient, toJsonObject } from './api-client.js';
import { createRequestAbortState, isAbortError } from '../internal/abort.js';
import { assertApiResponse } from '../internal/json.js';
import type {
ActionParams,
ActionResult,
@@ -16,7 +16,7 @@ import type {
RequestOptions,
SnowLumaAction,
SnowLumaClientOptions,
} from '../types/index';
} from '../types/index.js';
/** Options for the HTTP transport client. */
export interface SnowLumaHttpClientOptions extends SnowLumaClientOptions {
+5 -5
View File
@@ -1,12 +1,12 @@
export { SnowLumaApiClient } from './api-client';
export { SnowLumaHttpClient, createHttpClient } from './http-client';
export { SnowLumaWebSocketClient, createWebSocketClient } from './websocket-client';
export { SnowLumaApiClient } from './api-client.js';
export { SnowLumaHttpClient, createHttpClient } from './http-client.js';
export { SnowLumaWebSocketClient, createWebSocketClient } from './websocket-client.js';
export type { SnowLumaHttpClientOptions } from './http-client';
export type { SnowLumaHttpClientOptions } from './http-client.js';
export type {
ReconnectOptions,
SnowLumaWebSocketClientOptions,
SnowLumaWebSocketEvents,
WebSocketCloseInfo,
WebSocketConstructor,
} from './websocket-client';
} from './websocket-client.js';
+10 -10
View File
@@ -3,8 +3,8 @@ import {
SnowLumaConnectionError,
SnowLumaParseError,
SnowLumaTimeoutError,
} from '../errors';
import { Emitter } from '../emitter';
} from '../errors.js';
import { Emitter } from '../emitter.js';
import {
createEventContext,
isBotStatusEvent,
@@ -22,16 +22,16 @@ import {
type EventHandler,
type EventMiddleware,
type EventPredicate,
} from '../events/index';
import { SnowLumaApiClient, toJsonObject } from './api-client';
import { raceWithAbort, throwIfAborted } from '../internal/abort';
} from '../events/index.js';
import { SnowLumaApiClient, toJsonObject } from './api-client.js';
import { raceWithAbort, throwIfAborted } from '../internal/abort.js';
import {
appendAccessToken,
assertApiResponse,
createEcho,
echoKey,
isJsonObject,
} from '../internal/json';
} from '../internal/json.js';
import {
addSocketListener,
closeInfo,
@@ -41,7 +41,7 @@ import {
unwrapMessagePayload,
WEBSOCKET_CLOSED,
WEBSOCKET_OPEN,
} from './websocket-utils';
} from './websocket-utils.js';
import type {
ActionParams,
ActionResult,
@@ -57,14 +57,14 @@ import type {
SnowLumaAction,
SnowLumaEvent,
WsRole,
} from '../types/index';
} from '../types/index.js';
import type {
ReconnectOptions,
SnowLumaWebSocketClientOptions,
SnowLumaWebSocketEvents,
WebSocketConstructor,
WebSocketLike,
} from './websocket-types';
} from './websocket-types.js';
export type {
ReconnectOptions,
@@ -72,7 +72,7 @@ export type {
SnowLumaWebSocketEvents,
WebSocketCloseInfo,
WebSocketConstructor,
} from './websocket-types';
} from './websocket-types.js';
interface SocketConnection {
socket: WebSocketLike;
+1 -1
View File
@@ -1,4 +1,4 @@
import type { ApiResponse, SnowLumaClientOptions, SnowLumaEvent, WsRole } from '../types/index';
import type { ApiResponse, SnowLumaClientOptions, SnowLumaEvent, WsRole } from '../types/index.js';
export interface WebSocketLike {
readyState: number;
+2 -2
View File
@@ -1,5 +1,5 @@
import { isJsonObject } from '../internal/json';
import type { ReconnectOptions, WebSocketCloseInfo, WebSocketLike } from './websocket-types';
import { isJsonObject } from '../internal/json.js';
import type { ReconnectOptions, WebSocketCloseInfo, WebSocketLike } from './websocket-types.js';
export const WEBSOCKET_OPEN = 1;
export const WEBSOCKET_CLOSED = 3;
+1 -1
View File
@@ -1,4 +1,4 @@
import type { ApiResponse } from './types/index';
import type { ApiResponse } from './types/index.js';
/** Base error for every exception intentionally thrown by the SnowLuma SDK. */
export class SnowLumaError extends Error {
+2 -2
View File
@@ -1,5 +1,5 @@
import type { OneBotMessageEvent } from '../types/index';
import type { CommandMatch, CommandOptions } from './types';
import type { OneBotMessageEvent } from '../types/index.js';
import type { CommandMatch, CommandOptions } from './types.js';
export function matchCommand(
event: OneBotMessageEvent,
+4 -4
View File
@@ -1,7 +1,7 @@
import type { SnowLumaApiClient } from '../client/api-client';
import type { SnowLumaEvent } from '../types/index';
import { isGroupMessageEvent, isPrivateMessageEvent, isRequestEvent } from './guards';
import type { SnowLumaEventContext } from './types';
import type { SnowLumaApiClient } from '../client/api-client.js';
import type { SnowLumaEvent } from '../types/index.js';
import { isGroupMessageEvent, isPrivateMessageEvent, isRequestEvent } from './guards.js';
import type { SnowLumaEventContext } from './types.js';
export function createEventContext<TEvent extends SnowLumaEvent>(
event: TEvent,
+2 -2
View File
@@ -7,8 +7,8 @@ import type {
OneBotPrivateMessageEvent,
OneBotRequestEvent,
SnowLumaEvent,
} from '../types/index';
import type { EventPredicate } from './types';
} from '../types/index.js';
import type { EventPredicate } from './types.js';
export function isMessageEvent(event: SnowLumaEvent): event is OneBotMessageEvent {
return (
+4 -4
View File
@@ -1,4 +1,4 @@
export * from './types';
export * from './guards';
export * from './context';
export * from './command';
export * from './types.js';
export * from './guards.js';
export * from './context.js';
export * from './command.js';
+2 -2
View File
@@ -1,11 +1,11 @@
import type { SnowLumaApiClient } from '../client/api-client';
import type { SnowLumaApiClient } from '../client/api-client.js';
import type {
JsonObject,
OneBotMessageEvent,
OutgoingMessage,
RequestOptions,
SnowLumaEvent,
} from '../types/index';
} from '../types/index.js';
export type MaybePromise<T = void> = T | Promise<T>;
export type EventNext = () => Promise<void>;
+12 -10
View File
@@ -1,7 +1,9 @@
export { SnowLumaApiClient } from './client/api-client';
export { createHttpClient, SnowLumaHttpClient } from './client/http-client';
export type { SnowLumaHttpClientOptions } from './client/http-client';
export { createWebSocketClient, SnowLumaWebSocketClient } from './client/websocket-client';
export { SNOWLUMA_ACTIONS, isSnowLumaAction } from './actions.js';
export type { SnowLumaKnownAction } from './actions.js';
export { SnowLumaApiClient } from './client/api-client.js';
export { createHttpClient, SnowLumaHttpClient } from './client/http-client.js';
export type { SnowLumaHttpClientOptions } from './client/http-client.js';
export { createWebSocketClient, SnowLumaWebSocketClient } from './client/websocket-client.js';
export {
createSnowLumaApiError,
SnowLumaAbortError,
@@ -12,7 +14,7 @@ export {
SnowLumaParseError,
SnowLumaTimeoutError,
SnowLumaTransportError,
} from './errors';
} from './errors.js';
export {
createEventContext,
isBotStatusEvent,
@@ -25,7 +27,7 @@ export {
matchCommand,
noticeType,
requestType,
} from './events/index';
} from './events/index.js';
export {
at,
atAll,
@@ -55,7 +57,7 @@ export {
toCQString,
video,
xml,
} from './messages/index';
} from './messages/index.js';
export type {
ReconnectOptions,
@@ -63,7 +65,7 @@ export type {
SnowLumaWebSocketEvents,
WebSocketCloseInfo,
WebSocketConstructor,
} from './client/websocket-client';
} from './client/websocket-client.js';
export type {
CommandHandler,
@@ -76,6 +78,6 @@ export type {
MaybePromise,
RequestDecisionOptions,
SnowLumaEventContext,
} from './events/index';
} from './events/index.js';
export type * from './types/index';
export type * from './types/index.js';
+1 -1
View File
@@ -1,4 +1,4 @@
import { SnowLumaAbortError } from '../errors';
import { SnowLumaAbortError } from '../errors.js';
export interface RequestAbortState {
signal: AbortSignal;
+1 -1
View File
@@ -1,4 +1,4 @@
import type { ApiResponse, JsonObject, JsonValue } from '../types/index';
import type { ApiResponse, JsonObject, JsonValue } from '../types/index.js';
export function isJsonObject(value: unknown): value is JsonObject {
return typeof value === 'object' && value !== null && !Array.isArray(value);
+3 -3
View File
@@ -13,9 +13,9 @@ import type {
ShareSegment,
VideoSegment,
XmlSegment,
} from '../types/index';
import { segmentsToCQString } from './cq-format';
import { segments } from './segments';
} from '../types/index.js';
import { segmentsToCQString } from './cq-format.js';
import { segments } from './segments.js';
export interface MessageChainSender {
sendGroupMessage(
+1 -1
View File
@@ -1,4 +1,4 @@
import type { AnyMessageSegment } from '../types/index';
import type { AnyMessageSegment } from '../types/index.js';
export function escapeCqText(text: string): string {
return text.replaceAll('&', '&amp;').replaceAll('[', '&#91;').replaceAll(']', '&#93;');
+4 -4
View File
@@ -1,7 +1,7 @@
import { normalizeMessage, chain } from './chain';
import { escapeCqText, segmentsToCQString } from './cq-format';
import { segments } from './segments';
import type { AnyMessageSegment, FaceSegment, OutgoingMessage } from '../types/index';
import { normalizeMessage, chain } from './chain.js';
import { escapeCqText, segmentsToCQString } from './cq-format.js';
import { segments } from './segments.js';
import type { AnyMessageSegment, FaceSegment, OutgoingMessage } from '../types/index.js';
const CQ_REGEX = /\[CQ:([a-zA-Z0-9_.-]+)(?:,([^\]]*))?\]/g;
+5 -5
View File
@@ -1,6 +1,6 @@
import { segments } from './segments';
import { segments } from './segments.js';
export { MessageChain } from './chain';
export { MessageChain } from './chain.js';
export {
at,
atAll,
@@ -23,9 +23,9 @@ export {
text,
video,
xml,
} from './chain';
export { escapeCqParam, escapeCqText } from './cq-format';
export { fromCQString, parseSegments, toCQString } from './cq';
} from './chain.js';
export { escapeCqParam, escapeCqText } from './cq-format.js';
export { fromCQString, parseSegments, toCQString } from './cq.js';
export { segments };
export const message = {
+1 -1
View File
@@ -19,7 +19,7 @@ import type {
TextSegment,
VideoSegment,
XmlSegment,
} from '../types/index';
} from '../types/index.js';
function seg<TType extends string, TData extends Record<string, unknown>>(
type: TType,
+3 -3
View File
@@ -1,4 +1,4 @@
import type { JsonArray, JsonObject, JsonValue } from './json';
import type { JsonArray, JsonObject, JsonValue } from './json.js';
import type {
CreateGroupFileFolderParams,
DeleteFriendParams,
@@ -79,7 +79,7 @@ import type {
SendPacketParams,
SearchSysFacesParams,
GetQzoneMsgDetailParams,
} from './params';
} from './params.js';
import type {
CapabilityInfo,
ClientKeyInfo,
@@ -117,7 +117,7 @@ import type {
SystemFaceInfo,
SystemFaceSearchInfo,
QzoneMsgDetailResult,
} from './results';
} from './results.js';
export type ActionData = JsonValue;
+1 -1
View File
@@ -1,4 +1,4 @@
import type { JsonObject, JsonValue } from './json';
import type { JsonObject, JsonValue } from './json.js';
export interface OneBotBaseEvent extends JsonObject {
time: number;
+6 -6
View File
@@ -1,6 +1,6 @@
export * from './json';
export * from './messages';
export * from './results';
export * from './params';
export * from './actions';
export * from './events';
export * from './json.js';
export * from './messages.js';
export * from './results.js';
export * from './params.js';
export * from './actions.js';
export * from './events.js';
+1 -1
View File
@@ -1,4 +1,4 @@
import type { JsonObject } from './json';
import type { JsonObject } from './json.js';
export interface MessageSegment<
TType extends string = string,
+1 -1
View File
@@ -1,4 +1,4 @@
import type { JsonObject, JsonValue } from './json';
import type { JsonObject, JsonValue } from './json.js';
export interface SendMsgParams extends JsonObject {
message_type?: 'private' | 'group' | string;
+1 -1
View File
@@ -1,4 +1,4 @@
import type { JsonArray, JsonObject, JsonValue } from './json';
import type { JsonArray, JsonObject, JsonValue } from './json.js';
export interface QzoneCommentReply {
uin: number;