"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Tools_1 = require("../../src/services/Tools");
describe("ToolsService.setFunction bug with multiple registrations", () => {
    let toolsService;
    beforeEach(() => {
        toolsService = new Tools_1.ToolsService();
    });
    it("should update function when setFunction is called multiple times with different implementations", () => {
        const storage1 = new Map();
        storage1.set("key1", "data1");
        const expandTokens1 = ({ key }) => {
            const data = storage1.get(key);
            if (!data)
                throw new Error(`No data found for key: ${key}`);
            return data;
        };
        toolsService.addTools([
            {
                type: "function",
                function: {
                    name: "expandTokens",
                    description: "Retrieve compressed data",
                    parameters: {
                        type: "object",
                        properties: {
                            key: { type: "string", description: "The key" },
                        },
                        required: ["key"],
                    },
                },
            },
        ]);
        toolsService.setFunction("expandTokens", expandTokens1);
        const func1 = toolsService.getFunction("expandTokens");
        expect(func1({ key: "key1" })).toBe("data1");
        const storage2 = new Map();
        storage2.set("key2", "data2");
        const expandTokens2 = ({ key }) => {
            const data = storage2.get(key);
            if (!data)
                throw new Error(`No data found for key: ${key}`);
            return data;
        };
        toolsService.setFunction("expandTokens", expandTokens2);
        const func2 = toolsService.getFunction("expandTokens");
        expect(() => func2({ key: "key1" })).toThrow("No data found for key: key1");
        expect(func2({ key: "key2" })).toBe("data2");
    });
});
//# sourceMappingURL=ToolsService.setFunction.test.js.map