import logging

from .config import get_nexus_url

logger = logging.getLogger("iis_access")


async def is_nexus_running() -> bool:
    """Check if Nexus local agent is running and responsive."""
    try:
        import aiohttp

        nexus_url = get_nexus_url()
        timeout = aiohttp.ClientTimeout(total=1)
        async with aiohttp.ClientSession(timeout=timeout) as session:
            resp = await session.get(f"{nexus_url}/health")
            return resp.status == 200
    except Exception:
        return False
