38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
<?php
|
|
// Wrapper exec Playwright drafts proof - autonomous WEVIA intent
|
|
header('Content-Type: application/json');
|
|
header('Cache-Control: no-store, no-cache, must-revalidate');
|
|
|
|
$script = '/opt/weval-ops/opus-intents/opus-playwright-drafts-proof.sh';
|
|
if (!is_file($script) || !is_executable($script)) {
|
|
http_response_code(500);
|
|
echo json_encode(['error' => 'script_not_found', 'path' => $script]);
|
|
exit;
|
|
}
|
|
|
|
// Set env for playwright modules
|
|
putenv('NODE_PATH=/usr/lib/node_modules');
|
|
|
|
// Long timeout for Playwright video (up to 2 min)
|
|
$output = shell_exec('cd /usr/lib/node_modules && timeout 120 bash ' . escapeshellarg($script) . ' 2>&1 | tail -c 500');
|
|
if (trim((string)$output) === '') {
|
|
http_response_code(500);
|
|
echo json_encode(['error' => 'empty_output']);
|
|
exit;
|
|
}
|
|
|
|
// Try extract last JSON line
|
|
$lines = array_filter(array_map('trim', explode("\n", $output)));
|
|
$last = end($lines);
|
|
$parsed = @json_decode($last, true);
|
|
if ($parsed && isset($parsed['proof_url'])) {
|
|
echo json_encode([
|
|
'ok' => true,
|
|
'proof_url' => $parsed['proof_url'],
|
|
'ts' => $parsed['ts'],
|
|
'raw' => $output
|
|
]);
|
|
} else {
|
|
echo $output;
|
|
}
|