/** * File Watcher for Reactive Workflows * * Enables the orchestrator to: * - Watch directories/files for changes * - Trigger callbacks on file events * - Support glob patterns for filtering * - Debounce rapid changes */ import { EventEmitter } from 'events'; export type FileEventType = 'add' | 'change' | 'unlink' | 'addDir' | 'unlinkDir'; export interface FileEvent { type: FileEventType; path: string; timestamp: string; } export interface WatchRule { id: string; pattern: string; events: FileEventType[]; action: string; debounceMs?: number; enabled: boolean; lastTriggered?: string; } export interface WatcherConfig { rulesFile: string; defaultDebounce: number; } export declare class FileWatcher extends EventEmitter { private watchers; private rules; private debounceTimers; private config; private rulesFile; constructor(workspaceDir: string, config?: Partial); /** * Add a watch rule */ addRule(rule: Omit): string; /** * Remove a watch rule */ removeRule(id: string): boolean; /** * Enable/disable a rule */ toggleRule(id: string, enabled: boolean): boolean; /** * List all rules */ listRules(): WatchRule[]; /** * Get a specific rule */ getRule(id: string): WatchRule | undefined; /** * Watch a specific path */ watch(targetPath: string, callback: (event: FileEvent) => void): string; /** * Stop watching a specific watcher */ unwatch(watcherId: string): void; /** * Stop all watchers */ stopAll(): void; /** * Get watcher status */ status(): { activeWatchers: number; rules: number; enabledRules: number; }; private watchDirectory; private watchFile; private determineEventType; private startWatching; private stopWatching; private loadRules; private saveRules; } /** * Common watch patterns for development workflows */ export declare const COMMON_PATTERNS: { typescript: { pattern: string; events: FileEventType[]; action: string; }; tests: { pattern: string; events: FileEventType[]; action: string; }; config: { pattern: string; events: FileEventType[]; action: string; }; markdown: { pattern: string; events: FileEventType[]; action: string; }; };