Files
html/api/wevia-capabilities-ext.php
2026-04-16 02:28:32 +02:00

97 lines
4.9 KiB
PHP

<?php
/**
* WEVIA Extended Capabilities — Dormant modules activator
* Separate file from main capabilities (anti-fragmentation)
* Usage: POST /api/wevia-capabilities-ext.php?cap=tts|vision|pdf|...
*/
header('Content-Type: application/json');
$cap=$_GET['cap']??$_POST['cap']??'';
$q=$_POST['q']??$_GET['q']??'';
$auth=$_SERVER['HTTP_X_WEVIA_KEY']??$_POST['key']??'';
if($auth!=='W3V1A_CAP_2026'&&$cap!=='list')die(json_encode(['error'=>'unauthorized']));
function cap_api($url,$m='GET',$b=null,$t=8){$ch=curl_init($url);if($b)curl_setopt($ch,CURLOPT_POSTFIELDS,is_string($b)?$b:json_encode($b));if($m!=='GET')curl_setopt($ch,CURLOPT_CUSTOMREQUEST,$m);curl_setopt_array($ch,[CURLOPT_HTTPHEADER=>['Content-Type: application/json'],CURLOPT_RETURNTRANSFER=>true,CURLOPT_TIMEOUT=>$t]);$r=curl_exec($ch);$c=curl_getinfo($ch,CURLINFO_HTTP_CODE);curl_close($ch);return['code'=>$c,'data'=>json_decode($r,true)?:$r];}
switch($cap){
case 'list':
echo json_encode(['capabilities'=>[
'tts'=>'Text-to-speech (wevia-tts 151L)',
'voice'=>'Voice processing (wevia-voice 148L)',
'vision'=>'Image analysis (wevia-vision 135L)',
'pdf'=>'PDF orchestrator (opus-pdf 852L)',
'charts'=>'Adaptive charts (153L)',
'repair'=>'Self-repair API (174L)',
'consensus'=>'Multi-model consensus (167L)',
'planner'=>'Task planner (132L)',
'gpu-rotation'=>'Provider rotation (551L)',
'ssh'=>'Remote SSH ops (103L)',
'webhook'=>'Event dispatch (58L)',
'nexus'=>'Unified API (160+172+226L)',
'french'=>'French accent fix (164L)',
'collecte'=>'Browser-use collecteur',
'openclaw'=>'S151 qwen3:4b fallback',
'wevads'=>'Arsenal bridge API',
'toolfk'=>'External ToolFK APIs'
],'count'=>17]);
break;
case 'openclaw':
$p=$_POST['prompt']??$q;
if(!$p)die(json_encode(['error'=>'no prompt']));
$r=cap_api('http://localhost:11434/api/generate','POST',['model'=>'qwen3:4b','prompt'=>$p,'stream'=>false,'options'=>['temperature'=>0.7,'num_predict'=>300]],20);
echo json_encode(['response'=>$r['data']['response']??'','server'=>'S151']);
break;
case 'wevads':
$a=$_POST['action']??'exec';
$cmd=$_POST['cmd']??'echo OK';
$r=cap_api("http://10.1.0.3:5890/api/sentinel-brain.php?action=$a&cmd=".urlencode($cmd),'GET',null,10);
echo json_encode($r);
break;
case 'collecte':
$url=$_POST['url']??'';
if(!$url)die(json_encode(['error'=>'no url']));
$slug=preg_replace('/[^a-z0-9]/','-',strtolower(parse_url($url,PHP_URL_HOST)));
$file="/var/www/html/wevia-ia/screenshots/collecte-$slug.png";
$cmd="timeout 15 python3 -c \"
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
b=p.chromium.launch(headless=True,args=['--no-sandbox'])
pg=b.new_page()
pg.goto('".escapeshellarg($url)."',timeout=12000)
pg.wait_for_timeout(2000)
pg.screenshot(path='$file',full_page=True)
t=pg.title()
print(t)
b.close()
\" 2>&1";
$title=trim(shell_exec($cmd));
echo json_encode(['file'=>str_replace('/var/www/html','',$file),'title'=>$title,'exists'=>file_exists($file)]);
break;
case 'toolfk':
$tool=$_POST['tool']??'list';
$token='n5LpZaQt517aQA69Rt3OlD2OHc77fcc6NU0YNRkb';
echo json_encode(['tools'=>['js-obfuscate','php-encrypt','ai-image','ocr','qr-code','image-compress','regex-test','dns-check','pdf-convert','barcode','url-shorten','sql-design'],'note'=>'Use via toolfk.com web or API with token','token_masked'=>substr($token,0,6).'...']);
break;
case 'tts':case 'voice':case 'vision':case 'pdf':case 'charts':
case 'repair':case 'consensus':case 'planner':case 'gpu-rotation':
case 'ssh':case 'webhook':case 'nexus':case 'french':
$map=['tts'=>'wevia-tts','voice'=>'wevia-voice','vision'=>'wevia-vision','pdf'=>'opus-pdf-orchestrator','charts'=>'adaptive-charts','repair'=>'wevia-repair-api','consensus'=>'consensus-engine','planner'=>'wevia-planner','gpu-rotation'=>'cognitive-gpu-rotation','ssh'=>'wevia-ssh','webhook'=>'wevia-webhook','nexus'=>'nexus-api','french'=>'french-accent-postprocessor'];
$mod=$map[$cap]??$cap;
$path="/var/www/weval/wevia-ia/$mod.php";
if(!file_exists($path)){echo json_encode(['error'=>'module not found','path'=>$path]);break;}
$lines=count(file($path));
$funcs=[];
foreach(file($path) as $l){if(preg_match('/function\s+(\w+)\s*\(/',$l,$m))$funcs[]=$m[1];}
echo json_encode(['module'=>$mod,'lines'=>$lines,'functions'=>$funcs,'status'=>'loaded','usage'=>"POST with cap=$cap and module-specific params"]);
break;
default:
echo json_encode(['error'=>'unknown cap','use'=>'/api/wevia-capabilities.php for core (10 services) or /api/wevia-capabilities-ext.php?cap=list for extended (17 dormant)']);
}
// === NEW CAPABILITIES 29 MARS 2026 ===
// Browser Use - AI web browsing
// OpenClaw 5700+ skills
// Strix/Nuclei security scanning
// Prometheus node metrics
// Supermemory persistent context