import { Result } from "better-result";
import { CancelledError, LogStreamError } from "./errors.ts";
export type LogRecord = {
    type: "log";
    text: string;
    byteStart: number;
    byteEnd: number;
};
export type TerminalRecord = {
    type: "terminal";
    kind: "end" | "error";
    code: string;
    message: string;
    retryable: boolean;
    cursor: string | null;
    details?: Record<string, unknown>;
};
export type StreamRecord = LogRecord | TerminalRecord;
export type LogStreamOptions = {
    baseUrl: string;
    token: string;
    deploymentId: string;
    tail?: number;
    fromStart?: boolean;
    cursor?: string;
    signal?: AbortSignal;
};
export type StreamResult = {
    terminal: TerminalRecord | null;
    lastByteEnd: number | null;
};
export type StreamLogsError = LogStreamError | CancelledError;
/**
 * Open a WebSocket to the log-streaming endpoint and deliver records via callback.
 *
 * Returns `Ok` with the stream result on graceful close, or `Err` with a
 * `LogStreamError` (connection/HTTP errors) or `CancelledError` (abort signal).
 */
export declare function streamLogs(options: LogStreamOptions, onRecord: (record: StreamRecord) => void): Promise<Result<StreamResult, StreamLogsError>>;
//# sourceMappingURL=log-stream.d.ts.map