"""
LangGraph workflow implementations for CleverAgents.

This package contains the graph-based agent workflows using LangGraph's StateGraph.

Lazy-loaded to avoid circular imports — ``context_analysis`` re-exports from
``graphs.context_analysis``, and ``plan_generation`` imports from
``context_analysis``, so eagerly importing all submodules here creates a cycle.
"""

from __future__ import annotations

import importlib
from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:  # pragma: no cover
    from .auto_debug import AutoDebugAgent, AutoDebugState
    from .context_analysis import ContextAnalysisAgent, ContextAnalysisState
    from .plan_generation import PlanGenerationGraph, PlanGenerationState

__all__ = [
    "AutoDebugAgent",
    "AutoDebugState",
    "ContextAnalysisAgent",
    "ContextAnalysisState",
    "PlanGenerationGraph",
    "PlanGenerationState",
]

_LAZY_IMPORTS: dict[str, tuple[str, str]] = {
    "AutoDebugAgent": (".auto_debug", "AutoDebugAgent"),
    "AutoDebugState": (".auto_debug", "AutoDebugState"),
    "ContextAnalysisAgent": (".context_analysis", "ContextAnalysisAgent"),
    "ContextAnalysisState": (".context_analysis", "ContextAnalysisState"),
    "PlanGenerationGraph": (".plan_generation", "PlanGenerationGraph"),
    "PlanGenerationState": (".plan_generation", "PlanGenerationState"),
}


def __getattr__(name: str) -> Any:
    entry = _LAZY_IMPORTS.get(name)
    if entry is not None:
        module_path, attr_name = entry
        module = importlib.import_module(module_path, __name__)
        value = getattr(module, attr_name)
        # Cache on the module so subsequent accesses are fast
        globals()[name] = value
        return value
    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
