/** * Disk Space Utilities * * Provides disk space checking functionality for indexing operations. * Helps prevent disk full errors during indexing by checking available * space before starting. * * Note: statfs may not work on all platforms (especially Windows and network drives). * Falls back gracefully when unavailable. */ /** * Minimum required free space for indexing operations (100MB) * This accounts for LanceDB storage, fingerprints, and metadata */ export declare const MIN_REQUIRED_SPACE_BYTES: number; /** * Safety buffer multiplier for estimated space requirements * We require 10% more than estimated to be safe */ export declare const SPACE_BUFFER_MULTIPLIER = 1.1; /** * Estimated bytes per file for indexing * Based on average chunk size and embedding storage */ export declare const ESTIMATED_BYTES_PER_FILE: number; /** * Result of disk space check */ export interface DiskSpaceInfo { /** Available bytes on the filesystem */ available: number; /** Total bytes on the filesystem */ total: number; /** Used bytes on the filesystem */ used: number; /** Whether the check was successful */ success: boolean; /** Error message if check failed */ error?: string; } /** * Result of disk space validation */ export interface DiskSpaceValidation { /** Whether there is sufficient space */ sufficient: boolean; /** Available space in bytes */ availableBytes: number; /** Required space in bytes */ requiredBytes: number; /** Warning message if space is low but not critical */ warning?: string; } /** * Check available disk space at a given path * * Uses Node.js statfs to get filesystem statistics. * Falls back gracefully if statfs is not available (some platforms/network drives). * * @param path - Path to check (usually the index directory) * @returns DiskSpaceInfo with available, total, and used space */ export declare function checkDiskSpace(path: string): Promise; /** * Estimate required disk space for indexing a number of files * * @param fileCount - Number of files to be indexed * @returns Estimated bytes required */ export declare function estimateRequiredSpace(fileCount: number): number; /** * Check if there is sufficient disk space for indexing * * @param path - Path to check (usually the index directory) * @param fileCount - Number of files to be indexed (optional, for estimation) * @returns DiskSpaceValidation with sufficiency status */ export declare function hasSufficientSpace(path: string, fileCount?: number): Promise; /** * Validate disk space and throw error if insufficient * * @param path - Path to check (usually the index directory) * @param fileCount - Number of files to be indexed (optional) * @throws MCPError with DISK_FULL code if insufficient space */ export declare function validateDiskSpace(path: string, fileCount?: number): Promise; /** * Format bytes to human-readable string * * @param bytes - Size in bytes * @returns Human-readable string like "45MB", "1.2GB" */ export declare function formatBytes(bytes: number): string; /** * Default interval for disk space checks during indexing (5 seconds) */ export declare const DEFAULT_DISK_CHECK_INTERVAL_MS = 5000; /** * Critical disk space threshold - abort if below this (50MB) */ export declare const CRITICAL_DISK_SPACE_BYTES: number; /** * Result of a disk space monitor check */ export interface DiskMonitorResult { /** Whether there is sufficient space to continue */ sufficient: boolean; /** Available bytes at time of check */ availableBytes: number; /** Error message if space is critical */ error?: string; } /** * Callback type for disk space monitor * Return false from callback to stop monitoring */ export type DiskMonitorCallback = (result: DiskMonitorResult) => boolean | Promise; /** * Handle to control disk space monitoring */ export interface DiskMonitorHandle { /** Stop the monitor */ stop: () => void; /** Check if the monitor is still running */ isRunning: () => boolean; /** Get the last check result */ getLastResult: () => DiskMonitorResult | null; } /** * SMCP-057: Start continuous disk space monitoring during long operations * * Periodically checks disk space and calls the provided callback with results. * Automatically stops if space becomes critical or if the callback returns false. * * @param indexPath - Path to check disk space for * @param callback - Callback to receive monitoring results * @param intervalMs - Check interval in milliseconds (default: 5000ms) * @returns Handle to control the monitor * * @example * ```typescript * const monitor = startDiskSpaceMonitor( * indexPath, * (result) => { * if (!result.sufficient) { * console.error('Disk space critical:', result.error); * return false; // Stop monitoring * } * return true; // Continue monitoring * }, * 5000 // Check every 5 seconds * ); * * // Later, when operation completes: * monitor.stop(); * ``` */ export declare function startDiskSpaceMonitor(indexPath: string, callback: DiskMonitorCallback, intervalMs?: number): DiskMonitorHandle; /** * SMCP-057: Check disk space once and abort if critical * * Convenience function for one-time disk space check with abort on critical. * * @param path - Path to check disk space for * @throws MCPError with DISK_FULL code if space is critical */ export declare function checkDiskSpaceAndAbort(path: string): Promise; //# sourceMappingURL=diskSpace.d.ts.map