/** * SFTP Client using ssh2-streams transport */ import { EventEmitter } from 'events'; import { SSH2StreamsTransport, SSH2StreamsConfig } from '../ssh/ssh2-streams-transport'; import { FileAttributes, DirectoryEntry } from '../ssh/types'; export type { DirectoryEntry, FileAttributes } from '../ssh/types'; export interface KeepaliveConfig { enabled: boolean; interval?: number; maxMissed?: number; } export interface HealthCheckConfig { enabled: boolean; method?: 'ping' | 'realpath'; interval?: number; } export interface AutoReconnectConfig { enabled: boolean; maxAttempts?: number; delay?: number; backoff?: number; } export interface SFTPClientOptions extends SSH2StreamsConfig { connectTimeout?: number; operationTimeout?: number; chunkTimeout?: number; gracefulTimeout?: number; keepalive?: KeepaliveConfig; healthCheck?: HealthCheckConfig; autoReconnect?: AutoReconnectConfig; } export declare class SSH2StreamsSFTPClient extends EventEmitter { private transport; private sftpChannel; private requestId; private ready; private pendingRequests; private dataBuffer; private config; private operationCount; private bytesTransferred; private detectedOperationLimit; private detectedDataLimit; private lastLimitDetectionTime; private keepaliveTimer; private healthCheckTimer; private missedKeepalives; private isHealthy; private reconnectAttempts; private reconnecting; private lastReconnectError; private originalConnect; constructor(options: SFTPClientOptions); /** * Validate configuration options */ private validateConfig; private setupTransportHandlers; /** * Connect and initialize SFTP */ connect(): Promise; private setupSFTPHandlers; private initializeSFTP; private handleSFTPData; private handleSFTPPacket; private handleStatusPacket; private parseNamePacket; private parseFileAttributes; private sendSFTPRequest; /** * Open a file */ openFile(path: string, flags?: number): Promise; /** * Sync/flush a file to disk (forces write) */ syncFile(handle: Buffer): Promise; /** * Close a file */ closeFile(handle: Buffer): Promise; /** * Read file data */ readFile(handle: Buffer, offset: number, length: number, timeoutMs?: number): Promise; /** * List directory contents */ listDirectory(path: string): Promise; private openDirectory; private readDirectory; /** * Get file stats */ stat(path: string): Promise; /** * Write data to a file handle */ writeFile(handle: Buffer, offset: number, data: Buffer, timeoutMs?: number): Promise; /** * Remove a file */ removeFile(path: string): Promise; /** * Rename a file */ renameFile(oldPath: string, newPath: string): Promise; /** * Create a directory */ makeDirectory(path: string, attrs?: Partial): Promise; /** * Remove a directory */ removeDirectory(path: string): Promise; /** * Set file attributes */ setAttributes(path: string, attrs: Partial): Promise; /** * Get real path (resolve symbolic links) */ realPath(path: string): Promise; /** * Disconnect */ disconnect(): void; /** * Start SSH keepalive timer */ private startKeepalive; /** * Stop SSH keepalive timer */ private stopKeepalive; /** * Send SSH keepalive (ping) */ private sendKeepalive; /** * Start health check timer */ private startHealthCheck; /** * Stop health check timer */ private stopHealthCheck; /** * Perform connection health check */ private performHealthCheck; /** * Attempt automatic reconnection with proper termination logic */ private attemptReconnect; /** * Clean up pending requests on disconnect/reconnect */ private cleanupPendingRequests; /** * Get connection health status */ getHealthStatus(): { healthy: boolean; connected: boolean; ready: boolean; }; /** * Check if connected and ready */ isReady(): boolean; /** * Get current SSH channel window size for flow control */ getCurrentWindowSize(): number; /** * Report transfer metrics for adaptive performance tuning */ reportTransferMetrics(speedMBps: number, hadTimeout: boolean, responseTimeMs?: number): void; /** * Get transport reference for direct access to adaptive methods */ getTransport(): SSH2StreamsTransport; /** * Calculate safe concurrency based on SSH window size and chunk size */ getSafeConcurrency(chunkSize: number, maxConcurrency?: number): number; /** * Get optimal concurrency based on window size and performance testing */ getOptimalConcurrency(chunkSize: number): number; /** * Get maximum safe SFTP chunk size based on SSH packet limits */ getMaxSafeChunkSize(): number; /** * Track operation for limit detection */ private trackOperation; /** * Record server limit when timeout occurs */ recordServerLimit(operationCount: number, bytesTransferred: number): void; /** * Check if we're approaching server limits */ isApproachingLimit(): boolean; /** * Reset operation counters (call after reconnection) */ resetOperationCounters(): void; /** * Get current operation statistics */ getOperationStats(): { operations: number; bytesTransferred: number; mbTransferred: number; detectedLimits: { operations: number | null; bytes: number | null; }; }; } //# sourceMappingURL=ssh2-streams-client.d.ts.map