/** * Global Write Lock - Robust streaming-safe output coordination * * This module provides a thread-safe mechanism to ensure streaming content * is not interrupted by other UI components during streaming. * * Design Principles: * - During streaming, ONLY streaming content writes to stdout * - All other UI components (status, input area, etc.) wait until streaming ends * - Supports nested/re-entrant locking with reference counting * - Provides timeout-based automatic unlock for safety * * This prevents the garbled output and cutoffs that occur when multiple * components try to write simultaneously with cursor positioning. */ /** * Check if streaming mode is currently active */ export declare function isStreamingMode(): boolean; /** * Get current lock depth (for debugging) */ export declare function getLockDepth(): number; /** * Enter streaming mode - blocks all non-streaming output * Supports nested calls with reference counting */ export declare function enterStreamingMode(): void; /** * Exit streaming mode - allows normal UI output to resume * Only fully exits when all nested locks are released */ export declare function exitStreamingMode(): void; /** * Force release all locks (emergency/cleanup use) */ export declare function forceRelease(): void; /** * Execute a callback only if not in streaming mode. * Returns true if the callback was executed, false if skipped. */ export declare function ifNotStreaming(callback: () => void): boolean; /** * Execute a callback when streaming ends (immediately if not streaming) * Queues the callback if currently streaming */ export declare function whenStreamingEnds(callback: () => void): void; /** * Execute callback with exclusive stream lock * Automatically acquires and releases the lock */ export declare function withStreamLock(callback: () => T | Promise): Promise; /** * Legacy: installGlobalWriteLock is now a no-op * The old approach of wrapping stdout.write caused nested lock issues. * We now use a simpler streaming mode flag instead. */ export declare function installGlobalWriteLock(): void; /** * Reset all state (for testing) */ export declare function resetGlobalWriteLock(): void; //# sourceMappingURL=globalWriteLock.d.ts.map