import { isJsonObject } from '../../../../types/json.js';
import { applyReqInboundSemanticLiftWithNative, mapReqInboundResumeToolOutputsDetailedWithNative } from '../../../../../../router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js';
export function liftReqInboundSemantics(options) {
    const normalizedResponsesResume = options.responsesResume && isJsonObject(options.responsesResume) ? options.responsesResume : undefined;
    const lifted = applyReqInboundSemanticLiftWithNative({
        chatEnvelope: options.chatEnvelope,
        payload: options.formatEnvelope.payload,
        protocol: options.formatEnvelope.protocol,
        entryEndpoint: options.adapterContext.entryEndpoint,
        responsesResume: normalizedResponsesResume
    });
    replaceEnvelope(options.chatEnvelope, lifted);
}
export function mapResumeToolOutputsDetailed(responsesResume) {
    return mapReqInboundResumeToolOutputsDetailedWithNative(responsesResume);
}
function replaceEnvelope(target, source) {
    for (const key of Object.keys(target)) {
        if (!Object.prototype.hasOwnProperty.call(source, key)) {
            delete target[key];
        }
    }
    Object.assign(target, source);
}
