/** * State Manager Service * * Handles atomic state operations with backup/restore capability * and resource locking to prevent race conditions between * CLI operations and FileWatcher updates. */ import type { OrchestratorContext } from '../interfaces/orchestrator-context.js'; import type { OrchestratorService, ServiceContainer } from '../interfaces/service-container.js'; /** * Resource types that can be locked */ export type ResourceType = 'skill' | 'photon' | 'mcp'; /** * State Manager Service * * Provides: * - Atomic state operations with backup/restore * - Resource locking to prevent race conditions * - State snapshot and restoration */ export declare class StateManager implements OrchestratorService { private context; private container; private stateBackup; private lockedResources; private resourceLockQueues; constructor(context: OrchestratorContext, container: ServiceContainer); /** * Save current state for atomic operations * Used to enable rollback if an operation fails */ saveState(): void; /** * Restore previous state after a failed operation * Ensures consistency if skill/photon update fails */ restoreState(): void; /** * Clear the state backup after successful operation */ clearStateBackup(): void; /** * Check if there's a pending state backup */ hasStateBackup(): boolean; /** * Get the timestamp of the current backup (if any) */ getBackupTimestamp(): number | null; /** * Acquire lock for a resource to prevent conflicts * * Returns immediately if resource is not locked. * Queues operation if resource is currently locked. * * @param resourceType - Type of resource (skill, photon, mcp) * @param resourceName - Name of the specific resource */ acquireLock(resourceType: ResourceType, resourceName: string): Promise; /** * Release lock for a resource and process any queued operations * * @param resourceType - Type of resource (skill, photon, mcp) * @param resourceName - Name of the specific resource */ releaseLock(resourceType: ResourceType, resourceName: string): void; /** * Check if a resource is currently locked */ isLocked(resourceType: ResourceType, resourceName: string): boolean; /** * Get count of queued operations for a resource */ getQueuedOperationsCount(resourceType: ResourceType, resourceName: string): number; /** * Execute an operation atomically with automatic rollback on failure * * @param resourceType - Type of resource being modified * @param resourceName - Name of the specific resource * @param operation - Async operation to execute * @returns Result of the operation */ executeAtomic(resourceType: ResourceType, resourceName: string, operation: () => Promise): Promise; /** * Cleanup - release all locks and clear queues */ cleanup(): Promise; } /** * Factory function for creating StateManager */ export declare function createStateManager(context: OrchestratorContext, container: ServiceContainer): StateManager; //# sourceMappingURL=state-manager.d.ts.map