"""Unified Beaver agent engine.

这里不做顶层 eager import，避免子模块导入时触发循环依赖。
对外仍然保留同样的导出名称，但改成按需加载。
"""

from __future__ import annotations

from typing import Any

__all__ = ["AgentLoop", "AgentProfile", "AgentRunResult", "EngineLoader", "EngineLoadResult"]


def __getattr__(name: str) -> Any:
    if name == "EngineLoader":
        from .loader import EngineLoader

        return EngineLoader
    if name == "EngineLoadResult":
        from .loader import EngineLoadResult

        return EngineLoadResult
    if name in {"AgentLoop", "AgentProfile", "AgentRunResult"}:
        from .loop import AgentLoop, AgentProfile, AgentRunResult

        return {
            "AgentLoop": AgentLoop,
            "AgentProfile": AgentProfile,
            "AgentRunResult": AgentRunResult,
        }[name]
    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
