import { HeliconeManualLogger } from "./HeliconeManualLogger";
import { HeliconeLogRequest } from "./types";
type Stream<T> = AsyncIterable<T> & {
    tee(): [Stream<T>, Stream<T>];
    toReadableStream(): ReadableStream<T>;
};
/**
 * HeliconeLogBuilder provides a simplified way to handle streaming LLM responses
 * with better error handling and async support.
 */
export declare class HeliconeLogBuilder {
    private logger;
    private request;
    private additionalHeaders?;
    private startTime;
    private endTime;
    private responseBody;
    private error;
    private timeToFirstToken?;
    private streamTexts;
    private status;
    private wasCancelled;
    private streamState;
    private attachedStream;
    /**
     * Creates a new HeliconeLogBuilder
     * @param logger - The HeliconeManualLogger instance to use for logging
     * @param request - The request object to log
     * @param additionalHeaders - Additional headers to send with the request
     */
    constructor(logger: HeliconeManualLogger, request: HeliconeLogRequest, additionalHeaders?: Record<string, string>);
    /**
     * Sets an error that occurred during the request
     * @param error - The error that occurred
     */
    setError(error: any): void;
    /**
     * Collects streaming responses and converts them to a readable stream
     * while also capturing the response for logging
     * @param stream - The stream from an LLM provider response
     * @returns A ReadableStream that can be returned to the client
     */
    toReadableStream<T>(stream: Stream<T>): ReadableStream;
    addAdditionalHeaders(headers: Record<string, string>): void;
    /**
     * Attaches a stream to the log builder, this will consume the stream and log it on sendLog
     * @param stream - The stream to attach
     */
    attachStream<T>(stream: Stream<T>): Promise<void>;
    /**
     * Sets the response body for non-streaming responses
     * @param body - The response body
     */
    setResponse(body: string): void;
    private waitForStreamToFinish;
    private consumeStream;
    /**
     * Sends the log to Helicone
     * @returns A Promise that resolves when logging is complete
     */
    sendLog(): Promise<void>;
}
export {};
//# sourceMappingURL=HeliconeLogBuilder.d.ts.map