/** * Smart WebSocket - 83% token reduction through intelligent message tracking * * Features: * - WebSocket connection lifecycle management * - Message history tracking with deduplication * - Reconnection with exponential backoff * - Message pattern detection * - Connection health monitoring * - Bandwidth usage analysis * - Event stream summaries */ import { CacheEngine } from '../../core/cache-engine.js'; import { TokenCounter } from '../../core/token-counter.js'; import { MetricsCollector } from '../../core/metrics.js'; export interface SmartWebSocketOptions { url: string; protocols?: string[]; action: 'connect' | 'disconnect' | 'send' | 'history' | 'analyze'; message?: string | object; trackMessages?: boolean; detectPatterns?: boolean; analyzeHealth?: boolean; maxHistory?: number; maxReconnectAttempts?: number; force?: boolean; ttl?: number; } export interface Message { id: string; timestamp: number; direction: 'sent' | 'received'; type: string; size: number; content?: any; hash: string; } export interface MessageType { type: string; count: number; averageSize: number; frequency: number; } export interface SmartWebSocketResult { connection: { url: string; state: 'connecting' | 'connected' | 'disconnecting' | 'disconnected' | 'error'; protocol?: string; uptime?: number; reconnectAttempts?: number; }; history?: { total: number; sent: number; received: number; recent: Message[]; }; patterns?: { messageTypes: MessageType[]; averageSize: number; frequency: number; bandwidth: number; }; health?: { score: number; latency: number; reconnects: number; errors: number; }; cached: boolean; metrics: { originalTokens: number; compactedTokens: number; reductionPercentage: number; }; } export declare class SmartWebSocket { private cache; private tokenCounter; private metrics; private connections; private messageIdCounter; constructor(cache: CacheEngine, tokenCounter: TokenCounter, metrics: MetricsCollector); run(options: SmartWebSocketOptions): Promise; private executeAction; private connect; private disconnect; private sendMessage; private getHistory; private analyzeConnection; private analyzeMessagePatterns; private analyzeConnectionHealth; private transformOutput; private generateCacheKey; private getCachedResult; private cacheResult; private getUrlKey; private detectMessageType; private hashMessage; private calculateBackoff; private sleep; } export declare function getSmartWebSocket(cache: CacheEngine, tokenCounter: TokenCounter, metrics: MetricsCollector): SmartWebSocket; export declare function runSmartWebSocket(options: SmartWebSocketOptions): Promise; export declare const SMART_WEBSOCKET_TOOL_DEFINITION: { name: string; description: string; inputSchema: { type: string; properties: { url: { type: string; description: string; }; protocols: { type: string; items: { type: string; }; description: string; }; action: { type: string; enum: string[]; description: string; }; message: { description: string; }; trackMessages: { type: string; description: string; }; detectPatterns: { type: string; description: string; }; analyzeHealth: { type: string; description: string; }; maxHistory: { type: string; description: string; }; maxReconnectAttempts: { type: string; description: string; }; force: { type: string; description: string; }; ttl: { type: string; description: string; }; }; required: string[]; }; }; //# sourceMappingURL=smart-websocket.d.ts.map