/** * Utility class for SSH operations * * Provides methods for interacting with remote servers via SSH. */ export declare class SshUtils { private sshKeyPath; private remoteUser; private remoteHost; private remotePath; private debugMode; private strictHostKeyChecking; /** * Creates a new SshUtils instance * * @param sshKeyPath - Path to the SSH private key file * @param remoteUser - Username for the remote server * @param remoteHost - Hostname or IP address of the remote server * @param remotePath - Base path on the remote server for memory bank storage * @param options - Optional configuration (debugMode, strictHostKeyChecking) */ constructor(sshKeyPath: string, remoteUser: string, remoteHost: string, remotePath: string, options?: { debugMode?: boolean; strictHostKeyChecking?: boolean; }); /** * Validates an SSH identifier (user or host) to prevent option injection. * Rejects values that start with `-` or contain whitespace/control characters. */ private static validateSshIdentifier; /** * Executes an SSH command on the remote server. * * Uses `execFile` with an argv array so the local shell is never invoked, * preventing command-injection via user-controlled values (key path, host, * user, remote command). The *remote* command is passed as a single SSH * positional argument and interpreted by the remote shell. * * @param command - Command to execute on the remote side * @returns Promise that resolves with command output */ private executeCommand; /** * Checks if a remote path exists (file or directory) * * @param remotePath - Path to check (relative to base remote path) * @returns True if the path exists, false otherwise */ exists(remotePath: string): Promise; /** * Checks if a remote directory exists * * @param dirPath - Path to check * @returns True if the directory exists, false otherwise */ directoryExists(dirPath: string): Promise; /** * Checks if a remote path is a file * * @param filePath - Path to check * @returns True if the path is a file, false otherwise */ isFile(filePath: string): Promise; /** * Checks if a remote path is a directory * * @param dirPath - Path to check * @returns True if the path is a directory, false otherwise */ isDirectory(dirPath: string): Promise; /** * Creates a directory on the remote server * * @param dirPath - Path to create * @throws Error if directory creation fails */ createDirectory(dirPath: string): Promise; /** * Reads a file from the remote server * * @param filePath - Path to the file * @returns The file contents as a string * @throws Error if file reading fails */ readFile(filePath: string): Promise; /** * Writes content to a file on the remote server atomically * * Uses a write-to-temp-then-mv pattern for atomic writes. * This prevents file corruption if the connection drops during write. * * @param filePath - Path to the file (relative to remotePath) * @param content - Content to write * @throws Error if file writing fails */ writeFile(filePath: string, content: string): Promise; /** * Lists files in a remote directory * * @param dirPath - Path to the directory * @returns Array of file names * @throws Error if directory reading fails */ listFiles(dirPath: string): Promise; /** * Deletes a file on the remote server * * @param filePath - Path to the file * @throws Error if file deletion fails */ deleteFile(filePath: string): Promise; /** * Copies a file or directory on the remote server * * @param sourcePath - Source path * @param destPath - Destination path * @throws Error if copy operation fails */ copy(sourcePath: string, destPath: string): Promise; /** * Tests the SSH connection to the remote server * * @returns True if connection is successful, false otherwise */ testConnection(): Promise; } //# sourceMappingURL=SshUtils.d.ts.map