"auth"]); exit; } // Return pending tasks $tasks = []; foreach (glob("/var/www/html/api/blade-tasks/*.json") as $f) { $t = json_decode(file_get_contents($f), true); if (($t["status"] ?? "") === "pending") $tasks[] = $t; } // Also return any commands from the queue echo json_encode([ "heartbeat" => "ok", "server_time" => date("c"), "pending_tasks" => count($tasks), "tasks" => $tasks, "poll_interval" => 60 ]);