from fastapi import APIRouter, Depends, status from sqlalchemy.ext.asyncio import AsyncSession from ..agent_auth import AgentCredential, get_agent_credential from ..db import get_session from ..schemas import AcceptedResponse, HeartbeatRequest from ..services.ingestion import upsert_agent_heartbeat router = APIRouter() @router.post( "/heartbeat", response_model=AcceptedResponse, status_code=status.HTTP_202_ACCEPTED, ) async def heartbeat( body: HeartbeatRequest, credential: AgentCredential = Depends(get_agent_credential), session: AsyncSession = Depends(get_session), ) -> AcceptedResponse: await upsert_agent_heartbeat(session, body, credential) await session.commit() return AcceptedResponse(accepted=True)