import { harvestToolsWithNative } from '../../router/virtual-router/engine-selection/native-hub-bridge-action-semantics.js';
function assertToolHarvesterNativeAvailable() {
    if (typeof harvestToolsWithNative !== 'function') {
        throw new Error('[tool-harvester] native bindings are required');
    }
}
export function harvestTools(signal, ctx) {
    assertToolHarvesterNativeAvailable();
    const result = harvestToolsWithNative({
        signal: signal,
        context: ctx
    });
    const normalized = result?.normalized;
    if (normalized && signal?.payload && typeof signal.payload === 'object') {
        const target = signal.payload;
        const next = normalized;
        for (const key of Object.keys(target)) {
            delete target[key];
        }
        Object.assign(target, next);
    }
    return result;
}
