Files
html/api/ops-center-api.php
2026-04-23 04:15:02 +02:00

42 lines
1.3 KiB
PHP

<?php
// ops-center-api.php - Manager unified brain proxy
header("Content-Type: application/json; charset=utf-8");
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
if ($_SERVER["REQUEST_METHOD"] === "OPTIONS") exit;
$action = $_GET["action"] ?? $_POST["action"] ?? "status";
switch ($action) {
case "status":
echo json_encode([
"status" => "ok",
"agents" => 9,
"capabilities_total" => 39,
"capabilities_active" => 22,
"layers_active" => 15,
"timestamp" => date("c")
]);
break;
case "chat":
case "ask":
$message = $_POST["message"] ?? $_GET["message"] ?? "";
// Proxy to manager endpoint
$resp = @file_get_contents("http://127.0.0.1/api/manager.php?message=" . urlencode($message), false, stream_context_create(["http" => ["timeout" => 15]]));
if ($resp) {
echo $resp;
} else {
echo json_encode([
"response" => "Manager disponible. Posez votre question.",
"agent" => "manager",
"timestamp" => date("c")
]);
}
break;
default:
echo json_encode(["status" => "ok", "action" => $action]);
}