from fastapi import APIRouter, Depends, Request
from ...core.permission import require_login
from ...core.config import settings
import httpx

router = APIRouter()

DEERFLOW_BASE = settings.DEERFLOW_GATEWAY_URL


@router.get("")
async def get_agents(
    request: Request,
    user: dict = Depends(require_login),
):
    try:
        async with httpx.AsyncClient(timeout=10) as client:
            res = await client.get(f"{DEERFLOW_BASE}/api/agents")
            return res.json()
    except Exception:
        return {"agents": []}
