export const PROVIDER_PROFILE_KEYS = [
    "openai",
    "anthropic",
    "google-gemini",
    "openai-compatible",
];
const providerProfiles = [
    {
        profileKey: "openai",
        displayName: "OpenAI",
        description: "OpenAI API key for the MVP executable runtime path.",
        credential: {
            type: "api_key",
            label: "OpenAI API key",
        },
        runtimeExecutable: true,
        runnable: true,
        runnableBlockerReason: null,
        runtimeAvailability: "executable",
        credentialRef: {
            provider: "openai",
            kind: "openai_api_key",
            accountIdForWorkspace: legacyWorkspaceAccountId,
        },
    },
    {
        profileKey: "anthropic",
        displayName: "Anthropic",
        description: "Anthropic API key profile for future provider routing.",
        credential: {
            type: "api_key",
            label: "Anthropic API key",
        },
        runtimeExecutable: false,
        runnable: false,
        runnableBlockerReason: "execution-coming-soon",
        runtimeAvailability: "not_executable",
        credentialRef: {
            provider: "anthropic",
            kind: "anthropic_api_key",
            accountIdForWorkspace: profileWorkspaceAccountId("anthropic"),
        },
    },
    {
        profileKey: "google-gemini",
        displayName: "Google Gemini",
        description: "Google Gemini API key profile for future provider routing.",
        credential: {
            type: "api_key",
            label: "Google Gemini API key",
        },
        runtimeExecutable: false,
        runnable: false,
        runnableBlockerReason: "execution-coming-soon",
        runtimeAvailability: "not_executable",
        credentialRef: {
            provider: "google_gemini",
            kind: "google_gemini_api_key",
            accountIdForWorkspace: profileWorkspaceAccountId("google-gemini"),
        },
    },
    {
        profileKey: "openai-compatible",
        displayName: "OpenAI-compatible",
        description: "OpenAI-compatible API key profile for future OpenRouter-style endpoints.",
        credential: {
            type: "api_key",
            label: "OpenAI-compatible API key",
        },
        runtimeExecutable: false,
        runnable: false,
        runnableBlockerReason: "execution-coming-soon",
        runtimeAvailability: "not_executable",
        credentialRef: {
            provider: "openai_compatible",
            kind: "openai_compatible_api_key",
            accountIdForWorkspace: profileWorkspaceAccountId("openai-compatible"),
        },
    },
];
const profileByKey = new Map(providerProfiles.map((profile) => [profile.profileKey, profile]));
export function listProviderProfiles() {
    return providerProfiles.map(toPublicProviderProfile);
}
export function getProviderProfile(profileKey) {
    if (!isProviderProfileKey(profileKey))
        return undefined;
    return profileByKey.get(profileKey);
}
export function isProviderProfileKey(profileKey) {
    return PROVIDER_PROFILE_KEYS.includes(profileKey);
}
export function providerProfileCredentialRef(workspaceId, profileKey) {
    const profile = profileByKey.get(profileKey);
    if (!profile) {
        throw new Error("Unknown provider profile key.");
    }
    return {
        provider: profile.credentialRef.provider,
        kind: profile.credentialRef.kind,
        accountId: profile.credentialRef.accountIdForWorkspace(workspaceId),
    };
}
function toPublicProviderProfile(profile) {
    return {
        profileKey: profile.profileKey,
        displayName: profile.displayName,
        description: profile.description,
        credential: { ...profile.credential },
        runtimeExecutable: profile.runtimeExecutable,
        runnable: profile.runnable,
        runnableBlockerReason: profile.runnableBlockerReason,
    };
}
function legacyWorkspaceAccountId(workspaceId) {
    return `workspace:${workspaceId}`;
}
function profileWorkspaceAccountId(profileKey) {
    return (workspaceId) => `workspace:${workspaceId}:provider-profile:${profileKey}`;
}
