/** * Session Management for pause/resume support * Allows saving and restoring loop state across CLI invocations */ import type { Agent } from './agents.js'; import type { CircuitBreakerConfig } from './circuit-breaker.js'; import type { CostTrackerStats } from './cost-tracker.js'; /** * Session state that can be serialized and restored */ export interface SessionState { /** Unique session identifier */ id: string; /** Session creation timestamp */ createdAt: string; /** Last update timestamp */ updatedAt: string; /** Session status */ status: 'running' | 'paused' | 'completed' | 'failed'; /** Current iteration number */ iteration: number; /** Maximum iterations allowed */ maxIterations: number; /** The original task description */ task: string; /** Working directory */ cwd: string; /** Agent being used */ agent: { name: string; command: string; }; /** Options that were passed to the loop */ options: { auto?: boolean; commit?: boolean; push?: boolean; pr?: boolean; prTitle?: string; validate?: boolean; completionPromise?: string; requireExitSignal?: boolean; minCompletionIndicators?: number; circuitBreaker?: Partial; rateLimit?: number; trackProgress?: boolean; checkFileCompletion?: boolean; trackCost?: boolean; model?: string; }; /** Commits made so far */ commits: string[]; /** Accumulated statistics */ stats: { totalDuration: number; validationFailures: number; costStats?: CostTrackerStats; }; /** Reason for pausing (if paused) */ pauseReason?: string; /** Error message (if failed) */ error?: string; /** Last validation feedback (preserved for resume) */ lastValidationFeedback?: string; /** Exit reason */ exitReason?: 'completed' | 'blocked' | 'max_iterations' | 'circuit_breaker' | 'rate_limit' | 'file_signal' | 'paused'; } /** * Get the session file path for a directory */ export declare function getSessionPath(cwd: string): string; /** * Check if an active session exists */ export declare function hasActiveSession(cwd: string): Promise; /** * Load an existing session from disk */ export declare function loadSession(cwd: string): Promise; /** * Save session state to disk */ export declare function saveSession(session: SessionState): Promise; /** * Create a new session */ export declare function createSession(cwd: string, task: string, agent: Agent, options?: SessionState['options'], maxIterations?: number): SessionState; /** * Update session after an iteration */ export declare function updateSessionIteration(cwd: string, iteration: number, duration: number, commits: string[], costStats?: CostTrackerStats): Promise; /** * Pause the current session */ export declare function pauseSession(cwd: string, reason?: string, validationFeedback?: string): Promise; /** * Resume a paused session */ export declare function resumeSession(cwd: string): Promise; /** * Mark session as completed */ export declare function completeSession(cwd: string, exitReason: SessionState['exitReason'], error?: string): Promise; /** * Delete the session file */ export declare function deleteSession(cwd: string): Promise; /** * Get a summary of the session for display */ export declare function formatSessionSummary(session: SessionState): string; /** * Check if session can be resumed */ export declare function canResume(session: SessionState): boolean; /** * Check if session is still active (running or paused) */ export declare function isActiveSession(session: SessionState): boolean; /** * Calculate remaining iterations */ export declare function getRemainingIterations(session: SessionState): number; /** * Reconstruct agent object from session data */ export declare function reconstructAgent(session: SessionState): Agent; //# sourceMappingURL=session.d.ts.map