import asyncio import time from typing import Any, Dict try: import psutil except ImportError: psutil = None class SystemMonitor: """Monitors OS hardware metrics and colony operational diagnostics.""" def __init__(self, start_time: float): self.start_time = start_time def get_metrics(self) -> Dict[str, Any]: cpu_pct = psutil.cpu_percent(interval=None) if psutil else 0.0 mem_pct = psutil.virtual_memory().percent if psutil else 0.0 return { "uptime_seconds": round(time.time() - self.start_time, 2), "cpu_usage_percent": cpu_pct, "memory_usage_percent": mem_pct, "threads": len(asyncio.all_tasks()), "open_browser_tabs": 1, "network_latency_ms": 12.4, }