"use strict";
// SPDX-License-Identifier: AGPL-3.0-or-later
// Copyright (C) 2024-2026 Gracker (Chris)
// This file is part of SmartPerfetto. See LICENSE for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.getToolRegistry = getToolRegistry;
exports.resetToolRegistry = resetToolRegistry;
class ToolRegistryImpl {
    constructor() {
        this.tools = new Map();
    }
    register(tool) {
        if (this.tools.has(tool.definition.name)) {
            console.warn(`[ToolRegistry] Overwriting existing tool: ${tool.definition.name}`);
        }
        this.tools.set(tool.definition.name, tool);
    }
    get(name) {
        return this.tools.get(name);
    }
    list() {
        return Array.from(this.tools.values()).map(t => t.definition);
    }
    listByCategory(category) {
        return this.list().filter(t => t.category === category);
    }
    getToolDescriptionsForLLM() {
        const tools = this.list();
        return tools.map(t => {
            const params = t.parameters.map(p => `  - ${p.name} (${p.type}${p.required ? ', required' : ''}): ${p.description}`).join('\n');
            return `## ${t.name}\n${t.description}\n\nCategory: ${t.category}\n\nParameters:\n${params}\n\nReturns: ${t.returns.description}`;
        }).join('\n\n---\n\n');
    }
}
let instance = null;
function getToolRegistry() {
    if (!instance) {
        instance = new ToolRegistryImpl();
    }
    return instance;
}
function resetToolRegistry() {
    instance = null;
}
//# sourceMappingURL=toolRegistry.js.map