Move src/ → apps/server/ and packages/web/ → apps/web/ to adopt standard monorepo conventions (apps/ for runnable apps, packages/ for reusable libraries). Update all config files, shared package imports, test fixtures, and documentation to reflect new paths. Key fixes: - Update workspace config to ["apps/*", "packages/*"] - Update tsconfig.json rootDir/include for apps/server/ - Add apps/web/** to vitest exclude list - Update drizzle.config.ts schema path - Fix ensure-schema.ts migration path detection (3 levels up in dev, 2 levels up in dist) - Fix tests/integration/cli-server.test.ts import paths - Update packages/shared imports to apps/server/ paths - Update all docs/ files with new paths
58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
/**
|
|
* 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';
|
|
|
|
export interface LifecycleFactoryOptions {
|
|
repository: AgentRepository;
|
|
processManager: ProcessManager;
|
|
cleanupManager: CleanupManager;
|
|
accountRepository?: AccountRepository;
|
|
debug?: boolean;
|
|
}
|
|
|
|
/**
|
|
* Create a fully configured AgentLifecycleController with all dependencies.
|
|
*/
|
|
export function createLifecycleController(options: LifecycleFactoryOptions): AgentLifecycleController {
|
|
const {
|
|
repository,
|
|
processManager,
|
|
cleanupManager,
|
|
accountRepository,
|
|
debug = false
|
|
} = 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
|
|
);
|
|
|
|
return lifecycleController;
|
|
} |