import type { NormalizedMessage, MessageHandler, PlatformAdapter } from "../types.js"; import type { BotAtPermissionStatus, ChatMetadata, DeliveryOptions, MessageReadError } from "../../transport/types.js"; type MessageReadContext = Pick & { outerMessageId?: string; readErrors?: Map; }; export declare class FeishuAdapter implements PlatformAdapter { private client; private wsClient; private handler; private appId; private appSecret; /** Bot 自身的 open_id(启动时获取) */ private botOpenId; /** Bot 显示名称(从 /bot/v3/info/ 获取) */ private botName; /** App creator open_id(用于 admin 检测) */ private appCreatorId; /** 当前线上版本的 Bot→Bot @ 接收权限;失败时保留 unknown,下一次仍可重试。 */ private botAtPermissionStatus; private botAtPermissionCheckedAt; private botAtPermissionRequest; private messageReadErrorHandler; private forwardReadWarnings; /** 可选:通过 platform ID 查询发送者显示名称(只读,注入自 DB) */ private nameLookup; /** 可选:注册未知用户并返回显示名称(写入,注入自 DB) */ private nameRegister; /** GET 成功确认为人的 open_id。失败不写入,下一条还能再刷。 */ private confirmedHumans; /** 可选:通过 platform msg ID 查询已缓存的消息内容(注入自 DB) */ private contentResolver; /** 可选:查询本地 users 表身份。undefined 表示第一次遇见。 */ private identityLookup; /** 可选:自身 open_id 就绪后通知同机其他 Bot。 */ private onIdentity; /** 资源文件存储根目录(DB 同级,注入自 bot-instance) */ private storageDir; constructor(appId: string, appSecret: string); onMessage(handler: MessageHandler): void; /** 注入发送者名称查询(只读 DB),用于 merge_forward 等场景 */ setNameLookup(fn: (platformId: string) => string | undefined): void; /** 注入未知用户注册(写 DB),用于 merge_forward 等场景 */ setNameRegister(fn: (platformId: string, isBot?: boolean) => string): void; /** 注入消息内容缓存查询(DB 查询),用于 merge_forward 等场景 */ setContentResolver(fn: (platformMsgId: string) => string | undefined): void; onMessageReadError(handler: (event: MessageReadError) => void): void; /** 注入本地用户身份查询,用于决定要不要 GET 消息补标 Bot。 */ setIdentityLookup(fn: (platformId: string) => { isBot: boolean; } | undefined): void; /** 自身飞书身份就绪后回调(open_id / 名称)。 */ setOnIdentity(fn: (identity: { openId: string; name: string | null; }) => void): void; /** 注入资源文件存储目录(DB 同级目录) */ setStorageDir(dir: string): void; private streamDownload; /** * 下载图片资源到本地,返回绝对路径。失败返回 null。 * 存储路径:{storageDir}/images/{imageKey}.{ext} */ private downloadImage; /** * 下载文件资源到本地,返回绝对路径。失败返回 null。 * 存储路径:{storageDir}/files/{fileKey}_{fileName} */ private downloadFile; start(): Promise; stop(): Promise; sendText(chatId: string, text: string, _options?: DeliveryOptions): Promise; sendReply(chatId: string, text: string, replyToMsgId: string, options?: DeliveryOptions): Promise; sendMarkdownCard(chatId: string, markdown: string, options?: DeliveryOptions): Promise; sendCard(chatId: string, header: string, content: string, footer?: string, replyToMsgId?: string, options?: DeliveryOptions): Promise; editMessage(msgId: string, text: string): Promise; addReaction(chatId: string, msgId: string, emoji: string): Promise; removeReaction(chatId: string, msgId: string, emoji: string): Promise; /** 将文本内容写入临时 .md 文件并发送 */ private sendContentAsFile; sendFile(chatId: string, filePath: string, fileName?: string, options?: DeliveryOptions): Promise; private sendImage; private postMessage; getBotOpenId(): Promise; getBotName(): Promise; getChatName(chatId: string): Promise; getChatMetadata(chatId: string): Promise; getMessageThreadId(messageId: string, _context?: MessageReadContext): Promise; listChatMessages(chatId: string, options?: { sinceUnixSec?: number; limit?: number; threadId?: string; }): Promise; getMessageContent(msgId: string, context?: MessageReadContext): Promise; getAppCreatorId(): Promise; getBotAtPermissionStatus(): Promise; private fetchBotAtPermissionStatus; private fetchBotIdentity; private emitIdentity; private normalize; /** * Parse message content based on type. Returns extracted text and content type. * Handles mention placeholder replacement in the text. * For image/file types, downloads the resource and injects the local path. */ private parseContent; /** Replace @mention placeholders with display names */ private replaceMentions; /** * Extract text from rich text (post) messages, downloading embedded images. * Used by parseContent (main flow) where image download is available. */ private extractPostContent; /** * Extract text from rich text (post) messages without downloading images. * Used by extractChildMessageText (merge_forward) where image download is not supported. */ private extractPostText; /** 取得卡片原始 body;失败时保留入站占位,后续历史同步还可以重试。 */ private fetchOriginalCardContent; private fetchMessageBody; private getMessage; private getMessageForContent; private reportMessageReadError; private rememberHuman; private isConfirmedHuman; private isKnownBot; private applyKnownIdentities; private needsIdentityFetch; private fetchMessageIdentity; /** Fetch and render merge_forward message content via API (recursive) */ private parseMergeForward; /** Parse merge_forward into structured MessageNode tree */ private parseForwardNodes; /** Resolve sender display name: lookup -> bot -> register. */ private resolveSenderFromItem; /** Fetch child message content: DB cache → API item body → type fallback. */ private extractChildMessageText; /** Apply mention replacements from message.get() API response */ private applyItemMentions; } export {};