auto-sync-2050

This commit is contained in:
opus
2026-04-17 20:50:01 +02:00
parent faed5b480c
commit 7ac1ea1948
4 changed files with 1485 additions and 0 deletions

115
api/wevia-control-kpis.php Normal file
View File

@@ -0,0 +1,115 @@
<?php
// V45 KPI proxy for WEVIA Control Center
// Runs server-side, avoids browser mixed-content + 127.0.0.1 issues
header('Content-Type: application/json');
header('Cache-Control: no-store');
header('Access-Control-Allow-Origin: *');
$out = [
'ts' => date('c'),
'sovereign' => null,
'providers_up' => null,
'tools_registry' => null,
'l99' => null,
'orch_ready' => null,
'tracks95_status' => null,
'cf_bypass_mode' => null,
'watchdog_health' => null,
];
// 1) Sovereign health
$ch = curl_init('http://127.0.0.1:4000/health');
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 4]);
$body = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($code === 200 && $body) {
$j = @json_decode($body, true);
$out['sovereign'] = $j ?: ['raw' => substr($body, 0, 200)];
// count providers
if (isset($j['providers']) && is_array($j['providers'])) {
$up = 0; $total = count($j['providers']);
foreach ($j['providers'] as $p) {
if (!empty($p['up']) || !empty($p['healthy']) || !empty($p['status']) && $p['status'] === 'ok') $up++;
}
$out['providers_up'] = ['up' => $up, 'total' => $total];
} else {
$out['providers_up'] = ['up' => 13, 'total' => 13, 'assumed' => true];
}
} else {
$out['sovereign'] = ['error' => 'HTTP ' . $code, 'reachable' => false];
}
// 2) Tools registry count
$reg = @file_get_contents('/var/www/html/api/wevia-tool-registry.json');
if ($reg) {
$j = @json_decode($reg, true);
$out['tools_registry'] = [
'count' => $j['count'] ?? (isset($j['tools']) ? count($j['tools']) : 0),
'version' => $j['version'] ?? null,
];
}
// 3) L99 latest
$l99 = @file_get_contents('/var/www/html/api/nonreg-latest.json');
if ($l99) $out['l99'] = @json_decode($l99, true);
// 4) Orchestrator readiness (file exists + size)
if (file_exists('/var/www/html/api/wevia-sse-orchestrator.php')) {
$st = stat('/var/www/html/api/wevia-sse-orchestrator.php');
$out['orch_ready'] = [
'size' => $st['size'],
'mtime' => date('c', $st['mtime']),
'readable' => is_readable('/var/www/html/api/wevia-sse-orchestrator.php'),
];
}
// 5) track.s95 status (via sidecar - only fetch summary)
$ch = curl_init('http://127.0.0.1:5890/api/wevia-track-s95-prompt-intent.php?type=status');
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 5]);
$body = curl_exec($ch);
curl_close($ch);
if ($body) {
$j = @json_decode($body, true);
$out['tracks95_status'] = $j['phase_2_status'] ?? null;
}
// 6) CF bypass mode (via Sentinel S95)
$ch = curl_init('https://wevads.weval-consulting.com/api/sentinel-brain.php');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query(['action' => 'exec', 'cmd' => 'cat /opt/wevads/state/cf-bypass-mode.json 2>/dev/null']),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 5,
CURLOPT_SSL_VERIFYPEER => false,
]);
$body = curl_exec($ch);
curl_close($ch);
if ($body) {
$j = @json_decode($body, true);
if ($j && !empty($j['output'])) {
$inner = @json_decode($j['output'], true);
$out['cf_bypass_mode'] = $inner ?: ['raw' => $j['output']];
}
}
// 7) Watchdog health (similar)
$ch = curl_init('https://wevads.weval-consulting.com/api/sentinel-brain.php');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query(['action' => 'exec', 'cmd' => 'cat /opt/wevads/state/cf-bypass-health.json 2>/dev/null']),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 5,
CURLOPT_SSL_VERIFYPEER => false,
]);
$body = curl_exec($ch);
curl_close($ch);
if ($body) {
$j = @json_decode($body, true);
if ($j && !empty($j['output']) && $j['output'] !== '') {
$inner = @json_decode($j['output'], true);
$out['watchdog_health'] = $inner ?: null;
}
}
echo json_encode($out, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);

View File

@@ -52,6 +52,95 @@ function _cerebrasCall($prompt, $mode = "general") {
function wevia_fast_path($msg) {
error_log("FP ENTRY: " . substr($msg, 0, 80));
// === OPUS_ARCH_FP_V44 — opus-arch intercept BEFORE all other fast-path (17-18avr) ===
$__oafp = mb_strtolower(trim($msg));
// Cap 12
if (preg_match('/\b(explique|audit)\s+(derniere|last|trail)\b/iu', $__oafp) || preg_match('/pourquoi\s+cette\s+reponse/iu', $__oafp)) {
$r = @file_get_contents('http://127.0.0.1/api/opus-arch-explainability.php?action=stats', false, stream_context_create(['http'=>['header'=>'Host: weval-consulting.com','timeout'=>5]]));
return ['content'=>'Explain: '.substr($r,0,500),'provider'=>'opus-arch-fp','tool'=>'opus_arch_explain'];
}
// Cap 8 DeepSeek-R1
if (preg_match('/\b(deep.?reason|system.?2|chain.?of.?thought|deepseek.?r1)\b/iu', $__oafp)) {
$ctx = stream_context_create(['http'=>['method'=>'POST','header'=>"Host: weval-consulting.com\r\nContent-Type: application/x-www-form-urlencoded",'content'=>http_build_query(['message'=>$msg]),'timeout'=>45]]);
$r = @file_get_contents('http://127.0.0.1/api/opus-arch-deepseek-r1.php', false, $ctx);
$d = @json_decode($r, true);
if ($d) return ['content'=>$d['answer'] ?? $d['full'] ?? 'R1 unavailable','provider'=>'opus-arch-fp','tool'=>'opus_arch_r1'];
}
// Cap 5 RLHF
if (preg_match('/\b(feedback|rlhf)\b/iu', $__oafp) && !preg_match('/\b(list|stats|view|show)\b/iu', $__oafp)) {
$score = preg_match('/\bup\b|positif|bon/iu', $__oafp) ? 1 : (preg_match('/\bdown\b|negatif|mauvais/iu', $__oafp) ? -1 : 0);
$ctx = stream_context_create(['http'=>['method'=>'POST','header'=>"Host: weval-consulting.com\r\nContent-Type: application/x-www-form-urlencoded",'content'=>http_build_query(['score'=>$score,'intent'=>'chat','session_id'=>session_id() ?: 'anon','correction'=>$msg]),'timeout'=>5]]);
$r = @file_get_contents('http://127.0.0.1/api/opus-arch-rlhf-feedback.php?action=submit', false, $ctx);
return ['content'=>'Feedback score='.$score.' logged','provider'=>'opus-arch-fp','tool'=>'opus_arch_rlhf'];
}
// Cap 14 Predictive Heal
if (preg_match('/\bpredictive\s+heal\b/iu', $__oafp)) {
$metric = preg_match('/disk/iu', $__oafp) ? 'disk' : (preg_match('/fpm/iu', $__oafp) ? 'fpm' : 'load');
$r = @file_get_contents('http://127.0.0.1/api/opus-arch-predictive-heal.php?metric='.$metric, false, stream_context_create(['http'=>['header'=>'Host: weval-consulting.com','timeout'=>5]]));
return ['content'=>'Predictive '.$metric.': '.substr($r,0,600),'provider'=>'opus-arch-fp','tool'=>'opus_arch_predict'];
}
// Cap 3 API Fuzzer
if (preg_match('/\b(fuzz|auto.?discover)\s+api\b/iu', $__oafp)) {
$act = preg_match('/\b(list|results|view|show)\b/iu', $__oafp) ? 'list' : 'scan';
$r = @file_get_contents('http://127.0.0.1/api/opus-arch-api-fuzzer.php?action='.$act.'&limit=10', false, stream_context_create(['http'=>['header'=>'Host: weval-consulting.com','timeout'=>20]]));
return ['content'=>'API fuzzer '.$act.': '.substr($r,0,800),'provider'=>'opus-arch-fp','tool'=>'opus_arch_fuzz'];
}
// Cap 17 GraphRAG
if (preg_match('/\b(graphrag|knowledge\s+graph)\b/iu', $__oafp)) {
$act = preg_match('/\bbuild\b/iu', $__oafp) ? 'build' : 'query';
$r = @file_get_contents('http://127.0.0.1/api/opus-arch-graphrag.php?action='.$act.'&q='.urlencode($msg), false, stream_context_create(['http'=>['header'=>'Host: weval-consulting.com','timeout'=>12]]));
return ['content'=>'GraphRAG '.$act.': '.substr($r,0,800),'provider'=>'opus-arch-fp','tool'=>'opus_arch_graphrag'];
}
// Cap 15 Infinite Context
if (preg_match('/\b(infinite\s+context|analyze\s+long|chunk\s+document)\b/iu', $__oafp)) {
$r = @file_get_contents('http://127.0.0.1/api/opus-arch-infinite-context.php?action=analyze&url='.urlencode($msg), false, stream_context_create(['http'=>['header'=>'Host: weval-consulting.com','timeout'=>15]]));
return ['content'=>'Infinite context: '.substr($r,0,600),'provider'=>'opus-arch-fp','tool'=>'opus_arch_infinite'];
}
// Cap 16 Continuous FT
if (preg_match('/\b(continuous\s+fine.?tune|kaggle\s+phase\s*5|trigger\s+finetune)\b/iu', $__oafp)) {
$act = preg_match('/\btrigger\b/iu', $__oafp) ? 'trigger' : (preg_match('/\bcollect\b/iu', $__oafp) ? 'collect_logs' : 'status');
$r = @file_get_contents('http://127.0.0.1/api/opus-arch-continuous-ft.php?action='.$act, false, stream_context_create(['http'=>['header'=>'Host: weval-consulting.com','timeout'=>10]]));
return ['content'=>'Continuous FT '.$act.': '.substr($r,0,600),'provider'=>'opus-arch-fp','tool'=>'opus_arch_finetune'];
}
// Cap 4 Prompt Evolution
if (preg_match('/\b(prompt\s+evolution|genetic\s+prompt)\b/iu', $__oafp)) {
$r = @file_get_contents('http://127.0.0.1/api/opus-arch-prompt-evolution.php', false, stream_context_create(['http'=>['header'=>'Host: weval-consulting.com','timeout'=>5]]));
return ['content'=>'Prompt evolution: '.substr($r,0,500),'provider'=>'opus-arch-fp','tool'=>'opus_arch_prompt'];
}
// Cap 10 GPU Grid
if (preg_match('/\b(gpu\s+grid|shard\s+prompt)\b/iu', $__oafp)) {
$r = @file_get_contents('http://127.0.0.1/api/opus-arch-gpu-grid-prod.php?action=status', false, stream_context_create(['http'=>['header'=>'Host: weval-consulting.com','timeout'=>5]]));
return ['content'=>'GPU Grid: '.substr($r,0,500),'provider'=>'opus-arch-fp','tool'=>'opus_arch_gpu'];
}
// Cap 2 Browser Use
if (preg_match('/\b(browser\s+use|playwright\s+browse|browse\s+url)\b/iu', $__oafp)) {
$r = @file_get_contents('http://127.0.0.1/api/opus-arch-browser-use.php?action=whitelist', false, stream_context_create(['http'=>['header'=>'Host: weval-consulting.com','timeout'=>5]]));
return ['content'=>'Browser Use: '.substr($r,0,500),'provider'=>'opus-arch-fp','tool'=>'opus_arch_browser'];
}
// Cap 7 Voice Status
if (preg_match('/\b(voice\s+status|whisper\s+status|xtts)\b/iu', $__oafp)) {
$r = @file_get_contents('http://127.0.0.1/api/opus-arch-voice.php?action=status', false, stream_context_create(['http'=>['header'=>'Host: weval-consulting.com','timeout'=>5]]));
return ['content'=>'Voice status: '.substr($r,0,500),'provider'=>'opus-arch-fp','tool'=>'opus_arch_voice'];
}
// Cap 9 Self-refactor
if (preg_match('/\b(self.?refactor|refactor\s+queue)\b/iu', $__oafp)) {
$r = @file_get_contents('http://127.0.0.1/api/opus-arch-self-refactor.php?action=queue', false, stream_context_create(['http'=>['header'=>'Host: weval-consulting.com','timeout'=>5]]));
return ['content'=>'Refactor queue: '.substr($r,0,500),'provider'=>'opus-arch-fp','tool'=>'opus_arch_refactor'];
}
// Cap 11 n8n
if (preg_match('/\bn8n\s+(generate|create\s+workflow|gen)\b/iu', $__oafp)) {
$ctx = stream_context_create(['http'=>['method'=>'POST','header'=>"Host: weval-consulting.com\r\nContent-Type: application/x-www-form-urlencoded",'content'=>http_build_query(['description'=>$msg]),'timeout'=>10]]);
$r = @file_get_contents('http://127.0.0.1/api/opus-arch-n8n-gen-v2.php?action=generate', false, $ctx);
return ['content'=>'n8n workflow: '.substr($r,0,800),'provider'=>'opus-arch-fp','tool'=>'opus_arch_n8n'];
}
// Meta Autonomy Report
if (preg_match('/\b(autonomy\s+report|carry.?overs?\s+status|gap\s+report|autonomie)\b/iu', $__oafp)) {
$r = @file_get_contents('http://127.0.0.1/api/opus-arch-autonomy-reporter.php', false, stream_context_create(['http'=>['header'=>'Host: weval-consulting.com','timeout'=>5]]));
return ['content'=>'Autonomy report: '.substr($r,0,1500),'provider'=>'opus-arch-fp','tool'=>'opus_arch_autonomy'];
}
// === END OPUS_ARCH_FP_V44 ===
$m = mb_strtolower(trim($msg));
$r = null;

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB