$name, "source" => "v67_stubs", "category" => "erp_gap_fill", "type" => "enriched_v68", "endpoint" => "/api/agent-stubs/" . basename($f), "status" => "active" ]; } // === 2) Gap-fill manifest (23 + 950 abstract live) === $m = safe_json("/var/www/html/api/weval-agents-gap-fill-manifest.json"); if ($m && isset($m["gap_fill_agents_catalog"])) { foreach ($m["gap_fill_agents_catalog"] as $section => $agents) { if (!is_array($agents)) continue; foreach ($agents as $a) { $id = is_array($a) ? ($a["id"] ?? $a["name"] ?? "?") : strval($a); $nm = is_array($a) ? ($a["name"] ?? $a["filename"] ?? $id) : $id; $all[] = [ "name" => $nm, "source" => "gap_fill_manifest", "category" => $section, "type" => "gap_fill", "id" => $id, "status" => "cataloged" ]; } } } // === 3) agents-catalog.php (19 oh-my-claudecode) === $ctx = @stream_context_create(["http"=>["timeout"=>5,"header"=>"Host: weval-consulting.com"]]); $catraw = @file_get_contents("http://127.0.0.1/api/agents-catalog.php", false, $ctx); $cat = $catraw ? json_decode($catraw, true) : null; if ($cat && isset($cat["agents"])) { foreach ($cat["agents"] as $a) { $all[] = [ "name" => $a["name"] ?? "?", "source" => "oh_my_claudecode", "category" => "consultant", "type" => "prompt_agent", "description" => substr($a["desc"] ?? "", 0, 120), "status" => "cataloged" ]; } } // === 4) V71 extra-agents (10 domain) === $v71raw = @file_get_contents("http://127.0.0.1/api/wevia-orchestrator-extra-agents.php?action=list", false, $ctx); $v71 = $v71raw ? json_decode($v71raw, true) : null; if ($v71 && isset($v71["agents"])) { foreach ($v71["agents"] as $a) { $all[] = [ "name" => $a["name"] ?? "?", "source" => "v71_orchestrator_ext", "category" => "v71_domain", "type" => "php_function", "keywords" => $a["keywords"] ?? [], "status" => "active" ]; } } // === 5) V72 extra-agents (20 domain x 6 categories) === $v72raw = @file_get_contents("http://127.0.0.1/api/wevia-orchestrator-extra-agents-v72.php?action=list", false, $ctx); $v72 = $v72raw ? json_decode($v72raw, true) : null; if ($v72 && isset($v72["agents"])) { foreach ($v72["agents"] as $a) { $all[] = [ "name" => $a["name"] ?? "?", "source" => "v72_orchestrator_ext", "category" => $a["category"] ?? "v72_domain", "type" => "php_function", "keywords" => $a["keywords"] ?? [], "status" => "active" ]; } } // === 6) Core orchestrator hardcoded (16 from wevia-autonomous.php) === $core_agents = ["reconcile","providers","wiki","nonreg","ethica","docker","disk","git","ports","load", "screens_s204","screens_s95","gpus","pmta_all","machines_all","services_s204","crons_all","apis_catalog","mapper_html","git_commit","security_audit"]; foreach ($core_agents as $name) { $all[] = [ "name" => $name, "source" => "core_orchestrator", "category" => "infrastructure", "type" => "shell_cmd", "status" => "active" ]; } // === 7) WEVIA brain system agents (prompts) === foreach (glob("/opt/wevia-brain/prompts/system/agent-prompt-*.md") ?: [] as $f) { $name = basename($f, ".md"); $all[] = [ "name" => $name, "source" => "wevia_brain_prompts", "category" => "prompt_library", "type" => "system_prompt", "status" => "library" ]; } // === 8) Agents registry === $reg = safe_json("/var/www/html/api/wevia-agents-registry.json"); if ($reg && isset($reg["cats"])) { foreach ($reg["cats"] as $cat_name => $val) { $all[] = [ "name" => "registry_" . $cat_name, "source" => "wevia_agents_registry", "category" => "meta", "type" => "category_counter", "count" => is_array($val) ? count($val) : intval($val), "status" => "reference" ]; } } // === 9) agents-full-count contributions === $fcraw = @file_get_contents("http://127.0.0.1/api/agents-full-count.php", false, $ctx); $fc = $fcraw ? json_decode($fcraw, true) : null; if ($fc) { foreach (["blade","cognitive","sovereign","providers","crons"] as $src) { if (!empty($fc[$src]) && is_numeric($fc[$src])) { for ($i = 1; $i <= min(intval($fc[$src]), 100); $i++) { $all[] = [ "name" => $src . "_" . $i, "source" => "agents_full_count", "category" => $src, "type" => "counter_slot", "status" => "counted" ]; } } } } return $all; } $agents = collect_agents(); if ($action === "counts") { $by_source = []; $by_category = []; $by_status = []; foreach ($agents as $a) { $by_source[$a["source"]] = ($by_source[$a["source"]] ?? 0) + 1; $by_category[$a["category"]] = ($by_category[$a["category"]] ?? 0) + 1; $by_status[$a["status"]] = ($by_status[$a["status"]] ?? 0) + 1; } // Read manifest live counter $m = safe_json("/var/www/html/api/weval-agents-gap-fill-manifest.json"); $live_count = $m["meta"]["total_agents_live"] ?? 0; $catalog_count = $m["meta"]["total_agents_catalog"] ?? 0; arsort($by_source); arsort($by_category); echo json_encode([ "ok" => true, "version" => "V73-mega-aggregator", "total_aggregated" => count($agents), "manifest_total_live" => $live_count, "manifest_catalog_total" => $catalog_count, "by_source" => $by_source, "by_category" => $by_category, "by_status" => $by_status, "grand_total_universe" => max(count($agents), $live_count) ], JSON_PRETTY_PRINT); exit; } if ($action === "list") { $result = $agents; if ($category) { $result = array_values(array_filter($result, function($a) use ($category) { return stripos($a["category"], $category) !== false || stripos($a["source"], $category) !== false; })); } if ($query) { $result = array_values(array_filter($result, function($a) use ($query) { return stripos($a["name"], $query) !== false; })); } $total = count($result); $result = array_slice($result, 0, $limit); echo json_encode([ "ok" => true, "total_matched" => $total, "returned" => count($result), "limit" => $limit, "filter" => ["category" => $category, "query" => $query], "agents" => $result ], JSON_PRETTY_PRINT); exit; } if ($action === "categories") { $cats = []; foreach ($agents as $a) { $c = $a["category"]; if (!isset($cats[$c])) $cats[$c] = ["count" => 0, "sources" => []]; $cats[$c]["count"]++; $cats[$c]["sources"][$a["source"]] = ($cats[$c]["sources"][$a["source"]] ?? 0) + 1; } uasort($cats, function($a, $b){ return $b["count"] - $a["count"]; }); echo json_encode(["ok" => true, "total_categories" => count($cats), "categories" => $cats], JSON_PRETTY_PRINT); exit; } if ($action === "search") { if (!$query) { echo json_encode(["ok" => false, "error" => "need q= param"]); exit; } $q = strtolower($query); $matches = []; foreach ($agents as $a) { $hay = strtolower($a["name"] . " " . ($a["category"] ?? "") . " " . ($a["source"] ?? "")); if (strpos($hay, $q) !== false) $matches[] = $a; } echo json_encode([ "ok" => true, "query" => $query, "matched" => count($matches), "top_100" => array_slice($matches, 0, 100) ], JSON_PRETTY_PRINT); exit; } if ($action === "find") { $name = $_REQUEST["name"] ?? ""; if (!$name) { echo json_encode(["ok" => false, "error" => "need name= param"]); exit; } $found = null; foreach ($agents as $a) { if ($a["name"] === $name) { $found = $a; break; } } if (!$found) { echo json_encode(["ok" => false, "error" => "not found", "name" => $name]); exit; } echo json_encode(["ok" => true, "agent" => $found], JSON_PRETTY_PRINT); exit; } echo json_encode(["ok" => false, "error" => "unknown action", "valid" => ["counts","list","categories","search","find"]]);