from fastapi import HTTPException, APIRouter router = APIRouter() @router.get("/stats") async def get_stats(): import psutil return { "cpu": psutil.cpu_percent(), "ram": psutil.virtual_memory().percent, "disk": psutil.disk_usage('/').percent, "gpu": 0 } @router.get("/info") async def get_info(): return {"os": "windows", "version": "1.0.0-OMEGA", "build": "V15_FINAL_PRODUCTION"} @router.get("/health/mongo") async def health_mongo(): """Check MongoDB Atlas connectivity.""" try: from backend.db.mongodb import MongoDBClient await MongoDBClient.get_db().command("ping") return {"status": "online", "service": "MongoDB Atlas"} except Exception as e: raise HTTPException(status_code=503, detail=f"MongoDB offline: {e}") @router.get("/health/chroma") async def health_chroma(): """Check ChromaDB local vector store connectivity.""" try: import chromadb from chromadb.config import Settings client = chromadb.PersistentClient(path="chroma_db", settings=Settings(anonymized_telemetry=False)) collections = client.list_collections() return {"status": "online", "service": "ChromaDB", "collections": len(collections)} except Exception as e: raise HTTPException(status_code=503, detail=f"ChromaDB offline: {e}") @router.get("/health/supervisor") async def health_supervisor(): """Check AI Self-Heal supervisor status.""" import os supervisor_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "backend", "supervisor.py") exists = os.path.exists(supervisor_path) return { "status": "online" if exists else "error", "service": "AI Self-Heal Supervisor", "supervisor_present": exists, "max_restarts_per_minute": 5, "heal_engine": "Gemini API" } from pydantic import BaseModel class ActivationEventPayload(BaseModel): persona: str trigger_source: str @router.post("/activation_event") async def handle_activation_event(payload: ActivationEventPayload): from backend.voice.activation import on_jarvis_friday_activated import asyncio asyncio.create_task(on_jarvis_friday_activated(payload.persona, payload.trigger_source)) return {"status": "ok", "message": "Activation sequence initiated"}