/** * 平台标识符 */ export type PlatformId = 'feishu' | 'discord' | 'wecom' | 'telegram' | 'qq' | 'whatsapp' | 'weixin' | 'dingtalk' | string; /** * 聊天类型 */ export type ChatType = 'p2p' | 'group'; /** * 发送者类型 */ export type SenderType = 'user' | 'bot'; /** * 平台消息事件(入站消息的通用抽象) */ export interface PlatformMessageEvent { platform: PlatformId; conversationId: string; messageId: string; senderId: string; senderType: SenderType; content: string; msgType: string; threadId?: string; chatType?: ChatType; attachments?: PlatformAttachment[]; mentions?: PlatformMention[]; rawEvent: unknown; } /** * 平台附件 */ export interface PlatformAttachment { type: 'image' | 'file'; fileKey: string; fileName?: string; fileType?: string; fileSize?: number; } /** * 平台提及信息 */ export interface PlatformMention { key: string; id: { [key: string]: string; }; name: string; } /** * 平台动作事件(卡片/按钮点击等交互) */ export interface PlatformActionEvent { platform: PlatformId; senderId: string; action: { tag: string; value: Record; }; token: string; messageId?: string; conversationId?: string; threadId?: string; rawEvent: unknown; } /** * 平台输出发送器接口(出站消息抽象) */ export interface PlatformSender { sendText(conversationId: string, text: string): Promise; sendCard(conversationId: string, card: object): Promise; updateCard(messageId: string, card: object): Promise; deleteMessage(messageId: string): Promise; reply?(messageId: string, text: string): Promise; replyCard?(messageId: string, card: object): Promise; } /** * 平台适配器接口(入站事件接收 + 出站发送) */ export interface PlatformAdapter { readonly platform: PlatformId; start(): Promise; stop(): void; getSender(): PlatformSender; onMessage(callback: (event: PlatformMessageEvent) => void): void; onAction(callback: (event: PlatformActionEvent) => void): void; onChatUnavailable?(callback: (conversationId: string) => void): void; onMessageRecalled?(callback: (event: unknown) => void): void; onMemberLeft?(callback: (conversationId: string, memberId: string) => void): void; onChatDisbanded?(callback: (conversationId: string) => void): void; onInteraction?(callback: (interaction: unknown) => void): void; } //# sourceMappingURL=types.d.ts.map