from __future__ import annotations

"""Runtime registry for LLM providers."""

from dataclasses import dataclass, field

from agentrspy.core import LlmProvider


@dataclass(slots=True)
class ProviderRegistry:
    """Runtime registry for LLM providers."""

    providers: dict[str, LlmProvider] = field(default_factory=dict)

    @classmethod
    def new(cls) -> "ProviderRegistry":
        return cls()

    def register(self, provider: LlmProvider) -> "ProviderRegistry":
        self.providers[provider.name()] = provider
        return self

    def get(self, name: str) -> LlmProvider | None:
        return self.providers.get(name)
