/** * Smart Network Tool - Network Diagnostics and Monitoring * * Provides intelligent network analysis with: * - Connectivity testing * - Latency measurement * - Port scanning * - DNS resolution * - Token-optimized output */ import { CacheEngine } from '../../core/cache-engine.js'; interface SmartNetworkOptions { /** * Network operation to perform */ operation: 'ping' | 'port-scan' | 'dns' | 'traceroute' | 'all'; /** * Hosts to test (for ping/port-scan operations) */ hosts?: string[]; /** * Ports to scan (for port-scan operation) */ ports?: number[]; /** * Hostnames for DNS resolution */ hostnames?: string[]; /** * Number of ping attempts per host */ pingCount?: number; /** * Timeout in milliseconds */ timeout?: number; /** * Project root directory */ projectRoot?: string; /** * Maximum cache age in seconds (default: 300 = 5 minutes) */ maxCacheAge?: number; } interface SmartNetworkOutput { /** * Summary */ summary: { success: boolean; operation: string; hostsChecked: number; reachableHosts: number; duration: number; fromCache: boolean; }; /** * Connectivity results */ connectivity: Array<{ host: string; reachable: boolean; latency?: number; status: 'online' | 'offline' | 'timeout'; }>; /** * Port scan results */ ports?: Array<{ host: string; port: number; open: boolean; service?: string; }>; /** * DNS resolution results */ dns?: Array<{ hostname: string; addresses: string[]; resolved: boolean; }>; /** * Latency statistics */ latencyStats?: { min: number; max: number; avg: number; distribution: string; }; /** * Network diagnostics */ diagnostics: Array<{ type: 'connectivity' | 'dns' | 'performance'; message: string; severity: 'critical' | 'warning' | 'info'; }>; /** * Recommendations */ recommendations: Array<{ type: 'connectivity' | 'performance' | 'configuration'; message: string; impact: 'high' | 'medium' | 'low'; }>; /** * Token reduction metrics */ metrics: { originalTokens: number; compactedTokens: number; reductionPercentage: number; }; } export declare class SmartNetwork { private cache; private cacheNamespace; constructor(cache: CacheEngine, _projectRoot?: string); /** * Run network diagnostics */ run(options: SmartNetworkOptions): Promise; /** * Run network operation */ private runNetworkOperation; /** * Ping hosts */ private pingHosts; /** * Ping a single host */ private pingHost; /** * Parse ping latency from output */ private parsePingLatency; /** * Scan ports on hosts */ private scanPorts; /** * Check if a port is open */ private checkPort; /** * Get service name for common ports */ private getServiceName; /** * Resolve DNS for hostnames */ private resolveDns; /** * Calculate latency statistics */ private calculateLatencyStats; /** * Generate diagnostics */ private generateDiagnostics; /** * Generate recommendations */ private generateRecommendations; /** * Generate cache key */ private generateCacheKey; /** * Get cached result */ private getCachedResult; /** * Cache result */ private cacheResult; /** * Transform to smart output */ private transformOutput; /** * Get latency distribution description */ private getLatencyDistribution; /** * Format cached output */ private formatCachedOutput; /** * Estimate original output size */ private estimateOriginalOutputSize; /** * Estimate compact output size */ private estimateCompactSize; /** * Close cache connection */ close(): void; } /** * Factory function for dependency injection */ export declare function getSmartNetwork(cache: CacheEngine, projectRoot?: string): SmartNetwork; /** * CLI-friendly function for running smart network diagnostics */ export declare function runSmartNetwork(options: SmartNetworkOptions): Promise; export declare const SMART_NETWORK_TOOL_DEFINITION: { name: string; description: string; inputSchema: { type: string; properties: { operation: { type: string; enum: string[]; description: string; }; hosts: { type: string; items: { type: string; }; description: string; }; ports: { type: string; items: { type: string; }; description: string; }; hostnames: { type: string; items: { type: string; }; description: string; }; pingCount: { type: string; description: string; default: number; }; timeout: { type: string; description: string; default: number; }; projectRoot: { type: string; description: string; }; maxCacheAge: { type: string; description: string; default: number; }; }; required: string[]; }; }; export {}; //# sourceMappingURL=smart-network.d.ts.map