export type OutputStream = {
    off?(event: "error", listener: (error: unknown) => void): void;
    on?(event: "error", listener: (error: unknown) => void): void;
    write(chunk: string): void;
};
export type BrokenPipeState = {
    closed: boolean;
};
export declare function createBrokenPipeState(): BrokenPipeState;
export declare function createSafeOutputStream(stream: OutputStream, brokenPipe: BrokenPipeState): OutputStream;
export declare function withBrokenPipeGuard<TResult>(streams: readonly OutputStream[], brokenPipe: BrokenPipeState, callback: () => Promise<TResult>): Promise<TResult>;
export declare function addBrokenPipeListener(stream: OutputStream, brokenPipe: BrokenPipeState): () => void;
