export function createFunctionRegistry(args) {
    const functions = new Map();
    const register = (def) => {
        if (functions.has(def.name)) {
            throw new Error(`Function "${def.name}" is already registered.`);
        }
        functions.set(def.name, { handler: def.handler });
    };
    const call = (name, argsValue) => {
        const entry = functions.get(name);
        if (!entry) {
            const err = new Error(`Unknown function: ${name}`);
            err.code = "LIX_CALL_UNKNOWN";
            throw err;
        }
        return entry.handler({ engine: args.engine }, argsValue);
    };
    const list = () => Array.from(functions.keys(), (name) => ({ name }));
    return {
        register,
        call,
        list,
    };
}
//# sourceMappingURL=function-registry.js.map