#!/bin/bash python3 << 'PY' import json, re, urllib.request, os, subprocess with urllib.request.urlopen('https://weval-consulting.com/api/agent-avatars-v2.json', timeout=5) as r: v2 = json.load(r) missing = [] c = open('/var/www/html/agents-archi.html').read() for m in re.finditer(r"\{n:'([^']+)',t:(\d+)", c): name = m.group(1) if name not in v2 and not any(k.lower()==name.lower() for k in v2.keys()): missing.append(name) report = { 'ts': __import__('datetime').datetime.now().isoformat(), 'v2_entries': len(v2), 'missing_count': len(missing), 'missing_agents': missing, 'status': 'OK' if len(missing)==0 else 'WARN', } json.dump(report, open('/var/www/html/api/agent-persona-coverage.json','w'), indent=2, ensure_ascii=False) os.chmod('/var/www/html/api/agent-persona-coverage.json', 0o644) subprocess.run(['chown','www-data:www-data','/var/www/html/api/agent-persona-coverage.json']) print(f"coverage: {report['status']} missing={len(missing)} v2={len(v2)}") PY