<?php
/**
 * Background job runner — XAMPP: php cron/run-jobs.php
 * Or POST /api/index.php?r=jobs/run (authenticated)
 */
declare(strict_types=1);
chdir(dirname(__DIR__));
require __DIR__ . '/../api/bootstrap.php';
if (php_sapi_name() !== 'cli') {
    require_auth();
    require_any_permission(['jobs.run', 'ota.manage']);
}
$result = function_exists('hv5_run_jobs') ? hv5_run_jobs(30) : ['error' => 'V5 not loaded'];
if (php_sapi_name() === 'cli') {
    echo json_encode($result, JSON_PRETTY_PRINT) . PHP_EOL;
} else {
    json_ok($result, 'Done');
}
