/** * Cleanup registry for CCS CLI * * Manages cleanup callbacks that should be run on exit or error. * Used to clean up resources like: * - Spawned processes (proxies, child processes) * - Temporary files * - Network connections * - Open file handles */ /** * Cleanup callback type * Callbacks should be synchronous and non-throwing */ export type CleanupCallback = () => void; /** * Register a cleanup callback * Callbacks are executed in LIFO order (stack-like behavior) * * @param fn - Cleanup function to register * @returns Unregister function to remove the callback */ export declare function registerCleanup(fn: CleanupCallback): () => void; /** * Run all registered cleanup callbacks * Executes in LIFO order, catches and logs individual errors * Can only be run once per process */ export declare function runCleanup(): void; /** * Clear all registered cleanup callbacks * Primarily used for testing */ export declare function clearCleanup(): void; /** * Get the number of registered cleanup callbacks * Primarily used for testing */ export declare function getCleanupCount(): number; /** * Check if cleanup has already run * Primarily used for testing */ export declare function hasCleanupRun(): boolean; /** * Create a cleanup scope for automatic resource management * Resources registered within the scope are cleaned up when done * * @example * ```typescript * const scope = createCleanupScope(); * scope.register(() => process.kill()); * try { * // ... do work * } finally { * scope.cleanup(); * } * ``` */ export declare function createCleanupScope(): { register: (fn: CleanupCallback) => void; cleanup: () => void; }; //# sourceMappingURL=cleanup-registry.d.ts.map