import type { FileContent } from '../../types.js'; /** * Files Module - Implements 10 file operation tools with workspace path validation * All operations are constrained to the workspace path */ export declare class FilesModule { private workspacePath; constructor(workspacePath: string); /** * Unified files tool: maps actions to existing granular methods */ useFiles(params: unknown): Promise; /** * Validates that a path is within the workspace * * Security measures (2025 best practices): * 1. Resolves symlinks using fs.realpath to prevent symlink escape * 2. Uses path.relative to prevent sibling directory bypass * 3. Checks for '..' in relative path to catch parent/sibling escapes * * Prevents: * - Symlink escape (e.g., workspace/link -> /etc/passwd) * - Sibling bypass (e.g., ../workspace-backup/secret.txt) * - Parent traversal (e.g., ../../etc/passwd) */ private validatePath; /** * Read File - Reads file contents with optional offset/limit * v9.0.1: Enhanced with image and PDF support */ readFile(params: unknown): Promise; /** * Write File - Writes or appends content to a file */ writeFile(params: unknown): Promise<{ success: boolean; bytes_written: number; }>; /** * Edit Block - Performs surgical text replacements in files */ editBlock(params: unknown): Promise<{ success: boolean; replacements: number; message: string; }>; /** * Helper to escape special regex characters */ private escapeRegex; /** * List Directory - Lists files and directories */ listDirectory(params: unknown): Promise>; /** * Directory Tree - Builds a recursive directory tree structure */ directoryTree(params: unknown): Promise<{ name: string; type: 'file' | 'directory'; children?: unknown[]; }>; /** * Recursively builds directory tree structure * SECURITY: Uses lstat and validatePath to prevent symlink traversal * outside workspace that would disclose external directory structure */ private buildTree; /** * Create Directory - Creates a directory (with parents if needed) */ createDirectory(params: unknown): Promise<{ success: boolean; path: string; }>; /** * Delete File - Deletes a file or directory */ deleteFile(params: unknown): Promise<{ success: boolean; path: string; }>; /** * Copy File - Copies a file or directory */ copyFile(params: unknown): Promise<{ success: boolean; source: string; destination: string; }>; /** * Recursively copies a directory * SECURITY: Uses lstat to detect symlinks and refuses to copy them * to prevent materializing external files inside the workspace */ private copyRecursive; /** * Move File - Moves or renames a file or directory */ moveFile(params: unknown): Promise<{ success: boolean; source: string; destination: string; }>; /** * Get File Info - Retrieves file metadata */ getFileInfo(params: unknown): Promise<{ path: string; type: 'file' | 'directory'; size: number; created: string; modified: string; permissions: string; }>; } //# sourceMappingURL=index.d.ts.map