/** * File Watcher Service * * Provides robust cross-platform file watching using Chokidar library. * Handles file watching with debouncing, error recovery, and graceful fallbacks. */ import { EventEmitter } from "events"; import type { Logger } from "../types/index.js"; export interface FileWatchEvent { type: "change" | "create" | "delete" | "rename"; path: string; timestamp: number; size?: number; } export interface FileWatcherConfig { stabilityThreshold: number; pollInterval: number; maxRetries: number; fallbackPolling: boolean; ignoreTempFiles: boolean; depth: number; ignored: string[]; } export interface FileWatcherStatus { isActive: boolean; path: string; method: "native" | "polling" | "failed"; errorCount: number; lastError?: string; lastEvent?: FileWatchEvent; } export declare class FileWatcherService extends EventEmitter { private watchers; private globalWatcher; private defaultConfig; private logger?; constructor(logger?: Logger, config?: Partial); /** * Start watching a file * Maps to FR-010: Handle file deletion, creation, and modification */ watchFile(path: string, callback: (event: FileWatchEvent) => void): Promise; /** * Stop watching a file * Resource cleanup */ unwatchFile(path: string): Promise; /** * Get watcher status * Maps to FR-012: Handle watcher initialization failures */ getWatcherStatus(path: string): FileWatcherStatus | null; /** * Get all watcher statuses * For monitoring and debugging */ getAllWatcherStatuses(): FileWatcherStatus[]; /** * Cleanup all watchers */ cleanup(): Promise; private initializeWatcher; private setupGlobalWatcherEvents; private handleFileEvent; }