from __future__ import annotations

from typing import Final

from .models import AgentCode, AgentPersona
from .registry_admin import ADMIN_PERSONAS
from .registry_field import FIELD_PERSONAS
from .registry_technical import TECHNICAL_PERSONAS

PERSONA_REGISTRY: Final[dict[AgentCode, AgentPersona]] = {
    **ADMIN_PERSONAS,
    **TECHNICAL_PERSONAS,
    **FIELD_PERSONAS,
}


def get_persona(agent_code: str) -> AgentPersona:
    """Return a persona by agent code with a clear error for unsupported values."""
    if agent_code not in PERSONA_REGISTRY:
        raise ValueError(
            "Unsupported agent_code. Expected one of: minh, lan, hung, thao, nam, quynh, phuc, tung, thuy"
        )
    return PERSONA_REGISTRY[agent_code]  # type: ignore[index]


def list_persona_codes() -> list[str]:
    """Return supported persona codes."""
    return list(PERSONA_REGISTRY.keys())
