import { StringRayCodeReviewServer } from "./knowledge-skills/code-review.server.js";
import { StringRaySecurityAuditServer } from "./knowledge-skills/security-audit.server.js";
import { StringRayLibrarianServer } from "./researcher.server.js";
const instances = new Map();
function getCodeReview() {
    if (!instances.has("code-review")) {
        const server = new StringRayCodeReviewServer();
        instances.set("code-review", {
            analyzeProposal: (args) => server.analyzeProposal(args),
        });
    }
    return instances.get("code-review");
}
function getSecurityAudit() {
    if (!instances.has("security-audit")) {
        const server = new StringRaySecurityAuditServer();
        instances.set("security-audit", {
            analyzeProposal: (args) => server.analyzeProposal(args),
        });
    }
    return instances.get("security-audit");
}
function getResearcher() {
    if (!instances.has("researcher")) {
        const server = new StringRayLibrarianServer();
        instances.set("researcher", {
            analyzeProposal: (args) => server.analyzeProposal(args),
        });
    }
    return instances.get("researcher");
}
const registry = {
    "code-review": getCodeReview,
    "security-audit": getSecurityAudit,
    "researcher": getResearcher,
};
export async function callInProcessSkill(serverName, toolName, args) {
    const factory = registry[serverName];
    if (!factory) {
        throw new Error(`No in-process handler registered for server: ${serverName}`);
    }
    if (toolName !== "analyze_proposal") {
        throw new Error(`In-process skill registry only supports "analyze_proposal", got "${toolName}"`);
    }
    const handler = factory();
    return handler.analyzeProposal(args);
}
