import { Readable } from 'node:stream';
import type { AdapterContext } from '../types/chat-envelope.js';
import type { JsonObject } from '../types/json.js';
import type { StageRecorder } from '../format-adapters/index.js';
import type { ProviderInvoker } from '../../../servertool/types.js';
type ProviderProtocol = 'openai-chat' | 'openai-responses' | 'anthropic-messages' | 'gemini-chat';
export interface ProviderResponseConversionOptions {
    providerProtocol: ProviderProtocol;
    providerResponse: JsonObject;
    context: AdapterContext;
    entryEndpoint: string;
    wantsStream: boolean;
    /**
     * Canonical chat semantics from the request-side chat_process output.
     * This is the only allowed carrier for mappable cross-protocol semantics
     * (tool alias maps, client tool schemas, responses resume, etc.).
     *
     * Must not be stuffed into metadata/AdapterContext.
     */
    requestSemantics?: JsonObject;
    stageRecorder?: StageRecorder;
    providerInvoker?: ProviderInvoker;
    /**
     * 可选：由 Host 注入的二次请求入口。Server-side 工具在需要发起
     * followup 请求（例如 web_search 二跳）时，可以通过该回调将构造
     * 好的请求体交给 Host，由 Host 走完整 HubPipeline + VirtualRouter
     * 再返回最终客户端响应形状。
     */
    reenterPipeline?: (options: {
        entryEndpoint: string;
        requestId: string;
        body: JsonObject;
        metadata?: JsonObject;
    }) => Promise<ProviderResponseConversionResult>;
    clientInjectDispatch?: (options: {
        entryEndpoint: string;
        requestId: string;
        body?: JsonObject;
        metadata?: JsonObject;
    }) => Promise<{
        ok: boolean;
        reason?: string;
    }>;
}
export interface ProviderResponseConversionResult {
    body?: JsonObject;
    __sse_responses?: Readable;
    format?: string;
}
export declare function convertProviderResponse(options: ProviderResponseConversionOptions): Promise<ProviderResponseConversionResult>;
export {};
