41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""V101b - Enrich orchestrator-agents.php totals to include catalog total"""
|
|
path = "/var/www/html/api/orchestrator-agents.php"
|
|
with open(path, "r", encoding="utf-8") as f:
|
|
code = f.read()
|
|
|
|
if "catalog_total" in code:
|
|
print("ALREADY")
|
|
exit(0)
|
|
|
|
# Add catalog fetch + catalog_total in totals
|
|
old = '''// Registry tools par catgorie
|
|
$reg = @json_decode(@file_get_contents("/opt/wevia-brain/tool-registry-v2.json"), true);
|
|
$tool_count = count($reg["tools"] ?? []);'''
|
|
|
|
new = '''// Registry tools par catgorie
|
|
$reg = @json_decode(@file_get_contents("/opt/wevia-brain/tool-registry-v2.json"), true);
|
|
$tool_count = count($reg["tools"] ?? []);
|
|
|
|
// V101: Unified catalog total (includes business agents from enterprise-model)
|
|
$catalog = @json_decode(@file_get_contents("http://127.0.0.1/api/agents-catalog-api.php"), true);
|
|
$catalog_total = $catalog["total"] ?? 0;
|
|
$catalog_cats = $catalog["categories"] ?? [];'''
|
|
|
|
if old not in code:
|
|
print("MARKER NOT FOUND")
|
|
exit(1)
|
|
code = code.replace(old, new)
|
|
|
|
# Add catalog_total in totals output
|
|
old2 = '"registry_tools" => $tool_count,'
|
|
new2 = '''"registry_tools" => $tool_count,
|
|
"catalog_total" => $catalog_total,
|
|
"catalog_categories" => $catalog_cats,'''
|
|
|
|
code = code.replace(old2, new2)
|
|
|
|
with open(path, "w", encoding="utf-8") as f:
|
|
f.write(code)
|
|
print(f"PATCHED. size={len(code)}")
|