"""Normalize legacy agent_name values to agent_souls keys."""
from __future__ import annotations

AGENT_NAME_MAP: dict[str, str] = {
    "retail_360": "retail",
    "retail_scraper": "retail",
    "retail_crm": "retail",
    "retail_intel": "retail",
    "rss_feeds": "marketing",
    "wholesale_scraper": "sourcing",
    "halal_registry": "halal",
    "branch_scraper": "sourcing",
    "hermes": "herman",
    "herman_delegate": "herman",
}


def normalize_agent_key(name: str | None) -> str:
    key = (name or "").strip().lower()
    if not key:
        return ""
    return AGENT_NAME_MAP.get(key, key)
