Files
html/api/ambre-v11-debug.php
2026-04-22 04:55:03 +02:00

42 lines
1.5 KiB
PHP

<?php
header("Content-Type: application/json");
$path = "/var/www/html/wevia.html";
$c = @file_get_contents($path);
// Patch V11 fetch : add console.log trigger message + AbortController with 120s
$old = "var _ma_start = performance.now();
fetch(\"/api/ambre-multiagent-parallel.php\", {
method: \"POST\",
headers: {\"Content-Type\":\"application/json\"},
body: JSON.stringify({goal: text, max_agents: 5})
})";
$new = "console.log(\"[V11-MULTIAGENT] triggered for text:\", text.substring(0,80));
var _ma_start = performance.now();
var _ma_ctrl = new AbortController();
var _ma_timeout = setTimeout(function(){ _ma_ctrl.abort(); }, 120000);
fetch(\"/api/ambre-multiagent-parallel.php\", {
method: \"POST\",
headers: {\"Content-Type\":\"application/json\"},
body: JSON.stringify({goal: text, max_agents: 5}),
signal: _ma_ctrl.signal
})
.then(function(r){ clearTimeout(_ma_timeout); console.log(\"[V11] response status\", r.status); return r; })";
if (strpos($c, $old) === false) {
echo json_encode(["error"=>"V11 fetch pattern not found"]);
exit;
}
$c = str_replace($old, $new, $c);
$backup = "/opt/wevads/vault/wevia.html.GOLD-" . date("Ymd-His") . "-wave258-v11-debug";
@copy($path, $backup);
$wrote = @file_put_contents($path, $c);
echo json_encode([
"delta" => strlen($c) - strlen(@file_get_contents($backup)),
"wrote" => $wrote,
"backup" => basename($backup),
]);