/** * Lifecycle Factory — Wire up all lifecycle components with proper dependencies. * * Creates and configures the complete lifecycle management system with all * dependencies properly injected. Provides simple entry point for integration. */ import { FileSystemSignalManager } from './signal-manager.js'; import { DefaultRetryPolicy } from './retry-policy.js'; import { AgentErrorAnalyzer } from './error-analyzer.js'; import { DefaultCleanupStrategy } from './cleanup-strategy.js'; import { AgentLifecycleController } from './controller.js'; import type { AgentRepository } from '../../db/repositories/agent-repository.js'; import type { AccountRepository } from '../../db/repositories/account-repository.js'; import type { ProcessManager } from '../process-manager.js'; import type { CleanupManager } from '../cleanup-manager.js'; import type { EventBus } from '../../events/types.js'; export interface LifecycleFactoryOptions { repository: AgentRepository; processManager: ProcessManager; cleanupManager: CleanupManager; accountRepository?: AccountRepository; debug?: boolean; eventBus?: EventBus; } /** * Create a fully configured AgentLifecycleController with all dependencies. */ export function createLifecycleController(options: LifecycleFactoryOptions): AgentLifecycleController { const { repository, processManager, cleanupManager, accountRepository, debug = false, eventBus, } = options; // Create core components const signalManager = new FileSystemSignalManager(); const retryPolicy = new DefaultRetryPolicy(); const errorAnalyzer = new AgentErrorAnalyzer(signalManager); const cleanupStrategy = new DefaultCleanupStrategy(cleanupManager); // Wire up the main controller const lifecycleController = new AgentLifecycleController( signalManager, retryPolicy, errorAnalyzer, processManager, repository, cleanupManager, cleanupStrategy, accountRepository, debug, eventBus, ); return lifecycleController; }