import { buildNativeReqOutboundCompatAdapterContext } from '../../hub/pipeline/compat/native-adapter-context.js';
const PROFILE = 'chat:glm';
const DEFAULT_PROVIDER_PROTOCOL = 'openai-chat';
const DEFAULT_ENTRY_ENDPOINT = '/v1/chat/completions';
export function buildGlmCompatContext(adapterContext) {
    const nativeContext = buildNativeReqOutboundCompatAdapterContext(adapterContext);
    const adapterProfile = adapterContext && typeof adapterContext['compatibilityProfile'] === 'string'
        ? String(adapterContext['compatibilityProfile']).trim() || undefined
        : undefined;
    return {
        ...nativeContext,
        compatibilityProfile: nativeContext.compatibilityProfile ?? adapterProfile ?? PROFILE,
        providerProtocol: nativeContext.providerProtocol ??
            adapterContext?.providerProtocol ??
            DEFAULT_PROVIDER_PROTOCOL,
        entryEndpoint: nativeContext.entryEndpoint ??
            adapterContext?.entryEndpoint ??
            DEFAULT_ENTRY_ENDPOINT
    };
}
export function buildGlmRequestCompatInput(payload, adapterContext) {
    return {
        payload,
        adapterContext: buildGlmCompatContext(adapterContext),
        explicitProfile: PROFILE
    };
}
export function buildGlmResponseCompatInput(payload, adapterContext) {
    return {
        payload,
        adapterContext: buildGlmCompatContext(adapterContext),
        explicitProfile: PROFILE
    };
}
