/** * NotificationCenter — 通知中心 * * 统一管理 Agent 的各类通知: * 1. 任务完成通知 * 2. 错误/异常告警 * 3. 定时提醒 * 4. 系统状态变更 * 5. 多渠道推送(内存/WebSocket/Telegram/Webhook) */ export type NotificationType = "info" | "success" | "warning" | "error" | "reminder" | "task"; export type NotificationChannel = "internal" | "websocket" | "telegram" | "webhook"; export interface Notification { id: string; type: NotificationType; title: string; message: string; read: boolean; timestamp: string; source?: string; metadata?: Record; actions?: NotificationAction[]; } export interface NotificationAction { label: string; action: string; params?: Record; } export interface NotificationRule { id: string; event: string; type: NotificationType; titleTemplate: string; messageTemplate: string; channels: NotificationChannel[]; enabled: boolean; } export interface NotificationCenterConfig { dataPath: string; maxNotifications: number; channels: NotificationChannel[]; webhookUrl?: string; telegramChatId?: string; } export declare class NotificationCenter { private config; private notifications; private rules; /** 推送回调(由外部设置,如 WebSocket) */ private pushHandlers; constructor(config?: Partial); /** 发送通知 */ notify(type: NotificationType, title: string, message: string, options?: { source?: string; metadata?: Record; actions?: NotificationAction[]; channels?: NotificationChannel[]; }): Notification; /** 快捷:成功通知 */ success(title: string, message: string, source?: string): Notification; /** 快捷:错误通知 */ error(title: string, message: string, source?: string): Notification; /** 快捷:警告通知 */ warning(title: string, message: string, source?: string): Notification; /** 快捷:任务通知 */ task(title: string, message: string, actions?: NotificationAction[]): Notification; /** 快捷:提醒 */ reminder(title: string, message: string): Notification; /** 根据事件名自动匹配规则并发送通知 */ triggerByEvent(eventName: string, data?: Record): Notification | null; getAll(limit?: number): Notification[]; getUnread(): Notification[]; getUnreadCount(): number; getByType(type: NotificationType, limit?: number): Notification[]; markRead(id: string): boolean; markAllRead(): void; delete(id: string): boolean; clear(): void; registerChannel(channel: NotificationChannel, handler: (n: Notification) => void): void; addRule(rule: NotificationRule): void; getRules(): NotificationRule[]; private initDefaultRules; private matchEvent; private applyTemplate; private load; private save; } //# sourceMappingURL=center.d.ts.map