/** * File Organizer MCP Server v3.4.2 * Scheduler State Service * * Persists scheduler state to disk for smart catchup functionality. * Tracks last successful run timestamps per watched directory. */ /** * State entry for a single directory */ interface DirectoryState { /** ISO 8601 timestamp of last successful run */ lastRunTime: string; /** The cron schedule for this directory */ schedule: string; } /** * Root state file structure */ interface SchedulerState { /** Version for future migrations */ version: number; /** Map of directory paths to their state */ directories: Record; } /** * Service for persisting and retrieving scheduler state */ export declare class SchedulerStateService { private stateFilePath; private state; private initialized; /** * Create a new SchedulerStateService * @param stateFilePath - Optional custom path for state file */ constructor(stateFilePath?: string); /** * Get the default path for the state file * Uses the same directory as user config */ private getDefaultStateFilePath; /** * Create an empty state object */ private createEmptyState; /** * Initialize the service by loading state from disk * Must be called before other methods */ initialize(): Promise; /** * Ensure the service is initialized */ private ensureInitialized; /** * Load state from disk. * * SECURITY JUSTIFICATION (SEC-016): * The state file path (stateFilePath) is internal to the application - it is stored * in the application's private config directory (%APPDATA%, ~/Library/Application Support, * or ~/.config). JSON.parse is safe here because: * 1. The file is written only by this application using JSON.stringify() * 2. The file is stored in an OS-protected user directory not accessible to other processes * 3. The parsed data is validated by isValidState() before use, ensuring the structure * matches the expected SchedulerState type */ private loadState; /** * Save state to disk */ private saveState; /** * Validate the state object structure */ private isValidState; /** * Migrate state to current version if needed */ private migrateState; /** * Normalize directory path for consistent storage */ private normalizeDirectory; /** * Get the last run time for a directory * @param directory - The directory path * @returns The last run time, or null if never ran */ getLastRunTime(directory: string): Date | null; /** * Set the last run time for a directory * @param directory - The directory path * @param timestamp - The run timestamp (defaults to now) * @param schedule - The cron schedule for this directory */ setLastRunTime(directory: string, timestamp?: Date, schedule?: string): Promise; /** * Get the stored schedule for a directory * @param directory - The directory path * @returns The schedule string, or empty string if not found */ getSchedule(directory: string): string; /** * Clear state for a specific directory * @param directory - The directory path */ clearDirectoryState(directory: string): Promise; /** * Clear all state */ clearState(): Promise; /** * Get all tracked directories * @returns Array of directory paths */ getTrackedDirectories(): string[]; /** * Get the full state (for debugging/testing) * @returns A copy of the current state */ getState(): SchedulerState; /** * Get the state file path (for debugging/testing) * @returns The path to the state file */ getStateFilePath(): string; } /** * Get or create the global scheduler state service instance * @returns The global SchedulerStateService instance */ export declare function getSchedulerStateService(): Promise; /** * Reset the global scheduler state service (useful for testing) */ export declare function resetSchedulerStateService(): void; export {}; //# sourceMappingURL=scheduler-state.service.d.ts.map