import type { AiAttributes } from "@superblocksteam/library-shared/types";
import type { StreamConfig } from "./config.js";
import { StreamEventBus } from "./event-bus.js";
import type { ProviderInfo, StreamMetrics, SessionOutcome } from "./types.js";
/**
 * State container for a single stream operation.
 *
 * Contains all mutable state for the session:
 * - Current attempt number
 * - Current provider info
 * - Metrics (chunks, tokens, retries, duration)
 * - Error and outcome status
 *
 * The session also owns the event bus for this operation.
 *
 * @example
 * ```typescript
 * const session = new StreamSession({ config, initialProvider });
 *
 * // Record activity
 * session.recordChunk();
 * session.recordRetry(500);
 *
 * // Finalize when done
 * session.finalize("complete");
 * ```
 */
export interface StreamSessionOptions {
    config: StreamConfig;
    initialProvider: ProviderInfo;
    organizationId?: string;
    applicationId?: string;
    getJwt?: () => string | undefined;
    getAttributes?: () => Omit<AiAttributes, "input_tokens" | "output_tokens" | "cached_tokens" | "reasoning_tokens" | "started_at" | "completed_at" | "time_worked_ms"> | undefined;
}
export declare class StreamSession {
    readonly id: string;
    readonly startTime: number;
    readonly events: StreamEventBus;
    readonly config: StreamConfig;
    readonly organizationId?: string;
    readonly applicationId?: string;
    readonly getJwt?: () => string | undefined;
    readonly getAttributes?: () => Omit<AiAttributes, "input_tokens" | "output_tokens" | "cached_tokens" | "reasoning_tokens" | "started_at" | "completed_at" | "time_worked_ms"> | undefined;
    attempt: number;
    providerAttempt: number;
    provider: ProviderInfo;
    metrics: StreamMetrics;
    error: unknown;
    outcome: SessionOutcome;
    private lastActivityTime;
    constructor(options: StreamSessionOptions);
    /**
     * Finalize the session with an outcome.
     *
     * Can only be called once. Subsequent calls are ignored.
     * Emits the appropriate lifecycle event based on outcome.
     *
     * @param outcome - The final outcome of the session
     * @param error - Optional error that caused failure
     */
    finalize(outcome: Exclude<SessionOutcome, "pending">, error?: unknown): void;
    recordRetry(delayMs: number): void;
    resetAttempts(): void;
    resetProviderAttempts(): void;
    recordChunk(): void;
    setTotalTokens(tokens: number): void;
    isPending(): boolean;
    getElapsedMs(): number;
    getTimeSinceLastActivity(): number;
    resetActivityTimer(): void;
}
//# sourceMappingURL=session.d.ts.map