/** * BackgroundSyncService - Session-based automatic sync * * Runs sync operations during active MCP server sessions based on * user-configured frequency (daily/weekly). Uses non-blocking timers * that don't prevent process exit. */ import type { SyncEngine, SyncResult } from './SyncEngine.js'; import type { SyncConfigRepository } from '../repositories/SyncConfigRepository.js'; /** * Background sync service options */ export interface BackgroundSyncOptions { /** Check interval in ms (default: 60000 = 1 minute) */ checkIntervalMs?: number; /** Run sync immediately on start if due */ syncOnStart?: boolean; /** Callback when sync completes */ onSyncComplete?: (result: SyncResult) => void; /** Callback when sync fails */ onSyncError?: (error: Error) => void; /** Enable debug logging */ debug?: boolean; } /** * Service state */ export interface BackgroundSyncState { isStarted: boolean; isRunning: boolean; lastResult: SyncResult | null; lastError: Error | null; checksPerformed: number; syncsTriggered: number; } /** * Background sync service for automatic registry synchronization */ export declare class BackgroundSyncService { private syncEngine; private configRepo; private options; private timer; private isRunning; private isStopped; private abortController; private inFlightSync; private state; constructor(syncEngine: SyncEngine, configRepo: SyncConfigRepository, options?: BackgroundSyncOptions); private log; /** * Start the background sync service */ start(): void; /** * Stop the background sync service. * * SMI-5649: returns `Promise` (was `void`, fire-and-forget) so a * caller — namely the shutdown coordinator — can await settlement of any * in-flight sync before proceeding to close the database. Non-awaiting * callers still get the synchronous timer-clear + abort-signal behavior * unchanged, since steps 1-2 below run before any `await` point. */ stop(): Promise; /** * Check if sync should run now */ private shouldSyncNow; /** * Check if sync is due and trigger if needed */ private checkAndSync; /** * Trigger a sync operation */ private triggerSync; /** * Manually trigger a sync (for testing or manual intervention) */ manualSync(): Promise; /** * Get current service state */ getState(): BackgroundSyncState; /** * Check if service is actively running syncs */ isSyncRunning(): boolean; /** * Check if service is started */ isServiceStarted(): boolean; } /** * Create and start a background sync service */ export declare function createBackgroundSyncService(syncEngine: SyncEngine, configRepo: SyncConfigRepository, options?: BackgroundSyncOptions): BackgroundSyncService; //# sourceMappingURL=BackgroundSyncService.d.ts.map