import { recordStage } from '../../../stages/utils.js';
import { buildClientPayloadForProtocol } from './client-remap-protocol-switch.js';
import { normalizeProviderProtocolTokenWithNative } from '../../../../../../router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js';
export function runRespOutboundStage1ClientRemap(options) {
    const normalizedProtocol = normalizeProviderProtocolTokenWithNative(options.clientProtocol);
    const clientProtocol = normalizedProtocol === 'openai-chat' ||
        normalizedProtocol === 'openai-responses' ||
        normalizedProtocol === 'anthropic-messages'
        ? normalizedProtocol
        : options.clientProtocol;
    const clientPayload = buildClientPayloadForProtocol({
        payload: options.payload,
        clientProtocol,
        requestId: options.requestId,
        requestSemantics: options.requestSemantics
    });
    recordStage(options.stageRecorder, 'chat_process.resp.stage9.client_remap', clientPayload);
    return clientPayload;
}
