"""Register all built-in provider implementations."""

from __future__ import annotations

from pi_agents.ai.api_registry import register_api_provider


def register_builtin_providers() -> None:
    """Register all built-in LLM provider stream functions."""
    from pi_agents.ai.providers.anthropic import stream_anthropic, stream_simple_anthropic

    register_api_provider(
        api="anthropic-messages",
        stream=stream_anthropic,
        stream_simple=stream_simple_anthropic,
    )

    from pi_agents.ai.providers.openai_completions import stream_openai_completions, stream_simple_openai_completions

    register_api_provider(
        api="openai-completions",
        stream=stream_openai_completions,
        stream_simple=stream_simple_openai_completions,
    )

    from pi_agents.ai.providers.openai_responses import stream_openai_responses, stream_simple_openai_responses

    register_api_provider(
        api="openai-responses",
        stream=stream_openai_responses,
        stream_simple=stream_simple_openai_responses,
    )

    # Azure and Codex use same implementations as OpenAI Responses
    register_api_provider(
        api="azure-openai-responses",
        stream=stream_openai_responses,
        stream_simple=stream_simple_openai_responses,
    )
    register_api_provider(
        api="openai-codex-responses",
        stream=stream_openai_responses,
        stream_simple=stream_simple_openai_responses,
    )

    from pi_agents.ai.providers.google import stream_google, stream_simple_google

    register_api_provider(
        api="google-generative-ai",
        stream=stream_google,
        stream_simple=stream_simple_google,
    )

    # Google Gemini CLI and Vertex use same Google implementation
    register_api_provider(
        api="google-gemini-cli",
        stream=stream_google,
        stream_simple=stream_simple_google,
    )
    register_api_provider(
        api="google-vertex",
        stream=stream_google,
        stream_simple=stream_simple_google,
    )

    from pi_agents.ai.providers.mistral import stream_mistral, stream_simple_mistral

    register_api_provider(
        api="mistral-conversations",
        stream=stream_mistral,
        stream_simple=stream_simple_mistral,
    )

    # Bedrock uses OpenAI completions as fallback (lazy-loaded in TS)
    register_api_provider(
        api="bedrock-converse-stream",
        stream=stream_openai_completions,
        stream_simple=stream_simple_openai_completions,
    )


# Auto-register on import
register_builtin_providers()
