2026-06-23 10:04:23 +00:00
|
|
|
"""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",
|
2026-08-01 17:59:32 +00:00
|
|
|
"halal_engine": "halal",
|
|
|
|
|
"halal_reco": "halal",
|
2026-06-23 10:04:23 +00:00
|
|
|
"branch_scraper": "sourcing",
|
|
|
|
|
"hermes": "herman",
|
|
|
|
|
"herman_delegate": "herman",
|
2026-08-01 17:59:32 +00:00
|
|
|
"ops": "sysops",
|
|
|
|
|
"sysop": "sysops",
|
|
|
|
|
"web_builder": "webbuilder",
|
|
|
|
|
"packaging_agent": "packaging",
|
2026-06-23 10:04:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def normalize_agent_key(name: str | None) -> str:
|
|
|
|
|
key = (name or "").strip().lower()
|
|
|
|
|
if not key:
|
|
|
|
|
return ""
|
|
|
|
|
return AGENT_NAME_MAP.get(key, key)
|
2026-08-01 17:59:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def aliases_for_key(canonical: str) -> list[str]:
|
|
|
|
|
"""All raw agent_name values that map to this soul key (including the key itself)."""
|
|
|
|
|
key = (canonical or "").strip().lower()
|
|
|
|
|
if not key:
|
|
|
|
|
return []
|
|
|
|
|
names = {key}
|
|
|
|
|
for raw, canon in AGENT_NAME_MAP.items():
|
|
|
|
|
if canon == key:
|
|
|
|
|
names.add(raw)
|
|
|
|
|
return sorted(names)
|