Files
weval-l99/v97_archi_deep.py
2026-04-24 04:38:58 +02:00

158 lines
6.5 KiB
Python

#!/usr/bin/env python3
"""V97 - Deep analysis of agents-archi overlapping elements via Playwright"""
import asyncio, json, os, urllib.request
from playwright.async_api import async_playwright
OUTPUT_DIR = "/var/www/html/api/blade-tasks/v97-archi-deep"
os.makedirs(OUTPUT_DIR, exist_ok=True)
async def main():
req = urllib.request.Request(
"http://127.0.0.1/api/opus-test-session-v94.php?k=WEVADS2026",
headers={"Host": "weval-consulting.com"}
)
resp_data = urllib.request.urlopen(req, timeout=5).read().decode()
session_id = json.loads(resp_data).get("session_id")
print(f"Session: {session_id}")
async with async_playwright() as p:
browser = await p.chromium.launch(headless=True, args=['--no-sandbox'])
context = await browser.new_context(viewport={'width': 1920, 'height': 1080})
await context.add_cookies([{
"name": "PHPSESSID",
"value": session_id,
"domain": ".weval-consulting.com",
"path": "/",
"secure": True,
"httpOnly": True,
"sameSite": "Lax"
}])
page = await context.new_page()
errs = []
page.on("pageerror", lambda e: errs.append(str(e)[:200]))
# Load agents-archi
await page.goto("https://weval-consulting.com/agents-archi.html", wait_until='load', timeout=30000)
await page.wait_for_timeout(8000)
# Deep inspection
diag = await page.evaluate("""() => {
const result = {
url: location.href,
title: document.title,
body_len: document.body.innerText.length,
scripts_loaded: document.scripts.length,
canvas_count: document.querySelectorAll('canvas').length,
svg_count: document.querySelectorAll('svg').length,
// Canvas specific
canvas_details: [],
// Find overlapping elements
overlaps: [],
// Agent data
agent_vars: {},
// All visible containers
containers: []
};
// Canvas sizes
document.querySelectorAll('canvas').forEach((c, i) => {
result.canvas_details.push({
id: c.id || `canvas-${i}`,
width: c.width,
height: c.height,
display_width: c.offsetWidth,
display_height: c.offsetHeight
});
});
// Detect known globals
['AG','DP','NODES','AGENTS','AGENT_DATA','ORG','TEAMS'].forEach(v => {
try {
const val = window[v];
if (val !== undefined) {
result.agent_vars[v] = Array.isArray(val) ? `array(${val.length})` : typeof val;
}
} catch(e){}
});
// Find overlapping agent elements
const els = document.querySelectorAll('.agent, .node, .card, [class*="agent-"], [class*="node-"], svg g, svg circle');
const rects = [];
for (let i = 0; i < Math.min(els.length, 200); i++) {
const r = els[i].getBoundingClientRect();
if (r.width > 10 && r.height > 10) {
rects.push({
idx: i,
r: r,
cls: els[i].className.toString().substring(0, 50),
text: (els[i].textContent || '').substring(0, 30).trim()
});
}
}
for (let i = 0; i < rects.length; i++) {
for (let j = i + 1; j < rects.length; j++) {
const r1 = rects[i].r, r2 = rects[j].r;
const ox = Math.max(0, Math.min(r1.right, r2.right) - Math.max(r1.left, r2.left));
const oy = Math.max(0, Math.min(r1.bottom, r2.bottom) - Math.max(r1.top, r2.top));
const overlap = ox * oy;
const smaller = Math.min(r1.width*r1.height, r2.width*r2.height);
if (smaller > 0 && overlap / smaller > 0.7) {
result.overlaps.push({
a: { cls: rects[i].cls, text: rects[i].text, x: Math.round(r1.left), y: Math.round(r1.top), w: Math.round(r1.width), h: Math.round(r1.height) },
b: { cls: rects[j].cls, text: rects[j].text, x: Math.round(r2.left), y: Math.round(r2.top), w: Math.round(r2.width), h: Math.round(r2.height) },
overlap_pct: Math.round(overlap/smaller*100)
});
}
}
}
// Container structure
['#root', '#app', '#main', 'main', '.container', '.hero', 'section'].forEach(sel => {
const el = document.querySelector(sel);
if (el) {
result.containers.push({
sel,
w: el.offsetWidth,
h: el.offsetHeight,
text_sample: (el.textContent || '').substring(0, 100).trim()
});
}
});
return result;
}""")
diag['js_errors'] = errs[:10]
await page.screenshot(path=f"{OUTPUT_DIR}/agents-archi-full.png", full_page=True)
# Screenshot viewport only (top of page)
await page.screenshot(path=f"{OUTPUT_DIR}/agents-archi-viewport.png", full_page=False)
await context.close()
await browser.close()
with open(f"{OUTPUT_DIR}/diagnostic.json", "w") as f:
json.dump(diag, f, indent=2)
# Print summary
print(json.dumps({
"title": diag.get('title'),
"body_len": diag.get('body_len'),
"scripts_loaded": diag.get('scripts_loaded'),
"canvas": diag.get('canvas_count'),
"svg": diag.get('svg_count'),
"canvas_details": diag.get('canvas_details'),
"agent_vars": diag.get('agent_vars'),
"containers": diag.get('containers'),
"overlap_count": len(diag.get('overlaps', [])),
"overlaps_sample": diag.get('overlaps', [])[:3],
"js_errors": diag.get('js_errors')
}, indent=2))
asyncio.run(main())