import { BestAgentError } from "@best-agent/foundation";
export class SkillRegistry {
    #skills = new Map();
    constructor(skills) {
        for (const skill of skills) {
            if (this.#skills.has(skill.id)) {
                throw new BestAgentError("SKILL_CONFLICT", `Skill ${skill.id} is already registered.`);
            }
            this.#skills.set(skill.id, skill);
        }
    }
    get(id) {
        return this.#skills.get(id);
    }
    require(id) {
        const skill = this.#skills.get(id);
        if (!skill) {
            const available = this.list()
                .map((item) => item.id)
                .join(", ");
            throw new BestAgentError("SKILL_NOT_FOUND", `Skill "${id}" not found. Available skills: ${available || "none"}.`);
        }
        return skill;
    }
    list() {
        return Array.from(this.#skills.values()).map((skill) => ({
            allowedTools: skill.allowedTools,
            contextMode: skill.contextMode,
            description: skill.description,
            effort: skill.effort,
            executionMode: skill.executionMode,
            id: skill.id,
            model: skill.model,
            name: skill.name,
            pathScope: skill.pathScope,
            source: skill.source,
            sourceExtension: skill.sourceExtension,
            sourcePlugin: skill.sourcePlugin,
            whenToUse: skill.whenToUse,
        }));
    }
}
//# sourceMappingURL=registry.js.map