"""Health-/Status-Endpoint — schlanker Lebenszeichen-Check einer Instanz. Seit 24.09.2026 nennt er auch Rolle und Namen der Instanz: Die Partner-Instanz liest daran ab, wer ihr antwortet. Engine, Gateway und Hirn gibt es nur auf der KI-Box.""" from config import VERSION from fastapi import APIRouter from kern.einstellungen import einstellungen from pydantic import BaseModel router = APIRouter(prefix="/api") class HealthResponse(BaseModel): status: str version: str rolle: str instanz: str engine_reachable: bool | None = None gateway_reachable: bool | None = None brain: dict | None = None @router.get("/health", response_model=HealthResponse, response_model_exclude_none=True) def health() -> dict: e = einstellungen() antwort: dict = {"status": "ok", "version": VERSION, "rolle": e.rolle, "instanz": e.instanz} if e.rolle == "box": from services import gateway, llamaswap antwort.update( engine_reachable=llamaswap.engine_reachable(), gateway_reachable=gateway.gateway_reachable(), # Echte Hirn-Bereitschaft: Engine kann erreichbar sein, das Agent-Hirn aber tot # (Crash/OOM nach Engine-Update). Das wäre sonst ein silent fail. brain=llamaswap.brain_status(), ) return antwort