/**
 * {@link StreamSink}: writes closed segments to an injected {@link Writable}.
 *
 * It drains a {@link SignalChannel} and, for every `close` signal, serializes the
 * {@link TraceRecord} to a JSON line and writes it to a caller-provided
 * `node:stream` {@link Writable} — `process.stdout`, a file write stream, a
 * network socket, a `PassThrough` in tests. This is the most general sink: the
 * destination is whatever Writable you hand it.
 *
 * Backpressure is honoured. When `write` returns `false` (the stream's internal
 * buffer is full) the sink awaits the next `drain` event before continuing, so a
 * slow consumer throttles the trace rather than ballooning memory. {@link close}
 * optionally ends the underlying stream when the sink was told it owns it.
 */
import type { Writable } from "node:stream";
import type { SignalChannel } from "../channel/signal";
import type { Sink } from "./base";
/** Tuning for a {@link StreamSink}. */
export interface StreamSinkOptions {
    /**
     * Whether {@link close} should `end()` the underlying stream. Defaults to
     * `false` — by default the sink writes but never closes a stream it did not
     * create (e.g. you would not want it ending `process.stdout`).
     */
    readonly endOnClose?: boolean;
}
/**
 * A {@link Sink} that writes each closed segment as a JSON line to a {@link Writable}.
 *
 * Owns no buffer of its own — bytes go straight to the stream — so {@link flush}
 * is a no-op resolution. {@link close} ends the stream only when constructed with
 * `endOnClose: true`.
 */
export declare class StreamSink implements Sink {
    private readonly stream;
    private readonly endOnClose;
    constructor(stream: Writable, options?: StreamSinkOptions);
    /** Write `line`, resolving once it is accepted or once backpressure clears. */
    private writeLine;
    /** Drain `channel`, writing a JSON line per closed record (with backpressure). */
    drain(channel: SignalChannel): Promise<void>;
    /** No-op: bytes are not buffered by this sink. Present for interface symmetry. */
    flush(): Promise<void>;
    /** End the underlying stream when this sink owns it (`endOnClose`); else no-op. */
    close(): Promise<void>;
}
