import type { StreamFn } from "@earendil-works/pi-agent-core";
import * as piAi from "@earendil-works/pi-ai";
import type { ProviderRuntimeModel } from "../plugins/types.js";
import { OpenAIWebSocketManager, type OpenAIWebSocketManagerOptions } from "./openai-ws-connection.js";
type OpenAIWsStreamDeps = {
    createManager: (options?: OpenAIWebSocketManagerOptions) => OpenAIWebSocketManager;
    createHttpFallbackStreamFn: (model: ProviderRuntimeModel) => StreamFn | undefined;
    streamSimple: typeof piAi.streamSimple;
};
/**
 * Release and close the WebSocket session for the given sessionId.
 * Call this after the agent run completes to free the connection.
 */
export declare function releaseWsSession(sessionId: string): void;
/**
 * Returns true if a live WebSocket session exists for the given sessionId.
 */
export declare function hasWsSession(sessionId: string): boolean;
export { buildAssistantMessageFromResponse, convertMessagesToInputItems, convertTools, planTurnInput, } from "./openai-ws-message-conversion.js";
export interface OpenAIWebSocketStreamOptions {
    /** Manager options (url override, retry counts, etc.) */
    managerOptions?: OpenAIWebSocketManagerOptions;
    /** Abort signal forwarded from the run. */
    signal?: AbortSignal;
}
/**
 * Creates a `StreamFn` backed by a persistent WebSocket connection to the
 * OpenAI Responses API.  The first call for a given `sessionId` opens the
 * connection; subsequent calls reuse it, sending only incremental tool-result
 * inputs with `previous_response_id`.
 *
 * If the WebSocket connection is unavailable, the function falls back to the
 * standard `streamSimple` HTTP path and logs a warning.
 *
 * @param apiKey     OpenAI API key
 * @param sessionId  Agent session ID (used as the registry key)
 * @param opts       Optional manager + abort signal overrides
 */
export declare function createOpenAIWebSocketStreamFn(apiKey: string, sessionId: string, opts?: OpenAIWebSocketStreamOptions): StreamFn;
export declare const __testing: {
    setDepsForTest(overrides?: Partial<OpenAIWsStreamDeps>): void;
    setWsDegradeCooldownMsForTest(nextMs?: number): void;
};
