/** * Startup Coordinator * * Handles server initialization including: * - State persistence loading * - Recovery from previous crashes * - Component initialization in correct order */ import { StateStore } from './persistence/state-store.js'; import { type ReconciliationResult } from './worktrees/recovery.js'; /** * Configuration for startup initialization. */ export interface StartupConfig { /** Path to the git repository root */ repoPath: string; /** Base directory for worktrees (relative to repoPath) */ worktreeBaseDir?: string; /** Branch name pattern for task branches */ branchPattern?: string; /** Whether to run recovery on startup (default: true) */ autoRecover?: boolean; /** Whether to automatically clean up orphaned resources (default: false) */ autoCleanOrphans?: boolean; } /** * Result of the startup initialization process. */ export interface StartupResult { /** The initialized state store */ stateStore: StateStore; /** Result of the recovery process (if recovery was run) */ recoveryResult?: ReconciliationResult; /** Warnings encountered during startup */ warnings: string[]; } /** * Initialize Hari Seldon with state persistence and recovery. * * Call this early in the server startup process to: * 1. Load persisted state from disk * 2. Reconcile state with physical worktrees * 3. Clean up orphaned resources (if autoCleanOrphans is true) * * @param config - Startup configuration options * @returns Promise resolving to the startup result * * @example * ```typescript * const { stateStore, recoveryResult, warnings } = await initializeWithRecovery({ * repoPath: process.cwd(), * autoRecover: true, * }); * * if (warnings.length > 0) { * console.warn('Startup warnings:', warnings); * } * ``` */ export declare function initializeWithRecovery(config: StartupConfig): Promise; /** * Gracefully shutdown the state store, ensuring final state is persisted. * * Call this before process exit to ensure no state is lost. * * @param stateStore - The state store to shutdown * @param repoPath - Path to the repository root * * @example * ```typescript * process.on('SIGINT', async () => { * await shutdown(stateStore, repoPath); * process.exit(0); * }); * ``` */ export declare function shutdown(stateStore: StateStore, repoPath: string): Promise; //# sourceMappingURL=startup.d.ts.map