"""Agents package — YAML-driven agent factory.

All agent definitions live in config/agents.yaml.
The loader reads YAML and builds SubAgent instances from a single seed class.
"""

from timmy.agents.base import BaseAgent, SubAgent
from timmy.agents.loader import (
    get_agent,
    list_agents,
    load_agents,
    reload_agents,
    route_request,
)

# Backwards compat — old code that imported create_timmy_swarm
# now gets the YAML-driven equivalent.


def create_timmy_swarm():
    """Load all agents from YAML config.

    Backwards-compatible wrapper for code that called create_timmy_swarm().
    Returns the orchestrator agent (or first agent if no orchestrator defined).
    """
    agents = load_agents()
    return agents.get("orchestrator", next(iter(agents.values())))


# Also alias TimmyOrchestrator for old imports
TimmyOrchestrator = SubAgent

__all__ = [
    "BaseAgent",
    "SubAgent",
    "TimmyOrchestrator",
    "create_timmy_swarm",
    "get_agent",
    "list_agents",
    "load_agents",
    "reload_agents",
    "route_request",
]
