import { resolveAgentId } from "@poe-code/agent-defs";
function snapshotConfig(config) {
    return { ...config };
}
const agentMcpConfigs = {
    "claude-code": {
        configFile: "~/.claude.json",
        configKey: "mcpServers",
        format: "json",
        shape: "standard"
    },
    "claude-desktop": {
        configFile: (platform) => {
            switch (platform) {
                case "darwin":
                    return "~/Library/Application Support/Claude/claude_desktop_config.json";
                case "win32":
                    return "~/AppData/Roaming/Claude/claude_desktop_config.json";
                default:
                    return "~/.config/Claude/claude_desktop_config.json";
            }
        },
        configKey: "mcpServers",
        format: "json",
        shape: "standard",
        mcpOutputFormat: "markdown_instructions"
    },
    codex: {
        configFile: "~/.codex/config.toml",
        configKey: "mcp_servers",
        format: "toml",
        shape: "standard"
    },
    cursor: {
        configFile: "~/.cursor/mcp.json",
        configKey: "mcpServers",
        format: "json",
        shape: "standard"
    },
    opencode: {
        configFile: "~/.config/opencode/opencode.json",
        configKey: "mcp",
        format: "json",
        shape: "opencode"
    },
    kimi: {
        configFile: "~/.kimi/mcp.json",
        configKey: "mcpServers",
        format: "json",
        shape: "standard"
    },
    goose: {
        configFile: "~/.config/goose/config.yaml",
        configKey: "extensions",
        format: "yaml",
        shape: "goose"
    }
};
export const supportedAgents = Object.keys(agentMcpConfigs);
export function resolveAgentSupport(input, registry = agentMcpConfigs) {
    const resolvedId = resolveAgentId(input);
    if (!resolvedId) {
        return { status: "unknown", input };
    }
    const config = registry[resolvedId];
    if (!config) {
        return { status: "unsupported", input, id: resolvedId };
    }
    return { status: "supported", input, id: resolvedId, config: snapshotConfig(config) };
}
export function isSupported(agentId) {
    return resolveAgentSupport(agentId).status === "supported";
}
export function getAgentConfig(agentId) {
    const support = resolveAgentSupport(agentId);
    return support.status === "supported" ? support.config : undefined;
}
export function resolveConfigPath(config, platform) {
    if (typeof config.configFile === "function") {
        return config.configFile(platform);
    }
    return config.configFile;
}
