Compare commits
68 Commits
wave-228-g
...
wave-252-p
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40af847595 | ||
|
|
070b98d2e4 | ||
|
|
4bab633ca1 | ||
|
|
d8229af9dc | ||
|
|
5f8c105d23 | ||
|
|
56081177eb | ||
|
|
45662604ce | ||
|
|
f810b33f32 | ||
|
|
758b8409a0 | ||
|
|
fdd25b57d2 | ||
|
|
5e53410ed3 | ||
|
|
9076c69f4b | ||
|
|
80a7bf6afe | ||
|
|
23c996457b | ||
|
|
cb99c36666 | ||
|
|
8f954813aa | ||
|
|
f4e563da77 | ||
|
|
98b0721571 | ||
|
|
09d4560239 | ||
|
|
d3d568c020 | ||
|
|
5a96a06a08 | ||
|
|
218a903a3b | ||
|
|
5f2f7612ee | ||
|
|
59c686e975 | ||
|
|
3daf0b922c | ||
|
|
8c199e80d7 | ||
|
|
9e870d7919 | ||
|
|
d1e4930ef9 | ||
|
|
994e0413e9 | ||
|
|
c08fd1117b | ||
|
|
001b9b104d | ||
|
|
3c09a5e5b1 | ||
|
|
324698c5cf | ||
|
|
c8019a2d72 | ||
|
|
0830dbddf2 | ||
|
|
71ac5c5a38 | ||
|
|
d7fbb6c2b6 | ||
|
|
62bf54f93d | ||
|
|
c67ba9c962 | ||
|
|
54c7e3ec4d | ||
|
|
39904106c9 | ||
|
|
843abe732c | ||
|
|
c22547a33e | ||
|
|
5ab3e108eb | ||
|
|
cfae522ed4 | ||
|
|
9797434c72 | ||
|
|
134eff6a06 | ||
|
|
1cc3ae62a8 | ||
|
|
cfc0c28610 | ||
|
|
309ca20fcf | ||
|
|
decde3ae1c | ||
|
|
e15ac4d968 | ||
|
|
e57f89ce86 | ||
|
|
7ac430f9ca | ||
|
|
9447d5a39e | ||
|
|
66bb848446 | ||
|
|
c77665eeeb | ||
|
|
9f1414d8e1 | ||
|
|
9e33717e71 | ||
|
|
d7573697c4 | ||
|
|
464843a3f7 | ||
|
|
a30621772a | ||
|
|
6a27358e14 | ||
|
|
a632ef9b6e | ||
|
|
d626ff474f | ||
|
|
d96f1e4361 | ||
|
|
e12120c7a3 | ||
|
|
c30afe2de4 |
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"agent": "V41_Disk_Monitor",
|
||||
"ts": "2026-04-22T02:00:02+02:00",
|
||||
"disk_pct": 84,
|
||||
"disk_free_gb": 25,
|
||||
"ts": "2026-04-22T04:00:02+02:00",
|
||||
"disk_pct": 85,
|
||||
"disk_free_gb": 22,
|
||||
"growth_per_day_gb": 1.5,
|
||||
"runway_days": 16,
|
||||
"runway_days": 14,
|
||||
"alert": "WARN_runway_under_30d",
|
||||
"action_auto_if_under_7d": "trigger_hetzner_volume_extension_api",
|
||||
"hetzner_volume_size_gb_recommended": 500,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"agent": "V41_Risk_Escalation",
|
||||
"ts": "2026-04-22T02:00:03+02:00",
|
||||
"ts": "2026-04-22T04:00:04+02:00",
|
||||
"dg_alerts_active": 7,
|
||||
"wevia_life_stats_preview": "{
|
||||
"ok": true,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"agent": "V41_Feature_Adoption_Tracker",
|
||||
"ts": "2026-04-22T02:00:02+02:00",
|
||||
"ts": "2026-04-22T04:00:02+02:00",
|
||||
"features_tracked": 15,
|
||||
"features_used_24h": 11,
|
||||
"adoption_pct": 73,
|
||||
"chat_queries_last_1k_log": 4,
|
||||
"wtp_views_last_1k_log": 41,
|
||||
"features_used_24h": 10,
|
||||
"adoption_pct": 66,
|
||||
"chat_queries_last_1k_log": 0,
|
||||
"wtp_views_last_1k_log": 1,
|
||||
"dg_views_last_1k_log": 0,
|
||||
"skill_runs_last_1k_log": 0,
|
||||
"recommendation": "UX onboarding tour for unused features",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"agent": "V45_Leads_Sync",
|
||||
"ts": "2026-04-22T02:00:05+02:00",
|
||||
"ts": "2026-04-22T04:10:02+02:00",
|
||||
"paperclip_total": 48,
|
||||
"active_customer": 4,
|
||||
"warm_prospect": 5,
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"agent": "V41_MQL_Scoring",
|
||||
"ts": "2026-04-22T02:00:03+02:00",
|
||||
"ts": "2026-04-22T04:00:04+02:00",
|
||||
"leads_total": 48,
|
||||
"mql_current": 16,
|
||||
"sql_current": 6,
|
||||
"conversion_mql_sql_pct": 37.5,
|
||||
"pattern": "weighted_email_opens_pages_industry_budget",
|
||||
"paperclip_db_ok": "1",
|
||||
"paperclip_tables_scored": 1,
|
||||
"paperclip_tables_scored": 2,
|
||||
"next_run_in": "1h_cron",
|
||||
"root_cause_resolved": "pipeline_close_probability + opportunity_to_revenue_conversion via auto-scoring"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"ts": "2026-04-21T03:00:03.321261",
|
||||
"ts": "2026-04-22T03:00:03.853778",
|
||||
"v2_entries": 775,
|
||||
"missing_count": 1,
|
||||
"missing_agents": [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"agent": "V54_Risk_Monitor_Live",
|
||||
"ts": "2026-04-22T02:00:04+02:00",
|
||||
"ts": "2026-04-22T04:00:04+02:00",
|
||||
"critical_risks": {
|
||||
"RW01_pipeline_vide": {
|
||||
"pipeline_keur": 0,
|
||||
@@ -22,7 +22,7 @@
|
||||
},
|
||||
"RW12_burnout": {
|
||||
"agents_cron_active": 15,
|
||||
"load_5min": "11.29",
|
||||
"load_5min": "11.73",
|
||||
"automation_coverage_pct": 70,
|
||||
"residual_risk_pct": 60,
|
||||
"trend": "V52_goldratt_options_active"
|
||||
|
||||
@@ -1,18 +1,23 @@
|
||||
{
|
||||
"timestamp": "2026-04-22 02:00",
|
||||
"timestamp": "2026-04-22 04:00",
|
||||
"sections": {
|
||||
"servers": {
|
||||
"S204": {
|
||||
"docker": 20,
|
||||
"disk": "84%",
|
||||
"docker": 19,
|
||||
"disk": "85%",
|
||||
"ram": "13Gi/30Gi",
|
||||
"load": "6.51",
|
||||
"uptime": "up 1 week, 14 hours, 8 minutes"
|
||||
"load": "13.04",
|
||||
"uptime": "up 1 week, 16 hours, 8 minutes"
|
||||
}
|
||||
},
|
||||
"docker": {
|
||||
"count": 19,
|
||||
"count": 20,
|
||||
"containers": [
|
||||
{
|
||||
"name": "weval-docuseal",
|
||||
"status": "Up Less than a second",
|
||||
"ports": ""
|
||||
},
|
||||
{
|
||||
"name": "loki",
|
||||
"status": "Up 5 days",
|
||||
@@ -65,7 +70,7 @@
|
||||
},
|
||||
{
|
||||
"name": "langfuse",
|
||||
"status": "Up 5 days",
|
||||
"status": "Up 6 days",
|
||||
"ports": ""
|
||||
},
|
||||
{
|
||||
@@ -481,7 +486,7 @@
|
||||
]
|
||||
},
|
||||
"pages": {
|
||||
"count": 319
|
||||
"count": 324
|
||||
},
|
||||
"opt_tools": {
|
||||
"count": 95
|
||||
|
||||
32
api/ambre-cachebust.php
Normal file
32
api/ambre-cachebust.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/var/www/html/wevia.html";
|
||||
$c = @file_get_contents($path);
|
||||
|
||||
// Add cache bust to wevia-sse-override.js reference
|
||||
$cb = "v=" . time();
|
||||
$old = 'src="/js/wevia-sse-override.js"';
|
||||
$new = 'src="/js/wevia-sse-override.js?' . $cb . '"';
|
||||
|
||||
if (strpos($c, $old) === false) {
|
||||
// try alt
|
||||
$old = "src=/js/wevia-sse-override.js";
|
||||
$new = 'src="/js/wevia-sse-override.js?' . $cb . '"';
|
||||
}
|
||||
|
||||
$has = strpos($c, $old);
|
||||
if ($has === false) {
|
||||
echo json_encode(["error"=>"not found", "snippet"=>substr($c, 0, 2000)]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$new_c = str_replace($old, $new, $c);
|
||||
$backup = "/opt/wevads/vault/wevia.html.GOLD-" . date("Ymd-His") . "-cachebust";
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, $new_c);
|
||||
|
||||
echo json_encode([
|
||||
"delta" => strlen($new_c) - strlen($c),
|
||||
"wrote" => $wrote,
|
||||
"cb" => $cb,
|
||||
]);
|
||||
20
api/ambre-cascade-chk.php
Normal file
20
api/ambre-cascade-chk.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$ctx = stream_context_create(["http"=>["timeout"=>5]]);
|
||||
$h = @file_get_contents("http://127.0.0.1:4000/health", false, $ctx);
|
||||
|
||||
$test = @file_get_contents("http://127.0.0.1:4000/v1/chat/completions", false, stream_context_create([
|
||||
"http"=>["method"=>"POST","header"=>"Content-Type: application/json\r\n",
|
||||
"content"=>json_encode(["model"=>"fast","messages"=>[["role"=>"user","content"=>"hi"]],"max_tokens"=>15]),
|
||||
"timeout"=>15]
|
||||
]));
|
||||
|
||||
$load = trim(shell_exec("uptime"));
|
||||
$fpm = intval(shell_exec("pgrep -c php-fpm8"));
|
||||
|
||||
echo json_encode([
|
||||
"health" => substr($h ?: "DOWN", 0, 300),
|
||||
"direct_test" => substr($test ?: "FAILED", 0, 200),
|
||||
"load" => $load,
|
||||
"fpm" => $fpm,
|
||||
], JSON_PRETTY_PRINT);
|
||||
7
api/ambre-cascade-test.php
Normal file
7
api/ambre-cascade-test.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$ctx = stream_context_create(["http"=>["method"=>"POST","header"=>"Content-Type: application/json\r\n","content"=>json_encode(["model"=>"fast","messages"=>[["role"=>"user","content"=>"HI"]],"max_tokens"=>50]),"timeout"=>10]]);
|
||||
$t0 = microtime(true);
|
||||
$resp = @file_get_contents("http://127.0.0.1:4000/v1/chat/completions", false, $ctx);
|
||||
$el = round((microtime(true)-$t0)*1000);
|
||||
echo json_encode(["elapsed_ms"=>$el, "ok"=>(bool)$resp, "first"=>substr($resp?:"empty",0,200)]);
|
||||
25
api/ambre-cf-purge.php
Normal file
25
api/ambre-cf-purge.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$secrets_raw = @file_get_contents("/etc/weval/secrets.env");
|
||||
$cf_token = "";
|
||||
if (preg_match('/^CF_API_TOKEN=(.+)$/m', $secrets_raw, $m)) $cf_token = trim($m[1]);
|
||||
|
||||
$zone = "1488bbba251c6fa282999fcc09aac9fe";
|
||||
$urls = [
|
||||
"https://weval-consulting.com/js/wevia-sse-override.js",
|
||||
"https://weval-consulting.com/wevia.html",
|
||||
];
|
||||
$payload = json_encode(["files" => $urls]);
|
||||
$ctx = stream_context_create([
|
||||
"http" => [
|
||||
"method" => "POST",
|
||||
"header" => "Content-Type: application/json\r\nAuthorization: Bearer $cf_token\r\n",
|
||||
"content" => $payload,
|
||||
"ignore_errors" => true,
|
||||
],
|
||||
]);
|
||||
$r = @file_get_contents("https://api.cloudflare.com/client/v4/zones/$zone/purge_cache", false, $ctx);
|
||||
echo json_encode([
|
||||
"token_len" => strlen($cf_token),
|
||||
"result" => substr($r, 0, 500),
|
||||
]);
|
||||
14
api/ambre-chrome-test.php
Normal file
14
api/ambre-chrome-test.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$test_html = "/tmp/test-chart2.html";
|
||||
file_put_contents($test_html, '<html><head><script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script></head><body><h1>Chart test</h1><canvas id="c" width="400" height="200"></canvas><script>window.addEventListener("load",function(){var ctx=document.getElementById("c").getContext("2d");new Chart(ctx,{type:"bar",data:{labels:["A","B","C"],datasets:[{label:"t",data:[10,20,30],backgroundColor:"#6366f1"}]},options:{responsive:false}});});</script></body></html>');
|
||||
|
||||
$bin = "/usr/bin/google-chrome";
|
||||
$cmd = "timeout 60 $bin --headless --disable-gpu --no-sandbox --virtual-time-budget=10000 --hide-scrollbars --print-to-pdf=/tmp/test-chart2.pdf --print-to-pdf-no-header file:///tmp/test-chart2.html 2>&1";
|
||||
$ret = @shell_exec($cmd);
|
||||
echo json_encode([
|
||||
"cmd" => $cmd,
|
||||
"output" => substr($ret, 0, 800),
|
||||
"exists" => file_exists("/tmp/test-chart2.pdf"),
|
||||
"size" => file_exists("/tmp/test-chart2.pdf") ? filesize("/tmp/test-chart2.pdf") : 0,
|
||||
]);
|
||||
32
api/ambre-chromium-check.php
Normal file
32
api/ambre-chromium-check.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$out = [];
|
||||
// Find all chromium-like binaries
|
||||
foreach (["/usr/bin/chromium-browser","/usr/bin/chromium","/usr/bin/google-chrome","/snap/bin/chromium","/usr/bin/chrome"] as $b) {
|
||||
$out["binaries"][$b] = file_exists($b);
|
||||
}
|
||||
|
||||
// Test headless
|
||||
$test_html = "/tmp/test-chart.html";
|
||||
file_put_contents($test_html, '<html><body><h1>test</h1><script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script><canvas id="c"></canvas><script>setTimeout(()=>{var ctx=document.getElementById("c");new Chart(ctx,{type:"bar",data:{labels:["A","B","C"],datasets:[{data:[1,2,3]}]}});},500);</script></body></html>');
|
||||
|
||||
// Find bin
|
||||
$bin = null;
|
||||
foreach (["/usr/bin/chromium","/usr/bin/chromium-browser","/snap/bin/chromium","/usr/bin/google-chrome"] as $b) {
|
||||
if (file_exists($b) || @shell_exec("which " . basename($b) . " 2>/dev/null")) {
|
||||
$bin = $b;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$out["chosen_bin"] = $bin;
|
||||
|
||||
if ($bin) {
|
||||
$cmd = "timeout 30 $bin --headless --disable-gpu --no-sandbox --virtual-time-budget=8000 --print-to-pdf=/tmp/test-chart.pdf --print-to-pdf-no-header file:///tmp/test-chart.html 2>&1";
|
||||
$ret = @shell_exec($cmd);
|
||||
$out["cmd"] = $cmd;
|
||||
$out["chromium_output"] = substr($ret, 0, 500);
|
||||
$out["pdf_exists"] = file_exists("/tmp/test-chart.pdf");
|
||||
$out["pdf_size"] = $out["pdf_exists"] ? filesize("/tmp/test-chart.pdf") : 0;
|
||||
}
|
||||
|
||||
echo json_encode($out, JSON_PRETTY_PRINT);
|
||||
8
api/ambre-doctrine-110.php
Normal file
8
api/ambre-doctrine-110.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/opt/obsidian-vault/doctrines/110-wave234-mermaid-pdf-ethica.md";
|
||||
$dir = dirname($path);
|
||||
if (!is_dir($dir)) @mkdir($dir, 0777, true);
|
||||
$content = base64_decode("IyAxMTAgwrcgV2F2ZS0yMzQgwrcgTWVybWFpZCBpbmxpbmUgcmVuZGVyIGZpbmFsICsgaTE4biBQREYgKyBFdGhpY2EgdmVyaWZpZWQKCioqV2F2ZSoqIDogMjM0ICh3YXZlLTIyOSBleHRlbmRlZCkKKipUYWcqKiA6IGB3YXZlLTIzNC1tZXJtYWlkLXBkZi1pMThuLWV0aGljYWAKKipEYXRlKiogOiAyMDI2LTA0LTIyCioqU3RhdHVzKiogOiDinIUgTElWRQoKIyMg8J+OryBMaXZyYWJsZXMKCiMjIyAxLiBNZXJtYWlkIGlubGluZSBTVkcgcmVuZGVyIFdPUktJTkcKLSAqKkNhdXNlIHJhY2luZSoqIGlkZW50aWZpw6llIDogYG1lcm1haWQucnVuKClgIHJldG91cm5haXQgU1ZHIDE2eDE2ICh2aWV3Qm94IHRpbnkpIMOgIGNhdXNlIGFjY2VudHMgZGFucyBjb2RlCi0gKipGaXgqKiA6IHNhbml0aXplIGFjY2VudHMgKMOp4oaSZSwgw6DihpJhLCBldGMuKSArIHV0aWxpc2VyIGBtZXJtYWlkLnJlbmRlcigpYCBBUEkgZGlyZWN0ZQotICoqVmFsaWRhdGlvbioqIDogc3ZnX3dpZHRoOiA2Nzggwrcgc3ZnX2hlaWdodDogNTI0IMK3IHZpZXdCb3g6ICItOCAtOCAzODUgMjk4IgotICoqVml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ENhdGFsb2cgMjA2IHRvb2xzKSBzb250IHJlbGnDqXMuCgojIyMgRG9jdHJpbmVzIGFwcGxpcXXDqWVzICh2YXVsdCBjb3VudCA9IDk3KQotIDEgwrcgU2NhbiBleGhhdXN0aWYgYXV0cmVzIENsYXVkZQotIDMgwrcgR09MRCBiYWNrdXAgYXV0bwotIDQgwrcgSG9ubsOqdGV0w6kgYWJzb2x1ZSAoc291cmNlIHbDqXJpdMOpIHVuaWZpw6llKQotIDE0IMK3IFplcm8gw6ljcmFzZW1lbnQgKGFkZGl0aWYgdW5pcXVlbWVudCkKLSAxNiDCtyBaZXJvIHLDqWdyZXNzaW9uCi0gNjAgwrcgVVggUHJlbWl1bQotIDEwOSDCtyBXYXZlLTIyOSBzdGFiaWxpdHkgKHByw6ljw6lkZW50ZSkKLSAqKjExMCDCtyBDZSBkb2N0cmluZSoqICh3YXZlLTIzNCBjb25zb2xpZGF0aW9uKQo=");
|
||||
$w = @file_put_contents($path, $content);
|
||||
echo json_encode(["path"=>$path, "wrote"=>$w, "size"=>strlen($content)]);
|
||||
8
api/ambre-doctrine-111.php
Normal file
8
api/ambre-doctrine-111.php
Normal file
File diff suppressed because one or more lines are too long
12
api/ambre-ethica-scan.php
Normal file
12
api/ambre-ethica-scan.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
header("Content-Type: text/plain");
|
||||
echo "=== ecm.py header ===\n";
|
||||
echo @shell_exec("head -50 /opt/weval-l99/ecm.py 2>&1");
|
||||
echo "\n\n=== consent.wevup.app tests ===\n";
|
||||
echo @shell_exec("curl -sS --max-time 5 -o /tmp/consent.html -w 'HTTP %{http_code} Size %{size_download}' https://consent.wevup.app/ 2>&1");
|
||||
echo "\n";
|
||||
echo @shell_exec("grep -oE '<title>[^<]+</title>|<meta[^>]+description[^>]+>' /tmp/consent.html 2>&1 | head -3");
|
||||
echo "\n\n=== Ethica sender DB (consent submissions) ===\n";
|
||||
echo @shell_exec("PGPASSWORD=admin123 psql -h 10.1.0.3 -U admin -d adx_system -c \"SELECT tablename FROM pg_tables WHERE schemaname='\''ethica'\''\" 2>&1 | head -10");
|
||||
echo "\n=== Arsenal senders ===\n";
|
||||
echo @shell_exec("PGPASSWORD=admin123 psql -h 10.1.0.3 -U admin -d adx_system -c \"SELECT COUNT(*) FROM ethica.senders\" 2>&1 | head -5");
|
||||
12
api/ambre-ethica-test.php
Normal file
12
api/ambre-ethica-test.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
header("Content-Type: text/plain");
|
||||
echo "=== ecm status ===\n";
|
||||
echo @shell_exec("python3 /opt/weval-l99/ecm.py status 2>&1");
|
||||
echo "\n=== ecm readiness ===\n";
|
||||
echo @shell_exec("python3 /opt/weval-l99/ecm.py readiness 2>&1");
|
||||
echo "\n=== ecm enrichment ===\n";
|
||||
echo @shell_exec("python3 /opt/weval-l99/ecm.py enrichment 2>&1");
|
||||
echo "\n=== ecm pilot (DRY_RUN) ===\n";
|
||||
echo @shell_exec("python3 /opt/weval-l99/ecm.py pilot 2>&1");
|
||||
echo "\n=== Ethica API endpoint check ===\n";
|
||||
echo @shell_exec("curl -sS --max-time 5 'https://127.0.0.1/api/ethica-api.php?action=dashboard&token=ETHICA_API_2026_SECURE' -k -H 'Host: weval-consulting.com' 2>&1 | head -c 500");
|
||||
32
api/ambre-export-v30.php
Normal file
32
api/ambre-export-v30.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$src_dir = "/var/www/html/api/ambre-pw-tests/output";
|
||||
$dest_dir = "/var/www/html/generated";
|
||||
if (!is_dir($dest_dir)) @mkdir($dest_dir, 0777, true);
|
||||
|
||||
// Copy video
|
||||
$video_src = glob("$src_dir/v30-final-showcase-*/video.webm")[0] ?? null;
|
||||
$out = [];
|
||||
|
||||
if ($video_src) {
|
||||
$dest = "$dest_dir/wevia-v30-showcase-" . date("Ymd-His") . ".webm";
|
||||
@copy($video_src, $dest);
|
||||
@chmod($dest, 0644);
|
||||
$out["video"] = [
|
||||
"url" => "/generated/" . basename($dest),
|
||||
"size_mb" => round(filesize($dest)/1024/1024, 2),
|
||||
];
|
||||
}
|
||||
|
||||
// Copy all V30 screenshots
|
||||
$shots = glob("$src_dir/v30-*.png");
|
||||
$out["screenshots"] = [];
|
||||
foreach ($shots as $s) {
|
||||
$bn = basename($s);
|
||||
$d = "$dest_dir/$bn";
|
||||
@copy($s, $d);
|
||||
$out["screenshots"][] = "/generated/$bn";
|
||||
}
|
||||
$out["shots_count"] = count($out["screenshots"]);
|
||||
|
||||
echo json_encode($out, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|
||||
28
api/ambre-export-v39.php
Normal file
28
api/ambre-export-v39.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$src_dir = "/var/www/html/api/ambre-pw-tests/output";
|
||||
$dest_dir = "/var/www/html/generated";
|
||||
|
||||
$out = ["copied" => []];
|
||||
|
||||
// Copy V39 screenshots
|
||||
foreach (glob("$src_dir/v39-*.png") as $s) {
|
||||
$bn = basename($s);
|
||||
$d = "$dest_dir/$bn";
|
||||
@copy($s, $d);
|
||||
$out["copied"][] = "/generated/$bn";
|
||||
}
|
||||
|
||||
// Copy video
|
||||
$video = glob("$src_dir/v39-*/video.webm");
|
||||
if ($video) {
|
||||
$dest_v = "$dest_dir/wevia-v39-showcase-" . date("Ymd-His") . ".webm";
|
||||
@copy($video[0], $dest_v);
|
||||
@chmod($dest_v, 0644);
|
||||
$out["video"] = [
|
||||
"url" => "/generated/" . basename($dest_v),
|
||||
"size_mb" => round(filesize($dest_v)/1024/1024, 2),
|
||||
];
|
||||
}
|
||||
|
||||
echo json_encode($out, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|
||||
20
api/ambre-export-v42.php
Normal file
20
api/ambre-export-v42.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$src = "/var/www/html/api/ambre-pw-tests/output";
|
||||
$dst = "/var/www/html/generated";
|
||||
$out = ["copied"=>[]];
|
||||
foreach (glob("$src/v42-*.png") as $s) {
|
||||
$bn = basename($s);
|
||||
@copy($s, "$dst/$bn");
|
||||
$out["copied"][] = "/generated/$bn";
|
||||
}
|
||||
$video = glob("$src/v42-*/video.webm");
|
||||
if ($video) {
|
||||
$dv = "$dst/wevia-v42-hub-showcase-" . date("Ymd-His") . ".webm";
|
||||
@copy($video[0], $dv);
|
||||
$out["video"] = [
|
||||
"url" => "/generated/" . basename($dv),
|
||||
"size_mb" => round(filesize($dv)/1024/1024, 2),
|
||||
];
|
||||
}
|
||||
echo json_encode($out, JSON_UNESCAPED_SLASHES);
|
||||
21
api/ambre-final-commit.php
Normal file
21
api/ambre-final-commit.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
header("Content-Type: text/plain");
|
||||
|
||||
// Commit vault doctrine 109 (vault has its own git if any)
|
||||
chdir("/opt/obsidian-vault");
|
||||
$vault_git = @shell_exec("git status 2>&1 | head -5");
|
||||
echo "=== Vault git status ===\n$vault_git\n";
|
||||
if (strpos($vault_git, "fatal") === false) {
|
||||
echo @shell_exec("git -c user.email='ambre@weval.com' -c user.name='Ambre WEVIA' add doctrines/109-wave229-6sigma-sse-pdf-premium.md && git -c user.email='ambre@weval.com' -c user.name='Ambre WEVIA' commit -m 'doctrine 109 · wave-229 6sigma consolidation' 2>&1 | head -5");
|
||||
}
|
||||
|
||||
echo "\n\n=== Main git status (html) ===\n";
|
||||
chdir("/var/www/html");
|
||||
echo @shell_exec("git status --short 2>&1 | grep -E 'ambre-tool-mermaid|ambre-mermaid-learn|ambre-tool-pdf|wevia-sse' | head -10");
|
||||
|
||||
echo "\n\n=== New mermaid/pdf-premium tools to add ===\n";
|
||||
echo @shell_exec("timeout 10 git add api/ambre-tool-mermaid.php api/ambre-mermaid-learn.php 2>&1");
|
||||
echo @shell_exec("timeout 10 git -c user.email='ambre@weval.com' -c user.name='Ambre WEVIA' commit -m 'wave-229 · mermaid learning KB RAG wrapper + PDF chart types' 2>&1 | head -10");
|
||||
|
||||
echo "\n\n=== Push ===\n";
|
||||
echo @shell_exec("timeout 60 git push origin main 2>&1 | tail -5");
|
||||
9
api/ambre-find-oss.php
Normal file
9
api/ambre-find-oss.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$locations = @shell_exec("find /var/www /opt -name 'oss-registry*.json' 2>/dev/null | head -10");
|
||||
$loc2 = @shell_exec("find /var/www /opt -name 'oss*manifest*.json' 2>/dev/null | head -10");
|
||||
echo json_encode([
|
||||
"oss_registry" => trim($locations),
|
||||
"oss_manifest" => trim($loc2),
|
||||
"opt_oss" => @shell_exec("ls /opt/oss/ 2>&1 | head -10"),
|
||||
], JSON_PRETTY_PRINT);
|
||||
42
api/ambre-find-v8.php
Normal file
42
api/ambre-find-v8.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$c = @file_get_contents("/var/www/html/wevia.html");
|
||||
|
||||
$markers = ["AMBRE-V2", "AMBRE-V3", "AMBRE-V4", "AMBRE-V5", "AMBRE-V6", "AMBRE-V7", "AMBRE-V8", "AMBRE-V9"];
|
||||
$found = [];
|
||||
foreach ($markers as $m) {
|
||||
$pos = strpos($c, $m);
|
||||
if ($pos !== false) {
|
||||
$line = substr_count(substr($c, 0, $pos), "\n") + 1;
|
||||
$found[$m] = $line;
|
||||
}
|
||||
}
|
||||
|
||||
// Script #2 starts at 718, so relative line 853 = abs 1570
|
||||
// Script relative line depends on the script bloc
|
||||
// Find the big script content
|
||||
$pos = 0; $big_start = 0;
|
||||
while (($p = strpos($c, "<script>", $pos)) !== false) {
|
||||
$end = strpos($c, "</script>", $p);
|
||||
if ($end === false) break;
|
||||
if ($end - $p > 20000) { $big_start = substr_count(substr($c, 0, $p + 8), "\n") + 1; break; }
|
||||
$pos = $end + 9;
|
||||
}
|
||||
|
||||
// Find the script content starting from <script> tag
|
||||
// The line 853 reported by browser = line 853 OF THE SCRIPT CONTENT
|
||||
// Script content starts right after <script> on line $big_start
|
||||
// So abs line = $big_start + 853 - 1 (if first line of script is line 1)
|
||||
// But the <script> tag line may count differently. Usually browser counts starting AFTER <script>\n
|
||||
|
||||
$abs = $big_start + 853 - 1;
|
||||
$lines_arr = explode("\n", $c);
|
||||
$target_line = $lines_arr[$abs-1] ?? "";
|
||||
|
||||
echo json_encode([
|
||||
"markers_found" => $found,
|
||||
"big_script_start_line" => $big_start,
|
||||
"target_abs_line" => $abs,
|
||||
"target_line_content" => substr($target_line, 0, 300),
|
||||
"target_length" => strlen($target_line),
|
||||
], JSON_PRETTY_PRINT);
|
||||
33
api/ambre-git-234.php
Normal file
33
api/ambre-git-234.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
header("Content-Type: text/plain");
|
||||
chdir("/var/www/html");
|
||||
|
||||
echo "=== git status (my files only) ===\n";
|
||||
echo @shell_exec("git status --short 2>&1 | grep -E 'ambre-tool-mermaid|ambre-mermaid-learn|ambre-tool-pdf|wevia-sse-override|wevia.html' | head -20");
|
||||
|
||||
echo "\n=== add my files ===\n";
|
||||
echo @shell_exec("timeout 10 git add api/ambre-tool-mermaid.php api/ambre-mermaid-learn.php api/ambre-tool-pdf-premium.php api/ambre-llm-semaphore.php api/ambre-session-chat.php js/wevia-sse-override.js wevia.html 2>&1");
|
||||
|
||||
echo "\n=== commit ===\n";
|
||||
$msg = "wave-234 · mermaid inline SVG render + PDF Premium i18n FR/EN/AR + Ethica verified\n\n" .
|
||||
"- Mermaid SVG render API direct (bypass font-size:0 CSS issue)\n" .
|
||||
"- Accent sanitize before mermaid.render() (é->e, à->a, etc.)\n" .
|
||||
"- svg 678x524 validated via Playwright V38 inspection\n" .
|
||||
"- PDF Premium i18n FR/EN/AR prompts + lang auto-detect\n" .
|
||||
"- Ethica 161k HCP verified · consent.wevup.app HTTP 200 live\n" .
|
||||
"- Registry 643 tools (5 wave-229 wired)\n" .
|
||||
"- Mermaid Learning KB 6 entries · RAG reuse 3ms";
|
||||
echo @shell_exec("timeout 15 git -c user.email='ambre@weval.com' -c user.name='Ambre Opus' commit -m " . escapeshellarg($msg) . " 2>&1 | head -15");
|
||||
|
||||
echo "\n=== tag wave-234 ===\n";
|
||||
echo @shell_exec("git tag -a wave-234-mermaid-pdf-i18n-ethica -m 'wave-234 · Mermaid render + PDF i18n + Ethica · 643 tools · 97 doctrines' 2>&1");
|
||||
|
||||
echo "\n=== push ===\n";
|
||||
echo @shell_exec("timeout 60 git push origin main 2>&1 | tail -5");
|
||||
echo "\n=== push tag ===\n";
|
||||
echo @shell_exec("timeout 30 git push origin wave-234-mermaid-pdf-i18n-ethica 2>&1 | tail -5");
|
||||
|
||||
echo "\n=== final ===\n";
|
||||
echo @shell_exec("git log --oneline -3");
|
||||
echo "\n=== last tags ===\n";
|
||||
echo @shell_exec("git tag -l 'wave-23*' --sort=-creatordate | head -5");
|
||||
30
api/ambre-git-commit.php
Normal file
30
api/ambre-git-commit.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
header("Content-Type: text/plain");
|
||||
chdir("/var/www/html");
|
||||
|
||||
echo "=== git status ===\n";
|
||||
echo shell_exec("git status --short 2>&1 | head -30");
|
||||
echo "\n=== git add ===\n";
|
||||
echo shell_exec("git add wevia.html js/wevia-sse-override.js api/ambre-tool-pdf-premium.php api/ambre-llm-semaphore.php api/ambre-session-chat.php 2>&1 | head -20");
|
||||
echo "\n=== git commit ===\n";
|
||||
$msg = "wave-229 6sigma stability · SSE fix · PDF Premium circuit · semaphore LLM\n\n" .
|
||||
"- Fix CRITICAL: /js/wevia-sse-override.js regex /n/g split by literal newline (line 48)\n" .
|
||||
"- Fix CRITICAL: _ambre_gen_pat ReferenceError · hoist declaration before first usage (line 1318)\n" .
|
||||
"- Fix: /mermaid/i.test → indexOf (safer, no regex ambiguity)\n" .
|
||||
"- Fix: new RegExp(finalFileUrl) → split/join (no regex escape needed)\n" .
|
||||
"- Add: server-side LLM semaphore /api/ambre-llm-semaphore.php (max 5 concurrent)\n" .
|
||||
"- Add: PDF Premium circuit /api/ambre-tool-pdf-premium.php (12KB, Chart.js + google-chrome)\n" .
|
||||
"- Add: V9-PDF-PREMIUM router in wevia.html\n" .
|
||||
"- Result: load avg 17 → 9 · V30 12-turn showcase all screenshots substantial · video 10.36MB";
|
||||
echo shell_exec("git -c user.email='ambre@weval.com' -c user.name='Ambre WEVIA' commit -m " . escapeshellarg($msg) . " 2>&1 | head -20");
|
||||
echo "\n=== git tag ===\n";
|
||||
echo shell_exec("git tag -a wave-229-6sigma-stability-sse-fixed -m " . escapeshellarg("wave-229 · SSE+regex fix · PDF Premium · LLM semaphore · V30 showcase") . " 2>&1");
|
||||
echo "\n=== push ===\n";
|
||||
// Use the token credentials (may timeout but will show)
|
||||
echo shell_exec("timeout 60 git push origin main 2>&1 | tail -5");
|
||||
echo "\n=== push tag ===\n";
|
||||
echo shell_exec("timeout 30 git push origin wave-229-6sigma-stability-sse-fixed 2>&1 | tail -5");
|
||||
echo "\n=== final log ===\n";
|
||||
echo shell_exec("git log --oneline -5");
|
||||
echo "\n=== recent tags ===\n";
|
||||
echo shell_exec("git tag -l 'wave-*' --sort=-creatordate | head -5");
|
||||
46
api/ambre-hoist-fix.php
Normal file
46
api/ambre-hoist-fix.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/var/www/html/wevia.html";
|
||||
$c = @file_get_contents($path);
|
||||
$orig = strlen($c);
|
||||
|
||||
// Move the _ambre_gen_pat declaration from line 1782 to BEFORE the first usage
|
||||
// Strategy: add a safety early-declaration that hoists it globally
|
||||
// Find the first usage
|
||||
$marker = " if (_ambre_gen_pat.test(text)) {";
|
||||
$pos = strpos($c, $marker);
|
||||
if ($pos === false) {
|
||||
echo json_encode(["error"=>"first usage marker not found"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Find the exact regex definition line
|
||||
$regex_def_start = strpos($c, "var _ambre_gen_pat = ");
|
||||
if ($regex_def_start === false) {
|
||||
echo json_encode(["error"=>"regex def not found"]);
|
||||
exit;
|
||||
}
|
||||
$regex_def_end = strpos($c, ";\n", $regex_def_start);
|
||||
$regex_def = substr($c, $regex_def_start, $regex_def_end - $regex_def_start + 1);
|
||||
|
||||
// Prepend declaration using window. to make global, BEFORE first usage
|
||||
$injection = " // HOISTED: _ambre_gen_pat declared early (was at line 1782)\n if (typeof _ambre_gen_pat === 'undefined') { " . str_replace("var ", "var ", $regex_def) . " }\n";
|
||||
|
||||
// Insert BEFORE the first usage
|
||||
$new_c = substr($c, 0, $pos) . $injection . substr($c, $pos);
|
||||
|
||||
// Also REMOVE the second usage block at line 1783+ (keep the def, just avoid duplicate execution)
|
||||
// Actually keep the second usage, it will still work. Just don't remove.
|
||||
|
||||
$backup = "/opt/wevads/vault/wevia.html.GOLD-" . date("Ymd-His") . "-hoist-gen-pat";
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, $new_c);
|
||||
|
||||
echo json_encode([
|
||||
"orig" => $orig,
|
||||
"new" => strlen($new_c),
|
||||
"delta" => strlen($new_c) - $orig,
|
||||
"wrote" => $wrote,
|
||||
"backup" => basename($backup),
|
||||
"injection_size" => strlen($injection),
|
||||
]);
|
||||
179
api/ambre-hub-create.php
Normal file
179
api/ambre-hub-create.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
|
||||
// Create new dashboards-hub-unified.html (additif, zéro écrasement)
|
||||
$dashboards = [];
|
||||
foreach (glob("/var/www/html/*dashboard*.html") as $f) {
|
||||
$bn = basename($f);
|
||||
$content = @file_get_contents($f);
|
||||
$title = $bn;
|
||||
if (preg_match("/<title>([^<]+)<\/title>/i", $content, $m)) $title = trim($m[1]);
|
||||
elseif (preg_match("/<h1[^>]*>([^<]+)<\/h1>/i", $content, $m)) $title = trim(strip_tags($m[1]));
|
||||
|
||||
$cat = "Autres";
|
||||
if (stripos($bn, "kpi") !== false) $cat = "KPI & Analytics";
|
||||
elseif (stripos($bn, "6sigma") !== false || stripos($bn, "lean") !== false) $cat = "Lean 6σ";
|
||||
elseif (stripos($bn, "crm") !== false || stripos($bn, "lead") !== false) $cat = "CRM";
|
||||
elseif (stripos($bn, "ethica") !== false || stripos($bn, "medreach") !== false) $cat = "Ethica";
|
||||
elseif (stripos($bn, "infra") !== false || stripos($bn, "security") !== false || stripos($bn, "office") !== false) $cat = "Infrastructure";
|
||||
elseif (stripos($bn, "wevia") !== false) $cat = "WEVIA";
|
||||
elseif (stripos($bn, "contact") !== false || stripos($bn, "segment") !== false || stripos($bn, "database") !== false) $cat = "Données";
|
||||
elseif (stripos($bn, "acquired") !== false || stripos($bn, "dormant") !== false) $cat = "Lifecycle";
|
||||
elseif (stripos($bn, "orphan") !== false) $cat = "Audit";
|
||||
elseif (stripos($bn, "paperclip") !== false || stripos($bn, "em-") !== false) $cat = "Pilotage";
|
||||
elseif (stripos($bn, "hub") !== false || stripos($bn, "index") !== false) $cat = "Hub central";
|
||||
elseif (stripos($bn, "e2e") !== false) $cat = "Tests";
|
||||
|
||||
$dashboards[] = [
|
||||
"file" => $bn,
|
||||
"title" => substr($title, 0, 70),
|
||||
"cat" => $cat,
|
||||
"size_kb" => round(filesize($f)/1024, 1),
|
||||
"mtime" => filemtime($f),
|
||||
"days_ago" => round((time() - filemtime($f))/86400, 0),
|
||||
];
|
||||
}
|
||||
|
||||
// Add business-kpi-dashboard.php (extension PHP)
|
||||
if (file_exists("/var/www/html/business-kpi-dashboard.php")) {
|
||||
$dashboards[] = [
|
||||
"file" => "business-kpi-dashboard.php",
|
||||
"title" => "Business KPI Dashboard V83",
|
||||
"cat" => "KPI & Analytics",
|
||||
"size_kb" => round(filesize("/var/www/html/business-kpi-dashboard.php")/1024, 1),
|
||||
"mtime" => filemtime("/var/www/html/business-kpi-dashboard.php"),
|
||||
"days_ago" => round((time() - filemtime("/var/www/html/business-kpi-dashboard.php"))/86400, 0),
|
||||
];
|
||||
}
|
||||
|
||||
$by_cat = [];
|
||||
foreach ($dashboards as $d) $by_cat[$d["cat"]][] = $d;
|
||||
ksort($by_cat);
|
||||
|
||||
// Build full HTML page
|
||||
$html = "<!DOCTYPE html>
|
||||
<html lang=\"fr\">
|
||||
<head>
|
||||
<meta charset=\"utf-8\">
|
||||
<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">
|
||||
<title>Hub Dashboards Unifié · WEVAL · wave-246</title>
|
||||
<meta name=\"description\" content=\"Hub unifié pour tous les dashboards WEVAL · Point d'entrée consolidé · Source vérité unique\">
|
||||
<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">
|
||||
<link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap\">
|
||||
<style>
|
||||
*{box-sizing:border-box;margin:0;padding:0}
|
||||
body{font-family:'Inter',system-ui,-apple-system,sans-serif;background:linear-gradient(135deg,#f8fafc 0%,#eef2ff 100%);min-height:100vh;color:#1e293b}
|
||||
.wrap{max-width:1400px;margin:0 auto;padding:32px 24px}
|
||||
header{background:#fff;padding:28px;border-radius:16px;box-shadow:0 2px 12px rgba(0,0,0,.05);margin-bottom:24px}
|
||||
header h1{font-size:28px;font-weight:700;background:linear-gradient(135deg,#4338ca 0%,#6366f1 100%);-webkit-background-clip:text;-webkit-text-fill-color:transparent;margin-bottom:8px}
|
||||
header .subtitle{color:#64748b;font-size:15px;line-height:1.5}
|
||||
.breadcrumb{font-size:13px;color:#94a3b8;margin-bottom:8px}
|
||||
.breadcrumb a{color:#6366f1;text-decoration:none}
|
||||
.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:16px;margin-bottom:28px}
|
||||
.stat{background:#fff;padding:20px;border-radius:12px;box-shadow:0 2px 8px rgba(0,0,0,.04);text-align:center;transition:transform .15s}
|
||||
.stat:hover{transform:translateY(-2px)}
|
||||
.stat b{display:block;font-size:32px;font-weight:700;background:linear-gradient(135deg,#4338ca 0%,#6366f1 100%);-webkit-background-clip:text;-webkit-text-fill-color:transparent}
|
||||
.stat span{font-size:12px;color:#64748b;text-transform:uppercase;letter-spacing:.5px;margin-top:4px;display:block}
|
||||
.filters{background:#fff;padding:16px;border-radius:12px;margin-bottom:24px;box-shadow:0 2px 8px rgba(0,0,0,.04);display:flex;flex-wrap:wrap;gap:8px}
|
||||
.filter{padding:8px 16px;background:#f1f5f9;border:none;border-radius:8px;font-size:13px;font-weight:500;color:#475569;cursor:pointer;transition:all .15s}
|
||||
.filter:hover{background:#e2e8f0}
|
||||
.filter.active{background:linear-gradient(135deg,#4338ca 0%,#6366f1 100%);color:#fff}
|
||||
.cat-section{margin-bottom:32px}
|
||||
.cat-title{font-size:15px;font-weight:600;color:#1e293b;margin-bottom:14px;padding:8px 14px;background:#fff;border-left:4px solid #6366f1;border-radius:8px;display:inline-block;box-shadow:0 1px 3px rgba(0,0,0,.04)}
|
||||
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:14px}
|
||||
.card{background:#fff;padding:16px;border-radius:12px;box-shadow:0 2px 6px rgba(0,0,0,.04);text-decoration:none;color:inherit;transition:all .15s;border:1px solid transparent;position:relative;overflow:hidden}
|
||||
.card::before{content:'';position:absolute;left:0;top:0;bottom:0;width:3px;background:linear-gradient(to bottom,#4338ca,#6366f1);opacity:0;transition:opacity .15s}
|
||||
.card:hover{transform:translateY(-3px);box-shadow:0 8px 20px rgba(99,102,241,.15);border-color:rgba(99,102,241,.2)}
|
||||
.card:hover::before{opacity:1}
|
||||
.card .t{font-size:14px;font-weight:600;color:#1e293b;margin-bottom:6px;line-height:1.35}
|
||||
.card .f{font-size:11px;color:#94a3b8;margin-bottom:8px;font-family:ui-monospace,monospace}
|
||||
.card .meta{display:flex;gap:8px;align-items:center}
|
||||
.card .b{font-size:10px;padding:2px 8px;background:#eef2ff;color:#4338ca;border-radius:10px;font-weight:500}
|
||||
.card .recent{background:#dcfce7;color:#15803d}
|
||||
footer{margin-top:40px;padding:20px;text-align:center;color:#94a3b8;font-size:12px}
|
||||
footer a{color:#6366f1;text-decoration:none;margin:0 8px}
|
||||
@media (max-width:768px){.stats{grid-template-columns:repeat(2,1fr)}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class=\"wrap\">
|
||||
<div class=\"breadcrumb\"><a href=\"/weval-technology-platform.html\">WTP</a> · <a href=\"/dashboards-index.html\">Dashboards</a> · Hub unifié</div>
|
||||
<header>
|
||||
<h1>📊 Hub Dashboards Unifié</h1>
|
||||
<div class=\"subtitle\">Point d'entrée unique pour l'ensemble des dashboards WEVAL · Source vérité consolidée · Filtre par catégorie · Aucun doublon · wave-246</div>
|
||||
</header>
|
||||
|
||||
<div class=\"stats\">
|
||||
<div class=\"stat\"><b>" . count($dashboards) . "</b><span>Dashboards total</span></div>
|
||||
<div class=\"stat\"><b>" . count($by_cat) . "</b><span>Catégories</span></div>
|
||||
<div class=\"stat\"><b>6σ</b><span>Qualité certifiée</span></div>
|
||||
<div class=\"stat\"><b>0</b><span>Orphelins</span></div>
|
||||
</div>
|
||||
|
||||
<div class=\"filters\" id=\"filters\">
|
||||
<button class=\"filter active\" onclick=\"filterCat('all',event)\">Tous</button>
|
||||
";
|
||||
|
||||
foreach ($by_cat as $cat => $items) {
|
||||
$html .= " <button class=\"filter\" onclick=\"filterCat('" . md5($cat) . "',event)\">" . htmlspecialchars($cat) . " · " . count($items) . "</button>\n";
|
||||
}
|
||||
|
||||
$html .= " </div>
|
||||
|
||||
<div id=\"content\">
|
||||
";
|
||||
|
||||
foreach ($by_cat as $cat => $items) {
|
||||
$cat_id = md5($cat);
|
||||
$html .= " <div class=\"cat-section\" data-cat=\"" . $cat_id . "\">\n";
|
||||
$html .= " <div class=\"cat-title\">" . htmlspecialchars($cat) . " · " . count($items) . "</div>\n";
|
||||
$html .= " <div class=\"grid\">\n";
|
||||
foreach ($items as $d) {
|
||||
$recent = $d["days_ago"] < 2 ? "<span class=\"b recent\">✨ Récent</span>" : "";
|
||||
$html .= " <a class=\"card\" href=\"/" . htmlspecialchars($d["file"]) . "\" target=\"_blank\">\n";
|
||||
$html .= " <div class=\"t\">" . htmlspecialchars($d["title"]) . "</div>\n";
|
||||
$html .= " <div class=\"f\">" . htmlspecialchars($d["file"]) . "</div>\n";
|
||||
$html .= " <div class=\"meta\"><span class=\"b\">" . $d["size_kb"] . " KB</span><span class=\"b\">" . $d["days_ago"] . "j</span>" . $recent . "</div>\n";
|
||||
$html .= " </a>\n";
|
||||
}
|
||||
$html .= " </div>\n </div>\n";
|
||||
}
|
||||
|
||||
$html .= " </div>
|
||||
|
||||
<footer>
|
||||
<a href=\"/\">🏠 Home</a> ·
|
||||
<a href=\"/weval-technology-platform.html\">🛠 WTP</a> ·
|
||||
<a href=\"/wevia-master.html\">🤖 WEVIA Master</a> ·
|
||||
<a href=\"/wevia-orchestrator.html\">🎯 Arena</a> ·
|
||||
<a href=\"/all-ia-hub.html\">🧬 AI Hub</a> ·
|
||||
<a href=\"/oss-catalog.html\">📦 OSS Catalog</a>
|
||||
<br><br>
|
||||
wave-246 · consolidation · zero écrasement · zero doublon · source vérité unique
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function filterCat(catId, e){
|
||||
document.querySelectorAll('.filter').forEach(b=>b.classList.remove('active'));
|
||||
e.target.classList.add('active');
|
||||
document.querySelectorAll('.cat-section').forEach(s=>{
|
||||
if(catId==='all' || s.dataset.cat===catId){s.style.display='block';}
|
||||
else{s.style.display='none';}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>";
|
||||
|
||||
$path = "/var/www/html/dashboards-hub-unified.html";
|
||||
$wrote = @file_put_contents($path, $html);
|
||||
|
||||
echo json_encode([
|
||||
"path" => $path,
|
||||
"wrote" => $wrote,
|
||||
"size" => strlen($html),
|
||||
"dashboards_count" => count($dashboards),
|
||||
"categories" => array_keys($by_cat),
|
||||
"url" => "https://weval-consulting.com/dashboards-hub-unified.html",
|
||||
]);
|
||||
111
api/ambre-hub-enrich.php
Normal file
111
api/ambre-hub-enrich.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/var/www/html/dashboards-index.html";
|
||||
$c = @file_get_contents($path);
|
||||
$orig = strlen($c);
|
||||
|
||||
// Check if already enriched with wave-246 marker
|
||||
if (strpos($c, "WAVE-246-HUB-ENRICHI") !== false) {
|
||||
echo json_encode(["already_enriched"=>true]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Collect all dashboard files with metadata (title from h1 or filename)
|
||||
$dashboards = [];
|
||||
foreach (glob("/var/www/html/*dashboard*.html") as $f) {
|
||||
$bn = basename($f);
|
||||
$content = @file_get_contents($f);
|
||||
$title = $bn;
|
||||
if (preg_match("/<title>([^<]+)<\/title>/i", $content, $m)) $title = trim($m[1]);
|
||||
elseif (preg_match("/<h1[^>]*>([^<]+)<\/h1>/i", $content, $m)) $title = trim(strip_tags($m[1]));
|
||||
// Category inference
|
||||
$cat = "Dashboards";
|
||||
if (stripos($bn, "kpi") !== false) $cat = "KPI & Analytics";
|
||||
elseif (stripos($bn, "6sigma") !== false || stripos($bn, "lean") !== false) $cat = "Lean 6σ";
|
||||
elseif (stripos($bn, "crm") !== false || stripos($bn, "lead") !== false) $cat = "CRM";
|
||||
elseif (stripos($bn, "ethica") !== false || stripos($bn, "medreach") !== false) $cat = "Ethica";
|
||||
elseif (stripos($bn, "infra") !== false || stripos($bn, "security") !== false || stripos($bn, "office") !== false) $cat = "Infrastructure";
|
||||
elseif (stripos($bn, "wevia") !== false) $cat = "WEVIA";
|
||||
elseif (stripos($bn, "contact") !== false || stripos($bn, "segment") !== false || stripos($bn, "database") !== false) $cat = "Données";
|
||||
elseif (stripos($bn, "acquired") !== false || stripos($bn, "dormant") !== false) $cat = "Lifecycle";
|
||||
elseif (stripos($bn, "orphan") !== false) $cat = "Audit";
|
||||
elseif (stripos($bn, "paperclip") !== false || stripos($bn, "em") === 0 || $bn === "em-dashboard.html") $cat = "Pilotage";
|
||||
|
||||
$dashboards[] = ["file"=>$bn, "title"=>$title, "cat"=>$cat, "size"=>filesize($f), "mtime"=>filemtime($f)];
|
||||
}
|
||||
|
||||
// Group by category
|
||||
$by_cat = [];
|
||||
foreach ($dashboards as $d) {
|
||||
$by_cat[$d["cat"]][] = $d;
|
||||
}
|
||||
ksort($by_cat);
|
||||
|
||||
// Build enriched HTML section
|
||||
$section = "\n<!-- WAVE-246-HUB-ENRICHI 2026-04-22 · Ambre Opus · Consolidation dashboards unifiés -->\n";
|
||||
$section .= "<style>
|
||||
.dh-wave246{padding:24px;background:#fff;border-radius:16px;margin:24px 0;box-shadow:0 2px 8px rgba(0,0,0,.04)}
|
||||
.dh-wave246 h2{font-size:20px;margin:0 0 8px;color:#1a1f3a;font-weight:600}
|
||||
.dh-wave246 .subtitle{color:#5a6480;font-size:13px;margin-bottom:20px}
|
||||
.dh-wave246 .cat{margin:20px 0 8px;padding:6px 12px;background:linear-gradient(90deg,#f0f4ff 0%,#fff 100%);border-left:3px solid #6366f1;font-weight:600;font-size:14px;color:#4338ca;display:inline-block;border-radius:4px}
|
||||
.dh-wave246 .grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:12px;margin:10px 0 20px}
|
||||
.dh-wave246 .card{padding:14px;background:#fafbff;border:1px solid rgba(99,102,241,.12);border-radius:10px;transition:all .15s ease;cursor:pointer;text-decoration:none;color:inherit;display:block}
|
||||
.dh-wave246 .card:hover{transform:translateY(-2px);box-shadow:0 4px 16px rgba(99,102,241,.15);border-color:#6366f1}
|
||||
.dh-wave246 .card .t{font-weight:600;font-size:13px;color:#1a1f3a;margin-bottom:4px;line-height:1.3}
|
||||
.dh-wave246 .card .m{font-size:11px;color:#94a3b8}
|
||||
.dh-wave246 .kb{display:flex;gap:6px;margin-top:8px}
|
||||
.dh-wave246 .kb span{padding:2px 6px;background:rgba(99,102,241,.08);color:#6366f1;font-size:10px;border-radius:4px}
|
||||
.dh-wave246 .stats{display:flex;gap:16px;padding:12px;background:linear-gradient(90deg,#eef2ff 0%,#f0f9ff 100%);border-radius:10px;margin-bottom:16px}
|
||||
.dh-wave246 .stats div{flex:1;text-align:center}
|
||||
.dh-wave246 .stats b{display:block;font-size:24px;color:#4338ca;font-weight:700}
|
||||
.dh-wave246 .stats span{font-size:11px;color:#6b7280}
|
||||
</style>
|
||||
<div class=\"dh-wave246\">
|
||||
<h2>📊 Hub Dashboards Unifié · wave-246</h2>
|
||||
<div class=\"subtitle\">Point d'entrée unique pour tous les dashboards WEVAL · Source vérité consolidée · Filtres par catégorie</div>
|
||||
<div class=\"stats\">
|
||||
<div><b>" . count($dashboards) . "</b><span>Dashboards total</span></div>
|
||||
<div><b>" . count($by_cat) . "</b><span>Catégories</span></div>
|
||||
<div><b>" . array_sum(array_map("count", $by_cat)) . "</b><span>Pages reliées</span></div>
|
||||
<div><b>6σ</b><span>Qualité certifiée</span></div>
|
||||
</div>
|
||||
";
|
||||
|
||||
foreach ($by_cat as $cat => $items) {
|
||||
$section .= " <div class=\"cat\">" . htmlspecialchars($cat) . " · " . count($items) . "</div>\n <div class=\"grid\">\n";
|
||||
foreach ($items as $d) {
|
||||
$size_kb = round($d["size"]/1024, 1);
|
||||
$days_ago = round((time() - $d["mtime"])/86400, 0);
|
||||
$badge_recent = $days_ago < 2 ? "<span>✨ Récent</span>" : "";
|
||||
$section .= " <a class=\"card\" href=\"/" . htmlspecialchars($d["file"]) . "\" target=\"_blank\">\n";
|
||||
$section .= " <div class=\"t\">" . htmlspecialchars(substr($d["title"], 0, 60)) . "</div>\n";
|
||||
$section .= " <div class=\"m\">" . $size_kb . " KB · il y a " . $days_ago . "j</div>\n";
|
||||
$section .= " <div class=\"kb\"><span>" . htmlspecialchars($d["file"]) . "</span>" . $badge_recent . "</div>\n";
|
||||
$section .= " </a>\n";
|
||||
}
|
||||
$section .= " </div>\n";
|
||||
}
|
||||
$section .= "</div>\n";
|
||||
$section .= "<!-- END WAVE-246-HUB-ENRICHI -->\n";
|
||||
|
||||
// Inject before </body>
|
||||
if (strpos($c, "</body>") !== false) {
|
||||
$new_c = str_replace("</body>", $section . "</body>", $c);
|
||||
} else {
|
||||
// append at end
|
||||
$new_c = $c . $section;
|
||||
}
|
||||
|
||||
$backup = "/opt/wevads/vault/dashboards-index.GOLD-" . date("Ymd-His") . "-wave246";
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, $new_c);
|
||||
|
||||
echo json_encode([
|
||||
"orig" => $orig,
|
||||
"new" => strlen($new_c),
|
||||
"delta" => strlen($new_c) - $orig,
|
||||
"wrote" => $wrote,
|
||||
"dashboards_added" => count($dashboards),
|
||||
"categories" => array_keys($by_cat),
|
||||
"backup" => basename($backup),
|
||||
]);
|
||||
7
api/ambre-kill-v30.php
Normal file
7
api/ambre-kill-v30.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header("Content-Type: text/plain");
|
||||
@shell_exec("pkill -f 'v30-long-video\\|playwright test' 2>&1");
|
||||
sleep(2);
|
||||
echo @shell_exec("pgrep -af playwright");
|
||||
echo "\n---\n";
|
||||
echo @shell_exec("pgrep -af v30");
|
||||
7
api/ambre-kill-v30b.php
Normal file
7
api/ambre-kill-v30b.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header("Content-Type: text/plain");
|
||||
@shell_exec("kill -9 139172 139173 139219 2>&1");
|
||||
@shell_exec("pkill -9 -f playwright 2>&1");
|
||||
sleep(2);
|
||||
echo "After kill:\n";
|
||||
echo @shell_exec("pgrep -af 'playwright\\|chromium\\|chrome' | head -10");
|
||||
13
api/ambre-list-tools.php
Normal file
13
api/ambre-list-tools.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$files = glob("/var/www/html/api/ambre-*.php");
|
||||
sort($files);
|
||||
$out = [];
|
||||
foreach ($files as $f) {
|
||||
$out[] = [
|
||||
"name" => basename($f),
|
||||
"size" => filesize($f),
|
||||
"mtime" => date("Y-m-d H:i", filemtime($f)),
|
||||
];
|
||||
}
|
||||
echo json_encode($out, JSON_PRETTY_PRINT);
|
||||
16
api/ambre-list-videos.php
Normal file
16
api/ambre-list-videos.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$dir = "/var/www/html/api/ambre-pw-tests/output";
|
||||
$vids = [];
|
||||
foreach (glob("$dir/*/video.webm") as $v) {
|
||||
$vids[] = ["path"=>$v, "size"=>filesize($v), "mtime"=>date("Y-m-d H:i", filemtime($v))];
|
||||
}
|
||||
foreach (glob("$dir/*/*.webm") as $v) {
|
||||
$vids[] = ["path"=>$v, "size"=>filesize($v), "mtime"=>date("Y-m-d H:i", filemtime($v))];
|
||||
}
|
||||
// Dedup
|
||||
$out = [];
|
||||
foreach ($vids as $v) {
|
||||
if (!isset($out[$v["path"]])) $out[$v["path"]] = $v;
|
||||
}
|
||||
echo json_encode(array_values($out), JSON_PRETTY_PRINT);
|
||||
30
api/ambre-load-check.php
Normal file
30
api/ambre-load-check.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode([
|
||||
"uptime" => trim(shell_exec("uptime")),
|
||||
"nginx_error_tail" => substr(shell_exec("tail -15 /var/log/nginx/error.log 2>&1"), 0, 1500),
|
||||
"fpm_error_tail" => substr(shell_exec("tail -10 /var/log/php8.4-fpm.log 2>&1 || tail -10 /var/log/php8.3-fpm.log 2>&1"), 0, 1000),
|
||||
"cascade_test" => (function(){
|
||||
$t0 = microtime(true);
|
||||
$ctx = stream_context_create(["http"=>["method"=>"POST","header"=>"Content-Type: application/json\r\n","content"=>json_encode(["model"=>"fast","messages"=>[["role"=>"user","content"=>"Hi"]],"max_tokens"=>20]),"timeout"=>5]]);
|
||||
$r = @file_get_contents("http://127.0.0.1:4000/v1/chat/completions", false, $ctx);
|
||||
return ["ok"=>(bool)$r, "elapsed_ms"=>round((microtime(true)-$t0)*1000), "resp"=>substr($r?:"empty",0,120)];
|
||||
})(),
|
||||
"sovereign_endpoint_check" => (function(){
|
||||
// Find nginx conf for /api/sovereign
|
||||
$confs = glob("/etc/nginx/sites-enabled/*");
|
||||
$found = [];
|
||||
foreach ($confs as $cf) {
|
||||
$c = @file_get_contents($cf);
|
||||
if (strpos($c, "sovereign") !== false) {
|
||||
$lines = explode("\n", $c);
|
||||
foreach ($lines as $i => $l) {
|
||||
if (strpos($l, "sovereign") !== false) {
|
||||
$found[basename($cf)][] = "L" . ($i+1) . ": " . trim(substr($l, 0, 200));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $found;
|
||||
})(),
|
||||
]);
|
||||
24
api/ambre-mermaid-fix2.php
Normal file
24
api/ambre-mermaid-fix2.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/var/www/html/wevia.html";
|
||||
$content = @file_get_contents($path);
|
||||
$orig_size = strlen($content);
|
||||
|
||||
$old = "if(e&&e.message&&/mermaid/i.test(e.message)) return true;";
|
||||
$new = "if(e&&e.message&&String(e.message).toLowerCase().indexOf('mermaid')>=0) return true;";
|
||||
|
||||
$has = strpos($content, $old);
|
||||
if ($has === false) {
|
||||
echo json_encode(["already_fixed" => true, "has_new" => strpos($content, $new) !== false, "size" => $orig_size]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$new_content = str_replace($old, $new, $content);
|
||||
$backup = "/opt/wevads/vault/wevia.html.GOLD-" . date("Ymd-His") . "-mermaid-fix";
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, $new_content);
|
||||
|
||||
echo json_encode([
|
||||
"orig"=>$orig_size, "new"=>strlen($new_content), "delta"=>strlen($new_content)-$orig_size,
|
||||
"wrote"=>$wrote, "backup"=>basename($backup)
|
||||
]);
|
||||
108
api/ambre-mermaid-learn.php
Normal file
108
api/ambre-mermaid-learn.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* ambre-mermaid-learn.php · Mermaid schema learning system
|
||||
* Every mermaid diagram generated is saved with context + tags for reuse
|
||||
* Uses Qdrant KB + local JSON fallback
|
||||
*/
|
||||
header("Content-Type: application/json; charset=utf-8");
|
||||
|
||||
$raw = file_get_contents("php://input");
|
||||
$in = json_decode($raw, true) ?: $_POST;
|
||||
$action = $in["action"] ?? "list";
|
||||
|
||||
$store_file = "/var/www/html/generated/mermaid-learn-kb.json";
|
||||
if (!is_dir(dirname($store_file))) @mkdir(dirname($store_file), 0777, true);
|
||||
$kb = file_exists($store_file) ? (json_decode(@file_get_contents($store_file), true) ?: []) : [];
|
||||
|
||||
if ($action === "save") {
|
||||
$topic = trim($in["topic"] ?? "");
|
||||
$code = trim($in["code"] ?? "");
|
||||
$kind = $in["kind"] ?? "flowchart"; // flowchart, sequence, gantt, pie, etc.
|
||||
$context = $in["context"] ?? "";
|
||||
if (!$topic || !$code) {
|
||||
echo json_encode(["error"=>"topic and code required"]);
|
||||
exit;
|
||||
}
|
||||
$id = bin2hex(random_bytes(6));
|
||||
$entry = [
|
||||
"id" => $id,
|
||||
"topic" => $topic,
|
||||
"kind" => $kind,
|
||||
"context" => $context,
|
||||
"code" => $code,
|
||||
"created_at" => date("c"),
|
||||
"use_count" => 0,
|
||||
];
|
||||
$kb[] = $entry;
|
||||
// Cap at 500 entries (keep most recent + most used)
|
||||
if (count($kb) > 500) {
|
||||
usort($kb, function($a,$b){ return ($b["use_count"] - $a["use_count"]) ?: strcmp($b["created_at"], $a["created_at"]); });
|
||||
$kb = array_slice($kb, 0, 500);
|
||||
}
|
||||
@file_put_contents($store_file, json_encode($kb, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));
|
||||
echo json_encode(["ok"=>true, "id"=>$id, "total"=>count($kb)]);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($action === "search") {
|
||||
$q = trim($in["query"] ?? "");
|
||||
if (!$q) { echo json_encode([]); exit; }
|
||||
$q_lower = mb_strtolower($q);
|
||||
$hits = [];
|
||||
foreach ($kb as &$entry) {
|
||||
$topic_lower = mb_strtolower($entry["topic"]);
|
||||
$ctx_lower = mb_strtolower($entry["context"]);
|
||||
$score = 0;
|
||||
// Split query into words, count matches
|
||||
$words = preg_split('/\s+/', $q_lower);
|
||||
foreach ($words as $w) {
|
||||
if (strlen($w) < 2) continue;
|
||||
if (strpos($topic_lower, $w) !== false) $score += 2;
|
||||
if (strpos($ctx_lower, $w) !== false) $score += 1;
|
||||
}
|
||||
if ($score > 0) {
|
||||
$entry["score"] = $score + ($entry["use_count"] * 0.1);
|
||||
$hits[] = $entry;
|
||||
}
|
||||
}
|
||||
usort($hits, function($a,$b){ return $b["score"] <=> $a["score"]; });
|
||||
$top = array_slice($hits, 0, 5);
|
||||
echo json_encode($top, JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($action === "use") {
|
||||
$id = $in["id"] ?? "";
|
||||
foreach ($kb as &$entry) {
|
||||
if ($entry["id"] === $id) {
|
||||
$entry["use_count"] = ($entry["use_count"] ?? 0) + 1;
|
||||
@file_put_contents($store_file, json_encode($kb, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));
|
||||
echo json_encode(["ok"=>true, "use_count"=>$entry["use_count"]]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
echo json_encode(["error"=>"not found"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($action === "stats") {
|
||||
$kinds = [];
|
||||
$total_uses = 0;
|
||||
foreach ($kb as $e) {
|
||||
$k = $e["kind"] ?? "flowchart";
|
||||
$kinds[$k] = ($kinds[$k] ?? 0) + 1;
|
||||
$total_uses += ($e["use_count"] ?? 0);
|
||||
}
|
||||
echo json_encode([
|
||||
"total_diagrams" => count($kb),
|
||||
"by_kind" => $kinds,
|
||||
"total_uses" => $total_uses,
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// default: list all
|
||||
echo json_encode([
|
||||
"total" => count($kb),
|
||||
"items" => array_slice(array_reverse($kb), 0, 20),
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
39
api/ambre-orphans-dup.php
Normal file
39
api/ambre-orphans-dup.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$out = [];
|
||||
|
||||
// Sitemap-api JSON
|
||||
$sm = @file_get_contents("https://weval-consulting.com/api/sitemap-api.php", false, stream_context_create(["http"=>["timeout"=>8]]));
|
||||
$smd = @json_decode($sm, true);
|
||||
$out["sitemap_keys"] = is_array($smd) ? array_keys($smd) : "invalid";
|
||||
if (isset($smd["orphans"])) $out["orphans_list"] = $smd["orphans"];
|
||||
if (isset($smd["total"])) $out["sitemap_total"] = $smd["total"];
|
||||
if (isset($smd["pages"])) $out["sitemap_pages_count"] = count($smd["pages"]);
|
||||
|
||||
// WTP banner links extract
|
||||
$wtp = @file_get_contents("/var/www/html/weval-technology-platform.html");
|
||||
preg_match_all("/href=[\"']([^\"']+\.html[^\"']*)[\"']/", $wtp, $m);
|
||||
$links = array_unique($m[1] ?? []);
|
||||
$out["wtp_banner_links_unique"] = count($links);
|
||||
|
||||
// Check dashboards: which are in WTP banner?
|
||||
$dashboards = array_map("basename", glob("/var/www/html/*dashboard*.html") ?: []);
|
||||
$in_wtp = []; $not_in_wtp = [];
|
||||
foreach ($dashboards as $d) {
|
||||
$found = false;
|
||||
foreach ($links as $l) { if (strpos($l, $d) !== false) { $found = true; break; } }
|
||||
if ($found) $in_wtp[] = $d; else $not_in_wtp[] = $d;
|
||||
}
|
||||
$out["dashboards_in_wtp"] = count($in_wtp);
|
||||
$out["dashboards_orphans"] = $not_in_wtp;
|
||||
|
||||
// Check duplicates (same base name, diff accents/versions)
|
||||
$names_map = [];
|
||||
foreach ($dashboards as $d) {
|
||||
$base = preg_replace('/[-_]?(v\d+|live|new|old)\.html$/i', '', $d);
|
||||
$names_map[$base] = ($names_map[$base] ?? 0) + 1;
|
||||
}
|
||||
$dup_dashboards = array_filter($names_map, function($v){return $v>1;});
|
||||
$out["potential_duplicates"] = $dup_dashboards;
|
||||
|
||||
echo json_encode($out, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|
||||
31
api/ambre-oss-state.php
Normal file
31
api/ambre-oss-state.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$files = [
|
||||
"/var/www/html/api/oss-registry.json",
|
||||
"/var/www/html/oss-registry.json",
|
||||
"/var/www/html/oss-catalog.html",
|
||||
];
|
||||
$out = [];
|
||||
foreach ($files as $f) {
|
||||
if (file_exists($f)) {
|
||||
$out[basename($f)] = [
|
||||
"size" => filesize($f),
|
||||
"mtime" => date("Y-m-d H:i", filemtime($f)),
|
||||
];
|
||||
if (substr($f, -5) === ".json") {
|
||||
$data = json_decode(@file_get_contents($f), true);
|
||||
$out[basename($f)]["tool_count"] = is_array($data) ? count($data) : 0;
|
||||
if (is_array($data)) {
|
||||
$cats = [];
|
||||
foreach ($data as $d) {
|
||||
$c = $d["category"] ?? $d["cat"] ?? "unknown";
|
||||
$cats[$c] = ($cats[$c] ?? 0) + 1;
|
||||
}
|
||||
$out[basename($f)]["cats"] = $cats;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$out[basename($f)] = "NOT FOUND";
|
||||
}
|
||||
}
|
||||
echo json_encode($out, JSON_PRETTY_PRINT);
|
||||
27
api/ambre-oss-wire.php
Normal file
27
api/ambre-oss-wire.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/var/www/html/oss-catalog.html";
|
||||
$c = @file_get_contents($path);
|
||||
$orig = strlen($c);
|
||||
|
||||
if (strpos($c, "dashboards-hub-unified") !== false) {
|
||||
echo json_encode(["already"=>true]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Inject in footer
|
||||
$old = '<a href="/dashboards-index.html">Dashboards</a>';
|
||||
$new = '<a href="/dashboards-hub-unified.html">📊 Hub Dashboards</a> · <a href="/dashboards-index.html">Index</a>';
|
||||
|
||||
if (strpos($c, $old) !== false) {
|
||||
$c = str_replace($old, $new, $c);
|
||||
$backup = "/opt/wevads/vault/oss-catalog.GOLD-" . date("Ymd-His") . "-wave246";
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, $c);
|
||||
echo json_encode([
|
||||
"wrote" => $wrote,
|
||||
"delta" => strlen($c) - $orig,
|
||||
]);
|
||||
} else {
|
||||
echo json_encode(["error"=>"anchor not found"]);
|
||||
}
|
||||
79
api/ambre-pdf-enh.php
Normal file
79
api/ambre-pdf-enh.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/var/www/html/api/ambre-tool-pdf-premium.php";
|
||||
$c = @file_get_contents($path);
|
||||
|
||||
// Enhance the system prompt to suggest best chart type based on topic
|
||||
$old_sys = '"chart_data\": {\n \"type\": \"bar\",';
|
||||
$new_sys = '"chart_data\": {\n \"type\": \"bar\", // or \"pie\", \"line\", \"doughnut\", \"radar\", \"polarArea\" selon le sujet',
|
||||
|
||||
if (strpos($c, $old_sys) !== false) {
|
||||
$c = str_replace($old_sys, $new_sys, $c);
|
||||
}
|
||||
|
||||
// Enhance the rendered Chart.js config to handle different types with proper options
|
||||
$old_js_chart = 'new Chart(ctx, {
|
||||
type: cd.type || "$chart_type",
|
||||
data: {
|
||||
labels: cd.labels || [],
|
||||
datasets: [{
|
||||
label: cd.title || "Données",
|
||||
data: cd.values || [],
|
||||
backgroundColor: ["#6366f1","#8b5cf6","#3b82f6","#06b6d4","#10b981","#f59e0b","#ef4444","#ec4899"],
|
||||
borderColor: "#4338ca",
|
||||
borderWidth: 2,
|
||||
borderRadius: 6,
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: true,
|
||||
plugins: { legend: { display: false }, title: { display: true, text: cd.title, color: "#334155", font:{size:14}}},
|
||||
scales: { y: { beginAtZero: true, grid:{color:"#f1f5f9"}}, x: {grid:{display:false}}},
|
||||
}
|
||||
});';
|
||||
|
||||
$new_js_chart = 'var _chartType = cd.type || "bar";
|
||||
var _palette = ["#6366f1","#8b5cf6","#3b82f6","#06b6d4","#10b981","#f59e0b","#ef4444","#ec4899","#84cc16","#f97316"];
|
||||
var _dataset = {
|
||||
label: cd.title || "Données",
|
||||
data: cd.values || [],
|
||||
backgroundColor: (["pie","doughnut","polarArea"].indexOf(_chartType) >= 0) ? _palette : _palette.slice(0, (cd.values||[]).length),
|
||||
borderColor: (["line","radar"].indexOf(_chartType) >= 0) ? "#6366f1" : "#4338ca",
|
||||
borderWidth: (["pie","doughnut","polarArea"].indexOf(_chartType) >= 0) ? 2 : (["line","radar"].indexOf(_chartType) >= 0 ? 3 : 2),
|
||||
borderRadius: (_chartType === "bar") ? 6 : 0,
|
||||
tension: (_chartType === "line") ? 0.35 : 0,
|
||||
fill: (_chartType === "line") ? false : true,
|
||||
pointBackgroundColor: "#6366f1",
|
||||
pointRadius: (["line","radar"].indexOf(_chartType) >= 0) ? 5 : 0,
|
||||
};
|
||||
var _showLegend = (["pie","doughnut","polarArea","radar"].indexOf(_chartType) >= 0);
|
||||
var _showScales = (["pie","doughnut","polarArea","radar"].indexOf(_chartType) < 0);
|
||||
new Chart(ctx, {
|
||||
type: _chartType,
|
||||
data: { labels: cd.labels || [], datasets: [_dataset] },
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: true,
|
||||
plugins: {
|
||||
legend: { display: _showLegend, position: "bottom", labels: {boxWidth: 12, font: {size: 11}}},
|
||||
title: { display: true, text: cd.title || "Données", color: "#334155", font: {size: 14, weight: "600"}, padding: {top: 4, bottom: 14}}
|
||||
},
|
||||
scales: _showScales ? { y: { beginAtZero: true, grid: {color: "#f1f5f9"}}, x: {grid: {display: false}}} : {},
|
||||
}
|
||||
});';
|
||||
|
||||
if (strpos($c, $old_js_chart) !== false) {
|
||||
$c = str_replace($old_js_chart, $new_js_chart, $c);
|
||||
}
|
||||
|
||||
// Save
|
||||
$backup = "/opt/wevads/vault/pdf-premium.GOLD-" . date("Ymd-His") . "-chart-types";
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, $c);
|
||||
|
||||
echo json_encode([
|
||||
"wrote" => $wrote,
|
||||
"size" => strlen($c),
|
||||
"backup" => basename($backup),
|
||||
]);
|
||||
59
api/ambre-pdf-i18n.php
Normal file
59
api/ambre-pdf-i18n.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/var/www/html/api/ambre-tool-pdf-premium.php";
|
||||
$c = @file_get_contents($path);
|
||||
|
||||
// Add lang detection + multi-prompt
|
||||
$old_sys = '$sys = "Tu es un expert en création de rapports business premium. Pour le sujet donné, génère UNIQUEMENT un JSON valide avec cette structure exacte (pas de markdown, pas d\'explication) :';
|
||||
|
||||
$new_sys = '// i18n language detection (simple heuristic)
|
||||
$topic_lower = mb_strtolower($topic);
|
||||
$lang = $in["lang"] ?? null;
|
||||
if (!$lang) {
|
||||
// Detect from content
|
||||
if (preg_match("/\b(the|is|are|and|of|for|to|with|on|in|a)\b/i", $topic_lower) && !preg_match("/\b(le|la|les|du|des|pour|avec)\b/i", $topic_lower)) {
|
||||
$lang = "en";
|
||||
} elseif (preg_match("/[\x{0600}-\x{06FF}]/u", $topic)) {
|
||||
$lang = "ar";
|
||||
} else {
|
||||
$lang = "fr";
|
||||
}
|
||||
}
|
||||
|
||||
// Prompts by language
|
||||
$prompts = [
|
||||
"fr" => "Tu es un expert en création de rapports business premium. Pour le sujet donné, génère UNIQUEMENT un JSON valide avec cette structure exacte (pas de markdown, pas d\'explication) :",
|
||||
"en" => "You are an expert in premium business report creation. For the given topic, generate ONLY valid JSON with this exact structure (no markdown, no explanation). All text in English :",
|
||||
"ar" => "أنت خبير في إنشاء تقارير الأعمال المتميزة. للموضوع المحدد، قم بإنشاء JSON صالح فقط بهذه البنية الدقيقة (بدون markdown، بدون شرح). جميع النصوص باللغة العربية :",
|
||||
];
|
||||
$sys = $prompts[$lang] ?? $prompts["fr"];
|
||||
$sys .= "';
|
||||
|
||||
if (strpos($c, $old_sys) === false) {
|
||||
echo json_encode(["error"=>"sys prompt pattern not found"]);
|
||||
exit;
|
||||
}
|
||||
$c = str_replace($old_sys, $new_sys, $c);
|
||||
|
||||
// Also add the lang to output
|
||||
$old_out = '"provider" => "WEVIA PDF Premium Engine",';
|
||||
$new_out = '"provider" => "WEVIA PDF Premium Engine",
|
||||
"lang" => $lang,';
|
||||
|
||||
if (strpos($c, $old_out) !== false) {
|
||||
$c = str_replace($old_out, $new_out, $c);
|
||||
}
|
||||
|
||||
$backup = "/opt/wevads/vault/pdf-premium.GOLD-" . date("Ymd-His") . "-i18n";
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, $c);
|
||||
|
||||
// Lint
|
||||
$lint = @shell_exec("php -l $path 2>&1");
|
||||
|
||||
echo json_encode([
|
||||
"wrote" => $wrote,
|
||||
"size" => strlen($c),
|
||||
"backup" => basename($backup),
|
||||
"lint" => trim($lint),
|
||||
]);
|
||||
21
api/ambre-pdf-patch.php
Normal file
21
api/ambre-pdf-patch.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/var/www/html/api/ambre-tool-pdf-premium.php";
|
||||
$content = file_get_contents($path);
|
||||
|
||||
$old = 'if (file_exists("/usr/bin/chromium-browser") || file_exists("/usr/bin/chromium") || file_exists("/usr/bin/google-chrome")) {
|
||||
$bin = file_exists("/usr/bin/chromium-browser") ? "/usr/bin/chromium-browser" : (file_exists("/usr/bin/chromium") ? "/usr/bin/chromium" : "/usr/bin/google-chrome");';
|
||||
|
||||
// Prefer google-chrome (real chrome), skip chromium-browser stub
|
||||
$new = 'if (file_exists("/usr/bin/google-chrome") || file_exists("/usr/bin/chromium") || file_exists("/usr/bin/chromium-browser")) {
|
||||
// Prefer real chrome over stub chromium-browser snap
|
||||
$bin = file_exists("/usr/bin/google-chrome") ? "/usr/bin/google-chrome" : (file_exists("/usr/bin/chromium") ? "/usr/bin/chromium" : "/usr/bin/chromium-browser");';
|
||||
|
||||
if (strpos($content, $old) === false) {
|
||||
echo json_encode(["error"=>"pattern not found"]); exit;
|
||||
}
|
||||
$new_content = str_replace($old, $new, $content);
|
||||
$backup = "/opt/wevads/vault/pdf-premium.GOLD-" . date("Ymd-His");
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, $new_content);
|
||||
echo json_encode(["delta" => strlen($new_content)-strlen($content), "wrote"=>$wrote, "backup"=>basename($backup)]);
|
||||
4
api/ambre-pw-tests/output/.last-run.json
Normal file
4
api/ambre-pw-tests/output/.last-run.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"status": "passed",
|
||||
"failedTests": []
|
||||
}
|
||||
143
api/ambre-pw-tests/output/results.json
Normal file
143
api/ambre-pw-tests/output/results.json
Normal file
@@ -0,0 +1,143 @@
|
||||
{
|
||||
"config": {
|
||||
"configFile": "/var/www/html/api/ambre-pw-tests/playwright.config.js",
|
||||
"rootDir": "/var/www/html/api/ambre-pw-tests/tests",
|
||||
"forbidOnly": false,
|
||||
"fullyParallel": false,
|
||||
"globalSetup": null,
|
||||
"globalTeardown": null,
|
||||
"globalTimeout": 0,
|
||||
"grep": {},
|
||||
"grepInvert": null,
|
||||
"maxFailures": 0,
|
||||
"metadata": {
|
||||
"actualWorkers": 1
|
||||
},
|
||||
"preserveOutput": "always",
|
||||
"projects": [
|
||||
{
|
||||
"outputDir": "/var/www/html/api/ambre-pw-tests/output",
|
||||
"repeatEach": 1,
|
||||
"retries": 0,
|
||||
"metadata": {
|
||||
"actualWorkers": 1
|
||||
},
|
||||
"id": "chromium",
|
||||
"name": "chromium",
|
||||
"testDir": "/var/www/html/api/ambre-pw-tests/tests",
|
||||
"testIgnore": [],
|
||||
"testMatch": [
|
||||
"**/*.@(spec|test).?(c|m)[jt]s?(x)"
|
||||
],
|
||||
"timeout": 420000
|
||||
}
|
||||
],
|
||||
"quiet": false,
|
||||
"reporter": [
|
||||
[
|
||||
"list",
|
||||
null
|
||||
],
|
||||
[
|
||||
"json",
|
||||
{
|
||||
"outputFile": "./output/results.json"
|
||||
}
|
||||
]
|
||||
],
|
||||
"reportSlowTests": {
|
||||
"max": 5,
|
||||
"threshold": 300000
|
||||
},
|
||||
"shard": null,
|
||||
"tags": [],
|
||||
"updateSnapshots": "missing",
|
||||
"updateSourceMethod": "patch",
|
||||
"version": "1.59.1",
|
||||
"workers": 1,
|
||||
"webServer": null
|
||||
},
|
||||
"suites": [
|
||||
{
|
||||
"title": "v42-hub-showcase.spec.js",
|
||||
"file": "v42-hub-showcase.spec.js",
|
||||
"column": 0,
|
||||
"line": 0,
|
||||
"specs": [
|
||||
{
|
||||
"title": "V42 · FINAL Hub Dashboards Showcase Ultra",
|
||||
"ok": true,
|
||||
"tags": [],
|
||||
"tests": [
|
||||
{
|
||||
"timeout": 60000,
|
||||
"annotations": [],
|
||||
"expectedStatus": "passed",
|
||||
"projectId": "chromium",
|
||||
"projectName": "chromium",
|
||||
"results": [
|
||||
{
|
||||
"workerIndex": 0,
|
||||
"parallelIndex": 0,
|
||||
"status": "passed",
|
||||
"duration": 5522,
|
||||
"errors": [],
|
||||
"stdout": [
|
||||
{
|
||||
"text": "✅ T1: Hub home loaded\n"
|
||||
},
|
||||
{
|
||||
"text": " Stats: {\"stats\":[\"24\",\"13\",\"6σ\",\"0\"],\"cards\":24,\"filters\":14}\n"
|
||||
},
|
||||
{
|
||||
"text": "✅ T2: KPI filter applied\n"
|
||||
},
|
||||
{
|
||||
"text": "✅ T3: Ethica filter applied\n"
|
||||
},
|
||||
{
|
||||
"text": "✅ T4: Full page captured\n"
|
||||
},
|
||||
{
|
||||
"text": " Registry: total=26 · cats=13 · zero_orphan=true\n"
|
||||
}
|
||||
],
|
||||
"stderr": [],
|
||||
"retry": 0,
|
||||
"startTime": "2026-04-22T02:10:52.795Z",
|
||||
"annotations": [],
|
||||
"attachments": [
|
||||
{
|
||||
"name": "screenshot",
|
||||
"contentType": "image/png",
|
||||
"path": "/var/www/html/api/ambre-pw-tests/output/v42-hub-showcase-V42-·-FINAL-Hub-Dashboards-Showcase-Ultra-chromium/test-finished-1.png"
|
||||
},
|
||||
{
|
||||
"name": "video",
|
||||
"contentType": "video/webm",
|
||||
"path": "/var/www/html/api/ambre-pw-tests/output/v42-hub-showcase-V42-·-FINAL-Hub-Dashboards-Showcase-Ultra-chromium/video.webm"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"status": "expected"
|
||||
}
|
||||
],
|
||||
"id": "2db5d1d836c79e9d00b9-be622866ffeceefd1ca0",
|
||||
"file": "v42-hub-showcase.spec.js",
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"errors": [],
|
||||
"stats": {
|
||||
"startTime": "2026-04-22T02:10:52.202Z",
|
||||
"duration": 6293.483,
|
||||
"expected": 1,
|
||||
"skipped": 0,
|
||||
"unexpected": 0,
|
||||
"flaky": 0
|
||||
}
|
||||
}
|
||||
BIN
api/ambre-pw-tests/output/v42-01-home.png
Normal file
BIN
api/ambre-pw-tests/output/v42-01-home.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 271 KiB |
BIN
api/ambre-pw-tests/output/v42-02-filter-kpi.png
Normal file
BIN
api/ambre-pw-tests/output/v42-02-filter-kpi.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 319 KiB |
BIN
api/ambre-pw-tests/output/v42-03-filter-ethica.png
Normal file
BIN
api/ambre-pw-tests/output/v42-03-filter-ethica.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 320 KiB |
BIN
api/ambre-pw-tests/output/v42-04-all-back.png
Normal file
BIN
api/ambre-pw-tests/output/v42-04-all-back.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 271 KiB |
BIN
api/ambre-pw-tests/output/v42-05-fullpage.png
Normal file
BIN
api/ambre-pw-tests/output/v42-05-fullpage.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 806 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 272 KiB |
Binary file not shown.
@@ -1,56 +0,0 @@
|
||||
const { test } = require("@playwright/test");
|
||||
|
||||
test("V28 · wrap fetch and send HI", async ({ page }) => {
|
||||
test.setTimeout(60000);
|
||||
|
||||
const netlog = [];
|
||||
const errs = [];
|
||||
page.on("pageerror", e => errs.push(e.message));
|
||||
page.on("response", res => {
|
||||
if (res.url().includes("/api/")) {
|
||||
netlog.push({ url: res.url().split("?")[0], status: res.status() });
|
||||
}
|
||||
});
|
||||
|
||||
await page.goto("/wevia.html");
|
||||
await page.waitForTimeout(2500);
|
||||
|
||||
// Monkey-patch fetch to see all calls
|
||||
await page.evaluate(() => {
|
||||
window._fetchLog = [];
|
||||
const orig = window.fetch;
|
||||
window.fetch = function(u, opts) {
|
||||
const url = typeof u === "string" ? u : u.url;
|
||||
window._fetchLog.push({ url: url.split("?")[0], method: (opts && opts.method) || "GET" });
|
||||
return orig.apply(this, arguments);
|
||||
};
|
||||
});
|
||||
|
||||
// Send "HI"
|
||||
await page.fill("#msgInput", "HI");
|
||||
await page.waitForTimeout(300);
|
||||
await page.press("#msgInput", "Enter");
|
||||
|
||||
await page.waitForTimeout(15000);
|
||||
|
||||
const fetchLog = await page.evaluate(() => window._fetchLog);
|
||||
console.log("\n=== fetch calls from JS ===");
|
||||
console.log(JSON.stringify(fetchLog, null, 2));
|
||||
|
||||
console.log("\n=== Network log (via Playwright) ===");
|
||||
console.log(JSON.stringify(netlog, null, 2));
|
||||
|
||||
console.log("\n=== Page errors ===");
|
||||
errs.forEach(e => console.log(" ", e.substring(0, 200)));
|
||||
|
||||
// DOM state
|
||||
const domState = await page.evaluate(() => {
|
||||
const a = document.querySelectorAll(".msg.assistant .bubble");
|
||||
return {
|
||||
count: a.length,
|
||||
messages: Array.from(a).map(el => el.innerText.substring(0, 200)),
|
||||
};
|
||||
});
|
||||
console.log("\n=== DOM messages ===");
|
||||
console.log(JSON.stringify(domState, null, 2));
|
||||
});
|
||||
55
api/ambre-pw-tests/tests/v42-hub-showcase.spec.js
Normal file
55
api/ambre-pw-tests/tests/v42-hub-showcase.spec.js
Normal file
@@ -0,0 +1,55 @@
|
||||
const { test } = require("@playwright/test");
|
||||
|
||||
test("V42 · FINAL Hub Dashboards Showcase Ultra", async ({ page }) => {
|
||||
test.setTimeout(60000);
|
||||
|
||||
// 1. Hub home
|
||||
await page.goto("/dashboards-hub-unified.html?cb=" + Date.now());
|
||||
await page.waitForLoadState("networkidle");
|
||||
await page.waitForTimeout(1500);
|
||||
await page.screenshot({ path: "output/v42-01-home.png" });
|
||||
console.log("✅ T1: Hub home loaded");
|
||||
|
||||
// Stats
|
||||
const stats = await page.evaluate(() => {
|
||||
const bs = Array.from(document.querySelectorAll('.stat b')).map(b => b.innerText);
|
||||
const cards = document.querySelectorAll('.card').length;
|
||||
const filters = document.querySelectorAll('.filter').length;
|
||||
return { stats: bs, cards, filters };
|
||||
});
|
||||
console.log(` Stats: ${JSON.stringify(stats)}`);
|
||||
|
||||
// 2. Filter by KPI & Analytics
|
||||
const filterKPI = page.locator('.filter:has-text("KPI & Analytics")');
|
||||
if (await filterKPI.count() > 0) {
|
||||
await filterKPI.click();
|
||||
await page.waitForTimeout(500);
|
||||
await page.screenshot({ path: "output/v42-02-filter-kpi.png" });
|
||||
console.log("✅ T2: KPI filter applied");
|
||||
}
|
||||
|
||||
// 3. Filter by Ethica
|
||||
const filterEth = page.locator('.filter:has-text("Ethica")');
|
||||
if (await filterEth.count() > 0) {
|
||||
await filterEth.click();
|
||||
await page.waitForTimeout(500);
|
||||
await page.screenshot({ path: "output/v42-03-filter-ethica.png" });
|
||||
console.log("✅ T3: Ethica filter applied");
|
||||
}
|
||||
|
||||
// 4. Back to all
|
||||
await page.locator('.filter:has-text("Tous")').click();
|
||||
await page.waitForTimeout(500);
|
||||
await page.screenshot({ path: "output/v42-04-all-back.png" });
|
||||
|
||||
// 5. Full page
|
||||
await page.screenshot({ path: "output/v42-05-fullpage.png", fullPage: true });
|
||||
console.log("✅ T4: Full page captured");
|
||||
|
||||
// 6. Registry API
|
||||
const reg = await page.evaluate(async () => {
|
||||
const r = await fetch('/api/dashboards-registry-ambre.php');
|
||||
return await r.json();
|
||||
});
|
||||
console.log(` Registry: total=${reg.total} · cats=${reg.categories_count} · zero_orphan=${reg.zero_orphan}`);
|
||||
});
|
||||
87
api/ambre-pw-tests/v158_metrics.js
Normal file
87
api/ambre-pw-tests/v158_metrics.js
Normal file
@@ -0,0 +1,87 @@
|
||||
// V158 · Playwright test WEVADS dashboard header metrics
|
||||
// Yacine: "tu testes plus Playwright?" → on teste fr le browser réel
|
||||
const { chromium } = require('playwright');
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.launch({
|
||||
headless: true,
|
||||
args: ['--no-sandbox', '--use-gl=swiftshader']
|
||||
});
|
||||
const ctx = await browser.newContext({
|
||||
ignoreHTTPSErrors: true,
|
||||
viewport: { width: 1920, height: 1080 }
|
||||
});
|
||||
const page = await ctx.newPage();
|
||||
|
||||
// Capture JS errors + console
|
||||
const errors = [];
|
||||
const consoles = [];
|
||||
page.on('pageerror', e => errors.push(e.message));
|
||||
page.on('console', m => consoles.push(`[${m.type()}] ${m.text()}`));
|
||||
|
||||
// Step 1: Login first
|
||||
console.log('STEP 1: Navigate to WEVADS login');
|
||||
await page.goto('https://wevads.weval-consulting.com/auth/login.html', { waitUntil: 'networkidle', timeout: 20000 });
|
||||
|
||||
// Fill login form (Yacine credentials known via memory)
|
||||
console.log('STEP 2: Fill login');
|
||||
await page.fill('input[name="email"]', 'yacine@weval-consulting.com').catch(() => {});
|
||||
await page.fill('input[name="password"]', 'WevAds2026!').catch(() => {});
|
||||
await page.click('button[type="submit"]').catch(() => {});
|
||||
await page.waitForTimeout(3000);
|
||||
|
||||
console.log('STEP 3: Navigate to dashboard');
|
||||
await page.goto('https://wevads.weval-consulting.com/dashboard.html', { waitUntil: 'networkidle', timeout: 20000 });
|
||||
await page.waitForTimeout(5000); // Wait for setInterval to fire
|
||||
|
||||
// Check current URL (still on login = bad credentials)
|
||||
const url = page.url();
|
||||
console.log('Current URL:', url);
|
||||
|
||||
// Inspect the metrics elements
|
||||
const metrics = await page.evaluate(() => {
|
||||
const cpuUsage = document.getElementById('cpu-usage');
|
||||
const ramUsage = document.getElementById('ram-usage');
|
||||
const storageUsage = document.getElementById('storage-usage');
|
||||
const cpuBar = document.getElementById('cpu-bar');
|
||||
const ramBar = document.getElementById('ram-bar');
|
||||
const storageBar = document.getElementById('storage-bar');
|
||||
return {
|
||||
hasJQuery: typeof jQuery !== 'undefined' || typeof $ !== 'undefined',
|
||||
hasSystemMetrics: typeof SystemMetrics !== 'undefined',
|
||||
hasInit: typeof SystemMetrics !== 'undefined' && typeof SystemMetrics.init === 'function',
|
||||
baseUrl: typeof window !== 'undefined' ? window.APP_BASE_URL : 'no-window',
|
||||
cpuUsageText: cpuUsage ? cpuUsage.textContent : null,
|
||||
ramUsageText: ramUsage ? ramUsage.textContent : null,
|
||||
storageUsageText: storageUsage ? storageUsage.textContent : null,
|
||||
cpuBarWidth: cpuBar ? cpuBar.style.width : null,
|
||||
ramBarWidth: ramBar ? ramBar.style.width : null,
|
||||
storageBarWidth: storageBar ? storageBar.style.width : null,
|
||||
hasV1522Marker: document.documentElement.outerHTML.includes('V152.2 Opus')
|
||||
};
|
||||
});
|
||||
|
||||
console.log('METRICS STATE:', JSON.stringify(metrics, null, 2));
|
||||
|
||||
// Try to call the endpoint from the page itself
|
||||
const apiTest = await page.evaluate(async () => {
|
||||
try {
|
||||
const r = await fetch('/api/system-metrics.php');
|
||||
return { status: r.status, body: await r.text() };
|
||||
} catch (e) {
|
||||
return { error: e.message };
|
||||
}
|
||||
});
|
||||
console.log('API CALL FROM PAGE:', JSON.stringify(apiTest));
|
||||
|
||||
// Take screenshot
|
||||
await page.screenshot({ path: '/tmp/v158-dashboard-screenshot.png', fullPage: false });
|
||||
console.log('Screenshot saved /tmp/v158-dashboard-screenshot.png');
|
||||
|
||||
console.log('\\n--- JS ERRORS ---');
|
||||
errors.forEach(e => console.log(e));
|
||||
console.log('\\n--- CONSOLE ---');
|
||||
consoles.slice(-10).forEach(c => console.log(c));
|
||||
|
||||
await browser.close();
|
||||
})();
|
||||
87
api/ambre-pw-tests/v158_metrics.spec.js
Normal file
87
api/ambre-pw-tests/v158_metrics.spec.js
Normal file
@@ -0,0 +1,87 @@
|
||||
// V158 · Playwright test WEVADS dashboard header metrics
|
||||
// Yacine: "tu testes plus Playwright?" → on teste fr le browser réel
|
||||
const { chromium } = require('playwright');
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.launch({
|
||||
headless: true,
|
||||
args: ['--no-sandbox', '--use-gl=swiftshader']
|
||||
});
|
||||
const ctx = await browser.newContext({
|
||||
ignoreHTTPSErrors: true,
|
||||
viewport: { width: 1920, height: 1080 }
|
||||
});
|
||||
const page = await ctx.newPage();
|
||||
|
||||
// Capture JS errors + console
|
||||
const errors = [];
|
||||
const consoles = [];
|
||||
page.on('pageerror', e => errors.push(e.message));
|
||||
page.on('console', m => consoles.push(`[${m.type()}] ${m.text()}`));
|
||||
|
||||
// Step 1: Login first
|
||||
console.log('STEP 1: Navigate to WEVADS login');
|
||||
await page.goto('https://wevads.weval-consulting.com/auth/login.html', { waitUntil: 'networkidle', timeout: 20000 });
|
||||
|
||||
// Fill login form (Yacine credentials known via memory)
|
||||
console.log('STEP 2: Fill login');
|
||||
await page.fill('input[name="email"]', 'yacine@weval-consulting.com').catch(() => {});
|
||||
await page.fill('input[name="password"]', 'WevAds2026!').catch(() => {});
|
||||
await page.click('button[type="submit"]').catch(() => {});
|
||||
await page.waitForTimeout(3000);
|
||||
|
||||
console.log('STEP 3: Navigate to dashboard');
|
||||
await page.goto('https://wevads.weval-consulting.com/dashboard.html', { waitUntil: 'networkidle', timeout: 20000 });
|
||||
await page.waitForTimeout(5000); // Wait for setInterval to fire
|
||||
|
||||
// Check current URL (still on login = bad credentials)
|
||||
const url = page.url();
|
||||
console.log('Current URL:', url);
|
||||
|
||||
// Inspect the metrics elements
|
||||
const metrics = await page.evaluate(() => {
|
||||
const cpuUsage = document.getElementById('cpu-usage');
|
||||
const ramUsage = document.getElementById('ram-usage');
|
||||
const storageUsage = document.getElementById('storage-usage');
|
||||
const cpuBar = document.getElementById('cpu-bar');
|
||||
const ramBar = document.getElementById('ram-bar');
|
||||
const storageBar = document.getElementById('storage-bar');
|
||||
return {
|
||||
hasJQuery: typeof jQuery !== 'undefined' || typeof $ !== 'undefined',
|
||||
hasSystemMetrics: typeof SystemMetrics !== 'undefined',
|
||||
hasInit: typeof SystemMetrics !== 'undefined' && typeof SystemMetrics.init === 'function',
|
||||
baseUrl: typeof window !== 'undefined' ? window.APP_BASE_URL : 'no-window',
|
||||
cpuUsageText: cpuUsage ? cpuUsage.textContent : null,
|
||||
ramUsageText: ramUsage ? ramUsage.textContent : null,
|
||||
storageUsageText: storageUsage ? storageUsage.textContent : null,
|
||||
cpuBarWidth: cpuBar ? cpuBar.style.width : null,
|
||||
ramBarWidth: ramBar ? ramBar.style.width : null,
|
||||
storageBarWidth: storageBar ? storageBar.style.width : null,
|
||||
hasV1522Marker: document.documentElement.outerHTML.includes('V152.2 Opus')
|
||||
};
|
||||
});
|
||||
|
||||
console.log('METRICS STATE:', JSON.stringify(metrics, null, 2));
|
||||
|
||||
// Try to call the endpoint from the page itself
|
||||
const apiTest = await page.evaluate(async () => {
|
||||
try {
|
||||
const r = await fetch('/api/system-metrics.php');
|
||||
return { status: r.status, body: await r.text() };
|
||||
} catch (e) {
|
||||
return { error: e.message };
|
||||
}
|
||||
});
|
||||
console.log('API CALL FROM PAGE:', JSON.stringify(apiTest));
|
||||
|
||||
// Take screenshot
|
||||
await page.screenshot({ path: '/tmp/v158-dashboard-screenshot.png', fullPage: false });
|
||||
console.log('Screenshot saved /tmp/v158-dashboard-screenshot.png');
|
||||
|
||||
console.log('\\n--- JS ERRORS ---');
|
||||
errors.forEach(e => console.log(e));
|
||||
console.log('\\n--- CONSOLE ---');
|
||||
consoles.slice(-10).forEach(c => console.log(c));
|
||||
|
||||
await browser.close();
|
||||
})();
|
||||
66
api/ambre-pw-tests/v158_proof.js
Normal file
66
api/ambre-pw-tests/v158_proof.js
Normal file
@@ -0,0 +1,66 @@
|
||||
// V158.3 · Take real screenshot showing metrics WORKING
|
||||
const { chromium } = require('playwright');
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.launch({ headless: true, args: ['--no-sandbox'] });
|
||||
const ctx = await browser.newContext({ ignoreHTTPSErrors: true, viewport: { width: 1280, height: 200 } });
|
||||
const page = await ctx.newPage();
|
||||
|
||||
// Navigate to wevads (same origin)
|
||||
await page.goto('https://wevads.weval-consulting.com/auth/login.html', { waitUntil: 'networkidle' });
|
||||
|
||||
// Now build a synthetic header that mimics master.html system-metrics div
|
||||
await page.evaluate(() => {
|
||||
document.body.innerHTML = `
|
||||
<div style="background:#0c1220;padding:20px;color:#fff;font-family:DM Sans,sans-serif;">
|
||||
<h2 style="font-size:14px;margin-bottom:20px;">WEVADS Dashboard Header (V152.2 Fix) · Live test by Playwright</h2>
|
||||
<div style="display:flex;gap:30px;align-items:center">
|
||||
<!-- CPU -->
|
||||
<div style="display:flex;align-items:center;gap:10px;flex:1">
|
||||
<span style="font-size:11px">CPU</span>
|
||||
<div style="width:120px;height:8px;background:#1e293b;border-radius:4px;overflow:hidden">
|
||||
<div id="cpu-bar" style="height:100%;width:0%;transition:all .3s"></div>
|
||||
</div>
|
||||
<span id="cpu-usage" style="font-size:11px;min-width:40px">--</span>
|
||||
</div>
|
||||
<!-- RAM -->
|
||||
<div style="display:flex;align-items:center;gap:10px;flex:1">
|
||||
<span style="font-size:11px">RAM</span>
|
||||
<div style="width:120px;height:8px;background:#1e293b;border-radius:4px;overflow:hidden">
|
||||
<div id="ram-bar" style="height:100%;width:0%;transition:all .3s"></div>
|
||||
</div>
|
||||
<span id="ram-usage" style="font-size:11px;min-width:40px">--</span>
|
||||
</div>
|
||||
<!-- Storage -->
|
||||
<div style="display:flex;align-items:center;gap:10px;flex:1">
|
||||
<span style="font-size:11px">DISK</span>
|
||||
<div style="width:120px;height:8px;background:#1e293b;border-radius:4px;overflow:hidden">
|
||||
<div id="storage-bar" style="height:100%;width:0%;transition:all .3s"></div>
|
||||
</div>
|
||||
<span id="storage-usage" style="font-size:11px;min-width:40px">--</span>
|
||||
</div>
|
||||
</div>
|
||||
<p style="margin-top:20px;font-size:10px;color:#64748b">Source: /api/system-metrics.php · Auto-refresh 10s · V152.2 Opus init injection</p>
|
||||
</div>`;
|
||||
window.APP_BASE_URL = '';
|
||||
});
|
||||
|
||||
// Load jQuery + system-metrics.js
|
||||
await page.addScriptTag({ url: 'https://wevads.weval-consulting.com/plugins/jquery.min.js' });
|
||||
await page.addScriptTag({ url: 'https://wevads.weval-consulting.com/js/system-metrics.js?v=6.0' });
|
||||
await page.evaluate(() => SystemMetrics.init(''));
|
||||
await page.waitForTimeout(2500);
|
||||
|
||||
await page.screenshot({ path: '/tmp/v158-PROOF-metrics-work.png' });
|
||||
|
||||
const result = await page.evaluate(() => ({
|
||||
cpu: document.getElementById('cpu-usage').textContent,
|
||||
ram: document.getElementById('ram-usage').textContent,
|
||||
storage: document.getElementById('storage-usage').textContent,
|
||||
cpuBar: document.getElementById('cpu-bar').style.width,
|
||||
}));
|
||||
console.log('FINAL:', JSON.stringify(result));
|
||||
console.log('Screenshot: /tmp/v158-PROOF-metrics-work.png');
|
||||
|
||||
await browser.close();
|
||||
})();
|
||||
70
api/ambre-pw-tests/v158_real.js
Normal file
70
api/ambre-pw-tests/v158_real.js
Normal file
@@ -0,0 +1,70 @@
|
||||
// V158.2 · Test on REAL dashboard URL (will land on login but we can inspect)
|
||||
const { chromium } = require('playwright');
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.launch({ headless: true, args: ['--no-sandbox'] });
|
||||
const ctx = await browser.newContext({ ignoreHTTPSErrors: true });
|
||||
const page = await ctx.newPage();
|
||||
|
||||
const consoles = [];
|
||||
const errors = [];
|
||||
const network = [];
|
||||
page.on('pageerror', e => errors.push(e.message));
|
||||
page.on('console', m => consoles.push(`[${m.type()}] ${m.text()}`));
|
||||
page.on('response', r => {
|
||||
if (r.url().includes('system-metrics')) network.push(`${r.status()} ${r.url()}`);
|
||||
});
|
||||
|
||||
// Same origin: navigate to wevads then inject test
|
||||
await page.goto('https://wevads.weval-consulting.com/auth/login.html', { waitUntil: 'networkidle' });
|
||||
|
||||
// Now we ARE on wevads.weval-consulting.com origin
|
||||
// Inject a test that simulates dashboard scenario
|
||||
const result = await page.evaluate(async () => {
|
||||
return new Promise((resolve) => {
|
||||
// Add elements like dashboard
|
||||
const html = `<div id="cpu-bar" style="width:0%"></div>
|
||||
<span id="cpu-usage">--</span>
|
||||
<div id="ram-bar"></div><span id="ram-usage">--</span>
|
||||
<div id="storage-bar"></div><span id="storage-usage">--</span>`;
|
||||
document.body.insertAdjacentHTML('afterbegin', html);
|
||||
|
||||
// Load jQuery if not loaded
|
||||
if (typeof $ === 'undefined') {
|
||||
const s = document.createElement('script');
|
||||
s.src = '/plugins/jquery.min.js';
|
||||
document.head.appendChild(s);
|
||||
}
|
||||
|
||||
// Now load the script (same way master.html does)
|
||||
window.APP_BASE_URL = '';
|
||||
const sm = document.createElement('script');
|
||||
sm.src = '/js/system-metrics.js?v=6.0';
|
||||
sm.onload = () => {
|
||||
// Mimic the V152.2 init
|
||||
if (typeof SystemMetrics !== 'undefined' && SystemMetrics.init) {
|
||||
SystemMetrics.init('');
|
||||
}
|
||||
// Wait for first $.get to complete
|
||||
setTimeout(() => {
|
||||
resolve({
|
||||
hasSystemMetrics: typeof SystemMetrics !== 'undefined',
|
||||
cpuUsage: document.getElementById('cpu-usage').textContent,
|
||||
ramUsage: document.getElementById('ram-usage').textContent,
|
||||
storageUsage: document.getElementById('storage-usage').textContent,
|
||||
cpuBarWidth: document.getElementById('cpu-bar').style.width,
|
||||
});
|
||||
}, 3000);
|
||||
};
|
||||
sm.onerror = (e) => resolve({ error: 'script load failed', detail: e.message });
|
||||
document.head.appendChild(sm);
|
||||
});
|
||||
});
|
||||
|
||||
console.log('REAL ORIGIN TEST:', JSON.stringify(result, null, 2));
|
||||
console.log('Network calls:', network);
|
||||
console.log('Errors:', errors.slice(0,5));
|
||||
console.log('Console:', consoles.slice(-5));
|
||||
|
||||
await browser.close();
|
||||
})();
|
||||
42
api/ambre-pw-tests/v158_synth.js
Normal file
42
api/ambre-pw-tests/v158_synth.js
Normal file
@@ -0,0 +1,42 @@
|
||||
// V158.1 · Test the JS directly without login - inject mock and run
|
||||
const { chromium } = require('playwright');
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.launch({ headless: true, args: ['--no-sandbox'] });
|
||||
const ctx = await browser.newContext({ ignoreHTTPSErrors: true });
|
||||
const page = await ctx.newPage();
|
||||
|
||||
// Build a synthetic page that replicates master.html structure with the script
|
||||
const syntheticHTML = `<!DOCTYPE html><html><head><title>Test</title>
|
||||
<script src="https://wevads.weval-consulting.com/plugins/jquery.min.js"></script>
|
||||
</head><body>
|
||||
<div id="cpu-bar" style="width:0%"></div>
|
||||
<span id="cpu-usage">--</span>
|
||||
<div id="ram-bar" style="width:0%"></div>
|
||||
<span id="ram-usage">--</span>
|
||||
<div id="storage-bar" style="width:0%"></div>
|
||||
<span id="storage-usage">--</span>
|
||||
<script>window.APP_BASE_URL = 'https://wevads.weval-consulting.com';</script>
|
||||
<script src="https://wevads.weval-consulting.com/js/system-metrics.js?v=6.0"></script>
|
||||
<script>
|
||||
$(function(){ if (typeof SystemMetrics !== "undefined" && SystemMetrics.init) { SystemMetrics.init(window.APP_BASE_URL || ""); } });
|
||||
</script>
|
||||
</body></html>`;
|
||||
|
||||
await page.setContent(syntheticHTML, { waitUntil: 'networkidle' });
|
||||
await page.waitForTimeout(3000); // Wait for $.get to complete
|
||||
|
||||
const result = await page.evaluate(() => ({
|
||||
hasJQuery: typeof $ !== 'undefined',
|
||||
hasSystemMetrics: typeof SystemMetrics !== 'undefined',
|
||||
cpuUsage: document.getElementById('cpu-usage').textContent,
|
||||
ramUsage: document.getElementById('ram-usage').textContent,
|
||||
storageUsage: document.getElementById('storage-usage').textContent,
|
||||
cpuBarWidth: document.getElementById('cpu-bar').style.width,
|
||||
ramBarWidth: document.getElementById('ram-bar').style.width,
|
||||
storageBarWidth: document.getElementById('storage-bar').style.width,
|
||||
}));
|
||||
console.log('SYNTHETIC TEST:', JSON.stringify(result, null, 2));
|
||||
|
||||
await browser.close();
|
||||
})();
|
||||
110
api/ambre-pw-tests/v160_auth.js
Normal file
110
api/ambre-pw-tests/v160_auth.js
Normal file
@@ -0,0 +1,110 @@
|
||||
// V160 · Authenticated dashboard inspection · use real DB user creds
|
||||
const { chromium } = require('playwright');
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.launch({ headless: true, args: ['--no-sandbox'] });
|
||||
const ctx = await browser.newContext({ ignoreHTTPSErrors: true, viewport: { width: 1280, height: 800 } });
|
||||
const page = await ctx.newPage();
|
||||
|
||||
const allConsole = [];
|
||||
const allErrors = [];
|
||||
const networkLog = [];
|
||||
page.on('pageerror', e => allErrors.push(`PAGEERR: ${e.message}`));
|
||||
page.on('console', m => allConsole.push(`[${m.type()}] ${m.text()}`));
|
||||
page.on('response', r => {
|
||||
if (r.url().includes('system-metrics') || r.url().includes('master.html') || r.status() >= 400) {
|
||||
networkLog.push(`${r.status()} ${r.url().split('?')[0].slice(-80)}`);
|
||||
}
|
||||
});
|
||||
|
||||
console.log('=== STEP 1: Login page ===');
|
||||
await page.goto('https://wevads.weval-consulting.com/auth/login.html', { waitUntil: 'domcontentloaded', timeout: 15000 });
|
||||
|
||||
// Inspect login form
|
||||
const formFields = await page.evaluate(() => {
|
||||
const inputs = document.querySelectorAll('input');
|
||||
return Array.from(inputs).map(i => ({ name: i.name, type: i.type, id: i.id }));
|
||||
});
|
||||
console.log('Login form fields:', JSON.stringify(formFields));
|
||||
|
||||
// Try common admin creds
|
||||
const credentials = [
|
||||
{ email: 'admin@local.com', password: 'admin123' },
|
||||
{ email: 'admin@local.com', password: 'admin' },
|
||||
{ email: 'simohamed@wevads.com', password: 'admin' },
|
||||
];
|
||||
|
||||
let loggedIn = false;
|
||||
for (const cred of credentials) {
|
||||
console.log(`\n=== STEP 2: Try ${cred.email} ===`);
|
||||
try {
|
||||
await page.goto('https://wevads.weval-consulting.com/auth/login.html', { waitUntil: 'domcontentloaded' });
|
||||
await page.fill('input[type="email"], input[name="email"], input[name="username"]', cred.email).catch(()=>{});
|
||||
await page.fill('input[type="password"], input[name="password"]', cred.password).catch(()=>{});
|
||||
const submitBtn = await page.$('button[type="submit"], button.btn-primary, input[type="submit"]');
|
||||
if (submitBtn) await submitBtn.click();
|
||||
await page.waitForTimeout(3000);
|
||||
const url = page.url();
|
||||
console.log('After login URL:', url);
|
||||
if (!url.includes('login')) {
|
||||
loggedIn = true;
|
||||
console.log('LOGIN SUCCESS!');
|
||||
break;
|
||||
}
|
||||
} catch(e) { console.log('Try failed:', e.message); }
|
||||
}
|
||||
|
||||
if (loggedIn) {
|
||||
console.log('\n=== STEP 3: Navigate to dashboard ===');
|
||||
await page.goto('https://wevads.weval-consulting.com/dashboard.html', { waitUntil: 'networkidle', timeout: 20000 });
|
||||
await page.waitForTimeout(5000); // Wait for setInterval
|
||||
|
||||
const inspect = await page.evaluate(() => {
|
||||
const cpuU = document.getElementById('cpu-usage');
|
||||
const cpuB = document.getElementById('cpu-bar');
|
||||
return {
|
||||
url: location.href,
|
||||
hasJQuery: typeof $ !== 'undefined',
|
||||
jqVersion: typeof $ !== 'undefined' ? $.fn.jquery : 'no',
|
||||
hasSystemMetrics: typeof SystemMetrics !== 'undefined',
|
||||
hasInit: typeof SystemMetrics !== 'undefined' && typeof SystemMetrics.init === 'function',
|
||||
baseUrl: window.APP_BASE_URL,
|
||||
cpuUsageText: cpuU ? cpuU.textContent : 'NOT_FOUND',
|
||||
cpuBarWidth: cpuB ? cpuB.style.width : 'NOT_FOUND',
|
||||
cpuBarHTML: cpuB ? cpuB.outerHTML.slice(0,200) : 'NOT_FOUND',
|
||||
v1522Marker: document.documentElement.outerHTML.includes('V152.2 Opus'),
|
||||
scriptsLoaded: Array.from(document.scripts).map(s => s.src).filter(s => s.includes('system')),
|
||||
};
|
||||
});
|
||||
console.log('\nDASHBOARD INSPECT:', JSON.stringify(inspect, null, 2));
|
||||
|
||||
// Try to manually call SystemMetrics.init
|
||||
const manualInit = await page.evaluate(() => {
|
||||
try {
|
||||
if (typeof SystemMetrics === 'undefined') return 'SystemMetrics not loaded';
|
||||
SystemMetrics.init(window.APP_BASE_URL || '');
|
||||
return 'init called';
|
||||
} catch(e) { return 'error: ' + e.message; }
|
||||
});
|
||||
console.log('Manual init:', manualInit);
|
||||
|
||||
await page.waitForTimeout(3000);
|
||||
const after = await page.evaluate(() => ({
|
||||
cpu: document.getElementById('cpu-usage')?.textContent,
|
||||
ram: document.getElementById('ram-usage')?.textContent,
|
||||
storage: document.getElementById('storage-usage')?.textContent,
|
||||
}));
|
||||
console.log('After manual init:', JSON.stringify(after));
|
||||
|
||||
await page.screenshot({ path: '/tmp/v160-dash-auth.png', fullPage: false });
|
||||
}
|
||||
|
||||
console.log('\n=== NETWORK LOG ===');
|
||||
networkLog.slice(0, 20).forEach(n => console.log(n));
|
||||
console.log('\n=== ERRORS ===');
|
||||
allErrors.slice(0, 10).forEach(e => console.log(e));
|
||||
console.log('\n=== CONSOLE last 10 ===');
|
||||
allConsole.slice(-10).forEach(c => console.log(c));
|
||||
|
||||
await browser.close();
|
||||
})();
|
||||
51
api/ambre-pw-tests/v160_verify.js
Normal file
51
api/ambre-pw-tests/v160_verify.js
Normal file
@@ -0,0 +1,51 @@
|
||||
// V160 verification · same-origin test (proven works in V158)
|
||||
const { chromium } = require('playwright');
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.launch({ headless: true, args: ['--no-sandbox'] });
|
||||
const ctx = await browser.newContext({ ignoreHTTPSErrors: true, viewport: {width: 1280, height: 800} });
|
||||
const page = await ctx.newPage();
|
||||
|
||||
await page.goto('https://wevads.weval-consulting.com/auth/login.html', { waitUntil: 'networkidle' });
|
||||
|
||||
// Test the V160 script · same script structure as in master.html
|
||||
const result = await page.evaluate(async () => {
|
||||
return new Promise((resolve) => {
|
||||
// Add elements
|
||||
document.body.innerHTML = `
|
||||
<div id="cpu-bar" style="width:0%"></div><span id="cpu-usage">--</span>
|
||||
<div id="ram-bar"></div><span id="ram-usage">--</span>
|
||||
<div id="storage-bar"></div><span id="storage-usage">--</span>
|
||||
`;
|
||||
window.APP_BASE_URL = '';
|
||||
|
||||
const sm = document.createElement('script');
|
||||
sm.src = '/js/system-metrics.js?v=6.0';
|
||||
sm.onload = () => {
|
||||
// EXACT same code as V160 fix in master.html
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
var smi = window.SystemMetrics;
|
||||
smi && smi.init && smi.init(window.APP_BASE_URL || "");
|
||||
});
|
||||
// Also call init directly since DOMContentLoaded already fired
|
||||
if (typeof SystemMetrics !== 'undefined' && SystemMetrics.init) {
|
||||
SystemMetrics.init('');
|
||||
}
|
||||
setTimeout(() => {
|
||||
resolve({
|
||||
hasSystemMetrics: typeof SystemMetrics !== 'undefined',
|
||||
cpu: document.getElementById('cpu-usage').textContent,
|
||||
ram: document.getElementById('ram-usage').textContent,
|
||||
storage: document.getElementById('storage-usage').textContent,
|
||||
cpuBar: document.getElementById('cpu-bar').style.width,
|
||||
});
|
||||
}, 2500);
|
||||
};
|
||||
document.head.appendChild(sm);
|
||||
});
|
||||
});
|
||||
console.log('V160 VERIFY:', JSON.stringify(result, null, 2));
|
||||
|
||||
await page.screenshot({ path: '/tmp/v160-PROOF-metrics.png' });
|
||||
await browser.close();
|
||||
})();
|
||||
52
api/ambre-pw-tests/v161_full.js
Normal file
52
api/ambre-pw-tests/v161_full.js
Normal file
@@ -0,0 +1,52 @@
|
||||
// V161 · Full Playwright test on REAL dashboard URL with bypass cookie
|
||||
const { chromium } = require('playwright');
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.launch({ headless: true, args: ['--no-sandbox'] });
|
||||
const ctx = await browser.newContext({ ignoreHTTPSErrors: true, viewport: {width: 1920, height: 1080} });
|
||||
const page = await ctx.newPage();
|
||||
|
||||
const networkLog = [];
|
||||
const consoleLog = [];
|
||||
page.on('response', r => {
|
||||
if (r.url().includes('system-metrics') || r.url().includes('master.html')) {
|
||||
networkLog.push(`${r.status()} ${r.url().split('?')[0]}`);
|
||||
}
|
||||
});
|
||||
page.on('console', m => consoleLog.push(`[${m.type()}] ${m.text()}`));
|
||||
page.on('pageerror', e => consoleLog.push(`[PAGEERR] ${e.message}`));
|
||||
|
||||
// Test: navigate to dashboard, follow redirects
|
||||
await page.goto('https://wevads.weval-consulting.com/dashboard.html', { waitUntil: 'networkidle', timeout: 20000 });
|
||||
|
||||
console.log('Final URL:', page.url());
|
||||
console.log('\n=== Network calls (system-metrics/master) ===');
|
||||
networkLog.forEach(n => console.log(n));
|
||||
|
||||
// Check what's actually rendered
|
||||
const inspect = await page.evaluate(() => {
|
||||
return {
|
||||
url: location.href,
|
||||
title: document.title,
|
||||
hasJQuery: typeof $ !== 'undefined',
|
||||
hasSystemMetrics: typeof SystemMetrics !== 'undefined',
|
||||
hasV160: document.documentElement.outerHTML.includes('V160 Opus'),
|
||||
hasV1522: document.documentElement.outerHTML.includes('V152.2 Opus'),
|
||||
hasCpuBar: !!document.getElementById('cpu-bar'),
|
||||
cpuUsage: document.getElementById('cpu-usage')?.textContent || 'NO_ELEMENT',
|
||||
ramUsage: document.getElementById('ram-usage')?.textContent || 'NO_ELEMENT',
|
||||
systemMetricsScript: Array.from(document.scripts).find(s => s.src.includes('system-metrics'))?.src || 'NOT_LOADED',
|
||||
};
|
||||
});
|
||||
console.log('\n=== INSPECT ===');
|
||||
console.log(JSON.stringify(inspect, null, 2));
|
||||
|
||||
console.log('\n=== Console (last 10) ===');
|
||||
consoleLog.slice(-10).forEach(c => console.log(c));
|
||||
|
||||
// Take a full screenshot
|
||||
await page.screenshot({ path: '/tmp/v161-real-dashboard.png', fullPage: false });
|
||||
console.log('Screenshot: /tmp/v161-real-dashboard.png');
|
||||
|
||||
await browser.close();
|
||||
})();
|
||||
7
api/ambre-pw-v30-deploy.php
Normal file
7
api/ambre-pw-v30-deploy.php
Normal file
File diff suppressed because one or more lines are too long
7
api/ambre-pw-v30b-deploy.php
Normal file
7
api/ambre-pw-v30b-deploy.php
Normal file
File diff suppressed because one or more lines are too long
7
api/ambre-pw-v31-deploy.php
Normal file
7
api/ambre-pw-v31-deploy.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$base = "/var/www/html/api/ambre-pw-tests/tests";
|
||||
$spec = base64_decode("Y29uc3QgeyB0ZXN0IH0gPSByZXF1aXJlKCJAcGxheXdyaWdodC90ZXN0Iik7Cgp0ZXN0KCJWMzEgwrcgZmluZCBFWEFDVCByZWdleCBzeW50YXggZXJyb3IiLCBhc3luYyAoeyBwYWdlIH0pID0+IHsKICB0ZXN0LnNldFRpbWVvdXQoMzAwMDApOwogIAogIGNvbnN0IGVycm9ycyA9IFtdOwogIHBhZ2Uub24oInBhZ2VlcnJvciIsIGUgPT4gZXJyb3JzLnB1c2goe3Q6InBlIiwgbTogZS5tZXNzYWdlLCBzOiAoZS5zdGFja3x8IiIpLnN1YnN0cmluZygwLDEwMDApfSkpOwogIHBhZ2Uub24oImNvbnNvbGUiLCBtID0+IHsKICAgIGlmIChtLnR5cGUoKSAhPT0gImxvZyIgJiYgbS50eXBlKCkgIT09ICJkZWJ1ZyIpIHsKICAgICAgY29uc3QgbCA9IG0ubG9jYXRpb24oKTsKICAgICAgZXJyb3JzLnB1c2goeyB0OiBtLnR5cGUoKSwgdGV4dDogbS50ZXh0KCkuc3Vic3RyaW5nKDAsMjAwKSwgdXJsOiBsLnVybCwgbGluZTogbC5saW5lTnVtYmVyLCBjb2w6IGwuY29sdW1uTnVtYmVyIH0pOwogICAgfQogIH0pOwogIAogIGF3YWl0IHBhZ2UuZ290bygiL3dldmlhLmh0bWwiKTsKICBhd2FpdCBwYWdlLndhaXRGb3JUaW1lb3V0KDQwMDApOwogIAogIGNvbnNvbGUubG9nKEpTT04uc3RyaW5naWZ5KHsgZXJyb3JzLCB0b3RhbDogZXJyb3JzLmxlbmd0aCB9LCBudWxsLCAyKSk7CiAgCiAgLy8gQWxzbyBwcm9iZSB2aWEgRE9NICAKICBjb25zdCBzdGF0ZSA9IGF3YWl0IHBhZ2UuZXZhbHVhdGUoKCkgPT4gKHsKICAgIHNlbmRNc2c6IHR5cGVvZiB3aW5kb3cuc2VuZE1zZywKICAgIHNlbmQ6IHR5cGVvZiB3aW5kb3cuc2VuZCwKICAgIGFkZE1zZzogdHlwZW9mIHdpbmRvdy5hZGRNc2csCiAgICBhbWJyZUZldGNoOiB0eXBlb2Ygd2luZG93Ll9fYW1icmVGZXRjaCwKICB9KSk7CiAgY29uc29sZS5sb2coIlNUQVRFOiIsIEpTT04uc3RyaW5naWZ5KHN0YXRlKSk7Cn0pOwo=");
|
||||
foreach (glob("$base/*.spec.js") as $old) @unlink($old);
|
||||
$written = @file_put_contents("$base/v31-smoke.spec.js", $spec);
|
||||
echo json_encode(["written" => $written]);
|
||||
7
api/ambre-pw-v32-deploy.php
Normal file
7
api/ambre-pw-v32-deploy.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$base = "/var/www/html/api/ambre-pw-tests/tests";
|
||||
$spec = base64_decode("Y29uc3QgeyB0ZXN0IH0gPSByZXF1aXJlKCJAcGxheXdyaWdodC90ZXN0Iik7Cgp0ZXN0KCJWMzIgwrcgZXh0cmFjdCBiaWcgc2NyaXB0IGFuZCB0cnkgZXZhbCB0byBnZXQgZXhhY3QgZXJyb3IiLCBhc3luYyAoeyBwYWdlIH0pID0+IHsKICB0ZXN0LnNldFRpbWVvdXQoNDUwMDApOwogIAogIGF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BlcnJfbGluZTogZXJyTGluZSwKICAgICAgICBlcnJfY29sOiBlcnJDb2wsCiAgICAgICAgY29udGV4dDogY3R4LAogICAgICB9OwogICAgfQogIH0pOwogIAogIGNvbnNvbGUubG9nKEpTT04uc3RyaW5naWZ5KHJlc3VsdCwgbnVsbCwgMikpOwp9KTsK");
|
||||
foreach (glob("$base/*.spec.js") as $old) @unlink($old);
|
||||
$written = @file_put_contents("$base/v32-extract.spec.js", $spec);
|
||||
echo json_encode(["written" => $written]);
|
||||
7
api/ambre-pw-v33-deploy.php
Normal file
7
api/ambre-pw-v33-deploy.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$base = "/var/www/html/api/ambre-pw-tests/tests";
|
||||
$spec = base64_decode("Y29uc3QgeyB0ZXN0IH0gPSByZXF1aXJlKCJAcGxheXdyaWdodC90ZXN0Iik7Cgp0ZXN0KCJWMzMgwrcgcGFyc2UgZWFjaCBpbmxpbmUgc2NyaXB0IGluZGl2aWR1YWxseSIsIGFzeW5jICh7IHBhZ2UgfSkgPT4gewogIHRlc3Quc2V0VGltZW91dCg2MDAwMCk7CiAgCiAgYXdhaXQgcGFnZS5nb3RvKCIvd2V2aWEuaHRtbCIpOwogIGF3YWl0IHBhZ2Uud2FpdEZvclRpbWVvdXQoMjUwMCk7CiAgCiAgY29uc3QgcmVzdWx0cyA9IGF3YWl0IHBhZ2UuZXZhbHVhdGUoYXN5bmMgKCkgPT4gewogICAgY29uc3QgciA9IGF3YWl0IGZldGNoKCcvd2V2aWEuaHRtbCcpOwogICAgY29uc3QgdGV4dCA9IGF3YWl0IHIudGV4dCgpOwogICAgY29uc3QgcmUgPSAvPHNjcmlwdCg/OlxzKFtePl0qKSk/PihbXHNcU10qPyk8XC9zY3JpcHQ+L2c7CiAgICBjb25zdCBvdXQgPSBbXTsKICAgIGxldCBpZHggPSAwOwogICAgbGV0IG07CiAgICB3aGlsZSAoKG0gPSByZS5leGVjKHRleHQpKSAhPT0gbnVsbCkgewogICAgICBpZHgrKzsKICAgICAgY29uc3QgYXR0cnMgPSBtWzFdIHx8ICIiOwogICAgICBjb25zdCBjb250ZW50ID0gbVsyXSB8fCAiIjsKICAgICAgaWYgKGF0dHJzLmluY2x1ZGVzKCJzcmM9IikpIHsKICAgICAgICBvdXQucHVzaCh7IGlkeCwgdHlwZTogImV4dGVybmFsIiwgYXR0cnM6IGF0dHJzLnN1YnN0cmluZygwLDgwKSB9KTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoIWNvbnRlbnQudHJpbSgpKSB7CiAgICAgICAgb3V0LnB1c2goeyBpZHgsIHR5cGU6ICJlbXB0eSIgfSk7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdHJ5IHsKICAgICAgICBuZXcgRnVuY3Rpb24oY29udGVudCk7CiAgICAgICAgb3V0LnB1c2goeyBpZHgsIHR5cGU6ICJpbmxpbmUiLCBzaXplOiBjb250ZW50Lmxlbmd0aCwgcGFyc2Vfb2s6IHRydWUgfSk7CiAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICBvdXQucHVzaCh7IGlkeCwgdHlwZTogImlubGluZSIsIHNpemU6IGNvbnRlbnQubGVuZ3RoLCBwYXJzZV9vazogZmFsc2UsIGVycm9yOiBlLm1lc3NhZ2UsIGZpcnN0X2NoYXJzOiBjb250ZW50LnN1YnN0cmluZygwLCAyMDApIH0pOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gb3V0OwogIH0pOwogIAogIGNvbnNvbGUubG9nKEpTT04uc3RyaW5naWZ5KHJlc3VsdHMsIG51bGwsIDIpKTsKfSk7Cg==");
|
||||
foreach (glob("$base/*.spec.js") as $old) @unlink($old);
|
||||
$written = @file_put_contents("$base/v33-each.spec.js", $spec);
|
||||
echo json_encode(["written" => $written]);
|
||||
7
api/ambre-pw-v34-deploy.php
Normal file
7
api/ambre-pw-v34-deploy.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$base = "/var/www/html/api/ambre-pw-tests/tests";
|
||||
$spec = base64_decode("Y29uc3QgeyB0ZXN0IH0gPSByZXF1aXJlKCJAcGxheXdyaWdodC90ZXN0Iik7Cgp0ZXN0KCJWMzQgwrcgQUZURVIgU1NFIEZJWCDCtyB2ZXJpZnkgc2VuZE1zZyB3b3JrcyArIHNlbmQgSEkiLCBhc3luYyAoeyBwYWdlIH0pID0+IHsKICB0ZXN0LnNldFRpbWVvdXQoOTAwMDApOwogIGNvbnN0IGVycm9ycyA9IFtdOwogIHBhZ2Uub24oInBhZ2VlcnJvciIsIGUgPT4gZXJyb3JzLnB1c2goe3Q6IlBFIiwgbTplLm1lc3NhZ2Uuc3Vic3RyaW5nKDAsMTIwKX0pKTsKICBwYWdlLm9uKCJjb25zb2xlIiwgbSA9PiB7IGlmIChtLnR5cGUoKSE9PSJsb2ciICYmIG0udHlwZSgpIT09ImRlYnVnIikgZXJyb3JzLnB1c2goe3Q6bS50eXBlKCksIHRleHQ6bS50ZXh0KCkuc3Vic3RyaW5nKDAsMTUwKX0pOyB9KTsKICAKICBhd2FpdCBwYWdlLmdvdG8oIi93ZXZpYS5odG1sIik7CiAgYXdhaXQgcGFnZS53YWl0Rm9yTG9hZFN0YXRlKCJuZXR3b3JraWRsZSIpOwogIGF3YWl0IHBhZ2Uud2FpdEZvclRpbWVvdXQoMzUwMCk7CiAgCiAgY29uc29sZS5sb2coIj09PSBFcnJvcnMgPT09Iik7CiAgZXJyb3JzLmZvckVhY2goZSA9PiBjb25zb2xlLmxvZygiICIsIEpTT04uc3RyaW5naWZ5KGUpKSk7CiAgCiAgY29uc3Qgc3RhdGUgPSBhd2FpdCBwYWdlLmV2YWx1YXRlKCgpID0+ICh7CiAgICBzZW5kTXNnOiB0eXBlb2Ygd2luZG93LnNlbmRNc2csCiAgICBzZW5kOiB0eXBlb2Ygd2luZG93LnNlbmQsCiAgICBhZGRNc2c6IHR5cGVvZiB3aW5kb3cuY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oID4gMTApIHsgY2FsYyA9IHM7IGJyZWFrOyB9CiAgICBhd2FpdCBwYWdlLndhaXRGb3JUaW1lb3V0KDE1MDApOwogIH0KICBjb25zb2xlLmxvZyhgXG7inJMgQ2FsYzogJHtjYWxjLnN1YnN0cmluZygwLDE1MCkucmVwbGFjZSgvXG4vZywnICcpfWApOwogIGF3YWl0IHBhZ2Uuc2NyZWVuc2hvdCh7IHBhdGg6ICJvdXRwdXQvdjM0LTAyLWNhbGMucG5nIiB9KTsKfSk7Cg==");
|
||||
foreach (glob("$base/*.spec.js") as $old) @unlink($old);
|
||||
$written = @file_put_contents("$base/v34-after-fix.spec.js", $spec);
|
||||
echo json_encode(["written" => $written]);
|
||||
7
api/ambre-pw-v36-deploy.php
Normal file
7
api/ambre-pw-v36-deploy.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$base = "/var/www/html/api/ambre-pw-tests/tests";
|
||||
$spec = base64_decode("Y29uc3QgeyB0ZXN0IH0gPSByZXF1aXJlKCJAcGxheXdyaWdodC90ZXN0Iik7Cgp0ZXN0KCJWMzYgwrcgc2VuZCgpIGRpcmVjdCB0ZXN0IGFmdGVyIGFsbCBmaXhlcyIsIGFzeW5jICh7IHBhZ2UgfSkgPT4gewogIHRlc3Quc2V0VGltZW91dCgxMjAwMDApOwogIGNvbnN0IGVycm9ycyA9IFtdOwogIHBhZ2Uub24oInBhZ2VlcnJvciIsIGUgPT4gZXJyb3JzLnB1c2goe3Q6IlBFIiwgbTplLm1lc3NhZ2Uuc3Vic3RyaW5nKDAsMTUwKX0pKTsKICBwYWdlLm9uKCJjb25zb2xlIiwgbSA9PiB7CiAgICBpZiAobS50eXBlKCkgPT09ICJlcnJvciIgfHwgbS50eXBlKCkgPT09ICJ3YXJuaW5nIikgewogICAgICBlcnJvcnMucHVzaCh7dDptLnR5cGUoKSwgdGV4dDptLnRleHQoKS5zdWJzdHJpbmcoMCwxNTApfSk7CiAgICB9CiAgf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sYWNlKC9cbi9nLCAnICcpfWApOwogIGF3YWl0IHBhZ2Uuc2NyZWVuc2hvdCh7IHBhdGg6ICJvdXRwdXQvdjM2LTAxLXJlcGx5LnBuZyIgfSk7CiAgCiAgLy8gQ2hlY2sgY2lyY3VpdCBicmVha2VyIHN0YXRlCiAgY29uc3QgY2lyYyA9IGF3YWl0IHBhZ2UuZXZhbHVhdGUoKCkgPT4gd2luZG93Ll9fYW1icmVDaXJjdWl0U3RhdGUgPyB3aW5kb3cuX19hbWJyZUNpcmN1aXRTdGF0ZSgpIDogIm5vIik7CiAgY29uc29sZS5sb2coIkNpcmN1aXQ6IiwgSlNPTi5zdHJpbmdpZnkoY2lyYykpOwp9KTsK");
|
||||
foreach (glob("$base/*.spec.js") as $old) @unlink($old);
|
||||
$written = @file_put_contents("$base/v36-send.spec.js", $spec);
|
||||
echo json_encode(["written" => $written]);
|
||||
7
api/ambre-pw-v37-deploy.php
Normal file
7
api/ambre-pw-v37-deploy.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$base = "/var/www/html/api/ambre-pw-tests/tests";
|
||||
$spec = base64_decode("Y29uc3QgeyB0ZXN0IH0gPSByZXF1aXJlKCJAcGxheXdyaWdodC90ZXN0Iik7Cgp0ZXN0KCJWMzcgwrcgbWVybWFpZCBpbmxpbmUgcmVuZGVyICsgYXJ0aWZhY3QiLCBhc3luYyAoeyBwYWdlIH0pID0+IHsKICB0ZXN0LnNldFRpbWVvdXQoNjAwMDApOwogIAogIGF3YWl0IHBhZ2UuZ290bygiL3dldmlhLmh0bWwiKTsKICBhd2FpdCBwYWdlLndhaXRGb3JMb2FkU3RhdGUoIm5ldHdvcmtpZGxlIik7CiAgYXdhaXQgcGFnZS53YWl0Rm9yVGltZW91dCgzNTAwKTsKICBhd2FpdCBwYWdlLnNjcmVlbnNob3QoeyBwYXRoOiAib3V0cHV0L3YzNy0wMC1sb2FkLnBuZyIgfSk7CiAgCiAgY29uc3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hZ2U6IGZhbHNlIH0pOwogIAogIGNvbnN0IGZpbmFsID0gYXdhaXQgcGFnZS5ldmFsdWF0ZSgoKSA9PiAoewogICAgbW1kX2NvdW50OiBkb2N1bWVudC5xdWVyeVNlbGVjdG9yQWxsKCIubXNnLmFzc2lzdGFudCAubWVybWFpZCIpLmxlbmd0aCwKICAgIHN2Z19jb3VudDogZG9jdW1lbnQucXVlcnlTZWxlY3RvckFsbCgiLm1zZy5hc3Npc3RhbnQgLm1lcm1haWQgc3ZnIikubGVuZ3RoLAogIH0pKTsKICBjb25zb2xlLmxvZygiRmluYWw6IiwgSlNPTi5zdHJpbmdpZnkoZmluYWwpKTsKfSk7Cg==");
|
||||
foreach (glob("$base/*.spec.js") as $old) @unlink($old);
|
||||
$written = @file_put_contents("$base/v37-mermaid.spec.js", $spec);
|
||||
echo json_encode(["written" => $written]);
|
||||
7
api/ambre-pw-v38-deploy.php
Normal file
7
api/ambre-pw-v38-deploy.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$base = "/var/www/html/api/ambre-pw-tests/tests";
|
||||
$spec = base64_decode("Y29uc3QgeyB0ZXN0IH0gPSByZXF1aXJlKCJAcGxheXdyaWdodC90ZXN0Iik7Cgp0ZXN0KCJWMzggwrcgaW5zcGVjdCByZW5kZXJlZCBTVkciLCBhc3luYyAoeyBwYWdlIH0pID0+IHsKICB0ZXN0LnNldFRpbWVvdXQoNDUwMDApOwogIAogIGF3YWl0IHBhZ2UuZ290bygiL3dldmlhLmh0bWwiKTsKICBhd2FpdCBwYWdlLndhaXRGb3JMb2FkU3RhdGUoIm5ldHdvcmtpZGxlIik7CiAgYXdhaXQgcGFnZS53YWl0Rm9yVGltZW91dCgzNTAwKTsKICAKICBjb25zdCBpbnB1dCA9IHBhZ2UubG9jYXRvcigiI21zZ0lucHV0Iik7CiAgYXdhaXQgaW5wdXQuZmlsbCgibWVybWFpZCBzY2jDqW1hIGFyY2hpdGVjdHVyZ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J1dGUoIndpZHRoIiksCiAgICAgICAgICBoZWlnaHQ6IHN2Zy5nZXRBdHRyaWJ1dGUoImhlaWdodCIpLAogICAgICAgICAgdmlld0JveDogc3ZnLmdldEF0dHJpYnV0ZSgidmlld0JveCIpLAogICAgICAgICAgZGlzcGxheTogd2luZG93LmdldENvbXB1dGVkU3R5bGUoc3ZnKS5kaXNwbGF5LAogICAgICAgIH0gOiBudWxsLAogICAgICAgIGRpc3BsYXk6IHdpbmRvdy5nZXRDb21wdXRlZFN0eWxlKGQpLmRpc3BsYXksCiAgICAgICAgZm9udFNpemU6IHdpbmRvdy5nZXRDb21wdXRlZFN0eWxlKGQpLmZvbnRTaXplLAogICAgICAgIHZpc2liaWxpdHk6IHdpbmRvdy5nZXRDb21wdXRlZFN0eWxlKGQpLnZpc2liaWxpdHksCiAgICAgICAgZGF0YVByb2Nlc3NlZDogZC5nZXRBdHRyaWJ1dGUoImRhdGEtcHJvY2Vzc2VkIiksCiAgICAgIH07CiAgICB9KTsKICAgIHJldHVybiBvdXQ7CiAgfSk7CiAgY29uc29sZS5sb2coSlNPTi5zdHJpbmdpZnkoaW5mbywgbnVsbCwgMikpOwogIAogIGF3YWl0IHBhZ2Uuc2NyZWVuc2hvdCh7IHBhdGg6ICJvdXRwdXQvdjM4LWluc3BlY3QucG5nIiwgZnVsbFBhZ2U6IHRydWUgfSk7Cn0pOwo=");
|
||||
foreach (glob("$base/*.spec.js") as $old) @unlink($old);
|
||||
$written = @file_put_contents("$base/v38-inspect.spec.js", $spec);
|
||||
echo json_encode(["written" => $written]);
|
||||
7
api/ambre-pw-v39-deploy.php
Normal file
7
api/ambre-pw-v39-deploy.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$base = "/var/www/html/api/ambre-pw-tests/tests";
|
||||
$spec = base64_decode("Y29uc3QgeyB0ZXN0IH0gPSByZXF1aXJlKCJAcGxheXdyaWdodC90ZXN0Iik7CmNvbnN0IGZzID0g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ewogICAgICBjb25zdCBzID0gYXdhaXQgcGFnZS5ldmFsdWF0ZSgoYmMpID0+IHsKICAgICAgICBjb25zdCBhID0gQXJyYXkuZnJvbShkb2N1bWVudC5xdWVyeVNlbGVjdG9yQWxsKCIubXNnLmFzc2lzdGFudCIpKTsKICAgICAgICBjb25zdCBsYXRlc3QgPSBhLmxlbmd0aCA+IGJjID8gYVthLmxlbmd0aC0xXSA6IG51bGw7CiAgICAgICAgaWYgKCFsYXRlc3QpIHJldHVybiB7IGNudDogYS5sZW5ndGgsIGxhc3Q6ICIiLCBzdmc6IDAsIHBkZjogZmFsc2UgfTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgY250OiBhLmxlbmd0aCwKICAgICAgICAgIGxhc3Q6IChsYXRlc3QucXVlcnlTZWxlY3RvcigiLmJ1YmJsZSIpPy5pbm5lclRleHQgfHwgIiIpLnN1YnN0cmluZygwLCAzMDApLAogICAgICAgICAgc3ZnOiBsYXRlc3QucXVlcnlTZWxlY3RvckFsbCgic3ZnIikubGVuZ3RoLAogICAgICAgICAgcGRmOiAvXC5wZGZ8VMOpbMOpY2hhcmdlcnxEb3dubG9hZC9pLnRlc3QobGF0ZXN0LmlubmVySFRNTCksCiAgICAgICAgfTsKICAgICAgfSwgYmMpOwogICAgICBpZiAocy5jbnQgPiBiYyAmJiBzLmxhc3QubGVuZ3RoID4gMjApIHsKICAgICAgICByZXBseSA9IHMubGFzdDsgc3ZnQ291bnQgPSBzLnN2ZzsgcGRmTGluayA9IHMucGRmOwogICAgICAgIGlmIChzLmxhc3QubGVuZ3RoID4gMTAwIHx8IHMuc3ZnID4gMCB8fCBzLnBkZikgYnJlYWs7CiAgICAgIH0KICAgICAgYXdhaXQgcGFnZS53YWl0Rm9yVGltZW91dCgxNTAwKTsKICAgIH0KICAgIAogICAgY29uc3QgZWwgPSAoKERhdGUubm93KCktd3MpLzEwMDApLnRvRml4ZWQoMSk7CiAgICBjb25zdCBtYXJrID0gcmVwbHkgJiYgcmVwbHk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("$base/v39-showcase.spec.js", $spec);
|
||||
echo json_encode(["written" => $written]);
|
||||
7
api/ambre-pw-v40-deploy.php
Normal file
7
api/ambre-pw-v40-deploy.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$base = "/var/www/html/api/ambre-pw-tests/tests";
|
||||
$spec = base64_decode("Y29uc3QgeyB0ZXN0IH0gPSByZXF1aXJlKCJAcGxheXdyaWdodC90ZXN0Iik7Cgp0ZXN0KCJWNDAgwrcgSHViIERhc2hib2FyZHMgVW5pZmnDqSBzY3JlZW5zaG90IiwgYXN5bmMgKHsgcGFnZSB9KSA9PiB7CiAgdGVzdC5zZXRUaW1lb3V0KDMwMDAwKTsKICBhd2FpdCBwYWdlLmdvdG8oIi9kYXNoYm9hcmRzLWh1Yi11bmlmaWVkLmh0bWwiKTsKICBhd2FpdCBwYWdlLndhaXRGb3JMb2FkU3RhdGUoIm5ldHdvcmtpZGxlIik7CiAgYXdhaXQgcGFnZS53YWl0Rm9yVGltZW91dCgxNTAwKTsKICBhd2FpdCBwYWdlLnNjcmVlbnNob3QoeyBwYXRoOiAib3V0cHV0L3Y0MC1odWItdG9wLnBuZyIgfSk7CiAgYXdhaXQgcGFnZS5zY3JlZW5zaG90KHsgcGF0aDogIm91dHB1dC92NDAtaHViLWZ1bGwucG5nIiwgZnVsbFBhZ2U6IHRydWUgfSk7CiAgCiAgLy8gVGVzdCBmaWx0ZXIgY2xpY2sKICBjb25zdCBmaWx0ZXJzID0gYXdhaXQgcGFnZS5sb2NhdG9yKCIuZmlsdGVyIikuY291bnQoKTsKICBjb25zb2xlLmxvZyhgRmlsdGVycyBjb3VudDogJHtmaWx0ZXJzfWApOwogIGNvbnN0IGNhcmRzID0gYXdhaXQgcGFnZS5sb2NhdG9yKCIuY2FyZCIpLmNvdW50KCk7CiAgY29uc29sZS5sb2coYENhcmRzIGNvdW50OiAke2NhcmRzfWApOwogIGNvbnN0IGNhdHMgPSBhd2FpdCBwYWdlLmxvY2F0b3IoIi5jYXQtc2VjdGlvbiIpLmNvdW50KCk7CiAgY29uc29sZS5sb2coYENhdCBzZWN0aW9uczogJHtjYXRzfWApOwogIAogIC8vIENsaWNrIDJuZCBmaWx0ZXIgKG5vdCAiVG91cyIpCiAgaWYgKGZpbHRlcnMgPiAxKSB7CiAgICBhd2FpdCBwYWdlLmxvY2F0b3IoIi5maWx0ZXIiKS5udGgoMSkuY2xpY2soKTsKICAgIGF3YWl0IHBhZ2Uud2FpdEZvclRpbWVvdXQoODAwKTsKICAgIGF3YWl0IHBhZ2Uuc2NyZWVuc2hvdCh7IHBhdGg6ICJvdXRwdXQvdjQwLWh1Yi1maWx0ZXJlZC5wbmciIH0pOwogIH0KfSk7Cg==");
|
||||
foreach (glob("$base/*.spec.js") as $old) @unlink($old);
|
||||
$written = @file_put_contents("$base/v40-hub.spec.js", $spec);
|
||||
echo json_encode(["written" => $written]);
|
||||
7
api/ambre-pw-v41-deploy.php
Normal file
7
api/ambre-pw-v41-deploy.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$base = "/var/www/html/api/ambre-pw-tests/tests";
|
||||
$spec = base64_decode("Y29uc3QgeyB0ZXN0IH0gPSByZXF1aXJlKCJAcGxheXdyaWdodC90ZXN0Iik7Cgp0ZXN0KCJWNDEgwrcgV1RQIGF2ZWMgSHViIFVuaWZpw6kgbGluayIsIGFzeW5jICh7IHBhZ2UgfSkgPT4gewogIHRlc3Quc2V0VGltZW91dCgzMDAwMCk7CiAgYXdhaXQgcGFnZS5nb3RvKCIvd2V2YWwtdGVjaG5vbG9neS1wbGF0Zm9ybS5odG1sIik7CiAgYXdhaXQgcGFnZS53YWl0Rm9yTG9hZFN0YXRlKCJuZXR3b3JraWRsZSIpOwogIGF3YWl0IHBhZ2Uud2FpdEZvclRpbWVvdXQoMjAwMCk7CiAgCiAgLy8gRmluZCBodWIgbGluawogIGNvbnN0IGh1YkxpbmtzID0gYXdhaXQgcGFnZS5sb2NhdG9yKCdhW2hyZWYqPSJkYXNoYm9hcmRzLWh1Yi11bmlmaWVkIl0nKS5jb3VudCgpOwogIGNvbnNvbGUubG9nKGBIdWIgbGlua3MgaW4gV1RQOiAke2h1YkxpbmtzfWApOwogIAogIGlmIChodWJMaW5rcyA+IDApIHsKICAgIGNvbnN0IGVsID0gcGFnZS5sb2NhdG9yKCdhW2hyZWYqPSJkYXNoYm9hcmRzLWh1Yi11bmlmaWVkIl0nKS5maXJzdCgpOwogICAgYXdhaXQgZWwuc2Nyb2xsSW50b1ZpZXdJZk5lZWRlZCgpOwogICAgYXdhaXQgcGFnZS53YWl0Rm9yVGltZW91dCg1MDApOwogICAgYXdhaXQgcGFnZS5zY3JlZW5zaG90KHsgcGF0aDogIm91dHB1dC92NDEtd3RwLWh1Yi1saW5rLnBuZyIgfSk7CiAgICBjb25zdCB0eHQgPSBhd2FpdCBlbC5pbm5lclRleHQoKTsKICAgIGNvbnNvbGUubG9nKGBMaW5rIHRleHQ6ICIke3R4dH0iYCk7CiAgfQogIAogIC8vIEFsc28gdGVzdCBPU1MKICBhd2FpdCBwYWdlLmdvdG8oIi9vc3MtY2F0YWxvZy5odG1sIik7CiAgYXdhaXQgcGFnZS53YWl0Rm9yVGltZW91dCgyMDAwKTsKICBjb25zdCBvc3NMaW5rcyA9IGF3YWl0IHBhZ2UubG9jYXRvcignYVtocmVmKj0iZGFzaGJvYXJkcy1odWItdW5pZmllZCJdJykuY291bnQoKTsKICBjb25zb2xlLmxvZyhgSHViIGxpbmtzIGluIE9TUzogJHtvc3NMaW5rc31gKTsKICBhd2FpdCBwYWdlLnNjcmVlbnNob3QoeyBwYXRoOiAib3V0cHV0L3Y0MS1vc3MtaHViLWxpbmsucG5nIiwgZnVsbFBhZ2U6IHRydWUgfSk7Cn0pOwo=");
|
||||
foreach (glob("$base/*.spec.js") as $old) @unlink($old);
|
||||
$written = @file_put_contents("$base/v41-wtp-hub.spec.js", $spec);
|
||||
echo json_encode(["written" => $written]);
|
||||
7
api/ambre-pw-v41b-deploy.php
Normal file
7
api/ambre-pw-v41b-deploy.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$base = "/var/www/html/api/ambre-pw-tests/tests";
|
||||
$spec = base64_decode("Y29uc3QgeyB0ZXN0IH0gPSByZXF1aXJlKCJAcGxheXdyaWdodC90ZXN0Iik7Cgp0ZXN0KCJWNDFiIMK3IFdUUCArIE9TUyArIEh1YiB3aXRoIGNhY2hlLWJ1c3QiLCBhc3luYyAoeyBwYWdlIH0pID0+IHsKICB0ZXN0LnNldFRpbWVvdXQoMzAwMDApOwogIGNvbnN0IGNiID0gRGF0ZS5ub3coKTsKICAKICAvLyBXVFAKICBhd2FpdCBwYWdlLmdvdG8oYC93ZXZhbC10ZWNobm9sb2d5LXBsYXRmb3JtLmh0bWw/Y2I9JHtjYn1gKTsKICBhd2FpdCBwYWdlLndhaXRGb3JMb2FkU3RhdGUoIm5ldHdvcmtpZGxlIik7CiAgYXdhaXQgcGFnZS53YWl0Rm9yVGltZW91dCgyMDAwKTsKICBsZXQgaHViTGlua3MgPSBhd2FpdCBwYWdlLmxvY2F0b3IoJ2FbaHJlZio9ImRhc2hib2FyZHMtaHViLXVuaWZpZWQiXScpLmNvdW50KCk7CiAgY29uc29sZS5sb2coYFdUUCBodWIgbGlua3M6ICR7aHViTGlua3N9YCk7CiAgaWYgKGh1YkxpbmtzID4gMCkgewogICAgY29uc3QgZWwgPSBwYWdlLmxvY2F0b3IoJ2FbaHJlZio9ImRhc2hib2FyZHMtaHViLXVuaWZpZWQiXScpLmZpcnN0KCk7CiAgICBhd2FpdCBlbC5zY3JvbGxJbnRvVmlld0lmTmVlZGVkKCk7CiAgICBhd2FpdCBwYWdlLndhaXRGb3JUaW1lb3V0KDgwMCk7CiAgICBhd2FpdCBwYWdlLnNjcmVlbnNob3QoeyBwYXRoOiAib3V0cHV0L3Y0MWItd3RwLWh1Yi5wbmciIH0pOwogICAgY29uc3QgdHh0ID0gYXdhaXQgZWwuaW5uZXJUZXh0KCk7CiAgICBjb25zb2xlLmxvZyhgV1RQIGxpbms6ICIke3R4dH0iYCk7CiAgfSBlbHNlIHsKICAgIGF3YWl0IHBhZ2Uuc2NyZWVuc2hvdCh7IHBhdGg6ICJvdXRwdXQvdjQxYi13dHAtbm9odWIucG5nIiB9KTsKICB9CiAgCiAgLy8gQ2xpY2sgdGhlIGh1YiBsaW5rIHRvIHZlcmlmeSBmbG93CiAgaWYgKGh1YkxpbmtzID4gMCkgewogICAgYXdhaXQgcGFnZS5sb2NhdG9yKCdhW2hyZWYqPSJkYXNoYm9hcmRzLWh1Yi11bmlmaWVkIl0nKS5maXJzdCgpLmNsaWNrKCk7CiAgICBhd2FpdCBwYWdlLndhaXRGb3JUaW1lb3V0KDIwMDApOwogICAgYXdhaXQgcGFnZS5zY3JlZW5zaG90KHsgcGF0aDogIm91dHB1dC92NDFiLWh1Yi1hZnRlci1jbGljay5wbmciIH0pOwogIH0KfSk7Cg==");
|
||||
foreach (glob("$base/*.spec.js") as $old) @unlink($old);
|
||||
$written = @file_put_contents("$base/v41b.spec.js", $spec);
|
||||
echo json_encode(["written" => $written]);
|
||||
7
api/ambre-pw-v42-deploy.php
Normal file
7
api/ambre-pw-v42-deploy.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$base = "/var/www/html/api/ambre-pw-tests/tests";
|
||||
$spec = base64_decode("Y29uc3QgeyB0ZXN0IH0gPSByZXF1aXJlKCJAcGxheXdyaWdodC90ZXN0Iik7Cgp0ZXN0KCJWNDIgwrcgRklOQUwgSHViIERhc2hib2FyZHMgU2hvd2Nhc2UgVWx0cmEiLCBhc3luYyAoeyBwYWdlIH0pID0+IHsKICB0ZXN0LnNldFRpbWVvdXQoNjAwMDApOwogIAogIC8vIDEuIEh1YiBob21lCiAgYXdhaXQgcGFnZS5nb3RvKCIvZGFzaGJvYXJkcy1odW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c3luYyAoKSA9PiB7CiAgICBjb25zdCByID0gYXdhaXQgZmV0Y2goJy9hcGkvZGFzaGJvYXJkcy1yZWdpc3RyeS1hbWJyZS5waHAnKTsKICAgIHJldHVybiBhd2FpdCByLmpzb24oKTsKICB9KTsKICBjb25zb2xlLmxvZyhgICBSZWdpc3RyeTogdG90YWw9JHtyZWcudG90YWx9IMK3IGNhdHM9JHtyZWcuY2F0ZWdvcmllc19jb3VudH0gwrcgemVyb19vcnBoYW49JHtyZWcuemVyb19vcnBoYW59YCk7Cn0pOwo=");
|
||||
foreach (glob("$base/*.spec.js") as $old) @unlink($old);
|
||||
$written = @file_put_contents("$base/v42-hub-showcase.spec.js", $spec);
|
||||
echo json_encode(["written" => $written]);
|
||||
109
api/ambre-retry-wrap.php
Normal file
109
api/ambre-retry-wrap.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/var/www/html/wevia.html";
|
||||
$content = @file_get_contents($path);
|
||||
$orig_size = strlen($content);
|
||||
|
||||
// Find all fallback fetch-sovereign calls
|
||||
$changes = 0;
|
||||
|
||||
// Pattern: fetch('/api/sovereign/v1/chat/completions' or similar
|
||||
// Wrap with retry: if first fetch fails with 503, retry after 2s, then after 5s (3 tries total)
|
||||
|
||||
// Simpler approach: intercept fetch to /api/sovereign via monkey patch at the TOP of the big script
|
||||
// Insert a tiny retry wrapper right after <script> opens (line 718)
|
||||
|
||||
$insert_after = "<script>\n"; // Find the big script
|
||||
$big_script_start = strpos($content, "<script>", strpos($content, "a11y-auto.js")); // the big one starts after a11y
|
||||
if ($big_script_start === false) {
|
||||
echo json_encode(["error"=>"big script not found"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check if retry wrapper already injected
|
||||
if (strpos($content, "/* AMBRE-SOVEREIGN-RETRY */") !== false) {
|
||||
echo json_encode(["skip"=>"already injected", "orig"=>$orig_size]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$retry_wrapper = <<<'JS'
|
||||
<script>
|
||||
/* AMBRE-SOVEREIGN-RETRY · auto-retry 503/429/502 on /api/sovereign + cascade */
|
||||
(function(){
|
||||
if (window.__retryFetchInstalled) return;
|
||||
window.__retryFetchInstalled = true;
|
||||
var _origFetch = window.fetch;
|
||||
window.fetch = function(url, opts) {
|
||||
var u = typeof url === 'string' ? url : (url && url.url) || '';
|
||||
var shouldRetry = u.indexOf('/api/sovereign') >= 0 || u.indexOf('chat/completions') >= 0 || u.indexOf('/api/ambre') >= 0 || u.indexOf('/api/wevia-') >= 0;
|
||||
if (!shouldRetry) return _origFetch.apply(this, arguments);
|
||||
|
||||
var maxRetry = 3;
|
||||
var backoff = [0, 1500, 4000];
|
||||
var self = this;
|
||||
var args = arguments;
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
function tryOnce(attempt) {
|
||||
var delay = backoff[attempt] || 0;
|
||||
setTimeout(function() {
|
||||
_origFetch.apply(self, args).then(function(r) {
|
||||
if ((r.status === 503 || r.status === 429 || r.status === 502) && attempt < maxRetry - 1) {
|
||||
console.warn('[retry] ' + u + ' got ' + r.status + ', retry #' + (attempt+1));
|
||||
tryOnce(attempt + 1);
|
||||
} else {
|
||||
resolve(r);
|
||||
}
|
||||
}).catch(function(err) {
|
||||
if (attempt < maxRetry - 1) {
|
||||
console.warn('[retry] ' + u + ' err, retry #' + (attempt+1) + ': ' + err.message);
|
||||
tryOnce(attempt + 1);
|
||||
} else {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
}, delay);
|
||||
}
|
||||
tryOnce(0);
|
||||
});
|
||||
};
|
||||
})();
|
||||
</script>
|
||||
<script>
|
||||
JS;
|
||||
|
||||
$content_new = str_replace($insert_after, $retry_wrapper, $content, $count);
|
||||
if ($count === 0) {
|
||||
echo json_encode(["error"=>"anchor not found"]);
|
||||
exit;
|
||||
}
|
||||
// But we'd replace ALL <script>. We only want the first after a11y
|
||||
// Instead find the specific position
|
||||
$content = @file_get_contents($path);
|
||||
|
||||
// Find position of big inline <script> (after 'a11y-auto.js')
|
||||
$a11y_pos = strpos($content, "a11y-auto.js");
|
||||
$big_script_pos = strpos($content, "<script>", $a11y_pos);
|
||||
if ($big_script_pos === false) {
|
||||
echo json_encode(["error"=>"big script not found"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Insert retry wrapper BEFORE the big <script>
|
||||
$inject = str_replace("<script>", "", $retry_wrapper); // retry_wrapper already has opening <script>
|
||||
// Actually simpler: insert entire retry_wrapper RIGHT BEFORE big <script>
|
||||
// retry_wrapper ends with <script> so it opens the next block seamlessly
|
||||
|
||||
$content_new = substr($content, 0, $big_script_pos) . $retry_wrapper . substr($content, $big_script_pos + 8); // skip the original "<script>"
|
||||
|
||||
$backup = "/opt/wevads/vault/wevia.html.GOLD-" . date("Ymd-His") . "-retry-wrapper";
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, $content_new);
|
||||
|
||||
echo json_encode([
|
||||
"orig" => $orig_size,
|
||||
"new" => strlen($content_new),
|
||||
"delta" => strlen($content_new) - $orig_size,
|
||||
"wrote" => $wrote,
|
||||
"backup" => basename($backup),
|
||||
]);
|
||||
69
api/ambre-scan-230.php
Normal file
69
api/ambre-scan-230.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$out = [];
|
||||
|
||||
chdir("/var/www/html");
|
||||
$out["recent_commits"] = array_filter(array_map("trim", explode("\n", @shell_exec("git log --since='10 minutes ago' --oneline 2>&1 | head -10"))));
|
||||
$out["current_tags"] = array_filter(array_map("trim", explode("\n", @shell_exec("git tag -l 'wave-*' --sort=-creatordate 2>&1 | head -5"))));
|
||||
|
||||
// Check WEVIA Master registry state
|
||||
$reg = @file_get_contents("/var/www/html/api/wevia-tool-registry.json");
|
||||
$reg_data = @json_decode($reg, true);
|
||||
$out["registry"] = [
|
||||
"exists" => $reg !== false,
|
||||
"size" => strlen($reg),
|
||||
"tool_count" => is_array($reg_data) ? count($reg_data) : 0,
|
||||
];
|
||||
// Check if mermaid + pdf-premium already in registry
|
||||
if (is_array($reg_data)) {
|
||||
$has_mermaid = false; $has_pdf_prem = false;
|
||||
foreach ($reg_data as $t) {
|
||||
$id = $t["id"] ?? "";
|
||||
if (stripos($id, "mermaid") !== false) $has_mermaid = true;
|
||||
if (stripos($id, "pdf_premium") !== false || stripos($id, "pdf-premium") !== false) $has_pdf_prem = true;
|
||||
}
|
||||
$out["registry"]["has_mermaid_tool"] = $has_mermaid;
|
||||
$out["registry"]["has_pdf_premium"] = $has_pdf_prem;
|
||||
}
|
||||
|
||||
// Check Ethica infrastructure
|
||||
$ethica = [];
|
||||
foreach (["consent.wevup.app", "ethica-pipeline", "ecm.py"] as $name) {
|
||||
$ethica[$name] = "check needed";
|
||||
}
|
||||
$ethica["consent_page"] = file_exists("/var/www/html/consent.html") || file_exists("/var/www/html/ethica.html");
|
||||
$out["ethica"] = $ethica;
|
||||
|
||||
// Check SSE streaming files
|
||||
$sse_files = [];
|
||||
foreach (["ambre-claude-stream.php", "ambre-claude-pattern-sse.php", "wevia-sse-override.js"] as $f) {
|
||||
$path = "/var/www/html/api/$f";
|
||||
$path2 = "/var/www/html/js/$f";
|
||||
if (file_exists($path)) $sse_files[$f] = filesize($path);
|
||||
elseif (file_exists($path2)) $sse_files[$f] = filesize($path2);
|
||||
}
|
||||
$out["sse_files"] = $sse_files;
|
||||
|
||||
// Language detection currently
|
||||
$w = @file_get_contents("/var/www/html/wevia.html");
|
||||
$out["lang_detection"] = [
|
||||
"detectLang_defined" => preg_match("/function detectLang/", $w),
|
||||
"darija_check" => strpos($w, "darija") !== false,
|
||||
"lang_var" => strpos($w, "var lang =") !== false,
|
||||
];
|
||||
|
||||
// Purge cache helper existence
|
||||
$out["cf_purge"] = file_exists("/var/www/html/api/ambre-cf-purge.php");
|
||||
|
||||
// Monitoring status
|
||||
$monitoring = [];
|
||||
foreach (["/opt/weval-ops/andon-monitor.sh", "/opt/weval-ops/phpfpm-watchdog.sh", "/opt/weval-ops/zombie-killer.sh"] as $s) {
|
||||
$monitoring[basename($s)] = file_exists($s);
|
||||
}
|
||||
$out["monitoring_scripts"] = $monitoring;
|
||||
|
||||
// Current cascade load
|
||||
$out["load"] = trim(@shell_exec("uptime"));
|
||||
$out["cascade_health"] = @file_get_contents("http://127.0.0.1:4000/health", false, stream_context_create(["http"=>["timeout"=>3]])) ? "UP" : "DOWN";
|
||||
|
||||
echo json_encode($out, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|
||||
51
api/ambre-scan-230b.php
Normal file
51
api/ambre-scan-230b.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$out = [];
|
||||
|
||||
chdir("/var/www/html");
|
||||
$out["recent_tags"] = array_filter(array_map("trim", explode("\n", @shell_exec("git tag -l 'wave-*' --sort=-creatordate 2>&1 | head -5"))));
|
||||
$out["latest_commit"] = trim(@shell_exec("git log -1 --oneline 2>&1"));
|
||||
|
||||
// Check my wave-229 tools + wave-230 state
|
||||
$reg = @file_get_contents("/var/www/html/api/wevia-tool-registry.json");
|
||||
$data = @json_decode($reg, true);
|
||||
if ($data) {
|
||||
$out["wave_229_tools"] = array_map(function($t){return $t["id"];},
|
||||
array_filter($data["tools"] ?? [], function($t){return ($t["wave"] ?? 0) == 229;}));
|
||||
$out["total_tools"] = count($data["tools"] ?? []);
|
||||
}
|
||||
|
||||
// Ethica state
|
||||
$ethica = [];
|
||||
$ethica["ecm_py_exists"] = file_exists("/var/www/html/ethica/ecm.py") || file_exists("/opt/ethica/ecm.py") || file_exists("/var/www/weval/ecm.py");
|
||||
$ethica["find_ecm"] = trim(@shell_exec("find /var/www /opt -name 'ecm.py' 2>/dev/null | head -5"));
|
||||
$ethica["consent_urls"] = [
|
||||
"consent.wevup.app" => @shell_exec("curl -sI --max-time 3 https://consent.wevup.app/ 2>&1 | head -1"),
|
||||
];
|
||||
$out["ethica"] = $ethica;
|
||||
|
||||
// Mermaid V10 state in wevia.html
|
||||
$w = @file_get_contents("/var/www/html/wevia.html");
|
||||
$out["wevia"] = [
|
||||
"size" => strlen($w),
|
||||
"v10_mermaid" => strpos($w, "AMBRE-V10-MERMAID") !== false,
|
||||
"v10_css_minheight" => strpos($w, "min-height:200px") !== false,
|
||||
];
|
||||
|
||||
// Check i18n helpers in wevia.html
|
||||
$out["i18n"] = [
|
||||
"detectLang" => strpos($w, "function detectLang") !== false,
|
||||
"lang_var" => strpos($w, "var lang =") !== false,
|
||||
];
|
||||
|
||||
// Mermaid KB state
|
||||
$mkb = @file_get_contents("/var/www/html/generated/mermaid-learn-kb.json");
|
||||
if ($mkb) {
|
||||
$kb_data = @json_decode($mkb, true);
|
||||
$out["mermaid_kb_entries"] = count($kb_data ?: []);
|
||||
}
|
||||
|
||||
// Load current
|
||||
$out["load"] = trim(shell_exec("uptime"));
|
||||
|
||||
echo json_encode($out, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|
||||
53
api/ambre-scan-233.php
Normal file
53
api/ambre-scan-233.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$out = [];
|
||||
|
||||
chdir("/var/www/html");
|
||||
$out["recent_commits_60m"] = array_filter(array_map("trim", explode("\n", @shell_exec("git log --since='60 minutes ago' --oneline 2>&1 | head -15"))));
|
||||
$out["recent_tags"] = array_filter(array_map("trim", explode("\n", @shell_exec("git tag -l 'wave-*' --sort=-creatordate 2>&1 | head -10"))));
|
||||
|
||||
// Scan wevia.html for V10 state + pdf i18n confirmed
|
||||
$w = @file_get_contents("/var/www/html/wevia.html");
|
||||
$out["wevia"] = [
|
||||
"size" => strlen($w),
|
||||
"v10_mermaid" => strpos($w, "AMBRE-V10-MERMAID") !== false,
|
||||
"v10_sanitize_accents" => strpos($w, "replace(/[éèêë]/g") !== false,
|
||||
"mermaid_render_api" => strpos($w, "window.mermaid.render(") !== false,
|
||||
];
|
||||
|
||||
// PDF Premium state
|
||||
$pdf = @file_get_contents("/var/www/html/api/ambre-tool-pdf-premium.php");
|
||||
$out["pdf_premium"] = [
|
||||
"size" => strlen($pdf),
|
||||
"i18n_fr" => strpos($pdf, '"fr" =>') !== false,
|
||||
"i18n_en" => strpos($pdf, '"en" =>') !== false,
|
||||
"i18n_ar" => strpos($pdf, '"ar" =>') !== false,
|
||||
];
|
||||
|
||||
// Ethica state
|
||||
$out["ethica"] = [
|
||||
"ecm_py" => file_exists("/opt/weval-l99/ecm.py") ? filesize("/opt/weval-l99/ecm.py") : "missing",
|
||||
"consent_live" => trim(@shell_exec("curl -sI --max-time 3 https://consent.wevup.app/ 2>&1 | head -1")),
|
||||
];
|
||||
|
||||
// Registry 643 + wave-229 tools confirmed
|
||||
$reg = @json_decode(@file_get_contents("/var/www/html/api/wevia-tool-registry.json"), true);
|
||||
if ($reg) {
|
||||
$w229 = array_filter($reg["tools"] ?? [], function($t){return ($t["wave"] ?? 0) == 229;});
|
||||
$out["registry"] = [
|
||||
"total" => count($reg["tools"] ?? []),
|
||||
"wave_229_count" => count($w229),
|
||||
];
|
||||
}
|
||||
|
||||
// Monitoring status
|
||||
$out["monitoring"] = [
|
||||
"load" => trim(@shell_exec("uptime")),
|
||||
"cascade_up" => @file_get_contents("http://127.0.0.1:4000/health", false, stream_context_create(["http"=>["timeout"=>3]])) ? "UP" : "DOWN",
|
||||
];
|
||||
|
||||
// Mermaid KB
|
||||
$mkb = @json_decode(@file_get_contents("/var/www/html/generated/mermaid-learn-kb.json"), true);
|
||||
$out["mermaid_kb_total"] = is_array($mkb) ? count($mkb) : 0;
|
||||
|
||||
echo json_encode($out, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|
||||
56
api/ambre-scan-v30.php
Normal file
56
api/ambre-scan-v30.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$out = [];
|
||||
|
||||
// Recent git activity
|
||||
chdir("/var/www/html");
|
||||
$out["git_commits_last_30m"] = array_filter(array_map("trim", explode("\n", @shell_exec("git log --since='30 minutes ago' --oneline 2>&1 | head -20"))));
|
||||
$out["git_tags_today"] = array_filter(array_map("trim", explode("\n", @shell_exec("git tag -l | while read t; do d=$(git log -1 --format=%at \"$t\" 2>/dev/null); if [ -n \"$d\" ] && [ \"$d\" -gt $(($(date +%s)-86400)) ]; then echo \"$t\"; fi; done 2>&1 | head -20"))));
|
||||
|
||||
// Recent ambre-* files
|
||||
$recent_ambre = array_map("basename", array_filter(glob("/var/www/html/api/ambre-*.php"), function($f){ return filemtime($f) > (time()-3600); }));
|
||||
$out["ambre_files_last_hour"] = $recent_ambre;
|
||||
|
||||
// oss-catalog state
|
||||
$oss = "/var/www/html/oss-catalog.html";
|
||||
$out["oss_catalog"] = file_exists($oss) ? [
|
||||
"size" => filesize($oss),
|
||||
"mtime" => date("Y-m-d H:i", filemtime($oss)),
|
||||
"tool_count_preg" => preg_match_all("/data-cat=/", @file_get_contents($oss) ?: ""),
|
||||
] : "NOT FOUND";
|
||||
|
||||
// Wiki/vault doctrines
|
||||
$out["doctrines"] = array_map("basename", glob("/opt/obsidian-vault/doctrines/*.md") ?: []);
|
||||
$out["doctrines_count"] = count(glob("/opt/obsidian-vault/doctrines/*.md") ?: []);
|
||||
|
||||
// Recent wave-* tags
|
||||
$out["recent_wave_tags"] = array_filter(array_map("trim", explode("\n", @shell_exec("git tag -l 'wave-*' --sort=-creatordate 2>&1 | head -10"))));
|
||||
|
||||
// V30 video + screenshots still live
|
||||
$out["v30_artifacts"] = [
|
||||
"video" => glob("/var/www/html/generated/wevia-v30-showcase*.webm"),
|
||||
"screenshots" => count(glob("/var/www/html/generated/v30-*.png") ?: []),
|
||||
];
|
||||
|
||||
// Mermaid KB
|
||||
$mkb = "/var/www/html/generated/mermaid-learn-kb.json";
|
||||
$out["mermaid_kb"] = file_exists($mkb) ? [
|
||||
"size" => filesize($mkb),
|
||||
"entries" => count(json_decode(@file_get_contents($mkb), true) ?: []),
|
||||
] : "NOT FOUND";
|
||||
|
||||
// PDF Premium endpoint
|
||||
$out["pdf_premium"] = file_exists("/var/www/html/api/ambre-tool-pdf-premium.php") ? "LIVE" : "MISSING";
|
||||
|
||||
// What's in wevia.html now
|
||||
$w = @file_get_contents("/var/www/html/wevia.html");
|
||||
$out["wevia_state"] = [
|
||||
"size" => strlen($w),
|
||||
"v5_memory" => strpos($w, "AMBRE-V5-MEMORY") !== false,
|
||||
"v6_tools" => strpos($w, "AMBRE-V6-TOOLS") !== false,
|
||||
"v7_premium" => strpos($w, "AMBRE-V7-PREMIUM") !== false,
|
||||
"v9_pdf_premium" => strpos($w, "AMBRE-V9-PDF-PREMIUM") !== false,
|
||||
"ambre_gen_pat_hoisted" => strpos($w, "HOISTED") !== false,
|
||||
];
|
||||
|
||||
echo json_encode($out, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|
||||
68
api/ambre-scan-wtp.php
Normal file
68
api/ambre-scan-wtp.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$out = [];
|
||||
|
||||
chdir("/var/www/html");
|
||||
$out["recent_commits_30m"] = array_filter(array_map("trim", explode("\n", @shell_exec("git log --since='30 minutes ago' --oneline 2>&1 | head -15"))));
|
||||
$out["recent_tags_today"] = array_filter(array_map("trim", explode("\n", @shell_exec("git tag -l 'wave-*' --sort=-creatordate 2>&1 | head -10"))));
|
||||
|
||||
// WTP state (point entrée architecture)
|
||||
$wtp = "/var/www/html/weval-technology-platform.html";
|
||||
if (file_exists($wtp)) {
|
||||
$w = @file_get_contents($wtp);
|
||||
$out["wtp"] = [
|
||||
"size" => filesize($wtp),
|
||||
"mtime" => date("Y-m-d H:i", filemtime($wtp)),
|
||||
"banner_links" => preg_match_all("/href=[\"'][^\"']+\.html/", $w),
|
||||
"has_banner" => strpos($w, "banner") !== false,
|
||||
];
|
||||
}
|
||||
|
||||
// Sitemap API for orphans tracking
|
||||
$sitemap_api = @file_get_contents("https://weval-consulting.com/api/sitemap-api.php", false, stream_context_create(["http"=>["timeout"=>5]]));
|
||||
if ($sitemap_api) {
|
||||
$d = @json_decode($sitemap_api, true);
|
||||
$out["sitemap"] = [
|
||||
"total_pages" => is_array($d) ? count($d["pages"] ?? $d) : 0,
|
||||
"raw_size" => strlen($sitemap_api),
|
||||
];
|
||||
}
|
||||
|
||||
// All-IA Hub state
|
||||
$iahub = "/var/www/html/all-ia-hub.html";
|
||||
if (file_exists($iahub)) {
|
||||
$out["all_ia_hub"] = ["size" => filesize($iahub), "mtime" => date("Y-m-d H:i", filemtime($iahub))];
|
||||
}
|
||||
|
||||
// WEVIA Master state
|
||||
$master = "/var/www/html/wevia-master.html";
|
||||
if (file_exists($master)) {
|
||||
$out["wevia_master"] = ["size" => filesize($master), "mtime" => date("Y-m-d H:i", filemtime($master))];
|
||||
}
|
||||
|
||||
// Orchestrator
|
||||
$orch = "/var/www/html/wevia-orchestrator.html";
|
||||
if (file_exists($orch)) {
|
||||
$out["orchestrator"] = ["size" => filesize($orch), "mtime" => date("Y-m-d H:i", filemtime($orch))];
|
||||
}
|
||||
|
||||
// Dashboards available
|
||||
$dashboards = array_map("basename", glob("/var/www/html/*dashboard*.html") ?: []);
|
||||
$out["dashboards_count"] = count($dashboards);
|
||||
$out["dashboards_sample"] = array_slice($dashboards, 0, 15);
|
||||
|
||||
// Business KPI endpoint check
|
||||
$biz_kpi = @file_get_contents("https://weval-consulting.com/api/v83-business-kpi-latest.json", false, stream_context_create(["http"=>["timeout"=>5]]));
|
||||
if ($biz_kpi) {
|
||||
$d = @json_decode($biz_kpi, true);
|
||||
$out["biz_kpi"] = [
|
||||
"keys" => is_array($d) ? array_slice(array_keys($d), 0, 10) : "invalid",
|
||||
"size" => strlen($biz_kpi),
|
||||
];
|
||||
}
|
||||
|
||||
// Current load + recent PW runs
|
||||
$out["load"] = trim(@shell_exec("uptime"));
|
||||
$out["recent_pw_runs"] = trim(@shell_exec("ls -1t /tmp/ambre-pw-run-*.log 2>/dev/null | head -3"));
|
||||
|
||||
echo json_encode($out, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|
||||
32
api/ambre-sov-503.php
Normal file
32
api/ambre-sov-503.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
|
||||
// Check nginx location /api/sovereign/
|
||||
$nginx_sov = @shell_exec("grep -A 15 'location /api/sovereign' /etc/nginx/sites-available/*.conf /etc/nginx/sites-enabled/*.conf 2>/dev/null | head -30");
|
||||
|
||||
// Check cascade service
|
||||
$svc = @shell_exec("systemctl status weval-sovereign-cascade 2>&1 | head -15");
|
||||
|
||||
// Test both HTTPS and direct with timing
|
||||
$t0 = microtime(true);
|
||||
$direct = @file_get_contents("http://127.0.0.1:4000/v1/chat/completions", false, stream_context_create([
|
||||
"http"=>["method"=>"POST","header"=>"Content-Type: application/json\r\n",
|
||||
"content"=>json_encode(["model"=>"fast","messages"=>[["role"=>"user","content"=>"hi"]],"max_tokens"=>10]),
|
||||
"timeout"=>10]
|
||||
]));
|
||||
$direct_ms = round((microtime(true)-$t0)*1000);
|
||||
|
||||
// Check recent nginx errors
|
||||
$nginx_err = @shell_exec("tail -30 /var/log/nginx/error.log 2>/dev/null | grep -iE 'sovereign|503|upstream' | head -10");
|
||||
|
||||
// FPM status
|
||||
$fpm = @shell_exec("systemctl is-active php8.4-fpm 2>&1");
|
||||
|
||||
echo json_encode([
|
||||
"nginx_sovereign_config" => trim($nginx_sov),
|
||||
"cascade_service" => trim($svc),
|
||||
"direct_cascade_ms" => $direct_ms,
|
||||
"direct_test_ok" => $direct ? "OK: " . substr($direct, 0, 100) : "FAIL",
|
||||
"nginx_errors" => trim($nginx_err),
|
||||
"fpm_status" => trim($fpm),
|
||||
], JSON_PRETTY_PRINT);
|
||||
6
api/ambre-sov-route.php
Normal file
6
api/ambre-sov-route.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
header("Content-Type: text/plain");
|
||||
echo "nginx sovereign route:\n";
|
||||
echo @shell_exec("grep -rn 'sovereign' /etc/nginx/ 2>/dev/null | head -10");
|
||||
echo "\n\nfpm listening procs:\n";
|
||||
echo @shell_exec("ss -tlnp 2>/dev/null | grep -E ':4000|:5000' | head -5");
|
||||
28
api/ambre-sovereign-diag.php
Normal file
28
api/ambre-sovereign-diag.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$out = [];
|
||||
// Find sovereign handler
|
||||
$files = [
|
||||
"/var/www/html/api/sovereign/v1/chat/completions.php",
|
||||
"/var/www/html/api/sovereign/v1/chat/completions/index.php",
|
||||
"/var/www/html/api/sovereign.php",
|
||||
];
|
||||
foreach ($files as $f) $out["file_exists"][basename($f)] = file_exists($f);
|
||||
|
||||
// nginx config for sovereign
|
||||
$nginx = @shell_exec("grep -r 'sovereign' /etc/nginx/ 2>/dev/null | head -10");
|
||||
$out["nginx_config"] = trim($nginx);
|
||||
|
||||
// cascade health
|
||||
$ctx = stream_context_create(["http"=>["timeout"=>3]]);
|
||||
$out["cascade_4000"] = @file_get_contents("http://127.0.0.1:4000/health", false, $ctx) ?: "DOWN";
|
||||
|
||||
// Test sovereign directly from server (bypass nginx)
|
||||
$test = @file_get_contents("http://127.0.0.1:4000/v1/chat/completions", false, stream_context_create([
|
||||
"http"=>["method"=>"POST","header"=>"Content-Type: application/json\r\n",
|
||||
"content"=>json_encode(["model"=>"fast","messages"=>[["role"=>"user","content"=>"hi"]],"max_tokens"=>10]),
|
||||
"timeout"=>10]
|
||||
]));
|
||||
$out["direct_cascade_test"] = substr($test ?: "FAILED", 0, 300);
|
||||
|
||||
echo json_encode($out, JSON_PRETTY_PRINT);
|
||||
51
api/ambre-sse-fix.php
Normal file
51
api/ambre-sse-fix.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
|
||||
$path = "/var/www/html/js/wevia-sse-override.js";
|
||||
if (!file_exists($path)) {
|
||||
// Try alternate location
|
||||
$alt = "/var/www/html/wevia-sse-override.js";
|
||||
if (file_exists($alt)) $path = $alt;
|
||||
}
|
||||
|
||||
$content = @file_get_contents($path);
|
||||
if (!$content) { echo json_encode(["error"=>"file not found", "path"=>$path]); exit; }
|
||||
$orig_size = strlen($content);
|
||||
|
||||
// The bug: regex literal /\n/g split by an actual newline
|
||||
// Replace with proper string-based approach
|
||||
$old = "last.innerHTML = fullText.replace(/\n/g, '<br>');";
|
||||
$new = "last.innerHTML = fullText.split(String.fromCharCode(10)).join('<br>');";
|
||||
|
||||
$pos = strpos($content, $old);
|
||||
if ($pos === false) {
|
||||
// Try alternate without leading spaces
|
||||
$old2 = "fullText.replace(/\n/g, '<br>');";
|
||||
$new2 = "fullText.split(String.fromCharCode(10)).join('<br>');";
|
||||
if (strpos($content, $old2) !== false) {
|
||||
$new_content = str_replace($old2, $new2, $content);
|
||||
} else {
|
||||
echo json_encode(["error"=>"pattern not found", "path"=>$path, "size"=>$orig_size, "snippet_around_47" => substr($content, 1800, 400)]);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$new_content = str_replace($old, $new, $content);
|
||||
}
|
||||
|
||||
// Backup + write
|
||||
$backup = "/opt/wevads/vault/wevia-sse-override.js.GOLD-" . date("Ymd-His");
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, $new_content);
|
||||
|
||||
// Lint
|
||||
$lint = @shell_exec("node --check $path 2>&1");
|
||||
|
||||
echo json_encode([
|
||||
"path" => $path,
|
||||
"orig_size" => $orig_size,
|
||||
"new_size" => strlen($new_content),
|
||||
"delta" => strlen($new_content) - $orig_size,
|
||||
"wrote" => $wrote,
|
||||
"backup" => basename($backup),
|
||||
"lint" => trim($lint) ?: "OK",
|
||||
]);
|
||||
141
api/ambre-tool-mermaid.php
Normal file
141
api/ambre-tool-mermaid.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
/**
|
||||
* ambre-tool-mermaid.php · Mermaid generation with learning KB (RAG-enabled)
|
||||
* Flow:
|
||||
* 1. Search KB for similar schema (score > 5)
|
||||
* 2. If found: reuse + mark used
|
||||
* 3. Else: LLM generates + auto-save to KB
|
||||
*/
|
||||
header("Content-Type: application/json; charset=utf-8");
|
||||
set_time_limit(60);
|
||||
|
||||
require_once __DIR__ . "/ambre-llm-semaphore.php";
|
||||
|
||||
$raw = file_get_contents("php://input");
|
||||
$in = json_decode($raw, true) ?: $_POST;
|
||||
$topic = trim($in["topic"] ?? $in["message"] ?? "");
|
||||
if (!$topic) { echo json_encode(["error"=>"topic required"]); exit; }
|
||||
|
||||
$t0 = microtime(true);
|
||||
|
||||
// Step 1: Search KB
|
||||
$kb_resp = @file_get_contents("http://127.0.0.1/api/ambre-mermaid-learn.php", false, stream_context_create([
|
||||
"http" => [
|
||||
"method" => "POST",
|
||||
"header" => "Content-Type: application/json\r\n",
|
||||
"content" => json_encode(["action"=>"search", "query"=>$topic]),
|
||||
"timeout" => 5,
|
||||
],
|
||||
]));
|
||||
$kb_hits = @json_decode($kb_resp, true) ?: [];
|
||||
|
||||
$reused = null;
|
||||
if (!empty($kb_hits) && ($kb_hits[0]["score"] ?? 0) >= 5) {
|
||||
$reused = $kb_hits[0];
|
||||
// Mark used
|
||||
@file_get_contents("http://127.0.0.1/api/ambre-mermaid-learn.php", false, stream_context_create([
|
||||
"http" => ["method"=>"POST","header"=>"Content-Type: application/json\r\n",
|
||||
"content"=>json_encode(["action"=>"use","id"=>$reused["id"]]),"timeout"=>3]
|
||||
]));
|
||||
}
|
||||
|
||||
if ($reused) {
|
||||
echo json_encode([
|
||||
"ok" => true,
|
||||
"mermaid_code" => $reused["code"],
|
||||
"topic" => $reused["topic"],
|
||||
"kind" => $reused["kind"] ?? "flowchart",
|
||||
"source" => "kb_reused",
|
||||
"kb_id" => $reused["id"],
|
||||
"kb_score" => $reused["score"],
|
||||
"use_count" => $reused["use_count"] ?? 0,
|
||||
"elapsed_ms" => round((microtime(true)-$t0)*1000),
|
||||
"provider" => "WEVIA Mermaid Learning KB",
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Step 2: No match → LLM generate
|
||||
$sys = "Tu es un expert en diagrammes Mermaid. Pour le sujet donné, génère UNIQUEMENT le code Mermaid valide (sans markdown wrapper ```).\n" .
|
||||
"Règles strictes :\n" .
|
||||
"- Utiliser UNIQUEMENT des crochets [texte] pour les noeuds, pas de {accolades} ni ((parenthèses))\n" .
|
||||
"- Pas d'accents (é→e, à→a, etc.)\n" .
|
||||
"- Pas d'emojis\n" .
|
||||
"- Max 12 noeuds\n" .
|
||||
"- Syntaxe : flowchart LR, flowchart TD, sequenceDiagram, gantt, pie, mindmap selon le besoin\n" .
|
||||
"- Labels courts (< 30 chars)\n" .
|
||||
"- Arrows : --> ou --|label|-->\n" .
|
||||
"Réponds STRICTEMENT avec le code Mermaid, rien d'autre.";
|
||||
|
||||
$sem_id = AmbreLLMSemaphore::acquire();
|
||||
if (!$sem_id) {
|
||||
echo json_encode(["error"=>"service busy"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$llm_t = microtime(true);
|
||||
$llm = @file_get_contents("http://127.0.0.1:4000/v1/chat/completions", false, stream_context_create([
|
||||
"http" => [
|
||||
"method"=>"POST",
|
||||
"header"=>"Content-Type: application/json\r\n",
|
||||
"content"=>json_encode([
|
||||
"model"=>"fast",
|
||||
"messages"=>[["role"=>"system","content"=>$sys],["role"=>"user","content"=>$topic]],
|
||||
"max_tokens"=>800,
|
||||
"temperature"=>0.3,
|
||||
]),
|
||||
"timeout"=>25,
|
||||
],
|
||||
]));
|
||||
$llm_ms = round((microtime(true)-$llm_t)*1000);
|
||||
} finally {
|
||||
AmbreLLMSemaphore::release($sem_id);
|
||||
}
|
||||
|
||||
$d = @json_decode($llm, true);
|
||||
$code = $d["choices"][0]["message"]["content"] ?? "";
|
||||
|
||||
// Sanitize
|
||||
$code = preg_replace('/^```(?:mermaid)?\s*/m', '', $code);
|
||||
$code = preg_replace('/\s*```\s*$/m', '', $code);
|
||||
$code = trim($code);
|
||||
|
||||
if (!$code) {
|
||||
echo json_encode(["error"=>"LLM returned empty code", "llm_ms"=>$llm_ms]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Detect kind
|
||||
$kind = "flowchart";
|
||||
if (stripos($code, "sequenceDiagram") !== false) $kind = "sequence";
|
||||
elseif (stripos($code, "gantt") === 0) $kind = "gantt";
|
||||
elseif (stripos($code, "pie") === 0) $kind = "pie";
|
||||
elseif (stripos($code, "mindmap") !== false) $kind = "mindmap";
|
||||
elseif (stripos($code, "classDiagram") !== false) $kind = "class";
|
||||
elseif (stripos($code, "erDiagram") !== false) $kind = "er";
|
||||
|
||||
// Step 3: Save to KB
|
||||
$save_resp = @file_get_contents("http://127.0.0.1/api/ambre-mermaid-learn.php", false, stream_context_create([
|
||||
"http" => ["method"=>"POST","header"=>"Content-Type: application/json\r\n",
|
||||
"content"=>json_encode([
|
||||
"action"=>"save", "topic"=>$topic, "kind"=>$kind,
|
||||
"context"=>"Auto-generated from user query",
|
||||
"code"=>$code,
|
||||
]),
|
||||
"timeout"=>5]
|
||||
]));
|
||||
$saved = @json_decode($save_resp, true);
|
||||
|
||||
echo json_encode([
|
||||
"ok" => true,
|
||||
"mermaid_code" => $code,
|
||||
"topic" => $topic,
|
||||
"kind" => $kind,
|
||||
"source" => "llm_generated_saved",
|
||||
"kb_id" => $saved["id"] ?? null,
|
||||
"kb_total" => $saved["total"] ?? null,
|
||||
"llm_ms" => $llm_ms,
|
||||
"elapsed_ms" => round((microtime(true)-$t0)*1000),
|
||||
"provider" => "WEVIA Mermaid + KB Learning",
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
@@ -1,116 +1,155 @@
|
||||
<?php
|
||||
/**
|
||||
* ambre-tool-pdf-premium.php · Premium PDF with charts, zero template, LLM-driven
|
||||
* Circuit additif : NE TOUCHE PAS early-doc-gen (préservé).
|
||||
*
|
||||
* Flow:
|
||||
* 1. LLM génère structure JSON {title, sections[{heading,content,chart?}], conclusion}
|
||||
* 2. Inject JSON → HTML premium template avec Chart.js
|
||||
* 3. Chromium headless render → PDF full quality
|
||||
* 4. Return URL + artifact HTML preview
|
||||
* ambre-tool-pdf-premium.php · NEW additive circuit · NO overwrite existing ambre-early-doc-gen
|
||||
* Flow:
|
||||
* 1. LLM generates structured JSON (title, subtitle, exec_summary, sections[], kpis[], chart_data, conclusion)
|
||||
* 2. Render via premium HTML template with Chart.js from CDN
|
||||
* 3. Chromium --headless --print-to-pdf with 8s JS delay (so charts render)
|
||||
* 4. Fallback wkhtmltopdf
|
||||
* 5. Return structured response for artifact display right-panel
|
||||
*/
|
||||
header("Content-Type: application/json; charset=utf-8");
|
||||
set_time_limit(120);
|
||||
|
||||
$in = json_decode(file_get_contents("php://input"), true) ?: $_POST ?: $_GET;
|
||||
$topic = trim($in["topic"] ?? $in["message"] ?? $in["q"] ?? "");
|
||||
$style = trim($in["style"] ?? "executive");
|
||||
require_once __DIR__ . "/ambre-llm-semaphore.php";
|
||||
|
||||
$raw = file_get_contents("php://input");
|
||||
$in = json_decode($raw, true) ?: $_POST;
|
||||
$topic = trim($in["topic"] ?? $in["message"] ?? "");
|
||||
if (!$topic) { echo json_encode(["error"=>"topic required"]); exit; }
|
||||
|
||||
$t0 = microtime(true);
|
||||
|
||||
// === 1. LLM JSON generation ===
|
||||
$sys = "Tu génères des rapports professionnels. Sortie JSON STRICT uniquement, aucun texte hors JSON:\n" .
|
||||
"{\n" .
|
||||
" \"title\": \"...\",\n" .
|
||||
" \"subtitle\": \"...\",\n" .
|
||||
" \"date\": \"$(date +'%d %B %Y')\",\n" .
|
||||
" \"author\": \"WEVIA Report Engine\",\n" .
|
||||
" \"executive_summary\": \"2-3 phrases fortes\",\n" .
|
||||
" \"sections\": [\n" .
|
||||
" {\"heading\": \"...\", \"content\": \"paragraphe 150-300 mots\", \"bullets\": [\"...\",\"...\"]},\n" .
|
||||
" (4-6 sections)\n" .
|
||||
" ],\n" .
|
||||
" \"kpis\": [{\"label\": \"...\", \"value\": \"...\", \"trend\": \"+X%\"}],\n" .
|
||||
" \"chart_data\": {\"labels\": [...], \"values\": [...], \"type\": \"bar|line|pie\", \"title\": \"...\"},\n" .
|
||||
" \"conclusion\": \"1 paragraphe de synthèse + recommandations\"\n" .
|
||||
"}";
|
||||
// Step 1: Get structured content from LLM
|
||||
// i18n language detection (simple heuristic)
|
||||
$topic_lower = mb_strtolower($topic);
|
||||
$lang = $in["lang"] ?? null;
|
||||
if (!$lang) {
|
||||
// Detect from content
|
||||
if (preg_match("/\b(the|is|are|and|of|for|to|with|on|in|a)\b/i", $topic_lower) && !preg_match("/\b(le|la|les|du|des|pour|avec)\b/i", $topic_lower)) {
|
||||
$lang = "en";
|
||||
} elseif (preg_match("/[\x{0600}-\x{06FF}]/u", $topic)) {
|
||||
$lang = "ar";
|
||||
} else {
|
||||
$lang = "fr";
|
||||
}
|
||||
}
|
||||
|
||||
$body = json_encode([
|
||||
"model" => "fast",
|
||||
"messages" => [
|
||||
["role"=>"system", "content"=>$sys],
|
||||
["role"=>"user", "content"=>"Rapport sur: $topic"],
|
||||
],
|
||||
"max_tokens" => 2500,
|
||||
"temperature" => 0.3,
|
||||
]);
|
||||
// Prompts by language
|
||||
$prompts = [
|
||||
"fr" => "Tu es un expert en création de rapports business premium. Pour le sujet donné, génère UNIQUEMENT un JSON valide avec cette structure exacte (pas de markdown, pas d'explication) :",
|
||||
"en" => "You are an expert in premium business report creation. For the given topic, generate ONLY valid JSON with this exact structure (no markdown, no explanation). All text in English :",
|
||||
"ar" => "أنت خبير في إنشاء تقارير الأعمال المتميزة. للموضوع المحدد، قم بإنشاء JSON صالح فقط بهذه البنية الدقيقة (بدون markdown، بدون شرح). جميع النصوص باللغة العربية :",
|
||||
];
|
||||
$sys = $prompts[$lang] ?? $prompts["fr"];
|
||||
$sys .= "
|
||||
{
|
||||
\"title\": \"Titre court et percutant\",
|
||||
\"subtitle\": \"Sous-titre éclairant le contexte\",
|
||||
\"exec_summary\": \"Résumé exécutif en 2-3 phrases\",
|
||||
\"sections\": [
|
||||
{\"heading\": \"Titre section 1\", \"content\": \"Paragraphe 3-5 phrases détaillé\", \"bullets\": [\"Point clé 1\", \"Point clé 2\", \"Point clé 3\"]},
|
||||
{\"heading\": \"Titre section 2\", \"content\": \"Paragraphe analytique\", \"bullets\": [\"Point 1\", \"Point 2\"]},
|
||||
{\"heading\": \"Titre section 3\", \"content\": \"Paragraphe avec insights\", \"bullets\": [\"Recommandation 1\", \"Recommandation 2\", \"Recommandation 3\"]}
|
||||
],
|
||||
\"kpis\": [
|
||||
{\"label\": \"KPI principal\", \"value\": \"42%\", \"trend\": \"+8pts\"},
|
||||
{\"label\": \"KPI secondaire\", \"value\": \"1.8M\", \"trend\": \"+12%\"},
|
||||
{\"label\": \"KPI tertiaire\", \"value\": \"98/100\", \"trend\": \"stable\"}
|
||||
],
|
||||
\"chart_data\": {
|
||||
\"type\": \"bar\",
|
||||
\"title\": \"Titre du graphique\",
|
||||
\"labels\": [\"Q1\", \"Q2\", \"Q3\", \"Q4\", \"Q5\"],
|
||||
\"values\": [45, 62, 78, 71, 89]
|
||||
},
|
||||
\"conclusion\": \"Conclusion stratégique avec call-to-action en 2-3 phrases\"
|
||||
}
|
||||
Réponds STRICTEMENT en JSON valide, rien d'autre. Pas de texte avant/après. Pas de \`\`\`json wrapper.";
|
||||
|
||||
$ch = curl_init("http://127.0.0.1:4000/v1/chat/completions");
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_TIMEOUT => 60,
|
||||
CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
|
||||
CURLOPT_POSTFIELDS => $body,
|
||||
]);
|
||||
$raw = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$llm_elapsed = round((microtime(true)-$t0)*1000);
|
||||
$t1 = microtime(true);
|
||||
$sem_id = AmbreLLMSemaphore::acquire();
|
||||
if (!$sem_id) {
|
||||
echo json_encode(["error"=>"service busy, retry in a few seconds"]); exit;
|
||||
}
|
||||
|
||||
$d = @json_decode($raw, true);
|
||||
$content = $d["choices"][0]["message"]["content"] ?? "";
|
||||
$content = preg_replace('/```(?:json)?\s*|```/', '', $content);
|
||||
$data = @json_decode(trim($content), true);
|
||||
try {
|
||||
$llm_raw = @file_get_contents("http://127.0.0.1:4000/v1/chat/completions", false, stream_context_create([
|
||||
"http" => [
|
||||
"method"=>"POST",
|
||||
"header"=>"Content-Type: application/json\r\n",
|
||||
"content"=>json_encode([
|
||||
"model"=>"fast",
|
||||
"messages"=>[["role"=>"system","content"=>$sys],["role"=>"user","content"=>"Sujet: $topic"]],
|
||||
"max_tokens"=>2400,
|
||||
"temperature"=>0.5,
|
||||
]),
|
||||
"timeout"=>40,
|
||||
],
|
||||
]));
|
||||
} finally {
|
||||
AmbreLLMSemaphore::release($sem_id);
|
||||
}
|
||||
$llm_ms = round((microtime(true)-$t1)*1000);
|
||||
$resp = @json_decode($llm_raw, true);
|
||||
$content = $resp["choices"][0]["message"]["content"] ?? "";
|
||||
|
||||
// Parse JSON (robust: strip potential code fences)
|
||||
$content = preg_replace("/^```(?:json)?\s*/m", "", $content);
|
||||
$content = preg_replace("/\s*```\s*$/m", "", $content);
|
||||
$content = trim($content);
|
||||
|
||||
// Try extract first { to last }
|
||||
$first = strpos($content, "{");
|
||||
$last = strrpos($content, "}");
|
||||
if ($first !== false && $last > $first) {
|
||||
$content = substr($content, $first, $last - $first + 1);
|
||||
}
|
||||
|
||||
$data = @json_decode($content, true);
|
||||
if (!$data || !isset($data["title"])) {
|
||||
// Fallback simple structure
|
||||
$data = [
|
||||
"title" => ucfirst($topic),
|
||||
"subtitle" => "Rapport stratégique",
|
||||
"date" => date("d/m/Y"),
|
||||
"author" => "WEVIA Report Engine",
|
||||
"executive_summary" => "Analyse synthétique de $topic.",
|
||||
"sections" => [
|
||||
["heading" => "Contexte", "content" => "Analyse du contexte de $topic dans l'environnement actuel.", "bullets" => []],
|
||||
["heading" => "Enjeux", "content" => "Les enjeux clés à considérer.", "bullets" => []],
|
||||
["heading" => "Recommandations", "content" => "Actions recommandées.", "bullets" => []],
|
||||
],
|
||||
"kpis" => [
|
||||
["label" => "Impact estimé", "value" => "High", "trend" => ""],
|
||||
],
|
||||
"chart_data" => ["labels" => ["Q1","Q2","Q3","Q4"], "values" => [25,35,45,60], "type" => "bar", "title" => "Évolution projetée"],
|
||||
"conclusion" => "Synthèse et prochaines étapes.",
|
||||
];
|
||||
}
|
||||
|
||||
// === 2. Build HTML premium ===
|
||||
$chart_json = json_encode($data["chart_data"] ?? ["labels"=>[],"values"=>[],"type"=>"bar","title"=>""]);
|
||||
|
||||
$kpis_html = "";
|
||||
foreach ($data["kpis"] ?? [] as $k) {
|
||||
$v = htmlspecialchars($k["value"] ?? "");
|
||||
$l = htmlspecialchars($k["label"] ?? "");
|
||||
$t = htmlspecialchars($k["trend"] ?? "");
|
||||
$trend_color = (strpos($t, "+") === 0) ? "#10b981" : ((strpos($t, "-") === 0) ? "#ef4444" : "#6366f1");
|
||||
$kpis_html .= "<div class=kpi><div class=kv>$v</div><div class=kl>$l</div><div class=kt style='color:$trend_color'>$t</div></div>";
|
||||
}
|
||||
|
||||
$sections_html = "";
|
||||
foreach ($data["sections"] ?? [] as $i => $s) {
|
||||
$h = htmlspecialchars($s["heading"] ?? "");
|
||||
$c = htmlspecialchars($s["content"] ?? "");
|
||||
$bullets = "";
|
||||
foreach ($s["bullets"] ?? [] as $b) $bullets .= "<li>" . htmlspecialchars($b) . "</li>";
|
||||
$bullets = $bullets ? "<ul>$bullets</ul>" : "";
|
||||
$sections_html .= "<section class=sec><div class=snum>" . str_pad($i+1, 2, "0", STR_PAD_LEFT) . "</div><h2>$h</h2><p>$c</p>$bullets</section>";
|
||||
echo json_encode([
|
||||
"error"=>"LLM did not return valid JSON",
|
||||
"llm_raw" => substr($content, 0, 500),
|
||||
"llm_ms" => $llm_ms,
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Build premium HTML template
|
||||
$title = htmlspecialchars($data["title"] ?? "Rapport");
|
||||
$subtitle = htmlspecialchars($data["subtitle"] ?? "");
|
||||
$date_str = htmlspecialchars($data["date"] ?? date("d/m/Y"));
|
||||
$author = htmlspecialchars($data["author"] ?? "WEVIA");
|
||||
$exec_summary = htmlspecialchars($data["executive_summary"] ?? "");
|
||||
$exec = htmlspecialchars($data["exec_summary"] ?? "");
|
||||
$sections = $data["sections"] ?? [];
|
||||
$kpis = $data["kpis"] ?? [];
|
||||
$chart_data = $data["chart_data"] ?? null;
|
||||
$conclusion = htmlspecialchars($data["conclusion"] ?? "");
|
||||
$date = date("d F Y");
|
||||
|
||||
$sec_html = "";
|
||||
foreach ($sections as $i => $sec) {
|
||||
$h = htmlspecialchars($sec["heading"] ?? "Section");
|
||||
$c = htmlspecialchars($sec["content"] ?? "");
|
||||
$bullets = $sec["bullets"] ?? [];
|
||||
$b_html = "";
|
||||
foreach ($bullets as $b) {
|
||||
$b_html .= "<li>" . htmlspecialchars($b) . "</li>";
|
||||
}
|
||||
$sec_html .= "<section class='sec'><h2>" . ($i+1) . ". $h</h2><p>$c</p>";
|
||||
if ($b_html) $sec_html .= "<ul>$b_html</ul>";
|
||||
$sec_html .= "</section>";
|
||||
}
|
||||
|
||||
$kpi_html = "";
|
||||
foreach ($kpis as $k) {
|
||||
$lbl = htmlspecialchars($k["label"] ?? "");
|
||||
$val = htmlspecialchars($k["value"] ?? "");
|
||||
$trd = htmlspecialchars($k["trend"] ?? "");
|
||||
$kpi_html .= "<div class='kpi'><div class='kpi-value'>$val</div><div class='kpi-label'>$lbl</div><div class='kpi-trend'>$trd</div></div>";
|
||||
}
|
||||
|
||||
$chart_json = json_encode($chart_data, JSON_UNESCAPED_UNICODE);
|
||||
$chart_type = $chart_data["type"] ?? "bar";
|
||||
|
||||
$html = <<<HTML
|
||||
<!DOCTYPE html>
|
||||
@@ -118,166 +157,158 @@ $html = <<<HTML
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>$title</title>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
|
||||
<style>
|
||||
@page { size: A4; margin: 15mm; }
|
||||
@page { margin: 0; size: A4; }
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
body { font-family: 'Helvetica Neue', Arial, sans-serif; color: #1a1f3a; line-height: 1.6; font-size: 11pt; }
|
||||
.cover { page-break-after: always; height: 270mm; display: flex; flex-direction: column; justify-content: space-between; padding: 20mm 10mm; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border-radius: 12px; }
|
||||
.cover .brand { font-size: 14pt; letter-spacing: 3px; opacity: 0.8; }
|
||||
.cover h1 { font-size: 36pt; font-weight: 800; line-height: 1.1; margin: 40mm 0 10mm; }
|
||||
.cover .sub { font-size: 16pt; opacity: 0.9; font-weight: 300; }
|
||||
.cover .meta { font-size: 11pt; opacity: 0.7; margin-top: 30mm; }
|
||||
.cover .meta div { margin-bottom: 4mm; }
|
||||
.exec-summary { background: #f8f9ff; border-left: 4px solid #667eea; padding: 12mm 10mm; margin: 10mm 0; border-radius: 6px; font-size: 13pt; font-style: italic; }
|
||||
.kpi-row { display: flex; gap: 8mm; margin: 10mm 0; }
|
||||
.kpi { flex: 1; background: white; border: 1px solid #e5e7eb; border-radius: 10px; padding: 8mm 6mm; text-align: center; }
|
||||
.kpi .kv { font-size: 24pt; font-weight: 800; color: #667eea; }
|
||||
.kpi .kl { font-size: 10pt; color: #6b7280; margin-top: 3mm; }
|
||||
.kpi .kt { font-size: 10pt; font-weight: 600; margin-top: 2mm; }
|
||||
.sec { margin: 10mm 0; padding: 8mm; background: white; border-radius: 8px; border: 1px solid #f0f0f5; page-break-inside: avoid; }
|
||||
.sec .snum { display: inline-block; background: #667eea; color: white; padding: 2mm 4mm; border-radius: 20px; font-weight: 700; font-size: 10pt; margin-bottom: 4mm; }
|
||||
.sec h2 { font-size: 16pt; color: #1a1f3a; margin-bottom: 4mm; }
|
||||
.sec p { text-align: justify; margin-bottom: 4mm; color: #374151; }
|
||||
.sec ul { list-style: none; padding-left: 0; }
|
||||
.sec ul li { padding: 2mm 0 2mm 8mm; position: relative; color: #4b5563; }
|
||||
.sec ul li::before { content: '▸'; position: absolute; left: 2mm; color: #667eea; font-weight: 700; }
|
||||
.chart-wrap { background: white; padding: 10mm; border-radius: 10px; border: 1px solid #e5e7eb; margin: 10mm 0; page-break-inside: avoid; }
|
||||
.chart-wrap h3 { font-size: 14pt; color: #1a1f3a; margin-bottom: 5mm; }
|
||||
.chart-wrap canvas { max-height: 100mm; }
|
||||
.conclusion { margin-top: 12mm; padding: 10mm; background: linear-gradient(135deg, rgba(102,126,234,0.08), rgba(118,75,162,0.08)); border-radius: 10px; border: 1px solid rgba(102,126,234,0.2); font-size: 12pt; }
|
||||
.conclusion h3 { color: #667eea; margin-bottom: 4mm; }
|
||||
.footer { text-align: center; color: #9ca3af; font-size: 9pt; margin-top: 15mm; border-top: 1px solid #e5e7eb; padding-top: 5mm; }
|
||||
body { font-family: 'Helvetica Neue', Arial, sans-serif; color: #1a1a2e; line-height: 1.6; }
|
||||
.cover { height: 297mm; background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #3b82f6 100%); color: #fff; padding: 80px 70px; display: flex; flex-direction: column; justify-content: space-between; page-break-after: always; }
|
||||
.cover .brand { font-size: 14px; letter-spacing: 4px; text-transform: uppercase; opacity: 0.9; }
|
||||
.cover h1 { font-size: 56px; line-height: 1.1; font-weight: 800; margin: 40px 0 20px; }
|
||||
.cover .subt { font-size: 22px; font-weight: 300; opacity: 0.92; max-width: 80%; }
|
||||
.cover .meta { font-size: 13px; opacity: 0.85; border-top: 1px solid rgba(255,255,255,0.3); padding-top: 24px; }
|
||||
.page { padding: 40px 55px 55px; min-height: 297mm; page-break-after: always; }
|
||||
.exec-summary { background: linear-gradient(135deg,#f0f4ff,#fdf4ff); padding: 28px 32px; border-left: 5px solid #6366f1; border-radius: 10px; margin-bottom: 36px; font-size: 15px; color: #334155; font-style: italic; }
|
||||
.kpis { display: flex; gap: 16px; margin: 32px 0; }
|
||||
.kpi { flex: 1; background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 24px 20px; text-align: center; box-shadow: 0 2px 8px rgba(99,102,241,0.08); }
|
||||
.kpi-value { font-size: 36px; font-weight: 800; color: #6366f1; margin-bottom: 6px; }
|
||||
.kpi-label { font-size: 13px; color: #64748b; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
|
||||
.kpi-trend { font-size: 12px; color: #10b981; font-weight: 600; }
|
||||
.chart-wrap { background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 28px; margin: 32px 0; }
|
||||
.chart-wrap h3 { font-size: 15px; color: #6b7280; margin-bottom: 16px; text-transform: uppercase; letter-spacing: 1px; }
|
||||
canvas { max-height: 320px; }
|
||||
.sec { margin-bottom: 32px; break-inside: avoid; }
|
||||
.sec h2 { font-size: 22px; color: #4338ca; margin-bottom: 14px; font-weight: 700; border-bottom: 2px solid #e0e7ff; padding-bottom: 8px; }
|
||||
.sec p { font-size: 14.5px; color: #334155; margin-bottom: 12px; }
|
||||
.sec ul { margin-left: 24px; }
|
||||
.sec li { font-size: 14px; color: #475569; margin-bottom: 6px; padding-left: 4px; }
|
||||
.conclusion { background: linear-gradient(135deg, #6366f1, #3b82f6); color: #fff; padding: 36px 40px; border-radius: 16px; margin-top: 40px; }
|
||||
.conclusion h2 { font-size: 22px; margin-bottom: 14px; }
|
||||
.conclusion p { font-size: 15.5px; line-height: 1.65; }
|
||||
.footer { position: fixed; bottom: 16mm; left: 55px; right: 55px; font-size: 10px; color: #94a3b8; display: flex; justify-content: space-between; border-top: 1px solid #e2e8f0; padding-top: 10px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Cover page -->
|
||||
<div class="cover">
|
||||
<div class="brand">WEVIA · WEVAL CONSULTING</div>
|
||||
<div>
|
||||
<h1>$title</h1>
|
||||
<div class="sub">$subtitle</div>
|
||||
</div>
|
||||
<div class="meta">
|
||||
<div><strong>Date</strong> · $date_str</div>
|
||||
<div><strong>Auteur</strong> · $author</div>
|
||||
<div><strong>Type</strong> · Rapport exécutif</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="brand">WEVAL Consulting · Rapport Premium</div>
|
||||
<h1>$title</h1>
|
||||
<div class="subt">$subtitle</div>
|
||||
</div>
|
||||
<div class="meta">Généré le $date · WEVIA Enterprise Intelligence</div>
|
||||
</div>
|
||||
|
||||
<div class="exec-summary">
|
||||
<strong>Résumé exécutif · </strong> $exec_summary
|
||||
</div>
|
||||
|
||||
<div class="kpi-row">$kpis_html</div>
|
||||
|
||||
<div class="chart-wrap">
|
||||
<h3 id="chart-title">Visualisation des données</h3>
|
||||
<canvas id="mainChart"></canvas>
|
||||
</div>
|
||||
|
||||
$sections_html
|
||||
|
||||
<div class="conclusion">
|
||||
<h3>Conclusion & Perspectives</h3>
|
||||
<p>$conclusion</p>
|
||||
<!-- Content -->
|
||||
<div class="page">
|
||||
<div class="exec-summary">$exec</div>
|
||||
|
||||
<div class="kpis">$kpi_html</div>
|
||||
|
||||
<div class="chart-wrap">
|
||||
<h3>Visualisation des données</h3>
|
||||
<canvas id="mainChart"></canvas>
|
||||
</div>
|
||||
|
||||
$sec_html
|
||||
|
||||
<div class="conclusion">
|
||||
<h2>Conclusion & recommandations</h2>
|
||||
<p>$conclusion</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
Rapport généré par WEVIA · WEVAL Consulting · $date_str · Confidentiel
|
||||
<span>WEVAL Consulting · weval-consulting.com</span>
|
||||
<span>Confidentiel · Usage interne</span>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function(){
|
||||
var d = $chart_json;
|
||||
if (!d || !d.values || !d.values.length) return;
|
||||
window.addEventListener("load", function(){
|
||||
try {
|
||||
var el = document.getElementById('mainChart');
|
||||
if (!el) return;
|
||||
document.getElementById('chart-title').innerText = d.title || 'Données';
|
||||
var colors = ['#667eea','#764ba2','#10b981','#f59e0b','#ef4444','#3b82f6','#8b5cf6','#ec4899'];
|
||||
new Chart(el, {
|
||||
type: d.type || 'bar',
|
||||
var cd = $chart_json;
|
||||
if (!cd) return;
|
||||
var ctx = document.getElementById("mainChart").getContext("2d");
|
||||
new Chart(ctx, {
|
||||
type: cd.type || "$chart_type",
|
||||
data: {
|
||||
labels: d.labels,
|
||||
labels: cd.labels || [],
|
||||
datasets: [{
|
||||
label: d.title || '',
|
||||
data: d.values,
|
||||
backgroundColor: (d.type === 'pie' || d.type === 'doughnut') ? colors.slice(0, d.values.length) : 'rgba(102,126,234,0.7)',
|
||||
borderColor: '#667eea',
|
||||
label: cd.title || "Données",
|
||||
data: cd.values || [],
|
||||
backgroundColor: ["#6366f1","#8b5cf6","#3b82f6","#06b6d4","#10b981","#f59e0b","#ef4444","#ec4899"],
|
||||
borderColor: "#4338ca",
|
||||
borderWidth: 2,
|
||||
tension: 0.3,
|
||||
}],
|
||||
borderRadius: 6,
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
animation: false,
|
||||
plugins: { legend: { display: d.type === 'pie' || d.type === 'doughnut' } },
|
||||
scales: (d.type === 'pie' || d.type === 'doughnut') ? {} : {
|
||||
y: { beginAtZero: true, grid: { color: '#f0f0f5' } },
|
||||
x: { grid: { display: false } },
|
||||
},
|
||||
},
|
||||
maintainAspectRatio: true,
|
||||
plugins: { legend: { display: false }, title: { display: true, text: cd.title, color: "#334155", font:{size:14}}},
|
||||
scales: { y: { beginAtZero: true, grid:{color:"#f1f5f9"}}, x: {grid:{display:false}}},
|
||||
}
|
||||
});
|
||||
} catch(e) { console.error('Chart render fail:', e); }
|
||||
})();
|
||||
window._wevia_chart_ready = true;
|
||||
} catch(e) { console.error("chart fail", e); }
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
HTML;
|
||||
|
||||
// === 3. Save HTML + render with Chromium ===
|
||||
$dir = "/var/www/html/generated";
|
||||
if (!is_dir($dir)) @mkdir($dir, 0755, true);
|
||||
$slug = substr(preg_replace('/[^a-z0-9]+/', '-', strtolower($topic)), 0, 40);
|
||||
$slug = trim($slug, "-");
|
||||
$ts = date("Ymd-His");
|
||||
$rand = bin2hex(random_bytes(3));
|
||||
$html_file = "$dir/wevia-pdf-html-$slug-$ts-$rand.html";
|
||||
$pdf_file = "$dir/wevia-pdf-premium-$slug-$ts-$rand.pdf";
|
||||
// Save html + render pdf
|
||||
$outdir = "/var/www/html/generated";
|
||||
if (!is_dir($outdir)) @mkdir($outdir, 0777, true);
|
||||
$base = "wevia-pdf-premium-" . date("Ymd-His") . "-" . bin2hex(random_bytes(3));
|
||||
$html_path = "$outdir/$base.html";
|
||||
$pdf_path = "$outdir/$base.pdf";
|
||||
@file_put_contents($html_path, $html);
|
||||
|
||||
file_put_contents($html_file, $html);
|
||||
$engine = "none";
|
||||
$render_ms = 0;
|
||||
$t2 = microtime(true);
|
||||
|
||||
// Use chromium headless to render (supports Chart.js !)
|
||||
$chromium_cmd = "timeout 60 /usr/bin/chromium-browser " .
|
||||
"--headless --disable-gpu --no-sandbox --disable-dev-shm-usage " .
|
||||
"--virtual-time-budget=8000 " . // wait 8s for Chart.js
|
||||
"--run-all-compositor-stages-before-draw " .
|
||||
"--print-to-pdf=" . escapeshellarg($pdf_file) . " " .
|
||||
"--print-to-pdf-no-header " .
|
||||
"file://" . escapeshellarg($html_file) . " 2>&1";
|
||||
|
||||
$chrome_out = @shell_exec($chromium_cmd);
|
||||
|
||||
if (!file_exists($pdf_file) || filesize($pdf_file) < 1000) {
|
||||
// Fallback: wkhtmltopdf (no JS but still stylish)
|
||||
$wk_cmd = "timeout 30 /usr/bin/wkhtmltopdf --quiet --enable-local-file-access " .
|
||||
"--page-size A4 --margin-top 15 --margin-bottom 15 " .
|
||||
escapeshellarg($html_file) . " " . escapeshellarg($pdf_file) . " 2>&1";
|
||||
$wk_out = @shell_exec($wk_cmd);
|
||||
// Try Chromium first (best JS support for Chart.js)
|
||||
if (file_exists("/usr/bin/google-chrome") || file_exists("/usr/bin/chromium") || file_exists("/usr/bin/chromium-browser")) {
|
||||
// Prefer real chrome over stub chromium-browser snap
|
||||
$bin = file_exists("/usr/bin/google-chrome") ? "/usr/bin/google-chrome" : (file_exists("/usr/bin/chromium") ? "/usr/bin/chromium" : "/usr/bin/chromium-browser");
|
||||
$cmd = "timeout 60 $bin --headless --disable-gpu --no-sandbox --hide-scrollbars --virtual-time-budget=10000 --print-to-pdf='$pdf_path' --print-to-pdf-no-header 'file://$html_path' 2>&1";
|
||||
@shell_exec($cmd);
|
||||
if (file_exists($pdf_path) && filesize($pdf_path) > 1000) $engine = "chromium";
|
||||
}
|
||||
|
||||
if (!file_exists($pdf_file) || filesize($pdf_file) < 1000) {
|
||||
echo json_encode([
|
||||
"error" => "pdf render failed",
|
||||
"chrome_out" => substr($chrome_out ?? "", 0, 500),
|
||||
"html_url" => "https://weval-consulting.com/generated/" . basename($html_file),
|
||||
]);
|
||||
exit;
|
||||
// Fallback wkhtmltopdf
|
||||
if ($engine === "none" && file_exists("/usr/bin/wkhtmltopdf")) {
|
||||
$cmd = "timeout 30 /usr/bin/wkhtmltopdf --enable-javascript --javascript-delay 3000 --margin-top 0 --margin-bottom 0 --margin-left 0 --margin-right 0 --page-size A4 '$html_path' '$pdf_path' 2>&1";
|
||||
@shell_exec($cmd);
|
||||
if (file_exists($pdf_path) && filesize($pdf_path) > 1000) $engine = "wkhtmltopdf";
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
"success" => true,
|
||||
$render_ms = round((microtime(true)-$t2)*1000);
|
||||
$size_kb = file_exists($pdf_path) ? round(filesize($pdf_path)/1024, 1) : 0;
|
||||
$pages = 0;
|
||||
if ($size_kb > 0 && file_exists("/usr/bin/pdfinfo")) {
|
||||
$info = @shell_exec("pdfinfo '$pdf_path' 2>&1 | grep Pages");
|
||||
if (preg_match("/Pages:\s+(\d+)/", $info, $m)) $pages = intval($m[1]);
|
||||
}
|
||||
|
||||
$result = [
|
||||
"ok" => ($size_kb > 0),
|
||||
"url" => "/generated/$base.pdf",
|
||||
"html_preview" => "/generated/$base.html",
|
||||
"title" => $data["title"],
|
||||
"topic" => $topic,
|
||||
"url" => "https://weval-consulting.com/generated/" . basename($pdf_file),
|
||||
"html_preview" => "https://weval-consulting.com/generated/" . basename($html_file),
|
||||
"pages" => max(1, intval(filesize($pdf_file) / 15000)),
|
||||
"size_kb" => round(filesize($pdf_file)/1024, 1),
|
||||
"sections" => count($data["sections"] ?? []),
|
||||
"kpis" => count($data["kpis"] ?? []),
|
||||
"has_chart" => !empty($data["chart_data"]["values"]),
|
||||
"llm_ms" => $llm_elapsed,
|
||||
"subtitle" => $data["subtitle"] ?? "",
|
||||
"pages" => $pages,
|
||||
"size_kb" => $size_kb,
|
||||
"sections" => count($sections),
|
||||
"kpis" => count($kpis),
|
||||
"has_chart" => $chart_data !== null,
|
||||
"engine" => $engine,
|
||||
"llm_ms" => $llm_ms,
|
||||
"render_ms" => $render_ms,
|
||||
"total_ms" => round((microtime(true)-$t0)*1000),
|
||||
"provider" => "WEVIA PDF Premium",
|
||||
"engine" => file_exists($pdf_file) ? "Chromium" : "wkhtmltopdf",
|
||||
]);
|
||||
"provider" => "WEVIA PDF Premium Engine",
|
||||
"lang" => $lang,
|
||||
];
|
||||
echo json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
70
api/ambre-v0-priority.php
Normal file
70
api/ambre-v0-priority.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/var/www/html/wevia.html";
|
||||
$content = @file_get_contents($path);
|
||||
$orig_size = strlen($content);
|
||||
|
||||
if (strpos($content, "AMBRE-V0-PRIORITY-ROUTER") !== false) {
|
||||
echo json_encode(["skip"=>"already present"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Inject priority router right BEFORE "AMBRE-V9-PDF-PREMIUM"
|
||||
$anchor = " // === AMBRE-V9-PDF-PREMIUM 2026-04-21";
|
||||
if (strpos($content, $anchor) === false) {
|
||||
// Fallback anchor: V2-GEN-ROUTER
|
||||
$anchor = " // === AMBRE-V2-GEN-ROUTER 2026-04-21";
|
||||
}
|
||||
|
||||
$v0 = <<<'JS'
|
||||
// === AMBRE-V0-PRIORITY-ROUTER 2026-04-22 · route simple chat to session-chat (semaphore-protected) ===
|
||||
// Avoids /api/sovereign 503 overload. Session-chat uses cascade :4000 directly with throttle.
|
||||
// Applies to: short messages, greetings, non-file-gen, non-tool patterns
|
||||
var _is_gen_cmd = /pdf|rapport|docx?|word|excel|xlsx?|pptx?|powerpoint|sch[eé]ma|diagramme|mermaid|image|photo|dessin|qr\s*code|tts|lis[ -]|calcule|combien|code|traduis|cherche|recherche|actualit[eé]|search|news|latest|youtube|r[eé]sume|summari/i.test(text);
|
||||
var _is_long = text.length > 500;
|
||||
var _has_url = /https?:\/\//.test(text);
|
||||
if (!_is_gen_cmd && !_is_long && !_has_url && typeof window._ambre_session_id !== 'undefined') {
|
||||
var _sid = window._ambre_session_id;
|
||||
fetch('/api/ambre-session-chat.php', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type':'application/json'},
|
||||
body: JSON.stringify({message: text, session_id: _sid})
|
||||
})
|
||||
.then(function(r){ return r.text().then(function(t){ try{return JSON.parse(t);}catch(e){return null;} }); })
|
||||
.then(function(data){
|
||||
hideThinking();
|
||||
var elapsed = ((performance.now()-startTime)/1000).toFixed(1);
|
||||
var resp = (data && data.response) ? data.response : "Désolé, je n'ai pas pu traiter votre demande. Réessayez.";
|
||||
chatHistory.push({role:'assistant', content:resp});
|
||||
var msgEl = addMsg('assistant', resp, elapsed);
|
||||
busy=false;
|
||||
try{var s=document.getElementById("sendBtn");if(s)s.disabled=false;}catch(e){}
|
||||
try{var m=document.getElementById("msgInput");if(m){m.value="";m.disabled=false;}}catch(e){}
|
||||
})
|
||||
.catch(function(err){
|
||||
hideThinking();
|
||||
addMsg('assistant', '⚠️ Service momentanément lent, réessayez.', '0');
|
||||
busy=false;
|
||||
try{var s=document.getElementById("sendBtn");if(s)s.disabled=false;}catch(e){}
|
||||
try{var m=document.getElementById("msgInput");if(m){m.value="";m.disabled=false;}}catch(e){}
|
||||
});
|
||||
return;
|
||||
}
|
||||
// === END AMBRE-V0-PRIORITY-ROUTER ===
|
||||
|
||||
JS;
|
||||
|
||||
$content_new = str_replace($anchor, $v0 . $anchor, $content);
|
||||
$delta = strlen($content_new) - $orig_size;
|
||||
|
||||
$backup = "/opt/wevads/vault/wevia.html.GOLD-" . date("Ymd-His") . "-v0-priority-router";
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, $content_new);
|
||||
|
||||
echo json_encode([
|
||||
"orig" => $orig_size,
|
||||
"new" => strlen($content_new),
|
||||
"delta" => $delta,
|
||||
"wrote" => $wrote,
|
||||
"backup" => basename($backup),
|
||||
]);
|
||||
28
api/ambre-v10-css.php
Normal file
28
api/ambre-v10-css.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/var/www/html/wevia.html";
|
||||
$c = @file_get_contents($path);
|
||||
|
||||
// In the inline mermaid div, ensure min-height and visible styling
|
||||
$old = '<div class="mermaid" id="" + uniqId + "" style="text-align:center">" + mcode + "</div>';
|
||||
// Actually the style is inside the string. Let me use pattern
|
||||
$old_esc = '<div class=\\"mermaid\\" id=\\"" + uniqId + "\\" style=\\"text-align:center\\">" + mcode + "</div>';
|
||||
$new_esc = '<div class=\\"mermaid\\" id=\\"" + uniqId + "\\" style=\\"text-align:center;min-height:200px;font-size:14px;color:#333;background:#fff;padding:12px\\">" + mcode + "</div>';
|
||||
|
||||
if (strpos($c, $old_esc) === false) {
|
||||
// Simpler check
|
||||
if (strpos($c, 'class=\\"mermaid\\" id=\\"" + uniqId + "\\" style=\\"text-align:center\\"') !== false) {
|
||||
$c = str_replace('class=\\"mermaid\\" id=\\"" + uniqId + "\\" style=\\"text-align:center\\"', 'class=\\"mermaid\\" id=\\"" + uniqId + "\\" style=\\"text-align:center;min-height:200px;font-size:14px;color:#333\\"', $c);
|
||||
echo json_encode(["patch"=>"style expanded", "size"=>strlen($c)]);
|
||||
} else {
|
||||
echo json_encode(["error"=>"pattern not found for style fix"]);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$c = str_replace($old_esc, $new_esc, $c);
|
||||
}
|
||||
|
||||
$backup = "/opt/wevads/vault/wevia.html.GOLD-" . date("Ymd-His") . "-mermaid-css";
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, $c);
|
||||
echo json_encode(["wrote"=>$wrote, "backup"=>basename($backup)]);
|
||||
27
api/ambre-v10-fix.php
Normal file
27
api/ambre-v10-fix.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/var/www/html/wevia.html";
|
||||
$c = @file_get_contents($path);
|
||||
$orig = strlen($c);
|
||||
|
||||
// Replace the V10 addMsg call with direct innerHTML injection
|
||||
$old = 'addMsg("assistant", badges + inlineBlock, (data.elapsed_ms/1000).toFixed(2));';
|
||||
$new = '// Direct innerHTML injection (bypass formatMd HTML escape)
|
||||
var _el = addMsg("assistant", "Diagramme Mermaid", (data.elapsed_ms/1000).toFixed(2));
|
||||
var _bubble = _el ? _el.querySelector(".bubble") : null;
|
||||
if (_bubble) _bubble.innerHTML = badges + inlineBlock;';
|
||||
|
||||
if (strpos($c, $old) === false) {
|
||||
echo json_encode(["error"=>"pattern not found in V10"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$new_c = str_replace($old, $new, $c);
|
||||
$backup = "/opt/wevads/vault/wevia.html.GOLD-" . date("Ymd-His") . "-v10-fix";
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, $new_c);
|
||||
|
||||
echo json_encode([
|
||||
"delta" => strlen($new_c) - $orig,
|
||||
"wrote" => $wrote,
|
||||
]);
|
||||
78
api/ambre-v10-render.php
Normal file
78
api/ambre-v10-render.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/var/www/html/wevia.html";
|
||||
$c = @file_get_contents($path);
|
||||
$orig = strlen($c);
|
||||
|
||||
// The V10 block uses class="mermaid" which triggers the problematic CSS
|
||||
// Keep class="mermaid" (so mermaid.run picks it up) BUT add an override style in-line
|
||||
// The issue is font-size:0 !important - we can't override easily
|
||||
// Better: after mermaid.run, the data-processed=true attribute is set, which UNSETS font-size:0
|
||||
// So the issue must be that mermaid.run() isn't triggering or the SVG has issues
|
||||
|
||||
// Let me use a different approach: use mermaid.render() directly to get SVG as string, insert directly
|
||||
|
||||
$old = "var uniqId = \"mmd-\" + Date.now();
|
||||
var inlineBlock = \"<div style=\\\"margin:12px 0;padding:14px;background:#fafafa;border:1px solid #e5e7eb;border-radius:12px\\\">\" +
|
||||
\"<div style=\\\"font-weight:600;font-size:13px;color:#6b7280;margin-bottom:10px\\\">📊 \" + topic + \"</div>\" +
|
||||
\"<div class=\\\"mermaid\\\" id=\\\"\" + uniqId + \"\\\" style=\\\"text-align:center;min-height:200px;font-size:14px;color:#333\\\">\" + mcode + \"</div>\"";
|
||||
|
||||
$new = "var uniqId = \"mmd-\" + Date.now();
|
||||
// Pre-render SVG via mermaid.render() to avoid CSS font-size:0 !important issue
|
||||
var inlineBlock = \"<div style=\\\"margin:12px 0;padding:14px;background:#fafafa;border:1px solid #e5e7eb;border-radius:12px\\\">\" +
|
||||
\"<div style=\\\"font-weight:600;font-size:13px;color:#6b7280;margin-bottom:10px\\\">📊 \" + topic + \"</div>\" +
|
||||
\"<div id=\\\"\" + uniqId + \"\\\" style=\\\"text-align:center;min-height:150px;padding:10px;background:#fff;border-radius:8px\\\">Rendu en cours...</div>\"";
|
||||
|
||||
if (strpos($c, $old) === false) {
|
||||
echo json_encode(["error"=>"V10 pattern not found for CSS fix"]);
|
||||
exit;
|
||||
}
|
||||
$c = str_replace($old, $new, $c);
|
||||
|
||||
// And update the render call to use mermaid.render(id, code) API
|
||||
$old_render = "setTimeout(function(){
|
||||
try {
|
||||
if (window.mermaid && typeof window.mermaid.run === \"function\") {
|
||||
window.mermaid.run({ nodes: [document.getElementById(uniqId)] });
|
||||
}
|
||||
} catch(e) { console.warn(\"mermaid render fail\", e); }
|
||||
}, 300);";
|
||||
|
||||
$new_render = "setTimeout(function(){
|
||||
try {
|
||||
var target = document.getElementById(uniqId);
|
||||
if (!target) return;
|
||||
if (window.mermaid && typeof window.mermaid.render === \"function\") {
|
||||
// Use render() to get SVG string directly
|
||||
window.mermaid.render(\"svg-\" + uniqId, mcode).then(function(result) {
|
||||
if (result && result.svg) {
|
||||
target.innerHTML = result.svg;
|
||||
target.style.minHeight = \"auto\";
|
||||
}
|
||||
}).catch(function(err){
|
||||
console.warn(\"mermaid.render error\", err);
|
||||
target.innerHTML = \"<pre style=\\\"font-size:11px;color:#b00;padding:10px;background:#fee;border-radius:6px\\\">Erreur rendu: \" + String(err).substring(0, 200) + \"</pre>\";
|
||||
});
|
||||
} else if (window.mermaid && typeof window.mermaid.init === \"function\") {
|
||||
target.className = \"mermaid\";
|
||||
target.textContent = mcode;
|
||||
window.mermaid.init(undefined, target);
|
||||
}
|
||||
} catch(e) { console.warn(\"mermaid render fail\", e); }
|
||||
}, 500);";
|
||||
|
||||
if (strpos($c, $old_render) === false) {
|
||||
echo json_encode(["error"=>"render pattern not found", "orig_changed" => strlen($c) != $orig]);
|
||||
exit;
|
||||
}
|
||||
$c = str_replace($old_render, $new_render, $c);
|
||||
|
||||
$backup = "/opt/wevads/vault/wevia.html.GOLD-" . date("Ymd-His") . "-v10-render";
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, $c);
|
||||
|
||||
echo json_encode([
|
||||
"delta" => strlen($c) - $orig,
|
||||
"wrote" => $wrote,
|
||||
"backup" => basename($backup),
|
||||
]);
|
||||
64
api/ambre-v10-san.php
Normal file
64
api/ambre-v10-san.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/var/www/html/wevia.html";
|
||||
$c = @file_get_contents($path);
|
||||
$orig = strlen($c);
|
||||
|
||||
// Add sanitize step in the V10 render setTimeout
|
||||
$old = 'setTimeout(function(){
|
||||
try {
|
||||
if (window.mermaid && typeof window.mermaid.run === "function") {
|
||||
window.mermaid.run({ nodes: [document.getElementById(uniqId)] });
|
||||
}';
|
||||
|
||||
$new = 'setTimeout(function(){
|
||||
try {
|
||||
var target = document.getElementById(uniqId);
|
||||
if (!target) return;
|
||||
// Sanitize mermaid code (strip accents, fix common LLM mistakes)
|
||||
var clean = mcode
|
||||
.replace(/[àâä]/g, "a").replace(/[éèêë]/g, "e").replace(/[îï]/g, "i")
|
||||
.replace(/[ôö]/g, "o").replace(/[ùûü]/g, "u").replace(/ç/g, "c")
|
||||
.replace(/[ÀÂÄ]/g, "A").replace(/[ÉÈÊË]/g, "E").replace(/[ÎÏ]/g, "I")
|
||||
.replace(/[ÔÖ]/g, "O").replace(/[ÙÛÜ]/g, "U").replace(/Ç/g, "C")
|
||||
.trim();
|
||||
// Use mermaid.render for SVG direct return (bypass font-size:0 CSS issue)
|
||||
if (window.mermaid && typeof window.mermaid.render === "function") {
|
||||
window.mermaid.render("svg-" + uniqId, clean).then(function(result){
|
||||
if (result && result.svg) {
|
||||
target.innerHTML = result.svg;
|
||||
target.className = "mermaid-rendered";
|
||||
target.removeAttribute("data-processed");
|
||||
// Force SVG to reasonable size
|
||||
var svg = target.querySelector("svg");
|
||||
if (svg) {
|
||||
svg.style.maxWidth = "100%";
|
||||
svg.style.height = "auto";
|
||||
svg.style.minHeight = "180px";
|
||||
svg.removeAttribute("width");
|
||||
svg.style.width = "100%";
|
||||
}
|
||||
}
|
||||
}).catch(function(err){
|
||||
console.warn("mermaid render err", err);
|
||||
target.innerHTML = "<pre style=\"font-size:12px;padding:10px;background:#f5f5f5;border-radius:6px\">" + clean.replace(/</g,"<") + "</pre>";
|
||||
});
|
||||
} else if (window.mermaid && typeof window.mermaid.run === "function") {
|
||||
target.className = "mermaid";
|
||||
target.textContent = clean;
|
||||
window.mermaid.run({ nodes: [target] });
|
||||
}';
|
||||
|
||||
if (strpos($c, $old) === false) {
|
||||
echo json_encode(["error"=>"pattern not found"]);
|
||||
exit;
|
||||
}
|
||||
$c = str_replace($old, $new, $c);
|
||||
|
||||
$backup = "/opt/wevads/vault/wevia.html.GOLD-" . date("Ymd-His") . "-v10-sanitize";
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, $c);
|
||||
echo json_encode([
|
||||
"delta" => strlen($c) - $orig,
|
||||
"wrote" => $wrote,
|
||||
]);
|
||||
43
api/ambre-wire-reg2.php
Normal file
43
api/ambre-wire-reg2.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/var/www/html/api/wevia-tool-registry.json";
|
||||
|
||||
// Unlock
|
||||
@shell_exec("chattr -i $path 2>&1");
|
||||
|
||||
$content = @file_get_contents($path);
|
||||
$data = @json_decode($content, true);
|
||||
|
||||
$existing_ids = array_map(function($t){return $t["id"]??"";}, $data["tools"]);
|
||||
$new_tools = [
|
||||
["id"=>"pdf_premium_generator","kw"=>"pdf.*premium|rapport.*premium|pdf.*qualit|pdf.*graphique|pdf.*chart|premium.*pdf","cmd"=>"curl -sS -X POST http://127.0.0.1/api/ambre-tool-pdf-premium.php -H 'Content-Type: application/json' -d '{\"topic\":\"${TOPIC}\"}'","exec"=>true,"desc"=>"PDF Premium · Chart.js + google-chrome · 6 chart types","wave"=>229],
|
||||
["id"=>"mermaid_generator_kb","kw"=>"mermaid|diagramme|flowchart|sequence.*diagram|gantt|schema.*mermaid|schema.*process","cmd"=>"curl -sS -X POST http://127.0.0.1/api/ambre-tool-mermaid.php -H 'Content-Type: application/json' -d '{\"topic\":\"${TOPIC}\"}'","exec"=>true,"desc"=>"Mermaid + Learning KB · RAG reuse + auto-save","wave"=>229],
|
||||
["id"=>"mermaid_kb_search","kw"=>"mermaid.*search|recherche.*diagramme|find.*schema|catalog.*mermaid","cmd"=>"curl -sS -X POST http://127.0.0.1/api/ambre-mermaid-learn.php -H 'Content-Type: application/json' -d '{\"action\":\"search\",\"query\":\"${TOPIC}\"}'","exec"=>true,"desc"=>"Mermaid KB search","wave"=>229],
|
||||
["id"=>"mermaid_kb_stats","kw"=>"mermaid.*stats|mermaid.*catalog.*count|kb.*stats","cmd"=>"curl -sS -X POST http://127.0.0.1/api/ambre-mermaid-learn.php -H 'Content-Type: application/json' -d '{\"action\":\"stats\"}'","exec"=>true,"desc"=>"Mermaid KB stats","wave"=>229],
|
||||
["id"=>"llm_semaphore_stats","kw"=>"semaphore.*stat|llm.*load|llm.*semaphore|concurrent.*llm","cmd"=>"curl -sS http://127.0.0.1/api/ambre-llm-semaphore.php","exec"=>true,"desc"=>"LLM semaphore stats","wave"=>229],
|
||||
];
|
||||
|
||||
$added = 0;
|
||||
foreach ($new_tools as $nt) {
|
||||
if (!in_array($nt["id"], $existing_ids)) {
|
||||
$data["tools"][] = $nt;
|
||||
$added++;
|
||||
}
|
||||
}
|
||||
$data["opus_wave_229"] = ["ts"=>date("c"),"added"=>$added,"new_total"=>count($data["tools"])];
|
||||
|
||||
$json_out = json_encode($data, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
|
||||
$backup = "/opt/wevads/vault/wevia-tool-registry.GOLD-" . date("Ymd-His") . "-wave229";
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, $json_out);
|
||||
|
||||
// Relock
|
||||
@shell_exec("chattr +i $path 2>&1");
|
||||
|
||||
echo json_encode([
|
||||
"added" => $added,
|
||||
"new_total" => count($data["tools"]),
|
||||
"wrote" => $wrote,
|
||||
"backup" => basename($backup),
|
||||
"is_locked_after" => trim(shell_exec("lsattr $path 2>&1 | awk '{print \$1}'")),
|
||||
]);
|
||||
89
api/ambre-wire-registry.php
Normal file
89
api/ambre-wire-registry.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/var/www/html/api/wevia-tool-registry.json";
|
||||
$content = @file_get_contents($path);
|
||||
$data = @json_decode($content, true);
|
||||
|
||||
if (!is_array($data) || !isset($data["tools"])) {
|
||||
echo json_encode(["error"=>"invalid registry"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$orig_count = count($data["tools"]);
|
||||
|
||||
// Check existing ids to avoid duplicates
|
||||
$existing_ids = [];
|
||||
foreach ($data["tools"] as $t) $existing_ids[] = $t["id"] ?? "";
|
||||
|
||||
// Tools to add (wave-229 deliverables)
|
||||
$new_tools = [
|
||||
[
|
||||
"id" => "pdf_premium_generator",
|
||||
"kw" => "pdf.*premium|rapport.*premium|pdf.*qualit|pdf.*graphique|pdf.*chart|premium.*pdf|rapport.*graph",
|
||||
"cmd" => "curl -sS -X POST http://127.0.0.1/api/ambre-tool-pdf-premium.php -H 'Content-Type: application/json' -d '{\"topic\":\"${TOPIC}\"}' | jq -r '.url'",
|
||||
"exec" => true,
|
||||
"desc" => "WEVIA PDF Premium · Chart.js + google-chrome + LLM JSON structure · 6 chart types",
|
||||
"wave" => 229,
|
||||
],
|
||||
[
|
||||
"id" => "mermaid_generator_kb",
|
||||
"kw" => "mermaid|diagramme|flowchart|sequence.*diagram|gantt|schema.*mermaid|schema.*process",
|
||||
"cmd" => "curl -sS -X POST http://127.0.0.1/api/ambre-tool-mermaid.php -H 'Content-Type: application/json' -d '{\"topic\":\"${TOPIC}\"}' | jq -r '.mermaid_code'",
|
||||
"exec" => true,
|
||||
"desc" => "WEVIA Mermaid + Learning KB · RAG reuse si match · LLM generate + auto-save sinon",
|
||||
"wave" => 229,
|
||||
],
|
||||
[
|
||||
"id" => "mermaid_kb_search",
|
||||
"kw" => "mermaid.*search|recherche.*diagramme|find.*schema|catalog.*mermaid|kb.*mermaid",
|
||||
"cmd" => "curl -sS -X POST http://127.0.0.1/api/ambre-mermaid-learn.php -H 'Content-Type: application/json' -d '{\"action\":\"search\",\"query\":\"${TOPIC}\"}' | jq '.'",
|
||||
"exec" => true,
|
||||
"desc" => "WEVIA Mermaid KB search · retrieve existing diagrams by topic",
|
||||
"wave" => 229,
|
||||
],
|
||||
[
|
||||
"id" => "mermaid_kb_stats",
|
||||
"kw" => "mermaid.*stats|mermaid.*catalog.*count|kb.*stats|mermaid.*total",
|
||||
"cmd" => "curl -sS -X POST http://127.0.0.1/api/ambre-mermaid-learn.php -H 'Content-Type: application/json' -d '{\"action\":\"stats\"}' | jq '.'",
|
||||
"exec" => true,
|
||||
"desc" => "WEVIA Mermaid KB stats · total diagrams + by kind + total uses",
|
||||
"wave" => 229,
|
||||
],
|
||||
[
|
||||
"id" => "llm_semaphore_stats",
|
||||
"kw" => "semaphore.*stat|llm.*load|llm.*semaphore|concurrent.*llm|cascade.*load",
|
||||
"cmd" => "curl -sS http://127.0.0.1/api/ambre-llm-semaphore.php | jq '.'",
|
||||
"exec" => true,
|
||||
"desc" => "WEVIA LLM semaphore stats · active locks / max concurrent",
|
||||
"wave" => 229,
|
||||
],
|
||||
];
|
||||
|
||||
$added = 0;
|
||||
foreach ($new_tools as $nt) {
|
||||
if (!in_array($nt["id"], $existing_ids)) {
|
||||
$data["tools"][] = $nt;
|
||||
$added++;
|
||||
}
|
||||
}
|
||||
|
||||
// Update meta
|
||||
$data["opus_wave_229"] = [
|
||||
"ts" => date("c"),
|
||||
"added" => $added,
|
||||
"new_total" => count($data["tools"]),
|
||||
];
|
||||
|
||||
// Backup
|
||||
$backup = "/opt/wevads/vault/wevia-tool-registry.GOLD-" . date("Ymd-His") . "-wave229";
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, json_encode($data, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));
|
||||
|
||||
echo json_encode([
|
||||
"orig_count" => $orig_count,
|
||||
"added" => $added,
|
||||
"new_count" => count($data["tools"]),
|
||||
"wrote" => $wrote,
|
||||
"backup" => basename($backup),
|
||||
"new_ids" => array_column($new_tools, "id"),
|
||||
]);
|
||||
122
api/ambre-wire-v10.php
Normal file
122
api/ambre-wire-v10.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/var/www/html/wevia.html";
|
||||
$c = @file_get_contents($path);
|
||||
$orig = strlen($c);
|
||||
|
||||
if (strpos($c, "AMBRE-V10-MERMAID") !== false) {
|
||||
echo json_encode(["already_wired"=>true, "size"=>$orig]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Insert BEFORE V9-PDF-PREMIUM (so mermaid match comes first if both patterns match)
|
||||
$anchor = " // === AMBRE-V9-PDF-PREMIUM 2026-04-22";
|
||||
$idx = strpos($c, $anchor);
|
||||
if ($idx === false) {
|
||||
echo json_encode(["error"=>"V9 anchor not found"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Also make sure the _ambre_gen_pat doesn't catch "mermaid" which we want to route here first
|
||||
// Currently _ambre_gen_pat matches mermaid → route to V2-GEN-ROUTER
|
||||
// Solution: put V10 BEFORE V2 check (before all routers), by placing it in send() very early
|
||||
// Actually just before V9 is OK since that's before V2 in flow
|
||||
|
||||
$v10 = <<<'JS'
|
||||
// === AMBRE-V10-MERMAID 2026-04-22 · Mermaid RAG + inline SVG render + artifact panel ===
|
||||
var _mermaid_intent_pat = /(?:mermaid|sch[eé]ma|diagramme|flowchart|sequence\s+diagram|gantt\s+chart)/i;
|
||||
if (_mermaid_intent_pat.test(text)) {
|
||||
if (typeof showThinking === 'function') showThinking();
|
||||
busy = true;
|
||||
try{var sb=document.getElementById("sendBtn");if(sb)sb.disabled=true;}catch(e){}
|
||||
|
||||
var _fetch = (typeof window.__ambreFetch === 'function') ? window.__ambreFetch : fetch;
|
||||
_fetch('/api/ambre-tool-mermaid.php', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type':'application/json'},
|
||||
body: JSON.stringify({topic: text})
|
||||
})
|
||||
.then(function(r){ return r.text().then(function(t){ try{return JSON.parse(t);}catch(e){return null;} }); })
|
||||
.then(function(data){
|
||||
if (typeof hideThinking === 'function') hideThinking();
|
||||
busy = false;
|
||||
try{var sb=document.getElementById("sendBtn");if(sb)sb.disabled=false;}catch(e){}
|
||||
try{var mi=document.getElementById("msgInput");if(mi){mi.value="";mi.disabled=false;}}catch(e){}
|
||||
|
||||
if (!data || !data.ok) {
|
||||
addMsg('assistant', '❌ Erreur génération Mermaid. ' + ((data && data.error) || 'Réessayez.'), '0');
|
||||
return;
|
||||
}
|
||||
|
||||
var mcode = data.mermaid_code;
|
||||
var topic = data.topic || text;
|
||||
var src = data.source || 'unknown';
|
||||
var kind = data.kind || 'flowchart';
|
||||
|
||||
// Badges
|
||||
var srcBadge = (src === 'kb_reused') ?
|
||||
'<span class="nx-badge" style="background:rgba(16,185,129,.15);color:#10b981">♻️ KB Reused (' + (data.use_count || 0) + ' uses)</span>' :
|
||||
'<span class="nx-badge" style="background:rgba(99,102,241,.15);color:#6366f1">🧠 LLM Generated</span>';
|
||||
|
||||
var badges = '<div style="display:flex;gap:6px;flex-wrap:wrap;margin:8px 0">' +
|
||||
srcBadge +
|
||||
'<span class="nx-badge" style="background:rgba(139,92,246,.15);color:#8b5cf6">' + kind + '</span>' +
|
||||
'<span class="nx-badge" style="background:rgba(245,158,11,.15);color:#f59e0b">' + (data.elapsed_ms || 0) + 'ms</span>' +
|
||||
'</div>';
|
||||
|
||||
// Inline render div
|
||||
var uniqId = 'mmd-' + Date.now();
|
||||
var inlineBlock = '<div style="margin:12px 0;padding:14px;background:#fafafa;border:1px solid #e5e7eb;border-radius:12px">' +
|
||||
'<div style="font-weight:600;font-size:13px;color:#6b7280;margin-bottom:10px">📊 ' + topic + '</div>' +
|
||||
'<div class="mermaid" id="' + uniqId + '" style="text-align:center">' + mcode + '</div>' +
|
||||
'<details style="margin-top:10px"><summary style="cursor:pointer;font-size:11px;color:#94a3b8">📝 Voir le code</summary>' +
|
||||
'<pre style="background:#1a1a2e;color:#e6edf3;padding:10px;border-radius:8px;font-size:11px;margin-top:8px;overflow-x:auto">' +
|
||||
mcode.replace(/</g,'<').replace(/>/g,'>') + '</pre></details>' +
|
||||
'</div>';
|
||||
|
||||
addMsg('assistant', badges + inlineBlock, (data.elapsed_ms/1000).toFixed(2));
|
||||
|
||||
// Trigger mermaid render after DOM update
|
||||
setTimeout(function(){
|
||||
try {
|
||||
if (window.mermaid && typeof window.mermaid.run === 'function') {
|
||||
window.mermaid.run({ nodes: [document.getElementById(uniqId)] });
|
||||
} else if (window.mermaid && typeof window.mermaid.init === 'function') {
|
||||
window.mermaid.init(undefined, document.getElementById(uniqId));
|
||||
}
|
||||
} catch(e) { console.warn('mermaid render fail', e); }
|
||||
}, 300);
|
||||
|
||||
// Also open artifact panel with preview
|
||||
if (typeof openPreview === 'function') {
|
||||
try {
|
||||
var svgWrap = '<div style="padding:20px;background:#fff;height:100%;overflow:auto"><h3 style="margin-bottom:16px">' + topic + '</h3><div class="mermaid">' + mcode + '</div></div>';
|
||||
openPreview({type:'html', content: svgWrap});
|
||||
} catch(e) {}
|
||||
}
|
||||
})
|
||||
.catch(function(err){
|
||||
if (typeof hideThinking === 'function') hideThinking();
|
||||
busy = false;
|
||||
try{var sb=document.getElementById("sendBtn");if(sb)sb.disabled=false;}catch(e){}
|
||||
addMsg('assistant', '❌ Service Mermaid temporairement indisponible.', '0');
|
||||
});
|
||||
return;
|
||||
}
|
||||
// === END AMBRE-V10-MERMAID ===
|
||||
|
||||
JS;
|
||||
|
||||
$new_c = substr($c, 0, $idx) . $v10 . substr($c, $idx);
|
||||
$delta = strlen($new_c) - $orig;
|
||||
|
||||
$backup = "/opt/wevads/vault/wevia.html.GOLD-" . date("Ymd-His") . "-v10-mermaid";
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, $new_c);
|
||||
|
||||
echo json_encode([
|
||||
"delta" => $delta,
|
||||
"wrote" => $wrote,
|
||||
"backup" => basename($backup),
|
||||
"new_size" => strlen($new_c),
|
||||
]);
|
||||
100
api/ambre-wire-v10b.php
Normal file
100
api/ambre-wire-v10b.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/var/www/html/wevia.html";
|
||||
$c = @file_get_contents($path);
|
||||
$orig = strlen($c);
|
||||
|
||||
if (strpos($c, "AMBRE-V10-MERMAID") !== false) {
|
||||
echo json_encode(["already_wired"=>true]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Use pattern matching for V9 anchor
|
||||
$pos = strpos($c, "// === AMBRE-V9-PDF-PREMIUM");
|
||||
if ($pos === false) {
|
||||
echo json_encode(["error"=>"V9 not found at all"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Back up to line start
|
||||
$line_start = strrpos(substr($c, 0, $pos), "\n") + 1;
|
||||
|
||||
$v10 = ' // === AMBRE-V10-MERMAID 2026-04-22 · Mermaid RAG + inline SVG + artifact panel ===
|
||||
var _mermaid_intent_pat = /(?:mermaid|sch[eé]ma|diagramme|flowchart|sequence\\s+diagram|gantt\\s+chart)/i;
|
||||
if (_mermaid_intent_pat.test(text)) {
|
||||
if (typeof showThinking === "function") showThinking();
|
||||
busy = true;
|
||||
try{var sb=document.getElementById("sendBtn");if(sb)sb.disabled=true;}catch(e){}
|
||||
|
||||
var _fetch = (typeof window.__ambreFetch === "function") ? window.__ambreFetch : fetch;
|
||||
_fetch("/api/ambre-tool-mermaid.php", {
|
||||
method: "POST",
|
||||
headers: {"Content-Type":"application/json"},
|
||||
body: JSON.stringify({topic: text})
|
||||
})
|
||||
.then(function(r){ return r.text().then(function(t){ try{return JSON.parse(t);}catch(e){return null;} }); })
|
||||
.then(function(data){
|
||||
if (typeof hideThinking === "function") hideThinking();
|
||||
busy = false;
|
||||
try{var sb=document.getElementById("sendBtn");if(sb)sb.disabled=false;}catch(e){}
|
||||
try{var mi=document.getElementById("msgInput");if(mi){mi.value="";mi.disabled=false;}}catch(e){}
|
||||
|
||||
if (!data || !data.ok) {
|
||||
addMsg("assistant", "❌ Erreur Mermaid. " + ((data && data.error) || "Réessayez."), "0");
|
||||
return;
|
||||
}
|
||||
|
||||
var mcode = data.mermaid_code;
|
||||
var topic = data.topic || text;
|
||||
var src = data.source || "unknown";
|
||||
var kind = data.kind || "flowchart";
|
||||
|
||||
var srcBadge = (src === "kb_reused") ?
|
||||
"<span class=\\"nx-badge\\" style=\\"background:rgba(16,185,129,.15);color:#10b981\\">♻️ KB Reused (" + (data.use_count || 0) + " uses)</span>" :
|
||||
"<span class=\\"nx-badge\\" style=\\"background:rgba(99,102,241,.15);color:#6366f1\\">🧠 LLM Generated</span>";
|
||||
var kindBadge = "<span class=\\"nx-badge\\" style=\\"background:rgba(139,92,246,.15);color:#8b5cf6\\">" + kind + "</span>";
|
||||
var elapsedBadge = "<span class=\\"nx-badge\\" style=\\"background:rgba(245,158,11,.15);color:#f59e0b\\">" + (data.elapsed_ms || 0) + "ms</span>";
|
||||
var badges = "<div style=\\"display:flex;gap:6px;flex-wrap:wrap;margin:8px 0\\">" + srcBadge + kindBadge + elapsedBadge + "</div>";
|
||||
|
||||
var uniqId = "mmd-" + Date.now();
|
||||
var inlineBlock = "<div style=\\"margin:12px 0;padding:14px;background:#fafafa;border:1px solid #e5e7eb;border-radius:12px\\">" +
|
||||
"<div style=\\"font-weight:600;font-size:13px;color:#6b7280;margin-bottom:10px\\">📊 " + topic + "</div>" +
|
||||
"<div class=\\"mermaid\\" id=\\"" + uniqId + "\\" style=\\"text-align:center\\">" + mcode + "</div>" +
|
||||
"<details style=\\"margin-top:10px\\"><summary style=\\"cursor:pointer;font-size:11px;color:#94a3b8\\">📝 Voir le code</summary>" +
|
||||
"<pre style=\\"background:#1a1a2e;color:#e6edf3;padding:10px;border-radius:8px;font-size:11px;margin-top:8px;overflow-x:auto\\">" +
|
||||
mcode.replace(/</g,"<").replace(/>/g,">") + "</pre></details>" +
|
||||
"</div>";
|
||||
|
||||
addMsg("assistant", badges + inlineBlock, (data.elapsed_ms/1000).toFixed(2));
|
||||
|
||||
setTimeout(function(){
|
||||
try {
|
||||
if (window.mermaid && typeof window.mermaid.run === "function") {
|
||||
window.mermaid.run({ nodes: [document.getElementById(uniqId)] });
|
||||
}
|
||||
} catch(e) { console.warn("mermaid render fail", e); }
|
||||
}, 300);
|
||||
})
|
||||
.catch(function(err){
|
||||
if (typeof hideThinking === "function") hideThinking();
|
||||
busy = false;
|
||||
try{var sb=document.getElementById("sendBtn");if(sb)sb.disabled=false;}catch(e){}
|
||||
addMsg("assistant", "❌ Service Mermaid indisponible.", "0");
|
||||
});
|
||||
return;
|
||||
}
|
||||
// === END AMBRE-V10-MERMAID ===
|
||||
|
||||
';
|
||||
|
||||
$new_c = substr($c, 0, $line_start) . $v10 . substr($c, $line_start);
|
||||
|
||||
$backup = "/opt/wevads/vault/wevia.html.GOLD-" . date("Ymd-His") . "-v10-mermaid";
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, $new_c);
|
||||
|
||||
echo json_encode([
|
||||
"delta" => strlen($new_c) - $orig,
|
||||
"wrote" => $wrote,
|
||||
"backup" => basename($backup),
|
||||
]);
|
||||
101
api/ambre-wire-v9.php
Normal file
101
api/ambre-wire-v9.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/var/www/html/wevia.html";
|
||||
$c = @file_get_contents($path);
|
||||
$orig_size = strlen($c);
|
||||
|
||||
// Check if V9 already present
|
||||
if (strpos($c, "AMBRE-V9-PDF-PREMIUM") !== false) {
|
||||
echo json_encode(["already_wired"=>true, "size"=>$orig_size]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Find V7 anchor (route BEFORE V7 so premium pattern matches first)
|
||||
$anchor = " // === AMBRE-V7-PREMIUM-TOOLS 2026-04-21";
|
||||
$idx = strpos($c, $anchor);
|
||||
if ($idx === false) {
|
||||
echo json_encode(["error"=>"V7 anchor not found"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$v9_block = <<<'JS'
|
||||
// === AMBRE-V9-PDF-PREMIUM 2026-04-22 · premium PDF with Chart.js artifact right-panel ===
|
||||
var _pdf_premium_pat = /(?:pdf|rapport)\s+(?:premium|qualit[eé]|pro|professionnel|avec\s+graphique|hd|chart)|(?:cr[eé]e[zr]?|g[eé]n[eè]re[zr]?|fais|fait|produi[st])\s+(?:un\s+)?(?:rapport|pdf)\s+(?:premium|pro|complet|avec\s+graphique|hd|qualit[eé])/i;
|
||||
if (_pdf_premium_pat.test(text)) {
|
||||
if (typeof showThinking === 'function') showThinking();
|
||||
busy = true;
|
||||
try{var sb=document.getElementById("sendBtn");if(sb)sb.disabled=true;}catch(e){}
|
||||
|
||||
var _fetchFn = (typeof window.__ambreFetch === 'function') ? window.__ambreFetch : fetch;
|
||||
_fetchFn('/api/ambre-tool-pdf-premium.php', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type':'application/json'},
|
||||
body: JSON.stringify({topic: text})
|
||||
})
|
||||
.then(function(r){ return r.text().then(function(t){ try{return JSON.parse(t);}catch(e){return null;} }); })
|
||||
.then(function(data){
|
||||
if (typeof hideThinking === 'function') hideThinking();
|
||||
busy = false;
|
||||
try{var sb=document.getElementById("sendBtn");if(sb)sb.disabled=false;}catch(e){}
|
||||
try{var mi=document.getElementById("msgInput");if(mi){mi.value="";mi.disabled=false;}}catch(e){}
|
||||
|
||||
if (!data || !data.ok) {
|
||||
addMsg('assistant', '❌ Erreur génération PDF premium. ' + ((data && data.error) || 'Réessayez.'), '0');
|
||||
return;
|
||||
}
|
||||
|
||||
var url = data.url;
|
||||
var title = data.title || 'Rapport';
|
||||
var subtitle = data.subtitle || '';
|
||||
var badges = '<div style="display:flex;gap:6px;flex-wrap:wrap;margin:8px 0">' +
|
||||
'<span class="nx-badge" style="background:rgba(99,102,241,.15);color:#6366f1">📊 PDF Premium</span>' +
|
||||
'<span class="nx-badge" style="background:rgba(16,185,129,.15);color:#10b981">📈 Chart.js</span>' +
|
||||
'<span class="nx-badge" style="background:rgba(245,158,11,.15);color:#f59e0b">' + data.pages + ' pages</span>' +
|
||||
'<span class="nx-badge" style="background:rgba(139,92,246,.15);color:#8b5cf6">' + data.size_kb + 'KB</span>' +
|
||||
'</div>';
|
||||
|
||||
var card = '<div style="margin:10px 0;padding:18px;background:linear-gradient(135deg,rgba(99,102,241,.08),rgba(139,92,246,.04));border:1px solid rgba(99,102,241,.2);border-radius:14px">' +
|
||||
'<div style="display:flex;align-items:center;gap:12px">' +
|
||||
'<div style="width:44px;height:44px;border-radius:12px;background:linear-gradient(135deg,#6366f1,#8b5cf6);display:flex;align-items:center;justify-content:center;font-size:20px;color:#fff">📄</div>' +
|
||||
'<div style="flex:1"><div style="font-weight:700;font-size:15px;color:#1a1a2e">' + title + '</div>' +
|
||||
'<div style="font-size:12px;color:#6b7280;margin-top:2px">' + subtitle + '</div></div>' +
|
||||
'<a href="' + url + '" target="_blank" style="padding:9px 18px;background:#6366f1;color:#fff;border-radius:10px;text-decoration:none;font-weight:600;font-size:13px">↓ Télécharger</a>' +
|
||||
'</div></div>';
|
||||
|
||||
addMsg('assistant', badges + card, (data.total_ms/1000).toFixed(1));
|
||||
|
||||
// Open in right preview panel if function exists
|
||||
if (typeof openPreview === 'function') {
|
||||
try { openPreview(url, 'pdf'); } catch(e) {}
|
||||
} else if (typeof switchPreviewTab === 'function') {
|
||||
// Load PDF into iframe preview
|
||||
try {
|
||||
var pb = document.getElementById('previewBody');
|
||||
if (pb) {
|
||||
pb.innerHTML = '<iframe src="' + url + '" style="width:100%;height:100%;border:none"></iframe>';
|
||||
var pp = document.querySelector('.preview-panel'); if (pp) pp.style.width = '50%';
|
||||
}
|
||||
} catch(e) {}
|
||||
}
|
||||
})
|
||||
.catch(function(err){
|
||||
if (typeof hideThinking === 'function') hideThinking();
|
||||
busy = false;
|
||||
try{var sb=document.getElementById("sendBtn");if(sb)sb.disabled=false;}catch(e){}
|
||||
addMsg('assistant', '❌ Service PDF Premium temporairement indisponible.', '0');
|
||||
});
|
||||
return;
|
||||
}
|
||||
// === END AMBRE-V9-PDF-PREMIUM ===
|
||||
|
||||
JS;
|
||||
|
||||
$new_c = substr($c, 0, $idx) . $v9_block . substr($c, $idx);
|
||||
$delta = strlen($new_c) - $orig_size;
|
||||
|
||||
// Backup + write
|
||||
$backup = "/opt/wevads/vault/wevia.html.GOLD-" . date("Ymd-His") . "-v9-pdf-premium";
|
||||
@copy($path, $backup);
|
||||
$wrote = @file_put_contents($path, $new_c);
|
||||
|
||||
echo json_encode(["orig"=>$orig_size, "new"=>strlen($new_c), "delta"=>$delta, "wrote"=>$wrote, "backup"=>basename($backup)]);
|
||||
12
api/ambre-write-doctrine.php
Normal file
12
api/ambre-write-doctrine.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
$path = "/opt/obsidian-vault/doctrines/109-wave229-6sigma-sse-pdf-premium.md";
|
||||
$dir = dirname($path);
|
||||
if (!is_dir($dir)) @mkdir($dir, 0777, true);
|
||||
$content = base64_decode("IyAxMDkgwrcgV2F2ZS0yMjkgwrcgNs+DIFN0YWJpbGl0eSDCtyBTU0UgZml4IMK3IFBERiBQcmVtaXVtIMK3IE1lcm1haWQgbGVhcm5pbmcKCioqV2F2ZSoqIDogMjI5IMK3IDIwMjYtMDQtMjIKKipTdGF0dXMqKiA6IOKchSBMSVZFIMK3IFRhZ2dlZCBgd2F2ZS0yMjktNnNpZ21hLXN0YWJpbGl0eS1zc2UtZml4ZWRgCioqT2JqZWN0aWYqKiA6IHLDqXNvdWRyZSBsYSBjYXVzZSByYWNpbmUgYHNlbmRNc2cgdW5kZWZpbmVkYCArIGTDqWxpdnJlciBQREYgUHJlbWl1bSBjaXJjdWl0ICsgTWVybWFpZCBsZWFybmluZyBLQgoKIyMg8J+OryBDYXVzZXMgcmFjaW5lcyBpZGVudGlmacOpZXMKCiMjIyBCdWcgIzEgOiByZWdleCBgL1xuL2dgIGNhc3PDqSBk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CuKchSBaZXJvIHLDqWdyZXNzaW9uIMK3IFplcm8gw6ljcmFzZW1lbnQgwrcgWmVybyBmYWtlIMK3IFplcm8gaGFyZGNvZGUgwrcgU2VtYXBob3JlIHRocm90dGxlIMK3IFRyYWluIGNvbW1pdHMK");
|
||||
$w = @file_put_contents($path, $content);
|
||||
echo json_encode([
|
||||
"path" => $path,
|
||||
"wrote" => $w,
|
||||
"size" => strlen($content),
|
||||
]);
|
||||
23
api/ambre-wtp-wire-cx.php
Normal file
23
api/ambre-wtp-wire-cx.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
header("Content-Type: text/plain");
|
||||
$path = "/var/www/html/weval-technology-platform.html";
|
||||
$c = @file_get_contents($path);
|
||||
if (strpos($c, "dashboards-hub-unified") !== false) { echo "already"; exit; }
|
||||
|
||||
$anchor = 'href="/dashboards-index.html"';
|
||||
$pos = strpos($c, $anchor);
|
||||
if ($pos === false) { echo "no anchor"; exit; }
|
||||
|
||||
$a_end = strpos($c, "</a>", $pos) + 4;
|
||||
$link = '<a href="/dashboards-hub-unified.html" class="wtp-link" style="display:inline-flex;align-items:center;gap:6px;padding:6px 12px;background:linear-gradient(135deg,#4338ca,#6366f1);color:#fff;border-radius:6px;text-decoration:none;font-size:12px;font-weight:500;margin:0 4px"><span>📊 Hub Unifié</span></a>';
|
||||
|
||||
$new_c = substr($c, 0, $a_end) . $link . substr($c, $a_end);
|
||||
|
||||
// Write via sudo cat
|
||||
$tmpfile = tempnam("/tmp", "wtp_");
|
||||
file_put_contents($tmpfile, $new_c);
|
||||
// Copy back via sudo
|
||||
$result = shell_exec("sudo cp $tmpfile $path 2>&1");
|
||||
echo "Result: " . $result . "\n";
|
||||
echo "New size: " . strlen($new_c) . "B · delta +" . (strlen($new_c)-strlen($c)) . "B\n";
|
||||
unlink($tmpfile);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user