file_exists('/opt/wevia-brain/wevia-dynamic-resolver.php') ? 'active' : 'down', 'tools' => 207, 'dept' => 'CEO']; // Arena — 103 models, 12 categories $arenaFile = '/var/www/html/api/wevia-arena-health.php'; $live['Arena'] = ['status' => file_exists($arenaFile) ? 'active' : 'down', 'models' => 103, 'dept' => 'AI']; // Growth Engine $growthFile = '/opt/wevia-brain/growth-state.json'; $g = @json_decode(@file_get_contents($growthFile), true); $live['Growth'] = ['status' => $g ? 'active' : 'idle', 'dept' => 'Prospect']; // L99 Autonomous $l99auto = @json_decode(@file_get_contents('/var/www/html/api/l99-autonomous-report.json'), true); $l99age = $l99auto ? (time() - strtotime($l99auto['timestamp'] ?? $l99auto['ts'] ?? '2020-01-01')) : 99999; $live['L99 Autonomous'] = ['status' => $l99age < 3600 ? 'active' : 'idle', 'checks' => $l99auto['total_checks'] ?? 0, 'dept' => 'L99']; // L99 Pipeline $l99state = @json_decode(@file_get_contents('/var/www/html/api/l99-state.json'), true); $live['L99 Pipeline'] = ['status' => 'active', 'pass' => $l99state['pass'] ?? 0, 'total' => $l99state['total'] ?? 0, 'sigma' => $l99state['sigma']['level'] ?? '?', 'dept' => 'L99']; // Director Agent $live['Director'] = ['status' => file_exists('/opt/wevia-brain/wevia-director-registry.json') ? 'active' : 'idle', 'dept' => 'Director']; // Sentinel $live['Sentinel'] = ['status' => 'active', 'port' => 5890, 'dept' => 'Director']; // === LLM PROVIDERS === $providers = ['Groq','Cerebras','Mistral','SambaNova','DeepSeek','Gemini','HuggingFace']; foreach($providers as $p) { $live[$p] = ['status' => 'active', 'dept' => 'AI', 'type' => 'provider']; } // Ollama (local) $ol = @json_decode(@file_get_contents('http://127.0.0.1:11434/api/tags'), true); $live['Ollama'] = ['status' => $ol ? 'active' : 'down', 'models' => count($ol['models'] ?? []), 'dept' => 'AI']; // === DOCKER CONTAINERS === $dk = shell_exec('docker ps --format "{{.Names}}:{{.Status}}" 2>/dev/null'); foreach(explode("\n", trim($dk ?? '')) as $l) { if(!trim($l)) continue; $p = explode(':', $l, 2); $name = $p[0]; $live[$name] = ['status' => strpos($p[1]??'','Up')!==false ? 'active' : 'down', 'dept' => 'Docker']; } // === KEY PROCESSES === $procs = [ 'php-fpm8.5' => ['PHP-FPM', 'Infra'], 'deerflow' => ['DeerFlow', 'Consult'], 'crowdsec' => ['CrowdSec', 'Security'], 'snap-archiver' => ['SnapArchiver', 'DevOps'], ]; foreach($procs as $grep => $info) { $c = intval(trim(shell_exec("pgrep -c -f $grep 2>/dev/null"))); $live[$info[0]] = ['status' => $c > 0 ? 'active' : 'idle', 'dept' => $info[1]]; } // === ETHICA PIPELINE === $live['Ethica Pipeline'] = ['status' => 'active', 'hcps' => 126203, 'emails' => 109608, 'gap' => 16595, 'crons' => 17, 'dept' => 'Pharma']; // === BLADE === $hb = @json_decode(@file_get_contents('/var/www/html/api/blade-tasks/heartbeat.json'), true); $bladeAge = $hb ? (time() - strtotime($hb['ts'] ?? '2020-01-01')) : 99999; $live['Blade'] = ['status' => $bladeAge < 120 ? 'active' : 'idle', 'dept' => 'DevOps']; // === MEETING ROOMS === $live['Meeting Rooms'] = ['status' => file_exists('/var/www/html/api/wevia-meeting.php') ? 'active' : 'idle', 'dept' => 'Platform']; // === AGENTS ARCHI === $live['Agents Archi'] = ['status' => file_exists('/var/www/html/agents-archi.html') ? 'active' : 'idle', 'dept' => 'Platform']; // === ENTERPRISE MODEL === $live['Enterprise Model'] = ['status' => file_exists('/var/www/html/enterprise-model.html') ? 'active' : 'idle', 'agents' => 300, 'dept' => 'Platform']; // === WEVIA LIFE === $lifeState = @json_decode(@file_get_contents('/var/www/html/api/l99-state.json'), true); $live['WEVIA Life'] = ['status' => 'active', 'dept' => 'CEO']; // === QDRANT RAG === $qd = @json_decode(@file_get_contents('http://127.0.0.1:6333/collections'), true); $live['Qdrant RAG'] = ['status' => $qd ? 'active' : 'down', 'collections' => count($qd['result']['collections'] ?? []), 'dept' => 'AI']; // === WIKI/KB === $live['Wiki KB'] = ['status' => 'active', 'entries' => 2490, 'dept' => 'Platform']; // === KPIs === $live['_kpis'] = [ 'nonreg' => ($l99state['pass'] ?? 0).'/'.($l99state['total'] ?? 0), 'sigma' => $l99state['sigma'] ?? '?', 'tools' => 207, 'arena_models' => 103, 'arena_alive' => '9/10', 'emails' => 109608, 'gap' => 16595, 'docker' => intval(trim(shell_exec('docker ps -q 2>/dev/null | wc -l'))), 'crons' => intval(trim(shell_exec('crontab -l 2>/dev/null | grep -v ^# | grep -c .'))), 'agents_total' => count(array_filter($live, fn($v,$k) => !str_starts_with($k,'_'), ARRAY_FILTER_USE_BOTH)), ]; // === SUMMARY === $activeCount = count(array_filter($live, fn($v) => is_array($v) && ($v['status'] ?? '') === 'active')); $idleCount = count(array_filter($live, fn($v) => is_array($v) && ($v['status'] ?? '') === 'idle')); $downCount = count(array_filter($live, fn($v) => is_array($v) && ($v['status'] ?? '') === 'down')); echo json_encode([ 'ok' => true, 'summary' => ['active' => $activeCount, 'idle' => $idleCount, 'down' => $downCount], 'agents' => $live, 'ts' => date('Y-m-d H:i:s') ], JSON_PRETTY_PRINT);