"""Build Agent HTTP URLs — use HTTPS when Nexus API base URL is HTTPS."""

from server.config import settings


def agent_url(host: str, port: int, path: str) -> str:
    """Agent endpoint URL on a managed host (health, exec, etc.)."""
    scheme = "https" if (settings.API_BASE_URL or "").lower().startswith("https://") else "http"
    if not path.startswith("/"):
        path = f"/{path}"
    return f"{scheme}://{host}:{port}{path}"
