/** * 邮箱系统核心模块 * 实现 Worker 间的异步消息通信 */ import { Message, MessageType } from '../types/index.js'; /** * 邮箱管理器 */ export declare class Mailbox { private workerId; private basePath; private mailboxPath; private statePath; private mailboxLockPath; constructor(workerId: string, basePath?: string); /** * 初始化邮箱 */ init(): Promise; /** * 发送消息到指定 Worker */ send(to: string, type: MessageType, content: string, options?: { taskId?: string; metadata?: Record; }): Promise; /** * 广播消息给所有 Worker */ broadcast(type: MessageType, content: string, recipients: string[], options?: { taskId?: string; metadata?: Record; }): Promise; /** * 接收消息 */ receive(options?: { limit?: number; unreadOnly?: boolean; markAsRead?: boolean; }): Promise; /** * 等待特定类型的消息 */ waitFor(type: MessageType, options?: { from?: string; taskId?: string; timeout?: number; }): Promise; /** * 获取未读消息数量 */ getUnreadCount(): Promise; /** * 清空邮箱 */ clear(): Promise; private loadMessages; private appendMessage; private markMessageIdsAsRead; private loadReadState; private saveReadState; private generateMessageId; } /** * 获取所有 Worker 的邮箱 */ export declare function getAllMailboxes(workerIds: string[], basePath?: string): Promise; //# sourceMappingURL=mailbox.d.ts.map